@@ -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&tab=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&tab=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 | |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function get_columns() { |
98 | 98 | $columns = array( |
99 | - 'title' => esc_html__( 'Form', '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' ) |
|
99 | + 'title' => esc_html__('Form', '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 | |
175 | 175 | } |
176 | 176 | |
@@ -182,27 +182,27 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @param string $which |
184 | 184 | */ |
185 | - protected function display_tablenav( $which ) { |
|
185 | + protected function display_tablenav($which) { |
|
186 | 186 | |
187 | - if ( 'top' === $which ) { |
|
188 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
187 | + if ('top' === $which) { |
|
188 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
189 | 189 | } |
190 | 190 | ?> |
191 | - <div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
191 | + <div class="tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
192 | 192 | |
193 | - <?php if ( 'top' === $which ) { ?> |
|
193 | + <?php if ('top' === $which) { ?> |
|
194 | 194 | <h3 class="alignleft reports-earnings-title"> |
195 | - <span><?php esc_html_e( 'Donation Forms Report', 'give' ); ?></span> |
|
195 | + <span><?php esc_html_e('Donation Forms Report', 'give'); ?></span> |
|
196 | 196 | </h3> |
197 | 197 | <?php } ?> |
198 | 198 | |
199 | 199 | <div class="alignright tablenav-right"> |
200 | 200 | <div class="actions bulkactions"> |
201 | - <?php $this->bulk_actions( $which ); ?> |
|
201 | + <?php $this->bulk_actions($which); ?> |
|
202 | 202 | </div> |
203 | 203 | <?php |
204 | - $this->extra_tablenav( $which ); |
|
205 | - $this->pagination( $which ); |
|
204 | + $this->extra_tablenav($which); |
|
205 | + $this->pagination($which); |
|
206 | 206 | ?> |
207 | 207 | </div> |
208 | 208 | |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function category_filter() { |
224 | 224 | |
225 | - $categories = get_terms( 'form_category' ); |
|
226 | - if ( $categories && ! is_wp_error( $categories ) ) { |
|
227 | - echo Give()->html->category_dropdown( 'category', $this->get_category() ); |
|
225 | + $categories = get_terms('form_category'); |
|
226 | + if ($categories && ! is_wp_error($categories)) { |
|
227 | + echo Give()->html->category_dropdown('category', $this->get_category()); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function query() { |
240 | 240 | |
241 | - $orderby = isset( $_GET['orderby'] ) ? $_GET['orderby'] : 'title'; |
|
242 | - $order = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC'; |
|
241 | + $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : 'title'; |
|
242 | + $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; |
|
243 | 243 | $category = $this->get_category(); |
244 | 244 | |
245 | 245 | $args = array( |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | 'suppress_filters' => true |
253 | 253 | ); |
254 | 254 | |
255 | - if ( ! empty( $category ) ) { |
|
255 | + if ( ! empty($category)) { |
|
256 | 256 | $args['tax_query'] = array( |
257 | 257 | array( |
258 | 258 | 'taxonomy' => 'form_category', |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | ); |
262 | 262 | } |
263 | 263 | |
264 | - switch ( $orderby ) : |
|
264 | + switch ($orderby) : |
|
265 | 265 | case 'title' : |
266 | 266 | $args['orderby'] = 'title'; |
267 | 267 | break; |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | break; |
278 | 278 | endswitch; |
279 | 279 | |
280 | - $args = apply_filters( 'give_form_reports_prepare_items_args', $args, $this ); |
|
280 | + $args = apply_filters('give_form_reports_prepare_items_args', $args, $this); |
|
281 | 281 | |
282 | - $this->products = new WP_Query( $args ); |
|
282 | + $this->products = new WP_Query($args); |
|
283 | 283 | |
284 | 284 | } |
285 | 285 | |
@@ -295,15 +295,15 @@ discard block |
||
295 | 295 | |
296 | 296 | $give_forms = $this->products->posts; |
297 | 297 | |
298 | - if ( $give_forms ) { |
|
299 | - foreach ( $give_forms as $form ) { |
|
298 | + if ($give_forms) { |
|
299 | + foreach ($give_forms as $form) { |
|
300 | 300 | $reports_data[] = array( |
301 | 301 | 'ID' => $form, |
302 | - 'title' => get_the_title( $form ), |
|
303 | - 'sales' => give_get_form_sales_stats( $form ), |
|
304 | - 'earnings' => give_get_form_earnings_stats( $form ), |
|
305 | - 'average_sales' => give_get_average_monthly_form_sales( $form ), |
|
306 | - 'average_earnings' => give_get_average_monthly_form_earnings( $form ) |
|
302 | + 'title' => get_the_title($form), |
|
303 | + 'sales' => give_get_form_sales_stats($form), |
|
304 | + 'earnings' => give_get_form_earnings_stats($form), |
|
305 | + 'average_sales' => give_get_average_monthly_form_sales($form), |
|
306 | + 'average_earnings' => give_get_average_monthly_form_earnings($form) |
|
307 | 307 | ); |
308 | 308 | } |
309 | 309 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | |
332 | 332 | $sortable = $this->get_sortable_columns(); |
333 | 333 | |
334 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
334 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
335 | 335 | |
336 | 336 | $data = $this->reports_data(); |
337 | 337 | |
@@ -339,10 +339,10 @@ discard block |
||
339 | 339 | |
340 | 340 | $this->items = $data; |
341 | 341 | |
342 | - $this->set_pagination_args( array( |
|
342 | + $this->set_pagination_args(array( |
|
343 | 343 | 'total_items' => $total_items, |
344 | 344 | 'per_page' => $this->per_page, |
345 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
345 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
346 | 346 | ) |
347 | 347 | ); |
348 | 348 | } |
@@ -814,12 +814,12 @@ |
||
814 | 814 | ) ), 'give-refresh-reports' ); |
815 | 815 | |
816 | 816 | echo '<a href="' |
817 | - . esc_url_raw( $url ) |
|
818 | - . '" data-tooltip="'. esc_attr__( 'Clicking this will clear the reports cache.', 'give' ) |
|
819 | - . '" data-tooltip-my-position="right center" data-tooltip-target-position="left center" class="button alignright give-admin-button give-tooltip">' |
|
820 | - . '<span class="give-admin-button-icon give-admin-button-icon-update"></span>' |
|
821 | - . esc_html__( 'Refresh Report Data', 'give' ) |
|
822 | - . '</a>'; |
|
817 | + . esc_url_raw( $url ) |
|
818 | + . '" data-tooltip="'. esc_attr__( 'Clicking this will clear the reports cache.', 'give' ) |
|
819 | + . '" data-tooltip-my-position="right center" data-tooltip-target-position="left center" class="button alignright give-admin-button give-tooltip">' |
|
820 | + . '<span class="give-admin-button-icon give-admin-button-icon-update"></span>' |
|
821 | + . esc_html__( 'Refresh Report Data', 'give' ) |
|
822 | + . '</a>'; |
|
823 | 823 | |
824 | 824 | } |
825 | 825 |
@@ -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,7 +25,7 @@ discard block |
||
25 | 25 | $dates = give_get_report_dates(); |
26 | 26 | |
27 | 27 | // Determine graph options |
28 | - switch ( $dates['range'] ) : |
|
28 | + switch ($dates['range']) : |
|
29 | 29 | case 'today' : |
30 | 30 | case 'yesterday' : |
31 | 31 | $day_by_day = true; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $day_by_day = false; |
38 | 38 | break; |
39 | 39 | case 'other' : |
40 | - if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) { |
|
40 | + if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) { |
|
41 | 41 | $day_by_day = false; |
42 | 42 | } else { |
43 | 43 | $day_by_day = true; |
@@ -49,61 +49,61 @@ discard block |
||
49 | 49 | endswitch; |
50 | 50 | |
51 | 51 | $earnings_totals = 0.00; // Total earnings for time period shown |
52 | - $sales_totals = 0; // Total sales for time period shown |
|
52 | + $sales_totals = 0; // Total sales for time period shown |
|
53 | 53 | |
54 | 54 | $earnings_data = array(); |
55 | 55 | $sales_data = array(); |
56 | 56 | |
57 | - if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) { |
|
57 | + if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') { |
|
58 | 58 | // Hour by hour |
59 | 59 | $hour = 1; |
60 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
61 | - while ( $hour <= 23 ) : |
|
60 | + $month = date('n', current_time('timestamp')); |
|
61 | + while ($hour <= 23) : |
|
62 | 62 | |
63 | - $sales = give_get_sales_by_date( $dates['day'], $month, $dates['year'], $hour ); |
|
64 | - $earnings = give_get_earnings_by_date( $dates['day'], $month, $dates['year'], $hour ); |
|
63 | + $sales = give_get_sales_by_date($dates['day'], $month, $dates['year'], $hour); |
|
64 | + $earnings = give_get_earnings_by_date($dates['day'], $month, $dates['year'], $hour); |
|
65 | 65 | |
66 | 66 | $sales_totals += $sales; |
67 | 67 | $earnings_totals += $earnings; |
68 | 68 | |
69 | - $date = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] ) * 1000; |
|
70 | - $sales_data[] = array( $date, $sales ); |
|
71 | - $earnings_data[] = array( $date, $earnings ); |
|
69 | + $date = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']) * 1000; |
|
70 | + $sales_data[] = array($date, $sales); |
|
71 | + $earnings_data[] = array($date, $earnings); |
|
72 | 72 | |
73 | - $hour ++; |
|
73 | + $hour++; |
|
74 | 74 | endwhile; |
75 | 75 | |
76 | - } elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) { |
|
76 | + } elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') { |
|
77 | 77 | |
78 | 78 | // Day by day |
79 | 79 | $day = $dates['day']; |
80 | 80 | $day_end = $dates['day_end']; |
81 | 81 | $month = $dates['m_start']; |
82 | - while ( $day <= $day_end ) : |
|
83 | - $sales = give_get_sales_by_date( $day, $month, $dates['year'] ); |
|
82 | + while ($day <= $day_end) : |
|
83 | + $sales = give_get_sales_by_date($day, $month, $dates['year']); |
|
84 | 84 | $sales_totals += $sales; |
85 | 85 | |
86 | - $earnings = give_get_earnings_by_date( $day, $month, $dates['year'] ); |
|
86 | + $earnings = give_get_earnings_by_date($day, $month, $dates['year']); |
|
87 | 87 | $earnings_totals += $earnings; |
88 | 88 | |
89 | - $date = mktime( 0, 0, 0, $month, $day, $dates['year'] ) * 1000; |
|
90 | - $sales_data[] = array( $date, $sales ); |
|
91 | - $earnings_data[] = array( $date, $earnings ); |
|
92 | - $day ++; |
|
89 | + $date = mktime(0, 0, 0, $month, $day, $dates['year']) * 1000; |
|
90 | + $sales_data[] = array($date, $sales); |
|
91 | + $earnings_data[] = array($date, $earnings); |
|
92 | + $day++; |
|
93 | 93 | endwhile; |
94 | 94 | |
95 | 95 | } else { |
96 | 96 | |
97 | 97 | $y = $dates['year']; |
98 | - while ( $y <= $dates['year_end'] ) : |
|
98 | + while ($y <= $dates['year_end']) : |
|
99 | 99 | |
100 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
100 | + if ($dates['year'] == $dates['year_end']) { |
|
101 | 101 | $month_start = $dates['m_start']; |
102 | 102 | $month_end = $dates['m_end']; |
103 | - } elseif ( $y == $dates['year'] ) { |
|
103 | + } elseif ($y == $dates['year']) { |
|
104 | 104 | $month_start = $dates['m_start']; |
105 | 105 | $month_end = 12; |
106 | - } elseif ( $y == $dates['year_end'] ) { |
|
106 | + } elseif ($y == $dates['year_end']) { |
|
107 | 107 | $month_start = 1; |
108 | 108 | $month_end = $dates['m_end']; |
109 | 109 | } else { |
@@ -112,48 +112,48 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | $i = $month_start; |
115 | - while ( $i <= $month_end ) : |
|
115 | + while ($i <= $month_end) : |
|
116 | 116 | |
117 | - if ( $day_by_day ) { |
|
117 | + if ($day_by_day) { |
|
118 | 118 | |
119 | - if ( $i == $month_end ) { |
|
119 | + if ($i == $month_end) { |
|
120 | 120 | |
121 | 121 | $num_of_days = $dates['day_end']; |
122 | 122 | |
123 | 123 | } else { |
124 | 124 | |
125 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
125 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
126 | 126 | |
127 | 127 | } |
128 | 128 | |
129 | 129 | $d = $dates['day']; |
130 | 130 | |
131 | - while ( $d <= $num_of_days ) : |
|
131 | + while ($d <= $num_of_days) : |
|
132 | 132 | |
133 | - $sales = give_get_sales_by_date( $d, $i, $y ); |
|
133 | + $sales = give_get_sales_by_date($d, $i, $y); |
|
134 | 134 | $sales_totals += $sales; |
135 | 135 | |
136 | - $earnings = give_get_earnings_by_date( $d, $i, $y ); |
|
136 | + $earnings = give_get_earnings_by_date($d, $i, $y); |
|
137 | 137 | $earnings_totals += $earnings; |
138 | 138 | |
139 | - $date = mktime( 0, 0, 0, $i, $d, $y ) * 1000; |
|
140 | - $sales_data[] = array( $date, $sales ); |
|
141 | - $earnings_data[] = array( $date, $earnings ); |
|
142 | - $d ++; |
|
139 | + $date = mktime(0, 0, 0, $i, $d, $y) * 1000; |
|
140 | + $sales_data[] = array($date, $sales); |
|
141 | + $earnings_data[] = array($date, $earnings); |
|
142 | + $d++; |
|
143 | 143 | |
144 | 144 | endwhile; |
145 | 145 | |
146 | 146 | } else { |
147 | 147 | |
148 | - $sales = give_get_sales_by_date( null, $i, $y ); |
|
148 | + $sales = give_get_sales_by_date(null, $i, $y); |
|
149 | 149 | $sales_totals += $sales; |
150 | 150 | |
151 | - $earnings = give_get_earnings_by_date( null, $i, $y ); |
|
151 | + $earnings = give_get_earnings_by_date(null, $i, $y); |
|
152 | 152 | $earnings_totals += $earnings; |
153 | 153 | |
154 | - if ( $i == $month_end ) { |
|
154 | + if ($i == $month_end) { |
|
155 | 155 | |
156 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
156 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
157 | 157 | |
158 | 158 | } else { |
159 | 159 | |
@@ -161,24 +161,24 @@ discard block |
||
161 | 161 | |
162 | 162 | } |
163 | 163 | |
164 | - $date = mktime( 0, 0, 0, $i, $num_of_days, $y ) * 1000; |
|
165 | - $sales_data[] = array( $date, $sales ); |
|
166 | - $earnings_data[] = array( $date, $earnings ); |
|
164 | + $date = mktime(0, 0, 0, $i, $num_of_days, $y) * 1000; |
|
165 | + $sales_data[] = array($date, $sales); |
|
166 | + $earnings_data[] = array($date, $earnings); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | |
170 | - $i ++; |
|
170 | + $i++; |
|
171 | 171 | |
172 | 172 | endwhile; |
173 | 173 | |
174 | - $y ++; |
|
174 | + $y++; |
|
175 | 175 | endwhile; |
176 | 176 | |
177 | 177 | } |
178 | 178 | |
179 | 179 | $data = array( |
180 | - esc_html__( 'Income', 'give' ) => $earnings_data, |
|
181 | - esc_html__( 'Donations', 'give' ) => $sales_data |
|
180 | + esc_html__('Income', 'give') => $earnings_data, |
|
181 | + esc_html__('Donations', 'give') => $sales_data |
|
182 | 182 | ); |
183 | 183 | |
184 | 184 | // start our own output buffer |
@@ -191,12 +191,12 @@ discard block |
||
191 | 191 | <div class="inside"> |
192 | 192 | <?php give_reports_graph_controls(); ?> |
193 | 193 | <?php |
194 | - $graph = new Give_Graph( $data ); |
|
195 | - $graph->set( 'x_mode', 'time' ); |
|
196 | - $graph->set( 'multiple_y_axes', true ); |
|
194 | + $graph = new Give_Graph($data); |
|
195 | + $graph->set('x_mode', 'time'); |
|
196 | + $graph->set('multiple_y_axes', true); |
|
197 | 197 | $graph->display(); |
198 | 198 | |
199 | - if ( 'this_month' == $dates['range'] ) { |
|
199 | + if ('this_month' == $dates['range']) { |
|
200 | 200 | $estimated = give_estimated_monthly_stats(); |
201 | 201 | } |
202 | 202 | ?> |
@@ -205,21 +205,21 @@ discard block |
||
205 | 205 | <table class="widefat reports-table alignleft" style="max-width:450px"> |
206 | 206 | <tbody> |
207 | 207 | <tr> |
208 | - <th scope="row"><strong><?php esc_html_e( 'Total income for period:', 'give' ); ?></strong></th> |
|
209 | - <td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td> |
|
208 | + <th scope="row"><strong><?php esc_html_e('Total income for period:', 'give'); ?></strong></th> |
|
209 | + <td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td> |
|
210 | 210 | </tr> |
211 | 211 | <tr class="alternate"> |
212 | - <th scope="row"><strong><?php esc_html_e( 'Total donations for period:', 'give' ); ?><strong></th> |
|
212 | + <th scope="row"><strong><?php esc_html_e('Total donations for period:', 'give'); ?><strong></th> |
|
213 | 213 | <td><?php echo $sales_totals; ?></td> |
214 | 214 | </tr> |
215 | - <?php if ( 'this_month' == $dates['range'] ) : ?> |
|
215 | + <?php if ('this_month' == $dates['range']) : ?> |
|
216 | 216 | <tr> |
217 | - <th scope="row"><strong><?php esc_html_e( 'Estimated monthly income:', 'give' ); ?></strong></th> |
|
218 | - <td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'] ) ); ?></td> |
|
217 | + <th scope="row"><strong><?php esc_html_e('Estimated monthly income:', 'give'); ?></strong></th> |
|
218 | + <td><?php echo give_currency_filter(give_format_amount($estimated['earnings'])); ?></td> |
|
219 | 219 | </tr> |
220 | 220 | <tr class="alternate"> |
221 | - <th scope="row"><strong><?php esc_html_e( 'Estimated monthly donations:', 'give' ); ?></strong></th> |
|
222 | - <td><?php echo floor( $estimated['sales'] ); ?></td> |
|
221 | + <th scope="row"><strong><?php esc_html_e('Estimated monthly donations:', 'give'); ?></strong></th> |
|
222 | + <td><?php echo floor($estimated['sales']); ?></td> |
|
223 | 223 | </tr> |
224 | 224 | <?php endif; ?> |
225 | 225 | </table> |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @since 1.0 |
234 | 234 | */ |
235 | - do_action( 'give_reports_graph_additional_stats' ); |
|
235 | + do_action('give_reports_graph_additional_stats'); |
|
236 | 236 | ?> |
237 | 237 | |
238 | 238 | </div> |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | * @since 1.0 |
252 | 252 | * @return void |
253 | 253 | */ |
254 | -function give_reports_graph_of_form( $form_id = 0 ) { |
|
254 | +function give_reports_graph_of_form($form_id = 0) { |
|
255 | 255 | // Retrieve the queried dates |
256 | 256 | $dates = give_get_report_dates(); |
257 | 257 | |
258 | 258 | // Determine graph options |
259 | - switch ( $dates['range'] ) : |
|
259 | + switch ($dates['range']) : |
|
260 | 260 | case 'today' : |
261 | 261 | case 'yesterday' : |
262 | 262 | $day_by_day = true; |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $day_by_day = false; |
275 | 275 | break; |
276 | 276 | case 'other' : |
277 | - if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] ) { |
|
277 | + if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) { |
|
278 | 278 | $day_by_day = false; |
279 | 279 | } else { |
280 | 280 | $day_by_day = true; |
@@ -286,75 +286,75 @@ discard block |
||
286 | 286 | endswitch; |
287 | 287 | |
288 | 288 | $earnings_totals = (float) 0.00; // Total earnings for time period shown |
289 | - $sales_totals = 0; // Total sales for time period shown |
|
289 | + $sales_totals = 0; // Total sales for time period shown |
|
290 | 290 | |
291 | 291 | $earnings_data = array(); |
292 | 292 | $sales_data = array(); |
293 | 293 | $stats = new Give_Payment_Stats; |
294 | 294 | |
295 | - if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) { |
|
295 | + if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') { |
|
296 | 296 | |
297 | 297 | // Hour by hour |
298 | 298 | $month = $dates['m_start']; |
299 | 299 | $hour = 1; |
300 | 300 | $minute = 0; |
301 | 301 | $second = 0; |
302 | - while ( $hour <= 23 ) : |
|
302 | + while ($hour <= 23) : |
|
303 | 303 | |
304 | - if ( $hour == 23 ) { |
|
304 | + if ($hour == 23) { |
|
305 | 305 | $minute = $second = 59; |
306 | 306 | } |
307 | 307 | |
308 | - $date = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] ); |
|
309 | - $date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] ); |
|
308 | + $date = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']); |
|
309 | + $date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']); |
|
310 | 310 | |
311 | - $sales = $stats->get_sales( $form_id, $date, $date_end ); |
|
311 | + $sales = $stats->get_sales($form_id, $date, $date_end); |
|
312 | 312 | $sales_totals += $sales; |
313 | 313 | |
314 | - $earnings = $stats->get_earnings( $form_id, $date, $date_end ); |
|
314 | + $earnings = $stats->get_earnings($form_id, $date, $date_end); |
|
315 | 315 | $earnings_totals += $earnings; |
316 | 316 | |
317 | - $sales_data[] = array( $date * 1000, $sales ); |
|
318 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
317 | + $sales_data[] = array($date * 1000, $sales); |
|
318 | + $earnings_data[] = array($date * 1000, $earnings); |
|
319 | 319 | |
320 | - $hour ++; |
|
320 | + $hour++; |
|
321 | 321 | endwhile; |
322 | 322 | |
323 | - } elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) { |
|
323 | + } elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') { |
|
324 | 324 | |
325 | 325 | //Day by day |
326 | 326 | $day = $dates['day']; |
327 | 327 | $day_end = $dates['day_end']; |
328 | 328 | $month = $dates['m_start']; |
329 | - while ( $day <= $day_end ) : |
|
329 | + while ($day <= $day_end) : |
|
330 | 330 | |
331 | - $date = mktime( 0, 0, 0, $month, $day, $dates['year'] ); |
|
332 | - $date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] ); |
|
333 | - $sales = $stats->get_sales( $form_id, $date, $date_end ); |
|
331 | + $date = mktime(0, 0, 0, $month, $day, $dates['year']); |
|
332 | + $date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']); |
|
333 | + $sales = $stats->get_sales($form_id, $date, $date_end); |
|
334 | 334 | $sales_totals += $sales; |
335 | 335 | |
336 | - $earnings = $stats->get_earnings( $form_id, $date, $date_end ); |
|
336 | + $earnings = $stats->get_earnings($form_id, $date, $date_end); |
|
337 | 337 | $earnings_totals += $earnings; |
338 | 338 | |
339 | - $sales_data[] = array( $date * 1000, $sales ); |
|
340 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
339 | + $sales_data[] = array($date * 1000, $sales); |
|
340 | + $earnings_data[] = array($date * 1000, $earnings); |
|
341 | 341 | |
342 | - $day ++; |
|
342 | + $day++; |
|
343 | 343 | endwhile; |
344 | 344 | |
345 | 345 | } else { |
346 | 346 | |
347 | 347 | $y = $dates['year']; |
348 | 348 | |
349 | - while ( $y <= $dates['year_end'] ) : |
|
349 | + while ($y <= $dates['year_end']) : |
|
350 | 350 | |
351 | 351 | $last_year = false; |
352 | 352 | |
353 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
353 | + if ($dates['year'] == $dates['year_end']) { |
|
354 | 354 | $month_start = $dates['m_start']; |
355 | 355 | $month_end = $dates['m_end']; |
356 | 356 | $last_year = true; |
357 | - } elseif ( $y == $dates['year'] ) { |
|
357 | + } elseif ($y == $dates['year']) { |
|
358 | 358 | $month_start = $dates['m_start']; |
359 | 359 | $month_end = 12; |
360 | 360 | } else { |
@@ -363,76 +363,76 @@ discard block |
||
363 | 363 | } |
364 | 364 | |
365 | 365 | $i = $month_start; |
366 | - while ( $i <= $month_end ) : |
|
366 | + while ($i <= $month_end) : |
|
367 | 367 | |
368 | - if ( $day_by_day ) { |
|
368 | + if ($day_by_day) { |
|
369 | 369 | |
370 | - if ( $i == $month_end && $last_year ) { |
|
370 | + if ($i == $month_end && $last_year) { |
|
371 | 371 | |
372 | 372 | $num_of_days = $dates['day_end']; |
373 | 373 | |
374 | 374 | } else { |
375 | 375 | |
376 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
376 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
377 | 377 | |
378 | 378 | } |
379 | 379 | |
380 | 380 | $d = $dates['day']; |
381 | - while ( $d <= $num_of_days ) : |
|
381 | + while ($d <= $num_of_days) : |
|
382 | 382 | |
383 | - $date = mktime( 0, 0, 0, $i, $d, $y ); |
|
384 | - $end_date = mktime( 23, 59, 59, $i, $d, $y ); |
|
383 | + $date = mktime(0, 0, 0, $i, $d, $y); |
|
384 | + $end_date = mktime(23, 59, 59, $i, $d, $y); |
|
385 | 385 | |
386 | - $sales = $stats->get_sales( $form_id, $date, $end_date ); |
|
386 | + $sales = $stats->get_sales($form_id, $date, $end_date); |
|
387 | 387 | $sales_totals += $sales; |
388 | 388 | |
389 | - $earnings = $stats->get_earnings( $form_id, $date, $end_date ); |
|
389 | + $earnings = $stats->get_earnings($form_id, $date, $end_date); |
|
390 | 390 | $earnings_totals += $earnings; |
391 | 391 | |
392 | - $sales_data[] = array( $date * 1000, $sales ); |
|
393 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
394 | - $d ++; |
|
392 | + $sales_data[] = array($date * 1000, $sales); |
|
393 | + $earnings_data[] = array($date * 1000, $earnings); |
|
394 | + $d++; |
|
395 | 395 | |
396 | 396 | endwhile; |
397 | 397 | |
398 | 398 | } else { |
399 | 399 | |
400 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
400 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
401 | 401 | |
402 | - $date = mktime( 0, 0, 0, $i, 1, $y ); |
|
403 | - $end_date = mktime( 23, 59, 59, $i, $num_of_days, $y ); |
|
402 | + $date = mktime(0, 0, 0, $i, 1, $y); |
|
403 | + $end_date = mktime(23, 59, 59, $i, $num_of_days, $y); |
|
404 | 404 | |
405 | - $sales = $stats->get_sales( $form_id, $date, $end_date ); |
|
405 | + $sales = $stats->get_sales($form_id, $date, $end_date); |
|
406 | 406 | $sales_totals += $sales; |
407 | 407 | |
408 | - $earnings = $stats->get_earnings( $form_id, $date, $end_date ); |
|
408 | + $earnings = $stats->get_earnings($form_id, $date, $end_date); |
|
409 | 409 | $earnings_totals += $earnings; |
410 | 410 | |
411 | - $sales_data[] = array( $date * 1000, $sales ); |
|
412 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
411 | + $sales_data[] = array($date * 1000, $sales); |
|
412 | + $earnings_data[] = array($date * 1000, $earnings); |
|
413 | 413 | |
414 | 414 | } |
415 | 415 | |
416 | - $i ++; |
|
416 | + $i++; |
|
417 | 417 | |
418 | 418 | endwhile; |
419 | 419 | |
420 | - $y ++; |
|
420 | + $y++; |
|
421 | 421 | endwhile; |
422 | 422 | |
423 | 423 | } |
424 | 424 | |
425 | 425 | $data = array( |
426 | - esc_html__( 'Income', 'give' ) => $earnings_data, |
|
427 | - esc_html__( 'Donations', 'give' ) => $sales_data |
|
426 | + esc_html__('Income', 'give') => $earnings_data, |
|
427 | + esc_html__('Donations', 'give') => $sales_data |
|
428 | 428 | ); |
429 | 429 | |
430 | 430 | ?> |
431 | 431 | <h3><span><?php |
432 | 432 | printf( |
433 | 433 | /* translators: %s: form title */ |
434 | - esc_html__( 'Income Report for %s', 'give' ), |
|
435 | - get_the_title( $form_id ) |
|
434 | + esc_html__('Income Report for %s', 'give'), |
|
435 | + get_the_title($form_id) |
|
436 | 436 | ); |
437 | 437 | ?></span></h3> |
438 | 438 | <div id="give-dashboard-widgets-wrap"> |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | <div class="inside"> |
442 | 442 | <?php give_reports_graph_controls(); ?> |
443 | 443 | <?php |
444 | - $graph = new Give_Graph( $data ); |
|
445 | - $graph->set( 'x_mode', 'time' ); |
|
446 | - $graph->set( 'multiple_y_axes', true ); |
|
444 | + $graph = new Give_Graph($data); |
|
445 | + $graph->set('x_mode', 'time'); |
|
446 | + $graph->set('multiple_y_axes', true); |
|
447 | 447 | $graph->display(); |
448 | 448 | ?> |
449 | 449 | </div> |
@@ -452,20 +452,20 @@ discard block |
||
452 | 452 | <table class="widefat reports-table alignleft" style="max-width:450px"> |
453 | 453 | <tbody> |
454 | 454 | <tr> |
455 | - <th scope="row"><strong><?php esc_html_e( 'Total income for period:', 'give' ); ?></strong></th> |
|
456 | - <td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td> |
|
455 | + <th scope="row"><strong><?php esc_html_e('Total income for period:', 'give'); ?></strong></th> |
|
456 | + <td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td> |
|
457 | 457 | </tr> |
458 | 458 | <tr class="alternate"> |
459 | - <th scope="row"><strong><?php esc_html_e( 'Total donations for period:', 'give' ); ?></strong></th> |
|
459 | + <th scope="row"><strong><?php esc_html_e('Total donations for period:', 'give'); ?></strong></th> |
|
460 | 460 | <td><?php echo $sales_totals; ?></td> |
461 | 461 | </tr> |
462 | 462 | <tr> |
463 | - <th scope="row"><strong><?php esc_html_e( 'Average monthly income:', 'give' ); ?></strong></th> |
|
464 | - <td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ) ) ); ?></td> |
|
463 | + <th scope="row"><strong><?php esc_html_e('Average monthly income:', 'give'); ?></strong></th> |
|
464 | + <td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id))); ?></td> |
|
465 | 465 | </tr> |
466 | 466 | <tr class="alternate"> |
467 | - <th scope="row"><strong><?php esc_html_e( 'Average monthly donations:', 'give' ); ?></strong></th> |
|
468 | - <td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td> |
|
467 | + <th scope="row"><strong><?php esc_html_e('Average monthly donations:', 'give'); ?></strong></th> |
|
468 | + <td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td> |
|
469 | 469 | </tr> |
470 | 470 | </tbody> |
471 | 471 | </table> |
@@ -484,26 +484,26 @@ discard block |
||
484 | 484 | * @return void |
485 | 485 | */ |
486 | 486 | function give_reports_graph_controls() { |
487 | - $date_options = apply_filters( 'give_report_date_options', array( |
|
488 | - 'today' => esc_html__( 'Today', 'give' ), |
|
489 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
490 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
491 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
492 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
493 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
494 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
495 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
496 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
497 | - 'last_year' => esc_html__( 'Last Year', 'give' ), |
|
498 | - 'other' => esc_html__( 'Custom', 'give' ) |
|
499 | - ) ); |
|
487 | + $date_options = apply_filters('give_report_date_options', array( |
|
488 | + 'today' => esc_html__('Today', 'give'), |
|
489 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
490 | + 'this_week' => esc_html__('This Week', 'give'), |
|
491 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
492 | + 'this_month' => esc_html__('This Month', 'give'), |
|
493 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
494 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
495 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
496 | + 'this_year' => esc_html__('This Year', 'give'), |
|
497 | + 'last_year' => esc_html__('Last Year', 'give'), |
|
498 | + 'other' => esc_html__('Custom', 'give') |
|
499 | + )); |
|
500 | 500 | |
501 | 501 | $dates = give_get_report_dates(); |
502 | 502 | $display = $dates['range'] == 'other' ? '' : 'display: none;'; |
503 | - $tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
503 | + $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
504 | 504 | |
505 | - if ( empty( $dates['day_end'] ) ) { |
|
506 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) ); |
|
505 | + if (empty($dates['day_end'])) { |
|
506 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y')); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | /** |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | * |
512 | 512 | * @since 1.0 |
513 | 513 | */ |
514 | - do_action( 'give_report_graph_controls_before' ); |
|
514 | + do_action('give_report_graph_controls_before'); |
|
515 | 515 | ?> |
516 | 516 | <form id="give-graphs-filter" method="get"> |
517 | 517 | <div class="tablenav top"> |
@@ -519,56 +519,56 @@ discard block |
||
519 | 519 | |
520 | 520 | <input type="hidden" name="post_type" value="give_forms" /> |
521 | 521 | <input type="hidden" name="page" value="give-reports" /> |
522 | - <input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" /> |
|
522 | + <input type="hidden" name="tab" value="<?php echo esc_attr($tab); ?>" /> |
|
523 | 523 | |
524 | - <?php if ( isset( $_GET['form-id'] ) ) : ?> |
|
525 | - <input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" /> |
|
524 | + <?php if (isset($_GET['form-id'])) : ?> |
|
525 | + <input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" /> |
|
526 | 526 | <?php endif; ?> |
527 | 527 | |
528 | 528 | <div id="give-graphs-date-options-wrap"> |
529 | 529 | <select id="give-graphs-date-options" name="range"> |
530 | - <?php foreach ( $date_options as $key => $option ) : ?> |
|
531 | - <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option> |
|
530 | + <?php foreach ($date_options as $key => $option) : ?> |
|
531 | + <option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option> |
|
532 | 532 | <?php endforeach; ?> |
533 | 533 | </select> |
534 | 534 | |
535 | - <div id="give-date-range-options" style="<?php echo esc_attr( $display ); ?>"> |
|
536 | - <span class="screen-reader-text"><?php esc_html_e( 'From', 'give' ); ?> </span> |
|
535 | + <div id="give-date-range-options" style="<?php echo esc_attr($display); ?>"> |
|
536 | + <span class="screen-reader-text"><?php esc_html_e('From', 'give'); ?> </span> |
|
537 | 537 | <select id="give-graphs-month-start" name="m_start" aria-label="Start Month"> |
538 | - <?php for ( $i = 1; $i <= 12; $i ++ ) : ?> |
|
539 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_start'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option> |
|
538 | + <?php for ($i = 1; $i <= 12; $i++) : ?> |
|
539 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_start'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option> |
|
540 | 540 | <?php endfor; ?> |
541 | 541 | </select> |
542 | 542 | <select id="give-graphs-day-start" name="day" aria-label="Start Day"> |
543 | - <?php for ( $i = 1; $i <= 31; $i ++ ) : ?> |
|
544 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
543 | + <?php for ($i = 1; $i <= 31; $i++) : ?> |
|
544 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day'])); ?>><?php echo esc_html($i); ?></option> |
|
545 | 545 | <?php endfor; ?> |
546 | 546 | </select> |
547 | 547 | <select id="give-graphs-year-start" name="year" aria-label="Start Year"> |
548 | - <?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?> |
|
549 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
548 | + <?php for ($i = 2007; $i <= date('Y'); $i++) : ?> |
|
549 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year'])); ?>><?php echo esc_html($i); ?></option> |
|
550 | 550 | <?php endfor; ?> |
551 | 551 | </select> |
552 | - <span class="screen-reader-text"><?php esc_html_e( 'To', 'give' ); ?> </span> |
|
552 | + <span class="screen-reader-text"><?php esc_html_e('To', 'give'); ?> </span> |
|
553 | 553 | <span>–</span> |
554 | 554 | <select id="give-graphs-month-end" name="m_end" aria-label="End Month"> |
555 | - <?php for ( $i = 1; $i <= 12; $i ++ ) : ?> |
|
556 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_end'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option> |
|
555 | + <?php for ($i = 1; $i <= 12; $i++) : ?> |
|
556 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_end'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option> |
|
557 | 557 | <?php endfor; ?> |
558 | 558 | </select> |
559 | 559 | <select id="give-graphs-day-end" name="day_end" aria-label="End Day"> |
560 | - <?php for ( $i = 1; $i <= 31; $i ++ ) : ?> |
|
561 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day_end'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
560 | + <?php for ($i = 1; $i <= 31; $i++) : ?> |
|
561 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day_end'])); ?>><?php echo esc_html($i); ?></option> |
|
562 | 562 | <?php endfor; ?> |
563 | 563 | </select> |
564 | 564 | <select id="give-graphs-year-end" name="year_end" aria-label="End Year"> |
565 | - <?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?> |
|
566 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year_end'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
565 | + <?php for ($i = 2007; $i <= date('Y'); $i++) : ?> |
|
566 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year_end'])); ?>><?php echo esc_html($i); ?></option> |
|
567 | 567 | <?php endfor; ?> |
568 | 568 | </select> |
569 | 569 | </div> |
570 | 570 | |
571 | - <input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Filter', 'give' ); ?>" /> |
|
571 | + <input type="submit" class="button-secondary" value="<?php esc_attr_e('Filter', 'give'); ?>" /> |
|
572 | 572 | </div> |
573 | 573 | |
574 | 574 | <input type="hidden" name="give_action" value="filter_reports" /> |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @since 1.0 |
583 | 583 | */ |
584 | - do_action( 'give_report_graph_controls_after' ); |
|
584 | + do_action('give_report_graph_controls_after'); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
@@ -596,65 +596,65 @@ discard block |
||
596 | 596 | function give_get_report_dates() { |
597 | 597 | $dates = array(); |
598 | 598 | |
599 | - $current_time = current_time( 'timestamp' ); |
|
599 | + $current_time = current_time('timestamp'); |
|
600 | 600 | |
601 | - $dates['range'] = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month'; |
|
602 | - $dates['year'] = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' ); |
|
603 | - $dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' ); |
|
604 | - $dates['m_start'] = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1; |
|
605 | - $dates['m_end'] = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12; |
|
606 | - $dates['day'] = isset( $_GET['day'] ) ? $_GET['day'] : 1; |
|
607 | - $dates['day_end'] = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
601 | + $dates['range'] = isset($_GET['range']) ? $_GET['range'] : 'this_month'; |
|
602 | + $dates['year'] = isset($_GET['year']) ? $_GET['year'] : date('Y'); |
|
603 | + $dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y'); |
|
604 | + $dates['m_start'] = isset($_GET['m_start']) ? $_GET['m_start'] : 1; |
|
605 | + $dates['m_end'] = isset($_GET['m_end']) ? $_GET['m_end'] : 12; |
|
606 | + $dates['day'] = isset($_GET['day']) ? $_GET['day'] : 1; |
|
607 | + $dates['day_end'] = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
608 | 608 | |
609 | 609 | // Modify dates based on predefined ranges |
610 | - switch ( $dates['range'] ) : |
|
610 | + switch ($dates['range']) : |
|
611 | 611 | |
612 | 612 | case 'this_month' : |
613 | - $dates['m_start'] = date( 'n', $current_time ); |
|
614 | - $dates['m_end'] = date( 'n', $current_time ); |
|
613 | + $dates['m_start'] = date('n', $current_time); |
|
614 | + $dates['m_end'] = date('n', $current_time); |
|
615 | 615 | $dates['day'] = 1; |
616 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
617 | - $dates['year'] = date( 'Y' ); |
|
618 | - $dates['year_end'] = date( 'Y' ); |
|
616 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
617 | + $dates['year'] = date('Y'); |
|
618 | + $dates['year_end'] = date('Y'); |
|
619 | 619 | break; |
620 | 620 | |
621 | 621 | case 'last_month' : |
622 | - if ( date( 'n' ) == 1 ) { |
|
622 | + if (date('n') == 1) { |
|
623 | 623 | $dates['m_start'] = 12; |
624 | 624 | $dates['m_end'] = 12; |
625 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
626 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
625 | + $dates['year'] = date('Y', $current_time) - 1; |
|
626 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
627 | 627 | } else { |
628 | - $dates['m_start'] = date( 'n' ) - 1; |
|
629 | - $dates['m_end'] = date( 'n' ) - 1; |
|
628 | + $dates['m_start'] = date('n') - 1; |
|
629 | + $dates['m_end'] = date('n') - 1; |
|
630 | 630 | $dates['year_end'] = $dates['year']; |
631 | 631 | } |
632 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
632 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
633 | 633 | break; |
634 | 634 | |
635 | 635 | case 'today' : |
636 | - $dates['day'] = date( 'd', $current_time ); |
|
637 | - $dates['m_start'] = date( 'n', $current_time ); |
|
638 | - $dates['m_end'] = date( 'n', $current_time ); |
|
639 | - $dates['year'] = date( 'Y', $current_time ); |
|
636 | + $dates['day'] = date('d', $current_time); |
|
637 | + $dates['m_start'] = date('n', $current_time); |
|
638 | + $dates['m_end'] = date('n', $current_time); |
|
639 | + $dates['year'] = date('Y', $current_time); |
|
640 | 640 | break; |
641 | 641 | |
642 | 642 | case 'yesterday' : |
643 | 643 | |
644 | - $year = date( 'Y', $current_time ); |
|
645 | - $month = date( 'n', $current_time ); |
|
646 | - $day = date( 'd', $current_time ); |
|
644 | + $year = date('Y', $current_time); |
|
645 | + $month = date('n', $current_time); |
|
646 | + $day = date('d', $current_time); |
|
647 | 647 | |
648 | - if ( $month == 1 && $day == 1 ) { |
|
648 | + if ($month == 1 && $day == 1) { |
|
649 | 649 | |
650 | 650 | $year -= 1; |
651 | 651 | $month = 12; |
652 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
652 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
653 | 653 | |
654 | - } elseif ( $month > 1 && $day == 1 ) { |
|
654 | + } elseif ($month > 1 && $day == 1) { |
|
655 | 655 | |
656 | 656 | $month -= 1; |
657 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
657 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
658 | 658 | |
659 | 659 | } else { |
660 | 660 | |
@@ -670,91 +670,91 @@ discard block |
||
670 | 670 | break; |
671 | 671 | |
672 | 672 | case 'this_week' : |
673 | - $dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1; |
|
674 | - $dates['day'] += get_option( 'start_of_week' ); |
|
673 | + $dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1; |
|
674 | + $dates['day'] += get_option('start_of_week'); |
|
675 | 675 | $dates['day_end'] = $dates['day'] + 6; |
676 | - $dates['m_start'] = date( 'n', $current_time ); |
|
677 | - $dates['m_end'] = date( 'n', $current_time ); |
|
678 | - $dates['year'] = date( 'Y', $current_time ); |
|
676 | + $dates['m_start'] = date('n', $current_time); |
|
677 | + $dates['m_end'] = date('n', $current_time); |
|
678 | + $dates['year'] = date('Y', $current_time); |
|
679 | 679 | break; |
680 | 680 | |
681 | 681 | case 'last_week' : |
682 | - $dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8; |
|
683 | - $dates['day'] += get_option( 'start_of_week' ); |
|
682 | + $dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8; |
|
683 | + $dates['day'] += get_option('start_of_week'); |
|
684 | 684 | $dates['day_end'] = $dates['day'] + 6; |
685 | - $dates['year'] = date( 'Y' ); |
|
686 | - |
|
687 | - if ( date( 'j', $current_time ) <= 7 ) { |
|
688 | - $dates['m_start'] = date( 'n', $current_time ) - 1; |
|
689 | - $dates['m_end'] = date( 'n', $current_time ) - 1; |
|
690 | - if ( $dates['m_start'] <= 1 ) { |
|
691 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
692 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
685 | + $dates['year'] = date('Y'); |
|
686 | + |
|
687 | + if (date('j', $current_time) <= 7) { |
|
688 | + $dates['m_start'] = date('n', $current_time) - 1; |
|
689 | + $dates['m_end'] = date('n', $current_time) - 1; |
|
690 | + if ($dates['m_start'] <= 1) { |
|
691 | + $dates['year'] = date('Y', $current_time) - 1; |
|
692 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
693 | 693 | } |
694 | 694 | } else { |
695 | - $dates['m_start'] = date( 'n', $current_time ); |
|
696 | - $dates['m_end'] = date( 'n', $current_time ); |
|
695 | + $dates['m_start'] = date('n', $current_time); |
|
696 | + $dates['m_end'] = date('n', $current_time); |
|
697 | 697 | } |
698 | 698 | break; |
699 | 699 | |
700 | 700 | case 'this_quarter' : |
701 | - $month_now = date( 'n', $current_time ); |
|
701 | + $month_now = date('n', $current_time); |
|
702 | 702 | |
703 | - if ( $month_now <= 3 ) { |
|
703 | + if ($month_now <= 3) { |
|
704 | 704 | |
705 | 705 | $dates['m_start'] = 1; |
706 | 706 | $dates['m_end'] = 4; |
707 | - $dates['year'] = date( 'Y', $current_time ); |
|
707 | + $dates['year'] = date('Y', $current_time); |
|
708 | 708 | |
709 | - } else if ( $month_now <= 6 ) { |
|
709 | + } else if ($month_now <= 6) { |
|
710 | 710 | |
711 | 711 | $dates['m_start'] = 4; |
712 | 712 | $dates['m_end'] = 7; |
713 | - $dates['year'] = date( 'Y', $current_time ); |
|
713 | + $dates['year'] = date('Y', $current_time); |
|
714 | 714 | |
715 | - } else if ( $month_now <= 9 ) { |
|
715 | + } else if ($month_now <= 9) { |
|
716 | 716 | |
717 | 717 | $dates['m_start'] = 7; |
718 | 718 | $dates['m_end'] = 10; |
719 | - $dates['year'] = date( 'Y', $current_time ); |
|
719 | + $dates['year'] = date('Y', $current_time); |
|
720 | 720 | |
721 | 721 | } else { |
722 | 722 | |
723 | 723 | $dates['m_start'] = 10; |
724 | 724 | $dates['m_end'] = 1; |
725 | - $dates['year'] = date( 'Y', $current_time ); |
|
726 | - $dates['year_end'] = date( 'Y', $current_time ) + 1; |
|
725 | + $dates['year'] = date('Y', $current_time); |
|
726 | + $dates['year_end'] = date('Y', $current_time) + 1; |
|
727 | 727 | |
728 | 728 | } |
729 | 729 | break; |
730 | 730 | |
731 | 731 | case 'last_quarter' : |
732 | - $month_now = date( 'n' ); |
|
732 | + $month_now = date('n'); |
|
733 | 733 | |
734 | - if ( $month_now <= 3 ) { |
|
734 | + if ($month_now <= 3) { |
|
735 | 735 | |
736 | 736 | $dates['m_start'] = 10; |
737 | 737 | $dates['m_end'] = 12; |
738 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year |
|
739 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; // Previous year |
|
738 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year |
|
739 | + $dates['year_end'] = date('Y', $current_time) - 1; // Previous year |
|
740 | 740 | |
741 | - } else if ( $month_now <= 6 ) { |
|
741 | + } else if ($month_now <= 6) { |
|
742 | 742 | |
743 | 743 | $dates['m_start'] = 1; |
744 | 744 | $dates['m_end'] = 3; |
745 | - $dates['year'] = date( 'Y', $current_time ); |
|
745 | + $dates['year'] = date('Y', $current_time); |
|
746 | 746 | |
747 | - } else if ( $month_now <= 9 ) { |
|
747 | + } else if ($month_now <= 9) { |
|
748 | 748 | |
749 | 749 | $dates['m_start'] = 4; |
750 | 750 | $dates['m_end'] = 6; |
751 | - $dates['year'] = date( 'Y', $current_time ); |
|
751 | + $dates['year'] = date('Y', $current_time); |
|
752 | 752 | |
753 | 753 | } else { |
754 | 754 | |
755 | 755 | $dates['m_start'] = 7; |
756 | 756 | $dates['m_end'] = 9; |
757 | - $dates['year'] = date( 'Y', $current_time ); |
|
757 | + $dates['year'] = date('Y', $current_time); |
|
758 | 758 | |
759 | 759 | } |
760 | 760 | break; |
@@ -762,19 +762,19 @@ discard block |
||
762 | 762 | case 'this_year' : |
763 | 763 | $dates['m_start'] = 1; |
764 | 764 | $dates['m_end'] = 12; |
765 | - $dates['year'] = date( 'Y', $current_time ); |
|
765 | + $dates['year'] = date('Y', $current_time); |
|
766 | 766 | break; |
767 | 767 | |
768 | 768 | case 'last_year' : |
769 | 769 | $dates['m_start'] = 1; |
770 | 770 | $dates['m_end'] = 12; |
771 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
772 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
771 | + $dates['year'] = date('Y', $current_time) - 1; |
|
772 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
773 | 773 | break; |
774 | 774 | |
775 | 775 | endswitch; |
776 | 776 | |
777 | - return apply_filters( 'give_report_dates', $dates ); |
|
777 | + return apply_filters('give_report_dates', $dates); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | /** |
@@ -785,18 +785,18 @@ discard block |
||
785 | 785 | * |
786 | 786 | * @param $data |
787 | 787 | */ |
788 | -function give_parse_report_dates( $data ) { |
|
788 | +function give_parse_report_dates($data) { |
|
789 | 789 | $dates = give_get_report_dates(); |
790 | 790 | |
791 | 791 | $view = give_get_reporting_view(); |
792 | - $tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
793 | - $id = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null; |
|
792 | + $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
793 | + $id = isset($_GET['form-id']) ? $_GET['form-id'] : null; |
|
794 | 794 | |
795 | - wp_redirect( add_query_arg( $dates, admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=' . esc_attr( $tab ) . '&view=' . esc_attr( $view ) . '&form-id=' . absint( $id ) ) ) ); |
|
795 | + wp_redirect(add_query_arg($dates, admin_url('edit.php?post_type=give_forms&page=give-reports&tab='.esc_attr($tab).'&view='.esc_attr($view).'&form-id='.absint($id)))); |
|
796 | 796 | give_die(); |
797 | 797 | } |
798 | 798 | |
799 | -add_action( 'give_filter_reports', 'give_parse_report_dates' ); |
|
799 | +add_action('give_filter_reports', 'give_parse_report_dates'); |
|
800 | 800 | |
801 | 801 | |
802 | 802 | /** |
@@ -808,22 +808,22 @@ discard block |
||
808 | 808 | */ |
809 | 809 | function give_reports_refresh_button() { |
810 | 810 | |
811 | - $url = wp_nonce_url( add_query_arg( array( |
|
811 | + $url = wp_nonce_url(add_query_arg(array( |
|
812 | 812 | 'give_action' => 'refresh_reports_transients', |
813 | 813 | 'give-message' => 'refreshed-reports' |
814 | - ) ), 'give-refresh-reports' ); |
|
814 | + )), 'give-refresh-reports'); |
|
815 | 815 | |
816 | 816 | echo '<a href="' |
817 | - . esc_url_raw( $url ) |
|
818 | - . '" data-tooltip="'. esc_attr__( 'Clicking this will clear the reports cache.', 'give' ) |
|
817 | + . esc_url_raw($url) |
|
818 | + . '" data-tooltip="'.esc_attr__('Clicking this will clear the reports cache.', 'give') |
|
819 | 819 | . '" data-tooltip-my-position="right center" data-tooltip-target-position="left center" class="button alignright give-admin-button give-tooltip">' |
820 | 820 | . '<span class="give-admin-button-icon give-admin-button-icon-update"></span>' |
821 | - . esc_html__( 'Refresh Report Data', 'give' ) |
|
821 | + . esc_html__('Refresh Report Data', 'give') |
|
822 | 822 | . '</a>'; |
823 | 823 | |
824 | 824 | } |
825 | 825 | |
826 | -add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' ); |
|
826 | +add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button'); |
|
827 | 827 | |
828 | 828 | /** |
829 | 829 | * Trigger the refresh of reports transients |
@@ -834,18 +834,18 @@ discard block |
||
834 | 834 | * |
835 | 835 | * @return void |
836 | 836 | */ |
837 | -function give_run_refresh_reports_transients( $data ) { |
|
837 | +function give_run_refresh_reports_transients($data) { |
|
838 | 838 | |
839 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) { |
|
839 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) { |
|
840 | 840 | return; |
841 | 841 | } |
842 | 842 | |
843 | 843 | //Delete transients |
844 | - delete_transient( 'give_estimated_monthly_stats' ); |
|
845 | - delete_transient( 'give_earnings_total' ); |
|
846 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
847 | - delete_transient( md5( 'give_earnings_todaytoday' ) ); |
|
844 | + delete_transient('give_estimated_monthly_stats'); |
|
845 | + delete_transient('give_earnings_total'); |
|
846 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
847 | + delete_transient(md5('give_earnings_todaytoday')); |
|
848 | 848 | |
849 | 849 | } |
850 | 850 | |
851 | -add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' ); |
|
852 | 851 | \ No newline at end of file |
852 | +add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients'); |
|
853 | 853 | \ No newline at end of file |
@@ -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 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | global $status, $page; |
46 | 46 | |
47 | 47 | // Set parent defaults |
48 | - parent::__construct( array( |
|
49 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
48 | + parent::__construct(array( |
|
49 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | 51 | 'ajax' => false // Does this table support ajax? |
52 | - ) ); |
|
52 | + )); |
|
53 | 53 | |
54 | 54 | } |
55 | 55 | |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
68 | - switch ( $column_name ) { |
|
67 | + public function column_default($item, $column_name) { |
|
68 | + switch ($column_name) { |
|
69 | 69 | default: |
70 | - return $item[ $column_name ]; |
|
70 | + return $item[$column_name]; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function get_columns() { |
82 | 82 | $columns = array( |
83 | - 'label' => esc_attr__( 'Gateway', 'give' ), |
|
84 | - 'complete_sales' => esc_attr__( 'Complete Transactions', 'give' ), |
|
85 | - 'pending_sales' => esc_attr__( 'Pending / Failed Transactions', 'give' ), |
|
86 | - 'total_sales' => esc_attr__( 'Total Transactions', 'give' ), |
|
87 | - 'total_donations' => esc_attr__( 'Total Donated', 'give' ) |
|
83 | + 'label' => esc_attr__('Gateway', 'give'), |
|
84 | + 'complete_sales' => esc_attr__('Complete Transactions', 'give'), |
|
85 | + 'pending_sales' => esc_attr__('Pending / Failed Transactions', 'give'), |
|
86 | + 'total_sales' => esc_attr__('Total Transactions', 'give'), |
|
87 | + 'total_donations' => esc_attr__('Total Donated', 'give') |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | return $columns; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return int Current page number |
100 | 100 | */ |
101 | 101 | public function get_paged() { |
102 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
102 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @since 1.0 |
111 | 111 | * @return void |
112 | 112 | */ |
113 | - public function bulk_actions( $which = '' ) { |
|
113 | + public function bulk_actions($which = '') { |
|
114 | 114 | |
115 | 115 | } |
116 | 116 | |
@@ -122,27 +122,27 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @param string $which |
124 | 124 | */ |
125 | - protected function display_tablenav( $which ) { |
|
125 | + protected function display_tablenav($which) { |
|
126 | 126 | |
127 | - if ( 'top' === $which ) { |
|
128 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
127 | + if ('top' === $which) { |
|
128 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
129 | 129 | } |
130 | 130 | ?> |
131 | - <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
131 | + <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
132 | 132 | |
133 | - <?php if ( 'top' === $which ) { ?> |
|
133 | + <?php if ('top' === $which) { ?> |
|
134 | 134 | <h3 class="alignleft reports-earnings-title"> |
135 | - <span><?php esc_html_e( 'Donation Methods Report', 'give' ); ?></span> |
|
135 | + <span><?php esc_html_e('Donation Methods Report', 'give'); ?></span> |
|
136 | 136 | </h3> |
137 | 137 | <?php } ?> |
138 | 138 | |
139 | 139 | <div class="alignright tablenav-right"> |
140 | 140 | <div class="actions bulkactions"> |
141 | - <?php $this->bulk_actions( $which ); ?> |
|
141 | + <?php $this->bulk_actions($which); ?> |
|
142 | 142 | </div> |
143 | 143 | <?php |
144 | - $this->extra_tablenav( $which ); |
|
145 | - $this->pagination( $which ); |
|
144 | + $this->extra_tablenav($which); |
|
145 | + $this->pagination($which); |
|
146 | 146 | ?> |
147 | 147 | </div> |
148 | 148 | |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | $gateways = give_get_payment_gateways(); |
168 | 168 | $stats = new Give_Payment_Stats(); |
169 | 169 | |
170 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
170 | + foreach ($gateways as $gateway_id => $gateway) { |
|
171 | 171 | |
172 | - $complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' ); |
|
173 | - $pending_count = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) ); |
|
172 | + $complete_count = give_count_sales_by_gateway($gateway_id, 'publish'); |
|
173 | + $pending_count = give_count_sales_by_gateway($gateway_id, array('pending', 'failed')); |
|
174 | 174 | |
175 | 175 | $reports_data[] = array( |
176 | 176 | 'ID' => $gateway_id, |
177 | 177 | 'label' => $gateway['admin_label'], |
178 | - 'complete_sales' => give_format_amount( $complete_count, false ), |
|
179 | - 'pending_sales' => give_format_amount( $pending_count, false ), |
|
180 | - 'total_sales' => give_format_amount( $complete_count + $pending_count, false ), |
|
181 | - 'total_donations' => give_currency_filter( give_format_amount( $stats->get_earnings( 0, 0, 0, $gateway_id ) ) ) |
|
178 | + 'complete_sales' => give_format_amount($complete_count, false), |
|
179 | + 'pending_sales' => give_format_amount($pending_count, false), |
|
180 | + 'total_sales' => give_format_amount($complete_count + $pending_count, false), |
|
181 | + 'total_donations' => give_currency_filter(give_format_amount($stats->get_earnings(0, 0, 0, $gateway_id))) |
|
182 | 182 | ); |
183 | 183 | } |
184 | 184 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $columns = $this->get_columns(); |
201 | 201 | $hidden = array(); // No hidden columns |
202 | 202 | $sortable = $this->get_sortable_columns(); |
203 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
203 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
204 | 204 | $this->items = $this->reports_data(); |
205 | 205 | |
206 | 206 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -25,34 +25,34 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | } |
49 | 49 | |
50 | - if ( $did_upgrade ) { |
|
51 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
50 | + if ($did_upgrade) { |
|
51 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
55 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Display Upgrade Notices |
@@ -62,18 +62,18 @@ discard block |
||
62 | 62 | */ |
63 | 63 | function give_show_upgrade_notices() { |
64 | 64 | // Don't show notices on the upgrades page. |
65 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) { |
|
65 | + if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') { |
|
66 | 66 | return; |
67 | 67 | } |
68 | 68 | |
69 | - $give_version = get_option( 'give_version' ); |
|
69 | + $give_version = get_option('give_version'); |
|
70 | 70 | |
71 | - if ( ! $give_version ) { |
|
71 | + if ( ! $give_version) { |
|
72 | 72 | // 1.0 is the first version to use this option so we must add it. |
73 | 73 | $give_version = '1.0'; |
74 | 74 | } |
75 | 75 | |
76 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
76 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
77 | 77 | |
78 | 78 | /* |
79 | 79 | * NOTICE: |
@@ -84,27 +84,27 @@ discard block |
||
84 | 84 | */ |
85 | 85 | |
86 | 86 | // v1.3.2 Upgrades |
87 | - if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) { |
|
87 | + if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) { |
|
88 | 88 | printf( |
89 | 89 | /* translators: %s: upgrade URL */ |
90 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
91 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) ) |
|
90 | + '<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
91 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id')) |
|
92 | 92 | ); |
93 | 93 | } |
94 | 94 | |
95 | 95 | // v1.3.4 Upgrades //ensure the user has gone through 1.3.4. |
96 | - if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) { |
|
96 | + if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) { |
|
97 | 97 | printf( |
98 | 98 | /* translators: %s: upgrade URL */ |
99 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
100 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) ) |
|
99 | + '<div class="updated"><p>'.__('Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
100 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status')) |
|
101 | 101 | ); |
102 | 102 | } |
103 | 103 | |
104 | 104 | // End 'Stepped' upgrade process notices. |
105 | 105 | } |
106 | 106 | |
107 | -add_action( 'admin_notices', 'give_show_upgrade_notices' ); |
|
107 | +add_action('admin_notices', 'give_show_upgrade_notices'); |
|
108 | 108 | |
109 | 109 | /** |
110 | 110 | * Triggers all upgrade functions |
@@ -116,26 +116,26 @@ discard block |
||
116 | 116 | */ |
117 | 117 | function give_trigger_upgrades() { |
118 | 118 | |
119 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
120 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
119 | + if ( ! current_user_can('manage_give_settings')) { |
|
120 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
121 | 121 | } |
122 | 122 | |
123 | - $give_version = get_option( 'give_version' ); |
|
123 | + $give_version = get_option('give_version'); |
|
124 | 124 | |
125 | - if ( ! $give_version ) { |
|
125 | + if ( ! $give_version) { |
|
126 | 126 | // 1.0 is the first version to use this option so we must add it. |
127 | 127 | $give_version = '1.0'; |
128 | - add_option( 'give_version', $give_version ); |
|
128 | + add_option('give_version', $give_version); |
|
129 | 129 | } |
130 | 130 | |
131 | - update_option( 'give_version', GIVE_VERSION ); |
|
131 | + update_option('give_version', GIVE_VERSION); |
|
132 | 132 | |
133 | - if ( DOING_AJAX ) { |
|
134 | - die( 'complete' ); |
|
133 | + if (DOING_AJAX) { |
|
134 | + die('complete'); |
|
135 | 135 | } // Let AJAX know that the upgrade is complete. |
136 | 136 | } |
137 | 137 | |
138 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
138 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Check if the upgrade routine has been run for a specific action |
@@ -146,15 +146,15 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return bool If the action has been added to the completed actions array |
148 | 148 | */ |
149 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
149 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
150 | 150 | |
151 | - if ( empty( $upgrade_action ) ) { |
|
151 | + if (empty($upgrade_action)) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | 155 | $completed_upgrades = give_get_completed_upgrades(); |
156 | 156 | |
157 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
157 | + return in_array($upgrade_action, $completed_upgrades); |
|
158 | 158 | |
159 | 159 | } |
160 | 160 | |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return bool If the function was successfully added |
169 | 169 | */ |
170 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
170 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
171 | 171 | |
172 | - if ( empty( $upgrade_action ) ) { |
|
172 | + if (empty($upgrade_action)) { |
|
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | $completed_upgrades[] = $upgrade_action; |
178 | 178 | |
179 | 179 | // Remove any blanks, and only show uniques. |
180 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
180 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
181 | 181 | |
182 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
182 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | */ |
191 | 191 | function give_get_completed_upgrades() { |
192 | 192 | |
193 | - $completed_upgrades = get_option( 'give_completed_upgrades' ); |
|
193 | + $completed_upgrades = get_option('give_completed_upgrades'); |
|
194 | 194 | |
195 | - if ( false === $completed_upgrades ) { |
|
195 | + if (false === $completed_upgrades) { |
|
196 | 196 | $completed_upgrades = array(); |
197 | 197 | } |
198 | 198 | |
@@ -209,29 +209,29 @@ discard block |
||
209 | 209 | */ |
210 | 210 | function give_v132_upgrade_give_payment_customer_id() { |
211 | 211 | global $wpdb; |
212 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
213 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
212 | + if ( ! current_user_can('manage_give_settings')) { |
|
213 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
214 | 214 | } |
215 | 215 | |
216 | - ignore_user_abort( true ); |
|
216 | + ignore_user_abort(true); |
|
217 | 217 | |
218 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
219 | - @set_time_limit( 0 ); |
|
218 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
219 | + @set_time_limit(0); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | // UPDATE DB METAKEYS. |
223 | 223 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
224 | - $query = $wpdb->query( $sql ); |
|
224 | + $query = $wpdb->query($sql); |
|
225 | 225 | |
226 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
227 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
228 | - delete_option( 'give_doing_upgrade' ); |
|
229 | - wp_redirect( admin_url() ); |
|
226 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
227 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
228 | + delete_option('give_doing_upgrade'); |
|
229 | + wp_redirect(admin_url()); |
|
230 | 230 | exit; |
231 | 231 | |
232 | 232 | } |
233 | 233 | |
234 | -add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' ); |
|
234 | +add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id'); |
|
235 | 235 | |
236 | 236 | /** |
237 | 237 | * Upgrades the Offline Status |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | |
245 | 245 | global $wpdb; |
246 | 246 | |
247 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
248 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
247 | + if ( ! current_user_can('manage_give_settings')) { |
|
248 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
249 | 249 | } |
250 | 250 | |
251 | - ignore_user_abort( true ); |
|
251 | + ignore_user_abort(true); |
|
252 | 252 | |
253 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
254 | - @set_time_limit( 0 ); |
|
253 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
254 | + @set_time_limit(0); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | // Get abandoned offline payments. |
@@ -261,31 +261,31 @@ discard block |
||
261 | 261 | $where .= "AND ( p.post_status = 'abandoned' )"; |
262 | 262 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
263 | 263 | |
264 | - $sql = $select . $join . $where; |
|
265 | - $found_payments = $wpdb->get_col( $sql ); |
|
264 | + $sql = $select.$join.$where; |
|
265 | + $found_payments = $wpdb->get_col($sql); |
|
266 | 266 | |
267 | - foreach ( $found_payments as $payment ) { |
|
267 | + foreach ($found_payments as $payment) { |
|
268 | 268 | |
269 | 269 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
270 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
270 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
271 | 271 | |
272 | 272 | // 1450124863 = 12/10/2015 20:42:25. |
273 | - if ( $modified_time >= 1450124863 ) { |
|
273 | + if ($modified_time >= 1450124863) { |
|
274 | 274 | |
275 | - give_update_payment_status( $payment, 'pending' ); |
|
275 | + give_update_payment_status($payment, 'pending'); |
|
276 | 276 | |
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
280 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
281 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
282 | - delete_option( 'give_doing_upgrade' ); |
|
283 | - wp_redirect( admin_url() ); |
|
280 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
281 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
282 | + delete_option('give_doing_upgrade'); |
|
283 | + wp_redirect(admin_url()); |
|
284 | 284 | exit; |
285 | 285 | |
286 | 286 | } |
287 | 287 | |
288 | -add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' ); |
|
288 | +add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status'); |
|
289 | 289 | |
290 | 290 | /** |
291 | 291 | * Cleanup User Roles |
@@ -296,17 +296,17 @@ discard block |
||
296 | 296 | */ |
297 | 297 | function give_v152_cleanup_users() { |
298 | 298 | |
299 | - $give_version = get_option( 'give_version' ); |
|
299 | + $give_version = get_option('give_version'); |
|
300 | 300 | |
301 | - if ( ! $give_version ) { |
|
301 | + if ( ! $give_version) { |
|
302 | 302 | // 1.0 is the first version to use this option so we must add it. |
303 | 303 | $give_version = '1.0'; |
304 | 304 | } |
305 | 305 | |
306 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
306 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
307 | 307 | |
308 | 308 | // v1.5.2 Upgrades |
309 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
309 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
310 | 310 | |
311 | 311 | // Delete all caps with "ss". |
312 | 312 | // Also delete all unused "campaign" roles. |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | ); |
354 | 354 | |
355 | 355 | global $wp_roles; |
356 | - foreach ( $delete_caps as $cap ) { |
|
357 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
358 | - $wp_roles->remove_cap( $role, $cap ); |
|
356 | + foreach ($delete_caps as $cap) { |
|
357 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
358 | + $wp_roles->remove_cap($role, $cap); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
@@ -365,15 +365,15 @@ discard block |
||
365 | 365 | $roles->add_caps(); |
366 | 366 | |
367 | 367 | // The Update Ran. |
368 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
369 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
370 | - delete_option( 'give_doing_upgrade' ); |
|
368 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
369 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
370 | + delete_option('give_doing_upgrade'); |
|
371 | 371 | |
372 | 372 | } |
373 | 373 | |
374 | 374 | } |
375 | 375 | |
376 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
376 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
377 | 377 | |
378 | 378 | /** |
379 | 379 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -413,53 +413,53 @@ discard block |
||
413 | 413 | |
414 | 414 | // Get addons license key. |
415 | 415 | $addons = array(); |
416 | - foreach ( $give_options as $key => $value ) { |
|
417 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
418 | - $addons[ $key ] = $value; |
|
416 | + foreach ($give_options as $key => $value) { |
|
417 | + if (false !== strpos($key, '_license_key')) { |
|
418 | + $addons[$key] = $value; |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | |
422 | 422 | // Bailout: We do not have any addon license data to upgrade. |
423 | - if ( empty( $addons ) ) { |
|
423 | + if (empty($addons)) { |
|
424 | 424 | return false; |
425 | 425 | } |
426 | 426 | |
427 | - foreach ( $addons as $key => $addon_license ) { |
|
427 | + foreach ($addons as $key => $addon_license) { |
|
428 | 428 | |
429 | 429 | // Get addon shortname. |
430 | - $shortname = str_replace( '_license_key', '', $key ); |
|
430 | + $shortname = str_replace('_license_key', '', $key); |
|
431 | 431 | |
432 | 432 | // Addon license option name. |
433 | - $addon_license_option_name = $shortname . '_license_active'; |
|
433 | + $addon_license_option_name = $shortname.'_license_active'; |
|
434 | 434 | |
435 | 435 | // bailout if license is empty. |
436 | - if ( empty( $addon_license ) ) { |
|
437 | - delete_option( $addon_license_option_name ); |
|
436 | + if (empty($addon_license)) { |
|
437 | + delete_option($addon_license_option_name); |
|
438 | 438 | continue; |
439 | 439 | } |
440 | 440 | |
441 | 441 | // Get addon name. |
442 | 442 | $addon_name = array(); |
443 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
444 | - foreach ( $addon_name_parts as $name_part ) { |
|
443 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
444 | + foreach ($addon_name_parts as $name_part) { |
|
445 | 445 | |
446 | 446 | // Fix addon name |
447 | - switch ( $name_part ) { |
|
447 | + switch ($name_part) { |
|
448 | 448 | case 'authorizenet' : |
449 | 449 | $name_part = 'authorize.net'; |
450 | 450 | break; |
451 | 451 | } |
452 | 452 | |
453 | - $addon_name[] = ucfirst( $name_part ); |
|
453 | + $addon_name[] = ucfirst($name_part); |
|
454 | 454 | } |
455 | 455 | |
456 | - $addon_name = implode( ' ', $addon_name ); |
|
456 | + $addon_name = implode(' ', $addon_name); |
|
457 | 457 | |
458 | 458 | // Data to send to the API |
459 | 459 | $api_params = array( |
460 | 460 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
461 | 461 | 'license' => $addon_license, |
462 | - 'item_name' => urlencode( $addon_name ), |
|
462 | + 'item_name' => urlencode($addon_name), |
|
463 | 463 | 'url' => home_url() |
464 | 464 | ); |
465 | 465 | |
@@ -474,17 +474,17 @@ discard block |
||
474 | 474 | ); |
475 | 475 | |
476 | 476 | // Make sure there are no errors. |
477 | - if ( is_wp_error( $response ) ) { |
|
478 | - delete_option( $addon_license_option_name ); |
|
477 | + if (is_wp_error($response)) { |
|
478 | + delete_option($addon_license_option_name); |
|
479 | 479 | continue; |
480 | 480 | } |
481 | 481 | |
482 | 482 | // Tell WordPress to look for updates. |
483 | - set_site_transient( 'update_plugins', null ); |
|
483 | + set_site_transient('update_plugins', null); |
|
484 | 484 | |
485 | 485 | // Decode license data. |
486 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
487 | - update_option( $addon_license_option_name, $license_data ); |
|
486 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
487 | + update_option($addon_license_option_name, $license_data); |
|
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
@@ -514,9 +514,9 @@ discard block |
||
514 | 514 | ); |
515 | 515 | |
516 | 516 | global $wp_roles; |
517 | - foreach ( $delete_caps as $cap ) { |
|
518 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
519 | - $wp_roles->remove_cap( $role, $cap ); |
|
517 | + foreach ($delete_caps as $cap) { |
|
518 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
519 | + $wp_roles->remove_cap($role, $cap); |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | function give_v18_upgrades_core_setting() { |
553 | 553 | // Core settings which changes from checkbox to radio. |
554 | 554 | $core_setting_names = array_merge( |
555 | - array_keys( give_v18_renamed_core_settings() ), |
|
555 | + array_keys(give_v18_renamed_core_settings()), |
|
556 | 556 | array( |
557 | 557 | 'uninstall_on_delete', |
558 | 558 | 'scripts_footer', |
@@ -564,44 +564,44 @@ discard block |
||
564 | 564 | ); |
565 | 565 | |
566 | 566 | // Bailout: If not any setting define. |
567 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
567 | + if ($give_settings = get_option('give_settings')) { |
|
568 | 568 | |
569 | 569 | $setting_changed = false; |
570 | 570 | |
571 | 571 | // Loop: check each setting field. |
572 | - foreach ( $core_setting_names as $setting_name ) { |
|
572 | + foreach ($core_setting_names as $setting_name) { |
|
573 | 573 | // New setting name. |
574 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
574 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
575 | 575 | |
576 | 576 | // Continue: If setting already set. |
577 | 577 | if ( |
578 | - array_key_exists( $new_setting_name, $give_settings ) |
|
579 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
578 | + array_key_exists($new_setting_name, $give_settings) |
|
579 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
580 | 580 | ) { |
581 | 581 | continue; |
582 | 582 | } |
583 | 583 | |
584 | 584 | // Set checkbox value to radio value. |
585 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
585 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
586 | 586 | |
587 | 587 | // @see https://github.com/WordImpress/Give/issues/1063 |
588 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
588 | + if (false !== strpos($setting_name, 'disable_')) { |
|
589 | 589 | |
590 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
591 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
590 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
591 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
592 | 592 | |
593 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enable' : 'disabled' ); |
|
593 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enable' : 'disabled'); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | // Tell bot to update core setting to db. |
597 | - if ( ! $setting_changed ) { |
|
597 | + if ( ! $setting_changed) { |
|
598 | 598 | $setting_changed = true; |
599 | 599 | } |
600 | 600 | } |
601 | 601 | |
602 | 602 | // Update setting only if they changed. |
603 | - if ( $setting_changed ) { |
|
604 | - update_option( 'give_settings', $give_settings ); |
|
603 | + if ($setting_changed) { |
|
604 | + update_option('give_settings', $give_settings); |
|
605 | 605 | } |
606 | 606 | } |
607 | 607 | } |
@@ -613,25 +613,25 @@ discard block |
||
613 | 613 | * @return void |
614 | 614 | */ |
615 | 615 | function give_v18_upgrades_form_metadata() { |
616 | - $forms = new WP_Query( array( |
|
616 | + $forms = new WP_Query(array( |
|
617 | 617 | 'post_type' => 'give_forms', |
618 | - 'posts_per_page' => - 1, |
|
618 | + 'posts_per_page' => -1, |
|
619 | 619 | ) |
620 | 620 | ); |
621 | 621 | |
622 | - if ( $forms->have_posts() ) { |
|
623 | - while ( $forms->have_posts() ) { |
|
622 | + if ($forms->have_posts()) { |
|
623 | + while ($forms->have_posts()) { |
|
624 | 624 | $forms->the_post(); |
625 | 625 | |
626 | 626 | // Form content. |
627 | 627 | // Note in version 1.8 display content setting split into display content and content placement setting. |
628 | - $show_content = get_post_meta( get_the_ID(), '_give_content_option', true ); |
|
629 | - if ( $show_content && ! get_post_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
630 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
631 | - update_post_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
628 | + $show_content = get_post_meta(get_the_ID(), '_give_content_option', true); |
|
629 | + if ($show_content && ! get_post_meta(get_the_ID(), '_give_display_content', true)) { |
|
630 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
631 | + update_post_meta(get_the_ID(), '_give_display_content', $field_value); |
|
632 | 632 | |
633 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
634 | - update_post_meta( get_the_ID(), '_give_content_option', $field_value ); |
|
633 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
634 | + update_post_meta(get_the_ID(), '_give_content_option', $field_value); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | |
@@ -660,15 +660,15 @@ discard block |
||
660 | 660 | ); |
661 | 661 | |
662 | 662 | |
663 | - foreach ( $form_radio_settings as $meta_key ) { |
|
663 | + foreach ($form_radio_settings as $meta_key) { |
|
664 | 664 | // Get value. |
665 | - $field_value = get_post_meta( get_the_ID(), $meta_key, true ); |
|
665 | + $field_value = get_post_meta(get_the_ID(), $meta_key, true); |
|
666 | 666 | |
667 | 667 | // Convert meta value only if it is in yes/no/none. |
668 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
668 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
669 | 669 | |
670 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
671 | - update_post_meta( get_the_ID(), $meta_key, $field_value ); |
|
670 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
671 | + update_post_meta(get_the_ID(), $meta_key, $field_value); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | } |
@@ -11,7 +11,7 @@ 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 | |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @since 1.0 |
64 | 64 | */ |
65 | - public function __construct( $shortcode ) { |
|
65 | + public function __construct($shortcode) { |
|
66 | 66 | |
67 | 67 | |
68 | 68 | $this->shortcode_tag = $shortcode; |
69 | 69 | |
70 | - add_action( 'admin_init', array( $this, 'init' ) ); |
|
70 | + add_action('admin_init', array($this, 'init')); |
|
71 | 71 | |
72 | 72 | } |
73 | 73 | |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function init() { |
80 | 80 | |
81 | - if ( $this->shortcode_tag ) { |
|
81 | + if ($this->shortcode_tag) { |
|
82 | 82 | |
83 | - $this->self = get_class( $this ); |
|
83 | + $this->self = get_class($this); |
|
84 | 84 | |
85 | 85 | $this->errors = array(); |
86 | 86 | $this->required = array(); |
@@ -89,18 +89,18 @@ discard block |
||
89 | 89 | $fields = $this->get_fields(); |
90 | 90 | |
91 | 91 | $defaults = array( |
92 | - 'btn_close' => esc_html__( 'Close', 'give' ), |
|
93 | - 'btn_okay' => esc_html__( 'Insert Shortcode', 'give' ), |
|
92 | + 'btn_close' => esc_html__('Close', 'give'), |
|
93 | + 'btn_okay' => esc_html__('Insert Shortcode', 'give'), |
|
94 | 94 | 'errors' => $this->errors, |
95 | 95 | 'fields' => $fields, |
96 | - 'label' => '[' . $this->shortcode_tag . ']', |
|
96 | + 'label' => '['.$this->shortcode_tag.']', |
|
97 | 97 | 'required' => $this->required, |
98 | - 'title' => esc_html__( 'Insert Shortcode', 'give' ), |
|
98 | + 'title' => esc_html__('Insert Shortcode', 'give'), |
|
99 | 99 | ); |
100 | 100 | |
101 | - if ( user_can_richedit() ) { |
|
101 | + if (user_can_richedit()) { |
|
102 | 102 | |
103 | - Give_Shortcode_Button::$shortcodes[ $this->shortcode_tag ] = wp_parse_args( $this->shortcode, $defaults ); |
|
103 | + Give_Shortcode_Button::$shortcodes[$this->shortcode_tag] = wp_parse_args($this->shortcode, $defaults); |
|
104 | 104 | |
105 | 105 | } |
106 | 106 | } |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @since 1.0 |
131 | 131 | */ |
132 | - protected function generate_fields( $defined_fields ) { |
|
132 | + protected function generate_fields($defined_fields) { |
|
133 | 133 | |
134 | 134 | $fields = array(); |
135 | 135 | |
136 | - if ( is_array( $defined_fields ) ) { |
|
136 | + if (is_array($defined_fields)) { |
|
137 | 137 | |
138 | - foreach ( $defined_fields as $field ) { |
|
138 | + foreach ($defined_fields as $field) { |
|
139 | 139 | |
140 | 140 | $defaults = array( |
141 | 141 | 'label' => false, |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | 'type' => '', |
147 | 147 | ); |
148 | 148 | |
149 | - $field = wp_parse_args( (array) $field, $defaults ); |
|
150 | - $method = 'generate_' . strtolower( $field['type'] ); |
|
149 | + $field = wp_parse_args((array) $field, $defaults); |
|
150 | + $method = 'generate_'.strtolower($field['type']); |
|
151 | 151 | |
152 | - if ( method_exists( $this, $method ) ) { |
|
152 | + if (method_exists($this, $method)) { |
|
153 | 153 | |
154 | - $field = call_user_func( array( $this, $method ), $field ); |
|
154 | + $field = call_user_func(array($this, $method), $field); |
|
155 | 155 | |
156 | - if ( $field ) { |
|
156 | + if ($field) { |
|
157 | 157 | $fields[] = $field; |
158 | 158 | } |
159 | 159 | } |
@@ -173,22 +173,22 @@ discard block |
||
173 | 173 | protected function get_fields() { |
174 | 174 | |
175 | 175 | $defined_fields = $this->define_fields(); |
176 | - $generated_fields = $this->generate_fields( $defined_fields ); |
|
176 | + $generated_fields = $this->generate_fields($defined_fields); |
|
177 | 177 | |
178 | 178 | $errors = array(); |
179 | 179 | |
180 | - if ( ! empty( $this->errors ) ) { |
|
181 | - foreach ( $this->required as $name => $alert ) { |
|
182 | - if ( false === array_search( $name, array_column( $generated_fields, 'name' ) ) ) { |
|
180 | + if ( ! empty($this->errors)) { |
|
181 | + foreach ($this->required as $name => $alert) { |
|
182 | + if (false === array_search($name, array_column($generated_fields, 'name'))) { |
|
183 | 183 | |
184 | - $errors[] = $this->errors[ $name ]; |
|
184 | + $errors[] = $this->errors[$name]; |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | 188 | $this->errors = $errors; |
189 | 189 | } |
190 | 190 | |
191 | - if ( ! empty( $errors ) ) { |
|
191 | + if ( ! empty($errors)) { |
|
192 | 192 | |
193 | 193 | return $errors; |
194 | 194 | } |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @since 1.0 |
207 | 207 | */ |
208 | - protected function generate_container( $field ) { |
|
208 | + protected function generate_container($field) { |
|
209 | 209 | |
210 | - if ( array_key_exists( 'html', $field ) ) { |
|
210 | + if (array_key_exists('html', $field)) { |
|
211 | 211 | |
212 | 212 | return array( |
213 | 213 | 'type' => $field['type'], |
@@ -227,36 +227,36 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @since 1.0 |
229 | 229 | */ |
230 | - protected function generate_listbox( $field ) { |
|
230 | + protected function generate_listbox($field) { |
|
231 | 231 | |
232 | - $listbox = shortcode_atts( array( |
|
232 | + $listbox = shortcode_atts(array( |
|
233 | 233 | 'label' => '', |
234 | 234 | 'minWidth' => '', |
235 | 235 | 'name' => false, |
236 | 236 | 'tooltip' => '', |
237 | 237 | 'type' => '', |
238 | 238 | 'value' => '', |
239 | - ), $field ); |
|
239 | + ), $field); |
|
240 | 240 | |
241 | - if ( $this->validate( $field ) ) { |
|
241 | + if ($this->validate($field)) { |
|
242 | 242 | |
243 | 243 | $new_listbox = array(); |
244 | 244 | |
245 | - foreach ( $listbox as $key => $value ) { |
|
245 | + foreach ($listbox as $key => $value) { |
|
246 | 246 | |
247 | - if ( $key == 'value' && empty( $value ) ) { |
|
248 | - $new_listbox[ $key ] = $listbox['name']; |
|
249 | - } else if ( $value ) { |
|
250 | - $new_listbox[ $key ] = $value; |
|
247 | + if ($key == 'value' && empty($value)) { |
|
248 | + $new_listbox[$key] = $listbox['name']; |
|
249 | + } else if ($value) { |
|
250 | + $new_listbox[$key] = $value; |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | 254 | // do not reindex array! |
255 | 255 | $field['options'] = array( |
256 | - '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ), |
|
256 | + '' => ($field['placeholder'] ? $field['placeholder'] : esc_attr__('- Select -', 'give')), |
|
257 | 257 | ) + $field['options']; |
258 | 258 | |
259 | - foreach ( $field['options'] as $value => $text ) { |
|
259 | + foreach ($field['options'] as $value => $text) { |
|
260 | 260 | $new_listbox['values'][] = array( |
261 | 261 | 'text' => $text, |
262 | 262 | 'value' => $value, |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @since 1.0 |
280 | 280 | */ |
281 | - protected function generate_post( $field ) { |
|
281 | + protected function generate_post($field) { |
|
282 | 282 | |
283 | 283 | $args = array( |
284 | 284 | 'post_type' => 'post', |
@@ -287,23 +287,23 @@ discard block |
||
287 | 287 | 'posts_per_page' => 30, |
288 | 288 | ); |
289 | 289 | |
290 | - $args = wp_parse_args( (array) $field['query_args'], $args ); |
|
291 | - $posts = get_posts( $args ); |
|
290 | + $args = wp_parse_args((array) $field['query_args'], $args); |
|
291 | + $posts = get_posts($args); |
|
292 | 292 | $options = array(); |
293 | 293 | |
294 | - if ( $posts ) { |
|
295 | - foreach ( $posts as $post ) { |
|
296 | - $options[ absint( $post->ID ) ] = ( empty( $post->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $post->ID ) : $post->post_title ); |
|
294 | + if ($posts) { |
|
295 | + foreach ($posts as $post) { |
|
296 | + $options[absint($post->ID)] = (empty($post->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $post->ID) : $post->post_title); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | $field['type'] = 'listbox'; |
300 | 300 | $field['options'] = $options; |
301 | 301 | |
302 | - return $this->generate_listbox( $field ); |
|
302 | + return $this->generate_listbox($field); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | // perform validation here before returning false |
306 | - $this->validate( $field ); |
|
306 | + $this->validate($field); |
|
307 | 307 | |
308 | 308 | return false; |
309 | 309 | } |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @since 1.0 |
319 | 319 | */ |
320 | - protected function generate_textbox( $field ) { |
|
320 | + protected function generate_textbox($field) { |
|
321 | 321 | |
322 | - $textbox = shortcode_atts( array( |
|
322 | + $textbox = shortcode_atts(array( |
|
323 | 323 | 'label' => '', |
324 | 324 | 'maxLength' => '', |
325 | 325 | 'minHeight' => '', |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | 'tooltip' => '', |
330 | 330 | 'type' => '', |
331 | 331 | 'value' => '', |
332 | - ), $field ); |
|
332 | + ), $field); |
|
333 | 333 | |
334 | - if ( $this->validate( $field ) ) { |
|
335 | - return array_filter( $textbox, array( $this, 'return_textbox_value' ) ); |
|
334 | + if ($this->validate($field)) { |
|
335 | + return array_filter($textbox, array($this, 'return_textbox_value')); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | return false; |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return bool |
347 | 347 | */ |
348 | - function return_textbox_value( $value ) { |
|
348 | + function return_textbox_value($value) { |
|
349 | 349 | return $value !== ''; |
350 | 350 | } |
351 | 351 | |
@@ -361,9 +361,9 @@ discard block |
||
361 | 361 | * |
362 | 362 | * @since 1.0 |
363 | 363 | */ |
364 | - protected function validate( $field ) { |
|
364 | + protected function validate($field) { |
|
365 | 365 | |
366 | - extract( shortcode_atts( |
|
366 | + extract(shortcode_atts( |
|
367 | 367 | array( |
368 | 368 | 'name' => false, |
369 | 369 | 'required' => false, |
@@ -371,36 +371,36 @@ discard block |
||
371 | 371 | ), $field ) |
372 | 372 | ); |
373 | 373 | |
374 | - if ( $name ) { |
|
374 | + if ($name) { |
|
375 | 375 | |
376 | - if ( isset( $required['error'] ) ) { |
|
376 | + if (isset($required['error'])) { |
|
377 | 377 | |
378 | 378 | $error = array( |
379 | 379 | 'type' => 'container', |
380 | 380 | 'html' => $required['error'], |
381 | 381 | ); |
382 | 382 | |
383 | - $this->errors[ $name ] = $this->generate_container( $error ); |
|
383 | + $this->errors[$name] = $this->generate_container($error); |
|
384 | 384 | } |
385 | 385 | |
386 | - if ( ! ! $required || is_array( $required ) ) { |
|
386 | + if ( ! ! $required || is_array($required)) { |
|
387 | 387 | |
388 | - $alert = esc_html__( 'Some of the shortcode options are required.', 'give' ); |
|
388 | + $alert = esc_html__('Some of the shortcode options are required.', 'give'); |
|
389 | 389 | |
390 | - if ( isset( $required['alert'] ) ) { |
|
390 | + if (isset($required['alert'])) { |
|
391 | 391 | |
392 | 392 | $alert = $required['alert']; |
393 | 393 | |
394 | - } else if ( ! empty( $label ) ) { |
|
394 | + } else if ( ! empty($label)) { |
|
395 | 395 | |
396 | 396 | $alert = sprintf( |
397 | 397 | /* translators: %s: option label */ |
398 | - esc_html__( 'The "%s" option is required.', 'give' ), |
|
399 | - str_replace( ':', '', $label ) |
|
398 | + esc_html__('The "%s" option is required.', 'give'), |
|
399 | + str_replace(':', '', $label) |
|
400 | 400 | ); |
401 | 401 | } |
402 | 402 | |
403 | - $this->required[ $name ] = $alert; |
|
403 | + $this->required[$name] = $alert; |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | return true; |
@@ -119,7 +119,7 @@ |
||
119 | 119 | * @param $field_args |
120 | 120 | * @param $field |
121 | 121 | * |
122 | - * @return bool |
|
122 | + * @return false|null |
|
123 | 123 | */ |
124 | 124 | function give_format_admin_multilevel_amount( $field_args, $field ) { |
125 | 125 |
@@ -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 | |
@@ -24,53 +24,53 @@ discard block |
||
24 | 24 | function give_hide_subscription_notices() { |
25 | 25 | |
26 | 26 | // Hide subscription notices permanently. |
27 | - if ( ! empty( $_GET['_give_hide_license_notices_permanently'] ) ) { |
|
27 | + if ( ! empty($_GET['_give_hide_license_notices_permanently'])) { |
|
28 | 28 | $current_user = wp_get_current_user(); |
29 | 29 | |
30 | 30 | // check previously disabled notice ids. |
31 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
31 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
32 | 32 | ? $already_dismiss_notices |
33 | 33 | : array(); |
34 | 34 | |
35 | 35 | // Get notice id. |
36 | - $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_permanently'] ); |
|
36 | + $notice_id = sanitize_text_field($_GET['_give_hide_license_notices_permanently']); |
|
37 | 37 | |
38 | - if ( ! in_array( $notice_id, $already_dismiss_notices ) ) { |
|
38 | + if ( ! in_array($notice_id, $already_dismiss_notices)) { |
|
39 | 39 | $already_dismiss_notices[] = $notice_id; |
40 | 40 | } |
41 | 41 | |
42 | 42 | // Store subscription ids. |
43 | - update_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices ); |
|
43 | + update_user_meta($current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices); |
|
44 | 44 | |
45 | 45 | // Redirect user. |
46 | - wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI'] ) ); |
|
46 | + wp_safe_redirect(remove_query_arg('_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI'])); |
|
47 | 47 | exit(); |
48 | 48 | } |
49 | 49 | |
50 | 50 | // Hide subscription notices shortly. |
51 | - if ( ! empty( $_GET['_give_hide_license_notices_shortly'] ) ) { |
|
51 | + if ( ! empty($_GET['_give_hide_license_notices_shortly'])) { |
|
52 | 52 | $current_user = wp_get_current_user(); |
53 | 53 | |
54 | 54 | // Get notice id. |
55 | - $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_shortly'] ); |
|
55 | + $notice_id = sanitize_text_field($_GET['_give_hide_license_notices_shortly']); |
|
56 | 56 | |
57 | 57 | // Transient key name. |
58 | 58 | $transient_key = "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}"; |
59 | 59 | |
60 | - if ( get_transient( $transient_key ) ) { |
|
60 | + if (get_transient($transient_key)) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | 64 | // Hide notice for 24 hours. |
65 | - set_transient( $transient_key, true, 24 * HOUR_IN_SECONDS ); |
|
65 | + set_transient($transient_key, true, 24 * HOUR_IN_SECONDS); |
|
66 | 66 | |
67 | 67 | // Redirect user. |
68 | - wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI'] ) ); |
|
68 | + wp_safe_redirect(remove_query_arg('_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI'])); |
|
69 | 69 | exit(); |
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | -add_action( 'admin_init', 'give_hide_subscription_notices' ); |
|
73 | +add_action('admin_init', 'give_hide_subscription_notices'); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Load wp editor by ajax. |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | * @since 1.8 |
79 | 79 | */ |
80 | 80 | function give_load_wp_editor() { |
81 | - if ( ! isset( $_POST['wp_editor'] ) ) { |
|
81 | + if ( ! isset($_POST['wp_editor'])) { |
|
82 | 82 | die(); |
83 | 83 | } |
84 | 84 | |
85 | - $wp_editor = json_decode( base64_decode( $_POST['wp_editor'] ), true ); |
|
85 | + $wp_editor = json_decode(base64_decode($_POST['wp_editor']), true); |
|
86 | 86 | $wp_editor[2]['textarea_name'] = $_POST['textarea_name']; |
87 | 87 | |
88 | - wp_editor( $wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2] ); |
|
88 | + wp_editor($wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2]); |
|
89 | 89 | |
90 | 90 | die(); |
91 | 91 | } |
92 | 92 | |
93 | -add_action( 'wp_ajax_give_load_wp_editor', 'give_load_wp_editor' ); |
|
93 | +add_action('wp_ajax_give_load_wp_editor', 'give_load_wp_editor'); |
|
94 | 94 | |
95 | 95 | |
96 | 96 | /** |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | ); |
110 | 110 | |
111 | 111 | // Get current page. |
112 | - $current_page = isset( $_GET['page'] ) ? esc_attr( $_GET['page'] ) : ''; |
|
112 | + $current_page = isset($_GET['page']) ? esc_attr($_GET['page']) : ''; |
|
113 | 113 | |
114 | 114 | // Bailout. |
115 | 115 | if ( |
116 | - empty( $current_page ) |
|
117 | - || empty( $_GET['_wp_http_referer'] ) |
|
118 | - || ! in_array( $current_page, $give_pages ) |
|
116 | + empty($current_page) |
|
117 | + || empty($_GET['_wp_http_referer']) |
|
118 | + || ! in_array($current_page, $give_pages) |
|
119 | 119 | ) { |
120 | 120 | return false; |
121 | 121 | } |
@@ -125,18 +125,18 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @since 1.8 |
127 | 127 | */ |
128 | - $redirect = apply_filters( "give_validate_{$current_page}", true ); |
|
128 | + $redirect = apply_filters("give_validate_{$current_page}", true); |
|
129 | 129 | |
130 | - if ( $redirect ) { |
|
130 | + if ($redirect) { |
|
131 | 131 | // Redirect. |
132 | 132 | wp_redirect( |
133 | 133 | remove_query_arg( |
134 | - array( '_wp_http_referer', '_wpnonce' ), |
|
135 | - wp_unslash( $_SERVER['REQUEST_URI'] ) |
|
134 | + array('_wp_http_referer', '_wpnonce'), |
|
135 | + wp_unslash($_SERVER['REQUEST_URI']) |
|
136 | 136 | ) |
137 | 137 | ); |
138 | 138 | exit; |
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | -add_action( 'admin_init', 'give_redirect_to_clean_url_admin_pages' ); |
|
142 | +add_action('admin_init', 'give_redirect_to_clean_url_admin_pages'); |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * and redirect back to the donor interface for feedback |
528 | 528 | * |
529 | 529 | * @since 1.7 |
530 | - * @return bool|null |
|
530 | + * @return false|null |
|
531 | 531 | */ |
532 | 532 | function give_remove_donor_email() { |
533 | 533 | if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * and redirect back to the donor interface for feedback |
569 | 569 | * |
570 | 570 | * @since 1.7 |
571 | - * @return bool|null |
|
571 | + * @return false|null |
|
572 | 572 | */ |
573 | 573 | function give_set_donor_primary_email() { |
574 | 574 | if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array $output Response messages |
25 | 25 | */ |
26 | -function give_edit_customer( $args ) { |
|
26 | +function give_edit_customer($args) { |
|
27 | 27 | |
28 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
28 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
29 | 29 | |
30 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
31 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
31 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( empty( $args ) ) { |
|
34 | + if (empty($args)) { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | $customer_id = (int) $args['customerinfo']['id']; |
40 | 40 | $nonce = $args['_wpnonce']; |
41 | 41 | |
42 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
43 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
42 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
43 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
44 | 44 | } |
45 | 45 | |
46 | - $customer = new Give_Customer( $customer_id ); |
|
47 | - if ( empty( $customer->id ) ) { |
|
46 | + $customer = new Give_Customer($customer_id); |
|
47 | + if (empty($customer->id)) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
@@ -53,70 +53,70 @@ discard block |
||
53 | 53 | 'user_id' => 0, |
54 | 54 | ); |
55 | 55 | |
56 | - $customer_info = wp_parse_args( $customer_info, $defaults ); |
|
56 | + $customer_info = wp_parse_args($customer_info, $defaults); |
|
57 | 57 | |
58 | - if ( (int) $customer_info['user_id'] != (int) $customer->user_id ) { |
|
58 | + if ((int) $customer_info['user_id'] != (int) $customer->user_id) { |
|
59 | 59 | |
60 | 60 | // Make sure we don't already have this user attached to a customer |
61 | - if ( ! empty( $customer_info['user_id'] ) && false !== Give()->customers->get_customer_by( 'user_id', $customer_info['user_id'] ) ) { |
|
62 | - give_set_error( 'give-invalid-customer-user_id', sprintf( esc_html__( 'The User ID %d is already associated with a different donor.', 'give' ), $customer_info['user_id'] ) ); |
|
61 | + if ( ! empty($customer_info['user_id']) && false !== Give()->customers->get_customer_by('user_id', $customer_info['user_id'])) { |
|
62 | + give_set_error('give-invalid-customer-user_id', sprintf(esc_html__('The User ID %d is already associated with a different donor.', 'give'), $customer_info['user_id'])); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Make sure it's actually a user |
66 | - $user = get_user_by( 'id', $customer_info['user_id'] ); |
|
67 | - if ( ! empty( $customer_info['user_id'] ) && false === $user ) { |
|
68 | - give_set_error( 'give-invalid-user_id', sprintf( esc_html__( 'The User ID %d does not exist. Please assign an existing user.', 'give' ), $customer_info['user_id'] ) ); |
|
66 | + $user = get_user_by('id', $customer_info['user_id']); |
|
67 | + if ( ! empty($customer_info['user_id']) && false === $user) { |
|
68 | + give_set_error('give-invalid-user_id', sprintf(esc_html__('The User ID %d does not exist. Please assign an existing user.', 'give'), $customer_info['user_id'])); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | 72 | // Record this for later |
73 | 73 | $previous_user_id = $customer->user_id; |
74 | 74 | |
75 | - if ( give_get_errors() ) { |
|
75 | + if (give_get_errors()) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | 79 | // Setup the customer address, if present |
80 | 80 | $address = array(); |
81 | - if ( intval( $customer_info['user_id'] ) > 0 ) { |
|
81 | + if (intval($customer_info['user_id']) > 0) { |
|
82 | 82 | |
83 | - $current_address = get_user_meta( $customer_info['user_id'], '_give_user_address', true ); |
|
83 | + $current_address = get_user_meta($customer_info['user_id'], '_give_user_address', true); |
|
84 | 84 | |
85 | - if ( false === $current_address ) { |
|
86 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : ''; |
|
87 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : ''; |
|
88 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : ''; |
|
89 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : ''; |
|
90 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : ''; |
|
91 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : ''; |
|
85 | + if (false === $current_address) { |
|
86 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : ''; |
|
87 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : ''; |
|
88 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : ''; |
|
89 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : ''; |
|
90 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : ''; |
|
91 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : ''; |
|
92 | 92 | } else { |
93 | - $current_address = wp_parse_args( $current_address, array( |
|
93 | + $current_address = wp_parse_args($current_address, array( |
|
94 | 94 | 'line1', |
95 | 95 | 'line2', |
96 | 96 | 'city', |
97 | 97 | 'zip', |
98 | 98 | 'state', |
99 | 99 | 'country', |
100 | - ) ); |
|
101 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : $current_address['line1']; |
|
102 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : $current_address['line2']; |
|
103 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : $current_address['city']; |
|
104 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : $current_address['country']; |
|
105 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : $current_address['zip']; |
|
106 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : $current_address['state']; |
|
100 | + )); |
|
101 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : $current_address['line1']; |
|
102 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : $current_address['line2']; |
|
103 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : $current_address['city']; |
|
104 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : $current_address['country']; |
|
105 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : $current_address['zip']; |
|
106 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : $current_address['state']; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | 110 | // Sanitize the inputs |
111 | 111 | $customer_data = array(); |
112 | - $customer_data['name'] = strip_tags( stripslashes( $customer_info['name'] ) ); |
|
112 | + $customer_data['name'] = strip_tags(stripslashes($customer_info['name'])); |
|
113 | 113 | $customer_data['user_id'] = $customer_info['user_id']; |
114 | 114 | |
115 | - $customer_data = apply_filters( 'give_edit_customer_info', $customer_data, $customer_id ); |
|
116 | - $address = apply_filters( 'give_edit_customer_address', $address, $customer_id ); |
|
115 | + $customer_data = apply_filters('give_edit_customer_info', $customer_data, $customer_id); |
|
116 | + $address = apply_filters('give_edit_customer_address', $address, $customer_id); |
|
117 | 117 | |
118 | - $customer_data = array_map( 'sanitize_text_field', $customer_data ); |
|
119 | - $address = array_map( 'sanitize_text_field', $address ); |
|
118 | + $customer_data = array_map('sanitize_text_field', $customer_data); |
|
119 | + $address = array_map('sanitize_text_field', $address); |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * Fires before editing customer. |
@@ -127,27 +127,27 @@ discard block |
||
127 | 127 | * @param array $customer_data The customer data. |
128 | 128 | * @param array $address The customer address. |
129 | 129 | */ |
130 | - do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address ); |
|
130 | + do_action('give_pre_edit_customer', $customer_id, $customer_data, $address); |
|
131 | 131 | |
132 | 132 | $output = array(); |
133 | 133 | |
134 | - if ( $customer->update( $customer_data ) ) { |
|
134 | + if ($customer->update($customer_data)) { |
|
135 | 135 | |
136 | - if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) { |
|
137 | - update_user_meta( $customer->user_id, '_give_user_address', $address ); |
|
136 | + if ( ! empty($customer->user_id) && $customer->user_id > 0) { |
|
137 | + update_user_meta($customer->user_id, '_give_user_address', $address); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | // Update some donation meta if we need to |
141 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
141 | + $payments_array = explode(',', $customer->payment_ids); |
|
142 | 142 | |
143 | - if ( $customer->user_id != $previous_user_id ) { |
|
144 | - foreach ( $payments_array as $payment_id ) { |
|
145 | - give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id ); |
|
143 | + if ($customer->user_id != $previous_user_id) { |
|
144 | + foreach ($payments_array as $payment_id) { |
|
145 | + give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | 149 | $output['success'] = true; |
150 | - $customer_data = array_merge( $customer_data, $address ); |
|
150 | + $customer_data = array_merge($customer_data, $address); |
|
151 | 151 | $output['customer_info'] = $customer_data; |
152 | 152 | |
153 | 153 | } else { |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | * @param int $customer_id The ID of the customer. |
165 | 165 | * @param array $customer_data The customer data. |
166 | 166 | */ |
167 | - do_action( 'give_post_edit_customer', $customer_id, $customer_data ); |
|
167 | + do_action('give_post_edit_customer', $customer_id, $customer_data); |
|
168 | 168 | |
169 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
170 | - header( 'Content-Type: application/json' ); |
|
171 | - echo json_encode( $output ); |
|
169 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
170 | + header('Content-Type: application/json'); |
|
171 | + echo json_encode($output); |
|
172 | 172 | wp_die(); |
173 | 173 | } |
174 | 174 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | } |
178 | 178 | |
179 | -add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 ); |
|
179 | +add_action('give_edit-customer', 'give_edit_customer', 10, 1); |
|
180 | 180 | |
181 | 181 | /** |
182 | 182 | * Save a customer note being added |
@@ -187,36 +187,36 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return int The Note ID that was saved, or 0 if nothing was saved |
189 | 189 | */ |
190 | -function give_customer_save_note( $args ) { |
|
190 | +function give_customer_save_note($args) { |
|
191 | 191 | |
192 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
192 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
193 | 193 | |
194 | - if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) { |
|
195 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
194 | + if ( ! is_admin() || ! current_user_can($customer_view_role)) { |
|
195 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
196 | 196 | } |
197 | 197 | |
198 | - if ( empty( $args ) ) { |
|
198 | + if (empty($args)) { |
|
199 | 199 | return; |
200 | 200 | } |
201 | 201 | |
202 | - $customer_note = trim( sanitize_text_field( $args['customer_note'] ) ); |
|
202 | + $customer_note = trim(sanitize_text_field($args['customer_note'])); |
|
203 | 203 | $customer_id = (int) $args['customer_id']; |
204 | 204 | $nonce = $args['add_customer_note_nonce']; |
205 | 205 | |
206 | - if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) { |
|
207 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
206 | + if ( ! wp_verify_nonce($nonce, 'add-customer-note')) { |
|
207 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
208 | 208 | } |
209 | 209 | |
210 | - if ( empty( $customer_note ) ) { |
|
211 | - give_set_error( 'empty-customer-note', esc_html__( 'A note is required.', 'give' ) ); |
|
210 | + if (empty($customer_note)) { |
|
211 | + give_set_error('empty-customer-note', esc_html__('A note is required.', 'give')); |
|
212 | 212 | } |
213 | 213 | |
214 | - if ( give_get_errors() ) { |
|
214 | + if (give_get_errors()) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
218 | - $customer = new Give_Customer( $customer_id ); |
|
219 | - $new_note = $customer->add_note( $customer_note ); |
|
218 | + $customer = new Give_Customer($customer_id); |
|
219 | + $new_note = $customer->add_note($customer_note); |
|
220 | 220 | |
221 | 221 | /** |
222 | 222 | * Fires before inserting customer note. |
@@ -226,22 +226,22 @@ discard block |
||
226 | 226 | * @param int $customer_id The ID of the customer. |
227 | 227 | * @param string $new_note Note content. |
228 | 228 | */ |
229 | - do_action( 'give_pre_insert_customer_note', $customer_id, $new_note ); |
|
229 | + do_action('give_pre_insert_customer_note', $customer_id, $new_note); |
|
230 | 230 | |
231 | - if ( ! empty( $new_note ) && ! empty( $customer->id ) ) { |
|
231 | + if ( ! empty($new_note) && ! empty($customer->id)) { |
|
232 | 232 | |
233 | 233 | ob_start(); |
234 | 234 | ?> |
235 | 235 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
236 | 236 | <span class="note-content-wrap"> |
237 | - <?php echo stripslashes( $new_note ); ?> |
|
237 | + <?php echo stripslashes($new_note); ?> |
|
238 | 238 | </span> |
239 | 239 | </div> |
240 | 240 | <?php |
241 | 241 | $output = ob_get_contents(); |
242 | 242 | ob_end_clean(); |
243 | 243 | |
244 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
244 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
245 | 245 | echo $output; |
246 | 246 | exit; |
247 | 247 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | |
255 | 255 | } |
256 | 256 | |
257 | -add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 ); |
|
257 | +add_action('give_add-customer-note', 'give_customer_save_note', 10, 1); |
|
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Delete a customer |
@@ -265,37 +265,37 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return int Whether it was a successful deletion |
267 | 267 | */ |
268 | -function give_customer_delete( $args ) { |
|
268 | +function give_customer_delete($args) { |
|
269 | 269 | |
270 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
270 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
271 | 271 | |
272 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
273 | - wp_die( esc_html__( 'You do not have permission to delete donors.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
272 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
273 | + wp_die(esc_html__('You do not have permission to delete donors.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
274 | 274 | } |
275 | 275 | |
276 | - if ( empty( $args ) ) { |
|
276 | + if (empty($args)) { |
|
277 | 277 | return; |
278 | 278 | } |
279 | 279 | |
280 | 280 | $customer_id = (int) $args['customer_id']; |
281 | - $confirm = ! empty( $args['give-customer-delete-confirm'] ) ? true : false; |
|
282 | - $remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false; |
|
281 | + $confirm = ! empty($args['give-customer-delete-confirm']) ? true : false; |
|
282 | + $remove_data = ! empty($args['give-customer-delete-records']) ? true : false; |
|
283 | 283 | $nonce = $args['_wpnonce']; |
284 | 284 | |
285 | - if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) { |
|
286 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
285 | + if ( ! wp_verify_nonce($nonce, 'delete-customer')) { |
|
286 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
287 | 287 | } |
288 | 288 | |
289 | - if ( ! $confirm ) { |
|
290 | - give_set_error( 'customer-delete-no-confirm', esc_html__( 'Please confirm you want to delete this donor.', 'give' ) ); |
|
289 | + if ( ! $confirm) { |
|
290 | + give_set_error('customer-delete-no-confirm', esc_html__('Please confirm you want to delete this donor.', 'give')); |
|
291 | 291 | } |
292 | 292 | |
293 | - if ( give_get_errors() ) { |
|
294 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) ); |
|
293 | + if (give_get_errors()) { |
|
294 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id)); |
|
295 | 295 | exit; |
296 | 296 | } |
297 | 297 | |
298 | - $customer = new Give_Customer( $customer_id ); |
|
298 | + $customer = new Give_Customer($customer_id); |
|
299 | 299 | |
300 | 300 | /** |
301 | 301 | * Fires before deleting customer. |
@@ -306,50 +306,50 @@ discard block |
||
306 | 306 | * @param bool $confirm Delete confirmation. |
307 | 307 | * @param bool $remove_data Records delete confirmation. |
308 | 308 | */ |
309 | - do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data ); |
|
309 | + do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data); |
|
310 | 310 | |
311 | - if ( $customer->id > 0 ) { |
|
311 | + if ($customer->id > 0) { |
|
312 | 312 | |
313 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
314 | - $success = Give()->customers->delete( $customer->id ); |
|
313 | + $payments_array = explode(',', $customer->payment_ids); |
|
314 | + $success = Give()->customers->delete($customer->id); |
|
315 | 315 | |
316 | - if ( $success ) { |
|
316 | + if ($success) { |
|
317 | 317 | |
318 | - if ( $remove_data ) { |
|
318 | + if ($remove_data) { |
|
319 | 319 | |
320 | 320 | // Remove all donations, logs, etc |
321 | - foreach ( $payments_array as $payment_id ) { |
|
322 | - give_delete_purchase( $payment_id ); |
|
321 | + foreach ($payments_array as $payment_id) { |
|
322 | + give_delete_purchase($payment_id); |
|
323 | 323 | } |
324 | 324 | } else { |
325 | 325 | |
326 | 326 | // Just set the donations to customer_id of 0 |
327 | - foreach ( $payments_array as $payment_id ) { |
|
328 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
327 | + foreach ($payments_array as $payment_id) { |
|
328 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' ); |
|
332 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted'); |
|
333 | 333 | |
334 | 334 | } else { |
335 | 335 | |
336 | - give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) ); |
|
337 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id ); |
|
336 | + give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give')); |
|
337 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id); |
|
338 | 338 | |
339 | 339 | } |
340 | 340 | } else { |
341 | 341 | |
342 | - give_set_error( 'give-customer-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
343 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
342 | + give_set_error('give-customer-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give')); |
|
343 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
344 | 344 | |
345 | 345 | } |
346 | 346 | |
347 | - wp_redirect( $redirect ); |
|
347 | + wp_redirect($redirect); |
|
348 | 348 | exit; |
349 | 349 | |
350 | 350 | } |
351 | 351 | |
352 | -add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 ); |
|
352 | +add_action('give_delete-customer', 'give_customer_delete', 10, 1); |
|
353 | 353 | |
354 | 354 | /** |
355 | 355 | * Disconnect a user ID from a donor |
@@ -360,27 +360,27 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @return bool If the disconnect was successful |
362 | 362 | */ |
363 | -function give_disconnect_customer_user_id( $args ) { |
|
363 | +function give_disconnect_customer_user_id($args) { |
|
364 | 364 | |
365 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
365 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
366 | 366 | |
367 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
368 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
367 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
368 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
369 | 369 | } |
370 | 370 | |
371 | - if ( empty( $args ) ) { |
|
371 | + if (empty($args)) { |
|
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | 375 | $customer_id = (int) $args['customer_id']; |
376 | 376 | $nonce = $args['_wpnonce']; |
377 | 377 | |
378 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
379 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
378 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
379 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
380 | 380 | } |
381 | 381 | |
382 | - $customer = new Give_Customer( $customer_id ); |
|
383 | - if ( empty( $customer->id ) ) { |
|
382 | + $customer = new Give_Customer($customer_id); |
|
383 | + if (empty($customer->id)) { |
|
384 | 384 | return false; |
385 | 385 | } |
386 | 386 | |
@@ -394,16 +394,16 @@ discard block |
||
394 | 394 | * @param int $customer_id The ID of the customer. |
395 | 395 | * @param int $user_id The ID of the user. |
396 | 396 | */ |
397 | - do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $user_id ); |
|
397 | + do_action('give_pre_customer_disconnect_user_id', $customer_id, $user_id); |
|
398 | 398 | |
399 | 399 | $output = array(); |
400 | - $customer_args = array( 'user_id' => 0 ); |
|
400 | + $customer_args = array('user_id' => 0); |
|
401 | 401 | |
402 | - if ( $customer->update( $customer_args ) ) { |
|
402 | + if ($customer->update($customer_args)) { |
|
403 | 403 | global $wpdb; |
404 | 404 | |
405 | - if ( ! empty( $customer->payment_ids ) ) { |
|
406 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" ); |
|
405 | + if ( ! empty($customer->payment_ids)) { |
|
406 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )"); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | $output['success'] = true; |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | } else { |
412 | 412 | |
413 | 413 | $output['success'] = false; |
414 | - give_set_error( 'give-disconnect-user-fail', esc_html__( 'Failed to disconnect user from donor.', 'give' ) ); |
|
414 | + give_set_error('give-disconnect-user-fail', esc_html__('Failed to disconnect user from donor.', 'give')); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -421,11 +421,11 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @param int $customer_id The ID of the customer. |
423 | 423 | */ |
424 | - do_action( 'give_post_customer_disconnect_user_id', $customer_id ); |
|
424 | + do_action('give_post_customer_disconnect_user_id', $customer_id); |
|
425 | 425 | |
426 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
427 | - header( 'Content-Type: application/json' ); |
|
428 | - echo json_encode( $output ); |
|
426 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
427 | + header('Content-Type: application/json'); |
|
428 | + echo json_encode($output); |
|
429 | 429 | wp_die(); |
430 | 430 | } |
431 | 431 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | |
434 | 434 | } |
435 | 435 | |
436 | -add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 ); |
|
436 | +add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1); |
|
437 | 437 | |
438 | 438 | /** |
439 | 439 | * Add an email address to the donor from within the admin and log a donor note |
@@ -444,82 +444,82 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string) |
446 | 446 | */ |
447 | -function give_add_donor_email( $args ) { |
|
448 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
447 | +function give_add_donor_email($args) { |
|
448 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
449 | 449 | |
450 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
451 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'edit' ) ); |
|
450 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
451 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'edit')); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | $output = array(); |
455 | - if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) { |
|
455 | + if (empty($args) || empty($args['email']) || empty($args['customer_id'])) { |
|
456 | 456 | $output['success'] = false; |
457 | - if ( empty( $args['email'] ) ) { |
|
458 | - $output['message'] = esc_html__( 'Email address is required.', 'give' ); |
|
459 | - } elseif ( empty( $args['customer_id'] ) ) { |
|
460 | - $output['message'] = esc_html__( 'Customer ID is required.', 'give' ); |
|
457 | + if (empty($args['email'])) { |
|
458 | + $output['message'] = esc_html__('Email address is required.', 'give'); |
|
459 | + } elseif (empty($args['customer_id'])) { |
|
460 | + $output['message'] = esc_html__('Customer ID is required.', 'give'); |
|
461 | 461 | } else { |
462 | - $output['message'] = esc_html__( 'An error has occurred. Please try again.', 'give' ); |
|
462 | + $output['message'] = esc_html__('An error has occurred. Please try again.', 'give'); |
|
463 | 463 | } |
464 | - } elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) { |
|
464 | + } elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) { |
|
465 | 465 | $output = array( |
466 | 466 | 'success' => false, |
467 | - 'message' => esc_html__( 'Nonce verification failed.', 'give' ), |
|
467 | + 'message' => esc_html__('Nonce verification failed.', 'give'), |
|
468 | 468 | ); |
469 | - } elseif ( ! is_email( $args['email'] ) ) { |
|
469 | + } elseif ( ! is_email($args['email'])) { |
|
470 | 470 | $output = array( |
471 | 471 | 'success' => false, |
472 | - 'message' => esc_html__( 'Invalid email.', 'give' ), |
|
472 | + 'message' => esc_html__('Invalid email.', 'give'), |
|
473 | 473 | ); |
474 | 474 | } else { |
475 | - $email = sanitize_email( $args['email'] ); |
|
475 | + $email = sanitize_email($args['email']); |
|
476 | 476 | $customer_id = (int) $args['customer_id']; |
477 | 477 | $primary = 'true' === $args['primary'] ? true : false; |
478 | - $customer = new Give_Customer( $customer_id ); |
|
479 | - if ( false === $customer->add_email( $email, $primary ) ) { |
|
480 | - if ( in_array( $email, $customer->emails ) ) { |
|
478 | + $customer = new Give_Customer($customer_id); |
|
479 | + if (false === $customer->add_email($email, $primary)) { |
|
480 | + if (in_array($email, $customer->emails)) { |
|
481 | 481 | $output = array( |
482 | 482 | 'success' => false, |
483 | - 'message' => esc_html__( 'Email already associated with this donor.', 'give' ), |
|
483 | + 'message' => esc_html__('Email already associated with this donor.', 'give'), |
|
484 | 484 | ); |
485 | 485 | } else { |
486 | 486 | $output = array( |
487 | 487 | 'success' => false, |
488 | - 'message' => esc_html__( 'Email address is already associated with another donor.', 'give' ), |
|
488 | + 'message' => esc_html__('Email address is already associated with another donor.', 'give'), |
|
489 | 489 | ); |
490 | 490 | } |
491 | 491 | } else { |
492 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id . '&give-message=email-added' ); |
|
492 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id.'&give-message=email-added'); |
|
493 | 493 | $output = array( |
494 | 494 | 'success' => true, |
495 | - 'message' => esc_html__( 'Email successfully added to donor.', 'give' ), |
|
495 | + 'message' => esc_html__('Email successfully added to donor.', 'give'), |
|
496 | 496 | 'redirect' => $redirect, |
497 | 497 | ); |
498 | 498 | |
499 | 499 | $user = wp_get_current_user(); |
500 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' ); |
|
501 | - $customer_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login ); |
|
502 | - $customer->add_note( $customer_note ); |
|
500 | + $user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give'); |
|
501 | + $customer_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login); |
|
502 | + $customer->add_note($customer_note); |
|
503 | 503 | |
504 | - if ( $primary ) { |
|
505 | - $customer_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login ); |
|
506 | - $customer->add_note( $customer_note ); |
|
504 | + if ($primary) { |
|
505 | + $customer_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login); |
|
506 | + $customer->add_note($customer_note); |
|
507 | 507 | } |
508 | 508 | } |
509 | 509 | } |
510 | 510 | |
511 | - do_action( 'give_post_add_customer_email', $customer_id, $args ); |
|
511 | + do_action('give_post_add_customer_email', $customer_id, $args); |
|
512 | 512 | |
513 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
514 | - header( 'Content-Type: application/json' ); |
|
515 | - echo json_encode( $output ); |
|
513 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
514 | + header('Content-Type: application/json'); |
|
515 | + echo json_encode($output); |
|
516 | 516 | wp_die(); |
517 | 517 | } |
518 | 518 | |
519 | 519 | return $output; |
520 | 520 | } |
521 | 521 | |
522 | -add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 ); |
|
522 | +add_action('give_add_donor_email', 'give_add_donor_email', 10, 1); |
|
523 | 523 | |
524 | 524 | |
525 | 525 | /** |
@@ -530,37 +530,37 @@ discard block |
||
530 | 530 | * @return bool|null |
531 | 531 | */ |
532 | 532 | function give_remove_donor_email() { |
533 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
533 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
534 | 534 | return false; |
535 | 535 | } |
536 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
536 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
537 | 537 | return false; |
538 | 538 | } |
539 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
539 | + if (empty($_GET['_wpnonce'])) { |
|
540 | 540 | return false; |
541 | 541 | } |
542 | 542 | |
543 | 543 | $nonce = $_GET['_wpnonce']; |
544 | - if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) { |
|
545 | - wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
544 | + if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) { |
|
545 | + wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
546 | 546 | } |
547 | 547 | |
548 | - $customer = new Give_Customer( $_GET['id'] ); |
|
549 | - if ( $customer->remove_email( $_GET['email'] ) ) { |
|
550 | - $url = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ) ); |
|
548 | + $customer = new Give_Customer($_GET['id']); |
|
549 | + if ($customer->remove_email($_GET['email'])) { |
|
550 | + $url = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id)); |
|
551 | 551 | $user = wp_get_current_user(); |
552 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' ); |
|
553 | - $customer_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
554 | - $customer->add_note( $customer_note ); |
|
552 | + $user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give'); |
|
553 | + $customer_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login); |
|
554 | + $customer->add_note($customer_note); |
|
555 | 555 | } else { |
556 | - $url = add_query_arg( 'give-message', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ) ); |
|
556 | + $url = add_query_arg('give-message', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id)); |
|
557 | 557 | } |
558 | 558 | |
559 | - wp_safe_redirect( $url ); |
|
559 | + wp_safe_redirect($url); |
|
560 | 560 | exit; |
561 | 561 | } |
562 | 562 | |
563 | -add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 ); |
|
563 | +add_action('give_remove_donor_email', 'give_remove_donor_email', 10); |
|
564 | 564 | |
565 | 565 | |
566 | 566 | /** |
@@ -571,39 +571,39 @@ discard block |
||
571 | 571 | * @return bool|null |
572 | 572 | */ |
573 | 573 | function give_set_donor_primary_email() { |
574 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
574 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
575 | 575 | return false; |
576 | 576 | } |
577 | 577 | |
578 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
578 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
579 | 579 | return false; |
580 | 580 | } |
581 | 581 | |
582 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
582 | + if (empty($_GET['_wpnonce'])) { |
|
583 | 583 | return false; |
584 | 584 | } |
585 | 585 | |
586 | 586 | $nonce = $_GET['_wpnonce']; |
587 | 587 | |
588 | - if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) { |
|
589 | - wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
588 | + if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) { |
|
589 | + wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
590 | 590 | } |
591 | 591 | |
592 | - $donor = new Give_Customer( $_GET['id'] ); |
|
592 | + $donor = new Give_Customer($_GET['id']); |
|
593 | 593 | |
594 | - if ( $donor->set_primary_email( $_GET['email'] ) ) { |
|
595 | - $url = add_query_arg( 'give-message', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
594 | + if ($donor->set_primary_email($_GET['email'])) { |
|
595 | + $url = add_query_arg('give-message', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
596 | 596 | $user = wp_get_current_user(); |
597 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' ); |
|
598 | - $donor_note = sprintf( __( 'Email address %1$s set as primary by %1$s', 'give' ), $_GET['email'], $user_login ); |
|
597 | + $user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give'); |
|
598 | + $donor_note = sprintf(__('Email address %1$s set as primary by %1$s', 'give'), $_GET['email'], $user_login); |
|
599 | 599 | |
600 | - $donor->add_note( $donor_note ); |
|
600 | + $donor->add_note($donor_note); |
|
601 | 601 | } else { |
602 | - $url = add_query_arg( 'give-message', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
602 | + $url = add_query_arg('give-message', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
603 | 603 | } |
604 | 604 | |
605 | - wp_safe_redirect( $url ); |
|
605 | + wp_safe_redirect($url); |
|
606 | 606 | exit; |
607 | 607 | } |
608 | 608 | |
609 | -add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 ); |
|
609 | +add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10); |
@@ -157,7 +157,7 @@ |
||
157 | 157 | * |
158 | 158 | * @access public |
159 | 159 | * @since 1.0 |
160 | - * @return string|bool String if search is present, false otherwise |
|
160 | + * @return string|false String if search is present, false otherwise |
|
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | 163 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -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 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | global $status, $page; |
46 | 46 | |
47 | 47 | // Set parent defaults |
48 | - parent::__construct( array( |
|
49 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | - 'ajax' => false,// Does this table support ajax? |
|
52 | - ) ); |
|
48 | + parent::__construct(array( |
|
49 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | + 'ajax' => false, // Does this table support ajax? |
|
52 | + )); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return void |
65 | 65 | */ |
66 | - public function search_box( $text, $input_id ) { |
|
67 | - $input_id = $input_id . '-search-input'; |
|
66 | + public function search_box($text, $input_id) { |
|
67 | + $input_id = $input_id.'-search-input'; |
|
68 | 68 | |
69 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
70 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
69 | + if ( ! empty($_REQUEST['orderby'])) { |
|
70 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
71 | 71 | } |
72 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
73 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
72 | + if ( ! empty($_REQUEST['order'])) { |
|
73 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
74 | 74 | } |
75 | 75 | ?> |
76 | 76 | <p class="search-box" role="search"> |
77 | 77 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
78 | 78 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
79 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
79 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
80 | 80 | </p> |
81 | 81 | <?php |
82 | 82 | } |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function get_columns() { |
92 | 92 | $columns = array( |
93 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
94 | - 'details' => esc_html__( 'Request Details', 'give' ), |
|
95 | - 'ip' => esc_html__( 'Request IP', 'give' ), |
|
96 | - 'date' => esc_html__( 'Date', 'give' ), |
|
93 | + 'ID' => esc_html__('Log ID', 'give'), |
|
94 | + 'details' => esc_html__('Request Details', 'give'), |
|
95 | + 'ip' => esc_html__('Request IP', 'give'), |
|
96 | + 'date' => esc_html__('Date', 'give'), |
|
97 | 97 | ); |
98 | 98 | |
99 | 99 | return $columns; |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return string Column Name |
112 | 112 | */ |
113 | - public function column_default( $item, $column_name ) { |
|
114 | - switch ( $column_name ) { |
|
113 | + public function column_default($item, $column_name) { |
|
114 | + switch ($column_name) { |
|
115 | 115 | default: |
116 | - return $item[ $column_name ]; |
|
116 | + return $item[$column_name]; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -127,26 +127,26 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return void |
129 | 129 | */ |
130 | - public function column_details( $item ) { |
|
130 | + public function column_details($item) { |
|
131 | 131 | ?> |
132 | - <a href="#TB_inline?width=640&inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e( 'View Request', 'give' ); ?></a> |
|
132 | + <a href="#TB_inline?width=640&inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e('View Request', 'give'); ?></a> |
|
133 | 133 | <div id="log-details-<?php echo $item['ID']; ?>" style="display:none;"> |
134 | 134 | <?php |
135 | 135 | |
136 | - $request = get_post_field( 'post_excerpt', $item['ID'] ); |
|
137 | - $error = get_post_field( 'post_content', $item['ID'] ); |
|
138 | - echo '<p><strong>' . esc_html__( 'API Request:', 'give' ) . '</strong></p>'; |
|
139 | - echo '<div>' . $request . '</div>'; |
|
140 | - if ( ! empty( $error ) ) { |
|
141 | - echo '<p><strong>' . esc_html__( 'Error', 'give' ) . '</strong></p>'; |
|
142 | - echo '<div>' . esc_html( $error ) . '</div>'; |
|
136 | + $request = get_post_field('post_excerpt', $item['ID']); |
|
137 | + $error = get_post_field('post_content', $item['ID']); |
|
138 | + echo '<p><strong>'.esc_html__('API Request:', 'give').'</strong></p>'; |
|
139 | + echo '<div>'.$request.'</div>'; |
|
140 | + if ( ! empty($error)) { |
|
141 | + echo '<p><strong>'.esc_html__('Error', 'give').'</strong></p>'; |
|
142 | + echo '<div>'.esc_html($error).'</div>'; |
|
143 | 143 | } |
144 | - echo '<p><strong>' . esc_html__( 'API User:', 'give' ) . '</strong></p>'; |
|
145 | - echo '<div>' . get_post_meta( $item['ID'], '_give_log_user', true ) . '</div>'; |
|
146 | - echo '<p><strong>' . esc_html__( 'API Key:', 'give' ) . '</strong></p>'; |
|
147 | - echo '<div>' . get_post_meta( $item['ID'], '_give_log_key', true ) . '</div>'; |
|
148 | - echo '<p><strong>' . esc_html__( 'Request Date:', 'give' ) . '</strong></p>'; |
|
149 | - echo '<div>' . get_post_field( 'post_date', $item['ID'] ) . '</div>'; |
|
144 | + echo '<p><strong>'.esc_html__('API User:', 'give').'</strong></p>'; |
|
145 | + echo '<div>'.get_post_meta($item['ID'], '_give_log_user', true).'</div>'; |
|
146 | + echo '<p><strong>'.esc_html__('API Key:', 'give').'</strong></p>'; |
|
147 | + echo '<div>'.get_post_meta($item['ID'], '_give_log_key', true).'</div>'; |
|
148 | + echo '<p><strong>'.esc_html__('Request Date:', 'give').'</strong></p>'; |
|
149 | + echo '<div>'.get_post_field('post_date', $item['ID']).'</div>'; |
|
150 | 150 | ?> |
151 | 151 | </div> |
152 | 152 | <?php |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return string|bool String if search is present, false otherwise |
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
163 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -176,19 +176,19 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @param string $which |
178 | 178 | */ |
179 | - protected function display_tablenav( $which ) { |
|
180 | - if ( 'top' === $which ) { |
|
181 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
179 | + protected function display_tablenav($which) { |
|
180 | + if ('top' === $which) { |
|
181 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
182 | 182 | } |
183 | 183 | ?> |
184 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
184 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
185 | 185 | |
186 | 186 | <div class="alignleft actions bulkactions"> |
187 | - <?php $this->bulk_actions( $which ); ?> |
|
187 | + <?php $this->bulk_actions($which); ?> |
|
188 | 188 | </div> |
189 | 189 | <?php |
190 | - $this->extra_tablenav( $which ); |
|
191 | - $this->pagination( $which ); |
|
190 | + $this->extra_tablenav($which); |
|
191 | + $this->pagination($which); |
|
192 | 192 | ?> |
193 | 193 | |
194 | 194 | <br class="clear"/> |
@@ -210,31 +210,31 @@ discard block |
||
210 | 210 | |
211 | 211 | $search = $this->get_search(); |
212 | 212 | |
213 | - if ( $search ) { |
|
214 | - if ( filter_var( $search, FILTER_VALIDATE_IP ) ) { |
|
213 | + if ($search) { |
|
214 | + if (filter_var($search, FILTER_VALIDATE_IP)) { |
|
215 | 215 | // This is an IP address search |
216 | 216 | $key = '_give_log_request_ip'; |
217 | - } elseif ( is_email( $search ) ) { |
|
217 | + } elseif (is_email($search)) { |
|
218 | 218 | // This is an email search |
219 | - $userdata = get_user_by( 'email', $search ); |
|
219 | + $userdata = get_user_by('email', $search); |
|
220 | 220 | |
221 | - if ( $userdata ) { |
|
221 | + if ($userdata) { |
|
222 | 222 | $search = $userdata->ID; |
223 | 223 | } |
224 | 224 | |
225 | 225 | $key = '_give_log_user'; |
226 | - } elseif ( strlen( $search ) == 32 ) { |
|
226 | + } elseif (strlen($search) == 32) { |
|
227 | 227 | // Look for an API key |
228 | 228 | $key = '_give_log_key'; |
229 | - } elseif ( stristr( $search, 'token:' ) ) { |
|
229 | + } elseif (stristr($search, 'token:')) { |
|
230 | 230 | // Look for an API token |
231 | - $search = str_ireplace( 'token:', '', $search ); |
|
231 | + $search = str_ireplace('token:', '', $search); |
|
232 | 232 | $key = '_give_log_token'; |
233 | 233 | } else { |
234 | 234 | // This is (probably) a user ID search |
235 | - $userdata = get_userdata( $search ); |
|
235 | + $userdata = get_userdata($search); |
|
236 | 236 | |
237 | - if ( $userdata ) { |
|
237 | + if ($userdata) { |
|
238 | 238 | $search = $userdata->ID; |
239 | 239 | } |
240 | 240 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @return int Current page number |
261 | 261 | */ |
262 | 262 | public function get_paged() { |
263 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
263 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @since 1.0 |
271 | 271 | * @return void |
272 | 272 | */ |
273 | - function bulk_actions( $which = '' ) { |
|
273 | + function bulk_actions($which = '') { |
|
274 | 274 | give_log_views(); |
275 | 275 | } |
276 | 276 | |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | 'meta_query' => $this->get_meta_query(), |
294 | 294 | ); |
295 | 295 | |
296 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
296 | + $logs = $give_logs->get_connected_logs($log_query); |
|
297 | 297 | |
298 | - if ( $logs ) { |
|
299 | - foreach ( $logs as $log ) { |
|
298 | + if ($logs) { |
|
299 | + foreach ($logs as $log) { |
|
300 | 300 | |
301 | 301 | $logs_data[] = array( |
302 | 302 | 'ID' => $log->ID, |
303 | - 'ip' => get_post_meta( $log->ID, '_give_log_request_ip', true ), |
|
303 | + 'ip' => get_post_meta($log->ID, '_give_log_request_ip', true), |
|
304 | 304 | 'date' => $log->post_date, |
305 | 305 | ); |
306 | 306 | } |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | $columns = $this->get_columns(); |
329 | 329 | $hidden = array(); // No hidden columns |
330 | 330 | $sortable = $this->get_sortable_columns(); |
331 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
331 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
332 | 332 | $this->items = $this->get_logs(); |
333 | - $total_items = $give_logs->get_log_count( 0, 'api_requests' ); |
|
333 | + $total_items = $give_logs->get_log_count(0, 'api_requests'); |
|
334 | 334 | |
335 | - $this->set_pagination_args( array( |
|
335 | + $this->set_pagination_args(array( |
|
336 | 336 | 'total_items' => $total_items, |
337 | 337 | 'per_page' => $this->per_page, |
338 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
338 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
339 | 339 | ) |
340 | 340 | ); |
341 | 341 | } |
@@ -157,7 +157,7 @@ |
||
157 | 157 | * |
158 | 158 | * @access public |
159 | 159 | * @since 1.0 |
160 | - * @return string|bool string If search is present, false otherwise |
|
160 | + * @return string|false string If search is present, false otherwise |
|
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | 163 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // Load WP_List_Table if not loaded |
17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | +if ( ! class_exists('WP_List_Table')) { |
|
18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | global $status, $page; |
45 | 45 | |
46 | 46 | // Set parent defaults |
47 | - parent::__construct( array( |
|
48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
50 | - 'ajax' => false,// Does this table support ajax? |
|
51 | - ) ); |
|
47 | + parent::__construct(array( |
|
48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
50 | + 'ajax' => false, // Does this table support ajax? |
|
51 | + )); |
|
52 | 52 | |
53 | - add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) ); |
|
53 | + add_action('give_log_view_actions', array($this, 'give_forms_filter')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -64,37 +64,37 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
67 | + public function column_default($item, $column_name) { |
|
68 | 68 | |
69 | - $payment = give_get_payment_by( 'id', $item['payment_id'] ); |
|
69 | + $payment = give_get_payment_by('id', $item['payment_id']); |
|
70 | 70 | |
71 | - switch ( $column_name ) { |
|
71 | + switch ($column_name) { |
|
72 | 72 | case 'form' : |
73 | - return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . get_the_title( $item[ $column_name ] ) . '</a>'; |
|
73 | + return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.get_the_title($item[$column_name]).'</a>'; |
|
74 | 74 | |
75 | 75 | case 'user_id' : |
76 | - return '<a href="' . |
|
77 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) . |
|
78 | - '">' . $item['user_name'] . '</a>'; |
|
76 | + return '<a href="'. |
|
77 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.( ! empty($item['user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))). |
|
78 | + '">'.$item['user_name'].'</a>'; |
|
79 | 79 | |
80 | 80 | case 'amount' : |
81 | - return give_currency_filter( give_format_amount( $item['amount'] ) ); |
|
81 | + return give_currency_filter(give_format_amount($item['amount'])); |
|
82 | 82 | |
83 | 83 | case 'status' : |
84 | 84 | |
85 | - $value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>'; |
|
85 | + $value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>'; |
|
86 | 86 | |
87 | - if ( $payment->mode == 'test' ) { |
|
88 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . esc_html__( 'Test', 'give' ) . '</span>'; |
|
87 | + if ($payment->mode == 'test') { |
|
88 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.esc_html__('Test', 'give').'</span>'; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $value; |
92 | 92 | |
93 | 93 | case 'payment_id' : |
94 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>'; |
|
94 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>'; |
|
95 | 95 | |
96 | 96 | default: |
97 | - return $item[ $column_name ]; |
|
97 | + return $item[$column_name]; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function get_columns() { |
109 | 109 | $columns = array( |
110 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
111 | - 'user_id' => esc_html__( 'Donor', 'give' ), |
|
112 | - 'form' => esc_html__( 'Form', 'give' ), |
|
113 | - 'amount' => esc_html__( 'Donation Amount', 'give' ), |
|
114 | - 'status' => esc_html__( 'Status', 'give' ), |
|
115 | - 'payment_id' => esc_html__( 'Transaction ID', 'give' ), |
|
116 | - 'date' => esc_html__( 'Date', 'give' ), |
|
110 | + 'ID' => esc_html__('Log ID', 'give'), |
|
111 | + 'user_id' => esc_html__('Donor', 'give'), |
|
112 | + 'form' => esc_html__('Form', 'give'), |
|
113 | + 'amount' => esc_html__('Donation Amount', 'give'), |
|
114 | + 'status' => esc_html__('Status', 'give'), |
|
115 | + 'payment_id' => esc_html__('Transaction ID', 'give'), |
|
116 | + 'date' => esc_html__('Date', 'give'), |
|
117 | 117 | ); |
118 | 118 | |
119 | 119 | return $columns; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @return int Current page number |
128 | 128 | */ |
129 | 129 | public function get_paged() { |
130 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
130 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return mixed int If User ID, string If Email/Login |
139 | 139 | */ |
140 | 140 | public function get_filtered_user() { |
141 | - return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false; |
|
141 | + return isset($_GET['user']) ? absint($_GET['user']) : false; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return int Download ID |
150 | 150 | */ |
151 | 151 | public function get_filtered_give_form() { |
152 | - return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false; |
|
152 | + return ! empty($_GET['form']) ? absint($_GET['form']) : false; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return string|bool string If search is present, false otherwise |
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
163 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -176,20 +176,20 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @param string $which |
178 | 178 | */ |
179 | - protected function display_tablenav( $which ) { |
|
179 | + protected function display_tablenav($which) { |
|
180 | 180 | |
181 | - if ( 'top' === $which ) { |
|
182 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
181 | + if ('top' === $which) { |
|
182 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
183 | 183 | } |
184 | 184 | ?> |
185 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
185 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
186 | 186 | |
187 | 187 | <div class="alignleft actions bulkactions"> |
188 | - <?php $this->bulk_actions( $which ); ?> |
|
188 | + <?php $this->bulk_actions($which); ?> |
|
189 | 189 | </div> |
190 | 190 | <?php |
191 | - $this->extra_tablenav( $which ); |
|
192 | - $this->pagination( $which ); |
|
191 | + $this->extra_tablenav($which); |
|
192 | + $this->pagination($which); |
|
193 | 193 | ?> |
194 | 194 | |
195 | 195 | <br class="clear"/> |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | $meta_query = array(); |
214 | 214 | |
215 | - if ( $user ) { |
|
215 | + if ($user) { |
|
216 | 216 | // Show only logs from a specific user |
217 | 217 | $meta_query[] = array( |
218 | 218 | 'key' => '_give_log_user_id', |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | $search = $this->get_search(); |
224 | - if ( $search ) { |
|
225 | - if ( is_email( $search ) ) { |
|
224 | + if ($search) { |
|
225 | + if (is_email($search)) { |
|
226 | 226 | // This is an email search. We use this to ensure it works for guest users and logged-in users |
227 | 227 | $key = '_give_log_user_info'; |
228 | 228 | $compare = 'LIKE'; |
@@ -231,32 +231,32 @@ discard block |
||
231 | 231 | $key = '_give_log_user_id'; |
232 | 232 | $compare = 'LIKE'; |
233 | 233 | |
234 | - if ( ! is_numeric( $search ) ) { |
|
234 | + if ( ! is_numeric($search)) { |
|
235 | 235 | // Searching for user by username |
236 | - $user = get_user_by( 'login', $search ); |
|
236 | + $user = get_user_by('login', $search); |
|
237 | 237 | |
238 | - if ( $user ) { |
|
238 | + if ($user) { |
|
239 | 239 | // Found one, set meta value to user's ID |
240 | 240 | $search = $user->ID; |
241 | 241 | } else { |
242 | 242 | // No user found so let's do a real search query |
243 | - $users = new WP_User_Query( array( |
|
243 | + $users = new WP_User_Query(array( |
|
244 | 244 | 'search' => $search, |
245 | - 'search_columns' => array( 'user_url', 'user_nicename' ), |
|
245 | + 'search_columns' => array('user_url', 'user_nicename'), |
|
246 | 246 | 'number' => 1, |
247 | 247 | 'fields' => 'ids', |
248 | - ) ); |
|
248 | + )); |
|
249 | 249 | |
250 | 250 | $found_user = $users->get_results(); |
251 | 251 | |
252 | - if ( $found_user ) { |
|
252 | + if ($found_user) { |
|
253 | 253 | $search = $found_user[0]; |
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - if ( ! $this->file_search ) { |
|
259 | + if ( ! $this->file_search) { |
|
260 | 260 | // Meta query only works for non file name searche |
261 | 261 | $meta_query[] = array( |
262 | 262 | 'key' => $key, |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @since 1.0 |
278 | 278 | * @return void |
279 | 279 | */ |
280 | - function bulk_actions( $which = '' ) { |
|
280 | + function bulk_actions($which = '') { |
|
281 | 281 | give_log_views(); |
282 | 282 | } |
283 | 283 | |
@@ -289,22 +289,22 @@ discard block |
||
289 | 289 | * @return void |
290 | 290 | */ |
291 | 291 | public function give_forms_filter() { |
292 | - $give_forms = get_posts( array( |
|
292 | + $give_forms = get_posts(array( |
|
293 | 293 | 'post_type' => 'give_forms', |
294 | 294 | 'post_status' => 'any', |
295 | - 'posts_per_page' => - 1, |
|
295 | + 'posts_per_page' => -1, |
|
296 | 296 | 'orderby' => 'title', |
297 | 297 | 'order' => 'ASC', |
298 | 298 | 'fields' => 'ids', |
299 | 299 | 'update_post_meta_cache' => false, |
300 | 300 | 'update_post_term_cache' => false, |
301 | - ) ); |
|
301 | + )); |
|
302 | 302 | |
303 | - if ( $give_forms ) { |
|
303 | + if ($give_forms) { |
|
304 | 304 | echo '<select name="form" id="give-log-form-filter">'; |
305 | - echo '<option value="0">' . esc_html__( 'All', 'give' ) . '</option>'; |
|
306 | - foreach ( $give_forms as $form ) { |
|
307 | - echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( get_the_title( $form ) ) . '</option>'; |
|
305 | + echo '<option value="0">'.esc_html__('All', 'give').'</option>'; |
|
306 | + foreach ($give_forms as $form) { |
|
307 | + echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html(get_the_title($form)).'</option>'; |
|
308 | 308 | } |
309 | 309 | echo '</select>'; |
310 | 310 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | |
325 | 325 | $logs_data = array(); |
326 | 326 | $paged = $this->get_paged(); |
327 | - $give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null; |
|
327 | + $give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null; |
|
328 | 328 | $user = $this->get_filtered_user(); |
329 | 329 | |
330 | 330 | $log_query = array( |
@@ -334,39 +334,39 @@ discard block |
||
334 | 334 | 'meta_query' => $this->get_meta_query(), |
335 | 335 | ); |
336 | 336 | |
337 | - $cache_key = give_get_cache_key( 'get_logs', $log_query ); |
|
337 | + $cache_key = give_get_cache_key('get_logs', $log_query); |
|
338 | 338 | |
339 | 339 | // Return result from cache if exist. |
340 | - if ( ! ( $logs_data = get_option( $cache_key ) ) ) { |
|
340 | + if ( ! ($logs_data = get_option($cache_key))) { |
|
341 | 341 | |
342 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
342 | + $logs = $give_logs->get_connected_logs($log_query); |
|
343 | 343 | |
344 | - if ( $logs ) { |
|
345 | - foreach ( $logs as $log ) { |
|
346 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
344 | + if ($logs) { |
|
345 | + foreach ($logs as $log) { |
|
346 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
347 | 347 | |
348 | 348 | // Make sure this payment hasn't been deleted |
349 | - if ( get_post( $payment_id ) ) : |
|
350 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
351 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
352 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
349 | + if (get_post($payment_id)) : |
|
350 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
351 | + $payment_meta = give_get_payment_meta($payment_id); |
|
352 | + $payment_amount = give_get_payment_amount($payment_id); |
|
353 | 353 | |
354 | 354 | $logs_data[] = array( |
355 | - 'ID' => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>', |
|
355 | + 'ID' => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>', |
|
356 | 356 | 'payment_id' => $payment_id, |
357 | 357 | 'form' => $log->post_parent, |
358 | 358 | 'amount' => $payment_amount, |
359 | 359 | 'user_id' => $user_info['id'], |
360 | - 'user_name' => $user_info['first_name'] . ' ' . $user_info['last_name'], |
|
361 | - 'date' => get_post_field( 'post_date', $payment_id ), |
|
360 | + 'user_name' => $user_info['first_name'].' '.$user_info['last_name'], |
|
361 | + 'date' => get_post_field('post_date', $payment_id), |
|
362 | 362 | ); |
363 | 363 | |
364 | 364 | endif; |
365 | 365 | } |
366 | 366 | |
367 | 367 | // Cache results. |
368 | - if ( ! empty( $logs_data ) ) { |
|
369 | - add_option( $cache_key, $logs_data, '', 'no' ); |
|
368 | + if ( ! empty($logs_data)) { |
|
369 | + add_option($cache_key, $logs_data, '', 'no'); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | } |
@@ -394,15 +394,15 @@ discard block |
||
394 | 394 | $columns = $this->get_columns(); |
395 | 395 | $hidden = array(); |
396 | 396 | $sortable = $this->get_sortable_columns(); |
397 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
397 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
398 | 398 | $current_page = $this->get_pagenum(); |
399 | 399 | $this->items = $this->get_logs(); |
400 | - $total_items = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() ); |
|
400 | + $total_items = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query()); |
|
401 | 401 | |
402 | - $this->set_pagination_args( array( |
|
402 | + $this->set_pagination_args(array( |
|
403 | 403 | 'total_items' => $total_items, |
404 | 404 | 'per_page' => $this->per_page, |
405 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
405 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
406 | 406 | ) |
407 | 407 | ); |
408 | 408 | } |