@@ -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 | |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * Constructor. |
51 | 51 | */ |
52 | - public function __construct( $_step = 1 ) { |
|
53 | - parent::__construct( $_step ); |
|
52 | + public function __construct($_step = 1) { |
|
53 | + parent::__construct($_step); |
|
54 | 54 | |
55 | 55 | $this->is_writable = true; |
56 | 56 | } |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | public function get_data() { |
68 | 68 | global $wpdb; |
69 | 69 | |
70 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
70 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
71 | 71 | |
72 | - if ( ! is_array( $items ) ) { |
|
72 | + if ( ! is_array($items)) { |
|
73 | 73 | return false; |
74 | 74 | } |
75 | 75 | |
76 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
77 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
76 | + $offset = ($this->step - 1) * $this->per_step; |
|
77 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
78 | 78 | |
79 | - if ( $step_items ) { |
|
79 | + if ($step_items) { |
|
80 | 80 | |
81 | 81 | $step_ids = array( |
82 | 82 | 'customers' => array(), |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | 'other' => array(), |
85 | 85 | ); |
86 | 86 | |
87 | - foreach ( $step_items as $item ) { |
|
87 | + foreach ($step_items as $item) { |
|
88 | 88 | |
89 | - switch ( $item['type'] ) { |
|
89 | + switch ($item['type']) { |
|
90 | 90 | case 'customer': |
91 | 91 | $step_ids['customers'][] = $item['id']; |
92 | 92 | break; |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | $step_ids['give_forms'][] = $item['id']; |
95 | 95 | break; |
96 | 96 | default: |
97 | - $item_type = apply_filters( 'give_reset_item_type', 'other', $item ); |
|
98 | - $step_ids[ $item_type ][] = $item['id']; |
|
97 | + $item_type = apply_filters('give_reset_item_type', 'other', $item); |
|
98 | + $step_ids[$item_type][] = $item['id']; |
|
99 | 99 | break; |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | 103 | $sql = array(); |
104 | - $meta_table = __give_v20_bc_table_details('form' ); |
|
104 | + $meta_table = __give_v20_bc_table_details('form'); |
|
105 | 105 | |
106 | - foreach ( $step_ids as $type => $ids ) { |
|
106 | + foreach ($step_ids as $type => $ids) { |
|
107 | 107 | |
108 | - if ( empty( $ids ) ) { |
|
108 | + if (empty($ids)) { |
|
109 | 109 | continue; |
110 | 110 | } |
111 | 111 | |
112 | - $ids = implode( ',', $ids ); |
|
112 | + $ids = implode(',', $ids); |
|
113 | 113 | |
114 | - switch ( $type ) { |
|
114 | + switch ($type) { |
|
115 | 115 | case 'customers': |
116 | 116 | $sql[] = "DELETE FROM $wpdb->donors WHERE id IN ($ids)"; |
117 | 117 | $table_name = $wpdb->donors; |
@@ -131,16 +131,16 @@ discard block |
||
131 | 131 | break; |
132 | 132 | } |
133 | 133 | |
134 | - if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) { |
|
134 | + if ( ! in_array($type, array('customers', 'forms', 'other'))) { |
|
135 | 135 | // Allows other types of custom post types to filter on their own post_type |
136 | 136 | // and add items to the query list, for the IDs found in their post type. |
137 | - $sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids ); |
|
137 | + $sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | - if ( ! empty( $sql ) ) { |
|
142 | - foreach ( $sql as $query ) { |
|
143 | - $wpdb->query( $query ); |
|
141 | + if ( ! empty($sql)) { |
|
142 | + foreach ($sql as $query) { |
|
143 | + $wpdb->query($query); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
@@ -160,16 +160,16 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get_percentage_complete() { |
162 | 162 | |
163 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
164 | - $total = count( $items ); |
|
163 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
164 | + $total = count($items); |
|
165 | 165 | |
166 | 166 | $percentage = 100; |
167 | 167 | |
168 | - if ( $total > 0 ) { |
|
169 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
168 | + if ($total > 0) { |
|
169 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
170 | 170 | } |
171 | 171 | |
172 | - if ( $percentage > 100 ) { |
|
172 | + if ($percentage > 100) { |
|
173 | 173 | $percentage = 100; |
174 | 174 | } |
175 | 175 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param array $request The Form Data passed into the batch processing. |
185 | 185 | */ |
186 | - public function set_properties( $request ) { |
|
186 | + public function set_properties($request) { |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -194,31 +194,31 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function process_step() { |
196 | 196 | |
197 | - if ( ! $this->can_export() ) { |
|
198 | - wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
197 | + if ( ! $this->can_export()) { |
|
198 | + wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array( |
|
199 | 199 | 'response' => 403, |
200 | - ) ); |
|
200 | + )); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | $had_data = $this->get_data(); |
204 | 204 | |
205 | - if ( $had_data ) { |
|
205 | + if ($had_data) { |
|
206 | 206 | $this->done = false; |
207 | 207 | |
208 | 208 | return true; |
209 | 209 | } else { |
210 | - update_option( 'give_earnings_total', 0 ); |
|
211 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
210 | + update_option('give_earnings_total', 0); |
|
211 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
212 | 212 | |
213 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
213 | + $this->delete_data('give_temp_reset_ids'); |
|
214 | 214 | |
215 | 215 | // Reset the sequential order numbers |
216 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
217 | - delete_option( 'give_last_payment_number' ); |
|
216 | + if (give_get_option('enable_sequential')) { |
|
217 | + delete_option('give_last_payment_number'); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | $this->done = true; |
221 | - $this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' ); |
|
221 | + $this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give'); |
|
222 | 222 | |
223 | 223 | return false; |
224 | 224 | } |
@@ -251,26 +251,26 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function pre_fetch() { |
253 | 253 | |
254 | - if ( $this->step == 1 ) { |
|
255 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
254 | + if ($this->step == 1) { |
|
255 | + $this->delete_data('give_temp_reset_ids'); |
|
256 | 256 | } |
257 | 257 | |
258 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
258 | + $items = get_option('give_temp_reset_ids', false); |
|
259 | 259 | |
260 | - if ( false === $items ) { |
|
260 | + if (false === $items) { |
|
261 | 261 | $items = array(); |
262 | 262 | |
263 | - $give_types_for_reset = array( 'give_forms', 'give_payment' ); |
|
264 | - $give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset ); |
|
263 | + $give_types_for_reset = array('give_forms', 'give_payment'); |
|
264 | + $give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset); |
|
265 | 265 | |
266 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
266 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
267 | 267 | 'post_type' => $give_types_for_reset, |
268 | 268 | 'post_status' => 'any', |
269 | - 'posts_per_page' => - 1, |
|
270 | - ) ); |
|
269 | + 'posts_per_page' => -1, |
|
270 | + )); |
|
271 | 271 | |
272 | - $posts = get_posts( $args ); |
|
273 | - foreach ( $posts as $post ) { |
|
272 | + $posts = get_posts($args); |
|
273 | + foreach ($posts as $post) { |
|
274 | 274 | $items[] = array( |
275 | 275 | 'id' => (int) $post->ID, |
276 | 276 | 'type' => $post->post_type, |
@@ -278,10 +278,10 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | $donor_args = array( |
281 | - 'number' => - 1, |
|
281 | + 'number' => -1, |
|
282 | 282 | ); |
283 | - $donors = Give()->donors->get_donors( $donor_args ); |
|
284 | - foreach ( $donors as $donor ) { |
|
283 | + $donors = Give()->donors->get_donors($donor_args); |
|
284 | + foreach ($donors as $donor) { |
|
285 | 285 | $items[] = array( |
286 | 286 | 'id' => (int) $donor->id, |
287 | 287 | 'type' => 'customer', |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | |
291 | 291 | // Allow filtering of items to remove with an unassociative array for each item |
292 | 292 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
293 | - $items = apply_filters( 'give_reset_items', $items ); |
|
293 | + $items = apply_filters('give_reset_items', $items); |
|
294 | 294 | |
295 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
295 | + $this->store_data('give_temp_reset_ids', $items); |
|
296 | 296 | }// End if(). |
297 | 297 | |
298 | 298 | } |
@@ -306,17 +306,17 @@ discard block |
||
306 | 306 | * |
307 | 307 | * @return mixed Returns the data from the database. |
308 | 308 | */ |
309 | - private function get_stored_data( $key ) { |
|
309 | + private function get_stored_data($key) { |
|
310 | 310 | global $wpdb; |
311 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
311 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
312 | 312 | |
313 | - if ( empty( $value ) ) { |
|
313 | + if (empty($value)) { |
|
314 | 314 | return false; |
315 | 315 | } |
316 | 316 | |
317 | - $maybe_json = json_decode( $value ); |
|
318 | - if ( ! is_null( $maybe_json ) ) { |
|
319 | - $value = json_decode( $value, true ); |
|
317 | + $maybe_json = json_decode($value); |
|
318 | + if ( ! is_null($maybe_json)) { |
|
319 | + $value = json_decode($value, true); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | return $value; |
@@ -332,10 +332,10 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @return void |
334 | 334 | */ |
335 | - private function store_data( $key, $value ) { |
|
335 | + private function store_data($key, $value) { |
|
336 | 336 | global $wpdb; |
337 | 337 | |
338 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
338 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
339 | 339 | |
340 | 340 | $data = array( |
341 | 341 | 'option_name' => $key, |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | '%s', |
350 | 350 | ); |
351 | 351 | |
352 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
352 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -361,11 +361,11 @@ discard block |
||
361 | 361 | * |
362 | 362 | * @return void |
363 | 363 | */ |
364 | - private function delete_data( $key ) { |
|
364 | + private function delete_data($key) { |
|
365 | 365 | global $wpdb; |
366 | - $wpdb->delete( $wpdb->options, array( |
|
366 | + $wpdb->delete($wpdb->options, array( |
|
367 | 367 | 'option_name' => $key, |
368 | - ) ); |
|
368 | + )); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | } |
372 | 372 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | * @return void |
25 | 25 | */ |
26 | 26 | function give_payment_history_page() { |
27 | - if ( isset( $_GET['view'] ) && 'view-payment-details' == $_GET['view'] ) { |
|
28 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/view-payment-details.php'; |
|
27 | + if (isset($_GET['view']) && 'view-payment-details' == $_GET['view']) { |
|
28 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/view-payment-details.php'; |
|
29 | 29 | } else { |
30 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/class-payments-table.php'; |
|
30 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/class-payments-table.php'; |
|
31 | 31 | $payments_table = new Give_Payment_History_Table(); |
32 | 32 | $payments_table->prepare_items(); |
33 | 33 | ?> |
@@ -41,23 +41,23 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @since 1.7 |
43 | 43 | */ |
44 | - do_action( 'give_payments_page_top' ); |
|
44 | + do_action('give_payments_page_top'); |
|
45 | 45 | ?> |
46 | 46 | <hr class="wp-header-end"> |
47 | 47 | |
48 | - <form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"> |
|
48 | + <form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"> |
|
49 | 49 | <input type="hidden" name="post_type" value="give_forms" /> |
50 | 50 | <input type="hidden" name="page" value="give-payment-history" /> |
51 | 51 | <?php $payments_table->views() ?> |
52 | 52 | <?php $payments_table->advanced_filters(); ?> |
53 | 53 | </form> |
54 | 54 | |
55 | - <form id="give-payments-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"> |
|
55 | + <form id="give-payments-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"> |
|
56 | 56 | <input type="hidden" name="post_type" value="give_forms" /> |
57 | 57 | <input type="hidden" name="page" value="give-payment-history" /> |
58 | 58 | <?php |
59 | - if ( ! empty( $_GET['donor'] ) ) { |
|
60 | - echo sprintf( '<input type="hidden" name="donor" value="%s"/>', absint( $_GET['donor'] ) ); |
|
59 | + if ( ! empty($_GET['donor'])) { |
|
60 | + echo sprintf('<input type="hidden" name="donor" value="%s"/>', absint($_GET['donor'])); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $payments_table->display(); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @since 1.7 |
72 | 72 | */ |
73 | - do_action( 'give_payments_page_bottom' ); |
|
73 | + do_action('give_payments_page_bottom'); |
|
74 | 74 | ?> |
75 | 75 | |
76 | 76 | </div> |
@@ -87,29 +87,29 @@ discard block |
||
87 | 87 | * @param $title |
88 | 88 | * @return string |
89 | 89 | */ |
90 | -function give_view_order_details_title( $admin_title, $title ) { |
|
90 | +function give_view_order_details_title($admin_title, $title) { |
|
91 | 91 | |
92 | - if ( 'give_forms_page_give-payment-history' != get_current_screen()->base ) { |
|
92 | + if ('give_forms_page_give-payment-history' != get_current_screen()->base) { |
|
93 | 93 | return $admin_title; |
94 | 94 | } |
95 | 95 | |
96 | - if( ! isset( $_GET['give-action'] ) ) { |
|
96 | + if ( ! isset($_GET['give-action'])) { |
|
97 | 97 | return $admin_title; |
98 | 98 | } |
99 | 99 | |
100 | - switch( $_GET['give-action'] ) : |
|
100 | + switch ($_GET['give-action']) : |
|
101 | 101 | |
102 | 102 | case 'view-payment-details' : |
103 | 103 | $title = sprintf( |
104 | 104 | /* translators: %s: admin title */ |
105 | - esc_html__( 'View Donation Details - %s', 'give' ), |
|
105 | + esc_html__('View Donation Details - %s', 'give'), |
|
106 | 106 | $admin_title |
107 | 107 | ); |
108 | 108 | break; |
109 | 109 | case 'edit-payment' : |
110 | 110 | $title = sprintf( |
111 | 111 | /* translators: %s: admin title */ |
112 | - esc_html__( 'Edit Donation - %s', 'give' ), |
|
112 | + esc_html__('Edit Donation - %s', 'give'), |
|
113 | 113 | $admin_title |
114 | 114 | ); |
115 | 115 | break; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | return $title; |
122 | 122 | } |
123 | -add_filter( 'admin_title', 'give_view_order_details_title', 10, 2 ); |
|
123 | +add_filter('admin_title', 'give_view_order_details_title', 10, 2); |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Intercept default Edit post links for Give payments and rewrite them to the View Order Details screen. |
@@ -132,20 +132,20 @@ discard block |
||
132 | 132 | * @param $context |
133 | 133 | * @return string |
134 | 134 | */ |
135 | -function give_override_edit_post_for_payment_link( $url, $post_id = 0, $context ) { |
|
135 | +function give_override_edit_post_for_payment_link($url, $post_id = 0, $context) { |
|
136 | 136 | |
137 | - $post = get_post( $post_id ); |
|
137 | + $post = get_post($post_id); |
|
138 | 138 | |
139 | - if( ! $post ) { |
|
139 | + if ( ! $post) { |
|
140 | 140 | return $url; |
141 | 141 | } |
142 | 142 | |
143 | - if( 'give_payment' != $post->post_type ) { |
|
143 | + if ('give_payment' != $post->post_type) { |
|
144 | 144 | return $url; |
145 | 145 | } |
146 | 146 | |
147 | - $url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $post_id ); |
|
147 | + $url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$post_id); |
|
148 | 148 | |
149 | 149 | return $url; |
150 | 150 | } |
151 | -add_filter( 'get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3 ); |
|
151 | +add_filter('get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @return string |
22 | 22 | */ |
23 | 23 | function give_get_templates_dir() { |
24 | - return GIVE_PLUGIN_DIR . 'templates'; |
|
24 | + return GIVE_PLUGIN_DIR.'templates'; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | function give_get_templates_url() { |
34 | - return GIVE_PLUGIN_URL . 'templates'; |
|
34 | + return GIVE_PLUGIN_URL.'templates'; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -44,24 +44,24 @@ discard block |
||
44 | 44 | * @param string $template_path Template file path. Default is empty. |
45 | 45 | * @param string $default_path Default path. Default is empty. |
46 | 46 | */ |
47 | -function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | - extract( $args ); |
|
47 | +function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
48 | + if ( ! empty($args) && is_array($args)) { |
|
49 | + extract($args); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $template_names = "{$template_name}.php"; |
53 | 53 | |
54 | - $located = give_get_locate_template( $template_names, $template_path, $default_path ); |
|
54 | + $located = give_get_locate_template($template_names, $template_path, $default_path); |
|
55 | 55 | |
56 | - if ( ! file_exists( $located ) ) { |
|
56 | + if ( ! file_exists($located)) { |
|
57 | 57 | /* translators: %s: the template */ |
58 | - Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
58 | + Give()->notices->print_frontend_notice(sprintf(__('The %s template was not found.', 'give'), $located), true); |
|
59 | 59 | |
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Allow 3rd party plugin filter template file from their plugin. |
64 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
64 | + $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Fires in give template, before the file is included. |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | * @param string $located Template file filter by 3rd party plugin. |
76 | 76 | * @param array $args Passed arguments. |
77 | 77 | */ |
78 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
78 | + do_action('give_before_template_part', $template_name, $template_path, $located, $args); |
|
79 | 79 | |
80 | - include( $located ); |
|
80 | + include($located); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Fires in give template, after the file is included. |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param string $located Template file filter by 3rd party plugin. |
92 | 92 | * @param array $args Passed arguments. |
93 | 93 | */ |
94 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
94 | + do_action('give_after_template_part', $template_name, $template_path, $located, $args); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return string |
109 | 109 | */ |
110 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
110 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * Fires in give template part, before the template part is retrieved. |
@@ -119,20 +119,20 @@ discard block |
||
119 | 119 | * @param string $slug Template part file slug {slug}.php. |
120 | 120 | * @param string $name Template part file name {slug}-{name}.php. |
121 | 121 | */ |
122 | - do_action( "get_template_part_{$slug}", $slug, $name ); |
|
122 | + do_action("get_template_part_{$slug}", $slug, $name); |
|
123 | 123 | |
124 | 124 | // Setup possible parts |
125 | 125 | $templates = array(); |
126 | - if ( isset( $name ) ) { |
|
127 | - $templates[] = $slug . '-' . $name . '.php'; |
|
126 | + if (isset($name)) { |
|
127 | + $templates[] = $slug.'-'.$name.'.php'; |
|
128 | 128 | } |
129 | - $templates[] = $slug . '.php'; |
|
129 | + $templates[] = $slug.'.php'; |
|
130 | 130 | |
131 | 131 | // Allow template parts to be filtered |
132 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
132 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
133 | 133 | |
134 | 134 | // Return the part that is found |
135 | - return give_locate_template( $templates, $load, false ); |
|
135 | + return give_locate_template($templates, $load, false); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -153,37 +153,37 @@ discard block |
||
153 | 153 | * |
154 | 154 | * @return string The template filename if one is located. |
155 | 155 | */ |
156 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
156 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
157 | 157 | // No file found yet |
158 | 158 | $located = false; |
159 | 159 | |
160 | 160 | // Try to find a template file |
161 | - foreach ( (array) $template_names as $template_name ) { |
|
161 | + foreach ((array) $template_names as $template_name) { |
|
162 | 162 | |
163 | 163 | // Continue if template is empty |
164 | - if ( empty( $template_name ) ) { |
|
164 | + if (empty($template_name)) { |
|
165 | 165 | continue; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // Trim off any slashes from the template name |
169 | - $template_name = ltrim( $template_name, '/' ); |
|
169 | + $template_name = ltrim($template_name, '/'); |
|
170 | 170 | |
171 | 171 | // try locating this template file by looping through the template paths |
172 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
172 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
173 | 173 | |
174 | - if ( file_exists( $template_path . $template_name ) ) { |
|
175 | - $located = $template_path . $template_name; |
|
174 | + if (file_exists($template_path.$template_name)) { |
|
175 | + $located = $template_path.$template_name; |
|
176 | 176 | break; |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | - if ( $located ) { |
|
180 | + if ($located) { |
|
181 | 181 | break; |
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
186 | - load_template( $located, $require_once ); |
|
185 | + if ((true == $load) && ! empty($located)) { |
|
186 | + load_template($located, $require_once); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | return $located; |
@@ -207,26 +207,26 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return string |
209 | 209 | */ |
210 | -function give_get_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
211 | - if ( ! $template_path ) { |
|
212 | - $template_path = give_get_theme_template_dir_name() . '/'; |
|
210 | +function give_get_locate_template($template_name, $template_path = '', $default_path = '') { |
|
211 | + if ( ! $template_path) { |
|
212 | + $template_path = give_get_theme_template_dir_name().'/'; |
|
213 | 213 | } |
214 | 214 | |
215 | - if ( ! $default_path ) { |
|
216 | - $default_path = GIVE_PLUGIN_DIR . 'templates/'; |
|
215 | + if ( ! $default_path) { |
|
216 | + $default_path = GIVE_PLUGIN_DIR.'templates/'; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | // Look within passed path within the theme - this is priority. |
220 | 220 | $template = locate_template( |
221 | 221 | array( |
222 | - trailingslashit( $template_path ) . $template_name, |
|
222 | + trailingslashit($template_path).$template_name, |
|
223 | 223 | $template_name, |
224 | 224 | ) |
225 | 225 | ); |
226 | 226 | |
227 | 227 | // Get default template/ |
228 | - if ( ! $template ) { |
|
229 | - $template = $default_path . $template_name; |
|
228 | + if ( ! $template) { |
|
229 | + $template = $default_path.$template_name; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @since 2.0.3 |
236 | 236 | */ |
237 | - return apply_filters( 'give_get_locate_template', $template, $template_name, $template_path ); |
|
237 | + return apply_filters('give_get_locate_template', $template, $template_name, $template_path); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -248,17 +248,17 @@ discard block |
||
248 | 248 | $template_dir = give_get_theme_template_dir_name(); |
249 | 249 | |
250 | 250 | $file_paths = array( |
251 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
252 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
251 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
252 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
253 | 253 | 100 => give_get_templates_dir(), |
254 | 254 | ); |
255 | 255 | |
256 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
256 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
257 | 257 | |
258 | 258 | // sort the file paths based on priority |
259 | - ksort( $file_paths, SORT_NUMERIC ); |
|
259 | + ksort($file_paths, SORT_NUMERIC); |
|
260 | 260 | |
261 | - return array_map( 'trailingslashit', $file_paths ); |
|
261 | + return array_map('trailingslashit', $file_paths); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @return string |
271 | 271 | */ |
272 | 272 | function give_get_theme_template_dir_name() { |
273 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
273 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -280,10 +280,10 @@ discard block |
||
280 | 280 | * @return void |
281 | 281 | */ |
282 | 282 | function give_version_in_header() { |
283 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
283 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
284 | 284 | } |
285 | 285 | |
286 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
286 | +add_action('wp_head', 'give_version_in_header'); |
|
287 | 287 | |
288 | 288 | /** |
289 | 289 | * Determines if we're currently on the Donations History page. |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | */ |
294 | 294 | function give_is_donation_history_page() { |
295 | 295 | |
296 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
296 | + $ret = is_page(give_get_option('history_page')); |
|
297 | 297 | |
298 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
298 | + return apply_filters('give_is_donation_history_page', $ret); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -307,25 +307,25 @@ discard block |
||
307 | 307 | * |
308 | 308 | * @return array Modified array of classes |
309 | 309 | */ |
310 | -function give_add_body_classes( $class ) { |
|
310 | +function give_add_body_classes($class) { |
|
311 | 311 | $classes = (array) $class; |
312 | 312 | |
313 | - if ( give_is_success_page() ) { |
|
313 | + if (give_is_success_page()) { |
|
314 | 314 | $classes[] = 'give-success'; |
315 | 315 | $classes[] = 'give-page'; |
316 | 316 | } |
317 | 317 | |
318 | - if ( give_is_failed_transaction_page() ) { |
|
318 | + if (give_is_failed_transaction_page()) { |
|
319 | 319 | $classes[] = 'give-failed-transaction'; |
320 | 320 | $classes[] = 'give-page'; |
321 | 321 | } |
322 | 322 | |
323 | - if ( give_is_donation_history_page() ) { |
|
323 | + if (give_is_donation_history_page()) { |
|
324 | 324 | $classes[] = 'give-donation-history'; |
325 | 325 | $classes[] = 'give-page'; |
326 | 326 | } |
327 | 327 | |
328 | - if ( give_is_test_mode() ) { |
|
328 | + if (give_is_test_mode()) { |
|
329 | 329 | $classes[] = 'give-test-mode'; |
330 | 330 | $classes[] = 'give-page'; |
331 | 331 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | /* @var WP_Theme $current_theme */ |
335 | 335 | $current_theme = wp_get_theme(); |
336 | 336 | |
337 | - switch ( $current_theme->get_template() ) { |
|
337 | + switch ($current_theme->get_template()) { |
|
338 | 338 | |
339 | 339 | case 'Divi': |
340 | 340 | $classes[] = 'give-divi'; |
@@ -351,10 +351,10 @@ discard block |
||
351 | 351 | |
352 | 352 | } |
353 | 353 | |
354 | - return array_unique( $classes ); |
|
354 | + return array_unique($classes); |
|
355 | 355 | } |
356 | 356 | |
357 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
357 | +add_filter('body_class', 'give_add_body_classes'); |
|
358 | 358 | |
359 | 359 | |
360 | 360 | /** |
@@ -370,22 +370,22 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @return array |
372 | 372 | */ |
373 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
374 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
373 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
374 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
375 | 375 | return $classes; |
376 | 376 | } |
377 | 377 | |
378 | 378 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
379 | 379 | |
380 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
381 | - unset( $classes[ $key ] ); |
|
380 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
381 | + unset($classes[$key]); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | return $classes; |
385 | 385 | } |
386 | 386 | |
387 | 387 | |
388 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
388 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
389 | 389 | |
390 | 390 | /** |
391 | 391 | * Get the placeholder image URL for forms etc |
@@ -395,74 +395,74 @@ discard block |
||
395 | 395 | */ |
396 | 396 | function give_get_placeholder_img_src() { |
397 | 397 | |
398 | - $placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
398 | + $placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
399 | 399 | |
400 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
400 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | |
404 | 404 | /** |
405 | 405 | * Global |
406 | 406 | */ |
407 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
407 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
408 | 408 | |
409 | 409 | /** |
410 | 410 | * Output the start of the page wrapper. |
411 | 411 | */ |
412 | 412 | function give_output_content_wrapper() { |
413 | - give_get_template_part( 'global/wrapper-start' ); |
|
413 | + give_get_template_part('global/wrapper-start'); |
|
414 | 414 | } |
415 | 415 | } |
416 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
416 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Output the end of the page wrapper. |
420 | 420 | */ |
421 | 421 | function give_output_content_wrapper_end() { |
422 | - give_get_template_part( 'global/wrapper-end' ); |
|
422 | + give_get_template_part('global/wrapper-end'); |
|
423 | 423 | } |
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
427 | 427 | * Single Give Form |
428 | 428 | */ |
429 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
429 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
430 | 430 | function give_left_sidebar_pre_wrap() { |
431 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
431 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
435 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
436 | 436 | function give_left_sidebar_post_wrap() { |
437 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
437 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
438 | 438 | } |
439 | 439 | } |
440 | 440 | |
441 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
441 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
442 | 442 | function give_get_forms_sidebar() { |
443 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
443 | + give_get_template_part('single-give-form/sidebar'); |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
447 | +if ( ! function_exists('give_show_form_images')) { |
|
448 | 448 | |
449 | 449 | /** |
450 | 450 | * Output the donation form featured image. |
451 | 451 | */ |
452 | 452 | function give_show_form_images() { |
453 | - if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
454 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
453 | + if (give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
454 | + give_get_template_part('single-give-form/featured-image'); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
459 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
459 | +if ( ! function_exists('give_template_single_title')) { |
|
460 | 460 | |
461 | 461 | /** |
462 | 462 | * Output the form title. |
463 | 463 | */ |
464 | 464 | function give_template_single_title() { |
465 | - give_get_template_part( 'single-give-form/title' ); |
|
465 | + give_get_template_part('single-give-form/title'); |
|
466 | 466 | } |
467 | 467 | } |
468 | 468 | |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * Conditional Functions |
471 | 471 | */ |
472 | 472 | |
473 | -if ( ! function_exists( 'is_give_form' ) ) { |
|
473 | +if ( ! function_exists('is_give_form')) { |
|
474 | 474 | |
475 | 475 | /** |
476 | 476 | * is_give_form |
@@ -482,11 +482,11 @@ discard block |
||
482 | 482 | * @return bool |
483 | 483 | */ |
484 | 484 | function is_give_form() { |
485 | - return is_singular( array( 'give_form' ) ); |
|
485 | + return is_singular(array('give_form')); |
|
486 | 486 | } |
487 | 487 | } |
488 | 488 | |
489 | -if ( ! function_exists( 'is_give_category' ) ) { |
|
489 | +if ( ! function_exists('is_give_category')) { |
|
490 | 490 | |
491 | 491 | /** |
492 | 492 | * is_give_category |
@@ -501,12 +501,12 @@ discard block |
||
501 | 501 | * |
502 | 502 | * @return bool |
503 | 503 | */ |
504 | - function is_give_category( $term = '' ) { |
|
505 | - return is_tax( 'give_forms_category', $term ); |
|
504 | + function is_give_category($term = '') { |
|
505 | + return is_tax('give_forms_category', $term); |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
509 | -if ( ! function_exists( 'is_give_tag' ) ) { |
|
509 | +if ( ! function_exists('is_give_tag')) { |
|
510 | 510 | |
511 | 511 | /** |
512 | 512 | * is_give_tag |
@@ -521,12 +521,12 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return bool |
523 | 523 | */ |
524 | - function is_give_tag( $term = '' ) { |
|
525 | - return is_tax( 'give_forms_tag', $term ); |
|
524 | + function is_give_tag($term = '') { |
|
525 | + return is_tax('give_forms_tag', $term); |
|
526 | 526 | } |
527 | 527 | } |
528 | 528 | |
529 | -if ( ! function_exists( 'is_give_taxonomy' ) ) { |
|
529 | +if ( ! function_exists('is_give_taxonomy')) { |
|
530 | 530 | |
531 | 531 | /** |
532 | 532 | * is_give_taxonomy |
@@ -538,6 +538,6 @@ discard block |
||
538 | 538 | * @return bool |
539 | 539 | */ |
540 | 540 | function is_give_taxonomy() { |
541 | - return is_tax( get_object_taxonomies( 'give_form' ) ); |
|
541 | + return is_tax(get_object_taxonomies('give_form')); |
|
542 | 542 | } |
543 | 543 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,41 +23,41 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string|bool |
25 | 25 | */ |
26 | -function give_donation_history( $atts ) { |
|
26 | +function give_donation_history($atts) { |
|
27 | 27 | |
28 | - $donation_history_args = shortcode_atts( array( |
|
28 | + $donation_history_args = shortcode_atts(array( |
|
29 | 29 | 'id' => true, |
30 | 30 | 'date' => true, |
31 | 31 | 'donor' => false, |
32 | 32 | 'amount' => true, |
33 | 33 | 'status' => false, |
34 | 34 | 'payment_method' => false, |
35 | - ), $atts, 'donation_history' ); |
|
35 | + ), $atts, 'donation_history'); |
|
36 | 36 | |
37 | 37 | // Always show receipt link. |
38 | 38 | $donation_history_args['details'] = true; |
39 | 39 | |
40 | 40 | // Set Donation History Shortcode Arguments in session variable. |
41 | - Give()->session->set( 'give_donation_history_args', $donation_history_args ); |
|
41 | + Give()->session->set('give_donation_history_args', $donation_history_args); |
|
42 | 42 | |
43 | 43 | // If payment_key query arg exists, return receipt instead of donation history. |
44 | - if ( isset( $_GET['payment_key'] ) ) { |
|
44 | + if (isset($_GET['payment_key'])) { |
|
45 | 45 | ob_start(); |
46 | 46 | |
47 | - echo give_receipt_shortcode( array() ); |
|
47 | + echo give_receipt_shortcode(array()); |
|
48 | 48 | |
49 | 49 | // Display donation history link only if Receipt Access Session is available. |
50 | - if ( give_get_receipt_session() ) { |
|
50 | + if (give_get_receipt_session()) { |
|
51 | 51 | echo sprintf( |
52 | 52 | '<a href="%s">%s</a>', |
53 | - esc_url( give_get_history_page_uri() ), |
|
54 | - __( '« Return to All Donations', 'give' ) |
|
53 | + esc_url(give_get_history_page_uri()), |
|
54 | + __('« Return to All Donations', 'give') |
|
55 | 55 | ); |
56 | 56 | } |
57 | 57 | return ob_get_clean(); |
58 | 58 | } |
59 | 59 | |
60 | - $email_access = give_get_option( 'email_access' ); |
|
60 | + $email_access = give_get_option('email_access'); |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Determine access |
@@ -68,31 +68,31 @@ discard block |
||
68 | 68 | if ( |
69 | 69 | is_user_logged_in() || |
70 | 70 | false !== Give()->session->get_session_expiration() || |
71 | - ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) || |
|
71 | + (give_is_setting_enabled($email_access) && Give()->email_access->token_exists) || |
|
72 | 72 | true === give_get_history_session() |
73 | 73 | ) { |
74 | 74 | ob_start(); |
75 | - give_get_template_part( 'history', 'donations' ); |
|
75 | + give_get_template_part('history', 'donations'); |
|
76 | 76 | |
77 | 77 | return ob_get_clean(); |
78 | 78 | |
79 | - } elseif ( give_is_setting_enabled( $email_access ) ) { |
|
79 | + } elseif (give_is_setting_enabled($email_access)) { |
|
80 | 80 | // Is Email-based access enabled? |
81 | 81 | ob_start(); |
82 | - give_get_template_part( 'email', 'login-form' ); |
|
82 | + give_get_template_part('email', 'login-form'); |
|
83 | 83 | |
84 | 84 | return ob_get_clean(); |
85 | 85 | |
86 | 86 | } else { |
87 | 87 | |
88 | - $output = apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) ); |
|
89 | - $output .= do_shortcode( '[give_login]' ); |
|
88 | + $output = apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false)); |
|
89 | + $output .= do_shortcode('[give_login]'); |
|
90 | 90 | |
91 | 91 | return $output; |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
95 | +add_shortcode('donation_history', 'give_donation_history'); |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * Donation Form Shortcode |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return string |
107 | 107 | */ |
108 | -function give_form_shortcode( $atts ) { |
|
109 | - $atts = shortcode_atts( array( |
|
108 | +function give_form_shortcode($atts) { |
|
109 | + $atts = shortcode_atts(array( |
|
110 | 110 | 'id' => '', |
111 | 111 | 'show_title' => true, |
112 | 112 | 'show_goal' => true, |
@@ -114,21 +114,21 @@ discard block |
||
114 | 114 | 'float_labels' => '', |
115 | 115 | 'display_style' => '', |
116 | 116 | 'continue_button_title' => '', |
117 | - ), $atts, 'give_form' ); |
|
117 | + ), $atts, 'give_form'); |
|
118 | 118 | |
119 | 119 | // Convert string to bool. |
120 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
121 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
120 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
121 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
122 | 122 | |
123 | 123 | // get the Give Form |
124 | 124 | ob_start(); |
125 | - give_get_donation_form( $atts ); |
|
125 | + give_get_donation_form($atts); |
|
126 | 126 | $final_output = ob_get_clean(); |
127 | 127 | |
128 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
128 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
129 | 129 | } |
130 | 130 | |
131 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
131 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
132 | 132 | |
133 | 133 | /** |
134 | 134 | * Donation Form Goal Shortcode. |
@@ -141,36 +141,36 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return string |
143 | 143 | */ |
144 | -function give_goal_shortcode( $atts ) { |
|
145 | - $atts = shortcode_atts( array( |
|
144 | +function give_goal_shortcode($atts) { |
|
145 | + $atts = shortcode_atts(array( |
|
146 | 146 | 'id' => '', |
147 | 147 | 'show_text' => true, |
148 | 148 | 'show_bar' => true, |
149 | - ), $atts, 'give_goal' ); |
|
149 | + ), $atts, 'give_goal'); |
|
150 | 150 | |
151 | 151 | // get the Give Form. |
152 | 152 | ob_start(); |
153 | 153 | |
154 | 154 | // Sanity check 1: ensure there is an ID Provided. |
155 | - if ( empty( $atts['id'] ) ) { |
|
156 | - Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
155 | + if (empty($atts['id'])) { |
|
156 | + Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | // Sanity check 2: Check the form even has Goals enabled. |
160 | - if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
160 | + if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) { |
|
161 | 161 | |
162 | - Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true ); |
|
162 | + Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true); |
|
163 | 163 | } else { |
164 | 164 | // Passed all sanity checks: output Goal. |
165 | - give_show_goal_progress( $atts['id'], $atts ); |
|
165 | + give_show_goal_progress($atts['id'], $atts); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | $final_output = ob_get_clean(); |
169 | 169 | |
170 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
170 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
171 | 171 | } |
172 | 172 | |
173 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
173 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
174 | 174 | |
175 | 175 | |
176 | 176 | /** |
@@ -187,22 +187,22 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return string |
189 | 189 | */ |
190 | -function give_login_form_shortcode( $atts ) { |
|
190 | +function give_login_form_shortcode($atts) { |
|
191 | 191 | |
192 | - $atts = shortcode_atts( array( |
|
192 | + $atts = shortcode_atts(array( |
|
193 | 193 | // Add backward compatibility for redirect attribute. |
194 | 194 | 'redirect' => '', |
195 | 195 | 'login-redirect' => '', |
196 | 196 | 'logout-redirect' => '', |
197 | - ), $atts, 'give_login' ); |
|
197 | + ), $atts, 'give_login'); |
|
198 | 198 | |
199 | 199 | // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
200 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
200 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
201 | 201 | |
202 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
202 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
203 | 203 | } |
204 | 204 | |
205 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
205 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Register Shortcode. |
@@ -217,15 +217,15 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return string |
219 | 219 | */ |
220 | -function give_register_form_shortcode( $atts ) { |
|
221 | - $atts = shortcode_atts( array( |
|
220 | +function give_register_form_shortcode($atts) { |
|
221 | + $atts = shortcode_atts(array( |
|
222 | 222 | 'redirect' => '', |
223 | - ), $atts, 'give_register' ); |
|
223 | + ), $atts, 'give_register'); |
|
224 | 224 | |
225 | - return give_register_form( $atts['redirect'] ); |
|
225 | + return give_register_form($atts['redirect']); |
|
226 | 226 | } |
227 | 227 | |
228 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
228 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
229 | 229 | |
230 | 230 | /** |
231 | 231 | * Receipt Shortcode. |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return string |
240 | 240 | */ |
241 | -function give_receipt_shortcode( $atts ) { |
|
241 | +function give_receipt_shortcode($atts) { |
|
242 | 242 | |
243 | 243 | global $give_receipt_args; |
244 | 244 | |
245 | - $give_receipt_args = shortcode_atts( array( |
|
246 | - 'error' => __( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
245 | + $give_receipt_args = shortcode_atts(array( |
|
246 | + 'error' => __('You are missing the payment key to view this donation receipt.', 'give'), |
|
247 | 247 | 'price' => true, |
248 | 248 | 'donor' => true, |
249 | 249 | 'date' => true, |
@@ -252,49 +252,49 @@ discard block |
||
252 | 252 | 'payment_id' => true, |
253 | 253 | 'payment_status' => false, |
254 | 254 | 'status_notice' => true, |
255 | - ), $atts, 'give_receipt' ); |
|
255 | + ), $atts, 'give_receipt'); |
|
256 | 256 | |
257 | 257 | // set $session var |
258 | 258 | $session = give_get_purchase_session(); |
259 | 259 | |
260 | 260 | // set payment key var |
261 | - if ( isset( $_GET['payment_key'] ) ) { |
|
262 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
263 | - } elseif ( $session ) { |
|
261 | + if (isset($_GET['payment_key'])) { |
|
262 | + $payment_key = urldecode($_GET['payment_key']); |
|
263 | + } elseif ($session) { |
|
264 | 264 | $payment_key = $session['purchase_key']; |
265 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
265 | + } elseif ($give_receipt_args['payment_key']) { |
|
266 | 266 | $payment_key = $give_receipt_args['payment_key']; |
267 | 267 | } |
268 | 268 | |
269 | - $email_access = give_get_option( 'email_access' ); |
|
269 | + $email_access = give_get_option('email_access'); |
|
270 | 270 | |
271 | 271 | // No payment_key found & Email Access is Turned on. |
272 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
272 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
273 | 273 | |
274 | 274 | ob_start(); |
275 | 275 | |
276 | - give_get_template_part( 'email-login-form' ); |
|
276 | + give_get_template_part('email-login-form'); |
|
277 | 277 | |
278 | 278 | return ob_get_clean(); |
279 | 279 | |
280 | - } elseif ( ! isset( $payment_key ) ) { |
|
280 | + } elseif ( ! isset($payment_key)) { |
|
281 | 281 | |
282 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
282 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
283 | 283 | |
284 | 284 | } |
285 | 285 | |
286 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
286 | + $user_can_view = give_can_view_receipt($payment_key); |
|
287 | 287 | |
288 | 288 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
289 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
289 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
290 | 290 | |
291 | 291 | ob_start(); |
292 | 292 | |
293 | - give_get_template_part( 'email-login-form' ); |
|
293 | + give_get_template_part('email-login-form'); |
|
294 | 294 | |
295 | 295 | return ob_get_clean(); |
296 | 296 | |
297 | - } elseif ( ! $user_can_view ) { |
|
297 | + } elseif ( ! $user_can_view) { |
|
298 | 298 | |
299 | 299 | global $give_login_redirect; |
300 | 300 | |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | |
303 | 303 | ob_start(); |
304 | 304 | |
305 | - Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
305 | + Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give'))); |
|
306 | 306 | |
307 | - give_get_template_part( 'shortcode', 'login' ); |
|
307 | + give_get_template_part('shortcode', 'login'); |
|
308 | 308 | |
309 | 309 | $login_form = ob_get_clean(); |
310 | 310 | |
@@ -318,20 +318,20 @@ discard block |
||
318 | 318 | * or if user is logged out and donation was made as a guest, the donation session is checked for |
319 | 319 | * or if user is logged in and the user can view sensitive shop data. |
320 | 320 | */ |
321 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
322 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
321 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
322 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | ob_start(); |
326 | 326 | |
327 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
327 | + give_get_template_part('shortcode', 'receipt'); |
|
328 | 328 | |
329 | 329 | $display = ob_get_clean(); |
330 | 330 | |
331 | 331 | return $display; |
332 | 332 | } |
333 | 333 | |
334 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
334 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
335 | 335 | |
336 | 336 | /** |
337 | 337 | * Profile Editor Shortcode. |
@@ -350,25 +350,25 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @return string Output generated from the profile editor |
352 | 352 | */ |
353 | -function give_profile_editor_shortcode( $atts ) { |
|
353 | +function give_profile_editor_shortcode($atts) { |
|
354 | 354 | |
355 | 355 | ob_start(); |
356 | 356 | |
357 | 357 | // Restrict access to donor profile, if donor and user are disconnected. |
358 | - $is_donor_disconnected = get_user_meta( get_current_user_id(), '_give_is_donor_disconnected', true ); |
|
359 | - if ( is_user_logged_in() && $is_donor_disconnected ) { |
|
360 | - Give()->notices->print_frontend_notice( __( 'Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give' ), true, 'error' ); |
|
358 | + $is_donor_disconnected = get_user_meta(get_current_user_id(), '_give_is_donor_disconnected', true); |
|
359 | + if (is_user_logged_in() && $is_donor_disconnected) { |
|
360 | + Give()->notices->print_frontend_notice(__('Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give'), true, 'error'); |
|
361 | 361 | return false; |
362 | 362 | } |
363 | 363 | |
364 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
364 | + give_get_template_part('shortcode', 'profile-editor'); |
|
365 | 365 | |
366 | 366 | $display = ob_get_clean(); |
367 | 367 | |
368 | 368 | return $display; |
369 | 369 | } |
370 | 370 | |
371 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
371 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Process Profile Updater Form. |
@@ -381,29 +381,29 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @return bool |
383 | 383 | */ |
384 | -function give_process_profile_editor_updates( $data ) { |
|
384 | +function give_process_profile_editor_updates($data) { |
|
385 | 385 | // Profile field change request. |
386 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
386 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
387 | 387 | return false; |
388 | 388 | } |
389 | 389 | |
390 | 390 | // Nonce security. |
391 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
391 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
392 | 392 | return false; |
393 | 393 | } |
394 | 394 | |
395 | 395 | $user_id = get_current_user_id(); |
396 | - $old_user_data = get_userdata( $user_id ); |
|
396 | + $old_user_data = get_userdata($user_id); |
|
397 | 397 | |
398 | 398 | /* @var Give_Donor $donor */ |
399 | - $donor = new Give_Donor( $user_id, true ); |
|
399 | + $donor = new Give_Donor($user_id, true); |
|
400 | 400 | |
401 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
402 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
403 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
404 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
405 | - $password = ! empty( $data['give_new_user_pass1'] ) ? $data['give_new_user_pass1'] : ''; |
|
406 | - $confirm_password = ! empty( $data['give_new_user_pass2'] ) ? $data['give_new_user_pass2'] : ''; |
|
401 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
402 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
403 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
404 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
405 | + $password = ! empty($data['give_new_user_pass1']) ? $data['give_new_user_pass1'] : ''; |
|
406 | + $confirm_password = ! empty($data['give_new_user_pass2']) ? $data['give_new_user_pass2'] : ''; |
|
407 | 407 | |
408 | 408 | $userdata = array( |
409 | 409 | 'ID' => $user_id, |
@@ -422,58 +422,58 @@ discard block |
||
422 | 422 | * @param int $user_id The ID of the user. |
423 | 423 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
424 | 424 | */ |
425 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
425 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
426 | 426 | |
427 | 427 | // Make sure to validate first name of existing donors. |
428 | - if ( empty( $first_name ) ) { |
|
428 | + if (empty($first_name)) { |
|
429 | 429 | // Empty First Name. |
430 | - give_set_error( 'empty_first_name', __( 'Please enter your first name.', 'give' ) ); |
|
430 | + give_set_error('empty_first_name', __('Please enter your first name.', 'give')); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | // Make sure to validate passwords for existing Donors. |
434 | - give_validate_user_password( $password, $confirm_password ); |
|
434 | + give_validate_user_password($password, $confirm_password); |
|
435 | 435 | |
436 | - if ( empty( $email ) ) { |
|
436 | + if (empty($email)) { |
|
437 | 437 | // Make sure email should not be empty. |
438 | - give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) ); |
|
438 | + give_set_error('email_empty', __('The email you entered is empty.', 'give')); |
|
439 | 439 | |
440 | - } elseif ( ! is_email( $email ) ) { |
|
440 | + } elseif ( ! is_email($email)) { |
|
441 | 441 | // Make sure email should be valid. |
442 | - give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
442 | + give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give')); |
|
443 | 443 | |
444 | - } elseif ( $email != $old_user_data->user_email ) { |
|
444 | + } elseif ($email != $old_user_data->user_email) { |
|
445 | 445 | // Make sure the new email doesn't belong to another user. |
446 | - if ( email_exists( $email ) ) { |
|
447 | - give_set_error( 'user_email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
448 | - } elseif ( Give()->donors->get_donor_by( 'email', $email ) ) { |
|
446 | + if (email_exists($email)) { |
|
447 | + give_set_error('user_email_exists', __('The email you entered belongs to another user. Please use another.', 'give')); |
|
448 | + } elseif (Give()->donors->get_donor_by('email', $email)) { |
|
449 | 449 | // Make sure the new email doesn't belong to another user. |
450 | - give_set_error( 'donor_email_exists', __( 'The email you entered belongs to another donor. Please use another.', 'give' ) ); |
|
450 | + give_set_error('donor_email_exists', __('The email you entered belongs to another donor. Please use another.', 'give')); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
454 | 454 | // Check for errors. |
455 | 455 | $errors = give_get_errors(); |
456 | 456 | |
457 | - if ( $errors ) { |
|
457 | + if ($errors) { |
|
458 | 458 | // Send back to the profile editor if there are errors. |
459 | - wp_redirect( $data['give_redirect'] ); |
|
459 | + wp_redirect($data['give_redirect']); |
|
460 | 460 | give_die(); |
461 | 461 | } |
462 | 462 | |
463 | 463 | // Update Donor First Name and Last Name. |
464 | - Give()->donors->update( $donor->id, array( |
|
465 | - 'name' => trim( "{$first_name} {$last_name}" ), |
|
466 | - ) ); |
|
467 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_first_name', $first_name ); |
|
468 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_last_name', $last_name ); |
|
464 | + Give()->donors->update($donor->id, array( |
|
465 | + 'name' => trim("{$first_name} {$last_name}"), |
|
466 | + )); |
|
467 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_first_name', $first_name); |
|
468 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_last_name', $last_name); |
|
469 | 469 | |
470 | 470 | $current_user = wp_get_current_user(); |
471 | 471 | |
472 | 472 | // Compares new values with old values to detect change in values. |
473 | - $email_update = ( $email !== $current_user->user_email ) ? true : false; |
|
474 | - $display_name_update = ( $display_name !== $current_user->display_name ) ? true : false; |
|
475 | - $first_name_update = ( $first_name !== $current_user->first_name ) ? true : false; |
|
476 | - $last_name_update = ( $last_name !== $current_user->last_name ) ? true : false; |
|
473 | + $email_update = ($email !== $current_user->user_email) ? true : false; |
|
474 | + $display_name_update = ($display_name !== $current_user->display_name) ? true : false; |
|
475 | + $first_name_update = ($first_name !== $current_user->first_name) ? true : false; |
|
476 | + $last_name_update = ($last_name !== $current_user->last_name) ? true : false; |
|
477 | 477 | $update_code = 0; |
478 | 478 | |
479 | 479 | /** |
@@ -481,35 +481,35 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @var boolean |
483 | 483 | */ |
484 | - $profile_update = ( $email_update || $display_name_update || $first_name_update || $last_name_update ); |
|
484 | + $profile_update = ($email_update || $display_name_update || $first_name_update || $last_name_update); |
|
485 | 485 | |
486 | 486 | /** |
487 | 487 | * True if password fields are filled. |
488 | 488 | * |
489 | 489 | * @var boolean |
490 | 490 | */ |
491 | - $password_update = ( ! empty( $password ) && ! empty( $confirm_password ) ); |
|
491 | + $password_update = ( ! empty($password) && ! empty($confirm_password)); |
|
492 | 492 | |
493 | - if ( $profile_update ) { |
|
493 | + if ($profile_update) { |
|
494 | 494 | |
495 | 495 | // If only profile fields are updated. |
496 | 496 | $update_code = '1'; |
497 | 497 | |
498 | - if ( $password_update ) { |
|
498 | + if ($password_update) { |
|
499 | 499 | |
500 | 500 | // If profile fields AND password both are updated. |
501 | 501 | $update_code = '2'; |
502 | 502 | } |
503 | - } elseif ( $password_update ) { |
|
503 | + } elseif ($password_update) { |
|
504 | 504 | |
505 | 505 | // If only password is updated. |
506 | 506 | $update_code = '3'; |
507 | 507 | } |
508 | 508 | |
509 | 509 | // Update the user. |
510 | - $updated = wp_update_user( $userdata ); |
|
510 | + $updated = wp_update_user($userdata); |
|
511 | 511 | |
512 | - if ( $updated ) { |
|
512 | + if ($updated) { |
|
513 | 513 | |
514 | 514 | /** |
515 | 515 | * Fires after updating user profile. |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | * @param int $user_id The ID of the user. |
520 | 520 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
521 | 521 | */ |
522 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
522 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
523 | 523 | |
524 | 524 | $profile_edit_redirect_args = array( |
525 | 525 | 'updated' => 'true', |
@@ -530,10 +530,10 @@ discard block |
||
530 | 530 | * Update codes '2' and '3' indicate a password change. |
531 | 531 | * If the password is changed, then logout and redirect to the same page. |
532 | 532 | */ |
533 | - if ( '2' === $update_code || '3' === $update_code ) { |
|
534 | - wp_logout( wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) ) ); |
|
533 | + if ('2' === $update_code || '3' === $update_code) { |
|
534 | + wp_logout(wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect']))); |
|
535 | 535 | } else { |
536 | - wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) ); |
|
536 | + wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect'])); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | give_die(); |
@@ -542,4 +542,4 @@ discard block |
||
542 | 542 | return false; |
543 | 543 | } |
544 | 544 | |
545 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
545 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
@@ -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 | |
@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return void |
30 | 30 | */ |
31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
32 | 32 | |
33 | 33 | // Make sure that payments are only completed once. |
34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Make sure the payment completion is only processed when new status is complete. |
39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - $payment = new Give_Payment( $payment_id ); |
|
43 | + $payment = new Give_Payment($payment_id); |
|
44 | 44 | |
45 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
45 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
46 | 46 | $payment_meta = $payment->payment_meta; |
47 | 47 | $completed_date = $payment->completed_date; |
48 | 48 | $user_info = $payment->user_info; |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param int $payment_id The ID of the payment. |
60 | 60 | */ |
61 | - do_action( 'give_pre_complete_donation', $payment_id ); |
|
61 | + do_action('give_pre_complete_donation', $payment_id); |
|
62 | 62 | |
63 | 63 | // Ensure these actions only run once, ever. |
64 | - if ( empty( $completed_date ) ) { |
|
64 | + if (empty($completed_date)) { |
|
65 | 65 | |
66 | - give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
66 | + give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Fires after logging donation record. |
@@ -74,29 +74,29 @@ discard block |
||
74 | 74 | * @param int $payment_id The ID number of the payment. |
75 | 75 | * @param array $payment_meta The payment meta. |
76 | 76 | */ |
77 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
77 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | 81 | // Increase the earnings for this form ID. |
82 | - give_increase_earnings( $form_id, $amount ); |
|
83 | - give_increase_donation_count( $form_id ); |
|
82 | + give_increase_earnings($form_id, $amount); |
|
83 | + give_increase_donation_count($form_id); |
|
84 | 84 | |
85 | 85 | // @todo: Refresh only range related stat cache |
86 | 86 | give_delete_donation_stats(); |
87 | 87 | |
88 | 88 | // Increase the donor's donation stats. |
89 | - $donor = new Give_Donor( $donor_id ); |
|
89 | + $donor = new Give_Donor($donor_id); |
|
90 | 90 | $donor->increase_purchase_count(); |
91 | - $donor->increase_value( $amount ); |
|
91 | + $donor->increase_value($amount); |
|
92 | 92 | |
93 | - give_increase_total_earnings( $amount ); |
|
93 | + give_increase_total_earnings($amount); |
|
94 | 94 | |
95 | 95 | // Ensure this action only runs once ever. |
96 | - if ( empty( $completed_date ) ) { |
|
96 | + if (empty($completed_date)) { |
|
97 | 97 | |
98 | 98 | // Save the completed date. |
99 | - $payment->completed_date = current_time( 'mysql' ); |
|
99 | + $payment->completed_date = current_time('mysql'); |
|
100 | 100 | $payment->save(); |
101 | 101 | |
102 | 102 | /** |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param int $payment_id The ID of the payment. |
108 | 108 | */ |
109 | - do_action( 'give_complete_donation', $payment_id ); |
|
109 | + do_action('give_complete_donation', $payment_id); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
114 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -125,20 +125,20 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
128 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
129 | 129 | |
130 | 130 | // Get the list of statuses so that status in the payment note can be translated. |
131 | 131 | $stati = give_get_payment_statuses(); |
132 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
133 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
132 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
133 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
134 | 134 | |
135 | 135 | // translators: 1: old status 2: new status. |
136 | - $status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status ); |
|
136 | + $status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status); |
|
137 | 137 | |
138 | - give_insert_payment_note( $payment_id, $status_change ); |
|
138 | + give_insert_payment_note($payment_id, $status_change); |
|
139 | 139 | } |
140 | 140 | |
141 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
141 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
142 | 142 | |
143 | 143 | |
144 | 144 | /** |
@@ -154,25 +154,25 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @return void |
156 | 156 | */ |
157 | -function give_update_old_payments_with_totals( $data ) { |
|
158 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
157 | +function give_update_old_payments_with_totals($data) { |
|
158 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
159 | 159 | return; |
160 | 160 | } |
161 | 161 | |
162 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
162 | + if (get_option('give_payment_totals_upgraded')) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - $payments = give_get_payments( array( |
|
166 | + $payments = give_get_payments(array( |
|
167 | 167 | 'offset' => 0, |
168 | - 'number' => - 1, |
|
168 | + 'number' => -1, |
|
169 | 169 | 'mode' => 'all', |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | |
172 | - if ( $payments ) { |
|
173 | - foreach ( $payments as $payment ) { |
|
172 | + if ($payments) { |
|
173 | + foreach ($payments as $payment) { |
|
174 | 174 | |
175 | - $payment = new Give_Payment( $payment->ID ); |
|
175 | + $payment = new Give_Payment($payment->ID); |
|
176 | 176 | $meta = $payment->get_meta(); |
177 | 177 | |
178 | 178 | $payment->total = $meta['amount']; |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
184 | + add_option('give_payment_totals_upgraded', 1); |
|
185 | 185 | } |
186 | 186 | |
187 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
187 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Mark Abandoned Donations |
@@ -198,17 +198,17 @@ discard block |
||
198 | 198 | function give_mark_abandoned_donations() { |
199 | 199 | $args = array( |
200 | 200 | 'status' => 'pending', |
201 | - 'number' => - 1, |
|
201 | + 'number' => -1, |
|
202 | 202 | 'output' => 'give_payments', |
203 | 203 | ); |
204 | 204 | |
205 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
205 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
206 | 206 | |
207 | - $payments = give_get_payments( $args ); |
|
207 | + $payments = give_get_payments($args); |
|
208 | 208 | |
209 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
209 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
210 | 210 | |
211 | - if ( $payments ) { |
|
211 | + if ($payments) { |
|
212 | 212 | /** |
213 | 213 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
214 | 214 | * |
@@ -216,14 +216,14 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @param array $skip_payment_gateways Array of payment gateways |
218 | 218 | */ |
219 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
219 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
220 | 220 | |
221 | 221 | /* @var Give_Payment $payment */ |
222 | - foreach ( $payments as $payment ) { |
|
223 | - $gateway = give_get_payment_gateway( $payment->ID ); |
|
222 | + foreach ($payments as $payment) { |
|
223 | + $gateway = give_get_payment_gateway($payment->ID); |
|
224 | 224 | |
225 | 225 | // Skip payment gateways. |
226 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
226 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
227 | 227 | continue; |
228 | 228 | } |
229 | 229 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | -Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' ); |
|
236 | +Give_Cron::add_weekly_event('give_mark_abandoned_donations'); |
|
237 | 237 | |
238 | 238 | |
239 | 239 | /** |
@@ -245,15 +245,15 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @return void |
247 | 247 | */ |
248 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
248 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
249 | 249 | // Monthly stats. |
250 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
250 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
251 | 251 | |
252 | 252 | // @todo: Refresh only range related stat cache |
253 | 253 | give_delete_donation_stats(); |
254 | 254 | } |
255 | 255 | |
256 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
256 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
|
257 | 257 | |
258 | 258 | |
259 | 259 | /** |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return array |
271 | 271 | */ |
272 | -function give_bc_v20_get_payment_meta( $check, $object_id, $meta_key, $single ) { |
|
272 | +function give_bc_v20_get_payment_meta($check, $object_id, $meta_key, $single) { |
|
273 | 273 | // Bailout. |
274 | 274 | if ( |
275 | - 'give_payment' !== get_post_type( $object_id ) || |
|
275 | + 'give_payment' !== get_post_type($object_id) || |
|
276 | 276 | '_give_payment_meta' !== $meta_key || |
277 | - ! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) |
|
277 | + ! give_has_upgrade_completed('v20_upgrades_payment_metadata') |
|
278 | 278 | ) { |
279 | 279 | return $check; |
280 | 280 | } |
@@ -282,73 +282,69 @@ discard block |
||
282 | 282 | $cache_key = "_give_payment_meta_{$object_id}"; |
283 | 283 | |
284 | 284 | // Get already calculate payment meta from cache. |
285 | - $payment_meta = Give_Cache::get_db_query( $cache_key ); |
|
285 | + $payment_meta = Give_Cache::get_db_query($cache_key); |
|
286 | 286 | |
287 | - if ( is_null( $payment_meta ) ) { |
|
287 | + if (is_null($payment_meta)) { |
|
288 | 288 | // Remove filter. |
289 | - remove_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999 ); |
|
289 | + remove_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999); |
|
290 | 290 | |
291 | - $donation = new Give_Payment( $object_id ); |
|
291 | + $donation = new Give_Payment($object_id); |
|
292 | 292 | |
293 | 293 | // Get all payment meta. |
294 | - $payment_meta = give_get_meta( $object_id ); |
|
294 | + $payment_meta = give_get_meta($object_id); |
|
295 | 295 | |
296 | 296 | // Set default value to array. |
297 | - if ( empty( $payment_meta ) ) { |
|
297 | + if (empty($payment_meta)) { |
|
298 | 298 | return $check; |
299 | 299 | } |
300 | 300 | |
301 | 301 | // Convert all meta key value to string instead of array |
302 | - array_walk( $payment_meta, function ( &$meta, $key ) { |
|
303 | - $meta = current( $meta ); |
|
302 | + array_walk($payment_meta, function(&$meta, $key) { |
|
303 | + $meta = current($meta); |
|
304 | 304 | } ); |
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Add backward compatibility to old meta keys. |
308 | 308 | */ |
309 | 309 | // Donation key. |
310 | - $payment_meta['key'] = ! empty( $payment_meta['_give_payment_purchase_key'] ) ? $payment_meta['_give_payment_purchase_key'] : ''; |
|
310 | + $payment_meta['key'] = ! empty($payment_meta['_give_payment_purchase_key']) ? $payment_meta['_give_payment_purchase_key'] : ''; |
|
311 | 311 | |
312 | 312 | // Donation form. |
313 | - $payment_meta['form_title'] = ! empty( $payment_meta['_give_payment_form_title'] ) ? $payment_meta['_give_payment_form_title'] : ''; |
|
313 | + $payment_meta['form_title'] = ! empty($payment_meta['_give_payment_form_title']) ? $payment_meta['_give_payment_form_title'] : ''; |
|
314 | 314 | |
315 | 315 | // Donor email. |
316 | - $payment_meta['email'] = ! empty( $payment_meta['_give_payment_donor_email'] ) ? $payment_meta['_give_payment_donor_email'] : ''; |
|
317 | - $payment_meta['email'] = ! empty( $payment_meta['email'] ) ? |
|
318 | - $payment_meta['email'] : |
|
319 | - Give()->donors->get_column( 'email', $donation->donor_id ); |
|
316 | + $payment_meta['email'] = ! empty($payment_meta['_give_payment_donor_email']) ? $payment_meta['_give_payment_donor_email'] : ''; |
|
317 | + $payment_meta['email'] = ! empty($payment_meta['email']) ? |
|
318 | + $payment_meta['email'] : Give()->donors->get_column('email', $donation->donor_id); |
|
320 | 319 | |
321 | 320 | // Form id. |
322 | - $payment_meta['form_id'] = ! empty( $payment_meta['_give_payment_form_id'] ) ? $payment_meta['_give_payment_form_id'] : ''; |
|
321 | + $payment_meta['form_id'] = ! empty($payment_meta['_give_payment_form_id']) ? $payment_meta['_give_payment_form_id'] : ''; |
|
323 | 322 | |
324 | 323 | // Price id. |
325 | - $payment_meta['price_id'] = ! empty( $payment_meta['_give_payment_price_id'] ) ? $payment_meta['_give_payment_price_id'] : ''; |
|
324 | + $payment_meta['price_id'] = ! empty($payment_meta['_give_payment_price_id']) ? $payment_meta['_give_payment_price_id'] : ''; |
|
326 | 325 | |
327 | 326 | // Date. |
328 | - $payment_meta['date'] = ! empty( $payment_meta['_give_payment_date'] ) ? $payment_meta['_give_payment_date'] : ''; |
|
329 | - $payment_meta['date'] = ! empty( $payment_meta['date'] ) ? |
|
330 | - $payment_meta['date'] : |
|
331 | - get_post_field( 'post_date', $object_id ); |
|
327 | + $payment_meta['date'] = ! empty($payment_meta['_give_payment_date']) ? $payment_meta['_give_payment_date'] : ''; |
|
328 | + $payment_meta['date'] = ! empty($payment_meta['date']) ? |
|
329 | + $payment_meta['date'] : get_post_field('post_date', $object_id); |
|
332 | 330 | |
333 | 331 | |
334 | 332 | // Currency. |
335 | - $payment_meta['currency'] = ! empty( $payment_meta['_give_payment_currency'] ) ? $payment_meta['_give_payment_currency'] : ''; |
|
333 | + $payment_meta['currency'] = ! empty($payment_meta['_give_payment_currency']) ? $payment_meta['_give_payment_currency'] : ''; |
|
336 | 334 | |
337 | 335 | // Decode donor data. |
338 | - $donor_id = ! empty( $payment_meta['_give_payment_donor_id'] ) ? $payment_meta['_give_payment_donor_id'] : 0; |
|
339 | - $donor = new Give_Donor( $donor_id ); |
|
336 | + $donor_id = ! empty($payment_meta['_give_payment_donor_id']) ? $payment_meta['_give_payment_donor_id'] : 0; |
|
337 | + $donor = new Give_Donor($donor_id); |
|
340 | 338 | |
341 | 339 | // Donor first name. |
342 | - $donor_data['first_name'] = ! empty( $payment_meta['_give_donor_billing_first_name'] ) ? $payment_meta['_give_donor_billing_first_name'] : ''; |
|
343 | - $donor_data['first_name'] = ! empty( $donor_data['first_name'] ) ? |
|
344 | - $donor_data['first_name'] : |
|
345 | - $donor->get_first_name(); |
|
340 | + $donor_data['first_name'] = ! empty($payment_meta['_give_donor_billing_first_name']) ? $payment_meta['_give_donor_billing_first_name'] : ''; |
|
341 | + $donor_data['first_name'] = ! empty($donor_data['first_name']) ? |
|
342 | + $donor_data['first_name'] : $donor->get_first_name(); |
|
346 | 343 | |
347 | 344 | // Donor last name. |
348 | - $donor_data['last_name'] = ! empty( $payment_meta['_give_donor_billing_last_name'] ) ? $payment_meta['_give_donor_billing_last_name'] : ''; |
|
349 | - $donor_data['last_name'] = ! empty( $donor_data['last_name'] ) ? |
|
350 | - $donor_data['last_name'] : |
|
351 | - $donor->get_last_name(); |
|
345 | + $donor_data['last_name'] = ! empty($payment_meta['_give_donor_billing_last_name']) ? $payment_meta['_give_donor_billing_last_name'] : ''; |
|
346 | + $donor_data['last_name'] = ! empty($donor_data['last_name']) ? |
|
347 | + $donor_data['last_name'] : $donor->get_last_name(); |
|
352 | 348 | |
353 | 349 | // Donor email. |
354 | 350 | $donor_data['email'] = $payment_meta['email']; |
@@ -359,63 +355,63 @@ discard block |
||
359 | 355 | $donor_data['address'] = false; |
360 | 356 | |
361 | 357 | // Address1. |
362 | - $address1 = ! empty( $payment_meta['_give_donor_billing_address1'] ) ? $payment_meta['_give_donor_billing_address1'] : ''; |
|
363 | - if ( $address1 ) { |
|
358 | + $address1 = ! empty($payment_meta['_give_donor_billing_address1']) ? $payment_meta['_give_donor_billing_address1'] : ''; |
|
359 | + if ($address1) { |
|
364 | 360 | $donor_data['address']['line1'] = $address1; |
365 | 361 | } |
366 | 362 | |
367 | 363 | // Address2. |
368 | - $address2 = ! empty( $payment_meta['_give_donor_billing_address2'] ) ? $payment_meta['_give_donor_billing_address2'] : ''; |
|
369 | - if ( $address2 ) { |
|
364 | + $address2 = ! empty($payment_meta['_give_donor_billing_address2']) ? $payment_meta['_give_donor_billing_address2'] : ''; |
|
365 | + if ($address2) { |
|
370 | 366 | $donor_data['address']['line2'] = $address2; |
371 | 367 | } |
372 | 368 | |
373 | 369 | // City. |
374 | - $city = ! empty( $payment_meta['_give_donor_billing_city'] ) ? $payment_meta['_give_donor_billing_city'] : ''; |
|
375 | - if ( $city ) { |
|
370 | + $city = ! empty($payment_meta['_give_donor_billing_city']) ? $payment_meta['_give_donor_billing_city'] : ''; |
|
371 | + if ($city) { |
|
376 | 372 | $donor_data['address']['city'] = $city; |
377 | 373 | } |
378 | 374 | |
379 | 375 | // Zip. |
380 | - $zip = ! empty( $payment_meta['_give_donor_billing_zip'] ) ? $payment_meta['_give_donor_billing_zip'] : ''; |
|
381 | - if ( $zip ) { |
|
376 | + $zip = ! empty($payment_meta['_give_donor_billing_zip']) ? $payment_meta['_give_donor_billing_zip'] : ''; |
|
377 | + if ($zip) { |
|
382 | 378 | $donor_data['address']['zip'] = $zip; |
383 | 379 | } |
384 | 380 | |
385 | 381 | // State. |
386 | - $state = ! empty( $payment_meta['_give_donor_billing_state'] ) ? $payment_meta['_give_donor_billing_state'] : ''; |
|
387 | - if ( $state ) { |
|
382 | + $state = ! empty($payment_meta['_give_donor_billing_state']) ? $payment_meta['_give_donor_billing_state'] : ''; |
|
383 | + if ($state) { |
|
388 | 384 | $donor_data['address']['state'] = $state; |
389 | 385 | } |
390 | 386 | |
391 | 387 | // Country. |
392 | - $country = ! empty( $payment_meta['_give_donor_billing_country'] ) ? $payment_meta['_give_donor_billing_country'] : ''; |
|
393 | - if ( $country ) { |
|
388 | + $country = ! empty($payment_meta['_give_donor_billing_country']) ? $payment_meta['_give_donor_billing_country'] : ''; |
|
389 | + if ($country) { |
|
394 | 390 | $donor_data['address']['country'] = $country; |
395 | 391 | } |
396 | 392 | |
397 | 393 | $payment_meta['user_info'] = $donor_data; |
398 | 394 | |
399 | 395 | // Add filter |
400 | - add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
396 | + add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
401 | 397 | |
402 | 398 | // Set custom meta key into payment meta. |
403 | - if ( ! empty( $payment_meta['_give_payment_meta'] ) ) { |
|
404 | - $payment_meta = array_merge( maybe_unserialize( $payment_meta['_give_payment_meta'] ), $payment_meta ); |
|
399 | + if ( ! empty($payment_meta['_give_payment_meta'])) { |
|
400 | + $payment_meta = array_merge(maybe_unserialize($payment_meta['_give_payment_meta']), $payment_meta); |
|
405 | 401 | } |
406 | 402 | |
407 | 403 | // Set cache. |
408 | - Give_Cache::set_db_query( $cache_key, $payment_meta ); |
|
404 | + Give_Cache::set_db_query($cache_key, $payment_meta); |
|
409 | 405 | } |
410 | 406 | |
411 | - if ( $single ) { |
|
407 | + if ($single) { |
|
412 | 408 | /** |
413 | 409 | * Filter the payment meta |
414 | 410 | * Add custom meta key to payment meta |
415 | 411 | * |
416 | 412 | * @since 2.0 |
417 | 413 | */ |
418 | - $new_payment_meta[0] = apply_filters( 'give_get_payment_meta', $payment_meta, $object_id, $meta_key ); |
|
414 | + $new_payment_meta[0] = apply_filters('give_get_payment_meta', $payment_meta, $object_id, $meta_key); |
|
419 | 415 | |
420 | 416 | $payment_meta = $new_payment_meta; |
421 | 417 | } |
@@ -423,7 +419,7 @@ discard block |
||
423 | 419 | return $payment_meta; |
424 | 420 | } |
425 | 421 | |
426 | -add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
422 | +add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
427 | 423 | |
428 | 424 | /** |
429 | 425 | * Add meta in payment that store page id and page url. |
@@ -435,19 +431,19 @@ discard block |
||
435 | 431 | * |
436 | 432 | * @param int $payment_id Payment id for which the meta value should be updated. |
437 | 433 | */ |
438 | -function give_payment_save_page_data( $payment_id ) { |
|
439 | - $page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false ); |
|
434 | +function give_payment_save_page_data($payment_id) { |
|
435 | + $page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false); |
|
440 | 436 | |
441 | 437 | // Check $page_url is not empty. |
442 | - if ( $page_url ) { |
|
443 | - update_post_meta( $payment_id, '_give_current_url', $page_url ); |
|
444 | - $page_id = url_to_postid( $page_url ); |
|
438 | + if ($page_url) { |
|
439 | + update_post_meta($payment_id, '_give_current_url', $page_url); |
|
440 | + $page_id = url_to_postid($page_url); |
|
445 | 441 | // Check $page_id is not empty. |
446 | - if ( $page_id ) { |
|
447 | - update_post_meta( $payment_id, '_give_current_page_id', $page_id ); |
|
442 | + if ($page_id) { |
|
443 | + update_post_meta($payment_id, '_give_current_page_id', $page_id); |
|
448 | 444 | } |
449 | 445 | } |
450 | 446 | } |
451 | 447 | |
452 | 448 | // Fire when payment is save. |
453 | -add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
454 | 449 | \ No newline at end of file |
450 | +add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
455 | 451 | \ No newline at end of file |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Exit if accessed directly. |
26 | -if ( ! defined( 'ABSPATH' ) ) { |
|
26 | +if ( ! defined('ABSPATH')) { |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | * @param callable $func Hook to run when email tag is found |
57 | 57 | * @param string $context Email tag category |
58 | 58 | */ |
59 | - public function add( $tag, $description, $func, $context = '' ) { |
|
60 | - if ( is_callable( $func ) ) { |
|
61 | - $this->tags[ $tag ] = array( |
|
59 | + public function add($tag, $description, $func, $context = '') { |
|
60 | + if (is_callable($func)) { |
|
61 | + $this->tags[$tag] = array( |
|
62 | 62 | 'tag' => $tag, |
63 | 63 | 'description' => $description, |
64 | 64 | 'func' => $func, |
65 | - 'context' => give_check_variable( $context, 'empty', 'general' ), |
|
65 | + 'context' => give_check_variable($context, 'empty', 'general'), |
|
66 | 66 | ); |
67 | 67 | } |
68 | 68 | } |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param string $tag Email tag to remove hook from |
76 | 76 | */ |
77 | - public function remove( $tag ) { |
|
78 | - unset( $this->tags[ $tag ] ); |
|
77 | + public function remove($tag) { |
|
78 | + unset($this->tags[$tag]); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return bool |
89 | 89 | */ |
90 | - public function email_tag_exists( $tag ) { |
|
91 | - return array_key_exists( $tag, $this->tags ); |
|
90 | + public function email_tag_exists($tag) { |
|
91 | + return array_key_exists($tag, $this->tags); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -102,23 +102,23 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return array |
104 | 104 | */ |
105 | - public function get_tags( $context_type = 'all', $field = '' ) { |
|
105 | + public function get_tags($context_type = 'all', $field = '') { |
|
106 | 106 | $tags = $this->tags; |
107 | 107 | |
108 | - if ( 'all' !== $context_type ) { |
|
108 | + if ('all' !== $context_type) { |
|
109 | 109 | $tags = array(); |
110 | 110 | |
111 | - foreach ( $this->tags as $tag ) { |
|
112 | - if ( empty( $tag['context'] ) || $context_type !== $tag['context'] ) { |
|
111 | + foreach ($this->tags as $tag) { |
|
112 | + if (empty($tag['context']) || $context_type !== $tag['context']) { |
|
113 | 113 | continue; |
114 | 114 | } |
115 | 115 | |
116 | - $tags[ $tag['tag'] ] = $tag; |
|
116 | + $tags[$tag['tag']] = $tag; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - if ( ! empty( $tags ) && ! empty( $field ) ) { |
|
121 | - $tags = wp_list_pluck( $tags, $field ); |
|
120 | + if ( ! empty($tags) && ! empty($field)) { |
|
121 | + $tags = wp_list_pluck($tags, $field); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | return $tags; |
@@ -136,16 +136,16 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return string Content with email tags filtered out. |
138 | 138 | */ |
139 | - public function do_tags( $content, $tag_args ) { |
|
139 | + public function do_tags($content, $tag_args) { |
|
140 | 140 | |
141 | 141 | // Check if there is at least one tag added. |
142 | - if ( empty( $this->tags ) || ! is_array( $this->tags ) ) { |
|
142 | + if (empty($this->tags) || ! is_array($this->tags)) { |
|
143 | 143 | return $content; |
144 | 144 | } |
145 | 145 | |
146 | 146 | $this->tag_args = $tag_args; |
147 | 147 | |
148 | - $new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content ); |
|
148 | + $new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content); |
|
149 | 149 | |
150 | 150 | $this->tag_args = null; |
151 | 151 | |
@@ -161,17 +161,17 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return mixed |
163 | 163 | */ |
164 | - public function do_tag( $m ) { |
|
164 | + public function do_tag($m) { |
|
165 | 165 | |
166 | 166 | // Get tag |
167 | 167 | $tag = $m[1]; |
168 | 168 | |
169 | 169 | // Return tag if tag not set |
170 | - if ( ! $this->email_tag_exists( $tag ) ) { |
|
170 | + if ( ! $this->email_tag_exists($tag)) { |
|
171 | 171 | return $m[0]; |
172 | 172 | } |
173 | 173 | |
174 | - return call_user_func( $this->tags[ $tag ]['func'], $this->tag_args, $tag ); |
|
174 | + return call_user_func($this->tags[$tag]['func'], $this->tag_args, $tag); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | } |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param callable $func Hook to run when email tag is found |
187 | 187 | * @param string $context Email tag category |
188 | 188 | */ |
189 | -function give_add_email_tag( $tag, $description, $func, $context = '' ) { |
|
190 | - Give()->email_tags->add( $tag, $description, $func, $context ); |
|
189 | +function give_add_email_tag($tag, $description, $func, $context = '') { |
|
190 | + Give()->email_tags->add($tag, $description, $func, $context); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param string $tag Email tag to remove hook from |
199 | 199 | */ |
200 | -function give_remove_email_tag( $tag ) { |
|
201 | - Give()->email_tags->remove( $tag ); |
|
200 | +function give_remove_email_tag($tag) { |
|
201 | + Give()->email_tags->remove($tag); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return bool |
212 | 212 | */ |
213 | -function give_email_tag_exists( $tag ) { |
|
214 | - return Give()->email_tags->email_tag_exists( $tag ); |
|
213 | +function give_email_tag_exists($tag) { |
|
214 | + return Give()->email_tags->email_tag_exists($tag); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | $email_tags = give_get_email_tags(); |
239 | 239 | |
240 | 240 | ob_start(); |
241 | - if ( count( $email_tags ) > 0 ) : ?> |
|
241 | + if (count($email_tags) > 0) : ?> |
|
242 | 242 | <div class="give-email-tags-wrap"> |
243 | - <?php foreach ( $email_tags as $email_tag ) : ?> |
|
243 | + <?php foreach ($email_tags as $email_tag) : ?> |
|
244 | 244 | <span class="give_<?php echo $email_tag['tag']; ?>_tag"> |
245 | 245 | <code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?> |
246 | 246 | </span> |
@@ -264,14 +264,14 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return string Content with email tags filtered out. |
266 | 266 | */ |
267 | -function give_do_email_tags( $content, $tag_args ) { |
|
267 | +function give_do_email_tags($content, $tag_args) { |
|
268 | 268 | // Backward compatibility < 2.0 |
269 | - if ( ! is_array( $tag_args ) ) { |
|
270 | - $tag_args = array( 'payment_id' => $tag_args ); |
|
269 | + if ( ! is_array($tag_args)) { |
|
270 | + $tag_args = array('payment_id' => $tag_args); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // Replace all tags |
274 | - $content = Give()->email_tags->do_tags( $content, $tag_args ); |
|
274 | + $content = Give()->email_tags->do_tags($content, $tag_args); |
|
275 | 275 | |
276 | 276 | /** |
277 | 277 | * Filter the filtered content text. |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * @since 1.0 |
280 | 280 | * @since 2.0 $payment_meta, $payment_id removed and $tag_args added. |
281 | 281 | */ |
282 | - $content = apply_filters( 'give_email_template_tags', $content, $tag_args ); |
|
282 | + $content = apply_filters('give_email_template_tags', $content, $tag_args); |
|
283 | 283 | |
284 | 284 | // Return content |
285 | 285 | return $content; |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @since 1.0 |
300 | 300 | */ |
301 | - do_action( 'give_add_email_tags' ); |
|
301 | + do_action('give_add_email_tags'); |
|
302 | 302 | } |
303 | 303 | |
304 | -add_action( 'init', 'give_load_email_tags', - 999 ); |
|
304 | +add_action('init', 'give_load_email_tags', - 999); |
|
305 | 305 | |
306 | 306 | |
307 | 307 | /** |
@@ -316,67 +316,67 @@ discard block |
||
316 | 316 | /* Donation Payment */ |
317 | 317 | array( |
318 | 318 | 'tag' => 'donation', |
319 | - 'description' => esc_html__( 'The donation form name, and the donation level (if applicable).', 'give' ), |
|
319 | + 'description' => esc_html__('The donation form name, and the donation level (if applicable).', 'give'), |
|
320 | 320 | 'function' => 'give_email_tag_donation', |
321 | 321 | 'context' => 'donation', |
322 | 322 | ), |
323 | 323 | array( |
324 | 324 | 'tag' => 'amount', |
325 | - 'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ), |
|
325 | + 'description' => esc_html__('The total donation amount with currency sign.', 'give'), |
|
326 | 326 | 'function' => 'give_email_tag_amount', |
327 | 327 | 'context' => 'donation', |
328 | 328 | ), |
329 | 329 | array( |
330 | 330 | 'tag' => 'price', |
331 | - 'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ), |
|
331 | + 'description' => esc_html__('The total donation amount with currency sign.', 'give'), |
|
332 | 332 | 'function' => 'give_email_tag_price', |
333 | 333 | 'context' => 'donation', |
334 | 334 | ), |
335 | 335 | array( |
336 | 336 | 'tag' => 'billing_address', |
337 | - 'description' => esc_html__( 'The donor\'s billing address.', 'give' ), |
|
337 | + 'description' => esc_html__('The donor\'s billing address.', 'give'), |
|
338 | 338 | 'function' => 'give_email_tag_billing_address', |
339 | 339 | 'context' => 'donation', |
340 | 340 | ), |
341 | 341 | array( |
342 | 342 | 'tag' => 'date', |
343 | - 'description' => esc_html__( 'The date of the donation.', 'give' ), |
|
343 | + 'description' => esc_html__('The date of the donation.', 'give'), |
|
344 | 344 | 'function' => 'give_email_tag_date', |
345 | 345 | 'context' => 'donation', |
346 | 346 | ), |
347 | 347 | array( |
348 | 348 | 'tag' => 'payment_id', |
349 | - 'description' => esc_html__( 'The unique ID number for this donation.', 'give' ), |
|
349 | + 'description' => esc_html__('The unique ID number for this donation.', 'give'), |
|
350 | 350 | 'function' => 'give_email_tag_payment_id', |
351 | 351 | 'context' => 'donation', |
352 | 352 | ), |
353 | 353 | array( |
354 | 354 | 'tag' => 'payment_method', |
355 | - 'description' => esc_html__( 'The method of payment used for this donation.', 'give' ), |
|
355 | + 'description' => esc_html__('The method of payment used for this donation.', 'give'), |
|
356 | 356 | 'function' => 'give_email_tag_payment_method', |
357 | 357 | 'context' => 'donation', |
358 | 358 | ), |
359 | 359 | array( |
360 | 360 | 'tag' => 'payment_total', |
361 | - 'description' => esc_html__( 'The payment total for this donation.', 'give' ), |
|
361 | + 'description' => esc_html__('The payment total for this donation.', 'give'), |
|
362 | 362 | 'function' => 'give_email_tag_payment_total', |
363 | 363 | 'context' => 'donation', |
364 | 364 | ), |
365 | 365 | array( |
366 | 366 | 'tag' => 'receipt_id', |
367 | - 'description' => esc_html__( 'The unique ID number for this donation receipt.', 'give' ), |
|
367 | + 'description' => esc_html__('The unique ID number for this donation receipt.', 'give'), |
|
368 | 368 | 'function' => 'give_email_tag_receipt_id', |
369 | 369 | 'context' => 'donation', |
370 | 370 | ), |
371 | 371 | array( |
372 | 372 | 'tag' => 'receipt_link', |
373 | - 'description' => esc_html__( 'The donation receipt direct link, to view the receipt on the website.', 'give' ), |
|
373 | + 'description' => esc_html__('The donation receipt direct link, to view the receipt on the website.', 'give'), |
|
374 | 374 | 'function' => 'give_email_tag_receipt_link', |
375 | 375 | 'context' => 'donation', |
376 | 376 | ), |
377 | 377 | array( |
378 | 378 | 'tag' => 'receipt_link_url', |
379 | - 'description' => esc_html__( 'The donation receipt direct URL, to view the receipt on the website.', 'give' ), |
|
379 | + 'description' => esc_html__('The donation receipt direct URL, to view the receipt on the website.', 'give'), |
|
380 | 380 | 'function' => 'give_email_tag_receipt_link_url', |
381 | 381 | 'context' => 'donation', |
382 | 382 | ), |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | /* Donation Form */ |
385 | 385 | array( |
386 | 386 | 'tag' => 'form_title', |
387 | - 'description' => esc_html__( 'The donation form name.', 'give' ), |
|
387 | + 'description' => esc_html__('The donation form name.', 'give'), |
|
388 | 388 | 'function' => 'give_email_tag_form_title', |
389 | 389 | 'context' => 'form', |
390 | 390 | ), |
@@ -392,31 +392,31 @@ discard block |
||
392 | 392 | /* Donor */ |
393 | 393 | array( |
394 | 394 | 'tag' => 'name', |
395 | - 'description' => esc_html__( 'The donor\'s first name.', 'give' ), |
|
395 | + 'description' => esc_html__('The donor\'s first name.', 'give'), |
|
396 | 396 | 'function' => 'give_email_tag_first_name', |
397 | 397 | 'context' => 'donor', |
398 | 398 | ), |
399 | 399 | array( |
400 | 400 | 'tag' => 'fullname', |
401 | - 'description' => esc_html__( 'The donor\'s full name, first and last.', 'give' ), |
|
401 | + 'description' => esc_html__('The donor\'s full name, first and last.', 'give'), |
|
402 | 402 | 'function' => 'give_email_tag_fullname', |
403 | 403 | 'context' => 'donor', |
404 | 404 | ), |
405 | 405 | array( |
406 | 406 | 'tag' => 'username', |
407 | - 'description' => esc_html__( 'The donor\'s user name on the site, if they registered an account.', 'give' ), |
|
407 | + 'description' => esc_html__('The donor\'s user name on the site, if they registered an account.', 'give'), |
|
408 | 408 | 'function' => 'give_email_tag_username', |
409 | 409 | 'context' => 'donor', |
410 | 410 | ), |
411 | 411 | array( |
412 | 412 | 'tag' => 'user_email', |
413 | - 'description' => esc_html__( 'The donor\'s email address.', 'give' ), |
|
413 | + 'description' => esc_html__('The donor\'s email address.', 'give'), |
|
414 | 414 | 'function' => 'give_email_tag_user_email', |
415 | 415 | 'context' => 'donor', |
416 | 416 | ), |
417 | 417 | array( |
418 | 418 | 'tag' => 'email_access_link', |
419 | - 'description' => esc_html__( 'The donor\'s email access link.', 'give' ), |
|
419 | + 'description' => esc_html__('The donor\'s email access link.', 'give'), |
|
420 | 420 | 'function' => 'give_email_tag_email_access_link', |
421 | 421 | 'context' => 'donor', |
422 | 422 | ), |
@@ -424,14 +424,14 @@ discard block |
||
424 | 424 | /* General */ |
425 | 425 | array( |
426 | 426 | 'tag' => 'sitename', |
427 | - 'description' => esc_html__( 'The name of your site.', 'give' ), |
|
427 | + 'description' => esc_html__('The name of your site.', 'give'), |
|
428 | 428 | 'function' => 'give_email_tag_sitename', |
429 | 429 | 'context' => 'general', |
430 | 430 | ), |
431 | 431 | |
432 | 432 | array( |
433 | 433 | 'tag' => 'reset_password_link', |
434 | - 'description' => esc_html__( 'The reset password link for user.', 'give' ), |
|
434 | + 'description' => esc_html__('The reset password link for user.', 'give'), |
|
435 | 435 | 'function' => 'give_email_tag_reset_password_link', |
436 | 436 | 'context' => 'general', |
437 | 437 | ), |
@@ -439,21 +439,21 @@ discard block |
||
439 | 439 | ); |
440 | 440 | |
441 | 441 | // Apply give_email_tags filter |
442 | - $email_tags = apply_filters( 'give_email_tags', $email_tags ); |
|
442 | + $email_tags = apply_filters('give_email_tags', $email_tags); |
|
443 | 443 | |
444 | 444 | // Add email tags |
445 | - foreach ( $email_tags as $email_tag ) { |
|
445 | + foreach ($email_tags as $email_tag) { |
|
446 | 446 | give_add_email_tag( |
447 | 447 | $email_tag['tag'], |
448 | 448 | $email_tag['description'], |
449 | 449 | $email_tag['function'], |
450 | - ( ! empty( $email_tag['context'] ) ? $email_tag['context'] : '' ) |
|
450 | + ( ! empty($email_tag['context']) ? $email_tag['context'] : '') |
|
451 | 451 | ); |
452 | 452 | } |
453 | 453 | |
454 | 454 | } |
455 | 455 | |
456 | -add_action( 'give_add_email_tags', 'give_setup_email_tags' ); |
|
456 | +add_action('give_add_email_tags', 'give_setup_email_tags'); |
|
457 | 457 | |
458 | 458 | |
459 | 459 | /** |
@@ -465,26 +465,26 @@ discard block |
||
465 | 465 | * |
466 | 466 | * @return string $firstname |
467 | 467 | */ |
468 | -function give_email_tag_first_name( $tag_args ) { |
|
468 | +function give_email_tag_first_name($tag_args) { |
|
469 | 469 | $user_info = array(); |
470 | 470 | $firstname = ''; |
471 | 471 | |
472 | 472 | // Backward compatibility. |
473 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
473 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
474 | 474 | |
475 | - switch ( true ) { |
|
476 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
477 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
475 | + switch (true) { |
|
476 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
477 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
478 | 478 | |
479 | 479 | // Get firstname. |
480 | - if ( ! empty( $payment->user_info ) ) { |
|
481 | - $email_names = give_get_email_names( $payment->user_info ); |
|
480 | + if ( ! empty($payment->user_info)) { |
|
481 | + $email_names = give_get_email_names($payment->user_info); |
|
482 | 482 | $firstname = $email_names['name']; |
483 | 483 | } |
484 | 484 | break; |
485 | 485 | |
486 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
487 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
486 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
487 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
488 | 488 | $firstname = $donor->get_first_name(); |
489 | 489 | break; |
490 | 490 | |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @since 2.0 |
495 | 495 | */ |
496 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
497 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
496 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
497 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
498 | 498 | $firstname = $donor->get_first_name(); |
499 | 499 | break; |
500 | 500 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * @param string $firstname |
508 | 508 | * @param array $tag_args |
509 | 509 | */ |
510 | - $firstname = apply_filters( 'give_email_tag_first_name', $firstname, $tag_args ); |
|
510 | + $firstname = apply_filters('give_email_tag_first_name', $firstname, $tag_args); |
|
511 | 511 | |
512 | 512 | return $firstname; |
513 | 513 | } |
@@ -521,26 +521,26 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return string $fullname |
523 | 523 | */ |
524 | -function give_email_tag_fullname( $tag_args ) { |
|
524 | +function give_email_tag_fullname($tag_args) { |
|
525 | 525 | $fullname = ''; |
526 | 526 | |
527 | 527 | // Backward compatibility. |
528 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
528 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
529 | 529 | |
530 | - switch ( true ) { |
|
531 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
532 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
530 | + switch (true) { |
|
531 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
532 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
533 | 533 | |
534 | 534 | // Get fullname. |
535 | - if ( ! empty( $payment->user_info ) ) { |
|
536 | - $email_names = give_get_email_names( $payment->user_info ); |
|
535 | + if ( ! empty($payment->user_info)) { |
|
536 | + $email_names = give_get_email_names($payment->user_info); |
|
537 | 537 | $fullname = $email_names['fullname']; |
538 | 538 | } |
539 | 539 | break; |
540 | 540 | |
541 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
542 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
543 | - $fullname = trim( "{$donor->get_first_name()} {$donor->get_last_name()}" ); |
|
541 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
542 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
543 | + $fullname = trim("{$donor->get_first_name()} {$donor->get_last_name()}"); |
|
544 | 544 | break; |
545 | 545 | |
546 | 546 | /** |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | * |
549 | 549 | * @since 2.0 |
550 | 550 | */ |
551 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
552 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
551 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
552 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
553 | 553 | $fullname = $donor->name; |
554 | 554 | break; |
555 | 555 | } |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * @param string $fullname |
563 | 563 | * @param array $tag_args |
564 | 564 | */ |
565 | - $fullname = apply_filters( 'give_email_tag_fullname', $fullname, $tag_args ); |
|
565 | + $fullname = apply_filters('give_email_tag_fullname', $fullname, $tag_args); |
|
566 | 566 | |
567 | 567 | return $fullname; |
568 | 568 | } |
@@ -576,25 +576,25 @@ discard block |
||
576 | 576 | * |
577 | 577 | * @return string username. |
578 | 578 | */ |
579 | -function give_email_tag_username( $tag_args ) { |
|
579 | +function give_email_tag_username($tag_args) { |
|
580 | 580 | $username = ''; |
581 | 581 | |
582 | 582 | // Backward compatibility. |
583 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
583 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
584 | 584 | |
585 | - switch ( true ) { |
|
586 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
587 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
585 | + switch (true) { |
|
586 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
587 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
588 | 588 | |
589 | 589 | // Get username. |
590 | - if ( ! empty( $payment->user_info ) ) { |
|
591 | - $email_names = give_get_email_names( $payment->user_info ); |
|
590 | + if ( ! empty($payment->user_info)) { |
|
591 | + $email_names = give_get_email_names($payment->user_info); |
|
592 | 592 | $username = $email_names['username']; |
593 | 593 | } |
594 | 594 | break; |
595 | 595 | |
596 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
597 | - $user_info = get_user_by( 'id', $tag_args['user_id'] ); |
|
596 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
597 | + $user_info = get_user_by('id', $tag_args['user_id']); |
|
598 | 598 | $username = $user_info->user_login; |
599 | 599 | break; |
600 | 600 | |
@@ -603,10 +603,10 @@ discard block |
||
603 | 603 | * |
604 | 604 | * @since 2.0 |
605 | 605 | */ |
606 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
607 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
608 | - if ( ! empty( $donor->id ) && ! empty( $donor->user_id ) ) { |
|
609 | - $user_info = get_user_by( 'id', $donor->user_id ); |
|
606 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
607 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
608 | + if ( ! empty($donor->id) && ! empty($donor->user_id)) { |
|
609 | + $user_info = get_user_by('id', $donor->user_id); |
|
610 | 610 | $username = $user_info->user_login; |
611 | 611 | } |
612 | 612 | break; |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | * @param string $username |
621 | 621 | * @param array $tag_args |
622 | 622 | */ |
623 | - $username = apply_filters( 'give_email_tag_username', $username, $tag_args ); |
|
623 | + $username = apply_filters('give_email_tag_username', $username, $tag_args); |
|
624 | 624 | |
625 | 625 | return $username; |
626 | 626 | } |
@@ -634,20 +634,20 @@ discard block |
||
634 | 634 | * |
635 | 635 | * @return string user_email |
636 | 636 | */ |
637 | -function give_email_tag_user_email( $tag_args ) { |
|
637 | +function give_email_tag_user_email($tag_args) { |
|
638 | 638 | $email = ''; |
639 | 639 | |
640 | 640 | // Backward compatibility. |
641 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
641 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
642 | 642 | |
643 | - switch ( true ) { |
|
644 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
645 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
643 | + switch (true) { |
|
644 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
645 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
646 | 646 | $email = $payment->email; |
647 | 647 | break; |
648 | 648 | |
649 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
650 | - $user_info = get_user_by( 'id', $tag_args['user_id'] ); |
|
649 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
650 | + $user_info = get_user_by('id', $tag_args['user_id']); |
|
651 | 651 | $email = $user_info->user_email; |
652 | 652 | break; |
653 | 653 | |
@@ -656,9 +656,9 @@ discard block |
||
656 | 656 | * |
657 | 657 | * @since 2.0 |
658 | 658 | */ |
659 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
660 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
661 | - $email = $donor->email; |
|
659 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
660 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
661 | + $email = $donor->email; |
|
662 | 662 | break; |
663 | 663 | } |
664 | 664 | |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * @param string $email |
671 | 671 | * @param array $tag_args |
672 | 672 | */ |
673 | - $email = apply_filters( 'give_email_tag_user_email', $email, $tag_args ); |
|
673 | + $email = apply_filters('give_email_tag_user_email', $email, $tag_args); |
|
674 | 674 | |
675 | 675 | return $email; |
676 | 676 | } |
@@ -684,22 +684,22 @@ discard block |
||
684 | 684 | * |
685 | 685 | * @return string billing_address |
686 | 686 | */ |
687 | -function give_email_tag_billing_address( $tag_args ) { |
|
687 | +function give_email_tag_billing_address($tag_args) { |
|
688 | 688 | $address = ''; |
689 | 689 | |
690 | 690 | // Backward compatibility. |
691 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
691 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
692 | 692 | |
693 | - switch ( true ) { |
|
694 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
695 | - $donation = new Give_Payment( $tag_args['payment_id'] ); |
|
696 | - $address = $donation->address['line1'] . "\n"; |
|
693 | + switch (true) { |
|
694 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
695 | + $donation = new Give_Payment($tag_args['payment_id']); |
|
696 | + $address = $donation->address['line1']."\n"; |
|
697 | 697 | |
698 | - if ( ! empty( $donation->address['line2'] ) ) { |
|
699 | - $address .= $donation->address['line2'] . "\n"; |
|
698 | + if ( ! empty($donation->address['line2'])) { |
|
699 | + $address .= $donation->address['line2']."\n"; |
|
700 | 700 | } |
701 | 701 | |
702 | - $address .= $donation->address['city'] . ' ' . $donation->address['zip'] . ' ' . $donation->address['state'] . "\n"; |
|
702 | + $address .= $donation->address['city'].' '.$donation->address['zip'].' '.$donation->address['state']."\n"; |
|
703 | 703 | $address .= $donation->address['country']; |
704 | 704 | break; |
705 | 705 | } |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | * @param string $address |
713 | 713 | * @param array $tag_args |
714 | 714 | */ |
715 | - $address = apply_filters( 'give_email_tag_billing_address', $address, $tag_args ); |
|
715 | + $address = apply_filters('give_email_tag_billing_address', $address, $tag_args); |
|
716 | 716 | |
717 | 717 | return $address; |
718 | 718 | } |
@@ -726,16 +726,16 @@ discard block |
||
726 | 726 | * |
727 | 727 | * @return string date |
728 | 728 | */ |
729 | -function give_email_tag_date( $tag_args ) { |
|
729 | +function give_email_tag_date($tag_args) { |
|
730 | 730 | $date = ''; |
731 | 731 | |
732 | 732 | // Backward compatibility. |
733 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
733 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
734 | 734 | |
735 | - switch ( true ) { |
|
736 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
737 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
738 | - $date = date_i18n( give_date_format(), strtotime( $payment->date ) ); |
|
735 | + switch (true) { |
|
736 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
737 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
738 | + $date = date_i18n(give_date_format(), strtotime($payment->date)); |
|
739 | 739 | break; |
740 | 740 | } |
741 | 741 | |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | * @param string $date |
748 | 748 | * @param array $tag_args |
749 | 749 | */ |
750 | - $date = apply_filters( 'give_email_tag_date', $date, $tag_args ); |
|
750 | + $date = apply_filters('give_email_tag_date', $date, $tag_args); |
|
751 | 751 | |
752 | 752 | return $date; |
753 | 753 | } |
@@ -761,17 +761,17 @@ discard block |
||
761 | 761 | * |
762 | 762 | * @return string amount |
763 | 763 | */ |
764 | -function give_email_tag_amount( $tag_args ) { |
|
764 | +function give_email_tag_amount($tag_args) { |
|
765 | 765 | $amount = ''; |
766 | 766 | |
767 | 767 | // Backward compatibility. |
768 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
768 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
769 | 769 | |
770 | - switch ( true ) { |
|
771 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
772 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
773 | - $give_amount = give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ), array( 'currency_code' => $payment->currency ) ); |
|
774 | - $amount = html_entity_decode( $give_amount, ENT_COMPAT, 'UTF-8' ); |
|
770 | + switch (true) { |
|
771 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
772 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
773 | + $give_amount = give_currency_filter(give_format_amount($payment->total, array('sanitize' => false)), array('currency_code' => $payment->currency)); |
|
774 | + $amount = html_entity_decode($give_amount, ENT_COMPAT, 'UTF-8'); |
|
775 | 775 | break; |
776 | 776 | } |
777 | 777 | |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | * @param string $amount |
784 | 784 | * @param array $tag_args |
785 | 785 | */ |
786 | - $amount = apply_filters( 'give_email_tag_amount', $amount, $tag_args ); |
|
786 | + $amount = apply_filters('give_email_tag_amount', $amount, $tag_args); |
|
787 | 787 | |
788 | 788 | return $amount; |
789 | 789 | } |
@@ -797,8 +797,8 @@ discard block |
||
797 | 797 | * |
798 | 798 | * @return string price |
799 | 799 | */ |
800 | -function give_email_tag_price( $tag_args ) { |
|
801 | - return give_email_tag_amount( $tag_args ); |
|
800 | +function give_email_tag_price($tag_args) { |
|
801 | + return give_email_tag_amount($tag_args); |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | /** |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | * |
811 | 811 | * @return int payment_id |
812 | 812 | */ |
813 | -function give_email_tag_payment_id( $tag_args ) { |
|
813 | +function give_email_tag_payment_id($tag_args) { |
|
814 | 814 | $payment_id = ''; |
815 | 815 | |
816 | 816 | // Backward compatibility. |
817 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
817 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
818 | 818 | |
819 | - switch ( true ) { |
|
820 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
821 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
819 | + switch (true) { |
|
820 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
821 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
822 | 822 | $payment_id = $payment->number; |
823 | 823 | break; |
824 | 824 | } |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | * @param string $payment_id |
832 | 832 | * @param array $tag_args |
833 | 833 | */ |
834 | - return apply_filters( 'give_email_tag_payment_id', $payment_id, $tag_args ); |
|
834 | + return apply_filters('give_email_tag_payment_id', $payment_id, $tag_args); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | /** |
@@ -843,15 +843,15 @@ discard block |
||
843 | 843 | * |
844 | 844 | * @return string receipt_id |
845 | 845 | */ |
846 | -function give_email_tag_receipt_id( $tag_args ) { |
|
846 | +function give_email_tag_receipt_id($tag_args) { |
|
847 | 847 | $receipt_id = ''; |
848 | 848 | |
849 | 849 | // Backward compatibility. |
850 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
850 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
851 | 851 | |
852 | - switch ( true ) { |
|
853 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
854 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
852 | + switch (true) { |
|
853 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
854 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
855 | 855 | $receipt_id = $payment->key; |
856 | 856 | break; |
857 | 857 | } |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | * @param string $receipt_id |
865 | 865 | * @param array $tag_args |
866 | 866 | */ |
867 | - return apply_filters( 'give_email_tag_receipt_id', $receipt_id, $tag_args ); |
|
867 | + return apply_filters('give_email_tag_receipt_id', $receipt_id, $tag_args); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | /** |
@@ -876,23 +876,23 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return string $form_title |
878 | 878 | */ |
879 | -function give_email_tag_donation( $tag_args ) { |
|
879 | +function give_email_tag_donation($tag_args) { |
|
880 | 880 | $donation_form_title = ''; |
881 | 881 | |
882 | 882 | // Backward compatibility. |
883 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
883 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
884 | 884 | |
885 | - switch ( true ) { |
|
886 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
887 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
888 | - $level_title = give_has_variable_prices( $payment->form_id ); |
|
885 | + switch (true) { |
|
886 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
887 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
888 | + $level_title = give_has_variable_prices($payment->form_id); |
|
889 | 889 | $separator = $level_title ? '-' : ''; |
890 | - $donation_form_title = strip_tags( give_check_variable( give_get_donation_form_title( |
|
890 | + $donation_form_title = strip_tags(give_check_variable(give_get_donation_form_title( |
|
891 | 891 | $payment, |
892 | 892 | array( |
893 | 893 | 'separator' => $separator, |
894 | 894 | ) |
895 | - ), 'empty', '' ) ); |
|
895 | + ), 'empty', '')); |
|
896 | 896 | break; |
897 | 897 | } |
898 | 898 | |
@@ -920,17 +920,17 @@ discard block |
||
920 | 920 | * |
921 | 921 | * @return string $form_title |
922 | 922 | */ |
923 | -function give_email_tag_form_title( $tag_args ) { |
|
923 | +function give_email_tag_form_title($tag_args) { |
|
924 | 924 | $donation_form_title = ''; |
925 | 925 | |
926 | 926 | // Backward compatibility. |
927 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
927 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
928 | 928 | |
929 | - switch ( true ) { |
|
930 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
931 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
929 | + switch (true) { |
|
930 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
931 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
932 | 932 | $payment_meta = $payment->payment_meta; |
933 | - $donation_form_title = strip_tags( give_check_variable( $payment_meta, 'empty', '', 'form_title' ) ); |
|
933 | + $donation_form_title = strip_tags(give_check_variable($payment_meta, 'empty', '', 'form_title')); |
|
934 | 934 | break; |
935 | 935 | } |
936 | 936 | |
@@ -958,19 +958,19 @@ discard block |
||
958 | 958 | * |
959 | 959 | * @return string gateway |
960 | 960 | */ |
961 | -function give_email_tag_payment_method( $tag_args ) { |
|
961 | +function give_email_tag_payment_method($tag_args) { |
|
962 | 962 | $payment_method = ''; |
963 | 963 | |
964 | 964 | // Backward compatibility. |
965 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
965 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
966 | 966 | |
967 | 967 | // Backward compatibility. |
968 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
968 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
969 | 969 | |
970 | - switch ( true ) { |
|
971 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
972 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
973 | - $payment_method = give_get_gateway_checkout_label( $payment->gateway ); |
|
970 | + switch (true) { |
|
971 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
972 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
973 | + $payment_method = give_get_gateway_checkout_label($payment->gateway); |
|
974 | 974 | break; |
975 | 975 | } |
976 | 976 | |
@@ -1001,16 +1001,16 @@ discard block |
||
1001 | 1001 | * |
1002 | 1002 | * @return string |
1003 | 1003 | */ |
1004 | -function give_email_tag_payment_total( $tag_args ) { |
|
1004 | +function give_email_tag_payment_total($tag_args) { |
|
1005 | 1005 | $payment_total = ''; |
1006 | 1006 | |
1007 | 1007 | // Backward compatibility. |
1008 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1008 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1009 | 1009 | |
1010 | - switch ( true ) { |
|
1011 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
1012 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
1013 | - $payment_total = give_currency_filter( $payment->total ); |
|
1010 | + switch (true) { |
|
1011 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
1012 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
1013 | + $payment_total = give_currency_filter($payment->total); |
|
1014 | 1014 | break; |
1015 | 1015 | } |
1016 | 1016 | |
@@ -1038,11 +1038,11 @@ discard block |
||
1038 | 1038 | * |
1039 | 1039 | * @return string |
1040 | 1040 | */ |
1041 | -function give_email_tag_sitename( $tag_args = array() ) { |
|
1042 | - $sitename = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
1041 | +function give_email_tag_sitename($tag_args = array()) { |
|
1042 | + $sitename = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
1043 | 1043 | |
1044 | 1044 | // Backward compatibility. |
1045 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1045 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1046 | 1046 | |
1047 | 1047 | /** |
1048 | 1048 | * Filter the {sitename} email template tag output. |
@@ -1068,26 +1068,26 @@ discard block |
||
1068 | 1068 | * |
1069 | 1069 | * @return string receipt_link |
1070 | 1070 | */ |
1071 | -function give_email_tag_receipt_link( $tag_args ) { |
|
1071 | +function give_email_tag_receipt_link($tag_args) { |
|
1072 | 1072 | // Backward compatibility. |
1073 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1073 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1074 | 1074 | |
1075 | - $receipt_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) ); |
|
1075 | + $receipt_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id')); |
|
1076 | 1076 | |
1077 | 1077 | // Bailout. |
1078 | - if ( give_get_option( 'email_template' ) === 'none' ) { |
|
1078 | + if (give_get_option('email_template') === 'none') { |
|
1079 | 1079 | return $receipt_url; |
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | |
1083 | - $receipt_url = esc_url( add_query_arg( array( |
|
1084 | - 'payment_key' => give_get_payment_key( $tag_args['payment_id'] ), |
|
1085 | - ), give_get_history_page_uri() ) ); |
|
1083 | + $receipt_url = esc_url(add_query_arg(array( |
|
1084 | + 'payment_key' => give_get_payment_key($tag_args['payment_id']), |
|
1085 | + ), give_get_history_page_uri())); |
|
1086 | 1086 | |
1087 | - $formatted = sprintf( |
|
1087 | + $formatted = sprintf( |
|
1088 | 1088 | '<a href="%1$s">%2$s</a>', |
1089 | 1089 | $receipt_url, |
1090 | - __( 'View it in your browser »', 'give' ) |
|
1090 | + __('View it in your browser »', 'give') |
|
1091 | 1091 | ); |
1092 | 1092 | |
1093 | 1093 | /** |
@@ -1116,11 +1116,11 @@ discard block |
||
1116 | 1116 | * |
1117 | 1117 | * @return string receipt_url |
1118 | 1118 | */ |
1119 | -function give_email_tag_receipt_link_url( $tag_args ) { |
|
1119 | +function give_email_tag_receipt_link_url($tag_args) { |
|
1120 | 1120 | // Backward compatibility. |
1121 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1121 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1122 | 1122 | |
1123 | - $receipt_link_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) ); |
|
1123 | + $receipt_link_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id')); |
|
1124 | 1124 | |
1125 | 1125 | /** |
1126 | 1126 | * Filter the {receipt_link_url} email template tag output. |
@@ -1147,13 +1147,13 @@ discard block |
||
1147 | 1147 | * |
1148 | 1148 | * @return string |
1149 | 1149 | */ |
1150 | -function give_get_receipt_url( $payment_id ) { |
|
1150 | +function give_get_receipt_url($payment_id) { |
|
1151 | 1151 | $receipt_url = ''; |
1152 | 1152 | |
1153 | - if ( $payment_id ) { |
|
1154 | - $receipt_url = esc_url( add_query_arg( array( |
|
1155 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
1156 | - ), give_get_history_page_uri() ) ); |
|
1153 | + if ($payment_id) { |
|
1154 | + $receipt_url = esc_url(add_query_arg(array( |
|
1155 | + 'payment_key' => give_get_payment_key($payment_id), |
|
1156 | + ), give_get_history_page_uri())); |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | 1159 | return $receipt_url; |
@@ -1169,22 +1169,22 @@ discard block |
||
1169 | 1169 | * |
1170 | 1170 | * @return string |
1171 | 1171 | */ |
1172 | -function give_email_tag_email_access_link( $tag_args ) { |
|
1172 | +function give_email_tag_email_access_link($tag_args) { |
|
1173 | 1173 | $donor_id = 0; |
1174 | 1174 | $donor = array(); |
1175 | 1175 | $email_access_link = ''; |
1176 | 1176 | |
1177 | 1177 | // Backward compatibility. |
1178 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1178 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1179 | 1179 | |
1180 | - switch ( true ) { |
|
1181 | - case ! empty( $tag_args['donor_id'] ): |
|
1180 | + switch (true) { |
|
1181 | + case ! empty($tag_args['donor_id']): |
|
1182 | 1182 | $donor_id = $tag_args['donor_id']; |
1183 | - $donor = Give()->donors->get_by( 'id', $tag_args['donor_id'] ); |
|
1183 | + $donor = Give()->donors->get_by('id', $tag_args['donor_id']); |
|
1184 | 1184 | break; |
1185 | 1185 | |
1186 | - case ! empty( $tag_args['user_id'] ): |
|
1187 | - $donor = Give()->donors->get_by( 'user_id', $tag_args['user_id'] ); |
|
1186 | + case ! empty($tag_args['user_id']): |
|
1187 | + $donor = Give()->donors->get_by('user_id', $tag_args['user_id']); |
|
1188 | 1188 | $donor_id = $donor->id; |
1189 | 1189 | break; |
1190 | 1190 | |
@@ -1193,11 +1193,11 @@ discard block |
||
1193 | 1193 | } |
1194 | 1194 | |
1195 | 1195 | // Set email access link if donor exist. |
1196 | - if ( $donor_id ) { |
|
1197 | - $verify_key = wp_generate_password( 20, false ); |
|
1196 | + if ($donor_id) { |
|
1197 | + $verify_key = wp_generate_password(20, false); |
|
1198 | 1198 | |
1199 | 1199 | // Generate a new verify key |
1200 | - Give()->email_access->set_verify_key( $donor_id, $donor->email, $verify_key ); |
|
1200 | + Give()->email_access->set_verify_key($donor_id, $donor->email, $verify_key); |
|
1201 | 1201 | |
1202 | 1202 | $access_url = add_query_arg( |
1203 | 1203 | array( |
@@ -1207,28 +1207,28 @@ discard block |
||
1207 | 1207 | ); |
1208 | 1208 | |
1209 | 1209 | // Add Payment Key to email access url, if it exists. |
1210 | - if ( ! empty( $_GET['payment_key'] ) ) { |
|
1210 | + if ( ! empty($_GET['payment_key'])) { |
|
1211 | 1211 | $access_url = add_query_arg( |
1212 | 1212 | array( |
1213 | - 'payment_key' => give_clean( $_GET['payment_key'] ), |
|
1213 | + 'payment_key' => give_clean($_GET['payment_key']), |
|
1214 | 1214 | ), |
1215 | 1215 | $access_url |
1216 | 1216 | ); |
1217 | 1217 | } |
1218 | 1218 | |
1219 | - if ( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) { |
|
1219 | + if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) { |
|
1220 | 1220 | $email_access_link = sprintf( |
1221 | 1221 | '<a href="%1$s" target="_blank">%2$s</a>', |
1222 | - esc_url( $access_url ), |
|
1223 | - __( 'View your donation history »', 'give' ) |
|
1222 | + esc_url($access_url), |
|
1223 | + __('View your donation history »', 'give') |
|
1224 | 1224 | ); |
1225 | 1225 | |
1226 | 1226 | } else { |
1227 | 1227 | |
1228 | 1228 | $email_access_link = sprintf( |
1229 | 1229 | '%1$s: %2$s', |
1230 | - __( 'View your donation history', 'give' ), |
|
1231 | - esc_url( $access_url ) |
|
1230 | + __('View your donation history', 'give'), |
|
1231 | + esc_url($access_url) |
|
1232 | 1232 | ); |
1233 | 1233 | } |
1234 | 1234 | } |
@@ -1260,23 +1260,23 @@ discard block |
||
1260 | 1260 | * |
1261 | 1261 | * @return array |
1262 | 1262 | */ |
1263 | -function __give_20_bc_str_type_email_tag_param( $tag_args ) { |
|
1264 | - if ( ! is_array( $tag_args ) ) { |
|
1265 | - switch ( true ) { |
|
1266 | - case ( 'give_payment' === get_post_type( $tag_args ) ): |
|
1267 | - $tag_args = array( 'payment_id' => $tag_args ); |
|
1263 | +function __give_20_bc_str_type_email_tag_param($tag_args) { |
|
1264 | + if ( ! is_array($tag_args)) { |
|
1265 | + switch (true) { |
|
1266 | + case ('give_payment' === get_post_type($tag_args)): |
|
1267 | + $tag_args = array('payment_id' => $tag_args); |
|
1268 | 1268 | break; |
1269 | 1269 | |
1270 | - case ( ! is_wp_error( get_user_by( 'id', $tag_args ) ) ): |
|
1271 | - $tag_args = array( 'user_id' => $tag_args ); |
|
1270 | + case ( ! is_wp_error(get_user_by('id', $tag_args))): |
|
1271 | + $tag_args = array('user_id' => $tag_args); |
|
1272 | 1272 | break; |
1273 | 1273 | |
1274 | - case ( Give()->donors->get_by( 'id', $tag_args ) ): |
|
1275 | - $tag_args = array( 'donor_id' => $tag_args ); |
|
1274 | + case (Give()->donors->get_by('id', $tag_args)): |
|
1275 | + $tag_args = array('donor_id' => $tag_args); |
|
1276 | 1276 | break; |
1277 | 1277 | |
1278 | - case ( Give()->donors->get_by( 'user_id', $tag_args ) ): |
|
1279 | - $tag_args = array( 'user_id' => $tag_args ); |
|
1278 | + case (Give()->donors->get_by('user_id', $tag_args)): |
|
1279 | + $tag_args = array('user_id' => $tag_args); |
|
1280 | 1280 | break; |
1281 | 1281 | } |
1282 | 1282 | } |
@@ -1294,39 +1294,39 @@ discard block |
||
1294 | 1294 | * |
1295 | 1295 | * @return array |
1296 | 1296 | */ |
1297 | -function give_email_tag_reset_password_link( $tag_args, $payment_id ) { |
|
1297 | +function give_email_tag_reset_password_link($tag_args, $payment_id) { |
|
1298 | 1298 | |
1299 | 1299 | $reset_password_url = ''; |
1300 | 1300 | |
1301 | - switch ( true ) { |
|
1302 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
1303 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
1301 | + switch (true) { |
|
1302 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
1303 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
1304 | 1304 | $payment_id = $payment->number; |
1305 | 1305 | break; |
1306 | 1306 | |
1307 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
1308 | - $reset_password_url = give_get_reset_password_url( $tag_args['user_id'] ); |
|
1307 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
1308 | + $reset_password_url = give_get_reset_password_url($tag_args['user_id']); |
|
1309 | 1309 | break; |
1310 | 1310 | |
1311 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
1311 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
1312 | 1312 | /* @var Give_Donor $donor */ |
1313 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
1314 | - $reset_password_url = give_get_reset_password_url( $donor->user_id ); |
|
1313 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
1314 | + $reset_password_url = give_get_reset_password_url($donor->user_id); |
|
1315 | 1315 | break; |
1316 | 1316 | } |
1317 | 1317 | |
1318 | - if( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) { |
|
1318 | + if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) { |
|
1319 | 1319 | // Generate link, if Email content type is html. |
1320 | 1320 | $reset_password_link = sprintf( |
1321 | 1321 | '<a href="%1$s" target="_blank">%2$s</a>', |
1322 | - esc_url( $reset_password_url ), |
|
1323 | - __( 'Reset your password »', 'give' ) |
|
1322 | + esc_url($reset_password_url), |
|
1323 | + __('Reset your password »', 'give') |
|
1324 | 1324 | ); |
1325 | - } else{ |
|
1325 | + } else { |
|
1326 | 1326 | $reset_password_link = sprintf( |
1327 | 1327 | '%1$s: %2$s', |
1328 | - __( 'Reset your password', 'give' ), |
|
1329 | - esc_url( $reset_password_url ) |
|
1328 | + __('Reset your password', 'give'), |
|
1329 | + esc_url($reset_password_url) |
|
1330 | 1330 | ); |
1331 | 1331 | } |
1332 | 1332 | |
@@ -1355,21 +1355,21 @@ discard block |
||
1355 | 1355 | * |
1356 | 1356 | * @return mixed|string |
1357 | 1357 | */ |
1358 | -function give_get_reset_password_url( $user_id ) { |
|
1358 | +function give_get_reset_password_url($user_id) { |
|
1359 | 1359 | $reset_password_url = ''; |
1360 | 1360 | |
1361 | 1361 | // Proceed further only, if user_id exists. |
1362 | - if ( $user_id ) { |
|
1362 | + if ($user_id) { |
|
1363 | 1363 | |
1364 | 1364 | // Get User Object Details. |
1365 | - $user = get_user_by( 'ID', $user_id ); |
|
1365 | + $user = get_user_by('ID', $user_id); |
|
1366 | 1366 | |
1367 | 1367 | // Prepare Reset Password URL. |
1368 | - $reset_password_url = esc_url( add_query_arg( array( |
|
1368 | + $reset_password_url = esc_url(add_query_arg(array( |
|
1369 | 1369 | 'action' => 'rp', |
1370 | - 'key' => get_password_reset_key( $user ), |
|
1370 | + 'key' => get_password_reset_key($user), |
|
1371 | 1371 | 'login' => $user->user_login, |
1372 | - ), wp_login_url() ) ); |
|
1372 | + ), wp_login_url())); |
|
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | return $reset_password_url; |
@@ -1388,91 +1388,91 @@ discard block |
||
1388 | 1388 | * |
1389 | 1389 | * @return mixed |
1390 | 1390 | */ |
1391 | -function __give_render_metadata_email_tag( $content, $tag_args ) { |
|
1392 | - preg_match_all( "/{meta_([A-z0-9\-\_\ ]+)}/s", $content, $matches ); |
|
1391 | +function __give_render_metadata_email_tag($content, $tag_args) { |
|
1392 | + preg_match_all("/{meta_([A-z0-9\-\_\ ]+)}/s", $content, $matches); |
|
1393 | 1393 | |
1394 | - if ( ! empty( $matches[0] ) ) { |
|
1394 | + if ( ! empty($matches[0])) { |
|
1395 | 1395 | $search = $replace = array(); |
1396 | - foreach ( $matches[0] as $index => $meta_tag ) { |
|
1397 | - if ( in_array( $meta_tag, $search ) ) { |
|
1396 | + foreach ($matches[0] as $index => $meta_tag) { |
|
1397 | + if (in_array($meta_tag, $search)) { |
|
1398 | 1398 | continue; |
1399 | 1399 | } |
1400 | 1400 | |
1401 | 1401 | $search[] = $meta_tag; |
1402 | 1402 | |
1403 | - $meta_tag = str_replace( array( '{', 'meta_', '}' ), '', $meta_tag ); |
|
1404 | - $meta_tag_arr = array_map( 'trim', explode( ' ', $meta_tag, 2 ) ); |
|
1405 | - $meta_tag = current( $meta_tag_arr ); |
|
1403 | + $meta_tag = str_replace(array('{', 'meta_', '}'), '', $meta_tag); |
|
1404 | + $meta_tag_arr = array_map('trim', explode(' ', $meta_tag, 2)); |
|
1405 | + $meta_tag = current($meta_tag_arr); |
|
1406 | 1406 | |
1407 | - $meta_tag = str_replace( array( '{', 'meta_', '}' ), '', $meta_tag ); |
|
1408 | - $type = current( explode( '_', $meta_tag, 2 ) ); |
|
1409 | - $meta_name = preg_replace( "/^{$type}_/", '', $meta_tag ); |
|
1407 | + $meta_tag = str_replace(array('{', 'meta_', '}'), '', $meta_tag); |
|
1408 | + $type = current(explode('_', $meta_tag, 2)); |
|
1409 | + $meta_name = preg_replace("/^{$type}_/", '', $meta_tag); |
|
1410 | 1410 | |
1411 | - switch ( $type ) { |
|
1411 | + switch ($type) { |
|
1412 | 1412 | case 'donation': |
1413 | 1413 | |
1414 | 1414 | //Bailout. |
1415 | - if ( ! isset( $tag_args['payment_id'] ) ) { |
|
1415 | + if ( ! isset($tag_args['payment_id'])) { |
|
1416 | 1416 | $replace[] = ''; |
1417 | 1417 | continue; |
1418 | 1418 | } |
1419 | 1419 | |
1420 | - $meta_data = give_get_meta( absint( $tag_args['payment_id'] ), $meta_name, true, '' ); |
|
1420 | + $meta_data = give_get_meta(absint($tag_args['payment_id']), $meta_name, true, ''); |
|
1421 | 1421 | |
1422 | - if ( ! isset( $meta_tag_arr[1] ) || ! is_array( $meta_data ) ) { |
|
1422 | + if ( ! isset($meta_tag_arr[1]) || ! is_array($meta_data)) { |
|
1423 | 1423 | $replace[] = $meta_data; |
1424 | - } elseif ( in_array( $meta_tag_arr[1], array_keys( $meta_data ) ) ) { |
|
1425 | - $replace[] = $meta_data[ $meta_tag_arr[1] ]; |
|
1424 | + } elseif (in_array($meta_tag_arr[1], array_keys($meta_data))) { |
|
1425 | + $replace[] = $meta_data[$meta_tag_arr[1]]; |
|
1426 | 1426 | } |
1427 | 1427 | |
1428 | 1428 | break; |
1429 | 1429 | |
1430 | 1430 | case 'form': |
1431 | - $form_id = isset( $tag_args['form_id'] ) ? absint( $tag_args['form_id'] ) : 0; |
|
1431 | + $form_id = isset($tag_args['form_id']) ? absint($tag_args['form_id']) : 0; |
|
1432 | 1432 | |
1433 | 1433 | // Bailout. |
1434 | - if ( ! $form_id && isset( $tag_args['payment_id'] ) ) { |
|
1435 | - $form_id = give_get_payment_form_id( $tag_args['payment_id'] ); |
|
1434 | + if ( ! $form_id && isset($tag_args['payment_id'])) { |
|
1435 | + $form_id = give_get_payment_form_id($tag_args['payment_id']); |
|
1436 | 1436 | } |
1437 | 1437 | |
1438 | - $meta_data = give_get_meta( $form_id, $meta_name, true, '' ); |
|
1439 | - if ( ! isset( $meta_tag_arr[1] ) || ! is_array( $meta_data ) ) { |
|
1438 | + $meta_data = give_get_meta($form_id, $meta_name, true, ''); |
|
1439 | + if ( ! isset($meta_tag_arr[1]) || ! is_array($meta_data)) { |
|
1440 | 1440 | $replace[] = $meta_data; |
1441 | - } elseif ( in_array( $meta_tag_arr[1], array_keys( $meta_data ) ) ) { |
|
1442 | - $replace[] = $meta_data[ $meta_tag_arr[1] ]; |
|
1441 | + } elseif (in_array($meta_tag_arr[1], array_keys($meta_data))) { |
|
1442 | + $replace[] = $meta_data[$meta_tag_arr[1]]; |
|
1443 | 1443 | } |
1444 | 1444 | break; |
1445 | 1445 | |
1446 | 1446 | case 'donor': |
1447 | - $donor_id = isset( $tag_args['donor_id'] ) ? absint( $tag_args['donor_id'] ) : 0; |
|
1447 | + $donor_id = isset($tag_args['donor_id']) ? absint($tag_args['donor_id']) : 0; |
|
1448 | 1448 | |
1449 | 1449 | // Bailout. |
1450 | - if ( ! $donor_id ) { |
|
1451 | - if ( isset( $tag_args['payment_id'] ) ) { |
|
1452 | - $donor_id = give_get_payment_donor_id( $tag_args['payment_id'] ); |
|
1453 | - } elseif ( isset( $tag_args['user_id'] ) ) { |
|
1454 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
1450 | + if ( ! $donor_id) { |
|
1451 | + if (isset($tag_args['payment_id'])) { |
|
1452 | + $donor_id = give_get_payment_donor_id($tag_args['payment_id']); |
|
1453 | + } elseif (isset($tag_args['user_id'])) { |
|
1454 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
1455 | 1455 | $donor_id = $donor->ID; |
1456 | 1456 | } |
1457 | 1457 | } |
1458 | 1458 | |
1459 | - $donor = new Give_Donor( $donor_id ); |
|
1460 | - $meta_data = $donor->get_meta( $meta_name ); |
|
1461 | - if ( ! isset( $meta_tag_arr[1] ) || ! is_array( $meta_data ) ) { |
|
1459 | + $donor = new Give_Donor($donor_id); |
|
1460 | + $meta_data = $donor->get_meta($meta_name); |
|
1461 | + if ( ! isset($meta_tag_arr[1]) || ! is_array($meta_data)) { |
|
1462 | 1462 | $replace[] = $meta_data; |
1463 | - } elseif ( in_array( $meta_tag_arr[1], array_keys( $meta_data ) ) ) { |
|
1464 | - $replace[] = $meta_data[ $meta_tag_arr[1] ]; |
|
1463 | + } elseif (in_array($meta_tag_arr[1], array_keys($meta_data))) { |
|
1464 | + $replace[] = $meta_data[$meta_tag_arr[1]]; |
|
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | break; |
1468 | 1468 | |
1469 | 1469 | default: |
1470 | - $replace[] = end( $search ); |
|
1470 | + $replace[] = end($search); |
|
1471 | 1471 | } |
1472 | 1472 | } |
1473 | 1473 | |
1474 | - if ( ! empty( $search ) && ! empty( $replace ) ) { |
|
1475 | - $content = str_replace( $search, $replace, $content ); |
|
1474 | + if ( ! empty($search) && ! empty($replace)) { |
|
1475 | + $content = str_replace($search, $replace, $content); |
|
1476 | 1476 | } |
1477 | 1477 | } |
1478 | 1478 | |
@@ -1480,4 +1480,4 @@ discard block |
||
1480 | 1480 | return $content; |
1481 | 1481 | } |
1482 | 1482 | |
1483 | -add_filter( 'give_email_template_tags', '__give_render_metadata_email_tag', 10, 2 ); |
|
1483 | +add_filter('give_email_template_tags', '__give_render_metadata_email_tag', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,16 +26,16 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_email_donation_receipt( $payment_id, $admin_notice = true ) { |
|
30 | - $payment = new Give_Payment( $payment_id ); |
|
29 | +function give_email_donation_receipt($payment_id, $admin_notice = true) { |
|
30 | + $payment = new Give_Payment($payment_id); |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Fire the action |
34 | 34 | */ |
35 | - do_action( 'give_donation-receipt_email_notification', $payment_id ); |
|
35 | + do_action('give_donation-receipt_email_notification', $payment_id); |
|
36 | 36 | |
37 | 37 | // If admin notifications are on, send the admin notice. |
38 | - if ( $admin_notice && give_is_setting_enabled( Give_Email_Notification::get_instance('new-donation' )->get_notification_status() ) ) { |
|
38 | + if ($admin_notice && give_is_setting_enabled(Give_Email_Notification::get_instance('new-donation')->get_notification_status())) { |
|
39 | 39 | /** |
40 | 40 | * Fires in the donation email receipt. |
41 | 41 | * |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param int $payment_id Payment id. |
47 | 47 | * @param mixed $payment_data Payment meta data. |
48 | 48 | */ |
49 | - do_action( 'give_new-donation_email_notification', $payment_id, $payment->payment_meta ); |
|
49 | + do_action('give_new-donation_email_notification', $payment_id, $payment->payment_meta); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return void |
61 | 61 | */ |
62 | -function give_admin_email_notice( $payment_id ) { |
|
62 | +function give_admin_email_notice($payment_id) { |
|
63 | 63 | /** |
64 | 64 | * Fires in the donation email receipt. |
65 | 65 | * |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | * @param int $payment_id Payment id. |
71 | 71 | * @param mixed $payment_data Payment meta data. |
72 | 72 | */ |
73 | - do_action( 'give_new-donation_email_notification', $payment_id ); |
|
73 | + do_action('give_new-donation_email_notification', $payment_id); |
|
74 | 74 | } |
75 | 75 | |
76 | -add_action( 'give_admin_donation_email', 'give_admin_email_notice' ); |
|
76 | +add_action('give_admin_donation_email', 'give_admin_email_notice'); |
|
77 | 77 | |
78 | 78 | |
79 | 79 | /** |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | */ |
87 | 87 | function give_get_default_donation_notification_email() { |
88 | 88 | |
89 | - $default_email_body = __( 'Hi there,', 'give' ) . "\n\n"; |
|
90 | - $default_email_body .= __( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n"; |
|
91 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n"; |
|
92 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
93 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
94 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n"; |
|
95 | - $default_email_body .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
96 | - $default_email_body .= '{sitename}' . "\n"; |
|
89 | + $default_email_body = __('Hi there,', 'give')."\n\n"; |
|
90 | + $default_email_body .= __('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n"; |
|
91 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {name}'."\n"; |
|
92 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
93 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
94 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n"; |
|
95 | + $default_email_body .= __('Thank you,', 'give')."\n\n"; |
|
96 | + $default_email_body .= '{sitename}'."\n"; |
|
97 | 97 | |
98 | - return apply_filters( 'give_default_donation_notification_email', $default_email_body ); |
|
98 | + return apply_filters('give_default_donation_notification_email', $default_email_body); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -109,21 +109,21 @@ discard block |
||
109 | 109 | */ |
110 | 110 | function give_get_default_donation_receipt_email() { |
111 | 111 | |
112 | - $default_email_body = __( 'Dear', 'give' ) . " {name},\n\n"; |
|
113 | - $default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n"; |
|
114 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
115 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
116 | - $default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n"; |
|
117 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
118 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n"; |
|
119 | - $default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n"; |
|
120 | - $default_email_body .= '<strong>' . __( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n"; |
|
121 | - $default_email_body .= '{receipt_link}' . "\n\n"; |
|
112 | + $default_email_body = __('Dear', 'give')." {name},\n\n"; |
|
113 | + $default_email_body .= __('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n"; |
|
114 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
115 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
116 | + $default_email_body .= '<strong>'.__('Donation Date:', 'give').'</strong> {date}'."\n"; |
|
117 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
118 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n"; |
|
119 | + $default_email_body .= '<strong>'.__('Payment ID:', 'give').'</strong> {payment_id}'."\n"; |
|
120 | + $default_email_body .= '<strong>'.__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n"; |
|
121 | + $default_email_body .= '{receipt_link}'."\n\n"; |
|
122 | 122 | $default_email_body .= "\n\n"; |
123 | - $default_email_body .= __( 'Sincerely,', 'give' ) . "\n"; |
|
124 | - $default_email_body .= '{sitename}' . "\n"; |
|
123 | + $default_email_body .= __('Sincerely,', 'give')."\n"; |
|
124 | + $default_email_body .= '{sitename}'."\n"; |
|
125 | 125 | |
126 | - return apply_filters( 'give_default_donation_receipt_email', $default_email_body ); |
|
126 | + return apply_filters('give_default_donation_receipt_email', $default_email_body); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -136,22 +136,22 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return array $email_names |
138 | 138 | */ |
139 | -function give_get_email_names( $user_info, $payment = false ) { |
|
139 | +function give_get_email_names($user_info, $payment = false) { |
|
140 | 140 | $email_names = array(); |
141 | 141 | |
142 | - if ( is_a( $payment, 'Give_Payment' ) ) { |
|
142 | + if (is_a($payment, 'Give_Payment')) { |
|
143 | 143 | |
144 | - if ( $payment->user_id > 0 ) { |
|
144 | + if ($payment->user_id > 0) { |
|
145 | 145 | |
146 | - $user_data = get_userdata( $payment->user_id ); |
|
146 | + $user_data = get_userdata($payment->user_id); |
|
147 | 147 | $email_names['name'] = $payment->first_name; |
148 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
148 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
149 | 149 | $email_names['username'] = $user_data->user_login; |
150 | 150 | |
151 | - } elseif ( ! empty( $payment->first_name ) ) { |
|
151 | + } elseif ( ! empty($payment->first_name)) { |
|
152 | 152 | |
153 | 153 | $email_names['name'] = $payment->first_name; |
154 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
154 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
155 | 155 | $email_names['username'] = $payment->first_name; |
156 | 156 | |
157 | 157 | } else { |
@@ -164,30 +164,30 @@ discard block |
||
164 | 164 | } else { |
165 | 165 | |
166 | 166 | // Support for old serialized data. |
167 | - if ( is_serialized( $user_info ) ) { |
|
167 | + if (is_serialized($user_info)) { |
|
168 | 168 | |
169 | 169 | // Security check. |
170 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches ); |
|
171 | - if ( ! empty( $matches ) ) { |
|
170 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches); |
|
171 | + if ( ! empty($matches)) { |
|
172 | 172 | return array( |
173 | 173 | 'name' => '', |
174 | 174 | 'fullname' => '', |
175 | 175 | 'username' => '', |
176 | 176 | ); |
177 | 177 | } else { |
178 | - $user_info = maybe_unserialize( $user_info ); |
|
178 | + $user_info = maybe_unserialize($user_info); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | } |
182 | 182 | |
183 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) { |
|
184 | - $user_data = get_userdata( $user_info['id'] ); |
|
183 | + if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) { |
|
184 | + $user_data = get_userdata($user_info['id']); |
|
185 | 185 | $email_names['name'] = $user_info['first_name']; |
186 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
186 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
187 | 187 | $email_names['username'] = $user_data->user_login; |
188 | - } elseif ( isset( $user_info['first_name'] ) ) { |
|
188 | + } elseif (isset($user_info['first_name'])) { |
|
189 | 189 | $email_names['name'] = $user_info['first_name']; |
190 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
190 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
191 | 191 | $email_names['username'] = $user_info['first_name']; |
192 | 192 | } else { |
193 | 193 | $email_names['name'] = $user_info['email']; |
@@ -207,37 +207,37 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @since 1.8.14 |
209 | 209 | */ |
210 | -function give_admin_email_user_donor_disconnection( $user_id, $donor_id ) { |
|
210 | +function give_admin_email_user_donor_disconnection($user_id, $donor_id) { |
|
211 | 211 | |
212 | - $user_id = absint( $user_id ); |
|
213 | - $donor_id = absint( $donor_id ); |
|
212 | + $user_id = absint($user_id); |
|
213 | + $donor_id = absint($donor_id); |
|
214 | 214 | |
215 | 215 | // Bail Out, if user id doesn't exists. |
216 | - if ( empty( $user_id ) ) { |
|
216 | + if (empty($user_id)) { |
|
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Bail Out, if donor id doesn't exists. |
221 | - if ( empty( $donor_id ) ) { |
|
221 | + if (empty($donor_id)) { |
|
222 | 222 | return; |
223 | 223 | } |
224 | 224 | |
225 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
225 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
226 | 226 | |
227 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
227 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
228 | 228 | |
229 | 229 | /* translators: %s: payment id */ |
230 | - $subject = __( 'Attention: User tries to login whose Donor profile is disconnected!', 'give' ); |
|
230 | + $subject = __('Attention: User tries to login whose Donor profile is disconnected!', 'give'); |
|
231 | 231 | |
232 | 232 | /** |
233 | 233 | * Filters the Donor-User Disconnection notification subject. |
234 | 234 | * |
235 | 235 | * @since 1.8.14 |
236 | 236 | */ |
237 | - $subject = apply_filters( 'give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags( $subject ) ); |
|
237 | + $subject = apply_filters('give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags($subject)); |
|
238 | 238 | |
239 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
240 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
239 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
240 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
241 | 241 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
242 | 242 | |
243 | 243 | /** |
@@ -245,25 +245,25 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @since 1.8.14 |
247 | 247 | */ |
248 | - $headers = apply_filters( 'give_admin_donor_user_disconnection_notification_headers', $headers ); |
|
248 | + $headers = apply_filters('give_admin_donor_user_disconnection_notification_headers', $headers); |
|
249 | 249 | |
250 | - $message = __( 'Hi Admin,', 'give' ) . "\n\n"; |
|
251 | - $message .= __( 'This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give' ) . "\n\n"; |
|
252 | - $message .= __( 'Do you want to reconnect User and Donor profile again?', 'give' ) . "\n\n"; |
|
250 | + $message = __('Hi Admin,', 'give')."\n\n"; |
|
251 | + $message .= __('This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give')."\n\n"; |
|
252 | + $message .= __('Do you want to reconnect User and Donor profile again?', 'give')."\n\n"; |
|
253 | 253 | $message .= sprintf( |
254 | 254 | '<a href="%1$s">%2$s</a>', |
255 | - esc_url( admin_url() . 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&user_id=' . $user_id . '&give-message=reconnect-user' ), |
|
256 | - __( 'Reconnect User', 'give' ) . "\n\n" |
|
255 | + esc_url(admin_url().'edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&user_id='.$user_id.'&give-message=reconnect-user'), |
|
256 | + __('Reconnect User', 'give')."\n\n" |
|
257 | 257 | ); |
258 | - $message .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
259 | - $message .= '{sitename}' . "\n"; |
|
258 | + $message .= __('Thank you,', 'give')."\n\n"; |
|
259 | + $message .= '{sitename}'."\n"; |
|
260 | 260 | |
261 | 261 | $emails = Give()->emails; |
262 | - $emails->__set( 'from_name', $from_name ); |
|
263 | - $emails->__set( 'from_email', $from_email ); |
|
264 | - $emails->__set( 'headers', $headers ); |
|
265 | - $emails->__set( 'heading', __( 'User - Donor Profile Disconnection', 'give' ) ); |
|
262 | + $emails->__set('from_name', $from_name); |
|
263 | + $emails->__set('from_email', $from_email); |
|
264 | + $emails->__set('headers', $headers); |
|
265 | + $emails->__set('heading', __('User - Donor Profile Disconnection', 'give')); |
|
266 | 266 | |
267 | - $emails->send( give_get_admin_notice_emails(), $subject, give_do_email_tags( $message ) ); |
|
267 | + $emails->send(give_get_admin_notice_emails(), $subject, give_do_email_tags($message)); |
|
268 | 268 | |
269 | 269 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly. |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -25,70 +25,70 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
49 | + case version_compare($give_version, '1.8.7', '<') : |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare($give_version, '1.8.8', '<') : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | - case version_compare( $give_version, '1.8.9', '<' ) : |
|
57 | + case version_compare($give_version, '1.8.9', '<') : |
|
58 | 58 | give_v189_upgrades(); |
59 | 59 | $did_upgrade = true; |
60 | 60 | |
61 | - case version_compare( $give_version, '1.8.12', '<' ) : |
|
61 | + case version_compare($give_version, '1.8.12', '<') : |
|
62 | 62 | give_v1812_upgrades(); |
63 | 63 | $did_upgrade = true; |
64 | 64 | |
65 | - case version_compare( $give_version, '1.8.13', '<' ) : |
|
65 | + case version_compare($give_version, '1.8.13', '<') : |
|
66 | 66 | give_v1813_upgrades(); |
67 | 67 | $did_upgrade = true; |
68 | 68 | |
69 | - case version_compare( $give_version, '1.8.17', '<' ) : |
|
69 | + case version_compare($give_version, '1.8.17', '<') : |
|
70 | 70 | give_v1817_upgrades(); |
71 | 71 | $did_upgrade = true; |
72 | 72 | |
73 | - case version_compare( $give_version, '1.8.18', '<' ) : |
|
73 | + case version_compare($give_version, '1.8.18', '<') : |
|
74 | 74 | give_v1818_upgrades(); |
75 | 75 | $did_upgrade = true; |
76 | 76 | |
77 | - case version_compare( $give_version, '2.0', '<' ) : |
|
77 | + case version_compare($give_version, '2.0', '<') : |
|
78 | 78 | give_v20_upgrades(); |
79 | 79 | $did_upgrade = true; |
80 | 80 | |
81 | - case version_compare( $give_version, '2.0.1', '<' ) : |
|
81 | + case version_compare($give_version, '2.0.1', '<') : |
|
82 | 82 | // Do nothing on fresh install. |
83 | - if( ! doing_action( 'give_upgrades' ) ) { |
|
83 | + if ( ! doing_action('give_upgrades')) { |
|
84 | 84 | give_v201_create_tables(); |
85 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
85 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
86 | 86 | Give_Updates::$background_updater->dispatch(); |
87 | 87 | } |
88 | 88 | |
89 | 89 | $did_upgrade = true; |
90 | 90 | |
91 | - case version_compare( $give_version, '2.0.2', '<' ) : |
|
91 | + case version_compare($give_version, '2.0.2', '<') : |
|
92 | 92 | // Remove 2.0.1 update to rerun on 2.0.2 |
93 | 93 | $completed_upgrades = give_get_completed_upgrades(); |
94 | 94 | $v201_updates = array( |
@@ -98,35 +98,35 @@ discard block |
||
98 | 98 | 'v201_logs_upgrades' |
99 | 99 | ); |
100 | 100 | |
101 | - foreach ( $v201_updates as $v201_update ) { |
|
102 | - if( in_array( $v201_update, $completed_upgrades ) ) { |
|
103 | - unset( $completed_upgrades[ array_search( $v201_update, $completed_upgrades )] ); |
|
101 | + foreach ($v201_updates as $v201_update) { |
|
102 | + if (in_array($v201_update, $completed_upgrades)) { |
|
103 | + unset($completed_upgrades[array_search($v201_update, $completed_upgrades)]); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
107 | + update_option('give_completed_upgrades', $completed_upgrades); |
|
108 | 108 | |
109 | 109 | // Do nothing on fresh install. |
110 | - if( ! doing_action( 'give_upgrades' ) ) { |
|
110 | + if ( ! doing_action('give_upgrades')) { |
|
111 | 111 | give_v201_create_tables(); |
112 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
112 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
113 | 113 | Give_Updates::$background_updater->dispatch(); |
114 | 114 | } |
115 | 115 | |
116 | 116 | $did_upgrade = true; |
117 | 117 | |
118 | - case version_compare( $give_version, '2.0.3', '<' ) : |
|
118 | + case version_compare($give_version, '2.0.3', '<') : |
|
119 | 119 | give_v203_upgrades(); |
120 | 120 | $did_upgrade = true; |
121 | 121 | } |
122 | 122 | |
123 | - if ( $did_upgrade ) { |
|
124 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
123 | + if ($did_upgrade) { |
|
124 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
129 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
128 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
129 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * Display Upgrade Notices. |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return void |
142 | 142 | */ |
143 | -function give_show_upgrade_notices( $give_updates ) { |
|
143 | +function give_show_upgrade_notices($give_updates) { |
|
144 | 144 | // v1.3.2 Upgrades |
145 | 145 | $give_updates->register( |
146 | 146 | array( |
@@ -206,32 +206,32 @@ discard block |
||
206 | 206 | ); |
207 | 207 | |
208 | 208 | // v1.8.17 Upgrades for donations. |
209 | - $give_updates->register( array( |
|
209 | + $give_updates->register(array( |
|
210 | 210 | 'id' => 'v1817_update_donation_iranian_currency_code', |
211 | 211 | 'version' => '1.8.17', |
212 | 212 | 'callback' => 'give_v1817_update_donation_iranian_currency_code', |
213 | - ) ); |
|
213 | + )); |
|
214 | 214 | |
215 | 215 | // v1.8.17 Upgrades for cleanup of user roles. |
216 | - $give_updates->register( array( |
|
216 | + $give_updates->register(array( |
|
217 | 217 | 'id' => 'v1817_cleanup_user_roles', |
218 | 218 | 'version' => '1.8.17', |
219 | 219 | 'callback' => 'give_v1817_cleanup_user_roles', |
220 | - ) ); |
|
220 | + )); |
|
221 | 221 | |
222 | 222 | // v1.8.18 Upgrades for assigning custom amount to existing set donations. |
223 | - $give_updates->register( array( |
|
223 | + $give_updates->register(array( |
|
224 | 224 | 'id' => 'v1818_assign_custom_amount_set_donation', |
225 | 225 | 'version' => '1.8.18', |
226 | 226 | 'callback' => 'give_v1818_assign_custom_amount_set_donation', |
227 | - ) ); |
|
227 | + )); |
|
228 | 228 | |
229 | 229 | // v1.8.18 Cleanup the Give Worker Role Caps. |
230 | - $give_updates->register( array( |
|
230 | + $give_updates->register(array( |
|
231 | 231 | 'id' => 'v1818_give_worker_role_cleanup', |
232 | 232 | 'version' => '1.8.18', |
233 | 233 | 'callback' => 'give_v1818_give_worker_role_cleanup', |
234 | - ) ); |
|
234 | + )); |
|
235 | 235 | |
236 | 236 | // v2.0.0 Upgrades |
237 | 237 | $give_updates->register( |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | 'id' => 'v20_move_metadata_into_new_table', |
286 | 286 | 'version' => '2.0.0', |
287 | 287 | 'callback' => 'give_v20_move_metadata_into_new_table_callback', |
288 | - 'depend' => array( 'v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata' ), |
|
288 | + 'depend' => array('v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata'), |
|
289 | 289 | ) |
290 | 290 | ); |
291 | 291 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | 'id' => 'v201_move_metadata_into_new_table', |
332 | 332 | 'version' => '2.0.1', |
333 | 333 | 'callback' => 'give_v201_move_metadata_into_new_table_callback', |
334 | - 'depend' => array( 'v201_upgrades_payment_metadata', 'v201_add_missing_donors' ), |
|
334 | + 'depend' => array('v201_upgrades_payment_metadata', 'v201_add_missing_donors'), |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | ); |
347 | 347 | } |
348 | 348 | |
349 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
349 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Triggers all upgrade functions |
@@ -358,29 +358,29 @@ discard block |
||
358 | 358 | */ |
359 | 359 | function give_trigger_upgrades() { |
360 | 360 | |
361 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
362 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
361 | + if ( ! current_user_can('manage_give_settings')) { |
|
362 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
363 | 363 | 'response' => 403, |
364 | - ) ); |
|
364 | + )); |
|
365 | 365 | } |
366 | 366 | |
367 | - $give_version = get_option( 'give_version' ); |
|
367 | + $give_version = get_option('give_version'); |
|
368 | 368 | |
369 | - if ( ! $give_version ) { |
|
369 | + if ( ! $give_version) { |
|
370 | 370 | // 1.0 is the first version to use this option so we must add it. |
371 | 371 | $give_version = '1.0'; |
372 | - add_option( 'give_version', $give_version ); |
|
372 | + add_option('give_version', $give_version); |
|
373 | 373 | } |
374 | 374 | |
375 | - update_option( 'give_version', GIVE_VERSION ); |
|
376 | - delete_option( 'give_doing_upgrade' ); |
|
375 | + update_option('give_version', GIVE_VERSION); |
|
376 | + delete_option('give_doing_upgrade'); |
|
377 | 377 | |
378 | - if ( DOING_AJAX ) { |
|
379 | - die( 'complete' ); |
|
378 | + if (DOING_AJAX) { |
|
379 | + die('complete'); |
|
380 | 380 | } // End if(). |
381 | 381 | } |
382 | 382 | |
383 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
383 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
384 | 384 | |
385 | 385 | |
386 | 386 | /** |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | |
399 | 399 | // UPDATE DB METAKEYS. |
400 | 400 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
401 | - $query = $wpdb->query( $sql ); |
|
401 | + $query = $wpdb->query($sql); |
|
402 | 402 | |
403 | 403 | $give_updates->percentage = 100; |
404 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
404 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -425,24 +425,24 @@ discard block |
||
425 | 425 | $where .= "AND ( p.post_status = 'abandoned' )"; |
426 | 426 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
427 | 427 | |
428 | - $sql = $select . $join . $where; |
|
429 | - $found_payments = $wpdb->get_col( $sql ); |
|
428 | + $sql = $select.$join.$where; |
|
429 | + $found_payments = $wpdb->get_col($sql); |
|
430 | 430 | |
431 | - foreach ( $found_payments as $payment ) { |
|
431 | + foreach ($found_payments as $payment) { |
|
432 | 432 | |
433 | 433 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
434 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
434 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
435 | 435 | |
436 | 436 | // 1450124863 = 12/10/2015 20:42:25. |
437 | - if ( $modified_time >= 1450124863 ) { |
|
437 | + if ($modified_time >= 1450124863) { |
|
438 | 438 | |
439 | - give_update_payment_status( $payment, 'pending' ); |
|
439 | + give_update_payment_status($payment, 'pending'); |
|
440 | 440 | |
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | 444 | $give_updates->percentage = 100; |
445 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
445 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
@@ -455,17 +455,17 @@ discard block |
||
455 | 455 | */ |
456 | 456 | function give_v152_cleanup_users() { |
457 | 457 | |
458 | - $give_version = get_option( 'give_version' ); |
|
458 | + $give_version = get_option('give_version'); |
|
459 | 459 | |
460 | - if ( ! $give_version ) { |
|
460 | + if ( ! $give_version) { |
|
461 | 461 | // 1.0 is the first version to use this option so we must add it. |
462 | 462 | $give_version = '1.0'; |
463 | 463 | } |
464 | 464 | |
465 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
465 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
466 | 466 | |
467 | 467 | // v1.5.2 Upgrades |
468 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
468 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
469 | 469 | |
470 | 470 | // Delete all caps with "ss". |
471 | 471 | // Also delete all unused "campaign" roles. |
@@ -512,9 +512,9 @@ discard block |
||
512 | 512 | ); |
513 | 513 | |
514 | 514 | global $wp_roles; |
515 | - foreach ( $delete_caps as $cap ) { |
|
516 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
517 | - $wp_roles->remove_cap( $role, $cap ); |
|
515 | + foreach ($delete_caps as $cap) { |
|
516 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
517 | + $wp_roles->remove_cap($role, $cap); |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
@@ -524,15 +524,15 @@ discard block |
||
524 | 524 | $roles->add_caps(); |
525 | 525 | |
526 | 526 | // The Update Ran. |
527 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
528 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
529 | - delete_option( 'give_doing_upgrade' ); |
|
527 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
528 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
529 | + delete_option('give_doing_upgrade'); |
|
530 | 530 | |
531 | 531 | }// End if(). |
532 | 532 | |
533 | 533 | } |
534 | 534 | |
535 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
535 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
536 | 536 | |
537 | 537 | /** |
538 | 538 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -575,53 +575,53 @@ discard block |
||
575 | 575 | |
576 | 576 | // Get addons license key. |
577 | 577 | $addons = array(); |
578 | - foreach ( $give_options as $key => $value ) { |
|
579 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
580 | - $addons[ $key ] = $value; |
|
578 | + foreach ($give_options as $key => $value) { |
|
579 | + if (false !== strpos($key, '_license_key')) { |
|
580 | + $addons[$key] = $value; |
|
581 | 581 | } |
582 | 582 | } |
583 | 583 | |
584 | 584 | // Bailout: We do not have any addon license data to upgrade. |
585 | - if ( empty( $addons ) ) { |
|
585 | + if (empty($addons)) { |
|
586 | 586 | return false; |
587 | 587 | } |
588 | 588 | |
589 | - foreach ( $addons as $key => $addon_license ) { |
|
589 | + foreach ($addons as $key => $addon_license) { |
|
590 | 590 | |
591 | 591 | // Get addon shortname. |
592 | - $shortname = str_replace( '_license_key', '', $key ); |
|
592 | + $shortname = str_replace('_license_key', '', $key); |
|
593 | 593 | |
594 | 594 | // Addon license option name. |
595 | - $addon_license_option_name = $shortname . '_license_active'; |
|
595 | + $addon_license_option_name = $shortname.'_license_active'; |
|
596 | 596 | |
597 | 597 | // bailout if license is empty. |
598 | - if ( empty( $addon_license ) ) { |
|
599 | - delete_option( $addon_license_option_name ); |
|
598 | + if (empty($addon_license)) { |
|
599 | + delete_option($addon_license_option_name); |
|
600 | 600 | continue; |
601 | 601 | } |
602 | 602 | |
603 | 603 | // Get addon name. |
604 | 604 | $addon_name = array(); |
605 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
606 | - foreach ( $addon_name_parts as $name_part ) { |
|
605 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
606 | + foreach ($addon_name_parts as $name_part) { |
|
607 | 607 | |
608 | 608 | // Fix addon name |
609 | - switch ( $name_part ) { |
|
609 | + switch ($name_part) { |
|
610 | 610 | case 'authorizenet' : |
611 | 611 | $name_part = 'authorize.net'; |
612 | 612 | break; |
613 | 613 | } |
614 | 614 | |
615 | - $addon_name[] = ucfirst( $name_part ); |
|
615 | + $addon_name[] = ucfirst($name_part); |
|
616 | 616 | } |
617 | 617 | |
618 | - $addon_name = implode( ' ', $addon_name ); |
|
618 | + $addon_name = implode(' ', $addon_name); |
|
619 | 619 | |
620 | 620 | // Data to send to the API. |
621 | 621 | $api_params = array( |
622 | 622 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
623 | 623 | 'license' => $addon_license, |
624 | - 'item_name' => urlencode( $addon_name ), |
|
624 | + 'item_name' => urlencode($addon_name), |
|
625 | 625 | 'url' => home_url(), |
626 | 626 | ); |
627 | 627 | |
@@ -636,17 +636,17 @@ discard block |
||
636 | 636 | ); |
637 | 637 | |
638 | 638 | // Make sure there are no errors. |
639 | - if ( is_wp_error( $response ) ) { |
|
640 | - delete_option( $addon_license_option_name ); |
|
639 | + if (is_wp_error($response)) { |
|
640 | + delete_option($addon_license_option_name); |
|
641 | 641 | continue; |
642 | 642 | } |
643 | 643 | |
644 | 644 | // Tell WordPress to look for updates. |
645 | - set_site_transient( 'update_plugins', null ); |
|
645 | + set_site_transient('update_plugins', null); |
|
646 | 646 | |
647 | 647 | // Decode license data. |
648 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
649 | - update_option( $addon_license_option_name, $license_data ); |
|
648 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
649 | + update_option($addon_license_option_name, $license_data); |
|
650 | 650 | }// End foreach(). |
651 | 651 | } |
652 | 652 | |
@@ -676,9 +676,9 @@ discard block |
||
676 | 676 | ); |
677 | 677 | |
678 | 678 | global $wp_roles; |
679 | - foreach ( $delete_caps as $cap ) { |
|
680 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
681 | - $wp_roles->remove_cap( $role, $cap ); |
|
679 | + foreach ($delete_caps as $cap) { |
|
680 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
681 | + $wp_roles->remove_cap($role, $cap); |
|
682 | 682 | } |
683 | 683 | } |
684 | 684 | |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | function give_v18_upgrades_core_setting() { |
713 | 713 | // Core settings which changes from checkbox to radio. |
714 | 714 | $core_setting_names = array_merge( |
715 | - array_keys( give_v18_renamed_core_settings() ), |
|
715 | + array_keys(give_v18_renamed_core_settings()), |
|
716 | 716 | array( |
717 | 717 | 'uninstall_on_delete', |
718 | 718 | 'scripts_footer', |
@@ -724,48 +724,48 @@ discard block |
||
724 | 724 | ); |
725 | 725 | |
726 | 726 | // Bailout: If not any setting define. |
727 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
727 | + if ($give_settings = get_option('give_settings')) { |
|
728 | 728 | |
729 | 729 | $setting_changed = false; |
730 | 730 | |
731 | 731 | // Loop: check each setting field. |
732 | - foreach ( $core_setting_names as $setting_name ) { |
|
732 | + foreach ($core_setting_names as $setting_name) { |
|
733 | 733 | // New setting name. |
734 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
734 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
735 | 735 | |
736 | 736 | // Continue: If setting already set. |
737 | 737 | if ( |
738 | - array_key_exists( $new_setting_name, $give_settings ) |
|
739 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
738 | + array_key_exists($new_setting_name, $give_settings) |
|
739 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
740 | 740 | ) { |
741 | 741 | continue; |
742 | 742 | } |
743 | 743 | |
744 | 744 | // Set checkbox value to radio value. |
745 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
745 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
746 | 746 | |
747 | 747 | // @see https://github.com/WordImpress/Give/issues/1063. |
748 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
748 | + if (false !== strpos($setting_name, 'disable_')) { |
|
749 | 749 | |
750 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
751 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
750 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
751 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
752 | 752 | |
753 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
753 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | // Tell bot to update core setting to db. |
757 | - if ( ! $setting_changed ) { |
|
757 | + if ( ! $setting_changed) { |
|
758 | 758 | $setting_changed = true; |
759 | 759 | } |
760 | 760 | } |
761 | 761 | |
762 | 762 | // Update setting only if they changed. |
763 | - if ( $setting_changed ) { |
|
764 | - update_option( 'give_settings', $give_settings ); |
|
763 | + if ($setting_changed) { |
|
764 | + update_option('give_settings', $give_settings); |
|
765 | 765 | } |
766 | 766 | }// End if(). |
767 | 767 | |
768 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
768 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | /** |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | $give_updates = Give_Updates::get_instance(); |
780 | 780 | |
781 | 781 | // form query |
782 | - $forms = new WP_Query( array( |
|
782 | + $forms = new WP_Query(array( |
|
783 | 783 | 'paged' => $give_updates->step, |
784 | 784 | 'status' => 'any', |
785 | 785 | 'order' => 'ASC', |
@@ -788,41 +788,41 @@ discard block |
||
788 | 788 | ) |
789 | 789 | ); |
790 | 790 | |
791 | - if ( $forms->have_posts() ) { |
|
792 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
791 | + if ($forms->have_posts()) { |
|
792 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
793 | 793 | |
794 | - while ( $forms->have_posts() ) { |
|
794 | + while ($forms->have_posts()) { |
|
795 | 795 | $forms->the_post(); |
796 | 796 | |
797 | 797 | // Form content. |
798 | 798 | // Note in version 1.8 display content setting split into display content and content placement setting. |
799 | 799 | // You can delete _give_content_option in future. |
800 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
801 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
802 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
803 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
800 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
801 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
802 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
803 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
804 | 804 | |
805 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
806 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
805 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
806 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | // "Disable" Guest Donation. Checkbox. |
810 | 810 | // See: https://github.com/WordImpress/Give/issues/1470. |
811 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
812 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
813 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
811 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
812 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
813 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
814 | 814 | |
815 | 815 | // Offline Donations. |
816 | 816 | // See: https://github.com/WordImpress/Give/issues/1579. |
817 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
818 | - if ( 'no' === $offline_donation ) { |
|
817 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
818 | + if ('no' === $offline_donation) { |
|
819 | 819 | $offline_donation_newval = 'global'; |
820 | - } elseif ( 'yes' === $offline_donation ) { |
|
820 | + } elseif ('yes' === $offline_donation) { |
|
821 | 821 | $offline_donation_newval = 'enabled'; |
822 | 822 | } else { |
823 | 823 | $offline_donation_newval = 'disabled'; |
824 | 824 | } |
825 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
825 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
826 | 826 | |
827 | 827 | // Convert yes/no setting field to enabled/disabled. |
828 | 828 | $form_radio_settings = array( |
@@ -842,15 +842,15 @@ discard block |
||
842 | 842 | '_give_offline_donation_enable_billing_fields_single', |
843 | 843 | ); |
844 | 844 | |
845 | - foreach ( $form_radio_settings as $meta_key ) { |
|
845 | + foreach ($form_radio_settings as $meta_key) { |
|
846 | 846 | // Get value. |
847 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
847 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
848 | 848 | |
849 | 849 | // Convert meta value only if it is in yes/no/none. |
850 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
850 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
851 | 851 | |
852 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
853 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
852 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
853 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
854 | 854 | } |
855 | 855 | } |
856 | 856 | }// End while(). |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | |
860 | 860 | } else { |
861 | 861 | // No more forms found, finish up. |
862 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
862 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
863 | 863 | } |
864 | 864 | } |
865 | 865 | |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | '%_transient_give_stats_%', |
927 | 927 | 'give_cache%', |
928 | 928 | '%_transient_give_add_ons_feed%', |
929 | - '%_transient__give_ajax_works' . |
|
929 | + '%_transient__give_ajax_works'. |
|
930 | 930 | '%_transient_give_total_api_keys%', |
931 | 931 | '%_transient_give_i18n_give_promo_hide%', |
932 | 932 | '%_transient_give_contributors%', |
@@ -953,24 +953,24 @@ discard block |
||
953 | 953 | ARRAY_A |
954 | 954 | ); |
955 | 955 | |
956 | - if ( ! empty( $user_apikey_options ) ) { |
|
957 | - foreach ( $user_apikey_options as $user ) { |
|
958 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
959 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
960 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
956 | + if ( ! empty($user_apikey_options)) { |
|
957 | + foreach ($user_apikey_options as $user) { |
|
958 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
959 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
960 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
961 | 961 | } |
962 | 962 | } |
963 | 963 | |
964 | - if ( ! empty( $cached_options ) ) { |
|
965 | - foreach ( $cached_options as $option ) { |
|
966 | - switch ( true ) { |
|
967 | - case ( false !== strpos( $option, 'transient' ) ): |
|
968 | - $option = str_replace( '_transient_', '', $option ); |
|
969 | - delete_transient( $option ); |
|
964 | + if ( ! empty($cached_options)) { |
|
965 | + foreach ($cached_options as $option) { |
|
966 | + switch (true) { |
|
967 | + case (false !== strpos($option, 'transient')): |
|
968 | + $option = str_replace('_transient_', '', $option); |
|
969 | + delete_transient($option); |
|
970 | 970 | break; |
971 | 971 | |
972 | 972 | default: |
973 | - delete_option( $option ); |
|
973 | + delete_option($option); |
|
974 | 974 | } |
975 | 975 | } |
976 | 976 | } |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | global $wp_roles; |
989 | 989 | |
990 | 990 | // Get the role object. |
991 | - $give_worker = get_role( 'give_worker' ); |
|
991 | + $give_worker = get_role('give_worker'); |
|
992 | 992 | |
993 | 993 | // A list of capabilities to add for give workers. |
994 | 994 | $caps_to_add = array( |
@@ -996,9 +996,9 @@ discard block |
||
996 | 996 | 'edit_pages', |
997 | 997 | ); |
998 | 998 | |
999 | - foreach ( $caps_to_add as $cap ) { |
|
999 | + foreach ($caps_to_add as $cap) { |
|
1000 | 1000 | // Add the capability. |
1001 | - $give_worker->add_cap( $cap ); |
|
1001 | + $give_worker->add_cap($cap); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | } |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | $give_updates = Give_Updates::get_instance(); |
1016 | 1016 | |
1017 | 1017 | // form query. |
1018 | - $donation_forms = new WP_Query( array( |
|
1018 | + $donation_forms = new WP_Query(array( |
|
1019 | 1019 | 'paged' => $give_updates->step, |
1020 | 1020 | 'status' => 'any', |
1021 | 1021 | 'order' => 'ASC', |
@@ -1024,10 +1024,10 @@ discard block |
||
1024 | 1024 | ) |
1025 | 1025 | ); |
1026 | 1026 | |
1027 | - if ( $donation_forms->have_posts() ) { |
|
1028 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1027 | + if ($donation_forms->have_posts()) { |
|
1028 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1029 | 1029 | |
1030 | - while ( $donation_forms->have_posts() ) { |
|
1030 | + while ($donation_forms->have_posts()) { |
|
1031 | 1031 | $donation_forms->the_post(); |
1032 | 1032 | $form_id = get_the_ID(); |
1033 | 1033 | |
@@ -1035,41 +1035,41 @@ discard block |
||
1035 | 1035 | update_post_meta( |
1036 | 1036 | $form_id, |
1037 | 1037 | '_give_set_price', |
1038 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
1038 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
1039 | 1039 | ); |
1040 | 1040 | |
1041 | 1041 | // Remove formatting from _give_custom_amount_minimum. |
1042 | 1042 | update_post_meta( |
1043 | 1043 | $form_id, |
1044 | 1044 | '_give_custom_amount_minimum', |
1045 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
1045 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
1046 | 1046 | ); |
1047 | 1047 | |
1048 | 1048 | // Bailout. |
1049 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
1049 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
1050 | 1050 | continue; |
1051 | 1051 | } |
1052 | 1052 | |
1053 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
1053 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
1054 | 1054 | |
1055 | - if ( ! empty( $donation_levels ) ) { |
|
1055 | + if ( ! empty($donation_levels)) { |
|
1056 | 1056 | |
1057 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
1058 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
1059 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
1057 | + foreach ($donation_levels as $index => $donation_level) { |
|
1058 | + if (isset($donation_level['_give_amount'])) { |
|
1059 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
1060 | 1060 | } |
1061 | 1061 | } |
1062 | 1062 | |
1063 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
1063 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
1064 | 1064 | |
1065 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
1065 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
1066 | 1066 | |
1067 | - $min_amount = min( $donation_levels_amounts ); |
|
1068 | - $max_amount = max( $donation_levels_amounts ); |
|
1067 | + $min_amount = min($donation_levels_amounts); |
|
1068 | + $max_amount = max($donation_levels_amounts); |
|
1069 | 1069 | |
1070 | 1070 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
1071 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
1072 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
1071 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
1072 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | } |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | wp_reset_postdata(); |
1079 | 1079 | } else { |
1080 | 1080 | // The Update Ran. |
1081 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
1081 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | } |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | */ |
1129 | 1129 | function give_v20_upgrades() { |
1130 | 1130 | // Update cache setting. |
1131 | - give_update_option( 'cache', 'enabled' ); |
|
1131 | + give_update_option('cache', 'enabled'); |
|
1132 | 1132 | |
1133 | 1133 | // Upgrade email settings. |
1134 | 1134 | give_v20_upgrades_email_setting(); |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | $all_setting = give_get_settings(); |
1148 | 1148 | |
1149 | 1149 | // Bailout on fresh install. |
1150 | - if ( empty( $all_setting ) ) { |
|
1150 | + if (empty($all_setting)) { |
|
1151 | 1151 | return; |
1152 | 1152 | } |
1153 | 1153 | |
@@ -1166,19 +1166,19 @@ discard block |
||
1166 | 1166 | 'admin_notices' => 'new-donation_notification', |
1167 | 1167 | ); |
1168 | 1168 | |
1169 | - foreach ( $settings as $old_setting => $new_setting ) { |
|
1169 | + foreach ($settings as $old_setting => $new_setting) { |
|
1170 | 1170 | // Do not update already modified |
1171 | - if ( ! is_array( $new_setting ) ) { |
|
1172 | - if ( array_key_exists( $new_setting, $all_setting ) || ! array_key_exists( $old_setting, $all_setting ) ) { |
|
1171 | + if ( ! is_array($new_setting)) { |
|
1172 | + if (array_key_exists($new_setting, $all_setting) || ! array_key_exists($old_setting, $all_setting)) { |
|
1173 | 1173 | continue; |
1174 | 1174 | } |
1175 | 1175 | } |
1176 | 1176 | |
1177 | - switch ( $old_setting ) { |
|
1177 | + switch ($old_setting) { |
|
1178 | 1178 | case 'admin_notices': |
1179 | - $notification_status = give_get_option( $old_setting, 'enabled' ); |
|
1179 | + $notification_status = give_get_option($old_setting, 'enabled'); |
|
1180 | 1180 | |
1181 | - give_update_option( $new_setting, $notification_status ); |
|
1181 | + give_update_option($new_setting, $notification_status); |
|
1182 | 1182 | |
1183 | 1183 | // @todo: Delete this option later ( version > 2.0 ), We need this for per form email addon. |
1184 | 1184 | // give_delete_option( $old_setting ); |
@@ -1189,19 +1189,19 @@ discard block |
||
1189 | 1189 | case 'admin_notice_emails': |
1190 | 1190 | $recipients = give_get_admin_notice_emails(); |
1191 | 1191 | |
1192 | - foreach ( $new_setting as $setting ) { |
|
1192 | + foreach ($new_setting as $setting) { |
|
1193 | 1193 | // bailout if setting already exist. |
1194 | - if ( array_key_exists( $setting, $all_setting ) ) { |
|
1194 | + if (array_key_exists($setting, $all_setting)) { |
|
1195 | 1195 | continue; |
1196 | 1196 | } |
1197 | 1197 | |
1198 | - give_update_option( $setting, $recipients ); |
|
1198 | + give_update_option($setting, $recipients); |
|
1199 | 1199 | } |
1200 | 1200 | break; |
1201 | 1201 | |
1202 | 1202 | default: |
1203 | - give_update_option( $new_setting, give_get_option( $old_setting ) ); |
|
1204 | - give_delete_option( $old_setting ); |
|
1203 | + give_update_option($new_setting, give_get_option($old_setting)); |
|
1204 | + give_delete_option($old_setting); |
|
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | } |
@@ -1218,22 +1218,22 @@ discard block |
||
1218 | 1218 | $give_settings = give_get_settings(); |
1219 | 1219 | $give_setting_updated = false; |
1220 | 1220 | |
1221 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
1221 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
1222 | 1222 | $give_settings['number_decimals'] = 0; |
1223 | 1223 | $give_settings['decimal_separator'] = ''; |
1224 | 1224 | $give_setting_updated = true; |
1225 | 1225 | |
1226 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
1226 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
1227 | 1227 | $give_settings['number_decimals'] = 0; |
1228 | 1228 | $give_setting_updated = true; |
1229 | 1229 | |
1230 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
1230 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
1231 | 1231 | $give_settings['number_decimals'] = 5; |
1232 | 1232 | $give_setting_updated = true; |
1233 | 1233 | } |
1234 | 1234 | |
1235 | - if ( $give_setting_updated ) { |
|
1236 | - update_option( 'give_settings', $give_settings ); |
|
1235 | + if ($give_setting_updated) { |
|
1236 | + update_option('give_settings', $give_settings); |
|
1237 | 1237 | } |
1238 | 1238 | } |
1239 | 1239 | |
@@ -1252,69 +1252,69 @@ discard block |
||
1252 | 1252 | $give_updates = Give_Updates::get_instance(); |
1253 | 1253 | |
1254 | 1254 | // form query. |
1255 | - $donation_forms = new WP_Query( array( |
|
1255 | + $donation_forms = new WP_Query(array( |
|
1256 | 1256 | 'paged' => $give_updates->step, |
1257 | 1257 | 'status' => 'any', |
1258 | 1258 | 'order' => 'ASC', |
1259 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1259 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1260 | 1260 | 'posts_per_page' => 20, |
1261 | 1261 | ) |
1262 | 1262 | ); |
1263 | - if ( $donation_forms->have_posts() ) { |
|
1264 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1263 | + if ($donation_forms->have_posts()) { |
|
1264 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1265 | 1265 | |
1266 | - while ( $donation_forms->have_posts() ) { |
|
1266 | + while ($donation_forms->have_posts()) { |
|
1267 | 1267 | $donation_forms->the_post(); |
1268 | 1268 | global $post; |
1269 | 1269 | |
1270 | - $meta = get_post_meta( $post->ID ); |
|
1270 | + $meta = get_post_meta($post->ID); |
|
1271 | 1271 | |
1272 | - switch ( $post->post_type ) { |
|
1272 | + switch ($post->post_type) { |
|
1273 | 1273 | case 'give_forms': |
1274 | 1274 | // _give_set_price. |
1275 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
1276 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
1275 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
1276 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | // _give_custom_amount_minimum. |
1280 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
1281 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
1280 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
1281 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | // _give_levels_minimum_amount. |
1285 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
1286 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
1285 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
1286 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
1287 | 1287 | } |
1288 | 1288 | |
1289 | 1289 | // _give_levels_maximum_amount. |
1290 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
1291 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
1290 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
1291 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
1292 | 1292 | } |
1293 | 1293 | |
1294 | 1294 | // _give_set_goal. |
1295 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
1296 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
1295 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
1296 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | 1299 | // _give_form_earnings. |
1300 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
1301 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
1300 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
1301 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
1302 | 1302 | } |
1303 | 1303 | |
1304 | 1304 | // _give_custom_amount_minimum. |
1305 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
1306 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
1305 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
1306 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
1307 | 1307 | |
1308 | - foreach ( $donation_levels as $index => $level ) { |
|
1309 | - if ( empty( $level['_give_amount'] ) ) { |
|
1308 | + foreach ($donation_levels as $index => $level) { |
|
1309 | + if (empty($level['_give_amount'])) { |
|
1310 | 1310 | continue; |
1311 | 1311 | } |
1312 | 1312 | |
1313 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
1313 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
1314 | 1314 | } |
1315 | 1315 | |
1316 | 1316 | $meta['_give_donation_levels'] = $donation_levels; |
1317 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
1317 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
1318 | 1318 | } |
1319 | 1319 | |
1320 | 1320 | |
@@ -1322,8 +1322,8 @@ discard block |
||
1322 | 1322 | |
1323 | 1323 | case 'give_payment': |
1324 | 1324 | // _give_payment_total. |
1325 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
1326 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
1325 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
1326 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
1327 | 1327 | } |
1328 | 1328 | |
1329 | 1329 | break; |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | wp_reset_postdata(); |
1335 | 1335 | } else { |
1336 | 1336 | // The Update Ran. |
1337 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
1337 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
1338 | 1338 | } |
1339 | 1339 | } |
1340 | 1340 | |
@@ -1354,22 +1354,22 @@ discard block |
||
1354 | 1354 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
1355 | 1355 | |
1356 | 1356 | // form query. |
1357 | - $donors = Give()->donors->get_donors( array( |
|
1357 | + $donors = Give()->donors->get_donors(array( |
|
1358 | 1358 | 'number' => 20, |
1359 | 1359 | 'offset' => $offset, |
1360 | 1360 | ) |
1361 | 1361 | ); |
1362 | 1362 | |
1363 | - if ( ! empty( $donors ) ) { |
|
1364 | - $give_updates->set_percentage( Give()->donors->count(), $offset ); |
|
1363 | + if ( ! empty($donors)) { |
|
1364 | + $give_updates->set_percentage(Give()->donors->count(), $offset); |
|
1365 | 1365 | |
1366 | 1366 | /* @var Object $donor */ |
1367 | - foreach ( $donors as $donor ) { |
|
1368 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
1367 | + foreach ($donors as $donor) { |
|
1368 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
1369 | 1369 | } |
1370 | 1370 | } else { |
1371 | 1371 | // The Update Ran. |
1372 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
1372 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
1373 | 1373 | } |
1374 | 1374 | } |
1375 | 1375 | |
@@ -1384,25 +1384,25 @@ discard block |
||
1384 | 1384 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
1385 | 1385 | |
1386 | 1386 | // Fetch all the existing donors. |
1387 | - $donors = Give()->donors->get_donors( array( |
|
1387 | + $donors = Give()->donors->get_donors(array( |
|
1388 | 1388 | 'number' => 20, |
1389 | 1389 | 'offset' => $offset, |
1390 | 1390 | ) |
1391 | 1391 | ); |
1392 | 1392 | |
1393 | - if ( ! empty( $donors ) ) { |
|
1394 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
1393 | + if ( ! empty($donors)) { |
|
1394 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
1395 | 1395 | |
1396 | 1396 | /* @var Object $donor */ |
1397 | - foreach ( $donors as $donor ) { |
|
1397 | + foreach ($donors as $donor) { |
|
1398 | 1398 | $user_id = $donor->user_id; |
1399 | 1399 | |
1400 | 1400 | // Proceed, if donor is attached with user. |
1401 | - if ( $user_id ) { |
|
1402 | - $user = get_userdata( $user_id ); |
|
1401 | + if ($user_id) { |
|
1402 | + $user = get_userdata($user_id); |
|
1403 | 1403 | |
1404 | 1404 | // Update user role, if user has subscriber role. |
1405 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
1405 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
1406 | 1406 | wp_update_user( |
1407 | 1407 | array( |
1408 | 1408 | 'ID' => $user_id, |
@@ -1414,7 +1414,7 @@ discard block |
||
1414 | 1414 | } |
1415 | 1415 | } else { |
1416 | 1416 | // The Update Ran. |
1417 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
1417 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
1418 | 1418 | } |
1419 | 1419 | } |
1420 | 1420 | |
@@ -1426,7 +1426,7 @@ discard block |
||
1426 | 1426 | */ |
1427 | 1427 | function give_v1813_upgrades() { |
1428 | 1428 | // Update admin setting. |
1429 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
1429 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
1430 | 1430 | |
1431 | 1431 | // Update Give roles. |
1432 | 1432 | $roles = new Give_Roles(); |
@@ -1444,33 +1444,33 @@ discard block |
||
1444 | 1444 | $give_updates = Give_Updates::get_instance(); |
1445 | 1445 | |
1446 | 1446 | // form query. |
1447 | - $payments = new WP_Query( array( |
|
1447 | + $payments = new WP_Query(array( |
|
1448 | 1448 | 'paged' => $give_updates->step, |
1449 | 1449 | 'status' => 'any', |
1450 | 1450 | 'order' => 'ASC', |
1451 | - 'post_type' => array( 'give_payment' ), |
|
1451 | + 'post_type' => array('give_payment'), |
|
1452 | 1452 | 'posts_per_page' => 100, |
1453 | 1453 | ) |
1454 | 1454 | ); |
1455 | 1455 | |
1456 | - if ( $payments->have_posts() ) { |
|
1457 | - $give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 100 ) ); |
|
1456 | + if ($payments->have_posts()) { |
|
1457 | + $give_updates->set_percentage($payments->found_posts, ($give_updates->step * 100)); |
|
1458 | 1458 | |
1459 | - while ( $payments->have_posts() ) { |
|
1459 | + while ($payments->have_posts()) { |
|
1460 | 1460 | $payments->the_post(); |
1461 | 1461 | |
1462 | - $payment_meta = give_get_payment_meta( get_the_ID() ); |
|
1462 | + $payment_meta = give_get_payment_meta(get_the_ID()); |
|
1463 | 1463 | |
1464 | - if ( 'RIAL' === $payment_meta['currency'] ) { |
|
1464 | + if ('RIAL' === $payment_meta['currency']) { |
|
1465 | 1465 | $payment_meta['currency'] = 'IRR'; |
1466 | - give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta ); |
|
1466 | + give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta); |
|
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | } |
1470 | 1470 | |
1471 | 1471 | } else { |
1472 | 1472 | // The Update Ran. |
1473 | - give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
|
1473 | + give_set_upgrade_complete('v1817_update_donation_iranian_currency_code'); |
|
1474 | 1474 | } |
1475 | 1475 | } |
1476 | 1476 | |
@@ -1483,9 +1483,9 @@ discard block |
||
1483 | 1483 | function give_v1817_upgrades() { |
1484 | 1484 | $give_settings = give_get_settings(); |
1485 | 1485 | |
1486 | - if ( 'RIAL' === $give_settings['currency'] ) { |
|
1486 | + if ('RIAL' === $give_settings['currency']) { |
|
1487 | 1487 | $give_settings['currency'] = 'IRR'; |
1488 | - update_option( 'give_settings', $give_settings ); |
|
1488 | + update_option('give_settings', $give_settings); |
|
1489 | 1489 | } |
1490 | 1490 | } |
1491 | 1491 | |
@@ -1498,7 +1498,7 @@ discard block |
||
1498 | 1498 | |
1499 | 1499 | global $wp_roles; |
1500 | 1500 | |
1501 | - if( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1501 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1502 | 1502 | return; |
1503 | 1503 | } |
1504 | 1504 | |
@@ -1522,15 +1522,15 @@ discard block |
||
1522 | 1522 | ), |
1523 | 1523 | ); |
1524 | 1524 | |
1525 | - foreach ( $add_caps as $role => $caps ) { |
|
1526 | - foreach ( $caps as $cap ) { |
|
1527 | - $wp_roles->add_cap( $role, $cap ); |
|
1525 | + foreach ($add_caps as $role => $caps) { |
|
1526 | + foreach ($caps as $cap) { |
|
1527 | + $wp_roles->add_cap($role, $cap); |
|
1528 | 1528 | } |
1529 | 1529 | } |
1530 | 1530 | |
1531 | - foreach ( $remove_caps as $role => $caps ) { |
|
1532 | - foreach ( $caps as $cap ) { |
|
1533 | - $wp_roles->remove_cap( $role, $cap ); |
|
1531 | + foreach ($remove_caps as $role => $caps) { |
|
1532 | + foreach ($caps as $cap) { |
|
1533 | + $wp_roles->remove_cap($role, $cap); |
|
1534 | 1534 | } |
1535 | 1535 | } |
1536 | 1536 | |
@@ -1554,7 +1554,7 @@ discard block |
||
1554 | 1554 | $roles->add_roles(); |
1555 | 1555 | $roles->add_caps(); |
1556 | 1556 | |
1557 | - give_set_upgrade_complete( 'v1817_cleanup_user_roles' ); |
|
1557 | + give_set_upgrade_complete('v1817_cleanup_user_roles'); |
|
1558 | 1558 | } |
1559 | 1559 | |
1560 | 1560 | /** |
@@ -1565,7 +1565,7 @@ discard block |
||
1565 | 1565 | function give_v1818_upgrades() { |
1566 | 1566 | |
1567 | 1567 | // Remove email_access_installed from give_settings. |
1568 | - give_delete_option( 'email_access_installed' ); |
|
1568 | + give_delete_option('email_access_installed'); |
|
1569 | 1569 | } |
1570 | 1570 | |
1571 | 1571 | /** |
@@ -1576,25 +1576,25 @@ discard block |
||
1576 | 1576 | function give_v1818_assign_custom_amount_set_donation() { |
1577 | 1577 | |
1578 | 1578 | /* @var Give_Updates $give_updates */ |
1579 | - $give_updates = Give_Updates::get_instance(); |
|
1579 | + $give_updates = Give_Updates::get_instance(); |
|
1580 | 1580 | |
1581 | - $donations = new WP_Query( array( |
|
1581 | + $donations = new WP_Query(array( |
|
1582 | 1582 | 'paged' => $give_updates->step, |
1583 | 1583 | 'status' => 'any', |
1584 | 1584 | 'order' => 'ASC', |
1585 | - 'post_type' => array( 'give_payment' ), |
|
1585 | + 'post_type' => array('give_payment'), |
|
1586 | 1586 | 'posts_per_page' => 100, |
1587 | 1587 | ) |
1588 | 1588 | ); |
1589 | 1589 | |
1590 | - if ( $donations->have_posts() ) { |
|
1591 | - $give_updates->set_percentage( $donations->found_posts, $give_updates->step * 100 ); |
|
1590 | + if ($donations->have_posts()) { |
|
1591 | + $give_updates->set_percentage($donations->found_posts, $give_updates->step * 100); |
|
1592 | 1592 | |
1593 | - while ( $donations->have_posts() ) { |
|
1593 | + while ($donations->have_posts()) { |
|
1594 | 1594 | $donations->the_post(); |
1595 | 1595 | |
1596 | - $form = new Give_Donate_Form( give_get_meta( get_the_ID(), '_give_payment_form_id', true ) ); |
|
1597 | - $donation_meta = give_get_payment_meta( get_the_ID() ); |
|
1596 | + $form = new Give_Donate_Form(give_get_meta(get_the_ID(), '_give_payment_form_id', true)); |
|
1597 | + $donation_meta = give_get_payment_meta(get_the_ID()); |
|
1598 | 1598 | |
1599 | 1599 | // Update Donation meta with price_id set as custom, only if it is: |
1600 | 1600 | // 1. Donation Type = Set Donation. |
@@ -1603,19 +1603,19 @@ discard block |
||
1603 | 1603 | if ( |
1604 | 1604 | $form->ID && |
1605 | 1605 | $form->is_set_type_donation_form() && |
1606 | - ( 'custom' !== $donation_meta['price_id'] ) && |
|
1607 | - $form->is_custom_price( give_get_meta( get_the_ID(), '_give_payment_total', true ) ) |
|
1606 | + ('custom' !== $donation_meta['price_id']) && |
|
1607 | + $form->is_custom_price(give_get_meta(get_the_ID(), '_give_payment_total', true)) |
|
1608 | 1608 | ) { |
1609 | 1609 | $donation_meta['price_id'] = 'custom'; |
1610 | - give_update_meta( get_the_ID(), '_give_payment_meta', $donation_meta ); |
|
1611 | - give_update_meta( get_the_ID(), '_give_payment_price_id', 'custom' ); |
|
1610 | + give_update_meta(get_the_ID(), '_give_payment_meta', $donation_meta); |
|
1611 | + give_update_meta(get_the_ID(), '_give_payment_price_id', 'custom'); |
|
1612 | 1612 | } |
1613 | 1613 | } |
1614 | 1614 | |
1615 | 1615 | wp_reset_postdata(); |
1616 | 1616 | } else { |
1617 | 1617 | // Update Ran Successfully. |
1618 | - give_set_upgrade_complete( 'v1818_assign_custom_amount_set_donation' ); |
|
1618 | + give_set_upgrade_complete('v1818_assign_custom_amount_set_donation'); |
|
1619 | 1619 | } |
1620 | 1620 | } |
1621 | 1621 | |
@@ -1626,14 +1626,14 @@ discard block |
||
1626 | 1626 | * |
1627 | 1627 | * @since 1.8.18 |
1628 | 1628 | */ |
1629 | -function give_v1818_give_worker_role_cleanup(){ |
|
1629 | +function give_v1818_give_worker_role_cleanup() { |
|
1630 | 1630 | |
1631 | 1631 | /* @var Give_Updates $give_updates */ |
1632 | 1632 | $give_updates = Give_Updates::get_instance(); |
1633 | 1633 | |
1634 | 1634 | global $wp_roles; |
1635 | 1635 | |
1636 | - if( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1636 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1637 | 1637 | return; |
1638 | 1638 | } |
1639 | 1639 | |
@@ -1651,9 +1651,9 @@ discard block |
||
1651 | 1651 | ), |
1652 | 1652 | ); |
1653 | 1653 | |
1654 | - foreach ( $remove_caps as $role => $caps ) { |
|
1655 | - foreach( $caps as $cap ) { |
|
1656 | - $wp_roles->remove_cap( $role, $cap ); |
|
1654 | + foreach ($remove_caps as $role => $caps) { |
|
1655 | + foreach ($caps as $cap) { |
|
1656 | + $wp_roles->remove_cap($role, $cap); |
|
1657 | 1657 | } |
1658 | 1658 | } |
1659 | 1659 | |
@@ -1664,7 +1664,7 @@ discard block |
||
1664 | 1664 | $roles->add_roles(); |
1665 | 1665 | $roles->add_caps(); |
1666 | 1666 | |
1667 | - give_set_upgrade_complete( 'v1818_give_worker_role_cleanup' ); |
|
1667 | + give_set_upgrade_complete('v1818_give_worker_role_cleanup'); |
|
1668 | 1668 | } |
1669 | 1669 | |
1670 | 1670 | /** |
@@ -1678,7 +1678,7 @@ discard block |
||
1678 | 1678 | $give_updates = Give_Updates::get_instance(); |
1679 | 1679 | |
1680 | 1680 | // form query |
1681 | - $forms = new WP_Query( array( |
|
1681 | + $forms = new WP_Query(array( |
|
1682 | 1682 | 'paged' => $give_updates->step, |
1683 | 1683 | 'status' => 'any', |
1684 | 1684 | 'order' => 'ASC', |
@@ -1687,22 +1687,22 @@ discard block |
||
1687 | 1687 | ) |
1688 | 1688 | ); |
1689 | 1689 | |
1690 | - if ( $forms->have_posts() ) { |
|
1691 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1690 | + if ($forms->have_posts()) { |
|
1691 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1692 | 1692 | |
1693 | - while ( $forms->have_posts() ) { |
|
1693 | + while ($forms->have_posts()) { |
|
1694 | 1694 | $forms->the_post(); |
1695 | 1695 | global $post; |
1696 | 1696 | |
1697 | 1697 | // Update offline instruction email notification status. |
1698 | - $offline_instruction_notification_status = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
1699 | - $offline_instruction_notification_status = give_is_setting_enabled( $offline_instruction_notification_status, array( |
|
1698 | + $offline_instruction_notification_status = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
1699 | + $offline_instruction_notification_status = give_is_setting_enabled($offline_instruction_notification_status, array( |
|
1700 | 1700 | 'enabled', |
1701 | 1701 | 'global', |
1702 | - ) ) |
|
1702 | + )) |
|
1703 | 1703 | ? $offline_instruction_notification_status |
1704 | 1704 | : 'global'; |
1705 | - update_post_meta( get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status ); |
|
1705 | + update_post_meta(get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status); |
|
1706 | 1706 | |
1707 | 1707 | // Update offline instruction email message. |
1708 | 1708 | update_post_meta( |
@@ -1734,7 +1734,7 @@ discard block |
||
1734 | 1734 | wp_reset_postdata(); |
1735 | 1735 | } else { |
1736 | 1736 | // No more forms found, finish up. |
1737 | - give_set_upgrade_complete( 'v20_upgrades_form_metadata' ); |
|
1737 | + give_set_upgrade_complete('v20_upgrades_form_metadata'); |
|
1738 | 1738 | } |
1739 | 1739 | } |
1740 | 1740 | |
@@ -1751,7 +1751,7 @@ discard block |
||
1751 | 1751 | $give_updates = Give_Updates::get_instance(); |
1752 | 1752 | |
1753 | 1753 | // form query |
1754 | - $forms = new WP_Query( array( |
|
1754 | + $forms = new WP_Query(array( |
|
1755 | 1755 | 'paged' => $give_updates->step, |
1756 | 1756 | 'status' => 'any', |
1757 | 1757 | 'order' => 'ASC', |
@@ -1760,19 +1760,19 @@ discard block |
||
1760 | 1760 | ) |
1761 | 1761 | ); |
1762 | 1762 | |
1763 | - if ( $forms->have_posts() ) { |
|
1764 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1763 | + if ($forms->have_posts()) { |
|
1764 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1765 | 1765 | |
1766 | - while ( $forms->have_posts() ) { |
|
1766 | + while ($forms->have_posts()) { |
|
1767 | 1767 | $forms->the_post(); |
1768 | 1768 | global $post; |
1769 | 1769 | |
1770 | 1770 | // Split _give_payment_meta meta. |
1771 | 1771 | // @todo Remove _give_payment_meta after releases 2.0 |
1772 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
1772 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
1773 | 1773 | |
1774 | - if ( ! empty( $payment_meta ) ) { |
|
1775 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
1774 | + if ( ! empty($payment_meta)) { |
|
1775 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
1776 | 1776 | } |
1777 | 1777 | |
1778 | 1778 | $deprecated_meta_keys = array( |
@@ -1781,9 +1781,9 @@ discard block |
||
1781 | 1781 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
1782 | 1782 | ); |
1783 | 1783 | |
1784 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
1784 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
1785 | 1785 | // Do not add new meta key if already exist. |
1786 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
1786 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
1787 | 1787 | continue; |
1788 | 1788 | } |
1789 | 1789 | |
@@ -1792,25 +1792,25 @@ discard block |
||
1792 | 1792 | array( |
1793 | 1793 | 'post_id' => $post->ID, |
1794 | 1794 | 'meta_key' => $new_meta_key, |
1795 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ) |
|
1795 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true) |
|
1796 | 1796 | ) |
1797 | 1797 | ); |
1798 | 1798 | } |
1799 | 1799 | |
1800 | 1800 | // Bailout |
1801 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
1801 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
1802 | 1802 | /* @var Give_Donor $donor */ |
1803 | - $donor = new Give_Donor( $donor_id ); |
|
1803 | + $donor = new Give_Donor($donor_id); |
|
1804 | 1804 | |
1805 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
1806 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
1807 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
1808 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
1809 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
1810 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
1805 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
1806 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
1807 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
1808 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
1809 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
1810 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
1811 | 1811 | |
1812 | 1812 | // Save address. |
1813 | - $donor->add_address( 'billing[]', $address ); |
|
1813 | + $donor->add_address('billing[]', $address); |
|
1814 | 1814 | } |
1815 | 1815 | |
1816 | 1816 | }// End while(). |
@@ -1821,7 +1821,7 @@ discard block |
||
1821 | 1821 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
1822 | 1822 | |
1823 | 1823 | // No more forms found, finish up. |
1824 | - give_set_upgrade_complete( 'v20_upgrades_payment_metadata' ); |
|
1824 | + give_set_upgrade_complete('v20_upgrades_payment_metadata'); |
|
1825 | 1825 | } |
1826 | 1826 | } |
1827 | 1827 | |
@@ -1837,7 +1837,7 @@ discard block |
||
1837 | 1837 | $give_updates = Give_Updates::get_instance(); |
1838 | 1838 | |
1839 | 1839 | // form query |
1840 | - $forms = new WP_Query( array( |
|
1840 | + $forms = new WP_Query(array( |
|
1841 | 1841 | 'paged' => $give_updates->step, |
1842 | 1842 | 'order' => 'DESC', |
1843 | 1843 | 'post_type' => 'give_log', |
@@ -1846,20 +1846,20 @@ discard block |
||
1846 | 1846 | ) |
1847 | 1847 | ); |
1848 | 1848 | |
1849 | - if ( $forms->have_posts() ) { |
|
1850 | - $give_updates->set_percentage( $forms->found_posts, $give_updates->step * 100 ); |
|
1849 | + if ($forms->have_posts()) { |
|
1850 | + $give_updates->set_percentage($forms->found_posts, $give_updates->step * 100); |
|
1851 | 1851 | |
1852 | - while ( $forms->have_posts() ) { |
|
1852 | + while ($forms->have_posts()) { |
|
1853 | 1853 | $forms->the_post(); |
1854 | 1854 | global $post; |
1855 | 1855 | |
1856 | - if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
1856 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
1857 | 1857 | continue; |
1858 | 1858 | } |
1859 | 1859 | |
1860 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
1861 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
1862 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
1860 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
1861 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
1862 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
1863 | 1863 | |
1864 | 1864 | $log_data = array( |
1865 | 1865 | 'ID' => $post->ID, |
@@ -1872,29 +1872,29 @@ discard block |
||
1872 | 1872 | ); |
1873 | 1873 | $log_meta = array(); |
1874 | 1874 | |
1875 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
1876 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
1877 | - switch ( $meta_key ) { |
|
1875 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
1876 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
1877 | + switch ($meta_key) { |
|
1878 | 1878 | case '_give_log_payment_id': |
1879 | - $log_data['log_parent'] = current( $meta_value ); |
|
1879 | + $log_data['log_parent'] = current($meta_value); |
|
1880 | 1880 | $log_meta['_give_log_form_id'] = $post->post_parent; |
1881 | 1881 | break; |
1882 | 1882 | |
1883 | 1883 | default: |
1884 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
1884 | + $log_meta[$meta_key] = current($meta_value); |
|
1885 | 1885 | } |
1886 | 1886 | } |
1887 | 1887 | } |
1888 | 1888 | |
1889 | - if ( 'api_request' === $term_name ) { |
|
1889 | + if ('api_request' === $term_name) { |
|
1890 | 1890 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
1891 | 1891 | } |
1892 | 1892 | |
1893 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
1893 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
1894 | 1894 | |
1895 | - if ( ! empty( $log_meta ) ) { |
|
1896 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
1897 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
1895 | + if ( ! empty($log_meta)) { |
|
1896 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
1897 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
1898 | 1898 | } |
1899 | 1899 | } |
1900 | 1900 | |
@@ -1936,7 +1936,7 @@ discard block |
||
1936 | 1936 | Give()->logs->delete_cache(); |
1937 | 1937 | |
1938 | 1938 | // No more forms found, finish up. |
1939 | - give_set_upgrade_complete( 'v20_logs_upgrades' ); |
|
1939 | + give_set_upgrade_complete('v20_logs_upgrades'); |
|
1940 | 1940 | } |
1941 | 1941 | } |
1942 | 1942 | |
@@ -1952,19 +1952,19 @@ discard block |
||
1952 | 1952 | $give_updates = Give_Updates::get_instance(); |
1953 | 1953 | |
1954 | 1954 | // form query |
1955 | - $payments = new WP_Query( array( |
|
1955 | + $payments = new WP_Query(array( |
|
1956 | 1956 | 'paged' => $give_updates->step, |
1957 | 1957 | 'status' => 'any', |
1958 | 1958 | 'order' => 'ASC', |
1959 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1959 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1960 | 1960 | 'posts_per_page' => 100, |
1961 | 1961 | ) |
1962 | 1962 | ); |
1963 | 1963 | |
1964 | - if ( $payments->have_posts() ) { |
|
1965 | - $give_updates->set_percentage( $payments->found_posts, $give_updates->step * 100 ); |
|
1964 | + if ($payments->have_posts()) { |
|
1965 | + $give_updates->set_percentage($payments->found_posts, $give_updates->step * 100); |
|
1966 | 1966 | |
1967 | - while ( $payments->have_posts() ) { |
|
1967 | + while ($payments->have_posts()) { |
|
1968 | 1968 | $payments->the_post(); |
1969 | 1969 | global $post; |
1970 | 1970 | |
@@ -1976,19 +1976,19 @@ discard block |
||
1976 | 1976 | ARRAY_A |
1977 | 1977 | ); |
1978 | 1978 | |
1979 | - if ( ! empty( $meta_data ) ) { |
|
1980 | - foreach ( $meta_data as $index => $data ) { |
|
1979 | + if ( ! empty($meta_data)) { |
|
1980 | + foreach ($meta_data as $index => $data) { |
|
1981 | 1981 | // Check for duplicate meta values. |
1982 | - if( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
1982 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
1983 | 1983 | continue; |
1984 | 1984 | } |
1985 | 1985 | |
1986 | - switch ( $post->post_type ) { |
|
1986 | + switch ($post->post_type) { |
|
1987 | 1987 | case 'give_forms': |
1988 | 1988 | $data['form_id'] = $data['post_id']; |
1989 | - unset( $data['post_id'] ); |
|
1989 | + unset($data['post_id']); |
|
1990 | 1990 | |
1991 | - Give()->form_meta->insert( $data ); |
|
1991 | + Give()->form_meta->insert($data); |
|
1992 | 1992 | // @todo: delete form meta from post meta table after releases 2.0. |
1993 | 1993 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
1994 | 1994 | |
@@ -1996,9 +1996,9 @@ discard block |
||
1996 | 1996 | |
1997 | 1997 | case 'give_payment': |
1998 | 1998 | $data['payment_id'] = $data['post_id']; |
1999 | - unset( $data['post_id'] ); |
|
1999 | + unset($data['post_id']); |
|
2000 | 2000 | |
2001 | - Give()->payment_meta->insert( $data ); |
|
2001 | + Give()->payment_meta->insert($data); |
|
2002 | 2002 | |
2003 | 2003 | // @todo: delete donation meta from post meta table after releases 2.0. |
2004 | 2004 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2013,7 +2013,7 @@ discard block |
||
2013 | 2013 | wp_reset_postdata(); |
2014 | 2014 | } else { |
2015 | 2015 | // No more forms found, finish up. |
2016 | - give_set_upgrade_complete( 'v20_move_metadata_into_new_table' ); |
|
2016 | + give_set_upgrade_complete('v20_move_metadata_into_new_table'); |
|
2017 | 2017 | } |
2018 | 2018 | |
2019 | 2019 | } |
@@ -2029,44 +2029,44 @@ discard block |
||
2029 | 2029 | /* @var Give_Updates $give_updates */ |
2030 | 2030 | $give_updates = Give_Updates::get_instance(); |
2031 | 2031 | |
2032 | - $donors = Give()->donors->get_donors( array( |
|
2032 | + $donors = Give()->donors->get_donors(array( |
|
2033 | 2033 | 'paged' => $give_updates->step, |
2034 | 2034 | 'number' => 100, |
2035 | - ) ); |
|
2035 | + )); |
|
2036 | 2036 | |
2037 | - if ( $donors ) { |
|
2038 | - $give_updates->set_percentage( count( $donors ), $give_updates->step * 100 ); |
|
2037 | + if ($donors) { |
|
2038 | + $give_updates->set_percentage(count($donors), $give_updates->step * 100); |
|
2039 | 2039 | // Loop through Donors |
2040 | - foreach ( $donors as $donor ) { |
|
2040 | + foreach ($donors as $donor) { |
|
2041 | 2041 | |
2042 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2043 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2044 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2042 | + $donor_name = explode(' ', $donor->name, 2); |
|
2043 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2044 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2045 | 2045 | |
2046 | 2046 | // If first name meta of donor is not created, then create it. |
2047 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2048 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2047 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2048 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2049 | 2049 | } |
2050 | 2050 | |
2051 | 2051 | // If last name meta of donor is not created, then create it. |
2052 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2053 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2052 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2053 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2054 | 2054 | } |
2055 | 2055 | |
2056 | 2056 | // If Donor is connected with WP User then update user meta. |
2057 | - if ( $donor->user_id ) { |
|
2058 | - if ( isset( $donor_name[0] ) ) { |
|
2059 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2057 | + if ($donor->user_id) { |
|
2058 | + if (isset($donor_name[0])) { |
|
2059 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2060 | 2060 | } |
2061 | - if ( isset( $donor_name[1] ) ) { |
|
2062 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2061 | + if (isset($donor_name[1])) { |
|
2062 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2063 | 2063 | } |
2064 | 2064 | } |
2065 | 2065 | } |
2066 | 2066 | |
2067 | 2067 | } else { |
2068 | 2068 | // The Update Ran. |
2069 | - give_set_upgrade_complete( 'v20_upgrades_donor_name' ); |
|
2069 | + give_set_upgrade_complete('v20_upgrades_donor_name'); |
|
2070 | 2070 | } |
2071 | 2071 | |
2072 | 2072 | } |
@@ -2095,15 +2095,15 @@ discard block |
||
2095 | 2095 | |
2096 | 2096 | $users = $user_query->get_results(); |
2097 | 2097 | |
2098 | - if ( $users ) { |
|
2099 | - $give_updates->set_percentage( $user_query->get_total(), $give_updates->step * 100 ); |
|
2098 | + if ($users) { |
|
2099 | + $give_updates->set_percentage($user_query->get_total(), $give_updates->step * 100); |
|
2100 | 2100 | |
2101 | 2101 | // Loop through Donors |
2102 | - foreach ( $users as $user ) { |
|
2102 | + foreach ($users as $user) { |
|
2103 | 2103 | /* @var Give_Donor $donor */ |
2104 | - $donor = new Give_Donor( $user->ID, true ); |
|
2104 | + $donor = new Give_Donor($user->ID, true); |
|
2105 | 2105 | |
2106 | - if ( ! $donor->id ) { |
|
2106 | + if ( ! $donor->id) { |
|
2107 | 2107 | continue; |
2108 | 2108 | } |
2109 | 2109 | |
@@ -2119,10 +2119,10 @@ discard block |
||
2119 | 2119 | ) |
2120 | 2120 | ); |
2121 | 2121 | |
2122 | - if ( ! empty( $address ) ) { |
|
2123 | - $address = maybe_unserialize( $address ); |
|
2124 | - $donor->add_address( 'personal', $address ); |
|
2125 | - $donor->add_address( 'billing[]', $address ); |
|
2122 | + if ( ! empty($address)) { |
|
2123 | + $address = maybe_unserialize($address); |
|
2124 | + $donor->add_address('personal', $address); |
|
2125 | + $donor->add_address('billing[]', $address); |
|
2126 | 2126 | |
2127 | 2127 | |
2128 | 2128 | // @todo: delete _give_user_address from user meta after releases 2.0. |
@@ -2132,7 +2132,7 @@ discard block |
||
2132 | 2132 | |
2133 | 2133 | } else { |
2134 | 2134 | // The Update Ran. |
2135 | - give_set_upgrade_complete( 'v20_upgrades_user_address' ); |
|
2135 | + give_set_upgrade_complete('v20_upgrades_user_address'); |
|
2136 | 2136 | } |
2137 | 2137 | |
2138 | 2138 | } |
@@ -2156,15 +2156,15 @@ discard block |
||
2156 | 2156 | ); |
2157 | 2157 | |
2158 | 2158 | // Alter customer table |
2159 | - foreach ( $tables as $old_table => $new_table ) { |
|
2159 | + foreach ($tables as $old_table => $new_table) { |
|
2160 | 2160 | if ( |
2161 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $old_table ) ) && |
|
2162 | - ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $new_table ) ) |
|
2161 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $old_table)) && |
|
2162 | + ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $new_table)) |
|
2163 | 2163 | ) { |
2164 | - $wpdb->query( "ALTER TABLE {$old_table} RENAME TO {$new_table}" ); |
|
2164 | + $wpdb->query("ALTER TABLE {$old_table} RENAME TO {$new_table}"); |
|
2165 | 2165 | |
2166 | - if ( "{$wpdb->prefix}give_donormeta" === $new_table ) { |
|
2167 | - $wpdb->query( "ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)" ); |
|
2166 | + if ("{$wpdb->prefix}give_donormeta" === $new_table) { |
|
2167 | + $wpdb->query("ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)"); |
|
2168 | 2168 | } |
2169 | 2169 | } |
2170 | 2170 | } |
@@ -2172,7 +2172,7 @@ discard block |
||
2172 | 2172 | $give_updates->percentage = 100; |
2173 | 2173 | |
2174 | 2174 | // No more forms found, finish up. |
2175 | - give_set_upgrade_complete( 'v20_rename_donor_tables' ); |
|
2175 | + give_set_upgrade_complete('v20_rename_donor_tables'); |
|
2176 | 2176 | |
2177 | 2177 | // Re initiate donor classes. |
2178 | 2178 | Give()->donors = new Give_DB_Donors(); |
@@ -2187,22 +2187,22 @@ discard block |
||
2187 | 2187 | * @global wpdb $wpdb |
2188 | 2188 | * @return void |
2189 | 2189 | */ |
2190 | -function give_v201_create_tables(){ |
|
2190 | +function give_v201_create_tables() { |
|
2191 | 2191 | global $wpdb; |
2192 | 2192 | |
2193 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta" ) ) ) { |
|
2193 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta"))) { |
|
2194 | 2194 | Give()->payment_meta->create_table(); |
2195 | 2195 | } |
2196 | 2196 | |
2197 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta" ) ) ) { |
|
2197 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta"))) { |
|
2198 | 2198 | Give()->form_meta->create_table(); |
2199 | 2199 | } |
2200 | 2200 | |
2201 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs" ) ) ) { |
|
2201 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs"))) { |
|
2202 | 2202 | Give()->logs->log_db->create_table(); |
2203 | 2203 | } |
2204 | 2204 | |
2205 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta" ) ) ) { |
|
2205 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta"))) { |
|
2206 | 2206 | Give()->logs->logmeta_db->create_table(); |
2207 | 2207 | } |
2208 | 2208 | } |
@@ -2227,31 +2227,31 @@ discard block |
||
2227 | 2227 | $wpdb->posts.post_date >= '2018-01-08 00:00:00' |
2228 | 2228 | ) |
2229 | 2229 | AND $wpdb->posts.post_type = 'give_payment' |
2230 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2230 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2231 | 2231 | ORDER BY $wpdb->posts.post_date ASC |
2232 | 2232 | LIMIT 100 |
2233 | - OFFSET " . ( 1 === $give_updates->step ? 0 : ( $give_updates->step * 100 ) ) |
|
2233 | + OFFSET ".(1 === $give_updates->step ? 0 : ($give_updates->step * 100)) |
|
2234 | 2234 | ); |
2235 | 2235 | |
2236 | - if ( ! empty( $payments ) ) { |
|
2237 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_payment' ), ( $give_updates->step * 100 ) ); |
|
2236 | + if ( ! empty($payments)) { |
|
2237 | + $give_updates->set_percentage(give_get_total_post_type_count('give_payment'), ($give_updates->step * 100)); |
|
2238 | 2238 | |
2239 | - foreach ( $payments as $payment_id ) { |
|
2240 | - $post = get_post( $payment_id ); |
|
2241 | - setup_postdata( $post ); |
|
2239 | + foreach ($payments as $payment_id) { |
|
2240 | + $post = get_post($payment_id); |
|
2241 | + setup_postdata($post); |
|
2242 | 2242 | |
2243 | 2243 | // Do not add new meta keys if already refactored. |
2244 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id' ) ) ) { |
|
2244 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id'))) { |
|
2245 | 2245 | continue; |
2246 | 2246 | } |
2247 | 2247 | |
2248 | 2248 | |
2249 | 2249 | // Split _give_payment_meta meta. |
2250 | 2250 | // @todo Remove _give_payment_meta after releases 2.0 |
2251 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
2251 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
2252 | 2252 | |
2253 | - if ( ! empty( $payment_meta ) ) { |
|
2254 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
2253 | + if ( ! empty($payment_meta)) { |
|
2254 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
2255 | 2255 | } |
2256 | 2256 | |
2257 | 2257 | $deprecated_meta_keys = array( |
@@ -2260,9 +2260,9 @@ discard block |
||
2260 | 2260 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
2261 | 2261 | ); |
2262 | 2262 | |
2263 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
2263 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
2264 | 2264 | // Do not add new meta key if already exist. |
2265 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
2265 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
2266 | 2266 | continue; |
2267 | 2267 | } |
2268 | 2268 | |
@@ -2271,25 +2271,25 @@ discard block |
||
2271 | 2271 | array( |
2272 | 2272 | 'post_id' => $post->ID, |
2273 | 2273 | 'meta_key' => $new_meta_key, |
2274 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ) |
|
2274 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true) |
|
2275 | 2275 | ) |
2276 | 2276 | ); |
2277 | 2277 | } |
2278 | 2278 | |
2279 | 2279 | // Bailout |
2280 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
2280 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
2281 | 2281 | /* @var Give_Donor $donor */ |
2282 | - $donor = new Give_Donor( $donor_id ); |
|
2282 | + $donor = new Give_Donor($donor_id); |
|
2283 | 2283 | |
2284 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
2285 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
2286 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
2287 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
2288 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
2289 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
2284 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
2285 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
2286 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
2287 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
2288 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
2289 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
2290 | 2290 | |
2291 | 2291 | // Save address. |
2292 | - $donor->add_address( 'billing[]', $address ); |
|
2292 | + $donor->add_address('billing[]', $address); |
|
2293 | 2293 | } |
2294 | 2294 | |
2295 | 2295 | }// End while(). |
@@ -2300,7 +2300,7 @@ discard block |
||
2300 | 2300 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
2301 | 2301 | |
2302 | 2302 | // No more forms found, finish up. |
2303 | - give_set_upgrade_complete( 'v201_upgrades_payment_metadata' ); |
|
2303 | + give_set_upgrade_complete('v201_upgrades_payment_metadata'); |
|
2304 | 2304 | } |
2305 | 2305 | } |
2306 | 2306 | |
@@ -2320,18 +2320,18 @@ discard block |
||
2320 | 2320 | SELECT ID FROM $wpdb->posts |
2321 | 2321 | WHERE 1=1 |
2322 | 2322 | AND ( $wpdb->posts.post_type = 'give_payment' OR $wpdb->posts.post_type = 'give_forms' ) |
2323 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2323 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2324 | 2324 | ORDER BY $wpdb->posts.post_date ASC |
2325 | 2325 | LIMIT 100 |
2326 | - OFFSET " . ( 1 === $give_updates->step ? 0 : ( $give_updates->step * 100 ) ) |
|
2326 | + OFFSET ".(1 === $give_updates->step ? 0 : ($give_updates->step * 100)) |
|
2327 | 2327 | ); |
2328 | 2328 | |
2329 | - if ( ! empty( $payments ) ) { |
|
2330 | - $give_updates->set_percentage( give_get_total_post_type_count( array( 'give_forms', 'give_payment' ) ), $give_updates->step * 100 ); |
|
2329 | + if ( ! empty($payments)) { |
|
2330 | + $give_updates->set_percentage(give_get_total_post_type_count(array('give_forms', 'give_payment')), $give_updates->step * 100); |
|
2331 | 2331 | |
2332 | - foreach ( $payments as $payment_id ) { |
|
2333 | - $post = get_post( $payment_id ); |
|
2334 | - setup_postdata( $post ); |
|
2332 | + foreach ($payments as $payment_id) { |
|
2333 | + $post = get_post($payment_id); |
|
2334 | + setup_postdata($post); |
|
2335 | 2335 | |
2336 | 2336 | $meta_data = $wpdb->get_results( |
2337 | 2337 | $wpdb->prepare( |
@@ -2341,19 +2341,19 @@ discard block |
||
2341 | 2341 | ARRAY_A |
2342 | 2342 | ); |
2343 | 2343 | |
2344 | - if ( ! empty( $meta_data ) ) { |
|
2345 | - foreach ( $meta_data as $index => $data ) { |
|
2344 | + if ( ! empty($meta_data)) { |
|
2345 | + foreach ($meta_data as $index => $data) { |
|
2346 | 2346 | // Check for duplicate meta values. |
2347 | - if( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
2347 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
2348 | 2348 | continue; |
2349 | 2349 | } |
2350 | 2350 | |
2351 | - switch ( $post->post_type ) { |
|
2351 | + switch ($post->post_type) { |
|
2352 | 2352 | case 'give_forms': |
2353 | 2353 | $data['form_id'] = $data['post_id']; |
2354 | - unset( $data['post_id'] ); |
|
2354 | + unset($data['post_id']); |
|
2355 | 2355 | |
2356 | - Give()->form_meta->insert( $data ); |
|
2356 | + Give()->form_meta->insert($data); |
|
2357 | 2357 | // @todo: delete form meta from post meta table after releases 2.0. |
2358 | 2358 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2359 | 2359 | |
@@ -2361,9 +2361,9 @@ discard block |
||
2361 | 2361 | |
2362 | 2362 | case 'give_payment': |
2363 | 2363 | $data['payment_id'] = $data['post_id']; |
2364 | - unset( $data['post_id'] ); |
|
2364 | + unset($data['post_id']); |
|
2365 | 2365 | |
2366 | - Give()->payment_meta->insert( $data ); |
|
2366 | + Give()->payment_meta->insert($data); |
|
2367 | 2367 | |
2368 | 2368 | // @todo: delete donation meta from post meta table after releases 2.0. |
2369 | 2369 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2378,7 +2378,7 @@ discard block |
||
2378 | 2378 | wp_reset_postdata(); |
2379 | 2379 | } else { |
2380 | 2380 | // No more forms found, finish up. |
2381 | - give_set_upgrade_complete( 'v201_move_metadata_into_new_table' ); |
|
2381 | + give_set_upgrade_complete('v201_move_metadata_into_new_table'); |
|
2382 | 2382 | } |
2383 | 2383 | |
2384 | 2384 | } |
@@ -2399,26 +2399,26 @@ discard block |
||
2399 | 2399 | SELECT ID FROM $wpdb->posts |
2400 | 2400 | WHERE 1=1 |
2401 | 2401 | AND $wpdb->posts.post_type = 'give_log' |
2402 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2402 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2403 | 2403 | ORDER BY $wpdb->posts.post_date ASC |
2404 | 2404 | LIMIT 100 |
2405 | - OFFSET " . ( 1 === $give_updates->step ? 0 : ( $give_updates->step * 100 ) ) |
|
2405 | + OFFSET ".(1 === $give_updates->step ? 0 : ($give_updates->step * 100)) |
|
2406 | 2406 | ); |
2407 | 2407 | |
2408 | - if ( ! empty( $logs ) ) { |
|
2409 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_log' ), $give_updates->step * 100 ); |
|
2408 | + if ( ! empty($logs)) { |
|
2409 | + $give_updates->set_percentage(give_get_total_post_type_count('give_log'), $give_updates->step * 100); |
|
2410 | 2410 | |
2411 | - foreach ( $logs as $log_id ) { |
|
2412 | - $post = get_post( $log_id ); |
|
2413 | - setup_postdata( $post ); |
|
2411 | + foreach ($logs as $log_id) { |
|
2412 | + $post = get_post($log_id); |
|
2413 | + setup_postdata($post); |
|
2414 | 2414 | |
2415 | - if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
2415 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
2416 | 2416 | continue; |
2417 | 2417 | } |
2418 | 2418 | |
2419 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
2420 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
2421 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
2419 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
2420 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
2421 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
2422 | 2422 | |
2423 | 2423 | $log_data = array( |
2424 | 2424 | 'ID' => $post->ID, |
@@ -2431,29 +2431,29 @@ discard block |
||
2431 | 2431 | ); |
2432 | 2432 | $log_meta = array(); |
2433 | 2433 | |
2434 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
2435 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
2436 | - switch ( $meta_key ) { |
|
2434 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
2435 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
2436 | + switch ($meta_key) { |
|
2437 | 2437 | case '_give_log_payment_id': |
2438 | - $log_data['log_parent'] = current( $meta_value ); |
|
2438 | + $log_data['log_parent'] = current($meta_value); |
|
2439 | 2439 | $log_meta['_give_log_form_id'] = $post->post_parent; |
2440 | 2440 | break; |
2441 | 2441 | |
2442 | 2442 | default: |
2443 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
2443 | + $log_meta[$meta_key] = current($meta_value); |
|
2444 | 2444 | } |
2445 | 2445 | } |
2446 | 2446 | } |
2447 | 2447 | |
2448 | - if ( 'api_request' === $term_name ) { |
|
2448 | + if ('api_request' === $term_name) { |
|
2449 | 2449 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
2450 | 2450 | } |
2451 | 2451 | |
2452 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
2452 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
2453 | 2453 | |
2454 | - if ( ! empty( $log_meta ) ) { |
|
2455 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
2456 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
2454 | + if ( ! empty($log_meta)) { |
|
2455 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
2456 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
2457 | 2457 | } |
2458 | 2458 | } |
2459 | 2459 | |
@@ -2466,7 +2466,7 @@ discard block |
||
2466 | 2466 | Give()->logs->delete_cache(); |
2467 | 2467 | |
2468 | 2468 | // No more forms found, finish up. |
2469 | - give_set_upgrade_complete( 'v201_logs_upgrades' ); |
|
2469 | + give_set_upgrade_complete('v201_logs_upgrades'); |
|
2470 | 2470 | } |
2471 | 2471 | } |
2472 | 2472 | |
@@ -2477,55 +2477,55 @@ discard block |
||
2477 | 2477 | * @since 2.0.1 |
2478 | 2478 | * @return void |
2479 | 2479 | */ |
2480 | -function give_v201_add_missing_donors_callback(){ |
|
2480 | +function give_v201_add_missing_donors_callback() { |
|
2481 | 2481 | global $wpdb; |
2482 | 2482 | give_v201_create_tables(); |
2483 | 2483 | |
2484 | - if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) ) ) { |
|
2485 | - $customers = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_customers" ), 'id' ); |
|
2486 | - $donors = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_donors" ), 'id' ); |
|
2484 | + if ($wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))) { |
|
2485 | + $customers = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_customers"), 'id'); |
|
2486 | + $donors = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_donors"), 'id'); |
|
2487 | 2487 | $donor_data = array(); |
2488 | 2488 | |
2489 | - if ( $missing_donors = array_diff( $customers, $donors ) ) { |
|
2490 | - foreach ( $missing_donors as $donor_id ) { |
|
2489 | + if ($missing_donors = array_diff($customers, $donors)) { |
|
2490 | + foreach ($missing_donors as $donor_id) { |
|
2491 | 2491 | $donor_data[] = array( |
2492 | - 'info' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id ) ), |
|
2493 | - 'meta' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id ) ), |
|
2492 | + 'info' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id)), |
|
2493 | + 'meta' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id)), |
|
2494 | 2494 | |
2495 | 2495 | ); |
2496 | 2496 | } |
2497 | 2497 | } |
2498 | 2498 | |
2499 | - if( ! empty( $donor_data ) ) { |
|
2499 | + if ( ! empty($donor_data)) { |
|
2500 | 2500 | $donor_table_name = Give()->donors->table_name; |
2501 | 2501 | $donor_meta_table_name = Give()->donor_meta->table_name; |
2502 | 2502 | |
2503 | 2503 | Give()->donors->table_name = "{$wpdb->prefix}give_donors"; |
2504 | 2504 | Give()->donor_meta->table_name = "{$wpdb->prefix}give_donormeta"; |
2505 | 2505 | |
2506 | - foreach ( $donor_data as $donor ) { |
|
2506 | + foreach ($donor_data as $donor) { |
|
2507 | 2507 | $donor['info'][0] = (array) $donor['info'][0]; |
2508 | 2508 | |
2509 | 2509 | // Prevent duplicate meta id issue. |
2510 | - if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id'] ) ) ){ |
|
2510 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id']))) { |
|
2511 | 2511 | continue; |
2512 | 2512 | } |
2513 | 2513 | |
2514 | - $donor_id = Give()->donors->add( $donor['info'][0] ); |
|
2514 | + $donor_id = Give()->donors->add($donor['info'][0]); |
|
2515 | 2515 | |
2516 | - if( ! empty( $donor['meta'] ) ) { |
|
2517 | - foreach ( $donor['meta'] as $donor_meta ) { |
|
2516 | + if ( ! empty($donor['meta'])) { |
|
2517 | + foreach ($donor['meta'] as $donor_meta) { |
|
2518 | 2518 | $donor_meta = (array) $donor_meta; |
2519 | 2519 | |
2520 | 2520 | // Prevent duplicate meta id issue. |
2521 | - if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id'] ) ) ){ |
|
2522 | - unset( $donor_meta['meta_id'] ); |
|
2521 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id']))) { |
|
2522 | + unset($donor_meta['meta_id']); |
|
2523 | 2523 | } |
2524 | 2524 | |
2525 | 2525 | $donor_meta['donor_id'] = $donor_meta['customer_id']; |
2526 | - unset( $donor_meta['customer_id'] ); |
|
2526 | + unset($donor_meta['customer_id']); |
|
2527 | 2527 | |
2528 | - Give()->donor_meta->insert( $donor_meta ); |
|
2528 | + Give()->donor_meta->insert($donor_meta); |
|
2529 | 2529 | } |
2530 | 2530 | } |
2531 | 2531 | |
@@ -2544,35 +2544,35 @@ discard block |
||
2544 | 2544 | ) |
2545 | 2545 | ); |
2546 | 2546 | |
2547 | - $donor = new Give_Donor( $donor_id ); |
|
2547 | + $donor = new Give_Donor($donor_id); |
|
2548 | 2548 | |
2549 | - if ( ! empty( $address ) ) { |
|
2550 | - $address = maybe_unserialize( $address ); |
|
2551 | - $donor->add_address( 'personal', $address ); |
|
2552 | - $donor->add_address( 'billing[]', $address ); |
|
2549 | + if ( ! empty($address)) { |
|
2550 | + $address = maybe_unserialize($address); |
|
2551 | + $donor->add_address('personal', $address); |
|
2552 | + $donor->add_address('billing[]', $address); |
|
2553 | 2553 | } |
2554 | 2554 | |
2555 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2556 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2557 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2555 | + $donor_name = explode(' ', $donor->name, 2); |
|
2556 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2557 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2558 | 2558 | |
2559 | 2559 | // If first name meta of donor is not created, then create it. |
2560 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2561 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2560 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2561 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2562 | 2562 | } |
2563 | 2563 | |
2564 | 2564 | // If last name meta of donor is not created, then create it. |
2565 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2566 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2565 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2566 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2567 | 2567 | } |
2568 | 2568 | |
2569 | 2569 | // If Donor is connected with WP User then update user meta. |
2570 | - if ( $donor->user_id ) { |
|
2571 | - if ( isset( $donor_name[0] ) ) { |
|
2572 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2570 | + if ($donor->user_id) { |
|
2571 | + if (isset($donor_name[0])) { |
|
2572 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2573 | 2573 | } |
2574 | - if ( isset( $donor_name[1] ) ) { |
|
2575 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2574 | + if (isset($donor_name[1])) { |
|
2575 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2576 | 2576 | } |
2577 | 2577 | } |
2578 | 2578 | } |
@@ -2583,7 +2583,7 @@ discard block |
||
2583 | 2583 | } |
2584 | 2584 | |
2585 | 2585 | Give_Updates::get_instance()->percentage = 100; |
2586 | - give_set_upgrade_complete('v201_add_missing_donors' ); |
|
2586 | + give_set_upgrade_complete('v201_add_missing_donors'); |
|
2587 | 2587 | } |
2588 | 2588 | |
2589 | 2589 | |
@@ -2592,18 +2592,18 @@ discard block |
||
2592 | 2592 | * |
2593 | 2593 | * @since 2.0.3 |
2594 | 2594 | */ |
2595 | -function give_v203_upgrades(){ |
|
2595 | +function give_v203_upgrades() { |
|
2596 | 2596 | global $wpdb; |
2597 | 2597 | |
2598 | 2598 | // Do not auto load option. |
2599 | - $wpdb->update( $wpdb->options, array( 'autoload' => 'no' ), array( 'option_name' => 'give_completed_upgrades' ) ); |
|
2599 | + $wpdb->update($wpdb->options, array('autoload' => 'no'), array('option_name' => 'give_completed_upgrades')); |
|
2600 | 2600 | |
2601 | 2601 | // Remove from cache. |
2602 | 2602 | $all_options = wp_load_alloptions(); |
2603 | 2603 | |
2604 | - if( isset( $all_options['give_completed_upgrades'] ) ) { |
|
2605 | - unset( $all_options['give_completed_upgrades'] ); |
|
2606 | - wp_cache_set( 'alloptions', $all_options, 'options' ); |
|
2604 | + if (isset($all_options['give_completed_upgrades'])) { |
|
2605 | + unset($all_options['give_completed_upgrades']); |
|
2606 | + wp_cache_set('alloptions', $all_options, 'options'); |
|
2607 | 2607 | } |
2608 | 2608 | |
2609 | 2609 | } |
2610 | 2610 | \ No newline at end of file |
@@ -80,34 +80,34 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param array $args |
82 | 82 | */ |
83 | - public function register( $args ) { |
|
83 | + public function register($args) { |
|
84 | 84 | $args_default = array( |
85 | 85 | 'id' => '', |
86 | 86 | 'version' => '', |
87 | 87 | 'callback' => '', |
88 | 88 | ); |
89 | 89 | |
90 | - $args = wp_parse_args( $args, $args_default ); |
|
90 | + $args = wp_parse_args($args, $args_default); |
|
91 | 91 | |
92 | 92 | // You can only register database upgrade. |
93 | 93 | $args['type'] = 'database'; |
94 | 94 | |
95 | 95 | // Bailout. |
96 | 96 | if ( |
97 | - empty( $args['id'] ) || |
|
98 | - empty( $args['version'] ) || |
|
99 | - empty( $args['callback'] ) || |
|
100 | - ! is_callable( $args['callback'] ) |
|
97 | + empty($args['id']) || |
|
98 | + empty($args['version']) || |
|
99 | + empty($args['callback']) || |
|
100 | + ! is_callable($args['callback']) |
|
101 | 101 | ) { |
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
105 | 105 | // Change depend param to array. |
106 | - if ( isset( $args['depend'] ) && is_string( $args['depend'] ) ) { |
|
107 | - $args['depend'] = array( $args['depend'] ); |
|
106 | + if (isset($args['depend']) && is_string($args['depend'])) { |
|
107 | + $args['depend'] = array($args['depend']); |
|
108 | 108 | } |
109 | 109 | |
110 | - $this->updates[ $args['type'] ][] = $args; |
|
110 | + $this->updates[$args['type']][] = $args; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return static |
119 | 119 | */ |
120 | 120 | static function get_instance() { |
121 | - if ( is_null( self::$instance ) ) { |
|
121 | + if (is_null(self::$instance)) { |
|
122 | 122 | self::$instance = new self(); |
123 | 123 | } |
124 | 124 | |
@@ -136,27 +136,27 @@ discard block |
||
136 | 136 | /** |
137 | 137 | * Load file |
138 | 138 | */ |
139 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-background-updater.php'; |
|
140 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
139 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-background-updater.php'; |
|
140 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
141 | 141 | |
142 | 142 | self::$background_updater = new Give_Background_Updater(); |
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Setup hooks. |
146 | 146 | */ |
147 | - add_action( 'init', array( $this, '__register_upgrade' ), 9999 ); |
|
148 | - add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 ); |
|
149 | - add_action( 'wp_ajax_give_db_updates_info', array( $this, '__give_db_updates_info' ) ); |
|
150 | - add_action( 'wp_ajax_give_run_db_updates', array( $this, '__give_start_updating' ) ); |
|
151 | - add_action( 'admin_init', array( $this, '__redirect_admin' ) ); |
|
152 | - add_action( 'admin_init', array( $this, '__pause_db_update' ), - 1 ); |
|
153 | - add_action( 'admin_init', array( $this, '__restart_db_update' ), - 1 ); |
|
154 | - add_action( 'admin_notices', array( $this, '__show_notice' ) ); |
|
155 | - add_action( 'give_restart_db_upgrade', array( $this, '__health_background_update' ) ); |
|
156 | - |
|
157 | - if ( is_admin() ) { |
|
158 | - add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 ); |
|
159 | - add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 ); |
|
147 | + add_action('init', array($this, '__register_upgrade'), 9999); |
|
148 | + add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999); |
|
149 | + add_action('wp_ajax_give_db_updates_info', array($this, '__give_db_updates_info')); |
|
150 | + add_action('wp_ajax_give_run_db_updates', array($this, '__give_start_updating')); |
|
151 | + add_action('admin_init', array($this, '__redirect_admin')); |
|
152 | + add_action('admin_init', array($this, '__pause_db_update'), - 1); |
|
153 | + add_action('admin_init', array($this, '__restart_db_update'), - 1); |
|
154 | + add_action('admin_notices', array($this, '__show_notice')); |
|
155 | + add_action('give_restart_db_upgrade', array($this, '__health_background_update')); |
|
156 | + |
|
157 | + if (is_admin()) { |
|
158 | + add_action('admin_init', array($this, '__change_donations_label'), 9999); |
|
159 | + add_action('admin_menu', array($this, '__register_menu'), 9999); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | $addons = give_get_plugins(); |
171 | 171 | $plugin_updates = get_plugin_updates(); |
172 | 172 | |
173 | - foreach ( $addons as $key => $info ) { |
|
174 | - if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) { |
|
173 | + foreach ($addons as $key => $info) { |
|
174 | + if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) { |
|
175 | 175 | continue; |
176 | 176 | } |
177 | 177 | |
178 | - $this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] ); |
|
178 | + $this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @access public |
188 | 188 | */ |
189 | 189 | public function __register_upgrade() { |
190 | - if ( ! is_admin() ) { |
|
190 | + if ( ! is_admin()) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @since 1.8.12 |
198 | 198 | */ |
199 | - do_action( 'give_register_updates', $this ); |
|
199 | + do_action('give_register_updates', $this); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -209,23 +209,22 @@ discard block |
||
209 | 209 | global $menu; |
210 | 210 | |
211 | 211 | // Bailout. |
212 | - if ( empty( $menu ) || ! $this->get_total_update_count() ) { |
|
212 | + if (empty($menu) || ! $this->get_total_update_count()) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
216 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
217 | 217 | |
218 | - foreach ( $menu as $index => $menu_item ) { |
|
219 | - if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) { |
|
218 | + foreach ($menu as $index => $menu_item) { |
|
219 | + if ('edit.php?post_type=give_forms' !== $menu_item[2]) { |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | |
223 | - $menu[ $index ][0] = sprintf( |
|
223 | + $menu[$index][0] = sprintf( |
|
224 | 224 | '%1$s <span class="update-plugins"><span class="plugin-count give-update-progress-count">%2$s%3$s</span></span>', |
225 | - __( 'Donations', 'give' ), |
|
225 | + __('Donations', 'give'), |
|
226 | 226 | $is_update ? |
227 | - $this->get_db_update_processing_percentage() : |
|
228 | - $this->get_total_update_count(), |
|
227 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
229 | 228 | $is_update ? '%' : '' |
230 | 229 | ); |
231 | 230 | |
@@ -241,7 +240,7 @@ discard block |
||
241 | 240 | */ |
242 | 241 | public function __register_menu() { |
243 | 242 | // Bailout. |
244 | - if ( ! give_test_ajax_works() ) { |
|
243 | + if ( ! give_test_ajax_works()) { |
|
245 | 244 | return; |
246 | 245 | } |
247 | 246 | |
@@ -249,41 +248,40 @@ discard block |
||
249 | 248 | $this->__register_plugin_addon_updates(); |
250 | 249 | |
251 | 250 | // Bailout. |
252 | - if ( ! $this->get_total_update_count() ) { |
|
251 | + if ( ! $this->get_total_update_count()) { |
|
253 | 252 | // Show complete update message if still on update setting page. |
254 | - if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) { |
|
253 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
255 | 254 | // Upgrades |
256 | 255 | add_submenu_page( |
257 | 256 | 'edit.php?post_type=give_forms', |
258 | - esc_html__( 'Give Updates Complete', 'give' ), |
|
259 | - __( 'Updates', 'give' ), |
|
257 | + esc_html__('Give Updates Complete', 'give'), |
|
258 | + __('Updates', 'give'), |
|
260 | 259 | 'manage_give_settings', |
261 | 260 | 'give-updates', |
262 | - array( $this, 'render_complete_page' ) |
|
261 | + array($this, 'render_complete_page') |
|
263 | 262 | ); |
264 | 263 | } |
265 | 264 | |
266 | 265 | return; |
267 | 266 | } |
268 | 267 | |
269 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
268 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
270 | 269 | |
271 | 270 | // Upgrades |
272 | 271 | add_submenu_page( |
273 | 272 | 'edit.php?post_type=give_forms', |
274 | - esc_html__( 'Give Updates', 'give' ), |
|
273 | + esc_html__('Give Updates', 'give'), |
|
275 | 274 | sprintf( |
276 | 275 | '%1$s <span class="update-plugins"%2$s><span class="plugin-count give-update-progress-count">%3$s%4$s</span></span>', |
277 | - __( 'Updates', 'give' ), |
|
278 | - isset( $_GET['give-pause-db-upgrades'] ) ? ' style="display:none;"' : '', |
|
276 | + __('Updates', 'give'), |
|
277 | + isset($_GET['give-pause-db-upgrades']) ? ' style="display:none;"' : '', |
|
279 | 278 | $is_update ? |
280 | - $this->get_db_update_processing_percentage() : |
|
281 | - $this->get_total_update_count(), |
|
279 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
282 | 280 | $is_update ? '%' : '' |
283 | 281 | ), |
284 | 282 | 'manage_give_settings', |
285 | 283 | 'give-updates', |
286 | - array( $this, 'render_page' ) |
|
284 | + array($this, 'render_page') |
|
287 | 285 | ); |
288 | 286 | } |
289 | 287 | |
@@ -298,13 +296,13 @@ discard block |
||
298 | 296 | // Show db upgrade completed notice. |
299 | 297 | if ( |
300 | 298 | ! wp_doing_ajax() && |
301 | - current_user_can( 'manage_give_settings' ) && |
|
302 | - get_option( 'give_show_db_upgrade_complete_notice' ) && |
|
303 | - ! isset( $_GET['give-db-update-completed'] ) |
|
299 | + current_user_can('manage_give_settings') && |
|
300 | + get_option('give_show_db_upgrade_complete_notice') && |
|
301 | + ! isset($_GET['give-db-update-completed']) |
|
304 | 302 | ) { |
305 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
303 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
306 | 304 | |
307 | - wp_redirect( add_query_arg( array( 'give-db-update-completed' => 'give_db_upgrade_completed' ) ) ); |
|
305 | + wp_redirect(add_query_arg(array('give-db-update-completed' => 'give_db_upgrade_completed'))); |
|
308 | 306 | exit(); |
309 | 307 | } |
310 | 308 | } |
@@ -320,15 +318,15 @@ discard block |
||
320 | 318 | * |
321 | 319 | * @return bool |
322 | 320 | */ |
323 | - public function __pause_db_update( $force = false ) { |
|
321 | + public function __pause_db_update($force = false) { |
|
324 | 322 | // Bailout. |
325 | 323 | if ( |
326 | 324 | ! $force && |
327 | 325 | ( |
328 | 326 | wp_doing_ajax() || |
329 | - ! isset( $_GET['page'] ) || |
|
327 | + ! isset($_GET['page']) || |
|
330 | 328 | 'give-updates' !== $_GET['page'] || |
331 | - ! isset( $_GET['give-pause-db-upgrades'] ) || |
|
329 | + ! isset($_GET['give-pause-db-upgrades']) || |
|
332 | 330 | self::$background_updater->is_paused_process() || |
333 | 331 | ! self::$background_updater->has_queue() |
334 | 332 | ) |
@@ -337,13 +335,13 @@ discard block |
||
337 | 335 | return false; |
338 | 336 | } |
339 | 337 | |
340 | - delete_option( 'give_upgrade_error' ); |
|
338 | + delete_option('give_upgrade_error'); |
|
341 | 339 | |
342 | - $this->__health_background_update( $this ); |
|
340 | + $this->__health_background_update($this); |
|
343 | 341 | $batch = self::$background_updater->get_all_batch(); |
344 | 342 | |
345 | 343 | // Bailout: if batch is empty |
346 | - if ( empty( $batch->data ) ) { |
|
344 | + if (empty($batch->data)) { |
|
347 | 345 | return false; |
348 | 346 | } |
349 | 347 | |
@@ -352,25 +350,25 @@ discard block |
||
352 | 350 | |
353 | 351 | // Do not stop background process immediately if task running. |
354 | 352 | // @see Give_Background_Updater::lock_process |
355 | - if ( ! $force && self::$background_updater->is_process_running() ) { |
|
356 | - update_option( 'give_pause_upgrade', 1 ); |
|
353 | + if ( ! $force && self::$background_updater->is_process_running()) { |
|
354 | + update_option('give_pause_upgrade', 1); |
|
357 | 355 | |
358 | 356 | return true; |
359 | 357 | } |
360 | 358 | |
361 | - update_option( 'give_paused_batches', $batch, 'no' ); |
|
362 | - delete_option( $batch->key ); |
|
363 | - delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' ); |
|
364 | - wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() ); |
|
359 | + update_option('give_paused_batches', $batch, 'no'); |
|
360 | + delete_option($batch->key); |
|
361 | + delete_site_transient(self::$background_updater->get_identifier().'_process_lock'); |
|
362 | + wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier()); |
|
365 | 363 | |
366 | - Give()->logs->add( 'Update Pause', print_r( $batch, true ), 0, 'update' ); |
|
364 | + Give()->logs->add('Update Pause', print_r($batch, true), 0, 'update'); |
|
367 | 365 | |
368 | 366 | /** |
369 | 367 | * Fire action when pause db updates |
370 | 368 | * |
371 | 369 | * @since 2.0.1 |
372 | 370 | */ |
373 | - do_action( 'give_pause_db_upgrade', $this ); |
|
371 | + do_action('give_pause_db_upgrade', $this); |
|
374 | 372 | |
375 | 373 | return true; |
376 | 374 | } |
@@ -387,31 +385,31 @@ discard block |
||
387 | 385 | // Bailout. |
388 | 386 | if ( |
389 | 387 | wp_doing_ajax() || |
390 | - ! isset( $_GET['page'] ) || |
|
388 | + ! isset($_GET['page']) || |
|
391 | 389 | 'give-updates' !== $_GET['page'] || |
392 | - ! isset( $_GET['give-restart-db-upgrades'] ) || |
|
390 | + ! isset($_GET['give-restart-db-upgrades']) || |
|
393 | 391 | ! self::$background_updater->is_paused_process() |
394 | 392 | ) { |
395 | 393 | return false; |
396 | 394 | } |
397 | 395 | |
398 | 396 | Give_Background_Updater::flush_cache(); |
399 | - $batch = get_option( 'give_paused_batches' ); |
|
397 | + $batch = get_option('give_paused_batches'); |
|
400 | 398 | |
401 | - if ( ! empty( $batch ) ) { |
|
402 | - wp_cache_delete( $batch->key, 'options' ); |
|
403 | - update_option( $batch->key, $batch->data ); |
|
399 | + if ( ! empty($batch)) { |
|
400 | + wp_cache_delete($batch->key, 'options'); |
|
401 | + update_option($batch->key, $batch->data); |
|
404 | 402 | |
405 | - delete_option( 'give_paused_batches' ); |
|
403 | + delete_option('give_paused_batches'); |
|
406 | 404 | |
407 | - Give()->logs->add( 'Update Restart', print_r( $batch, true ), 0, 'update' ); |
|
405 | + Give()->logs->add('Update Restart', print_r($batch, true), 0, 'update'); |
|
408 | 406 | |
409 | 407 | |
410 | 408 | /** Fire action when restart db updates |
411 | 409 | * |
412 | 410 | * @since 2.0.1 |
413 | 411 | */ |
414 | - do_action( 'give_restart_db_upgrade', $this ); |
|
412 | + do_action('give_restart_db_upgrade', $this); |
|
415 | 413 | |
416 | 414 | self::$background_updater->dispatch(); |
417 | 415 | } |
@@ -427,53 +425,53 @@ discard block |
||
427 | 425 | * |
428 | 426 | * @param Give_Updates $give_updates |
429 | 427 | */ |
430 | - public function __health_background_update( $give_updates ) { |
|
431 | - if ( ! $this->is_doing_updates() ) { |
|
428 | + public function __health_background_update($give_updates) { |
|
429 | + if ( ! $this->is_doing_updates()) { |
|
432 | 430 | return; |
433 | 431 | } |
434 | 432 | |
435 | 433 | Give_Background_Updater::flush_cache(); |
436 | 434 | |
437 | 435 | $batch = Give_Updates::$background_updater->get_all_batch(); |
438 | - $batch_data_count = count( $batch->data ); |
|
439 | - $all_updates = $give_updates->get_updates( 'database', 'all' ); |
|
440 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
441 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
436 | + $batch_data_count = count($batch->data); |
|
437 | + $all_updates = $give_updates->get_updates('database', 'all'); |
|
438 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
439 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
442 | 440 | $log_data = ''; |
443 | - $doing_upgrade_args = get_option( 'give_doing_upgrade' ); |
|
441 | + $doing_upgrade_args = get_option('give_doing_upgrade'); |
|
444 | 442 | |
445 | - if ( ! empty( $doing_upgrade_args ) ) { |
|
446 | - $log_data .= 'Doing update:' . "\n"; |
|
447 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
443 | + if ( ! empty($doing_upgrade_args)) { |
|
444 | + $log_data .= 'Doing update:'."\n"; |
|
445 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
448 | 446 | } |
449 | 447 | |
450 | 448 | /** |
451 | 449 | * Add remove upgrade from batch |
452 | 450 | */ |
453 | - if ( ! empty( $batch->data ) ) { |
|
451 | + if ( ! empty($batch->data)) { |
|
454 | 452 | |
455 | - foreach ( $batch->data as $index => $update ) { |
|
456 | - $log_data = print_r( $update, true ) . "\n"; |
|
453 | + foreach ($batch->data as $index => $update) { |
|
454 | + $log_data = print_r($update, true)."\n"; |
|
457 | 455 | |
458 | - if ( ! is_callable( $update['callback'] ) ) { |
|
459 | - $log_data .= 'Removing missing callback update: ' . "{$update['id']}\n"; |
|
460 | - unset( $batch->data[ $index ] ); |
|
461 | - } elseif ( give_has_upgrade_completed( $update['id'] ) ) { |
|
462 | - $log_data .= 'Removing already completed update: ' . "{$update['id']}\n"; |
|
463 | - unset( $batch->data[ $index ] ); |
|
456 | + if ( ! is_callable($update['callback'])) { |
|
457 | + $log_data .= 'Removing missing callback update: '."{$update['id']}\n"; |
|
458 | + unset($batch->data[$index]); |
|
459 | + } elseif (give_has_upgrade_completed($update['id'])) { |
|
460 | + $log_data .= 'Removing already completed update: '."{$update['id']}\n"; |
|
461 | + unset($batch->data[$index]); |
|
464 | 462 | } |
465 | 463 | |
466 | - if ( ! empty( $update['depend'] ) ) { |
|
464 | + if ( ! empty($update['depend'])) { |
|
467 | 465 | |
468 | - foreach ( $update['depend'] as $depend ) { |
|
469 | - if ( give_has_upgrade_completed( $depend ) ) { |
|
470 | - $log_data .= 'Completed update: ' . "{$depend}\n"; |
|
466 | + foreach ($update['depend'] as $depend) { |
|
467 | + if (give_has_upgrade_completed($depend)) { |
|
468 | + $log_data .= 'Completed update: '."{$depend}\n"; |
|
471 | 469 | continue; |
472 | 470 | } |
473 | 471 | |
474 | - if ( in_array( $depend, $all_update_ids ) && ! in_array( $depend, $all_batch_update_ids ) ) { |
|
475 | - $log_data .= 'Adding missing update: ' . "{$depend}\n"; |
|
476 | - array_unshift( $batch->data, $all_updates[ array_search( $depend, $all_update_ids ) ] ); |
|
472 | + if (in_array($depend, $all_update_ids) && ! in_array($depend, $all_batch_update_ids)) { |
|
473 | + $log_data .= 'Adding missing update: '."{$depend}\n"; |
|
474 | + array_unshift($batch->data, $all_updates[array_search($depend, $all_update_ids)]); |
|
477 | 475 | } |
478 | 476 | } |
479 | 477 | } |
@@ -483,60 +481,60 @@ discard block |
||
483 | 481 | /** |
484 | 482 | * Add new upgrade to batch |
485 | 483 | */ |
486 | - if ( $new_updates = $this->get_updates( 'database', 'new' ) ) { |
|
487 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
484 | + if ($new_updates = $this->get_updates('database', 'new')) { |
|
485 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
488 | 486 | |
489 | - foreach ( $new_updates as $index => $new_update ) { |
|
490 | - if ( give_has_upgrade_completed( $new_update['id'] ) || in_array( $new_update['id'], $all_batch_update_ids ) ) { |
|
491 | - unset( $new_updates[ $index ] ); |
|
487 | + foreach ($new_updates as $index => $new_update) { |
|
488 | + if (give_has_upgrade_completed($new_update['id']) || in_array($new_update['id'], $all_batch_update_ids)) { |
|
489 | + unset($new_updates[$index]); |
|
492 | 490 | } |
493 | 491 | } |
494 | 492 | |
495 | - if ( ! empty( $new_updates ) ) { |
|
496 | - $log_data .= 'Adding new update: ' . "\n"; |
|
497 | - $log_data .= print_r( $new_updates, true ) . "\n"; |
|
493 | + if ( ! empty($new_updates)) { |
|
494 | + $log_data .= 'Adding new update: '."\n"; |
|
495 | + $log_data .= print_r($new_updates, true)."\n"; |
|
498 | 496 | |
499 | - $batch->data = array_merge( (array) $batch->data, $new_updates ); |
|
500 | - update_option( 'give_db_update_count', ( absint( get_option( 'give_db_update_count' ) ) + count( $new_updates ) ) ); |
|
497 | + $batch->data = array_merge((array) $batch->data, $new_updates); |
|
498 | + update_option('give_db_update_count', (absint(get_option('give_db_update_count')) + count($new_updates))); |
|
501 | 499 | } |
502 | 500 | } |
503 | 501 | |
504 | 502 | /** |
505 | 503 | * Fix batch |
506 | 504 | */ |
507 | - if ( empty( $batch->data ) ) { |
|
505 | + if (empty($batch->data)) { |
|
508 | 506 | // Complete batch if do not have any data to process. |
509 | - self::$background_updater->delete( $batch->key ); |
|
507 | + self::$background_updater->delete($batch->key); |
|
510 | 508 | |
511 | - if ( self::$background_updater->has_queue() ) { |
|
512 | - $this->__health_background_update( $this ); |
|
509 | + if (self::$background_updater->has_queue()) { |
|
510 | + $this->__health_background_update($this); |
|
513 | 511 | } else { |
514 | 512 | self::$background_updater->complete(); |
515 | 513 | } |
516 | 514 | |
517 | - } elseif ( $batch_data_count !== count( $batch->data ) ) { |
|
515 | + } elseif ($batch_data_count !== count($batch->data)) { |
|
518 | 516 | |
519 | - $log_data .= 'Updating batch' . "\n"; |
|
520 | - $log_data .= print_r( $batch, true ); |
|
517 | + $log_data .= 'Updating batch'."\n"; |
|
518 | + $log_data .= print_r($batch, true); |
|
521 | 519 | |
522 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', $doing_upgrade_args['update'], get_option( 'give_db_update_count' ) ); |
|
520 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', $doing_upgrade_args['update'], get_option('give_db_update_count')); |
|
523 | 521 | $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage(); |
524 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
522 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
525 | 523 | |
526 | - if ( ! empty( $batch->key ) ) { |
|
527 | - wp_cache_delete( $batch->key, 'options' ); |
|
528 | - update_option( $batch->key, $batch->data ); |
|
524 | + if ( ! empty($batch->key)) { |
|
525 | + wp_cache_delete($batch->key, 'options'); |
|
526 | + update_option($batch->key, $batch->data); |
|
529 | 527 | } else { |
530 | 528 | |
531 | - update_option( 'give_db_update_count', count( $batch->data ) ); |
|
529 | + update_option('give_db_update_count', count($batch->data)); |
|
532 | 530 | |
533 | 531 | $doing_upgrade_args['update'] = $give_updates->update; |
534 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, count( $batch->data ) ); |
|
532 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', 1, count($batch->data)); |
|
535 | 533 | |
536 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
534 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
537 | 535 | |
538 | - foreach ( $batch->data as $data ) { |
|
539 | - Give_Updates::$background_updater->push_to_queue( $data ); |
|
536 | + foreach ($batch->data as $data) { |
|
537 | + Give_Updates::$background_updater->push_to_queue($data); |
|
540 | 538 | } |
541 | 539 | |
542 | 540 | Give_Updates::$background_updater->save(); |
@@ -548,27 +546,27 @@ discard block |
||
548 | 546 | * Fix give_doing_upgrade option |
549 | 547 | */ |
550 | 548 | $update_option = false; |
551 | - $fresh_new_db_count = $this->get_total_new_db_update_count( true ); |
|
552 | - if ( $fresh_new_db_count < $doing_upgrade_args['update'] ) { |
|
553 | - update_option( 'give_db_update_count', $fresh_new_db_count ); |
|
549 | + $fresh_new_db_count = $this->get_total_new_db_update_count(true); |
|
550 | + if ($fresh_new_db_count < $doing_upgrade_args['update']) { |
|
551 | + update_option('give_db_update_count', $fresh_new_db_count); |
|
554 | 552 | $doing_upgrade_args['update'] = 1; |
555 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, $fresh_new_db_count ); |
|
553 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', 1, $fresh_new_db_count); |
|
556 | 554 | $update_option = true; |
557 | 555 | } |
558 | 556 | |
559 | - if ( 101 < $doing_upgrade_args['total_percentage'] ) { |
|
560 | - $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage( true ); |
|
557 | + if (101 < $doing_upgrade_args['total_percentage']) { |
|
558 | + $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage(true); |
|
561 | 559 | $update_option = true; |
562 | 560 | } |
563 | 561 | |
564 | - if ( $update_option ) { |
|
565 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
562 | + if ($update_option) { |
|
563 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
566 | 564 | |
567 | - $log_data .= 'Updated doing update:' . "\n"; |
|
568 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
565 | + $log_data .= 'Updated doing update:'."\n"; |
|
566 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
569 | 567 | } |
570 | 568 | |
571 | - Give()->logs->add( 'Update Health Check', $log_data, 0, 'update' ); |
|
569 | + Give()->logs->add('Update Health Check', $log_data, 0, 'update'); |
|
572 | 570 | } |
573 | 571 | |
574 | 572 | |
@@ -580,66 +578,66 @@ discard block |
||
580 | 578 | */ |
581 | 579 | public function __show_notice() { |
582 | 580 | // Bailout. |
583 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
581 | + if ( ! current_user_can('manage_give_settings')) { |
|
584 | 582 | return; |
585 | 583 | } |
586 | 584 | |
587 | 585 | // Run DB updates. |
588 | - if ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
586 | + if ( ! empty($_GET['give-run-db-update'])) { |
|
589 | 587 | $this->run_db_update(); |
590 | 588 | } |
591 | 589 | |
592 | 590 | |
593 | 591 | // Bailout. |
594 | - if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) { |
|
592 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
595 | 593 | return; |
596 | 594 | } |
597 | 595 | |
598 | 596 | // Show notice if upgrade paused. |
599 | - if ( self::$background_updater->is_paused_process() ) { |
|
597 | + if (self::$background_updater->is_paused_process()) { |
|
600 | 598 | ob_start(); |
601 | 599 | |
602 | - $upgrade_error = get_option( 'give_upgrade_error' ); |
|
603 | - if ( ! $upgrade_error ) : ?> |
|
604 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
605 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give' ); ?> |
|
600 | + $upgrade_error = get_option('give_upgrade_error'); |
|
601 | + if ( ! $upgrade_error) : ?> |
|
602 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
603 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give'); ?> |
|
606 | 604 | <br> |
607 | 605 | <br> |
608 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-restart-db-upgrades' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-restart-updater-btn"> |
|
609 | - <?php _e( 'Restart the updater', 'give' ); ?> |
|
606 | + <a href="<?php echo esc_url(add_query_arg(array('give-restart-db-upgrades' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-restart-updater-btn"> |
|
607 | + <?php _e('Restart the updater', 'give'); ?> |
|
610 | 608 | </a> |
611 | 609 | <script type="text/javascript"> |
612 | 610 | jQuery('.give-restart-updater-btn').click('click', function () { |
613 | - return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line |
|
611 | + return window.confirm('<?php echo esc_js(__('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give')); ?>'); // jshint ignore:line |
|
614 | 612 | }); |
615 | 613 | </script> |
616 | 614 | <?php else: ?> |
617 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
618 | - – <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
|
615 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
616 | + – <?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?> |
|
619 | 617 | <?php |
620 | 618 | endif; |
621 | 619 | $desc_html = ob_get_clean(); |
622 | 620 | |
623 | - Give()->notices->register_notice( array( |
|
621 | + Give()->notices->register_notice(array( |
|
624 | 622 | 'id' => 'give_upgrade_db', |
625 | 623 | 'type' => 'error', |
626 | 624 | 'dismissible' => false, |
627 | 625 | 'description' => $desc_html, |
628 | - ) ); |
|
626 | + )); |
|
629 | 627 | } |
630 | 628 | |
631 | 629 | // Bailout if doing upgrades. |
632 | - if ( $this->is_doing_updates() ) { |
|
630 | + if ($this->is_doing_updates()) { |
|
633 | 631 | return; |
634 | 632 | } |
635 | 633 | |
636 | 634 | // Show notice if ajax is not working. |
637 | - if ( ! give_test_ajax_works() ) { |
|
635 | + if ( ! give_test_ajax_works()) { |
|
638 | 636 | Give()->notices->register_notice( |
639 | 637 | array( |
640 | 638 | 'id' => 'give_db_upgrade_ajax_inaccessible', |
641 | 639 | 'type' => 'error', |
642 | - 'description' => sprintf( '%1$s <a href="%2$s" target="_blank">%3$s</a>', __( 'Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give' ), 'http://docs.givewp.com/admin-ajax-error', __( 'Read More', 'give' ) . ' »' ), |
|
640 | + 'description' => sprintf('%1$s <a href="%2$s" target="_blank">%3$s</a>', __('Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give'), 'http://docs.givewp.com/admin-ajax-error', __('Read More', 'give').' »'), |
|
643 | 641 | 'show' => true, |
644 | 642 | ) |
645 | 643 | ); |
@@ -648,45 +646,45 @@ discard block |
||
648 | 646 | } |
649 | 647 | |
650 | 648 | // Show db upgrade completed notice. |
651 | - if ( ! empty( $_GET['give-db-update-completed'] ) ) { |
|
652 | - Give()->notices->register_notice( array( |
|
649 | + if ( ! empty($_GET['give-db-update-completed'])) { |
|
650 | + Give()->notices->register_notice(array( |
|
653 | 651 | 'id' => 'give_db_upgrade_completed', |
654 | 652 | 'type' => 'updated', |
655 | - 'description' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
653 | + 'description' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
656 | 654 | 'show' => true, |
657 | - ) ); |
|
655 | + )); |
|
658 | 656 | |
659 | 657 | // Start update. |
660 | - } elseif ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
658 | + } elseif ( ! empty($_GET['give-run-db-update'])) { |
|
661 | 659 | $this->run_db_update(); |
662 | 660 | |
663 | 661 | // Show run the update notice. |
664 | - } elseif ( $this->get_total_new_db_update_count() ) { |
|
662 | + } elseif ($this->get_total_new_db_update_count()) { |
|
665 | 663 | ob_start(); |
666 | 664 | ?> |
667 | 665 | <p> |
668 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
669 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give' ); ?> |
|
666 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
667 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give'); ?> |
|
670 | 668 | </p> |
671 | 669 | <p class="submit"> |
672 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-run-db-update' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-run-update-now"> |
|
673 | - <?php _e( 'Run the updater', 'give' ); ?> |
|
670 | + <a href="<?php echo esc_url(add_query_arg(array('give-run-db-update' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-run-update-now"> |
|
671 | + <?php _e('Run the updater', 'give'); ?> |
|
674 | 672 | </a> |
675 | 673 | </p> |
676 | 674 | <script type="text/javascript"> |
677 | 675 | jQuery('.give-run-update-now').click('click', function () { |
678 | - return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line |
|
676 | + return window.confirm('<?php echo esc_js(__('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give')); ?>'); // jshint ignore:line |
|
679 | 677 | }); |
680 | 678 | </script> |
681 | 679 | <?php |
682 | 680 | $desc_html = ob_get_clean(); |
683 | 681 | |
684 | - Give()->notices->register_notice( array( |
|
682 | + Give()->notices->register_notice(array( |
|
685 | 683 | 'id' => 'give_upgrade_db', |
686 | 684 | 'type' => 'updated', |
687 | 685 | 'dismissible' => false, |
688 | 686 | 'description' => $desc_html, |
689 | - ) ); |
|
687 | + )); |
|
690 | 688 | } |
691 | 689 | } |
692 | 690 | |
@@ -697,7 +695,7 @@ discard block |
||
697 | 695 | * @access public |
698 | 696 | */ |
699 | 697 | public function render_complete_page() { |
700 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php'; |
|
698 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php'; |
|
701 | 699 | } |
702 | 700 | |
703 | 701 | /** |
@@ -707,7 +705,7 @@ discard block |
||
707 | 705 | * @access public |
708 | 706 | */ |
709 | 707 | public function render_page() { |
710 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php'; |
|
708 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php'; |
|
711 | 709 | } |
712 | 710 | |
713 | 711 | /** |
@@ -718,26 +716,26 @@ discard block |
||
718 | 716 | */ |
719 | 717 | private function run_db_update() { |
720 | 718 | // Bailout. |
721 | - if ( $this->is_doing_updates() || ! $this->get_total_new_db_update_count() ) { |
|
719 | + if ($this->is_doing_updates() || ! $this->get_total_new_db_update_count()) { |
|
722 | 720 | return; |
723 | 721 | } |
724 | 722 | |
725 | - $updates = $this->get_updates( 'database', 'new' ); |
|
723 | + $updates = $this->get_updates('database', 'new'); |
|
726 | 724 | |
727 | - foreach ( $updates as $update ) { |
|
728 | - self::$background_updater->push_to_queue( $update ); |
|
725 | + foreach ($updates as $update) { |
|
726 | + self::$background_updater->push_to_queue($update); |
|
729 | 727 | } |
730 | 728 | |
731 | - add_option( 'give_db_update_count', count( $updates ), '', 'no' ); |
|
729 | + add_option('give_db_update_count', count($updates), '', 'no'); |
|
732 | 730 | |
733 | - add_option( 'give_doing_upgrade', array( |
|
731 | + add_option('give_doing_upgrade', array( |
|
734 | 732 | 'update_info' => $updates[0], |
735 | 733 | 'step' => 1, |
736 | 734 | 'update' => 1, |
737 | - 'heading' => sprintf( 'Update %s of %s', 1, count( $updates ) ), |
|
735 | + 'heading' => sprintf('Update %s of %s', 1, count($updates)), |
|
738 | 736 | 'percentage' => 0, |
739 | 737 | 'total_percentage' => 0, |
740 | - ), '', 'no' ); |
|
738 | + ), '', 'no'); |
|
741 | 739 | |
742 | 740 | self::$background_updater->save()->dispatch(); |
743 | 741 | } |
@@ -751,14 +749,13 @@ discard block |
||
751 | 749 | */ |
752 | 750 | public function __flush_resume_updates() { |
753 | 751 | //delete_option( 'give_doing_upgrade' ); |
754 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
752 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
755 | 753 | |
756 | 754 | // Reset counter. |
757 | 755 | $this->step = $this->percentage = 0; |
758 | 756 | |
759 | - $this->update = ( $this->get_total_db_update_count() > $this->update ) ? |
|
760 | - ( $this->update + 1 ) : |
|
761 | - $this->update; |
|
757 | + $this->update = ($this->get_total_db_update_count() > $this->update) ? |
|
758 | + ($this->update + 1) : $this->update; |
|
762 | 759 | } |
763 | 760 | |
764 | 761 | |
@@ -773,7 +770,7 @@ discard block |
||
773 | 770 | public function __give_start_updating() { |
774 | 771 | // Check permission. |
775 | 772 | if ( |
776 | - ! current_user_can( 'manage_give_settings' ) || |
|
773 | + ! current_user_can('manage_give_settings') || |
|
777 | 774 | $this->is_doing_updates() |
778 | 775 | ) { |
779 | 776 | wp_send_json_error(); |
@@ -781,7 +778,7 @@ discard block |
||
781 | 778 | |
782 | 779 | // @todo: validate nonce |
783 | 780 | // @todo: set http method to post |
784 | - if ( empty( $_POST['run_db_update'] ) ) { |
|
781 | + if (empty($_POST['run_db_update'])) { |
|
785 | 782 | wp_send_json_error(); |
786 | 783 | } |
787 | 784 | |
@@ -800,34 +797,34 @@ discard block |
||
800 | 797 | * @return string |
801 | 798 | */ |
802 | 799 | public function __give_db_updates_info() { |
803 | - $update_info = get_option( 'give_doing_upgrade' ); |
|
800 | + $update_info = get_option('give_doing_upgrade'); |
|
804 | 801 | $response_type = ''; |
805 | 802 | |
806 | - if ( self::$background_updater->is_paused_process() ) { |
|
803 | + if (self::$background_updater->is_paused_process()) { |
|
807 | 804 | $update_info = array( |
808 | - 'message' => __( 'The updates have been paused.', 'give' ), |
|
809 | - 'heading' => __( '', 'give' ), |
|
805 | + 'message' => __('The updates have been paused.', 'give'), |
|
806 | + 'heading' => __('', 'give'), |
|
810 | 807 | 'percentage' => 0, |
811 | 808 | ); |
812 | 809 | |
813 | - if ( get_option( 'give_upgrade_error' ) ) { |
|
814 | - $update_info['message'] = __( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); |
|
810 | + if (get_option('give_upgrade_error')) { |
|
811 | + $update_info['message'] = __('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); |
|
815 | 812 | } |
816 | 813 | |
817 | 814 | $response_type = 'error'; |
818 | 815 | |
819 | - } elseif ( empty( $update_info ) ) { |
|
816 | + } elseif (empty($update_info)) { |
|
820 | 817 | $update_info = array( |
821 | - 'message' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
822 | - 'heading' => __( 'Updates Completed.', 'give' ), |
|
818 | + 'message' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
819 | + 'heading' => __('Updates Completed.', 'give'), |
|
823 | 820 | 'percentage' => 0, |
824 | 821 | ); |
825 | 822 | $response_type = 'success'; |
826 | 823 | |
827 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
824 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
828 | 825 | } |
829 | 826 | |
830 | - $this->send_ajax_response( $update_info, $response_type ); |
|
827 | + $this->send_ajax_response($update_info, $response_type); |
|
831 | 828 | } |
832 | 829 | |
833 | 830 | /** |
@@ -839,7 +836,7 @@ discard block |
||
839 | 836 | * @param $data |
840 | 837 | * @param string $type |
841 | 838 | */ |
842 | - public function send_ajax_response( $data, $type = '' ) { |
|
839 | + public function send_ajax_response($data, $type = '') { |
|
843 | 840 | $default = array( |
844 | 841 | 'message' => '', |
845 | 842 | 'heading' => '', |
@@ -849,24 +846,24 @@ discard block |
||
849 | 846 | ); |
850 | 847 | |
851 | 848 | // Set data. |
852 | - $data = wp_parse_args( $data, $default ); |
|
849 | + $data = wp_parse_args($data, $default); |
|
853 | 850 | |
854 | 851 | // Enable cache. |
855 | 852 | Give_Cache::enable(); |
856 | 853 | |
857 | - switch ( $type ) { |
|
854 | + switch ($type) { |
|
858 | 855 | case 'success': |
859 | - wp_send_json_success( $data ); |
|
856 | + wp_send_json_success($data); |
|
860 | 857 | break; |
861 | 858 | |
862 | 859 | case 'error': |
863 | - wp_send_json_error( $data ); |
|
860 | + wp_send_json_error($data); |
|
864 | 861 | break; |
865 | 862 | |
866 | 863 | default: |
867 | - wp_send_json( array( |
|
864 | + wp_send_json(array( |
|
868 | 865 | 'data' => $data, |
869 | - ) ); |
|
866 | + )); |
|
870 | 867 | break; |
871 | 868 | } |
872 | 869 | } |
@@ -880,12 +877,12 @@ discard block |
||
880 | 877 | * @param $total |
881 | 878 | * @param $current_total |
882 | 879 | */ |
883 | - public function set_percentage( $total, $current_total ) { |
|
880 | + public function set_percentage($total, $current_total) { |
|
884 | 881 | // Set percentage. |
885 | - $this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0; |
|
882 | + $this->percentage = $total ? (($current_total) / $total) * 100 : 0; |
|
886 | 883 | |
887 | 884 | // Verify percentage. |
888 | - $this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage; |
|
885 | + $this->percentage = (100 < $this->percentage) ? 100 : $this->percentage; |
|
889 | 886 | } |
890 | 887 | |
891 | 888 | /** |
@@ -898,22 +895,22 @@ discard block |
||
898 | 895 | * |
899 | 896 | * @return bool|null |
900 | 897 | */ |
901 | - public function is_parent_updates_completed( $update ) { |
|
898 | + public function is_parent_updates_completed($update) { |
|
902 | 899 | // Bailout. |
903 | - if ( empty( $update['depend'] ) ) { |
|
900 | + if (empty($update['depend'])) { |
|
904 | 901 | return true; |
905 | 902 | } |
906 | 903 | |
907 | 904 | // Check if dependency is valid or not. |
908 | - if ( ! $this->has_valid_dependency( $update ) ) { |
|
905 | + if ( ! $this->has_valid_dependency($update)) { |
|
909 | 906 | return null; |
910 | 907 | } |
911 | 908 | |
912 | 909 | $is_dependency_completed = true; |
913 | 910 | |
914 | - foreach ( $update['depend'] as $depend ) { |
|
911 | + foreach ($update['depend'] as $depend) { |
|
915 | 912 | |
916 | - if ( ! give_has_upgrade_completed( $depend ) ) { |
|
913 | + if ( ! give_has_upgrade_completed($depend)) { |
|
917 | 914 | $is_dependency_completed = false; |
918 | 915 | break; |
919 | 916 | } |
@@ -930,7 +927,7 @@ discard block |
||
930 | 927 | * @return bool |
931 | 928 | */ |
932 | 929 | public function is_doing_updates() { |
933 | - return (bool) get_option( 'give_doing_upgrade' ); |
|
930 | + return (bool) get_option('give_doing_upgrade'); |
|
934 | 931 | } |
935 | 932 | |
936 | 933 | |
@@ -944,7 +941,7 @@ discard block |
||
944 | 941 | * |
945 | 942 | * @return bool |
946 | 943 | */ |
947 | - public function has_valid_dependency( $update ) { |
|
944 | + public function has_valid_dependency($update) { |
|
948 | 945 | $is_valid_dependency = true; |
949 | 946 | // $update_ids = wp_list_pluck( $this->get_updates( 'database', 'all' ), 'id' ); |
950 | 947 | // |
@@ -970,33 +967,33 @@ discard block |
||
970 | 967 | * |
971 | 968 | * @return array |
972 | 969 | */ |
973 | - public function get_updates( $update_type = '', $status = 'all' ) { |
|
970 | + public function get_updates($update_type = '', $status = 'all') { |
|
974 | 971 | // return all updates. |
975 | - if ( empty( $update_type ) ) { |
|
972 | + if (empty($update_type)) { |
|
976 | 973 | return $this->updates; |
977 | 974 | } |
978 | 975 | |
979 | 976 | // Get specific update. |
980 | - $updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array(); |
|
977 | + $updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array(); |
|
981 | 978 | |
982 | 979 | // Bailout. |
983 | - if ( empty( $updates ) ) { |
|
980 | + if (empty($updates)) { |
|
984 | 981 | return $updates; |
985 | 982 | } |
986 | 983 | |
987 | - switch ( $status ) { |
|
984 | + switch ($status) { |
|
988 | 985 | case 'new': |
989 | 986 | // Remove already completed updates. |
990 | - wp_cache_delete( 'give_completed_upgrades', 'options' ); |
|
987 | + wp_cache_delete('give_completed_upgrades', 'options'); |
|
991 | 988 | $completed_updates = give_get_completed_upgrades(); |
992 | 989 | |
993 | - if ( ! empty( $completed_updates ) ) { |
|
994 | - foreach ( $updates as $index => $update ) { |
|
995 | - if ( in_array( $update['id'], $completed_updates ) ) { |
|
996 | - unset( $updates[ $index ] ); |
|
990 | + if ( ! empty($completed_updates)) { |
|
991 | + foreach ($updates as $index => $update) { |
|
992 | + if (in_array($update['id'], $completed_updates)) { |
|
993 | + unset($updates[$index]); |
|
997 | 994 | } |
998 | 995 | } |
999 | - $updates = array_values( $updates ); |
|
996 | + $updates = array_values($updates); |
|
1000 | 997 | } |
1001 | 998 | |
1002 | 999 | break; |
@@ -1013,7 +1010,7 @@ discard block |
||
1013 | 1010 | * @return int |
1014 | 1011 | */ |
1015 | 1012 | public function get_total_plugin_update_count() { |
1016 | - return count( $this->get_updates( 'plugin' ) ); |
|
1013 | + return count($this->get_updates('plugin')); |
|
1017 | 1014 | } |
1018 | 1015 | |
1019 | 1016 | /** |
@@ -1028,7 +1025,7 @@ discard block |
||
1028 | 1025 | $db_update_count = $this->get_pending_db_update_count(); |
1029 | 1026 | $plugin_update_count = $this->get_total_plugin_update_count(); |
1030 | 1027 | |
1031 | - return ( $db_update_count + $plugin_update_count ); |
|
1028 | + return ($db_update_count + $plugin_update_count); |
|
1032 | 1029 | } |
1033 | 1030 | |
1034 | 1031 | /** |
@@ -1040,7 +1037,7 @@ discard block |
||
1040 | 1037 | * @return int |
1041 | 1038 | */ |
1042 | 1039 | public function get_pending_db_update_count() { |
1043 | - return count( $this->get_updates( 'database', 'new' ) ); |
|
1040 | + return count($this->get_updates('database', 'new')); |
|
1044 | 1041 | } |
1045 | 1042 | |
1046 | 1043 | /** |
@@ -1052,7 +1049,7 @@ discard block |
||
1052 | 1049 | * @return int |
1053 | 1050 | */ |
1054 | 1051 | public function get_total_db_update_count() { |
1055 | - return count( $this->get_updates( 'database', 'all' ) ); |
|
1052 | + return count($this->get_updates('database', 'all')); |
|
1056 | 1053 | } |
1057 | 1054 | |
1058 | 1055 | /** |
@@ -1065,10 +1062,9 @@ discard block |
||
1065 | 1062 | * |
1066 | 1063 | * @return int |
1067 | 1064 | */ |
1068 | - public function get_total_new_db_update_count( $refresh = false ) { |
|
1065 | + public function get_total_new_db_update_count($refresh = false) { |
|
1069 | 1066 | $update_count = $this->is_doing_updates() && ! $refresh ? |
1070 | - get_option( 'give_db_update_count' ) : |
|
1071 | - $this->get_pending_db_update_count(); |
|
1067 | + get_option('give_db_update_count') : $this->get_pending_db_update_count(); |
|
1072 | 1068 | |
1073 | 1069 | return $update_count; |
1074 | 1070 | } |
@@ -1083,11 +1079,11 @@ discard block |
||
1083 | 1079 | * |
1084 | 1080 | * @return int |
1085 | 1081 | */ |
1086 | - public function get_running_db_update( $refresh = false ) { |
|
1082 | + public function get_running_db_update($refresh = false) { |
|
1087 | 1083 | $current_update = 1; |
1088 | 1084 | |
1089 | - if ( $this->is_doing_updates() && ! $refresh ) { |
|
1090 | - $current_update = get_option( 'give_doing_upgrade' ); |
|
1085 | + if ($this->is_doing_updates() && ! $refresh) { |
|
1086 | + $current_update = get_option('give_doing_upgrade'); |
|
1091 | 1087 | $current_update = $current_update['update']; |
1092 | 1088 | } |
1093 | 1089 | |
@@ -1104,25 +1100,23 @@ discard block |
||
1104 | 1100 | * |
1105 | 1101 | * @return float|int |
1106 | 1102 | */ |
1107 | - public function get_db_update_processing_percentage( $refresh = false ) { |
|
1103 | + public function get_db_update_processing_percentage($refresh = false) { |
|
1108 | 1104 | // Bailout. |
1109 | - if ( ! $this->get_total_new_db_update_count( $refresh ) ) { |
|
1105 | + if ( ! $this->get_total_new_db_update_count($refresh)) { |
|
1110 | 1106 | return 0; |
1111 | 1107 | } |
1112 | 1108 | |
1113 | - $resume_update = get_option( 'give_doing_upgrade' ); |
|
1114 | - $update_count_percentages = ( ( $this->get_running_db_update( $refresh ) - 1 ) / $this->get_total_new_db_update_count( $refresh ) ) * 100; |
|
1115 | - $update_percentage_share = ( 1 / $this->get_total_new_db_update_count() ) * 100; |
|
1116 | - $upgrade_percentage = ( ( $resume_update['percentage'] * $update_percentage_share ) / 100 ); |
|
1109 | + $resume_update = get_option('give_doing_upgrade'); |
|
1110 | + $update_count_percentages = (($this->get_running_db_update($refresh) - 1) / $this->get_total_new_db_update_count($refresh)) * 100; |
|
1111 | + $update_percentage_share = (1 / $this->get_total_new_db_update_count()) * 100; |
|
1112 | + $upgrade_percentage = (($resume_update['percentage'] * $update_percentage_share) / 100); |
|
1117 | 1113 | |
1118 | 1114 | $final_percentage = $update_count_percentages + $upgrade_percentage; |
1119 | 1115 | |
1120 | 1116 | return $this->is_doing_updates() ? |
1121 | - ( absint( $final_percentage ) ? |
|
1122 | - absint( $final_percentage ) : |
|
1123 | - round( $final_percentage, 2 ) |
|
1124 | - ) : |
|
1125 | - 0; |
|
1117 | + (absint($final_percentage) ? |
|
1118 | + absint($final_percentage) : round($final_percentage, 2) |
|
1119 | + ) : 0; |
|
1126 | 1120 | } |
1127 | 1121 | |
1128 | 1122 | |
@@ -1134,8 +1128,8 @@ discard block |
||
1134 | 1128 | * @return array |
1135 | 1129 | */ |
1136 | 1130 | public function get_update_ids() { |
1137 | - $all_updates = $this->get_updates( 'database', 'all' ); |
|
1138 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
1131 | + $all_updates = $this->get_updates('database', 'all'); |
|
1132 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
1139 | 1133 | |
1140 | 1134 | return $all_update_ids; |
1141 | 1135 | } |
@@ -613,8 +613,11 @@ |
||
613 | 613 | return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line |
614 | 614 | }); |
615 | 615 | </script> |
616 | - <?php else: ?> |
|
617 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
616 | + <?php else { |
|
617 | + : ?> |
|
618 | + <strong><?php _e( 'Database Update', 'give' ); |
|
619 | +} |
|
620 | +?></strong> |
|
618 | 621 | – <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
619 | 622 | <?php |
620 | 623 | endif; |