@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | global $status, $page; |
51 | 51 | |
52 | 52 | // Set parent defaults |
53 | - parent::__construct( array( |
|
54 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
55 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
53 | + parent::__construct(array( |
|
54 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
55 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
56 | 56 | 'ajax' => false // Does this table support ajax? |
57 | - ) ); |
|
57 | + )); |
|
58 | 58 | |
59 | - add_action( 'give_report_view_actions', array( $this, 'category_filter' ) ); |
|
59 | + add_action('give_report_view_actions', array($this, 'category_filter')); |
|
60 | 60 | $this->query(); |
61 | 61 | |
62 | 62 | } |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return string Column Name |
74 | 74 | */ |
75 | - public function column_default( $item, $column_name ) { |
|
76 | - switch ( $column_name ) { |
|
75 | + public function column_default($item, $column_name) { |
|
76 | + switch ($column_name) { |
|
77 | 77 | case 'earnings' : |
78 | - return give_currency_filter( give_format_amount( $item[ $column_name ] ) ); |
|
78 | + return give_currency_filter(give_format_amount($item[$column_name])); |
|
79 | 79 | case 'average_sales' : |
80 | - return round( $item[ $column_name ] ); |
|
80 | + return round($item[$column_name]); |
|
81 | 81 | case 'average_earnings' : |
82 | - return give_currency_filter( give_format_amount( $item[ $column_name ] ) ); |
|
82 | + return give_currency_filter(give_format_amount($item[$column_name])); |
|
83 | 83 | case 'details' : |
84 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $item['ID'] ) . '">' . esc_html__( 'View Detailed Report', 'give' ) . '</a>'; |
|
84 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$item['ID']).'">'.esc_html__('View Detailed Report', 'give').'</a>'; |
|
85 | 85 | default: |
86 | - return $item[ $column_name ]; |
|
86 | + return $item[$column_name]; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | public function get_columns() { |
98 | 98 | $columns = array( |
99 | 99 | 'title' => give_get_forms_label_singular(), |
100 | - 'sales' => esc_html__( 'Donations', 'give' ), |
|
101 | - 'earnings' => esc_html__( 'Income', 'give' ), |
|
102 | - 'average_sales' => esc_html__( 'Monthly Average Donations', 'give' ), |
|
103 | - 'average_earnings' => esc_html__( 'Monthly Average Income', 'give' ), |
|
104 | - 'details' => esc_html__( 'Detailed Report', 'give' ) |
|
100 | + 'sales' => esc_html__('Donations', 'give'), |
|
101 | + 'earnings' => esc_html__('Income', 'give'), |
|
102 | + 'average_sales' => esc_html__('Monthly Average Donations', 'give'), |
|
103 | + 'average_earnings' => esc_html__('Monthly Average Income', 'give'), |
|
104 | + 'details' => esc_html__('Detailed Report', 'give') |
|
105 | 105 | ); |
106 | 106 | |
107 | 107 | return $columns; |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function get_sortable_columns() { |
118 | 118 | return array( |
119 | - 'title' => array( 'title', true ), |
|
120 | - 'sales' => array( 'sales', false ), |
|
121 | - 'earnings' => array( 'earnings', false ), |
|
119 | + 'title' => array('title', true), |
|
120 | + 'sales' => array('sales', false), |
|
121 | + 'earnings' => array('earnings', false), |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @return int Current page number |
131 | 131 | */ |
132 | 132 | public function get_paged() { |
133 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
133 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @return int Category ID |
143 | 143 | */ |
144 | 144 | public function get_category() { |
145 | - return isset( $_GET['category'] ) ? absint( $_GET['category'] ) : 0; |
|
145 | + return isset($_GET['category']) ? absint($_GET['category']) : 0; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function get_total_forms() { |
157 | 157 | $total = 0; |
158 | - $counts = wp_count_posts( 'give_forms', 'readable' ); |
|
159 | - foreach ( $counts as $status => $count ) { |
|
158 | + $counts = wp_count_posts('give_forms', 'readable'); |
|
159 | + foreach ($counts as $status => $count) { |
|
160 | 160 | $total += $count; |
161 | 161 | } |
162 | 162 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @since 1.0 |
171 | 171 | * @return void |
172 | 172 | */ |
173 | - public function bulk_actions( $which = '' ) { |
|
173 | + public function bulk_actions($which = '') { |
|
174 | 174 | // These aren't really bulk actions but this outputs the markup in the right place |
175 | 175 | give_report_views(); |
176 | 176 | } |
@@ -183,23 +183,23 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param string $which |
185 | 185 | */ |
186 | - protected function display_tablenav( $which ) { |
|
186 | + protected function display_tablenav($which) { |
|
187 | 187 | |
188 | - if ( 'top' == $which ) { |
|
189 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
188 | + if ('top' == $which) { |
|
189 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
190 | 190 | } |
191 | 191 | ?> |
192 | - <div class="tablenav give-clearfix <?php esc_attr_e( $which ); ?>"> |
|
192 | + <div class="tablenav give-clearfix <?php esc_attr_e($which); ?>"> |
|
193 | 193 | |
194 | - <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Donation Forms Report', 'give' ); ?></span></h3> |
|
194 | + <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Donation Forms Report', 'give'); ?></span></h3> |
|
195 | 195 | |
196 | 196 | <div class="alignright tablenav-right"> |
197 | 197 | <div class="actions bulkactions"> |
198 | - <?php $this->bulk_actions( $which ); ?> |
|
198 | + <?php $this->bulk_actions($which); ?> |
|
199 | 199 | </div> |
200 | 200 | <?php |
201 | - $this->extra_tablenav( $which ); |
|
202 | - $this->pagination( $which ); |
|
201 | + $this->extra_tablenav($which); |
|
202 | + $this->pagination($which); |
|
203 | 203 | ?> |
204 | 204 | </div> |
205 | 205 | |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public function category_filter() { |
221 | 221 | |
222 | - $categories = get_terms( 'form_category' ); |
|
223 | - if ( $categories && ! is_wp_error( $categories ) ) { |
|
224 | - echo Give()->html->category_dropdown( 'category', $this->get_category() ); |
|
222 | + $categories = get_terms('form_category'); |
|
223 | + if ($categories && ! is_wp_error($categories)) { |
|
224 | + echo Give()->html->category_dropdown('category', $this->get_category()); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function query() { |
237 | 237 | |
238 | - $orderby = isset( $_GET['orderby'] ) ? $_GET['orderby'] : 'title'; |
|
239 | - $order = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC'; |
|
238 | + $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : 'title'; |
|
239 | + $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; |
|
240 | 240 | $category = $this->get_category(); |
241 | 241 | |
242 | 242 | $args = array( |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | 'suppress_filters' => true |
250 | 250 | ); |
251 | 251 | |
252 | - if ( ! empty( $category ) ) { |
|
252 | + if ( ! empty($category)) { |
|
253 | 253 | $args['tax_query'] = array( |
254 | 254 | array( |
255 | 255 | 'taxonomy' => 'form_category', |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | ); |
259 | 259 | } |
260 | 260 | |
261 | - switch ( $orderby ) : |
|
261 | + switch ($orderby) : |
|
262 | 262 | case 'title' : |
263 | 263 | $args['orderby'] = 'title'; |
264 | 264 | break; |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | break; |
275 | 275 | endswitch; |
276 | 276 | |
277 | - $args = apply_filters( 'give_form_reports_prepare_items_args', $args, $this ); |
|
277 | + $args = apply_filters('give_form_reports_prepare_items_args', $args, $this); |
|
278 | 278 | |
279 | - $this->products = new WP_Query( $args ); |
|
279 | + $this->products = new WP_Query($args); |
|
280 | 280 | |
281 | 281 | } |
282 | 282 | |
@@ -292,15 +292,15 @@ discard block |
||
292 | 292 | |
293 | 293 | $give_forms = $this->products->posts; |
294 | 294 | |
295 | - if ( $give_forms ) { |
|
296 | - foreach ( $give_forms as $form ) { |
|
295 | + if ($give_forms) { |
|
296 | + foreach ($give_forms as $form) { |
|
297 | 297 | $reports_data[] = array( |
298 | 298 | 'ID' => $form, |
299 | - 'title' => get_the_title( $form ), |
|
300 | - 'sales' => give_get_form_sales_stats( $form ), |
|
301 | - 'earnings' => give_get_form_earnings_stats( $form ), |
|
302 | - 'average_sales' => give_get_average_monthly_form_sales( $form ), |
|
303 | - 'average_earnings' => give_get_average_monthly_form_earnings( $form ) |
|
299 | + 'title' => get_the_title($form), |
|
300 | + 'sales' => give_get_form_sales_stats($form), |
|
301 | + 'earnings' => give_get_form_earnings_stats($form), |
|
302 | + 'average_sales' => give_get_average_monthly_form_sales($form), |
|
303 | + 'average_earnings' => give_get_average_monthly_form_earnings($form) |
|
304 | 304 | ); |
305 | 305 | } |
306 | 306 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | |
329 | 329 | $sortable = $this->get_sortable_columns(); |
330 | 330 | |
331 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
331 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
332 | 332 | |
333 | 333 | $data = $this->reports_data(); |
334 | 334 | |
@@ -336,10 +336,10 @@ discard block |
||
336 | 336 | |
337 | 337 | $this->items = $data; |
338 | 338 | |
339 | - $this->set_pagination_args( array( |
|
339 | + $this->set_pagination_args(array( |
|
340 | 340 | 'total_items' => $total_items, |
341 | 341 | 'per_page' => $this->per_page, |
342 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
342 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
343 | 343 | ) |
344 | 344 | ); |
345 | 345 | } |
@@ -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,36 +70,36 @@ 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 | - if ( empty( $columns ) ) { |
|
75 | + if (empty($columns)) { |
|
76 | 76 | return false; |
77 | 77 | } |
78 | - if ( ! empty( $columns['full_name'] ) ) { |
|
79 | - $cols['full_name'] = esc_html__( 'Full Name', 'give' ); |
|
78 | + if ( ! empty($columns['full_name'])) { |
|
79 | + $cols['full_name'] = esc_html__('Full Name', 'give'); |
|
80 | 80 | } |
81 | - if ( ! empty( $columns['email'] ) ) { |
|
82 | - $cols['email'] = esc_html__( 'Email Address', 'give' ); |
|
81 | + if ( ! empty($columns['email'])) { |
|
82 | + $cols['email'] = esc_html__('Email Address', 'give'); |
|
83 | 83 | } |
84 | - if ( ! empty( $columns['address'] ) ) { |
|
85 | - $cols['address_line1'] = esc_html__( 'Address', 'give' ); |
|
86 | - $cols['address_line2'] = esc_html__( 'Address (Line 2)', 'give' ); |
|
87 | - $cols['address_city'] = esc_html__( 'City', 'give' ); |
|
88 | - $cols['address_state'] = esc_html__( 'State', 'give' ); |
|
89 | - $cols['address_zip'] = esc_html__( 'Zip', 'give' ); |
|
90 | - $cols['address_country'] = esc_html__( 'Country', 'give' ); |
|
84 | + if ( ! empty($columns['address'])) { |
|
85 | + $cols['address_line1'] = esc_html__('Address', 'give'); |
|
86 | + $cols['address_line2'] = esc_html__('Address (Line 2)', 'give'); |
|
87 | + $cols['address_city'] = esc_html__('City', 'give'); |
|
88 | + $cols['address_state'] = esc_html__('State', 'give'); |
|
89 | + $cols['address_zip'] = esc_html__('Zip', 'give'); |
|
90 | + $cols['address_country'] = esc_html__('Country', 'give'); |
|
91 | 91 | } |
92 | - if ( ! empty( $columns['userid'] ) ) { |
|
93 | - $cols['userid'] = esc_html__( 'User ID', 'give' ); |
|
92 | + if ( ! empty($columns['userid'])) { |
|
93 | + $cols['userid'] = esc_html__('User ID', 'give'); |
|
94 | 94 | } |
95 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
96 | - $cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' ); |
|
95 | + if ( ! empty($columns['date_first_donated'])) { |
|
96 | + $cols['date_first_donated'] = esc_html__('First Donation Date', 'give'); |
|
97 | 97 | } |
98 | - if ( ! empty( $columns['donations'] ) ) { |
|
99 | - $cols['donations'] = esc_html__( 'Number of Donations', 'give' ); |
|
98 | + if ( ! empty($columns['donations'])) { |
|
99 | + $cols['donations'] = esc_html__('Number of Donations', 'give'); |
|
100 | 100 | } |
101 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
102 | - $cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' ); |
|
101 | + if ( ! empty($columns['donation_sum'])) { |
|
102 | + $cols['donation_sum'] = esc_html__('Sum of Donations', 'give'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $cols; |
@@ -119,20 +119,20 @@ discard block |
||
119 | 119 | |
120 | 120 | $i = 0; |
121 | 121 | |
122 | - if ( ! empty( $this->form ) ) { |
|
122 | + if ( ! empty($this->form)) { |
|
123 | 123 | |
124 | 124 | // Export donors of a specific product |
125 | 125 | global $give_logs; |
126 | 126 | |
127 | 127 | $args = array( |
128 | - 'post_parent' => absint( $this->form ), |
|
128 | + 'post_parent' => absint($this->form), |
|
129 | 129 | 'log_type' => 'sale', |
130 | 130 | 'posts_per_page' => 30, |
131 | 131 | 'paged' => $this->step |
132 | 132 | ); |
133 | 133 | |
134 | 134 | //Check for price option |
135 | - if ( null !== $this->price_id ) { |
|
135 | + if (null !== $this->price_id) { |
|
136 | 136 | $args['meta_query'] = array( |
137 | 137 | array( |
138 | 138 | 'key' => '_give_log_price_id', |
@@ -141,33 +141,33 @@ discard block |
||
141 | 141 | ); |
142 | 142 | } |
143 | 143 | |
144 | - $logs = $give_logs->get_connected_logs( $args ); |
|
144 | + $logs = $give_logs->get_connected_logs($args); |
|
145 | 145 | |
146 | - if ( $logs ) { |
|
147 | - foreach ( $logs as $log ) { |
|
148 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
149 | - $payment = new Give_Payment( $payment_id ); |
|
150 | - $donor = Give()->customers->get_customer_by( 'id', $payment->customer_id ); |
|
151 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
152 | - $i ++; |
|
146 | + if ($logs) { |
|
147 | + foreach ($logs as $log) { |
|
148 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
149 | + $payment = new Give_Payment($payment_id); |
|
150 | + $donor = Give()->customers->get_customer_by('id', $payment->customer_id); |
|
151 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
152 | + $i++; |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | 156 | } else { |
157 | 157 | |
158 | 158 | // Export all customers |
159 | - $offset = 30 * ( $this->step - 1 ); |
|
160 | - $donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) ); |
|
159 | + $offset = 30 * ($this->step - 1); |
|
160 | + $donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset)); |
|
161 | 161 | |
162 | - foreach ( $donors as $donor ) { |
|
162 | + foreach ($donors as $donor) { |
|
163 | 163 | |
164 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
165 | - $i ++; |
|
164 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
165 | + $i++; |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
170 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
169 | + $data = apply_filters('give_export_get_data', $data); |
|
170 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
171 | 171 | |
172 | 172 | return $data; |
173 | 173 | } |
@@ -183,19 +183,19 @@ discard block |
||
183 | 183 | $percentage = 0; |
184 | 184 | |
185 | 185 | // We can't count the number when getting them for a specific form |
186 | - if ( empty( $this->form ) ) { |
|
186 | + if (empty($this->form)) { |
|
187 | 187 | |
188 | 188 | $total = Give()->customers->count(); |
189 | 189 | |
190 | - if ( $total > 0 ) { |
|
190 | + if ($total > 0) { |
|
191 | 191 | |
192 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
192 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
193 | 193 | |
194 | 194 | } |
195 | 195 | |
196 | 196 | } |
197 | 197 | |
198 | - if ( $percentage > 100 ) { |
|
198 | + if ($percentage > 100) { |
|
199 | 199 | $percentage = 100; |
200 | 200 | } |
201 | 201 | |
@@ -207,46 +207,46 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param $donor |
209 | 209 | */ |
210 | - private function set_donor_data( $i, $data, $donor ) { |
|
210 | + private function set_donor_data($i, $data, $donor) { |
|
211 | 211 | |
212 | 212 | $columns = $this->csv_cols(); |
213 | 213 | |
214 | 214 | //Set address variable |
215 | 215 | $address = ''; |
216 | - if ( isset( $donor->user_id ) && $donor->user_id > 0 ) { |
|
217 | - $address = give_get_donor_address( $donor->user_id ); |
|
216 | + if (isset($donor->user_id) && $donor->user_id > 0) { |
|
217 | + $address = give_get_donor_address($donor->user_id); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | //Set columns |
221 | - if ( ! empty( $columns['full_name'] ) ) { |
|
222 | - $data[ $i ]['full_name'] = $donor->name; |
|
221 | + if ( ! empty($columns['full_name'])) { |
|
222 | + $data[$i]['full_name'] = $donor->name; |
|
223 | 223 | } |
224 | - if ( ! empty( $columns['email'] ) ) { |
|
225 | - $data[ $i ]['email'] = $donor->email; |
|
224 | + if ( ! empty($columns['email'])) { |
|
225 | + $data[$i]['email'] = $donor->email; |
|
226 | 226 | } |
227 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
227 | + if ( ! empty($columns['address_line1'])) { |
|
228 | 228 | |
229 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
230 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
231 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
232 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
233 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
234 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
229 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
230 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
231 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
232 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
233 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
234 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
235 | 235 | } |
236 | - if ( ! empty( $columns['userid'] ) ) { |
|
237 | - $data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : ''; |
|
236 | + if ( ! empty($columns['userid'])) { |
|
237 | + $data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : ''; |
|
238 | 238 | } |
239 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
240 | - $data[ $i ]['date_first_donated'] = date_i18n( get_option( 'date_format' ), strtotime( $donor->date_created ) ); |
|
239 | + if ( ! empty($columns['date_first_donated'])) { |
|
240 | + $data[$i]['date_first_donated'] = date_i18n(get_option('date_format'), strtotime($donor->date_created)); |
|
241 | 241 | } |
242 | - if ( ! empty( $columns['donations'] ) ) { |
|
243 | - $data[ $i ]['donations'] = $donor->purchase_count; |
|
242 | + if ( ! empty($columns['donations'])) { |
|
243 | + $data[$i]['donations'] = $donor->purchase_count; |
|
244 | 244 | } |
245 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
246 | - $data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value ); |
|
245 | + if ( ! empty($columns['donation_sum'])) { |
|
246 | + $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value); |
|
247 | 247 | } |
248 | 248 | |
249 | - return $data[ $i ]; |
|
249 | + return $data[$i]; |
|
250 | 250 | |
251 | 251 | } |
252 | 252 |
@@ -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 | |
@@ -39,29 +39,29 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function csv_cols() { |
41 | 41 | $cols = array( |
42 | - 'id' => esc_html__( 'ID', 'give' ), // unaltered payment ID (use for querying) |
|
43 | - 'seq_id' => esc_html__( 'Payment Number', 'give' ), // sequential payment ID |
|
44 | - 'email' => esc_html__( 'Email', 'give' ), |
|
45 | - 'first' => esc_html__( 'First Name', 'give' ), |
|
46 | - 'last' => esc_html__( 'Last Name', 'give' ), |
|
47 | - 'address1' => esc_html__( 'Address', 'give' ), |
|
48 | - 'address2' => esc_html__( 'Address (Line 2)', 'give' ), |
|
49 | - 'city' => esc_html__( 'City', 'give' ), |
|
50 | - 'state' => esc_html__( 'State', 'give' ), |
|
51 | - 'country' => esc_html__( 'Country', 'give' ), |
|
52 | - 'zip' => esc_html__( 'Zip / Postal Code', 'give' ), |
|
53 | - 'products' => esc_html__( 'Products', 'give' ), |
|
54 | - 'amount' => esc_html__( 'Amount', 'give' ) . ' (' . html_entity_decode( give_currency_filter( '' ) ) . ')', |
|
55 | - 'gateway' => esc_html__( 'Payment Method', 'give' ), |
|
56 | - 'trans_id' => esc_html__( 'Transaction ID', 'give' ), |
|
57 | - 'key' => esc_html__( 'Purchase Key', 'give' ), |
|
58 | - 'date' => esc_html__( 'Date', 'give' ), |
|
59 | - 'user' => esc_html__( 'User', 'give' ), |
|
60 | - 'status' => esc_html__( 'Status', 'give' ) |
|
42 | + 'id' => esc_html__('ID', 'give'), // unaltered payment ID (use for querying) |
|
43 | + 'seq_id' => esc_html__('Payment Number', 'give'), // sequential payment ID |
|
44 | + 'email' => esc_html__('Email', 'give'), |
|
45 | + 'first' => esc_html__('First Name', 'give'), |
|
46 | + 'last' => esc_html__('Last Name', 'give'), |
|
47 | + 'address1' => esc_html__('Address', 'give'), |
|
48 | + 'address2' => esc_html__('Address (Line 2)', 'give'), |
|
49 | + 'city' => esc_html__('City', 'give'), |
|
50 | + 'state' => esc_html__('State', 'give'), |
|
51 | + 'country' => esc_html__('Country', 'give'), |
|
52 | + 'zip' => esc_html__('Zip / Postal Code', 'give'), |
|
53 | + 'products' => esc_html__('Products', 'give'), |
|
54 | + 'amount' => esc_html__('Amount', 'give').' ('.html_entity_decode(give_currency_filter('')).')', |
|
55 | + 'gateway' => esc_html__('Payment Method', 'give'), |
|
56 | + 'trans_id' => esc_html__('Transaction ID', 'give'), |
|
57 | + 'key' => esc_html__('Purchase Key', 'give'), |
|
58 | + 'date' => esc_html__('Date', 'give'), |
|
59 | + 'user' => esc_html__('User', 'give'), |
|
60 | + 'status' => esc_html__('Status', 'give') |
|
61 | 61 | ); |
62 | 62 | |
63 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
64 | - unset( $cols['seq_id'] ); |
|
63 | + if ( ! give_get_option('enable_sequential')) { |
|
64 | + unset($cols['seq_id']); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | return $cols; |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | 'status' => $this->status |
88 | 88 | ); |
89 | 89 | |
90 | - if ( ! empty( $this->start ) || ! empty( $this->end ) ) { |
|
90 | + if ( ! empty($this->start) || ! empty($this->end)) { |
|
91 | 91 | |
92 | 92 | $args['date_query'] = array( |
93 | 93 | array( |
94 | - 'after' => date( 'Y-n-d 00:00:00', strtotime( $this->start ) ), |
|
95 | - 'before' => date( 'Y-n-d 23:59:59', strtotime( $this->end ) ), |
|
94 | + 'after' => date('Y-n-d 00:00:00', strtotime($this->start)), |
|
95 | + 'before' => date('Y-n-d 23:59:59', strtotime($this->end)), |
|
96 | 96 | 'inclusive' => true |
97 | 97 | ) |
98 | 98 | ); |
@@ -101,104 +101,104 @@ discard block |
||
101 | 101 | |
102 | 102 | //echo json_encode($args ); exit; |
103 | 103 | |
104 | - $payments = give_get_payments( $args ); |
|
104 | + $payments = give_get_payments($args); |
|
105 | 105 | |
106 | - if ( $payments ) { |
|
106 | + if ($payments) { |
|
107 | 107 | |
108 | - foreach ( $payments as $payment ) { |
|
109 | - $payment_meta = give_get_payment_meta( $payment->ID ); |
|
110 | - $user_info = give_get_payment_meta_user_info( $payment->ID ); |
|
111 | - $total = give_get_payment_amount( $payment->ID ); |
|
112 | - $user_id = isset( $user_info['id'] ) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email']; |
|
108 | + foreach ($payments as $payment) { |
|
109 | + $payment_meta = give_get_payment_meta($payment->ID); |
|
110 | + $user_info = give_get_payment_meta_user_info($payment->ID); |
|
111 | + $total = give_get_payment_amount($payment->ID); |
|
112 | + $user_id = isset($user_info['id']) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email']; |
|
113 | 113 | $products = ''; |
114 | 114 | $skus = ''; |
115 | 115 | |
116 | - if ( $downloads ) { |
|
117 | - foreach ( $downloads as $key => $download ) { |
|
116 | + if ($downloads) { |
|
117 | + foreach ($downloads as $key => $download) { |
|
118 | 118 | |
119 | 119 | // Form ID |
120 | - $id = isset( $payment_meta['cart_details'] ) ? $download['id'] : $download; |
|
121 | - $qty = isset( $download['quantity'] ) ? $download['quantity'] : 1; |
|
120 | + $id = isset($payment_meta['cart_details']) ? $download['id'] : $download; |
|
121 | + $qty = isset($download['quantity']) ? $download['quantity'] : 1; |
|
122 | 122 | |
123 | - if ( isset( $download['price'] ) ) { |
|
123 | + if (isset($download['price'])) { |
|
124 | 124 | $price = $download['price']; |
125 | 125 | } else { |
126 | 126 | // If the download has variable prices, override the default price |
127 | - $price_override = isset( $payment_meta['cart_details'] ) ? $download['price'] : null; |
|
128 | - $price = give_get_download_final_price( $id, $user_info, $price_override ); |
|
127 | + $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null; |
|
128 | + $price = give_get_download_final_price($id, $user_info, $price_override); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | 132 | // Display the Downoad Name |
133 | - $products .= html_entity_decode( get_the_title( $id ) ); |
|
133 | + $products .= html_entity_decode(get_the_title($id)); |
|
134 | 134 | |
135 | - if ( $qty > 1 ) { |
|
136 | - $products .= html_entity_decode( ' (' . $qty . ')' ); |
|
135 | + if ($qty > 1) { |
|
136 | + $products .= html_entity_decode(' ('.$qty.')'); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | $products .= ' - '; |
140 | 140 | |
141 | - if ( give_use_skus() ) { |
|
142 | - $sku = give_get_download_sku( $id ); |
|
141 | + if (give_use_skus()) { |
|
142 | + $sku = give_get_download_sku($id); |
|
143 | 143 | |
144 | - if ( ! empty( $sku ) ) { |
|
144 | + if ( ! empty($sku)) { |
|
145 | 145 | $skus .= $sku; |
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - if ( isset( $downloads[ $key ]['item_number'] ) && isset( $downloads[ $key ]['item_number']['options'] ) ) { |
|
150 | - $price_options = $downloads[ $key ]['item_number']['options']; |
|
149 | + if (isset($downloads[$key]['item_number']) && isset($downloads[$key]['item_number']['options'])) { |
|
150 | + $price_options = $downloads[$key]['item_number']['options']; |
|
151 | 151 | |
152 | - if ( isset( $price_options['price_id'] ) ) { |
|
153 | - $products .= html_entity_decode( give_get_price_option_name( $id, $price_options['price_id'], $payment->ID ) ) . ' - '; |
|
152 | + if (isset($price_options['price_id'])) { |
|
153 | + $products .= html_entity_decode(give_get_price_option_name($id, $price_options['price_id'], $payment->ID)).' - '; |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | - $products .= html_entity_decode( give_currency_filter( give_format_amount( $price ) ) ); |
|
157 | + $products .= html_entity_decode(give_currency_filter(give_format_amount($price))); |
|
158 | 158 | |
159 | - if ( $key != ( count( $downloads ) - 1 ) ) { |
|
159 | + if ($key != (count($downloads) - 1)) { |
|
160 | 160 | $products .= ' / '; |
161 | 161 | |
162 | - if ( give_use_skus() ) { |
|
162 | + if (give_use_skus()) { |
|
163 | 163 | $skus .= ' / '; |
164 | 164 | } |
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | - if ( is_numeric( $user_id ) ) { |
|
170 | - $user = get_userdata( $user_id ); |
|
169 | + if (is_numeric($user_id)) { |
|
170 | + $user = get_userdata($user_id); |
|
171 | 171 | } else { |
172 | 172 | $user = false; |
173 | 173 | } |
174 | 174 | |
175 | 175 | $data[] = array( |
176 | 176 | 'id' => $payment->ID, |
177 | - 'seq_id' => give_get_payment_number( $payment->ID ), |
|
177 | + 'seq_id' => give_get_payment_number($payment->ID), |
|
178 | 178 | 'email' => $payment_meta['email'], |
179 | 179 | 'first' => $user_info['first_name'], |
180 | 180 | 'last' => $user_info['last_name'], |
181 | - 'address1' => isset( $user_info['address']['line1'] ) ? $user_info['address']['line1'] : '', |
|
182 | - 'address2' => isset( $user_info['address']['line2'] ) ? $user_info['address']['line2'] : '', |
|
183 | - 'city' => isset( $user_info['address']['city'] ) ? $user_info['address']['city'] : '', |
|
184 | - 'state' => isset( $user_info['address']['state'] ) ? $user_info['address']['state'] : '', |
|
185 | - 'country' => isset( $user_info['address']['country'] ) ? $user_info['address']['country'] : '', |
|
186 | - 'zip' => isset( $user_info['address']['zip'] ) ? $user_info['address']['zip'] : '', |
|
181 | + 'address1' => isset($user_info['address']['line1']) ? $user_info['address']['line1'] : '', |
|
182 | + 'address2' => isset($user_info['address']['line2']) ? $user_info['address']['line2'] : '', |
|
183 | + 'city' => isset($user_info['address']['city']) ? $user_info['address']['city'] : '', |
|
184 | + 'state' => isset($user_info['address']['state']) ? $user_info['address']['state'] : '', |
|
185 | + 'country' => isset($user_info['address']['country']) ? $user_info['address']['country'] : '', |
|
186 | + 'zip' => isset($user_info['address']['zip']) ? $user_info['address']['zip'] : '', |
|
187 | 187 | 'products' => $products, |
188 | 188 | 'skus' => $skus, |
189 | - 'amount' => html_entity_decode( give_format_amount( $total ) ), |
|
190 | - 'gateway' => give_get_gateway_admin_label( get_post_meta( $payment->ID, '_give_payment_gateway', true ) ), |
|
191 | - 'trans_id' => give_get_payment_transaction_id( $payment->ID ), |
|
189 | + 'amount' => html_entity_decode(give_format_amount($total)), |
|
190 | + 'gateway' => give_get_gateway_admin_label(get_post_meta($payment->ID, '_give_payment_gateway', true)), |
|
191 | + 'trans_id' => give_get_payment_transaction_id($payment->ID), |
|
192 | 192 | 'key' => $payment_meta['key'], |
193 | 193 | 'date' => $payment->post_date, |
194 | - 'user' => $user ? $user->display_name : esc_html__( 'guest', 'give' ), |
|
195 | - 'status' => give_get_payment_status( $payment, true ) |
|
194 | + 'user' => $user ? $user->display_name : esc_html__('guest', 'give'), |
|
195 | + 'status' => give_get_payment_status($payment, true) |
|
196 | 196 | ); |
197 | 197 | |
198 | 198 | } |
199 | 199 | |
200 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
201 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
200 | + $data = apply_filters('give_export_get_data', $data); |
|
201 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
202 | 202 | |
203 | 203 | return $data; |
204 | 204 | |
@@ -218,27 +218,27 @@ discard block |
||
218 | 218 | |
219 | 219 | $status = $this->status; |
220 | 220 | $args = array( |
221 | - 'start-date' => date( 'n/d/Y', strtotime( $this->start ) ), |
|
222 | - 'end-date' => date( 'n/d/Y', strtotime( $this->end ) ), |
|
221 | + 'start-date' => date('n/d/Y', strtotime($this->start)), |
|
222 | + 'end-date' => date('n/d/Y', strtotime($this->end)), |
|
223 | 223 | ); |
224 | 224 | |
225 | - if ( 'any' == $status ) { |
|
225 | + if ('any' == $status) { |
|
226 | 226 | |
227 | - $total = array_sum( (array) give_count_payments( $args ) ); |
|
227 | + $total = array_sum((array) give_count_payments($args)); |
|
228 | 228 | |
229 | 229 | } else { |
230 | 230 | |
231 | - $total = give_count_payments( $args )->$status; |
|
231 | + $total = give_count_payments($args)->$status; |
|
232 | 232 | |
233 | 233 | } |
234 | 234 | |
235 | 235 | $percentage = 100; |
236 | 236 | |
237 | - if ( $total > 0 ) { |
|
238 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
237 | + if ($total > 0) { |
|
238 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
239 | 239 | } |
240 | 240 | |
241 | - if ( $percentage > 100 ) { |
|
241 | + if ($percentage > 100) { |
|
242 | 242 | $percentage = 100; |
243 | 243 | } |
244 | 244 | |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @param array $request The Form Data passed into the batch processing |
254 | 254 | */ |
255 | - public function set_properties( $request ) { |
|
256 | - $this->start = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : ''; |
|
257 | - $this->end = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : ''; |
|
258 | - $this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'complete'; |
|
255 | + public function set_properties($request) { |
|
256 | + $this->start = isset($request['start']) ? sanitize_text_field($request['start']) : ''; |
|
257 | + $this->end = isset($request['end']) ? sanitize_text_field($request['end']) : ''; |
|
258 | + $this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'complete'; |
|
259 | 259 | } |
260 | 260 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
15 | +if ( ! defined('ABSPATH')) exit; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Give_Batch_Export Class |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | * @param $_step int The step to process |
105 | 105 | * @since 1.5 |
106 | 106 | */ |
107 | - public function __construct( $_step = 1 ) { |
|
107 | + public function __construct($_step = 1) { |
|
108 | 108 | |
109 | 109 | $upload_dir = wp_upload_dir(); |
110 | 110 | $this->filetype = '.csv'; |
111 | - $this->filename = 'give-' . $this->export_type . $this->filetype; |
|
112 | - $this->file = trailingslashit( $upload_dir['basedir'] ) . $this->filename; |
|
111 | + $this->filename = 'give-'.$this->export_type.$this->filetype; |
|
112 | + $this->file = trailingslashit($upload_dir['basedir']).$this->filename; |
|
113 | 113 | |
114 | - if ( ! is_writeable( $upload_dir['basedir'] ) ) { |
|
114 | + if ( ! is_writeable($upload_dir['basedir'])) { |
|
115 | 115 | $this->is_writable = false; |
116 | 116 | } |
117 | 117 | |
@@ -127,20 +127,20 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function process_step() { |
129 | 129 | |
130 | - if ( ! $this->can_export() ) { |
|
131 | - wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
130 | + if ( ! $this->can_export()) { |
|
131 | + wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
132 | 132 | } |
133 | 133 | |
134 | - if( $this->step < 2 ) { |
|
134 | + if ($this->step < 2) { |
|
135 | 135 | |
136 | 136 | // Make sure we start with a fresh file on step 1 |
137 | - @unlink( $this->file ); |
|
137 | + @unlink($this->file); |
|
138 | 138 | $this->print_csv_cols(); |
139 | 139 | } |
140 | 140 | |
141 | 141 | $rows = $this->print_csv_rows(); |
142 | 142 | |
143 | - if( $rows ) { |
|
143 | + if ($rows) { |
|
144 | 144 | return true; |
145 | 145 | } else { |
146 | 146 | return false; |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | $col_data = ''; |
161 | 161 | $cols = $this->get_csv_cols(); |
162 | 162 | $i = 1; |
163 | - foreach( $cols as $col_id => $column ) { |
|
164 | - $col_data .= '"' . addslashes( $column ) . '"'; |
|
165 | - $col_data .= $i == count( $cols ) ? '' : ','; |
|
163 | + foreach ($cols as $col_id => $column) { |
|
164 | + $col_data .= '"'.addslashes($column).'"'; |
|
165 | + $col_data .= $i == count($cols) ? '' : ','; |
|
166 | 166 | $i++; |
167 | 167 | } |
168 | 168 | $col_data .= "\r\n"; |
169 | 169 | |
170 | - $this->stash_step_data( $col_data ); |
|
170 | + $this->stash_step_data($col_data); |
|
171 | 171 | |
172 | 172 | return $col_data; |
173 | 173 | |
@@ -186,23 +186,23 @@ discard block |
||
186 | 186 | $data = $this->get_data(); |
187 | 187 | $cols = $this->get_csv_cols(); |
188 | 188 | |
189 | - if( $data ) { |
|
189 | + if ($data) { |
|
190 | 190 | |
191 | 191 | // Output each row |
192 | - foreach ( $data as $row ) { |
|
192 | + foreach ($data as $row) { |
|
193 | 193 | $i = 1; |
194 | - foreach ( $row as $col_id => $column ) { |
|
194 | + foreach ($row as $col_id => $column) { |
|
195 | 195 | // Make sure the column is valid |
196 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
197 | - $row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"'; |
|
198 | - $row_data .= $i == count( $cols ) ? '' : ','; |
|
196 | + if (array_key_exists($col_id, $cols)) { |
|
197 | + $row_data .= '"'.addslashes(preg_replace("/\"/", "'", $column)).'"'; |
|
198 | + $row_data .= $i == count($cols) ? '' : ','; |
|
199 | 199 | $i++; |
200 | 200 | } |
201 | 201 | } |
202 | 202 | $row_data .= "\r\n"; |
203 | 203 | } |
204 | 204 | |
205 | - $this->stash_step_data( $row_data ); |
|
205 | + $this->stash_step_data($row_data); |
|
206 | 206 | |
207 | 207 | return $row_data; |
208 | 208 | } |
@@ -230,18 +230,18 @@ discard block |
||
230 | 230 | |
231 | 231 | $file = ''; |
232 | 232 | |
233 | - if ( @file_exists( $this->file ) ) { |
|
233 | + if (@file_exists($this->file)) { |
|
234 | 234 | |
235 | - if ( ! is_writeable( $this->file ) ) { |
|
235 | + if ( ! is_writeable($this->file)) { |
|
236 | 236 | $this->is_writable = false; |
237 | 237 | } |
238 | 238 | |
239 | - $file = @file_get_contents( $this->file ); |
|
239 | + $file = @file_get_contents($this->file); |
|
240 | 240 | |
241 | 241 | } else { |
242 | 242 | |
243 | - @file_put_contents( $this->file, '' ); |
|
244 | - @chmod( $this->file, 0664 ); |
|
243 | + @file_put_contents($this->file, ''); |
|
244 | + @chmod($this->file, 0664); |
|
245 | 245 | |
246 | 246 | } |
247 | 247 | |
@@ -255,18 +255,18 @@ discard block |
||
255 | 255 | * @param $data string The data to add to the file |
256 | 256 | * @return void |
257 | 257 | */ |
258 | - protected function stash_step_data( $data = '' ) { |
|
258 | + protected function stash_step_data($data = '') { |
|
259 | 259 | |
260 | 260 | $file = $this->get_file(); |
261 | 261 | $file .= $data; |
262 | - @file_put_contents( $this->file, $file ); |
|
262 | + @file_put_contents($this->file, $file); |
|
263 | 263 | |
264 | 264 | // If we have no rows after this step, mark it as an empty export |
265 | - $file_rows = file( $this->file, FILE_SKIP_EMPTY_LINES); |
|
265 | + $file_rows = file($this->file, FILE_SKIP_EMPTY_LINES); |
|
266 | 266 | $default_cols = $this->get_csv_cols(); |
267 | - $default_cols = empty( $default_cols ) ? 0 : 1; |
|
267 | + $default_cols = empty($default_cols) ? 0 : 1; |
|
268 | 268 | |
269 | - $this->is_empty = count( $file_rows ) == $default_cols ? true : false; |
|
269 | + $this->is_empty = count($file_rows) == $default_cols ? true : false; |
|
270 | 270 | |
271 | 271 | } |
272 | 272 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | $file = $this->get_file(); |
286 | 286 | |
287 | - @unlink( $this->file ); |
|
287 | + @unlink($this->file); |
|
288 | 288 | |
289 | 289 | echo $file; |
290 | 290 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @since 1.5 |
298 | 298 | * @param array $request The Form Data passed into the batch processing |
299 | 299 | */ |
300 | - public function set_properties( $request ) {} |
|
300 | + public function set_properties($request) {} |
|
301 | 301 | |
302 | 302 | /** |
303 | 303 | * Allow for prefetching of data for the remainder of the exporter |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
18 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export.php'; |
|
19 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-actions.php'; |
|
18 | +require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export.php'; |
|
19 | +require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-actions.php'; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Process batch exports via ajax |
@@ -26,79 +26,79 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function give_do_ajax_export() { |
28 | 28 | |
29 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php'; |
|
29 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php'; |
|
30 | 30 | |
31 | - parse_str( $_POST['form'], $form ); |
|
31 | + parse_str($_POST['form'], $form); |
|
32 | 32 | |
33 | 33 | $_REQUEST = $form = (array) $form; |
34 | 34 | |
35 | - if ( ! wp_verify_nonce( $_REQUEST['give_ajax_export'], 'give_ajax_export' ) ) { |
|
36 | - die( '-2' ); |
|
35 | + if ( ! wp_verify_nonce($_REQUEST['give_ajax_export'], 'give_ajax_export')) { |
|
36 | + die('-2'); |
|
37 | 37 | } |
38 | 38 | |
39 | - do_action( 'give_batch_export_class_include', $form['give-export-class'] ); |
|
39 | + do_action('give_batch_export_class_include', $form['give-export-class']); |
|
40 | 40 | |
41 | - $step = absint( $_POST['step'] ); |
|
42 | - $class = sanitize_text_field( $form['give-export-class'] ); |
|
41 | + $step = absint($_POST['step']); |
|
42 | + $class = sanitize_text_field($form['give-export-class']); |
|
43 | 43 | |
44 | - $export = new $class( $step ); |
|
44 | + $export = new $class($step); |
|
45 | 45 | |
46 | - if ( ! $export->can_export() ) { |
|
47 | - die( '-1' ); |
|
46 | + if ( ! $export->can_export()) { |
|
47 | + die('-1'); |
|
48 | 48 | } |
49 | 49 | |
50 | - if ( ! $export->is_writable ) { |
|
50 | + if ( ! $export->is_writable) { |
|
51 | 51 | $json_args = array( |
52 | 52 | 'error' => true, |
53 | - 'message' => esc_html__( 'Export location or file not writable.', 'give' ) |
|
53 | + 'message' => esc_html__('Export location or file not writable.', 'give') |
|
54 | 54 | ); |
55 | 55 | echo json_encode($json_args); |
56 | 56 | exit; |
57 | 57 | } |
58 | 58 | |
59 | - $export->set_properties( $_REQUEST ); |
|
59 | + $export->set_properties($_REQUEST); |
|
60 | 60 | |
61 | 61 | $export->pre_fetch(); |
62 | 62 | |
63 | - $ret = $export->process_step( $step ); |
|
63 | + $ret = $export->process_step($step); |
|
64 | 64 | |
65 | 65 | $percentage = $export->get_percentage_complete(); |
66 | 66 | |
67 | - if ( $ret ) { |
|
67 | + if ($ret) { |
|
68 | 68 | |
69 | 69 | $step += 1; |
70 | - echo json_encode( array( 'step' => $step, 'percentage' => $percentage ) ); |
|
70 | + echo json_encode(array('step' => $step, 'percentage' => $percentage)); |
|
71 | 71 | exit; |
72 | 72 | |
73 | - } elseif ( true === $export->is_empty ) { |
|
73 | + } elseif (true === $export->is_empty) { |
|
74 | 74 | |
75 | - echo json_encode( array( |
|
75 | + echo json_encode(array( |
|
76 | 76 | 'error' => true, |
77 | - 'message' => esc_html__( 'No data found for export parameters.', 'give' ) |
|
78 | - ) ); |
|
77 | + 'message' => esc_html__('No data found for export parameters.', 'give') |
|
78 | + )); |
|
79 | 79 | exit; |
80 | 80 | |
81 | - } elseif ( true === $export->done && true === $export->is_void ) { |
|
81 | + } elseif (true === $export->done && true === $export->is_void) { |
|
82 | 82 | |
83 | - $message = ! empty( $export->message ) ? $export->message : esc_html__( 'Batch Processing Complete', 'give' ); |
|
84 | - echo json_encode( array( 'success' => true, 'message' => $message ) ); |
|
83 | + $message = ! empty($export->message) ? $export->message : esc_html__('Batch Processing Complete', 'give'); |
|
84 | + echo json_encode(array('success' => true, 'message' => $message)); |
|
85 | 85 | exit; |
86 | 86 | |
87 | 87 | } else { |
88 | 88 | |
89 | - $args = array_merge( $_REQUEST, array( |
|
89 | + $args = array_merge($_REQUEST, array( |
|
90 | 90 | 'step' => $step, |
91 | 91 | 'class' => $class, |
92 | - 'nonce' => wp_create_nonce( 'give-batch-export' ), |
|
92 | + 'nonce' => wp_create_nonce('give-batch-export'), |
|
93 | 93 | 'give_action' => 'form_batch_export', |
94 | - ) ); |
|
94 | + )); |
|
95 | 95 | |
96 | - $download_url = add_query_arg( $args, admin_url() ); |
|
96 | + $download_url = add_query_arg($args, admin_url()); |
|
97 | 97 | |
98 | - echo json_encode( array( 'step' => 'done', 'url' => $download_url ) ); |
|
98 | + echo json_encode(array('step' => 'done', 'url' => $download_url)); |
|
99 | 99 | exit; |
100 | 100 | |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | -add_action( 'wp_ajax_give_do_ajax_export', 'give_do_ajax_export' ); |
|
104 | +add_action('wp_ajax_give_do_ajax_export', 'give_do_ajax_export'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -22,20 +22,20 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_process_batch_export_form() { |
24 | 24 | |
25 | - if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) { |
|
26 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
25 | + if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) { |
|
26 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
27 | 27 | } |
28 | 28 | |
29 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php'; |
|
29 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php'; |
|
30 | 30 | |
31 | - do_action( 'give_batch_export_class_include', $_REQUEST['class'] ); |
|
31 | + do_action('give_batch_export_class_include', $_REQUEST['class']); |
|
32 | 32 | |
33 | 33 | $export = new $_REQUEST['class']; |
34 | 34 | $export->export(); |
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | -add_action( 'give_form_batch_export', 'give_process_batch_export_form' ); |
|
38 | +add_action('give_form_batch_export', 'give_process_batch_export_form'); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Exports earnings for a specified time period |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | * @return void |
47 | 47 | */ |
48 | 48 | function give_export_earnings() { |
49 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php'; |
|
49 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-earnings.php'; |
|
50 | 50 | |
51 | 51 | $earnings_export = new Give_Earnings_Export(); |
52 | 52 | |
53 | 53 | $earnings_export->export(); |
54 | 54 | } |
55 | 55 | |
56 | -add_action( 'give_earnings_export', 'give_export_earnings' ); |
|
56 | +add_action('give_earnings_export', 'give_export_earnings'); |
|
57 | 57 | |
58 | 58 | |
59 | 59 | /** |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | * @return void |
67 | 67 | */ |
68 | 68 | function give_export_all_customers() { |
69 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php'; |
|
69 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-customers.php'; |
|
70 | 70 | |
71 | 71 | $customer_export = new Give_Donors_Export(); |
72 | 72 | |
73 | 73 | $customer_export->export(); |
74 | 74 | } |
75 | 75 | |
76 | -add_action( 'give_email_export', 'give_export_all_customers' ); |
|
76 | +add_action('give_email_export', 'give_export_all_customers'); |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Add a hook allowing extensions to register a hook on the batch export process |
@@ -82,22 +82,22 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | function give_register_batch_exporters() { |
85 | - if ( is_admin() ) { |
|
86 | - do_action( 'give_register_batch_exporter' ); |
|
85 | + if (is_admin()) { |
|
86 | + do_action('give_register_batch_exporter'); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | -add_action( 'plugins_loaded', 'give_register_batch_exporters' ); |
|
90 | +add_action('plugins_loaded', 'give_register_batch_exporters'); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Register the payments batch exporter |
94 | 94 | * @since 1.5 |
95 | 95 | */ |
96 | 96 | function give_register_payments_batch_export() { |
97 | - add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 ); |
|
97 | + add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1); |
|
98 | 98 | } |
99 | 99 | |
100 | -add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 ); |
|
100 | +add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10); |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Loads the payments batch process if needed |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return void |
110 | 110 | */ |
111 | -function give_include_payments_batch_processor( $class ) { |
|
111 | +function give_include_payments_batch_processor($class) { |
|
112 | 112 | |
113 | - if ( 'Give_Batch_Payments_Export' === $class ) { |
|
114 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
113 | + if ('Give_Batch_Payments_Export' === $class) { |
|
114 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | } |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | * @since 1.5.2 |
122 | 122 | */ |
123 | 123 | function give_register_customers_batch_export() { |
124 | - add_action( 'give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1 ); |
|
124 | + add_action('give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1); |
|
125 | 125 | } |
126 | 126 | |
127 | -add_action( 'give_register_batch_exporter', 'give_register_customers_batch_export', 10 ); |
|
127 | +add_action('give_register_batch_exporter', 'give_register_customers_batch_export', 10); |
|
128 | 128 | |
129 | 129 | /** |
130 | 130 | * Loads the customers batch process if needed |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_include_customers_batch_processor( $class ) { |
|
138 | +function give_include_customers_batch_processor($class) { |
|
139 | 139 | |
140 | - if ( 'Give_Batch_Customers_Export' === $class ) { |
|
141 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
140 | + if ('Give_Batch_Customers_Export' === $class) { |
|
141 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | } |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | * @since 1.5 |
150 | 150 | */ |
151 | 151 | function give_register_forms_batch_export() { |
152 | - add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 ); |
|
152 | + add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1); |
|
153 | 153 | } |
154 | 154 | |
155 | -add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 ); |
|
155 | +add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10); |
|
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Loads the file downloads batch process if needed |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return void |
165 | 165 | */ |
166 | -function give_include_forms_batch_processor( $class ) { |
|
166 | +function give_include_forms_batch_processor($class) { |
|
167 | 167 | |
168 | - if ( 'Give_Batch_Forms_Export' === $class ) { |
|
169 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
168 | + if ('Give_Batch_Forms_Export' === $class) { |
|
169 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | } |
173 | 173 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -41,20 +41,20 @@ discard block |
||
41 | 41 | public function csv_cols() { |
42 | 42 | |
43 | 43 | $cols = array( |
44 | - 'ID' => esc_html__( 'ID', 'give' ), |
|
45 | - 'post_name' => esc_html__( 'Slug', 'give' ), |
|
46 | - 'post_title' => esc_html__( 'Name', 'give' ), |
|
47 | - 'post_date' => esc_html__( 'Date Created', 'give' ), |
|
48 | - 'post_author' => esc_html__( 'Author', 'give' ), |
|
49 | - 'post_content' => esc_html__( 'Description', 'give' ), |
|
50 | - 'post_excerpt' => esc_html__( 'Excerpt', 'give' ), |
|
51 | - 'post_status' => esc_html__( 'Status', 'give' ), |
|
52 | - 'categories' => esc_html__( 'Categories', 'give' ), |
|
53 | - 'tags' => esc_html__( 'Tags', 'give' ), |
|
54 | - 'give_price' => esc_html__( 'Price', 'give' ), |
|
55 | - '_thumbnail_id' => esc_html__( 'Featured Image', 'give' ), |
|
56 | - '_give_form_sales' => esc_html__( 'Donations', 'give' ), |
|
57 | - '_give_download_earnings' => esc_html__( 'Income', 'give' ), |
|
44 | + 'ID' => esc_html__('ID', 'give'), |
|
45 | + 'post_name' => esc_html__('Slug', 'give'), |
|
46 | + 'post_title' => esc_html__('Name', 'give'), |
|
47 | + 'post_date' => esc_html__('Date Created', 'give'), |
|
48 | + 'post_author' => esc_html__('Author', 'give'), |
|
49 | + 'post_content' => esc_html__('Description', 'give'), |
|
50 | + 'post_excerpt' => esc_html__('Excerpt', 'give'), |
|
51 | + 'post_status' => esc_html__('Status', 'give'), |
|
52 | + 'categories' => esc_html__('Categories', 'give'), |
|
53 | + 'tags' => esc_html__('Tags', 'give'), |
|
54 | + 'give_price' => esc_html__('Price', 'give'), |
|
55 | + '_thumbnail_id' => esc_html__('Featured Image', 'give'), |
|
56 | + '_give_form_sales' => esc_html__('Donations', 'give'), |
|
57 | + '_give_download_earnings' => esc_html__('Income', 'give'), |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | return $cols; |
@@ -86,43 +86,43 @@ discard block |
||
86 | 86 | 'paged' => $this->step |
87 | 87 | ); |
88 | 88 | |
89 | - $downloads = new WP_Query( $args ); |
|
89 | + $downloads = new WP_Query($args); |
|
90 | 90 | |
91 | - if ( $downloads->posts ) { |
|
92 | - foreach ( $downloads->posts as $download ) { |
|
91 | + if ($downloads->posts) { |
|
92 | + foreach ($downloads->posts as $download) { |
|
93 | 93 | |
94 | 94 | $row = array(); |
95 | 95 | |
96 | - foreach ( $this->csv_cols() as $key => $value ) { |
|
96 | + foreach ($this->csv_cols() as $key => $value) { |
|
97 | 97 | |
98 | 98 | // Setup default value |
99 | - $row[ $key ] = ''; |
|
99 | + $row[$key] = ''; |
|
100 | 100 | |
101 | - if ( in_array( $key, $meta ) ) { |
|
101 | + if (in_array($key, $meta)) { |
|
102 | 102 | |
103 | - switch ( $key ) { |
|
103 | + switch ($key) { |
|
104 | 104 | |
105 | 105 | case '_thumbnail_id' : |
106 | 106 | |
107 | - $image_id = get_post_thumbnail_id( $download->ID ); |
|
108 | - $row[ $key ] = wp_get_attachment_url( $image_id ); |
|
107 | + $image_id = get_post_thumbnail_id($download->ID); |
|
108 | + $row[$key] = wp_get_attachment_url($image_id); |
|
109 | 109 | |
110 | 110 | break; |
111 | 111 | |
112 | 112 | case 'give_price' : |
113 | 113 | |
114 | - if ( give_has_variable_prices( $download->ID ) ) { |
|
114 | + if (give_has_variable_prices($download->ID)) { |
|
115 | 115 | |
116 | 116 | $prices = array(); |
117 | - foreach ( give_get_variable_prices( $download->ID ) as $price ) { |
|
118 | - $prices[] = $price['name'] . ': ' . $price['amount']; |
|
117 | + foreach (give_get_variable_prices($download->ID) as $price) { |
|
118 | + $prices[] = $price['name'].': '.$price['amount']; |
|
119 | 119 | } |
120 | 120 | |
121 | - $row[ $key ] = implode( ' | ', $prices ); |
|
121 | + $row[$key] = implode(' | ', $prices); |
|
122 | 122 | |
123 | 123 | } else { |
124 | 124 | |
125 | - $row[ $key ] = give_get_download_price( $download->ID ); |
|
125 | + $row[$key] = give_get_download_price($download->ID); |
|
126 | 126 | |
127 | 127 | } |
128 | 128 | |
@@ -132,54 +132,54 @@ discard block |
||
132 | 132 | |
133 | 133 | |
134 | 134 | $files = array(); |
135 | - foreach ( give_get_download_files( $download->ID ) as $file ) { |
|
135 | + foreach (give_get_download_files($download->ID) as $file) { |
|
136 | 136 | $files[] = $file['file']; |
137 | 137 | } |
138 | 138 | |
139 | - $row[ $key ] = implode( ' | ', $files ); |
|
139 | + $row[$key] = implode(' | ', $files); |
|
140 | 140 | |
141 | 141 | break; |
142 | 142 | |
143 | 143 | default : |
144 | 144 | |
145 | - $row[ $key ] = get_post_meta( $download->ID, $key, true ); |
|
145 | + $row[$key] = get_post_meta($download->ID, $key, true); |
|
146 | 146 | |
147 | 147 | break; |
148 | 148 | |
149 | 149 | } |
150 | 150 | |
151 | - } elseif ( isset( $download->$key ) ) { |
|
151 | + } elseif (isset($download->$key)) { |
|
152 | 152 | |
153 | - switch ( $key ) { |
|
153 | + switch ($key) { |
|
154 | 154 | |
155 | 155 | case 'post_author' : |
156 | 156 | |
157 | - $row[ $key ] = get_the_author_meta( 'user_login', $download->post_author ); |
|
157 | + $row[$key] = get_the_author_meta('user_login', $download->post_author); |
|
158 | 158 | |
159 | 159 | break; |
160 | 160 | |
161 | 161 | default : |
162 | 162 | |
163 | - $row[ $key ] = $download->$key; |
|
163 | + $row[$key] = $download->$key; |
|
164 | 164 | |
165 | 165 | break; |
166 | 166 | } |
167 | 167 | |
168 | - } elseif ( 'tags' == $key ) { |
|
168 | + } elseif ('tags' == $key) { |
|
169 | 169 | |
170 | - $terms = get_the_terms( $download->ID, 'download_tag' ); |
|
171 | - if ( $terms ) { |
|
172 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
173 | - $row[ $key ] = implode( ' | ', $terms ); |
|
170 | + $terms = get_the_terms($download->ID, 'download_tag'); |
|
171 | + if ($terms) { |
|
172 | + $terms = wp_list_pluck($terms, 'name'); |
|
173 | + $row[$key] = implode(' | ', $terms); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
177 | - } elseif ( 'categories' == $key ) { |
|
177 | + } elseif ('categories' == $key) { |
|
178 | 178 | |
179 | - $terms = get_the_terms( $download->ID, 'download_category' ); |
|
180 | - if ( $terms ) { |
|
181 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
182 | - $row[ $key ] = implode( ' | ', $terms ); |
|
179 | + $terms = get_the_terms($download->ID, 'download_category'); |
|
180 | + if ($terms) { |
|
181 | + $terms = wp_list_pluck($terms, 'name'); |
|
182 | + $row[$key] = implode(' | ', $terms); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | } |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | |
191 | 191 | } |
192 | 192 | |
193 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
194 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
193 | + $data = apply_filters('give_export_get_data', $data); |
|
194 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
195 | 195 | |
196 | 196 | return $data; |
197 | 197 | } |
@@ -210,20 +210,20 @@ discard block |
||
210 | 210 | |
211 | 211 | $args = array( |
212 | 212 | 'post_type' => 'give_forms', |
213 | - 'posts_per_page' => - 1, |
|
213 | + 'posts_per_page' => -1, |
|
214 | 214 | 'post_status' => 'any', |
215 | 215 | 'fields' => 'ids', |
216 | 216 | ); |
217 | 217 | |
218 | - $downloads = new WP_Query( $args ); |
|
218 | + $downloads = new WP_Query($args); |
|
219 | 219 | $total = (int) $downloads->post_count; |
220 | 220 | $percentage = 100; |
221 | 221 | |
222 | - if ( $total > 0 ) { |
|
223 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
222 | + if ($total > 0) { |
|
223 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
224 | 224 | } |
225 | 225 | |
226 | - if ( $percentage > 100 ) { |
|
226 | + if ($percentage > 100) { |
|
227 | 227 | $percentage = 100; |
228 | 228 | } |
229 | 229 |
@@ -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 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @return bool Whether we can export or not |
38 | 38 | */ |
39 | 39 | public function can_export() { |
40 | - return (bool) apply_filters( 'give_export_capability', current_user_can( 'export_give_reports' ) ); |
|
40 | + return (bool) apply_filters('give_export_capability', current_user_can('export_give_reports')); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | * @return void |
49 | 49 | */ |
50 | 50 | public function headers() { |
51 | - ignore_user_abort( true ); |
|
51 | + ignore_user_abort(true); |
|
52 | 52 | |
53 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
54 | - set_time_limit( 0 ); |
|
53 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
54 | + set_time_limit(0); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | nocache_headers(); |
58 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
59 | - header( 'Content-Disposition: attachment; filename=give-export-' . $this->export_type . '-' . date( 'm-d-Y' ) . '.csv' ); |
|
60 | - header( "Expires: 0" ); |
|
58 | + header('Content-Type: text/csv; charset=utf-8'); |
|
59 | + header('Content-Disposition: attachment; filename=give-export-'.$this->export_type.'-'.date('m-d-Y').'.csv'); |
|
60 | + header("Expires: 0"); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function csv_cols() { |
71 | 71 | $cols = array( |
72 | - 'id' => esc_html__( 'ID', 'give' ), |
|
73 | - 'date' => esc_html__( 'Date', 'give' ) |
|
72 | + 'id' => esc_html__('ID', 'give'), |
|
73 | + 'date' => esc_html__('Date', 'give') |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | return $cols; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function get_csv_cols() { |
87 | 87 | $cols = $this->csv_cols(); |
88 | 88 | |
89 | - return apply_filters( 'give_export_csv_cols_' . $this->export_type, $cols ); |
|
89 | + return apply_filters('give_export_csv_cols_'.$this->export_type, $cols); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | public function csv_cols_out() { |
101 | 101 | $cols = $this->get_csv_cols(); |
102 | 102 | $i = 1; |
103 | - foreach ( $cols as $col_id => $column ) { |
|
104 | - echo '"' . addslashes( $column ) . '"'; |
|
105 | - echo $i == count( $cols ) ? '' : ','; |
|
106 | - $i ++; |
|
103 | + foreach ($cols as $col_id => $column) { |
|
104 | + echo '"'.addslashes($column).'"'; |
|
105 | + echo $i == count($cols) ? '' : ','; |
|
106 | + $i++; |
|
107 | 107 | } |
108 | 108 | echo "\r\n"; |
109 | 109 | } |
@@ -120,16 +120,16 @@ discard block |
||
120 | 120 | $data = array( |
121 | 121 | 0 => array( |
122 | 122 | 'id' => '', |
123 | - 'data' => date( 'F j, Y' ) |
|
123 | + 'data' => date('F j, Y') |
|
124 | 124 | ), |
125 | 125 | 1 => array( |
126 | 126 | 'id' => '', |
127 | - 'data' => date( 'F j, Y' ) |
|
127 | + 'data' => date('F j, Y') |
|
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | |
131 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
132 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
131 | + $data = apply_filters('give_export_get_data', $data); |
|
132 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
133 | 133 | |
134 | 134 | return $data; |
135 | 135 | } |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | $cols = $this->get_csv_cols(); |
148 | 148 | |
149 | 149 | // Output each row |
150 | - foreach ( $data as $row ) { |
|
150 | + foreach ($data as $row) { |
|
151 | 151 | $i = 1; |
152 | - foreach ( $row as $col_id => $column ) { |
|
152 | + foreach ($row as $col_id => $column) { |
|
153 | 153 | // Make sure the column is valid |
154 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
155 | - echo '"' . addslashes( $column ) . '"'; |
|
156 | - echo $i == count( $cols ) ? '' : ','; |
|
157 | - $i ++; |
|
154 | + if (array_key_exists($col_id, $cols)) { |
|
155 | + echo '"'.addslashes($column).'"'; |
|
156 | + echo $i == count($cols) ? '' : ','; |
|
157 | + $i++; |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | echo "\r\n"; |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @return void |
174 | 174 | */ |
175 | 175 | public function export() { |
176 | - if ( ! $this->can_export() ) { |
|
177 | - wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
176 | + if ( ! $this->can_export()) { |
|
177 | + wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | // Set headers |
@@ -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 | - __( '%1$s to %2$s', 'give' ), |
|
45 | - date_i18n( get_option( 'date_format' ), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ), |
|
46 | - date_i18n( get_option( 'date_format' ) ) |
|
44 | + __('%1$s to %2$s', 'give'), |
|
45 | + date_i18n(get_option('date_format'), mktime(0, 0, 0, 1, 1, date('Y'))), |
|
46 | + date_i18n(get_option('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( GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png', 247, 8 ); |
|
57 | + $pdf->Image(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,57 +108,57 @@ 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 ) ); |
|
135 | + $pdf->SetWidths(array(280)); |
|
136 | 136 | $title = utf8_decode( |
137 | 137 | sprintf( |
138 | 138 | /* translators: %s: form plural label */ |
139 | - __( 'No %s found.', 'give' ), |
|
139 | + __('No %s found.', 'give'), |
|
140 | 140 | give_get_forms_label_plural() |
141 | 141 | ) |
142 | 142 | ); |
143 | - $pdf->Row( array( $title ) ); |
|
143 | + $pdf->Row(array($title)); |
|
144 | 144 | endif; |
145 | 145 | |
146 | 146 | $pdf->Ln(); |
147 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
148 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
149 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false ); |
|
150 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
151 | - |
|
152 | - $image = html_entity_decode( urldecode( give_draw_chart_image() ) ); |
|
153 | - $image = str_replace( ' ', '%20', $image ); |
|
154 | - |
|
155 | - $pdf->SetX( 25 ); |
|
156 | - $pdf->Image( $image . '&file=.png' ); |
|
157 | - $pdf->Ln( 7 ); |
|
158 | - $pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' ); |
|
147 | + $pdf->SetTextColor(50, 50, 50); |
|
148 | + $pdf->SetFont('Helvetica', '', 14); |
|
149 | + $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false); |
|
150 | + $pdf->SetFont('Helvetica', '', 12); |
|
151 | + |
|
152 | + $image = html_entity_decode(urldecode(give_draw_chart_image())); |
|
153 | + $image = str_replace(' ', '%20', $image); |
|
154 | + |
|
155 | + $pdf->SetX(25); |
|
156 | + $pdf->Image($image.'&file=.png'); |
|
157 | + $pdf->Ln(7); |
|
158 | + $pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D'); |
|
159 | 159 | } |
160 | 160 | |
161 | -add_action( 'give_generate_pdf', 'give_generate_pdf' ); |
|
161 | +add_action('give_generate_pdf', 'give_generate_pdf'); |
|
162 | 162 | |
163 | 163 | /** |
164 | 164 | * Draws Chart for PDF Report |
@@ -175,38 +175,38 @@ discard block |
||
175 | 175 | * @return string $chart->getUrl() URL for the Google Chart |
176 | 176 | */ |
177 | 177 | function give_draw_chart_image() { |
178 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php'; |
|
179 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
180 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
178 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php'; |
|
179 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
180 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
181 | 181 | |
182 | - $chart = new GoogleChart( 'lc', 900, 330 ); |
|
182 | + $chart = new GoogleChart('lc', 900, 330); |
|
183 | 183 | |
184 | 184 | $i = 1; |
185 | 185 | $earnings = ""; |
186 | 186 | $sales = ""; |
187 | 187 | |
188 | - while ( $i <= 12 ) : |
|
189 | - $earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ","; |
|
190 | - $sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ","; |
|
191 | - $i ++; |
|
188 | + while ($i <= 12) : |
|
189 | + $earnings .= give_get_earnings_by_date(null, $i, date('Y')).","; |
|
190 | + $sales .= give_get_sales_by_date(null, $i, date('Y')).","; |
|
191 | + $i++; |
|
192 | 192 | endwhile; |
193 | 193 | |
194 | - $earnings_array = explode( ",", $earnings ); |
|
195 | - $sales_array = explode( ",", $sales ); |
|
194 | + $earnings_array = explode(",", $earnings); |
|
195 | + $sales_array = explode(",", $sales); |
|
196 | 196 | |
197 | 197 | $i = 0; |
198 | - while ( $i <= 11 ) { |
|
199 | - if ( empty( $sales_array[ $i ] ) ) { |
|
200 | - $sales_array[ $i ] = 0; |
|
198 | + while ($i <= 11) { |
|
199 | + if (empty($sales_array[$i])) { |
|
200 | + $sales_array[$i] = 0; |
|
201 | 201 | } |
202 | - $i ++; |
|
202 | + $i++; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | $min_earnings = 0; |
206 | - $max_earnings = max( $earnings_array ); |
|
207 | - $earnings_scale = round( $max_earnings, - 1 ); |
|
206 | + $max_earnings = max($earnings_array); |
|
207 | + $earnings_scale = round($max_earnings, - 1); |
|
208 | 208 | |
209 | - $data = new GoogleChartData( array( |
|
209 | + $data = new GoogleChartData(array( |
|
210 | 210 | $earnings_array[0], |
211 | 211 | $earnings_array[1], |
212 | 212 | $earnings_array[2], |
@@ -219,25 +219,25 @@ discard block |
||
219 | 219 | $earnings_array[9], |
220 | 220 | $earnings_array[10], |
221 | 221 | $earnings_array[11] |
222 | - ) ); |
|
222 | + )); |
|
223 | 223 | |
224 | - $data->setLegend( __( 'Income', 'give' ) ); |
|
225 | - $data->setColor( '1b58a3' ); |
|
226 | - $chart->addData( $data ); |
|
224 | + $data->setLegend(__('Income', 'give')); |
|
225 | + $data->setColor('1b58a3'); |
|
226 | + $chart->addData($data); |
|
227 | 227 | |
228 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
229 | - $shape_marker->setColor( '000000' ); |
|
230 | - $shape_marker->setSize( 7 ); |
|
231 | - $shape_marker->setBorder( 2 ); |
|
232 | - $shape_marker->setData( $data ); |
|
233 | - $chart->addMarker( $shape_marker ); |
|
228 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
229 | + $shape_marker->setColor('000000'); |
|
230 | + $shape_marker->setSize(7); |
|
231 | + $shape_marker->setBorder(2); |
|
232 | + $shape_marker->setData($data); |
|
233 | + $chart->addMarker($shape_marker); |
|
234 | 234 | |
235 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
236 | - $value_marker->setColor( '000000' ); |
|
237 | - $value_marker->setData( $data ); |
|
238 | - $chart->addMarker( $value_marker ); |
|
235 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
236 | + $value_marker->setColor('000000'); |
|
237 | + $value_marker->setData($data); |
|
238 | + $chart->addMarker($value_marker); |
|
239 | 239 | |
240 | - $data = new GoogleChartData( array( |
|
240 | + $data = new GoogleChartData(array( |
|
241 | 241 | $sales_array[0], |
242 | 242 | $sales_array[1], |
243 | 243 | $sales_array[2], |
@@ -250,46 +250,46 @@ discard block |
||
250 | 250 | $sales_array[9], |
251 | 251 | $sales_array[10], |
252 | 252 | $sales_array[11] |
253 | - ) ); |
|
254 | - $data->setLegend( __( 'Donations', 'give' ) ); |
|
255 | - $data->setColor( 'ff6c1c' ); |
|
256 | - $chart->addData( $data ); |
|
257 | - |
|
258 | - $chart->setTitle( __( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 ); |
|
259 | - |
|
260 | - $chart->setScale( 0, $max_earnings ); |
|
261 | - |
|
262 | - $y_axis = new GoogleChartAxis( 'y' ); |
|
263 | - $y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) ); |
|
264 | - $chart->addAxis( $y_axis ); |
|
265 | - |
|
266 | - $x_axis = new GoogleChartAxis( 'x' ); |
|
267 | - $x_axis->setTickMarks( 5 ); |
|
268 | - $x_axis->setLabels( array( |
|
269 | - __( 'Jan', 'give' ), |
|
270 | - __( 'Feb', 'give' ), |
|
271 | - __( 'Mar', 'give' ), |
|
272 | - __( 'Apr', 'give' ), |
|
273 | - __( 'May', 'give' ), |
|
274 | - __( 'June', 'give' ), |
|
275 | - __( 'July', 'give' ), |
|
276 | - __( 'Aug', 'give' ), |
|
277 | - __( 'Sept', 'give' ), |
|
278 | - __( 'Oct', 'give' ), |
|
279 | - __( 'Nov', 'give' ), |
|
280 | - __( 'Dec', 'give' ) |
|
281 | - ) ); |
|
282 | - $chart->addAxis( $x_axis ); |
|
283 | - |
|
284 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
285 | - $shape_marker->setSize( 6 ); |
|
286 | - $shape_marker->setBorder( 2 ); |
|
287 | - $shape_marker->setData( $data ); |
|
288 | - $chart->addMarker( $shape_marker ); |
|
289 | - |
|
290 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
291 | - $value_marker->setData( $data ); |
|
292 | - $chart->addMarker( $value_marker ); |
|
253 | + )); |
|
254 | + $data->setLegend(__('Donations', 'give')); |
|
255 | + $data->setColor('ff6c1c'); |
|
256 | + $chart->addData($data); |
|
257 | + |
|
258 | + $chart->setTitle(__('Donations by Month for all Give Forms', 'give'), '336699', 18); |
|
259 | + |
|
260 | + $chart->setScale(0, $max_earnings); |
|
261 | + |
|
262 | + $y_axis = new GoogleChartAxis('y'); |
|
263 | + $y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings)); |
|
264 | + $chart->addAxis($y_axis); |
|
265 | + |
|
266 | + $x_axis = new GoogleChartAxis('x'); |
|
267 | + $x_axis->setTickMarks(5); |
|
268 | + $x_axis->setLabels(array( |
|
269 | + __('Jan', 'give'), |
|
270 | + __('Feb', 'give'), |
|
271 | + __('Mar', 'give'), |
|
272 | + __('Apr', 'give'), |
|
273 | + __('May', 'give'), |
|
274 | + __('June', 'give'), |
|
275 | + __('July', 'give'), |
|
276 | + __('Aug', 'give'), |
|
277 | + __('Sept', 'give'), |
|
278 | + __('Oct', 'give'), |
|
279 | + __('Nov', 'give'), |
|
280 | + __('Dec', 'give') |
|
281 | + )); |
|
282 | + $chart->addAxis($x_axis); |
|
283 | + |
|
284 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
285 | + $shape_marker->setSize(6); |
|
286 | + $shape_marker->setBorder(2); |
|
287 | + $shape_marker->setData($data); |
|
288 | + $chart->addMarker($shape_marker); |
|
289 | + |
|
290 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
291 | + $value_marker->setData($data); |
|
292 | + $chart->addMarker($value_marker); |
|
293 | 293 | |
294 | 294 | return $chart->getUrl(); |
295 | 295 | } |