@@ -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 | |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * @return void |
39 | 39 | */ |
40 | 40 | public function headers() { |
41 | - ignore_user_abort( true ); |
|
41 | + ignore_user_abort(true); |
|
42 | 42 | |
43 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
44 | - set_time_limit( 0 ); |
|
43 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
44 | + set_time_limit(0); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | nocache_headers(); |
48 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
49 | - header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_earnings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.csv' ); |
|
50 | - header( "Expires: 0" ); |
|
48 | + header('Content-Type: text/csv; charset=utf-8'); |
|
49 | + header('Content-Disposition: attachment; filename='.apply_filters('give_earnings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.csv'); |
|
50 | + header("Expires: 0"); |
|
51 | 51 | |
52 | 52 | } |
53 | 53 | |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | public function csv_cols() { |
62 | 62 | |
63 | 63 | $cols = array( |
64 | - 'date' => esc_html__( 'Date', 'give' ), |
|
65 | - 'donations' => esc_html__( 'Donations', 'give' ), |
|
64 | + 'date' => esc_html__('Date', 'give'), |
|
65 | + 'donations' => esc_html__('Donations', 'give'), |
|
66 | 66 | /* translators: %s: currency */ |
67 | - 'earnings' => sprintf( esc_html__( 'Income (%s)', 'give' ), html_entity_decode( give_currency_filter( '' ) ) ) |
|
67 | + 'earnings' => sprintf(esc_html__('Income (%s)', 'give'), html_entity_decode(give_currency_filter(''))) |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | return $cols; |
@@ -79,28 +79,28 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function get_data() { |
81 | 81 | |
82 | - $start_year = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' ); |
|
83 | - $end_year = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' ); |
|
84 | - $start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' ); |
|
85 | - $end_month = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' ); |
|
82 | + $start_year = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y'); |
|
83 | + $end_year = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y'); |
|
84 | + $start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n'); |
|
85 | + $end_month = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n'); |
|
86 | 86 | |
87 | 87 | $data = array(); |
88 | 88 | $year = $start_year; |
89 | 89 | $stats = new Give_Payment_Stats; |
90 | 90 | |
91 | - while ( $year <= $end_year ) { |
|
91 | + while ($year <= $end_year) { |
|
92 | 92 | |
93 | - if ( $year == $start_year && $year == $end_year ) { |
|
93 | + if ($year == $start_year && $year == $end_year) { |
|
94 | 94 | |
95 | 95 | $m1 = $start_month; |
96 | 96 | $m2 = $end_month; |
97 | 97 | |
98 | - } elseif ( $year == $start_year ) { |
|
98 | + } elseif ($year == $start_year) { |
|
99 | 99 | |
100 | 100 | $m1 = $start_month; |
101 | 101 | $m2 = 12; |
102 | 102 | |
103 | - } elseif ( $year == $end_year ) { |
|
103 | + } elseif ($year == $end_year) { |
|
104 | 104 | |
105 | 105 | $m1 = 1; |
106 | 106 | $m2 = $end_month; |
@@ -112,28 +112,28 @@ discard block |
||
112 | 112 | |
113 | 113 | } |
114 | 114 | |
115 | - while ( $m1 <= $m2 ) { |
|
115 | + while ($m1 <= $m2) { |
|
116 | 116 | |
117 | - $date1 = mktime( 0, 0, 0, $m1, 1, $year ); |
|
118 | - $date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year ); |
|
117 | + $date1 = mktime(0, 0, 0, $m1, 1, $year); |
|
118 | + $date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year); |
|
119 | 119 | |
120 | 120 | $data[] = array( |
121 | - 'date' => date_i18n( 'F Y', $date1 ), |
|
122 | - 'donations' => $stats->get_sales( 0, $date1, $date2 ), |
|
123 | - 'earnings' => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ) ), |
|
121 | + 'date' => date_i18n('F Y', $date1), |
|
122 | + 'donations' => $stats->get_sales(0, $date1, $date2), |
|
123 | + 'earnings' => give_format_amount($stats->get_earnings(0, $date1, $date2)), |
|
124 | 124 | ); |
125 | 125 | |
126 | - $m1 ++; |
|
126 | + $m1++; |
|
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | - $year ++; |
|
131 | + $year++; |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
136 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
135 | + $data = apply_filters('give_export_get_data', $data); |
|
136 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
137 | 137 | |
138 | 138 | return $data; |
139 | 139 | } |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | * @access public |
891 | 891 | * |
892 | 892 | * @param string $meta_key Metadata name. Default is empty. |
893 | - * @param mixed $meta_value Metadata value. |
|
893 | + * @param string $meta_value Metadata value. |
|
894 | 894 | * @param bool $unique Optional. Whether the same key should not be added. Default is false. |
895 | 895 | * |
896 | 896 | * @return bool False for failure. True for success. |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | * @access public |
923 | 923 | * |
924 | 924 | * @param string $meta_key Metadata name. Default is empty. |
925 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
925 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
926 | 926 | * |
927 | 927 | * @return bool False for failure. True for success. |
928 | 928 | */ |
@@ -714,12 +714,12 @@ discard block |
||
714 | 714 | |
715 | 715 | /** |
716 | 716 | * Decrease/Increase a customer's lifetime value. |
717 | - * |
|
718 | - * This function will update donation stat on basis of current amount and new amount donation difference. |
|
719 | - * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat. |
|
720 | - * |
|
717 | + * |
|
718 | + * This function will update donation stat on basis of current amount and new amount donation difference. |
|
719 | + * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat. |
|
720 | + * |
|
721 | 721 | * @since 1.0 |
722 | - * @access public |
|
722 | + * @access public |
|
723 | 723 | * |
724 | 724 | * @param float $curr_amount Current Donation amount. |
725 | 725 | * @param float $new_amount New (changed) Donation amount. |
@@ -727,35 +727,35 @@ discard block |
||
727 | 727 | * @return mixed If successful, the new donation stat value, otherwise false. |
728 | 728 | */ |
729 | 729 | public function update_donation_value( $curr_amount, $new_amount ) { |
730 | - /** |
|
731 | - * Payment total difference value can be: |
|
732 | - * zero (in case amount not change) |
|
733 | - * or -ve (in case amount decrease) |
|
734 | - * or +ve (in case amount increase) |
|
735 | - */ |
|
736 | - $payment_total_diff = $new_amount - $curr_amount; |
|
737 | - |
|
738 | - // We do not need to update donation stat if donation did not change. |
|
739 | - if( ! $payment_total_diff ) { |
|
740 | - return false; |
|
741 | - } |
|
742 | - |
|
743 | - |
|
744 | - if( $payment_total_diff > 0 ) { |
|
745 | - $this->increase_value( $payment_total_diff ); |
|
746 | - } else { |
|
747 | - // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
|
748 | - $this->decrease_value( -$payment_total_diff ); |
|
749 | - } |
|
750 | - |
|
751 | - return $this->purchase_value; |
|
730 | + /** |
|
731 | + * Payment total difference value can be: |
|
732 | + * zero (in case amount not change) |
|
733 | + * or -ve (in case amount decrease) |
|
734 | + * or +ve (in case amount increase) |
|
735 | + */ |
|
736 | + $payment_total_diff = $new_amount - $curr_amount; |
|
737 | + |
|
738 | + // We do not need to update donation stat if donation did not change. |
|
739 | + if( ! $payment_total_diff ) { |
|
740 | + return false; |
|
741 | + } |
|
742 | + |
|
743 | + |
|
744 | + if( $payment_total_diff > 0 ) { |
|
745 | + $this->increase_value( $payment_total_diff ); |
|
746 | + } else { |
|
747 | + // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
|
748 | + $this->decrease_value( -$payment_total_diff ); |
|
749 | + } |
|
750 | + |
|
751 | + return $this->purchase_value; |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | /** |
755 | 755 | * Get the parsed notes for a customer as an array. |
756 | 756 | * |
757 | 757 | * @since 1.0 |
758 | - * @access public |
|
758 | + * @access public |
|
759 | 759 | * |
760 | 760 | * @param int $length The number of notes to get. |
761 | 761 | * @param int $paged What note to start at. |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | * Get the total number of notes we have after parsing. |
781 | 781 | * |
782 | 782 | * @since 1.0 |
783 | - * @access public |
|
783 | + * @access public |
|
784 | 784 | * |
785 | 785 | * @return int The number of notes for the customer. |
786 | 786 | */ |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | * Add a note for the customer. |
798 | 798 | * |
799 | 799 | * @since 1.0 |
800 | - * @access public |
|
800 | + * @access public |
|
801 | 801 | * |
802 | 802 | * @param string $note The note to add. Default is empty. |
803 | 803 | * |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | * Get the notes column for the customer |
857 | 857 | * |
858 | 858 | * @since 1.0 |
859 | - * @access private |
|
859 | + * @access private |
|
860 | 860 | * |
861 | 861 | * @return string The Notes for the customer, non-parsed. |
862 | 862 | */ |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | * Sanitize the data for update/create |
935 | 935 | * |
936 | 936 | * @since 1.0 |
937 | - * @access private |
|
937 | + * @access private |
|
938 | 938 | * |
939 | 939 | * @param array $data The data to sanitize. |
940 | 940 | * |
@@ -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 | |
@@ -144,29 +144,29 @@ discard block |
||
144 | 144 | * @param bool $_id_or_email |
145 | 145 | * @param bool $by_user_id |
146 | 146 | */ |
147 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
147 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
148 | 148 | |
149 | 149 | $this->db = new Give_DB_Customers; |
150 | 150 | |
151 | - if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) { |
|
151 | + if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
155 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
156 | 156 | |
157 | - if ( is_numeric( $_id_or_email ) ) { |
|
157 | + if (is_numeric($_id_or_email)) { |
|
158 | 158 | $field = $by_user_id ? 'user_id' : 'id'; |
159 | 159 | } else { |
160 | 160 | $field = 'email'; |
161 | 161 | } |
162 | 162 | |
163 | - $customer = $this->db->get_customer_by( $field, $_id_or_email ); |
|
163 | + $customer = $this->db->get_customer_by($field, $_id_or_email); |
|
164 | 164 | |
165 | - if ( empty( $customer ) || ! is_object( $customer ) ) { |
|
165 | + if (empty($customer) || ! is_object($customer)) { |
|
166 | 166 | return false; |
167 | 167 | } |
168 | 168 | |
169 | - $this->setup_customer( $customer ); |
|
169 | + $this->setup_customer($customer); |
|
170 | 170 | |
171 | 171 | } |
172 | 172 | |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return bool If the setup was successful or not. |
184 | 184 | */ |
185 | - private function setup_customer( $customer ) { |
|
185 | + private function setup_customer($customer) { |
|
186 | 186 | |
187 | - if ( ! is_object( $customer ) ) { |
|
187 | + if ( ! is_object($customer)) { |
|
188 | 188 | return false; |
189 | 189 | } |
190 | 190 | |
191 | - foreach ( $customer as $key => $value ) { |
|
191 | + foreach ($customer as $key => $value) { |
|
192 | 192 | |
193 | - switch ( $key ) { |
|
193 | + switch ($key) { |
|
194 | 194 | |
195 | 195 | case 'notes': |
196 | 196 | $this->$key = $this->get_notes(); |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | // Get donor's all email including primary email. |
208 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
209 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
208 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
209 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
210 | 210 | |
211 | 211 | // Customer ID and email are the only things that are necessary, make sure they exist. |
212 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
212 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
213 | 213 | return true; |
214 | 214 | } |
215 | 215 | |
@@ -223,16 +223,16 @@ discard block |
||
223 | 223 | * @since 1.0 |
224 | 224 | * @access public |
225 | 225 | */ |
226 | - public function __get( $key ) { |
|
226 | + public function __get($key) { |
|
227 | 227 | |
228 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
228 | + if (method_exists($this, 'get_'.$key)) { |
|
229 | 229 | |
230 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
230 | + return call_user_func(array($this, 'get_'.$key)); |
|
231 | 231 | |
232 | 232 | } else { |
233 | 233 | |
234 | 234 | /* translators: %s: property key */ |
235 | - return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
235 | + return new WP_Error('give-customer-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
236 | 236 | |
237 | 237 | } |
238 | 238 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return bool|int False if not a valid creation, customer ID if user is found or valid creation. |
250 | 250 | */ |
251 | - public function create( $data = array() ) { |
|
251 | + public function create($data = array()) { |
|
252 | 252 | |
253 | - if ( $this->id != 0 || empty( $data ) ) { |
|
253 | + if ($this->id != 0 || empty($data)) { |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | 'payment_ids' => '' |
259 | 259 | ); |
260 | 260 | |
261 | - $args = wp_parse_args( $data, $defaults ); |
|
262 | - $args = $this->sanitize_columns( $args ); |
|
261 | + $args = wp_parse_args($data, $defaults); |
|
262 | + $args = $this->sanitize_columns($args); |
|
263 | 263 | |
264 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
264 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
269 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
268 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
269 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -276,18 +276,18 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @param array $args Customer attributes. |
278 | 278 | */ |
279 | - do_action( 'give_customer_pre_create', $args ); |
|
279 | + do_action('give_customer_pre_create', $args); |
|
280 | 280 | |
281 | 281 | $created = false; |
282 | 282 | |
283 | 283 | // The DB class 'add' implies an update if the customer being asked to be created already exists |
284 | - if ( $this->db->add( $data ) ) { |
|
284 | + if ($this->db->add($data)) { |
|
285 | 285 | |
286 | 286 | // We've successfully added/updated the customer, reset the class vars with the new data |
287 | - $customer = $this->db->get_customer_by( 'email', $args['email'] ); |
|
287 | + $customer = $this->db->get_customer_by('email', $args['email']); |
|
288 | 288 | |
289 | 289 | // Setup the customer data with the values from DB |
290 | - $this->setup_customer( $customer ); |
|
290 | + $this->setup_customer($customer); |
|
291 | 291 | |
292 | 292 | $created = $this->id; |
293 | 293 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * customer ID if user is found or valid creation. |
302 | 302 | * @param array $args Customer attributes. |
303 | 303 | */ |
304 | - do_action( 'give_customer_post_create', $created, $args ); |
|
304 | + do_action('give_customer_post_create', $created, $args); |
|
305 | 305 | |
306 | 306 | return $created; |
307 | 307 | |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return bool If the update was successful or not. |
319 | 319 | */ |
320 | - public function update( $data = array() ) { |
|
320 | + public function update($data = array()) { |
|
321 | 321 | |
322 | - if ( empty( $data ) ) { |
|
322 | + if (empty($data)) { |
|
323 | 323 | return false; |
324 | 324 | } |
325 | 325 | |
326 | - $data = $this->sanitize_columns( $data ); |
|
326 | + $data = $this->sanitize_columns($data); |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * Fires before updating customers. |
@@ -333,14 +333,14 @@ discard block |
||
333 | 333 | * @param int $customer_id Customer id. |
334 | 334 | * @param array $data Customer attributes. |
335 | 335 | */ |
336 | - do_action( 'give_customer_pre_update', $this->id, $data ); |
|
336 | + do_action('give_customer_pre_update', $this->id, $data); |
|
337 | 337 | |
338 | 338 | $updated = false; |
339 | 339 | |
340 | - if ( $this->db->update( $this->id, $data ) ) { |
|
340 | + if ($this->db->update($this->id, $data)) { |
|
341 | 341 | |
342 | - $customer = $this->db->get_customer_by( 'id', $this->id ); |
|
343 | - $this->setup_customer( $customer ); |
|
342 | + $customer = $this->db->get_customer_by('id', $this->id); |
|
343 | + $this->setup_customer($customer); |
|
344 | 344 | |
345 | 345 | $updated = true; |
346 | 346 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * @param int $customer_id Customer id. |
355 | 355 | * @param array $data Customer attributes. |
356 | 356 | */ |
357 | - do_action( 'give_customer_post_update', $updated, $this->id, $data ); |
|
357 | + do_action('give_customer_post_update', $updated, $this->id, $data); |
|
358 | 358 | |
359 | 359 | return $updated; |
360 | 360 | } |
@@ -372,27 +372,27 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @return bool If the attachment was successfuly. |
374 | 374 | */ |
375 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
375 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
376 | 376 | |
377 | - if ( empty( $payment_id ) ) { |
|
377 | + if (empty($payment_id)) { |
|
378 | 378 | return false; |
379 | 379 | } |
380 | 380 | |
381 | - if ( empty( $this->payment_ids ) ) { |
|
381 | + if (empty($this->payment_ids)) { |
|
382 | 382 | |
383 | 383 | $new_payment_ids = $payment_id; |
384 | 384 | |
385 | 385 | } else { |
386 | 386 | |
387 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
387 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
388 | 388 | |
389 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
389 | + if (in_array($payment_id, $payment_ids)) { |
|
390 | 390 | $update_stats = false; |
391 | 391 | } |
392 | 392 | |
393 | 393 | $payment_ids[] = $payment_id; |
394 | 394 | |
395 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
395 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
396 | 396 | |
397 | 397 | } |
398 | 398 | |
@@ -404,20 +404,20 @@ discard block |
||
404 | 404 | * @param int $payment_id Payment id. |
405 | 405 | * @param int $customer_id Customer id. |
406 | 406 | */ |
407 | - do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id ); |
|
407 | + do_action('give_customer_pre_attach_payment', $payment_id, $this->id); |
|
408 | 408 | |
409 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
409 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
410 | 410 | |
411 | - if ( $payment_added ) { |
|
411 | + if ($payment_added) { |
|
412 | 412 | |
413 | 413 | $this->payment_ids = $new_payment_ids; |
414 | 414 | |
415 | 415 | // We added this payment successfully, increment the stats |
416 | - if ( $update_stats ) { |
|
417 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
416 | + if ($update_stats) { |
|
417 | + $payment_amount = give_get_payment_amount($payment_id); |
|
418 | 418 | |
419 | - if ( ! empty( $payment_amount ) ) { |
|
420 | - $this->increase_value( $payment_amount ); |
|
419 | + if ( ! empty($payment_amount)) { |
|
420 | + $this->increase_value($payment_amount); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | $this->increase_purchase_count(); |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * @param int $payment_id Payment id. |
435 | 435 | * @param int $customer_id Customer id. |
436 | 436 | */ |
437 | - do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
437 | + do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
438 | 438 | |
439 | 439 | return $payment_added; |
440 | 440 | } |
@@ -452,33 +452,33 @@ discard block |
||
452 | 452 | * |
453 | 453 | * @return boolean If the removal was successful. |
454 | 454 | */ |
455 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
455 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
456 | 456 | |
457 | - if ( empty( $payment_id ) ) { |
|
457 | + if (empty($payment_id)) { |
|
458 | 458 | return false; |
459 | 459 | } |
460 | 460 | |
461 | - $payment = new Give_Payment( $payment_id ); |
|
461 | + $payment = new Give_Payment($payment_id); |
|
462 | 462 | |
463 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
463 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
464 | 464 | $update_stats = false; |
465 | 465 | } |
466 | 466 | |
467 | 467 | $new_payment_ids = ''; |
468 | 468 | |
469 | - if ( ! empty( $this->payment_ids ) ) { |
|
469 | + if ( ! empty($this->payment_ids)) { |
|
470 | 470 | |
471 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
471 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
472 | 472 | |
473 | - $pos = array_search( $payment_id, $payment_ids ); |
|
474 | - if ( false === $pos ) { |
|
473 | + $pos = array_search($payment_id, $payment_ids); |
|
474 | + if (false === $pos) { |
|
475 | 475 | return false; |
476 | 476 | } |
477 | 477 | |
478 | - unset( $payment_ids[ $pos ] ); |
|
479 | - $payment_ids = array_filter( $payment_ids ); |
|
478 | + unset($payment_ids[$pos]); |
|
479 | + $payment_ids = array_filter($payment_ids); |
|
480 | 480 | |
481 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
481 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | |
@@ -490,20 +490,20 @@ discard block |
||
490 | 490 | * @param int $payment_id Payment id. |
491 | 491 | * @param int $customer_id Customer id. |
492 | 492 | */ |
493 | - do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id ); |
|
493 | + do_action('give_customer_pre_remove_payment', $payment_id, $this->id); |
|
494 | 494 | |
495 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
495 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
496 | 496 | |
497 | - if ( $payment_removed ) { |
|
497 | + if ($payment_removed) { |
|
498 | 498 | |
499 | 499 | $this->payment_ids = $new_payment_ids; |
500 | 500 | |
501 | - if ( $update_stats ) { |
|
501 | + if ($update_stats) { |
|
502 | 502 | // We removed this payment successfully, decrement the stats |
503 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
503 | + $payment_amount = give_get_payment_amount($payment_id); |
|
504 | 504 | |
505 | - if ( ! empty( $payment_amount ) ) { |
|
506 | - $this->decrease_value( $payment_amount ); |
|
505 | + if ( ! empty($payment_amount)) { |
|
506 | + $this->decrease_value($payment_amount); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | $this->decrease_purchase_count(); |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @param int $payment_id Payment id. |
521 | 521 | * @param int $customer_id Customer id. |
522 | 522 | */ |
523 | - do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
523 | + do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
524 | 524 | |
525 | 525 | return $payment_removed; |
526 | 526 | |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | * |
537 | 537 | * @return int The donation count. |
538 | 538 | */ |
539 | - public function increase_purchase_count( $count = 1 ) { |
|
539 | + public function increase_purchase_count($count = 1) { |
|
540 | 540 | |
541 | 541 | // Make sure it's numeric and not negative. |
542 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
542 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
543 | 543 | return false; |
544 | 544 | } |
545 | 545 | |
@@ -553,9 +553,9 @@ discard block |
||
553 | 553 | * @param int $count The number to increase by. |
554 | 554 | * @param int $customer_id Customer id. |
555 | 555 | */ |
556 | - do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id ); |
|
556 | + do_action('give_customer_pre_increase_purchase_count', $count, $this->id); |
|
557 | 557 | |
558 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
558 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
559 | 559 | $this->purchase_count = $new_total; |
560 | 560 | } |
561 | 561 | |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @param int $count The number increased by. |
569 | 569 | * @param int $customer_id Customer id. |
570 | 570 | */ |
571 | - do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id ); |
|
571 | + do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id); |
|
572 | 572 | |
573 | 573 | return $this->purchase_count; |
574 | 574 | } |
@@ -583,16 +583,16 @@ discard block |
||
583 | 583 | * |
584 | 584 | * @return mixed If successful, the new count, otherwise false. |
585 | 585 | */ |
586 | - public function decrease_purchase_count( $count = 1 ) { |
|
586 | + public function decrease_purchase_count($count = 1) { |
|
587 | 587 | |
588 | 588 | // Make sure it's numeric and not negative |
589 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
589 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
590 | 590 | return false; |
591 | 591 | } |
592 | 592 | |
593 | 593 | $new_total = (int) $this->purchase_count - (int) $count; |
594 | 594 | |
595 | - if ( $new_total < 0 ) { |
|
595 | + if ($new_total < 0) { |
|
596 | 596 | $new_total = 0; |
597 | 597 | } |
598 | 598 | |
@@ -604,9 +604,9 @@ discard block |
||
604 | 604 | * @param int $count The number to decrease by. |
605 | 605 | * @param int $customer_id Customer id. |
606 | 606 | */ |
607 | - do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id ); |
|
607 | + do_action('give_customer_pre_decrease_purchase_count', $count, $this->id); |
|
608 | 608 | |
609 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
609 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
610 | 610 | $this->purchase_count = $new_total; |
611 | 611 | } |
612 | 612 | |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * @param int $count The number decreased by. |
620 | 620 | * @param int $customer_id Customer id. |
621 | 621 | */ |
622 | - do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id ); |
|
622 | + do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id); |
|
623 | 623 | |
624 | 624 | return $this->purchase_count; |
625 | 625 | } |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * |
635 | 635 | * @return mixed If successful, the new value, otherwise false. |
636 | 636 | */ |
637 | - public function increase_value( $value = 0.00 ) { |
|
637 | + public function increase_value($value = 0.00) { |
|
638 | 638 | |
639 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
639 | + $new_value = floatval($this->purchase_value) + $value; |
|
640 | 640 | |
641 | 641 | /** |
642 | 642 | * Fires before increasing customer lifetime value. |
@@ -646,9 +646,9 @@ discard block |
||
646 | 646 | * @param float $value The value to increase by. |
647 | 647 | * @param int $customer_id Customer id. |
648 | 648 | */ |
649 | - do_action( 'give_customer_pre_increase_value', $value, $this->id ); |
|
649 | + do_action('give_customer_pre_increase_value', $value, $this->id); |
|
650 | 650 | |
651 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
651 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
652 | 652 | $this->purchase_value = $new_value; |
653 | 653 | } |
654 | 654 | |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | * @param float $value The value increased by. |
662 | 662 | * @param int $customer_id Customer id. |
663 | 663 | */ |
664 | - do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
664 | + do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id); |
|
665 | 665 | |
666 | 666 | return $this->purchase_value; |
667 | 667 | } |
@@ -676,11 +676,11 @@ discard block |
||
676 | 676 | * |
677 | 677 | * @return mixed If successful, the new value, otherwise false. |
678 | 678 | */ |
679 | - public function decrease_value( $value = 0.00 ) { |
|
679 | + public function decrease_value($value = 0.00) { |
|
680 | 680 | |
681 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
681 | + $new_value = floatval($this->purchase_value) - $value; |
|
682 | 682 | |
683 | - if ( $new_value < 0 ) { |
|
683 | + if ($new_value < 0) { |
|
684 | 684 | $new_value = 0.00; |
685 | 685 | } |
686 | 686 | |
@@ -692,9 +692,9 @@ discard block |
||
692 | 692 | * @param float $value The value to decrease by. |
693 | 693 | * @param int $customer_id Customer id. |
694 | 694 | */ |
695 | - do_action( 'give_customer_pre_decrease_value', $value, $this->id ); |
|
695 | + do_action('give_customer_pre_decrease_value', $value, $this->id); |
|
696 | 696 | |
697 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
697 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
698 | 698 | $this->purchase_value = $new_value; |
699 | 699 | } |
700 | 700 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * @param float $value The value decreased by. |
708 | 708 | * @param int $customer_id Customer id. |
709 | 709 | */ |
710 | - do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
710 | + do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
711 | 711 | |
712 | 712 | return $this->purchase_value; |
713 | 713 | } |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | * |
727 | 727 | * @return mixed If successful, the new donation stat value, otherwise false. |
728 | 728 | */ |
729 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
729 | + public function update_donation_value($curr_amount, $new_amount) { |
|
730 | 730 | /** |
731 | 731 | * Payment total difference value can be: |
732 | 732 | * zero (in case amount not change) |
@@ -736,13 +736,13 @@ discard block |
||
736 | 736 | $payment_total_diff = $new_amount - $curr_amount; |
737 | 737 | |
738 | 738 | // We do not need to update donation stat if donation did not change. |
739 | - if( ! $payment_total_diff ) { |
|
739 | + if ( ! $payment_total_diff) { |
|
740 | 740 | return false; |
741 | 741 | } |
742 | 742 | |
743 | 743 | |
744 | - if( $payment_total_diff > 0 ) { |
|
745 | - $this->increase_value( $payment_total_diff ); |
|
744 | + if ($payment_total_diff > 0) { |
|
745 | + $this->increase_value($payment_total_diff); |
|
746 | 746 | } else { |
747 | 747 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
748 | 748 | $this->decrease_value( -$payment_total_diff ); |
@@ -762,15 +762,15 @@ discard block |
||
762 | 762 | * |
763 | 763 | * @return array The notes requested. |
764 | 764 | */ |
765 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
765 | + public function get_notes($length = 20, $paged = 1) { |
|
766 | 766 | |
767 | - $length = is_numeric( $length ) ? $length : 20; |
|
768 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
767 | + $length = is_numeric($length) ? $length : 20; |
|
768 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
769 | 769 | |
770 | 770 | $all_notes = $this->get_raw_notes(); |
771 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
771 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
772 | 772 | |
773 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
773 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
774 | 774 | |
775 | 775 | return $desired_notes; |
776 | 776 | |
@@ -787,9 +787,9 @@ discard block |
||
787 | 787 | public function get_notes_count() { |
788 | 788 | |
789 | 789 | $all_notes = $this->get_raw_notes(); |
790 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
790 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
791 | 791 | |
792 | - return count( $notes_array ); |
|
792 | + return count($notes_array); |
|
793 | 793 | |
794 | 794 | } |
795 | 795 | |
@@ -803,22 +803,22 @@ discard block |
||
803 | 803 | * |
804 | 804 | * @return string|boolean The new note if added successfully, false otherwise. |
805 | 805 | */ |
806 | - public function add_note( $note = '' ) { |
|
806 | + public function add_note($note = '') { |
|
807 | 807 | |
808 | - $note = trim( $note ); |
|
809 | - if ( empty( $note ) ) { |
|
808 | + $note = trim($note); |
|
809 | + if (empty($note)) { |
|
810 | 810 | return false; |
811 | 811 | } |
812 | 812 | |
813 | 813 | $notes = $this->get_raw_notes(); |
814 | 814 | |
815 | - if ( empty( $notes ) ) { |
|
815 | + if (empty($notes)) { |
|
816 | 816 | $notes = ''; |
817 | 817 | } |
818 | 818 | |
819 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
820 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
821 | - $notes .= "\n\n" . $new_note; |
|
819 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
820 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
821 | + $notes .= "\n\n".$new_note; |
|
822 | 822 | |
823 | 823 | /** |
824 | 824 | * Fires before customer note added. |
@@ -828,11 +828,11 @@ discard block |
||
828 | 828 | * @param string $new_note New note to add. |
829 | 829 | * @param int $customer_id Customer id. |
830 | 830 | */ |
831 | - do_action( 'give_customer_pre_add_note', $new_note, $this->id ); |
|
831 | + do_action('give_customer_pre_add_note', $new_note, $this->id); |
|
832 | 832 | |
833 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
833 | + $updated = $this->update(array('notes' => $notes)); |
|
834 | 834 | |
835 | - if ( $updated ) { |
|
835 | + if ($updated) { |
|
836 | 836 | $this->notes = $this->get_notes(); |
837 | 837 | } |
838 | 838 | |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | * @param string $new_note New note added. |
846 | 846 | * @param int $customer_id Customer id. |
847 | 847 | */ |
848 | - do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id ); |
|
848 | + do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id); |
|
849 | 849 | |
850 | 850 | // Return the formatted note, so we can test, as well as update any displays |
851 | 851 | return $new_note; |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | */ |
863 | 863 | private function get_raw_notes() { |
864 | 864 | |
865 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
865 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
866 | 866 | |
867 | 867 | return $all_notes; |
868 | 868 | |
@@ -879,8 +879,8 @@ discard block |
||
879 | 879 | * |
880 | 880 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
881 | 881 | */ |
882 | - public function get_meta( $meta_key = '', $single = true ) { |
|
883 | - return Give()->customer_meta->get_meta( $this->id, $meta_key, $single ); |
|
882 | + public function get_meta($meta_key = '', $single = true) { |
|
883 | + return Give()->customer_meta->get_meta($this->id, $meta_key, $single); |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | /** |
@@ -895,8 +895,8 @@ discard block |
||
895 | 895 | * |
896 | 896 | * @return bool False for failure. True for success. |
897 | 897 | */ |
898 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
899 | - return Give()->customer_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
898 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
899 | + return Give()->customer_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | /** |
@@ -911,8 +911,8 @@ discard block |
||
911 | 911 | * |
912 | 912 | * @return bool False on failure, true if success. |
913 | 913 | */ |
914 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
915 | - return Give()->customer_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
914 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
915 | + return Give()->customer_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
916 | 916 | } |
917 | 917 | |
918 | 918 | /** |
@@ -926,8 +926,8 @@ discard block |
||
926 | 926 | * |
927 | 927 | * @return bool False for failure. True for success. |
928 | 928 | */ |
929 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
930 | - return Give()->customer_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
929 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
930 | + return Give()->customer_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | /** |
@@ -940,51 +940,51 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @return array The sanitized data, based off column defaults. |
942 | 942 | */ |
943 | - private function sanitize_columns( $data ) { |
|
943 | + private function sanitize_columns($data) { |
|
944 | 944 | |
945 | 945 | $columns = $this->db->get_columns(); |
946 | 946 | $default_values = $this->db->get_column_defaults(); |
947 | 947 | |
948 | - foreach ( $columns as $key => $type ) { |
|
948 | + foreach ($columns as $key => $type) { |
|
949 | 949 | |
950 | 950 | // Only sanitize data that we were provided |
951 | - if ( ! array_key_exists( $key, $data ) ) { |
|
951 | + if ( ! array_key_exists($key, $data)) { |
|
952 | 952 | continue; |
953 | 953 | } |
954 | 954 | |
955 | - switch ( $type ) { |
|
955 | + switch ($type) { |
|
956 | 956 | |
957 | 957 | case '%s': |
958 | - if ( 'email' == $key ) { |
|
959 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
960 | - } elseif ( 'notes' == $key ) { |
|
961 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
958 | + if ('email' == $key) { |
|
959 | + $data[$key] = sanitize_email($data[$key]); |
|
960 | + } elseif ('notes' == $key) { |
|
961 | + $data[$key] = strip_tags($data[$key]); |
|
962 | 962 | } else { |
963 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
963 | + $data[$key] = sanitize_text_field($data[$key]); |
|
964 | 964 | } |
965 | 965 | break; |
966 | 966 | |
967 | 967 | case '%d': |
968 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
969 | - $data[ $key ] = $default_values[ $key ]; |
|
968 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
969 | + $data[$key] = $default_values[$key]; |
|
970 | 970 | } else { |
971 | - $data[ $key ] = absint( $data[ $key ] ); |
|
971 | + $data[$key] = absint($data[$key]); |
|
972 | 972 | } |
973 | 973 | break; |
974 | 974 | |
975 | 975 | case '%f': |
976 | 976 | // Convert what was given to a float |
977 | - $value = floatval( $data[ $key ] ); |
|
977 | + $value = floatval($data[$key]); |
|
978 | 978 | |
979 | - if ( ! is_float( $value ) ) { |
|
980 | - $data[ $key ] = $default_values[ $key ]; |
|
979 | + if ( ! is_float($value)) { |
|
980 | + $data[$key] = $default_values[$key]; |
|
981 | 981 | } else { |
982 | - $data[ $key ] = $value; |
|
982 | + $data[$key] = $value; |
|
983 | 983 | } |
984 | 984 | break; |
985 | 985 | |
986 | 986 | default: |
987 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
987 | + $data[$key] = sanitize_text_field($data[$key]); |
|
988 | 988 | break; |
989 | 989 | |
990 | 990 | } |
@@ -1002,33 +1002,33 @@ discard block |
||
1002 | 1002 | * @param bool $primary Allows setting the email added as the primary |
1003 | 1003 | * @return bool If the email was added successfully |
1004 | 1004 | */ |
1005 | - public function add_email( $email = '', $primary = false ) { |
|
1006 | - if( ! is_email( $email ) ) { |
|
1005 | + public function add_email($email = '', $primary = false) { |
|
1006 | + if ( ! is_email($email)) { |
|
1007 | 1007 | return false; |
1008 | 1008 | } |
1009 | - $existing = new Give_Customer( $email ); |
|
1009 | + $existing = new Give_Customer($email); |
|
1010 | 1010 | |
1011 | - if( $existing->id > 0 ) { |
|
1011 | + if ($existing->id > 0) { |
|
1012 | 1012 | // Email address already belongs to another customer |
1013 | 1013 | return false; |
1014 | 1014 | } |
1015 | 1015 | |
1016 | - if ( email_exists( $email ) ) { |
|
1017 | - $user = get_user_by( 'email', $email ); |
|
1018 | - if ( $user->ID != $this->user_id ) { |
|
1016 | + if (email_exists($email)) { |
|
1017 | + $user = get_user_by('email', $email); |
|
1018 | + if ($user->ID != $this->user_id) { |
|
1019 | 1019 | return false; |
1020 | 1020 | } |
1021 | 1021 | } |
1022 | 1022 | |
1023 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
1023 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
1024 | 1024 | |
1025 | 1025 | // Add is used to ensure duplicate emails are not added |
1026 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
1026 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
1027 | 1027 | |
1028 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
1028 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
1029 | 1029 | |
1030 | - if ( $ret && true === $primary ) { |
|
1031 | - $this->set_primary_email( $email ); |
|
1030 | + if ($ret && true === $primary) { |
|
1031 | + $this->set_primary_email($email); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | return $ret; |
@@ -1042,16 +1042,16 @@ discard block |
||
1042 | 1042 | * @param string $email The email address to remove from the customer |
1043 | 1043 | * @return bool If the email was removeed successfully |
1044 | 1044 | */ |
1045 | - public function remove_email( $email = '' ) { |
|
1046 | - if( ! is_email( $email ) ) { |
|
1045 | + public function remove_email($email = '') { |
|
1046 | + if ( ! is_email($email)) { |
|
1047 | 1047 | return false; |
1048 | 1048 | } |
1049 | 1049 | |
1050 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
1050 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
1051 | 1051 | |
1052 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
1052 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
1053 | 1053 | |
1054 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
1054 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
1055 | 1055 | |
1056 | 1056 | return $ret; |
1057 | 1057 | } |
@@ -1065,16 +1065,16 @@ discard block |
||
1065 | 1065 | * @param string $new_primary_email The email address to remove from the customer |
1066 | 1066 | * @return bool If the email was set as primary successfully |
1067 | 1067 | */ |
1068 | - public function set_primary_email( $new_primary_email = '' ) { |
|
1069 | - if( ! is_email( $new_primary_email ) ) { |
|
1068 | + public function set_primary_email($new_primary_email = '') { |
|
1069 | + if ( ! is_email($new_primary_email)) { |
|
1070 | 1070 | return false; |
1071 | 1071 | } |
1072 | 1072 | |
1073 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1073 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
1074 | 1074 | |
1075 | - $existing = new Give_Customer( $new_primary_email ); |
|
1075 | + $existing = new Give_Customer($new_primary_email); |
|
1076 | 1076 | |
1077 | - if( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
1077 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
1078 | 1078 | // This email belongs to another customer |
1079 | 1079 | return false; |
1080 | 1080 | } |
@@ -1082,21 +1082,21 @@ discard block |
||
1082 | 1082 | $old_email = $this->email; |
1083 | 1083 | |
1084 | 1084 | // Update customer record with new email |
1085 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
1085 | + $update = $this->update(array('email' => $new_primary_email)); |
|
1086 | 1086 | |
1087 | 1087 | // Remove new primary from list of additional emails |
1088 | - $remove = $this->remove_email( $new_primary_email ); |
|
1088 | + $remove = $this->remove_email($new_primary_email); |
|
1089 | 1089 | |
1090 | 1090 | // Add old email to additional emails list |
1091 | - $add = $this->add_email( $old_email ); |
|
1091 | + $add = $this->add_email($old_email); |
|
1092 | 1092 | |
1093 | 1093 | $ret = $update && $remove && $add; |
1094 | 1094 | |
1095 | - if( $ret ) { |
|
1095 | + if ($ret) { |
|
1096 | 1096 | $this->email = $new_primary_email; |
1097 | 1097 | } |
1098 | 1098 | |
1099 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1099 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
1100 | 1100 | |
1101 | 1101 | return $ret; |
1102 | 1102 | } |
@@ -10,7 +10,7 @@ |
||
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 |
@@ -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 | |
@@ -62,50 +62,50 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return bool If the gravatar exists or not |
64 | 64 | */ |
65 | - public function validate_gravatar( $id_or_email ) { |
|
65 | + public function validate_gravatar($id_or_email) { |
|
66 | 66 | //id or email code borrowed from wp-includes/pluggable.php |
67 | 67 | $email = ''; |
68 | - if ( is_numeric( $id_or_email ) ) { |
|
68 | + if (is_numeric($id_or_email)) { |
|
69 | 69 | $id = (int) $id_or_email; |
70 | - $user = get_userdata( $id ); |
|
71 | - if ( $user ) { |
|
70 | + $user = get_userdata($id); |
|
71 | + if ($user) { |
|
72 | 72 | $email = $user->user_email; |
73 | 73 | } |
74 | - } elseif ( is_object( $id_or_email ) ) { |
|
74 | + } elseif (is_object($id_or_email)) { |
|
75 | 75 | // No avatar for pingbacks or trackbacks |
76 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
77 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
76 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
77 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
81 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
81 | + if ( ! empty($id_or_email->user_id)) { |
|
82 | 82 | $id = (int) $id_or_email->user_id; |
83 | - $user = get_userdata( $id ); |
|
84 | - if ( $user ) { |
|
83 | + $user = get_userdata($id); |
|
84 | + if ($user) { |
|
85 | 85 | $email = $user->user_email; |
86 | 86 | } |
87 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
87 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
88 | 88 | $email = $id_or_email->comment_author_email; |
89 | 89 | } |
90 | 90 | } else { |
91 | 91 | $email = $id_or_email; |
92 | 92 | } |
93 | 93 | |
94 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
95 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
94 | + $hashkey = md5(strtolower(trim($email))); |
|
95 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
96 | 96 | |
97 | - $data = wp_cache_get( $hashkey ); |
|
98 | - if ( false === $data ) { |
|
99 | - $response = wp_remote_head( $uri ); |
|
100 | - if ( is_wp_error( $response ) ) { |
|
97 | + $data = wp_cache_get($hashkey); |
|
98 | + if (false === $data) { |
|
99 | + $response = wp_remote_head($uri); |
|
100 | + if (is_wp_error($response)) { |
|
101 | 101 | $data = 'not200'; |
102 | 102 | } else { |
103 | 103 | $data = $response['response']['code']; |
104 | 104 | } |
105 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
105 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
106 | 106 | |
107 | 107 | } |
108 | - if ( $data == '200' ) { |
|
108 | + if ($data == '200') { |
|
109 | 109 | return true; |
110 | 110 | } else { |
111 | 111 | return false; |
@@ -122,19 +122,19 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return array IDs if logs, false otherwise |
124 | 124 | */ |
125 | - public function get_log_ids( $form_id = '' ) { |
|
125 | + public function get_log_ids($form_id = '') { |
|
126 | 126 | |
127 | 127 | // get Give_Logging class |
128 | 128 | global $give_logs; |
129 | 129 | |
130 | 130 | // get log for this form |
131 | - $logs = $give_logs->get_logs( $form_id ); |
|
131 | + $logs = $give_logs->get_logs($form_id); |
|
132 | 132 | |
133 | - if ( $logs ) { |
|
133 | + if ($logs) { |
|
134 | 134 | $log_ids = array(); |
135 | 135 | |
136 | 136 | // make an array with all the donor IDs |
137 | - foreach ( $logs as $log ) { |
|
137 | + foreach ($logs as $log) { |
|
138 | 138 | $log_ids[] = $log->ID; |
139 | 139 | } |
140 | 140 | |
@@ -155,51 +155,51 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return mixed |
157 | 157 | */ |
158 | - public function get_payment_ids( $form_id = '' ) { |
|
158 | + public function get_payment_ids($form_id = '') { |
|
159 | 159 | |
160 | 160 | $give_options = give_get_settings(); |
161 | 161 | |
162 | - $log_ids = $this->get_log_ids( $form_id ); |
|
162 | + $log_ids = $this->get_log_ids($form_id); |
|
163 | 163 | |
164 | - if ( $log_ids ) { |
|
164 | + if ($log_ids) { |
|
165 | 165 | |
166 | 166 | $payment_ids = array(); |
167 | 167 | |
168 | - foreach ( $log_ids as $id ) { |
|
168 | + foreach ($log_ids as $id) { |
|
169 | 169 | // get the payment ID for each corresponding log ID |
170 | - $payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true ); |
|
170 | + $payment_ids[] = get_post_meta($id, '_give_log_payment_id', true); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // remove donors who have donated more than once so we can have unique avatars |
174 | 174 | $unique_emails = array(); |
175 | 175 | |
176 | - foreach ( $payment_ids as $key => $id ) { |
|
176 | + foreach ($payment_ids as $key => $id) { |
|
177 | 177 | |
178 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
178 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
179 | 179 | |
180 | - if ( isset ( $give_options['give_donors_gravatars_has_gravatar_account'] ) ) { |
|
181 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
180 | + if (isset ($give_options['give_donors_gravatars_has_gravatar_account'])) { |
|
181 | + if ( ! $this->validate_gravatar($email)) { |
|
182 | 182 | continue; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - $unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true ); |
|
186 | + $unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true); |
|
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | 190 | $unique_ids = array(); |
191 | 191 | |
192 | 192 | // strip duplicate emails |
193 | - $unique_emails = array_unique( $unique_emails ); |
|
193 | + $unique_emails = array_unique($unique_emails); |
|
194 | 194 | |
195 | 195 | // convert the unique IDs back into simple array |
196 | - foreach ( $unique_emails as $id => $email ) { |
|
196 | + foreach ($unique_emails as $id => $email) { |
|
197 | 197 | $unique_ids[] = $id; |
198 | 198 | } |
199 | 199 | |
200 | 200 | // randomize the payment IDs if enabled |
201 | - if ( isset( $give_options['give_donors_gravatars_random_gravatars'] ) ) { |
|
202 | - shuffle( $unique_ids ); |
|
201 | + if (isset($give_options['give_donors_gravatars_random_gravatars'])) { |
|
202 | + shuffle($unique_ids); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // return our unique IDs |
@@ -220,22 +220,22 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - public function gravatars( $form_id = false, $title = '' ) { |
|
223 | + public function gravatars($form_id = false, $title = '') { |
|
224 | 224 | |
225 | 225 | // unique $payment_ids |
226 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
226 | + $payment_ids = $this->get_payment_ids($form_id); |
|
227 | 227 | |
228 | 228 | $give_options = give_get_settings(); |
229 | 229 | |
230 | 230 | // return if no ID |
231 | - if ( ! $form_id ) { |
|
231 | + if ( ! $form_id) { |
|
232 | 232 | return; |
233 | 233 | } |
234 | 234 | |
235 | 235 | // minimum amount of donations before showing gravatars |
236 | 236 | // if the number of items in array is not greater or equal to the number specified, then exit |
237 | - if ( isset( $give_options['give_donors_gravatars_min_purchases_required'] ) && '' != $give_options['give_donors_gravatars_min_purchases_required'] ) { |
|
238 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donors_gravatars_min_purchases_required'] ) ) { |
|
237 | + if (isset($give_options['give_donors_gravatars_min_purchases_required']) && '' != $give_options['give_donors_gravatars_min_purchases_required']) { |
|
238 | + if ( ! (count($payment_ids) >= $give_options['give_donors_gravatars_min_purchases_required'])) { |
|
239 | 239 | return; |
240 | 240 | } |
241 | 241 | } |
@@ -246,51 +246,51 @@ discard block |
||
246 | 246 | echo '<div id="give-purchase-gravatars">'; |
247 | 247 | |
248 | 248 | |
249 | - if ( isset ( $title ) ) { |
|
249 | + if (isset ($title)) { |
|
250 | 250 | |
251 | - if ( $title ) { |
|
252 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ); |
|
253 | - } elseif ( isset( $give_options['give_donors_gravatars_heading'] ) ) { |
|
254 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donors_gravatars_heading'] ) . '</h2>' ); |
|
251 | + if ($title) { |
|
252 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>'); |
|
253 | + } elseif (isset($give_options['give_donors_gravatars_heading'])) { |
|
254 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donors_gravatars_heading']).'</h2>'); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | } |
258 | 258 | echo '<ul class="give-purchase-gravatars-list">'; |
259 | 259 | $i = 0; |
260 | 260 | |
261 | - if ( $payment_ids ) { |
|
262 | - foreach ( $payment_ids as $id ) { |
|
261 | + if ($payment_ids) { |
|
262 | + foreach ($payment_ids as $id) { |
|
263 | 263 | |
264 | 264 | // Give saves a blank option even when the control is turned off, hence the extra check |
265 | - if ( isset( $give_options['give_donors_gravatars_maximum_number'] ) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number'] ) { |
|
265 | + if (isset($give_options['give_donors_gravatars_maximum_number']) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number']) { |
|
266 | 266 | continue; |
267 | 267 | } |
268 | 268 | |
269 | 269 | // get the payment meta |
270 | - $payment_meta = get_post_meta( $id, '_give_payment_meta', true ); |
|
270 | + $payment_meta = get_post_meta($id, '_give_payment_meta', true); |
|
271 | 271 | |
272 | 272 | // unserialize the payment meta |
273 | - $user_info = maybe_unserialize( $payment_meta['user_info'] ); |
|
273 | + $user_info = maybe_unserialize($payment_meta['user_info']); |
|
274 | 274 | |
275 | 275 | // get donor's first name |
276 | 276 | $name = $user_info['first_name']; |
277 | 277 | |
278 | 278 | // get donor's email |
279 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
279 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
280 | 280 | |
281 | 281 | // set gravatar size and provide filter |
282 | - $size = isset( $give_options['give_donors_gravatars_gravatar_size'] ) ? apply_filters( 'give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size'] ) : ''; |
|
282 | + $size = isset($give_options['give_donors_gravatars_gravatar_size']) ? apply_filters('give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size']) : ''; |
|
283 | 283 | |
284 | 284 | // default image |
285 | - $default_image = apply_filters( 'give_donors_gravatars_gravatar_default_image', false ); |
|
285 | + $default_image = apply_filters('give_donors_gravatars_gravatar_default_image', false); |
|
286 | 286 | |
287 | 287 | // assemble output |
288 | 288 | $output .= '<li>'; |
289 | 289 | |
290 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
290 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
291 | 291 | $output .= '</li>'; |
292 | 292 | |
293 | - $i ++; |
|
293 | + $i++; |
|
294 | 294 | |
295 | 295 | } // end foreach |
296 | 296 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | echo '</ul>'; |
300 | 300 | echo '</div>'; |
301 | 301 | |
302 | - return apply_filters( 'give_donors_gravatars', ob_get_clean() ); |
|
302 | + return apply_filters('give_donors_gravatars', ob_get_clean()); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @return void |
312 | 312 | */ |
313 | 313 | public function register_widget() { |
314 | - register_widget( 'Give_Donors_Gravatars_Widget' ); |
|
314 | + register_widget('Give_Donors_Gravatars_Widget'); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -327,19 +327,19 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @todo Set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars |
329 | 329 | */ |
330 | - public function shortcode( $atts, $content = null ) { |
|
330 | + public function shortcode($atts, $content = null) { |
|
331 | 331 | |
332 | - $atts = shortcode_atts( array( |
|
332 | + $atts = shortcode_atts(array( |
|
333 | 333 | 'id' => '', |
334 | 334 | 'title' => '' |
335 | - ), $atts, 'give_donors_gravatars' ); |
|
335 | + ), $atts, 'give_donors_gravatars'); |
|
336 | 336 | |
337 | 337 | // if no ID is passed on single give_forms pages, get the correct ID |
338 | - if ( is_singular( 'give_forms' ) ) { |
|
338 | + if (is_singular('give_forms')) { |
|
339 | 339 | $id = get_the_ID(); |
340 | 340 | } |
341 | 341 | |
342 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
342 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
343 | 343 | |
344 | 344 | return $content; |
345 | 345 | |
@@ -355,56 +355,56 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return array Gravatar settings. |
357 | 357 | */ |
358 | - public function settings( $settings ) { |
|
358 | + public function settings($settings) { |
|
359 | 359 | |
360 | 360 | $give_gravatar_settings = array( |
361 | 361 | array( |
362 | - 'name' => esc_html__( 'Donator Gravatars', 'give' ), |
|
362 | + 'name' => esc_html__('Donator Gravatars', 'give'), |
|
363 | 363 | 'desc' => '<hr>', |
364 | 364 | 'id' => 'give_title', |
365 | 365 | 'type' => 'give_title' |
366 | 366 | ), |
367 | 367 | array( |
368 | - 'name' => esc_html__( 'Heading', 'give' ), |
|
369 | - 'desc' => esc_html__( 'The heading to display above the Gravatars.', 'give' ), |
|
368 | + 'name' => esc_html__('Heading', 'give'), |
|
369 | + 'desc' => esc_html__('The heading to display above the Gravatars.', 'give'), |
|
370 | 370 | 'type' => 'text', |
371 | 371 | 'id' => 'give_donors_gravatars_heading' |
372 | 372 | ), |
373 | 373 | array( |
374 | - 'name' => esc_html__( 'Gravatar Size', 'give' ), |
|
375 | - 'desc' => esc_html__( 'The size of each Gravatar in pixels (512px maximum).', 'give' ), |
|
374 | + 'name' => esc_html__('Gravatar Size', 'give'), |
|
375 | + 'desc' => esc_html__('The size of each Gravatar in pixels (512px maximum).', 'give'), |
|
376 | 376 | 'type' => 'text_small', |
377 | 377 | 'id' => 'give_donors_gravatars_gravatar_size', |
378 | 378 | 'default' => '64' |
379 | 379 | ), |
380 | 380 | array( |
381 | - 'name' => esc_html__( 'Minimum Unique Donations Required', 'give' ), |
|
382 | - 'desc' => esc_html__( 'The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), |
|
381 | + 'name' => esc_html__('Minimum Unique Donations Required', 'give'), |
|
382 | + 'desc' => esc_html__('The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), |
|
383 | 383 | 'type' => 'text_small', |
384 | 384 | 'id' => 'give_donors_gravatars_min_purchases_required', |
385 | 385 | ), |
386 | 386 | array( |
387 | - 'name' => esc_html__( 'Maximum Gravatars To Show', 'give' ), |
|
388 | - 'desc' => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
387 | + 'name' => esc_html__('Maximum Gravatars To Show', 'give'), |
|
388 | + 'desc' => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
389 | 389 | 'type' => 'text', |
390 | 390 | 'id' => 'give_donors_gravatars_maximum_number', |
391 | 391 | 'default' => '20', |
392 | 392 | ), |
393 | 393 | array( |
394 | - 'name' => esc_html__( 'Gravatar Visibility', 'give' ), |
|
395 | - 'desc' => esc_html__( 'Show only donors with a Gravatar account.', 'give' ), |
|
394 | + 'name' => esc_html__('Gravatar Visibility', 'give'), |
|
395 | + 'desc' => esc_html__('Show only donors with a Gravatar account.', 'give'), |
|
396 | 396 | 'id' => 'give_donors_gravatars_has_gravatar_account', |
397 | 397 | 'type' => 'checkbox', |
398 | 398 | ), |
399 | 399 | array( |
400 | - 'name' => esc_html__( 'Randomize Gravatars', 'give' ), |
|
401 | - 'desc' => esc_html__( 'Randomize the Gravatars.', 'give' ), |
|
400 | + 'name' => esc_html__('Randomize Gravatars', 'give'), |
|
401 | + 'desc' => esc_html__('Randomize the Gravatars.', 'give'), |
|
402 | 402 | 'id' => 'give_donors_gravatars_random_gravatars', |
403 | 403 | 'type' => 'checkbox', |
404 | 404 | ), |
405 | 405 | ); |
406 | 406 | |
407 | - return array_merge( $settings, $give_gravatar_settings ); |
|
407 | + return array_merge($settings, $give_gravatar_settings); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | // widget settings |
431 | 431 | $widget_ops = array( |
432 | 432 | 'classname' => 'give-donors-gravatars', |
433 | - 'description' => esc_html__( 'Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give' ), |
|
433 | + 'description' => esc_html__('Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give'), |
|
434 | 434 | ); |
435 | 435 | |
436 | 436 | // widget control settings |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | // create the widget |
444 | 444 | parent::__construct( |
445 | 445 | 'give_donors_gravatars_widget', |
446 | - esc_html__( 'Give Donors Gravatars', 'give' ), |
|
446 | + esc_html__('Give Donors Gravatars', 'give'), |
|
447 | 447 | $widget_ops, |
448 | 448 | $control_ops |
449 | 449 | ); |
@@ -463,29 +463,29 @@ discard block |
||
463 | 463 | * |
464 | 464 | * @return void |
465 | 465 | */ |
466 | - public function widget( $args, $instance ) { |
|
466 | + public function widget($args, $instance) { |
|
467 | 467 | |
468 | 468 | //@TODO: Don't extract it!!! |
469 | - extract( $args ); |
|
469 | + extract($args); |
|
470 | 470 | |
471 | - if ( ! is_singular( 'give_forms' ) ) { |
|
471 | + if ( ! is_singular('give_forms')) { |
|
472 | 472 | return; |
473 | 473 | } |
474 | 474 | |
475 | 475 | // Variables from widget settings |
476 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
476 | + $title = apply_filters('widget_title', $instance['title']); |
|
477 | 477 | |
478 | 478 | // Used by themes. Opens the widget |
479 | 479 | echo $before_widget; |
480 | 480 | |
481 | 481 | // Display the widget title |
482 | - if ( $title ) { |
|
483 | - echo $before_title . $title . $after_title; |
|
482 | + if ($title) { |
|
483 | + echo $before_title.$title.$after_title; |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | $gravatars = new Give_Donors_Gravatars(); |
487 | 487 | |
488 | - echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
488 | + echo $gravatars->gravatars(get_the_ID(), null); // remove title |
|
489 | 489 | |
490 | 490 | // Used by themes. Closes the widget |
491 | 491 | echo $after_widget; |
@@ -505,11 +505,11 @@ discard block |
||
505 | 505 | * |
506 | 506 | * @return array Updated settings to save. |
507 | 507 | */ |
508 | - public function update( $new_instance, $old_instance ) { |
|
508 | + public function update($new_instance, $old_instance) { |
|
509 | 509 | |
510 | 510 | $instance = $old_instance; |
511 | 511 | |
512 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
512 | + $instance['title'] = strip_tags($new_instance['title']); |
|
513 | 513 | |
514 | 514 | return $instance; |
515 | 515 | |
@@ -527,19 +527,19 @@ discard block |
||
527 | 527 | * |
528 | 528 | * @return void |
529 | 529 | */ |
530 | - public function form( $instance ) { |
|
530 | + public function form($instance) { |
|
531 | 531 | |
532 | 532 | // Set up some default widget settings. |
533 | 533 | $defaults = array( |
534 | 534 | 'title' => '', |
535 | 535 | ); |
536 | 536 | |
537 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
537 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
538 | 538 | |
539 | 539 | <!-- Title --> |
540 | 540 | <p> |
541 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label> |
|
542 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
541 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label> |
|
542 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
543 | 543 | </p> |
544 | 544 | |
545 | 545 | <?php |
@@ -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 | |
@@ -25,82 +25,82 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @uses give_pdf |
27 | 27 | */ |
28 | -function give_generate_pdf( $data ) { |
|
28 | +function give_generate_pdf($data) { |
|
29 | 29 | |
30 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
31 | - wp_die( esc_html__( 'You do not have permission to generate PDF sales reports.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! current_user_can('view_give_reports')) { |
|
31 | + wp_die(esc_html__('You do not have permission to generate PDF sales reports.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) { |
|
35 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
34 | + if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) { |
|
35 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
36 | 36 | } |
37 | 37 | |
38 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php'; |
|
39 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/give_pdf.php'; |
|
38 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/fpdf.php'; |
|
39 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/give_pdf.php'; |
|
40 | 40 | |
41 | 41 | $daterange = utf8_decode( |
42 | 42 | sprintf( |
43 | 43 | /* translators: 1: start date 2: end date */ |
44 | - esc_html__( '%1$s to %2$s', 'give' ), |
|
45 | - date_i18n( give_date_format(), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ), |
|
46 | - date_i18n( give_date_format() ) |
|
44 | + esc_html__('%1$s to %2$s', 'give'), |
|
45 | + date_i18n(give_date_format(), mktime(0, 0, 0, 1, 1, date('Y'))), |
|
46 | + date_i18n(give_date_format()) |
|
47 | 47 | ) |
48 | 48 | ); |
49 | 49 | |
50 | 50 | $pdf = new give_pdf(); |
51 | - $pdf->AddPage( 'L', 'A4' ); |
|
51 | + $pdf->AddPage('L', 'A4'); |
|
52 | 52 | |
53 | - $pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) ); |
|
54 | - $pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
55 | - $pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
53 | + $pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give'))); |
|
54 | + $pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
55 | + $pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
56 | 56 | |
57 | - $pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png' ), 247, 8 ); |
|
57 | + $pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL.'assets/images/give-logo-small.png'), 247, 8); |
|
58 | 58 | |
59 | - $pdf->SetMargins( 8, 8, 8 ); |
|
60 | - $pdf->SetX( 8 ); |
|
59 | + $pdf->SetMargins(8, 8, 8); |
|
60 | + $pdf->SetX(8); |
|
61 | 61 | |
62 | - $pdf->SetFont( 'Helvetica', '', 16 ); |
|
63 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
64 | - $pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false ); |
|
62 | + $pdf->SetFont('Helvetica', '', 16); |
|
63 | + $pdf->SetTextColor(50, 50, 50); |
|
64 | + $pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false); |
|
65 | 65 | |
66 | - $pdf->SetFont( 'Helvetica', '', 13 ); |
|
66 | + $pdf->SetFont('Helvetica', '', 13); |
|
67 | 67 | $pdf->Ln(); |
68 | - $pdf->SetTextColor( 150, 150, 150 ); |
|
69 | - $pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false ); |
|
68 | + $pdf->SetTextColor(150, 150, 150); |
|
69 | + $pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false); |
|
70 | 70 | $pdf->Ln(); |
71 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
72 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
73 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false ); |
|
74 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
71 | + $pdf->SetTextColor(50, 50, 50); |
|
72 | + $pdf->SetFont('Helvetica', '', 14); |
|
73 | + $pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false); |
|
74 | + $pdf->SetFont('Helvetica', '', 12); |
|
75 | 75 | |
76 | - $pdf->SetFillColor( 238, 238, 238 ); |
|
77 | - $pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
|
78 | - $pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
|
79 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
|
80 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
|
81 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
|
82 | - $pdf->Cell( 35, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
|
76 | + $pdf->SetFillColor(238, 238, 238); |
|
77 | + $pdf->Cell(70, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true); |
|
78 | + $pdf->Cell(30, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true); |
|
79 | + $pdf->Cell(50, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true); |
|
80 | + $pdf->Cell(50, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true); |
|
81 | + $pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true); |
|
82 | + $pdf->Cell(35, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true); |
|
83 | 83 | |
84 | - $year = date( 'Y' ); |
|
85 | - $give_forms = get_posts( array( 'post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => - 1 ) ); |
|
84 | + $year = date('Y'); |
|
85 | + $give_forms = get_posts(array('post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => -1)); |
|
86 | 86 | |
87 | - if ( $give_forms ) { |
|
88 | - $pdf->SetWidths( array( 70, 30, 50, 50, 45, 35 ) ); |
|
87 | + if ($give_forms) { |
|
88 | + $pdf->SetWidths(array(70, 30, 50, 50, 45, 35)); |
|
89 | 89 | |
90 | - foreach ( $give_forms as $form ): |
|
91 | - $pdf->SetFillColor( 255, 255, 255 ); |
|
90 | + foreach ($give_forms as $form): |
|
91 | + $pdf->SetFillColor(255, 255, 255); |
|
92 | 92 | |
93 | 93 | $title = $form->post_title; |
94 | 94 | |
95 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
95 | + if (give_has_variable_prices($form->ID)) { |
|
96 | 96 | |
97 | - $prices = give_get_variable_prices( $form->ID ); |
|
97 | + $prices = give_get_variable_prices($form->ID); |
|
98 | 98 | |
99 | 99 | $first = $prices[0]['_give_amount']; |
100 | - $last = array_pop( $prices ); |
|
100 | + $last = array_pop($prices); |
|
101 | 101 | $last = $last['_give_amount']; |
102 | 102 | |
103 | - if ( $first < $last ) { |
|
103 | + if ($first < $last) { |
|
104 | 104 | $min = $first; |
105 | 105 | $max = $last; |
106 | 106 | } else { |
@@ -108,51 +108,51 @@ discard block |
||
108 | 108 | $max = $first; |
109 | 109 | } |
110 | 110 | |
111 | - $price = html_entity_decode( give_currency_filter( give_format_amount( $min ) ) . ' - ' . give_currency_filter( give_format_amount( $max ) ) ); |
|
111 | + $price = html_entity_decode(give_currency_filter(give_format_amount($min)).' - '.give_currency_filter(give_format_amount($max))); |
|
112 | 112 | } else { |
113 | - $price = html_entity_decode( give_currency_filter( give_get_form_price( $form->ID ) ) ); |
|
113 | + $price = html_entity_decode(give_currency_filter(give_get_form_price($form->ID))); |
|
114 | 114 | } |
115 | 115 | |
116 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
117 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
116 | + $categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', ''); |
|
117 | + $categories = ! is_wp_error($categories) ? strip_tags($categories) : ''; |
|
118 | 118 | |
119 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
120 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
119 | + $tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', ''); |
|
120 | + $tags = ! is_wp_error($tags) ? strip_tags($tags) : ''; |
|
121 | 121 | |
122 | - $sales = give_get_form_sales_stats( $form->ID ); |
|
123 | - $link = get_permalink( $form->ID ); |
|
124 | - $earnings = html_entity_decode( give_currency_filter( give_get_form_earnings_stats( $form->ID ) ) ); |
|
122 | + $sales = give_get_form_sales_stats($form->ID); |
|
123 | + $link = get_permalink($form->ID); |
|
124 | + $earnings = html_entity_decode(give_currency_filter(give_get_form_earnings_stats($form->ID))); |
|
125 | 125 | |
126 | - if ( function_exists( 'iconv' ) ) { |
|
126 | + if (function_exists('iconv')) { |
|
127 | 127 | // Ensure characters like euro; are properly converted. |
128 | - $price = iconv( 'UTF-8', 'windows-1252', utf8_encode( $price ) ); |
|
129 | - $earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) ); |
|
128 | + $price = iconv('UTF-8', 'windows-1252', utf8_encode($price)); |
|
129 | + $earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings)); |
|
130 | 130 | } |
131 | 131 | |
132 | - $pdf->Row( array( $title, $price, $categories, $tags, $sales, $earnings ) ); |
|
132 | + $pdf->Row(array($title, $price, $categories, $tags, $sales, $earnings)); |
|
133 | 133 | endforeach; |
134 | 134 | } else { |
135 | - $pdf->SetWidths( array( 280 ) ); |
|
136 | - $title = utf8_decode( esc_html__( 'No forms found.', 'give' ) ); |
|
137 | - $pdf->Row( array( $title ) ); |
|
135 | + $pdf->SetWidths(array(280)); |
|
136 | + $title = utf8_decode(esc_html__('No forms found.', 'give')); |
|
137 | + $pdf->Row(array($title)); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $pdf->Ln(); |
141 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
142 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
143 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false ); |
|
144 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
145 | - |
|
146 | - $image = html_entity_decode( urldecode( give_draw_chart_image() ) ); |
|
147 | - $image = str_replace( ' ', '%20', $image ); |
|
148 | - |
|
149 | - $pdf->SetX( 25 ); |
|
150 | - $pdf->Image( $image . '&file=.png' ); |
|
151 | - $pdf->Ln( 7 ); |
|
152 | - $pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' ); |
|
141 | + $pdf->SetTextColor(50, 50, 50); |
|
142 | + $pdf->SetFont('Helvetica', '', 14); |
|
143 | + $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false); |
|
144 | + $pdf->SetFont('Helvetica', '', 12); |
|
145 | + |
|
146 | + $image = html_entity_decode(urldecode(give_draw_chart_image())); |
|
147 | + $image = str_replace(' ', '%20', $image); |
|
148 | + |
|
149 | + $pdf->SetX(25); |
|
150 | + $pdf->Image($image.'&file=.png'); |
|
151 | + $pdf->Ln(7); |
|
152 | + $pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D'); |
|
153 | 153 | } |
154 | 154 | |
155 | -add_action( 'give_generate_pdf', 'give_generate_pdf' ); |
|
155 | +add_action('give_generate_pdf', 'give_generate_pdf'); |
|
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Draws Chart for PDF Report. |
@@ -169,38 +169,38 @@ discard block |
||
169 | 169 | * @return string $chart->getUrl() URL for the Google Chart |
170 | 170 | */ |
171 | 171 | function give_draw_chart_image() { |
172 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php'; |
|
173 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
174 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
172 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php'; |
|
173 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
174 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
175 | 175 | |
176 | - $chart = new GoogleChart( 'lc', 900, 330 ); |
|
176 | + $chart = new GoogleChart('lc', 900, 330); |
|
177 | 177 | |
178 | 178 | $i = 1; |
179 | 179 | $earnings = ""; |
180 | 180 | $sales = ""; |
181 | 181 | |
182 | - while ( $i <= 12 ) : |
|
183 | - $earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ","; |
|
184 | - $sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ","; |
|
185 | - $i ++; |
|
182 | + while ($i <= 12) : |
|
183 | + $earnings .= give_get_earnings_by_date(null, $i, date('Y')).","; |
|
184 | + $sales .= give_get_sales_by_date(null, $i, date('Y')).","; |
|
185 | + $i++; |
|
186 | 186 | endwhile; |
187 | 187 | |
188 | - $earnings_array = explode( ",", $earnings ); |
|
189 | - $sales_array = explode( ",", $sales ); |
|
188 | + $earnings_array = explode(",", $earnings); |
|
189 | + $sales_array = explode(",", $sales); |
|
190 | 190 | |
191 | 191 | $i = 0; |
192 | - while ( $i <= 11 ) { |
|
193 | - if ( empty( $sales_array[ $i ] ) ) { |
|
194 | - $sales_array[ $i ] = 0; |
|
192 | + while ($i <= 11) { |
|
193 | + if (empty($sales_array[$i])) { |
|
194 | + $sales_array[$i] = 0; |
|
195 | 195 | } |
196 | - $i ++; |
|
196 | + $i++; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | $min_earnings = 0; |
200 | - $max_earnings = max( $earnings_array ); |
|
201 | - $earnings_scale = round( $max_earnings, - 1 ); |
|
200 | + $max_earnings = max($earnings_array); |
|
201 | + $earnings_scale = round($max_earnings, - 1); |
|
202 | 202 | |
203 | - $data = new GoogleChartData( array( |
|
203 | + $data = new GoogleChartData(array( |
|
204 | 204 | $earnings_array[0], |
205 | 205 | $earnings_array[1], |
206 | 206 | $earnings_array[2], |
@@ -213,25 +213,25 @@ discard block |
||
213 | 213 | $earnings_array[9], |
214 | 214 | $earnings_array[10], |
215 | 215 | $earnings_array[11] |
216 | - ) ); |
|
216 | + )); |
|
217 | 217 | |
218 | - $data->setLegend( esc_html__( 'Income', 'give' ) ); |
|
219 | - $data->setColor( '1b58a3' ); |
|
220 | - $chart->addData( $data ); |
|
218 | + $data->setLegend(esc_html__('Income', 'give')); |
|
219 | + $data->setColor('1b58a3'); |
|
220 | + $chart->addData($data); |
|
221 | 221 | |
222 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
223 | - $shape_marker->setColor( '000000' ); |
|
224 | - $shape_marker->setSize( 7 ); |
|
225 | - $shape_marker->setBorder( 2 ); |
|
226 | - $shape_marker->setData( $data ); |
|
227 | - $chart->addMarker( $shape_marker ); |
|
222 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
223 | + $shape_marker->setColor('000000'); |
|
224 | + $shape_marker->setSize(7); |
|
225 | + $shape_marker->setBorder(2); |
|
226 | + $shape_marker->setData($data); |
|
227 | + $chart->addMarker($shape_marker); |
|
228 | 228 | |
229 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
230 | - $value_marker->setColor( '000000' ); |
|
231 | - $value_marker->setData( $data ); |
|
232 | - $chart->addMarker( $value_marker ); |
|
229 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
230 | + $value_marker->setColor('000000'); |
|
231 | + $value_marker->setData($data); |
|
232 | + $chart->addMarker($value_marker); |
|
233 | 233 | |
234 | - $data = new GoogleChartData( array( |
|
234 | + $data = new GoogleChartData(array( |
|
235 | 235 | $sales_array[0], |
236 | 236 | $sales_array[1], |
237 | 237 | $sales_array[2], |
@@ -244,46 +244,46 @@ discard block |
||
244 | 244 | $sales_array[9], |
245 | 245 | $sales_array[10], |
246 | 246 | $sales_array[11] |
247 | - ) ); |
|
248 | - $data->setLegend( esc_html__( 'Donations', 'give' ) ); |
|
249 | - $data->setColor( 'ff6c1c' ); |
|
250 | - $chart->addData( $data ); |
|
251 | - |
|
252 | - $chart->setTitle( esc_html__( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 ); |
|
253 | - |
|
254 | - $chart->setScale( 0, $max_earnings ); |
|
255 | - |
|
256 | - $y_axis = new GoogleChartAxis( 'y' ); |
|
257 | - $y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) ); |
|
258 | - $chart->addAxis( $y_axis ); |
|
259 | - |
|
260 | - $x_axis = new GoogleChartAxis( 'x' ); |
|
261 | - $x_axis->setTickMarks( 5 ); |
|
262 | - $x_axis->setLabels( array( |
|
263 | - esc_html__( 'Jan', 'give' ), |
|
264 | - esc_html__( 'Feb', 'give' ), |
|
265 | - esc_html__( 'Mar', 'give' ), |
|
266 | - esc_html__( 'Apr', 'give' ), |
|
267 | - esc_html__( 'May', 'give' ), |
|
268 | - esc_html__( 'June', 'give' ), |
|
269 | - esc_html__( 'July', 'give' ), |
|
270 | - esc_html__( 'Aug', 'give' ), |
|
271 | - esc_html__( 'Sept', 'give' ), |
|
272 | - esc_html__( 'Oct', 'give' ), |
|
273 | - esc_html__( 'Nov', 'give' ), |
|
274 | - esc_html__( 'Dec', 'give' ) |
|
275 | - ) ); |
|
276 | - $chart->addAxis( $x_axis ); |
|
277 | - |
|
278 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
279 | - $shape_marker->setSize( 6 ); |
|
280 | - $shape_marker->setBorder( 2 ); |
|
281 | - $shape_marker->setData( $data ); |
|
282 | - $chart->addMarker( $shape_marker ); |
|
283 | - |
|
284 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
285 | - $value_marker->setData( $data ); |
|
286 | - $chart->addMarker( $value_marker ); |
|
247 | + )); |
|
248 | + $data->setLegend(esc_html__('Donations', 'give')); |
|
249 | + $data->setColor('ff6c1c'); |
|
250 | + $chart->addData($data); |
|
251 | + |
|
252 | + $chart->setTitle(esc_html__('Donations by Month for all Give Forms', 'give'), '336699', 18); |
|
253 | + |
|
254 | + $chart->setScale(0, $max_earnings); |
|
255 | + |
|
256 | + $y_axis = new GoogleChartAxis('y'); |
|
257 | + $y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings)); |
|
258 | + $chart->addAxis($y_axis); |
|
259 | + |
|
260 | + $x_axis = new GoogleChartAxis('x'); |
|
261 | + $x_axis->setTickMarks(5); |
|
262 | + $x_axis->setLabels(array( |
|
263 | + esc_html__('Jan', 'give'), |
|
264 | + esc_html__('Feb', 'give'), |
|
265 | + esc_html__('Mar', 'give'), |
|
266 | + esc_html__('Apr', 'give'), |
|
267 | + esc_html__('May', 'give'), |
|
268 | + esc_html__('June', 'give'), |
|
269 | + esc_html__('July', 'give'), |
|
270 | + esc_html__('Aug', 'give'), |
|
271 | + esc_html__('Sept', 'give'), |
|
272 | + esc_html__('Oct', 'give'), |
|
273 | + esc_html__('Nov', 'give'), |
|
274 | + esc_html__('Dec', 'give') |
|
275 | + )); |
|
276 | + $chart->addAxis($x_axis); |
|
277 | + |
|
278 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
279 | + $shape_marker->setSize(6); |
|
280 | + $shape_marker->setBorder(2); |
|
281 | + $shape_marker->setData($data); |
|
282 | + $chart->addMarker($shape_marker); |
|
283 | + |
|
284 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
285 | + $value_marker->setData($data); |
|
286 | + $chart->addMarker($value_marker); |
|
287 | 287 | |
288 | 288 | return $chart->getUrl(); |
289 | 289 | } |
@@ -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 | |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | * @param $_step int The step to process |
107 | 107 | * @since 1.5 |
108 | 108 | */ |
109 | - public function __construct( $_step = 1 ) { |
|
109 | + public function __construct($_step = 1) { |
|
110 | 110 | |
111 | 111 | $upload_dir = wp_upload_dir(); |
112 | 112 | $this->filetype = '.csv'; |
113 | - $this->filename = 'give-' . $this->export_type . $this->filetype; |
|
114 | - $this->file = trailingslashit( $upload_dir['basedir'] ) . $this->filename; |
|
113 | + $this->filename = 'give-'.$this->export_type.$this->filetype; |
|
114 | + $this->file = trailingslashit($upload_dir['basedir']).$this->filename; |
|
115 | 115 | |
116 | - if ( ! is_writeable( $upload_dir['basedir'] ) ) { |
|
116 | + if ( ! is_writeable($upload_dir['basedir'])) { |
|
117 | 117 | $this->is_writable = false; |
118 | 118 | } |
119 | 119 | |
@@ -129,20 +129,20 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function process_step() { |
131 | 131 | |
132 | - if ( ! $this->can_export() ) { |
|
133 | - wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
132 | + if ( ! $this->can_export()) { |
|
133 | + wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
134 | 134 | } |
135 | 135 | |
136 | - if( $this->step < 2 ) { |
|
136 | + if ($this->step < 2) { |
|
137 | 137 | |
138 | 138 | // Make sure we start with a fresh file on step 1 |
139 | - @unlink( $this->file ); |
|
139 | + @unlink($this->file); |
|
140 | 140 | $this->print_csv_cols(); |
141 | 141 | } |
142 | 142 | |
143 | 143 | $rows = $this->print_csv_rows(); |
144 | 144 | |
145 | - if( $rows ) { |
|
145 | + if ($rows) { |
|
146 | 146 | return true; |
147 | 147 | } else { |
148 | 148 | return false; |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | $col_data = ''; |
163 | 163 | $cols = $this->get_csv_cols(); |
164 | 164 | $i = 1; |
165 | - foreach( $cols as $col_id => $column ) { |
|
166 | - $col_data .= '"' . addslashes( $column ) . '"'; |
|
167 | - $col_data .= $i == count( $cols ) ? '' : ','; |
|
165 | + foreach ($cols as $col_id => $column) { |
|
166 | + $col_data .= '"'.addslashes($column).'"'; |
|
167 | + $col_data .= $i == count($cols) ? '' : ','; |
|
168 | 168 | $i++; |
169 | 169 | } |
170 | 170 | $col_data .= "\r\n"; |
171 | 171 | |
172 | - $this->stash_step_data( $col_data ); |
|
172 | + $this->stash_step_data($col_data); |
|
173 | 173 | |
174 | 174 | return $col_data; |
175 | 175 | |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | $data = $this->get_data(); |
189 | 189 | $cols = $this->get_csv_cols(); |
190 | 190 | |
191 | - if( $data ) { |
|
191 | + if ($data) { |
|
192 | 192 | |
193 | 193 | // Output each row |
194 | - foreach ( $data as $row ) { |
|
194 | + foreach ($data as $row) { |
|
195 | 195 | $i = 1; |
196 | - foreach ( $row as $col_id => $column ) { |
|
196 | + foreach ($row as $col_id => $column) { |
|
197 | 197 | // Make sure the column is valid |
198 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
199 | - $row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"'; |
|
200 | - $row_data .= $i == count( $cols ) ? '' : ','; |
|
198 | + if (array_key_exists($col_id, $cols)) { |
|
199 | + $row_data .= '"'.addslashes(preg_replace("/\"/", "'", $column)).'"'; |
|
200 | + $row_data .= $i == count($cols) ? '' : ','; |
|
201 | 201 | $i++; |
202 | 202 | } |
203 | 203 | } |
204 | 204 | $row_data .= "\r\n"; |
205 | 205 | } |
206 | 206 | |
207 | - $this->stash_step_data( $row_data ); |
|
207 | + $this->stash_step_data($row_data); |
|
208 | 208 | |
209 | 209 | return $row_data; |
210 | 210 | } |
@@ -232,18 +232,18 @@ discard block |
||
232 | 232 | |
233 | 233 | $file = ''; |
234 | 234 | |
235 | - if ( @file_exists( $this->file ) ) { |
|
235 | + if (@file_exists($this->file)) { |
|
236 | 236 | |
237 | - if ( ! is_writeable( $this->file ) ) { |
|
237 | + if ( ! is_writeable($this->file)) { |
|
238 | 238 | $this->is_writable = false; |
239 | 239 | } |
240 | 240 | |
241 | - $file = @file_get_contents( $this->file ); |
|
241 | + $file = @file_get_contents($this->file); |
|
242 | 242 | |
243 | 243 | } else { |
244 | 244 | |
245 | - @file_put_contents( $this->file, '' ); |
|
246 | - @chmod( $this->file, 0664 ); |
|
245 | + @file_put_contents($this->file, ''); |
|
246 | + @chmod($this->file, 0664); |
|
247 | 247 | |
248 | 248 | } |
249 | 249 | |
@@ -257,18 +257,18 @@ discard block |
||
257 | 257 | * @param $data string The data to add to the file |
258 | 258 | * @return void |
259 | 259 | */ |
260 | - protected function stash_step_data( $data = '' ) { |
|
260 | + protected function stash_step_data($data = '') { |
|
261 | 261 | |
262 | 262 | $file = $this->get_file(); |
263 | 263 | $file .= $data; |
264 | - @file_put_contents( $this->file, $file ); |
|
264 | + @file_put_contents($this->file, $file); |
|
265 | 265 | |
266 | 266 | // If we have no rows after this step, mark it as an empty export |
267 | - $file_rows = file( $this->file, FILE_SKIP_EMPTY_LINES); |
|
267 | + $file_rows = file($this->file, FILE_SKIP_EMPTY_LINES); |
|
268 | 268 | $default_cols = $this->get_csv_cols(); |
269 | - $default_cols = empty( $default_cols ) ? 0 : 1; |
|
269 | + $default_cols = empty($default_cols) ? 0 : 1; |
|
270 | 270 | |
271 | - $this->is_empty = count( $file_rows ) == $default_cols ? true : false; |
|
271 | + $this->is_empty = count($file_rows) == $default_cols ? true : false; |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | |
287 | 287 | $file = $this->get_file(); |
288 | 288 | |
289 | - @unlink( $this->file ); |
|
289 | + @unlink($this->file); |
|
290 | 290 | |
291 | 291 | echo $file; |
292 | 292 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @since 1.5 |
300 | 300 | * @param array $request The Form Data passed into the batch processing |
301 | 301 | */ |
302 | - public function set_properties( $request ) {} |
|
302 | + public function set_properties($request) {} |
|
303 | 303 | |
304 | 304 | /** |
305 | 305 | * Allow for prefetching of data for the remainder of the exporter |
@@ -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 | |
@@ -46,16 +46,16 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @param array $request The Form Data passed into the batch processing |
48 | 48 | */ |
49 | - public function set_properties( $request ) { |
|
49 | + public function set_properties($request) { |
|
50 | 50 | |
51 | 51 | //Set data from form submission |
52 | - if ( isset( $_POST['form'] ) ) { |
|
53 | - parse_str( $_POST['form'], $this->data ); |
|
52 | + if (isset($_POST['form'])) { |
|
53 | + parse_str($_POST['form'], $this->data); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | $this->form = $this->data['forms']; |
57 | 57 | |
58 | - $this->price_id = ! empty( $request['give_price_option'] ) && 0 !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null; |
|
58 | + $this->price_id = ! empty($request['give_price_option']) && 0 !== $request['give_price_option'] ? absint($request['give_price_option']) : null; |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | |
71 | 71 | $cols = array(); |
72 | 72 | |
73 | - $columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array(); |
|
73 | + $columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array(); |
|
74 | 74 | |
75 | 75 | //We need columns. |
76 | - if ( empty( $columns ) ) { |
|
76 | + if (empty($columns)) { |
|
77 | 77 | return false; |
78 | 78 | } |
79 | 79 | |
80 | - $cols = $this->get_cols( $columns ); |
|
80 | + $cols = $this->get_cols($columns); |
|
81 | 81 | |
82 | 82 | return $cols; |
83 | 83 | } |
@@ -85,38 +85,38 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * @param $column |
87 | 87 | */ |
88 | - private function get_cols( $columns ) { |
|
88 | + private function get_cols($columns) { |
|
89 | 89 | |
90 | 90 | $cols = array(); |
91 | 91 | |
92 | - foreach ( $columns as $key => $value ) { |
|
92 | + foreach ($columns as $key => $value) { |
|
93 | 93 | |
94 | - switch ( $key ) { |
|
94 | + switch ($key) { |
|
95 | 95 | case 'full_name' : |
96 | - $cols['full_name'] = esc_html__( 'Full Name', 'give' ); |
|
96 | + $cols['full_name'] = esc_html__('Full Name', 'give'); |
|
97 | 97 | break; |
98 | 98 | case 'email' : |
99 | - $cols['email'] = esc_html__( 'Email Address', 'give' ); |
|
99 | + $cols['email'] = esc_html__('Email Address', 'give'); |
|
100 | 100 | break; |
101 | 101 | case 'address' : |
102 | - $cols['address_line1'] = esc_html__( 'Address', 'give' ); |
|
103 | - $cols['address_line2'] = esc_html__( 'Address 2', 'give' ); |
|
104 | - $cols['address_city'] = esc_html__( 'City', 'give' ); |
|
105 | - $cols['address_state'] = esc_html__( 'State', 'give' ); |
|
106 | - $cols['address_zip'] = esc_html__( 'Zip', 'give' ); |
|
107 | - $cols['address_country'] = esc_html__( 'Country', 'give' ); |
|
102 | + $cols['address_line1'] = esc_html__('Address', 'give'); |
|
103 | + $cols['address_line2'] = esc_html__('Address 2', 'give'); |
|
104 | + $cols['address_city'] = esc_html__('City', 'give'); |
|
105 | + $cols['address_state'] = esc_html__('State', 'give'); |
|
106 | + $cols['address_zip'] = esc_html__('Zip', 'give'); |
|
107 | + $cols['address_country'] = esc_html__('Country', 'give'); |
|
108 | 108 | break; |
109 | 109 | case 'userid' : |
110 | - $cols['userid'] = esc_html__( 'User ID', 'give' ); |
|
110 | + $cols['userid'] = esc_html__('User ID', 'give'); |
|
111 | 111 | break; |
112 | 112 | case 'date_first_donated' : |
113 | - $cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' ); |
|
113 | + $cols['date_first_donated'] = esc_html__('First Donation Date', 'give'); |
|
114 | 114 | break; |
115 | 115 | case 'donations' : |
116 | - $cols['donations'] = esc_html__( 'Number of Donations', 'give' ); |
|
116 | + $cols['donations'] = esc_html__('Number of Donations', 'give'); |
|
117 | 117 | break; |
118 | 118 | case 'donation_sum' : |
119 | - $cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' ); |
|
119 | + $cols['donation_sum'] = esc_html__('Sum of Donations', 'give'); |
|
120 | 120 | break; |
121 | 121 | } |
122 | 122 | } |
@@ -139,20 +139,20 @@ discard block |
||
139 | 139 | |
140 | 140 | $i = 0; |
141 | 141 | |
142 | - if ( ! empty( $this->form ) ) { |
|
142 | + if ( ! empty($this->form)) { |
|
143 | 143 | |
144 | 144 | // Export donors of a specific product |
145 | 145 | global $give_logs; |
146 | 146 | |
147 | 147 | $args = array( |
148 | - 'post_parent' => absint( $this->form ), |
|
148 | + 'post_parent' => absint($this->form), |
|
149 | 149 | 'log_type' => 'sale', |
150 | 150 | 'posts_per_page' => 30, |
151 | 151 | 'paged' => $this->step |
152 | 152 | ); |
153 | 153 | |
154 | 154 | //Check for price option |
155 | - if ( null !== $this->price_id ) { |
|
155 | + if (null !== $this->price_id) { |
|
156 | 156 | $args['meta_query'] = array( |
157 | 157 | array( |
158 | 158 | 'key' => '_give_log_price_id', |
@@ -161,33 +161,33 @@ discard block |
||
161 | 161 | ); |
162 | 162 | } |
163 | 163 | |
164 | - $logs = $give_logs->get_connected_logs( $args ); |
|
164 | + $logs = $give_logs->get_connected_logs($args); |
|
165 | 165 | |
166 | - if ( $logs ) { |
|
167 | - foreach ( $logs as $log ) { |
|
168 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
169 | - $payment = new Give_Payment( $payment_id ); |
|
170 | - $donor = Give()->customers->get_customer_by( 'id', $payment->customer_id ); |
|
171 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
172 | - $i ++; |
|
166 | + if ($logs) { |
|
167 | + foreach ($logs as $log) { |
|
168 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
169 | + $payment = new Give_Payment($payment_id); |
|
170 | + $donor = Give()->customers->get_customer_by('id', $payment->customer_id); |
|
171 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
172 | + $i++; |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | 176 | } else { |
177 | 177 | |
178 | 178 | // Export all customers |
179 | - $offset = 30 * ( $this->step - 1 ); |
|
180 | - $donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) ); |
|
179 | + $offset = 30 * ($this->step - 1); |
|
180 | + $donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset)); |
|
181 | 181 | |
182 | - foreach ( $donors as $donor ) { |
|
182 | + foreach ($donors as $donor) { |
|
183 | 183 | |
184 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
185 | - $i ++; |
|
184 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
185 | + $i++; |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
190 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
189 | + $data = apply_filters('give_export_get_data', $data); |
|
190 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
191 | 191 | |
192 | 192 | return $data; |
193 | 193 | } |
@@ -203,19 +203,19 @@ discard block |
||
203 | 203 | $percentage = 0; |
204 | 204 | |
205 | 205 | // We can't count the number when getting them for a specific form |
206 | - if ( empty( $this->form ) ) { |
|
206 | + if (empty($this->form)) { |
|
207 | 207 | |
208 | 208 | $total = Give()->customers->count(); |
209 | 209 | |
210 | - if ( $total > 0 ) { |
|
210 | + if ($total > 0) { |
|
211 | 211 | |
212 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
212 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
213 | 213 | |
214 | 214 | } |
215 | 215 | |
216 | 216 | } |
217 | 217 | |
218 | - if ( $percentage > 100 ) { |
|
218 | + if ($percentage > 100) { |
|
219 | 219 | $percentage = 100; |
220 | 220 | } |
221 | 221 | |
@@ -227,46 +227,46 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @param $donor |
229 | 229 | */ |
230 | - private function set_donor_data( $i, $data, $donor ) { |
|
230 | + private function set_donor_data($i, $data, $donor) { |
|
231 | 231 | |
232 | 232 | $columns = $this->csv_cols(); |
233 | 233 | |
234 | 234 | //Set address variable |
235 | 235 | $address = ''; |
236 | - if ( isset( $donor->user_id ) && $donor->user_id > 0 ) { |
|
237 | - $address = give_get_donor_address( $donor->user_id ); |
|
236 | + if (isset($donor->user_id) && $donor->user_id > 0) { |
|
237 | + $address = give_get_donor_address($donor->user_id); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | //Set columns |
241 | - if ( ! empty( $columns['full_name'] ) ) { |
|
242 | - $data[ $i ]['full_name'] = $donor->name; |
|
241 | + if ( ! empty($columns['full_name'])) { |
|
242 | + $data[$i]['full_name'] = $donor->name; |
|
243 | 243 | } |
244 | - if ( ! empty( $columns['email'] ) ) { |
|
245 | - $data[ $i ]['email'] = $donor->email; |
|
244 | + if ( ! empty($columns['email'])) { |
|
245 | + $data[$i]['email'] = $donor->email; |
|
246 | 246 | } |
247 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
248 | - |
|
249 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
250 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
251 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
252 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
253 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
254 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
247 | + if ( ! empty($columns['address_line1'])) { |
|
248 | + |
|
249 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
250 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
251 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
252 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
253 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
254 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
255 | 255 | } |
256 | - if ( ! empty( $columns['userid'] ) ) { |
|
257 | - $data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : ''; |
|
256 | + if ( ! empty($columns['userid'])) { |
|
257 | + $data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : ''; |
|
258 | 258 | } |
259 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
260 | - $data[ $i ]['date_first_donated'] = date_i18n( give_date_format(), strtotime( $donor->date_created ) ); |
|
259 | + if ( ! empty($columns['date_first_donated'])) { |
|
260 | + $data[$i]['date_first_donated'] = date_i18n(give_date_format(), strtotime($donor->date_created)); |
|
261 | 261 | } |
262 | - if ( ! empty( $columns['donations'] ) ) { |
|
263 | - $data[ $i ]['donations'] = $donor->purchase_count; |
|
262 | + if ( ! empty($columns['donations'])) { |
|
263 | + $data[$i]['donations'] = $donor->purchase_count; |
|
264 | 264 | } |
265 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
266 | - $data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value ); |
|
265 | + if ( ! empty($columns['donation_sum'])) { |
|
266 | + $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value); |
|
267 | 267 | } |
268 | 268 | |
269 | - return $data[ $i ]; |
|
269 | + return $data[$i]; |
|
270 | 270 | |
271 | 271 | } |
272 | 272 |
@@ -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 | |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | 23 | |
24 | - $this->shortcode['label'] = esc_html__( 'Donation History', 'give' ); |
|
24 | + $this->shortcode['label'] = esc_html__('Donation History', 'give'); |
|
25 | 25 | |
26 | - parent::__construct( 'donation_history' ); |
|
26 | + parent::__construct('donation_history'); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 |
@@ -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 | |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | 23 | |
24 | - $this->shortcode['title'] = esc_html__( 'Register', 'give' ); |
|
25 | - $this->shortcode['label'] = esc_html__( 'Register', 'give' ); |
|
24 | + $this->shortcode['title'] = esc_html__('Register', 'give'); |
|
25 | + $this->shortcode['label'] = esc_html__('Register', 'give'); |
|
26 | 26 | |
27 | - parent::__construct( 'give_register' ); |
|
27 | + parent::__construct('give_register'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | return array( |
38 | 38 | array( |
39 | 39 | 'type' => 'container', |
40 | - 'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Redirect URL (optional):', 'give' ) ), |
|
40 | + 'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Redirect URL (optional):', 'give')), |
|
41 | 41 | ), |
42 | 42 | array( |
43 | 43 | 'type' => 'textbox', |
44 | 44 | 'name' => 'redirect', |
45 | 45 | 'minWidth' => 320, |
46 | - 'tooltip' => esc_attr__( 'Enter an URL here to redirect to after registering.', 'give' ), |
|
46 | + 'tooltip' => esc_attr__('Enter an URL here to redirect to after registering.', 'give'), |
|
47 | 47 | ), |
48 | 48 | ); |
49 | 49 | } |