@@ -254,8 +254,8 @@ |
||
254 | 254 | $args = array( |
255 | 255 | 'id' => 'give-api-user-search', |
256 | 256 | 'name' => 'user_id', |
257 | - ); |
|
258 | - echo Give()->html->ajax_user_search($args); ?> |
|
257 | + ); |
|
258 | + echo Give()->html->ajax_user_search($args); ?> |
|
259 | 259 | <?php submit_button( esc_html__( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); ?> |
260 | 260 | <?php |
261 | 261 | $give_api_is_bottom = true; |
@@ -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 | /** |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | global $status, $page; |
54 | 54 | |
55 | 55 | // Set parent defaults |
56 | - parent::__construct( array( |
|
57 | - 'singular' => esc_html__( 'API Key', 'give' ), // Singular name of the listed records |
|
58 | - 'plural' => esc_html__( 'API Keys', 'give' ), // Plural name of the listed records |
|
59 | - 'ajax' => false,// Does this table support ajax? |
|
60 | - ) ); |
|
56 | + parent::__construct(array( |
|
57 | + 'singular' => esc_html__('API Key', 'give'), // Singular name of the listed records |
|
58 | + 'plural' => esc_html__('API Keys', 'give'), // Plural name of the listed records |
|
59 | + 'ajax' => false, // Does this table support ajax? |
|
60 | + )); |
|
61 | 61 | |
62 | 62 | $this->query(); |
63 | 63 | } |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string Column Name |
75 | 75 | */ |
76 | - public function column_default( $item, $column_name ) { |
|
77 | - return $item[ $column_name ]; |
|
76 | + public function column_default($item, $column_name) { |
|
77 | + return $item[$column_name]; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return string Column Name |
89 | 89 | */ |
90 | - public function column_key( $item ) { |
|
91 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['key'] ) . '"/>'; |
|
90 | + public function column_key($item) { |
|
91 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['key']).'"/>'; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string Column Name |
103 | 103 | */ |
104 | - public function column_token( $item ) { |
|
105 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['token'] ) . '"/>'; |
|
104 | + public function column_token($item) { |
|
105 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['token']).'"/>'; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return string Column Name |
117 | 117 | */ |
118 | - public function column_secret( $item ) { |
|
119 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['secret'] ) . '"/>'; |
|
118 | + public function column_secret($item) { |
|
119 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['secret']).'"/>'; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,46 +126,46 @@ discard block |
||
126 | 126 | * @since 1.1 |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - public function column_user( $item ) { |
|
129 | + public function column_user($item) { |
|
130 | 130 | |
131 | 131 | $actions = array(); |
132 | 132 | |
133 | - if ( apply_filters( 'give_api_log_requests', true ) ) { |
|
133 | + if (apply_filters('give_api_log_requests', true)) { |
|
134 | 134 | $actions['view'] = sprintf( |
135 | 135 | '<a href="%s">%s</a>', |
136 | - esc_url( add_query_arg( array( |
|
136 | + esc_url(add_query_arg(array( |
|
137 | 137 | 'section' => 'api_requests', |
138 | 138 | 'post_type' => 'give_forms', |
139 | 139 | 'page' => 'give-tools', |
140 | 140 | 'tab' => 'logs', |
141 | 141 | 's' => $item['email'], |
142 | - ), 'edit.php' ) ), |
|
143 | - esc_html__( 'View API Log', 'give' ) |
|
142 | + ), 'edit.php')), |
|
143 | + esc_html__('View API Log', 'give') |
|
144 | 144 | ); |
145 | 145 | } |
146 | 146 | |
147 | 147 | $actions['reissue'] = sprintf( |
148 | 148 | '<a href="%s" class="give-regenerate-api-key">%s</a>', |
149 | - esc_url( wp_nonce_url( add_query_arg( array( |
|
149 | + esc_url(wp_nonce_url(add_query_arg(array( |
|
150 | 150 | 'user_id' => $item['id'], |
151 | 151 | 'give_action' => 'process_api_key', |
152 | 152 | 'give_api_process' => 'regenerate', |
153 | - ) ), 'give-api-nonce' ) ), |
|
154 | - esc_html__( 'Reissue', 'give' ) |
|
153 | + )), 'give-api-nonce')), |
|
154 | + esc_html__('Reissue', 'give') |
|
155 | 155 | ); |
156 | - $actions['revoke'] = sprintf( |
|
156 | + $actions['revoke'] = sprintf( |
|
157 | 157 | '<a href="%s" class="give-revoke-api-key give-delete">%s</a>', |
158 | - esc_url( wp_nonce_url( add_query_arg( array( |
|
158 | + esc_url(wp_nonce_url(add_query_arg(array( |
|
159 | 159 | 'user_id' => $item['id'], |
160 | 160 | 'give_action' => 'process_api_key', |
161 | 161 | 'give_api_process' => 'revoke', |
162 | - ) ), 'give-api-nonce' ) ), |
|
163 | - esc_html__( 'Revoke', 'give' ) |
|
162 | + )), 'give-api-nonce')), |
|
163 | + esc_html__('Revoke', 'give') |
|
164 | 164 | ); |
165 | 165 | |
166 | - $actions = apply_filters( 'give_api_row_actions', array_filter( $actions ) ); |
|
166 | + $actions = apply_filters('give_api_row_actions', array_filter($actions)); |
|
167 | 167 | |
168 | - return sprintf( '%1$s %2$s', $item['user'], $this->row_actions( $actions ) ); |
|
168 | + return sprintf('%1$s %2$s', $item['user'], $this->row_actions($actions)); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function get_columns() { |
191 | 191 | $columns = array( |
192 | - 'user' => esc_html__( 'Username', 'give' ), |
|
193 | - 'key' => esc_html__( 'Public Key', 'give' ), |
|
194 | - 'token' => esc_html__( 'Token', 'give' ), |
|
195 | - 'secret' => esc_html__( 'Secret Key', 'give' ), |
|
192 | + 'user' => esc_html__('Username', 'give'), |
|
193 | + 'key' => esc_html__('Public Key', 'give'), |
|
194 | + 'token' => esc_html__('Token', 'give'), |
|
195 | + 'secret' => esc_html__('Secret Key', 'give'), |
|
196 | 196 | ); |
197 | 197 | |
198 | 198 | return $columns; |
@@ -206,20 +206,20 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @param string $which |
208 | 208 | */ |
209 | - protected function display_tablenav( $which ) { |
|
210 | - if ( 'top' === $which ) { |
|
211 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
209 | + protected function display_tablenav($which) { |
|
210 | + if ('top' === $which) { |
|
211 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
212 | 212 | } |
213 | 213 | ?> |
214 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
214 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
215 | 215 | |
216 | 216 | <div class="alignleft actions bulkactions"> |
217 | - <?php $this->bulk_actions( $which ); ?> |
|
217 | + <?php $this->bulk_actions($which); ?> |
|
218 | 218 | </div> |
219 | 219 | |
220 | 220 | <?php |
221 | - $this->extra_tablenav( $which ); |
|
222 | - $this->pagination( $which ); |
|
221 | + $this->extra_tablenav($which); |
|
222 | + $this->pagination($which); |
|
223 | 223 | ?> |
224 | 224 | |
225 | 225 | <br class="clear"/> |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - function bulk_actions( $which = '' ) { |
|
240 | + function bulk_actions($which = '') { |
|
241 | 241 | // These aren't really bulk actions but this outputs the markup in the right place. |
242 | 242 | static $give_api_is_bottom; |
243 | 243 | |
244 | - if ( $give_api_is_bottom ) { |
|
244 | + if ($give_api_is_bottom) { |
|
245 | 245 | return; |
246 | 246 | } |
247 | 247 | ?> |
248 | 248 | <input type="hidden" name="give_action" value="process_api_key"/> |
249 | 249 | <input type="hidden" name="give_api_process" value="generate"/> |
250 | - <?php wp_nonce_field( 'give-api-nonce' ); |
|
250 | + <?php wp_nonce_field('give-api-nonce'); |
|
251 | 251 | /** |
252 | 252 | * API Key user search. |
253 | 253 | */ |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'name' => 'user_id', |
257 | 257 | ); |
258 | 258 | echo Give()->html->ajax_user_search($args); ?> |
259 | - <?php submit_button( esc_html__( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); ?> |
|
259 | + <?php submit_button(esc_html__('Generate New API Keys', 'give'), 'secondary', 'submit', false); ?> |
|
260 | 260 | <?php |
261 | 261 | $give_api_is_bottom = true; |
262 | 262 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @return int Current page number |
270 | 270 | */ |
271 | 271 | public function get_paged() { |
272 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
272 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -280,21 +280,21 @@ discard block |
||
280 | 280 | * @return array |
281 | 281 | */ |
282 | 282 | public function query() { |
283 | - $users = get_users( array( |
|
283 | + $users = get_users(array( |
|
284 | 284 | 'meta_value' => 'give_user_secret_key', |
285 | 285 | 'number' => $this->per_page, |
286 | - 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
287 | - ) ); |
|
288 | - $keys = array(); |
|
289 | - |
|
290 | - foreach ( $users as $user ) { |
|
291 | - $keys[ $user->ID ]['id'] = $user->ID; |
|
292 | - $keys[ $user->ID ]['email'] = $user->user_email; |
|
293 | - $keys[ $user->ID ]['user'] = '<a href="' . add_query_arg( 'user_id', $user->ID, 'user-edit.php' ) . '"><strong>' . $user->user_login . '</strong></a>'; |
|
294 | - |
|
295 | - $keys[ $user->ID ]['key'] = Give()->api->get_user_public_key( $user->ID ); |
|
296 | - $keys[ $user->ID ]['secret'] = Give()->api->get_user_secret_key( $user->ID ); |
|
297 | - $keys[ $user->ID ]['token'] = Give()->api->get_token( $user->ID ); |
|
286 | + 'offset' => $this->per_page * ($this->get_paged() - 1), |
|
287 | + )); |
|
288 | + $keys = array(); |
|
289 | + |
|
290 | + foreach ($users as $user) { |
|
291 | + $keys[$user->ID]['id'] = $user->ID; |
|
292 | + $keys[$user->ID]['email'] = $user->user_email; |
|
293 | + $keys[$user->ID]['user'] = '<a href="'.add_query_arg('user_id', $user->ID, 'user-edit.php').'"><strong>'.$user->user_login.'</strong></a>'; |
|
294 | + |
|
295 | + $keys[$user->ID]['key'] = Give()->api->get_user_public_key($user->ID); |
|
296 | + $keys[$user->ID]['secret'] = Give()->api->get_user_secret_key($user->ID); |
|
297 | + $keys[$user->ID]['token'] = Give()->api->get_token($user->ID); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | return $keys; |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | public function total_items() { |
312 | 312 | global $wpdb; |
313 | 313 | |
314 | - if ( ! ( $total_items = Give_Cache::get( 'give_total_api_keys', true ) ) ) { |
|
314 | + if ( ! ($total_items = Give_Cache::get('give_total_api_keys', true))) { |
|
315 | 315 | $total_items = $wpdb->get_var( |
316 | 316 | $wpdb->prepare( |
317 | 317 | "SELECT count(user_id) |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | ) |
321 | 321 | ); |
322 | 322 | |
323 | - Give_Cache::set( 'give_total_api_keys', $total_items, HOUR_IN_SECONDS, true ); |
|
323 | + Give_Cache::set('give_total_api_keys', $total_items, HOUR_IN_SECONDS, true); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | return $total_items; |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $hidden = array(); // No hidden columns |
340 | 340 | $sortable = array(); // Not sortable... for now |
341 | 341 | |
342 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
342 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
343 | 343 | |
344 | 344 | $data = $this->query(); |
345 | 345 | |
@@ -347,10 +347,10 @@ discard block |
||
347 | 347 | |
348 | 348 | $this->items = $data; |
349 | 349 | |
350 | - $this->set_pagination_args( array( |
|
350 | + $this->set_pagination_args(array( |
|
351 | 351 | 'total_items' => $total_items, |
352 | 352 | 'per_page' => $this->per_page, |
353 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
353 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -41,20 +41,20 @@ discard block |
||
41 | 41 | public function csv_cols() { |
42 | 42 | |
43 | 43 | $cols = array( |
44 | - 'ID' => __( 'ID', 'give' ), |
|
45 | - 'post_name' => __( 'Slug', 'give' ), |
|
46 | - 'post_title' => __( 'Name', 'give' ), |
|
47 | - 'post_date' => __( 'Date Created', 'give' ), |
|
48 | - 'post_author' => __( 'Author', 'give' ), |
|
49 | - 'post_content' => __( 'Description', 'give' ), |
|
50 | - 'post_excerpt' => __( 'Excerpt', 'give' ), |
|
51 | - 'post_status' => __( 'Status', 'give' ), |
|
52 | - 'categories' => __( 'Categories', 'give' ), |
|
53 | - 'tags' => __( 'Tags', 'give' ), |
|
54 | - 'give_price' => __( 'Price', 'give' ), |
|
55 | - '_thumbnail_id' => __( 'Featured Image', 'give' ), |
|
56 | - '_give_form_sales' => __( 'Donations', 'give' ), |
|
57 | - '_give_download_earnings' => __( 'Income', 'give' ), |
|
44 | + 'ID' => __('ID', 'give'), |
|
45 | + 'post_name' => __('Slug', 'give'), |
|
46 | + 'post_title' => __('Name', 'give'), |
|
47 | + 'post_date' => __('Date Created', 'give'), |
|
48 | + 'post_author' => __('Author', 'give'), |
|
49 | + 'post_content' => __('Description', 'give'), |
|
50 | + 'post_excerpt' => __('Excerpt', 'give'), |
|
51 | + 'post_status' => __('Status', 'give'), |
|
52 | + 'categories' => __('Categories', 'give'), |
|
53 | + 'tags' => __('Tags', 'give'), |
|
54 | + 'give_price' => __('Price', 'give'), |
|
55 | + '_thumbnail_id' => __('Featured Image', 'give'), |
|
56 | + '_give_form_sales' => __('Donations', 'give'), |
|
57 | + '_give_download_earnings' => __('Income', 'give'), |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | return $cols; |
@@ -84,43 +84,43 @@ discard block |
||
84 | 84 | 'paged' => $this->step |
85 | 85 | ); |
86 | 86 | |
87 | - $forms = new WP_Query( $args ); |
|
87 | + $forms = new WP_Query($args); |
|
88 | 88 | |
89 | - if ( $forms->posts ) { |
|
90 | - foreach ( $forms->posts as $form ) { |
|
89 | + if ($forms->posts) { |
|
90 | + foreach ($forms->posts as $form) { |
|
91 | 91 | |
92 | 92 | $row = []; |
93 | 93 | |
94 | - foreach ( $this->csv_cols() as $key => $value ) { |
|
94 | + foreach ($this->csv_cols() as $key => $value) { |
|
95 | 95 | |
96 | 96 | // Setup default value/ |
97 | - $row[ $key ] = ''; |
|
97 | + $row[$key] = ''; |
|
98 | 98 | |
99 | - if ( in_array( $key, $meta ) ) { |
|
99 | + if (in_array($key, $meta)) { |
|
100 | 100 | |
101 | - switch ( $key ) { |
|
101 | + switch ($key) { |
|
102 | 102 | |
103 | 103 | case '_thumbnail_id' : |
104 | 104 | |
105 | - $image_id = get_post_thumbnail_id( $form->ID ); |
|
106 | - $row[ $key ] = wp_get_attachment_url( $image_id ); |
|
105 | + $image_id = get_post_thumbnail_id($form->ID); |
|
106 | + $row[$key] = wp_get_attachment_url($image_id); |
|
107 | 107 | |
108 | 108 | break; |
109 | 109 | |
110 | 110 | case 'give_price' : |
111 | 111 | |
112 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
112 | + if (give_has_variable_prices($form->ID)) { |
|
113 | 113 | |
114 | 114 | $prices = []; |
115 | - foreach ( give_get_variable_prices( $form->ID ) as $price ) { |
|
116 | - $prices[] = $price['name'] . ': ' . $price['amount']; |
|
115 | + foreach (give_get_variable_prices($form->ID) as $price) { |
|
116 | + $prices[] = $price['name'].': '.$price['amount']; |
|
117 | 117 | } |
118 | 118 | |
119 | - $row[ $key ] = implode( ' | ', $prices ); |
|
119 | + $row[$key] = implode(' | ', $prices); |
|
120 | 120 | |
121 | 121 | } else { |
122 | 122 | |
123 | - $row[ $key ] = give_get_form_price( $form->ID ); |
|
123 | + $row[$key] = give_get_form_price($form->ID); |
|
124 | 124 | |
125 | 125 | } |
126 | 126 | |
@@ -128,44 +128,44 @@ discard block |
||
128 | 128 | |
129 | 129 | default : |
130 | 130 | |
131 | - $row[ $key ] = give_get_meta( $form->ID, $key, TRUE ); |
|
131 | + $row[$key] = give_get_meta($form->ID, $key, TRUE); |
|
132 | 132 | |
133 | 133 | break; |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | - } elseif ( isset( $form->$key ) ) { |
|
137 | + } elseif (isset($form->$key)) { |
|
138 | 138 | |
139 | - switch ( $key ) { |
|
139 | + switch ($key) { |
|
140 | 140 | |
141 | 141 | case 'post_author' : |
142 | 142 | |
143 | - $row[ $key ] = get_the_author_meta( 'user_login', $form->post_author ); |
|
143 | + $row[$key] = get_the_author_meta('user_login', $form->post_author); |
|
144 | 144 | |
145 | 145 | break; |
146 | 146 | |
147 | 147 | default : |
148 | 148 | |
149 | - $row[ $key ] = $form->$key; |
|
149 | + $row[$key] = $form->$key; |
|
150 | 150 | |
151 | 151 | break; |
152 | 152 | } |
153 | 153 | |
154 | - } elseif ( 'tags' == $key ) { |
|
154 | + } elseif ('tags' == $key) { |
|
155 | 155 | |
156 | - $terms = get_the_terms( $form->ID, 'form_tag' ); |
|
157 | - if ( $terms ) { |
|
158 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
159 | - $row[ $key ] = implode( ' | ', $terms ); |
|
156 | + $terms = get_the_terms($form->ID, 'form_tag'); |
|
157 | + if ($terms) { |
|
158 | + $terms = wp_list_pluck($terms, 'name'); |
|
159 | + $row[$key] = implode(' | ', $terms); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
163 | - } elseif ( 'categories' == $key ) { |
|
163 | + } elseif ('categories' == $key) { |
|
164 | 164 | |
165 | - $terms = get_the_terms( $form->ID, 'form_category' ); |
|
166 | - if ( $terms ) { |
|
167 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
168 | - $row[ $key ] = implode( ' | ', $terms ); |
|
165 | + $terms = get_the_terms($form->ID, 'form_category'); |
|
166 | + if ($terms) { |
|
167 | + $terms = wp_list_pluck($terms, 'name'); |
|
168 | + $row[$key] = implode(' | ', $terms); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | } |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | |
177 | 177 | } |
178 | 178 | |
179 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
180 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
179 | + $data = apply_filters('give_export_get_data', $data); |
|
180 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
181 | 181 | |
182 | 182 | return $data; |
183 | 183 | |
@@ -197,20 +197,20 @@ discard block |
||
197 | 197 | |
198 | 198 | $args = array( |
199 | 199 | 'post_type' => 'give_forms', |
200 | - 'posts_per_page' => - 1, |
|
200 | + 'posts_per_page' => -1, |
|
201 | 201 | 'post_status' => 'any', |
202 | 202 | 'fields' => 'ids', |
203 | 203 | ); |
204 | 204 | |
205 | - $forms = new WP_Query( $args ); |
|
205 | + $forms = new WP_Query($args); |
|
206 | 206 | $total = (int) $forms->post_count; |
207 | 207 | $percentage = 100; |
208 | 208 | |
209 | - if ( $total > 0 ) { |
|
210 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
209 | + if ($total > 0) { |
|
210 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
211 | 211 | } |
212 | 212 | |
213 | - if ( $percentage > 100 ) { |
|
213 | + if ($percentage > 100) { |
|
214 | 214 | $percentage = 100; |
215 | 215 | } |
216 | 216 |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | * @access private |
704 | 704 | * @since 1.7 |
705 | 705 | * |
706 | - * @return bool |
|
706 | + * @return false|null |
|
707 | 707 | */ |
708 | 708 | private function __remove_license_key_from_subscriptions() { |
709 | 709 | $subscriptions = get_option( 'give_subscriptions', array() ); |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | * @param $plugin_data |
737 | 737 | * @param $status |
738 | 738 | * |
739 | - * @return bool |
|
739 | + * @return false|null |
|
740 | 740 | */ |
741 | 741 | public function plugin_page_notices( $plugin_file, $plugin_data, $status ) { |
742 | 742 | // Bailout. |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @since 1.8.7 |
760 | 760 | * @access public |
761 | - * @return array |
|
761 | + * @return string |
|
762 | 762 | */ |
763 | 763 | public function license_state_message() { |
764 | 764 | $message_data = array(); |
@@ -10,11 +10,11 @@ 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 | -if ( ! class_exists( 'Give_License' ) ) : |
|
17 | +if ( ! class_exists('Give_License')) : |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Give_License Class |
@@ -143,27 +143,27 @@ discard block |
||
143 | 143 | * @param string $_checkout_url |
144 | 144 | * @param string $_account_url |
145 | 145 | */ |
146 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) { |
|
146 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) { |
|
147 | 147 | |
148 | 148 | $give_options = give_get_settings(); |
149 | 149 | |
150 | 150 | $this->file = $_file; |
151 | 151 | $this->item_name = $_item_name; |
152 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
152 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
153 | 153 | $this->version = $_version; |
154 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
155 | - $this->license_data = get_option( $this->item_shortname . '_license_active' ); |
|
154 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
155 | + $this->license_data = get_option($this->item_shortname.'_license_active'); |
|
156 | 156 | $this->author = $_author; |
157 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
158 | - $this->checkout_url = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url; |
|
159 | - $this->account_url = is_null( $_account_url ) ? $this->account_url : $_account_url; |
|
157 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
158 | + $this->checkout_url = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url; |
|
159 | + $this->account_url = is_null($_account_url) ? $this->account_url : $_account_url; |
|
160 | 160 | $this->auto_updater_obj = null; |
161 | 161 | |
162 | 162 | // Add Setting for Give Add-on activation status. |
163 | - $is_addon_activated = get_option( 'give_is_addon_activated' ); |
|
164 | - if ( ! $is_addon_activated && is_object( $this ) && sizeof( $this ) > 0 ) { |
|
165 | - update_option( 'give_is_addon_activated', true ); |
|
166 | - Give_Cache::set( 'give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS ); |
|
163 | + $is_addon_activated = get_option('give_is_addon_activated'); |
|
164 | + if ( ! $is_addon_activated && is_object($this) && sizeof($this) > 0) { |
|
165 | + update_option('give_is_addon_activated', true); |
|
166 | + Give_Cache::set('give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | // Setup hooks |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | private function includes() { |
186 | 186 | |
187 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
187 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
188 | 188 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
189 | 189 | } |
190 | 190 | } |
@@ -202,30 +202,30 @@ discard block |
||
202 | 202 | private function hooks() { |
203 | 203 | |
204 | 204 | // Register settings. |
205 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
205 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
206 | 206 | |
207 | 207 | // Activate license key on settings save. |
208 | - add_action( 'admin_init', array( $this, 'activate_license' ), 10 ); |
|
208 | + add_action('admin_init', array($this, 'activate_license'), 10); |
|
209 | 209 | |
210 | 210 | // Deactivate license key. |
211 | - add_action( 'admin_init', array( $this, 'deactivate_license' ), 11 ); |
|
211 | + add_action('admin_init', array($this, 'deactivate_license'), 11); |
|
212 | 212 | |
213 | 213 | // Updater. |
214 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
215 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
214 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
215 | + add_action('admin_notices', array($this, 'notices')); |
|
216 | 216 | |
217 | 217 | // Check license weekly. |
218 | - Give_Cron::add_weekly_event( array( $this, 'weekly_license_check' ) ); |
|
219 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) ); |
|
218 | + Give_Cron::add_weekly_event(array($this, 'weekly_license_check')); |
|
219 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check')); |
|
220 | 220 | |
221 | 221 | // Check subscription weekly. |
222 | - Give_Cron::add_weekly_event( array( $this, 'weekly_subscription_check' ) ); |
|
223 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) ); |
|
222 | + Give_Cron::add_weekly_event(array($this, 'weekly_subscription_check')); |
|
223 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check')); |
|
224 | 224 | |
225 | 225 | // Show addon notice on plugin page. |
226 | - $plugin_name = explode( 'plugins/', $this->file ); |
|
227 | - $plugin_name = end( $plugin_name ); |
|
228 | - add_action( "after_plugin_row_{$plugin_name}", array( $this, 'plugin_page_notices' ), 10, 3 ); |
|
226 | + $plugin_name = explode('plugins/', $this->file); |
|
227 | + $plugin_name = end($plugin_name); |
|
228 | + add_action("after_plugin_row_{$plugin_name}", array($this, 'plugin_page_notices'), 10, 3); |
|
229 | 229 | |
230 | 230 | } |
231 | 231 | |
@@ -265,16 +265,16 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return array License settings. |
267 | 267 | */ |
268 | - public function settings( $settings ) { |
|
268 | + public function settings($settings) { |
|
269 | 269 | |
270 | 270 | $give_license_settings = array( |
271 | 271 | array( |
272 | 272 | 'name' => $this->item_name, |
273 | - 'id' => $this->item_shortname . '_license_key', |
|
273 | + 'id' => $this->item_shortname.'_license_key', |
|
274 | 274 | 'desc' => '', |
275 | 275 | 'type' => 'license_key', |
276 | 276 | 'options' => array( |
277 | - 'license' => get_option( $this->item_shortname . '_license_active' ), |
|
277 | + 'license' => get_option($this->item_shortname.'_license_active'), |
|
278 | 278 | 'shortname' => $this->item_shortname, |
279 | 279 | 'item_name' => $this->item_name, |
280 | 280 | 'api_url' => $this->api_url, |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | ), |
286 | 286 | ); |
287 | 287 | |
288 | - return array_merge( $settings, $give_license_settings ); |
|
288 | + return array_merge($settings, $give_license_settings); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -300,18 +300,18 @@ discard block |
||
300 | 300 | * |
301 | 301 | * @return array License settings content. |
302 | 302 | */ |
303 | - public function license_settings_content( $settings ) { |
|
303 | + public function license_settings_content($settings) { |
|
304 | 304 | |
305 | 305 | $give_license_settings = array( |
306 | 306 | array( |
307 | - 'name' => __( 'Add-on Licenses', 'give' ), |
|
307 | + 'name' => __('Add-on Licenses', 'give'), |
|
308 | 308 | 'desc' => '<hr>', |
309 | 309 | 'type' => 'give_title', |
310 | 310 | 'id' => 'give_title', |
311 | 311 | ), |
312 | 312 | ); |
313 | 313 | |
314 | - return array_merge( $settings, $give_license_settings ); |
|
314 | + return array_merge($settings, $give_license_settings); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -326,62 +326,62 @@ discard block |
||
326 | 326 | */ |
327 | 327 | public function activate_license() { |
328 | 328 | // Bailout. |
329 | - if ( ! $this->__is_user_can_edit_license() ) { |
|
329 | + if ( ! $this->__is_user_can_edit_license()) { |
|
330 | 330 | return; |
331 | 331 | } |
332 | 332 | |
333 | 333 | // Allow third party addon developers to handle license activation. |
334 | - if ( $this->__is_third_party_addon() ) { |
|
335 | - do_action( 'give_activate_license', $this ); |
|
334 | + if ($this->__is_third_party_addon()) { |
|
335 | + do_action('give_activate_license', $this); |
|
336 | 336 | |
337 | 337 | return; |
338 | 338 | } |
339 | 339 | |
340 | 340 | // Delete previous license setting if a empty license key submitted. |
341 | - if ( empty( $_POST["{$this->item_shortname}_license_key"] ) ) { |
|
341 | + if (empty($_POST["{$this->item_shortname}_license_key"])) { |
|
342 | 342 | $this->unset_license(); |
343 | 343 | |
344 | 344 | return; |
345 | 345 | } |
346 | 346 | |
347 | 347 | // Do not simultaneously activate add-ons if the user want to deactivate a specific add-on. |
348 | - if( $this->is_deactivating_license() ) { |
|
348 | + if ($this->is_deactivating_license()) { |
|
349 | 349 | return; |
350 | 350 | } |
351 | 351 | |
352 | 352 | // Check if plugin previously installed. |
353 | - if ( $this->is_valid_license() ) { |
|
353 | + if ($this->is_valid_license()) { |
|
354 | 354 | return; |
355 | 355 | } |
356 | 356 | |
357 | 357 | // Get license key. |
358 | - $this->license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
358 | + $this->license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
359 | 359 | |
360 | 360 | // Delete previous license key from subscription if previously added. |
361 | 361 | $this->__remove_license_key_from_subscriptions(); |
362 | 362 | |
363 | 363 | // Make sure there are no api errors. |
364 | - if ( ! ( $license_data = $this->get_license_info( 'activate_license' ) ) ) { |
|
364 | + if ( ! ($license_data = $this->get_license_info('activate_license'))) { |
|
365 | 365 | return; |
366 | 366 | } |
367 | 367 | |
368 | 368 | // Make sure license is valid. |
369 | 369 | // return because admin will want to activate license again. |
370 | - if ( ! $this->is_license( $license_data ) ) { |
|
370 | + if ( ! $this->is_license($license_data)) { |
|
371 | 371 | // Add license key. |
372 | - give_update_option( "{$this->item_shortname}_license_key", $this->license ); |
|
372 | + give_update_option("{$this->item_shortname}_license_key", $this->license); |
|
373 | 373 | |
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | 377 | // Tell WordPress to look for updates. |
378 | - set_site_transient( 'update_plugins', null ); |
|
378 | + set_site_transient('update_plugins', null); |
|
379 | 379 | |
380 | 380 | // Add license data. |
381 | - update_option( "{$this->item_shortname}_license_active", $license_data ); |
|
381 | + update_option("{$this->item_shortname}_license_active", $license_data); |
|
382 | 382 | |
383 | 383 | // Add license key. |
384 | - give_update_option( "{$this->item_shortname}_license_key", $this->license ); |
|
384 | + give_update_option("{$this->item_shortname}_license_key", $this->license); |
|
385 | 385 | |
386 | 386 | // Check subscription for license key and store this to db (if any). |
387 | 387 | $this->__single_subscription_check(); |
@@ -399,19 +399,19 @@ discard block |
||
399 | 399 | */ |
400 | 400 | public function deactivate_license() { |
401 | 401 | // Bailout. |
402 | - if ( ! $this->__is_user_can_edit_license() ) { |
|
402 | + if ( ! $this->__is_user_can_edit_license()) { |
|
403 | 403 | return; |
404 | 404 | } |
405 | 405 | |
406 | 406 | // Allow third party add-on developers to handle license deactivation. |
407 | - if ( $this->__is_third_party_addon() ) { |
|
408 | - do_action( 'give_deactivate_license', $this ); |
|
407 | + if ($this->__is_third_party_addon()) { |
|
408 | + do_action('give_deactivate_license', $this); |
|
409 | 409 | |
410 | 410 | return; |
411 | 411 | } |
412 | 412 | |
413 | 413 | // Run on deactivate button press. |
414 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
414 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
415 | 415 | $this->unset_license(); |
416 | 416 | } |
417 | 417 | } |
@@ -427,30 +427,30 @@ discard block |
||
427 | 427 | public function weekly_license_check() { |
428 | 428 | |
429 | 429 | if ( |
430 | - ! empty( $_POST['give_settings'] ) || |
|
431 | - empty( $this->license ) |
|
430 | + ! empty($_POST['give_settings']) || |
|
431 | + empty($this->license) |
|
432 | 432 | ) { |
433 | 433 | return; |
434 | 434 | } |
435 | 435 | |
436 | 436 | // Allow third party add-on developers to handle their license check. |
437 | - if ( $this->__is_third_party_addon() ) { |
|
438 | - do_action( 'give_weekly_license_check', $this ); |
|
437 | + if ($this->__is_third_party_addon()) { |
|
438 | + do_action('give_weekly_license_check', $this); |
|
439 | 439 | |
440 | 440 | return; |
441 | 441 | } |
442 | 442 | |
443 | 443 | // Make sure there are no api errors. |
444 | - if ( ! ( $license_data = $this->get_license_info( 'check_license' ) ) ) { |
|
444 | + if ( ! ($license_data = $this->get_license_info('check_license'))) { |
|
445 | 445 | return; |
446 | 446 | } |
447 | 447 | |
448 | 448 | // Bailout. |
449 | - if ( ! $this->is_license( $license_data ) ) { |
|
449 | + if ( ! $this->is_license($license_data)) { |
|
450 | 450 | return; |
451 | 451 | } |
452 | 452 | |
453 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
453 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
454 | 454 | |
455 | 455 | return; |
456 | 456 | } |
@@ -466,21 +466,21 @@ discard block |
||
466 | 466 | public function weekly_subscription_check() { |
467 | 467 | // Bailout. |
468 | 468 | if ( |
469 | - ! empty( $_POST['give_settings'] ) || |
|
470 | - empty( $this->license ) |
|
469 | + ! empty($_POST['give_settings']) || |
|
470 | + empty($this->license) |
|
471 | 471 | ) { |
472 | 472 | return; |
473 | 473 | } |
474 | 474 | |
475 | 475 | // Remove old subscription data. |
476 | - if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) { |
|
477 | - delete_option( 'give_subscriptions' ); |
|
478 | - update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ) ); |
|
476 | + if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) { |
|
477 | + delete_option('give_subscriptions'); |
|
478 | + update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1))); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | // Allow third party add-on developers to handle their subscription check. |
482 | - if ( $this->__is_third_party_addon() ) { |
|
483 | - do_action( 'give_weekly_subscription_check', $this ); |
|
482 | + if ($this->__is_third_party_addon()) { |
|
483 | + do_action('give_weekly_subscription_check', $this); |
|
484 | 484 | |
485 | 485 | return; |
486 | 486 | } |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | * @return void |
498 | 498 | */ |
499 | 499 | private function __single_subscription_check() { |
500 | - if ( empty( $this->license ) ) { |
|
500 | + if (empty($this->license)) { |
|
501 | 501 | return; |
502 | 502 | } |
503 | 503 | |
@@ -508,26 +508,26 @@ discard block |
||
508 | 508 | * By default edd software licensing api does not have api to check subscription. |
509 | 509 | * This is a custom feature to check subscriptions. |
510 | 510 | */ |
511 | - $subscription_data = $this->get_license_info( 'check_subscription', true ); |
|
511 | + $subscription_data = $this->get_license_info('check_subscription', true); |
|
512 | 512 | |
513 | - if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
513 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
514 | 514 | |
515 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
515 | + $subscriptions = get_option('give_subscriptions', array()); |
|
516 | 516 | |
517 | 517 | // Update subscription data only if subscription does not exist already. |
518 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
518 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
519 | 519 | |
520 | 520 | // Initiate default set of license for subscription. |
521 | - if ( ! isset( $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
522 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
521 | + if ( ! isset($subscriptions[$subscription_data['id']]['licenses'])) { |
|
522 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | // Store licenses for subscription. |
526 | - if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
527 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
526 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
527 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
528 | 528 | } |
529 | 529 | |
530 | - update_option( 'give_subscriptions', $subscriptions ); |
|
530 | + update_option('give_subscriptions', $subscriptions); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
@@ -541,12 +541,12 @@ discard block |
||
541 | 541 | */ |
542 | 542 | public function notices() { |
543 | 543 | |
544 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
544 | + if ( ! current_user_can('manage_give_settings')) { |
|
545 | 545 | return; |
546 | 546 | } |
547 | 547 | |
548 | 548 | // Do not show licenses notices on license tab. |
549 | - if ( 'licenses' === give_get_current_setting_tab() ) { |
|
549 | + if ('licenses' === give_get_current_setting_tab()) { |
|
550 | 550 | return; |
551 | 551 | } |
552 | 552 | |
@@ -555,118 +555,118 @@ discard block |
||
555 | 555 | static $addon_license_key_in_subscriptions; |
556 | 556 | |
557 | 557 | // Set default value. |
558 | - $addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array(); |
|
558 | + $addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array(); |
|
559 | 559 | $messages = array(); |
560 | 560 | |
561 | 561 | // Check whether admin has Give Add-on activated since 24 hours? |
562 | - $is_license_notice_hidden = Give_Cache::get( 'give_cache_hide_license_notice_after_activation' ); |
|
562 | + $is_license_notice_hidden = Give_Cache::get('give_cache_hide_license_notice_after_activation'); |
|
563 | 563 | |
564 | 564 | // Display Invalid License notice, if its more than 24 hours since first Give Add-on activation. |
565 | 565 | if ( |
566 | - empty( $this->license ) |
|
567 | - && empty( $showed_invalid_message ) |
|
568 | - && ( false === $is_license_notice_hidden ) |
|
566 | + empty($this->license) |
|
567 | + && empty($showed_invalid_message) |
|
568 | + && (false === $is_license_notice_hidden) |
|
569 | 569 | ) { |
570 | 570 | |
571 | - Give()->notices->register_notice( array( |
|
571 | + Give()->notices->register_notice(array( |
|
572 | 572 | 'id' => 'give-invalid-license', |
573 | 573 | 'type' => 'error', |
574 | 574 | 'description' => sprintf( |
575 | - __( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
576 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
575 | + __('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
576 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
577 | 577 | ), |
578 | 578 | 'dismissible_type' => 'user', |
579 | 579 | 'dismiss_interval' => 'shortly', |
580 | - ) ); |
|
580 | + )); |
|
581 | 581 | |
582 | 582 | $showed_invalid_message = true; |
583 | 583 | |
584 | 584 | } |
585 | 585 | |
586 | 586 | // Get subscriptions. |
587 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
587 | + $subscriptions = get_option('give_subscriptions'); |
|
588 | 588 | |
589 | 589 | // Show subscription messages. |
590 | - if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) { |
|
590 | + if ( ! empty($subscriptions) && ! $showed_subscriptions_message) { |
|
591 | 591 | |
592 | - foreach ( $subscriptions as $subscription ) { |
|
592 | + foreach ($subscriptions as $subscription) { |
|
593 | 593 | // Subscription expires timestamp. |
594 | - $subscription_expires = strtotime( $subscription['expires'] ); |
|
594 | + $subscription_expires = strtotime($subscription['expires']); |
|
595 | 595 | |
596 | 596 | // Start showing subscriptions message before one week of renewal date. |
597 | - if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) { |
|
597 | + if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) { |
|
598 | 598 | continue; |
599 | 599 | } |
600 | 600 | |
601 | 601 | // Check if subscription message already exist in messages. |
602 | - if ( array_key_exists( $subscription['id'], $messages ) ) { |
|
602 | + if (array_key_exists($subscription['id'], $messages)) { |
|
603 | 603 | continue; |
604 | 604 | } |
605 | 605 | |
606 | 606 | // Check if license already expired. |
607 | - if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) { |
|
608 | - Give()->notices->register_notice( array( |
|
607 | + if (strtotime($subscription['expires']) < current_time('timestamp', 1)) { |
|
608 | + Give()->notices->register_notice(array( |
|
609 | 609 | 'id' => "give-expired-subscription-{$subscription['id']}", |
610 | 610 | 'type' => 'error', |
611 | 611 | 'description' => sprintf( |
612 | - __( 'Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give' ), |
|
613 | - urldecode( $subscription['invoice_url'] ), |
|
612 | + __('Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give'), |
|
613 | + urldecode($subscription['invoice_url']), |
|
614 | 614 | $subscription['payment_id'], |
615 | 615 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
616 | - Give()->notices->get_dismiss_link( array( |
|
617 | - 'title' => __( 'Click here if already renewed', 'give' ), |
|
616 | + Give()->notices->get_dismiss_link(array( |
|
617 | + 'title' => __('Click here if already renewed', 'give'), |
|
618 | 618 | 'dismissible_type' => 'user', |
619 | 619 | 'dismiss_interval' => 'permanent', |
620 | - ) ) |
|
620 | + )) |
|
621 | 621 | ), |
622 | 622 | 'dismissible_type' => 'user', |
623 | 623 | 'dismiss_interval' => 'shortly', |
624 | - ) ); |
|
624 | + )); |
|
625 | 625 | } else { |
626 | - Give()->notices->register_notice( array( |
|
626 | + Give()->notices->register_notice(array( |
|
627 | 627 | 'id' => "give-expires-subscription-{$subscription['id']}", |
628 | 628 | 'type' => 'error', |
629 | 629 | 'description' => sprintf( |
630 | - __( 'Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give' ), |
|
631 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
|
632 | - urldecode( $subscription['invoice_url'] ), |
|
630 | + __('Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give'), |
|
631 | + human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])), |
|
632 | + urldecode($subscription['invoice_url']), |
|
633 | 633 | $subscription['payment_id'], |
634 | 634 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
635 | - Give()->notices->get_dismiss_link( array( |
|
636 | - 'title' => __( 'Click here if already renewed', 'give' ), |
|
635 | + Give()->notices->get_dismiss_link(array( |
|
636 | + 'title' => __('Click here if already renewed', 'give'), |
|
637 | 637 | 'dismissible_type' => 'user', |
638 | 638 | 'dismiss_interval' => 'permanent', |
639 | - ) ) |
|
639 | + )) |
|
640 | 640 | ), |
641 | 641 | 'dismissible_type' => 'user', |
642 | 642 | 'dismiss_interval' => 'shortly', |
643 | - ) ); |
|
643 | + )); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | // Stop validation for these license keys. |
647 | - $addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] ); |
|
647 | + $addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']); |
|
648 | 648 | }// End foreach(). |
649 | 649 | $showed_subscriptions_message = true; |
650 | 650 | }// End if(). |
651 | 651 | |
652 | 652 | // Show Non Subscription Give Add-on messages. |
653 | 653 | if ( |
654 | - ! in_array( $this->license, $addon_license_key_in_subscriptions ) |
|
655 | - && ! empty( $this->license ) |
|
656 | - && empty( $showed_invalid_message ) |
|
654 | + ! in_array($this->license, $addon_license_key_in_subscriptions) |
|
655 | + && ! empty($this->license) |
|
656 | + && empty($showed_invalid_message) |
|
657 | 657 | && ! $this->is_valid_license() |
658 | 658 | ) { |
659 | 659 | |
660 | - Give()->notices->register_notice( array( |
|
660 | + Give()->notices->register_notice(array( |
|
661 | 661 | 'id' => 'give-invalid-license', |
662 | 662 | 'type' => 'error', |
663 | 663 | 'description' => sprintf( |
664 | - __( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
665 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
664 | + __('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
665 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
666 | 666 | ), |
667 | 667 | 'dismissible_type' => 'user', |
668 | 668 | 'dismiss_interval' => 'shortly', |
669 | - ) ); |
|
669 | + )); |
|
670 | 670 | |
671 | 671 | $showed_invalid_message = true; |
672 | 672 | |
@@ -683,10 +683,10 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @return bool |
685 | 685 | */ |
686 | - public function is_valid_license( $licence_data = null ) { |
|
687 | - $license_data = empty( $licence_data ) ? $this->license_data : $licence_data; |
|
686 | + public function is_valid_license($licence_data = null) { |
|
687 | + $license_data = empty($licence_data) ? $this->license_data : $licence_data; |
|
688 | 688 | |
689 | - if ( apply_filters( 'give_is_valid_license', ( $this->is_license( $license_data ) && 'valid' === $license_data->license ) ) ) { |
|
689 | + if (apply_filters('give_is_valid_license', ($this->is_license($license_data) && 'valid' === $license_data->license))) { |
|
690 | 690 | return true; |
691 | 691 | } |
692 | 692 | |
@@ -704,10 +704,10 @@ discard block |
||
704 | 704 | * |
705 | 705 | * @return bool |
706 | 706 | */ |
707 | - public function is_license( $licence_data = null ) { |
|
708 | - $license_data = empty( $licence_data ) ? $this->license_data : $licence_data; |
|
707 | + public function is_license($licence_data = null) { |
|
708 | + $license_data = empty($licence_data) ? $this->license_data : $licence_data; |
|
709 | 709 | |
710 | - if ( apply_filters( 'give_is_license', ( is_object( $license_data ) && ! empty( $license_data ) && property_exists( $license_data, 'license' ) ) ) ) { |
|
710 | + if (apply_filters('give_is_license', (is_object($license_data) && ! empty($license_data) && property_exists($license_data, 'license')))) { |
|
711 | 711 | return true; |
712 | 712 | } |
713 | 713 | |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | * @return bool |
724 | 724 | */ |
725 | 725 | private function __is_third_party_addon() { |
726 | - return ( false === strpos( $this->api_url, 'givewp.com/' ) ); |
|
726 | + return (false === strpos($this->api_url, 'givewp.com/')); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | /** |
@@ -738,25 +738,25 @@ discard block |
||
738 | 738 | * @return bool |
739 | 739 | */ |
740 | 740 | private function __remove_license_key_from_subscriptions() { |
741 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
741 | + $subscriptions = get_option('give_subscriptions', array()); |
|
742 | 742 | |
743 | 743 | // Bailout. |
744 | - if ( empty( $this->license ) ) { |
|
744 | + if (empty($this->license)) { |
|
745 | 745 | return false; |
746 | 746 | } |
747 | 747 | |
748 | - if ( ! empty( $subscriptions ) ) { |
|
749 | - foreach ( $subscriptions as $subscription_id => $subscription ) { |
|
750 | - $license_index = array_search( $this->license, $subscription['licenses'] ); |
|
751 | - if ( false !== $license_index ) { |
|
748 | + if ( ! empty($subscriptions)) { |
|
749 | + foreach ($subscriptions as $subscription_id => $subscription) { |
|
750 | + $license_index = array_search($this->license, $subscription['licenses']); |
|
751 | + if (false !== $license_index) { |
|
752 | 752 | // Remove license key. |
753 | - unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] ); |
|
753 | + unset($subscriptions[$subscription_id]['licenses'][$license_index]); |
|
754 | 754 | |
755 | 755 | // Rearrange license keys. |
756 | - $subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] ); |
|
756 | + $subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']); |
|
757 | 757 | |
758 | 758 | // Update subscription information. |
759 | - update_option( 'give_subscriptions', $subscriptions ); |
|
759 | + update_option('give_subscriptions', $subscriptions); |
|
760 | 760 | break; |
761 | 761 | } |
762 | 762 | } |
@@ -770,17 +770,17 @@ discard block |
||
770 | 770 | * |
771 | 771 | * @return bool |
772 | 772 | */ |
773 | - public function plugin_page_notices( $plugin_file, $plugin_data, $status ) { |
|
773 | + public function plugin_page_notices($plugin_file, $plugin_data, $status) { |
|
774 | 774 | // Bailout. |
775 | - if ( $this->is_valid_license() ) { |
|
775 | + if ($this->is_valid_license()) { |
|
776 | 776 | return false; |
777 | 777 | } |
778 | 778 | |
779 | 779 | $update_notice_wrap = '<tr class="give-addon-notice-tr active"><td colspan="3" class="colspanchange"><div class="notice inline notice-warning notice-alt give-invalid-license"><p><span class="dashicons dashicons-info"></span> %s</p></div></td></tr>'; |
780 | 780 | $message = $this->license_state_message(); |
781 | 781 | |
782 | - if ( ! empty( $message['message'] ) ) { |
|
783 | - echo sprintf( $update_notice_wrap, $message['message'] ); |
|
782 | + if ( ! empty($message['message'])) { |
|
783 | + echo sprintf($update_notice_wrap, $message['message']); |
|
784 | 784 | } |
785 | 785 | } |
786 | 786 | |
@@ -795,11 +795,11 @@ discard block |
||
795 | 795 | public function license_state_message() { |
796 | 796 | $message_data = array(); |
797 | 797 | |
798 | - if ( ! $this->is_valid_license() ) { |
|
798 | + if ( ! $this->is_valid_license()) { |
|
799 | 799 | |
800 | 800 | $message_data['message'] = sprintf( |
801 | 801 | 'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.', |
802 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ), |
|
802 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')), |
|
803 | 803 | $this->item_name |
804 | 804 | ); |
805 | 805 | } |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | // Bailout. |
819 | 819 | if ( |
820 | 820 | ! Give_Admin_Settings::verify_nonce() || |
821 | - ! current_user_can( 'manage_give_settings' ) || |
|
821 | + ! current_user_can('manage_give_settings') || |
|
822 | 822 | 'licenses' !== give_get_current_setting_tab() |
823 | 823 | ) { |
824 | 824 | return false; |
@@ -826,10 +826,10 @@ discard block |
||
826 | 826 | |
827 | 827 | // Security check. |
828 | 828 | if ( |
829 | - isset( $_POST[ $this->item_shortname . '_license_key-nonce' ] ) && |
|
830 | - ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) |
|
829 | + isset($_POST[$this->item_shortname.'_license_key-nonce']) && |
|
830 | + ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce') |
|
831 | 831 | ) { |
832 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
832 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | return true; |
@@ -847,9 +847,9 @@ discard block |
||
847 | 847 | * |
848 | 848 | * @return mixed |
849 | 849 | */ |
850 | - public function get_license_info( $edd_action = '', $response_in_array = false ) { |
|
850 | + public function get_license_info($edd_action = '', $response_in_array = false) { |
|
851 | 851 | |
852 | - if ( empty( $edd_action ) ) { |
|
852 | + if (empty($edd_action)) { |
|
853 | 853 | return false; |
854 | 854 | } |
855 | 855 | |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | $api_params = array( |
858 | 858 | 'edd_action' => $edd_action, // never change from "edd_" to "give_"! |
859 | 859 | 'license' => $this->license, |
860 | - 'item_name' => urlencode( $this->item_name ), |
|
860 | + 'item_name' => urlencode($this->item_name), |
|
861 | 861 | 'url' => home_url(), |
862 | 862 | ); |
863 | 863 | |
@@ -872,11 +872,11 @@ discard block |
||
872 | 872 | ); |
873 | 873 | |
874 | 874 | // Make sure there are no errors. |
875 | - if ( is_wp_error( $response ) ) { |
|
875 | + if (is_wp_error($response)) { |
|
876 | 876 | return false; |
877 | 877 | } |
878 | 878 | |
879 | - return json_decode( wp_remote_retrieve_body( $response ), $response_in_array ); |
|
879 | + return json_decode(wp_remote_retrieve_body($response), $response_in_array); |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | |
@@ -892,9 +892,9 @@ discard block |
||
892 | 892 | $this->__remove_license_key_from_subscriptions(); |
893 | 893 | |
894 | 894 | // Remove license from database. |
895 | - delete_option( "{$this->item_shortname}_license_active" ); |
|
896 | - give_delete_option( "{$this->item_shortname}_license_key" ); |
|
897 | - unset( $_POST["{$this->item_shortname}_license_key"] ); |
|
895 | + delete_option("{$this->item_shortname}_license_active"); |
|
896 | + give_delete_option("{$this->item_shortname}_license_key"); |
|
897 | + unset($_POST["{$this->item_shortname}_license_key"]); |
|
898 | 898 | |
899 | 899 | // Unset license param. |
900 | 900 | $this->license = ''; |
@@ -912,8 +912,8 @@ discard block |
||
912 | 912 | private function is_deactivating_license() { |
913 | 913 | $status = false; |
914 | 914 | |
915 | - foreach ( $_POST as $key => $value ) { |
|
916 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
915 | + foreach ($_POST as $key => $value) { |
|
916 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
917 | 917 | $status = true; |
918 | 918 | break; |
919 | 919 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param $end_date string|bool The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month` |
37 | 37 | * @param $status string|array The sale status(es) to count. Only valid when retrieving global stats |
38 | 38 | * |
39 | - * @return float|int Total amount of donations based on the passed arguments. |
|
39 | + * @return string Total amount of donations based on the passed arguments. |
|
40 | 40 | */ |
41 | 41 | public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
42 | 42 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param $end_date string|bool The end date for which we'd like to filter the donations stats. If false, method will use the default end date of `this_month`. |
84 | 84 | * @param $gateway_id string|bool The gateway to get earnings for such as 'paypal' or 'stripe'. |
85 | 85 | * |
86 | - * @return float|int Total amount of donations based on the passed arguments. |
|
86 | + * @return string Total amount of donations based on the passed arguments. |
|
87 | 87 | */ |
88 | 88 | public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
89 | 89 | $this->setup_dates( $start_date, $end_date ); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param $end_date string|bool The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month` |
169 | 169 | * @param $gateway_id string|bool The gateway to get earnings for such as 'paypal' or 'stripe' |
170 | 170 | * |
171 | - * @return float|int Total amount of donations based on the passed arguments. |
|
171 | + * @return string Total amount of donations based on the passed arguments. |
|
172 | 172 | */ |
173 | 173 | public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
174 | 174 |
@@ -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 | |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return float|int Total amount of donations based on the passed arguments. |
40 | 40 | */ |
41 | - public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
|
41 | + public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') { |
|
42 | 42 | |
43 | - $this->setup_dates( $start_date, $end_date ); |
|
43 | + $this->setup_dates($start_date, $end_date); |
|
44 | 44 | |
45 | 45 | // Make sure start date is valid |
46 | - if ( is_wp_error( $this->start_date ) ) { |
|
46 | + if (is_wp_error($this->start_date)) { |
|
47 | 47 | return $this->start_date; |
48 | 48 | } |
49 | 49 | |
50 | 50 | // Make sure end date is valid |
51 | - if ( is_wp_error( $this->end_date ) ) { |
|
51 | + if (is_wp_error($this->end_date)) { |
|
52 | 52 | return $this->end_date; |
53 | 53 | } |
54 | 54 | |
@@ -57,18 +57,18 @@ discard block |
||
57 | 57 | 'start_date' => $this->start_date, |
58 | 58 | 'end_date' => $this->end_date, |
59 | 59 | 'fields' => 'ids', |
60 | - 'number' => - 1, |
|
60 | + 'number' => -1, |
|
61 | 61 | ); |
62 | 62 | |
63 | - if ( ! empty( $form_id ) ) { |
|
63 | + if ( ! empty($form_id)) { |
|
64 | 64 | $args['give_forms'] = $form_id; |
65 | 65 | } |
66 | 66 | |
67 | 67 | /* @var Give_Payments_Query $payments */ |
68 | - $payments = new Give_Payments_Query( $args ); |
|
68 | + $payments = new Give_Payments_Query($args); |
|
69 | 69 | $payments = $payments->get_payments(); |
70 | 70 | |
71 | - return count( $payments ); |
|
71 | + return count($payments); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -85,16 +85,16 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return float|int Total amount of donations based on the passed arguments. |
87 | 87 | */ |
88 | - public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
89 | - $this->setup_dates( $start_date, $end_date ); |
|
88 | + public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
89 | + $this->setup_dates($start_date, $end_date); |
|
90 | 90 | |
91 | 91 | // Make sure start date is valid |
92 | - if ( is_wp_error( $this->start_date ) ) { |
|
92 | + if (is_wp_error($this->start_date)) { |
|
93 | 93 | return $this->start_date; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Make sure end date is valid |
97 | - if ( is_wp_error( $this->end_date ) ) { |
|
97 | + if (is_wp_error($this->end_date)) { |
|
98 | 98 | return $this->end_date; |
99 | 99 | } |
100 | 100 | |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | 'start_date' => $this->start_date, |
105 | 105 | 'end_date' => $this->end_date, |
106 | 106 | 'fields' => 'ids', |
107 | - 'number' => - 1, |
|
107 | + 'number' => -1, |
|
108 | 108 | ); |
109 | 109 | |
110 | 110 | |
111 | 111 | // Filter by Gateway ID meta_key |
112 | - if ( $gateway_id ) { |
|
112 | + if ($gateway_id) { |
|
113 | 113 | $args['meta_query'][] = array( |
114 | 114 | 'key' => '_give_payment_gateway', |
115 | 115 | 'value' => $gateway_id, |
@@ -117,39 +117,39 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | // Filter by Gateway ID meta_key |
120 | - if ( $form_id ) { |
|
120 | + if ($form_id) { |
|
121 | 121 | $args['meta_query'][] = array( |
122 | 122 | 'key' => '_give_payment_form_id', |
123 | 123 | 'value' => $form_id, |
124 | 124 | ); |
125 | 125 | } |
126 | 126 | |
127 | - if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) { |
|
127 | + if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) { |
|
128 | 128 | $args['meta_query']['relation'] = 'AND'; |
129 | 129 | } |
130 | 130 | |
131 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
132 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
131 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
132 | + $key = Give_Cache::get_key('give_stats', $args); |
|
133 | 133 | |
134 | 134 | // Set transient for faster stats. |
135 | - $earnings = Give_Cache::get( $key ); |
|
135 | + $earnings = Give_Cache::get($key); |
|
136 | 136 | |
137 | - if ( false === $earnings ) { |
|
137 | + if (false === $earnings) { |
|
138 | 138 | |
139 | 139 | $this->timestamp = false; |
140 | - $payments = new Give_Payments_Query( $args ); |
|
140 | + $payments = new Give_Payments_Query($args); |
|
141 | 141 | $payments = $payments->get_payments(); |
142 | 142 | $earnings = 0; |
143 | 143 | |
144 | - if ( ! empty( $payments ) ) { |
|
145 | - foreach ( $payments as $payment ) { |
|
146 | - $earnings += (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) ); |
|
144 | + if ( ! empty($payments)) { |
|
145 | + foreach ($payments as $payment) { |
|
146 | + $earnings += (float) give_donation_amount($payment->ID, array('type' => 'stats')); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Cache the results for one hour. |
152 | - Give_Cache::set( $key, give_sanitize_amount_for_db( $earnings ), 60 * 60 ); |
|
152 | + Give_Cache::set($key, give_sanitize_amount_for_db($earnings), 60 * 60); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | * @param string|bool $end_date Earning end date. |
164 | 164 | * @param string|bool $gateway_id Payment gateway id. |
165 | 165 | */ |
166 | - $earnings = apply_filters( 'give_get_earnings', $earnings, $form_id, $start_date, $end_date, $gateway_id ); |
|
166 | + $earnings = apply_filters('give_get_earnings', $earnings, $form_id, $start_date, $end_date, $gateway_id); |
|
167 | 167 | |
168 | 168 | //return earnings |
169 | - return round( $earnings, give_get_price_decimals( $form_id ) ); |
|
169 | + return round($earnings, give_get_price_decimals($form_id)); |
|
170 | 170 | |
171 | 171 | } |
172 | 172 | |
@@ -183,17 +183,17 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return float|int Total amount of donations based on the passed arguments. |
185 | 185 | */ |
186 | - public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
186 | + public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
187 | 187 | |
188 | - $this->setup_dates( $start_date, $end_date ); |
|
188 | + $this->setup_dates($start_date, $end_date); |
|
189 | 189 | |
190 | 190 | // Make sure start date is valid |
191 | - if ( is_wp_error( $this->start_date ) ) { |
|
191 | + if (is_wp_error($this->start_date)) { |
|
192 | 192 | return $this->start_date; |
193 | 193 | } |
194 | 194 | |
195 | 195 | // Make sure end date is valid |
196 | - if ( is_wp_error( $this->end_date ) ) { |
|
196 | + if (is_wp_error($this->end_date)) { |
|
197 | 197 | return $this->end_date; |
198 | 198 | } |
199 | 199 | |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | 'start_date' => $this->start_date, |
204 | 204 | 'end_date' => $this->end_date, |
205 | 205 | 'fields' => 'ids', |
206 | - 'number' => - 1, |
|
206 | + 'number' => -1, |
|
207 | 207 | ); |
208 | 208 | |
209 | 209 | |
210 | 210 | // Filter by Gateway ID meta_key |
211 | - if ( $gateway_id ) { |
|
211 | + if ($gateway_id) { |
|
212 | 212 | $args['meta_query'][] = array( |
213 | 213 | 'key' => '_give_payment_gateway', |
214 | 214 | 'value' => $gateway_id, |
@@ -216,19 +216,19 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | // Filter by Gateway ID meta_key |
219 | - if ( $form_id ) { |
|
219 | + if ($form_id) { |
|
220 | 220 | $args['meta_query'][] = array( |
221 | 221 | 'key' => '_give_payment_form_id', |
222 | 222 | 'value' => $form_id, |
223 | 223 | ); |
224 | 224 | } |
225 | 225 | |
226 | - if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) { |
|
226 | + if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) { |
|
227 | 227 | $args['meta_query']['relation'] = 'AND'; |
228 | 228 | } |
229 | 229 | |
230 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
231 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
230 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
231 | + $key = Give_Cache::get_key('give_stats', $args); |
|
232 | 232 | |
233 | 233 | //return earnings |
234 | 234 | return $key; |
@@ -246,17 +246,17 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @return array Best selling forms |
248 | 248 | */ |
249 | - public function get_best_selling( $number = 10 ) { |
|
249 | + public function get_best_selling($number = 10) { |
|
250 | 250 | global $wpdb; |
251 | 251 | |
252 | - $meta_table = __give_v20_bc_table_details( 'form' ); |
|
252 | + $meta_table = __give_v20_bc_table_details('form'); |
|
253 | 253 | |
254 | - $give_forms = $wpdb->get_results( $wpdb->prepare( |
|
254 | + $give_forms = $wpdb->get_results($wpdb->prepare( |
|
255 | 255 | "SELECT {$meta_table['column']['id']} as form_id, max(meta_value) as sales |
256 | 256 | FROM {$meta_table['name']} WHERE meta_key='_give_form_sales' AND meta_value > 0 |
257 | 257 | GROUP BY meta_value+0 |
258 | 258 | DESC LIMIT %d;", $number |
259 | - ) ); |
|
259 | + )); |
|
260 | 260 | |
261 | 261 | return $give_forms; |
262 | 262 | } |
@@ -249,10 +249,10 @@ |
||
249 | 249 | $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
250 | 250 | |
251 | 251 | $admin_message .= sprintf( |
252 | - '<a href="%1$s">%2$s</a>', |
|
253 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ), |
|
254 | - __( 'View Donation Details »', 'give' ) |
|
255 | - ) . "\n\n"; |
|
252 | + '<a href="%1$s">%2$s</a>', |
|
253 | + admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ), |
|
254 | + __( 'View Donation Details »', 'give' ) |
|
255 | + ) . "\n\n"; |
|
256 | 256 | |
257 | 257 | $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
258 | 258 | $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | - 'admin_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_attr__('Offline Donation', 'give'), |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | -function give_offline_payment_cc_form( $form_id ) { |
|
43 | +function give_offline_payment_cc_form($form_id) { |
|
44 | 44 | // Get offline payment instruction. |
45 | - $offline_instructions = give_get_offline_payment_instruction( $form_id, true ); |
|
45 | + $offline_instructions = give_get_offline_payment_instruction($form_id, true); |
|
46 | 46 | |
47 | 47 | ob_start(); |
48 | 48 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param int $form_id Give form id. |
55 | 55 | */ |
56 | - do_action( 'give_before_offline_info_fields', $form_id ); |
|
56 | + do_action('give_before_offline_info_fields', $form_id); |
|
57 | 57 | ?> |
58 | 58 | <fieldset id="give_offline_payment_info"> |
59 | - <?php echo stripslashes( $offline_instructions ); ?> |
|
59 | + <?php echo stripslashes($offline_instructions); ?> |
|
60 | 60 | </fieldset> |
61 | 61 | <?php |
62 | 62 | /** |
@@ -66,35 +66,35 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param int $form_id Give form id. |
68 | 68 | */ |
69 | - do_action( 'give_after_offline_info_fields', $form_id ); |
|
69 | + do_action('give_after_offline_info_fields', $form_id); |
|
70 | 70 | |
71 | 71 | echo ob_get_clean(); |
72 | 72 | } |
73 | 73 | |
74 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
74 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Give Offline Billing Field |
78 | 78 | * |
79 | 79 | * @param $form_id |
80 | 80 | */ |
81 | -function give_offline_billing_fields( $form_id ) { |
|
81 | +function give_offline_billing_fields($form_id) { |
|
82 | 82 | //Enable Default CC fields (billing info) |
83 | - $post_offline_cc_fields = give_get_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
84 | - $post_offline_customize_option = give_get_meta( $form_id, '_give_customize_offline_donations', true ); |
|
83 | + $post_offline_cc_fields = give_get_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
84 | + $post_offline_customize_option = give_get_meta($form_id, '_give_customize_offline_donations', true); |
|
85 | 85 | |
86 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
86 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
87 | 87 | |
88 | 88 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
89 | 89 | if ( |
90 | - ( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) ) |
|
91 | - || ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) ) |
|
90 | + (give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields)) |
|
91 | + || (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields)) |
|
92 | 92 | ) { |
93 | - give_default_cc_address_fields( $form_id ); |
|
93 | + give_default_cc_address_fields($form_id); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
97 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Process the payment |
@@ -105,18 +105,18 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return void |
107 | 107 | */ |
108 | -function give_offline_process_payment( $purchase_data ) { |
|
108 | +function give_offline_process_payment($purchase_data) { |
|
109 | 109 | |
110 | 110 | // Setup the payment details. |
111 | 111 | $payment_data = array( |
112 | 112 | 'price' => $purchase_data['price'], |
113 | 113 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
114 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
115 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
114 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
115 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
116 | 116 | 'date' => $purchase_data['date'], |
117 | 117 | 'user_email' => $purchase_data['user_email'], |
118 | 118 | 'purchase_key' => $purchase_data['purchase_key'], |
119 | - 'currency' => give_get_currency( $purchase_data['post_data']['give-form-id'], $purchase_data ), |
|
119 | + 'currency' => give_get_currency($purchase_data['post_data']['give-form-id'], $purchase_data), |
|
120 | 120 | 'user_info' => $purchase_data['user_info'], |
121 | 121 | 'status' => 'pending', |
122 | 122 | 'gateway' => 'offline', |
@@ -124,18 +124,18 @@ discard block |
||
124 | 124 | |
125 | 125 | |
126 | 126 | // record the pending payment |
127 | - $payment = give_insert_payment( $payment_data ); |
|
127 | + $payment = give_insert_payment($payment_data); |
|
128 | 128 | |
129 | - if ( $payment ) { |
|
129 | + if ($payment) { |
|
130 | 130 | give_send_to_success_page(); |
131 | 131 | } else { |
132 | 132 | // if errors are present, send the user back to the donation form so they can be corrected |
133 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
133 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | } |
137 | 137 | |
138 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
138 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
139 | 139 | |
140 | 140 | |
141 | 141 | /** |
@@ -148,59 +148,59 @@ discard block |
||
148 | 148 | * @since 1.0 |
149 | 149 | * @return void |
150 | 150 | */ |
151 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
151 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
152 | 152 | |
153 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
154 | - $post_offline_customization_option = give_get_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
153 | + $payment_data = give_get_payment_meta($payment_id); |
|
154 | + $post_offline_customization_option = give_get_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
155 | 155 | |
156 | 156 | //Customize email content depending on whether the single form has been customized |
157 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
157 | + $email_content = give_get_option('global_offline_donation_email'); |
|
158 | 158 | |
159 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
160 | - $email_content = give_get_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
159 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
160 | + $email_content = give_get_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
161 | 161 | } |
162 | 162 | |
163 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
163 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * Filters the from name. |
167 | 167 | * |
168 | 168 | * @since 1.7 |
169 | 169 | */ |
170 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
170 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
171 | 171 | |
172 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
172 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
173 | 173 | |
174 | 174 | /** |
175 | 175 | * Filters the from email. |
176 | 176 | * |
177 | 177 | * @since 1.7 |
178 | 178 | */ |
179 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
179 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
180 | 180 | |
181 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
181 | + $to_email = give_get_payment_user_email($payment_id); |
|
182 | 182 | |
183 | - $subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) ); |
|
184 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
185 | - $subject = give_get_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
183 | + $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); |
|
184 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
185 | + $subject = give_get_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
186 | 186 | } |
187 | 187 | |
188 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
189 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
188 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
189 | + $subject = give_do_email_tags($subject, $payment_id); |
|
190 | 190 | |
191 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
192 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
191 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
192 | + $message = give_do_email_tags($email_content, $payment_id); |
|
193 | 193 | |
194 | 194 | $emails = Give()->emails; |
195 | 195 | |
196 | - $emails->__set( 'from_name', $from_name ); |
|
197 | - $emails->__set( 'from_email', $from_email ); |
|
198 | - $emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) ); |
|
196 | + $emails->__set('from_name', $from_name); |
|
197 | + $emails->__set('from_email', $from_email); |
|
198 | + $emails->__set('heading', __('Offline Donation Instructions', 'give')); |
|
199 | 199 | |
200 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
201 | - $emails->__set( 'headers', $headers ); |
|
200 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
201 | + $emails->__set('headers', $headers); |
|
202 | 202 | |
203 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
203 | + $emails->send($to_email, $subject, $message, $attachments); |
|
204 | 204 | |
205 | 205 | } |
206 | 206 | |
@@ -217,54 +217,54 @@ discard block |
||
217 | 217 | * @return void |
218 | 218 | * |
219 | 219 | */ |
220 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
220 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
221 | 221 | |
222 | 222 | /* Send an email notification to the admin */ |
223 | 223 | $admin_email = give_get_admin_notice_emails(); |
224 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
224 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
225 | 225 | |
226 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
227 | - $user_data = get_userdata( $user_info['id'] ); |
|
226 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
227 | + $user_data = get_userdata($user_info['id']); |
|
228 | 228 | $name = $user_data->display_name; |
229 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
230 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
229 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
230 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
231 | 231 | } else { |
232 | 232 | $name = $user_info['email']; |
233 | 233 | } |
234 | 234 | |
235 | - $amount = give_donation_amount( $payment_id ); |
|
235 | + $amount = give_donation_amount($payment_id); |
|
236 | 236 | |
237 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id ); |
|
237 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id); |
|
238 | 238 | |
239 | - $admin_message = __( 'Dear Admin,', 'give' ) . "\n\n"; |
|
240 | - $admin_message .= sprintf(__( 'A new offline donation has been made on your website for %s.', 'give' ), $amount) . "\n\n"; |
|
241 | - $admin_message .= __( 'The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
239 | + $admin_message = __('Dear Admin,', 'give')."\n\n"; |
|
240 | + $admin_message .= sprintf(__('A new offline donation has been made on your website for %s.', 'give'), $amount)."\n\n"; |
|
241 | + $admin_message .= __('The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
242 | 242 | |
243 | 243 | |
244 | - $admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
245 | - $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
|
244 | + $admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
245 | + $admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n"; |
|
246 | 246 | |
247 | 247 | $admin_message .= sprintf( |
248 | 248 | '<a href="%1$s">%2$s</a>', |
249 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ), |
|
250 | - __( 'View Donation Details »', 'give' ) |
|
251 | - ) . "\n\n"; |
|
249 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment_id), |
|
250 | + __('View Donation Details »', 'give') |
|
251 | + )."\n\n"; |
|
252 | 252 | |
253 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
254 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
253 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
254 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
255 | 255 | |
256 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
257 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
256 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
257 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
258 | 258 | |
259 | 259 | //Send Email |
260 | 260 | $emails = Give()->emails; |
261 | - $emails->__set( 'heading', __( 'New Offline Donation', 'give' ) ); |
|
261 | + $emails->__set('heading', __('New Offline Donation', 'give')); |
|
262 | 262 | |
263 | - if ( ! empty( $admin_headers ) ) { |
|
264 | - $emails->__set( 'headers', $admin_headers ); |
|
263 | + if ( ! empty($admin_headers)) { |
|
264 | + $emails->__set('headers', $admin_headers); |
|
265 | 265 | } |
266 | 266 | |
267 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
267 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
268 | 268 | |
269 | 269 | } |
270 | 270 | |
@@ -277,20 +277,20 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return array |
279 | 279 | */ |
280 | -function give_offline_add_settings( $settings ) { |
|
280 | +function give_offline_add_settings($settings) { |
|
281 | 281 | |
282 | 282 | // Bailout: Do not show offline gateways setting in to metabox if its disabled globally. |
283 | - if ( in_array( 'offline', (array) give_get_option( 'gateways' ) ) ) { |
|
283 | + if (in_array('offline', (array) give_get_option('gateways'))) { |
|
284 | 284 | return $settings; |
285 | 285 | } |
286 | 286 | |
287 | 287 | //Vars |
288 | 288 | $prefix = '_give_'; |
289 | 289 | |
290 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
290 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
291 | 291 | |
292 | 292 | //this gateway isn't active |
293 | - if ( ! $is_gateway_active ) { |
|
293 | + if ( ! $is_gateway_active) { |
|
294 | 294 | //return settings and bounce |
295 | 295 | return $settings; |
296 | 296 | } |
@@ -299,34 +299,34 @@ discard block |
||
299 | 299 | $check_settings = array( |
300 | 300 | |
301 | 301 | array( |
302 | - 'name' => __( 'Offline Donations', 'give' ), |
|
303 | - 'desc' => __( 'Do you want to customize the donation instructions for this form?', 'give' ), |
|
304 | - 'id' => $prefix . 'customize_offline_donations', |
|
302 | + 'name' => __('Offline Donations', 'give'), |
|
303 | + 'desc' => __('Do you want to customize the donation instructions for this form?', 'give'), |
|
304 | + 'id' => $prefix.'customize_offline_donations', |
|
305 | 305 | 'type' => 'radio_inline', |
306 | 306 | 'default' => 'global', |
307 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
308 | - 'global' => __( 'Global Option', 'give' ), |
|
309 | - 'enabled' => __( 'Customize', 'give' ), |
|
310 | - 'disabled' => __( 'Disable', 'give' ), |
|
307 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
308 | + 'global' => __('Global Option', 'give'), |
|
309 | + 'enabled' => __('Customize', 'give'), |
|
310 | + 'disabled' => __('Disable', 'give'), |
|
311 | 311 | ) |
312 | 312 | ), |
313 | 313 | ), |
314 | 314 | array( |
315 | - 'name' => __( 'Billing Fields', 'give' ), |
|
316 | - 'desc' => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
317 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
315 | + 'name' => __('Billing Fields', 'give'), |
|
316 | + 'desc' => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
317 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
318 | 318 | 'row_classes' => 'give-subfield give-hidden', |
319 | 319 | 'type' => 'radio_inline', |
320 | 320 | 'default' => 'disabled', |
321 | 321 | 'options' => array( |
322 | - 'enabled' => __( 'Enabled', 'give' ), |
|
323 | - 'disabled' => __( 'Disabled', 'give' ), |
|
322 | + 'enabled' => __('Enabled', 'give'), |
|
323 | + 'disabled' => __('Disabled', 'give'), |
|
324 | 324 | ), |
325 | 325 | ), |
326 | 326 | array( |
327 | - 'id' => $prefix . 'offline_checkout_notes', |
|
328 | - 'name' => __( 'Donation Instructions', 'give' ), |
|
329 | - 'desc' => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
327 | + 'id' => $prefix.'offline_checkout_notes', |
|
328 | + 'name' => __('Donation Instructions', 'give'), |
|
329 | + 'desc' => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
330 | 330 | 'default' => give_get_default_offline_donation_content(), |
331 | 331 | 'type' => 'wysiwyg', |
332 | 332 | 'row_classes' => 'give-subfield give-hidden', |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | 'name' => 'offline_docs', |
339 | 339 | 'type' => 'docs_link', |
340 | 340 | 'url' => 'http://docs.givewp.com/settings-gateway-offline-donations', |
341 | - 'title' => __( 'Offline Donations', 'give' ), |
|
341 | + 'title' => __('Offline Donations', 'give'), |
|
342 | 342 | ), |
343 | 343 | ); |
344 | 344 | |
345 | - return array_merge( $settings, $check_settings ); |
|
345 | + return array_merge($settings, $check_settings); |
|
346 | 346 | } |
347 | 347 | |
348 | -add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' ); |
|
348 | +add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings'); |
|
349 | 349 | |
350 | 350 | |
351 | 351 | /** |
@@ -357,32 +357,32 @@ discard block |
||
357 | 357 | */ |
358 | 358 | function give_get_default_offline_donation_content() { |
359 | 359 | |
360 | - $sitename = get_bloginfo( 'sitename' ); |
|
360 | + $sitename = get_bloginfo('sitename'); |
|
361 | 361 | |
362 | - $default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
362 | + $default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
363 | 363 | $default_text .= '<ol>'; |
364 | 364 | $default_text .= '<li>'; |
365 | 365 | $default_text .= sprintf( |
366 | 366 | /* translators: %s: site name */ |
367 | - __( 'Make a check payable to "%s"', 'give' ), |
|
367 | + __('Make a check payable to "%s"', 'give'), |
|
368 | 368 | $sitename |
369 | 369 | ); |
370 | 370 | $default_text .= '</li>'; |
371 | 371 | $default_text .= '<li>'; |
372 | 372 | $default_text .= sprintf( |
373 | 373 | /* translators: %s: site name */ |
374 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
374 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
375 | 375 | $sitename |
376 | 376 | ); |
377 | 377 | $default_text .= '</li>'; |
378 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
378 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
379 | 379 | $default_text .= '</ol>'; |
380 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
380 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
381 | 381 | $default_text .= ' <em>111 Not A Real St.</em><br>'; |
382 | 382 | $default_text .= ' <em>Anytown, CA 12345 </em><br>'; |
383 | - $default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
383 | + $default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
384 | 384 | |
385 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
385 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
386 | 386 | |
387 | 387 | } |
388 | 388 | |
@@ -395,34 +395,34 @@ discard block |
||
395 | 395 | */ |
396 | 396 | function give_get_default_offline_donation_email_content() { |
397 | 397 | |
398 | - $sitename = get_bloginfo( 'sitename' ); |
|
399 | - $default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>'; |
|
400 | - $default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
398 | + $sitename = get_bloginfo('sitename'); |
|
399 | + $default_text = '<p>'.__('Dear {name},', 'give').'</p>'; |
|
400 | + $default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
401 | 401 | $default_text .= '<ol>'; |
402 | 402 | $default_text .= '<li>'; |
403 | 403 | $default_text .= sprintf( |
404 | 404 | /* translators: %s: site name */ |
405 | - __( 'Make a check payable to "%s"', 'give' ), |
|
405 | + __('Make a check payable to "%s"', 'give'), |
|
406 | 406 | $sitename |
407 | 407 | ); |
408 | 408 | $default_text .= '</li>'; |
409 | 409 | $default_text .= '<li>'; |
410 | 410 | $default_text .= sprintf( |
411 | 411 | /* translators: %s: site name */ |
412 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
412 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
413 | 413 | $sitename |
414 | 414 | ); |
415 | 415 | $default_text .= '</li>'; |
416 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
416 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
417 | 417 | $default_text .= '</ol>'; |
418 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
418 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
419 | 419 | $default_text .= ' <em>111 Not A Real St.</em><br>'; |
420 | 420 | $default_text .= ' <em>Anytown, CA 12345 </em><br>'; |
421 | - $default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
422 | - $default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>'; |
|
423 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
421 | + $default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
422 | + $default_text .= '<p>'.__('Sincerely,', 'give').'</p>'; |
|
423 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
424 | 424 | |
425 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
425 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
426 | 426 | |
427 | 427 | } |
428 | 428 | |
@@ -436,17 +436,17 @@ discard block |
||
436 | 436 | * |
437 | 437 | * @return string |
438 | 438 | */ |
439 | -function give_offline_donation_receipt_status_notice( $notice, $id ) { |
|
440 | - $payment = new Give_Payment( $id ); |
|
439 | +function give_offline_donation_receipt_status_notice($notice, $id) { |
|
440 | + $payment = new Give_Payment($id); |
|
441 | 441 | |
442 | - if ( 'offline' !== $payment->gateway || $payment->is_completed() ) { |
|
442 | + if ('offline' !== $payment->gateway || $payment->is_completed()) { |
|
443 | 443 | return $notice; |
444 | 444 | } |
445 | 445 | |
446 | - return Give()->notices->print_frontend_notice( __( 'Payment Pending: Please follow the instructions below to complete your donation.', 'give' ), false, 'warning' ); |
|
446 | + return Give()->notices->print_frontend_notice(__('Payment Pending: Please follow the instructions below to complete your donation.', 'give'), false, 'warning'); |
|
447 | 447 | } |
448 | 448 | |
449 | -add_filter( 'give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2 ); |
|
449 | +add_filter('give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2); |
|
450 | 450 | |
451 | 451 | /** |
452 | 452 | * Get offline payment instructions. |
@@ -458,27 +458,27 @@ discard block |
||
458 | 458 | * |
459 | 459 | * @return string |
460 | 460 | */ |
461 | -function give_get_offline_payment_instruction( $form_id, $wpautop = false ) { |
|
461 | +function give_get_offline_payment_instruction($form_id, $wpautop = false) { |
|
462 | 462 | // Bailout. |
463 | - if ( ! $form_id ) { |
|
463 | + if ( ! $form_id) { |
|
464 | 464 | return ''; |
465 | 465 | } |
466 | 466 | |
467 | - $post_offline_customization_option = give_get_meta( $form_id, '_give_customize_offline_donations', true ); |
|
468 | - $post_offline_instructions = give_get_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
469 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
467 | + $post_offline_customization_option = give_get_meta($form_id, '_give_customize_offline_donations', true); |
|
468 | + $post_offline_instructions = give_get_meta($form_id, '_give_offline_checkout_notes', true); |
|
469 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
470 | 470 | $offline_instructions = $global_offline_instruction; |
471 | 471 | |
472 | - if ( give_is_setting_enabled( $post_offline_customization_option ) ) { |
|
472 | + if (give_is_setting_enabled($post_offline_customization_option)) { |
|
473 | 473 | $offline_instructions = $post_offline_instructions; |
474 | 474 | } |
475 | 475 | |
476 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
476 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
477 | 477 | |
478 | 478 | /* translators: %s: form settings url */ |
479 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
479 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
480 | 480 | |
481 | - return ( $wpautop ? wpautop( $offline_instructions ) : $offline_instructions ); |
|
481 | + return ($wpautop ? wpautop($offline_instructions) : $offline_instructions); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | |
@@ -492,21 +492,21 @@ discard block |
||
492 | 492 | * |
493 | 493 | * @return array |
494 | 494 | */ |
495 | -function give_filter_offline_gateway( $gateway_list, $form_id ) { |
|
495 | +function give_filter_offline_gateway($gateway_list, $form_id) { |
|
496 | 496 | if ( |
497 | 497 | // Show offline payment gateway if enable for new donation form. |
498 | - ( false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) |
|
498 | + (false === strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms')) |
|
499 | 499 | && $form_id |
500 | - && ! give_is_setting_enabled( give_get_meta( $form_id, '_give_customize_offline_donations', true ), array( 'enabled', 'global' ) ) |
|
500 | + && ! give_is_setting_enabled(give_get_meta($form_id, '_give_customize_offline_donations', true), array('enabled', 'global')) |
|
501 | 501 | ) { |
502 | - unset( $gateway_list['offline'] ); |
|
502 | + unset($gateway_list['offline']); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | // Output. |
506 | 506 | return $gateway_list; |
507 | 507 | } |
508 | 508 | |
509 | -add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 ); |
|
509 | +add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2); |
|
510 | 510 | |
511 | 511 | /** |
512 | 512 | * Set default gateway to global default payment gateway |
@@ -520,13 +520,13 @@ discard block |
||
520 | 520 | * |
521 | 521 | * @return void |
522 | 522 | */ |
523 | -function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) { |
|
523 | +function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) { |
|
524 | 524 | if ( |
525 | - ! give_is_setting_enabled( $meta_value, array( 'global', 'enabled' ) ) |
|
526 | - && ( 'offline' === give_get_meta( $postid, '_give_default_gateway', true ) ) |
|
525 | + ! give_is_setting_enabled($meta_value, array('global', 'enabled')) |
|
526 | + && ('offline' === give_get_meta($postid, '_give_default_gateway', true)) |
|
527 | 527 | ) { |
528 | - give_update_meta( $postid, '_give_default_gateway', 'global' ); |
|
528 | + give_update_meta($postid, '_give_default_gateway', 'global'); |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 | |
532 | -add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 ); |
|
532 | +add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3); |
@@ -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 | |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_ajax_export() { |
27 | 27 | |
28 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export.php'; |
|
28 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export.php'; |
|
29 | 29 | |
30 | - parse_str( $_POST['form'], $form ); |
|
30 | + parse_str($_POST['form'], $form); |
|
31 | 31 | |
32 | 32 | $_REQUEST = $form = (array) $form; |
33 | 33 | |
34 | - if ( ! wp_verify_nonce( $_REQUEST['give_ajax_export'], 'give_ajax_export' ) ) { |
|
35 | - die( '-2' ); |
|
34 | + if ( ! wp_verify_nonce($_REQUEST['give_ajax_export'], 'give_ajax_export')) { |
|
35 | + die('-2'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -42,28 +42,28 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param string $class Export class. |
44 | 44 | */ |
45 | - do_action( 'give_batch_export_class_include', $form['give-export-class'] ); |
|
45 | + do_action('give_batch_export_class_include', $form['give-export-class']); |
|
46 | 46 | |
47 | - $step = absint( $_POST['step'] ); |
|
48 | - $class = sanitize_text_field( $form['give-export-class'] ); |
|
47 | + $step = absint($_POST['step']); |
|
48 | + $class = sanitize_text_field($form['give-export-class']); |
|
49 | 49 | |
50 | 50 | /* @var Give_Batch_Export $export */ |
51 | - $export = new $class( $step ); |
|
51 | + $export = new $class($step); |
|
52 | 52 | |
53 | - if ( ! $export->can_export() ) { |
|
54 | - die( '-1' ); |
|
53 | + if ( ! $export->can_export()) { |
|
54 | + die('-1'); |
|
55 | 55 | } |
56 | 56 | |
57 | - if ( ! $export->is_writable ) { |
|
57 | + if ( ! $export->is_writable) { |
|
58 | 58 | $json_args = array( |
59 | 59 | 'error' => true, |
60 | - 'message' => esc_html__( 'Export location or file not writable.', 'give' ) |
|
60 | + 'message' => esc_html__('Export location or file not writable.', 'give') |
|
61 | 61 | ); |
62 | 62 | echo json_encode($json_args); |
63 | 63 | exit; |
64 | 64 | } |
65 | 65 | |
66 | - $export->set_properties( give_clean( $_REQUEST ) ); |
|
66 | + $export->set_properties(give_clean($_REQUEST)); |
|
67 | 67 | |
68 | 68 | $export->pre_fetch(); |
69 | 69 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | $percentage = $export->get_percentage_complete(); |
73 | 73 | |
74 | - if ( $ret ) { |
|
74 | + if ($ret) { |
|
75 | 75 | |
76 | 76 | $step += 1; |
77 | 77 | $json_data = array( |
@@ -79,18 +79,17 @@ discard block |
||
79 | 79 | 'percentage' => $percentage |
80 | 80 | ); |
81 | 81 | |
82 | - } elseif ( true === $export->is_empty ) { |
|
82 | + } elseif (true === $export->is_empty) { |
|
83 | 83 | |
84 | 84 | $json_data = array( |
85 | 85 | 'error' => true, |
86 | - 'message' => esc_html__( 'No data found for export parameters.', 'give' ) |
|
86 | + 'message' => esc_html__('No data found for export parameters.', 'give') |
|
87 | 87 | ); |
88 | 88 | |
89 | - } elseif ( true === $export->done && true === $export->is_void ) { |
|
89 | + } elseif (true === $export->done && true === $export->is_void) { |
|
90 | 90 | |
91 | - $message = ! empty( $export->message ) ? |
|
92 | - $export->message : |
|
93 | - esc_html__( 'Batch Processing Complete', 'give' ); |
|
91 | + $message = ! empty($export->message) ? |
|
92 | + $export->message : esc_html__('Batch Processing Complete', 'give'); |
|
94 | 93 | |
95 | 94 | $json_data = array( |
96 | 95 | 'success' => true, |
@@ -99,23 +98,23 @@ discard block |
||
99 | 98 | |
100 | 99 | } else { |
101 | 100 | |
102 | - $args = array_merge( $_REQUEST, array( |
|
101 | + $args = array_merge($_REQUEST, array( |
|
103 | 102 | 'step' => $step, |
104 | 103 | 'class' => $class, |
105 | - 'nonce' => wp_create_nonce( 'give-batch-export' ), |
|
104 | + 'nonce' => wp_create_nonce('give-batch-export'), |
|
106 | 105 | 'give_action' => 'form_batch_export', |
107 | - ) ); |
|
106 | + )); |
|
108 | 107 | |
109 | 108 | $json_data = array( |
110 | 109 | 'step' => 'done', |
111 | - 'url' => add_query_arg( $args, admin_url() ) |
|
110 | + 'url' => add_query_arg($args, admin_url()) |
|
112 | 111 | ); |
113 | 112 | |
114 | 113 | } |
115 | 114 | |
116 | - $export->unset_properties( give_clean( $_REQUEST ), $export ); |
|
117 | - echo json_encode( $json_data ); |
|
115 | + $export->unset_properties(give_clean($_REQUEST), $export); |
|
116 | + echo json_encode($json_data); |
|
118 | 117 | exit; |
119 | 118 | } |
120 | 119 | |
121 | -add_action( 'wp_ajax_give_do_ajax_export', 'give_do_ajax_export' ); |
|
120 | +add_action('wp_ajax_give_do_ajax_export', 'give_do_ajax_export'); |
@@ -245,7 +245,7 @@ |
||
245 | 245 | |
246 | 246 | // Continue if donor already included. |
247 | 247 | if ( empty( $payment->customer_id ) || |
248 | - in_array( $payment->customer_id, $cached_donor_ids ) |
|
248 | + in_array( $payment->customer_id, $cached_donor_ids ) |
|
249 | 249 | ) { |
250 | 250 | continue; |
251 | 251 | } |
@@ -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 | |
@@ -70,23 +70,23 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @param array $request The Form Data passed into the batch processing |
72 | 72 | */ |
73 | - public function set_properties( $request ) { |
|
73 | + public function set_properties($request) { |
|
74 | 74 | |
75 | 75 | // Set data from form submission |
76 | - if ( isset( $_POST['form'] ) ) { |
|
77 | - parse_str( $_POST['form'], $this->data ); |
|
76 | + if (isset($_POST['form'])) { |
|
77 | + parse_str($_POST['form'], $this->data); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $this->form = $this->data['forms']; |
81 | 81 | |
82 | 82 | // Setup donor ids cache. |
83 | - if ( ! empty( $this->form ) ) { |
|
83 | + if ( ! empty($this->form)) { |
|
84 | 84 | // Cache donor ids to output unique list of donor. |
85 | - $this->query_id = give_clean( $_REQUEST['give_export_option']['query_id'] ); |
|
85 | + $this->query_id = give_clean($_REQUEST['give_export_option']['query_id']); |
|
86 | 86 | $this->cache_donor_ids(); |
87 | 87 | } |
88 | 88 | |
89 | - $this->price_id = ! empty( $request['give_price_option'] ) && 'all' !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null; |
|
89 | + $this->price_id = ! empty($request['give_price_option']) && 'all' !== $request['give_price_option'] ? absint($request['give_price_option']) : null; |
|
90 | 90 | |
91 | 91 | } |
92 | 92 | |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | // Fetch already cached donor ids. |
102 | 102 | $donor_ids = $this->donor_ids; |
103 | 103 | |
104 | - if ( $cached_donor_ids = Give_Cache::get( $this->query_id, true ) ) { |
|
105 | - $donor_ids = array_unique( array_merge( $cached_donor_ids, $this->donor_ids ) ); |
|
104 | + if ($cached_donor_ids = Give_Cache::get($this->query_id, true)) { |
|
105 | + $donor_ids = array_unique(array_merge($cached_donor_ids, $this->donor_ids)); |
|
106 | 106 | } |
107 | 107 | |
108 | - $donor_ids = array_values( $donor_ids ); |
|
109 | - Give_Cache::set( $this->query_id, $donor_ids, HOUR_IN_SECONDS, true ); |
|
108 | + $donor_ids = array_values($donor_ids); |
|
109 | + Give_Cache::set($this->query_id, $donor_ids, HOUR_IN_SECONDS, true); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function csv_cols() { |
120 | 120 | |
121 | - $columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array(); |
|
121 | + $columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array(); |
|
122 | 122 | |
123 | 123 | // We need columns. |
124 | - if ( empty( $columns ) ) { |
|
124 | + if (empty($columns)) { |
|
125 | 125 | return false; |
126 | 126 | } |
127 | 127 | |
128 | - $cols = $this->get_cols( $columns ); |
|
128 | + $cols = $this->get_cols($columns); |
|
129 | 129 | |
130 | 130 | return $cols; |
131 | 131 | } |
@@ -137,41 +137,41 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return array |
139 | 139 | */ |
140 | - private function get_cols( $columns ) { |
|
140 | + private function get_cols($columns) { |
|
141 | 141 | |
142 | 142 | $cols = array(); |
143 | 143 | |
144 | - foreach ( $columns as $key => $value ) { |
|
144 | + foreach ($columns as $key => $value) { |
|
145 | 145 | |
146 | - switch ( $key ) { |
|
146 | + switch ($key) { |
|
147 | 147 | case 'full_name' : |
148 | - $cols['full_name'] = esc_html__( 'Full Name', 'give' ); |
|
148 | + $cols['full_name'] = esc_html__('Full Name', 'give'); |
|
149 | 149 | break; |
150 | 150 | case 'email' : |
151 | - $cols['email'] = esc_html__( 'Email Address', 'give' ); |
|
151 | + $cols['email'] = esc_html__('Email Address', 'give'); |
|
152 | 152 | break; |
153 | 153 | case 'address' : |
154 | - $cols['address_line1'] = esc_html__( 'Address', 'give' ); |
|
155 | - $cols['address_line2'] = esc_html__( 'Address 2', 'give' ); |
|
156 | - $cols['address_city'] = esc_html__( 'City', 'give' ); |
|
157 | - $cols['address_state'] = esc_html__( 'State', 'give' ); |
|
158 | - $cols['address_zip'] = esc_html__( 'Zip', 'give' ); |
|
159 | - $cols['address_country'] = esc_html__( 'Country', 'give' ); |
|
154 | + $cols['address_line1'] = esc_html__('Address', 'give'); |
|
155 | + $cols['address_line2'] = esc_html__('Address 2', 'give'); |
|
156 | + $cols['address_city'] = esc_html__('City', 'give'); |
|
157 | + $cols['address_state'] = esc_html__('State', 'give'); |
|
158 | + $cols['address_zip'] = esc_html__('Zip', 'give'); |
|
159 | + $cols['address_country'] = esc_html__('Country', 'give'); |
|
160 | 160 | break; |
161 | 161 | case 'userid' : |
162 | - $cols['userid'] = esc_html__( 'User ID', 'give' ); |
|
162 | + $cols['userid'] = esc_html__('User ID', 'give'); |
|
163 | 163 | break; |
164 | 164 | case 'donation_form' : |
165 | - $cols['donation_form'] = esc_html__( 'Donation Form', 'give' ); |
|
165 | + $cols['donation_form'] = esc_html__('Donation Form', 'give'); |
|
166 | 166 | break; |
167 | 167 | case 'date_first_donated' : |
168 | - $cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' ); |
|
168 | + $cols['date_first_donated'] = esc_html__('First Donation Date', 'give'); |
|
169 | 169 | break; |
170 | 170 | case 'donations' : |
171 | - $cols['donations'] = esc_html__( 'Number of Donations', 'give' ); |
|
171 | + $cols['donations'] = esc_html__('Number of Donations', 'give'); |
|
172 | 172 | break; |
173 | 173 | case 'donation_sum' : |
174 | - $cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' ); |
|
174 | + $cols['donation_sum'] = esc_html__('Sum of Donations', 'give'); |
|
175 | 175 | break; |
176 | 176 | } |
177 | 177 | } |
@@ -192,29 +192,29 @@ discard block |
||
192 | 192 | $i = 0; |
193 | 193 | |
194 | 194 | $data = array(); |
195 | - $cached_donor_ids = Give_Cache::get( $this->query_id, true ); |
|
195 | + $cached_donor_ids = Give_Cache::get($this->query_id, true); |
|
196 | 196 | |
197 | - if ( ! empty( $this->form ) ) { |
|
197 | + if ( ! empty($this->form)) { |
|
198 | 198 | |
199 | 199 | // Export donors for a specific donation form and also within specified timeframe |
200 | 200 | $args = array( |
201 | 201 | 'output' => 'payments', // Use 'posts' to get standard post objects |
202 | - 'post_type' => array( 'give_payment' ), |
|
202 | + 'post_type' => array('give_payment'), |
|
203 | 203 | 'number' => 30, |
204 | 204 | 'paged' => $this->step, |
205 | 205 | 'status' => 'publish', |
206 | 206 | 'meta_key' => '_give_payment_form_id', |
207 | - 'meta_value' => absint( $this->form ), |
|
207 | + 'meta_value' => absint($this->form), |
|
208 | 208 | ); |
209 | 209 | |
210 | 210 | // Check for date option filter |
211 | - if ( ! empty( $this->data['donor_export_start_date'] ) || ! empty( $this->data['donor_export_end_date'] ) ) { |
|
212 | - $args['start_date'] = ! empty( $this->data['donor_export_start_date'] ) ? date( 'Y-n-d 00:00:00', strtotime( $this->data['donor_export_start_date'] ) ) : date( 'Y-n-d 23:59:59', '1970-1-01 00:00:00' ); |
|
213 | - $args['end_date'] = ! empty( $this->data['donor_export_end_date'] ) ? date( 'Y-n-d 23:59:59', strtotime( $this->data['donor_export_end_date'] ) ) : date( 'Y-n-d 23:59:59', current_time( 'timestamp' ) ); |
|
211 | + if ( ! empty($this->data['donor_export_start_date']) || ! empty($this->data['donor_export_end_date'])) { |
|
212 | + $args['start_date'] = ! empty($this->data['donor_export_start_date']) ? date('Y-n-d 00:00:00', strtotime($this->data['donor_export_start_date'])) : date('Y-n-d 23:59:59', '1970-1-01 00:00:00'); |
|
213 | + $args['end_date'] = ! empty($this->data['donor_export_end_date']) ? date('Y-n-d 23:59:59', strtotime($this->data['donor_export_end_date'])) : date('Y-n-d 23:59:59', current_time('timestamp')); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | // Check for price option. |
217 | - if ( null !== $this->price_id ) { |
|
217 | + if (null !== $this->price_id) { |
|
218 | 218 | $args['meta_query'] = array( |
219 | 219 | array( |
220 | 220 | 'key' => '_give_payment_price_id', |
@@ -223,45 +223,43 @@ discard block |
||
223 | 223 | ); |
224 | 224 | } |
225 | 225 | |
226 | - $payments_query = new Give_Payments_Query( $args ); |
|
226 | + $payments_query = new Give_Payments_Query($args); |
|
227 | 227 | $payments = $payments_query->get_payments(); |
228 | 228 | |
229 | - if ( $payments ) { |
|
229 | + if ($payments) { |
|
230 | 230 | /* @var Give_Payment $payment */ |
231 | - foreach ( $payments as $payment ) { |
|
231 | + foreach ($payments as $payment) { |
|
232 | 232 | // Set donation sum. |
233 | - $this->payment_stats[ $payment->customer_id ]['donation_sum'] = isset( $this->payment_stats[ $payment->customer_id ]['donation_sum'] ) ? |
|
234 | - $this->payment_stats[ $payment->customer_id ]['donation_sum'] : |
|
235 | - 0; |
|
236 | - $this->payment_stats[ $payment->customer_id ]['donation_sum'] += $payment->total; |
|
233 | + $this->payment_stats[$payment->customer_id]['donation_sum'] = isset($this->payment_stats[$payment->customer_id]['donation_sum']) ? |
|
234 | + $this->payment_stats[$payment->customer_id]['donation_sum'] : 0; |
|
235 | + $this->payment_stats[$payment->customer_id]['donation_sum'] += $payment->total; |
|
237 | 236 | |
238 | 237 | // Set donation count. |
239 | - $this->payment_stats[ $payment->customer_id ]['donations'] = isset( $this->payment_stats[ $payment->customer_id ]['donations'] ) ? |
|
240 | - ++ $this->payment_stats[ $payment->customer_id ]['donations'] : |
|
241 | - 1; |
|
238 | + $this->payment_stats[$payment->customer_id]['donations'] = isset($this->payment_stats[$payment->customer_id]['donations']) ? |
|
239 | + ++$this->payment_stats[$payment->customer_id]['donations'] : 1; |
|
242 | 240 | |
243 | 241 | // Set donation form name. |
244 | - $this->payment_stats[ $payment->customer_id ]['form_title'] = $payment->form_title; |
|
242 | + $this->payment_stats[$payment->customer_id]['form_title'] = $payment->form_title; |
|
245 | 243 | |
246 | 244 | // Continue if donor already included. |
247 | - if ( empty( $payment->customer_id ) || |
|
248 | - in_array( $payment->customer_id, $cached_donor_ids ) |
|
245 | + if (empty($payment->customer_id) || |
|
246 | + in_array($payment->customer_id, $cached_donor_ids) |
|
249 | 247 | ) { |
250 | 248 | continue; |
251 | 249 | } |
252 | 250 | |
253 | 251 | $this->donor_ids[] = $cached_donor_ids[] = $payment->customer_id; |
254 | 252 | |
255 | - $i ++; |
|
253 | + $i++; |
|
256 | 254 | } |
257 | 255 | |
258 | - if ( ! empty( $this->donor_ids ) ) { |
|
259 | - foreach ( $this->donor_ids as $donor_id ) { |
|
260 | - $donor = Give()->donors->get_donor_by( 'id', $donor_id ); |
|
261 | - $donor->donation_form_title = $this->payment_stats[ $donor_id ]['form_title']; |
|
262 | - $donor->purchase_count = $this->payment_stats[ $donor_id ]['donations']; |
|
263 | - $donor->purchase_value = $this->payment_stats[ $donor_id ]['donation_sum']; |
|
264 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
256 | + if ( ! empty($this->donor_ids)) { |
|
257 | + foreach ($this->donor_ids as $donor_id) { |
|
258 | + $donor = Give()->donors->get_donor_by('id', $donor_id); |
|
259 | + $donor->donation_form_title = $this->payment_stats[$donor_id]['form_title']; |
|
260 | + $donor->purchase_count = $this->payment_stats[$donor_id]['donations']; |
|
261 | + $donor->purchase_value = $this->payment_stats[$donor_id]['donation_sum']; |
|
262 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
265 | 263 | } |
266 | 264 | |
267 | 265 | // Cache donor ids only if admin export donor for specific form. |
@@ -271,7 +269,7 @@ discard block |
||
271 | 269 | } else { |
272 | 270 | |
273 | 271 | // Export all donors. |
274 | - $offset = 30 * ( $this->step - 1 ); |
|
272 | + $offset = 30 * ($this->step - 1); |
|
275 | 273 | |
276 | 274 | $args = array( |
277 | 275 | 'number' => 30, |
@@ -279,31 +277,31 @@ discard block |
||
279 | 277 | ); |
280 | 278 | |
281 | 279 | // Check for date option filter |
282 | - if ( ! empty( $this->data['donor_export_start_date'] ) || ! empty( $this->data['donor_export_end_date'] ) ) { |
|
280 | + if ( ! empty($this->data['donor_export_start_date']) || ! empty($this->data['donor_export_end_date'])) { |
|
283 | 281 | $args['date'] = array( |
284 | - 'start' => ! empty( $this->data['donor_export_start_date'] ) ? date( 'Y-n-d 00:00:00', strtotime( $this->data['donor_export_start_date'] ) ) : date( 'Y-n-d 23:59:59', '1970-1-01 00:00:00' ), |
|
285 | - 'end' => ! empty( $this->data['donor_export_end_date'] ) ? date( 'Y-n-d 23:59:59', strtotime( $this->data['donor_export_end_date'] ) ) : date( 'Y-n-d 23:59:59', current_time( 'timestamp' ) ), |
|
282 | + 'start' => ! empty($this->data['donor_export_start_date']) ? date('Y-n-d 00:00:00', strtotime($this->data['donor_export_start_date'])) : date('Y-n-d 23:59:59', '1970-1-01 00:00:00'), |
|
283 | + 'end' => ! empty($this->data['donor_export_end_date']) ? date('Y-n-d 23:59:59', strtotime($this->data['donor_export_end_date'])) : date('Y-n-d 23:59:59', current_time('timestamp')), |
|
286 | 284 | ); |
287 | 285 | } |
288 | 286 | |
289 | - $donors = Give()->donors->get_donors( $args ); |
|
287 | + $donors = Give()->donors->get_donors($args); |
|
290 | 288 | |
291 | - foreach ( $donors as $donor ) { |
|
289 | + foreach ($donors as $donor) { |
|
292 | 290 | |
293 | 291 | // Continue if donor already included. |
294 | - if ( empty( $donor->id ) || empty( $donor->payment_ids ) ) { |
|
292 | + if (empty($donor->id) || empty($donor->payment_ids)) { |
|
295 | 293 | continue; |
296 | 294 | } |
297 | 295 | |
298 | - $payment = new Give_Payment( $donor->payment_ids ); |
|
296 | + $payment = new Give_Payment($donor->payment_ids); |
|
299 | 297 | $donor->donation_form_title = $payment->form_title; |
300 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
301 | - $i ++; |
|
298 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
299 | + $i++; |
|
302 | 300 | } |
303 | 301 | }// End if(). |
304 | 302 | |
305 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
306 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
303 | + $data = apply_filters('give_export_get_data', $data); |
|
304 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
307 | 305 | |
308 | 306 | return $data; |
309 | 307 | } |
@@ -319,18 +317,18 @@ discard block |
||
319 | 317 | $percentage = 0; |
320 | 318 | |
321 | 319 | // We can't count the number when getting them for a specific form. |
322 | - if ( empty( $this->form ) ) { |
|
320 | + if (empty($this->form)) { |
|
323 | 321 | |
324 | 322 | $total = Give()->donors->count(); |
325 | 323 | |
326 | - if ( $total > 0 ) { |
|
324 | + if ($total > 0) { |
|
327 | 325 | |
328 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
326 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
329 | 327 | |
330 | 328 | } |
331 | 329 | } |
332 | 330 | |
333 | - if ( $percentage > 100 ) { |
|
331 | + if ($percentage > 100) { |
|
334 | 332 | $percentage = 100; |
335 | 333 | } |
336 | 334 | |
@@ -346,51 +344,51 @@ discard block |
||
346 | 344 | * |
347 | 345 | * @return mixed |
348 | 346 | */ |
349 | - private function set_donor_data( $i, $data, $donor ) { |
|
347 | + private function set_donor_data($i, $data, $donor) { |
|
350 | 348 | |
351 | 349 | $columns = $this->csv_cols(); |
352 | 350 | |
353 | 351 | // Set address variable |
354 | 352 | $address = ''; |
355 | - if ( isset( $donor->user_id ) && $donor->user_id > 0 ) { |
|
356 | - $address = give_get_donor_address( $donor->user_id ); |
|
353 | + if (isset($donor->user_id) && $donor->user_id > 0) { |
|
354 | + $address = give_get_donor_address($donor->user_id); |
|
357 | 355 | } |
358 | 356 | |
359 | 357 | // Set columns |
360 | - if ( ! empty( $columns['full_name'] ) ) { |
|
361 | - $data[ $i ]['full_name'] = $donor->name; |
|
358 | + if ( ! empty($columns['full_name'])) { |
|
359 | + $data[$i]['full_name'] = $donor->name; |
|
362 | 360 | } |
363 | - if ( ! empty( $columns['email'] ) ) { |
|
364 | - $data[ $i ]['email'] = $donor->email; |
|
361 | + if ( ! empty($columns['email'])) { |
|
362 | + $data[$i]['email'] = $donor->email; |
|
365 | 363 | } |
366 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
367 | - |
|
368 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
369 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
370 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
371 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
372 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
373 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
364 | + if ( ! empty($columns['address_line1'])) { |
|
365 | + |
|
366 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
367 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
368 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
369 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
370 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
371 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
374 | 372 | } |
375 | - if ( ! empty( $columns['userid'] ) ) { |
|
376 | - $data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : ''; |
|
373 | + if ( ! empty($columns['userid'])) { |
|
374 | + $data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : ''; |
|
377 | 375 | } |
378 | - if ( ! empty( $columns['donation_form'] ) ) { |
|
379 | - $data[ $i ]['donation_form'] = ! empty( $donor->donation_form_title ) ? $donor->donation_form_title : ''; |
|
376 | + if ( ! empty($columns['donation_form'])) { |
|
377 | + $data[$i]['donation_form'] = ! empty($donor->donation_form_title) ? $donor->donation_form_title : ''; |
|
380 | 378 | } |
381 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
382 | - $data[ $i ]['date_first_donated'] = date_i18n( give_date_format(), strtotime( $donor->date_created ) ); |
|
379 | + if ( ! empty($columns['date_first_donated'])) { |
|
380 | + $data[$i]['date_first_donated'] = date_i18n(give_date_format(), strtotime($donor->date_created)); |
|
383 | 381 | } |
384 | - if ( ! empty( $columns['donations'] ) ) { |
|
385 | - $data[ $i ]['donations'] = $donor->purchase_count; |
|
382 | + if ( ! empty($columns['donations'])) { |
|
383 | + $data[$i]['donations'] = $donor->purchase_count; |
|
386 | 384 | } |
387 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
388 | - $data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value, array( 'sanitize' => false ) ); |
|
385 | + if ( ! empty($columns['donation_sum'])) { |
|
386 | + $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value, array('sanitize' => false)); |
|
389 | 387 | } |
390 | 388 | |
391 | - $data[ $i ] = apply_filters( 'give_export_set_donor_data', $data[ $i ], $donor ); |
|
389 | + $data[$i] = apply_filters('give_export_set_donor_data', $data[$i], $donor); |
|
392 | 390 | |
393 | - return $data[ $i ]; |
|
391 | + return $data[$i]; |
|
394 | 392 | |
395 | 393 | } |
396 | 394 | |
@@ -400,9 +398,9 @@ discard block |
||
400 | 398 | * @param array $request |
401 | 399 | * @param Give_Batch_Export $export |
402 | 400 | */ |
403 | - public function unset_properties( $request, $export ) { |
|
404 | - if ( $export->done ) { |
|
405 | - Give_Cache::delete( "give_cache_{$this->query_id}" ); |
|
401 | + public function unset_properties($request, $export) { |
|
402 | + if ($export->done) { |
|
403 | + Give_Cache::delete("give_cache_{$this->query_id}"); |
|
406 | 404 | } |
407 | 405 | } |
408 | 406 | } |
409 | 407 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @param int $_step |
120 | 120 | */ |
121 | - public function __construct( $_step = 1 ) { |
|
121 | + public function __construct($_step = 1) { |
|
122 | 122 | |
123 | 123 | $upload_dir = wp_upload_dir(); |
124 | 124 | $this->filetype = '.csv'; |
125 | - $this->filename = 'give-' . $this->export_type . $this->filetype; |
|
126 | - $this->file = trailingslashit( $upload_dir['basedir'] ) . $this->filename; |
|
125 | + $this->filename = 'give-'.$this->export_type.$this->filetype; |
|
126 | + $this->file = trailingslashit($upload_dir['basedir']).$this->filename; |
|
127 | 127 | |
128 | - if ( ! is_writeable( $upload_dir['basedir'] ) ) { |
|
128 | + if ( ! is_writeable($upload_dir['basedir'])) { |
|
129 | 129 | $this->is_writable = false; |
130 | 130 | } |
131 | 131 | |
@@ -141,22 +141,22 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function process_step() { |
143 | 143 | |
144 | - if ( ! $this->can_export() ) { |
|
145 | - wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
144 | + if ( ! $this->can_export()) { |
|
145 | + wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array( |
|
146 | 146 | 'response' => 403, |
147 | - ) ); |
|
147 | + )); |
|
148 | 148 | } |
149 | 149 | |
150 | - if ( $this->step < 2 ) { |
|
150 | + if ($this->step < 2) { |
|
151 | 151 | |
152 | 152 | // Make sure we start with a fresh file on step 1. |
153 | - @unlink( $this->file ); |
|
153 | + @unlink($this->file); |
|
154 | 154 | $this->print_csv_cols(); |
155 | 155 | } |
156 | 156 | |
157 | 157 | $rows = $this->print_csv_rows(); |
158 | 158 | |
159 | - if ( $rows ) { |
|
159 | + if ($rows) { |
|
160 | 160 | return true; |
161 | 161 | } else { |
162 | 162 | return false; |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | $col_data = ''; |
177 | 177 | $cols = $this->get_csv_cols(); |
178 | 178 | $i = 1; |
179 | - foreach ( $cols as $col_id => $column ) { |
|
180 | - $col_data .= '"' . addslashes( $column ) . '"'; |
|
181 | - $col_data .= $i == count( $cols ) ? '' : ','; |
|
182 | - $i ++; |
|
179 | + foreach ($cols as $col_id => $column) { |
|
180 | + $col_data .= '"'.addslashes($column).'"'; |
|
181 | + $col_data .= $i == count($cols) ? '' : ','; |
|
182 | + $i++; |
|
183 | 183 | } |
184 | 184 | $col_data .= "\r\n"; |
185 | 185 | |
186 | - $this->stash_step_data( $col_data ); |
|
186 | + $this->stash_step_data($col_data); |
|
187 | 187 | |
188 | 188 | return $col_data; |
189 | 189 | |
@@ -202,23 +202,23 @@ discard block |
||
202 | 202 | $data = $this->get_data(); |
203 | 203 | $cols = $this->get_csv_cols(); |
204 | 204 | |
205 | - if ( $data ) { |
|
205 | + if ($data) { |
|
206 | 206 | |
207 | 207 | // Output each row |
208 | - foreach ( $data as $row ) { |
|
208 | + foreach ($data as $row) { |
|
209 | 209 | $i = 1; |
210 | - foreach ( $row as $col_id => $column ) { |
|
210 | + foreach ($row as $col_id => $column) { |
|
211 | 211 | // Make sure the column is valid |
212 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
213 | - $row_data .= '"' . addslashes( preg_replace( '/"/', "'", $column ) ) . '"'; |
|
214 | - $row_data .= $i == count( $cols ) ? '' : ','; |
|
215 | - $i ++; |
|
212 | + if (array_key_exists($col_id, $cols)) { |
|
213 | + $row_data .= '"'.addslashes(preg_replace('/"/', "'", $column)).'"'; |
|
214 | + $row_data .= $i == count($cols) ? '' : ','; |
|
215 | + $i++; |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | $row_data .= "\r\n"; |
219 | 219 | } |
220 | 220 | |
221 | - $this->stash_step_data( $row_data ); |
|
221 | + $this->stash_step_data($row_data); |
|
222 | 222 | |
223 | 223 | return $row_data; |
224 | 224 | } |
@@ -246,18 +246,18 @@ discard block |
||
246 | 246 | |
247 | 247 | $file = ''; |
248 | 248 | |
249 | - if ( @file_exists( $this->file ) ) { |
|
249 | + if (@file_exists($this->file)) { |
|
250 | 250 | |
251 | - if ( ! is_writeable( $this->file ) ) { |
|
251 | + if ( ! is_writeable($this->file)) { |
|
252 | 252 | $this->is_writable = false; |
253 | 253 | } |
254 | 254 | |
255 | - $file = @file_get_contents( $this->file ); |
|
255 | + $file = @file_get_contents($this->file); |
|
256 | 256 | |
257 | 257 | } else { |
258 | 258 | |
259 | - @file_put_contents( $this->file, '' ); |
|
260 | - @chmod( $this->file, 0664 ); |
|
259 | + @file_put_contents($this->file, ''); |
|
260 | + @chmod($this->file, 0664); |
|
261 | 261 | |
262 | 262 | } |
263 | 263 | |
@@ -273,18 +273,18 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return void |
275 | 275 | */ |
276 | - protected function stash_step_data( $data = '' ) { |
|
276 | + protected function stash_step_data($data = '') { |
|
277 | 277 | |
278 | 278 | $file = $this->get_file(); |
279 | 279 | $file .= $data; |
280 | - @file_put_contents( $this->file, $file ); |
|
280 | + @file_put_contents($this->file, $file); |
|
281 | 281 | |
282 | 282 | // If we have no rows after this step, mark it as an empty export. |
283 | - $file_rows = file( $this->file, FILE_SKIP_EMPTY_LINES ); |
|
283 | + $file_rows = file($this->file, FILE_SKIP_EMPTY_LINES); |
|
284 | 284 | $default_cols = $this->get_csv_cols(); |
285 | - $default_cols = empty( $default_cols ) ? 0 : 1; |
|
285 | + $default_cols = empty($default_cols) ? 0 : 1; |
|
286 | 286 | |
287 | - $this->is_empty = count( $file_rows ) == $default_cols ? true : false; |
|
287 | + $this->is_empty = count($file_rows) == $default_cols ? true : false; |
|
288 | 288 | |
289 | 289 | } |
290 | 290 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | $file = $this->get_file(); |
304 | 304 | |
305 | - @unlink( $this->file ); |
|
305 | + @unlink($this->file); |
|
306 | 306 | |
307 | 307 | echo $file; |
308 | 308 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @since 1.8 |
313 | 313 | */ |
314 | - do_action( 'give_file_export_complete', $_REQUEST ); |
|
314 | + do_action('give_file_export_complete', $_REQUEST); |
|
315 | 315 | |
316 | 316 | give_die(); |
317 | 317 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @param array $request The Form Data passed into the batch processing. |
325 | 325 | */ |
326 | - public function set_properties( $request ) { |
|
326 | + public function set_properties($request) { |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @param array $request The Form Data passed into the batch processing. |
335 | 335 | * @param Give_Batch_Export $export |
336 | 336 | */ |
337 | - public function unset_properties( $request, $export ) { |
|
337 | + public function unset_properties($request, $export) { |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
@@ -143,7 +143,7 @@ |
||
143 | 143 | * |
144 | 144 | * @access public |
145 | 145 | * @since 1.0 |
146 | - * @return mixed string If search is present, false otherwise |
|
146 | + * @return string|false string If search is present, false otherwise |
|
147 | 147 | */ |
148 | 148 | public function get_search() { |
149 | 149 | 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 | /** |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | global $status, $page; |
63 | 63 | |
64 | 64 | // Set parent defaults |
65 | - parent::__construct( array( |
|
66 | - 'singular' => esc_html__( 'Donor', 'give' ), // Singular name of the listed records |
|
67 | - 'plural' => esc_html__( 'Donors', 'give' ), // Plural name of the listed records |
|
68 | - 'ajax' => false,// Does this table support ajax? |
|
69 | - ) ); |
|
65 | + parent::__construct(array( |
|
66 | + 'singular' => esc_html__('Donor', 'give'), // Singular name of the listed records |
|
67 | + 'plural' => esc_html__('Donors', 'give'), // Plural name of the listed records |
|
68 | + 'ajax' => false, // Does this table support ajax? |
|
69 | + )); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return false |
85 | 85 | */ |
86 | - public function search_box( $text, $input_id ) { |
|
86 | + public function search_box($text, $input_id) { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | |
@@ -98,20 +98,20 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function give_search_box( $text, $input_id ) { |
|
102 | - $input_id = $input_id . '-search-input'; |
|
101 | + public function give_search_box($text, $input_id) { |
|
102 | + $input_id = $input_id.'-search-input'; |
|
103 | 103 | |
104 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
105 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
104 | + if ( ! empty($_REQUEST['orderby'])) { |
|
105 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
106 | 106 | } |
107 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
108 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
107 | + if ( ! empty($_REQUEST['order'])) { |
|
108 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
109 | 109 | } |
110 | 110 | ?> |
111 | 111 | <p class="search-box donor-search" role="search"> |
112 | 112 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
113 | 113 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
114 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
114 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
115 | 115 | </p> |
116 | 116 | <?php |
117 | 117 | } |
@@ -124,33 +124,33 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param string $which |
126 | 126 | */ |
127 | - protected function display_tablenav( $which ) { |
|
127 | + protected function display_tablenav($which) { |
|
128 | 128 | |
129 | - if ( 'top' === $which ) { |
|
130 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
129 | + if ('top' === $which) { |
|
130 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
131 | 131 | } |
132 | 132 | ?> |
133 | - <div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
133 | + <div class="tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
134 | 134 | |
135 | - <?php if ( 'top' === $which ) { ?> |
|
135 | + <?php if ('top' === $which) { ?> |
|
136 | 136 | <h2 class="alignleft reports-earnings-title"> |
137 | - <?php esc_html_e( 'Donors Report', 'give' ); ?> |
|
137 | + <?php esc_html_e('Donors Report', 'give'); ?> |
|
138 | 138 | </h2> |
139 | 139 | <?php } ?> |
140 | 140 | |
141 | 141 | <div class="alignright tablenav-right"> |
142 | 142 | <div class="actions bulkactions"> |
143 | 143 | <?php |
144 | - if ( 'top' === $which ) { |
|
145 | - $this->give_search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors-report-search' ); |
|
144 | + if ('top' === $which) { |
|
145 | + $this->give_search_box(esc_html__('Search Donors', 'give'), 'give-donors-report-search'); |
|
146 | 146 | } |
147 | 147 | |
148 | - $this->bulk_actions( $which ); ?> |
|
148 | + $this->bulk_actions($which); ?> |
|
149 | 149 | |
150 | 150 | </div> |
151 | 151 | <?php |
152 | - $this->extra_tablenav( $which ); |
|
153 | - $this->pagination( $which ); |
|
152 | + $this->extra_tablenav($which); |
|
153 | + $this->pagination($which); |
|
154 | 154 | ?> |
155 | 155 | </div> |
156 | 156 | |
@@ -172,35 +172,35 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return string Column Name |
174 | 174 | */ |
175 | - public function column_default( $item, $column_name ) { |
|
175 | + public function column_default($item, $column_name) { |
|
176 | 176 | |
177 | - switch ( $column_name ) { |
|
177 | + switch ($column_name) { |
|
178 | 178 | |
179 | 179 | case 'name' : |
180 | - $name = '#' . $item['id'] . ' '; |
|
181 | - $name .= ! empty( $item['name'] ) ? $item['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
182 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] ); |
|
183 | - $value = '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>'; |
|
180 | + $name = '#'.$item['id'].' '; |
|
181 | + $name .= ! empty($item['name']) ? $item['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
182 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']); |
|
183 | + $value = '<a href="'.esc_url($view_url).'">'.$name.'</a>'; |
|
184 | 184 | break; |
185 | 185 | |
186 | 186 | case 'num_donations' : |
187 | 187 | $value = sprintf( |
188 | 188 | '<a href="%s">%s</a>', |
189 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $item['id'] ) ), |
|
190 | - esc_html( $item['num_donations'] ) |
|
189 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($item['id'])), |
|
190 | + esc_html($item['num_donations']) |
|
191 | 191 | ); |
192 | 192 | break; |
193 | 193 | |
194 | 194 | case 'amount_spent' : |
195 | - $value = give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) ); |
|
195 | + $value = give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false))); |
|
196 | 196 | break; |
197 | 197 | |
198 | 198 | default: |
199 | - $value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null; |
|
199 | + $value = isset($item[$column_name]) ? $item[$column_name] : null; |
|
200 | 200 | break; |
201 | 201 | } |
202 | 202 | |
203 | - return apply_filters( "give_report_column_{$column_name}", $value, $item['id'] ); |
|
203 | + return apply_filters("give_report_column_{$column_name}", $value, $item['id']); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function get_columns() { |
214 | 214 | $columns = array( |
215 | - 'name' => __( 'Name', 'give' ), |
|
216 | - 'email' => __( 'Email', 'give' ), |
|
217 | - 'num_donations' => __( 'Donations', 'give' ), |
|
218 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
215 | + 'name' => __('Name', 'give'), |
|
216 | + 'email' => __('Email', 'give'), |
|
217 | + 'num_donations' => __('Donations', 'give'), |
|
218 | + 'amount_spent' => __('Total Donated', 'give'), |
|
219 | 219 | ); |
220 | 220 | |
221 | - return apply_filters( 'give_report_donor_columns', $columns ); |
|
221 | + return apply_filters('give_report_donor_columns', $columns); |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function get_sortable_columns() { |
233 | 233 | return array( |
234 | - 'id' => array( 'id', true ), |
|
235 | - 'name' => array( 'name', true ), |
|
236 | - 'num_donations' => array( 'purchase_count', false ), |
|
237 | - 'amount_spent' => array( 'purchase_value', false ), |
|
234 | + 'id' => array('id', true), |
|
235 | + 'name' => array('name', true), |
|
236 | + 'num_donations' => array('purchase_count', false), |
|
237 | + 'amount_spent' => array('purchase_value', false), |
|
238 | 238 | ); |
239 | 239 | } |
240 | 240 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @since 1.0 |
246 | 246 | * @return void |
247 | 247 | */ |
248 | - public function bulk_actions( $which = '' ) { |
|
248 | + public function bulk_actions($which = '') { |
|
249 | 249 | |
250 | 250 | } |
251 | 251 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return int Current page number |
258 | 258 | */ |
259 | 259 | public function get_paged() { |
260 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
260 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @return mixed string If search is present, false otherwise |
269 | 269 | */ |
270 | 270 | public function get_search() { |
271 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
271 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -287,15 +287,15 @@ discard block |
||
287 | 287 | |
288 | 288 | // Get donor query. |
289 | 289 | $args = $this->get_donor_query(); |
290 | - $donors = Give()->donors->get_donors( $args ); |
|
290 | + $donors = Give()->donors->get_donors($args); |
|
291 | 291 | |
292 | - if ( $donors ) { |
|
292 | + if ($donors) { |
|
293 | 293 | |
294 | - $this->count = count( $donors ); |
|
294 | + $this->count = count($donors); |
|
295 | 295 | |
296 | - foreach ( $donors as $donor ) { |
|
296 | + foreach ($donors as $donor) { |
|
297 | 297 | |
298 | - $user_id = ! empty( $donor->user_id ) ? absint( $donor->user_id ) : 0; |
|
298 | + $user_id = ! empty($donor->user_id) ? absint($donor->user_id) : 0; |
|
299 | 299 | |
300 | 300 | $data[] = array( |
301 | 301 | 'id' => $donor->id, |
@@ -323,9 +323,9 @@ discard block |
||
323 | 323 | |
324 | 324 | $_donor_query['number'] = -1; |
325 | 325 | $_donor_query['offset'] = 0; |
326 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
326 | + $donors = Give()->donors->get_donors($_donor_query); |
|
327 | 327 | |
328 | - return count( $donors ); |
|
328 | + return count($donors); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
@@ -337,10 +337,10 @@ discard block |
||
337 | 337 | */ |
338 | 338 | public function get_donor_query() { |
339 | 339 | $paged = $this->get_paged(); |
340 | - $offset = $this->per_page * ( $paged - 1 ); |
|
340 | + $offset = $this->per_page * ($paged - 1); |
|
341 | 341 | $search = $this->get_search(); |
342 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
343 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
342 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
343 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
344 | 344 | |
345 | 345 | $args = array( |
346 | 346 | 'number' => $this->per_page, |
@@ -349,10 +349,10 @@ discard block |
||
349 | 349 | 'orderby' => $orderby, |
350 | 350 | ); |
351 | 351 | |
352 | - if( $search ) { |
|
353 | - if ( is_email( $search ) ) { |
|
352 | + if ($search) { |
|
353 | + if (is_email($search)) { |
|
354 | 354 | $args['email'] = $search; |
355 | - } elseif ( is_numeric( $search ) ) { |
|
355 | + } elseif (is_numeric($search)) { |
|
356 | 356 | $args['id'] = $search; |
357 | 357 | } else { |
358 | 358 | $args['name'] = $search; |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | $hidden = array(); // No hidden columns |
380 | 380 | $sortable = $this->get_sortable_columns(); |
381 | 381 | |
382 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
382 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
383 | 383 | |
384 | 384 | $this->items = $this->reports_data(); |
385 | 385 | |
386 | 386 | $this->total = $this->get_donor_count(); |
387 | 387 | |
388 | - $this->set_pagination_args( array( |
|
388 | + $this->set_pagination_args(array( |
|
389 | 389 | 'total_items' => $this->total, |
390 | 390 | 'per_page' => $this->per_page, |
391 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
392 | - ) ); |
|
391 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
392 | + )); |
|
393 | 393 | } |
394 | 394 | } |