@@ -6,7 +6,7 @@ |
||
6 | 6 | * @version 1.0 |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
9 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly. |
|
10 | 10 | |
11 | 11 | // {email} is replaced by the content entered in Donations > Settings > Emails |
12 | 12 |
@@ -6,7 +6,10 @@ |
||
6 | 6 | * @version 1.0 |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
9 | +if ( ! defined( 'ABSPATH' ) ) { |
|
10 | + exit; |
|
11 | +} |
|
12 | +// Exit if accessed directly. |
|
10 | 13 | |
11 | 14 | // {email} is replaced by the content entered in Donations > Settings > Emails |
12 | 15 |
@@ -6,7 +6,7 @@ |
||
6 | 6 | * @version 1.0 |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
9 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly. |
|
10 | 10 | |
11 | 11 | // This is the footer used if no others are available |
12 | 12 |
@@ -6,7 +6,10 @@ |
||
6 | 6 | * @version 1.0 |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
9 | +if ( ! defined( 'ABSPATH' ) ) { |
|
10 | + exit; |
|
11 | +} |
|
12 | +// Exit if accessed directly. |
|
10 | 13 | |
11 | 14 | // This is the footer used if no others are available |
12 | 15 |
@@ -6,7 +6,7 @@ |
||
6 | 6 | * @version 1.0 |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
9 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly. |
|
10 | 10 | |
11 | 11 | // {email} is replaced by the content entered in Donations > Settings > Emails |
12 | 12 |
@@ -6,7 +6,10 @@ |
||
6 | 6 | * @version 1.0 |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
9 | +if ( ! defined( 'ABSPATH' ) ) { |
|
10 | + exit; |
|
11 | +} |
|
12 | +// Exit if accessed directly. |
|
10 | 13 | |
11 | 14 | // {email} is replaced by the content entered in Donations > Settings > Emails |
12 | 15 |
@@ -39,8 +39,8 @@ |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | if ( ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
42 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
43 | - && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
42 | + || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
43 | + && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
44 | 44 | ) { |
45 | 45 | |
46 | 46 | $forms_singular_option = give_get_option( 'forms_singular' ); |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | * @return void |
20 | 20 | */ |
21 | 21 | function give_disable_mandrill_nl2br() { |
22 | - add_filter( 'mandrill_nl2br', '__return_false' ); |
|
22 | + add_filter('mandrill_nl2br', '__return_false'); |
|
23 | 23 | } |
24 | 24 | |
25 | -add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br' ); |
|
25 | +add_action('give_email_send_before', 'give_disable_mandrill_nl2br'); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,33 +34,33 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function give_clear_seo_sitemap_cache_on_settings_change() { |
36 | 36 | // Load required file if the fn 'is_plugin_active' doesn't exists. |
37 | - if ( ! function_exists( 'is_plugin_active' ) ) { |
|
38 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
37 | + if ( ! function_exists('is_plugin_active')) { |
|
38 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
39 | 39 | } |
40 | 40 | |
41 | - if ( ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
|
42 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
43 | - && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
41 | + if ((is_plugin_active('wordpress-seo/wp-seo.php') |
|
42 | + || is_plugin_active('wordpress-seo-premium/wp-seo-premium.php')) |
|
43 | + && class_exists('WPSEO_Sitemaps_Cache') |
|
44 | 44 | ) { |
45 | 45 | |
46 | - $forms_singular_option = give_get_option( 'forms_singular' ); |
|
47 | - $forms_archive_option = give_get_option( 'forms_singular' ); |
|
46 | + $forms_singular_option = give_get_option('forms_singular'); |
|
47 | + $forms_archive_option = give_get_option('forms_singular'); |
|
48 | 48 | |
49 | 49 | // If there is change detected for Single Form View and Form Archives options then proceed. |
50 | 50 | if ( |
51 | - ( isset( $_POST['forms_singular'] ) && $_POST['forms_singular'] !== $forms_singular_option ) || |
|
52 | - ( isset( $_POST['forms_archives'] ) && $_POST['forms_archives'] !== $forms_archive_option ) |
|
51 | + (isset($_POST['forms_singular']) && $_POST['forms_singular'] !== $forms_singular_option) || |
|
52 | + (isset($_POST['forms_archives']) && $_POST['forms_archives'] !== $forms_archive_option) |
|
53 | 53 | ) { |
54 | 54 | // If Yoast SEO or Yoast SEO Premium plugin exists, then update seo sitemap cache. |
55 | 55 | $yoast_sitemaps_cache = new WPSEO_Sitemaps_Cache(); |
56 | - if ( method_exists( $yoast_sitemaps_cache, 'clear' ) ) { |
|
56 | + if (method_exists($yoast_sitemaps_cache, 'clear')) { |
|
57 | 57 | WPSEO_Sitemaps_Cache::clear(); |
58 | 58 | } |
59 | 59 | } |
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -add_action( 'give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change' ); |
|
63 | +add_action('give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change'); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * This is support for the plugin Elementor. This function |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * Is the plugin: Elementor activated? |
80 | 80 | */ |
81 | - if ( is_plugin_active( 'elementor/elementor.php' ) ) { |
|
81 | + if (is_plugin_active('elementor/elementor.php')) { |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * Check user is on the Elementor's editor page, then hide Give Shortcodes Button. |
85 | 85 | */ |
86 | - if ( isset( $_GET['action'] ) && 'elementor' === give_clean( $_GET['action'] ) ) { |
|
86 | + if (isset($_GET['action']) && 'elementor' === give_clean($_GET['action'])) { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | } |
@@ -91,4 +91,4 @@ discard block |
||
91 | 91 | return true; |
92 | 92 | } |
93 | 93 | |
94 | -add_filter( 'give_shortcode_button_condition', 'give_elementor_hide_shortcodes_button', 11 ); |
|
94 | +add_filter('give_shortcode_button_condition', 'give_elementor_hide_shortcodes_button', 11); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * Return the calculated completion percentage. |
217 | 217 | * |
218 | 218 | * @since 1.8.12 |
219 | - * @return int |
|
219 | + * @return double |
|
220 | 220 | */ |
221 | 221 | public function get_percentage_complete() { |
222 | 222 | return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
@@ -353,6 +353,9 @@ discard block |
||
353 | 353 | return true; |
354 | 354 | } |
355 | 355 | |
356 | + /** |
|
357 | + * @param integer $page |
|
358 | + */ |
|
356 | 359 | public function get_delete_ids( $donation_ids, $page ) { |
357 | 360 | $index = $page --; |
358 | 361 | $count = count( $donation_ids ); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * Constructor. |
107 | 107 | */ |
108 | - public function __construct( $_step = 1 ) { |
|
109 | - parent::__construct( $_step ); |
|
108 | + public function __construct($_step = 1) { |
|
109 | + parent::__construct($_step); |
|
110 | 110 | |
111 | 111 | $this->is_writable = true; |
112 | 112 | } |
@@ -125,34 +125,34 @@ discard block |
||
125 | 125 | $donor_ids = array(); |
126 | 126 | |
127 | 127 | // Check if the ajax request if running for the first time. |
128 | - if ( 1 === (int) $this->step ) { |
|
128 | + if (1 === (int) $this->step) { |
|
129 | 129 | // Delete all the form ids. |
130 | - $this->delete_option( $this->form_key ); |
|
130 | + $this->delete_option($this->form_key); |
|
131 | 131 | // Delete all the donation ids. |
132 | - $this->delete_option( $this->donation_key ); |
|
132 | + $this->delete_option($this->donation_key); |
|
133 | 133 | // Delete all the donor ids. |
134 | - $this->delete_option( $this->donor_key ); |
|
134 | + $this->delete_option($this->donor_key); |
|
135 | 135 | |
136 | 136 | // Delete all the step and set to 'count' which if the first step in the process of deleting the donors. |
137 | - $this->update_option( $this->step_key, 'count' ); |
|
137 | + $this->update_option($this->step_key, 'count'); |
|
138 | 138 | |
139 | 139 | // Delete tha page count of the step. |
140 | - $this->update_option( $this->step_on_key, '0' ); |
|
140 | + $this->update_option($this->step_on_key, '0'); |
|
141 | 141 | } else { |
142 | 142 | // Get the old donors list. |
143 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
143 | + $donor_ids = $this->get_option($this->donor_key); |
|
144 | 144 | |
145 | 145 | // Get the old donation list. |
146 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
146 | + $donation_ids = $this->get_option($this->donation_key); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // Get the step and check for it if it's on the first step( 'count' ) or not. |
150 | 150 | $step = (int) $this->get_step(); |
151 | - if ( 1 === $step ) { |
|
151 | + if (1 === $step) { |
|
152 | 152 | /** |
153 | 153 | * Will add or update the donation and donor data by running wp query. |
154 | 154 | */ |
155 | - $this->count( $step, $donation_ids, $donor_ids ); |
|
155 | + $this->count($step, $donation_ids, $donor_ids); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
@@ -163,17 +163,17 @@ discard block |
||
163 | 163 | * @param array $donation_ids Contain the list of all the donation id's that has being add before this |
164 | 164 | * @param array $donor_ids Contain the list of all the donors id's that has being add before this |
165 | 165 | */ |
166 | - private function count( $step, $donation_ids = array(), $donor_ids = array() ) { |
|
166 | + private function count($step, $donation_ids = array(), $donor_ids = array()) { |
|
167 | 167 | |
168 | 168 | // Get the Page count by default it's zero. |
169 | 169 | $paged = (int) $this->get_step_page(); |
170 | 170 | // Incresed the page count by one. |
171 | - ++ $paged; |
|
171 | + ++$paged; |
|
172 | 172 | |
173 | 173 | /** |
174 | 174 | * Filter add to alter the argument before the wp quest run |
175 | 175 | */ |
176 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
176 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
177 | 177 | 'post_type' => 'give_payment', |
178 | 178 | 'post_status' => 'any', |
179 | 179 | 'posts_per_page' => $this->per_step, |
@@ -181,40 +181,40 @@ discard block |
||
181 | 181 | 'meta_key' => '_give_payment_import', |
182 | 182 | 'meta_value_num' => 1, |
183 | 183 | 'meta_compare' => '=', |
184 | - ) ); |
|
184 | + )); |
|
185 | 185 | |
186 | 186 | // Reset the post data. |
187 | 187 | wp_reset_postdata(); |
188 | 188 | // Getting the new donation. |
189 | - $donation_posts = new WP_Query( $args ); |
|
189 | + $donation_posts = new WP_Query($args); |
|
190 | 190 | |
191 | 191 | // The Loop. |
192 | - if ( $donation_posts->have_posts() ) { |
|
193 | - while ( $donation_posts->have_posts() ) { |
|
192 | + if ($donation_posts->have_posts()) { |
|
193 | + while ($donation_posts->have_posts()) { |
|
194 | 194 | $add_author = true; |
195 | 195 | $donation_posts->the_post(); |
196 | 196 | global $post; |
197 | 197 | // Add the donation id in side the array. |
198 | 198 | $donation_ids[] = $post->ID; |
199 | 199 | |
200 | - $donor_id = (int) give_get_meta( $post->ID, '_give_payment_customer_id', true ); |
|
201 | - if ( ! empty( $donor_id ) ) { |
|
202 | - $donor = new Give_Donor( $donor_id ); |
|
203 | - if ( ! empty( $donor->id ) ) { |
|
204 | - if ( empty( $donor->user_id ) && ! empty( $donor->payment_ids ) ) { |
|
200 | + $donor_id = (int) give_get_meta($post->ID, '_give_payment_customer_id', true); |
|
201 | + if ( ! empty($donor_id)) { |
|
202 | + $donor = new Give_Donor($donor_id); |
|
203 | + if ( ! empty($donor->id)) { |
|
204 | + if (empty($donor->user_id) && ! empty($donor->payment_ids)) { |
|
205 | 205 | $add_author = false; |
206 | - $count = (int) count( $donor->payment_ids ); |
|
207 | - if ( 1 === $count ) { |
|
208 | - Give()->donors->delete( $donor->id ); |
|
206 | + $count = (int) count($donor->payment_ids); |
|
207 | + if (1 === $count) { |
|
208 | + Give()->donors->delete($donor->id); |
|
209 | 209 | } else { |
210 | - $donor->remove_payment( $post->ID ); |
|
210 | + $donor->remove_payment($post->ID); |
|
211 | 211 | $donor->decrease_donation_count(); |
212 | 212 | } |
213 | 213 | } |
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | - if ( ! empty( $add_author ) ) { |
|
217 | + if ( ! empty($add_author)) { |
|
218 | 218 | // Add the donor id in side the array. |
219 | 219 | $donor_ids[] = (int) $post->post_author; |
220 | 220 | } |
@@ -229,23 +229,23 @@ discard block |
||
229 | 229 | $max_num_pages = (int) $donation_posts->max_num_pages; |
230 | 230 | |
231 | 231 | // Check current page is less then max number of page or not |
232 | - if ( $paged < $max_num_pages ) { |
|
232 | + if ($paged < $max_num_pages) { |
|
233 | 233 | // Update the curretn page virable for the next step |
234 | - $this->update_option( $this->step_on_key, $paged ); |
|
234 | + $this->update_option($this->step_on_key, $paged); |
|
235 | 235 | |
236 | 236 | // Calculating percentage. |
237 | 237 | $page_remain = $max_num_pages - $paged; |
238 | - $this->total_step = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) ); |
|
238 | + $this->total_step = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids)); |
|
239 | 239 | $this->step_completed = $paged; |
240 | 240 | } else { |
241 | - $donation_ids_count = count( $donor_ids ); |
|
242 | - $this->update_option( $this->step_key, 'donation' ); |
|
243 | - $this->update_option( $this->step_on_key, '0' ); |
|
241 | + $donation_ids_count = count($donor_ids); |
|
242 | + $this->update_option($this->step_key, 'donation'); |
|
243 | + $this->update_option($this->step_on_key, '0'); |
|
244 | 244 | } |
245 | 245 | |
246 | - $donor_ids = array_unique( $donor_ids ); |
|
247 | - $this->update_option( $this->donor_key, $donor_ids ); |
|
248 | - $this->update_option( $this->donation_key, $donation_ids ); |
|
246 | + $donor_ids = array_unique($donor_ids); |
|
247 | + $this->update_option($this->donor_key, $donor_ids); |
|
248 | + $this->update_option($this->donation_key, $donation_ids); |
|
249 | 249 | |
250 | 250 | wp_reset_postdata(); |
251 | 251 | } |
@@ -257,33 +257,33 @@ discard block |
||
257 | 257 | * @return int |
258 | 258 | */ |
259 | 259 | public function get_percentage_complete() { |
260 | - return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
|
260 | + return ceil((100 * $this->step_completed) / $this->total_step); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | public function process_step() { |
264 | 264 | |
265 | - if ( ! $this->can_export() ) { |
|
265 | + if ( ! $this->can_export()) { |
|
266 | 266 | wp_die( |
267 | - esc_html__( 'You do not have permission to delete Import transactions.', 'give' ), |
|
268 | - esc_html__( 'Error', 'give' ), |
|
269 | - array( 'response' => 403 ) |
|
267 | + esc_html__('You do not have permission to delete Import transactions.', 'give'), |
|
268 | + esc_html__('Error', 'give'), |
|
269 | + array('response' => 403) |
|
270 | 270 | ); |
271 | 271 | } |
272 | 272 | |
273 | 273 | $had_data = $this->get_data(); |
274 | 274 | |
275 | - if ( $had_data ) { |
|
275 | + if ($had_data) { |
|
276 | 276 | $this->done = false; |
277 | 277 | |
278 | 278 | return true; |
279 | 279 | } else { |
280 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
281 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
280 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
281 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
282 | 282 | |
283 | - $this->delete_option( $this->donation_key ); |
|
283 | + $this->delete_option($this->donation_key); |
|
284 | 284 | |
285 | 285 | $this->done = true; |
286 | - $this->message = __( 'Imported donor and transactions successfully deleted.', 'give' ); |
|
286 | + $this->message = __('Imported donor and transactions successfully deleted.', 'give'); |
|
287 | 287 | |
288 | 288 | return false; |
289 | 289 | } |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | public function get_data() { |
302 | 302 | |
303 | 303 | // Get the donation id's. |
304 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
304 | + $donation_ids = $this->get_option($this->donation_key); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Return false id not Import donation is found. |
308 | 308 | */ |
309 | - if ( empty( $donation_ids ) ) { |
|
309 | + if (empty($donation_ids)) { |
|
310 | 310 | $this->is_empty = true; |
311 | 311 | $this->total_step = 1; |
312 | 312 | |
@@ -317,110 +317,110 @@ discard block |
||
317 | 317 | $step = (int) $this->get_step(); |
318 | 318 | |
319 | 319 | // get teh donor ids. |
320 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
320 | + $donor_ids = $this->get_option($this->donor_key); |
|
321 | 321 | |
322 | 322 | // In step to we delete all the donation in loop. |
323 | - if ( 2 === $step ) { |
|
323 | + if (2 === $step) { |
|
324 | 324 | $pass_to_donor = false; |
325 | 325 | $page = (int) $this->get_step_page(); |
326 | - $page ++; |
|
327 | - $count = count( $donation_ids ); |
|
326 | + $page++; |
|
327 | + $count = count($donation_ids); |
|
328 | 328 | |
329 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
329 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
330 | 330 | $this->step_completed = $page; |
331 | 331 | |
332 | - if ( $count > $this->per_step ) { |
|
332 | + if ($count > $this->per_step) { |
|
333 | 333 | |
334 | - $this->update_option( $this->step_on_key, $page ); |
|
335 | - $donation_ids = $this->get_delete_ids( $donation_ids, $page ); |
|
336 | - $current_page = (int) ceil( $count / $this->per_step ); |
|
334 | + $this->update_option($this->step_on_key, $page); |
|
335 | + $donation_ids = $this->get_delete_ids($donation_ids, $page); |
|
336 | + $current_page = (int) ceil($count / $this->per_step); |
|
337 | 337 | |
338 | - if ( $page === $current_page ) { |
|
338 | + if ($page === $current_page) { |
|
339 | 339 | $pass_to_donor = true; |
340 | 340 | } |
341 | 341 | } else { |
342 | 342 | $pass_to_donor = true; |
343 | 343 | } |
344 | 344 | |
345 | - if ( true === $pass_to_donor ) { |
|
346 | - $this->update_option( $this->step_key, 'donor' ); |
|
347 | - $this->update_option( $this->step_on_key, '0' ); |
|
345 | + if (true === $pass_to_donor) { |
|
346 | + $this->update_option($this->step_key, 'donor'); |
|
347 | + $this->update_option($this->step_on_key, '0'); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | // Get the old form list. |
351 | - $form_ids = (array) $this->get_option( $this->form_key ); |
|
351 | + $form_ids = (array) $this->get_option($this->form_key); |
|
352 | 352 | |
353 | - foreach ( $donation_ids as $item ) { |
|
354 | - $form_ids[] = give_get_meta( $item, '_give_payment_form_id', true ); |
|
353 | + foreach ($donation_ids as $item) { |
|
354 | + $form_ids[] = give_get_meta($item, '_give_payment_form_id', true); |
|
355 | 355 | |
356 | 356 | // Delete the main payment. |
357 | - give_delete_donation( absint( $item ) ); |
|
357 | + give_delete_donation(absint($item)); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | // update the new form list. |
361 | - $this->update_option( $this->form_key, $form_ids ); |
|
361 | + $this->update_option($this->form_key, $form_ids); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | // Here we delete all the donor |
365 | - if ( 3 === $step ) { |
|
365 | + if (3 === $step) { |
|
366 | 366 | |
367 | 367 | // Get the old form list. |
368 | - $form_ids = (array) $this->get_option( $this->form_key ); |
|
369 | - if ( ! empty( $form_ids ) ) { |
|
370 | - $form_ids = array_unique( $form_ids ); |
|
371 | - foreach ( $form_ids as $form_id ) { |
|
372 | - give_recount_form_income_donation( (int) $form_id ); |
|
368 | + $form_ids = (array) $this->get_option($this->form_key); |
|
369 | + if ( ! empty($form_ids)) { |
|
370 | + $form_ids = array_unique($form_ids); |
|
371 | + foreach ($form_ids as $form_id) { |
|
372 | + give_recount_form_income_donation((int) $form_id); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | // update the new form list. |
376 | - $this->update_option( $this->form_key, array() ); |
|
376 | + $this->update_option($this->form_key, array()); |
|
377 | 377 | |
378 | 378 | $page = (int) $this->get_step_page(); |
379 | - $count = count( $donor_ids ); |
|
379 | + $count = count($donor_ids); |
|
380 | 380 | |
381 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
382 | - $this->step_completed = $page + ( count( $donation_ids ) / $this->per_step ); |
|
381 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
382 | + $this->step_completed = $page + (count($donation_ids) / $this->per_step); |
|
383 | 383 | |
384 | - if ( ! empty( $donor_ids[ $page ] ) ) { |
|
385 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
384 | + if ( ! empty($donor_ids[$page])) { |
|
385 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
386 | 386 | 'post_status' => 'any', |
387 | 387 | 'posts_per_page' => 1, |
388 | - 'author' => $donor_ids[ $page ], |
|
389 | - ) ); |
|
388 | + 'author' => $donor_ids[$page], |
|
389 | + )); |
|
390 | 390 | |
391 | 391 | $donations = array(); |
392 | - $payments = new Give_Payments_Query( $args ); |
|
392 | + $payments = new Give_Payments_Query($args); |
|
393 | 393 | $payments = $payments->get_payments(); |
394 | - if ( empty( $payments ) ) { |
|
395 | - Give()->donors->delete_by_user_id( $donor_ids[ $page ] ); |
|
394 | + if (empty($payments)) { |
|
395 | + Give()->donors->delete_by_user_id($donor_ids[$page]); |
|
396 | 396 | |
397 | 397 | /** |
398 | 398 | * If Checked then delete WP user. |
399 | 399 | * |
400 | 400 | * @since 1.8.14 |
401 | 401 | */ |
402 | - $delete_import_donors = isset( $_REQUEST['delete-import-donors'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['delete-import-donors'] ) ) : ''; |
|
402 | + $delete_import_donors = isset($_REQUEST['delete-import-donors']) ? sanitize_text_field(wp_unslash($_REQUEST['delete-import-donors'])) : ''; |
|
403 | 403 | |
404 | - if ( 'on' === (string) $delete_import_donors ) { |
|
405 | - wp_delete_user( $donor_ids[ $page ] ); |
|
404 | + if ('on' === (string) $delete_import_donors) { |
|
405 | + wp_delete_user($donor_ids[$page]); |
|
406 | 406 | } |
407 | 407 | } else { |
408 | - foreach ( $payments as $payment ) { |
|
408 | + foreach ($payments as $payment) { |
|
409 | 409 | $donations[] = $payment->ID; |
410 | 410 | } |
411 | 411 | |
412 | - $donor = new Give_Donor( $donor_ids[ $page ], true ); |
|
412 | + $donor = new Give_Donor($donor_ids[$page], true); |
|
413 | 413 | $data_to_update = array( |
414 | - 'purchase_count' => count( $donations ), |
|
415 | - 'payment_ids' => implode( ',', $donations ), |
|
414 | + 'purchase_count' => count($donations), |
|
415 | + 'payment_ids' => implode(',', $donations), |
|
416 | 416 | ); |
417 | - $donor->update( $data_to_update ); |
|
417 | + $donor->update($data_to_update); |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 | |
421 | - $page ++; |
|
422 | - $this->update_option( $this->step_on_key, $page ); |
|
423 | - if ( $count === $page ) { |
|
421 | + $page++; |
|
422 | + $this->update_option($this->step_on_key, $page); |
|
423 | + if ($count === $page) { |
|
424 | 424 | $this->is_empty = false; |
425 | 425 | |
426 | 426 | return false; |
@@ -432,24 +432,24 @@ discard block |
||
432 | 432 | return true; |
433 | 433 | } |
434 | 434 | |
435 | - public function get_delete_ids( $donation_ids, $page ) { |
|
436 | - $index = $page --; |
|
437 | - $count = count( $donation_ids ); |
|
435 | + public function get_delete_ids($donation_ids, $page) { |
|
436 | + $index = $page--; |
|
437 | + $count = count($donation_ids); |
|
438 | 438 | $temp = 0; |
439 | 439 | $current_page = 0; |
440 | 440 | $post_delete = $this->per_step; |
441 | 441 | $page_donation_id = array(); |
442 | 442 | |
443 | - foreach ( $donation_ids as $item ) { |
|
444 | - $temp ++; |
|
445 | - $page_donation_id[ $current_page ][] = $item; |
|
446 | - if ( $temp === $post_delete ) { |
|
447 | - $current_page ++; |
|
443 | + foreach ($donation_ids as $item) { |
|
444 | + $temp++; |
|
445 | + $page_donation_id[$current_page][] = $item; |
|
446 | + if ($temp === $post_delete) { |
|
447 | + $current_page++; |
|
448 | 448 | $temp = 0; |
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
452 | - return $page_donation_id[ $page ]; |
|
452 | + return $page_donation_id[$page]; |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -461,8 +461,8 @@ discard block |
||
461 | 461 | * |
462 | 462 | * @return mixed Returns the data from the database |
463 | 463 | */ |
464 | - public function get_option( $key, $defalut_value = false ) { |
|
465 | - return get_option( $key, $defalut_value ); |
|
464 | + public function get_option($key, $defalut_value = false) { |
|
465 | + return get_option($key, $defalut_value); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
@@ -475,8 +475,8 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @return void |
477 | 477 | */ |
478 | - public function update_option( $key, $value ) { |
|
479 | - update_option( $key, $value, false ); |
|
478 | + public function update_option($key, $value) { |
|
479 | + update_option($key, $value, false); |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | /** |
@@ -488,8 +488,8 @@ discard block |
||
488 | 488 | * |
489 | 489 | * @return void |
490 | 490 | */ |
491 | - public function delete_option( $key ) { |
|
492 | - delete_option( $key ); |
|
491 | + public function delete_option($key) { |
|
492 | + delete_option($key); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -500,12 +500,12 @@ discard block |
||
500 | 500 | * @return int|string |
501 | 501 | */ |
502 | 502 | private function get_step() { |
503 | - $step_key = (string) $this->get_option( $this->step_key, false ); |
|
504 | - if ( 'count' === $step_key ) { |
|
503 | + $step_key = (string) $this->get_option($this->step_key, false); |
|
504 | + if ('count' === $step_key) { |
|
505 | 505 | return 1; |
506 | - } elseif ( 'donation' === $step_key ) { |
|
506 | + } elseif ('donation' === $step_key) { |
|
507 | 507 | return 2; |
508 | - } elseif ( 'donor' === $step_key ) { |
|
508 | + } elseif ('donor' === $step_key) { |
|
509 | 509 | return 3; |
510 | 510 | } else { |
511 | 511 | return $step_key; |
@@ -516,6 +516,6 @@ discard block |
||
516 | 516 | * Get the current $page value in the ajax. |
517 | 517 | */ |
518 | 518 | private function get_step_page() { |
519 | - return $this->get_option( $this->step_on_key, false ); |
|
519 | + return $this->get_option($this->step_on_key, false); |
|
520 | 520 | } |
521 | 521 | } |
@@ -918,7 +918,7 @@ |
||
918 | 918 | * @access public |
919 | 919 | * |
920 | 920 | * @param string $meta_key Metadata name. Default is empty. |
921 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
921 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
922 | 922 | * |
923 | 923 | * @return bool False for failure. True for success. |
924 | 924 | */ |
@@ -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 | |
@@ -149,32 +149,32 @@ discard block |
||
149 | 149 | * @param int|bool $_id_or_email |
150 | 150 | * @param bool $by_user_id |
151 | 151 | */ |
152 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
152 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
153 | 153 | |
154 | 154 | $this->db = Give()->donors; |
155 | 155 | |
156 | 156 | if ( |
157 | 157 | false === $_id_or_email |
158 | - || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) |
|
158 | + || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email)) |
|
159 | 159 | ) { |
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
163 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
163 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
164 | 164 | |
165 | - if ( is_numeric( $_id_or_email ) ) { |
|
165 | + if (is_numeric($_id_or_email)) { |
|
166 | 166 | $field = $by_user_id ? 'user_id' : 'id'; |
167 | 167 | } else { |
168 | 168 | $field = 'email'; |
169 | 169 | } |
170 | 170 | |
171 | - $donor = $this->db->get_donor_by( $field, $_id_or_email ); |
|
171 | + $donor = $this->db->get_donor_by($field, $_id_or_email); |
|
172 | 172 | |
173 | - if ( empty( $donor ) || ! is_object( $donor ) ) { |
|
173 | + if (empty($donor) || ! is_object($donor)) { |
|
174 | 174 | return false; |
175 | 175 | } |
176 | 176 | |
177 | - $this->setup_donor( $donor ); |
|
177 | + $this->setup_donor($donor); |
|
178 | 178 | |
179 | 179 | } |
180 | 180 | |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return bool If the setup was successful or not. |
192 | 192 | */ |
193 | - private function setup_donor( $donor ) { |
|
193 | + private function setup_donor($donor) { |
|
194 | 194 | |
195 | - if ( ! is_object( $donor ) ) { |
|
195 | + if ( ! is_object($donor)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Get cached donors. |
200 | - $donor_vars = Give_Cache::get_group( $donor->id, 'give-donors' ); |
|
200 | + $donor_vars = Give_Cache::get_group($donor->id, 'give-donors'); |
|
201 | 201 | |
202 | - if( is_null( $donor_vars ) ){ |
|
203 | - foreach ( $donor as $key => $value ) { |
|
202 | + if (is_null($donor_vars)) { |
|
203 | + foreach ($donor as $key => $value) { |
|
204 | 204 | |
205 | - switch ( $key ) { |
|
205 | + switch ($key) { |
|
206 | 206 | |
207 | 207 | case 'notes': |
208 | 208 | $this->$key = $this->get_notes(); |
@@ -216,20 +216,20 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | // Get donor's all email including primary email. |
219 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
220 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
219 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
220 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
221 | 221 | |
222 | 222 | $this->setup_address(); |
223 | 223 | |
224 | - Give_Cache::set_group( $donor->id, get_object_vars( $this ), 'give-donors' ); |
|
225 | - } else{ |
|
226 | - foreach ( $donor_vars as $donor_var => $value ) { |
|
224 | + Give_Cache::set_group($donor->id, get_object_vars($this), 'give-donors'); |
|
225 | + } else { |
|
226 | + foreach ($donor_vars as $donor_var => $value) { |
|
227 | 227 | $this->$donor_var = $value; |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | 231 | // Donor ID and email are the only things that are necessary, make sure they exist. |
232 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
232 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
233 | 233 | return true; |
234 | 234 | } |
235 | 235 | |
@@ -262,18 +262,18 @@ discard block |
||
262 | 262 | ARRAY_N |
263 | 263 | ); |
264 | 264 | |
265 | - if ( empty( $addresses ) ) { |
|
265 | + if (empty($addresses)) { |
|
266 | 266 | return $this->address; |
267 | 267 | } |
268 | 268 | |
269 | - foreach ( $addresses as $address ) { |
|
270 | - $address[0] = str_replace( '_give_donor_address_', '', $address[0] ); |
|
271 | - $address[0] = explode( '_', $address[0] ); |
|
269 | + foreach ($addresses as $address) { |
|
270 | + $address[0] = str_replace('_give_donor_address_', '', $address[0]); |
|
271 | + $address[0] = explode('_', $address[0]); |
|
272 | 272 | |
273 | - if ( 3 === count( $address[0] ) ) { |
|
274 | - $this->address[ $address[0][0] ][ $address[0][2] ][ $address[0][1] ] = $address[1]; |
|
273 | + if (3 === count($address[0])) { |
|
274 | + $this->address[$address[0][0]][$address[0][2]][$address[0][1]] = $address[1]; |
|
275 | 275 | } else { |
276 | - $this->address[ $address[0][0] ][ $address[0][1] ] = $address[1]; |
|
276 | + $this->address[$address[0][0]][$address[0][1]] = $address[1]; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @return array The donor's address, if any |
291 | 291 | */ |
292 | - public function get_donor_address( $args = array() ) { |
|
292 | + public function get_donor_address($args = array()) { |
|
293 | 293 | $args = wp_parse_args( |
294 | 294 | $args, |
295 | 295 | array( |
@@ -307,24 +307,24 @@ discard block |
||
307 | 307 | ); |
308 | 308 | |
309 | 309 | // Backward compatibility. |
310 | - if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) ) { |
|
310 | + if ( ! give_has_upgrade_completed('v20_upgrades_user_address')) { |
|
311 | 311 | |
312 | 312 | // Backward compatibility for user id param. |
313 | - return wp_parse_args( (array) get_user_meta( $this->user_id, '_give_user_address', true ), $default_address ); |
|
313 | + return wp_parse_args((array) get_user_meta($this->user_id, '_give_user_address', true), $default_address); |
|
314 | 314 | |
315 | 315 | } |
316 | 316 | |
317 | - if ( ! $this->id || empty( $this->address ) || ! array_key_exists( $args['address_type'], $this->address ) ) { |
|
317 | + if ( ! $this->id || empty($this->address) || ! array_key_exists($args['address_type'], $this->address)) { |
|
318 | 318 | return $default_address; |
319 | 319 | } |
320 | 320 | |
321 | - switch ( true ) { |
|
322 | - case is_string( end( $this->address[ $args['address_type'] ] ) ): |
|
323 | - $address = wp_parse_args( $this->address[ $args['address_type'] ], $default_address ); |
|
321 | + switch (true) { |
|
322 | + case is_string(end($this->address[$args['address_type']])): |
|
323 | + $address = wp_parse_args($this->address[$args['address_type']], $default_address); |
|
324 | 324 | break; |
325 | 325 | |
326 | - case is_array( end( $this->address[ $args['address_type'] ] ) ): |
|
327 | - $address = wp_parse_args( array_shift( $this->address[ $args['address_type'] ] ), $default_address ); |
|
326 | + case is_array(end($this->address[$args['address_type']])): |
|
327 | + $address = wp_parse_args(array_shift($this->address[$args['address_type']]), $default_address); |
|
328 | 328 | break; |
329 | 329 | } |
330 | 330 | |
@@ -340,16 +340,16 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @return mixed|\WP_Error |
342 | 342 | */ |
343 | - public function __get( $key ) { |
|
343 | + public function __get($key) { |
|
344 | 344 | |
345 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
345 | + if (method_exists($this, 'get_'.$key)) { |
|
346 | 346 | |
347 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
347 | + return call_user_func(array($this, 'get_'.$key)); |
|
348 | 348 | |
349 | 349 | } else { |
350 | 350 | |
351 | 351 | /* translators: %s: property key */ |
352 | - return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
352 | + return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
353 | 353 | |
354 | 354 | } |
355 | 355 | |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return bool|int False if not a valid creation, donor ID if user is found or valid creation. |
367 | 367 | */ |
368 | - public function create( $data = array() ) { |
|
368 | + public function create($data = array()) { |
|
369 | 369 | |
370 | - if ( $this->id != 0 || empty( $data ) ) { |
|
370 | + if ($this->id != 0 || empty($data)) { |
|
371 | 371 | return false; |
372 | 372 | } |
373 | 373 | |
@@ -375,15 +375,15 @@ discard block |
||
375 | 375 | 'payment_ids' => '', |
376 | 376 | ); |
377 | 377 | |
378 | - $args = wp_parse_args( $data, $defaults ); |
|
379 | - $args = $this->sanitize_columns( $args ); |
|
378 | + $args = wp_parse_args($data, $defaults); |
|
379 | + $args = $this->sanitize_columns($args); |
|
380 | 380 | |
381 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
381 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
382 | 382 | return false; |
383 | 383 | } |
384 | 384 | |
385 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
386 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
385 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
386 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -393,18 +393,18 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @param array $args Donor attributes. |
395 | 395 | */ |
396 | - do_action( 'give_donor_pre_create', $args ); |
|
396 | + do_action('give_donor_pre_create', $args); |
|
397 | 397 | |
398 | 398 | $created = false; |
399 | 399 | |
400 | 400 | // The DB class 'add' implies an update if the donor being asked to be created already exists |
401 | - if ( $this->db->add( $data ) ) { |
|
401 | + if ($this->db->add($data)) { |
|
402 | 402 | |
403 | 403 | // We've successfully added/updated the donor, reset the class vars with the new data |
404 | - $donor = $this->db->get_donor_by( 'email', $args['email'] ); |
|
404 | + $donor = $this->db->get_donor_by('email', $args['email']); |
|
405 | 405 | |
406 | 406 | // Setup the donor data with the values from DB |
407 | - $this->setup_donor( $donor ); |
|
407 | + $this->setup_donor($donor); |
|
408 | 408 | |
409 | 409 | $created = $this->id; |
410 | 410 | } |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation. |
418 | 418 | * @param array $args Customer attributes. |
419 | 419 | */ |
420 | - do_action( 'give_donor_post_create', $created, $args ); |
|
420 | + do_action('give_donor_post_create', $created, $args); |
|
421 | 421 | |
422 | 422 | return $created; |
423 | 423 | |
@@ -433,13 +433,13 @@ discard block |
||
433 | 433 | * |
434 | 434 | * @return bool If the update was successful or not. |
435 | 435 | */ |
436 | - public function update( $data = array() ) { |
|
436 | + public function update($data = array()) { |
|
437 | 437 | |
438 | - if ( empty( $data ) ) { |
|
438 | + if (empty($data)) { |
|
439 | 439 | return false; |
440 | 440 | } |
441 | 441 | |
442 | - $data = $this->sanitize_columns( $data ); |
|
442 | + $data = $this->sanitize_columns($data); |
|
443 | 443 | |
444 | 444 | /** |
445 | 445 | * Fires before updating donors. |
@@ -449,15 +449,15 @@ discard block |
||
449 | 449 | * @param int $donor_id Donor id. |
450 | 450 | * @param array $data Donor attributes. |
451 | 451 | */ |
452 | - do_action( 'give_donor_pre_update', $this->id, $data ); |
|
452 | + do_action('give_donor_pre_update', $this->id, $data); |
|
453 | 453 | |
454 | 454 | $updated = false; |
455 | 455 | |
456 | - if ( $this->db->update( $this->id, $data ) ) { |
|
456 | + if ($this->db->update($this->id, $data)) { |
|
457 | 457 | |
458 | - $donor = $this->db->get_donor_by( 'id', $this->id ); |
|
458 | + $donor = $this->db->get_donor_by('id', $this->id); |
|
459 | 459 | |
460 | - $this->setup_donor( $donor ); |
|
460 | + $this->setup_donor($donor); |
|
461 | 461 | |
462 | 462 | $updated = true; |
463 | 463 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | * @param int $donor_id Donor id. |
472 | 472 | * @param array $data Donor attributes. |
473 | 473 | */ |
474 | - do_action( 'give_donor_post_update', $updated, $this->id, $data ); |
|
474 | + do_action('give_donor_post_update', $updated, $this->id, $data); |
|
475 | 475 | |
476 | 476 | return $updated; |
477 | 477 | } |
@@ -489,27 +489,27 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @return bool If the attachment was successfully. |
491 | 491 | */ |
492 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
492 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
493 | 493 | |
494 | - if ( empty( $payment_id ) ) { |
|
494 | + if (empty($payment_id)) { |
|
495 | 495 | return false; |
496 | 496 | } |
497 | 497 | |
498 | - if ( empty( $this->payment_ids ) ) { |
|
498 | + if (empty($this->payment_ids)) { |
|
499 | 499 | |
500 | 500 | $new_payment_ids = $payment_id; |
501 | 501 | |
502 | 502 | } else { |
503 | 503 | |
504 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
504 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
505 | 505 | |
506 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
506 | + if (in_array($payment_id, $payment_ids)) { |
|
507 | 507 | $update_stats = false; |
508 | 508 | } |
509 | 509 | |
510 | 510 | $payment_ids[] = $payment_id; |
511 | 511 | |
512 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
512 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
513 | 513 | |
514 | 514 | } |
515 | 515 | |
@@ -521,20 +521,20 @@ discard block |
||
521 | 521 | * @param int $payment_id Payment id. |
522 | 522 | * @param int $donor_id Customer id. |
523 | 523 | */ |
524 | - do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id ); |
|
524 | + do_action('give_donor_pre_attach_payment', $payment_id, $this->id); |
|
525 | 525 | |
526 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
526 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
527 | 527 | |
528 | - if ( $payment_added ) { |
|
528 | + if ($payment_added) { |
|
529 | 529 | |
530 | 530 | $this->payment_ids = $new_payment_ids; |
531 | 531 | |
532 | 532 | // We added this payment successfully, increment the stats |
533 | - if ( $update_stats ) { |
|
534 | - $payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) ); |
|
533 | + if ($update_stats) { |
|
534 | + $payment_amount = give_donation_amount($payment_id, array('type' => 'stats')); |
|
535 | 535 | |
536 | - if ( ! empty( $payment_amount ) ) { |
|
537 | - $this->increase_value( $payment_amount ); |
|
536 | + if ( ! empty($payment_amount)) { |
|
537 | + $this->increase_value($payment_amount); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | $this->increase_purchase_count(); |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @param int $payment_id Payment id. |
551 | 551 | * @param int $donor_id Donor id. |
552 | 552 | */ |
553 | - do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
553 | + do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
554 | 554 | |
555 | 555 | return $payment_added; |
556 | 556 | } |
@@ -568,33 +568,33 @@ discard block |
||
568 | 568 | * |
569 | 569 | * @return boolean If the removal was successful. |
570 | 570 | */ |
571 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
571 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
572 | 572 | |
573 | - if ( empty( $payment_id ) ) { |
|
573 | + if (empty($payment_id)) { |
|
574 | 574 | return false; |
575 | 575 | } |
576 | 576 | |
577 | - $payment = new Give_Payment( $payment_id ); |
|
577 | + $payment = new Give_Payment($payment_id); |
|
578 | 578 | |
579 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
579 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
580 | 580 | $update_stats = false; |
581 | 581 | } |
582 | 582 | |
583 | 583 | $new_payment_ids = ''; |
584 | 584 | |
585 | - if ( ! empty( $this->payment_ids ) ) { |
|
585 | + if ( ! empty($this->payment_ids)) { |
|
586 | 586 | |
587 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
587 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
588 | 588 | |
589 | - $pos = array_search( $payment_id, $payment_ids ); |
|
590 | - if ( false === $pos ) { |
|
589 | + $pos = array_search($payment_id, $payment_ids); |
|
590 | + if (false === $pos) { |
|
591 | 591 | return false; |
592 | 592 | } |
593 | 593 | |
594 | - unset( $payment_ids[ $pos ] ); |
|
595 | - $payment_ids = array_filter( $payment_ids ); |
|
594 | + unset($payment_ids[$pos]); |
|
595 | + $payment_ids = array_filter($payment_ids); |
|
596 | 596 | |
597 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
597 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
598 | 598 | |
599 | 599 | } |
600 | 600 | |
@@ -606,20 +606,20 @@ discard block |
||
606 | 606 | * @param int $payment_id Payment id. |
607 | 607 | * @param int $donor_id Customer id. |
608 | 608 | */ |
609 | - do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id ); |
|
609 | + do_action('give_donor_pre_remove_payment', $payment_id, $this->id); |
|
610 | 610 | |
611 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
611 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
612 | 612 | |
613 | - if ( $payment_removed ) { |
|
613 | + if ($payment_removed) { |
|
614 | 614 | |
615 | 615 | $this->payment_ids = $new_payment_ids; |
616 | 616 | |
617 | - if ( $update_stats ) { |
|
617 | + if ($update_stats) { |
|
618 | 618 | // We removed this payment successfully, decrement the stats |
619 | - $payment_amount = give_donation_amount( $payment_id ); |
|
619 | + $payment_amount = give_donation_amount($payment_id); |
|
620 | 620 | |
621 | - if ( ! empty( $payment_amount ) ) { |
|
622 | - $this->decrease_value( $payment_amount ); |
|
621 | + if ( ! empty($payment_amount)) { |
|
622 | + $this->decrease_value($payment_amount); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | $this->decrease_donation_count(); |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | * @param int $payment_id Payment id. |
636 | 636 | * @param int $donor_id Donor id. |
637 | 637 | */ |
638 | - do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
638 | + do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
639 | 639 | |
640 | 640 | return $payment_removed; |
641 | 641 | |
@@ -651,10 +651,10 @@ discard block |
||
651 | 651 | * |
652 | 652 | * @return int The donation count. |
653 | 653 | */ |
654 | - public function increase_purchase_count( $count = 1 ) { |
|
654 | + public function increase_purchase_count($count = 1) { |
|
655 | 655 | |
656 | 656 | // Make sure it's numeric and not negative. |
657 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
657 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
658 | 658 | return false; |
659 | 659 | } |
660 | 660 | |
@@ -668,9 +668,9 @@ discard block |
||
668 | 668 | * @param int $count The number to increase by. |
669 | 669 | * @param int $donor_id Donor id. |
670 | 670 | */ |
671 | - do_action( 'give_donor_pre_increase_donation_count', $count, $this->id ); |
|
671 | + do_action('give_donor_pre_increase_donation_count', $count, $this->id); |
|
672 | 672 | |
673 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
673 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
674 | 674 | $this->purchase_count = $new_total; |
675 | 675 | } |
676 | 676 | |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | * @param int $count The number increased by. |
684 | 684 | * @param int $donor_id Donor id. |
685 | 685 | */ |
686 | - do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id ); |
|
686 | + do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id); |
|
687 | 687 | |
688 | 688 | return $this->purchase_count; |
689 | 689 | } |
@@ -698,16 +698,16 @@ discard block |
||
698 | 698 | * |
699 | 699 | * @return mixed If successful, the new count, otherwise false. |
700 | 700 | */ |
701 | - public function decrease_donation_count( $count = 1 ) { |
|
701 | + public function decrease_donation_count($count = 1) { |
|
702 | 702 | |
703 | 703 | // Make sure it's numeric and not negative |
704 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
704 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
705 | 705 | return false; |
706 | 706 | } |
707 | 707 | |
708 | 708 | $new_total = (int) $this->purchase_count - (int) $count; |
709 | 709 | |
710 | - if ( $new_total < 0 ) { |
|
710 | + if ($new_total < 0) { |
|
711 | 711 | $new_total = 0; |
712 | 712 | } |
713 | 713 | |
@@ -719,9 +719,9 @@ discard block |
||
719 | 719 | * @param int $count The number to decrease by. |
720 | 720 | * @param int $donor_id Customer id. |
721 | 721 | */ |
722 | - do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id ); |
|
722 | + do_action('give_donor_pre_decrease_donation_count', $count, $this->id); |
|
723 | 723 | |
724 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
724 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
725 | 725 | $this->purchase_count = $new_total; |
726 | 726 | } |
727 | 727 | |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | * @param int $count The number decreased by. |
735 | 735 | * @param int $donor_id Donor id. |
736 | 736 | */ |
737 | - do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id ); |
|
737 | + do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id); |
|
738 | 738 | |
739 | 739 | return $this->purchase_count; |
740 | 740 | } |
@@ -749,9 +749,9 @@ discard block |
||
749 | 749 | * |
750 | 750 | * @return mixed If successful, the new value, otherwise false. |
751 | 751 | */ |
752 | - public function increase_value( $value = 0.00 ) { |
|
752 | + public function increase_value($value = 0.00) { |
|
753 | 753 | |
754 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
754 | + $new_value = floatval($this->purchase_value) + $value; |
|
755 | 755 | |
756 | 756 | /** |
757 | 757 | * Fires before increasing donor lifetime value. |
@@ -761,9 +761,9 @@ discard block |
||
761 | 761 | * @param float $value The value to increase by. |
762 | 762 | * @param int $donor_id Customer id. |
763 | 763 | */ |
764 | - do_action( 'give_donor_pre_increase_value', $value, $this->id ); |
|
764 | + do_action('give_donor_pre_increase_value', $value, $this->id); |
|
765 | 765 | |
766 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
766 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
767 | 767 | $this->purchase_value = $new_value; |
768 | 768 | } |
769 | 769 | |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | * @param float $value The value increased by. |
777 | 777 | * @param int $donor_id Donor id. |
778 | 778 | */ |
779 | - do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
779 | + do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id); |
|
780 | 780 | |
781 | 781 | return $this->purchase_value; |
782 | 782 | } |
@@ -791,11 +791,11 @@ discard block |
||
791 | 791 | * |
792 | 792 | * @return mixed If successful, the new value, otherwise false. |
793 | 793 | */ |
794 | - public function decrease_value( $value = 0.00 ) { |
|
794 | + public function decrease_value($value = 0.00) { |
|
795 | 795 | |
796 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
796 | + $new_value = floatval($this->purchase_value) - $value; |
|
797 | 797 | |
798 | - if ( $new_value < 0 ) { |
|
798 | + if ($new_value < 0) { |
|
799 | 799 | $new_value = 0.00; |
800 | 800 | } |
801 | 801 | |
@@ -807,9 +807,9 @@ discard block |
||
807 | 807 | * @param float $value The value to decrease by. |
808 | 808 | * @param int $donor_id Donor id. |
809 | 809 | */ |
810 | - do_action( 'give_donor_pre_decrease_value', $value, $this->id ); |
|
810 | + do_action('give_donor_pre_decrease_value', $value, $this->id); |
|
811 | 811 | |
812 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
812 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
813 | 813 | $this->purchase_value = $new_value; |
814 | 814 | } |
815 | 815 | |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | * @param float $value The value decreased by. |
823 | 823 | * @param int $donor_id Donor id. |
824 | 824 | */ |
825 | - do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
825 | + do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
826 | 826 | |
827 | 827 | return $this->purchase_value; |
828 | 828 | } |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | * |
842 | 842 | * @return mixed If successful, the new donation stat value, otherwise false. |
843 | 843 | */ |
844 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
844 | + public function update_donation_value($curr_amount, $new_amount) { |
|
845 | 845 | /** |
846 | 846 | * Payment total difference value can be: |
847 | 847 | * zero (in case amount not change) |
@@ -851,15 +851,15 @@ discard block |
||
851 | 851 | $payment_total_diff = $new_amount - $curr_amount; |
852 | 852 | |
853 | 853 | // We do not need to update donation stat if donation did not change. |
854 | - if ( ! $payment_total_diff ) { |
|
854 | + if ( ! $payment_total_diff) { |
|
855 | 855 | return false; |
856 | 856 | } |
857 | 857 | |
858 | - if ( $payment_total_diff > 0 ) { |
|
859 | - $this->increase_value( $payment_total_diff ); |
|
858 | + if ($payment_total_diff > 0) { |
|
859 | + $this->increase_value($payment_total_diff); |
|
860 | 860 | } else { |
861 | 861 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
862 | - $this->decrease_value( - $payment_total_diff ); |
|
862 | + $this->decrease_value( -$payment_total_diff ); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | return $this->purchase_value; |
@@ -876,15 +876,15 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return array The notes requested. |
878 | 878 | */ |
879 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
879 | + public function get_notes($length = 20, $paged = 1) { |
|
880 | 880 | |
881 | - $length = is_numeric( $length ) ? $length : 20; |
|
882 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
881 | + $length = is_numeric($length) ? $length : 20; |
|
882 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
883 | 883 | |
884 | 884 | $all_notes = $this->get_raw_notes(); |
885 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
885 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
886 | 886 | |
887 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
887 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
888 | 888 | |
889 | 889 | return $desired_notes; |
890 | 890 | |
@@ -901,9 +901,9 @@ discard block |
||
901 | 901 | public function get_notes_count() { |
902 | 902 | |
903 | 903 | $all_notes = $this->get_raw_notes(); |
904 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
904 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
905 | 905 | |
906 | - return count( $notes_array ); |
|
906 | + return count($notes_array); |
|
907 | 907 | |
908 | 908 | } |
909 | 909 | |
@@ -916,7 +916,7 @@ discard block |
||
916 | 916 | * |
917 | 917 | * @return string|float |
918 | 918 | */ |
919 | - public function get_total_donation_amount( $args = array() ) { |
|
919 | + public function get_total_donation_amount($args = array()) { |
|
920 | 920 | |
921 | 921 | /** |
922 | 922 | * Filter total donation amount. |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | * @param integer $donor_id Donor ID. |
928 | 928 | * @param array $args Pass additional data. |
929 | 929 | */ |
930 | - return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args ); |
|
930 | + return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | /** |
@@ -940,22 +940,22 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @return string|boolean The new note if added successfully, false otherwise. |
942 | 942 | */ |
943 | - public function add_note( $note = '' ) { |
|
943 | + public function add_note($note = '') { |
|
944 | 944 | |
945 | - $note = trim( $note ); |
|
946 | - if ( empty( $note ) ) { |
|
945 | + $note = trim($note); |
|
946 | + if (empty($note)) { |
|
947 | 947 | return false; |
948 | 948 | } |
949 | 949 | |
950 | 950 | $notes = $this->get_raw_notes(); |
951 | 951 | |
952 | - if ( empty( $notes ) ) { |
|
952 | + if (empty($notes)) { |
|
953 | 953 | $notes = ''; |
954 | 954 | } |
955 | 955 | |
956 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
957 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
958 | - $notes .= "\n\n" . $new_note; |
|
956 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
957 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
958 | + $notes .= "\n\n".$new_note; |
|
959 | 959 | |
960 | 960 | /** |
961 | 961 | * Fires before donor note is added. |
@@ -965,11 +965,11 @@ discard block |
||
965 | 965 | * @param string $new_note New note to add. |
966 | 966 | * @param int $donor_id Donor id. |
967 | 967 | */ |
968 | - do_action( 'give_donor_pre_add_note', $new_note, $this->id ); |
|
968 | + do_action('give_donor_pre_add_note', $new_note, $this->id); |
|
969 | 969 | |
970 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
970 | + $updated = $this->update(array('notes' => $notes)); |
|
971 | 971 | |
972 | - if ( $updated ) { |
|
972 | + if ($updated) { |
|
973 | 973 | $this->notes = $this->get_notes(); |
974 | 974 | } |
975 | 975 | |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | * @param string $new_note New note added. |
983 | 983 | * @param int $donor_id Donor id. |
984 | 984 | */ |
985 | - do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id ); |
|
985 | + do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id); |
|
986 | 986 | |
987 | 987 | // Return the formatted note, so we can test, as well as update any displays |
988 | 988 | return $new_note; |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | */ |
1000 | 1000 | private function get_raw_notes() { |
1001 | 1001 | |
1002 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
1002 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
1003 | 1003 | |
1004 | 1004 | return $all_notes; |
1005 | 1005 | |
@@ -1016,8 +1016,8 @@ discard block |
||
1016 | 1016 | * |
1017 | 1017 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
1018 | 1018 | */ |
1019 | - public function get_meta( $meta_key = '', $single = true ) { |
|
1020 | - return Give()->donor_meta->get_meta( $this->id, $meta_key, $single ); |
|
1019 | + public function get_meta($meta_key = '', $single = true) { |
|
1020 | + return Give()->donor_meta->get_meta($this->id, $meta_key, $single); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | /** |
@@ -1032,8 +1032,8 @@ discard block |
||
1032 | 1032 | * |
1033 | 1033 | * @return bool False for failure. True for success. |
1034 | 1034 | */ |
1035 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
1036 | - return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
1035 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
1036 | + return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | /** |
@@ -1048,8 +1048,8 @@ discard block |
||
1048 | 1048 | * |
1049 | 1049 | * @return bool False on failure, true if success. |
1050 | 1050 | */ |
1051 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
1052 | - return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
1051 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
1052 | + return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | /** |
@@ -1063,8 +1063,8 @@ discard block |
||
1063 | 1063 | * |
1064 | 1064 | * @return bool False for failure. True for success. |
1065 | 1065 | */ |
1066 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
1067 | - return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
1066 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
1067 | + return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | /** |
@@ -1077,51 +1077,51 @@ discard block |
||
1077 | 1077 | * |
1078 | 1078 | * @return array The sanitized data, based off column defaults. |
1079 | 1079 | */ |
1080 | - private function sanitize_columns( $data ) { |
|
1080 | + private function sanitize_columns($data) { |
|
1081 | 1081 | |
1082 | 1082 | $columns = $this->db->get_columns(); |
1083 | 1083 | $default_values = $this->db->get_column_defaults(); |
1084 | 1084 | |
1085 | - foreach ( $columns as $key => $type ) { |
|
1085 | + foreach ($columns as $key => $type) { |
|
1086 | 1086 | |
1087 | 1087 | // Only sanitize data that we were provided |
1088 | - if ( ! array_key_exists( $key, $data ) ) { |
|
1088 | + if ( ! array_key_exists($key, $data)) { |
|
1089 | 1089 | continue; |
1090 | 1090 | } |
1091 | 1091 | |
1092 | - switch ( $type ) { |
|
1092 | + switch ($type) { |
|
1093 | 1093 | |
1094 | 1094 | case '%s': |
1095 | - if ( 'email' == $key ) { |
|
1096 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
1097 | - } elseif ( 'notes' == $key ) { |
|
1098 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
1095 | + if ('email' == $key) { |
|
1096 | + $data[$key] = sanitize_email($data[$key]); |
|
1097 | + } elseif ('notes' == $key) { |
|
1098 | + $data[$key] = strip_tags($data[$key]); |
|
1099 | 1099 | } else { |
1100 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
1100 | + $data[$key] = sanitize_text_field($data[$key]); |
|
1101 | 1101 | } |
1102 | 1102 | break; |
1103 | 1103 | |
1104 | 1104 | case '%d': |
1105 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
1106 | - $data[ $key ] = $default_values[ $key ]; |
|
1105 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
1106 | + $data[$key] = $default_values[$key]; |
|
1107 | 1107 | } else { |
1108 | - $data[ $key ] = absint( $data[ $key ] ); |
|
1108 | + $data[$key] = absint($data[$key]); |
|
1109 | 1109 | } |
1110 | 1110 | break; |
1111 | 1111 | |
1112 | 1112 | case '%f': |
1113 | 1113 | // Convert what was given to a float |
1114 | - $value = floatval( $data[ $key ] ); |
|
1114 | + $value = floatval($data[$key]); |
|
1115 | 1115 | |
1116 | - if ( ! is_float( $value ) ) { |
|
1117 | - $data[ $key ] = $default_values[ $key ]; |
|
1116 | + if ( ! is_float($value)) { |
|
1117 | + $data[$key] = $default_values[$key]; |
|
1118 | 1118 | } else { |
1119 | - $data[ $key ] = $value; |
|
1119 | + $data[$key] = $value; |
|
1120 | 1120 | } |
1121 | 1121 | break; |
1122 | 1122 | |
1123 | 1123 | default: |
1124 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
1124 | + $data[$key] = sanitize_text_field($data[$key]); |
|
1125 | 1125 | break; |
1126 | 1126 | |
1127 | 1127 | } |
@@ -1141,33 +1141,33 @@ discard block |
||
1141 | 1141 | * |
1142 | 1142 | * @return bool If the email was added successfully |
1143 | 1143 | */ |
1144 | - public function add_email( $email = '', $primary = false ) { |
|
1145 | - if ( ! is_email( $email ) ) { |
|
1144 | + public function add_email($email = '', $primary = false) { |
|
1145 | + if ( ! is_email($email)) { |
|
1146 | 1146 | return false; |
1147 | 1147 | } |
1148 | - $existing = new Give_Donor( $email ); |
|
1148 | + $existing = new Give_Donor($email); |
|
1149 | 1149 | |
1150 | - if ( $existing->id > 0 ) { |
|
1150 | + if ($existing->id > 0) { |
|
1151 | 1151 | // Email address already belongs to another donor |
1152 | 1152 | return false; |
1153 | 1153 | } |
1154 | 1154 | |
1155 | - if ( email_exists( $email ) ) { |
|
1156 | - $user = get_user_by( 'email', $email ); |
|
1157 | - if ( $user->ID != $this->user_id ) { |
|
1155 | + if (email_exists($email)) { |
|
1156 | + $user = get_user_by('email', $email); |
|
1157 | + if ($user->ID != $this->user_id) { |
|
1158 | 1158 | return false; |
1159 | 1159 | } |
1160 | 1160 | } |
1161 | 1161 | |
1162 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
1162 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
1163 | 1163 | |
1164 | 1164 | // Add is used to ensure duplicate emails are not added |
1165 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
1165 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
1166 | 1166 | |
1167 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
1167 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
1168 | 1168 | |
1169 | - if ( $ret && true === $primary ) { |
|
1170 | - $this->set_primary_email( $email ); |
|
1169 | + if ($ret && true === $primary) { |
|
1170 | + $this->set_primary_email($email); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | return $ret; |
@@ -1183,16 +1183,16 @@ discard block |
||
1183 | 1183 | * |
1184 | 1184 | * @return bool If the email was removed successfully. |
1185 | 1185 | */ |
1186 | - public function remove_email( $email = '' ) { |
|
1187 | - if ( ! is_email( $email ) ) { |
|
1186 | + public function remove_email($email = '') { |
|
1187 | + if ( ! is_email($email)) { |
|
1188 | 1188 | return false; |
1189 | 1189 | } |
1190 | 1190 | |
1191 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
1191 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
1192 | 1192 | |
1193 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
1193 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
1194 | 1194 | |
1195 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
1195 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
1196 | 1196 | |
1197 | 1197 | return $ret; |
1198 | 1198 | } |
@@ -1209,16 +1209,16 @@ discard block |
||
1209 | 1209 | * |
1210 | 1210 | * @return bool If the email was set as primary successfully. |
1211 | 1211 | */ |
1212 | - public function set_primary_email( $new_primary_email = '' ) { |
|
1213 | - if ( ! is_email( $new_primary_email ) ) { |
|
1212 | + public function set_primary_email($new_primary_email = '') { |
|
1213 | + if ( ! is_email($new_primary_email)) { |
|
1214 | 1214 | return false; |
1215 | 1215 | } |
1216 | 1216 | |
1217 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1217 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
1218 | 1218 | |
1219 | - $existing = new Give_Donor( $new_primary_email ); |
|
1219 | + $existing = new Give_Donor($new_primary_email); |
|
1220 | 1220 | |
1221 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
1221 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
1222 | 1222 | // This email belongs to another donor. |
1223 | 1223 | return false; |
1224 | 1224 | } |
@@ -1226,21 +1226,21 @@ discard block |
||
1226 | 1226 | $old_email = $this->email; |
1227 | 1227 | |
1228 | 1228 | // Update donor record with new email. |
1229 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
1229 | + $update = $this->update(array('email' => $new_primary_email)); |
|
1230 | 1230 | |
1231 | 1231 | // Remove new primary from list of additional emails. |
1232 | - $remove = $this->remove_email( $new_primary_email ); |
|
1232 | + $remove = $this->remove_email($new_primary_email); |
|
1233 | 1233 | |
1234 | 1234 | // Add old email to additional emails list. |
1235 | - $add = $this->add_email( $old_email ); |
|
1235 | + $add = $this->add_email($old_email); |
|
1236 | 1236 | |
1237 | 1237 | $ret = $update && $remove && $add; |
1238 | 1238 | |
1239 | - if ( $ret ) { |
|
1239 | + if ($ret) { |
|
1240 | 1240 | $this->email = $new_primary_email; |
1241 | 1241 | } |
1242 | 1242 | |
1243 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1243 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
1244 | 1244 | |
1245 | 1245 | return $ret; |
1246 | 1246 | } |
@@ -1255,17 +1255,17 @@ discard block |
||
1255 | 1255 | * |
1256 | 1256 | * @return bool |
1257 | 1257 | */ |
1258 | - private function is_valid_address( $address ) { |
|
1258 | + private function is_valid_address($address) { |
|
1259 | 1259 | $is_valid_address = true; |
1260 | 1260 | |
1261 | 1261 | // Address ready to process even if only one value set. |
1262 | - foreach ( $address as $address_type => $value ) { |
|
1262 | + foreach ($address as $address_type => $value) { |
|
1263 | 1263 | // @todo: Handle state field validation on basis of country. |
1264 | - if( in_array( $address_type, array( 'line2', 'state' )) ) { |
|
1264 | + if (in_array($address_type, array('line2', 'state'))) { |
|
1265 | 1265 | continue; |
1266 | 1266 | } |
1267 | 1267 | |
1268 | - if ( empty( $value ) ) { |
|
1268 | + if (empty($value)) { |
|
1269 | 1269 | $is_valid_address = false; |
1270 | 1270 | break; |
1271 | 1271 | } |
@@ -1292,30 +1292,27 @@ discard block |
||
1292 | 1292 | * |
1293 | 1293 | * @return bool |
1294 | 1294 | */ |
1295 | - public function add_address( $address_type, $address ) { |
|
1295 | + public function add_address($address_type, $address) { |
|
1296 | 1296 | // Bailout. |
1297 | - if ( empty( $address_type ) || ! $this->is_valid_address( $address ) || ! $this->id ) { |
|
1297 | + if (empty($address_type) || ! $this->is_valid_address($address) || ! $this->id) { |
|
1298 | 1298 | return false; |
1299 | 1299 | } |
1300 | 1300 | |
1301 | 1301 | // Check if multiple address exist or not and set params. |
1302 | 1302 | $multi_address_id = null; |
1303 | - if( $is_multi_address = ( false !== strpos( $address_type, '[]' ) ) ) { |
|
1304 | - $address_type = $is_multi_address ? |
|
1305 | - str_replace( '[]', '', $address_type ) : |
|
1306 | - $address_type; |
|
1307 | - } elseif ( $is_multi_address = ( false !== strpos( $address_type, '_' ) ) ){ |
|
1308 | - $multi_address_id = $is_multi_address ? |
|
1309 | - array_pop( explode( '_', $address_type ) ) : |
|
1310 | - $address_type; |
|
1303 | + if ($is_multi_address = (false !== strpos($address_type, '[]'))) { |
|
1304 | + $address_type = $is_multi_address ? |
|
1305 | + str_replace('[]', '', $address_type) : $address_type; |
|
1306 | + } elseif ($is_multi_address = (false !== strpos($address_type, '_'))) { |
|
1307 | + $multi_address_id = $is_multi_address ? |
|
1308 | + array_pop(explode('_', $address_type)) : $address_type; |
|
1311 | 1309 | |
1312 | - $address_type = $is_multi_address ? |
|
1313 | - array_shift( explode( '_', $address_type ) ) : |
|
1314 | - $address_type; |
|
1310 | + $address_type = $is_multi_address ? |
|
1311 | + array_shift(explode('_', $address_type)) : $address_type; |
|
1315 | 1312 | } |
1316 | 1313 | |
1317 | 1314 | // Bailout: do not save duplicate orders |
1318 | - if( $this->is_address_exist( $address_type, $address ) ) { |
|
1315 | + if ($this->is_address_exist($address_type, $address)) { |
|
1319 | 1316 | return false; |
1320 | 1317 | } |
1321 | 1318 | |
@@ -1337,8 +1334,8 @@ discard block |
||
1337 | 1334 | $meta_key_prefix = "_give_donor_address_{$address_type}_{address_name}"; |
1338 | 1335 | $meta_type = Give()->donor_meta->meta_type; |
1339 | 1336 | |
1340 | - if ( $is_multi_address ) { |
|
1341 | - if ( is_null( $multi_address_id ) ) { |
|
1337 | + if ($is_multi_address) { |
|
1338 | + if (is_null($multi_address_id)) { |
|
1342 | 1339 | // Get latest address key to set multi address id. |
1343 | 1340 | $multi_address_id = $wpdb->get_var( |
1344 | 1341 | $wpdb->prepare( |
@@ -1355,10 +1352,10 @@ discard block |
||
1355 | 1352 | ) |
1356 | 1353 | ); |
1357 | 1354 | |
1358 | - if( ! empty( $multi_address_id ) ) { |
|
1359 | - $multi_address_id = absint( substr( strrchr( $multi_address_id, '_' ), 1 ) ); |
|
1355 | + if ( ! empty($multi_address_id)) { |
|
1356 | + $multi_address_id = absint(substr(strrchr($multi_address_id, '_'), 1)); |
|
1360 | 1357 | $multi_address_id++; |
1361 | - } else{ |
|
1358 | + } else { |
|
1362 | 1359 | $multi_address_id = 0; |
1363 | 1360 | } |
1364 | 1361 | } |
@@ -1367,9 +1364,9 @@ discard block |
||
1367 | 1364 | } |
1368 | 1365 | |
1369 | 1366 | // Save donor address. |
1370 | - foreach ( $address as $type => $value ) { |
|
1371 | - $meta_key = str_replace( '{address_name}', $type, $meta_key_prefix ); |
|
1372 | - Give()->donor_meta->update_meta( $this->id, $meta_key, $value ); |
|
1367 | + foreach ($address as $type => $value) { |
|
1368 | + $meta_key = str_replace('{address_name}', $type, $meta_key_prefix); |
|
1369 | + Give()->donor_meta->update_meta($this->id, $meta_key, $value); |
|
1373 | 1370 | } |
1374 | 1371 | |
1375 | 1372 | $this->setup_address(); |
@@ -1388,23 +1385,21 @@ discard block |
||
1388 | 1385 | * |
1389 | 1386 | * @return bool |
1390 | 1387 | */ |
1391 | - public function remove_address( $address_id ) { |
|
1388 | + public function remove_address($address_id) { |
|
1392 | 1389 | global $wpdb; |
1393 | 1390 | |
1394 | 1391 | // Get address type. |
1395 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; |
|
1392 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; |
|
1396 | 1393 | |
1397 | - $address_type = false !== strpos( $address_id, '_' ) ? |
|
1398 | - array_shift( explode( '_', $address_id ) ) : |
|
1399 | - $address_id; |
|
1394 | + $address_type = false !== strpos($address_id, '_') ? |
|
1395 | + array_shift(explode('_', $address_id)) : $address_id; |
|
1400 | 1396 | |
1401 | - $address_count = false !== strpos( $address_id, '_' ) ? |
|
1402 | - array_pop( explode( '_', $address_id ) ) : |
|
1403 | - null; |
|
1397 | + $address_count = false !== strpos($address_id, '_') ? |
|
1398 | + array_pop(explode('_', $address_id)) : null; |
|
1404 | 1399 | |
1405 | 1400 | // Set meta key prefix. |
1406 | 1401 | $meta_key_prefix = "_give_donor_address_{$address_type}_%"; |
1407 | - if ( $is_multi_address && is_numeric( $address_count ) ) { |
|
1402 | + if ($is_multi_address && is_numeric($address_count)) { |
|
1408 | 1403 | $meta_key_prefix .= "_{$address_count}"; |
1409 | 1404 | } |
1410 | 1405 | |
@@ -1441,23 +1436,21 @@ discard block |
||
1441 | 1436 | * |
1442 | 1437 | * @return bool |
1443 | 1438 | */ |
1444 | - public function update_address( $address_id, $address ) { |
|
1439 | + public function update_address($address_id, $address) { |
|
1445 | 1440 | global $wpdb; |
1446 | 1441 | |
1447 | 1442 | // Get address type. |
1448 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; |
|
1443 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; |
|
1449 | 1444 | |
1450 | - $address_type = false !== strpos( $address_id, '_' ) ? |
|
1451 | - array_shift( explode( '_', $address_id ) ) : |
|
1452 | - $address_id; |
|
1445 | + $address_type = false !== strpos($address_id, '_') ? |
|
1446 | + array_shift(explode('_', $address_id)) : $address_id; |
|
1453 | 1447 | |
1454 | - $address_count = false !== strpos( $address_id, '_' ) ? |
|
1455 | - array_pop( explode( '_', $address_id ) ) : |
|
1456 | - null; |
|
1448 | + $address_count = false !== strpos($address_id, '_') ? |
|
1449 | + array_pop(explode('_', $address_id)) : null; |
|
1457 | 1450 | |
1458 | 1451 | // Set meta key prefix. |
1459 | 1452 | $meta_key_prefix = "_give_donor_address_{$address_type}_%"; |
1460 | - if ( $is_multi_address && is_numeric( $address_count ) ) { |
|
1453 | + if ($is_multi_address && is_numeric($address_count)) { |
|
1461 | 1454 | $meta_key_prefix .= "_{$address_count}"; |
1462 | 1455 | } |
1463 | 1456 | |
@@ -1478,12 +1471,12 @@ discard block |
||
1478 | 1471 | ); |
1479 | 1472 | |
1480 | 1473 | // Return result. |
1481 | - if( ! count( $row_affected ) ) { |
|
1474 | + if ( ! count($row_affected)) { |
|
1482 | 1475 | return false; |
1483 | 1476 | } |
1484 | 1477 | |
1485 | 1478 | // Update address. |
1486 | - if( ! $this->add_address( $address_id, $address ) ) { |
|
1479 | + if ( ! $this->add_address($address_id, $address)) { |
|
1487 | 1480 | return false; |
1488 | 1481 | } |
1489 | 1482 | |
@@ -1502,39 +1495,39 @@ discard block |
||
1502 | 1495 | * |
1503 | 1496 | * @return bool|null |
1504 | 1497 | */ |
1505 | - public function is_address_exist( $current_address_type, $current_address ) { |
|
1498 | + public function is_address_exist($current_address_type, $current_address) { |
|
1506 | 1499 | $status = false; |
1507 | 1500 | |
1508 | 1501 | // Bailout. |
1509 | - if( empty( $current_address_type ) || empty( $current_address ) ) { |
|
1502 | + if (empty($current_address_type) || empty($current_address)) { |
|
1510 | 1503 | return null; |
1511 | 1504 | } |
1512 | 1505 | |
1513 | 1506 | // Bailout. |
1514 | - if( empty( $this->address ) || empty( $this->address[ $current_address_type ] ) ) { |
|
1507 | + if (empty($this->address) || empty($this->address[$current_address_type])) { |
|
1515 | 1508 | return $status; |
1516 | 1509 | } |
1517 | 1510 | |
1518 | 1511 | // Get address. |
1519 | - $address = $this->address[ $current_address_type ]; |
|
1512 | + $address = $this->address[$current_address_type]; |
|
1520 | 1513 | |
1521 | - switch ( true ){ |
|
1514 | + switch (true) { |
|
1522 | 1515 | |
1523 | 1516 | // Single address. |
1524 | - case is_string( end( $address ) ) : |
|
1525 | - $status = $this->is_address_match( $current_address, $address ); |
|
1517 | + case is_string(end($address)) : |
|
1518 | + $status = $this->is_address_match($current_address, $address); |
|
1526 | 1519 | break; |
1527 | 1520 | |
1528 | 1521 | // Multi address. |
1529 | - case is_array( end( $address ) ): |
|
1522 | + case is_array(end($address)): |
|
1530 | 1523 | // Compare address. |
1531 | - foreach ( $address as $saved_address ) { |
|
1532 | - if( empty( $saved_address ) ) { |
|
1524 | + foreach ($address as $saved_address) { |
|
1525 | + if (empty($saved_address)) { |
|
1533 | 1526 | continue; |
1534 | 1527 | } |
1535 | 1528 | |
1536 | 1529 | // Exit loop immediately if address exist. |
1537 | - if( $status = $this->is_address_match( $current_address, $saved_address ) ) { |
|
1530 | + if ($status = $this->is_address_match($current_address, $saved_address)) { |
|
1538 | 1531 | break; |
1539 | 1532 | } |
1540 | 1533 | } |
@@ -1555,10 +1548,10 @@ discard block |
||
1555 | 1548 | * |
1556 | 1549 | * @return bool |
1557 | 1550 | */ |
1558 | - private function is_address_match( $address_1, $address_2 ) { |
|
1559 | - $result = array_diff( $address_1, $address_2 ); |
|
1551 | + private function is_address_match($address_1, $address_2) { |
|
1552 | + $result = array_diff($address_1, $address_2); |
|
1560 | 1553 | |
1561 | - return empty( $result ); |
|
1554 | + return empty($result); |
|
1562 | 1555 | } |
1563 | 1556 | |
1564 | 1557 | /** |
@@ -1568,22 +1561,22 @@ discard block |
||
1568 | 1561 | * @since 2.0 |
1569 | 1562 | * @return object |
1570 | 1563 | */ |
1571 | - public function split_donor_name( $id ) { |
|
1572 | - $first_name = $last_name = ''; |
|
1573 | - $donor = new Give_Donor( $id ); |
|
1564 | + public function split_donor_name($id) { |
|
1565 | + $first_name = $last_name = ''; |
|
1566 | + $donor = new Give_Donor($id); |
|
1574 | 1567 | |
1575 | - $split_donor_name = explode( ' ', $donor->name, 2 ); |
|
1568 | + $split_donor_name = explode(' ', $donor->name, 2); |
|
1576 | 1569 | |
1577 | 1570 | // Check for existence of first name after split of donor name. |
1578 | - if( is_array( $split_donor_name ) && ! empty( $split_donor_name[0] ) ) { |
|
1571 | + if (is_array($split_donor_name) && ! empty($split_donor_name[0])) { |
|
1579 | 1572 | $first_name = $split_donor_name[0]; |
1580 | 1573 | } |
1581 | 1574 | |
1582 | 1575 | // Check for existence of last name after split of donor name. |
1583 | - if( is_array( $split_donor_name ) && ! empty( $split_donor_name[1] ) ) { |
|
1576 | + if (is_array($split_donor_name) && ! empty($split_donor_name[1])) { |
|
1584 | 1577 | $last_name = $split_donor_name[1]; |
1585 | 1578 | } |
1586 | - return (object) array( 'first_name' => $first_name, 'last_name' => $last_name ); |
|
1579 | + return (object) array('first_name' => $first_name, 'last_name' => $last_name); |
|
1587 | 1580 | } |
1588 | 1581 | |
1589 | 1582 | /** |
@@ -1593,9 +1586,9 @@ discard block |
||
1593 | 1586 | * @return string |
1594 | 1587 | */ |
1595 | 1588 | public function get_first_name() { |
1596 | - $first_name = $this->get_meta( '_give_donor_first_name'); |
|
1597 | - if( ! $first_name ) { |
|
1598 | - $first_name = $this->split_donor_name( $this->id )->first_name; |
|
1589 | + $first_name = $this->get_meta('_give_donor_first_name'); |
|
1590 | + if ( ! $first_name) { |
|
1591 | + $first_name = $this->split_donor_name($this->id)->first_name; |
|
1599 | 1592 | } |
1600 | 1593 | |
1601 | 1594 | return $first_name; |
@@ -1608,15 +1601,15 @@ discard block |
||
1608 | 1601 | * @return string |
1609 | 1602 | */ |
1610 | 1603 | public function get_last_name() { |
1611 | - $first_name = $this->get_meta( '_give_donor_first_name'); |
|
1612 | - $last_name = $this->get_meta( '_give_donor_last_name'); |
|
1604 | + $first_name = $this->get_meta('_give_donor_first_name'); |
|
1605 | + $last_name = $this->get_meta('_give_donor_last_name'); |
|
1613 | 1606 | |
1614 | 1607 | // This condition will prevent unnecessary splitting of donor name to fetch last name. |
1615 | - if( ! $first_name && ! $last_name ) { |
|
1616 | - $last_name = $this->split_donor_name( $this->id )->last_name; |
|
1608 | + if ( ! $first_name && ! $last_name) { |
|
1609 | + $last_name = $this->split_donor_name($this->id)->last_name; |
|
1617 | 1610 | } |
1618 | 1611 | |
1619 | - return ( $last_name ) ? $last_name : ''; |
|
1612 | + return ($last_name) ? $last_name : ''; |
|
1620 | 1613 | } |
1621 | 1614 | |
1622 | 1615 | /** |
@@ -1627,7 +1620,7 @@ discard block |
||
1627 | 1620 | * @return string $company_name Donor Company Name |
1628 | 1621 | */ |
1629 | 1622 | public function get_company_name() { |
1630 | - $company_name = $this->get_meta( '_give_donor_company' ); |
|
1623 | + $company_name = $this->get_meta('_give_donor_company'); |
|
1631 | 1624 | |
1632 | 1625 | return $company_name; |
1633 | 1626 | } |
@@ -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 | |
@@ -74,57 +74,57 @@ discard block |
||
74 | 74 | public function __construct() { |
75 | 75 | |
76 | 76 | $this->use_php_sessions = $this->use_php_sessions(); |
77 | - $this->exp_option = give_get_option( 'session_lifetime' ); |
|
77 | + $this->exp_option = give_get_option('session_lifetime'); |
|
78 | 78 | |
79 | 79 | // PHP Sessions. |
80 | - if ( $this->use_php_sessions ) { |
|
80 | + if ($this->use_php_sessions) { |
|
81 | 81 | |
82 | - if ( is_multisite() ) { |
|
82 | + if (is_multisite()) { |
|
83 | 83 | |
84 | - $this->prefix = '_' . get_current_blog_id(); |
|
84 | + $this->prefix = '_'.get_current_blog_id(); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
88 | - add_action( 'init', array( $this, 'maybe_start_session' ), - 2 ); |
|
88 | + add_action('init', array($this, 'maybe_start_session'), - 2); |
|
89 | 89 | |
90 | 90 | } else { |
91 | 91 | |
92 | - if ( ! $this->should_start_session() ) { |
|
92 | + if ( ! $this->should_start_session()) { |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Use WP_Session. |
97 | - if ( ! defined( 'WP_SESSION_COOKIE' ) ) { |
|
98 | - define( 'WP_SESSION_COOKIE', 'give_wp_session' ); |
|
97 | + if ( ! defined('WP_SESSION_COOKIE')) { |
|
98 | + define('WP_SESSION_COOKIE', 'give_wp_session'); |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( ! class_exists( 'Recursive_ArrayAccess' ) ) { |
|
102 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
101 | + if ( ! class_exists('Recursive_ArrayAccess')) { |
|
102 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // Include utilities class |
106 | - if ( ! class_exists( 'WP_Session_Utils' ) ) { |
|
107 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php'; |
|
106 | + if ( ! class_exists('WP_Session_Utils')) { |
|
107 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php'; |
|
108 | 108 | } |
109 | - if ( ! class_exists( 'WP_Session' ) ) { |
|
110 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php'; |
|
111 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php'; |
|
109 | + if ( ! class_exists('WP_Session')) { |
|
110 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php'; |
|
111 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php'; |
|
112 | 112 | } |
113 | 113 | |
114 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
115 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
114 | + add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); |
|
115 | + add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); |
|
116 | 116 | |
117 | 117 | } |
118 | 118 | |
119 | 119 | // Init Session. |
120 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
121 | - add_action( 'plugins_loaded', array( $this, 'init' ), 9999 ); |
|
120 | + if (empty($this->session) && ! $this->use_php_sessions) { |
|
121 | + add_action('plugins_loaded', array($this, 'init'), 9999); |
|
122 | 122 | } else { |
123 | - add_action( 'init', array( $this, 'init' ), - 1 ); |
|
123 | + add_action('init', array($this, 'init'), - 1); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // Set cookie on Donation Completion page. |
127 | - add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) ); |
|
127 | + add_action('give_pre_process_donation', array($this, 'set_session_cookies')); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function init() { |
142 | 142 | |
143 | - if ( $this->use_php_sessions ) { |
|
144 | - $this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array(); |
|
143 | + if ($this->use_php_sessions) { |
|
144 | + $this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array(); |
|
145 | 145 | } else { |
146 | 146 | $this->session = WP_Session::get_instance(); |
147 | 147 | } |
@@ -176,37 +176,37 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return string|array Session variable. |
178 | 178 | */ |
179 | - public function get( $key ) { |
|
180 | - $key = sanitize_key( $key ); |
|
179 | + public function get($key) { |
|
180 | + $key = sanitize_key($key); |
|
181 | 181 | $return = false; |
182 | 182 | |
183 | - if ( isset( $this->session[ $key ] ) && ! empty( $this->session[ $key ] ) ) { |
|
183 | + if (isset($this->session[$key]) && ! empty($this->session[$key])) { |
|
184 | 184 | |
185 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[ $key ], $matches ); |
|
186 | - if ( ! empty( $matches ) ) { |
|
187 | - $this->set( $key, null ); |
|
185 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[$key], $matches); |
|
186 | + if ( ! empty($matches)) { |
|
187 | + $this->set($key, null); |
|
188 | 188 | |
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | |
192 | - if ( is_numeric( $this->session[ $key ] ) ) { |
|
193 | - $return = $this->session[ $key ]; |
|
192 | + if (is_numeric($this->session[$key])) { |
|
193 | + $return = $this->session[$key]; |
|
194 | 194 | } else { |
195 | 195 | |
196 | - $maybe_json = json_decode( $this->session[ $key ] ); |
|
196 | + $maybe_json = json_decode($this->session[$key]); |
|
197 | 197 | |
198 | 198 | // Since json_last_error is PHP 5.3+, we have to rely on a `null` value for failing to parse JSON. |
199 | - if ( is_null( $maybe_json ) ) { |
|
200 | - $is_serialized = is_serialized( $this->session[ $key ] ); |
|
201 | - if ( $is_serialized ) { |
|
202 | - $value = @unserialize( $this->session[ $key ] ); |
|
203 | - $this->set( $key, (array) $value ); |
|
199 | + if (is_null($maybe_json)) { |
|
200 | + $is_serialized = is_serialized($this->session[$key]); |
|
201 | + if ($is_serialized) { |
|
202 | + $value = @unserialize($this->session[$key]); |
|
203 | + $this->set($key, (array) $value); |
|
204 | 204 | $return = $value; |
205 | 205 | } else { |
206 | - $return = $this->session[ $key ]; |
|
206 | + $return = $this->session[$key]; |
|
207 | 207 | } |
208 | 208 | } else { |
209 | - $return = json_decode( $this->session[ $key ], true ); |
|
209 | + $return = json_decode($this->session[$key], true); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | } |
@@ -229,21 +229,21 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return string Session variable. |
231 | 231 | */ |
232 | - public function set( $key, $value ) { |
|
232 | + public function set($key, $value) { |
|
233 | 233 | |
234 | - $key = sanitize_key( $key ); |
|
234 | + $key = sanitize_key($key); |
|
235 | 235 | |
236 | - if ( is_array( $value ) ) { |
|
237 | - $this->session[ $key ] = wp_json_encode( $value ); |
|
236 | + if (is_array($value)) { |
|
237 | + $this->session[$key] = wp_json_encode($value); |
|
238 | 238 | } else { |
239 | - $this->session[ $key ] = esc_attr( $value ); |
|
239 | + $this->session[$key] = esc_attr($value); |
|
240 | 240 | } |
241 | 241 | |
242 | - if ( $this->use_php_sessions ) { |
|
243 | - $_SESSION[ 'give' . $this->prefix ] = $this->session; |
|
242 | + if ($this->use_php_sessions) { |
|
243 | + $_SESSION['give'.$this->prefix] = $this->session; |
|
244 | 244 | } |
245 | 245 | |
246 | - return $this->session[ $key ]; |
|
246 | + return $this->session[$key]; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -258,10 +258,10 @@ discard block |
||
258 | 258 | * @hook |
259 | 259 | */ |
260 | 260 | public function set_session_cookies() { |
261 | - if ( ! headers_sent() ) { |
|
262 | - $lifetime = current_time( 'timestamp' ) + $this->set_expiration_time(); |
|
263 | - @setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
264 | - @setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
261 | + if ( ! headers_sent()) { |
|
262 | + $lifetime = current_time('timestamp') + $this->set_expiration_time(); |
|
263 | + @setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
264 | + @setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public function set_expiration_variant_time() { |
279 | 279 | |
280 | - return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 ); |
|
280 | + return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function set_expiration_time() { |
294 | 294 | |
295 | - return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 ); |
|
295 | + return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -310,21 +310,21 @@ discard block |
||
310 | 310 | $ret = false; |
311 | 311 | |
312 | 312 | // If the database variable is already set, no need to run auto detection. |
313 | - $give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' ); |
|
313 | + $give_use_php_sessions = (bool) get_option('give_use_php_sessions'); |
|
314 | 314 | |
315 | - if ( ! $give_use_php_sessions ) { |
|
315 | + if ( ! $give_use_php_sessions) { |
|
316 | 316 | |
317 | 317 | // Attempt to detect if the server supports PHP sessions. |
318 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
318 | + if (function_exists('session_start') && ! ini_get('safe_mode')) { |
|
319 | 319 | |
320 | - $this->set( 'give_use_php_sessions', 1 ); |
|
320 | + $this->set('give_use_php_sessions', 1); |
|
321 | 321 | |
322 | - if ( $this->get( 'give_use_php_sessions' ) ) { |
|
322 | + if ($this->get('give_use_php_sessions')) { |
|
323 | 323 | |
324 | 324 | $ret = true; |
325 | 325 | |
326 | 326 | // Set the database option. |
327 | - update_option( 'give_use_php_sessions', true ); |
|
327 | + update_option('give_use_php_sessions', true); |
|
328 | 328 | |
329 | 329 | } |
330 | 330 | } |
@@ -334,13 +334,13 @@ discard block |
||
334 | 334 | } |
335 | 335 | |
336 | 336 | // Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant. |
337 | - if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) { |
|
337 | + if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) { |
|
338 | 338 | $ret = true; |
339 | - } elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) { |
|
339 | + } elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) { |
|
340 | 340 | $ret = false; |
341 | 341 | } |
342 | 342 | |
343 | - return (bool) apply_filters( 'give_use_php_sessions', $ret ); |
|
343 | + return (bool) apply_filters('give_use_php_sessions', $ret); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -357,9 +357,9 @@ discard block |
||
357 | 357 | |
358 | 358 | $start_session = true; |
359 | 359 | |
360 | - if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { |
|
360 | + if ( ! empty($_SERVER['REQUEST_URI'])) { |
|
361 | 361 | |
362 | - $blacklist = apply_filters( 'give_session_start_uri_blacklist', array( |
|
362 | + $blacklist = apply_filters('give_session_start_uri_blacklist', array( |
|
363 | 363 | 'feed', |
364 | 364 | 'feed', |
365 | 365 | 'feed/rss', |
@@ -367,21 +367,21 @@ discard block |
||
367 | 367 | 'feed/rdf', |
368 | 368 | 'feed/atom', |
369 | 369 | 'comments/feed/', |
370 | - ) ); |
|
371 | - $uri = ltrim( $_SERVER['REQUEST_URI'], '/' ); |
|
372 | - $uri = untrailingslashit( $uri ); |
|
373 | - if ( in_array( $uri, $blacklist ) ) { |
|
370 | + )); |
|
371 | + $uri = ltrim($_SERVER['REQUEST_URI'], '/'); |
|
372 | + $uri = untrailingslashit($uri); |
|
373 | + if (in_array($uri, $blacklist)) { |
|
374 | 374 | $start_session = false; |
375 | 375 | } |
376 | - if ( false !== strpos( $uri, 'feed=' ) ) { |
|
376 | + if (false !== strpos($uri, 'feed=')) { |
|
377 | 377 | $start_session = false; |
378 | 378 | } |
379 | - if ( is_admin() ) { |
|
379 | + if (is_admin()) { |
|
380 | 380 | $start_session = false; |
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | - return apply_filters( 'give_start_session', $start_session ); |
|
384 | + return apply_filters('give_start_session', $start_session); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | */ |
398 | 398 | public function maybe_start_session() { |
399 | 399 | |
400 | - if ( ! $this->should_start_session() ) { |
|
400 | + if ( ! $this->should_start_session()) { |
|
401 | 401 | return; |
402 | 402 | } |
403 | 403 | |
404 | - if ( ! session_id() && ! headers_sent() ) { |
|
404 | + if ( ! session_id() && ! headers_sent()) { |
|
405 | 405 | session_start(); |
406 | 406 | } |
407 | 407 | |
@@ -420,9 +420,9 @@ discard block |
||
420 | 420 | |
421 | 421 | $expiration = false; |
422 | 422 | |
423 | - if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) { |
|
423 | + if (session_id() && isset($_COOKIE[session_name().'_expiration'])) { |
|
424 | 424 | |
425 | - $expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) ); |
|
425 | + $expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration'])); |
|
426 | 426 | |
427 | 427 | } |
428 | 428 |
@@ -95,5 +95,8 @@ |
||
95 | 95 | <?php endif; ?> |
96 | 96 | <?php echo $form_close_tag; ?> |
97 | 97 | </div> |
98 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
98 | +<?php else { |
|
99 | + : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; |
|
100 | +} |
|
101 | +?> |
|
99 | 102 | <?php endif; ?> |
100 | 103 | \ No newline at end of file |
@@ -2,12 +2,12 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Admin View: Settings |
4 | 4 | */ |
5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
5 | +if ( ! defined('ABSPATH')) { |
|
6 | 6 | exit; |
7 | 7 | } |
8 | 8 | |
9 | 9 | // Bailout: Do not output anything if setting tab is not defined. |
10 | -if ( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) : |
|
10 | +if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) : |
|
11 | 11 | /** |
12 | 12 | * Filter the form action. |
13 | 13 | * |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @since 1.8 |
19 | 19 | */ |
20 | - $form_method = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' ); |
|
20 | + $form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post'); |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Filter the main form tab. |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @since 1.8 |
31 | 31 | */ |
32 | - $form_open_tag = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method . '" id="give-mainform" action="" enctype="multipart/form-data">' ); |
|
33 | - $form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' ); |
|
32 | + $form_open_tag = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">'); |
|
33 | + $form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>'); |
|
34 | 34 | |
35 | - $wrapper_class = implode( ' ', |
|
35 | + $wrapper_class = implode(' ', |
|
36 | 36 | array( |
37 | - self::$setting_filter_prefix . '-setting-page', |
|
38 | - self::$setting_filter_prefix . '-' . give_get_current_setting_section() . '-section', |
|
39 | - self::$setting_filter_prefix . '-' . give_get_current_setting_tab() . '-tab', |
|
37 | + self::$setting_filter_prefix.'-setting-page', |
|
38 | + self::$setting_filter_prefix.'-'.give_get_current_setting_section().'-section', |
|
39 | + self::$setting_filter_prefix.'-'.give_get_current_setting_tab().'-tab', |
|
40 | 40 | ) |
41 | 41 | ); |
42 | 42 | ?> |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | |
47 | 47 | /* @var Give_Settings_Page $current_setting_obj */ |
48 | 48 | if ( |
49 | - ! empty( $current_setting_obj ) && |
|
50 | - method_exists( $current_setting_obj, 'get_heading_html' ) |
|
49 | + ! empty($current_setting_obj) && |
|
50 | + method_exists($current_setting_obj, 'get_heading_html') |
|
51 | 51 | ) { |
52 | 52 | echo $current_setting_obj->get_heading_html(); |
53 | 53 | } else { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | // Backward compatibility. |
56 | 56 | echo sprintf( |
57 | 57 | '<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">', |
58 | - esc_html( $tabs[ $current_tab ] ) |
|
58 | + esc_html($tabs[$current_tab]) |
|
59 | 59 | ); |
60 | 60 | } |
61 | 61 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | ?> |
64 | 64 | <div class="nav-tab-wrapper give-nav-tab-wrapper"> |
65 | 65 | <?php |
66 | - foreach ( $tabs as $name => $label ) { |
|
67 | - echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden' ) . '">' . $label . '</a>'; |
|
66 | + foreach ($tabs as $name => $label) { |
|
67 | + echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden').'">'.$label.'</a>'; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @since 1.8 |
78 | 78 | */ |
79 | - do_action( self::$setting_filter_prefix . '_tabs' ); |
|
79 | + do_action(self::$setting_filter_prefix.'_tabs'); |
|
80 | 80 | ?> |
81 | 81 | <div class="give-sub-nav-tab-wrapper"> |
82 | - <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e( 'View remaining setting tabs', 'give' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span> |
|
82 | + <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e('View remaining setting tabs', 'give'); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span> |
|
83 | 83 | </a> |
84 | 84 | <nav class="give-sub-nav-tab give-hidden"></nav> |
85 | 85 | </div> |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @since 1.8 |
97 | 97 | */ |
98 | - do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" ); |
|
98 | + do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page"); |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Trigger Action. |
@@ -106,16 +106,16 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @since 1.8 |
108 | 108 | */ |
109 | - do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" ); |
|
109 | + do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page"); |
|
110 | 110 | |
111 | - wp_nonce_field( 'give-save-settings', '_give-save-settings' ); |
|
111 | + wp_nonce_field('give-save-settings', '_give-save-settings'); |
|
112 | 112 | |
113 | - if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?> |
|
113 | + if (empty($GLOBALS['give_hide_save_button'])) : ?> |
|
114 | 114 | <div class="give-submit-wrap"> |
115 | - <input name="save" class="button-primary give-save-button" type="submit" value="<?php _e( 'Save changes', 'give' ); ?>"/> |
|
115 | + <input name="save" class="button-primary give-save-button" type="submit" value="<?php _e('Save changes', 'give'); ?>"/> |
|
116 | 116 | </div> |
117 | 117 | <?php endif; ?> |
118 | 118 | <?php echo $form_close_tag; ?> |
119 | 119 | </div> |
120 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
120 | +<?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?> |
|
121 | 121 | <?php endif; ?> |
122 | 122 | \ No newline at end of file |
@@ -17,23 +17,23 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="give-blank-slate"> |
20 | - <?php if ( ! empty( $content['image_url'] ) ) : ?> |
|
21 | - <img class="give-blank-slate__image" src="<?php echo esc_url( $content['image_url'] ); ?>" alt="<?php echo esc_attr( $content['image_alt'] ); ?>"> |
|
20 | + <?php if ( ! empty($content['image_url'])) : ?> |
|
21 | + <img class="give-blank-slate__image" src="<?php echo esc_url($content['image_url']); ?>" alt="<?php echo esc_attr($content['image_alt']); ?>"> |
|
22 | 22 | <?php endif; ?> |
23 | 23 | |
24 | - <?php if ( ! empty( $content['heading'] ) ) : ?> |
|
25 | - <h2 class="give-blank-slate__heading"><?php esc_html_e( $content['heading'] ); ?></h2> |
|
24 | + <?php if ( ! empty($content['heading'])) : ?> |
|
25 | + <h2 class="give-blank-slate__heading"><?php esc_html_e($content['heading']); ?></h2> |
|
26 | 26 | <?php endif; ?> |
27 | 27 | |
28 | - <?php if ( ! empty( $content['message'] ) ) : ?> |
|
29 | - <p class="give-blank-slate__message"><?php esc_html_e( $content['message'] ); ?></p> |
|
28 | + <?php if ( ! empty($content['message'])) : ?> |
|
29 | + <p class="give-blank-slate__message"><?php esc_html_e($content['message']); ?></p> |
|
30 | 30 | <?php endif; ?> |
31 | 31 | |
32 | - <?php if ( ! empty( $content['cta_text']) && ! empty( $content['cta_link'] ) ) : ?> |
|
33 | - <a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url( $content['cta_link'] ); ?>"><?php esc_html_e( $content['cta_text'] ); ?></a> |
|
32 | + <?php if ( ! empty($content['cta_text']) && ! empty($content['cta_link'])) : ?> |
|
33 | + <a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url($content['cta_link']); ?>"><?php esc_html_e($content['cta_text']); ?></a> |
|
34 | 34 | <?php endif; ?> |
35 | 35 | |
36 | - <?php if ( ! empty( $content['help'] ) ) : ?> |
|
36 | + <?php if ( ! empty($content['help'])) : ?> |
|
37 | 37 | <p class="give-blank-slate__help"> |
38 | 38 | <?php |
39 | 39 | $allowed_html = array( |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'code' => array(), |
48 | 48 | ); |
49 | 49 | |
50 | - echo wp_kses( $content['help'], $allowed_html ); |
|
50 | + echo wp_kses($content['help'], $allowed_html); |
|
51 | 51 | ?> |
52 | 52 | </p> |
53 | 53 | <?php endif; ?> |