@@ -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 | |
@@ -62,26 +62,26 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param array $request The Form Data passed into the batch processing |
64 | 64 | */ |
65 | - public function set_properties( $request ) { |
|
65 | + public function set_properties($request) { |
|
66 | 66 | |
67 | 67 | // Set data from form submission |
68 | - if ( isset( $_POST['form'] ) ) { |
|
69 | - parse_str( $_POST['form'], $this->data ); |
|
68 | + if (isset($_POST['form'])) { |
|
69 | + parse_str($_POST['form'], $this->data); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $this->form = $this->data['forms']; |
73 | 73 | |
74 | 74 | // Setup donor ids cache. |
75 | - if( ! empty( $this->form ) ) { |
|
75 | + if ( ! empty($this->form)) { |
|
76 | 76 | // Cache donor ids to output unique list of donor. |
77 | - $this->query_id = give_clean( $_REQUEST['give_export_option']['query_id'] ); |
|
78 | - if( ! ( $this->donor_ids = get_transient( $this->query_id ) ) ) { |
|
77 | + $this->query_id = give_clean($_REQUEST['give_export_option']['query_id']); |
|
78 | + if ( ! ($this->donor_ids = get_transient($this->query_id))) { |
|
79 | 79 | $this->donor_ids = array(); |
80 | - set_transient( $this->query_id, $this->donor_ids, HOUR_IN_SECONDS ); |
|
80 | + set_transient($this->query_id, $this->donor_ids, HOUR_IN_SECONDS); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | - $this->price_id = ! empty( $request['give_price_option'] ) && 0 !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null; |
|
84 | + $this->price_id = ! empty($request['give_price_option']) && 0 !== $request['give_price_option'] ? absint($request['give_price_option']) : null; |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | |
97 | 97 | $cols = array(); |
98 | 98 | |
99 | - $columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array(); |
|
99 | + $columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array(); |
|
100 | 100 | |
101 | 101 | // We need columns. |
102 | - if ( empty( $columns ) ) { |
|
102 | + if (empty($columns)) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | |
106 | - $cols = $this->get_cols( $columns ); |
|
106 | + $cols = $this->get_cols($columns); |
|
107 | 107 | |
108 | 108 | return $cols; |
109 | 109 | } |
@@ -115,38 +115,38 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return array |
117 | 117 | */ |
118 | - private function get_cols( $columns ) { |
|
118 | + private function get_cols($columns) { |
|
119 | 119 | |
120 | 120 | $cols = array(); |
121 | 121 | |
122 | - foreach ( $columns as $key => $value ) { |
|
122 | + foreach ($columns as $key => $value) { |
|
123 | 123 | |
124 | - switch ( $key ) { |
|
124 | + switch ($key) { |
|
125 | 125 | case 'full_name' : |
126 | - $cols['full_name'] = esc_html__( 'Full Name', 'give' ); |
|
126 | + $cols['full_name'] = esc_html__('Full Name', 'give'); |
|
127 | 127 | break; |
128 | 128 | case 'email' : |
129 | - $cols['email'] = esc_html__( 'Email Address', 'give' ); |
|
129 | + $cols['email'] = esc_html__('Email Address', 'give'); |
|
130 | 130 | break; |
131 | 131 | case 'address' : |
132 | - $cols['address_line1'] = esc_html__( 'Address', 'give' ); |
|
133 | - $cols['address_line2'] = esc_html__( 'Address 2', 'give' ); |
|
134 | - $cols['address_city'] = esc_html__( 'City', 'give' ); |
|
135 | - $cols['address_state'] = esc_html__( 'State', 'give' ); |
|
136 | - $cols['address_zip'] = esc_html__( 'Zip', 'give' ); |
|
137 | - $cols['address_country'] = esc_html__( 'Country', 'give' ); |
|
132 | + $cols['address_line1'] = esc_html__('Address', 'give'); |
|
133 | + $cols['address_line2'] = esc_html__('Address 2', 'give'); |
|
134 | + $cols['address_city'] = esc_html__('City', 'give'); |
|
135 | + $cols['address_state'] = esc_html__('State', 'give'); |
|
136 | + $cols['address_zip'] = esc_html__('Zip', 'give'); |
|
137 | + $cols['address_country'] = esc_html__('Country', 'give'); |
|
138 | 138 | break; |
139 | 139 | case 'userid' : |
140 | - $cols['userid'] = esc_html__( 'User ID', 'give' ); |
|
140 | + $cols['userid'] = esc_html__('User ID', 'give'); |
|
141 | 141 | break; |
142 | 142 | case 'date_first_donated' : |
143 | - $cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' ); |
|
143 | + $cols['date_first_donated'] = esc_html__('First Donation Date', 'give'); |
|
144 | 144 | break; |
145 | 145 | case 'donations' : |
146 | - $cols['donations'] = esc_html__( 'Number of Donations', 'give' ); |
|
146 | + $cols['donations'] = esc_html__('Number of Donations', 'give'); |
|
147 | 147 | break; |
148 | 148 | case 'donation_sum' : |
149 | - $cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' ); |
|
149 | + $cols['donation_sum'] = esc_html__('Sum of Donations', 'give'); |
|
150 | 150 | break; |
151 | 151 | } |
152 | 152 | } |
@@ -169,20 +169,20 @@ discard block |
||
169 | 169 | |
170 | 170 | $i = 0; |
171 | 171 | |
172 | - if ( ! empty( $this->form ) ) { |
|
172 | + if ( ! empty($this->form)) { |
|
173 | 173 | |
174 | 174 | // Export donors of a specific product |
175 | 175 | global $give_logs; |
176 | 176 | |
177 | 177 | $args = array( |
178 | - 'post_parent' => absint( $this->form ), |
|
178 | + 'post_parent' => absint($this->form), |
|
179 | 179 | 'log_type' => 'sale', |
180 | 180 | 'posts_per_page' => 30, |
181 | 181 | 'paged' => $this->step, |
182 | 182 | ); |
183 | 183 | |
184 | 184 | // Check for price option |
185 | - if ( null !== $this->price_id ) { |
|
185 | + if (null !== $this->price_id) { |
|
186 | 186 | $args['meta_query'] = array( |
187 | 187 | array( |
188 | 188 | 'key' => '_give_log_price_id', |
@@ -191,44 +191,44 @@ discard block |
||
191 | 191 | ); |
192 | 192 | } |
193 | 193 | |
194 | - $logs = $give_logs->get_connected_logs( $args ); |
|
194 | + $logs = $give_logs->get_connected_logs($args); |
|
195 | 195 | |
196 | - if ( $logs ) { |
|
197 | - foreach ( $logs as $log ) { |
|
198 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
199 | - $payment = new Give_Payment( $payment_id ); |
|
196 | + if ($logs) { |
|
197 | + foreach ($logs as $log) { |
|
198 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
199 | + $payment = new Give_Payment($payment_id); |
|
200 | 200 | |
201 | 201 | // Continue if donor already included. |
202 | - if( in_array( $payment->customer_id , $this->donor_ids ) ) { |
|
202 | + if (in_array($payment->customer_id, $this->donor_ids)) { |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | |
206 | 206 | $this->donor_ids[] = $payment->customer_id; |
207 | 207 | |
208 | - $donor = Give()->customers->get_customer_by( 'id', $payment->customer_id ); |
|
209 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
210 | - $i ++; |
|
208 | + $donor = Give()->customers->get_customer_by('id', $payment->customer_id); |
|
209 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
210 | + $i++; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | // Cache donor ids only if admin export donor for specific form. |
214 | - set_transient( $this->query_id, array_unique( $this->donor_ids ), HOUR_IN_SECONDS ); |
|
214 | + set_transient($this->query_id, array_unique($this->donor_ids), HOUR_IN_SECONDS); |
|
215 | 215 | } |
216 | 216 | } else { |
217 | 217 | |
218 | 218 | // Export all customers |
219 | - $offset = 30 * ( $this->step - 1 ); |
|
220 | - $donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) ); |
|
219 | + $offset = 30 * ($this->step - 1); |
|
220 | + $donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset)); |
|
221 | 221 | |
222 | - foreach ( $donors as $donor ) { |
|
222 | + foreach ($donors as $donor) { |
|
223 | 223 | |
224 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
225 | - $i ++; |
|
224 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
225 | + $i++; |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | 229 | |
230 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
231 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
230 | + $data = apply_filters('give_export_get_data', $data); |
|
231 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
232 | 232 | |
233 | 233 | return $data; |
234 | 234 | } |
@@ -244,18 +244,18 @@ discard block |
||
244 | 244 | $percentage = 0; |
245 | 245 | |
246 | 246 | // We can't count the number when getting them for a specific form |
247 | - if ( empty( $this->form ) ) { |
|
247 | + if (empty($this->form)) { |
|
248 | 248 | |
249 | 249 | $total = Give()->customers->count(); |
250 | 250 | |
251 | - if ( $total > 0 ) { |
|
251 | + if ($total > 0) { |
|
252 | 252 | |
253 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
253 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
254 | 254 | |
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
258 | - if ( $percentage > 100 ) { |
|
258 | + if ($percentage > 100) { |
|
259 | 259 | $percentage = 100; |
260 | 260 | } |
261 | 261 | |
@@ -271,46 +271,46 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @return mixed |
273 | 273 | */ |
274 | - private function set_donor_data( $i, $data, $donor ) { |
|
274 | + private function set_donor_data($i, $data, $donor) { |
|
275 | 275 | |
276 | 276 | $columns = $this->csv_cols(); |
277 | 277 | |
278 | 278 | // Set address variable |
279 | 279 | $address = ''; |
280 | - if ( isset( $donor->user_id ) && $donor->user_id > 0 ) { |
|
281 | - $address = give_get_donor_address( $donor->user_id ); |
|
280 | + if (isset($donor->user_id) && $donor->user_id > 0) { |
|
281 | + $address = give_get_donor_address($donor->user_id); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | // Set columns |
285 | - if ( ! empty( $columns['full_name'] ) ) { |
|
286 | - $data[ $i ]['full_name'] = $donor->name; |
|
285 | + if ( ! empty($columns['full_name'])) { |
|
286 | + $data[$i]['full_name'] = $donor->name; |
|
287 | 287 | } |
288 | - if ( ! empty( $columns['email'] ) ) { |
|
289 | - $data[ $i ]['email'] = $donor->email; |
|
288 | + if ( ! empty($columns['email'])) { |
|
289 | + $data[$i]['email'] = $donor->email; |
|
290 | 290 | } |
291 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
292 | - |
|
293 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
294 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
295 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
296 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
297 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
298 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
291 | + if ( ! empty($columns['address_line1'])) { |
|
292 | + |
|
293 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
294 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
295 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
296 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
297 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
298 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
299 | 299 | } |
300 | - if ( ! empty( $columns['userid'] ) ) { |
|
301 | - $data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : ''; |
|
300 | + if ( ! empty($columns['userid'])) { |
|
301 | + $data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : ''; |
|
302 | 302 | } |
303 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
304 | - $data[ $i ]['date_first_donated'] = date_i18n( give_date_format(), strtotime( $donor->date_created ) ); |
|
303 | + if ( ! empty($columns['date_first_donated'])) { |
|
304 | + $data[$i]['date_first_donated'] = date_i18n(give_date_format(), strtotime($donor->date_created)); |
|
305 | 305 | } |
306 | - if ( ! empty( $columns['donations'] ) ) { |
|
307 | - $data[ $i ]['donations'] = $donor->purchase_count; |
|
306 | + if ( ! empty($columns['donations'])) { |
|
307 | + $data[$i]['donations'] = $donor->purchase_count; |
|
308 | 308 | } |
309 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
310 | - $data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value ); |
|
309 | + if ( ! empty($columns['donation_sum'])) { |
|
310 | + $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value); |
|
311 | 311 | } |
312 | 312 | |
313 | - return $data[ $i ]; |
|
313 | + return $data[$i]; |
|
314 | 314 | |
315 | 315 | } |
316 | 316 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_process_batch_export_form() { |
24 | 24 | |
25 | - if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) { |
|
26 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
25 | + if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) { |
|
26 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
27 | 27 | } |
28 | 28 | |
29 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php'; |
|
29 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php'; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Fires before batch export. |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param string $class Export class. |
37 | 37 | */ |
38 | - do_action( 'give_batch_export_class_include', $_REQUEST['class'] ); |
|
38 | + do_action('give_batch_export_class_include', $_REQUEST['class']); |
|
39 | 39 | |
40 | 40 | $export = new $_REQUEST['class']; |
41 | 41 | $export->export(); |
42 | 42 | |
43 | 43 | } |
44 | 44 | |
45 | -add_action( 'give_form_batch_export', 'give_process_batch_export_form' ); |
|
45 | +add_action('give_form_batch_export', 'give_process_batch_export_form'); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Exports earnings for a specified time period |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | * @return void |
54 | 54 | */ |
55 | 55 | function give_export_earnings() { |
56 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php'; |
|
56 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-earnings.php'; |
|
57 | 57 | |
58 | 58 | $earnings_export = new Give_Earnings_Export(); |
59 | 59 | |
60 | 60 | $earnings_export->export(); |
61 | 61 | } |
62 | 62 | |
63 | -add_action( 'give_earnings_export', 'give_export_earnings' ); |
|
63 | +add_action('give_earnings_export', 'give_export_earnings'); |
|
64 | 64 | |
65 | 65 | |
66 | 66 | /** |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | */ |
75 | 75 | function give_export_all_customers() { |
76 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php'; |
|
76 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-customers.php'; |
|
77 | 77 | |
78 | 78 | $customer_export = new Give_Donors_Export(); |
79 | 79 | |
80 | 80 | $customer_export->export(); |
81 | 81 | } |
82 | 82 | |
83 | -add_action( 'give_email_export', 'give_export_all_customers' ); |
|
83 | +add_action('give_email_export', 'give_export_all_customers'); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Add a hook allowing extensions to register a hook on the batch export process |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return void |
90 | 90 | */ |
91 | 91 | function give_register_batch_exporters() { |
92 | - if ( is_admin() ) { |
|
92 | + if (is_admin()) { |
|
93 | 93 | /** |
94 | 94 | * Fires in the admin, while plugins loaded. |
95 | 95 | * |
@@ -99,21 +99,21 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @param string $class Export class. |
101 | 101 | */ |
102 | - do_action( 'give_register_batch_exporter' ); |
|
102 | + do_action('give_register_batch_exporter'); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | -add_action( 'plugins_loaded', 'give_register_batch_exporters' ); |
|
106 | +add_action('plugins_loaded', 'give_register_batch_exporters'); |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Register the payments batch exporter |
110 | 110 | * @since 1.5 |
111 | 111 | */ |
112 | 112 | function give_register_payments_batch_export() { |
113 | - add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 ); |
|
113 | + add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1); |
|
114 | 114 | } |
115 | 115 | |
116 | -add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 ); |
|
116 | +add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Loads the payments batch process if needed |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return void |
126 | 126 | */ |
127 | -function give_include_payments_batch_processor( $class ) { |
|
127 | +function give_include_payments_batch_processor($class) { |
|
128 | 128 | |
129 | - if ( 'Give_Batch_Payments_Export' === $class ) { |
|
130 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
129 | + if ('Give_Batch_Payments_Export' === $class) { |
|
130 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * @since 1.5.2 |
138 | 138 | */ |
139 | 139 | function give_register_customers_batch_export() { |
140 | - add_action( 'give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1 ); |
|
140 | + add_action('give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1); |
|
141 | 141 | } |
142 | 142 | |
143 | -add_action( 'give_register_batch_exporter', 'give_register_customers_batch_export', 10 ); |
|
143 | +add_action('give_register_batch_exporter', 'give_register_customers_batch_export', 10); |
|
144 | 144 | |
145 | 145 | /** |
146 | 146 | * Loads the customers batch process if needed |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return void |
153 | 153 | */ |
154 | -function give_include_customers_batch_processor( $class ) { |
|
154 | +function give_include_customers_batch_processor($class) { |
|
155 | 155 | |
156 | - if ( 'Give_Batch_Customers_Export' === $class ) { |
|
157 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
156 | + if ('Give_Batch_Customers_Export' === $class) { |
|
157 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | * @since 1.5 |
166 | 166 | */ |
167 | 167 | function give_register_forms_batch_export() { |
168 | - add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 ); |
|
168 | + add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1); |
|
169 | 169 | } |
170 | 170 | |
171 | -add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 ); |
|
171 | +add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10); |
|
172 | 172 | |
173 | 173 | /** |
174 | 174 | * Loads the file downloads batch process if needed |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return void |
181 | 181 | */ |
182 | -function give_include_forms_batch_processor( $class ) { |
|
182 | +function give_include_forms_batch_processor($class) { |
|
183 | 183 | |
184 | - if ( 'Give_Batch_Forms_Export' === $class ) { |
|
185 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
184 | + if ('Give_Batch_Forms_Export' === $class) { |
|
185 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } |
189 | 189 | \ No newline at end of file |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Earnings' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Earnings')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Earnings. |
@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'earnings'; |
46 | - $this->label = esc_html__( 'Income', 'give' ); |
|
46 | + $this->label = esc_html__('Income', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-reports_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-reports_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
50 | - add_action( 'give_admin_field_report_earnings', array( $this, 'render_report_earnings_field' ), 10, 2 ); |
|
48 | + add_filter('give-reports_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-reports_settings_{$this->id}_page", array($this, 'output')); |
|
50 | + add_action('give_admin_field_report_earnings', array($this, 'render_report_earnings_field'), 10, 2); |
|
51 | 51 | |
52 | 52 | // Do not use main form for this tab. |
53 | - if( give_get_current_setting_tab() === $this->id ) { |
|
54 | - add_action( 'give-reports_open_form', '__return_empty_string' ); |
|
55 | - add_action( 'give-reports_close_form', '__return_empty_string' ); |
|
53 | + if (give_get_current_setting_tab() === $this->id) { |
|
54 | + add_action('give-reports_open_form', '__return_empty_string'); |
|
55 | + add_action('give-reports_close_form', '__return_empty_string'); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | * @param array $pages Lst of pages. |
64 | 64 | * @return array |
65 | 65 | */ |
66 | - public function add_settings_page( $pages ) { |
|
67 | - $pages[ $this->id ] = $this->label; |
|
66 | + public function add_settings_page($pages) { |
|
67 | + $pages[$this->id] = $this->label; |
|
68 | 68 | |
69 | 69 | return $pages; |
70 | 70 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param array $settings |
87 | 87 | */ |
88 | 88 | $settings = apply_filters( |
89 | - 'give_get_settings_' . $this->id, |
|
89 | + 'give_get_settings_'.$this->id, |
|
90 | 90 | array( |
91 | 91 | array( |
92 | 92 | 'id' => 'give_tools_earnings', |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ), |
96 | 96 | array( |
97 | 97 | 'id' => 'earnings', |
98 | - 'name' => esc_html__( 'Income', 'give' ), |
|
98 | + 'name' => esc_html__('Income', 'give'), |
|
99 | 99 | 'type' => 'report_earnings', |
100 | 100 | ), |
101 | 101 | array( |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public function output() { |
120 | 120 | $settings = $this->get_settings(); |
121 | 121 | |
122 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
122 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param $field |
132 | 132 | * @param $option_value |
133 | 133 | */ |
134 | - public function render_report_earnings_field( $field, $option_value ) { |
|
135 | - do_action( 'give_reports_view_earnings' ); |
|
134 | + public function render_report_earnings_field($field, $option_value) { |
|
135 | + do_action('give_reports_view_earnings'); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 |
@@ -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 | |
@@ -25,35 +25,35 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | } |
49 | 49 | |
50 | - if ( $did_upgrade ) { |
|
51 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
50 | + if ($did_upgrade) { |
|
51 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
56 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
55 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
56 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Display Upgrade Notices |
@@ -63,18 +63,18 @@ discard block |
||
63 | 63 | */ |
64 | 64 | function give_show_upgrade_notices() { |
65 | 65 | // Don't show notices on the upgrades page. |
66 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) { |
|
66 | + if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') { |
|
67 | 67 | return; |
68 | 68 | } |
69 | 69 | |
70 | - $give_version = get_option( 'give_version' ); |
|
70 | + $give_version = get_option('give_version'); |
|
71 | 71 | |
72 | - if ( ! $give_version ) { |
|
72 | + if ( ! $give_version) { |
|
73 | 73 | // 1.0 is the first version to use this option so we must add it. |
74 | 74 | $give_version = '1.0'; |
75 | 75 | } |
76 | 76 | |
77 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
77 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
78 | 78 | |
79 | 79 | /* |
80 | 80 | * NOTICE: |
@@ -85,31 +85,31 @@ discard block |
||
85 | 85 | */ |
86 | 86 | |
87 | 87 | // v1.3.2 Upgrades |
88 | - if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) { |
|
88 | + if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) { |
|
89 | 89 | printf( |
90 | 90 | /* translators: %s: upgrade URL */ |
91 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
92 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) ) |
|
91 | + '<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
92 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id')) |
|
93 | 93 | ); |
94 | 94 | } |
95 | 95 | |
96 | 96 | // v1.3.4 Upgrades //ensure the user has gone through 1.3.4. |
97 | - if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) { |
|
97 | + if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) { |
|
98 | 98 | printf( |
99 | 99 | /* translators: %s: upgrade URL */ |
100 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
101 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) ) |
|
100 | + '<div class="updated"><p>'.__('Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
101 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status')) |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | 105 | // Check if we have a stalled upgrade. |
106 | 106 | $resume_upgrade = give_maybe_resume_upgrade(); |
107 | - if ( ! empty( $resume_upgrade ) ) { |
|
108 | - $resume_url = add_query_arg( $resume_upgrade, admin_url( 'index.php' ) ); |
|
107 | + if ( ! empty($resume_upgrade)) { |
|
108 | + $resume_url = add_query_arg($resume_upgrade, admin_url('index.php')); |
|
109 | 109 | echo Give_Notices::notice_html( |
110 | 110 | sprintf( |
111 | - __( 'Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give' ), |
|
112 | - esc_url( $resume_url ) |
|
111 | + __('Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give'), |
|
112 | + esc_url($resume_url) |
|
113 | 113 | ) |
114 | 114 | ); |
115 | 115 | |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | // v1.8 form metadata upgrades. |
120 | - if ( version_compare( $give_version, '1.8', '<' ) || ! give_has_upgrade_completed( 'v18_upgrades_form_metadata' ) ) { |
|
120 | + if (version_compare($give_version, '1.8', '<') || ! give_has_upgrade_completed('v18_upgrades_form_metadata')) { |
|
121 | 121 | echo Give_Notices::notice_html( |
122 | 122 | sprintf( |
123 | - esc_html__( 'Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give' ), |
|
124 | - '<a class="give-upgrade-link" href="' . esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata' ) ) . '">', |
|
123 | + esc_html__('Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give'), |
|
124 | + '<a class="give-upgrade-link" href="'.esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata')).'">', |
|
125 | 125 | '</a>' |
126 | 126 | ) |
127 | 127 | ); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | <?php |
150 | 150 | } |
151 | 151 | |
152 | -add_action( 'admin_notices', 'give_show_upgrade_notices' ); |
|
152 | +add_action('admin_notices', 'give_show_upgrade_notices'); |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Triggers all upgrade functions |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | */ |
162 | 162 | function give_trigger_upgrades() { |
163 | 163 | |
164 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
165 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
164 | + if ( ! current_user_can('manage_give_settings')) { |
|
165 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
166 | 166 | 'response' => 403, |
167 | - ) ); |
|
167 | + )); |
|
168 | 168 | } |
169 | 169 | |
170 | - $give_version = get_option( 'give_version' ); |
|
170 | + $give_version = get_option('give_version'); |
|
171 | 171 | |
172 | - if ( ! $give_version ) { |
|
172 | + if ( ! $give_version) { |
|
173 | 173 | // 1.0 is the first version to use this option so we must add it. |
174 | 174 | $give_version = '1.0'; |
175 | - add_option( 'give_version', $give_version ); |
|
175 | + add_option('give_version', $give_version); |
|
176 | 176 | } |
177 | 177 | |
178 | - update_option( 'give_version', GIVE_VERSION ); |
|
179 | - delete_option( 'give_doing_upgrade' ); |
|
178 | + update_option('give_version', GIVE_VERSION); |
|
179 | + delete_option('give_doing_upgrade'); |
|
180 | 180 | |
181 | - if ( DOING_AJAX ) { |
|
182 | - die( 'complete' ); |
|
181 | + if (DOING_AJAX) { |
|
182 | + die('complete'); |
|
183 | 183 | } // End if(). |
184 | 184 | } |
185 | 185 | |
186 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
186 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
187 | 187 | |
188 | 188 | /** |
189 | 189 | * Check if the upgrade routine has been run for a specific action |
@@ -194,15 +194,15 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @return bool If the action has been added to the completed actions array |
196 | 196 | */ |
197 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
197 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
198 | 198 | |
199 | - if ( empty( $upgrade_action ) ) { |
|
199 | + if (empty($upgrade_action)) { |
|
200 | 200 | return false; |
201 | 201 | } |
202 | 202 | |
203 | 203 | $completed_upgrades = give_get_completed_upgrades(); |
204 | 204 | |
205 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
205 | + return in_array($upgrade_action, $completed_upgrades); |
|
206 | 206 | |
207 | 207 | } |
208 | 208 | |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off |
215 | 215 | */ |
216 | 216 | function give_maybe_resume_upgrade() { |
217 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); |
|
218 | - if ( empty( $doing_upgrade ) ) { |
|
217 | + $doing_upgrade = get_option('give_doing_upgrade', false); |
|
218 | + if (empty($doing_upgrade)) { |
|
219 | 219 | return false; |
220 | 220 | } |
221 | 221 | |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return bool If the function was successfully added |
233 | 233 | */ |
234 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
234 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
235 | 235 | |
236 | - if ( empty( $upgrade_action ) ) { |
|
236 | + if (empty($upgrade_action)) { |
|
237 | 237 | return false; |
238 | 238 | } |
239 | 239 | |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | $completed_upgrades[] = $upgrade_action; |
242 | 242 | |
243 | 243 | // Remove any blanks, and only show uniques. |
244 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
244 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
245 | 245 | |
246 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
246 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -254,9 +254,9 @@ discard block |
||
254 | 254 | */ |
255 | 255 | function give_get_completed_upgrades() { |
256 | 256 | |
257 | - $completed_upgrades = get_option( 'give_completed_upgrades' ); |
|
257 | + $completed_upgrades = get_option('give_completed_upgrades'); |
|
258 | 258 | |
259 | - if ( false === $completed_upgrades ) { |
|
259 | + if (false === $completed_upgrades) { |
|
260 | 260 | $completed_upgrades = array(); |
261 | 261 | } |
262 | 262 | |
@@ -273,31 +273,31 @@ discard block |
||
273 | 273 | */ |
274 | 274 | function give_v132_upgrade_give_payment_customer_id() { |
275 | 275 | global $wpdb; |
276 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
277 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
276 | + if ( ! current_user_can('manage_give_settings')) { |
|
277 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
278 | 278 | 'response' => 403, |
279 | - ) ); |
|
279 | + )); |
|
280 | 280 | } |
281 | 281 | |
282 | - ignore_user_abort( true ); |
|
282 | + ignore_user_abort(true); |
|
283 | 283 | |
284 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
285 | - @set_time_limit( 0 ); |
|
284 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
285 | + @set_time_limit(0); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | // UPDATE DB METAKEYS. |
289 | 289 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
290 | - $query = $wpdb->query( $sql ); |
|
290 | + $query = $wpdb->query($sql); |
|
291 | 291 | |
292 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
293 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
294 | - delete_option( 'give_doing_upgrade' ); |
|
295 | - wp_redirect( admin_url() ); |
|
292 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
293 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
294 | + delete_option('give_doing_upgrade'); |
|
295 | + wp_redirect(admin_url()); |
|
296 | 296 | exit; |
297 | 297 | |
298 | 298 | } |
299 | 299 | |
300 | -add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' ); |
|
300 | +add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id'); |
|
301 | 301 | |
302 | 302 | /** |
303 | 303 | * Upgrades the Offline Status |
@@ -310,16 +310,16 @@ discard block |
||
310 | 310 | |
311 | 311 | global $wpdb; |
312 | 312 | |
313 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
314 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
313 | + if ( ! current_user_can('manage_give_settings')) { |
|
314 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
315 | 315 | 'response' => 403, |
316 | - ) ); |
|
316 | + )); |
|
317 | 317 | } |
318 | 318 | |
319 | - ignore_user_abort( true ); |
|
319 | + ignore_user_abort(true); |
|
320 | 320 | |
321 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
322 | - @set_time_limit( 0 ); |
|
321 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
322 | + @set_time_limit(0); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | // Get abandoned offline payments. |
@@ -329,31 +329,31 @@ discard block |
||
329 | 329 | $where .= "AND ( p.post_status = 'abandoned' )"; |
330 | 330 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
331 | 331 | |
332 | - $sql = $select . $join . $where; |
|
333 | - $found_payments = $wpdb->get_col( $sql ); |
|
332 | + $sql = $select.$join.$where; |
|
333 | + $found_payments = $wpdb->get_col($sql); |
|
334 | 334 | |
335 | - foreach ( $found_payments as $payment ) { |
|
335 | + foreach ($found_payments as $payment) { |
|
336 | 336 | |
337 | 337 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
338 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
338 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
339 | 339 | |
340 | 340 | // 1450124863 = 12/10/2015 20:42:25. |
341 | - if ( $modified_time >= 1450124863 ) { |
|
341 | + if ($modified_time >= 1450124863) { |
|
342 | 342 | |
343 | - give_update_payment_status( $payment, 'pending' ); |
|
343 | + give_update_payment_status($payment, 'pending'); |
|
344 | 344 | |
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
348 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
349 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
350 | - delete_option( 'give_doing_upgrade' ); |
|
351 | - wp_redirect( admin_url() ); |
|
348 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
349 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
350 | + delete_option('give_doing_upgrade'); |
|
351 | + wp_redirect(admin_url()); |
|
352 | 352 | exit; |
353 | 353 | |
354 | 354 | } |
355 | 355 | |
356 | -add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' ); |
|
356 | +add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status'); |
|
357 | 357 | |
358 | 358 | /** |
359 | 359 | * Cleanup User Roles |
@@ -364,17 +364,17 @@ discard block |
||
364 | 364 | */ |
365 | 365 | function give_v152_cleanup_users() { |
366 | 366 | |
367 | - $give_version = get_option( 'give_version' ); |
|
367 | + $give_version = get_option('give_version'); |
|
368 | 368 | |
369 | - if ( ! $give_version ) { |
|
369 | + if ( ! $give_version) { |
|
370 | 370 | // 1.0 is the first version to use this option so we must add it. |
371 | 371 | $give_version = '1.0'; |
372 | 372 | } |
373 | 373 | |
374 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
374 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
375 | 375 | |
376 | 376 | // v1.5.2 Upgrades |
377 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
377 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
378 | 378 | |
379 | 379 | // Delete all caps with "ss". |
380 | 380 | // Also delete all unused "campaign" roles. |
@@ -421,9 +421,9 @@ discard block |
||
421 | 421 | ); |
422 | 422 | |
423 | 423 | global $wp_roles; |
424 | - foreach ( $delete_caps as $cap ) { |
|
425 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
426 | - $wp_roles->remove_cap( $role, $cap ); |
|
424 | + foreach ($delete_caps as $cap) { |
|
425 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
426 | + $wp_roles->remove_cap($role, $cap); |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
@@ -433,15 +433,15 @@ discard block |
||
433 | 433 | $roles->add_caps(); |
434 | 434 | |
435 | 435 | // The Update Ran. |
436 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
437 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
438 | - delete_option( 'give_doing_upgrade' ); |
|
436 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
437 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
438 | + delete_option('give_doing_upgrade'); |
|
439 | 439 | |
440 | 440 | }// End if(). |
441 | 441 | |
442 | 442 | } |
443 | 443 | |
444 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
444 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
445 | 445 | |
446 | 446 | /** |
447 | 447 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -481,53 +481,53 @@ discard block |
||
481 | 481 | |
482 | 482 | // Get addons license key. |
483 | 483 | $addons = array(); |
484 | - foreach ( $give_options as $key => $value ) { |
|
485 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
486 | - $addons[ $key ] = $value; |
|
484 | + foreach ($give_options as $key => $value) { |
|
485 | + if (false !== strpos($key, '_license_key')) { |
|
486 | + $addons[$key] = $value; |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
490 | 490 | // Bailout: We do not have any addon license data to upgrade. |
491 | - if ( empty( $addons ) ) { |
|
491 | + if (empty($addons)) { |
|
492 | 492 | return false; |
493 | 493 | } |
494 | 494 | |
495 | - foreach ( $addons as $key => $addon_license ) { |
|
495 | + foreach ($addons as $key => $addon_license) { |
|
496 | 496 | |
497 | 497 | // Get addon shortname. |
498 | - $shortname = str_replace( '_license_key', '', $key ); |
|
498 | + $shortname = str_replace('_license_key', '', $key); |
|
499 | 499 | |
500 | 500 | // Addon license option name. |
501 | - $addon_license_option_name = $shortname . '_license_active'; |
|
501 | + $addon_license_option_name = $shortname.'_license_active'; |
|
502 | 502 | |
503 | 503 | // bailout if license is empty. |
504 | - if ( empty( $addon_license ) ) { |
|
505 | - delete_option( $addon_license_option_name ); |
|
504 | + if (empty($addon_license)) { |
|
505 | + delete_option($addon_license_option_name); |
|
506 | 506 | continue; |
507 | 507 | } |
508 | 508 | |
509 | 509 | // Get addon name. |
510 | 510 | $addon_name = array(); |
511 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
512 | - foreach ( $addon_name_parts as $name_part ) { |
|
511 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
512 | + foreach ($addon_name_parts as $name_part) { |
|
513 | 513 | |
514 | 514 | // Fix addon name |
515 | - switch ( $name_part ) { |
|
515 | + switch ($name_part) { |
|
516 | 516 | case 'authorizenet' : |
517 | 517 | $name_part = 'authorize.net'; |
518 | 518 | break; |
519 | 519 | } |
520 | 520 | |
521 | - $addon_name[] = ucfirst( $name_part ); |
|
521 | + $addon_name[] = ucfirst($name_part); |
|
522 | 522 | } |
523 | 523 | |
524 | - $addon_name = implode( ' ', $addon_name ); |
|
524 | + $addon_name = implode(' ', $addon_name); |
|
525 | 525 | |
526 | 526 | // Data to send to the API |
527 | 527 | $api_params = array( |
528 | 528 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
529 | 529 | 'license' => $addon_license, |
530 | - 'item_name' => urlencode( $addon_name ), |
|
530 | + 'item_name' => urlencode($addon_name), |
|
531 | 531 | 'url' => home_url(), |
532 | 532 | ); |
533 | 533 | |
@@ -542,17 +542,17 @@ discard block |
||
542 | 542 | ); |
543 | 543 | |
544 | 544 | // Make sure there are no errors. |
545 | - if ( is_wp_error( $response ) ) { |
|
546 | - delete_option( $addon_license_option_name ); |
|
545 | + if (is_wp_error($response)) { |
|
546 | + delete_option($addon_license_option_name); |
|
547 | 547 | continue; |
548 | 548 | } |
549 | 549 | |
550 | 550 | // Tell WordPress to look for updates. |
551 | - set_site_transient( 'update_plugins', null ); |
|
551 | + set_site_transient('update_plugins', null); |
|
552 | 552 | |
553 | 553 | // Decode license data. |
554 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
555 | - update_option( $addon_license_option_name, $license_data ); |
|
554 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
555 | + update_option($addon_license_option_name, $license_data); |
|
556 | 556 | }// End foreach(). |
557 | 557 | } |
558 | 558 | |
@@ -582,9 +582,9 @@ discard block |
||
582 | 582 | ); |
583 | 583 | |
584 | 584 | global $wp_roles; |
585 | - foreach ( $delete_caps as $cap ) { |
|
586 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
587 | - $wp_roles->remove_cap( $role, $cap ); |
|
585 | + foreach ($delete_caps as $cap) { |
|
586 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
587 | + $wp_roles->remove_cap($role, $cap); |
|
588 | 588 | } |
589 | 589 | } |
590 | 590 | |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | function give_v18_upgrades_core_setting() { |
619 | 619 | // Core settings which changes from checkbox to radio. |
620 | 620 | $core_setting_names = array_merge( |
621 | - array_keys( give_v18_renamed_core_settings() ), |
|
621 | + array_keys(give_v18_renamed_core_settings()), |
|
622 | 622 | array( |
623 | 623 | 'uninstall_on_delete', |
624 | 624 | 'scripts_footer', |
@@ -630,48 +630,48 @@ discard block |
||
630 | 630 | ); |
631 | 631 | |
632 | 632 | // Bailout: If not any setting define. |
633 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
633 | + if ($give_settings = get_option('give_settings')) { |
|
634 | 634 | |
635 | 635 | $setting_changed = false; |
636 | 636 | |
637 | 637 | // Loop: check each setting field. |
638 | - foreach ( $core_setting_names as $setting_name ) { |
|
638 | + foreach ($core_setting_names as $setting_name) { |
|
639 | 639 | // New setting name. |
640 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
640 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
641 | 641 | |
642 | 642 | // Continue: If setting already set. |
643 | 643 | if ( |
644 | - array_key_exists( $new_setting_name, $give_settings ) |
|
645 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
644 | + array_key_exists($new_setting_name, $give_settings) |
|
645 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
646 | 646 | ) { |
647 | 647 | continue; |
648 | 648 | } |
649 | 649 | |
650 | 650 | // Set checkbox value to radio value. |
651 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
651 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
652 | 652 | |
653 | 653 | // @see https://github.com/WordImpress/Give/issues/1063 |
654 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
654 | + if (false !== strpos($setting_name, 'disable_')) { |
|
655 | 655 | |
656 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
657 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
656 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
657 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
658 | 658 | |
659 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
659 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | // Tell bot to update core setting to db. |
663 | - if ( ! $setting_changed ) { |
|
663 | + if ( ! $setting_changed) { |
|
664 | 664 | $setting_changed = true; |
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
668 | 668 | // Update setting only if they changed. |
669 | - if ( $setting_changed ) { |
|
670 | - update_option( 'give_settings', $give_settings ); |
|
669 | + if ($setting_changed) { |
|
670 | + update_option('give_settings', $give_settings); |
|
671 | 671 | } |
672 | 672 | }// End if(). |
673 | 673 | |
674 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
674 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | /** |
@@ -681,22 +681,22 @@ discard block |
||
681 | 681 | * @return void |
682 | 682 | */ |
683 | 683 | function give_v18_upgrades_form_metadata() { |
684 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
685 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
684 | + if ( ! current_user_can('manage_give_settings')) { |
|
685 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
686 | 686 | 'response' => 403, |
687 | - ) ); |
|
687 | + )); |
|
688 | 688 | } |
689 | 689 | |
690 | - ignore_user_abort( true ); |
|
690 | + ignore_user_abort(true); |
|
691 | 691 | |
692 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
693 | - @set_time_limit( 0 ); |
|
692 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
693 | + @set_time_limit(0); |
|
694 | 694 | } |
695 | 695 | |
696 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
696 | + $step = isset($_GET['step']) ? absint($_GET['step']) : 1; |
|
697 | 697 | |
698 | 698 | // form query |
699 | - $forms = new WP_Query( array( |
|
699 | + $forms = new WP_Query(array( |
|
700 | 700 | 'paged' => $step, |
701 | 701 | 'status' => 'any', |
702 | 702 | 'order' => 'ASC', |
@@ -706,27 +706,27 @@ discard block |
||
706 | 706 | ); |
707 | 707 | |
708 | 708 | |
709 | - if ( $forms->have_posts() ) { |
|
710 | - while ( $forms->have_posts() ) { |
|
709 | + if ($forms->have_posts()) { |
|
710 | + while ($forms->have_posts()) { |
|
711 | 711 | $forms->the_post(); |
712 | 712 | |
713 | 713 | // Form content. |
714 | 714 | // Note in version 1.8 display content setting split into display content and content placement setting. |
715 | 715 | // You can delete _give_content_option in future |
716 | - $show_content = get_post_meta( get_the_ID(), '_give_content_option', true ); |
|
717 | - if ( $show_content && ! get_post_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
718 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
719 | - update_post_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
716 | + $show_content = get_post_meta(get_the_ID(), '_give_content_option', true); |
|
717 | + if ($show_content && ! get_post_meta(get_the_ID(), '_give_display_content', true)) { |
|
718 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
719 | + update_post_meta(get_the_ID(), '_give_display_content', $field_value); |
|
720 | 720 | |
721 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
722 | - update_post_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
721 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
722 | + update_post_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | // "Disable" Guest Donation. Checkbox |
726 | 726 | // See: https://github.com/WordImpress/Give/issues/1470 |
727 | - $guest_donation = get_post_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
728 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
729 | - update_post_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
727 | + $guest_donation = get_post_meta(get_the_ID(), '_give_logged_in_only', true); |
|
728 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
729 | + update_post_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
730 | 730 | |
731 | 731 | // Convert yes/no setting field to enabled/disabled. |
732 | 732 | $form_radio_settings = array( |
@@ -749,15 +749,15 @@ discard block |
||
749 | 749 | '_give_offline_donation_enable_billing_fields_single', |
750 | 750 | ); |
751 | 751 | |
752 | - foreach ( $form_radio_settings as $meta_key ) { |
|
752 | + foreach ($form_radio_settings as $meta_key) { |
|
753 | 753 | // Get value. |
754 | - $field_value = get_post_meta( get_the_ID(), $meta_key, true ); |
|
754 | + $field_value = get_post_meta(get_the_ID(), $meta_key, true); |
|
755 | 755 | |
756 | 756 | // Convert meta value only if it is in yes/no/none. |
757 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
757 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
758 | 758 | |
759 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
760 | - update_post_meta( get_the_ID(), $meta_key, $field_value ); |
|
759 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
760 | + update_post_meta(get_the_ID(), $meta_key, $field_value); |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | }// End while(). |
@@ -765,28 +765,28 @@ discard block |
||
765 | 765 | wp_reset_postdata(); |
766 | 766 | |
767 | 767 | // Forms found so upgrade them |
768 | - $step ++; |
|
769 | - $redirect = add_query_arg( array( |
|
768 | + $step++; |
|
769 | + $redirect = add_query_arg(array( |
|
770 | 770 | 'page' => 'give-upgrades', |
771 | 771 | 'give-upgrade' => 'give_v18_upgrades_form_metadata', |
772 | 772 | 'step' => $step, |
773 | - ), admin_url( 'index.php' ) ); |
|
774 | - wp_redirect( $redirect ); |
|
773 | + ), admin_url('index.php')); |
|
774 | + wp_redirect($redirect); |
|
775 | 775 | exit(); |
776 | 776 | |
777 | 777 | } else { |
778 | 778 | // No more forms found, finish up. |
779 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
780 | - delete_option( 'give_doing_upgrade' ); |
|
781 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
779 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
780 | + delete_option('give_doing_upgrade'); |
|
781 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
782 | 782 | |
783 | 783 | |
784 | - wp_redirect( admin_url() ); |
|
784 | + wp_redirect(admin_url()); |
|
785 | 785 | exit; |
786 | 786 | } |
787 | 787 | } |
788 | 788 | |
789 | -add_action( 'give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata' ); |
|
789 | +add_action('give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata'); |
|
790 | 790 | |
791 | 791 | /** |
792 | 792 | * Get list of core setting renamed in version 1.8. |
@@ -654,7 +654,7 @@ |
||
654 | 654 | |
655 | 655 | <div id="<?php echo $setting['id']; ?>" |
656 | 656 | class="panel give_options_panel<?php echo( $show_first_tab_content ? '' : ' give-hidden' ); |
657 | - $show_first_tab_content = false; ?>"> |
|
657 | + $show_first_tab_content = false; ?>"> |
|
658 | 658 | <?php if ( ! empty( $setting['fields'] ) ) : ?> |
659 | 659 | <?php foreach ( $setting['fields'] as $field ) : ?> |
660 | 660 | <?php give_render_field( $field ); ?> |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function __construct() { |
48 | 48 | $this->metabox_id = 'give-metabox-form-data'; |
49 | - $this->metabox_label = esc_html__( 'Donation Form Options', 'give' ); |
|
49 | + $this->metabox_label = esc_html__('Donation Form Options', 'give'); |
|
50 | 50 | |
51 | 51 | // Setup. |
52 | - add_action( 'admin_init', array( $this, 'setup' ) ); |
|
52 | + add_action('admin_init', array($this, 'setup')); |
|
53 | 53 | |
54 | 54 | // Add metabox. |
55 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ), 30 ); |
|
55 | + add_action('add_meta_boxes', array($this, 'add_meta_box'), 30); |
|
56 | 56 | |
57 | 57 | // Load required scripts. |
58 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_script' ) ); |
|
58 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_script')); |
|
59 | 59 | |
60 | 60 | // Save form meta. |
61 | - add_action( 'save_post_give_forms', array( $this, 'save' ), 10, 2 ); |
|
61 | + add_action('save_post_give_forms', array($this, 'save'), 10, 2); |
|
62 | 62 | |
63 | 63 | // cmb2 old setting loaders. |
64 | 64 | // add_filter( 'give_metabox_form_data_settings', array( $this, 'cmb2_metabox_settings' ) ); |
65 | 65 | // Add offline donations options. |
66 | - add_filter( 'give_metabox_form_data_settings', array( $this, 'add_offline_donations_setting_tab' ), 0, 1 ); |
|
66 | + add_filter('give_metabox_form_data_settings', array($this, 'add_offline_donations_setting_tab'), 0, 1); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -86,18 +86,18 @@ discard block |
||
86 | 86 | */ |
87 | 87 | function get_settings() { |
88 | 88 | $post_id = give_get_admin_post_id(); |
89 | - $price = give_get_form_price( $post_id ); |
|
90 | - $custom_amount_minimum = give_get_form_minimum_price( $post_id ); |
|
91 | - $goal = give_get_form_goal( $post_id ); |
|
89 | + $price = give_get_form_price($post_id); |
|
90 | + $custom_amount_minimum = give_get_form_minimum_price($post_id); |
|
91 | + $goal = give_get_form_goal($post_id); |
|
92 | 92 | |
93 | 93 | // No empty prices - min. 1.00 for new forms |
94 | - if ( empty( $price ) && is_null( $post_id ) ) { |
|
95 | - $price = esc_attr( give_format_decimal( '1.00' ) ); |
|
94 | + if (empty($price) && is_null($post_id)) { |
|
95 | + $price = esc_attr(give_format_decimal('1.00')); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // Min. $1.00 for new forms |
99 | - if ( empty( $custom_amount_minimum ) ) { |
|
100 | - $custom_amount_minimum = esc_attr( give_format_decimal( '1.00' ) ); |
|
99 | + if (empty($custom_amount_minimum)) { |
|
100 | + $custom_amount_minimum = esc_attr(give_format_decimal('1.00')); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // Start with an underscore to hide fields from custom fields list |
@@ -107,213 +107,213 @@ discard block |
||
107 | 107 | /** |
108 | 108 | * Repeatable Field Groups |
109 | 109 | */ |
110 | - 'form_field_options' => apply_filters( 'give_forms_field_options', array( |
|
110 | + 'form_field_options' => apply_filters('give_forms_field_options', array( |
|
111 | 111 | 'id' => 'form_field_options', |
112 | - 'title' => esc_html__( 'Donation Options', 'give' ), |
|
113 | - 'fields' => apply_filters( 'give_forms_donation_form_metabox_fields', array( |
|
112 | + 'title' => esc_html__('Donation Options', 'give'), |
|
113 | + 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array( |
|
114 | 114 | // Donation Option |
115 | 115 | array( |
116 | - 'name' => esc_html__( 'Donation Option', 'give' ), |
|
117 | - 'description' => esc_html__( 'Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ), |
|
118 | - 'id' => $prefix . 'price_option', |
|
116 | + 'name' => esc_html__('Donation Option', 'give'), |
|
117 | + 'description' => esc_html__('Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'), |
|
118 | + 'id' => $prefix.'price_option', |
|
119 | 119 | 'type' => 'radio_inline', |
120 | 120 | 'default' => 'set', |
121 | - 'options' => apply_filters( 'give_forms_price_options', array( |
|
122 | - 'set' => esc_html__( 'Set Donation', 'give' ), |
|
123 | - 'multi' => esc_html__( 'Multi-level Donation', 'give' ), |
|
124 | - ) ), |
|
121 | + 'options' => apply_filters('give_forms_price_options', array( |
|
122 | + 'set' => esc_html__('Set Donation', 'give'), |
|
123 | + 'multi' => esc_html__('Multi-level Donation', 'give'), |
|
124 | + )), |
|
125 | 125 | ), |
126 | 126 | array( |
127 | - 'name' => esc_html__( 'Set Donation', 'give' ), |
|
128 | - 'description' => esc_html__( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ), |
|
129 | - 'id' => $prefix . 'set_price', |
|
127 | + 'name' => esc_html__('Set Donation', 'give'), |
|
128 | + 'description' => esc_html__('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'), |
|
129 | + 'id' => $prefix.'set_price', |
|
130 | 130 | 'type' => 'text_small', |
131 | 131 | 'data_type' => 'price', |
132 | 132 | 'attributes' => array( |
133 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
134 | - 'value' => give_format_decimal( $price ), |
|
133 | + 'placeholder' => give_format_decimal('1.00'), |
|
134 | + 'value' => give_format_decimal($price), |
|
135 | 135 | 'class' => 'give-money-field', |
136 | 136 | ), |
137 | 137 | ), |
138 | 138 | // Display Style |
139 | 139 | array( |
140 | - 'name' => esc_html__( 'Display Style', 'give' ), |
|
141 | - 'description' => esc_html__( 'Set how the donations levels will display on the form.', 'give' ), |
|
142 | - 'id' => $prefix . 'display_style', |
|
140 | + 'name' => esc_html__('Display Style', 'give'), |
|
141 | + 'description' => esc_html__('Set how the donations levels will display on the form.', 'give'), |
|
142 | + 'id' => $prefix.'display_style', |
|
143 | 143 | 'type' => 'radio_inline', |
144 | 144 | 'default' => 'buttons', |
145 | 145 | 'options' => array( |
146 | - 'buttons' => esc_html__( 'Buttons', 'give' ), |
|
147 | - 'radios' => esc_html__( 'Radios', 'give' ), |
|
148 | - 'dropdown' => esc_html__( 'Dropdown', 'give' ), |
|
146 | + 'buttons' => esc_html__('Buttons', 'give'), |
|
147 | + 'radios' => esc_html__('Radios', 'give'), |
|
148 | + 'dropdown' => esc_html__('Dropdown', 'give'), |
|
149 | 149 | ), |
150 | 150 | ), |
151 | 151 | // Custom Amount |
152 | 152 | array( |
153 | - 'name' => esc_html__( 'Custom Amount', 'give' ), |
|
154 | - 'description' => esc_html__( 'Do you want the user to be able to input their own donation amount?', 'give' ), |
|
155 | - 'id' => $prefix . 'custom_amount', |
|
153 | + 'name' => esc_html__('Custom Amount', 'give'), |
|
154 | + 'description' => esc_html__('Do you want the user to be able to input their own donation amount?', 'give'), |
|
155 | + 'id' => $prefix.'custom_amount', |
|
156 | 156 | 'type' => 'radio_inline', |
157 | 157 | 'default' => 'disabled', |
158 | 158 | 'options' => array( |
159 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
160 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
159 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
160 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
161 | 161 | ), |
162 | 162 | ), |
163 | 163 | array( |
164 | - 'name' => esc_html__( 'Minimum Amount', 'give' ), |
|
165 | - 'description' => esc_html__( 'Enter the minimum custom donation amount.', 'give' ), |
|
166 | - 'id' => $prefix . 'custom_amount_minimum', |
|
164 | + 'name' => esc_html__('Minimum Amount', 'give'), |
|
165 | + 'description' => esc_html__('Enter the minimum custom donation amount.', 'give'), |
|
166 | + 'id' => $prefix.'custom_amount_minimum', |
|
167 | 167 | 'type' => 'text_small', |
168 | 168 | 'data_type' => 'price', |
169 | 169 | 'attributes' => array( |
170 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
171 | - 'value' => give_format_decimal( $custom_amount_minimum ), |
|
170 | + 'placeholder' => give_format_decimal('1.00'), |
|
171 | + 'value' => give_format_decimal($custom_amount_minimum), |
|
172 | 172 | 'class' => 'give-money-field', |
173 | 173 | ), |
174 | 174 | ), |
175 | 175 | array( |
176 | - 'name' => esc_html__( 'Custom Amount Text', 'give' ), |
|
177 | - 'description' => esc_html__( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ), |
|
178 | - 'id' => $prefix . 'custom_amount_text', |
|
176 | + 'name' => esc_html__('Custom Amount Text', 'give'), |
|
177 | + 'description' => esc_html__('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'), |
|
178 | + 'id' => $prefix.'custom_amount_text', |
|
179 | 179 | 'type' => 'text', |
180 | 180 | 'attributes' => array( |
181 | 181 | 'rows' => 3, |
182 | - 'placeholder' => esc_attr__( 'Give a Custom Amount', 'give' ), |
|
182 | + 'placeholder' => esc_attr__('Give a Custom Amount', 'give'), |
|
183 | 183 | ), |
184 | 184 | ), |
185 | 185 | // Donation Levels: Repeatable CMB2 Group |
186 | 186 | array( |
187 | - 'id' => $prefix . 'donation_levels', |
|
187 | + 'id' => $prefix.'donation_levels', |
|
188 | 188 | 'type' => 'group', |
189 | 189 | 'options' => array( |
190 | - 'add_button' => esc_html__( 'Add Level', 'give' ), |
|
191 | - 'header_title' => esc_html__( 'Donation Level', 'give' ), |
|
190 | + 'add_button' => esc_html__('Add Level', 'give'), |
|
191 | + 'header_title' => esc_html__('Donation Level', 'give'), |
|
192 | 192 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
193 | 193 | ), |
194 | 194 | // Fields array works the same, except id's only need to be unique for this group. |
195 | 195 | // Prefix is not needed. |
196 | - 'fields' => apply_filters( 'give_donation_levels_table_row', array( |
|
196 | + 'fields' => apply_filters('give_donation_levels_table_row', array( |
|
197 | 197 | array( |
198 | - 'name' => esc_html__( 'ID', 'give' ), |
|
199 | - 'id' => $prefix . 'id', |
|
198 | + 'name' => esc_html__('ID', 'give'), |
|
199 | + 'id' => $prefix.'id', |
|
200 | 200 | 'type' => 'levels_id', |
201 | 201 | ), |
202 | 202 | array( |
203 | - 'name' => esc_html__( 'Amount', 'give' ), |
|
204 | - 'id' => $prefix . 'amount', |
|
203 | + 'name' => esc_html__('Amount', 'give'), |
|
204 | + 'id' => $prefix.'amount', |
|
205 | 205 | 'type' => 'text_small', |
206 | 206 | 'data_type' => 'price', |
207 | 207 | 'attributes' => array( |
208 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
208 | + 'placeholder' => give_format_decimal('1.00'), |
|
209 | 209 | 'class' => 'give-money-field', |
210 | 210 | ), |
211 | 211 | ), |
212 | 212 | array( |
213 | - 'name' => esc_html__( 'Text', 'give' ), |
|
214 | - 'id' => $prefix . 'text', |
|
213 | + 'name' => esc_html__('Text', 'give'), |
|
214 | + 'id' => $prefix.'text', |
|
215 | 215 | 'type' => 'text', |
216 | 216 | 'attributes' => array( |
217 | - 'placeholder' => esc_html__( 'Donation Level', 'give' ), |
|
217 | + 'placeholder' => esc_html__('Donation Level', 'give'), |
|
218 | 218 | 'class' => 'give-multilevel-text-field', |
219 | 219 | ), |
220 | 220 | ), |
221 | 221 | array( |
222 | - 'name' => esc_html__( 'Default', 'give' ), |
|
223 | - 'id' => $prefix . 'default', |
|
222 | + 'name' => esc_html__('Default', 'give'), |
|
223 | + 'id' => $prefix.'default', |
|
224 | 224 | 'type' => 'give_default_radio_inline', |
225 | 225 | ), |
226 | - ) ), |
|
226 | + )), |
|
227 | 227 | ), |
228 | 228 | array( |
229 | 229 | 'name' => 'donation_options_docs', |
230 | 230 | 'type' => 'docs_link', |
231 | 231 | 'url' => 'http://docs.givewp.com/form-donation-options', |
232 | - 'title' => esc_html__( 'Donation Options', 'give' ), |
|
232 | + 'title' => esc_html__('Donation Options', 'give'), |
|
233 | 233 | ), |
234 | 234 | ), |
235 | 235 | $post_id |
236 | 236 | ), |
237 | - ) ), |
|
237 | + )), |
|
238 | 238 | |
239 | 239 | /** |
240 | 240 | * Display Options |
241 | 241 | */ |
242 | - 'form_display_options' => apply_filters( 'give_form_display_options', array( |
|
242 | + 'form_display_options' => apply_filters('give_form_display_options', array( |
|
243 | 243 | 'id' => 'form_display_options', |
244 | - 'title' => esc_html__( 'Form Display', 'give' ), |
|
245 | - 'fields' => apply_filters( 'give_forms_display_options_metabox_fields', array( |
|
244 | + 'title' => esc_html__('Form Display', 'give'), |
|
245 | + 'fields' => apply_filters('give_forms_display_options_metabox_fields', array( |
|
246 | 246 | array( |
247 | - 'name' => esc_html__( 'Display Options', 'give' ), |
|
248 | - 'desc' => sprintf( __( 'How would you like to display donation information for this form?', 'give' ), '#' ), |
|
249 | - 'id' => $prefix . 'payment_display', |
|
247 | + 'name' => esc_html__('Display Options', 'give'), |
|
248 | + 'desc' => sprintf(__('How would you like to display donation information for this form?', 'give'), '#'), |
|
249 | + 'id' => $prefix.'payment_display', |
|
250 | 250 | 'type' => 'radio_inline', |
251 | 251 | 'options' => array( |
252 | - 'onpage' => esc_html__( 'All Fields', 'give' ), |
|
253 | - 'modal' => esc_html__( 'Modal', 'give' ), |
|
254 | - 'reveal' => esc_html__( 'Reveal', 'give' ), |
|
255 | - 'button' => esc_html__( 'Button', 'give' ), |
|
252 | + 'onpage' => esc_html__('All Fields', 'give'), |
|
253 | + 'modal' => esc_html__('Modal', 'give'), |
|
254 | + 'reveal' => esc_html__('Reveal', 'give'), |
|
255 | + 'button' => esc_html__('Button', 'give'), |
|
256 | 256 | ), |
257 | 257 | 'default' => 'onpage', |
258 | 258 | ), |
259 | 259 | array( |
260 | - 'id' => $prefix . 'reveal_label', |
|
261 | - 'name' => esc_html__( 'Continue Button', 'give' ), |
|
262 | - 'desc' => esc_html__( 'The button label for displaying the additional payment fields.', 'give' ), |
|
260 | + 'id' => $prefix.'reveal_label', |
|
261 | + 'name' => esc_html__('Continue Button', 'give'), |
|
262 | + 'desc' => esc_html__('The button label for displaying the additional payment fields.', 'give'), |
|
263 | 263 | 'type' => 'text_small', |
264 | 264 | 'attributes' => array( |
265 | - 'placeholder' => esc_attr__( 'Donate Now', 'give' ), |
|
265 | + 'placeholder' => esc_attr__('Donate Now', 'give'), |
|
266 | 266 | ), |
267 | 267 | ), |
268 | 268 | array( |
269 | - 'id' => $prefix . 'checkout_label', |
|
270 | - 'name' => esc_html__( 'Submit Button', 'give' ), |
|
271 | - 'desc' => esc_html__( 'The button label for completing a donation.', 'give' ), |
|
269 | + 'id' => $prefix.'checkout_label', |
|
270 | + 'name' => esc_html__('Submit Button', 'give'), |
|
271 | + 'desc' => esc_html__('The button label for completing a donation.', 'give'), |
|
272 | 272 | 'type' => 'text_small', |
273 | 273 | 'attributes' => array( |
274 | - 'placeholder' => esc_html__( 'Donate Now', 'give' ), |
|
274 | + 'placeholder' => esc_html__('Donate Now', 'give'), |
|
275 | 275 | ), |
276 | 276 | ), |
277 | 277 | array( |
278 | - 'name' => esc_html__( 'Default Gateway', 'give' ), |
|
279 | - 'desc' => esc_html__( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ), |
|
280 | - 'id' => $prefix . 'default_gateway', |
|
278 | + 'name' => esc_html__('Default Gateway', 'give'), |
|
279 | + 'desc' => esc_html__('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'), |
|
280 | + 'id' => $prefix.'default_gateway', |
|
281 | 281 | 'type' => 'default_gateway', |
282 | 282 | ), |
283 | 283 | array( |
284 | - 'name' => esc_html__( 'Guest Donations', 'give' ), |
|
285 | - 'desc' => esc_html__( 'Do you want to allow non-logged-in users to make donations?', 'give' ), |
|
286 | - 'id' => $prefix . 'logged_in_only', |
|
284 | + 'name' => esc_html__('Guest Donations', 'give'), |
|
285 | + 'desc' => esc_html__('Do you want to allow non-logged-in users to make donations?', 'give'), |
|
286 | + 'id' => $prefix.'logged_in_only', |
|
287 | 287 | 'type' => 'radio_inline', |
288 | 288 | 'default' => 'enabled', |
289 | 289 | 'options' => array( |
290 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
291 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
290 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
291 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
292 | 292 | ), |
293 | 293 | ), |
294 | 294 | array( |
295 | - 'name' => esc_html__( 'Registration', 'give' ), |
|
296 | - 'desc' => esc_html__( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ), |
|
297 | - 'id' => $prefix . 'show_register_form', |
|
295 | + 'name' => esc_html__('Registration', 'give'), |
|
296 | + 'desc' => esc_html__('Display the registration and login forms in the payment section for non-logged-in users.', 'give'), |
|
297 | + 'id' => $prefix.'show_register_form', |
|
298 | 298 | 'type' => 'radio', |
299 | 299 | 'options' => array( |
300 | - 'none' => esc_html__( 'None', 'give' ), |
|
301 | - 'registration' => esc_html__( 'Registration', 'give' ), |
|
302 | - 'login' => esc_html__( 'Login', 'give' ), |
|
303 | - 'both' => esc_html__( 'Registration + Login', 'give' ), |
|
300 | + 'none' => esc_html__('None', 'give'), |
|
301 | + 'registration' => esc_html__('Registration', 'give'), |
|
302 | + 'login' => esc_html__('Login', 'give'), |
|
303 | + 'both' => esc_html__('Registration + Login', 'give'), |
|
304 | 304 | ), |
305 | 305 | 'default' => 'none', |
306 | 306 | ), |
307 | 307 | array( |
308 | - 'name' => esc_html__( 'Floating Labels', 'give' ), |
|
308 | + 'name' => esc_html__('Floating Labels', 'give'), |
|
309 | 309 | /* translators: %s: forms http://docs.givewp.com/form-floating-labels */ |
310 | - 'desc' => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ), |
|
311 | - 'id' => $prefix . 'form_floating_labels', |
|
310 | + 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('http://docs.givewp.com/form-floating-labels')), |
|
311 | + 'id' => $prefix.'form_floating_labels', |
|
312 | 312 | 'type' => 'radio_inline', |
313 | 313 | 'options' => array( |
314 | - 'global' => esc_html__( 'Global Option', 'give' ), |
|
315 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
316 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
314 | + 'global' => esc_html__('Global Option', 'give'), |
|
315 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
316 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
317 | 317 | ), |
318 | 318 | 'default' => 'global', |
319 | 319 | ), |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | 'name' => 'form_display_docs', |
322 | 322 | 'type' => 'docs_link', |
323 | 323 | 'url' => 'http://docs.givewp.com/form-display-options', |
324 | - 'title' => esc_html__( 'Form Display', 'give' ), |
|
324 | + 'title' => esc_html__('Form Display', 'give'), |
|
325 | 325 | ), |
326 | 326 | ), |
327 | 327 | $post_id |
@@ -332,190 +332,190 @@ discard block |
||
332 | 332 | /** |
333 | 333 | * Donation Goals |
334 | 334 | */ |
335 | - 'donation_goal_options' => apply_filters( 'give_donation_goal_options', array( |
|
335 | + 'donation_goal_options' => apply_filters('give_donation_goal_options', array( |
|
336 | 336 | 'id' => 'donation_goal_options', |
337 | - 'title' => esc_html__( 'Donation Goal', 'give' ), |
|
338 | - 'fields' => apply_filters( 'give_forms_donation_goal_metabox_fields', array( |
|
337 | + 'title' => esc_html__('Donation Goal', 'give'), |
|
338 | + 'fields' => apply_filters('give_forms_donation_goal_metabox_fields', array( |
|
339 | 339 | // Goals |
340 | 340 | array( |
341 | - 'name' => esc_html__( 'Donation Goal', 'give' ), |
|
342 | - 'description' => esc_html__( 'Do you want to set a donation goal for this form?', 'give' ), |
|
343 | - 'id' => $prefix . 'goal_option', |
|
341 | + 'name' => esc_html__('Donation Goal', 'give'), |
|
342 | + 'description' => esc_html__('Do you want to set a donation goal for this form?', 'give'), |
|
343 | + 'id' => $prefix.'goal_option', |
|
344 | 344 | 'type' => 'radio_inline', |
345 | 345 | 'default' => 'disabled', |
346 | 346 | 'options' => array( |
347 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
348 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
347 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
348 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
349 | 349 | ), |
350 | 350 | ), |
351 | 351 | array( |
352 | - 'name' => esc_html__( 'Goal Amount', 'give' ), |
|
353 | - 'description' => esc_html__( 'This is the monetary goal amount you want to reach for this form.', 'give' ), |
|
354 | - 'id' => $prefix . 'set_goal', |
|
352 | + 'name' => esc_html__('Goal Amount', 'give'), |
|
353 | + 'description' => esc_html__('This is the monetary goal amount you want to reach for this form.', 'give'), |
|
354 | + 'id' => $prefix.'set_goal', |
|
355 | 355 | 'type' => 'text_small', |
356 | 356 | 'data_type' => 'price', |
357 | 357 | 'attributes' => array( |
358 | - 'placeholder' => give_format_decimal( '0.00' ), |
|
359 | - 'value' => give_format_decimal( $goal ), |
|
358 | + 'placeholder' => give_format_decimal('0.00'), |
|
359 | + 'value' => give_format_decimal($goal), |
|
360 | 360 | 'class' => 'give-money-field', |
361 | 361 | ), |
362 | 362 | ), |
363 | 363 | |
364 | 364 | array( |
365 | - 'name' => esc_html__( 'Goal Format', 'give' ), |
|
366 | - 'description' => esc_html__( 'Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give' ), |
|
367 | - 'id' => $prefix . 'goal_format', |
|
365 | + 'name' => esc_html__('Goal Format', 'give'), |
|
366 | + 'description' => esc_html__('Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give'), |
|
367 | + 'id' => $prefix.'goal_format', |
|
368 | 368 | 'type' => 'radio_inline', |
369 | 369 | 'default' => 'amount', |
370 | 370 | 'options' => array( |
371 | - 'amount' => esc_html__( 'Amount', 'give' ), |
|
372 | - 'percentage' => esc_html__( 'Percentage', 'give' ), |
|
371 | + 'amount' => esc_html__('Amount', 'give'), |
|
372 | + 'percentage' => esc_html__('Percentage', 'give'), |
|
373 | 373 | ), |
374 | 374 | ), |
375 | 375 | array( |
376 | - 'name' => esc_html__( 'Progress Bar Color', 'give' ), |
|
377 | - 'desc' => esc_html__( 'Customize the color of the goal progress bar.', 'give' ), |
|
378 | - 'id' => $prefix . 'goal_color', |
|
376 | + 'name' => esc_html__('Progress Bar Color', 'give'), |
|
377 | + 'desc' => esc_html__('Customize the color of the goal progress bar.', 'give'), |
|
378 | + 'id' => $prefix.'goal_color', |
|
379 | 379 | 'type' => 'colorpicker', |
380 | 380 | 'default' => '#2bc253', |
381 | 381 | ), |
382 | 382 | |
383 | 383 | array( |
384 | - 'name' => esc_html__( 'Close Form', 'give' ), |
|
385 | - 'desc' => esc_html__( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ), |
|
386 | - 'id' => $prefix . 'close_form_when_goal_achieved', |
|
384 | + 'name' => esc_html__('Close Form', 'give'), |
|
385 | + 'desc' => esc_html__('Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give'), |
|
386 | + 'id' => $prefix.'close_form_when_goal_achieved', |
|
387 | 387 | 'type' => 'radio_inline', |
388 | 388 | 'default' => 'disabled', |
389 | 389 | 'options' => array( |
390 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
391 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
390 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
391 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
392 | 392 | ), |
393 | 393 | ), |
394 | 394 | array( |
395 | - 'name' => esc_html__( 'Goal Achieved Message', 'give' ), |
|
396 | - 'desc' => esc_html__( 'Do you want to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give' ), |
|
397 | - 'id' => $prefix . 'form_goal_achieved_message', |
|
395 | + 'name' => esc_html__('Goal Achieved Message', 'give'), |
|
396 | + 'desc' => esc_html__('Do you want to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give'), |
|
397 | + 'id' => $prefix.'form_goal_achieved_message', |
|
398 | 398 | 'type' => 'textarea', |
399 | 399 | 'attributes' => array( |
400 | - 'placeholder' => esc_attr__( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ), |
|
400 | + 'placeholder' => esc_attr__('Thank you to all our donors, we have met our fundraising goal.', 'give'), |
|
401 | 401 | ), |
402 | 402 | ), |
403 | 403 | array( |
404 | 404 | 'name' => 'donation_goal_docs', |
405 | 405 | 'type' => 'docs_link', |
406 | 406 | 'url' => 'http://docs.givewp.com/form-donation-goal', |
407 | - 'title' => esc_html__( 'Donation Goal', 'give' ), |
|
407 | + 'title' => esc_html__('Donation Goal', 'give'), |
|
408 | 408 | ), |
409 | 409 | ), |
410 | 410 | $post_id |
411 | 411 | ), |
412 | - ) ), |
|
412 | + )), |
|
413 | 413 | |
414 | 414 | /** |
415 | 415 | * Content Field |
416 | 416 | */ |
417 | - 'form_content_options' => apply_filters( 'give_forms_content_options', array( |
|
417 | + 'form_content_options' => apply_filters('give_forms_content_options', array( |
|
418 | 418 | 'id' => 'form_content_options', |
419 | - 'title' => esc_html__( 'Form Content', 'give' ), |
|
420 | - 'fields' => apply_filters( 'give_forms_content_options_metabox_fields', array( |
|
419 | + 'title' => esc_html__('Form Content', 'give'), |
|
420 | + 'fields' => apply_filters('give_forms_content_options_metabox_fields', array( |
|
421 | 421 | |
422 | 422 | // Donation content. |
423 | 423 | array( |
424 | - 'name' => esc_html__( 'Display Content', 'give' ), |
|
425 | - 'description' => esc_html__( 'Do you want to add custom content to this form?', 'give' ), |
|
426 | - 'id' => $prefix . 'display_content', |
|
424 | + 'name' => esc_html__('Display Content', 'give'), |
|
425 | + 'description' => esc_html__('Do you want to add custom content to this form?', 'give'), |
|
426 | + 'id' => $prefix.'display_content', |
|
427 | 427 | 'type' => 'radio_inline', |
428 | 428 | 'options' => array( |
429 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
430 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
429 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
430 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
431 | 431 | ), |
432 | 432 | 'default' => 'disabled', |
433 | 433 | ), |
434 | 434 | |
435 | 435 | // Content placement. |
436 | 436 | array( |
437 | - 'name' => esc_html__( 'Content Placement', 'give' ), |
|
438 | - 'description' => esc_html__( 'This option controls where the content appears within the donation form.', 'give' ), |
|
439 | - 'id' => $prefix . 'content_placement', |
|
437 | + 'name' => esc_html__('Content Placement', 'give'), |
|
438 | + 'description' => esc_html__('This option controls where the content appears within the donation form.', 'give'), |
|
439 | + 'id' => $prefix.'content_placement', |
|
440 | 440 | 'type' => 'radio_inline', |
441 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
442 | - 'give_pre_form' => esc_html__( 'Above fields', 'give' ), |
|
443 | - 'give_post_form' => esc_html__( 'Below fields', 'give' ), |
|
441 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
442 | + 'give_pre_form' => esc_html__('Above fields', 'give'), |
|
443 | + 'give_post_form' => esc_html__('Below fields', 'give'), |
|
444 | 444 | ) |
445 | 445 | ), |
446 | 446 | 'default' => 'give_pre_form', |
447 | 447 | ), |
448 | 448 | array( |
449 | - 'name' => esc_html__( 'Content', 'give' ), |
|
450 | - 'description' => esc_html__( 'This content will display on the single give form page.', 'give' ), |
|
451 | - 'id' => $prefix . 'form_content', |
|
449 | + 'name' => esc_html__('Content', 'give'), |
|
450 | + 'description' => esc_html__('This content will display on the single give form page.', 'give'), |
|
451 | + 'id' => $prefix.'form_content', |
|
452 | 452 | 'type' => 'wysiwyg', |
453 | 453 | ), |
454 | 454 | array( |
455 | 455 | 'name' => 'form_content_docs', |
456 | 456 | 'type' => 'docs_link', |
457 | 457 | 'url' => 'http://docs.givewp.com/form-content', |
458 | - 'title' => esc_html__( 'Form Content', 'give' ), |
|
458 | + 'title' => esc_html__('Form Content', 'give'), |
|
459 | 459 | ), |
460 | 460 | ), |
461 | 461 | $post_id |
462 | 462 | ), |
463 | - ) ), |
|
463 | + )), |
|
464 | 464 | |
465 | 465 | /** |
466 | 466 | * Terms & Conditions |
467 | 467 | */ |
468 | - 'form_terms_options' => apply_filters( 'give_forms_terms_options', array( |
|
468 | + 'form_terms_options' => apply_filters('give_forms_terms_options', array( |
|
469 | 469 | 'id' => 'form_terms_options', |
470 | - 'title' => esc_html__( 'Terms & Conditions', 'give' ), |
|
471 | - 'fields' => apply_filters( 'give_forms_terms_options_metabox_fields', array( |
|
470 | + 'title' => esc_html__('Terms & Conditions', 'give'), |
|
471 | + 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array( |
|
472 | 472 | // Donation Option |
473 | 473 | array( |
474 | - 'name' => esc_html__( 'Terms & Conditions', 'give' ), |
|
475 | - 'description' => esc_html__( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ), |
|
476 | - 'id' => $prefix . 'terms_option', |
|
474 | + 'name' => esc_html__('Terms & Conditions', 'give'), |
|
475 | + 'description' => esc_html__('Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give'), |
|
476 | + 'id' => $prefix.'terms_option', |
|
477 | 477 | 'type' => 'radio_inline', |
478 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
479 | - 'global' => esc_html__( 'Global Option', 'give' ), |
|
480 | - 'enabled' => esc_html__( 'Customize', 'give' ), |
|
481 | - 'disabled' => esc_html__( 'Disable', 'give' ), |
|
478 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
479 | + 'global' => esc_html__('Global Option', 'give'), |
|
480 | + 'enabled' => esc_html__('Customize', 'give'), |
|
481 | + 'disabled' => esc_html__('Disable', 'give'), |
|
482 | 482 | ) |
483 | 483 | ), |
484 | 484 | 'default' => 'global', |
485 | 485 | ), |
486 | 486 | array( |
487 | - 'id' => $prefix . 'agree_label', |
|
488 | - 'name' => esc_html__( 'Agreement Label', 'give' ), |
|
489 | - 'desc' => esc_html__( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ), |
|
487 | + 'id' => $prefix.'agree_label', |
|
488 | + 'name' => esc_html__('Agreement Label', 'give'), |
|
489 | + 'desc' => esc_html__('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'), |
|
490 | 490 | 'type' => 'text', |
491 | 491 | 'size' => 'regular', |
492 | 492 | 'attributes' => array( |
493 | - 'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ), |
|
493 | + 'placeholder' => esc_attr__('Agree to Terms?', 'give'), |
|
494 | 494 | ), |
495 | 495 | ), |
496 | 496 | array( |
497 | - 'id' => $prefix . 'agree_text', |
|
498 | - 'name' => esc_html__( 'Agreement Text', 'give' ), |
|
499 | - 'desc' => esc_html__( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ), |
|
497 | + 'id' => $prefix.'agree_text', |
|
498 | + 'name' => esc_html__('Agreement Text', 'give'), |
|
499 | + 'desc' => esc_html__('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), |
|
500 | 500 | 'type' => 'wysiwyg', |
501 | 501 | ), |
502 | 502 | array( |
503 | 503 | 'name' => 'terms_docs', |
504 | 504 | 'type' => 'docs_link', |
505 | 505 | 'url' => 'http://docs.givewp.com/form-terms', |
506 | - 'title' => esc_html__( 'Terms & Conditions', 'give' ), |
|
506 | + 'title' => esc_html__('Terms & Conditions', 'give'), |
|
507 | 507 | ), |
508 | 508 | ), |
509 | 509 | $post_id |
510 | 510 | ), |
511 | - ) ), |
|
511 | + )), |
|
512 | 512 | ); |
513 | 513 | |
514 | 514 | |
515 | 515 | /** |
516 | 516 | * Filter the metabox tabbed panel settings. |
517 | 517 | */ |
518 | - $settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id ); |
|
518 | + $settings = apply_filters('give_metabox_form_data_settings', $settings, $post_id); |
|
519 | 519 | |
520 | 520 | // Output. |
521 | 521 | return $settings; |
@@ -531,8 +531,8 @@ discard block |
||
531 | 531 | add_meta_box( |
532 | 532 | $this->get_metabox_ID(), |
533 | 533 | $this->get_metabox_label(), |
534 | - array( $this, 'output' ), |
|
535 | - array( 'give_forms' ), |
|
534 | + array($this, 'output'), |
|
535 | + array('give_forms'), |
|
536 | 536 | 'normal', |
537 | 537 | 'high' |
538 | 538 | ); |
@@ -548,9 +548,9 @@ discard block |
||
548 | 548 | function enqueue_script() { |
549 | 549 | global $post; |
550 | 550 | |
551 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
552 | - wp_enqueue_style( 'wp-color-picker' ); |
|
553 | - wp_enqueue_script( 'wp-color-picker' ); |
|
551 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
552 | + wp_enqueue_style('wp-color-picker'); |
|
553 | + wp_enqueue_script('wp-color-picker'); |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | public function get_tabs() { |
585 | 585 | $tabs = array(); |
586 | 586 | |
587 | - if ( ! empty( $this->settings ) ) { |
|
588 | - foreach ( $this->settings as $setting ) { |
|
589 | - if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) { |
|
587 | + if ( ! empty($this->settings)) { |
|
588 | + foreach ($this->settings as $setting) { |
|
589 | + if ( ! isset($setting['id']) || ! isset($setting['title'])) { |
|
590 | 590 | continue; |
591 | 591 | } |
592 | 592 | $tab = array( |
@@ -594,11 +594,11 @@ discard block |
||
594 | 594 | 'label' => $setting['title'], |
595 | 595 | ); |
596 | 596 | |
597 | - if ( $this->has_sub_tab( $setting ) ) { |
|
598 | - if ( empty( $setting['sub-fields'] ) ) { |
|
597 | + if ($this->has_sub_tab($setting)) { |
|
598 | + if (empty($setting['sub-fields'])) { |
|
599 | 599 | $tab = array(); |
600 | 600 | } else { |
601 | - foreach ( $setting['sub-fields'] as $sub_fields ) { |
|
601 | + foreach ($setting['sub-fields'] as $sub_fields) { |
|
602 | 602 | $tab['sub-fields'][] = array( |
603 | 603 | 'id' => $sub_fields['id'], |
604 | 604 | 'label' => $sub_fields['title'], |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
610 | - if ( ! empty( $tab ) ) { |
|
610 | + if ( ! empty($tab)) { |
|
611 | 611 | $tabs[] = $tab; |
612 | 612 | } |
613 | 613 | } |
@@ -624,17 +624,17 @@ discard block |
||
624 | 624 | */ |
625 | 625 | public function output() { |
626 | 626 | // Bailout. |
627 | - if ( $form_data_tabs = $this->get_tabs() ) { |
|
628 | - wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' ); |
|
627 | + if ($form_data_tabs = $this->get_tabs()) { |
|
628 | + wp_nonce_field('give_save_form_meta', 'give_form_meta_nonce'); |
|
629 | 629 | ?> |
630 | 630 | <div class="give-metabox-panel-wrap"> |
631 | 631 | <ul class="give-form-data-tabs give-metabox-tabs"> |
632 | - <?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?> |
|
633 | - <li class="<?php echo "{$form_data_tab['id']}_tab" . ( ! $index ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>"> |
|
632 | + <?php foreach ($form_data_tabs as $index => $form_data_tab) : ?> |
|
633 | + <li class="<?php echo "{$form_data_tab['id']}_tab".( ! $index ? ' active' : '').($this->has_sub_tab($form_data_tab) ? ' has-sub-fields' : ''); ?>"> |
|
634 | 634 | <a href="#<?php echo $form_data_tab['id']; ?>"><span><?php echo $form_data_tab['label']; ?></span></a> |
635 | - <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
|
635 | + <?php if ($this->has_sub_tab($form_data_tab)) : ?> |
|
636 | 636 | <ul class="give-metabox-sub-tabs give-hidden"> |
637 | - <?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?> |
|
637 | + <?php foreach ($form_data_tab['sub-fields'] as $sub_tab) : ?> |
|
638 | 638 | <li class="<?php echo "{$sub_tab['id']}_tab"; ?>"> |
639 | 639 | <a href="#<?php echo $sub_tab['id']; ?>"> |
640 | 640 | <span><?php echo $sub_tab['label']; ?></span> |
@@ -648,30 +648,30 @@ discard block |
||
648 | 648 | </ul> |
649 | 649 | |
650 | 650 | <?php $show_first_tab_content = true; ?> |
651 | - <?php foreach ( $this->settings as $setting ) : ?> |
|
652 | - <?php if ( ! $this->has_sub_tab( $setting ) ) : ?> |
|
653 | - <?php do_action( "give_before_{$setting['id']}_settings" ); ?> |
|
651 | + <?php foreach ($this->settings as $setting) : ?> |
|
652 | + <?php if ( ! $this->has_sub_tab($setting)) : ?> |
|
653 | + <?php do_action("give_before_{$setting['id']}_settings"); ?> |
|
654 | 654 | |
655 | 655 | <div id="<?php echo $setting['id']; ?>" |
656 | - class="panel give_options_panel<?php echo( $show_first_tab_content ? '' : ' give-hidden' ); |
|
656 | + class="panel give_options_panel<?php echo($show_first_tab_content ? '' : ' give-hidden'); |
|
657 | 657 | $show_first_tab_content = false; ?>"> |
658 | - <?php if ( ! empty( $setting['fields'] ) ) : ?> |
|
659 | - <?php foreach ( $setting['fields'] as $field ) : ?> |
|
660 | - <?php give_render_field( $field ); ?> |
|
658 | + <?php if ( ! empty($setting['fields'])) : ?> |
|
659 | + <?php foreach ($setting['fields'] as $field) : ?> |
|
660 | + <?php give_render_field($field); ?> |
|
661 | 661 | <?php endforeach; ?> |
662 | 662 | <?php endif; ?> |
663 | 663 | </div> |
664 | 664 | |
665 | - <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
|
665 | + <?php do_action("give_after_{$setting['id']}_settings"); ?> |
|
666 | 666 | <?php else: ?> |
667 | - <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
|
668 | - <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
|
669 | - <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
|
667 | + <?php if ($this->has_sub_tab($setting)) : ?> |
|
668 | + <?php if ( ! empty($setting['sub-fields'])) : ?> |
|
669 | + <?php foreach ($setting['sub-fields'] as $index => $sub_fields) : ?> |
|
670 | 670 | <div id="<?php echo $sub_fields['id']; ?>" |
671 | 671 | class="panel give_options_panel give-hidden"> |
672 | - <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
|
673 | - <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
|
674 | - <?php give_render_field( $sub_field ); ?> |
|
672 | + <?php if ( ! empty($sub_fields['fields'])) : ?> |
|
673 | + <?php foreach ($sub_fields['fields'] as $sub_field) : ?> |
|
674 | + <?php give_render_field($sub_field); ?> |
|
675 | 675 | <?php endforeach; ?> |
676 | 676 | <?php endif; ?> |
677 | 677 | </div> |
@@ -695,9 +695,9 @@ discard block |
||
695 | 695 | * |
696 | 696 | * @return bool |
697 | 697 | */ |
698 | - private function has_sub_tab( $field_setting ) { |
|
698 | + private function has_sub_tab($field_setting) { |
|
699 | 699 | $has_sub_tab = false; |
700 | - if ( array_key_exists( 'sub-fields', $field_setting ) ) { |
|
700 | + if (array_key_exists('sub-fields', $field_setting)) { |
|
701 | 701 | $has_sub_tab = true; |
702 | 702 | } |
703 | 703 | |
@@ -711,13 +711,13 @@ discard block |
||
711 | 711 | * @return array |
712 | 712 | */ |
713 | 713 | function cmb2_metabox_settings() { |
714 | - $all_cmb2_settings = apply_filters( 'cmb2_meta_boxes', array() ); |
|
714 | + $all_cmb2_settings = apply_filters('cmb2_meta_boxes', array()); |
|
715 | 715 | $give_forms_settings = $all_cmb2_settings; |
716 | 716 | |
717 | 717 | // Filter settings: Use only give forms related settings. |
718 | - foreach ( $all_cmb2_settings as $index => $setting ) { |
|
719 | - if ( ! in_array( 'give_forms', $setting['object_types'] ) ) { |
|
720 | - unset( $give_forms_settings[ $index ] ); |
|
718 | + foreach ($all_cmb2_settings as $index => $setting) { |
|
719 | + if ( ! in_array('give_forms', $setting['object_types'])) { |
|
720 | + unset($give_forms_settings[$index]); |
|
721 | 721 | } |
722 | 722 | } |
723 | 723 | |
@@ -735,114 +735,114 @@ discard block |
||
735 | 735 | * |
736 | 736 | * @return void |
737 | 737 | */ |
738 | - public function save( $post_id, $post ) { |
|
738 | + public function save($post_id, $post) { |
|
739 | 739 | |
740 | 740 | // $post_id and $post are required. |
741 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
741 | + if (empty($post_id) || empty($post)) { |
|
742 | 742 | return; |
743 | 743 | } |
744 | 744 | |
745 | 745 | // Don't save meta boxes for revisions or autosaves. |
746 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
746 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
747 | 747 | return; |
748 | 748 | } |
749 | 749 | |
750 | 750 | // Check the nonce. |
751 | - if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) { |
|
751 | + if (empty($_POST['give_form_meta_nonce']) || ! wp_verify_nonce($_POST['give_form_meta_nonce'], 'give_save_form_meta')) { |
|
752 | 752 | return; |
753 | 753 | } |
754 | 754 | |
755 | 755 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
756 | - if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
|
756 | + if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) { |
|
757 | 757 | return; |
758 | 758 | } |
759 | 759 | |
760 | 760 | // Check user has permission to edit. |
761 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
761 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
762 | 762 | return; |
763 | 763 | } |
764 | 764 | |
765 | 765 | // Fire action before saving form meta. |
766 | - do_action( 'give_pre_process_give_forms_meta', $post_id, $post ); |
|
766 | + do_action('give_pre_process_give_forms_meta', $post_id, $post); |
|
767 | 767 | |
768 | 768 | /** |
769 | 769 | * Filter the meta key to save. |
770 | 770 | * Third party addon developer can remove there meta keys from this array to handle saving data on there own. |
771 | 771 | */ |
772 | - $form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() ); |
|
772 | + $form_meta_keys = apply_filters('give_process_form_meta_keys', $this->get_meta_keys_from_settings()); |
|
773 | 773 | |
774 | 774 | // Save form meta data. |
775 | - if ( ! empty( $form_meta_keys ) ) { |
|
776 | - foreach ( $form_meta_keys as $form_meta_key ) { |
|
775 | + if ( ! empty($form_meta_keys)) { |
|
776 | + foreach ($form_meta_keys as $form_meta_key) { |
|
777 | 777 | |
778 | 778 | // Set default value for checkbox fields. |
779 | 779 | if ( |
780 | - ! isset( $_POST[ $form_meta_key ] ) |
|
781 | - && ( 'checkbox' === $this->get_field_type( $form_meta_key ) ) |
|
780 | + ! isset($_POST[$form_meta_key]) |
|
781 | + && ('checkbox' === $this->get_field_type($form_meta_key)) |
|
782 | 782 | ) { |
783 | - $_POST[ $form_meta_key ] = ''; |
|
783 | + $_POST[$form_meta_key] = ''; |
|
784 | 784 | } |
785 | 785 | |
786 | - if ( isset( $_POST[ $form_meta_key ] ) ) { |
|
787 | - if ( $field_type = $this->get_field_type( $form_meta_key ) ) { |
|
788 | - switch ( $field_type ) { |
|
786 | + if (isset($_POST[$form_meta_key])) { |
|
787 | + if ($field_type = $this->get_field_type($form_meta_key)) { |
|
788 | + switch ($field_type) { |
|
789 | 789 | case 'textarea': |
790 | 790 | case 'wysiwyg': |
791 | - $form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] ); |
|
792 | - update_post_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
791 | + $form_meta_value = wp_kses_post($_POST[$form_meta_key]); |
|
792 | + update_post_meta($post_id, $form_meta_key, $form_meta_value); |
|
793 | 793 | break; |
794 | 794 | |
795 | 795 | case 'group': |
796 | 796 | $form_meta_value = array(); |
797 | 797 | |
798 | - foreach ( $_POST[ $form_meta_key ] as $index => $group ) { |
|
798 | + foreach ($_POST[$form_meta_key] as $index => $group) { |
|
799 | 799 | |
800 | 800 | // Do not save template input field values. |
801 | - if ( '{{row-count-placeholder}}' === $index ) { |
|
801 | + if ('{{row-count-placeholder}}' === $index) { |
|
802 | 802 | continue; |
803 | 803 | } |
804 | 804 | |
805 | 805 | $group_meta_value = array(); |
806 | - foreach ( $group as $field_id => $field_value ) { |
|
807 | - switch ( $this->get_field_type( $field_id, $form_meta_key ) ) { |
|
806 | + foreach ($group as $field_id => $field_value) { |
|
807 | + switch ($this->get_field_type($field_id, $form_meta_key)) { |
|
808 | 808 | case 'wysiwyg': |
809 | - $group_meta_value[ $field_id ] = wp_kses_post( $field_value ); |
|
809 | + $group_meta_value[$field_id] = wp_kses_post($field_value); |
|
810 | 810 | break; |
811 | 811 | |
812 | 812 | default: |
813 | - $group_meta_value[ $field_id ] = give_clean( $field_value ); |
|
813 | + $group_meta_value[$field_id] = give_clean($field_value); |
|
814 | 814 | } |
815 | 815 | } |
816 | 816 | |
817 | - if ( ! empty( $group_meta_value ) ) { |
|
818 | - $form_meta_value[ $index ] = $group_meta_value; |
|
817 | + if ( ! empty($group_meta_value)) { |
|
818 | + $form_meta_value[$index] = $group_meta_value; |
|
819 | 819 | } |
820 | 820 | } |
821 | 821 | |
822 | 822 | |
823 | 823 | // Arrange repeater field keys in order. |
824 | - $form_meta_value = array_values( $form_meta_value ); |
|
824 | + $form_meta_value = array_values($form_meta_value); |
|
825 | 825 | |
826 | 826 | // Save data. |
827 | - update_post_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
827 | + update_post_meta($post_id, $form_meta_key, $form_meta_value); |
|
828 | 828 | break; |
829 | 829 | |
830 | 830 | default: |
831 | - $form_meta_value = give_clean( $_POST[ $form_meta_key ] ); |
|
831 | + $form_meta_value = give_clean($_POST[$form_meta_key]); |
|
832 | 832 | |
833 | 833 | // Save data. |
834 | - update_post_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
834 | + update_post_meta($post_id, $form_meta_key, $form_meta_value); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | // Fire after saving form meta key. |
838 | - do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post ); |
|
838 | + do_action("give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post); |
|
839 | 839 | } |
840 | 840 | } |
841 | 841 | } |
842 | 842 | } |
843 | 843 | |
844 | 844 | // Fire action after saving form meta. |
845 | - do_action( 'give_post_process_give_forms_meta', $post_id, $post ); |
|
845 | + do_action('give_post_process_give_forms_meta', $post_id, $post); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | |
@@ -855,10 +855,10 @@ discard block |
||
855 | 855 | * |
856 | 856 | * @return string |
857 | 857 | */ |
858 | - private function get_field_id( $field ) { |
|
858 | + private function get_field_id($field) { |
|
859 | 859 | $field_id = ''; |
860 | 860 | |
861 | - if ( array_key_exists( 'id', $field ) ) { |
|
861 | + if (array_key_exists('id', $field)) { |
|
862 | 862 | $field_id = $field['id']; |
863 | 863 | |
864 | 864 | } |
@@ -875,12 +875,12 @@ discard block |
||
875 | 875 | * |
876 | 876 | * @return array |
877 | 877 | */ |
878 | - private function get_fields_id( $setting ) { |
|
878 | + private function get_fields_id($setting) { |
|
879 | 879 | $meta_keys = array(); |
880 | 880 | |
881 | - if ( ! empty( $setting ) ) { |
|
882 | - foreach ( $setting['fields'] as $field ) { |
|
883 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
881 | + if ( ! empty($setting)) { |
|
882 | + foreach ($setting['fields'] as $field) { |
|
883 | + if ($field_id = $this->get_field_id($field)) { |
|
884 | 884 | $meta_keys[] = $field_id; |
885 | 885 | } |
886 | 886 | } |
@@ -898,14 +898,14 @@ discard block |
||
898 | 898 | * |
899 | 899 | * @return array |
900 | 900 | */ |
901 | - private function get_sub_fields_id( $setting ) { |
|
901 | + private function get_sub_fields_id($setting) { |
|
902 | 902 | $meta_keys = array(); |
903 | 903 | |
904 | - if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) { |
|
905 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
906 | - if ( ! empty( $fields['fields'] ) ) { |
|
907 | - foreach ( $fields['fields'] as $field ) { |
|
908 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
904 | + if ($this->has_sub_tab($setting) && ! empty($setting['sub-fields'])) { |
|
905 | + foreach ($setting['sub-fields'] as $fields) { |
|
906 | + if ( ! empty($fields['fields'])) { |
|
907 | + foreach ($fields['fields'] as $field) { |
|
908 | + if ($field_id = $this->get_field_id($field)) { |
|
909 | 909 | $meta_keys[] = $field_id; |
910 | 910 | } |
911 | 911 | } |
@@ -926,14 +926,14 @@ discard block |
||
926 | 926 | private function get_meta_keys_from_settings() { |
927 | 927 | $meta_keys = array(); |
928 | 928 | |
929 | - foreach ( $this->settings as $setting ) { |
|
930 | - if ( $this->has_sub_tab( $setting ) ) { |
|
931 | - $meta_key = $this->get_sub_fields_id( $setting ); |
|
929 | + foreach ($this->settings as $setting) { |
|
930 | + if ($this->has_sub_tab($setting)) { |
|
931 | + $meta_key = $this->get_sub_fields_id($setting); |
|
932 | 932 | } else { |
933 | - $meta_key = $this->get_fields_id( $setting ); |
|
933 | + $meta_key = $this->get_fields_id($setting); |
|
934 | 934 | } |
935 | 935 | |
936 | - $meta_keys = array_merge( $meta_keys, $meta_key ); |
|
936 | + $meta_keys = array_merge($meta_keys, $meta_key); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | return $meta_keys; |
@@ -950,10 +950,10 @@ discard block |
||
950 | 950 | * |
951 | 951 | * @return string |
952 | 952 | */ |
953 | - function get_field_type( $field_id, $group_id = '' ) { |
|
954 | - $field = $this->get_setting_field( $field_id, $group_id ); |
|
953 | + function get_field_type($field_id, $group_id = '') { |
|
954 | + $field = $this->get_setting_field($field_id, $group_id); |
|
955 | 955 | |
956 | - $type = array_key_exists( 'type', $field ) |
|
956 | + $type = array_key_exists('type', $field) |
|
957 | 957 | ? $field['type'] |
958 | 958 | : ''; |
959 | 959 | |
@@ -971,12 +971,12 @@ discard block |
||
971 | 971 | * |
972 | 972 | * @return array |
973 | 973 | */ |
974 | - private function get_field( $setting, $field_id ) { |
|
974 | + private function get_field($setting, $field_id) { |
|
975 | 975 | $setting_field = array(); |
976 | 976 | |
977 | - if ( ! empty( $setting['fields'] ) ) { |
|
978 | - foreach ( $setting['fields'] as $field ) { |
|
979 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) { |
|
977 | + if ( ! empty($setting['fields'])) { |
|
978 | + foreach ($setting['fields'] as $field) { |
|
979 | + if (array_key_exists('id', $field) && $field['id'] === $field_id) { |
|
980 | 980 | $setting_field = $field; |
981 | 981 | break; |
982 | 982 | } |
@@ -996,12 +996,12 @@ discard block |
||
996 | 996 | * |
997 | 997 | * @return array |
998 | 998 | */ |
999 | - private function get_sub_field( $setting, $field_id ) { |
|
999 | + private function get_sub_field($setting, $field_id) { |
|
1000 | 1000 | $setting_field = array(); |
1001 | 1001 | |
1002 | - if ( ! empty( $setting['sub-fields'] ) ) { |
|
1003 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
1004 | - if ( $field = $this->get_field( $fields, $field_id ) ) { |
|
1002 | + if ( ! empty($setting['sub-fields'])) { |
|
1003 | + foreach ($setting['sub-fields'] as $fields) { |
|
1004 | + if ($field = $this->get_field($fields, $field_id)) { |
|
1005 | 1005 | $setting_field = $field; |
1006 | 1006 | break; |
1007 | 1007 | } |
@@ -1021,17 +1021,17 @@ discard block |
||
1021 | 1021 | * |
1022 | 1022 | * @return array |
1023 | 1023 | */ |
1024 | - function get_setting_field( $field_id, $group_id = '' ) { |
|
1024 | + function get_setting_field($field_id, $group_id = '') { |
|
1025 | 1025 | $setting_field = array(); |
1026 | 1026 | |
1027 | 1027 | $_field_id = $field_id; |
1028 | - $field_id = empty( $group_id ) ? $field_id : $group_id; |
|
1028 | + $field_id = empty($group_id) ? $field_id : $group_id; |
|
1029 | 1029 | |
1030 | - if ( ! empty( $this->settings ) ) { |
|
1031 | - foreach ( $this->settings as $setting ) { |
|
1030 | + if ( ! empty($this->settings)) { |
|
1031 | + foreach ($this->settings as $setting) { |
|
1032 | 1032 | if ( |
1033 | - ( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) ) |
|
1034 | - || ( $setting_field = $this->get_field( $setting, $field_id ) ) |
|
1033 | + ($this->has_sub_tab($setting) && ($setting_field = $this->get_sub_field($setting, $field_id))) |
|
1034 | + || ($setting_field = $this->get_field($setting, $field_id)) |
|
1035 | 1035 | ) { |
1036 | 1036 | break; |
1037 | 1037 | } |
@@ -1040,9 +1040,9 @@ discard block |
||
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | // Get field from group. |
1043 | - if ( ! empty( $group_id ) ) { |
|
1044 | - foreach ( $setting_field['fields'] as $field ) { |
|
1045 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) { |
|
1043 | + if ( ! empty($group_id)) { |
|
1044 | + foreach ($setting_field['fields'] as $field) { |
|
1045 | + if (array_key_exists('id', $field) && $field['id'] === $_field_id) { |
|
1046 | 1046 | $setting_field = $field; |
1047 | 1047 | } |
1048 | 1048 | } |
@@ -1061,13 +1061,13 @@ discard block |
||
1061 | 1061 | * |
1062 | 1062 | * @return mixed |
1063 | 1063 | */ |
1064 | - function add_offline_donations_setting_tab( $settings ) { |
|
1065 | - if ( give_is_gateway_active( 'offline' ) ) { |
|
1066 | - $settings['offline_donations_options'] = apply_filters( 'give_forms_offline_donations_options', array( |
|
1064 | + function add_offline_donations_setting_tab($settings) { |
|
1065 | + if (give_is_gateway_active('offline')) { |
|
1066 | + $settings['offline_donations_options'] = apply_filters('give_forms_offline_donations_options', array( |
|
1067 | 1067 | 'id' => 'offline_donations_options', |
1068 | - 'title' => esc_html__( 'Offline Donations', 'give' ), |
|
1069 | - 'fields' => apply_filters( 'give_forms_offline_donations_metabox_fields', array() ), |
|
1070 | - ) ); |
|
1068 | + 'title' => esc_html__('Offline Donations', 'give'), |
|
1069 | + 'fields' => apply_filters('give_forms_offline_donations_metabox_fields', array()), |
|
1070 | + )); |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | return $settings; |
@@ -663,11 +663,14 @@ |
||
663 | 663 | </div> |
664 | 664 | |
665 | 665 | <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
666 | - <?php else: ?> |
|
666 | + <?php else { |
|
667 | + : ?> |
|
667 | 668 | <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
668 | 669 | <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
669 | 670 | <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
670 | - <div id="<?php echo $sub_fields['id']; ?>" |
|
671 | + <div id="<?php echo $sub_fields['id']; |
|
672 | +} |
|
673 | +?>" |
|
671 | 674 | class="panel give_options_panel give-hidden"> |
672 | 675 | <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
673 | 676 | <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
@@ -2,13 +2,13 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Admin View: Settings |
4 | 4 | */ |
5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
5 | +if ( ! defined('ABSPATH')) { |
|
6 | 6 | exit; |
7 | 7 | } |
8 | 8 | |
9 | 9 | |
10 | 10 | // Bailout: Do not output anything if setting tab is not defined. |
11 | -if( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) : |
|
11 | +if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) : |
|
12 | 12 | /** |
13 | 13 | * Filter the form action. |
14 | 14 | * |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @since 1.8 |
20 | 20 | */ |
21 | - $form_method = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' ); |
|
21 | + $form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post'); |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Filter the main form tab. |
@@ -30,15 +30,15 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.8 |
32 | 32 | */ |
33 | - $form_open_tag = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method . '" id="give-mainform" action="" enctype="multipart/form-data">' ); |
|
34 | - $form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' ); |
|
33 | + $form_open_tag = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">'); |
|
34 | + $form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>'); |
|
35 | 35 | ?> |
36 | - <div class="wrap give-settings-page <?php echo self::$setting_filter_prefix . '-setting-page'; ?>"> |
|
36 | + <div class="wrap give-settings-page <?php echo self::$setting_filter_prefix.'-setting-page'; ?>"> |
|
37 | 37 | <?php echo $form_open_tag; ?> |
38 | 38 | <h2 class="nav-tab-wrapper give-nav-tab-wrapper"> |
39 | 39 | <?php |
40 | - foreach ( $tabs as $name => $label ) { |
|
41 | - echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>'; |
|
40 | + foreach ($tabs as $name => $label) { |
|
41 | + echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab == $name ? 'nav-tab-active' : '').'">'.$label.'</a>'; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @since 1.8 |
52 | 52 | */ |
53 | - do_action( self::$setting_filter_prefix . '_tabs' ); |
|
53 | + do_action(self::$setting_filter_prefix.'_tabs'); |
|
54 | 54 | ?> |
55 | 55 | </h2> |
56 | 56 | <div class="give-sub-nav-tab-wrapper"> |
57 | - <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e( 'View remaining setting tabs', 'give' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span></a> |
|
57 | + <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e('View remaining setting tabs', 'give'); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span></a> |
|
58 | 58 | <nav class="give-sub-nav-tab give-hidden"></nav> |
59 | 59 | </div> |
60 | - <h1 class="screen-reader-text"><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1> |
|
60 | + <h1 class="screen-reader-text"><?php echo esc_html($tabs[$current_tab]); ?></h1> |
|
61 | 61 | <?php |
62 | 62 | |
63 | 63 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @since 1.8 |
71 | 71 | */ |
72 | - do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" ); |
|
72 | + do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page"); |
|
73 | 73 | |
74 | 74 | |
75 | 75 | // Show messages. |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @since 1.8 |
87 | 87 | */ |
88 | - do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" ); |
|
88 | + do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page"); |
|
89 | 89 | |
90 | - if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?> |
|
90 | + if (empty($GLOBALS['give_hide_save_button'])) : ?> |
|
91 | 91 | <div class="give-submit-wrap"> |
92 | - <?php wp_nonce_field( 'give-save-settings', '_give-save-settings' ); ?> |
|
93 | - <input name="save" class="button-primary give-save-button" type="submit" value="<?php esc_attr_e( 'Save changes', 'give' ); ?>" /> |
|
92 | + <?php wp_nonce_field('give-save-settings', '_give-save-settings'); ?> |
|
93 | + <input name="save" class="button-primary give-save-button" type="submit" value="<?php esc_attr_e('Save changes', 'give'); ?>" /> |
|
94 | 94 | </div> |
95 | 95 | <?php endif; ?> |
96 | 96 | <?php echo $form_close_tag; ?> |
97 | 97 | </div> |
98 | - <?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
98 | + <?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?> |
|
99 | 99 | <?php endif; ?> |
100 | 100 | \ No newline at end of file |
@@ -95,5 +95,8 @@ |
||
95 | 95 | <?php endif; ?> |
96 | 96 | <?php echo $form_close_tag; ?> |
97 | 97 | </div> |
98 | - <?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
98 | + <?php else { |
|
99 | + : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; |
|
100 | +} |
|
101 | +?> |
|
99 | 102 | <?php endif; ?> |
100 | 103 | \ No newline at end of file |
@@ -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 | |
@@ -33,17 +33,17 @@ discard block |
||
33 | 33 | global $give_settings_page, $give_payments_page, $give_reports_page, $give_add_ons_page, $give_upgrades_screen, $give_donors_page, $give_tools_page; |
34 | 34 | |
35 | 35 | //Payments |
36 | - $give_payment = get_post_type_object( 'give_payment' ); |
|
37 | - $give_payments_page = add_submenu_page( 'edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page' ); |
|
36 | + $give_payment = get_post_type_object('give_payment'); |
|
37 | + $give_payments_page = add_submenu_page('edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page'); |
|
38 | 38 | |
39 | 39 | //Donors |
40 | - $give_donors_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Donors', 'give' ), esc_html__( 'Donors', 'give' ), 'view_give_reports', 'give-donors', 'give_customers_page' ); |
|
40 | + $give_donors_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Donors', 'give'), esc_html__('Donors', 'give'), 'view_give_reports', 'give-donors', 'give_customers_page'); |
|
41 | 41 | |
42 | 42 | //Reports` |
43 | 43 | $give_reports_page = add_submenu_page( |
44 | 44 | 'edit.php?post_type=give_forms', |
45 | - esc_html__( 'Donation Reports', 'give' ), |
|
46 | - esc_html__( 'Reports', 'give' ), |
|
45 | + esc_html__('Donation Reports', 'give'), |
|
46 | + esc_html__('Reports', 'give'), |
|
47 | 47 | 'view_give_reports', |
48 | 48 | 'give-reports', |
49 | 49 | array( |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | //Settings |
56 | 56 | $give_settings_page = add_submenu_page( |
57 | 57 | 'edit.php?post_type=give_forms', |
58 | - esc_html__( 'Give Settings', 'give' ), |
|
59 | - esc_html__( 'Settings', 'give' ), |
|
58 | + esc_html__('Give Settings', 'give'), |
|
59 | + esc_html__('Settings', 'give'), |
|
60 | 60 | 'manage_give_settings', |
61 | 61 | 'give-settings', |
62 | 62 | array( |
@@ -66,21 +66,21 @@ discard block |
||
66 | 66 | ); |
67 | 67 | |
68 | 68 | //Tools. |
69 | - $give_tools_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Tools', 'give' ), esc_html__( 'Tools', 'give' ), 'manage_give_settings', 'give-tools', array( |
|
69 | + $give_tools_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Tools', 'give'), esc_html__('Tools', 'give'), 'manage_give_settings', 'give-tools', array( |
|
70 | 70 | Give()->give_settings, |
71 | 71 | 'output' |
72 | - ) ); |
|
72 | + )); |
|
73 | 73 | |
74 | 74 | //Add-ons |
75 | - $give_add_ons_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Add-ons', 'give' ), esc_html__( 'Add-ons', 'give' ), 'install_plugins', 'give-addons', 'give_add_ons_page' ); |
|
75 | + $give_add_ons_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Add-ons', 'give'), esc_html__('Add-ons', 'give'), 'install_plugins', 'give-addons', 'give_add_ons_page'); |
|
76 | 76 | |
77 | 77 | //Upgrades |
78 | - $give_upgrades_screen = add_submenu_page( null, esc_html__( 'Give Upgrades', 'give' ), esc_html__( 'Give Upgrades', 'give' ), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen' ); |
|
78 | + $give_upgrades_screen = add_submenu_page(null, esc_html__('Give Upgrades', 'give'), esc_html__('Give Upgrades', 'give'), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen'); |
|
79 | 79 | |
80 | 80 | |
81 | 81 | } |
82 | 82 | |
83 | -add_action( 'admin_menu', 'give_add_options_links', 10 ); |
|
83 | +add_action('admin_menu', 'give_add_options_links', 10); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Determines whether the current admin page is a Give admin page. |
@@ -95,224 +95,224 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return bool True if Give admin page. |
97 | 97 | */ |
98 | -function give_is_admin_page( $passed_page = '', $passed_view = '' ) { |
|
98 | +function give_is_admin_page($passed_page = '', $passed_view = '') { |
|
99 | 99 | |
100 | 100 | global $pagenow, $typenow; |
101 | 101 | |
102 | 102 | $found = false; |
103 | - $post_type = isset( $_GET['post_type'] ) ? strtolower( $_GET['post_type'] ) : false; |
|
104 | - $action = isset( $_GET['action'] ) ? strtolower( $_GET['action'] ) : false; |
|
105 | - $taxonomy = isset( $_GET['taxonomy'] ) ? strtolower( $_GET['taxonomy'] ) : false; |
|
106 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
107 | - $view = isset( $_GET['view'] ) ? strtolower( $_GET['view'] ) : false; |
|
108 | - $tab = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : false; |
|
109 | - |
|
110 | - switch ( $passed_page ) { |
|
103 | + $post_type = isset($_GET['post_type']) ? strtolower($_GET['post_type']) : false; |
|
104 | + $action = isset($_GET['action']) ? strtolower($_GET['action']) : false; |
|
105 | + $taxonomy = isset($_GET['taxonomy']) ? strtolower($_GET['taxonomy']) : false; |
|
106 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
107 | + $view = isset($_GET['view']) ? strtolower($_GET['view']) : false; |
|
108 | + $tab = isset($_GET['tab']) ? strtolower($_GET['tab']) : false; |
|
109 | + |
|
110 | + switch ($passed_page) { |
|
111 | 111 | case 'give_forms': |
112 | - switch ( $passed_view ) { |
|
112 | + switch ($passed_view) { |
|
113 | 113 | case 'list-table': |
114 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' ) { |
|
114 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php') { |
|
115 | 115 | $found = true; |
116 | 116 | } |
117 | 117 | break; |
118 | 118 | case 'edit': |
119 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post.php' ) { |
|
119 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post.php') { |
|
120 | 120 | $found = true; |
121 | 121 | } |
122 | 122 | break; |
123 | 123 | case 'new': |
124 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post-new.php' ) { |
|
124 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post-new.php') { |
|
125 | 125 | $found = true; |
126 | 126 | } |
127 | 127 | break; |
128 | 128 | default: |
129 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) || 'give_forms' === $post_type || ( 'post-new.php' == $pagenow && 'give_forms' === $post_type ) ) { |
|
129 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) || 'give_forms' === $post_type || ('post-new.php' == $pagenow && 'give_forms' === $post_type)) { |
|
130 | 130 | $found = true; |
131 | 131 | } |
132 | 132 | break; |
133 | 133 | } |
134 | 134 | break; |
135 | 135 | case 'categories': |
136 | - switch ( $passed_view ) { |
|
136 | + switch ($passed_view) { |
|
137 | 137 | case 'list-table': |
138 | 138 | case 'new': |
139 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy ) { |
|
139 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy) { |
|
140 | 140 | $found = true; |
141 | 141 | } |
142 | 142 | break; |
143 | 143 | case 'edit': |
144 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy ) { |
|
144 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy) { |
|
145 | 145 | $found = true; |
146 | 146 | } |
147 | 147 | break; |
148 | 148 | default: |
149 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy ) { |
|
149 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy) { |
|
150 | 150 | $found = true; |
151 | 151 | } |
152 | 152 | break; |
153 | 153 | } |
154 | 154 | break; |
155 | 155 | case 'tags': |
156 | - switch ( $passed_view ) { |
|
156 | + switch ($passed_view) { |
|
157 | 157 | case 'list-table': |
158 | 158 | case 'new': |
159 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy ) { |
|
159 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy) { |
|
160 | 160 | $found = true; |
161 | 161 | } |
162 | 162 | break; |
163 | 163 | case 'edit': |
164 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy ) { |
|
164 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy) { |
|
165 | 165 | $found = true; |
166 | 166 | } |
167 | 167 | break; |
168 | 168 | default: |
169 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy ) { |
|
169 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy) { |
|
170 | 170 | $found = true; |
171 | 171 | } |
172 | 172 | break; |
173 | 173 | } |
174 | 174 | break; |
175 | 175 | case 'payments': |
176 | - switch ( $passed_view ) { |
|
176 | + switch ($passed_view) { |
|
177 | 177 | case 'list-table': |
178 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view ) { |
|
178 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view) { |
|
179 | 179 | $found = true; |
180 | 180 | } |
181 | 181 | break; |
182 | 182 | case 'edit': |
183 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view ) { |
|
183 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view) { |
|
184 | 184 | $found = true; |
185 | 185 | } |
186 | 186 | break; |
187 | 187 | default: |
188 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page ) { |
|
188 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page) { |
|
189 | 189 | $found = true; |
190 | 190 | } |
191 | 191 | break; |
192 | 192 | } |
193 | 193 | break; |
194 | 194 | case 'reports': |
195 | - switch ( $passed_view ) { |
|
195 | + switch ($passed_view) { |
|
196 | 196 | // If you want to do something like enqueue a script on a particular report's duration, look at $_GET[ 'range' ] |
197 | 197 | case 'earnings': |
198 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) { |
|
198 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && ('earnings' === $view || '-1' === $view || false === $view)) { |
|
199 | 199 | $found = true; |
200 | 200 | } |
201 | 201 | break; |
202 | 202 | case 'donors': |
203 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view ) { |
|
203 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view) { |
|
204 | 204 | $found = true; |
205 | 205 | } |
206 | 206 | break; |
207 | 207 | case 'gateways': |
208 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view ) { |
|
208 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view) { |
|
209 | 209 | $found = true; |
210 | 210 | } |
211 | 211 | break; |
212 | 212 | case 'export': |
213 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view ) { |
|
213 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view) { |
|
214 | 214 | $found = true; |
215 | 215 | } |
216 | 216 | break; |
217 | 217 | case 'logs': |
218 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view ) { |
|
218 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view) { |
|
219 | 219 | $found = true; |
220 | 220 | } |
221 | 221 | break; |
222 | 222 | default: |
223 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) { |
|
223 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) { |
|
224 | 224 | $found = true; |
225 | 225 | } |
226 | 226 | break; |
227 | 227 | } |
228 | 228 | break; |
229 | 229 | case 'settings': |
230 | - switch ( $passed_view ) { |
|
230 | + switch ($passed_view) { |
|
231 | 231 | case 'general': |
232 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && ( 'general' === $tab || false === $tab ) ) { |
|
232 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && ('general' === $tab || false === $tab)) { |
|
233 | 233 | $found = true; |
234 | 234 | } |
235 | 235 | break; |
236 | 236 | case 'gateways': |
237 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab ) { |
|
237 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab) { |
|
238 | 238 | $found = true; |
239 | 239 | } |
240 | 240 | break; |
241 | 241 | case 'emails': |
242 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab ) { |
|
242 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab) { |
|
243 | 243 | $found = true; |
244 | 244 | } |
245 | 245 | break; |
246 | 246 | case 'display': |
247 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab ) { |
|
247 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab) { |
|
248 | 248 | $found = true; |
249 | 249 | } |
250 | 250 | break; |
251 | 251 | case 'licenses': |
252 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab ) { |
|
252 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab) { |
|
253 | 253 | $found = true; |
254 | 254 | } |
255 | 255 | break; |
256 | 256 | case 'api': |
257 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab ) { |
|
257 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab) { |
|
258 | 258 | $found = true; |
259 | 259 | } |
260 | 260 | break; |
261 | 261 | case 'advanced': |
262 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab ) { |
|
262 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab) { |
|
263 | 263 | $found = true; |
264 | 264 | } |
265 | 265 | break; |
266 | 266 | case 'system_info': |
267 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab ) { |
|
267 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab) { |
|
268 | 268 | $found = true; |
269 | 269 | } |
270 | 270 | break; |
271 | 271 | default: |
272 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page ) { |
|
272 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page) { |
|
273 | 273 | $found = true; |
274 | 274 | } |
275 | 275 | break; |
276 | 276 | } |
277 | 277 | break; |
278 | 278 | case 'addons': |
279 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-addons' === $page ) { |
|
279 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-addons' === $page) { |
|
280 | 280 | $found = true; |
281 | 281 | } |
282 | 282 | break; |
283 | 283 | case 'donors': |
284 | - switch ( $passed_view ) { |
|
284 | + switch ($passed_view) { |
|
285 | 285 | case 'list-table': |
286 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view ) { |
|
286 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view) { |
|
287 | 287 | $found = true; |
288 | 288 | } |
289 | 289 | break; |
290 | 290 | case 'overview': |
291 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view ) { |
|
291 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view) { |
|
292 | 292 | $found = true; |
293 | 293 | } |
294 | 294 | break; |
295 | 295 | case 'notes': |
296 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view ) { |
|
296 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view) { |
|
297 | 297 | $found = true; |
298 | 298 | } |
299 | 299 | break; |
300 | 300 | default: |
301 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page ) { |
|
301 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page) { |
|
302 | 302 | $found = true; |
303 | 303 | } |
304 | 304 | break; |
305 | 305 | } |
306 | 306 | break; |
307 | 307 | case 'reports': |
308 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) { |
|
308 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) { |
|
309 | 309 | $found = true; |
310 | 310 | } |
311 | 311 | break; |
312 | 312 | default: |
313 | 313 | global $give_payments_page, $give_settings_page, $give_reports_page, $give_system_info_page, $give_add_ons_page, $give_settings_export, $give_upgrades_screen, $give_customers_page, $give_tools_page; |
314 | 314 | |
315 | - $admin_pages = apply_filters( 'give_admin_pages', array( |
|
315 | + $admin_pages = apply_filters('give_admin_pages', array( |
|
316 | 316 | $give_payments_page, |
317 | 317 | $give_settings_page, |
318 | 318 | $give_reports_page, |
@@ -323,19 +323,19 @@ discard block |
||
323 | 323 | $give_customers_page, |
324 | 324 | $give_tools_page, |
325 | 325 | 'widgets.php' |
326 | - ) ); |
|
327 | - if ( 'give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow ) { |
|
326 | + )); |
|
327 | + if ('give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow) { |
|
328 | 328 | $found = true; |
329 | - if ( 'give-upgrades' === $page ) { |
|
329 | + if ('give-upgrades' === $page) { |
|
330 | 330 | $found = false; |
331 | 331 | } |
332 | - } elseif ( in_array( $pagenow, $admin_pages ) ) { |
|
332 | + } elseif (in_array($pagenow, $admin_pages)) { |
|
333 | 333 | $found = true; |
334 | 334 | } |
335 | 335 | break; |
336 | 336 | } |
337 | 337 | |
338 | - return (bool) apply_filters( 'give_is_admin_page', $found, $page, $view, $passed_page, $passed_view ); |
|
338 | + return (bool) apply_filters('give_is_admin_page', $found, $page, $view, $passed_page, $passed_view); |
|
339 | 339 | |
340 | 340 | } |
341 | 341 | |
@@ -347,37 +347,37 @@ discard block |
||
347 | 347 | * @param array $settings |
348 | 348 | * @return array |
349 | 349 | */ |
350 | -function give_settings_page_pages( $settings ) { |
|
351 | - include( 'abstract-admin-settings-page.php' ); |
|
352 | - include( 'settings/class-settings-cmb2-backward-compatibility.php' ); |
|
350 | +function give_settings_page_pages($settings) { |
|
351 | + include('abstract-admin-settings-page.php'); |
|
352 | + include('settings/class-settings-cmb2-backward-compatibility.php'); |
|
353 | 353 | |
354 | 354 | $settings = array( |
355 | 355 | // General settings. |
356 | - include( 'settings/class-settings-general.php' ), |
|
356 | + include('settings/class-settings-general.php'), |
|
357 | 357 | |
358 | 358 | // Payment Gateways Settings. |
359 | - include( 'settings/class-settings-gateways.php' ), |
|
359 | + include('settings/class-settings-gateways.php'), |
|
360 | 360 | |
361 | 361 | // Display settings. |
362 | - include( 'settings/class-settings-display.php' ), |
|
362 | + include('settings/class-settings-display.php'), |
|
363 | 363 | |
364 | 364 | // Emails settings. |
365 | - include( 'settings/class-settings-email.php' ), |
|
365 | + include('settings/class-settings-email.php'), |
|
366 | 366 | |
367 | 367 | // Addons settings. |
368 | - include( 'settings/class-settings-addon.php' ), |
|
368 | + include('settings/class-settings-addon.php'), |
|
369 | 369 | |
370 | 370 | // License settings. |
371 | - include( 'settings/class-settings-license.php' ), |
|
371 | + include('settings/class-settings-license.php'), |
|
372 | 372 | |
373 | 373 | // Advanced settinns. |
374 | - include( 'settings/class-settings-advanced.php' ) |
|
374 | + include('settings/class-settings-advanced.php') |
|
375 | 375 | ); |
376 | 376 | |
377 | 377 | // Output. |
378 | 378 | return $settings; |
379 | 379 | } |
380 | -add_filter( 'give-settings_get_settings_pages', 'give_settings_page_pages', 0, 1 ); |
|
380 | +add_filter('give-settings_get_settings_pages', 'give_settings_page_pages', 0, 1); |
|
381 | 381 | |
382 | 382 | |
383 | 383 | /** |
@@ -387,30 +387,30 @@ discard block |
||
387 | 387 | * @param array $settings |
388 | 388 | * @return array |
389 | 389 | */ |
390 | -function give_reports_page_pages( $settings ) { |
|
391 | - include( 'abstract-admin-settings-page.php' ); |
|
390 | +function give_reports_page_pages($settings) { |
|
391 | + include('abstract-admin-settings-page.php'); |
|
392 | 392 | |
393 | 393 | $settings = array( |
394 | 394 | // Earnings. |
395 | - include( 'reporting/class-settings-earnings.php' ), |
|
395 | + include('reporting/class-settings-earnings.php'), |
|
396 | 396 | |
397 | 397 | // Forms. |
398 | - include( 'reporting/class-settings-forms.php' ), |
|
398 | + include('reporting/class-settings-forms.php'), |
|
399 | 399 | |
400 | 400 | // Donors. |
401 | - include( 'reporting/class-settings-donors.php' ), |
|
401 | + include('reporting/class-settings-donors.php'), |
|
402 | 402 | |
403 | 403 | // Gateways. |
404 | - include( 'reporting/class-settings-gateways.php' ), |
|
404 | + include('reporting/class-settings-gateways.php'), |
|
405 | 405 | |
406 | 406 | // Export. |
407 | - include( 'reporting/class-settings-export.php' ), |
|
407 | + include('reporting/class-settings-export.php'), |
|
408 | 408 | ); |
409 | 409 | |
410 | 410 | // Output. |
411 | 411 | return $settings; |
412 | 412 | } |
413 | -add_filter( 'give-reports_get_settings_pages', 'give_reports_page_pages', 0, 1 ); |
|
413 | +add_filter('give-reports_get_settings_pages', 'give_reports_page_pages', 0, 1); |
|
414 | 414 | |
415 | 415 | /** |
416 | 416 | * Add setting tab to give-settings page |
@@ -419,27 +419,27 @@ discard block |
||
419 | 419 | * @param array $settings |
420 | 420 | * @return array |
421 | 421 | */ |
422 | -function give_tools_page_pages( $settings ) { |
|
423 | - include( 'abstract-admin-settings-page.php' ); |
|
422 | +function give_tools_page_pages($settings) { |
|
423 | + include('abstract-admin-settings-page.php'); |
|
424 | 424 | |
425 | 425 | $settings = array( |
426 | 426 | // System Info. |
427 | - include( 'tools/class-settings-system-info.php' ), |
|
427 | + include('tools/class-settings-system-info.php'), |
|
428 | 428 | |
429 | 429 | // Logs. |
430 | - include( 'tools/class-settings-logs.php' ), |
|
430 | + include('tools/class-settings-logs.php'), |
|
431 | 431 | |
432 | 432 | // API. |
433 | - include( 'tools/class-settings-api.php' ), |
|
433 | + include('tools/class-settings-api.php'), |
|
434 | 434 | |
435 | 435 | // Data. |
436 | - include( 'tools/class-settings-data.php' ), |
|
436 | + include('tools/class-settings-data.php'), |
|
437 | 437 | ); |
438 | 438 | |
439 | 439 | // Output. |
440 | 440 | return $settings; |
441 | 441 | } |
442 | -add_filter( 'give-tools_get_settings_pages', 'give_tools_page_pages', 0, 1 ); |
|
442 | +add_filter('give-tools_get_settings_pages', 'give_tools_page_pages', 0, 1); |
|
443 | 443 | |
444 | 444 | /** |
445 | 445 | * Set default tools page tab. |
@@ -448,10 +448,10 @@ discard block |
||
448 | 448 | * @param string $default_tab Default tab name. |
449 | 449 | * @return string |
450 | 450 | */ |
451 | -function give_set_default_tab_form_tools_page( $default_tab ) { |
|
451 | +function give_set_default_tab_form_tools_page($default_tab) { |
|
452 | 452 | return 'system-info'; |
453 | 453 | } |
454 | -add_filter( 'give_default_setting_tab_give-tools', 'give_set_default_tab_form_tools_page', 10, 1 ); |
|
454 | +add_filter('give_default_setting_tab_give-tools', 'give_set_default_tab_form_tools_page', 10, 1); |
|
455 | 455 | |
456 | 456 | |
457 | 457 | /** |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | * @param string $default_tab Default tab name. |
462 | 462 | * @return string |
463 | 463 | */ |
464 | -function give_set_default_tab_form_reports_page( $default_tab ) { |
|
464 | +function give_set_default_tab_form_reports_page($default_tab) { |
|
465 | 465 | return 'earnings'; |
466 | 466 | } |
467 | -add_filter( 'give_default_setting_tab_give-reports', 'give_set_default_tab_form_reports_page', 10, 1 ); |
|
468 | 467 | \ No newline at end of file |
468 | +add_filter('give_default_setting_tab_give-reports', 'give_set_default_tab_form_reports_page', 10, 1); |
|
469 | 469 | \ No newline at end of file |
@@ -87,13 +87,13 @@ |
||
87 | 87 | 'disabled' => __( 'Head', 'give' ), |
88 | 88 | ) |
89 | 89 | ), |
90 | - array( |
|
91 | - 'name' => esc_html__( 'Advanced Settings Docs Link', 'give' ), |
|
92 | - 'id' => 'advanced_settings_docs_link', |
|
93 | - 'url' => esc_url( 'http://docs.givewp.com/settings-advanced' ), |
|
94 | - 'title' => __( 'Advanced Settings', 'give' ), |
|
95 | - 'type' => 'give_docs_link', |
|
96 | - ), |
|
90 | + array( |
|
91 | + 'name' => esc_html__( 'Advanced Settings Docs Link', 'give' ), |
|
92 | + 'id' => 'advanced_settings_docs_link', |
|
93 | + 'url' => esc_url( 'http://docs.givewp.com/settings-advanced' ), |
|
94 | + 'title' => __( 'Advanced Settings', 'give' ), |
|
95 | + 'type' => 'give_docs_link', |
|
96 | + ), |
|
97 | 97 | array( |
98 | 98 | 'id' => 'give_title_data_control_2', |
99 | 99 | 'type' => 'sectionend' |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Advanced' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Advanced')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Advanced. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'advanced'; |
30 | - $this->label = esc_html__( 'Advanced', 'give' ); |
|
30 | + $this->label = esc_html__('Advanced', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'advanced-options'; |
33 | 33 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $current_section = give_get_current_setting_section(); |
47 | 47 | |
48 | - switch ( $current_section ) { |
|
48 | + switch ($current_section) { |
|
49 | 49 | case 'advanced-options': |
50 | 50 | $settings = array( |
51 | 51 | array( |
@@ -53,45 +53,45 @@ discard block |
||
53 | 53 | 'type' => 'title' |
54 | 54 | ), |
55 | 55 | array( |
56 | - 'name' => esc_html__( 'Remove Data on Uninstall', 'give' ), |
|
57 | - 'desc' => esc_html__( 'When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give' ), |
|
56 | + 'name' => esc_html__('Remove Data on Uninstall', 'give'), |
|
57 | + 'desc' => esc_html__('When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give'), |
|
58 | 58 | 'id' => 'uninstall_on_delete', |
59 | 59 | 'type' => 'radio_inline', |
60 | 60 | 'default' => 'disabled', |
61 | 61 | 'options' => array( |
62 | - 'enabled' => __( 'Yes, Remove all data', 'give' ), |
|
63 | - 'disabled' => __( 'No, keep my Give settings and donation data this time', 'give' ), |
|
62 | + 'enabled' => __('Yes, Remove all data', 'give'), |
|
63 | + 'disabled' => __('No, keep my Give settings and donation data this time', 'give'), |
|
64 | 64 | ) |
65 | 65 | ), |
66 | 66 | array( |
67 | 67 | /* translators: %s: the_content */ |
68 | - 'name' => sprintf( __( '%s filter', 'give' ), '<code>the_content</code>' ), |
|
68 | + 'name' => sprintf(__('%s filter', 'give'), '<code>the_content</code>'), |
|
69 | 69 | /* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */ |
70 | - 'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ), |
|
70 | + 'desc' => sprintf(__('If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give'), esc_url('https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content'), '<code>the_content</code>'), |
|
71 | 71 | 'id' => 'the_content_filter', |
72 | 72 | 'default' => 'enabled', |
73 | 73 | 'type' => 'radio_inline', |
74 | 74 | 'options' => array( |
75 | - 'enabled' => __( 'Enabled', 'give' ), |
|
76 | - 'disabled' => __( 'Disabled', 'give' ), |
|
75 | + 'enabled' => __('Enabled', 'give'), |
|
76 | + 'disabled' => __('Disabled', 'give'), |
|
77 | 77 | ) |
78 | 78 | ), |
79 | 79 | array( |
80 | - 'name' => esc_html__( 'Script Loading Location', 'give' ), |
|
81 | - 'desc' => __( 'This allows you to load your Give scripts either in the <code><head></code> or footer of your website.', 'give' ), |
|
80 | + 'name' => esc_html__('Script Loading Location', 'give'), |
|
81 | + 'desc' => __('This allows you to load your Give scripts either in the <code><head></code> or footer of your website.', 'give'), |
|
82 | 82 | 'id' => 'scripts_footer', |
83 | 83 | 'type' => 'radio_inline', |
84 | 84 | 'default' => 'disabled', |
85 | 85 | 'options' => array( |
86 | - 'enabled' => __( 'Footer', 'give' ), |
|
87 | - 'disabled' => __( 'Head', 'give' ), |
|
86 | + 'enabled' => __('Footer', 'give'), |
|
87 | + 'disabled' => __('Head', 'give'), |
|
88 | 88 | ) |
89 | 89 | ), |
90 | 90 | array( |
91 | - 'name' => esc_html__( 'Advanced Settings Docs Link', 'give' ), |
|
91 | + 'name' => esc_html__('Advanced Settings Docs Link', 'give'), |
|
92 | 92 | 'id' => 'advanced_settings_docs_link', |
93 | - 'url' => esc_url( 'http://docs.givewp.com/settings-advanced' ), |
|
94 | - 'title' => __( 'Advanced Settings', 'give' ), |
|
93 | + 'url' => esc_url('http://docs.givewp.com/settings-advanced'), |
|
94 | + 'title' => __('Advanced Settings', 'give'), |
|
95 | 95 | 'type' => 'give_docs_link', |
96 | 96 | ), |
97 | 97 | array( |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * Filter the advanced settings. |
108 | 108 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
109 | 109 | */ |
110 | - $settings = apply_filters( 'give_settings_advanced', $settings ); |
|
110 | + $settings = apply_filters('give_settings_advanced', $settings); |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * Filter the settings. |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @param array $settings |
118 | 118 | */ |
119 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
119 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
120 | 120 | |
121 | 121 | // Output. |
122 | 122 | return $settings; |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function get_sections() { |
132 | 132 | $sections = array( |
133 | - 'advanced-options' => esc_html__( 'Advanced Options', 'give' ) |
|
133 | + 'advanced-options' => esc_html__('Advanced Options', 'give') |
|
134 | 134 | ); |
135 | 135 | |
136 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
136 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 |
@@ -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 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return string $message Fully formatted message |
43 | 43 | */ |
44 | -function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) { |
|
45 | - return give_do_email_tags( $message, $payment_id ); |
|
44 | +function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) { |
|
45 | + return give_do_email_tags($message, $payment_id); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -56,42 +56,42 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return string $message Fully formatted message |
58 | 58 | */ |
59 | -function give_email_preview_template_tags( $message ) { |
|
59 | +function give_email_preview_template_tags($message) { |
|
60 | 60 | |
61 | - $price = give_currency_filter( give_format_amount( 10.50 ) ); |
|
61 | + $price = give_currency_filter(give_format_amount(10.50)); |
|
62 | 62 | |
63 | 63 | $gateway = 'PayPal'; |
64 | 64 | |
65 | - $receipt_id = strtolower( md5( uniqid() ) ); |
|
65 | + $receipt_id = strtolower(md5(uniqid())); |
|
66 | 66 | |
67 | - $payment_id = rand( 1, 100 ); |
|
67 | + $payment_id = rand(1, 100); |
|
68 | 68 | |
69 | - $receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) ); |
|
69 | + $receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url())); |
|
70 | 70 | $receipt_link = sprintf( |
71 | 71 | '<a href="%1$s">%2$s</a>', |
72 | 72 | $receipt_link_url, |
73 | - esc_html__( 'View the receipt in your browser »', 'give' ) |
|
73 | + esc_html__('View the receipt in your browser »', 'give') |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | $user = wp_get_current_user(); |
77 | 77 | |
78 | - $message = str_replace( '{name}', $user->display_name, $message ); |
|
79 | - $message = str_replace( '{fullname}', $user->display_name, $message ); |
|
80 | - $message = str_replace( '{username}', $user->user_login, $message ); |
|
81 | - $message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message ); |
|
82 | - $message = str_replace( '{amount}', $price, $message ); |
|
83 | - $message = str_replace( '{price}', $price, $message ); |
|
84 | - $message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message ); |
|
85 | - $message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message ); |
|
86 | - $message = str_replace( '{receipt_id}', $receipt_id, $message ); |
|
87 | - $message = str_replace( '{payment_method}', $gateway, $message ); |
|
88 | - $message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message ); |
|
89 | - $message = str_replace( '{payment_id}', $payment_id, $message ); |
|
90 | - $message = str_replace( '{receipt_link}', $receipt_link, $message ); |
|
91 | - $message = str_replace( '{receipt_link_url}', $receipt_link_url, $message ); |
|
92 | - $message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message ); |
|
93 | - |
|
94 | - return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) ); |
|
78 | + $message = str_replace('{name}', $user->display_name, $message); |
|
79 | + $message = str_replace('{fullname}', $user->display_name, $message); |
|
80 | + $message = str_replace('{username}', $user->user_login, $message); |
|
81 | + $message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message); |
|
82 | + $message = str_replace('{amount}', $price, $message); |
|
83 | + $message = str_replace('{price}', $price, $message); |
|
84 | + $message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message); |
|
85 | + $message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message); |
|
86 | + $message = str_replace('{receipt_id}', $receipt_id, $message); |
|
87 | + $message = str_replace('{payment_method}', $gateway, $message); |
|
88 | + $message = str_replace('{sitename}', get_bloginfo('name'), $message); |
|
89 | + $message = str_replace('{payment_id}', $payment_id, $message); |
|
90 | + $message = str_replace('{receipt_link}', $receipt_link, $message); |
|
91 | + $message = str_replace('{receipt_link_url}', $receipt_link_url, $message); |
|
92 | + $message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message); |
|
93 | + |
|
94 | + return wpautop(apply_filters('give_email_preview_template_tags', $message)); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -103,23 +103,23 @@ discard block |
||
103 | 103 | * @since 1.0 |
104 | 104 | * @return array|bool |
105 | 105 | */ |
106 | -function give_email_template_preview( $array ) { |
|
106 | +function give_email_template_preview($array) { |
|
107 | 107 | |
108 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
108 | + if ( ! current_user_can('manage_give_settings')) { |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | $custom_field = array( |
112 | - 'name' => esc_html__( 'Preview Email', 'give' ), |
|
113 | - 'desc' => esc_html__( 'Click the buttons to preview or send test emails.', 'give' ), |
|
112 | + 'name' => esc_html__('Preview Email', 'give'), |
|
113 | + 'desc' => esc_html__('Click the buttons to preview or send test emails.', 'give'), |
|
114 | 114 | 'id' => 'give_email_preview_buttons', |
115 | 115 | 'type' => 'email_preview_buttons' |
116 | 116 | ); |
117 | 117 | |
118 | - return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) ); |
|
118 | + return give_settings_array_insert($array, 'donation_subject', array($custom_field)); |
|
119 | 119 | |
120 | 120 | } |
121 | 121 | |
122 | -add_filter( 'give_settings_emails', 'give_email_template_preview' ); |
|
122 | +add_filter('give_settings_emails', 'give_email_template_preview'); |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * Output Email Template Preview Buttons. |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | function give_email_preview_buttons_callback() { |
132 | 132 | ob_start(); |
133 | 133 | ?> |
134 | - <a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" target="_blank"><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a> |
|
135 | - <a href="<?php echo wp_nonce_url( add_query_arg( array( |
|
134 | + <a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" target="_blank"><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a> |
|
135 | + <a href="<?php echo wp_nonce_url(add_query_arg(array( |
|
136 | 136 | 'give_action' => 'send_test_email', |
137 | 137 | 'give-message' => 'sent-test-email', |
138 | 138 | 'tag' => 'emails' |
139 | - ) ), 'give-test-email' ); ?>" aria-label="<?php esc_attr_e( 'Send demo donation receipt to the emails listed below.', 'give' ); ?>" class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a> |
|
139 | + )), 'give-test-email'); ?>" aria-label="<?php esc_attr_e('Send demo donation receipt to the emails listed below.', 'give'); ?>" class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a> |
|
140 | 140 | <?php |
141 | 141 | echo ob_get_clean(); |
142 | 142 | } |
@@ -149,46 +149,46 @@ discard block |
||
149 | 149 | */ |
150 | 150 | function give_display_email_template_preview() { |
151 | 151 | |
152 | - if ( empty( $_GET['give_action'] ) ) { |
|
152 | + if (empty($_GET['give_action'])) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | - if ( 'preview_email' !== $_GET['give_action'] ) { |
|
156 | + if ('preview_email' !== $_GET['give_action']) { |
|
157 | 157 | return; |
158 | 158 | } |
159 | 159 | |
160 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
160 | + if ( ! current_user_can('manage_give_settings')) { |
|
161 | 161 | return; |
162 | 162 | } |
163 | 163 | |
164 | 164 | |
165 | - Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' ); |
|
165 | + Give()->emails->heading = esc_html__('Donation Receipt', 'give'); |
|
166 | 166 | |
167 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
167 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
168 | 168 | |
169 | 169 | echo give_get_preview_email_header(); |
170 | 170 | |
171 | 171 | //Are we previewing an actual payment? |
172 | - if ( ! empty( $payment_id ) ) { |
|
172 | + if ( ! empty($payment_id)) { |
|
173 | 173 | |
174 | - $content = give_get_email_body_content( $payment_id ); |
|
174 | + $content = give_get_email_body_content($payment_id); |
|
175 | 175 | |
176 | - $preview_content = give_do_email_tags( $content, $payment_id ); |
|
176 | + $preview_content = give_do_email_tags($content, $payment_id); |
|
177 | 177 | |
178 | 178 | } else { |
179 | 179 | |
180 | 180 | //No payment ID, use sample preview content |
181 | - $preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
181 | + $preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
185 | - echo Give()->emails->build_email( $preview_content ); |
|
185 | + echo Give()->emails->build_email($preview_content); |
|
186 | 186 | |
187 | 187 | exit; |
188 | 188 | |
189 | 189 | } |
190 | 190 | |
191 | -add_action( 'init', 'give_display_email_template_preview' ); |
|
191 | +add_action('init', 'give_display_email_template_preview'); |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * Email Template Body. |
@@ -200,18 +200,18 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return string $email_body Body of the email |
202 | 202 | */ |
203 | -function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) { |
|
203 | +function give_get_email_body_content($payment_id = 0, $payment_data = array()) { |
|
204 | 204 | |
205 | 205 | $default_email_body = give_get_default_donation_receipt_email(); |
206 | 206 | |
207 | - $email_content = give_get_option( 'donation_receipt' ); |
|
208 | - $email_content = isset( $email_content ) ? stripslashes( $email_content ) : $default_email_body; |
|
207 | + $email_content = give_get_option('donation_receipt'); |
|
208 | + $email_content = isset($email_content) ? stripslashes($email_content) : $default_email_body; |
|
209 | 209 | |
210 | - $email_body = wpautop( $email_content ); |
|
210 | + $email_body = wpautop($email_content); |
|
211 | 211 | |
212 | - $email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data ); |
|
212 | + $email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data); |
|
213 | 213 | |
214 | - return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data ); |
|
214 | + return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -224,36 +224,36 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return string $email_body Body of the email |
226 | 226 | */ |
227 | -function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) { |
|
227 | +function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) { |
|
228 | 228 | |
229 | - $user_info = maybe_unserialize( $payment_data['user_info'] ); |
|
230 | - $email = give_get_payment_user_email( $payment_id ); |
|
229 | + $user_info = maybe_unserialize($payment_data['user_info']); |
|
230 | + $email = give_get_payment_user_email($payment_id); |
|
231 | 231 | |
232 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
233 | - $user_data = get_userdata( $user_info['id'] ); |
|
232 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
233 | + $user_data = get_userdata($user_info['id']); |
|
234 | 234 | $name = $user_data->display_name; |
235 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
236 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
235 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
236 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
237 | 237 | } else { |
238 | 238 | $name = $email; |
239 | 239 | } |
240 | 240 | |
241 | - $gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) ); |
|
241 | + $gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true)); |
|
242 | 242 | |
243 | - $default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n"; |
|
244 | - $default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n"; |
|
245 | - $default_email_body .= esc_html__( 'Donation:', 'give' ) . "\n\n"; |
|
246 | - $default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
247 | - $default_email_body .= esc_html__( 'Amount:', 'give' ) . ' ' . html_entity_decode( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
248 | - $default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n"; |
|
249 | - $default_email_body .= esc_html__( 'Thank you', 'give' ); |
|
243 | + $default_email_body = esc_html__('Hello', 'give')."\n\n"; |
|
244 | + $default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n"; |
|
245 | + $default_email_body .= esc_html__('Donation:', 'give')."\n\n"; |
|
246 | + $default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n"; |
|
247 | + $default_email_body .= esc_html__('Amount:', 'give').' '.html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8')."\n"; |
|
248 | + $default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n"; |
|
249 | + $default_email_body .= esc_html__('Thank you', 'give'); |
|
250 | 250 | |
251 | - $email = give_get_option( 'donation_notification' ); |
|
252 | - $email = isset( $email ) ? stripslashes( $email ) : $default_email_body; |
|
251 | + $email = give_get_option('donation_notification'); |
|
252 | + $email = isset($email) ? stripslashes($email) : $default_email_body; |
|
253 | 253 | |
254 | - $email_body = give_do_email_tags( $email, $payment_id ); |
|
254 | + $email_body = give_do_email_tags($email, $payment_id); |
|
255 | 255 | |
256 | - return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data ); |
|
256 | + return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -266,19 +266,19 @@ discard block |
||
266 | 266 | * @since 1.0 |
267 | 267 | */ |
268 | 268 | function give_render_receipt_in_browser() { |
269 | - if ( ! isset( $_GET['payment_key'] ) ) { |
|
270 | - wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
269 | + if ( ! isset($_GET['payment_key'])) { |
|
270 | + wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
271 | 271 | } |
272 | 272 | |
273 | - $key = urlencode( $_GET['payment_key'] ); |
|
273 | + $key = urlencode($_GET['payment_key']); |
|
274 | 274 | |
275 | 275 | ob_start(); |
276 | 276 | //Disallows caching of the page |
277 | - header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" ); |
|
278 | - header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1 |
|
279 | - header( "Cache-Control: post-check=0, pre-check=0", false ); |
|
280 | - header( "Pragma: no-cache" ); // HTTP/1.0 |
|
281 | - header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past |
|
277 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
278 | + header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 |
|
279 | + header("Cache-Control: post-check=0, pre-check=0", false); |
|
280 | + header("Pragma: no-cache"); // HTTP/1.0 |
|
281 | + header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past |
|
282 | 282 | ?> |
283 | 283 | <!DOCTYPE html> |
284 | 284 | <html lang="en"> |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @since 1.0 |
291 | 291 | */ |
292 | - do_action( 'give_receipt_head' ); |
|
292 | + do_action('give_receipt_head'); |
|
293 | 293 | ?> |
294 | 294 | </head> |
295 | - <body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>"> |
|
295 | + <body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>"> |
|
296 | 296 | |
297 | 297 | <div id="give_receipt_wrapper"> |
298 | 298 | <?php |
@@ -301,16 +301,16 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @since 1.0 |
303 | 303 | */ |
304 | - do_action( 'give_render_receipt_in_browser_before' ); |
|
304 | + do_action('give_render_receipt_in_browser_before'); |
|
305 | 305 | |
306 | - echo do_shortcode( '[give_receipt payment_key=' . $key . ']' ); |
|
306 | + echo do_shortcode('[give_receipt payment_key='.$key.']'); |
|
307 | 307 | |
308 | 308 | /** |
309 | 309 | * Fires in the receipt template after the content. |
310 | 310 | * |
311 | 311 | * @since 1.0 |
312 | 312 | */ |
313 | - do_action( 'give_render_receipt_in_browser_after' ); |
|
313 | + do_action('give_render_receipt_in_browser_after'); |
|
314 | 314 | ?> |
315 | 315 | </div> |
316 | 316 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @since 1.0 |
322 | 322 | */ |
323 | - do_action( 'give_receipt_footer' ); |
|
323 | + do_action('give_receipt_footer'); |
|
324 | 324 | ?> |
325 | 325 | </body> |
326 | 326 | </html> |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | die(); |
330 | 330 | } |
331 | 331 | |
332 | -add_action( 'give_view_receipt', 'give_render_receipt_in_browser' ); |
|
332 | +add_action('give_view_receipt', 'give_render_receipt_in_browser'); |
|
333 | 333 | |
334 | 334 | |
335 | 335 | /** |
@@ -344,29 +344,29 @@ discard block |
||
344 | 344 | |
345 | 345 | //Payment receipt switcher |
346 | 346 | $payment_count = give_count_payments()->publish; |
347 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
347 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
348 | 348 | |
349 | - if ( $payment_count <= 0 ) { |
|
349 | + if ($payment_count <= 0) { |
|
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | |
353 | 353 | //Get payments. |
354 | - $payments = new Give_Payments_Query( array( |
|
354 | + $payments = new Give_Payments_Query(array( |
|
355 | 355 | 'number' => 100 |
356 | - ) ); |
|
356 | + )); |
|
357 | 357 | $payments = $payments->get_payments(); |
358 | 358 | $options = array(); |
359 | 359 | |
360 | 360 | //Provide nice human readable options. |
361 | - if ( $payments ) { |
|
362 | - $options[0] = esc_html__( '- Select a donation -', 'give' ); |
|
363 | - foreach ( $payments as $payment ) { |
|
361 | + if ($payments) { |
|
362 | + $options[0] = esc_html__('- Select a donation -', 'give'); |
|
363 | + foreach ($payments as $payment) { |
|
364 | 364 | |
365 | - $options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
365 | + $options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
366 | 366 | |
367 | 367 | } |
368 | 368 | } else { |
369 | - $options[0] = esc_html__( 'No donations found.', 'give' ); |
|
369 | + $options[0] = esc_html__('No donations found.', 'give'); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | //Start constructing HTML output. |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | var selected_trans = transactions.options[transactions.selectedIndex]; |
380 | 380 | console.log(selected_trans); |
381 | 381 | if (selected_trans){ |
382 | - var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value; |
|
382 | + var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value; |
|
383 | 383 | window.location = url_string; |
384 | 384 | } |
385 | 385 | } |
386 | 386 | </script>'; |
387 | 387 | |
388 | - $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>'; |
|
388 | + $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>'; |
|
389 | 389 | |
390 | 390 | //The select field with 100 latest transactions |
391 | - $transaction_header .= Give()->html->select( array( |
|
391 | + $transaction_header .= Give()->html->select(array( |
|
392 | 392 | 'name' => 'preview_email_payment_id', |
393 | 393 | 'selected' => $payment_id, |
394 | 394 | 'id' => 'give_preview_email_payment_id', |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | 'select_atts' => 'onchange="change_preview()">', |
399 | 399 | 'show_option_all' => false, |
400 | 400 | 'show_option_none' => false |
401 | - ) ); |
|
401 | + )); |
|
402 | 402 | |
403 | 403 | //Closing tag |
404 | 404 | $transaction_header .= '</div>'; |
405 | 405 | |
406 | - return apply_filters( 'give_preview_email_receipt_header', $transaction_header ); |
|
406 | + return apply_filters('give_preview_email_receipt_header', $transaction_header); |
|
407 | 407 | |
408 | 408 | } |
409 | 409 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | function give_receipt_head_content() { |
418 | 418 | |
419 | 419 | //Title. |
420 | - $output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>'; |
|
420 | + $output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>'; |
|
421 | 421 | |
422 | 422 | //Meta. |
423 | 423 | $output .= '<meta charset="utf-8"/> |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | <meta name="robots" content="noindex, nofollow"/>'; |
432 | 432 | |
433 | 433 | //CSS |
434 | - $output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">'; |
|
434 | + $output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">'; |
|
435 | 435 | |
436 | - echo apply_filters( 'give_receipt_head_content', $output ); |
|
436 | + echo apply_filters('give_receipt_head_content', $output); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | |
440 | -add_action( 'give_receipt_head', 'give_receipt_head_content' ); |
|
441 | 440 | \ No newline at end of file |
441 | +add_action('give_receipt_head', 'give_receipt_head_content'); |
|
442 | 442 | \ No newline at end of file |