@@ -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 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @return Give_Donor_Wall |
51 | 51 | */ |
52 | 52 | public static function get_instance() { |
53 | - if ( null === static::$instance ) { |
|
53 | + if (null === static::$instance) { |
|
54 | 54 | self::$instance = new static(); |
55 | 55 | |
56 | 56 | self::$instance->setup_actions(); |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function setup_actions() { |
70 | 70 | |
71 | - add_shortcode( 'give_donor_wall', array( $this, 'render_shortcode' ) ); |
|
71 | + add_shortcode('give_donor_wall', array($this, 'render_shortcode')); |
|
72 | 72 | |
73 | - add_action( 'wp_ajax_give_get_donor_comments', array( $this, 'ajax_handler' ) ); |
|
74 | - add_action( 'wp_ajax_nopriv_give_get_donor_comments', array( $this, 'ajax_handler' ) ); |
|
73 | + add_action('wp_ajax_give_get_donor_comments', array($this, 'ajax_handler')); |
|
74 | + add_action('wp_ajax_nopriv_give_get_donor_comments', array($this, 'ajax_handler')); |
|
75 | 75 | |
76 | 76 | } |
77 | 77 | |
@@ -107,29 +107,29 @@ discard block |
||
107 | 107 | * } |
108 | 108 | * @return string|bool The markup of the form grid or false. |
109 | 109 | */ |
110 | - public function render_shortcode( $atts ) { |
|
110 | + public function render_shortcode($atts) { |
|
111 | 111 | |
112 | 112 | $give_settings = give_get_settings(); |
113 | 113 | |
114 | - $atts = $this->parse_atts( $atts ); |
|
115 | - $donor_query = $this->get_donor_query_atts( $atts ); |
|
116 | - $donors = $this->get_donors( $donor_query ); |
|
114 | + $atts = $this->parse_atts($atts); |
|
115 | + $donor_query = $this->get_donor_query_atts($atts); |
|
116 | + $donors = $this->get_donors($donor_query); |
|
117 | 117 | $html = ''; |
118 | 118 | |
119 | - if ( $donors ) { |
|
119 | + if ($donors) { |
|
120 | 120 | |
121 | 121 | ob_start(); |
122 | 122 | |
123 | - foreach ( $donors as $donor ) { |
|
123 | + foreach ($donors as $donor) { |
|
124 | 124 | // Give/templates/shortcode-donor-wall.php. |
125 | - give_get_template( 'shortcode-donor-wall', array( $donor, $give_settings, $atts ) ); |
|
125 | + give_get_template('shortcode-donor-wall', array($donor, $give_settings, $atts)); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | $html = ob_get_clean(); |
129 | 129 | |
130 | 130 | // Return only donor html. |
131 | 131 | if ( |
132 | - isset( $atts['only_donor_html'] ) |
|
132 | + isset($atts['only_donor_html']) |
|
133 | 133 | && wp_doing_ajax() |
134 | 134 | && $atts['only_donor_html'] |
135 | 135 | ) { |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | $next_donor_query['fields'] = 'id'; |
143 | 143 | |
144 | 144 | $more_btn_html = ''; |
145 | - if ( $this->get_donors( $next_donor_query ) ) { |
|
145 | + if ($this->get_donors($next_donor_query)) { |
|
146 | 146 | $more_btn_html = sprintf( |
147 | 147 | '<button class="give-donor__load_more give-button-with-loader" data-shortcode="%1$s"><span class="give-loading-animation"></span>%2$s</button>', |
148 | - rawurlencode( http_build_query( $atts ) ), |
|
148 | + rawurlencode(http_build_query($atts)), |
|
149 | 149 | $atts['loadmore_text'] |
150 | 150 | ); |
151 | 151 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $html = $html |
154 | 154 | ? sprintf( |
155 | 155 | '<div class="give-wrap"><div class="give-grid give-grid--%1$s">%2$s</div>%3$s</div>', |
156 | - esc_attr( $atts['columns'] ), |
|
156 | + esc_attr($atts['columns']), |
|
157 | 157 | $html, |
158 | 158 | $more_btn_html |
159 | 159 | ) |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return array |
174 | 174 | */ |
175 | - public function parse_atts( $atts ) { |
|
175 | + public function parse_atts($atts) { |
|
176 | 176 | $atts = shortcode_atts( |
177 | 177 | array( |
178 | 178 | 'donors_per_page' => 20, |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | 'show_comments' => true, |
188 | 188 | 'comment_length' => 20, |
189 | 189 | 'only_comments' => true, |
190 | - 'readmore_text' => esc_html__( 'Read More', 'give' ), |
|
191 | - 'loadmore_text' => esc_html__( 'Load More', 'give' ), |
|
190 | + 'readmore_text' => esc_html__('Read More', 'give'), |
|
191 | + 'loadmore_text' => esc_html__('Load More', 'give'), |
|
192 | 192 | 'avatar_size' => 60, |
193 | 193 | 'orderby' => 'donation_count', |
194 | 194 | 'order' => 'DESC', |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | ); |
199 | 199 | |
200 | 200 | // Validate integer attributes. |
201 | - $atts['donors_per_page'] = absint( $atts['donors_per_page'] ); |
|
201 | + $atts['donors_per_page'] = absint($atts['donors_per_page']); |
|
202 | 202 | |
203 | 203 | // Validate boolean attributes. |
204 | 204 | $boolean_attributes = array( |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | 'only_donor_html', |
214 | 214 | ); |
215 | 215 | |
216 | - foreach ( $boolean_attributes as $att ) { |
|
216 | + foreach ($boolean_attributes as $att) { |
|
217 | 217 | // Convert numeric to boolean. |
218 | 218 | // It will prevent condition check against boolean value. |
219 | - if ( is_numeric( $atts[ $att ] ) ) { |
|
220 | - $atts[ $att ] = (bool) $atts[ $att ]; |
|
219 | + if (is_numeric($atts[$att])) { |
|
220 | + $atts[$att] = (bool) $atts[$att]; |
|
221 | 221 | } |
222 | 222 | |
223 | - $atts[ $att ] = filter_var( $atts[ $att ], FILTER_VALIDATE_BOOLEAN ); |
|
223 | + $atts[$att] = filter_var($atts[$att], FILTER_VALIDATE_BOOLEAN); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | return $atts; |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return array |
238 | 238 | */ |
239 | - public function get_donor_query_atts( $atts ) { |
|
239 | + public function get_donor_query_atts($atts) { |
|
240 | 240 | // Set default form query args. |
241 | 241 | $donor_args = array( |
242 | 242 | 'number' => $atts['donors_per_page'], |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | ); |
247 | 247 | |
248 | 248 | // Hide donors with zero donation amount. |
249 | - if ( $atts['hide_empty'] ) { |
|
249 | + if ($atts['hide_empty']) { |
|
250 | 250 | $donor_args['donation_amount'] = array( |
251 | 251 | 'compare' => '>=', |
252 | 252 | 'amount' => 1, |
@@ -254,18 +254,18 @@ discard block |
||
254 | 254 | } |
255 | 255 | |
256 | 256 | // Show donor who donated to specific form. |
257 | - if ( $atts['form_id'] ) { |
|
257 | + if ($atts['form_id']) { |
|
258 | 258 | $donor_args['give_forms'] = $atts['form_id']; |
259 | 259 | } |
260 | 260 | |
261 | 261 | // Show donor by id. |
262 | - if ( $atts['ids'] ) { |
|
262 | + if ($atts['ids']) { |
|
263 | 263 | $donor_args['donor'] = $atts['ids']; |
264 | 264 | } |
265 | 265 | |
266 | 266 | // Replace donation with purchase because donor table has that prefix in column name. |
267 | 267 | $donor_args['orderby'] = str_replace( |
268 | - array( 'donation', 'amount' ), array( |
|
268 | + array('donation', 'amount'), array( |
|
269 | 269 | 'purchase', |
270 | 270 | 'value', |
271 | 271 | ), $atts['orderby'] |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | 'date_created' => 'DESC', |
278 | 278 | ); |
279 | 279 | |
280 | - unset( $donor_args['order'] ); |
|
280 | + unset($donor_args['order']); |
|
281 | 281 | |
282 | 282 | // Set payment query. |
283 | 283 | // @codingStandardsIgnoreStart |
284 | - if ( true === $atts['only_comments'] ) { |
|
284 | + if (true === $atts['only_comments']) { |
|
285 | 285 | $donor_args['meta_query'] = array( |
286 | 286 | array( |
287 | 287 | 'key' => '_give_has_comment', |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @return array |
306 | 306 | */ |
307 | - public function get_donors( $donor_query ) { |
|
308 | - $donor_query = new Give_Donors_Query( $donor_query ); |
|
307 | + public function get_donors($donor_query) { |
|
308 | + $donor_query = new Give_Donors_Query($donor_query); |
|
309 | 309 | $donors = $donor_query->get_donors(); |
310 | 310 | |
311 | 311 | return $donors; |
@@ -319,26 +319,26 @@ discard block |
||
319 | 319 | * @access public |
320 | 320 | */ |
321 | 321 | public function ajax_handler() { |
322 | - $shortcode_atts = wp_parse_args( give_clean( rawurldecode( $_POST['data'] ) ) ); // @codingStandardsIgnoreLine |
|
322 | + $shortcode_atts = wp_parse_args(give_clean(rawurldecode($_POST['data']))); // @codingStandardsIgnoreLine |
|
323 | 323 | |
324 | 324 | // Get next page donor comments. |
325 | 325 | $shortcode_atts['paged'] = $shortcode_atts['paged'] + 1; |
326 | 326 | $shortcode_atts['only_donor_html'] = true; |
327 | 327 | |
328 | - $donors_comment_html = $this->render_shortcode( $shortcode_atts ); |
|
328 | + $donors_comment_html = $this->render_shortcode($shortcode_atts); |
|
329 | 329 | |
330 | 330 | // Check if donor comment remaining. |
331 | - $donor_query = $this->get_donor_query_atts( $shortcode_atts ); |
|
331 | + $donor_query = $this->get_donor_query_atts($shortcode_atts); |
|
332 | 332 | $donor_query['paged'] = $donor_query['paged'] + 1; |
333 | 333 | $donor_query['fields'] = 'id'; |
334 | - $has_donors = $this->get_donors( $donor_query ) ? 1 : 0; |
|
334 | + $has_donors = $this->get_donors($donor_query) ? 1 : 0; |
|
335 | 335 | |
336 | 336 | // Remove internal shortcode param. |
337 | - unset( $shortcode_atts['only_donor_html'] ); |
|
337 | + unset($shortcode_atts['only_donor_html']); |
|
338 | 338 | |
339 | 339 | wp_send_json( |
340 | 340 | array( |
341 | - 'shortcode' => rawurlencode( http_build_query( $shortcode_atts ) ), |
|
341 | + 'shortcode' => rawurlencode(http_build_query($shortcode_atts)), |
|
342 | 342 | 'html' => $donors_comment_html, |
343 | 343 | 'remaining' => $has_donors, |
344 | 344 | ) |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @return Give_Donor_Stats |
39 | 39 | */ |
40 | 40 | public static function get_instance() { |
41 | - if ( null === static::$instance ) { |
|
41 | + if (null === static::$instance) { |
|
42 | 42 | self::$instance = new static(); |
43 | 43 | } |
44 | 44 | |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | * @return string |
58 | 58 | * |
59 | 59 | */ |
60 | - public static function donated( $args = array() ) { |
|
60 | + public static function donated($args = array()) { |
|
61 | 61 | global $wpdb; |
62 | - $donation_id_col = Give()->payment_meta->get_meta_type() . '_id'; |
|
62 | + $donation_id_col = Give()->payment_meta->get_meta_type().'_id'; |
|
63 | 63 | |
64 | 64 | $donated_amount = ''; |
65 | 65 | |
66 | - if ( empty( $args['donor'] ) ) { |
|
66 | + if (empty($args['donor'])) { |
|
67 | 67 | return $donated_amount; |
68 | 68 | } |
69 | 69 | |
@@ -72,20 +72,20 @@ discard block |
||
72 | 72 | $args['fields'] = 'ids'; |
73 | 73 | $args['number'] = - 1; |
74 | 74 | |
75 | - $donation_query = new Give_Payments_Query( $args ); |
|
75 | + $donation_query = new Give_Payments_Query($args); |
|
76 | 76 | $donations = $donation_query->get_payments(); |
77 | - $donation_id_str = implode( '\',\'', $donations ); |
|
77 | + $donation_id_str = implode('\',\'', $donations); |
|
78 | 78 | |
79 | 79 | $query = "SELECT {$donation_id_col} as id, meta_value as total |
80 | 80 | FROM {$wpdb->donationmeta} |
81 | 81 | WHERE meta_key='_give_payment_total' |
82 | 82 | AND {$donation_id_col} IN ('{$donation_id_str}')"; |
83 | 83 | |
84 | - $donated_amounts = $wpdb->get_results( $query, ARRAY_A ); |
|
84 | + $donated_amounts = $wpdb->get_results($query, ARRAY_A); |
|
85 | 85 | |
86 | - if ( ! empty( $donated_amounts ) ) { |
|
87 | - foreach ( $donated_amounts as $donation ) { |
|
88 | - $currency_code = give_get_payment_currency_code( $donation['id'] ); |
|
86 | + if ( ! empty($donated_amounts)) { |
|
87 | + foreach ($donated_amounts as $donation) { |
|
88 | + $currency_code = give_get_payment_currency_code($donation['id']); |
|
89 | 89 | /** |
90 | 90 | * Filter the donation amount |
91 | 91 | * Note: this filter documented in payments/functions.php:give_donation_amount() |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | */ |
95 | 95 | $formatted_amount = apply_filters( |
96 | 96 | 'give_donation_amount', |
97 | - give_format_amount( $donation['total'], array( 'currency' => $currency_code ) ), |
|
97 | + give_format_amount($donation['total'], array('currency' => $currency_code)), |
|
98 | 98 | $donation['total'], |
99 | 99 | $donation['id'], |
100 | - array( 'type' => 'stats', 'currency' => false, 'amount' => false ) |
|
100 | + array('type' => 'stats', 'currency' => false, 'amount' => false) |
|
101 | 101 | ); |
102 | 102 | |
103 | - $donated_amount = (float) give_maybe_sanitize_amount( $formatted_amount, array( 'currency' => $currency_code ) ); |
|
103 | + $donated_amount = (float) give_maybe_sanitize_amount($formatted_amount, array('currency' => $currency_code)); |
|
104 | 104 | $donated_amount += $donated_amount; |
105 | 105 | } |
106 | 106 | } |
@@ -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 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
88 | 88 | */ |
89 | - public function __construct( $args = array() ) { |
|
89 | + public function __construct($args = array()) { |
|
90 | 90 | $defaults = array( |
91 | 91 | 'number' => 20, |
92 | 92 | 'offset' => 0, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | // 'form' => array(), |
117 | 117 | ); |
118 | 118 | |
119 | - $this->args = wp_parse_args( $args, $defaults ); |
|
119 | + $this->args = wp_parse_args($args, $defaults); |
|
120 | 120 | $this->table_name = Give()->donors->table_name; |
121 | 121 | $this->meta_table_name = Give()->donor_meta->table_name; |
122 | 122 | $this->meta_type = Give()->donor_meta->meta_type; |
@@ -158,21 +158,21 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @param Give_Donors_Query $this Donors query object. |
160 | 160 | */ |
161 | - do_action( 'give_pre_get_donors', $this ); |
|
161 | + do_action('give_pre_get_donors', $this); |
|
162 | 162 | |
163 | - $cache_key = Give_Cache::get_key( 'give_donor', $this->get_sql(), false ); |
|
163 | + $cache_key = Give_Cache::get_key('give_donor', $this->get_sql(), false); |
|
164 | 164 | |
165 | 165 | // Get donors from cache. |
166 | - $this->donors = Give_Cache::get_db_query( $cache_key ); |
|
166 | + $this->donors = Give_Cache::get_db_query($cache_key); |
|
167 | 167 | |
168 | - if ( is_null( $this->donors ) ) { |
|
169 | - if ( empty( $this->args['count'] ) ) { |
|
170 | - $this->donors = $wpdb->get_results( $this->get_sql() ); |
|
168 | + if (is_null($this->donors)) { |
|
169 | + if (empty($this->args['count'])) { |
|
170 | + $this->donors = $wpdb->get_results($this->get_sql()); |
|
171 | 171 | } else { |
172 | - $this->donors = $wpdb->get_var( $this->get_sql() ); |
|
172 | + $this->donors = $wpdb->get_var($this->get_sql()); |
|
173 | 173 | } |
174 | 174 | |
175 | - Give_Cache::set_db_query( $cache_key, $this->donors ); |
|
175 | + Give_Cache::set_db_query($cache_key, $this->donors); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param Give_Donors_Query $this Donors query object. |
185 | 185 | */ |
186 | - do_action( 'give_post_get_donors', $this ); |
|
186 | + do_action('give_post_get_donors', $this); |
|
187 | 187 | |
188 | 188 | return $this->donors; |
189 | 189 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | public function get_sql() { |
201 | 201 | global $wpdb; |
202 | 202 | |
203 | - if ( $this->args['number'] < 1 ) { |
|
203 | + if ($this->args['number'] < 1) { |
|
204 | 204 | $this->args['number'] = 99999999999; |
205 | 205 | } |
206 | 206 | |
@@ -208,32 +208,32 @@ discard block |
||
208 | 208 | |
209 | 209 | |
210 | 210 | // Set offset. |
211 | - if ( empty( $this->args['offset'] ) && ( 0 < $this->args['paged'] ) ) { |
|
212 | - $this->args['offset'] = $this->args['number'] * ( $this->args['paged'] - 1 ); |
|
211 | + if (empty($this->args['offset']) && (0 < $this->args['paged'])) { |
|
212 | + $this->args['offset'] = $this->args['number'] * ($this->args['paged'] - 1); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | // Set fields. |
216 | 216 | $fields = "{$this->table_name}.*"; |
217 | - if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) { |
|
218 | - if ( is_string( $this->args['fields'] ) ) { |
|
217 | + if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) { |
|
218 | + if (is_string($this->args['fields'])) { |
|
219 | 219 | $fields = "{$this->table_name}.{$this->args['fields']}"; |
220 | - } elseif ( is_array( $this->args['fields'] ) ) { |
|
221 | - $fields = "{$this->table_name}." . implode( " , {$this->table_name}.", $this->args['fields'] ); |
|
220 | + } elseif (is_array($this->args['fields'])) { |
|
221 | + $fields = "{$this->table_name}.".implode(" , {$this->table_name}.", $this->args['fields']); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
225 | 225 | // Set count. |
226 | - if ( ! empty( $this->args['count'] ) ) { |
|
226 | + if ( ! empty($this->args['count'])) { |
|
227 | 227 | $fields = "COUNT({$this->table_name}.id)"; |
228 | 228 | } |
229 | 229 | |
230 | 230 | $orderby = $this->get_order_query(); |
231 | 231 | |
232 | - $sql = $wpdb->prepare( "SELECT {$fields} FROM {$this->table_name} LIMIT %d,%d;", absint( $this->args['offset'] ), absint( $this->args['number'] ) ); |
|
232 | + $sql = $wpdb->prepare("SELECT {$fields} FROM {$this->table_name} LIMIT %d,%d;", absint($this->args['offset']), absint($this->args['number'])); |
|
233 | 233 | |
234 | 234 | // $where, $orderby and order already prepared query they can generate notice if you re prepare them in above. |
235 | 235 | // WordPress consider LIKE condition as placeholder if start with s,f, or d. |
236 | - $sql = str_replace( 'LIMIT', "{$where} {$orderby} LIMIT", $sql ); |
|
236 | + $sql = str_replace('LIMIT', "{$where} {$orderby} LIMIT", $sql); |
|
237 | 237 | |
238 | 238 | return $sql; |
239 | 239 | } |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | private function get_where_query() { |
251 | 251 | |
252 | 252 | // Get sql query for meta. |
253 | - if ( ! empty( $this->args['meta_query'] ) ) { |
|
254 | - $meta_query_object = new WP_Meta_Query( $this->args['meta_query'] ); |
|
255 | - $meta_query = $meta_query_object->get_sql( $this->meta_type, $this->table_name, 'id' ); |
|
253 | + if ( ! empty($this->args['meta_query'])) { |
|
254 | + $meta_query_object = new WP_Meta_Query($this->args['meta_query']); |
|
255 | + $meta_query = $meta_query_object->get_sql($this->meta_type, $this->table_name, 'id'); |
|
256 | 256 | |
257 | - $where[] = implode( '', $meta_query ); |
|
257 | + $where[] = implode('', $meta_query); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | $where[] = 'WHERE 1=1'; |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | $where[] = $this->get_where_donation_count(); |
268 | 268 | $where[] = $this->get_where_give_forms(); |
269 | 269 | |
270 | - $where = array_filter( $where ); |
|
270 | + $where = array_filter($where); |
|
271 | 271 | |
272 | - return trim( implode( ' ', array_map( 'trim', $where ) ) ); |
|
272 | + return trim(implode(' ', array_map('trim', $where))); |
|
273 | 273 | |
274 | 274 | } |
275 | 275 | |
@@ -287,17 +287,17 @@ discard block |
||
287 | 287 | |
288 | 288 | $where = ''; |
289 | 289 | |
290 | - if ( ! empty( $this->args['email'] ) ) { |
|
290 | + if ( ! empty($this->args['email'])) { |
|
291 | 291 | |
292 | - if ( is_array( $this->args['email'] ) ) { |
|
292 | + if (is_array($this->args['email'])) { |
|
293 | 293 | |
294 | - $emails_count = count( $this->args['email'] ); |
|
295 | - $emails_placeholder = array_fill( 0, $emails_count, '%s' ); |
|
296 | - $emails = implode( ', ', $emails_placeholder ); |
|
294 | + $emails_count = count($this->args['email']); |
|
295 | + $emails_placeholder = array_fill(0, $emails_count, '%s'); |
|
296 | + $emails = implode(', ', $emails_placeholder); |
|
297 | 297 | |
298 | - $where .= $wpdb->prepare( "AND {$this->table_name}.email IN( $emails )", $this->args['email'] ); |
|
298 | + $where .= $wpdb->prepare("AND {$this->table_name}.email IN( $emails )", $this->args['email']); |
|
299 | 299 | } else { |
300 | - $where .= $wpdb->prepare( "AND {$this->table_name}.email = %s", $this->args['email'] ); |
|
300 | + $where .= $wpdb->prepare("AND {$this->table_name}.email = %s", $this->args['email']); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
@@ -317,11 +317,11 @@ discard block |
||
317 | 317 | $where = ''; |
318 | 318 | |
319 | 319 | // Specific donors. |
320 | - if ( ! empty( $this->args['donor'] ) ) { |
|
321 | - if ( ! is_array( $this->args['donor'] ) ) { |
|
322 | - $this->args['donor'] = explode( ',', $this->args['donor'] ); |
|
320 | + if ( ! empty($this->args['donor'])) { |
|
321 | + if ( ! is_array($this->args['donor'])) { |
|
322 | + $this->args['donor'] = explode(',', $this->args['donor']); |
|
323 | 323 | } |
324 | - $donor_ids = implode( ',', array_map( 'intval', $this->args['donor'] ) ); |
|
324 | + $donor_ids = implode(',', array_map('intval', $this->args['donor'])); |
|
325 | 325 | |
326 | 326 | $where .= "AND {$this->table_name}.id IN( {$donor_ids} )"; |
327 | 327 | } |
@@ -342,10 +342,10 @@ discard block |
||
342 | 342 | $where = ''; |
343 | 343 | |
344 | 344 | // Donors created for a specific date or in a date range |
345 | - if ( ! empty( $this->args['date_query'] ) ) { |
|
346 | - $date_query_object = new WP_Date_Query( is_array( $this->args['date_query'] ) ? $this->args['date_query'] : wp_parse_args( $this->args['date_query'] ), "{$this->table_name}.date_created" ); |
|
345 | + if ( ! empty($this->args['date_query'])) { |
|
346 | + $date_query_object = new WP_Date_Query(is_array($this->args['date_query']) ? $this->args['date_query'] : wp_parse_args($this->args['date_query']), "{$this->table_name}.date_created"); |
|
347 | 347 | |
348 | - $where .= str_replace( array( |
|
348 | + $where .= str_replace(array( |
|
349 | 349 | "\n", |
350 | 350 | '( (', |
351 | 351 | '))', |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | '', |
354 | 354 | '( (', |
355 | 355 | ') )', |
356 | - ), $date_query_object->get_sql() ); |
|
356 | + ), $date_query_object->get_sql()); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | return $where; |
@@ -372,11 +372,11 @@ discard block |
||
372 | 372 | $where = ''; |
373 | 373 | |
374 | 374 | // Donors created for a specific date or in a date range |
375 | - if ( ! empty( $this->args['s'] ) && false !== strpos( $this->args['s'], ':' ) ) { |
|
376 | - $search_parts = explode( ':', $this->args['s'] ); |
|
375 | + if ( ! empty($this->args['s']) && false !== strpos($this->args['s'], ':')) { |
|
376 | + $search_parts = explode(':', $this->args['s']); |
|
377 | 377 | |
378 | - if ( ! empty( $search_parts[0] ) ) { |
|
379 | - switch ( $search_parts[0] ) { |
|
378 | + if ( ! empty($search_parts[0])) { |
|
379 | + switch ($search_parts[0]) { |
|
380 | 380 | case 'name': |
381 | 381 | $where = "AND {$this->table_name}.name LIKE '%{$search_parts[1]}%'"; |
382 | 382 | break; |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | $where = ''; |
405 | 405 | |
406 | 406 | // Donors create for specific wp user. |
407 | - if ( ! empty( $this->args['user'] ) ) { |
|
408 | - if ( ! is_array( $this->args['user'] ) ) { |
|
409 | - $this->args['user'] = explode( ',', $this->args['user'] ); |
|
407 | + if ( ! empty($this->args['user'])) { |
|
408 | + if ( ! is_array($this->args['user'])) { |
|
409 | + $this->args['user'] = explode(',', $this->args['user']); |
|
410 | 410 | } |
411 | - $user_ids = implode( ',', array_map( 'intval', $this->args['user'] ) ); |
|
411 | + $user_ids = implode(',', array_map('intval', $this->args['user'])); |
|
412 | 412 | |
413 | 413 | $where .= "AND {$this->table_name}.user_id IN( {$user_ids} )"; |
414 | 414 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $query = array(); |
431 | 431 | $ordersby = $this->args['orderby']; |
432 | 432 | |
433 | - if( ! is_array( $ordersby ) ) { |
|
433 | + if ( ! is_array($ordersby)) { |
|
434 | 434 | $ordersby = array( |
435 | 435 | $this->args['orderby'] => $this->args['order'] |
436 | 436 | ); |
@@ -438,23 +438,23 @@ discard block |
||
438 | 438 | |
439 | 439 | // Remove non existing column. |
440 | 440 | // Filter orderby values. |
441 | - foreach ( $ordersby as $orderby => $order ) { |
|
442 | - if( ! array_key_exists( $orderby, $table_columns ) ) { |
|
443 | - unset( $ordersby[$orderby] ); |
|
441 | + foreach ($ordersby as $orderby => $order) { |
|
442 | + if ( ! array_key_exists($orderby, $table_columns)) { |
|
443 | + unset($ordersby[$orderby]); |
|
444 | 444 | } |
445 | 445 | |
446 | - $ordersby[ esc_sql( $orderby ) ] = esc_sql( $this->args['order'] ); |
|
446 | + $ordersby[esc_sql($orderby)] = esc_sql($this->args['order']); |
|
447 | 447 | } |
448 | 448 | |
449 | - if( empty( $ordersby ) ) { |
|
449 | + if (empty($ordersby)) { |
|
450 | 450 | $ordersby = array( |
451 | 451 | 'id' => $this->args['order'] |
452 | 452 | ); |
453 | 453 | } |
454 | 454 | |
455 | 455 | // Create query. |
456 | - foreach ( $ordersby as $orderby => $order ) { |
|
457 | - switch ( $table_columns[ $orderby ] ) { |
|
456 | + foreach ($ordersby as $orderby => $order) { |
|
457 | + switch ($table_columns[$orderby]) { |
|
458 | 458 | case '%d': |
459 | 459 | case '%f': |
460 | 460 | $query[] = "{$this->table_name}.{$orderby}+0 {$order}"; |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
468 | - return ! empty( $query ) ? 'ORDER BY ' . implode( ', ', $query ) : ''; |
|
468 | + return ! empty($query) ? 'ORDER BY '.implode(', ', $query) : ''; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
@@ -481,10 +481,10 @@ discard block |
||
481 | 481 | private function get_where_donation_count() { |
482 | 482 | $where = ''; |
483 | 483 | |
484 | - if ( ! empty( $this->args['donation_count'] ) ) { |
|
484 | + if ( ! empty($this->args['donation_count'])) { |
|
485 | 485 | $compare = '>'; |
486 | 486 | $amount = $this->args['donation_count']; |
487 | - if ( is_array( $this->args['donation_count'] ) ) { |
|
487 | + if (is_array($this->args['donation_count'])) { |
|
488 | 488 | $compare = $this->args['donation_count'] ['compare']; |
489 | 489 | $amount = $this->args['donation_count']['amount']; |
490 | 490 | } |
@@ -508,10 +508,10 @@ discard block |
||
508 | 508 | private function get_where_donation_amount() { |
509 | 509 | $where = ''; |
510 | 510 | |
511 | - if ( ! empty( $this->args['donation_amount'] ) ) { |
|
511 | + if ( ! empty($this->args['donation_amount'])) { |
|
512 | 512 | $compare = '>'; |
513 | 513 | $amount = $this->args['donation_amount']; |
514 | - if ( is_array( $this->args['donation_amount'] ) ) { |
|
514 | + if (is_array($this->args['donation_amount'])) { |
|
515 | 515 | $compare = $this->args['donation_amount'] ['compare']; |
516 | 516 | $amount = $this->args['donation_amount']['amount']; |
517 | 517 | } |
@@ -537,13 +537,13 @@ discard block |
||
537 | 537 | global $wpdb; |
538 | 538 | $where = ''; |
539 | 539 | |
540 | - if ( ! empty( $this->args['give_forms'] ) ) { |
|
541 | - if ( ! is_array( $this->args['give_forms'] ) ) { |
|
542 | - $this->args['give_forms'] = explode( ',', $this->args['give_forms'] ); |
|
540 | + if ( ! empty($this->args['give_forms'])) { |
|
541 | + if ( ! is_array($this->args['give_forms'])) { |
|
542 | + $this->args['give_forms'] = explode(',', $this->args['give_forms']); |
|
543 | 543 | } |
544 | 544 | |
545 | - $form_ids = implode( ',', array_map( 'intval', $this->args['give_forms'] ) ); |
|
546 | - $donation_id_col = Give()->payment_meta->get_meta_type() . '_id'; |
|
545 | + $form_ids = implode(',', array_map('intval', $this->args['give_forms'])); |
|
546 | + $donation_id_col = Give()->payment_meta->get_meta_type().'_id'; |
|
547 | 547 | |
548 | 548 | $query = $wpdb->prepare( |
549 | 549 | " |
@@ -562,12 +562,12 @@ discard block |
||
562 | 562 | $form_ids |
563 | 563 | ); |
564 | 564 | |
565 | - $donor_ids = $wpdb->get_results( $query, ARRAY_A ); |
|
565 | + $donor_ids = $wpdb->get_results($query, ARRAY_A); |
|
566 | 566 | |
567 | - if ( ! empty( $donor_ids ) ) { |
|
568 | - $donor_ids = wp_list_pluck( $donor_ids, 'donor_id' ); |
|
569 | - $donor_ids = implode( ',', array_map( 'intval', $donor_ids ) ); |
|
570 | - $where .= "AND {$this->table_name}.id IN ({$donor_ids})"; |
|
567 | + if ( ! empty($donor_ids)) { |
|
568 | + $donor_ids = wp_list_pluck($donor_ids, 'donor_id'); |
|
569 | + $donor_ids = implode(',', array_map('intval', $donor_ids)); |
|
570 | + $where .= "AND {$this->table_name}.id IN ({$donor_ids})"; |
|
571 | 571 | } else { |
572 | 572 | $where .= "AND {$this->table_name}.id IN ('0')"; |
573 | 573 | } |
@@ -8,28 +8,28 @@ discard block |
||
8 | 8 | * @param array $donation_data |
9 | 9 | * |
10 | 10 | */ |
11 | -function __give_insert_donor_donation_comment( $donation_id, $donation_data ) { |
|
12 | - $is_anonymous_donation = isset( $_POST['give_anonymous_donation'] ) |
|
13 | - ? absint( $_POST['give_anonymous_donation'] ) |
|
11 | +function __give_insert_donor_donation_comment($donation_id, $donation_data) { |
|
12 | + $is_anonymous_donation = isset($_POST['give_anonymous_donation']) |
|
13 | + ? absint($_POST['give_anonymous_donation']) |
|
14 | 14 | : 0; |
15 | 15 | |
16 | - if ( ! empty( $_POST['give_comment'] ) ) { |
|
16 | + if ( ! empty($_POST['give_comment'])) { |
|
17 | 17 | $comment_id = give_insert_donor_donation_comment( |
18 | 18 | $donation_id, |
19 | 19 | $donation_data['user_info']['donor_id'], |
20 | - trim( $_POST['give_comment'] ), // We are sanitizing comment in Give_comment:add |
|
21 | - array( 'comment_author_email' => $donation_data['user_info']['email'] ) |
|
20 | + trim($_POST['give_comment']), // We are sanitizing comment in Give_comment:add |
|
21 | + array('comment_author_email' => $donation_data['user_info']['email']) |
|
22 | 22 | ); |
23 | 23 | |
24 | - update_comment_meta( $comment_id, '_give_anonymous_donation', $is_anonymous_donation ); |
|
25 | - Give()->donor_meta->update_meta( $donation_data['user_info']['donor_id'], '_give_has_comment', '1' ); |
|
24 | + update_comment_meta($comment_id, '_give_anonymous_donation', $is_anonymous_donation); |
|
25 | + Give()->donor_meta->update_meta($donation_data['user_info']['donor_id'], '_give_has_comment', '1'); |
|
26 | 26 | } |
27 | 27 | |
28 | - give_update_meta( $donation_id, '_give_anonymous_donation', $is_anonymous_donation ); |
|
29 | - Give()->donor_meta->update_meta( $donation_data['user_info']['donor_id'], '_give_anonymous_donor', $is_anonymous_donation ); |
|
28 | + give_update_meta($donation_id, '_give_anonymous_donation', $is_anonymous_donation); |
|
29 | + Give()->donor_meta->update_meta($donation_data['user_info']['donor_id'], '_give_anonymous_donor', $is_anonymous_donation); |
|
30 | 30 | } |
31 | 31 | |
32 | -add_action( 'give_insert_payment', '__give_insert_donor_donation_comment', 10, 2 ); |
|
32 | +add_action('give_insert_payment', '__give_insert_donor_donation_comment', 10, 2); |
|
33 | 33 | |
34 | 34 | |
35 | 35 | /** |
@@ -39,16 +39,16 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function __give_validate_donor_comment() { |
41 | 41 | // Check wp_check_comment_data_max_lengths for comment length validation. |
42 | - if ( ! empty( $_POST['give_comment'] ) ) { |
|
42 | + if ( ! empty($_POST['give_comment'])) { |
|
43 | 43 | $max_lengths = wp_get_comment_fields_max_lengths(); |
44 | - $comment = give_clean( $_POST['give_comment'] ); |
|
44 | + $comment = give_clean($_POST['give_comment']); |
|
45 | 45 | |
46 | - if ( mb_strlen( $comment, '8bit' ) > $max_lengths['comment_content'] ) { |
|
47 | - give_set_error( 'comment_content_column_length', __( 'Your comment is too long.', 'give' ) ); |
|
46 | + if (mb_strlen($comment, '8bit') > $max_lengths['comment_content']) { |
|
47 | + give_set_error('comment_content_column_length', __('Your comment is too long.', 'give')); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
51 | -add_action( 'give_checkout_error_checks', '__give_validate_donor_comment', 10, 1 ); |
|
51 | +add_action('give_checkout_error_checks', '__give_validate_donor_comment', 10, 1); |
|
52 | 52 | |
53 | 53 | |
54 | 54 | /** |
@@ -59,18 +59,18 @@ discard block |
||
59 | 59 | * @param $donation_id |
60 | 60 | * @param $status |
61 | 61 | */ |
62 | -function __give_update_donor_donation_comment_status( $donation_id, $status ) { |
|
63 | - $approve = absint( 'publish' === $status ); |
|
62 | +function __give_update_donor_donation_comment_status($donation_id, $status) { |
|
63 | + $approve = absint('publish' === $status); |
|
64 | 64 | |
65 | 65 | /* @var WP_Comment $note */ |
66 | - $donor_comment = give_get_donor_donation_comment( $donation_id, give_get_payment_donor_id( $donation_id ) ); |
|
66 | + $donor_comment = give_get_donor_donation_comment($donation_id, give_get_payment_donor_id($donation_id)); |
|
67 | 67 | |
68 | - if( $donor_comment instanceof WP_Comment ) { |
|
69 | - wp_set_comment_status( $donor_comment->comment_ID, (string) $approve ); |
|
68 | + if ($donor_comment instanceof WP_Comment) { |
|
69 | + wp_set_comment_status($donor_comment->comment_ID, (string) $approve); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | -add_action( 'give_update_payment_status', '__give_update_donor_donation_comment_status', 10, 2 ); |
|
73 | +add_action('give_update_payment_status', '__give_update_donor_donation_comment_status', 10, 2); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Remove donor comment when donation delete |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @param $donation_id |
81 | 81 | */ |
82 | -function __give_remove_donor_donation_comment( $donation_id ) { |
|
82 | +function __give_remove_donor_donation_comment($donation_id) { |
|
83 | 83 | /* @var WP_Comment $note */ |
84 | - $donor_comment = give_get_donor_donation_comment( $donation_id, give_get_payment_donor_id( $donation_id ) ); |
|
84 | + $donor_comment = give_get_donor_donation_comment($donation_id, give_get_payment_donor_id($donation_id)); |
|
85 | 85 | |
86 | - if( $donor_comment instanceof WP_Comment ) { |
|
87 | - wp_delete_comment( $donor_comment->comment_ID ); |
|
86 | + if ($donor_comment instanceof WP_Comment) { |
|
87 | + wp_delete_comment($donor_comment->comment_ID); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | -add_action( 'give_payment_deleted', '__give_remove_donor_donation_comment', 10 ); |
|
91 | +add_action('give_payment_deleted', '__give_remove_donor_donation_comment', 10); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,16 +25,16 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_get_actions() { |
27 | 27 | |
28 | - $get_data = give_clean( $_GET ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
28 | + $get_data = give_clean($_GET); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
29 | 29 | |
30 | - $_get_action = ! empty( $get_data['give_action'] ) ? $get_data['give_action'] : null; |
|
30 | + $_get_action = ! empty($get_data['give_action']) ? $get_data['give_action'] : null; |
|
31 | 31 | |
32 | 32 | // Add backward compatibility to give-action param ( $_GET ). |
33 | - if ( empty( $_get_action ) ) { |
|
34 | - $_get_action = ! empty( $get_data['give-action'] ) ? $get_data['give-action'] : null; |
|
33 | + if (empty($_get_action)) { |
|
34 | + $_get_action = ! empty($get_data['give-action']) ? $get_data['give-action'] : null; |
|
35 | 35 | } |
36 | 36 | |
37 | - if ( isset( $_get_action ) ) { |
|
37 | + if (isset($_get_action)) { |
|
38 | 38 | /** |
39 | 39 | * Fires in WordPress init or admin init, when give_action is present in $_GET. |
40 | 40 | * |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param array $_GET Array of HTTP GET variables. |
44 | 44 | */ |
45 | - do_action( "give_{$_get_action}", $get_data ); |
|
45 | + do_action("give_{$_get_action}", $get_data); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | } |
49 | 49 | |
50 | -add_action( 'init', 'give_get_actions' ); |
|
50 | +add_action('init', 'give_get_actions'); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Hooks Give actions, when present in the $_POST super global. Every give_action |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | */ |
61 | 61 | function give_post_actions() { |
62 | 62 | |
63 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
63 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
64 | 64 | |
65 | - $_post_action = ! empty( $post_data['give_action'] ) ? $post_data['give_action'] : null; |
|
65 | + $_post_action = ! empty($post_data['give_action']) ? $post_data['give_action'] : null; |
|
66 | 66 | |
67 | 67 | // Add backward compatibility to give-action param ( $_POST ). |
68 | - if ( empty( $_post_action ) ) { |
|
69 | - $_post_action = ! empty( $post_data['give-action'] ) ? $post_data['give-action'] : null; |
|
68 | + if (empty($_post_action)) { |
|
69 | + $_post_action = ! empty($post_data['give-action']) ? $post_data['give-action'] : null; |
|
70 | 70 | } |
71 | 71 | |
72 | - if ( isset( $_post_action ) ) { |
|
72 | + if (isset($_post_action)) { |
|
73 | 73 | /** |
74 | 74 | * Fires in WordPress init or admin init, when give_action is present in $_POST. |
75 | 75 | * |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @param array $_POST Array of HTTP POST variables. |
79 | 79 | */ |
80 | - do_action( "give_{$_post_action}", $post_data ); |
|
80 | + do_action("give_{$_post_action}", $post_data); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | } |
84 | 84 | |
85 | -add_action( 'init', 'give_post_actions' ); |
|
85 | +add_action('init', 'give_post_actions'); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Connect WordPress user with Donor. |
@@ -94,17 +94,17 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @return void |
96 | 96 | */ |
97 | -function give_connect_donor_to_wpuser( $user_id, $user_data ) { |
|
97 | +function give_connect_donor_to_wpuser($user_id, $user_data) { |
|
98 | 98 | /* @var Give_Donor $donor */ |
99 | - $donor = new Give_Donor( $user_data['user_email'] ); |
|
99 | + $donor = new Give_Donor($user_data['user_email']); |
|
100 | 100 | |
101 | 101 | // Validate donor id and check if do nor is already connect to wp user or not. |
102 | - if ( $donor->id && ! $donor->user_id ) { |
|
102 | + if ($donor->id && ! $donor->user_id) { |
|
103 | 103 | |
104 | 104 | // Update donor user_id. |
105 | - if ( $donor->update( array( 'user_id' => $user_id ) ) ) { |
|
106 | - $donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id ); |
|
107 | - $donor->add_note( $donor_note ); |
|
105 | + if ($donor->update(array('user_id' => $user_id))) { |
|
106 | + $donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id); |
|
107 | + $donor->add_note($donor_note); |
|
108 | 108 | |
109 | 109 | // Update user_id meta in payments. |
110 | 110 | // if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
120 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
121 | 121 | |
122 | 122 | |
123 | 123 | /** |
@@ -127,19 +127,19 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @param $data |
129 | 129 | */ |
130 | -function give_donor_batch_export_complete( $data ) { |
|
130 | +function give_donor_batch_export_complete($data) { |
|
131 | 131 | // Remove donor ids cache. |
132 | 132 | if ( |
133 | - isset( $data['class'] ) |
|
133 | + isset($data['class']) |
|
134 | 134 | && 'Give_Batch_Donors_Export' === $data['class'] |
135 | - && ! empty( $data['forms'] ) |
|
136 | - && isset( $data['give_export_option']['query_id'] ) |
|
135 | + && ! empty($data['forms']) |
|
136 | + && isset($data['give_export_option']['query_id']) |
|
137 | 137 | ) { |
138 | - Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) ); |
|
138 | + Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id'])); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | -add_action( 'give_file_export_complete', 'give_donor_batch_export_complete' ); |
|
142 | +add_action('give_file_export_complete', 'give_donor_batch_export_complete'); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Print css for wordpress setting pages. |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | /* @var WP_Screen $screen */ |
151 | 151 | $screen = get_current_screen(); |
152 | 152 | |
153 | - if ( ! ( $screen instanceof WP_Screen ) ) { |
|
153 | + if ( ! ($screen instanceof WP_Screen)) { |
|
154 | 154 | return false; |
155 | 155 | } |
156 | 156 | |
157 | - switch ( true ) { |
|
158 | - case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ): |
|
157 | + switch (true) { |
|
158 | + case ('plugins' === $screen->base || 'plugins-network' === $screen->base): |
|
159 | 159 | ?> |
160 | 160 | <style> |
161 | 161 | tr.active.update + tr.give-addon-notice-tr td { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | -add_action( 'admin_head', 'give_admin_quick_css' ); |
|
195 | +add_action('admin_head', 'give_admin_quick_css'); |
|
196 | 196 | |
197 | 197 | |
198 | 198 | /** |
@@ -204,31 +204,31 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return void |
206 | 206 | */ |
207 | -function give_set_donation_levels_max_min_amount( $form_id ) { |
|
207 | +function give_set_donation_levels_max_min_amount($form_id) { |
|
208 | 208 | if ( |
209 | - ( 'set' === $_POST['_give_price_option'] ) || |
|
210 | - ( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) || |
|
211 | - ! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) ) |
|
209 | + ('set' === $_POST['_give_price_option']) || |
|
210 | + (in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) || |
|
211 | + ! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount')) |
|
212 | 212 | ) { |
213 | 213 | // Delete old meta. |
214 | - give_delete_meta( $form_id, '_give_levels_minimum_amount' ); |
|
215 | - give_delete_meta( $form_id, '_give_levels_maximum_amount' ); |
|
214 | + give_delete_meta($form_id, '_give_levels_minimum_amount'); |
|
215 | + give_delete_meta($form_id, '_give_levels_maximum_amount'); |
|
216 | 216 | |
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Sanitize donation level amounts. |
221 | - $donation_levels_amounts = array_map( 'give_maybe_sanitize_amount', $donation_levels_amounts ); |
|
221 | + $donation_levels_amounts = array_map('give_maybe_sanitize_amount', $donation_levels_amounts); |
|
222 | 222 | |
223 | - $min_amount = min( $donation_levels_amounts ); |
|
224 | - $max_amount = max( $donation_levels_amounts ); |
|
223 | + $min_amount = min($donation_levels_amounts); |
|
224 | + $max_amount = max($donation_levels_amounts); |
|
225 | 225 | |
226 | 226 | // Set Minimum and Maximum amount for Multi Level Donation Forms. |
227 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 ); |
|
228 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db( $max_amount ) : 0 ); |
|
227 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0); |
|
228 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0); |
|
229 | 229 | } |
230 | 230 | |
231 | -add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 ); |
|
231 | +add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30); |
|
232 | 232 | |
233 | 233 | |
234 | 234 | /** |
@@ -238,23 +238,23 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @param int $payment_id |
240 | 240 | */ |
241 | -function _give_save_donor_billing_address( $payment_id ) { |
|
242 | - $donor_id = absint( give_get_payment_donor_id( $payment_id )); |
|
241 | +function _give_save_donor_billing_address($payment_id) { |
|
242 | + $donor_id = absint(give_get_payment_donor_id($payment_id)); |
|
243 | 243 | |
244 | 244 | // Bailout |
245 | - if ( ! $donor_id ) { |
|
245 | + if ( ! $donor_id) { |
|
246 | 246 | return; |
247 | 247 | } |
248 | 248 | |
249 | 249 | |
250 | 250 | /* @var Give_Donor $donor */ |
251 | - $donor = new Give_Donor( $donor_id ); |
|
251 | + $donor = new Give_Donor($donor_id); |
|
252 | 252 | |
253 | 253 | // Save address. |
254 | - $donor->add_address( 'billing[]', give_get_donation_address( $payment_id ) ); |
|
254 | + $donor->add_address('billing[]', give_get_donation_address($payment_id)); |
|
255 | 255 | } |
256 | 256 | |
257 | -add_action( 'give_complete_donation', '_give_save_donor_billing_address', 9999 ); |
|
257 | +add_action('give_complete_donation', '_give_save_donor_billing_address', 9999); |
|
258 | 258 | |
259 | 259 | |
260 | 260 | /** |
@@ -264,26 +264,26 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @param array $args |
266 | 266 | */ |
267 | -function give_update_log_form_id( $args ) { |
|
268 | - $new_form_id = absint( $args[0] ); |
|
269 | - $payment_id = absint( $args[1] ); |
|
270 | - $logs = Give()->logs->get_logs( $payment_id ); |
|
267 | +function give_update_log_form_id($args) { |
|
268 | + $new_form_id = absint($args[0]); |
|
269 | + $payment_id = absint($args[1]); |
|
270 | + $logs = Give()->logs->get_logs($payment_id); |
|
271 | 271 | |
272 | 272 | // Bailout. |
273 | - if ( empty( $logs ) ) { |
|
273 | + if (empty($logs)) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
277 | 277 | /* @var object $log */ |
278 | - foreach ( $logs as $log ) { |
|
279 | - Give()->logs->logmeta_db->update_meta( $log->ID, '_give_log_form_id', $new_form_id ); |
|
278 | + foreach ($logs as $log) { |
|
279 | + Give()->logs->logmeta_db->update_meta($log->ID, '_give_log_form_id', $new_form_id); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | // Delete cache. |
283 | 283 | Give()->logs->delete_cache(); |
284 | 284 | } |
285 | 285 | |
286 | -add_action( 'give_update_log_form_id', 'give_update_log_form_id' ); |
|
286 | +add_action('give_update_log_form_id', 'give_update_log_form_id'); |
|
287 | 287 | |
288 | 288 | /** |
289 | 289 | * Verify addon dependency before addon update |
@@ -295,22 +295,22 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @return WP_Error |
297 | 297 | */ |
298 | -function __give_verify_addon_dependency_before_update( $error, $hook_extra ) { |
|
298 | +function __give_verify_addon_dependency_before_update($error, $hook_extra) { |
|
299 | 299 | // Bailout. |
300 | - if ( is_wp_error( $error ) ) { |
|
300 | + if (is_wp_error($error)) { |
|
301 | 301 | return $error; |
302 | 302 | } |
303 | 303 | |
304 | - $plugin_base = strtolower( $hook_extra['plugin'] ); |
|
305 | - $licensed_addon = array_map( 'strtolower', Give_License::get_licensed_addons() ); |
|
304 | + $plugin_base = strtolower($hook_extra['plugin']); |
|
305 | + $licensed_addon = array_map('strtolower', Give_License::get_licensed_addons()); |
|
306 | 306 | |
307 | 307 | // Skip if not a Give addon. |
308 | - if ( ! in_array( $plugin_base, $licensed_addon ) ) { |
|
308 | + if ( ! in_array($plugin_base, $licensed_addon)) { |
|
309 | 309 | return $error; |
310 | 310 | } |
311 | 311 | |
312 | - $plugin_base = strtolower( $plugin_base ); |
|
313 | - $plugin_slug = str_replace( '.php', '', basename( $plugin_base ) ); |
|
312 | + $plugin_base = strtolower($plugin_base); |
|
313 | + $plugin_slug = str_replace('.php', '', basename($plugin_base)); |
|
314 | 314 | |
315 | 315 | /** |
316 | 316 | * Filter the addon readme.txt url |
@@ -323,15 +323,15 @@ discard block |
||
323 | 323 | $plugin_slug |
324 | 324 | ); |
325 | 325 | |
326 | - $parser = new Give_Readme_Parser( $url ); |
|
326 | + $parser = new Give_Readme_Parser($url); |
|
327 | 327 | $give_min_version = $parser->requires_at_least(); |
328 | 328 | |
329 | 329 | |
330 | - if ( version_compare( GIVE_VERSION, $give_min_version, '<' ) ) { |
|
330 | + if (version_compare(GIVE_VERSION, $give_min_version, '<')) { |
|
331 | 331 | return new WP_Error( |
332 | 332 | 'Give_Addon_Update_Error', |
333 | 333 | sprintf( |
334 | - __( 'Give version %s is required to update this add-on.', 'give' ), |
|
334 | + __('Give version %s is required to update this add-on.', 'give'), |
|
335 | 335 | $give_min_version |
336 | 336 | ) |
337 | 337 | ); |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | return $error; |
341 | 341 | } |
342 | 342 | |
343 | -add_filter( 'upgrader_pre_install', '__give_verify_addon_dependency_before_update', 10, 2 ); |
|
343 | +add_filter('upgrader_pre_install', '__give_verify_addon_dependency_before_update', 10, 2); |
|
344 | 344 | |
345 | 345 | /** |
346 | 346 | * Function to add suppress_filters param if WPML add-on is activated. |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return array WP query argument for Total Goal. |
353 | 353 | */ |
354 | -function __give_wpml_total_goal_shortcode_agrs( $args ) { |
|
354 | +function __give_wpml_total_goal_shortcode_agrs($args) { |
|
355 | 355 | $args['suppress_filters'] = true; |
356 | 356 | |
357 | 357 | return $args; |
@@ -386,19 +386,19 @@ discard block |
||
386 | 386 | * @since 2.1.4 |
387 | 387 | */ |
388 | 388 | function give_add_support_for_wpml() { |
389 | - if ( ! function_exists( 'is_plugin_active' ) ) { |
|
390 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
389 | + if ( ! function_exists('is_plugin_active')) { |
|
390 | + include_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | |
394 | - if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) { |
|
394 | + if (is_plugin_active('sitepress-multilingual-cms/sitepress.php')) { |
|
395 | 395 | |
396 | - add_filter( 'give_totals_goal_shortcode_query_args', '__give_wpml_total_goal_shortcode_agrs' ); |
|
396 | + add_filter('give_totals_goal_shortcode_query_args', '__give_wpml_total_goal_shortcode_agrs'); |
|
397 | 397 | |
398 | 398 | // @see https://wpml.org/forums/topic/problem-with-query-filter-in-get_posts-function/#post-271309 |
399 | - add_action( 'give_totals_goal_shortcode_before_render', '__give_remove_wpml_parse_query_filter', 99 ); |
|
400 | - add_action( 'give_totals_goal_shortcode_after_render', '__give_add_wpml_parse_query_filter', 99 ); |
|
399 | + add_action('give_totals_goal_shortcode_before_render', '__give_remove_wpml_parse_query_filter', 99); |
|
400 | + add_action('give_totals_goal_shortcode_after_render', '__give_add_wpml_parse_query_filter', 99); |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
404 | -add_action( 'give_init', 'give_add_support_for_wpml', 1000 ); |
|
404 | +add_action('give_init', 'give_add_support_for_wpml', 1000); |
@@ -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 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return string Donations dropdown. |
37 | 37 | */ |
38 | - public function donations_dropdown( $args = array() ) { |
|
38 | + public function donations_dropdown($args = array()) { |
|
39 | 39 | |
40 | 40 | $defaults = array( |
41 | 41 | 'name' => 'donations', |
@@ -45,32 +45,32 @@ discard block |
||
45 | 45 | 'selected' => 0, |
46 | 46 | 'chosen' => false, |
47 | 47 | 'number' => 30, |
48 | - 'placeholder' => __( 'Select a donation', 'give' ), |
|
48 | + 'placeholder' => __('Select a donation', 'give'), |
|
49 | 49 | ); |
50 | 50 | |
51 | - $args = wp_parse_args( $args, $defaults ); |
|
51 | + $args = wp_parse_args($args, $defaults); |
|
52 | 52 | |
53 | - $payments = new Give_Payments_Query( array( |
|
53 | + $payments = new Give_Payments_Query(array( |
|
54 | 54 | 'number' => $args['number'], |
55 | - ) ); |
|
55 | + )); |
|
56 | 56 | |
57 | 57 | $payments = $payments->get_payments(); |
58 | 58 | |
59 | 59 | $options = array(); |
60 | 60 | |
61 | 61 | // Provide nice human readable options. |
62 | - if ( $payments ) { |
|
62 | + if ($payments) { |
|
63 | 63 | $options[0] = $args['placeholder']; |
64 | - foreach ( $payments as $payment ) { |
|
64 | + foreach ($payments as $payment) { |
|
65 | 65 | |
66 | - $options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
66 | + $options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | } else { |
70 | - $options[0] = __( 'No donations found.', 'give' ); |
|
70 | + $options[0] = __('No donations found.', 'give'); |
|
71 | 71 | } |
72 | 72 | |
73 | - $output = $this->select( array( |
|
73 | + $output = $this->select(array( |
|
74 | 74 | 'name' => $args['name'], |
75 | 75 | 'selected' => $args['selected'], |
76 | 76 | 'id' => $args['id'], |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'select_atts' => $args['select_atts'], |
83 | 83 | 'show_option_all' => false, |
84 | 84 | 'show_option_none' => false, |
85 | - ) ); |
|
85 | + )); |
|
86 | 86 | |
87 | 87 | return $output; |
88 | 88 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return string Give forms dropdown. |
101 | 101 | */ |
102 | - public function forms_dropdown( $args = array() ) { |
|
102 | + public function forms_dropdown($args = array()) { |
|
103 | 103 | |
104 | 104 | $defaults = array( |
105 | 105 | 'name' => 'forms', |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | 'selected' => 0, |
110 | 110 | 'chosen' => false, |
111 | 111 | 'number' => 30, |
112 | - 'placeholder' => esc_attr__( 'All Forms', 'give' ), |
|
112 | + 'placeholder' => esc_attr__('All Forms', 'give'), |
|
113 | 113 | 'data' => array( |
114 | 114 | 'search-type' => 'form', |
115 | 115 | ), |
116 | 116 | 'query_args' => array() |
117 | 117 | ); |
118 | 118 | |
119 | - $args = wp_parse_args( $args, $defaults ); |
|
119 | + $args = wp_parse_args($args, $defaults); |
|
120 | 120 | |
121 | 121 | $form_args = wp_parse_args( |
122 | 122 | $args['query_args'], |
@@ -128,37 +128,37 @@ discard block |
||
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | |
131 | - $cache_key = Give_Cache::get_key( 'give_forms', $form_args, false ); |
|
131 | + $cache_key = Give_Cache::get_key('give_forms', $form_args, false); |
|
132 | 132 | |
133 | 133 | // Get forms from cache. |
134 | - $forms = Give_Cache::get_db_query( $cache_key ); |
|
134 | + $forms = Give_Cache::get_db_query($cache_key); |
|
135 | 135 | |
136 | - if ( is_null( $forms ) ) { |
|
137 | - $forms = new WP_Query( $form_args ); |
|
136 | + if (is_null($forms)) { |
|
137 | + $forms = new WP_Query($form_args); |
|
138 | 138 | $forms = $forms->posts; |
139 | - Give_Cache::set_db_query( $cache_key, $forms ); |
|
139 | + Give_Cache::set_db_query($cache_key, $forms); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | $options = array(); |
143 | 143 | |
144 | 144 | // Ensure the selected. |
145 | - if ( false !== $args['selected'] && $args['selected'] !== 0 ) { |
|
146 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
145 | + if (false !== $args['selected'] && $args['selected'] !== 0) { |
|
146 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
147 | 147 | } |
148 | 148 | |
149 | - $options[0] = esc_html__( 'No forms found.', 'give' ); |
|
150 | - if ( ! empty( $forms ) ) { |
|
149 | + $options[0] = esc_html__('No forms found.', 'give'); |
|
150 | + if ( ! empty($forms)) { |
|
151 | 151 | $options[0] = $args['placeholder']; |
152 | - foreach ( $forms as $form ) { |
|
153 | - $form_title = empty( $form->post_title ) |
|
154 | - ? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID ) |
|
152 | + foreach ($forms as $form) { |
|
153 | + $form_title = empty($form->post_title) |
|
154 | + ? sprintf(__('Untitled (#%s)', 'give'), $form->ID) |
|
155 | 155 | : $form->post_title; |
156 | 156 | |
157 | - $options[ absint( $form->ID ) ] = esc_html( $form_title ); |
|
157 | + $options[absint($form->ID)] = esc_html($form_title); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | - $output = $this->select( array( |
|
161 | + $output = $this->select(array( |
|
162 | 162 | 'name' => $args['name'], |
163 | 163 | 'selected' => $args['selected'], |
164 | 164 | 'id' => $args['id'], |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | 'show_option_all' => false, |
171 | 171 | 'show_option_none' => false, |
172 | 172 | 'data' => $args['data'], |
173 | - ) ); |
|
173 | + )); |
|
174 | 174 | |
175 | 175 | return $output; |
176 | 176 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return string Donors dropdown. |
189 | 189 | */ |
190 | - public function donor_dropdown( $args = array() ) { |
|
190 | + public function donor_dropdown($args = array()) { |
|
191 | 191 | |
192 | 192 | $defaults = array( |
193 | 193 | 'name' => 'donors', |
@@ -196,58 +196,58 @@ discard block |
||
196 | 196 | 'multiple' => false, |
197 | 197 | 'selected' => 0, |
198 | 198 | 'chosen' => true, |
199 | - 'placeholder' => esc_attr__( 'Select a Donor', 'give' ), |
|
199 | + 'placeholder' => esc_attr__('Select a Donor', 'give'), |
|
200 | 200 | 'number' => 30, |
201 | 201 | 'data' => array( |
202 | 202 | 'search-type' => 'donor', |
203 | 203 | ), |
204 | 204 | ); |
205 | 205 | |
206 | - $args = wp_parse_args( $args, $defaults ); |
|
206 | + $args = wp_parse_args($args, $defaults); |
|
207 | 207 | |
208 | - $donors = Give()->donors->get_donors( array( |
|
208 | + $donors = Give()->donors->get_donors(array( |
|
209 | 209 | 'number' => $args['number'], |
210 | - ) ); |
|
210 | + )); |
|
211 | 211 | |
212 | 212 | $options = array(); |
213 | 213 | |
214 | - if ( $donors ) { |
|
215 | - $options[0] = esc_html__( 'No donor attached', 'give' ); |
|
216 | - foreach ( $donors as $donor ) { |
|
217 | - $donor = give_get_name_with_title_prefixes( $donor ); |
|
218 | - $options[ absint( $donor->id ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
214 | + if ($donors) { |
|
215 | + $options[0] = esc_html__('No donor attached', 'give'); |
|
216 | + foreach ($donors as $donor) { |
|
217 | + $donor = give_get_name_with_title_prefixes($donor); |
|
218 | + $options[absint($donor->id)] = esc_html($donor->name.' ('.$donor->email.')'); |
|
219 | 219 | } |
220 | 220 | } else { |
221 | - $options[0] = esc_html__( 'No donors found.', 'give' ); |
|
221 | + $options[0] = esc_html__('No donors found.', 'give'); |
|
222 | 222 | } |
223 | 223 | |
224 | - if ( ! empty( $args['selected'] ) ) { |
|
224 | + if ( ! empty($args['selected'])) { |
|
225 | 225 | |
226 | 226 | // If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed. |
227 | - if ( ! array_key_exists( $args['selected'], $options ) ) { |
|
227 | + if ( ! array_key_exists($args['selected'], $options)) { |
|
228 | 228 | |
229 | - $donor = new Give_Donor( $args['selected'] ); |
|
229 | + $donor = new Give_Donor($args['selected']); |
|
230 | 230 | |
231 | - if ( $donor ) { |
|
232 | - $donor = give_get_name_with_title_prefixes( $donor ); |
|
233 | - $options[ absint( $args['selected'] ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
231 | + if ($donor) { |
|
232 | + $donor = give_get_name_with_title_prefixes($donor); |
|
233 | + $options[absint($args['selected'])] = esc_html($donor->name.' ('.$donor->email.')'); |
|
234 | 234 | |
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | - $output = $this->select( array( |
|
239 | + $output = $this->select(array( |
|
240 | 240 | 'name' => $args['name'], |
241 | 241 | 'selected' => $args['selected'], |
242 | 242 | 'id' => $args['id'], |
243 | - 'class' => $args['class'] . ' give-customer-select', |
|
243 | + 'class' => $args['class'].' give-customer-select', |
|
244 | 244 | 'options' => $options, |
245 | 245 | 'multiple' => $args['multiple'], |
246 | 246 | 'chosen' => $args['chosen'], |
247 | 247 | 'show_option_all' => false, |
248 | 248 | 'show_option_none' => false, |
249 | 249 | 'data' => $args['data'], |
250 | - ) ); |
|
250 | + )); |
|
251 | 251 | |
252 | 252 | return $output; |
253 | 253 | } |
@@ -266,22 +266,22 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return string Categories dropdown. |
268 | 268 | */ |
269 | - public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) { |
|
270 | - $categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); |
|
269 | + public function category_dropdown($name = 'give_forms_categories', $selected = 0, $args = array()) { |
|
270 | + $categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array())); |
|
271 | 271 | |
272 | 272 | $options = array(); |
273 | 273 | |
274 | - foreach ( $categories as $category ) { |
|
275 | - $options[ absint( $category->term_id ) ] = esc_html( $category->name ); |
|
274 | + foreach ($categories as $category) { |
|
275 | + $options[absint($category->term_id)] = esc_html($category->name); |
|
276 | 276 | } |
277 | 277 | |
278 | - $output = $this->select( wp_parse_args( $args, array( |
|
278 | + $output = $this->select(wp_parse_args($args, array( |
|
279 | 279 | 'name' => $name, |
280 | 280 | 'selected' => $selected, |
281 | 281 | 'options' => $options, |
282 | - 'show_option_all' => esc_html__( 'All Categories', 'give' ), |
|
282 | + 'show_option_all' => esc_html__('All Categories', 'give'), |
|
283 | 283 | 'show_option_none' => false, |
284 | - ) ) ); |
|
284 | + ))); |
|
285 | 285 | |
286 | 286 | return $output; |
287 | 287 | } |
@@ -300,22 +300,22 @@ discard block |
||
300 | 300 | * |
301 | 301 | * @return string Tags dropdown. |
302 | 302 | */ |
303 | - public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) { |
|
304 | - $tags = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) ); |
|
303 | + public function tags_dropdown($name = 'give_forms_tags', $selected = 0, $args = array()) { |
|
304 | + $tags = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array())); |
|
305 | 305 | |
306 | 306 | $options = array(); |
307 | 307 | |
308 | - foreach ( $tags as $tag ) { |
|
309 | - $options[ absint( $tag->term_id ) ] = esc_html( $tag->name ); |
|
308 | + foreach ($tags as $tag) { |
|
309 | + $options[absint($tag->term_id)] = esc_html($tag->name); |
|
310 | 310 | } |
311 | 311 | |
312 | - $output = $this->select( wp_parse_args( $args, array( |
|
312 | + $output = $this->select(wp_parse_args($args, array( |
|
313 | 313 | 'name' => $name, |
314 | 314 | 'selected' => $selected, |
315 | 315 | 'options' => $options, |
316 | - 'show_option_all' => esc_html__( 'All Tags', 'give' ), |
|
316 | + 'show_option_all' => esc_html__('All Tags', 'give'), |
|
317 | 317 | 'show_option_none' => false, |
318 | - ) ) ); |
|
318 | + ))); |
|
319 | 319 | |
320 | 320 | return $output; |
321 | 321 | } |
@@ -335,25 +335,25 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return string Years dropdown. |
337 | 337 | */ |
338 | - public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
339 | - $current = date( 'Y' ); |
|
340 | - $start_year = $current - absint( $years_before ); |
|
341 | - $end_year = $current + absint( $years_after ); |
|
342 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
338 | + public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
339 | + $current = date('Y'); |
|
340 | + $start_year = $current - absint($years_before); |
|
341 | + $end_year = $current + absint($years_after); |
|
342 | + $selected = empty($selected) ? date('Y') : $selected; |
|
343 | 343 | $options = array(); |
344 | 344 | |
345 | - while ( $start_year <= $end_year ) { |
|
346 | - $options[ absint( $start_year ) ] = $start_year; |
|
347 | - $start_year ++; |
|
345 | + while ($start_year <= $end_year) { |
|
346 | + $options[absint($start_year)] = $start_year; |
|
347 | + $start_year++; |
|
348 | 348 | } |
349 | 349 | |
350 | - $output = $this->select( array( |
|
350 | + $output = $this->select(array( |
|
351 | 351 | 'name' => $name, |
352 | 352 | 'selected' => $selected, |
353 | 353 | 'options' => $options, |
354 | 354 | 'show_option_all' => false, |
355 | 355 | 'show_option_none' => false, |
356 | - ) ); |
|
356 | + )); |
|
357 | 357 | |
358 | 358 | return $output; |
359 | 359 | } |
@@ -371,23 +371,23 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return string Months dropdown. |
373 | 373 | */ |
374 | - public function month_dropdown( $name = 'month', $selected = 0 ) { |
|
374 | + public function month_dropdown($name = 'month', $selected = 0) { |
|
375 | 375 | $month = 1; |
376 | 376 | $options = array(); |
377 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
377 | + $selected = empty($selected) ? date('n') : $selected; |
|
378 | 378 | |
379 | - while ( $month <= 12 ) { |
|
380 | - $options[ absint( $month ) ] = give_month_num_to_name( $month ); |
|
381 | - $month ++; |
|
379 | + while ($month <= 12) { |
|
380 | + $options[absint($month)] = give_month_num_to_name($month); |
|
381 | + $month++; |
|
382 | 382 | } |
383 | 383 | |
384 | - $output = $this->select( array( |
|
384 | + $output = $this->select(array( |
|
385 | 385 | 'name' => $name, |
386 | 386 | 'selected' => $selected, |
387 | 387 | 'options' => $options, |
388 | 388 | 'show_option_all' => false, |
389 | 389 | 'show_option_none' => false, |
390 | - ) ); |
|
390 | + )); |
|
391 | 391 | |
392 | 392 | return $output; |
393 | 393 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * |
405 | 405 | * @return string The dropdown. |
406 | 406 | */ |
407 | - public function select( $args = array() ) { |
|
407 | + public function select($args = array()) { |
|
408 | 408 | $defaults = array( |
409 | 409 | 'options' => array(), |
410 | 410 | 'name' => null, |
@@ -415,74 +415,74 @@ discard block |
||
415 | 415 | 'placeholder' => null, |
416 | 416 | 'multiple' => false, |
417 | 417 | 'select_atts' => false, |
418 | - 'show_option_all' => __( 'All', 'give' ), |
|
419 | - 'show_option_none' => __( 'None', 'give' ), |
|
418 | + 'show_option_all' => __('All', 'give'), |
|
419 | + 'show_option_none' => __('None', 'give'), |
|
420 | 420 | 'data' => array(), |
421 | 421 | 'readonly' => false, |
422 | 422 | 'disabled' => false, |
423 | 423 | ); |
424 | 424 | |
425 | - $args = wp_parse_args( $args, $defaults ); |
|
425 | + $args = wp_parse_args($args, $defaults); |
|
426 | 426 | |
427 | 427 | $data_elements = ''; |
428 | - foreach ( $args['data'] as $key => $value ) { |
|
429 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
428 | + foreach ($args['data'] as $key => $value) { |
|
429 | + $data_elements .= ' data-'.esc_attr($key).'="'.esc_attr($value).'"'; |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | $multiple = ''; |
433 | - if ( $args['multiple'] ) { |
|
433 | + if ($args['multiple']) { |
|
434 | 434 | $multiple = 'MULTIPLE'; |
435 | 435 | } |
436 | 436 | |
437 | - if ( $args['chosen'] ) { |
|
437 | + if ($args['chosen']) { |
|
438 | 438 | $args['class'] .= ' give-select-chosen'; |
439 | 439 | } |
440 | 440 | |
441 | 441 | $placeholder = ''; |
442 | - if ( $args['placeholder'] ) { |
|
442 | + if ($args['placeholder']) { |
|
443 | 443 | $placeholder = $args['placeholder']; |
444 | 444 | } |
445 | 445 | |
446 | 446 | $output = sprintf( |
447 | 447 | '<select name="%1$s" id="%2$s" autocomplete="address-level4" class="give-select %3$s" %4$s %5$s placeholder="%6$s" data-placeholder="%6$s" %7$s>', |
448 | - esc_attr( $args['name'] ), |
|
449 | - esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ), |
|
450 | - esc_attr( $args['class'] ), |
|
448 | + esc_attr($args['name']), |
|
449 | + esc_attr(sanitize_key(str_replace('-', '_', $args['id']))), |
|
450 | + esc_attr($args['class']), |
|
451 | 451 | $multiple, |
452 | 452 | $args['select_atts'], |
453 | 453 | $placeholder, |
454 | 454 | $data_elements |
455 | 455 | ); |
456 | 456 | |
457 | - if ( $args['show_option_all'] ) { |
|
458 | - if ( $args['multiple'] ) { |
|
459 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
457 | + if ($args['show_option_all']) { |
|
458 | + if ($args['multiple']) { |
|
459 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
460 | 460 | } else { |
461 | - $selected = selected( $args['selected'], 0, false ); |
|
461 | + $selected = selected($args['selected'], 0, false); |
|
462 | 462 | } |
463 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
463 | + $output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>'; |
|
464 | 464 | } |
465 | 465 | |
466 | - if ( ! empty( $args['options'] ) ) { |
|
466 | + if ( ! empty($args['options'])) { |
|
467 | 467 | |
468 | - if ( $args['show_option_none'] ) { |
|
469 | - if ( $args['multiple'] ) { |
|
470 | - $selected = selected( true, in_array( - 1, $args['selected'] ), false ); |
|
468 | + if ($args['show_option_none']) { |
|
469 | + if ($args['multiple']) { |
|
470 | + $selected = selected(true, in_array( -1, $args['selected'] ), false); |
|
471 | 471 | } else { |
472 | - $selected = selected( $args['selected'], - 1, false ); |
|
472 | + $selected = selected($args['selected'], - 1, false); |
|
473 | 473 | } |
474 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
474 | + $output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>'; |
|
475 | 475 | } |
476 | 476 | |
477 | - foreach ( $args['options'] as $key => $option ) { |
|
477 | + foreach ($args['options'] as $key => $option) { |
|
478 | 478 | |
479 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
480 | - $selected = selected( true, in_array( $key, $args['selected'] ), false ); |
|
479 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
480 | + $selected = selected(true, in_array($key, $args['selected']), false); |
|
481 | 481 | } else { |
482 | - $selected = selected( $args['selected'], $key, false ); |
|
482 | + $selected = selected($args['selected'], $key, false); |
|
483 | 483 | } |
484 | 484 | |
485 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
485 | + $output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>'; |
|
486 | 486 | } |
487 | 487 | } |
488 | 488 | |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | * |
504 | 504 | * @return string The checkbox. |
505 | 505 | */ |
506 | - public function checkbox( $args = array() ) { |
|
506 | + public function checkbox($args = array()) { |
|
507 | 507 | $defaults = array( |
508 | 508 | 'name' => null, |
509 | 509 | 'current' => null, |
@@ -514,16 +514,16 @@ discard block |
||
514 | 514 | ), |
515 | 515 | ); |
516 | 516 | |
517 | - $args = wp_parse_args( $args, $defaults ); |
|
517 | + $args = wp_parse_args($args, $defaults); |
|
518 | 518 | |
519 | 519 | $options = ''; |
520 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
520 | + if ( ! empty($args['options']['disabled'])) { |
|
521 | 521 | $options .= ' disabled="disabled"'; |
522 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
522 | + } elseif ( ! empty($args['options']['readonly'])) { |
|
523 | 523 | $options .= ' readonly'; |
524 | 524 | } |
525 | 525 | |
526 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
526 | + $output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />'; |
|
527 | 527 | |
528 | 528 | return $output; |
529 | 529 | } |
@@ -540,22 +540,22 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return string The text field. |
542 | 542 | */ |
543 | - public function text( $args = array() ) { |
|
543 | + public function text($args = array()) { |
|
544 | 544 | // Backwards compatibility. |
545 | - if ( func_num_args() > 1 ) { |
|
545 | + if (func_num_args() > 1) { |
|
546 | 546 | $args = func_get_args(); |
547 | 547 | |
548 | 548 | $name = $args[0]; |
549 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
550 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
551 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
549 | + $value = isset($args[1]) ? $args[1] : ''; |
|
550 | + $label = isset($args[2]) ? $args[2] : ''; |
|
551 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | $defaults = array( |
555 | - 'name' => isset( $name ) ? $name : 'text', |
|
556 | - 'value' => isset( $value ) ? $value : null, |
|
557 | - 'label' => isset( $label ) ? $label : null, |
|
558 | - 'desc' => isset( $desc ) ? $desc : null, |
|
555 | + 'name' => isset($name) ? $name : 'text', |
|
556 | + 'value' => isset($value) ? $value : null, |
|
557 | + 'label' => isset($label) ? $label : null, |
|
558 | + 'desc' => isset($desc) ? $desc : null, |
|
559 | 559 | 'placeholder' => '', |
560 | 560 | 'class' => 'regular-text', |
561 | 561 | 'disabled' => false, |
@@ -563,29 +563,29 @@ discard block |
||
563 | 563 | 'data' => false, |
564 | 564 | ); |
565 | 565 | |
566 | - $args = wp_parse_args( $args, $defaults ); |
|
566 | + $args = wp_parse_args($args, $defaults); |
|
567 | 567 | |
568 | 568 | $disabled = ''; |
569 | - if ( $args['disabled'] ) { |
|
569 | + if ($args['disabled']) { |
|
570 | 570 | $disabled = ' disabled="disabled"'; |
571 | 571 | } |
572 | 572 | |
573 | 573 | $data = ''; |
574 | - if ( ! empty( $args['data'] ) ) { |
|
575 | - foreach ( $args['data'] as $key => $value ) { |
|
576 | - $data .= 'data-' . $key . '="' . $value . '" '; |
|
574 | + if ( ! empty($args['data'])) { |
|
575 | + foreach ($args['data'] as $key => $value) { |
|
576 | + $data .= 'data-'.$key.'="'.$value.'" '; |
|
577 | 577 | } |
578 | 578 | } |
579 | 579 | |
580 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
580 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
581 | 581 | |
582 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
582 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
583 | 583 | |
584 | - if ( ! empty( $args['desc'] ) ) { |
|
585 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
584 | + if ( ! empty($args['desc'])) { |
|
585 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
586 | 586 | } |
587 | 587 | |
588 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; |
|
588 | + $output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>'; |
|
589 | 589 | |
590 | 590 | $output .= '</span>'; |
591 | 591 | |
@@ -604,15 +604,15 @@ discard block |
||
604 | 604 | * |
605 | 605 | * @return string The date picker. |
606 | 606 | */ |
607 | - public function date_field( $args = array() ) { |
|
607 | + public function date_field($args = array()) { |
|
608 | 608 | |
609 | - if ( empty( $args['class'] ) ) { |
|
609 | + if (empty($args['class'])) { |
|
610 | 610 | $args['class'] = 'give_datepicker'; |
611 | - } elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) { |
|
611 | + } elseif ( ! strpos($args['class'], 'give_datepicker')) { |
|
612 | 612 | $args['class'] .= ' give_datepicker'; |
613 | 613 | } |
614 | 614 | |
615 | - return $this->text( $args ); |
|
615 | + return $this->text($args); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | /** |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | * |
628 | 628 | * @return string The textarea. |
629 | 629 | */ |
630 | - public function textarea( $args = array() ) { |
|
630 | + public function textarea($args = array()) { |
|
631 | 631 | $defaults = array( |
632 | 632 | 'name' => 'textarea', |
633 | 633 | 'value' => null, |
@@ -637,21 +637,21 @@ discard block |
||
637 | 637 | 'disabled' => false, |
638 | 638 | ); |
639 | 639 | |
640 | - $args = wp_parse_args( $args, $defaults ); |
|
640 | + $args = wp_parse_args($args, $defaults); |
|
641 | 641 | |
642 | 642 | $disabled = ''; |
643 | - if ( $args['disabled'] ) { |
|
643 | + if ($args['disabled']) { |
|
644 | 644 | $disabled = ' disabled="disabled"'; |
645 | 645 | } |
646 | 646 | |
647 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
647 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
648 | 648 | |
649 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
649 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
650 | 650 | |
651 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
651 | + $output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>'; |
|
652 | 652 | |
653 | - if ( ! empty( $args['desc'] ) ) { |
|
654 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
653 | + if ( ! empty($args['desc'])) { |
|
654 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | $output .= '</span>'; |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | * |
672 | 672 | * @return string The text field with ajax search. |
673 | 673 | */ |
674 | - public function ajax_user_search( $args = array() ) { |
|
674 | + public function ajax_user_search($args = array()) { |
|
675 | 675 | |
676 | 676 | $defaults = array( |
677 | 677 | 'name' => 'users', |
@@ -682,13 +682,13 @@ discard block |
||
682 | 682 | 'chosen' => true, |
683 | 683 | 'number' => 30, |
684 | 684 | 'select_atts' => '', |
685 | - 'placeholder' => __( 'Select a user', 'give' ), |
|
685 | + 'placeholder' => __('Select a user', 'give'), |
|
686 | 686 | 'data' => array( |
687 | 687 | 'search-type' => 'user', |
688 | 688 | ), |
689 | 689 | ); |
690 | 690 | |
691 | - $args = wp_parse_args( $args, $defaults ); |
|
691 | + $args = wp_parse_args($args, $defaults); |
|
692 | 692 | |
693 | 693 | // Set initial args. |
694 | 694 | $get_users_args = array( |
@@ -697,31 +697,31 @@ discard block |
||
697 | 697 | |
698 | 698 | // Ensure selected user is not included in initial query. |
699 | 699 | // This is because sites with many users, it's not a guarantee the selected user will be returned. |
700 | - if ( ! empty( $args['selected'] ) ) { |
|
700 | + if ( ! empty($args['selected'])) { |
|
701 | 701 | $get_users_args['exclude'] = $args['selected']; |
702 | 702 | } |
703 | 703 | |
704 | 704 | // Initial users array. |
705 | - $users = apply_filters( 'give_ajax_user_search_initial_results', get_users( $get_users_args ), $args ); |
|
705 | + $users = apply_filters('give_ajax_user_search_initial_results', get_users($get_users_args), $args); |
|
706 | 706 | |
707 | 707 | // Now add the selected user to the $users array if the arg is present. |
708 | - if ( ! empty( $args['selected'] ) ) { |
|
709 | - $selected_user = apply_filters( 'give_ajax_user_search_selected_results', get_users( "include={$args['selected']}" ), $args );; |
|
710 | - $users = array_merge( $users, $selected_user ); |
|
708 | + if ( ! empty($args['selected'])) { |
|
709 | + $selected_user = apply_filters('give_ajax_user_search_selected_results', get_users("include={$args['selected']}"), $args); ; |
|
710 | + $users = array_merge($users, $selected_user); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | $options = array(); |
714 | 714 | |
715 | - if ( $users ) { |
|
715 | + if ($users) { |
|
716 | 716 | $options[0] = $args['placeholder']; |
717 | - foreach ( $users as $user ) { |
|
718 | - $options[ absint( $user->ID ) ] = esc_html( $user->user_login . ' (' . $user->user_email . ')' ); |
|
717 | + foreach ($users as $user) { |
|
718 | + $options[absint($user->ID)] = esc_html($user->user_login.' ('.$user->user_email.')'); |
|
719 | 719 | } |
720 | 720 | } else { |
721 | - $options[0] = __( 'No users found.', 'give' ); |
|
721 | + $options[0] = __('No users found.', 'give'); |
|
722 | 722 | } |
723 | 723 | |
724 | - $output = $this->select( array( |
|
724 | + $output = $this->select(array( |
|
725 | 725 | 'name' => $args['name'], |
726 | 726 | 'selected' => $args['selected'], |
727 | 727 | 'id' => $args['id'], |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | 'show_option_all' => false, |
735 | 735 | 'show_option_none' => false, |
736 | 736 | 'data' => $args['data'], |
737 | - ) ); |
|
737 | + )); |
|
738 | 738 | |
739 | 739 | return $output; |
740 | 740 |
@@ -10,61 +10,61 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
13 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load Give file. |
18 | -include_once( 'give.php' ); |
|
18 | +include_once('give.php'); |
|
19 | 19 | |
20 | 20 | global $wpdb, $wp_roles; |
21 | 21 | |
22 | 22 | |
23 | -if ( give_is_setting_enabled( give_get_option( 'uninstall_on_delete' ) ) ) { |
|
23 | +if (give_is_setting_enabled(give_get_option('uninstall_on_delete'))) { |
|
24 | 24 | |
25 | 25 | // Delete All the Custom Post Types. |
26 | - $give_taxonomies = array( 'form_category', 'form_tag' ); |
|
27 | - $give_post_types = array( 'give_forms', 'give_payment' ); |
|
28 | - foreach ( $give_post_types as $post_type ) { |
|
26 | + $give_taxonomies = array('form_category', 'form_tag'); |
|
27 | + $give_post_types = array('give_forms', 'give_payment'); |
|
28 | + foreach ($give_post_types as $post_type) { |
|
29 | 29 | |
30 | - $give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) ); |
|
31 | - $items = get_posts( array( |
|
30 | + $give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type)); |
|
31 | + $items = get_posts(array( |
|
32 | 32 | 'post_type' => $post_type, |
33 | 33 | 'post_status' => 'any', |
34 | - 'numberposts' => - 1, |
|
34 | + 'numberposts' => -1, |
|
35 | 35 | 'fields' => 'ids', |
36 | - ) ); |
|
36 | + )); |
|
37 | 37 | |
38 | - if ( $items ) { |
|
39 | - foreach ( $items as $item ) { |
|
40 | - wp_delete_post( $item, true ); |
|
38 | + if ($items) { |
|
39 | + foreach ($items as $item) { |
|
40 | + wp_delete_post($item, true); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | // Delete All the Terms & Taxonomies. |
46 | - foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) { |
|
46 | + foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) { |
|
47 | 47 | |
48 | - $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) ); |
|
48 | + $terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy)); |
|
49 | 49 | |
50 | 50 | // Delete Terms. |
51 | - if ( $terms ) { |
|
52 | - foreach ( $terms as $term ) { |
|
53 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) ); |
|
54 | - $wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) ); |
|
51 | + if ($terms) { |
|
52 | + foreach ($terms as $term) { |
|
53 | + $wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id)); |
|
54 | + $wpdb->delete($wpdb->terms, array('term_id' => $term->term_id)); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Delete Taxonomies. |
59 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) ); |
|
59 | + $wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s')); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // Delete the Plugin Pages. |
63 | - $give_created_pages = array( 'success_page', 'failure_page', 'history_page' ); |
|
64 | - foreach ( $give_created_pages as $p ) { |
|
65 | - $page = give_get_option( $p, false ); |
|
66 | - if ( $page ) { |
|
67 | - wp_delete_post( $page, true ); |
|
63 | + $give_created_pages = array('success_page', 'failure_page', 'history_page'); |
|
64 | + foreach ($give_created_pages as $p) { |
|
65 | + $page = give_get_option($p, false); |
|
66 | + if ($page) { |
|
67 | + wp_delete_post($page, true); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -73,28 +73,28 @@ discard block |
||
73 | 73 | Give()->roles->remove_caps(); |
74 | 74 | |
75 | 75 | // Delete the Roles. |
76 | - $give_roles = array( 'give_manager', 'give_accountant', 'give_worker', 'give_donor' ); |
|
77 | - foreach ( $give_roles as $role ) { |
|
78 | - remove_role( $role ); |
|
76 | + $give_roles = array('give_manager', 'give_accountant', 'give_worker', 'give_donor'); |
|
77 | + foreach ($give_roles as $role) { |
|
78 | + remove_role($role); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | // Remove all database tables. |
82 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' ); |
|
83 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donormeta' ); |
|
84 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' ); |
|
85 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' ); |
|
86 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_paymentmeta' ); |
|
87 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_formmeta' ); |
|
88 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_logs' ); |
|
89 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_logmeta' ); |
|
90 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_sequential_ordering' ); |
|
91 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_sessions' ); |
|
82 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors'); |
|
83 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donormeta'); |
|
84 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers'); |
|
85 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta'); |
|
86 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_paymentmeta'); |
|
87 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_formmeta'); |
|
88 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_logs'); |
|
89 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_logmeta'); |
|
90 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_sequential_ordering'); |
|
91 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_sessions'); |
|
92 | 92 | |
93 | 93 | // Cleanup Cron Events. |
94 | - wp_clear_scheduled_hook( 'give_daily_scheduled_events' ); |
|
95 | - wp_clear_scheduled_hook( 'give_weekly_scheduled_events' ); |
|
96 | - wp_clear_scheduled_hook( 'give_daily_cron' ); |
|
97 | - wp_clear_scheduled_hook( 'give_weekly_cron' ); |
|
94 | + wp_clear_scheduled_hook('give_daily_scheduled_events'); |
|
95 | + wp_clear_scheduled_hook('give_weekly_scheduled_events'); |
|
96 | + wp_clear_scheduled_hook('give_daily_cron'); |
|
97 | + wp_clear_scheduled_hook('give_weekly_cron'); |
|
98 | 98 | |
99 | 99 | // Get all options. |
100 | 100 | $give_option_names = $wpdb->get_col( |
@@ -104,16 +104,16 @@ discard block |
||
104 | 104 | ) |
105 | 105 | ); |
106 | 106 | |
107 | - if ( ! empty( $give_option_names ) ) { |
|
107 | + if ( ! empty($give_option_names)) { |
|
108 | 108 | // Convert option name to transient or option name. |
109 | 109 | $new_give_option_names = array(); |
110 | 110 | |
111 | 111 | // Delete all the Plugin Options. |
112 | - foreach ( $give_option_names as $option ) { |
|
113 | - if ( false !== strpos( $option, 'give_cache' ) ) { |
|
114 | - Give_Cache::delete( $option ); |
|
112 | + foreach ($give_option_names as $option) { |
|
113 | + if (false !== strpos($option, 'give_cache')) { |
|
114 | + Give_Cache::delete($option); |
|
115 | 115 | } else { |
116 | - delete_option( $option ); |
|
116 | + delete_option($option); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
@@ -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 | |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | global $wpdb; |
52 | 52 | |
53 | 53 | // @todo: We leave $wpdb->paymentmeta for backward compatibility, use $wpdb->donationmeta instead. We can remove it after 2.1.3. |
54 | - $wpdb->paymentmeta = $wpdb->donationmeta = $this->table_name = $wpdb->prefix . 'give_donationmeta'; |
|
54 | + $wpdb->paymentmeta = $wpdb->donationmeta = $this->table_name = $wpdb->prefix.'give_donationmeta'; |
|
55 | 55 | $this->version = '1.0'; |
56 | 56 | |
57 | 57 | // Backward compatibility. |
58 | - if ( ! give_has_upgrade_completed( 'v220_rename_donation_meta_type' ) ) { |
|
58 | + if ( ! give_has_upgrade_completed('v220_rename_donation_meta_type')) { |
|
59 | 59 | $this->meta_type = 'payment'; |
60 | - $wpdb->paymentmeta = $wpdb->donationmeta = $this->table_name = $wpdb->prefix . 'give_paymentmeta'; |
|
60 | + $wpdb->paymentmeta = $wpdb->donationmeta = $this->table_name = $wpdb->prefix.'give_paymentmeta'; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $this->register_table(); |
@@ -90,6 +90,6 @@ discard block |
||
90 | 90 | * @return bool |
91 | 91 | */ |
92 | 92 | protected function is_custom_meta_table_active() { |
93 | - return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ); |
|
93 | + return give_has_upgrade_completed('v20_move_metadata_into_new_table'); |
|
94 | 94 | } |
95 | 95 | } |
@@ -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,39 +98,39 @@ 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, false ); |
|
107 | + update_option('give_completed_upgrades', $completed_upgrades, false); |
|
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 | - case version_compare( $give_version, '2.2.0', '<' ) : |
|
122 | + case version_compare($give_version, '2.2.0', '<') : |
|
123 | 123 | give_v220_upgrades(); |
124 | 124 | $did_upgrade = true; |
125 | 125 | } |
126 | 126 | |
127 | - if ( $did_upgrade ) { |
|
128 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ), false ); |
|
127 | + if ($did_upgrade) { |
|
128 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION), false); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
133 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
132 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
133 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
134 | 134 | |
135 | 135 | /** |
136 | 136 | * Display Upgrade Notices. |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @return void |
146 | 146 | */ |
147 | -function give_show_upgrade_notices( $give_updates ) { |
|
147 | +function give_show_upgrade_notices($give_updates) { |
|
148 | 148 | // v1.3.2 Upgrades |
149 | 149 | $give_updates->register( |
150 | 150 | array( |
@@ -210,32 +210,32 @@ discard block |
||
210 | 210 | ); |
211 | 211 | |
212 | 212 | // v1.8.17 Upgrades for donations. |
213 | - $give_updates->register( array( |
|
213 | + $give_updates->register(array( |
|
214 | 214 | 'id' => 'v1817_update_donation_iranian_currency_code', |
215 | 215 | 'version' => '1.8.17', |
216 | 216 | 'callback' => 'give_v1817_update_donation_iranian_currency_code', |
217 | - ) ); |
|
217 | + )); |
|
218 | 218 | |
219 | 219 | // v1.8.17 Upgrades for cleanup of user roles. |
220 | - $give_updates->register( array( |
|
220 | + $give_updates->register(array( |
|
221 | 221 | 'id' => 'v1817_cleanup_user_roles', |
222 | 222 | 'version' => '1.8.17', |
223 | 223 | 'callback' => 'give_v1817_cleanup_user_roles', |
224 | - ) ); |
|
224 | + )); |
|
225 | 225 | |
226 | 226 | // v1.8.18 Upgrades for assigning custom amount to existing set donations. |
227 | - $give_updates->register( array( |
|
227 | + $give_updates->register(array( |
|
228 | 228 | 'id' => 'v1818_assign_custom_amount_set_donation', |
229 | 229 | 'version' => '1.8.18', |
230 | 230 | 'callback' => 'give_v1818_assign_custom_amount_set_donation', |
231 | - ) ); |
|
231 | + )); |
|
232 | 232 | |
233 | 233 | // v1.8.18 Cleanup the Give Worker Role Caps. |
234 | - $give_updates->register( array( |
|
234 | + $give_updates->register(array( |
|
235 | 235 | 'id' => 'v1818_give_worker_role_cleanup', |
236 | 236 | 'version' => '1.8.18', |
237 | 237 | 'callback' => 'give_v1818_give_worker_role_cleanup', |
238 | - ) ); |
|
238 | + )); |
|
239 | 239 | |
240 | 240 | // v2.0.0 Upgrades |
241 | 241 | $give_updates->register( |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | 'id' => 'v20_move_metadata_into_new_table', |
290 | 290 | 'version' => '2.0.0', |
291 | 291 | 'callback' => 'give_v20_move_metadata_into_new_table_callback', |
292 | - 'depend' => array( 'v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata' ), |
|
292 | + 'depend' => array('v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata'), |
|
293 | 293 | ) |
294 | 294 | ); |
295 | 295 | |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | 'id' => 'v201_move_metadata_into_new_table', |
336 | 336 | 'version' => '2.0.1', |
337 | 337 | 'callback' => 'give_v201_move_metadata_into_new_table_callback', |
338 | - 'depend' => array( 'v201_upgrades_payment_metadata', 'v201_add_missing_donors' ), |
|
338 | + 'depend' => array('v201_upgrades_payment_metadata', 'v201_add_missing_donors'), |
|
339 | 339 | ) |
340 | 340 | ); |
341 | 341 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | 'id' => 'v213_delete_donation_meta', |
364 | 364 | 'version' => '2.1.3', |
365 | 365 | 'callback' => 'give_v213_delete_donation_meta_callback', |
366 | - 'depends' => array( 'v201_move_metadata_into_new_table' ) |
|
366 | + 'depends' => array('v201_move_metadata_into_new_table') |
|
367 | 367 | ) |
368 | 368 | ); |
369 | 369 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | ); |
378 | 378 | } |
379 | 379 | |
380 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
380 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
381 | 381 | |
382 | 382 | /** |
383 | 383 | * Triggers all upgrade functions |
@@ -389,29 +389,29 @@ discard block |
||
389 | 389 | */ |
390 | 390 | function give_trigger_upgrades() { |
391 | 391 | |
392 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
393 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
392 | + if ( ! current_user_can('manage_give_settings')) { |
|
393 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
394 | 394 | 'response' => 403, |
395 | - ) ); |
|
395 | + )); |
|
396 | 396 | } |
397 | 397 | |
398 | - $give_version = get_option( 'give_version' ); |
|
398 | + $give_version = get_option('give_version'); |
|
399 | 399 | |
400 | - if ( ! $give_version ) { |
|
400 | + if ( ! $give_version) { |
|
401 | 401 | // 1.0 is the first version to use this option so we must add it. |
402 | 402 | $give_version = '1.0'; |
403 | - add_option( 'give_version', $give_version, '', false ); |
|
403 | + add_option('give_version', $give_version, '', false); |
|
404 | 404 | } |
405 | 405 | |
406 | - update_option( 'give_version', GIVE_VERSION, false ); |
|
407 | - delete_option( 'give_doing_upgrade' ); |
|
406 | + update_option('give_version', GIVE_VERSION, false); |
|
407 | + delete_option('give_doing_upgrade'); |
|
408 | 408 | |
409 | - if ( DOING_AJAX ) { |
|
410 | - die( 'complete' ); |
|
409 | + if (DOING_AJAX) { |
|
410 | + die('complete'); |
|
411 | 411 | } // End if(). |
412 | 412 | } |
413 | 413 | |
414 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
414 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
415 | 415 | |
416 | 416 | |
417 | 417 | /** |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | |
430 | 430 | // UPDATE DB METAKEYS. |
431 | 431 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
432 | - $query = $wpdb->query( $sql ); |
|
432 | + $query = $wpdb->query($sql); |
|
433 | 433 | |
434 | 434 | $give_updates->percentage = 100; |
435 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
435 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | |
@@ -456,24 +456,24 @@ discard block |
||
456 | 456 | $where .= "AND ( p.post_status = 'abandoned' )"; |
457 | 457 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
458 | 458 | |
459 | - $sql = $select . $join . $where; |
|
460 | - $found_payments = $wpdb->get_col( $sql ); |
|
459 | + $sql = $select.$join.$where; |
|
460 | + $found_payments = $wpdb->get_col($sql); |
|
461 | 461 | |
462 | - foreach ( $found_payments as $payment ) { |
|
462 | + foreach ($found_payments as $payment) { |
|
463 | 463 | |
464 | 464 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
465 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
465 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
466 | 466 | |
467 | 467 | // 1450124863 = 12/10/2015 20:42:25. |
468 | - if ( $modified_time >= 1450124863 ) { |
|
468 | + if ($modified_time >= 1450124863) { |
|
469 | 469 | |
470 | - give_update_payment_status( $payment, 'pending' ); |
|
470 | + give_update_payment_status($payment, 'pending'); |
|
471 | 471 | |
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
475 | 475 | $give_updates->percentage = 100; |
476 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
476 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
@@ -486,17 +486,17 @@ discard block |
||
486 | 486 | */ |
487 | 487 | function give_v152_cleanup_users() { |
488 | 488 | |
489 | - $give_version = get_option( 'give_version' ); |
|
489 | + $give_version = get_option('give_version'); |
|
490 | 490 | |
491 | - if ( ! $give_version ) { |
|
491 | + if ( ! $give_version) { |
|
492 | 492 | // 1.0 is the first version to use this option so we must add it. |
493 | 493 | $give_version = '1.0'; |
494 | 494 | } |
495 | 495 | |
496 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
496 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
497 | 497 | |
498 | 498 | // v1.5.2 Upgrades |
499 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
499 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
500 | 500 | |
501 | 501 | // Delete all caps with "ss". |
502 | 502 | // Also delete all unused "campaign" roles. |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | ); |
544 | 544 | |
545 | 545 | global $wp_roles; |
546 | - foreach ( $delete_caps as $cap ) { |
|
547 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
548 | - $wp_roles->remove_cap( $role, $cap ); |
|
546 | + foreach ($delete_caps as $cap) { |
|
547 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
548 | + $wp_roles->remove_cap($role, $cap); |
|
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
@@ -555,15 +555,15 @@ discard block |
||
555 | 555 | $roles->add_caps(); |
556 | 556 | |
557 | 557 | // The Update Ran. |
558 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ), false ); |
|
559 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
560 | - delete_option( 'give_doing_upgrade' ); |
|
558 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION), false); |
|
559 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
560 | + delete_option('give_doing_upgrade'); |
|
561 | 561 | |
562 | 562 | }// End if(). |
563 | 563 | |
564 | 564 | } |
565 | 565 | |
566 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
566 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
567 | 567 | |
568 | 568 | /** |
569 | 569 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -606,53 +606,53 @@ discard block |
||
606 | 606 | |
607 | 607 | // Get addons license key. |
608 | 608 | $addons = array(); |
609 | - foreach ( $give_options as $key => $value ) { |
|
610 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
611 | - $addons[ $key ] = $value; |
|
609 | + foreach ($give_options as $key => $value) { |
|
610 | + if (false !== strpos($key, '_license_key')) { |
|
611 | + $addons[$key] = $value; |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | |
615 | 615 | // Bailout: We do not have any addon license data to upgrade. |
616 | - if ( empty( $addons ) ) { |
|
616 | + if (empty($addons)) { |
|
617 | 617 | return false; |
618 | 618 | } |
619 | 619 | |
620 | - foreach ( $addons as $key => $addon_license ) { |
|
620 | + foreach ($addons as $key => $addon_license) { |
|
621 | 621 | |
622 | 622 | // Get addon shortname. |
623 | - $shortname = str_replace( '_license_key', '', $key ); |
|
623 | + $shortname = str_replace('_license_key', '', $key); |
|
624 | 624 | |
625 | 625 | // Addon license option name. |
626 | - $addon_license_option_name = $shortname . '_license_active'; |
|
626 | + $addon_license_option_name = $shortname.'_license_active'; |
|
627 | 627 | |
628 | 628 | // bailout if license is empty. |
629 | - if ( empty( $addon_license ) ) { |
|
630 | - delete_option( $addon_license_option_name ); |
|
629 | + if (empty($addon_license)) { |
|
630 | + delete_option($addon_license_option_name); |
|
631 | 631 | continue; |
632 | 632 | } |
633 | 633 | |
634 | 634 | // Get addon name. |
635 | 635 | $addon_name = array(); |
636 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
637 | - foreach ( $addon_name_parts as $name_part ) { |
|
636 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
637 | + foreach ($addon_name_parts as $name_part) { |
|
638 | 638 | |
639 | 639 | // Fix addon name |
640 | - switch ( $name_part ) { |
|
640 | + switch ($name_part) { |
|
641 | 641 | case 'authorizenet' : |
642 | 642 | $name_part = 'authorize.net'; |
643 | 643 | break; |
644 | 644 | } |
645 | 645 | |
646 | - $addon_name[] = ucfirst( $name_part ); |
|
646 | + $addon_name[] = ucfirst($name_part); |
|
647 | 647 | } |
648 | 648 | |
649 | - $addon_name = implode( ' ', $addon_name ); |
|
649 | + $addon_name = implode(' ', $addon_name); |
|
650 | 650 | |
651 | 651 | // Data to send to the API. |
652 | 652 | $api_params = array( |
653 | 653 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
654 | 654 | 'license' => $addon_license, |
655 | - 'item_name' => urlencode( $addon_name ), |
|
655 | + 'item_name' => urlencode($addon_name), |
|
656 | 656 | 'url' => home_url(), |
657 | 657 | ); |
658 | 658 | |
@@ -667,17 +667,17 @@ discard block |
||
667 | 667 | ); |
668 | 668 | |
669 | 669 | // Make sure there are no errors. |
670 | - if ( is_wp_error( $response ) ) { |
|
671 | - delete_option( $addon_license_option_name ); |
|
670 | + if (is_wp_error($response)) { |
|
671 | + delete_option($addon_license_option_name); |
|
672 | 672 | continue; |
673 | 673 | } |
674 | 674 | |
675 | 675 | // Tell WordPress to look for updates. |
676 | - set_site_transient( 'update_plugins', null ); |
|
676 | + set_site_transient('update_plugins', null); |
|
677 | 677 | |
678 | 678 | // Decode license data. |
679 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
680 | - update_option( $addon_license_option_name, $license_data, false ); |
|
679 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
680 | + update_option($addon_license_option_name, $license_data, false); |
|
681 | 681 | }// End foreach(). |
682 | 682 | } |
683 | 683 | |
@@ -707,9 +707,9 @@ discard block |
||
707 | 707 | ); |
708 | 708 | |
709 | 709 | global $wp_roles; |
710 | - foreach ( $delete_caps as $cap ) { |
|
711 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
712 | - $wp_roles->remove_cap( $role, $cap ); |
|
710 | + foreach ($delete_caps as $cap) { |
|
711 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
712 | + $wp_roles->remove_cap($role, $cap); |
|
713 | 713 | } |
714 | 714 | } |
715 | 715 | |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | function give_v18_upgrades_core_setting() { |
744 | 744 | // Core settings which changes from checkbox to radio. |
745 | 745 | $core_setting_names = array_merge( |
746 | - array_keys( give_v18_renamed_core_settings() ), |
|
746 | + array_keys(give_v18_renamed_core_settings()), |
|
747 | 747 | array( |
748 | 748 | 'uninstall_on_delete', |
749 | 749 | 'scripts_footer', |
@@ -755,48 +755,48 @@ discard block |
||
755 | 755 | ); |
756 | 756 | |
757 | 757 | // Bailout: If not any setting define. |
758 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
758 | + if ($give_settings = get_option('give_settings')) { |
|
759 | 759 | |
760 | 760 | $setting_changed = false; |
761 | 761 | |
762 | 762 | // Loop: check each setting field. |
763 | - foreach ( $core_setting_names as $setting_name ) { |
|
763 | + foreach ($core_setting_names as $setting_name) { |
|
764 | 764 | // New setting name. |
765 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
765 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
766 | 766 | |
767 | 767 | // Continue: If setting already set. |
768 | 768 | if ( |
769 | - array_key_exists( $new_setting_name, $give_settings ) |
|
770 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
769 | + array_key_exists($new_setting_name, $give_settings) |
|
770 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
771 | 771 | ) { |
772 | 772 | continue; |
773 | 773 | } |
774 | 774 | |
775 | 775 | // Set checkbox value to radio value. |
776 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
776 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
777 | 777 | |
778 | 778 | // @see https://github.com/WordImpress/Give/issues/1063. |
779 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
779 | + if (false !== strpos($setting_name, 'disable_')) { |
|
780 | 780 | |
781 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
782 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
781 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
782 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
783 | 783 | |
784 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
784 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | // Tell bot to update core setting to db. |
788 | - if ( ! $setting_changed ) { |
|
788 | + if ( ! $setting_changed) { |
|
789 | 789 | $setting_changed = true; |
790 | 790 | } |
791 | 791 | } |
792 | 792 | |
793 | 793 | // Update setting only if they changed. |
794 | - if ( $setting_changed ) { |
|
795 | - update_option( 'give_settings', $give_settings, false ); |
|
794 | + if ($setting_changed) { |
|
795 | + update_option('give_settings', $give_settings, false); |
|
796 | 796 | } |
797 | 797 | }// End if(). |
798 | 798 | |
799 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
799 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | /** |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | $give_updates = Give_Updates::get_instance(); |
811 | 811 | |
812 | 812 | // form query |
813 | - $forms = new WP_Query( array( |
|
813 | + $forms = new WP_Query(array( |
|
814 | 814 | 'paged' => $give_updates->step, |
815 | 815 | 'status' => 'any', |
816 | 816 | 'order' => 'ASC', |
@@ -819,41 +819,41 @@ discard block |
||
819 | 819 | ) |
820 | 820 | ); |
821 | 821 | |
822 | - if ( $forms->have_posts() ) { |
|
823 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
822 | + if ($forms->have_posts()) { |
|
823 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
824 | 824 | |
825 | - while ( $forms->have_posts() ) { |
|
825 | + while ($forms->have_posts()) { |
|
826 | 826 | $forms->the_post(); |
827 | 827 | |
828 | 828 | // Form content. |
829 | 829 | // Note in version 1.8 display content setting split into display content and content placement setting. |
830 | 830 | // You can delete _give_content_option in future. |
831 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
832 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
833 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
834 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
831 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
832 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
833 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
834 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
835 | 835 | |
836 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
837 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
836 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
837 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | // "Disable" Guest Donation. Checkbox. |
841 | 841 | // See: https://github.com/WordImpress/Give/issues/1470. |
842 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
843 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
844 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
842 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
843 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
844 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
845 | 845 | |
846 | 846 | // Offline Donations. |
847 | 847 | // See: https://github.com/WordImpress/Give/issues/1579. |
848 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
849 | - if ( 'no' === $offline_donation ) { |
|
848 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
849 | + if ('no' === $offline_donation) { |
|
850 | 850 | $offline_donation_newval = 'global'; |
851 | - } elseif ( 'yes' === $offline_donation ) { |
|
851 | + } elseif ('yes' === $offline_donation) { |
|
852 | 852 | $offline_donation_newval = 'enabled'; |
853 | 853 | } else { |
854 | 854 | $offline_donation_newval = 'disabled'; |
855 | 855 | } |
856 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
856 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
857 | 857 | |
858 | 858 | // Convert yes/no setting field to enabled/disabled. |
859 | 859 | $form_radio_settings = array( |
@@ -873,15 +873,15 @@ discard block |
||
873 | 873 | '_give_offline_donation_enable_billing_fields_single', |
874 | 874 | ); |
875 | 875 | |
876 | - foreach ( $form_radio_settings as $meta_key ) { |
|
876 | + foreach ($form_radio_settings as $meta_key) { |
|
877 | 877 | // Get value. |
878 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
878 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
879 | 879 | |
880 | 880 | // Convert meta value only if it is in yes/no/none. |
881 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
881 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
882 | 882 | |
883 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
884 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
883 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
884 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
885 | 885 | } |
886 | 886 | } |
887 | 887 | }// End while(). |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | |
891 | 891 | } else { |
892 | 892 | // No more forms found, finish up. |
893 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
893 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
894 | 894 | } |
895 | 895 | } |
896 | 896 | |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | '%_transient_give_stats_%', |
958 | 958 | 'give_cache%', |
959 | 959 | '%_transient_give_add_ons_feed%', |
960 | - '%_transient__give_ajax_works' . |
|
960 | + '%_transient__give_ajax_works'. |
|
961 | 961 | '%_transient_give_total_api_keys%', |
962 | 962 | '%_transient_give_i18n_give_promo_hide%', |
963 | 963 | '%_transient_give_contributors%', |
@@ -984,24 +984,24 @@ discard block |
||
984 | 984 | ARRAY_A |
985 | 985 | ); |
986 | 986 | |
987 | - if ( ! empty( $user_apikey_options ) ) { |
|
988 | - foreach ( $user_apikey_options as $user ) { |
|
989 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
990 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
991 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
987 | + if ( ! empty($user_apikey_options)) { |
|
988 | + foreach ($user_apikey_options as $user) { |
|
989 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
990 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
991 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
992 | 992 | } |
993 | 993 | } |
994 | 994 | |
995 | - if ( ! empty( $cached_options ) ) { |
|
996 | - foreach ( $cached_options as $option ) { |
|
997 | - switch ( true ) { |
|
998 | - case ( false !== strpos( $option, 'transient' ) ): |
|
999 | - $option = str_replace( '_transient_', '', $option ); |
|
1000 | - delete_transient( $option ); |
|
995 | + if ( ! empty($cached_options)) { |
|
996 | + foreach ($cached_options as $option) { |
|
997 | + switch (true) { |
|
998 | + case (false !== strpos($option, 'transient')): |
|
999 | + $option = str_replace('_transient_', '', $option); |
|
1000 | + delete_transient($option); |
|
1001 | 1001 | break; |
1002 | 1002 | |
1003 | 1003 | default: |
1004 | - delete_option( $option ); |
|
1004 | + delete_option($option); |
|
1005 | 1005 | } |
1006 | 1006 | } |
1007 | 1007 | } |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | global $wp_roles; |
1020 | 1020 | |
1021 | 1021 | // Get the role object. |
1022 | - $give_worker = get_role( 'give_worker' ); |
|
1022 | + $give_worker = get_role('give_worker'); |
|
1023 | 1023 | |
1024 | 1024 | // A list of capabilities to add for give workers. |
1025 | 1025 | $caps_to_add = array( |
@@ -1027,9 +1027,9 @@ discard block |
||
1027 | 1027 | 'edit_pages', |
1028 | 1028 | ); |
1029 | 1029 | |
1030 | - foreach ( $caps_to_add as $cap ) { |
|
1030 | + foreach ($caps_to_add as $cap) { |
|
1031 | 1031 | // Add the capability. |
1032 | - $give_worker->add_cap( $cap ); |
|
1032 | + $give_worker->add_cap($cap); |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | } |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | $give_updates = Give_Updates::get_instance(); |
1047 | 1047 | |
1048 | 1048 | // form query. |
1049 | - $donation_forms = new WP_Query( array( |
|
1049 | + $donation_forms = new WP_Query(array( |
|
1050 | 1050 | 'paged' => $give_updates->step, |
1051 | 1051 | 'status' => 'any', |
1052 | 1052 | 'order' => 'ASC', |
@@ -1055,10 +1055,10 @@ discard block |
||
1055 | 1055 | ) |
1056 | 1056 | ); |
1057 | 1057 | |
1058 | - if ( $donation_forms->have_posts() ) { |
|
1059 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1058 | + if ($donation_forms->have_posts()) { |
|
1059 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1060 | 1060 | |
1061 | - while ( $donation_forms->have_posts() ) { |
|
1061 | + while ($donation_forms->have_posts()) { |
|
1062 | 1062 | $donation_forms->the_post(); |
1063 | 1063 | $form_id = get_the_ID(); |
1064 | 1064 | |
@@ -1066,41 +1066,41 @@ discard block |
||
1066 | 1066 | update_post_meta( |
1067 | 1067 | $form_id, |
1068 | 1068 | '_give_set_price', |
1069 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
1069 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
1070 | 1070 | ); |
1071 | 1071 | |
1072 | 1072 | // Remove formatting from _give_custom_amount_minimum. |
1073 | 1073 | update_post_meta( |
1074 | 1074 | $form_id, |
1075 | 1075 | '_give_custom_amount_minimum', |
1076 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
1076 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
1077 | 1077 | ); |
1078 | 1078 | |
1079 | 1079 | // Bailout. |
1080 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
1080 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
1081 | 1081 | continue; |
1082 | 1082 | } |
1083 | 1083 | |
1084 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
1084 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
1085 | 1085 | |
1086 | - if ( ! empty( $donation_levels ) ) { |
|
1086 | + if ( ! empty($donation_levels)) { |
|
1087 | 1087 | |
1088 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
1089 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
1090 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
1088 | + foreach ($donation_levels as $index => $donation_level) { |
|
1089 | + if (isset($donation_level['_give_amount'])) { |
|
1090 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
1091 | 1091 | } |
1092 | 1092 | } |
1093 | 1093 | |
1094 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
1094 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
1095 | 1095 | |
1096 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
1096 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
1097 | 1097 | |
1098 | - $min_amount = min( $donation_levels_amounts ); |
|
1099 | - $max_amount = max( $donation_levels_amounts ); |
|
1098 | + $min_amount = min($donation_levels_amounts); |
|
1099 | + $max_amount = max($donation_levels_amounts); |
|
1100 | 1100 | |
1101 | 1101 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
1102 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
1103 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
1102 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
1103 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | } |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | wp_reset_postdata(); |
1110 | 1110 | } else { |
1111 | 1111 | // The Update Ran. |
1112 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
1112 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | */ |
1160 | 1160 | function give_v20_upgrades() { |
1161 | 1161 | // Update cache setting. |
1162 | - give_update_option( 'cache', 'enabled' ); |
|
1162 | + give_update_option('cache', 'enabled'); |
|
1163 | 1163 | |
1164 | 1164 | // Upgrade email settings. |
1165 | 1165 | give_v20_upgrades_email_setting(); |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | $all_setting = give_get_settings(); |
1179 | 1179 | |
1180 | 1180 | // Bailout on fresh install. |
1181 | - if ( empty( $all_setting ) ) { |
|
1181 | + if (empty($all_setting)) { |
|
1182 | 1182 | return; |
1183 | 1183 | } |
1184 | 1184 | |
@@ -1197,19 +1197,19 @@ discard block |
||
1197 | 1197 | 'admin_notices' => 'new-donation_notification', |
1198 | 1198 | ); |
1199 | 1199 | |
1200 | - foreach ( $settings as $old_setting => $new_setting ) { |
|
1200 | + foreach ($settings as $old_setting => $new_setting) { |
|
1201 | 1201 | // Do not update already modified |
1202 | - if ( ! is_array( $new_setting ) ) { |
|
1203 | - if ( array_key_exists( $new_setting, $all_setting ) || ! array_key_exists( $old_setting, $all_setting ) ) { |
|
1202 | + if ( ! is_array($new_setting)) { |
|
1203 | + if (array_key_exists($new_setting, $all_setting) || ! array_key_exists($old_setting, $all_setting)) { |
|
1204 | 1204 | continue; |
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | |
1208 | - switch ( $old_setting ) { |
|
1208 | + switch ($old_setting) { |
|
1209 | 1209 | case 'admin_notices': |
1210 | - $notification_status = give_get_option( $old_setting, 'enabled' ); |
|
1210 | + $notification_status = give_get_option($old_setting, 'enabled'); |
|
1211 | 1211 | |
1212 | - give_update_option( $new_setting, $notification_status ); |
|
1212 | + give_update_option($new_setting, $notification_status); |
|
1213 | 1213 | |
1214 | 1214 | // @todo: Delete this option later ( version > 2.0 ), We need this for per form email addon. |
1215 | 1215 | // give_delete_option( $old_setting ); |
@@ -1220,19 +1220,19 @@ discard block |
||
1220 | 1220 | case 'admin_notice_emails': |
1221 | 1221 | $recipients = give_get_admin_notice_emails(); |
1222 | 1222 | |
1223 | - foreach ( $new_setting as $setting ) { |
|
1223 | + foreach ($new_setting as $setting) { |
|
1224 | 1224 | // bailout if setting already exist. |
1225 | - if ( array_key_exists( $setting, $all_setting ) ) { |
|
1225 | + if (array_key_exists($setting, $all_setting)) { |
|
1226 | 1226 | continue; |
1227 | 1227 | } |
1228 | 1228 | |
1229 | - give_update_option( $setting, $recipients ); |
|
1229 | + give_update_option($setting, $recipients); |
|
1230 | 1230 | } |
1231 | 1231 | break; |
1232 | 1232 | |
1233 | 1233 | default: |
1234 | - give_update_option( $new_setting, give_get_option( $old_setting ) ); |
|
1235 | - give_delete_option( $old_setting ); |
|
1234 | + give_update_option($new_setting, give_get_option($old_setting)); |
|
1235 | + give_delete_option($old_setting); |
|
1236 | 1236 | } |
1237 | 1237 | } |
1238 | 1238 | } |
@@ -1249,22 +1249,22 @@ discard block |
||
1249 | 1249 | $give_settings = give_get_settings(); |
1250 | 1250 | $give_setting_updated = false; |
1251 | 1251 | |
1252 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
1252 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
1253 | 1253 | $give_settings['number_decimals'] = 0; |
1254 | 1254 | $give_settings['decimal_separator'] = ''; |
1255 | 1255 | $give_setting_updated = true; |
1256 | 1256 | |
1257 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
1257 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
1258 | 1258 | $give_settings['number_decimals'] = 0; |
1259 | 1259 | $give_setting_updated = true; |
1260 | 1260 | |
1261 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
1261 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
1262 | 1262 | $give_settings['number_decimals'] = 5; |
1263 | 1263 | $give_setting_updated = true; |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - if ( $give_setting_updated ) { |
|
1267 | - update_option( 'give_settings', $give_settings, false ); |
|
1266 | + if ($give_setting_updated) { |
|
1267 | + update_option('give_settings', $give_settings, false); |
|
1268 | 1268 | } |
1269 | 1269 | } |
1270 | 1270 | |
@@ -1283,69 +1283,69 @@ discard block |
||
1283 | 1283 | $give_updates = Give_Updates::get_instance(); |
1284 | 1284 | |
1285 | 1285 | // form query. |
1286 | - $donation_forms = new WP_Query( array( |
|
1286 | + $donation_forms = new WP_Query(array( |
|
1287 | 1287 | 'paged' => $give_updates->step, |
1288 | 1288 | 'status' => 'any', |
1289 | 1289 | 'order' => 'ASC', |
1290 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1290 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1291 | 1291 | 'posts_per_page' => 20, |
1292 | 1292 | ) |
1293 | 1293 | ); |
1294 | - if ( $donation_forms->have_posts() ) { |
|
1295 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1294 | + if ($donation_forms->have_posts()) { |
|
1295 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1296 | 1296 | |
1297 | - while ( $donation_forms->have_posts() ) { |
|
1297 | + while ($donation_forms->have_posts()) { |
|
1298 | 1298 | $donation_forms->the_post(); |
1299 | 1299 | global $post; |
1300 | 1300 | |
1301 | - $meta = get_post_meta( $post->ID ); |
|
1301 | + $meta = get_post_meta($post->ID); |
|
1302 | 1302 | |
1303 | - switch ( $post->post_type ) { |
|
1303 | + switch ($post->post_type) { |
|
1304 | 1304 | case 'give_forms': |
1305 | 1305 | // _give_set_price. |
1306 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
1307 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
1306 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
1307 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
1308 | 1308 | } |
1309 | 1309 | |
1310 | 1310 | // _give_custom_amount_minimum. |
1311 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
1312 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
1311 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
1312 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
1313 | 1313 | } |
1314 | 1314 | |
1315 | 1315 | // _give_levels_minimum_amount. |
1316 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
1317 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
1316 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
1317 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
1318 | 1318 | } |
1319 | 1319 | |
1320 | 1320 | // _give_levels_maximum_amount. |
1321 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
1322 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
1321 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
1322 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
1323 | 1323 | } |
1324 | 1324 | |
1325 | 1325 | // _give_set_goal. |
1326 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
1327 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
1326 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
1327 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
1328 | 1328 | } |
1329 | 1329 | |
1330 | 1330 | // _give_form_earnings. |
1331 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
1332 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
1331 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
1332 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | // _give_custom_amount_minimum. |
1336 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
1337 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
1336 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
1337 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
1338 | 1338 | |
1339 | - foreach ( $donation_levels as $index => $level ) { |
|
1340 | - if ( empty( $level['_give_amount'] ) ) { |
|
1339 | + foreach ($donation_levels as $index => $level) { |
|
1340 | + if (empty($level['_give_amount'])) { |
|
1341 | 1341 | continue; |
1342 | 1342 | } |
1343 | 1343 | |
1344 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
1344 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
1345 | 1345 | } |
1346 | 1346 | |
1347 | 1347 | $meta['_give_donation_levels'] = $donation_levels; |
1348 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
1348 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
1349 | 1349 | } |
1350 | 1350 | |
1351 | 1351 | |
@@ -1353,8 +1353,8 @@ discard block |
||
1353 | 1353 | |
1354 | 1354 | case 'give_payment': |
1355 | 1355 | // _give_payment_total. |
1356 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
1357 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
1356 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
1357 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
1358 | 1358 | } |
1359 | 1359 | |
1360 | 1360 | break; |
@@ -1365,7 +1365,7 @@ discard block |
||
1365 | 1365 | wp_reset_postdata(); |
1366 | 1366 | } else { |
1367 | 1367 | // The Update Ran. |
1368 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
1368 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
1369 | 1369 | } |
1370 | 1370 | } |
1371 | 1371 | |
@@ -1384,22 +1384,22 @@ discard block |
||
1384 | 1384 | $give_updates = Give_Updates::get_instance(); |
1385 | 1385 | |
1386 | 1386 | // form query. |
1387 | - $donors = Give()->donors->get_donors( array( |
|
1387 | + $donors = Give()->donors->get_donors(array( |
|
1388 | 1388 | 'number' => 20, |
1389 | - 'offset' => $give_updates->get_offset( 20 ), |
|
1389 | + 'offset' => $give_updates->get_offset(20), |
|
1390 | 1390 | ) |
1391 | 1391 | ); |
1392 | 1392 | |
1393 | - if ( ! empty( $donors ) ) { |
|
1394 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
1393 | + if ( ! empty($donors)) { |
|
1394 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
1395 | 1395 | |
1396 | 1396 | /* @var Object $donor */ |
1397 | - foreach ( $donors as $donor ) { |
|
1398 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
1397 | + foreach ($donors as $donor) { |
|
1398 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
1399 | 1399 | } |
1400 | 1400 | } else { |
1401 | 1401 | // The Update Ran. |
1402 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
1402 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
1403 | 1403 | } |
1404 | 1404 | } |
1405 | 1405 | |
@@ -1413,25 +1413,25 @@ discard block |
||
1413 | 1413 | $give_updates = Give_Updates::get_instance(); |
1414 | 1414 | |
1415 | 1415 | // Fetch all the existing donors. |
1416 | - $donors = Give()->donors->get_donors( array( |
|
1416 | + $donors = Give()->donors->get_donors(array( |
|
1417 | 1417 | 'number' => 20, |
1418 | - 'offset' => $give_updates->get_offset( 20 ), |
|
1418 | + 'offset' => $give_updates->get_offset(20), |
|
1419 | 1419 | ) |
1420 | 1420 | ); |
1421 | 1421 | |
1422 | - if ( ! empty( $donors ) ) { |
|
1423 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
1422 | + if ( ! empty($donors)) { |
|
1423 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
1424 | 1424 | |
1425 | 1425 | /* @var Object $donor */ |
1426 | - foreach ( $donors as $donor ) { |
|
1426 | + foreach ($donors as $donor) { |
|
1427 | 1427 | $user_id = $donor->user_id; |
1428 | 1428 | |
1429 | 1429 | // Proceed, if donor is attached with user. |
1430 | - if ( $user_id ) { |
|
1431 | - $user = get_userdata( $user_id ); |
|
1430 | + if ($user_id) { |
|
1431 | + $user = get_userdata($user_id); |
|
1432 | 1432 | |
1433 | 1433 | // Update user role, if user has subscriber role. |
1434 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
1434 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
1435 | 1435 | wp_update_user( |
1436 | 1436 | array( |
1437 | 1437 | 'ID' => $user_id, |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | } |
1444 | 1444 | } else { |
1445 | 1445 | // The Update Ran. |
1446 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
1446 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
1447 | 1447 | } |
1448 | 1448 | } |
1449 | 1449 | |
@@ -1455,7 +1455,7 @@ discard block |
||
1455 | 1455 | */ |
1456 | 1456 | function give_v1813_upgrades() { |
1457 | 1457 | // Update admin setting. |
1458 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
1458 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
1459 | 1459 | |
1460 | 1460 | // Update Give roles. |
1461 | 1461 | $roles = new Give_Roles(); |
@@ -1473,33 +1473,33 @@ discard block |
||
1473 | 1473 | $give_updates = Give_Updates::get_instance(); |
1474 | 1474 | |
1475 | 1475 | // form query. |
1476 | - $payments = new WP_Query( array( |
|
1476 | + $payments = new WP_Query(array( |
|
1477 | 1477 | 'paged' => $give_updates->step, |
1478 | 1478 | 'status' => 'any', |
1479 | 1479 | 'order' => 'ASC', |
1480 | - 'post_type' => array( 'give_payment' ), |
|
1480 | + 'post_type' => array('give_payment'), |
|
1481 | 1481 | 'posts_per_page' => 100, |
1482 | 1482 | ) |
1483 | 1483 | ); |
1484 | 1484 | |
1485 | - if ( $payments->have_posts() ) { |
|
1486 | - $give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 100 ) ); |
|
1485 | + if ($payments->have_posts()) { |
|
1486 | + $give_updates->set_percentage($payments->found_posts, ($give_updates->step * 100)); |
|
1487 | 1487 | |
1488 | - while ( $payments->have_posts() ) { |
|
1488 | + while ($payments->have_posts()) { |
|
1489 | 1489 | $payments->the_post(); |
1490 | 1490 | |
1491 | - $payment_meta = give_get_payment_meta( get_the_ID() ); |
|
1491 | + $payment_meta = give_get_payment_meta(get_the_ID()); |
|
1492 | 1492 | |
1493 | - if ( 'RIAL' === $payment_meta['currency'] ) { |
|
1493 | + if ('RIAL' === $payment_meta['currency']) { |
|
1494 | 1494 | $payment_meta['currency'] = 'IRR'; |
1495 | - give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta ); |
|
1495 | + give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta); |
|
1496 | 1496 | } |
1497 | 1497 | |
1498 | 1498 | } |
1499 | 1499 | |
1500 | 1500 | } else { |
1501 | 1501 | // The Update Ran. |
1502 | - give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
|
1502 | + give_set_upgrade_complete('v1817_update_donation_iranian_currency_code'); |
|
1503 | 1503 | } |
1504 | 1504 | } |
1505 | 1505 | |
@@ -1512,9 +1512,9 @@ discard block |
||
1512 | 1512 | function give_v1817_upgrades() { |
1513 | 1513 | $give_settings = give_get_settings(); |
1514 | 1514 | |
1515 | - if ( 'RIAL' === $give_settings['currency'] ) { |
|
1515 | + if ('RIAL' === $give_settings['currency']) { |
|
1516 | 1516 | $give_settings['currency'] = 'IRR'; |
1517 | - update_option( 'give_settings', $give_settings, false ); |
|
1517 | + update_option('give_settings', $give_settings, false); |
|
1518 | 1518 | } |
1519 | 1519 | } |
1520 | 1520 | |
@@ -1527,7 +1527,7 @@ discard block |
||
1527 | 1527 | |
1528 | 1528 | global $wp_roles; |
1529 | 1529 | |
1530 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1530 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1531 | 1531 | return; |
1532 | 1532 | } |
1533 | 1533 | |
@@ -1551,15 +1551,15 @@ discard block |
||
1551 | 1551 | ), |
1552 | 1552 | ); |
1553 | 1553 | |
1554 | - foreach ( $add_caps as $role => $caps ) { |
|
1555 | - foreach ( $caps as $cap ) { |
|
1556 | - $wp_roles->add_cap( $role, $cap ); |
|
1554 | + foreach ($add_caps as $role => $caps) { |
|
1555 | + foreach ($caps as $cap) { |
|
1556 | + $wp_roles->add_cap($role, $cap); |
|
1557 | 1557 | } |
1558 | 1558 | } |
1559 | 1559 | |
1560 | - foreach ( $remove_caps as $role => $caps ) { |
|
1561 | - foreach ( $caps as $cap ) { |
|
1562 | - $wp_roles->remove_cap( $role, $cap ); |
|
1560 | + foreach ($remove_caps as $role => $caps) { |
|
1561 | + foreach ($caps as $cap) { |
|
1562 | + $wp_roles->remove_cap($role, $cap); |
|
1563 | 1563 | } |
1564 | 1564 | } |
1565 | 1565 | |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | $roles->add_roles(); |
1584 | 1584 | $roles->add_caps(); |
1585 | 1585 | |
1586 | - give_set_upgrade_complete( 'v1817_cleanup_user_roles' ); |
|
1586 | + give_set_upgrade_complete('v1817_cleanup_user_roles'); |
|
1587 | 1587 | } |
1588 | 1588 | |
1589 | 1589 | /** |
@@ -1594,7 +1594,7 @@ discard block |
||
1594 | 1594 | function give_v1818_upgrades() { |
1595 | 1595 | |
1596 | 1596 | // Remove email_access_installed from give_settings. |
1597 | - give_delete_option( 'email_access_installed' ); |
|
1597 | + give_delete_option('email_access_installed'); |
|
1598 | 1598 | } |
1599 | 1599 | |
1600 | 1600 | /** |
@@ -1607,23 +1607,23 @@ discard block |
||
1607 | 1607 | /* @var Give_Updates $give_updates */ |
1608 | 1608 | $give_updates = Give_Updates::get_instance(); |
1609 | 1609 | |
1610 | - $donations = new WP_Query( array( |
|
1610 | + $donations = new WP_Query(array( |
|
1611 | 1611 | 'paged' => $give_updates->step, |
1612 | 1612 | 'status' => 'any', |
1613 | 1613 | 'order' => 'ASC', |
1614 | - 'post_type' => array( 'give_payment' ), |
|
1614 | + 'post_type' => array('give_payment'), |
|
1615 | 1615 | 'posts_per_page' => 100, |
1616 | 1616 | ) |
1617 | 1617 | ); |
1618 | 1618 | |
1619 | - if ( $donations->have_posts() ) { |
|
1620 | - $give_updates->set_percentage( $donations->found_posts, $give_updates->step * 100 ); |
|
1619 | + if ($donations->have_posts()) { |
|
1620 | + $give_updates->set_percentage($donations->found_posts, $give_updates->step * 100); |
|
1621 | 1621 | |
1622 | - while ( $donations->have_posts() ) { |
|
1622 | + while ($donations->have_posts()) { |
|
1623 | 1623 | $donations->the_post(); |
1624 | 1624 | |
1625 | - $form = new Give_Donate_Form( give_get_meta( get_the_ID(), '_give_payment_form_id', true ) ); |
|
1626 | - $donation_meta = give_get_payment_meta( get_the_ID() ); |
|
1625 | + $form = new Give_Donate_Form(give_get_meta(get_the_ID(), '_give_payment_form_id', true)); |
|
1626 | + $donation_meta = give_get_payment_meta(get_the_ID()); |
|
1627 | 1627 | |
1628 | 1628 | // Update Donation meta with price_id set as custom, only if it is: |
1629 | 1629 | // 1. Donation Type = Set Donation. |
@@ -1632,19 +1632,19 @@ discard block |
||
1632 | 1632 | if ( |
1633 | 1633 | $form->ID && |
1634 | 1634 | $form->is_set_type_donation_form() && |
1635 | - ( 'custom' !== $donation_meta['price_id'] ) && |
|
1636 | - $form->is_custom_price( give_get_meta( get_the_ID(), '_give_payment_total', true ) ) |
|
1635 | + ('custom' !== $donation_meta['price_id']) && |
|
1636 | + $form->is_custom_price(give_get_meta(get_the_ID(), '_give_payment_total', true)) |
|
1637 | 1637 | ) { |
1638 | 1638 | $donation_meta['price_id'] = 'custom'; |
1639 | - give_update_meta( get_the_ID(), '_give_payment_meta', $donation_meta ); |
|
1640 | - give_update_meta( get_the_ID(), '_give_payment_price_id', 'custom' ); |
|
1639 | + give_update_meta(get_the_ID(), '_give_payment_meta', $donation_meta); |
|
1640 | + give_update_meta(get_the_ID(), '_give_payment_price_id', 'custom'); |
|
1641 | 1641 | } |
1642 | 1642 | } |
1643 | 1643 | |
1644 | 1644 | wp_reset_postdata(); |
1645 | 1645 | } else { |
1646 | 1646 | // Update Ran Successfully. |
1647 | - give_set_upgrade_complete( 'v1818_assign_custom_amount_set_donation' ); |
|
1647 | + give_set_upgrade_complete('v1818_assign_custom_amount_set_donation'); |
|
1648 | 1648 | } |
1649 | 1649 | } |
1650 | 1650 | |
@@ -1662,7 +1662,7 @@ discard block |
||
1662 | 1662 | |
1663 | 1663 | global $wp_roles; |
1664 | 1664 | |
1665 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1665 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1666 | 1666 | return; |
1667 | 1667 | } |
1668 | 1668 | |
@@ -1680,9 +1680,9 @@ discard block |
||
1680 | 1680 | ), |
1681 | 1681 | ); |
1682 | 1682 | |
1683 | - foreach ( $remove_caps as $role => $caps ) { |
|
1684 | - foreach ( $caps as $cap ) { |
|
1685 | - $wp_roles->remove_cap( $role, $cap ); |
|
1683 | + foreach ($remove_caps as $role => $caps) { |
|
1684 | + foreach ($caps as $cap) { |
|
1685 | + $wp_roles->remove_cap($role, $cap); |
|
1686 | 1686 | } |
1687 | 1687 | } |
1688 | 1688 | |
@@ -1693,7 +1693,7 @@ discard block |
||
1693 | 1693 | $roles->add_roles(); |
1694 | 1694 | $roles->add_caps(); |
1695 | 1695 | |
1696 | - give_set_upgrade_complete( 'v1818_give_worker_role_cleanup' ); |
|
1696 | + give_set_upgrade_complete('v1818_give_worker_role_cleanup'); |
|
1697 | 1697 | } |
1698 | 1698 | |
1699 | 1699 | /** |
@@ -1707,7 +1707,7 @@ discard block |
||
1707 | 1707 | $give_updates = Give_Updates::get_instance(); |
1708 | 1708 | |
1709 | 1709 | // form query |
1710 | - $forms = new WP_Query( array( |
|
1710 | + $forms = new WP_Query(array( |
|
1711 | 1711 | 'paged' => $give_updates->step, |
1712 | 1712 | 'status' => 'any', |
1713 | 1713 | 'order' => 'ASC', |
@@ -1716,22 +1716,22 @@ discard block |
||
1716 | 1716 | ) |
1717 | 1717 | ); |
1718 | 1718 | |
1719 | - if ( $forms->have_posts() ) { |
|
1720 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1719 | + if ($forms->have_posts()) { |
|
1720 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1721 | 1721 | |
1722 | - while ( $forms->have_posts() ) { |
|
1722 | + while ($forms->have_posts()) { |
|
1723 | 1723 | $forms->the_post(); |
1724 | 1724 | global $post; |
1725 | 1725 | |
1726 | 1726 | // Update offline instruction email notification status. |
1727 | - $offline_instruction_notification_status = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
1728 | - $offline_instruction_notification_status = give_is_setting_enabled( $offline_instruction_notification_status, array( |
|
1727 | + $offline_instruction_notification_status = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
1728 | + $offline_instruction_notification_status = give_is_setting_enabled($offline_instruction_notification_status, array( |
|
1729 | 1729 | 'enabled', |
1730 | 1730 | 'global', |
1731 | - ) ) |
|
1731 | + )) |
|
1732 | 1732 | ? $offline_instruction_notification_status |
1733 | 1733 | : 'global'; |
1734 | - update_post_meta( get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status ); |
|
1734 | + update_post_meta(get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status); |
|
1735 | 1735 | |
1736 | 1736 | // Update offline instruction email message. |
1737 | 1737 | update_post_meta( |
@@ -1763,7 +1763,7 @@ discard block |
||
1763 | 1763 | wp_reset_postdata(); |
1764 | 1764 | } else { |
1765 | 1765 | // No more forms found, finish up. |
1766 | - give_set_upgrade_complete( 'v20_upgrades_form_metadata' ); |
|
1766 | + give_set_upgrade_complete('v20_upgrades_form_metadata'); |
|
1767 | 1767 | } |
1768 | 1768 | } |
1769 | 1769 | |
@@ -1780,7 +1780,7 @@ discard block |
||
1780 | 1780 | $give_updates = Give_Updates::get_instance(); |
1781 | 1781 | |
1782 | 1782 | // form query |
1783 | - $forms = new WP_Query( array( |
|
1783 | + $forms = new WP_Query(array( |
|
1784 | 1784 | 'paged' => $give_updates->step, |
1785 | 1785 | 'status' => 'any', |
1786 | 1786 | 'order' => 'ASC', |
@@ -1789,19 +1789,19 @@ discard block |
||
1789 | 1789 | ) |
1790 | 1790 | ); |
1791 | 1791 | |
1792 | - if ( $forms->have_posts() ) { |
|
1793 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1792 | + if ($forms->have_posts()) { |
|
1793 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1794 | 1794 | |
1795 | - while ( $forms->have_posts() ) { |
|
1795 | + while ($forms->have_posts()) { |
|
1796 | 1796 | $forms->the_post(); |
1797 | 1797 | global $post; |
1798 | 1798 | |
1799 | 1799 | // Split _give_payment_meta meta. |
1800 | 1800 | // @todo Remove _give_payment_meta after releases 2.0 |
1801 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
1801 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
1802 | 1802 | |
1803 | - if ( ! empty( $payment_meta ) ) { |
|
1804 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
1803 | + if ( ! empty($payment_meta)) { |
|
1804 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
1805 | 1805 | } |
1806 | 1806 | |
1807 | 1807 | $deprecated_meta_keys = array( |
@@ -1810,9 +1810,9 @@ discard block |
||
1810 | 1810 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
1811 | 1811 | ); |
1812 | 1812 | |
1813 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
1813 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
1814 | 1814 | // Do not add new meta key if already exist. |
1815 | - 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 ) ) ) { |
|
1815 | + 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))) { |
|
1816 | 1816 | continue; |
1817 | 1817 | } |
1818 | 1818 | |
@@ -1821,25 +1821,25 @@ discard block |
||
1821 | 1821 | array( |
1822 | 1822 | 'post_id' => $post->ID, |
1823 | 1823 | 'meta_key' => $new_meta_key, |
1824 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
1824 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
1825 | 1825 | ) |
1826 | 1826 | ); |
1827 | 1827 | } |
1828 | 1828 | |
1829 | 1829 | // Bailout |
1830 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
1830 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
1831 | 1831 | /* @var Give_Donor $donor */ |
1832 | - $donor = new Give_Donor( $donor_id ); |
|
1832 | + $donor = new Give_Donor($donor_id); |
|
1833 | 1833 | |
1834 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
1835 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
1836 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
1837 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
1838 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
1839 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
1834 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
1835 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
1836 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
1837 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
1838 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
1839 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
1840 | 1840 | |
1841 | 1841 | // Save address. |
1842 | - $donor->add_address( 'billing[]', $address ); |
|
1842 | + $donor->add_address('billing[]', $address); |
|
1843 | 1843 | } |
1844 | 1844 | |
1845 | 1845 | }// End while(). |
@@ -1850,7 +1850,7 @@ discard block |
||
1850 | 1850 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
1851 | 1851 | |
1852 | 1852 | // No more forms found, finish up. |
1853 | - give_set_upgrade_complete( 'v20_upgrades_payment_metadata' ); |
|
1853 | + give_set_upgrade_complete('v20_upgrades_payment_metadata'); |
|
1854 | 1854 | } |
1855 | 1855 | } |
1856 | 1856 | |
@@ -1866,7 +1866,7 @@ discard block |
||
1866 | 1866 | $give_updates = Give_Updates::get_instance(); |
1867 | 1867 | |
1868 | 1868 | // form query |
1869 | - $forms = new WP_Query( array( |
|
1869 | + $forms = new WP_Query(array( |
|
1870 | 1870 | 'paged' => $give_updates->step, |
1871 | 1871 | 'order' => 'DESC', |
1872 | 1872 | 'post_type' => 'give_log', |
@@ -1875,20 +1875,20 @@ discard block |
||
1875 | 1875 | ) |
1876 | 1876 | ); |
1877 | 1877 | |
1878 | - if ( $forms->have_posts() ) { |
|
1879 | - $give_updates->set_percentage( $forms->found_posts, $give_updates->step * 100 ); |
|
1878 | + if ($forms->have_posts()) { |
|
1879 | + $give_updates->set_percentage($forms->found_posts, $give_updates->step * 100); |
|
1880 | 1880 | |
1881 | - while ( $forms->have_posts() ) { |
|
1881 | + while ($forms->have_posts()) { |
|
1882 | 1882 | $forms->the_post(); |
1883 | 1883 | global $post; |
1884 | 1884 | |
1885 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
1885 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
1886 | 1886 | continue; |
1887 | 1887 | } |
1888 | 1888 | |
1889 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
1890 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
1891 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
1889 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
1890 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
1891 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
1892 | 1892 | |
1893 | 1893 | $log_data = array( |
1894 | 1894 | 'ID' => $post->ID, |
@@ -1901,29 +1901,29 @@ discard block |
||
1901 | 1901 | ); |
1902 | 1902 | $log_meta = array(); |
1903 | 1903 | |
1904 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
1905 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
1906 | - switch ( $meta_key ) { |
|
1904 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
1905 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
1906 | + switch ($meta_key) { |
|
1907 | 1907 | case '_give_log_payment_id': |
1908 | - $log_data['log_parent'] = current( $meta_value ); |
|
1908 | + $log_data['log_parent'] = current($meta_value); |
|
1909 | 1909 | $log_meta['_give_log_form_id'] = $post->post_parent; |
1910 | 1910 | break; |
1911 | 1911 | |
1912 | 1912 | default: |
1913 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
1913 | + $log_meta[$meta_key] = current($meta_value); |
|
1914 | 1914 | } |
1915 | 1915 | } |
1916 | 1916 | } |
1917 | 1917 | |
1918 | - if ( 'api_request' === $term_name ) { |
|
1918 | + if ('api_request' === $term_name) { |
|
1919 | 1919 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
1920 | 1920 | } |
1921 | 1921 | |
1922 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
1922 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
1923 | 1923 | |
1924 | - if ( ! empty( $log_meta ) ) { |
|
1925 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
1926 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
1924 | + if ( ! empty($log_meta)) { |
|
1925 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
1926 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
1927 | 1927 | } |
1928 | 1928 | } |
1929 | 1929 | |
@@ -1965,7 +1965,7 @@ discard block |
||
1965 | 1965 | Give()->logs->delete_cache(); |
1966 | 1966 | |
1967 | 1967 | // No more forms found, finish up. |
1968 | - give_set_upgrade_complete( 'v20_logs_upgrades' ); |
|
1968 | + give_set_upgrade_complete('v20_logs_upgrades'); |
|
1969 | 1969 | } |
1970 | 1970 | } |
1971 | 1971 | |
@@ -1981,19 +1981,19 @@ discard block |
||
1981 | 1981 | $give_updates = Give_Updates::get_instance(); |
1982 | 1982 | |
1983 | 1983 | // form query |
1984 | - $payments = new WP_Query( array( |
|
1984 | + $payments = new WP_Query(array( |
|
1985 | 1985 | 'paged' => $give_updates->step, |
1986 | 1986 | 'status' => 'any', |
1987 | 1987 | 'order' => 'ASC', |
1988 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1988 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1989 | 1989 | 'posts_per_page' => 100, |
1990 | 1990 | ) |
1991 | 1991 | ); |
1992 | 1992 | |
1993 | - if ( $payments->have_posts() ) { |
|
1994 | - $give_updates->set_percentage( $payments->found_posts, $give_updates->step * 100 ); |
|
1993 | + if ($payments->have_posts()) { |
|
1994 | + $give_updates->set_percentage($payments->found_posts, $give_updates->step * 100); |
|
1995 | 1995 | |
1996 | - while ( $payments->have_posts() ) { |
|
1996 | + while ($payments->have_posts()) { |
|
1997 | 1997 | $payments->the_post(); |
1998 | 1998 | global $post; |
1999 | 1999 | |
@@ -2005,19 +2005,19 @@ discard block |
||
2005 | 2005 | ARRAY_A |
2006 | 2006 | ); |
2007 | 2007 | |
2008 | - if ( ! empty( $meta_data ) ) { |
|
2009 | - foreach ( $meta_data as $index => $data ) { |
|
2008 | + if ( ! empty($meta_data)) { |
|
2009 | + foreach ($meta_data as $index => $data) { |
|
2010 | 2010 | // Check for duplicate meta values. |
2011 | - 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 ) ) { |
|
2011 | + 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)) { |
|
2012 | 2012 | continue; |
2013 | 2013 | } |
2014 | 2014 | |
2015 | - switch ( $post->post_type ) { |
|
2015 | + switch ($post->post_type) { |
|
2016 | 2016 | case 'give_forms': |
2017 | 2017 | $data['form_id'] = $data['post_id']; |
2018 | - unset( $data['post_id'] ); |
|
2018 | + unset($data['post_id']); |
|
2019 | 2019 | |
2020 | - Give()->form_meta->insert( $data ); |
|
2020 | + Give()->form_meta->insert($data); |
|
2021 | 2021 | // @todo: delete form meta from post meta table after releases 2.0. |
2022 | 2022 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2023 | 2023 | |
@@ -2025,9 +2025,9 @@ discard block |
||
2025 | 2025 | |
2026 | 2026 | case 'give_payment': |
2027 | 2027 | $data['payment_id'] = $data['post_id']; |
2028 | - unset( $data['post_id'] ); |
|
2028 | + unset($data['post_id']); |
|
2029 | 2029 | |
2030 | - Give()->payment_meta->insert( $data ); |
|
2030 | + Give()->payment_meta->insert($data); |
|
2031 | 2031 | |
2032 | 2032 | // @todo: delete donation meta from post meta table after releases 2.0. |
2033 | 2033 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2042,7 +2042,7 @@ discard block |
||
2042 | 2042 | wp_reset_postdata(); |
2043 | 2043 | } else { |
2044 | 2044 | // No more forms found, finish up. |
2045 | - give_set_upgrade_complete( 'v20_move_metadata_into_new_table' ); |
|
2045 | + give_set_upgrade_complete('v20_move_metadata_into_new_table'); |
|
2046 | 2046 | } |
2047 | 2047 | |
2048 | 2048 | } |
@@ -2058,44 +2058,44 @@ discard block |
||
2058 | 2058 | /* @var Give_Updates $give_updates */ |
2059 | 2059 | $give_updates = Give_Updates::get_instance(); |
2060 | 2060 | |
2061 | - $donors = Give()->donors->get_donors( array( |
|
2061 | + $donors = Give()->donors->get_donors(array( |
|
2062 | 2062 | 'paged' => $give_updates->step, |
2063 | 2063 | 'number' => 100, |
2064 | - ) ); |
|
2064 | + )); |
|
2065 | 2065 | |
2066 | - if ( $donors ) { |
|
2067 | - $give_updates->set_percentage( count( $donors ), $give_updates->step * 100 ); |
|
2066 | + if ($donors) { |
|
2067 | + $give_updates->set_percentage(count($donors), $give_updates->step * 100); |
|
2068 | 2068 | // Loop through Donors |
2069 | - foreach ( $donors as $donor ) { |
|
2069 | + foreach ($donors as $donor) { |
|
2070 | 2070 | |
2071 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2072 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2073 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2071 | + $donor_name = explode(' ', $donor->name, 2); |
|
2072 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2073 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2074 | 2074 | |
2075 | 2075 | // If first name meta of donor is not created, then create it. |
2076 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2077 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2076 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2077 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2078 | 2078 | } |
2079 | 2079 | |
2080 | 2080 | // If last name meta of donor is not created, then create it. |
2081 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2082 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2081 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2082 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2083 | 2083 | } |
2084 | 2084 | |
2085 | 2085 | // If Donor is connected with WP User then update user meta. |
2086 | - if ( $donor->user_id ) { |
|
2087 | - if ( isset( $donor_name[0] ) ) { |
|
2088 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2086 | + if ($donor->user_id) { |
|
2087 | + if (isset($donor_name[0])) { |
|
2088 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2089 | 2089 | } |
2090 | - if ( isset( $donor_name[1] ) ) { |
|
2091 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2090 | + if (isset($donor_name[1])) { |
|
2091 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2092 | 2092 | } |
2093 | 2093 | } |
2094 | 2094 | } |
2095 | 2095 | |
2096 | 2096 | } else { |
2097 | 2097 | // The Update Ran. |
2098 | - give_set_upgrade_complete( 'v20_upgrades_donor_name' ); |
|
2098 | + give_set_upgrade_complete('v20_upgrades_donor_name'); |
|
2099 | 2099 | } |
2100 | 2100 | |
2101 | 2101 | } |
@@ -2124,15 +2124,15 @@ discard block |
||
2124 | 2124 | |
2125 | 2125 | $users = $user_query->get_results(); |
2126 | 2126 | |
2127 | - if ( $users ) { |
|
2128 | - $give_updates->set_percentage( $user_query->get_total(), $give_updates->step * 100 ); |
|
2127 | + if ($users) { |
|
2128 | + $give_updates->set_percentage($user_query->get_total(), $give_updates->step * 100); |
|
2129 | 2129 | |
2130 | 2130 | // Loop through Donors |
2131 | - foreach ( $users as $user ) { |
|
2131 | + foreach ($users as $user) { |
|
2132 | 2132 | /* @var Give_Donor $donor */ |
2133 | - $donor = new Give_Donor( $user->ID, true ); |
|
2133 | + $donor = new Give_Donor($user->ID, true); |
|
2134 | 2134 | |
2135 | - if ( ! $donor->id ) { |
|
2135 | + if ( ! $donor->id) { |
|
2136 | 2136 | continue; |
2137 | 2137 | } |
2138 | 2138 | |
@@ -2148,10 +2148,10 @@ discard block |
||
2148 | 2148 | ) |
2149 | 2149 | ); |
2150 | 2150 | |
2151 | - if ( ! empty( $address ) ) { |
|
2152 | - $address = maybe_unserialize( $address ); |
|
2153 | - $donor->add_address( 'personal', $address ); |
|
2154 | - $donor->add_address( 'billing[]', $address ); |
|
2151 | + if ( ! empty($address)) { |
|
2152 | + $address = maybe_unserialize($address); |
|
2153 | + $donor->add_address('personal', $address); |
|
2154 | + $donor->add_address('billing[]', $address); |
|
2155 | 2155 | |
2156 | 2156 | |
2157 | 2157 | // @todo: delete _give_user_address from user meta after releases 2.0. |
@@ -2161,7 +2161,7 @@ discard block |
||
2161 | 2161 | |
2162 | 2162 | } else { |
2163 | 2163 | // The Update Ran. |
2164 | - give_set_upgrade_complete( 'v20_upgrades_user_address' ); |
|
2164 | + give_set_upgrade_complete('v20_upgrades_user_address'); |
|
2165 | 2165 | } |
2166 | 2166 | |
2167 | 2167 | } |
@@ -2185,15 +2185,15 @@ discard block |
||
2185 | 2185 | ); |
2186 | 2186 | |
2187 | 2187 | // Alter customer table |
2188 | - foreach ( $tables as $old_table => $new_table ) { |
|
2188 | + foreach ($tables as $old_table => $new_table) { |
|
2189 | 2189 | if ( |
2190 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $old_table ) ) && |
|
2191 | - ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $new_table ) ) |
|
2190 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $old_table)) && |
|
2191 | + ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $new_table)) |
|
2192 | 2192 | ) { |
2193 | - $wpdb->query( "ALTER TABLE {$old_table} RENAME TO {$new_table}" ); |
|
2193 | + $wpdb->query("ALTER TABLE {$old_table} RENAME TO {$new_table}"); |
|
2194 | 2194 | |
2195 | - if ( "{$wpdb->prefix}give_donormeta" === $new_table ) { |
|
2196 | - $wpdb->query( "ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)" ); |
|
2195 | + if ("{$wpdb->prefix}give_donormeta" === $new_table) { |
|
2196 | + $wpdb->query("ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)"); |
|
2197 | 2197 | } |
2198 | 2198 | } |
2199 | 2199 | } |
@@ -2201,7 +2201,7 @@ discard block |
||
2201 | 2201 | $give_updates->percentage = 100; |
2202 | 2202 | |
2203 | 2203 | // No more forms found, finish up. |
2204 | - give_set_upgrade_complete( 'v20_rename_donor_tables' ); |
|
2204 | + give_set_upgrade_complete('v20_rename_donor_tables'); |
|
2205 | 2205 | |
2206 | 2206 | // Re initiate donor classes. |
2207 | 2207 | Give()->donors = new Give_DB_Donors(); |
@@ -2219,19 +2219,19 @@ discard block |
||
2219 | 2219 | function give_v201_create_tables() { |
2220 | 2220 | global $wpdb; |
2221 | 2221 | |
2222 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta" ) ) ) { |
|
2222 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta"))) { |
|
2223 | 2223 | Give()->payment_meta->create_table(); |
2224 | 2224 | } |
2225 | 2225 | |
2226 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta" ) ) ) { |
|
2226 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta"))) { |
|
2227 | 2227 | Give()->form_meta->create_table(); |
2228 | 2228 | } |
2229 | 2229 | |
2230 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs" ) ) ) { |
|
2230 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs"))) { |
|
2231 | 2231 | Give()->logs->log_db->create_table(); |
2232 | 2232 | } |
2233 | 2233 | |
2234 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta" ) ) ) { |
|
2234 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta"))) { |
|
2235 | 2235 | Give()->logs->logmeta_db->create_table(); |
2236 | 2236 | } |
2237 | 2237 | } |
@@ -2256,31 +2256,31 @@ discard block |
||
2256 | 2256 | $wpdb->posts.post_date >= '2018-01-08 00:00:00' |
2257 | 2257 | ) |
2258 | 2258 | AND $wpdb->posts.post_type = 'give_payment' |
2259 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2259 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2260 | 2260 | ORDER BY $wpdb->posts.post_date ASC |
2261 | 2261 | LIMIT 100 |
2262 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2262 | + OFFSET ".$give_updates->get_offset(100) |
|
2263 | 2263 | ); |
2264 | 2264 | |
2265 | - if ( ! empty( $payments ) ) { |
|
2266 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_payment' ), ( $give_updates->step * 100 ) ); |
|
2265 | + if ( ! empty($payments)) { |
|
2266 | + $give_updates->set_percentage(give_get_total_post_type_count('give_payment'), ($give_updates->step * 100)); |
|
2267 | 2267 | |
2268 | - foreach ( $payments as $payment_id ) { |
|
2269 | - $post = get_post( $payment_id ); |
|
2270 | - setup_postdata( $post ); |
|
2268 | + foreach ($payments as $payment_id) { |
|
2269 | + $post = get_post($payment_id); |
|
2270 | + setup_postdata($post); |
|
2271 | 2271 | |
2272 | 2272 | // Do not add new meta keys if already refactored. |
2273 | - 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' ) ) ) { |
|
2273 | + 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'))) { |
|
2274 | 2274 | continue; |
2275 | 2275 | } |
2276 | 2276 | |
2277 | 2277 | |
2278 | 2278 | // Split _give_payment_meta meta. |
2279 | 2279 | // @todo Remove _give_payment_meta after releases 2.0 |
2280 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
2280 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
2281 | 2281 | |
2282 | - if ( ! empty( $payment_meta ) ) { |
|
2283 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
2282 | + if ( ! empty($payment_meta)) { |
|
2283 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
2284 | 2284 | } |
2285 | 2285 | |
2286 | 2286 | $deprecated_meta_keys = array( |
@@ -2289,9 +2289,9 @@ discard block |
||
2289 | 2289 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
2290 | 2290 | ); |
2291 | 2291 | |
2292 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
2292 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
2293 | 2293 | // Do not add new meta key if already exist. |
2294 | - 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 ) ) ) { |
|
2294 | + 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))) { |
|
2295 | 2295 | continue; |
2296 | 2296 | } |
2297 | 2297 | |
@@ -2300,25 +2300,25 @@ discard block |
||
2300 | 2300 | array( |
2301 | 2301 | 'post_id' => $post->ID, |
2302 | 2302 | 'meta_key' => $new_meta_key, |
2303 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
2303 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
2304 | 2304 | ) |
2305 | 2305 | ); |
2306 | 2306 | } |
2307 | 2307 | |
2308 | 2308 | // Bailout |
2309 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
2309 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
2310 | 2310 | /* @var Give_Donor $donor */ |
2311 | - $donor = new Give_Donor( $donor_id ); |
|
2311 | + $donor = new Give_Donor($donor_id); |
|
2312 | 2312 | |
2313 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
2314 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
2315 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
2316 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
2317 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
2318 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
2313 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
2314 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
2315 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
2316 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
2317 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
2318 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
2319 | 2319 | |
2320 | 2320 | // Save address. |
2321 | - $donor->add_address( 'billing[]', $address ); |
|
2321 | + $donor->add_address('billing[]', $address); |
|
2322 | 2322 | } |
2323 | 2323 | |
2324 | 2324 | }// End while(). |
@@ -2329,7 +2329,7 @@ discard block |
||
2329 | 2329 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
2330 | 2330 | |
2331 | 2331 | // No more forms found, finish up. |
2332 | - give_set_upgrade_complete( 'v201_upgrades_payment_metadata' ); |
|
2332 | + give_set_upgrade_complete('v201_upgrades_payment_metadata'); |
|
2333 | 2333 | } |
2334 | 2334 | } |
2335 | 2335 | |
@@ -2349,21 +2349,21 @@ discard block |
||
2349 | 2349 | SELECT ID FROM $wpdb->posts |
2350 | 2350 | WHERE 1=1 |
2351 | 2351 | AND ( $wpdb->posts.post_type = 'give_payment' OR $wpdb->posts.post_type = 'give_forms' ) |
2352 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2352 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2353 | 2353 | ORDER BY $wpdb->posts.post_date ASC |
2354 | 2354 | LIMIT 100 |
2355 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2355 | + OFFSET ".$give_updates->get_offset(100) |
|
2356 | 2356 | ); |
2357 | 2357 | |
2358 | - if ( ! empty( $payments ) ) { |
|
2359 | - $give_updates->set_percentage( give_get_total_post_type_count( array( |
|
2358 | + if ( ! empty($payments)) { |
|
2359 | + $give_updates->set_percentage(give_get_total_post_type_count(array( |
|
2360 | 2360 | 'give_forms', |
2361 | 2361 | 'give_payment', |
2362 | - ) ), $give_updates->step * 100 ); |
|
2362 | + )), $give_updates->step * 100); |
|
2363 | 2363 | |
2364 | - foreach ( $payments as $payment_id ) { |
|
2365 | - $post = get_post( $payment_id ); |
|
2366 | - setup_postdata( $post ); |
|
2364 | + foreach ($payments as $payment_id) { |
|
2365 | + $post = get_post($payment_id); |
|
2366 | + setup_postdata($post); |
|
2367 | 2367 | |
2368 | 2368 | $meta_data = $wpdb->get_results( |
2369 | 2369 | $wpdb->prepare( |
@@ -2373,19 +2373,19 @@ discard block |
||
2373 | 2373 | ARRAY_A |
2374 | 2374 | ); |
2375 | 2375 | |
2376 | - if ( ! empty( $meta_data ) ) { |
|
2377 | - foreach ( $meta_data as $index => $data ) { |
|
2376 | + if ( ! empty($meta_data)) { |
|
2377 | + foreach ($meta_data as $index => $data) { |
|
2378 | 2378 | // Check for duplicate meta values. |
2379 | - 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 ) ) { |
|
2379 | + 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)) { |
|
2380 | 2380 | continue; |
2381 | 2381 | } |
2382 | 2382 | |
2383 | - switch ( $post->post_type ) { |
|
2383 | + switch ($post->post_type) { |
|
2384 | 2384 | case 'give_forms': |
2385 | 2385 | $data['form_id'] = $data['post_id']; |
2386 | - unset( $data['post_id'] ); |
|
2386 | + unset($data['post_id']); |
|
2387 | 2387 | |
2388 | - Give()->form_meta->insert( $data ); |
|
2388 | + Give()->form_meta->insert($data); |
|
2389 | 2389 | // @todo: delete form meta from post meta table after releases 2.0. |
2390 | 2390 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2391 | 2391 | |
@@ -2393,9 +2393,9 @@ discard block |
||
2393 | 2393 | |
2394 | 2394 | case 'give_payment': |
2395 | 2395 | $data['payment_id'] = $data['post_id']; |
2396 | - unset( $data['post_id'] ); |
|
2396 | + unset($data['post_id']); |
|
2397 | 2397 | |
2398 | - Give()->payment_meta->insert( $data ); |
|
2398 | + Give()->payment_meta->insert($data); |
|
2399 | 2399 | |
2400 | 2400 | // @todo: delete donation meta from post meta table after releases 2.0. |
2401 | 2401 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2410,7 +2410,7 @@ discard block |
||
2410 | 2410 | wp_reset_postdata(); |
2411 | 2411 | } else { |
2412 | 2412 | // No more forms found, finish up. |
2413 | - give_set_upgrade_complete( 'v201_move_metadata_into_new_table' ); |
|
2413 | + give_set_upgrade_complete('v201_move_metadata_into_new_table'); |
|
2414 | 2414 | } |
2415 | 2415 | |
2416 | 2416 | } |
@@ -2431,26 +2431,26 @@ discard block |
||
2431 | 2431 | SELECT ID FROM $wpdb->posts |
2432 | 2432 | WHERE 1=1 |
2433 | 2433 | AND $wpdb->posts.post_type = 'give_log' |
2434 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2434 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2435 | 2435 | ORDER BY $wpdb->posts.post_date ASC |
2436 | 2436 | LIMIT 100 |
2437 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2437 | + OFFSET ".$give_updates->get_offset(100) |
|
2438 | 2438 | ); |
2439 | 2439 | |
2440 | - if ( ! empty( $logs ) ) { |
|
2441 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_log' ), $give_updates->step * 100 ); |
|
2440 | + if ( ! empty($logs)) { |
|
2441 | + $give_updates->set_percentage(give_get_total_post_type_count('give_log'), $give_updates->step * 100); |
|
2442 | 2442 | |
2443 | - foreach ( $logs as $log_id ) { |
|
2444 | - $post = get_post( $log_id ); |
|
2445 | - setup_postdata( $post ); |
|
2443 | + foreach ($logs as $log_id) { |
|
2444 | + $post = get_post($log_id); |
|
2445 | + setup_postdata($post); |
|
2446 | 2446 | |
2447 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
2447 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
2448 | 2448 | continue; |
2449 | 2449 | } |
2450 | 2450 | |
2451 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
2452 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
2453 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
2451 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
2452 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
2453 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
2454 | 2454 | |
2455 | 2455 | $log_data = array( |
2456 | 2456 | 'ID' => $post->ID, |
@@ -2463,29 +2463,29 @@ discard block |
||
2463 | 2463 | ); |
2464 | 2464 | $log_meta = array(); |
2465 | 2465 | |
2466 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
2467 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
2468 | - switch ( $meta_key ) { |
|
2466 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
2467 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
2468 | + switch ($meta_key) { |
|
2469 | 2469 | case '_give_log_payment_id': |
2470 | - $log_data['log_parent'] = current( $meta_value ); |
|
2470 | + $log_data['log_parent'] = current($meta_value); |
|
2471 | 2471 | $log_meta['_give_log_form_id'] = $post->post_parent; |
2472 | 2472 | break; |
2473 | 2473 | |
2474 | 2474 | default: |
2475 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
2475 | + $log_meta[$meta_key] = current($meta_value); |
|
2476 | 2476 | } |
2477 | 2477 | } |
2478 | 2478 | } |
2479 | 2479 | |
2480 | - if ( 'api_request' === $term_name ) { |
|
2480 | + if ('api_request' === $term_name) { |
|
2481 | 2481 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
2482 | 2482 | } |
2483 | 2483 | |
2484 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
2484 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
2485 | 2485 | |
2486 | - if ( ! empty( $log_meta ) ) { |
|
2487 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
2488 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
2486 | + if ( ! empty($log_meta)) { |
|
2487 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
2488 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
2489 | 2489 | } |
2490 | 2490 | } |
2491 | 2491 | |
@@ -2498,7 +2498,7 @@ discard block |
||
2498 | 2498 | Give()->logs->delete_cache(); |
2499 | 2499 | |
2500 | 2500 | // No more forms found, finish up. |
2501 | - give_set_upgrade_complete( 'v201_logs_upgrades' ); |
|
2501 | + give_set_upgrade_complete('v201_logs_upgrades'); |
|
2502 | 2502 | } |
2503 | 2503 | } |
2504 | 2504 | |
@@ -2513,51 +2513,51 @@ discard block |
||
2513 | 2513 | global $wpdb; |
2514 | 2514 | give_v201_create_tables(); |
2515 | 2515 | |
2516 | - if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) ) ) { |
|
2517 | - $customers = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_customers" ), 'id' ); |
|
2518 | - $donors = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_donors" ), 'id' ); |
|
2516 | + if ($wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))) { |
|
2517 | + $customers = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_customers"), 'id'); |
|
2518 | + $donors = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_donors"), 'id'); |
|
2519 | 2519 | $donor_data = array(); |
2520 | 2520 | |
2521 | - if ( $missing_donors = array_diff( $customers, $donors ) ) { |
|
2522 | - foreach ( $missing_donors as $donor_id ) { |
|
2521 | + if ($missing_donors = array_diff($customers, $donors)) { |
|
2522 | + foreach ($missing_donors as $donor_id) { |
|
2523 | 2523 | $donor_data[] = array( |
2524 | - 'info' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id ) ), |
|
2525 | - 'meta' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id ) ), |
|
2524 | + 'info' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id)), |
|
2525 | + 'meta' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id)), |
|
2526 | 2526 | |
2527 | 2527 | ); |
2528 | 2528 | } |
2529 | 2529 | } |
2530 | 2530 | |
2531 | - if ( ! empty( $donor_data ) ) { |
|
2531 | + if ( ! empty($donor_data)) { |
|
2532 | 2532 | $donor_table_name = Give()->donors->table_name; |
2533 | 2533 | $donor_meta_table_name = Give()->donor_meta->table_name; |
2534 | 2534 | |
2535 | 2535 | Give()->donors->table_name = "{$wpdb->prefix}give_donors"; |
2536 | 2536 | Give()->donor_meta->table_name = "{$wpdb->prefix}give_donormeta"; |
2537 | 2537 | |
2538 | - foreach ( $donor_data as $donor ) { |
|
2538 | + foreach ($donor_data as $donor) { |
|
2539 | 2539 | $donor['info'][0] = (array) $donor['info'][0]; |
2540 | 2540 | |
2541 | 2541 | // Prevent duplicate meta id issue. |
2542 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id'] ) ) ) { |
|
2542 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id']))) { |
|
2543 | 2543 | continue; |
2544 | 2544 | } |
2545 | 2545 | |
2546 | - $donor_id = Give()->donors->add( $donor['info'][0] ); |
|
2546 | + $donor_id = Give()->donors->add($donor['info'][0]); |
|
2547 | 2547 | |
2548 | - if ( ! empty( $donor['meta'] ) ) { |
|
2549 | - foreach ( $donor['meta'] as $donor_meta ) { |
|
2548 | + if ( ! empty($donor['meta'])) { |
|
2549 | + foreach ($donor['meta'] as $donor_meta) { |
|
2550 | 2550 | $donor_meta = (array) $donor_meta; |
2551 | 2551 | |
2552 | 2552 | // Prevent duplicate meta id issue. |
2553 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id'] ) ) ) { |
|
2554 | - unset( $donor_meta['meta_id'] ); |
|
2553 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id']))) { |
|
2554 | + unset($donor_meta['meta_id']); |
|
2555 | 2555 | } |
2556 | 2556 | |
2557 | 2557 | $donor_meta['donor_id'] = $donor_meta['customer_id']; |
2558 | - unset( $donor_meta['customer_id'] ); |
|
2558 | + unset($donor_meta['customer_id']); |
|
2559 | 2559 | |
2560 | - Give()->donor_meta->insert( $donor_meta ); |
|
2560 | + Give()->donor_meta->insert($donor_meta); |
|
2561 | 2561 | } |
2562 | 2562 | } |
2563 | 2563 | |
@@ -2576,35 +2576,35 @@ discard block |
||
2576 | 2576 | ) |
2577 | 2577 | ); |
2578 | 2578 | |
2579 | - $donor = new Give_Donor( $donor_id ); |
|
2579 | + $donor = new Give_Donor($donor_id); |
|
2580 | 2580 | |
2581 | - if ( ! empty( $address ) ) { |
|
2582 | - $address = maybe_unserialize( $address ); |
|
2583 | - $donor->add_address( 'personal', $address ); |
|
2584 | - $donor->add_address( 'billing[]', $address ); |
|
2581 | + if ( ! empty($address)) { |
|
2582 | + $address = maybe_unserialize($address); |
|
2583 | + $donor->add_address('personal', $address); |
|
2584 | + $donor->add_address('billing[]', $address); |
|
2585 | 2585 | } |
2586 | 2586 | |
2587 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2588 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2589 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2587 | + $donor_name = explode(' ', $donor->name, 2); |
|
2588 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2589 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2590 | 2590 | |
2591 | 2591 | // If first name meta of donor is not created, then create it. |
2592 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2593 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2592 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2593 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2594 | 2594 | } |
2595 | 2595 | |
2596 | 2596 | // If last name meta of donor is not created, then create it. |
2597 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2598 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2597 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2598 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2599 | 2599 | } |
2600 | 2600 | |
2601 | 2601 | // If Donor is connected with WP User then update user meta. |
2602 | - if ( $donor->user_id ) { |
|
2603 | - if ( isset( $donor_name[0] ) ) { |
|
2604 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2602 | + if ($donor->user_id) { |
|
2603 | + if (isset($donor_name[0])) { |
|
2604 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2605 | 2605 | } |
2606 | - if ( isset( $donor_name[1] ) ) { |
|
2607 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2606 | + if (isset($donor_name[1])) { |
|
2607 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2608 | 2608 | } |
2609 | 2609 | } |
2610 | 2610 | } |
@@ -2615,7 +2615,7 @@ discard block |
||
2615 | 2615 | } |
2616 | 2616 | |
2617 | 2617 | Give_Updates::get_instance()->percentage = 100; |
2618 | - give_set_upgrade_complete( 'v201_add_missing_donors' ); |
|
2618 | + give_set_upgrade_complete('v201_add_missing_donors'); |
|
2619 | 2619 | } |
2620 | 2620 | |
2621 | 2621 | |
@@ -2628,14 +2628,14 @@ discard block |
||
2628 | 2628 | global $wpdb; |
2629 | 2629 | |
2630 | 2630 | // Do not auto load option. |
2631 | - $wpdb->update( $wpdb->options, array( 'autoload' => 'no' ), array( 'option_name' => 'give_completed_upgrades' ) ); |
|
2631 | + $wpdb->update($wpdb->options, array('autoload' => 'no'), array('option_name' => 'give_completed_upgrades')); |
|
2632 | 2632 | |
2633 | 2633 | // Remove from cache. |
2634 | 2634 | $all_options = wp_load_alloptions(); |
2635 | 2635 | |
2636 | - if ( isset( $all_options['give_completed_upgrades'] ) ) { |
|
2637 | - unset( $all_options['give_completed_upgrades'] ); |
|
2638 | - wp_cache_set( 'alloptions', $all_options, 'options' ); |
|
2636 | + if (isset($all_options['give_completed_upgrades'])) { |
|
2637 | + unset($all_options['give_completed_upgrades']); |
|
2638 | + wp_cache_set('alloptions', $all_options, 'options'); |
|
2639 | 2639 | } |
2640 | 2640 | |
2641 | 2641 | } |
@@ -2646,7 +2646,7 @@ discard block |
||
2646 | 2646 | * |
2647 | 2647 | * @since 2.2.0 |
2648 | 2648 | */ |
2649 | -function give_v220_upgrades(){ |
|
2649 | +function give_v220_upgrades() { |
|
2650 | 2650 | global $wpdb; |
2651 | 2651 | |
2652 | 2652 | /** |
@@ -2699,11 +2699,11 @@ discard block |
||
2699 | 2699 | " |
2700 | 2700 | ); |
2701 | 2701 | |
2702 | - if( ! empty( $option_like ) ) { |
|
2703 | - $options = array_merge( $options, $option_like ); |
|
2702 | + if ( ! empty($option_like)) { |
|
2703 | + $options = array_merge($options, $option_like); |
|
2704 | 2704 | } |
2705 | 2705 | |
2706 | - $options_str = '\'' . implode( "','", $options ) . '\''; |
|
2706 | + $options_str = '\''.implode("','", $options).'\''; |
|
2707 | 2707 | |
2708 | 2708 | $wpdb->query( |
2709 | 2709 | " |
@@ -2724,7 +2724,7 @@ discard block |
||
2724 | 2724 | $give_updates = Give_Updates::get_instance(); |
2725 | 2725 | |
2726 | 2726 | // form query. |
2727 | - $donation_forms = new WP_Query( array( |
|
2727 | + $donation_forms = new WP_Query(array( |
|
2728 | 2728 | 'paged' => $give_updates->step, |
2729 | 2729 | 'status' => 'any', |
2730 | 2730 | 'order' => 'ASC', |
@@ -2733,16 +2733,16 @@ discard block |
||
2733 | 2733 | ) |
2734 | 2734 | ); |
2735 | 2735 | |
2736 | - if ( $donation_forms->have_posts() ) { |
|
2737 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
2736 | + if ($donation_forms->have_posts()) { |
|
2737 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
2738 | 2738 | |
2739 | - while ( $donation_forms->have_posts() ) { |
|
2739 | + while ($donation_forms->have_posts()) { |
|
2740 | 2740 | $donation_forms->the_post(); |
2741 | 2741 | $form_id = get_the_ID(); |
2742 | 2742 | |
2743 | - $form_closed_status = give_get_meta( $form_id, '_give_form_status', true ); |
|
2744 | - if ( empty( $form_closed_status ) ) { |
|
2745 | - give_set_form_closed_status( $form_id ); |
|
2743 | + $form_closed_status = give_get_meta($form_id, '_give_form_status', true); |
|
2744 | + if (empty($form_closed_status)) { |
|
2745 | + give_set_form_closed_status($form_id); |
|
2746 | 2746 | } |
2747 | 2747 | } |
2748 | 2748 | |
@@ -2752,7 +2752,7 @@ discard block |
||
2752 | 2752 | } else { |
2753 | 2753 | |
2754 | 2754 | // The Update Ran. |
2755 | - give_set_upgrade_complete( 'v210_verify_form_status_upgrades' ); |
|
2755 | + give_set_upgrade_complete('v210_verify_form_status_upgrades'); |
|
2756 | 2756 | } |
2757 | 2757 | } |
2758 | 2758 | |
@@ -2771,22 +2771,22 @@ discard block |
||
2771 | 2771 | SELECT DISTINCT payment_id |
2772 | 2772 | FROM {$donation_meta_table} |
2773 | 2773 | LIMIT 20 |
2774 | - OFFSET {$give_updates->get_offset( 20 )} |
|
2774 | + OFFSET {$give_updates->get_offset(20)} |
|
2775 | 2775 | " |
2776 | 2776 | ); |
2777 | 2777 | |
2778 | - if ( ! empty( $donations ) ) { |
|
2779 | - foreach ( $donations as $donation ) { |
|
2780 | - $donation_obj = get_post( $donation ); |
|
2778 | + if ( ! empty($donations)) { |
|
2779 | + foreach ($donations as $donation) { |
|
2780 | + $donation_obj = get_post($donation); |
|
2781 | 2781 | |
2782 | - if ( ! $donation_obj instanceof WP_Post ) { |
|
2783 | - Give()->payment_meta->delete_all_meta( $donation ); |
|
2782 | + if ( ! $donation_obj instanceof WP_Post) { |
|
2783 | + Give()->payment_meta->delete_all_meta($donation); |
|
2784 | 2784 | } |
2785 | 2785 | } |
2786 | 2786 | } else { |
2787 | 2787 | |
2788 | 2788 | // The Update Ran. |
2789 | - give_set_upgrade_complete( 'v213_delete_donation_meta' ); |
|
2789 | + give_set_upgrade_complete('v213_delete_donation_meta'); |
|
2790 | 2790 | } |
2791 | 2791 | } |
2792 | 2792 | |
@@ -2797,11 +2797,11 @@ discard block |
||
2797 | 2797 | * |
2798 | 2798 | * @since 2.2.0 |
2799 | 2799 | */ |
2800 | -function give_v220_rename_donation_meta_type_callback(){ |
|
2800 | +function give_v220_rename_donation_meta_type_callback() { |
|
2801 | 2801 | global $wpdb; |
2802 | 2802 | |
2803 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_paymentmeta CHANGE COLUMN payment_id donation_id bigint(20)" ); |
|
2804 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_paymentmeta RENAME TO {$wpdb->prefix}give_donationmeta" ); |
|
2803 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}give_paymentmeta CHANGE COLUMN payment_id donation_id bigint(20)"); |
|
2804 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}give_paymentmeta RENAME TO {$wpdb->prefix}give_donationmeta"); |
|
2805 | 2805 | |
2806 | 2806 | give_set_upgrade_complete('v220_rename_donation_meta_type'); |
2807 | 2807 | } |
@@ -2813,10 +2813,10 @@ discard block |
||
2813 | 2813 | */ |
2814 | 2814 | function give_v215_update_donor_user_roles_callback() { |
2815 | 2815 | |
2816 | - $role = get_role( 'give_manager' ); |
|
2817 | - $role->add_cap( 'view_give_payments' ); |
|
2816 | + $role = get_role('give_manager'); |
|
2817 | + $role->add_cap('view_give_payments'); |
|
2818 | 2818 | |
2819 | - give_set_upgrade_complete( 'v215_update_donor_user_roles' ); |
|
2819 | + give_set_upgrade_complete('v215_update_donor_user_roles'); |
|
2820 | 2820 | } |
2821 | 2821 | |
2822 | 2822 | |
@@ -2828,8 +2828,8 @@ discard block |
||
2828 | 2828 | * |
2829 | 2829 | * @global wpdb $wpdb |
2830 | 2830 | */ |
2831 | -function give_v220_delete_wp_session_data(){ |
|
2831 | +function give_v220_delete_wp_session_data() { |
|
2832 | 2832 | global $wpdb; |
2833 | 2833 | |
2834 | - $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '_wp_session_%'" ); |
|
2834 | + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_wp_session_%'"); |
|
2835 | 2835 | } |