@@ -33,20 +33,20 @@ discard block |
||
33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $logout_redirect ) ) { |
|
37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
38 | - } |
|
36 | + if ( empty( $logout_redirect ) ) { |
|
37 | + $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - // Add user_logout action to logout url. |
|
42 | - $logout_redirect = add_query_arg( |
|
43 | - array( |
|
44 | - 'give_action' => 'user_logout', |
|
45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
47 | - ), |
|
48 | - home_url('/') |
|
49 | - ); |
|
41 | + // Add user_logout action to logout url. |
|
42 | + $logout_redirect = add_query_arg( |
|
43 | + array( |
|
44 | + 'give_action' => 'user_logout', |
|
45 | + 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
46 | + 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
47 | + ), |
|
48 | + home_url('/') |
|
49 | + ); |
|
50 | 50 | |
51 | 51 | $give_login_redirect = $login_redirect; |
52 | 52 | $give_logout_redirect = $logout_redirect; |
@@ -136,31 +136,31 @@ discard block |
||
136 | 136 | * @return void |
137 | 137 | */ |
138 | 138 | function give_process_user_logout( $data ) { |
139 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
139 | + if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
140 | 140 | |
141 | - // Prevent occurring of any custom action on wp_logout. |
|
142 | - remove_all_actions( 'wp_logout' ); |
|
141 | + // Prevent occurring of any custom action on wp_logout. |
|
142 | + remove_all_actions( 'wp_logout' ); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Fires before processing user logout. |
146 | 146 | * |
147 | 147 | * @since 1.0 |
148 | 148 | */ |
149 | - do_action( 'give_before_user_logout' ); |
|
149 | + do_action( 'give_before_user_logout' ); |
|
150 | 150 | |
151 | - // Logout user. |
|
152 | - wp_logout(); |
|
151 | + // Logout user. |
|
152 | + wp_logout(); |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Fires after processing user logout. |
156 | 156 | * |
157 | 157 | * @since 1.0 |
158 | 158 | */ |
159 | - do_action( 'give_after_user_logout' ); |
|
159 | + do_action( 'give_after_user_logout' ); |
|
160 | 160 | |
161 | - wp_redirect( $data['give_logout_redirect'] ); |
|
162 | - give_die(); |
|
163 | - } |
|
161 | + wp_redirect( $data['give_logout_redirect'] ); |
|
162 | + give_die(); |
|
163 | + } |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | add_action( 'give_user_logout', 'give_process_user_logout' ); |
@@ -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 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return string Login form |
28 | 28 | */ |
29 | -function give_login_form( $login_redirect = '', $logout_redirect = '' ) { |
|
29 | +function give_login_form($login_redirect = '', $logout_redirect = '') { |
|
30 | 30 | global $give_login_redirect, $give_logout_redirect; |
31 | 31 | |
32 | - if ( empty( $login_redirect ) ) { |
|
32 | + if (empty($login_redirect)) { |
|
33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $logout_redirect ) ) { |
|
37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
36 | + if (empty($logout_redirect)) { |
|
37 | + $logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | $logout_redirect = add_query_arg( |
43 | 43 | array( |
44 | 44 | 'give_action' => 'user_logout', |
45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
45 | + 'give_logout_nonce' => wp_create_nonce('give-logout-nonce'), |
|
46 | + 'give_logout_redirect' => urlencode($logout_redirect) |
|
47 | 47 | ), |
48 | 48 | home_url('/') |
49 | 49 | ); |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | |
54 | 54 | ob_start(); |
55 | 55 | |
56 | - give_get_template_part( 'shortcode', 'login' ); |
|
56 | + give_get_template_part('shortcode', 'login'); |
|
57 | 57 | |
58 | - return apply_filters( 'give_login_form', ob_get_clean() ); |
|
58 | + return apply_filters('give_login_form', ob_get_clean()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return string Register form |
70 | 70 | */ |
71 | -function give_register_form( $redirect = '' ) { |
|
71 | +function give_register_form($redirect = '') { |
|
72 | 72 | global $give_register_redirect; |
73 | 73 | |
74 | - if ( empty( $redirect ) ) { |
|
74 | + if (empty($redirect)) { |
|
75 | 75 | $redirect = give_get_current_page_url(); |
76 | 76 | } |
77 | 77 | |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | |
80 | 80 | ob_start(); |
81 | 81 | |
82 | - if ( ! is_user_logged_in() ) { |
|
83 | - give_get_template_part( 'shortcode', 'register' ); |
|
82 | + if ( ! is_user_logged_in()) { |
|
83 | + give_get_template_part('shortcode', 'register'); |
|
84 | 84 | } |
85 | 85 | |
86 | - return apply_filters( 'give_register_form', ob_get_clean() ); |
|
86 | + return apply_filters('give_register_form', ob_get_clean()); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -95,34 +95,34 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return void |
97 | 97 | */ |
98 | -function give_process_login_form( $data ) { |
|
99 | - if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) { |
|
100 | - $user_data = get_user_by( 'login', $data['give_user_login'] ); |
|
101 | - if ( ! $user_data ) { |
|
102 | - $user_data = get_user_by( 'email', $data['give_user_login'] ); |
|
98 | +function give_process_login_form($data) { |
|
99 | + if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) { |
|
100 | + $user_data = get_user_by('login', $data['give_user_login']); |
|
101 | + if ( ! $user_data) { |
|
102 | + $user_data = get_user_by('email', $data['give_user_login']); |
|
103 | 103 | } |
104 | - if ( $user_data ) { |
|
104 | + if ($user_data) { |
|
105 | 105 | $user_ID = $user_data->ID; |
106 | 106 | $user_email = $user_data->user_email; |
107 | - if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_data->ID ) ) { |
|
108 | - give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] ); |
|
107 | + if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_data->ID)) { |
|
108 | + give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']); |
|
109 | 109 | } else { |
110 | - give_set_error( 'password_incorrect', esc_html__( 'The password you entered is incorrect.', 'give' ) ); |
|
110 | + give_set_error('password_incorrect', esc_html__('The password you entered is incorrect.', 'give')); |
|
111 | 111 | } |
112 | 112 | } else { |
113 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
113 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
114 | 114 | } |
115 | 115 | // Check for errors and redirect if none present |
116 | 116 | $errors = give_get_errors(); |
117 | - if ( ! $errors ) { |
|
118 | - $redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID ); |
|
119 | - wp_redirect( $redirect ); |
|
117 | + if ( ! $errors) { |
|
118 | + $redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID); |
|
119 | + wp_redirect($redirect); |
|
120 | 120 | give_die(); |
121 | 121 | } |
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | -add_action( 'give_user_login', 'give_process_login_form' ); |
|
125 | +add_action('give_user_login', 'give_process_login_form'); |
|
126 | 126 | |
127 | 127 | |
128 | 128 | /** |
@@ -134,18 +134,18 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return void |
136 | 136 | */ |
137 | -function give_process_user_logout( $data ) { |
|
138 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
137 | +function give_process_user_logout($data) { |
|
138 | + if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) { |
|
139 | 139 | |
140 | 140 | // Prevent occurring of any custom action on wp_logout. |
141 | - remove_all_actions( 'wp_logout' ); |
|
141 | + remove_all_actions('wp_logout'); |
|
142 | 142 | |
143 | 143 | /** |
144 | 144 | * Fires before processing user logout. |
145 | 145 | * |
146 | 146 | * @since 1.0 |
147 | 147 | */ |
148 | - do_action( 'give_before_user_logout' ); |
|
148 | + do_action('give_before_user_logout'); |
|
149 | 149 | |
150 | 150 | // Logout user. |
151 | 151 | wp_logout(); |
@@ -155,14 +155,14 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @since 1.0 |
157 | 157 | */ |
158 | - do_action( 'give_after_user_logout' ); |
|
158 | + do_action('give_after_user_logout'); |
|
159 | 159 | |
160 | - wp_redirect( $data['give_logout_redirect'] ); |
|
160 | + wp_redirect($data['give_logout_redirect']); |
|
161 | 161 | give_die(); |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | -add_action( 'give_user_logout', 'give_process_user_logout' ); |
|
165 | +add_action('give_user_logout', 'give_process_user_logout'); |
|
166 | 166 | |
167 | 167 | /** |
168 | 168 | * Log User In |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return void |
177 | 177 | */ |
178 | -function give_log_user_in( $user_id, $user_login, $user_pass ) { |
|
179 | - if ( $user_id < 1 ) { |
|
178 | +function give_log_user_in($user_id, $user_login, $user_pass) { |
|
179 | + if ($user_id < 1) { |
|
180 | 180 | return; |
181 | 181 | } |
182 | 182 | |
183 | - wp_set_auth_cookie( $user_id ); |
|
184 | - wp_set_current_user( $user_id, $user_login ); |
|
183 | + wp_set_auth_cookie($user_id); |
|
184 | + wp_set_current_user($user_id, $user_login); |
|
185 | 185 | |
186 | 186 | /** |
187 | 187 | * Fires after the user has successfully logged in. |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param string $user_login Username. |
192 | 192 | * @param WP_User $$user WP_User object of the logged-in user. |
193 | 193 | */ |
194 | - do_action( 'wp_login', $user_login, get_userdata( $user_id ) ); |
|
194 | + do_action('wp_login', $user_login, get_userdata($user_id)); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Fires after give user has successfully logged in. |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param string $user_login Username. |
203 | 203 | * @param string $user_pass User password. |
204 | 204 | */ |
205 | - do_action( 'give_log_user_in', $user_id, $user_login, $user_pass ); |
|
205 | + do_action('give_log_user_in', $user_id, $user_login, $user_pass); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return void |
217 | 217 | */ |
218 | -function give_process_register_form( $data ) { |
|
218 | +function give_process_register_form($data) { |
|
219 | 219 | |
220 | - if ( is_user_logged_in() ) { |
|
220 | + if (is_user_logged_in()) { |
|
221 | 221 | return; |
222 | 222 | } |
223 | 223 | |
224 | - if ( empty( $_POST['give_register_submit'] ) ) { |
|
224 | + if (empty($_POST['give_register_submit'])) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
@@ -230,38 +230,38 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @since 1.0 |
232 | 232 | */ |
233 | - do_action( 'give_pre_process_register_form' ); |
|
233 | + do_action('give_pre_process_register_form'); |
|
234 | 234 | |
235 | - if ( empty( $data['give_user_login'] ) ) { |
|
236 | - give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) ); |
|
235 | + if (empty($data['give_user_login'])) { |
|
236 | + give_set_error('empty_username', esc_html__('Invalid username.', 'give')); |
|
237 | 237 | } |
238 | 238 | |
239 | - if ( username_exists( $data['give_user_login'] ) ) { |
|
240 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
239 | + if (username_exists($data['give_user_login'])) { |
|
240 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
241 | 241 | } |
242 | 242 | |
243 | - if ( ! validate_username( $data['give_user_login'] ) ) { |
|
244 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
243 | + if ( ! validate_username($data['give_user_login'])) { |
|
244 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
245 | 245 | } |
246 | 246 | |
247 | - if ( email_exists( $data['give_user_email'] ) ) { |
|
248 | - give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) ); |
|
247 | + if (email_exists($data['give_user_email'])) { |
|
248 | + give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give')); |
|
249 | 249 | } |
250 | 250 | |
251 | - if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) { |
|
252 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
251 | + if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) { |
|
252 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
253 | 253 | } |
254 | 254 | |
255 | - if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) { |
|
256 | - give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) ); |
|
255 | + if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) { |
|
256 | + give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give')); |
|
257 | 257 | } |
258 | 258 | |
259 | - if ( empty( $_POST['give_user_pass'] ) ) { |
|
260 | - give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) ); |
|
259 | + if (empty($_POST['give_user_pass'])) { |
|
260 | + give_set_error('empty_password', esc_html__('Please enter a password.', 'give')); |
|
261 | 261 | } |
262 | 262 | |
263 | - if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) { |
|
264 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
263 | + if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) { |
|
264 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -269,26 +269,26 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @since 1.0 |
271 | 271 | */ |
272 | - do_action( 'give_process_register_form' ); |
|
272 | + do_action('give_process_register_form'); |
|
273 | 273 | |
274 | 274 | // Check for errors and redirect if none present |
275 | 275 | $errors = give_get_errors(); |
276 | 276 | |
277 | - if ( empty( $errors ) ) { |
|
277 | + if (empty($errors)) { |
|
278 | 278 | |
279 | - $redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] ); |
|
279 | + $redirect = apply_filters('give_register_redirect', $data['give_redirect']); |
|
280 | 280 | |
281 | - give_register_and_login_new_user( array( |
|
281 | + give_register_and_login_new_user(array( |
|
282 | 282 | 'user_login' => $data['give_user_login'], |
283 | 283 | 'user_pass' => $data['give_user_pass'], |
284 | 284 | 'user_email' => $data['give_user_email'], |
285 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
286 | - 'role' => get_option( 'default_role' ) |
|
287 | - ) ); |
|
285 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
286 | + 'role' => get_option('default_role') |
|
287 | + )); |
|
288 | 288 | |
289 | - wp_redirect( $redirect ); |
|
289 | + wp_redirect($redirect); |
|
290 | 290 | give_die(); |
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
294 | -add_action( 'give_user_register', 'give_process_register_form' ); |
|
295 | 294 | \ No newline at end of file |
295 | +add_action('give_user_register', 'give_process_register_form'); |
|
296 | 296 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_process_batch_export_form() { |
24 | 24 | |
25 | - if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) { |
|
26 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
25 | + if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) { |
|
26 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
27 | 27 | } |
28 | 28 | |
29 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php'; |
|
29 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php'; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Fires before batch export. |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param atring $class Export class. |
37 | 37 | */ |
38 | - do_action( 'give_batch_export_class_include', $_REQUEST['class'] ); |
|
38 | + do_action('give_batch_export_class_include', $_REQUEST['class']); |
|
39 | 39 | |
40 | 40 | $export = new $_REQUEST['class']; |
41 | 41 | $export->export(); |
42 | 42 | |
43 | 43 | } |
44 | 44 | |
45 | -add_action( 'give_form_batch_export', 'give_process_batch_export_form' ); |
|
45 | +add_action('give_form_batch_export', 'give_process_batch_export_form'); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Exports earnings for a specified time period |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | * @return void |
54 | 54 | */ |
55 | 55 | function give_export_earnings() { |
56 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php'; |
|
56 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-earnings.php'; |
|
57 | 57 | |
58 | 58 | $earnings_export = new Give_Earnings_Export(); |
59 | 59 | |
60 | 60 | $earnings_export->export(); |
61 | 61 | } |
62 | 62 | |
63 | -add_action( 'give_earnings_export', 'give_export_earnings' ); |
|
63 | +add_action('give_earnings_export', 'give_export_earnings'); |
|
64 | 64 | |
65 | 65 | |
66 | 66 | /** |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | */ |
75 | 75 | function give_export_all_customers() { |
76 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php'; |
|
76 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-customers.php'; |
|
77 | 77 | |
78 | 78 | $customer_export = new Give_Donors_Export(); |
79 | 79 | |
80 | 80 | $customer_export->export(); |
81 | 81 | } |
82 | 82 | |
83 | -add_action( 'give_email_export', 'give_export_all_customers' ); |
|
83 | +add_action('give_email_export', 'give_export_all_customers'); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Add a hook allowing extensions to register a hook on the batch export process |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return void |
90 | 90 | */ |
91 | 91 | function give_register_batch_exporters() { |
92 | - if ( is_admin() ) { |
|
92 | + if (is_admin()) { |
|
93 | 93 | /** |
94 | 94 | * Fires in the admin, while plugins loaded. |
95 | 95 | * |
@@ -99,21 +99,21 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @param string $class Export class. |
101 | 101 | */ |
102 | - do_action( 'give_register_batch_exporter' ); |
|
102 | + do_action('give_register_batch_exporter'); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | -add_action( 'plugins_loaded', 'give_register_batch_exporters' ); |
|
106 | +add_action('plugins_loaded', 'give_register_batch_exporters'); |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Register the payments batch exporter |
110 | 110 | * @since 1.5 |
111 | 111 | */ |
112 | 112 | function give_register_payments_batch_export() { |
113 | - add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 ); |
|
113 | + add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1); |
|
114 | 114 | } |
115 | 115 | |
116 | -add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 ); |
|
116 | +add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Loads the payments batch process if needed |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return void |
126 | 126 | */ |
127 | -function give_include_payments_batch_processor( $class ) { |
|
127 | +function give_include_payments_batch_processor($class) { |
|
128 | 128 | |
129 | - if ( 'Give_Batch_Payments_Export' === $class ) { |
|
130 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
129 | + if ('Give_Batch_Payments_Export' === $class) { |
|
130 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * @since 1.5.2 |
138 | 138 | */ |
139 | 139 | function give_register_customers_batch_export() { |
140 | - add_action( 'give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1 ); |
|
140 | + add_action('give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1); |
|
141 | 141 | } |
142 | 142 | |
143 | -add_action( 'give_register_batch_exporter', 'give_register_customers_batch_export', 10 ); |
|
143 | +add_action('give_register_batch_exporter', 'give_register_customers_batch_export', 10); |
|
144 | 144 | |
145 | 145 | /** |
146 | 146 | * Loads the customers batch process if needed |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return void |
153 | 153 | */ |
154 | -function give_include_customers_batch_processor( $class ) { |
|
154 | +function give_include_customers_batch_processor($class) { |
|
155 | 155 | |
156 | - if ( 'Give_Batch_Customers_Export' === $class ) { |
|
157 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
156 | + if ('Give_Batch_Customers_Export' === $class) { |
|
157 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | * @since 1.5 |
166 | 166 | */ |
167 | 167 | function give_register_forms_batch_export() { |
168 | - add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 ); |
|
168 | + add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1); |
|
169 | 169 | } |
170 | 170 | |
171 | -add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 ); |
|
171 | +add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10); |
|
172 | 172 | |
173 | 173 | /** |
174 | 174 | * Loads the file downloads batch process if needed |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return void |
181 | 181 | */ |
182 | -function give_include_forms_batch_processor( $class ) { |
|
182 | +function give_include_forms_batch_processor($class) { |
|
183 | 183 | |
184 | - if ( 'Give_Batch_Forms_Export' === $class ) { |
|
185 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
184 | + if ('Give_Batch_Forms_Export' === $class) { |
|
185 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } |
189 | 189 | \ No newline at end of file |
@@ -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 | |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function __construct() { |
81 | 81 | |
82 | - if ( 'none' === $this->get_template() ) { |
|
82 | + if ('none' === $this->get_template()) { |
|
83 | 83 | $this->html = false; |
84 | 84 | } |
85 | 85 | |
86 | - add_action( 'give_email_send_before', array( $this, 'send_before' ) ); |
|
87 | - add_action( 'give_email_send_after', array( $this, 'send_after' ) ); |
|
86 | + add_action('give_email_send_before', array($this, 'send_before')); |
|
87 | + add_action('give_email_send_after', array($this, 'send_after')); |
|
88 | 88 | |
89 | 89 | } |
90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @since 1.0 |
95 | 95 | */ |
96 | - public function __set( $key, $value ) { |
|
96 | + public function __set($key, $value) { |
|
97 | 97 | $this->$key = $value; |
98 | 98 | } |
99 | 99 | |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | * @since 1.0 |
104 | 104 | */ |
105 | 105 | public function get_from_name() { |
106 | - if ( ! $this->from_name ) { |
|
107 | - $this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) ); |
|
106 | + if ( ! $this->from_name) { |
|
107 | + $this->from_name = give_get_option('from_name', get_bloginfo('name')); |
|
108 | 108 | } |
109 | 109 | |
110 | - return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this ); |
|
110 | + return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | * @since 1.0 |
117 | 117 | */ |
118 | 118 | public function get_from_address() { |
119 | - if ( ! $this->from_address ) { |
|
120 | - $this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) ); |
|
119 | + if ( ! $this->from_address) { |
|
120 | + $this->from_address = give_get_option('from_email', get_option('admin_email')); |
|
121 | 121 | } |
122 | 122 | |
123 | - return apply_filters( 'give_email_from_address', $this->from_address, $this ); |
|
123 | + return apply_filters('give_email_from_address', $this->from_address, $this); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | * @since 1.0 |
130 | 130 | */ |
131 | 131 | public function get_content_type() { |
132 | - if ( ! $this->content_type && $this->html ) { |
|
133 | - $this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this ); |
|
134 | - } else if ( ! $this->html ) { |
|
132 | + if ( ! $this->content_type && $this->html) { |
|
133 | + $this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this); |
|
134 | + } else if ( ! $this->html) { |
|
135 | 135 | $this->content_type = 'text/plain'; |
136 | 136 | } |
137 | 137 | |
138 | - return apply_filters( 'give_email_content_type', $this->content_type, $this ); |
|
138 | + return apply_filters('give_email_content_type', $this->content_type, $this); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | * @since 1.0 |
145 | 145 | */ |
146 | 146 | public function get_headers() { |
147 | - if ( ! $this->headers ) { |
|
147 | + if ( ! $this->headers) { |
|
148 | 148 | $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n"; |
149 | 149 | $this->headers .= "Reply-To: {$this->get_from_address()}\r\n"; |
150 | 150 | $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n"; |
151 | 151 | } |
152 | 152 | |
153 | - return apply_filters( 'give_email_headers', $this->headers, $this ); |
|
153 | + return apply_filters('give_email_headers', $this->headers, $this); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get_templates() { |
162 | 162 | $templates = array( |
163 | - 'default' => esc_html__( 'Default Template', 'give' ), |
|
164 | - 'none' => esc_html__( 'No template, plain text only', 'give' ) |
|
163 | + 'default' => esc_html__('Default Template', 'give'), |
|
164 | + 'none' => esc_html__('No template, plain text only', 'give') |
|
165 | 165 | ); |
166 | 166 | |
167 | - return apply_filters( 'give_email_templates', $templates ); |
|
167 | + return apply_filters('give_email_templates', $templates); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | * @since 1.0 |
174 | 174 | */ |
175 | 175 | public function get_template() { |
176 | - if ( ! $this->template ) { |
|
177 | - $this->template = give_get_option( 'email_template', 'default' ); |
|
176 | + if ( ! $this->template) { |
|
177 | + $this->template = give_get_option('email_template', 'default'); |
|
178 | 178 | } |
179 | 179 | |
180 | - return apply_filters( 'give_email_template', $this->template ); |
|
180 | + return apply_filters('give_email_template', $this->template); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @since 1.0 |
187 | 187 | */ |
188 | 188 | public function get_heading() { |
189 | - return apply_filters( 'give_email_heading', $this->heading ); |
|
189 | + return apply_filters('give_email_heading', $this->heading); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return mixed |
198 | 198 | */ |
199 | - public function parse_tags( $content ) { |
|
199 | + public function parse_tags($content) { |
|
200 | 200 | return $content; |
201 | 201 | } |
202 | 202 | |
@@ -205,19 +205,19 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @since 1.0 |
207 | 207 | */ |
208 | - public function build_email( $message ) { |
|
208 | + public function build_email($message) { |
|
209 | 209 | |
210 | - if ( false === $this->html ) { |
|
211 | - return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this ); |
|
210 | + if (false === $this->html) { |
|
211 | + return apply_filters('give_email_message', wp_strip_all_tags($message), $this); |
|
212 | 212 | } |
213 | 213 | |
214 | - $message = $this->text_to_html( $message ); |
|
214 | + $message = $this->text_to_html($message); |
|
215 | 215 | |
216 | 216 | $template = $this->get_template(); |
217 | 217 | |
218 | 218 | ob_start(); |
219 | 219 | |
220 | - give_get_template_part( 'emails/header', $template, true ); |
|
220 | + give_get_template_part('emails/header', $template, true); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Fires in the email head. |
@@ -226,17 +226,17 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @param Give_Emails $this The email object. |
228 | 228 | */ |
229 | - do_action( 'give_email_header', $this ); |
|
229 | + do_action('give_email_header', $this); |
|
230 | 230 | |
231 | - if ( has_action( 'give_email_template_' . $template ) ) { |
|
231 | + if (has_action('give_email_template_'.$template)) { |
|
232 | 232 | /** |
233 | 233 | * Fires in a specific email template. |
234 | 234 | * |
235 | 235 | * @since 1.0 |
236 | 236 | */ |
237 | - do_action( "give_email_template_{$template}" ); |
|
237 | + do_action("give_email_template_{$template}"); |
|
238 | 238 | } else { |
239 | - give_get_template_part( 'emails/body', $template, true ); |
|
239 | + give_get_template_part('emails/body', $template, true); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @param Give_Emails $this The email object. |
248 | 248 | */ |
249 | - do_action( 'give_email_body', $this ); |
|
249 | + do_action('give_email_body', $this); |
|
250 | 250 | |
251 | - give_get_template_part( 'emails/footer', $template, true ); |
|
251 | + give_get_template_part('emails/footer', $template, true); |
|
252 | 252 | |
253 | 253 | /** |
254 | 254 | * Fires in the email footer. |
@@ -257,12 +257,12 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @param Give_Emails $this The email object. |
259 | 259 | */ |
260 | - do_action( 'give_email_footer', $this ); |
|
260 | + do_action('give_email_footer', $this); |
|
261 | 261 | |
262 | 262 | $body = ob_get_clean(); |
263 | - $message = str_replace( '{email}', $message, $body ); |
|
263 | + $message = str_replace('{email}', $message, $body); |
|
264 | 264 | |
265 | - return apply_filters( 'give_email_message', $message, $this ); |
|
265 | + return apply_filters('give_email_message', $message, $this); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -275,10 +275,10 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return bool |
277 | 277 | */ |
278 | - public function send( $to, $subject, $message, $attachments = '' ) { |
|
278 | + public function send($to, $subject, $message, $attachments = '') { |
|
279 | 279 | |
280 | - if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) { |
|
281 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null ); |
|
280 | + if ( ! did_action('init') && ! did_action('admin_init')) { |
|
281 | + _doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null); |
|
282 | 282 | |
283 | 283 | return false; |
284 | 284 | } |
@@ -290,16 +290,16 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @param Give_Emails $this The email object. |
292 | 292 | */ |
293 | - do_action( 'give_email_send_before', $this ); |
|
293 | + do_action('give_email_send_before', $this); |
|
294 | 294 | |
295 | - $subject = $this->parse_tags( $subject ); |
|
296 | - $message = $this->parse_tags( $message ); |
|
295 | + $subject = $this->parse_tags($subject); |
|
296 | + $message = $this->parse_tags($message); |
|
297 | 297 | |
298 | - $message = $this->build_email( $message ); |
|
298 | + $message = $this->build_email($message); |
|
299 | 299 | |
300 | - $attachments = apply_filters( 'give_email_attachments', $attachments, $this ); |
|
300 | + $attachments = apply_filters('give_email_attachments', $attachments, $this); |
|
301 | 301 | |
302 | - $sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments ); |
|
302 | + $sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments); |
|
303 | 303 | |
304 | 304 | /** |
305 | 305 | * Fires after sending an email. |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @param Give_Emails $this The email object. |
310 | 310 | */ |
311 | - do_action( 'give_email_send_after', $this ); |
|
311 | + do_action('give_email_send_after', $this); |
|
312 | 312 | |
313 | 313 | return $sent; |
314 | 314 | |
@@ -320,9 +320,9 @@ discard block |
||
320 | 320 | * @since 1.0 |
321 | 321 | */ |
322 | 322 | public function send_before() { |
323 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
324 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
325 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
323 | + add_filter('wp_mail_from', array($this, 'get_from_address')); |
|
324 | + add_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
325 | + add_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | * @since 1.0 |
332 | 332 | */ |
333 | 333 | public function send_after() { |
334 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
335 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
336 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
334 | + remove_filter('wp_mail_from', array($this, 'get_from_address')); |
|
335 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
336 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
337 | 337 | |
338 | 338 | // Reset heading to an empty string |
339 | 339 | $this->heading = ''; |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | * |
345 | 345 | * @since 1.0 |
346 | 346 | */ |
347 | - public function text_to_html( $message ) { |
|
347 | + public function text_to_html($message) { |
|
348 | 348 | |
349 | - if ( 'text/html' == $this->content_type || true === $this->html ) { |
|
350 | - $message = wpautop( $message ); |
|
349 | + if ('text/html' == $this->content_type || true === $this->html) { |
|
350 | + $message = wpautop($message); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | return $message; |
@@ -10,61 +10,61 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
13 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load Give file. |
18 | -include_once( 'give.php' ); |
|
18 | +include_once('give.php'); |
|
19 | 19 | |
20 | 20 | global $wpdb, $wp_roles; |
21 | 21 | |
22 | 22 | |
23 | -if ( give_get_option( 'uninstall_on_delete' ) === 'on' ) { |
|
23 | +if (give_get_option('uninstall_on_delete') === 'on') { |
|
24 | 24 | |
25 | 25 | // Delete All the Custom Post Types. |
26 | - $give_taxonomies = array( 'form_category', 'form_tag', 'give_log_type' ); |
|
27 | - $give_post_types = array( 'give_forms', 'give_payment', 'give_log' ); |
|
28 | - foreach ( $give_post_types as $post_type ) { |
|
26 | + $give_taxonomies = array('form_category', 'form_tag', 'give_log_type'); |
|
27 | + $give_post_types = array('give_forms', 'give_payment', 'give_log'); |
|
28 | + foreach ($give_post_types as $post_type) { |
|
29 | 29 | |
30 | - $give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) ); |
|
31 | - $items = get_posts( array( |
|
30 | + $give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type)); |
|
31 | + $items = get_posts(array( |
|
32 | 32 | 'post_type' => $post_type, |
33 | 33 | 'post_status' => 'any', |
34 | - 'numberposts' => - 1, |
|
34 | + 'numberposts' => -1, |
|
35 | 35 | 'fields' => 'ids', |
36 | - ) ); |
|
36 | + )); |
|
37 | 37 | |
38 | - if ( $items ) { |
|
39 | - foreach ( $items as $item ) { |
|
40 | - wp_delete_post( $item, true ); |
|
38 | + if ($items) { |
|
39 | + foreach ($items as $item) { |
|
40 | + wp_delete_post($item, true); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | // Delete All the Terms & Taxonomies. |
46 | - foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) { |
|
46 | + foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) { |
|
47 | 47 | |
48 | - $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) ); |
|
48 | + $terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy)); |
|
49 | 49 | |
50 | 50 | // Delete Terms. |
51 | - if ( $terms ) { |
|
52 | - foreach ( $terms as $term ) { |
|
53 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) ); |
|
54 | - $wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) ); |
|
51 | + if ($terms) { |
|
52 | + foreach ($terms as $term) { |
|
53 | + $wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id)); |
|
54 | + $wpdb->delete($wpdb->terms, array('term_id' => $term->term_id)); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Delete Taxonomies. |
59 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) ); |
|
59 | + $wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s')); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // Delete the Plugin Pages. |
63 | - $give_created_pages = array( 'success_page', 'failure_page', 'history_page' ); |
|
64 | - foreach ( $give_created_pages as $p ) { |
|
65 | - $page = give_get_option( $p, false ); |
|
66 | - if ( $page ) { |
|
67 | - wp_delete_post( $page, true ); |
|
63 | + $give_created_pages = array('success_page', 'failure_page', 'history_page'); |
|
64 | + foreach ($give_created_pages as $p) { |
|
65 | + $page = give_get_option($p, false); |
|
66 | + if ($page) { |
|
67 | + wp_delete_post($page, true); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -72,20 +72,20 @@ discard block |
||
72 | 72 | Give()->roles->remove_caps(); |
73 | 73 | |
74 | 74 | // Delete the Roles. |
75 | - $give_roles = array( 'give_manager', 'give_accountant', 'give_worker' ); |
|
76 | - foreach ( $give_roles as $role ) { |
|
77 | - remove_role( $role ); |
|
75 | + $give_roles = array('give_manager', 'give_accountant', 'give_worker'); |
|
76 | + foreach ($give_roles as $role) { |
|
77 | + remove_role($role); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Remove all database tables. |
81 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' ); |
|
82 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' ); |
|
83 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' ); |
|
81 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors'); |
|
82 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers'); |
|
83 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta'); |
|
84 | 84 | |
85 | 85 | // Cleanup Cron Events. |
86 | - wp_clear_scheduled_hook( 'give_daily_scheduled_events' ); |
|
87 | - wp_clear_scheduled_hook( 'give_daily_cron' ); |
|
88 | - wp_clear_scheduled_hook( 'give_weekly_cron' ); |
|
86 | + wp_clear_scheduled_hook('give_daily_scheduled_events'); |
|
87 | + wp_clear_scheduled_hook('give_daily_cron'); |
|
88 | + wp_clear_scheduled_hook('give_weekly_cron'); |
|
89 | 89 | |
90 | 90 | // Get all options. |
91 | 91 | $give_option_names = $wpdb->get_results( |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | ARRAY_A |
97 | 97 | ); |
98 | 98 | |
99 | - if ( ! empty( $give_option_names ) ) { |
|
99 | + if ( ! empty($give_option_names)) { |
|
100 | 100 | // Convert option name to transient or option name. |
101 | 101 | $new_give_option_names = array(); |
102 | 102 | |
103 | - foreach ( $give_option_names as $option ) { |
|
104 | - $new_give_option_names[] = ( false !== strpos( $option['option_name'], '_transient_' ) ) |
|
105 | - ? str_replace( '_transient_', '', $option['option_name'] ) |
|
103 | + foreach ($give_option_names as $option) { |
|
104 | + $new_give_option_names[] = (false !== strpos($option['option_name'], '_transient_')) |
|
105 | + ? str_replace('_transient_', '', $option['option_name']) |
|
106 | 106 | : $option['option_name']; |
107 | 107 | } |
108 | 108 | |
109 | 109 | $give_option_names = $new_give_option_names; |
110 | 110 | |
111 | 111 | // Delete all the Plugin Options. |
112 | - foreach ( $give_option_names as $option ) { |
|
113 | - if ( false !== strpos( $option, '_transient_' ) ) { |
|
114 | - delete_transient( $option ); |
|
112 | + foreach ($give_option_names as $option) { |
|
113 | + if (false !== strpos($option, '_transient_')) { |
|
114 | + delete_transient($option); |
|
115 | 115 | } else { |
116 | - delete_option( $option ); |
|
116 | + delete_option($option); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
@@ -689,7 +689,7 @@ |
||
689 | 689 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
690 | 690 | esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
691 | 691 | ); |
692 | - }else{ |
|
692 | + } else{ |
|
693 | 693 | $messages[$subscription['id']] = sprintf( |
694 | 694 | __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
695 | 695 | human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @access private |
220 | 220 | * @since 1.0 |
221 | 221 | * |
222 | - * @return bool |
|
222 | + * @return false|null |
|
223 | 223 | */ |
224 | 224 | public function auto_updater() { |
225 | 225 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * @access public |
476 | 476 | * @since 1.7 |
477 | 477 | * |
478 | - * @return bool|void |
|
478 | + * @return false|null |
|
479 | 479 | */ |
480 | 480 | public function weekly_license_check() { |
481 | 481 | |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * @access public |
528 | 528 | * @since 1.7 |
529 | 529 | * |
530 | - * @return bool|void |
|
530 | + * @return false|null |
|
531 | 531 | */ |
532 | 532 | public function weekly_subscription_check() { |
533 | 533 | |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * @access private |
608 | 608 | * @since 1.7 |
609 | 609 | * |
610 | - * @return bool|void |
|
610 | + * @return false|null |
|
611 | 611 | */ |
612 | 612 | private function __single_subscription_check() { |
613 | 613 | // Do not fire if license key is not set. |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | * @access private |
803 | 803 | * @since 1.7 |
804 | 804 | * |
805 | - * @return void|bool |
|
805 | + * @return false|null |
|
806 | 806 | */ |
807 | 807 | private function __remove_license_key_from_subscriptions(){ |
808 | 808 | $subscriptions = get_option( 'give_subscriptions', 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 |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @var string |
105 | 105 | */ |
106 | - private $api_url = 'https://givewp.com/edd-sl-api/'; |
|
106 | + private $api_url = 'https://givewp.com/edd-sl-api/'; |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Account URL |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @var null|string |
115 | 115 | */ |
116 | - private $account_url = 'https://givewp.com/my-account/'; |
|
116 | + private $account_url = 'https://givewp.com/my-account/'; |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Ccheckout URL |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | * @param string $_checkout_url |
143 | 143 | * @param string $_account_url |
144 | 144 | */ |
145 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) { |
|
145 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) { |
|
146 | 146 | $give_options = give_get_settings(); |
147 | 147 | |
148 | 148 | $this->file = $_file; |
149 | 149 | $this->item_name = $_item_name; |
150 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
150 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
151 | 151 | $this->version = $_version; |
152 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
153 | - $this->license_data = get_option( $this->item_shortname . '_license_active' ); |
|
152 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
153 | + $this->license_data = get_option($this->item_shortname.'_license_active'); |
|
154 | 154 | $this->author = $_author; |
155 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
156 | - $this->checkout_url = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url; |
|
157 | - $this->account_url = is_null( $_account_url ) ? $this->account_url : $_account_url; |
|
155 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
156 | + $this->checkout_url = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url; |
|
157 | + $this->account_url = is_null($_account_url) ? $this->account_url : $_account_url; |
|
158 | 158 | |
159 | 159 | // Setup hooks |
160 | 160 | $this->includes(); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return void |
174 | 174 | */ |
175 | 175 | private function includes() { |
176 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
176 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
177 | 177 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
178 | 178 | } |
179 | 179 | } |
@@ -191,26 +191,26 @@ discard block |
||
191 | 191 | private function hooks() { |
192 | 192 | |
193 | 193 | // Register settings |
194 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
194 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
195 | 195 | |
196 | 196 | // Activate license key on settings save |
197 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
197 | + add_action('admin_init', array($this, 'activate_license')); |
|
198 | 198 | |
199 | 199 | // Deactivate license key |
200 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
200 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
201 | 201 | |
202 | 202 | // Updater |
203 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
203 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
204 | 204 | |
205 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
205 | + add_action('admin_notices', array($this, 'notices')); |
|
206 | 206 | |
207 | 207 | // Check license weekly. |
208 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) ); |
|
209 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) ); |
|
208 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check')); |
|
209 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check')); |
|
210 | 210 | |
211 | 211 | // Check subscription weekly. |
212 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) ); |
|
213 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) ); |
|
212 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check')); |
|
213 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check')); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function auto_updater() { |
225 | 225 | |
226 | - if ( ! $this->is_valid_license() ) { |
|
226 | + if ( ! $this->is_valid_license()) { |
|
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | |
@@ -252,16 +252,16 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return array License settings. |
254 | 254 | */ |
255 | - public function settings( $settings ) { |
|
255 | + public function settings($settings) { |
|
256 | 256 | |
257 | 257 | $give_license_settings = array( |
258 | 258 | array( |
259 | 259 | 'name' => $this->item_name, |
260 | - 'id' => $this->item_shortname . '_license_key', |
|
260 | + 'id' => $this->item_shortname.'_license_key', |
|
261 | 261 | 'desc' => '', |
262 | 262 | 'type' => 'license_key', |
263 | 263 | 'options' => array( |
264 | - 'license' => get_option( $this->item_shortname . '_license_active' ), |
|
264 | + 'license' => get_option($this->item_shortname.'_license_active'), |
|
265 | 265 | 'shortname' => $this->item_shortname, |
266 | 266 | 'item_name' => $this->item_name, |
267 | 267 | 'api_url' => $this->api_url, |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | ) |
273 | 273 | ); |
274 | 274 | |
275 | - return array_merge( $settings, $give_license_settings ); |
|
275 | + return array_merge($settings, $give_license_settings); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -287,18 +287,18 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return array License settings content. |
289 | 289 | */ |
290 | - public function license_settings_content( $settings ) { |
|
290 | + public function license_settings_content($settings) { |
|
291 | 291 | |
292 | 292 | $give_license_settings = array( |
293 | 293 | array( |
294 | - 'name' => esc_html__( 'Add-on Licenses', 'give' ), |
|
294 | + 'name' => esc_html__('Add-on Licenses', 'give'), |
|
295 | 295 | 'desc' => '<hr>', |
296 | 296 | 'type' => 'give_title', |
297 | 297 | 'id' => 'give_title' |
298 | 298 | ), |
299 | 299 | ); |
300 | 300 | |
301 | - return array_merge( $settings, $give_license_settings ); |
|
301 | + return array_merge($settings, $give_license_settings); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -313,37 +313,37 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public function activate_license() { |
315 | 315 | // Bailout: Check if license key set of not. |
316 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
316 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
317 | 317 | return; |
318 | 318 | } |
319 | 319 | |
320 | 320 | // Security check. |
321 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
321 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
322 | 322 | |
323 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
323 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
324 | 324 | |
325 | 325 | } |
326 | 326 | |
327 | 327 | // Check if user have correct permissions. |
328 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
328 | + if ( ! current_user_can('manage_give_settings')) { |
|
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Allow third party addon developers to handle license activation. |
333 | - if( $this->__is_third_party_addon() ){ |
|
334 | - do_action( 'give_activate_license', $this ); |
|
333 | + if ($this->__is_third_party_addon()) { |
|
334 | + do_action('give_activate_license', $this); |
|
335 | 335 | return; |
336 | 336 | } |
337 | 337 | |
338 | 338 | // Delete previous license setting if a empty license key submitted. |
339 | - if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
340 | - delete_option( $this->item_shortname . '_license_active' ); |
|
339 | + if (empty($_POST[$this->item_shortname.'_license_key'])) { |
|
340 | + delete_option($this->item_shortname.'_license_active'); |
|
341 | 341 | return; |
342 | 342 | } |
343 | 343 | |
344 | 344 | // Do not simultaneously activate any addon if user want to deactivate any addon. |
345 | - foreach ( $_POST as $key => $value ) { |
|
346 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
345 | + foreach ($_POST as $key => $value) { |
|
346 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
347 | 347 | // Don't activate a key when deactivating a different key |
348 | 348 | return; |
349 | 349 | } |
@@ -351,15 +351,15 @@ discard block |
||
351 | 351 | |
352 | 352 | |
353 | 353 | // Check if plugin previously installed. |
354 | - if ( $this->is_valid_license() ) { |
|
354 | + if ($this->is_valid_license()) { |
|
355 | 355 | return; |
356 | 356 | } |
357 | 357 | |
358 | 358 | // Get license key. |
359 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
359 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
360 | 360 | |
361 | 361 | // Bailout. |
362 | - if( empty( $license ) ) { |
|
362 | + if (empty($license)) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $api_params = array( |
371 | 371 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
372 | 372 | 'license' => $license, |
373 | - 'item_name' => urlencode( $this->item_name ), |
|
373 | + 'item_name' => urlencode($this->item_name), |
|
374 | 374 | 'url' => home_url() |
375 | 375 | ); |
376 | 376 | |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | ); |
386 | 386 | |
387 | 387 | // Make sure there are no errors |
388 | - if ( is_wp_error( $response ) ) { |
|
388 | + if (is_wp_error($response)) { |
|
389 | 389 | return; |
390 | 390 | } |
391 | 391 | |
392 | 392 | // Tell WordPress to look for updates |
393 | - set_site_transient( 'update_plugins', null ); |
|
393 | + set_site_transient('update_plugins', null); |
|
394 | 394 | |
395 | 395 | // Decode license data |
396 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
397 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
396 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
397 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
398 | 398 | |
399 | 399 | // Check subscription for license key and store this to db (if any). |
400 | 400 | $this->__single_subscription_check(); |
@@ -412,34 +412,34 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public function deactivate_license() { |
414 | 414 | |
415 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
415 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
419 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
420 | 420 | |
421 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
421 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
422 | 422 | |
423 | 423 | } |
424 | 424 | |
425 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
425 | + if ( ! current_user_can('manage_give_settings')) { |
|
426 | 426 | return; |
427 | 427 | } |
428 | 428 | |
429 | 429 | // Allow third party addon developers to handle license deactivation. |
430 | - if( $this->__is_third_party_addon() ){ |
|
431 | - do_action( 'give_deactivate_license', $this ); |
|
430 | + if ($this->__is_third_party_addon()) { |
|
431 | + do_action('give_deactivate_license', $this); |
|
432 | 432 | return; |
433 | 433 | } |
434 | 434 | |
435 | 435 | // Run on deactivate button press |
436 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
436 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
437 | 437 | |
438 | 438 | // Data to send to the API |
439 | 439 | $api_params = array( |
440 | 440 | 'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"! |
441 | 441 | 'license' => $this->license, |
442 | - 'item_name' => urlencode( $this->item_name ), |
|
442 | + 'item_name' => urlencode($this->item_name), |
|
443 | 443 | 'url' => home_url() |
444 | 444 | ); |
445 | 445 | |
@@ -454,15 +454,15 @@ discard block |
||
454 | 454 | ); |
455 | 455 | |
456 | 456 | // Make sure there are no errors |
457 | - if ( is_wp_error( $response ) ) { |
|
457 | + if (is_wp_error($response)) { |
|
458 | 458 | return; |
459 | 459 | } |
460 | 460 | |
461 | 461 | // Decode the license data |
462 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
462 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
463 | 463 | |
464 | 464 | // Remove license data. |
465 | - delete_option( $this->item_shortname . '_license_active' ); |
|
465 | + delete_option($this->item_shortname.'_license_active'); |
|
466 | 466 | |
467 | 467 | // Remove license key from subscriptions if exist. |
468 | 468 | $this->__remove_license_key_from_subscriptions(); |
@@ -479,18 +479,18 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function weekly_license_check() { |
481 | 481 | |
482 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
482 | + if ( ! empty($_POST['give_settings'])) { |
|
483 | 483 | // Don't fire when saving settings |
484 | 484 | return false; |
485 | 485 | } |
486 | 486 | |
487 | - if( empty( $this->license ) ) { |
|
487 | + if (empty($this->license)) { |
|
488 | 488 | return false; |
489 | 489 | } |
490 | 490 | |
491 | 491 | // Allow third party addon developers to handle their license check. |
492 | - if( $this->__is_third_party_addon() ){ |
|
493 | - do_action( 'give_weekly_license_check', $this ); |
|
492 | + if ($this->__is_third_party_addon()) { |
|
493 | + do_action('give_weekly_license_check', $this); |
|
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $api_params = array( |
499 | 499 | 'edd_action'=> 'check_license', |
500 | 500 | 'license' => $this->license, |
501 | - 'item_name' => urlencode( $this->item_name ), |
|
501 | + 'item_name' => urlencode($this->item_name), |
|
502 | 502 | 'url' => home_url() |
503 | 503 | ); |
504 | 504 | |
@@ -513,12 +513,12 @@ discard block |
||
513 | 513 | ); |
514 | 514 | |
515 | 515 | // Make sure the response came back okay. |
516 | - if ( is_wp_error( $response ) ) { |
|
516 | + if (is_wp_error($response)) { |
|
517 | 517 | return false; |
518 | 518 | } |
519 | 519 | |
520 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
521 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
520 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
521 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -531,24 +531,24 @@ discard block |
||
531 | 531 | */ |
532 | 532 | public function weekly_subscription_check() { |
533 | 533 | |
534 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
534 | + if ( ! empty($_POST['give_settings'])) { |
|
535 | 535 | // Don't fire when saving settings |
536 | 536 | return false; |
537 | 537 | } |
538 | 538 | |
539 | 539 | // Remove old subscription data. |
540 | - if( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp' , 1 ) ){ |
|
541 | - delete_option( 'give_subscriptions' ); |
|
542 | - update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp' , 1 ) ) ); |
|
540 | + if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) { |
|
541 | + delete_option('give_subscriptions'); |
|
542 | + update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1))); |
|
543 | 543 | } |
544 | 544 | |
545 | - if( empty( $this->license ) ) { |
|
545 | + if (empty($this->license)) { |
|
546 | 546 | return false; |
547 | 547 | } |
548 | 548 | |
549 | 549 | // Allow third party addon developers to handle there subscription check. |
550 | - if( $this->__is_third_party_addon() ){ |
|
551 | - do_action( 'give_weekly_subscription_check', $this ); |
|
550 | + if ($this->__is_third_party_addon()) { |
|
551 | + do_action('give_weekly_subscription_check', $this); |
|
552 | 552 | return false; |
553 | 553 | } |
554 | 554 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | // This is custom feature to check subscriptions. |
563 | 563 | 'edd_action'=> 'check_subscription', |
564 | 564 | 'license' => $this->license, |
565 | - 'item_name' => urlencode( $this->item_name ), |
|
565 | + 'item_name' => urlencode($this->item_name), |
|
566 | 566 | 'url' => home_url() |
567 | 567 | ); |
568 | 568 | |
@@ -577,27 +577,27 @@ discard block |
||
577 | 577 | ); |
578 | 578 | |
579 | 579 | // Make sure the response came back okay. |
580 | - if ( is_wp_error( $response ) ) { |
|
580 | + if (is_wp_error($response)) { |
|
581 | 581 | return false; |
582 | 582 | } |
583 | 583 | |
584 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
584 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
585 | 585 | |
586 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
587 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
586 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
587 | + $subscriptions = get_option('give_subscriptions', array()); |
|
588 | 588 | |
589 | 589 | // Update subscription data only if subscription does not exist already. |
590 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
591 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
592 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
590 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
591 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
592 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | // Store licenses for subscription. |
596 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
597 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
596 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
597 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
598 | 598 | } |
599 | 599 | |
600 | - update_option( 'give_subscriptions', $subscriptions ); |
|
600 | + update_option('give_subscriptions', $subscriptions); |
|
601 | 601 | } |
602 | 602 | } |
603 | 603 | |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | */ |
612 | 612 | private function __single_subscription_check() { |
613 | 613 | // Do not fire if license key is not set. |
614 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
614 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
615 | 615 | return false; |
616 | 616 | } |
617 | 617 | |
618 | - if( empty( $this->license ) ) { |
|
618 | + if (empty($this->license)) { |
|
619 | 619 | return false; |
620 | 620 | } |
621 | 621 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | // This is custom feature to check subscriptions. |
627 | 627 | 'edd_action'=> 'check_subscription', |
628 | 628 | 'license' => $this->license, |
629 | - 'item_name' => urlencode( $this->item_name ), |
|
629 | + 'item_name' => urlencode($this->item_name), |
|
630 | 630 | 'url' => home_url() |
631 | 631 | ); |
632 | 632 | |
@@ -641,27 +641,27 @@ discard block |
||
641 | 641 | ); |
642 | 642 | |
643 | 643 | // Make sure the response came back okay. |
644 | - if ( is_wp_error( $response ) ) { |
|
644 | + if (is_wp_error($response)) { |
|
645 | 645 | return false; |
646 | 646 | } |
647 | 647 | |
648 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
648 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
649 | 649 | |
650 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
651 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
650 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
651 | + $subscriptions = get_option('give_subscriptions', array()); |
|
652 | 652 | |
653 | 653 | // Update subscription data only if subscription does not exist already. |
654 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
655 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
656 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
654 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
655 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
656 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | // Store licenses for subscription. |
660 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
661 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
660 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
661 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
662 | 662 | } |
663 | 663 | |
664 | - update_option( 'give_subscriptions', $subscriptions ); |
|
664 | + update_option('give_subscriptions', $subscriptions); |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
@@ -679,87 +679,87 @@ discard block |
||
679 | 679 | static $addon_license_key_in_subscriptions; |
680 | 680 | |
681 | 681 | // Set default value. |
682 | - $addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array(); |
|
682 | + $addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array(); |
|
683 | 683 | |
684 | - if( empty( $this->license ) ) { |
|
684 | + if (empty($this->license)) { |
|
685 | 685 | return; |
686 | 686 | } |
687 | 687 | |
688 | - if( ! current_user_can( 'manage_shop_settings' ) ) { |
|
688 | + if ( ! current_user_can('manage_shop_settings')) { |
|
689 | 689 | return; |
690 | 690 | } |
691 | 691 | |
692 | 692 | // Do not show licenses notices on license tab. |
693 | - if( ! empty( $_GET['tab'] ) && 'licenses' === $_GET['tab'] ) { |
|
693 | + if ( ! empty($_GET['tab']) && 'licenses' === $_GET['tab']) { |
|
694 | 694 | return; |
695 | 695 | } |
696 | 696 | |
697 | 697 | $messages = array(); |
698 | 698 | |
699 | 699 | // Get subscriptions. |
700 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
700 | + $subscriptions = get_option('give_subscriptions'); |
|
701 | 701 | |
702 | 702 | // Show subscription messages. |
703 | - if( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) { |
|
703 | + if ( ! empty($subscriptions) && ! $showed_subscriptions_message) { |
|
704 | 704 | |
705 | - foreach ( $subscriptions as $subscription ) { |
|
705 | + foreach ($subscriptions as $subscription) { |
|
706 | 706 | // Subscription expires timestamp. |
707 | - $subscription_expires = strtotime( $subscription['expires'] ); |
|
707 | + $subscription_expires = strtotime($subscription['expires']); |
|
708 | 708 | |
709 | 709 | // Start showing subscriptions message before one week of renewal date. |
710 | - if( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) { |
|
710 | + if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) { |
|
711 | 711 | continue; |
712 | 712 | } |
713 | 713 | |
714 | 714 | // Check if subscription message already exist in messages. |
715 | - if( array_key_exists( $subscription['id'], $messages ) ) { |
|
715 | + if (array_key_exists($subscription['id'], $messages)) { |
|
716 | 716 | continue; |
717 | 717 | } |
718 | 718 | |
719 | - if( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) { |
|
719 | + if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) { |
|
720 | 720 | |
721 | - if( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired. |
|
721 | + if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired. |
|
722 | 722 | $messages[$subscription['id']] = sprintf( |
723 | - __( 'You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
724 | - urldecode( $subscription['invoice_url'] ), |
|
723 | + __('You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
724 | + urldecode($subscription['invoice_url']), |
|
725 | 725 | $subscription['payment_id'], |
726 | 726 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
727 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
727 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
728 | 728 | ); |
729 | - }else{ |
|
729 | + } else { |
|
730 | 730 | $messages[$subscription['id']] = sprintf( |
731 | - __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
732 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
|
733 | - urldecode( $subscription['invoice_url'] ), |
|
731 | + __('You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
732 | + human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])), |
|
733 | + urldecode($subscription['invoice_url']), |
|
734 | 734 | $subscription['payment_id'], |
735 | 735 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
736 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
736 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
737 | 737 | ); |
738 | 738 | } |
739 | 739 | } |
740 | 740 | |
741 | 741 | // Stop validation for these licencse keys. |
742 | - $addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] ); |
|
742 | + $addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']); |
|
743 | 743 | } |
744 | 744 | $showed_subscriptions_message = true; |
745 | 745 | } |
746 | 746 | |
747 | 747 | // Show non subscription addon messages. |
748 | - if( ! in_array( $this->license, $addon_license_key_in_subscriptions ) && ! $this->__is_notice_dismissed( 'general' ) && ! $this->is_valid_license() && empty( $showed_invalid_message ) ) { |
|
748 | + if ( ! in_array($this->license, $addon_license_key_in_subscriptions) && ! $this->__is_notice_dismissed('general') && ! $this->is_valid_license() && empty($showed_invalid_message)) { |
|
749 | 749 | |
750 | 750 | $messages['general'] = sprintf( |
751 | - __( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
752 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
751 | + __('You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
752 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
753 | 753 | ); |
754 | 754 | $showed_invalid_message = true; |
755 | 755 | |
756 | 756 | } |
757 | 757 | |
758 | 758 | // Print messages. |
759 | - if( ! empty( $messages ) ) { |
|
760 | - foreach( $messages as $notice_id => $message ) { |
|
761 | - echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="' . esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ) . '">'; |
|
762 | - echo '<p>' . $message . '</p>'; |
|
759 | + if ( ! empty($messages)) { |
|
760 | + foreach ($messages as $notice_id => $message) { |
|
761 | + echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="'.esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])).'">'; |
|
762 | + echo '<p>'.$message.'</p>'; |
|
763 | 763 | echo '</div>'; |
764 | 764 | } |
765 | 765 | } |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | * @return bool |
775 | 775 | */ |
776 | 776 | public function is_valid_license() { |
777 | - if( apply_filters( 'give_is_valid_license' , ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' )&& 'valid' === $this->license_data->license ) ) ) { |
|
777 | + if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) { |
|
778 | 778 | return true; |
779 | 779 | } |
780 | 780 | |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | * @return bool |
791 | 791 | */ |
792 | 792 | private function __is_third_party_addon() { |
793 | - return ( false === strpos( $this->api_url, 'givewp.com/' ) ); |
|
793 | + return (false === strpos($this->api_url, 'givewp.com/')); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | /** |
@@ -804,26 +804,26 @@ discard block |
||
804 | 804 | * |
805 | 805 | * @return void|bool |
806 | 806 | */ |
807 | - private function __remove_license_key_from_subscriptions(){ |
|
808 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
807 | + private function __remove_license_key_from_subscriptions() { |
|
808 | + $subscriptions = get_option('give_subscriptions', array()); |
|
809 | 809 | |
810 | 810 | // Bailout. |
811 | - if( empty( $this->license ) ) { |
|
811 | + if (empty($this->license)) { |
|
812 | 812 | return false; |
813 | 813 | } |
814 | 814 | |
815 | - if( ! empty( $subscriptions ) ) { |
|
816 | - foreach ( $subscriptions as $subscription_id => $subscription ) { |
|
817 | - $license_index = array_search( $this->license, $subscription['licenses'] ); |
|
818 | - if( false !== $license_index ) { |
|
815 | + if ( ! empty($subscriptions)) { |
|
816 | + foreach ($subscriptions as $subscription_id => $subscription) { |
|
817 | + $license_index = array_search($this->license, $subscription['licenses']); |
|
818 | + if (false !== $license_index) { |
|
819 | 819 | // Remove license key. |
820 | - unset( $subscriptions[ $subscription_id ]['licenses'][$license_index] ); |
|
820 | + unset($subscriptions[$subscription_id]['licenses'][$license_index]); |
|
821 | 821 | |
822 | 822 | // Rearrange license keys. |
823 | - $subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] ); |
|
823 | + $subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']); |
|
824 | 824 | |
825 | 825 | // Update subscription information. |
826 | - update_option( 'give_subscriptions', $subscriptions ); |
|
826 | + update_option('give_subscriptions', $subscriptions); |
|
827 | 827 | break; |
828 | 828 | } |
829 | 829 | } |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | * |
839 | 839 | * @return void |
840 | 840 | */ |
841 | - private function __remove_license_notices_show_blocker(){ |
|
841 | + private function __remove_license_notices_show_blocker() { |
|
842 | 842 | global $wpdb; |
843 | 843 | |
844 | 844 | // Delete permanent notice blocker. |
@@ -876,18 +876,18 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return bool |
878 | 878 | */ |
879 | - private function __is_notice_dismissed( $notice_id ){ |
|
879 | + private function __is_notice_dismissed($notice_id) { |
|
880 | 880 | $current_user = wp_get_current_user(); |
881 | 881 | $is_notice_dismissed = false; |
882 | 882 | |
883 | 883 | // Ge is notice dismissed permanently. |
884 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
884 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
885 | 885 | ? $already_dismiss_notices |
886 | 886 | : array(); |
887 | 887 | |
888 | 888 | |
889 | - if( in_array( $notice_id, $already_dismiss_notices ) || get_transient( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}" ) ) { |
|
890 | - $is_notice_dismissed = true; |
|
889 | + if (in_array($notice_id, $already_dismiss_notices) || get_transient("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}")) { |
|
890 | + $is_notice_dismissed = true; |
|
891 | 891 | } |
892 | 892 | |
893 | 893 | return $is_notice_dismissed; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param $data |
23 | 23 | */ |
24 | -function give_process_gateway_select( $data ) { |
|
25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
24 | +function give_process_gateway_select($data) { |
|
25 | + if (isset($_POST['gateway_submit'])) { |
|
26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Loads a payment gateway via AJAX |
@@ -38,20 +38,20 @@ discard block |
||
38 | 38 | * @return void |
39 | 39 | */ |
40 | 40 | function give_load_ajax_gateway() { |
41 | - if ( isset( $_POST['give_payment_mode'] ) ) { |
|
41 | + if (isset($_POST['give_payment_mode'])) { |
|
42 | 42 | /** |
43 | 43 | * Fire to render donation form. |
44 | 44 | * |
45 | 45 | * @since 1.7 |
46 | 46 | */ |
47 | - do_action( 'give_donation_form', $_POST['give_form_id'] ); |
|
47 | + do_action('give_donation_form', $_POST['give_form_id']); |
|
48 | 48 | |
49 | 49 | exit(); |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
54 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
53 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
54 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Sets an error on checkout if no gateways are enabled |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | function give_no_gateway_error() { |
64 | 64 | $gateways = give_get_enabled_payment_gateways(); |
65 | 65 | |
66 | - if ( empty( $gateways ) ) { |
|
67 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
66 | + if (empty($gateways)) { |
|
67 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
68 | 68 | } else { |
69 | - give_unset_error( 'no_gateways' ); |
|
69 | + give_unset_error('no_gateways'); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | -add_action( 'init', 'give_no_gateway_error' ); |
|
73 | +add_action('init', 'give_no_gateway_error'); |
@@ -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,35 +38,35 @@ 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 | |
55 | - if ( empty( $form_id ) ) { |
|
55 | + if (empty($form_id)) { |
|
56 | 56 | |
57 | 57 | // Global sale stats |
58 | - add_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
58 | + add_filter('give_count_payments_where', array($this, 'count_where')); |
|
59 | 59 | |
60 | - if ( is_array( $status ) ) { |
|
60 | + if (is_array($status)) { |
|
61 | 61 | $count = 0; |
62 | - foreach ( $status as $payment_status ) { |
|
62 | + foreach ($status as $payment_status) { |
|
63 | 63 | $count += give_count_payments()->$payment_status; |
64 | 64 | } |
65 | 65 | } else { |
66 | 66 | $count = give_count_payments()->$status; |
67 | 67 | } |
68 | 68 | |
69 | - remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
69 | + remove_filter('give_count_payments_where', array($this, 'count_where')); |
|
70 | 70 | |
71 | 71 | } else { |
72 | 72 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | // Product specific stats |
76 | 76 | global $give_logs; |
77 | 77 | |
78 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
78 | + add_filter('posts_where', array($this, 'payments_where')); |
|
79 | 79 | |
80 | - $count = $give_logs->get_log_count( $form_id, 'sale' ); |
|
80 | + $count = $give_logs->get_log_count($form_id, 'sale'); |
|
81 | 81 | |
82 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
82 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
@@ -101,31 +101,31 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return float|int Total amount of donations based on the passed arguments. |
103 | 103 | */ |
104 | - public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
104 | + public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
105 | 105 | |
106 | 106 | global $wpdb; |
107 | 107 | |
108 | - $this->setup_dates( $start_date, $end_date ); |
|
108 | + $this->setup_dates($start_date, $end_date); |
|
109 | 109 | |
110 | 110 | // Make sure start date is valid |
111 | - if ( is_wp_error( $this->start_date ) ) { |
|
111 | + if (is_wp_error($this->start_date)) { |
|
112 | 112 | return $this->start_date; |
113 | 113 | } |
114 | 114 | |
115 | 115 | // Make sure end date is valid |
116 | - if ( is_wp_error( $this->end_date ) ) { |
|
116 | + if (is_wp_error($this->end_date)) { |
|
117 | 117 | return $this->end_date; |
118 | 118 | } |
119 | 119 | |
120 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
120 | + add_filter('posts_where', array($this, 'payments_where')); |
|
121 | 121 | |
122 | - if ( empty( $form_id ) ) { |
|
122 | + if (empty($form_id)) { |
|
123 | 123 | |
124 | 124 | // Global earning stats |
125 | 125 | $args = array( |
126 | 126 | 'post_type' => 'give_payment', |
127 | 127 | 'nopaging' => true, |
128 | - 'post_status' => array( 'publish' ), |
|
128 | + 'post_status' => array('publish'), |
|
129 | 129 | 'fields' => 'ids', |
130 | 130 | 'update_post_term_cache' => false, |
131 | 131 | 'suppress_filters' => false, |
@@ -137,24 +137,24 @@ discard block |
||
137 | 137 | ); |
138 | 138 | |
139 | 139 | //Filter by Gateway ID meta_key |
140 | - if ( $gateway_id !== false ) { |
|
140 | + if ($gateway_id !== false) { |
|
141 | 141 | $args['meta_key'] = '_give_payment_gateway'; |
142 | 142 | $args['meta_value'] = $gateway_id; |
143 | 143 | } |
144 | 144 | |
145 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
146 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
147 | - $earnings = get_transient( $key ); |
|
145 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
146 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
147 | + $earnings = get_transient($key); |
|
148 | 148 | |
149 | - if ( false === $earnings ) { |
|
150 | - $sales = get_posts( $args ); |
|
149 | + if (false === $earnings) { |
|
150 | + $sales = get_posts($args); |
|
151 | 151 | $earnings = 0; |
152 | - if ( $sales ) { |
|
153 | - $sales = implode( ',', array_map('intval', $sales ) ); |
|
154 | - $earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" ); |
|
152 | + if ($sales) { |
|
153 | + $sales = implode(',', array_map('intval', $sales)); |
|
154 | + $earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})"); |
|
155 | 155 | } |
156 | 156 | // Cache the results for one hour |
157 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
157 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } else { |
@@ -174,37 +174,37 @@ discard block |
||
174 | 174 | 'give_transient_type' => 'give_earnings', |
175 | 175 | // This is not a valid query arg, but is used for cache keying |
176 | 176 | ); |
177 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
178 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
177 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
178 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
179 | 179 | //Set transient for faster stats |
180 | - $earnings = get_transient( $key ); |
|
180 | + $earnings = get_transient($key); |
|
181 | 181 | |
182 | - if ( false === $earnings ) { |
|
182 | + if (false === $earnings) { |
|
183 | 183 | |
184 | 184 | $this->timestamp = false; |
185 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
185 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
186 | 186 | $earnings = 0; |
187 | 187 | |
188 | - if ( $log_ids ) { |
|
189 | - $log_ids = implode( ',', array_map('intval', $log_ids ) ); |
|
190 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" ); |
|
188 | + if ($log_ids) { |
|
189 | + $log_ids = implode(',', array_map('intval', $log_ids)); |
|
190 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);"); |
|
191 | 191 | |
192 | - foreach ( $payment_ids as $payment_id ) { |
|
193 | - $earnings += give_get_payment_amount( $payment_id ); |
|
192 | + foreach ($payment_ids as $payment_id) { |
|
193 | + $earnings += give_get_payment_amount($payment_id); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | } |
197 | 197 | |
198 | 198 | // Cache the results for one hour |
199 | - set_transient( $key, $earnings, 60 * 60 ); |
|
199 | + set_transient($key, $earnings, 60 * 60); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | 203 | //remove our filter |
204 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
204 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
205 | 205 | |
206 | 206 | //return earnings |
207 | - return round( $earnings, give_currency_decimal_filter() ); |
|
207 | + return round($earnings, give_currency_decimal_filter()); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,29 +221,29 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return float|int Total amount of donations based on the passed arguments. |
223 | 223 | */ |
224 | - public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
224 | + public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
225 | 225 | |
226 | - $this->setup_dates( $start_date, $end_date ); |
|
226 | + $this->setup_dates($start_date, $end_date); |
|
227 | 227 | |
228 | 228 | // Make sure start date is valid |
229 | - if ( is_wp_error( $this->start_date ) ) { |
|
229 | + if (is_wp_error($this->start_date)) { |
|
230 | 230 | return $this->start_date; |
231 | 231 | } |
232 | 232 | |
233 | 233 | // Make sure end date is valid |
234 | - if ( is_wp_error( $this->end_date ) ) { |
|
234 | + if (is_wp_error($this->end_date)) { |
|
235 | 235 | return $this->end_date; |
236 | 236 | } |
237 | 237 | |
238 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
238 | + add_filter('posts_where', array($this, 'payments_where')); |
|
239 | 239 | |
240 | - if ( empty( $form_id ) ) { |
|
240 | + if (empty($form_id)) { |
|
241 | 241 | |
242 | 242 | // Global earning stats |
243 | 243 | $args = array( |
244 | 244 | 'post_type' => 'give_payment', |
245 | 245 | 'nopaging' => true, |
246 | - 'post_status' => array( 'publish' ), |
|
246 | + 'post_status' => array('publish'), |
|
247 | 247 | 'fields' => 'ids', |
248 | 248 | 'update_post_term_cache' => false, |
249 | 249 | 'suppress_filters' => false, |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | ); |
256 | 256 | |
257 | 257 | //Filter by Gateway ID meta_key |
258 | - if ( $gateway_id !== false ) { |
|
258 | + if ($gateway_id !== false) { |
|
259 | 259 | $args['meta_key'] = '_give_payment_gateway'; |
260 | 260 | $args['meta_value'] = $gateway_id; |
261 | 261 | } |
262 | 262 | |
263 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
264 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
263 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
264 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
265 | 265 | |
266 | 266 | } else { |
267 | 267 | |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | 'give_transient_type' => 'give_earnings', |
281 | 281 | // This is not a valid query arg, but is used for cache keying |
282 | 282 | ); |
283 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
284 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
283 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
284 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | //remove our filter |
288 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
288 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
289 | 289 | |
290 | 290 | //return earnings |
291 | 291 | return $key; |
@@ -302,16 +302,16 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @return array Best selling forms |
304 | 304 | */ |
305 | - public function get_best_selling( $number = 10 ) { |
|
305 | + public function get_best_selling($number = 10) { |
|
306 | 306 | |
307 | 307 | global $wpdb; |
308 | 308 | |
309 | - $give_forms = $wpdb->get_results( $wpdb->prepare( |
|
309 | + $give_forms = $wpdb->get_results($wpdb->prepare( |
|
310 | 310 | "SELECT post_id as form_id, max(meta_value) as sales |
311 | 311 | FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0 |
312 | 312 | GROUP BY meta_value+0 |
313 | 313 | DESC LIMIT %d;", $number |
314 | - ) ); |
|
314 | + )); |
|
315 | 315 | |
316 | 316 | return $give_forms; |
317 | 317 | } |
@@ -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 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @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`. |
100 | 100 | * @param $gateway_id string|bool The gateway to get earnings for such as 'paypal' or 'stripe'. |
101 | 101 | * |
102 | - * @return float|int Total amount of donations based on the passed arguments. |
|
102 | + * @return string Total amount of donations based on the passed arguments. |
|
103 | 103 | */ |
104 | 104 | public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
105 | 105 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @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` |
220 | 220 | * @param $gateway_id string|bool The gateway to get earnings for such as 'paypal' or 'stripe' |
221 | 221 | * |
222 | - * @return float|int Total amount of donations based on the passed arguments. |
|
222 | + * @return string Total amount of donations based on the passed arguments. |
|
223 | 223 | */ |
224 | 224 | public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
225 | 225 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -41,20 +41,20 @@ discard block |
||
41 | 41 | public function csv_cols() { |
42 | 42 | |
43 | 43 | $cols = array( |
44 | - 'ID' => esc_html__( 'ID', 'give' ), |
|
45 | - 'post_name' => esc_html__( 'Slug', 'give' ), |
|
46 | - 'post_title' => esc_html__( 'Name', 'give' ), |
|
47 | - 'post_date' => esc_html__( 'Date Created', 'give' ), |
|
48 | - 'post_author' => esc_html__( 'Author', 'give' ), |
|
49 | - 'post_content' => esc_html__( 'Description', 'give' ), |
|
50 | - 'post_excerpt' => esc_html__( 'Excerpt', 'give' ), |
|
51 | - 'post_status' => esc_html__( 'Status', 'give' ), |
|
52 | - 'categories' => esc_html__( 'Categories', 'give' ), |
|
53 | - 'tags' => esc_html__( 'Tags', 'give' ), |
|
54 | - 'give_price' => esc_html__( 'Price', 'give' ), |
|
55 | - '_thumbnail_id' => esc_html__( 'Featured Image', 'give' ), |
|
56 | - '_give_form_sales' => esc_html__( 'Donations', 'give' ), |
|
57 | - '_give_download_earnings' => esc_html__( 'Income', 'give' ), |
|
44 | + 'ID' => esc_html__('ID', 'give'), |
|
45 | + 'post_name' => esc_html__('Slug', 'give'), |
|
46 | + 'post_title' => esc_html__('Name', 'give'), |
|
47 | + 'post_date' => esc_html__('Date Created', 'give'), |
|
48 | + 'post_author' => esc_html__('Author', 'give'), |
|
49 | + 'post_content' => esc_html__('Description', 'give'), |
|
50 | + 'post_excerpt' => esc_html__('Excerpt', 'give'), |
|
51 | + 'post_status' => esc_html__('Status', 'give'), |
|
52 | + 'categories' => esc_html__('Categories', 'give'), |
|
53 | + 'tags' => esc_html__('Tags', 'give'), |
|
54 | + 'give_price' => esc_html__('Price', 'give'), |
|
55 | + '_thumbnail_id' => esc_html__('Featured Image', 'give'), |
|
56 | + '_give_form_sales' => esc_html__('Donations', 'give'), |
|
57 | + '_give_download_earnings' => esc_html__('Income', 'give'), |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | return $cols; |
@@ -86,43 +86,43 @@ discard block |
||
86 | 86 | 'paged' => $this->step |
87 | 87 | ); |
88 | 88 | |
89 | - $downloads = new WP_Query( $args ); |
|
89 | + $downloads = new WP_Query($args); |
|
90 | 90 | |
91 | - if ( $downloads->posts ) { |
|
92 | - foreach ( $downloads->posts as $download ) { |
|
91 | + if ($downloads->posts) { |
|
92 | + foreach ($downloads->posts as $download) { |
|
93 | 93 | |
94 | 94 | $row = array(); |
95 | 95 | |
96 | - foreach ( $this->csv_cols() as $key => $value ) { |
|
96 | + foreach ($this->csv_cols() as $key => $value) { |
|
97 | 97 | |
98 | 98 | // Setup default value |
99 | - $row[ $key ] = ''; |
|
99 | + $row[$key] = ''; |
|
100 | 100 | |
101 | - if ( in_array( $key, $meta ) ) { |
|
101 | + if (in_array($key, $meta)) { |
|
102 | 102 | |
103 | - switch ( $key ) { |
|
103 | + switch ($key) { |
|
104 | 104 | |
105 | 105 | case '_thumbnail_id' : |
106 | 106 | |
107 | - $image_id = get_post_thumbnail_id( $download->ID ); |
|
108 | - $row[ $key ] = wp_get_attachment_url( $image_id ); |
|
107 | + $image_id = get_post_thumbnail_id($download->ID); |
|
108 | + $row[$key] = wp_get_attachment_url($image_id); |
|
109 | 109 | |
110 | 110 | break; |
111 | 111 | |
112 | 112 | case 'give_price' : |
113 | 113 | |
114 | - if ( give_has_variable_prices( $download->ID ) ) { |
|
114 | + if (give_has_variable_prices($download->ID)) { |
|
115 | 115 | |
116 | 116 | $prices = array(); |
117 | - foreach ( give_get_variable_prices( $download->ID ) as $price ) { |
|
118 | - $prices[] = $price['name'] . ': ' . $price['amount']; |
|
117 | + foreach (give_get_variable_prices($download->ID) as $price) { |
|
118 | + $prices[] = $price['name'].': '.$price['amount']; |
|
119 | 119 | } |
120 | 120 | |
121 | - $row[ $key ] = implode( ' | ', $prices ); |
|
121 | + $row[$key] = implode(' | ', $prices); |
|
122 | 122 | |
123 | 123 | } else { |
124 | 124 | |
125 | - $row[ $key ] = give_get_download_price( $download->ID ); |
|
125 | + $row[$key] = give_get_download_price($download->ID); |
|
126 | 126 | |
127 | 127 | } |
128 | 128 | |
@@ -132,54 +132,54 @@ discard block |
||
132 | 132 | |
133 | 133 | |
134 | 134 | $files = array(); |
135 | - foreach ( give_get_download_files( $download->ID ) as $file ) { |
|
135 | + foreach (give_get_download_files($download->ID) as $file) { |
|
136 | 136 | $files[] = $file['file']; |
137 | 137 | } |
138 | 138 | |
139 | - $row[ $key ] = implode( ' | ', $files ); |
|
139 | + $row[$key] = implode(' | ', $files); |
|
140 | 140 | |
141 | 141 | break; |
142 | 142 | |
143 | 143 | default : |
144 | 144 | |
145 | - $row[ $key ] = get_post_meta( $download->ID, $key, true ); |
|
145 | + $row[$key] = get_post_meta($download->ID, $key, true); |
|
146 | 146 | |
147 | 147 | break; |
148 | 148 | |
149 | 149 | } |
150 | 150 | |
151 | - } elseif ( isset( $download->$key ) ) { |
|
151 | + } elseif (isset($download->$key)) { |
|
152 | 152 | |
153 | - switch ( $key ) { |
|
153 | + switch ($key) { |
|
154 | 154 | |
155 | 155 | case 'post_author' : |
156 | 156 | |
157 | - $row[ $key ] = get_the_author_meta( 'user_login', $download->post_author ); |
|
157 | + $row[$key] = get_the_author_meta('user_login', $download->post_author); |
|
158 | 158 | |
159 | 159 | break; |
160 | 160 | |
161 | 161 | default : |
162 | 162 | |
163 | - $row[ $key ] = $download->$key; |
|
163 | + $row[$key] = $download->$key; |
|
164 | 164 | |
165 | 165 | break; |
166 | 166 | } |
167 | 167 | |
168 | - } elseif ( 'tags' == $key ) { |
|
168 | + } elseif ('tags' == $key) { |
|
169 | 169 | |
170 | - $terms = get_the_terms( $download->ID, 'download_tag' ); |
|
171 | - if ( $terms ) { |
|
172 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
173 | - $row[ $key ] = implode( ' | ', $terms ); |
|
170 | + $terms = get_the_terms($download->ID, 'download_tag'); |
|
171 | + if ($terms) { |
|
172 | + $terms = wp_list_pluck($terms, 'name'); |
|
173 | + $row[$key] = implode(' | ', $terms); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
177 | - } elseif ( 'categories' == $key ) { |
|
177 | + } elseif ('categories' == $key) { |
|
178 | 178 | |
179 | - $terms = get_the_terms( $download->ID, 'download_category' ); |
|
180 | - if ( $terms ) { |
|
181 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
182 | - $row[ $key ] = implode( ' | ', $terms ); |
|
179 | + $terms = get_the_terms($download->ID, 'download_category'); |
|
180 | + if ($terms) { |
|
181 | + $terms = wp_list_pluck($terms, 'name'); |
|
182 | + $row[$key] = implode(' | ', $terms); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | } |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | |
191 | 191 | } |
192 | 192 | |
193 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
194 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
193 | + $data = apply_filters('give_export_get_data', $data); |
|
194 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
195 | 195 | |
196 | 196 | return $data; |
197 | 197 | } |
@@ -210,20 +210,20 @@ discard block |
||
210 | 210 | |
211 | 211 | $args = array( |
212 | 212 | 'post_type' => 'give_forms', |
213 | - 'posts_per_page' => - 1, |
|
213 | + 'posts_per_page' => -1, |
|
214 | 214 | 'post_status' => 'any', |
215 | 215 | 'fields' => 'ids', |
216 | 216 | ); |
217 | 217 | |
218 | - $downloads = new WP_Query( $args ); |
|
218 | + $downloads = new WP_Query($args); |
|
219 | 219 | $total = (int) $downloads->post_count; |
220 | 220 | $percentage = 100; |
221 | 221 | |
222 | - if ( $total > 0 ) { |
|
223 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
222 | + if ($total > 0) { |
|
223 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
224 | 224 | } |
225 | 225 | |
226 | - if ( $percentage > 100 ) { |
|
226 | + if ($percentage > 100) { |
|
227 | 227 | $percentage = 100; |
228 | 228 | } |
229 | 229 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @return bool Whether we can export or not |
38 | 38 | */ |
39 | 39 | public function can_export() { |
40 | - return (bool) apply_filters( 'give_export_capability', current_user_can( 'export_give_reports' ) ); |
|
40 | + return (bool) apply_filters('give_export_capability', current_user_can('export_give_reports')); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | * @return void |
49 | 49 | */ |
50 | 50 | public function headers() { |
51 | - ignore_user_abort( true ); |
|
51 | + ignore_user_abort(true); |
|
52 | 52 | |
53 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
54 | - set_time_limit( 0 ); |
|
53 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
54 | + set_time_limit(0); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | nocache_headers(); |
58 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
59 | - header( 'Content-Disposition: attachment; filename=give-export-' . $this->export_type . '-' . date( 'm-d-Y' ) . '.csv' ); |
|
60 | - header( "Expires: 0" ); |
|
58 | + header('Content-Type: text/csv; charset=utf-8'); |
|
59 | + header('Content-Disposition: attachment; filename=give-export-'.$this->export_type.'-'.date('m-d-Y').'.csv'); |
|
60 | + header("Expires: 0"); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function csv_cols() { |
71 | 71 | $cols = array( |
72 | - 'id' => esc_html__( 'ID', 'give' ), |
|
73 | - 'date' => esc_html__( 'Date', 'give' ) |
|
72 | + 'id' => esc_html__('ID', 'give'), |
|
73 | + 'date' => esc_html__('Date', 'give') |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | return $cols; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function get_csv_cols() { |
87 | 87 | $cols = $this->csv_cols(); |
88 | 88 | |
89 | - return apply_filters( "give_export_csv_cols_{$this->export_type}", $cols ); |
|
89 | + return apply_filters("give_export_csv_cols_{$this->export_type}", $cols); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | public function csv_cols_out() { |
101 | 101 | $cols = $this->get_csv_cols(); |
102 | 102 | $i = 1; |
103 | - foreach ( $cols as $col_id => $column ) { |
|
104 | - echo '"' . addslashes( $column ) . '"'; |
|
105 | - echo $i == count( $cols ) ? '' : ','; |
|
106 | - $i ++; |
|
103 | + foreach ($cols as $col_id => $column) { |
|
104 | + echo '"'.addslashes($column).'"'; |
|
105 | + echo $i == count($cols) ? '' : ','; |
|
106 | + $i++; |
|
107 | 107 | } |
108 | 108 | echo "\r\n"; |
109 | 109 | } |
@@ -120,16 +120,16 @@ discard block |
||
120 | 120 | $data = array( |
121 | 121 | 0 => array( |
122 | 122 | 'id' => '', |
123 | - 'data' => date( 'F j, Y' ) |
|
123 | + 'data' => date('F j, Y') |
|
124 | 124 | ), |
125 | 125 | 1 => array( |
126 | 126 | 'id' => '', |
127 | - 'data' => date( 'F j, Y' ) |
|
127 | + 'data' => date('F j, Y') |
|
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | |
131 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
132 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
131 | + $data = apply_filters('give_export_get_data', $data); |
|
132 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
133 | 133 | |
134 | 134 | return $data; |
135 | 135 | } |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | $cols = $this->get_csv_cols(); |
148 | 148 | |
149 | 149 | // Output each row |
150 | - foreach ( $data as $row ) { |
|
150 | + foreach ($data as $row) { |
|
151 | 151 | $i = 1; |
152 | - foreach ( $row as $col_id => $column ) { |
|
152 | + foreach ($row as $col_id => $column) { |
|
153 | 153 | // Make sure the column is valid |
154 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
155 | - echo '"' . addslashes( $column ) . '"'; |
|
156 | - echo $i == count( $cols ) ? '' : ','; |
|
157 | - $i ++; |
|
154 | + if (array_key_exists($col_id, $cols)) { |
|
155 | + echo '"'.addslashes($column).'"'; |
|
156 | + echo $i == count($cols) ? '' : ','; |
|
157 | + $i++; |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | echo "\r\n"; |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @return void |
174 | 174 | */ |
175 | 175 | public function export() { |
176 | - if ( ! $this->can_export() ) { |
|
177 | - wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
176 | + if ( ! $this->can_export()) { |
|
177 | + wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | // Set headers |