@@ -39,8 +39,8 @@ |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | if ( ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
| 42 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
| 43 | - && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
| 42 | + || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
| 43 | + && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
| 44 | 44 | ) { |
| 45 | 45 | |
| 46 | 46 | $forms_singular_option = give_get_option( 'forms_singular' ); |
@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | * @return void |
| 20 | 20 | */ |
| 21 | 21 | function give_disable_mandrill_nl2br() { |
| 22 | - add_filter( 'mandrill_nl2br', '__return_false' ); |
|
| 22 | + add_filter('mandrill_nl2br', '__return_false'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br' ); |
|
| 25 | +add_action('give_email_send_before', 'give_disable_mandrill_nl2br'); |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -34,30 +34,30 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | function give_clear_seo_sitemap_cache_on_settings_change() { |
| 36 | 36 | // Load required file if the fn 'is_plugin_active' doesn't exists. |
| 37 | - if ( ! function_exists( 'is_plugin_active' ) ) { |
|
| 38 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 37 | + if ( ! function_exists('is_plugin_active')) { |
|
| 38 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - if ( ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
|
| 42 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
| 43 | - && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
| 41 | + if ((is_plugin_active('wordpress-seo/wp-seo.php') |
|
| 42 | + || is_plugin_active('wordpress-seo-premium/wp-seo-premium.php')) |
|
| 43 | + && class_exists('WPSEO_Sitemaps_Cache') |
|
| 44 | 44 | ) { |
| 45 | 45 | |
| 46 | - $forms_singular_option = give_get_option( 'forms_singular' ); |
|
| 47 | - $forms_archive_option = give_get_option( 'forms_singular' ); |
|
| 46 | + $forms_singular_option = give_get_option('forms_singular'); |
|
| 47 | + $forms_archive_option = give_get_option('forms_singular'); |
|
| 48 | 48 | |
| 49 | 49 | // If there is change detected for Single Form View and Form Archives options then proceed. |
| 50 | 50 | if ( |
| 51 | - ( isset( $_POST['forms_singular'] ) && $_POST['forms_singular'] !== $forms_singular_option ) || |
|
| 52 | - ( isset( $_POST['forms_archives'] ) && $_POST['forms_archives'] !== $forms_archive_option ) |
|
| 51 | + (isset($_POST['forms_singular']) && $_POST['forms_singular'] !== $forms_singular_option) || |
|
| 52 | + (isset($_POST['forms_archives']) && $_POST['forms_archives'] !== $forms_archive_option) |
|
| 53 | 53 | ) { |
| 54 | 54 | // If Yoast SEO or Yoast SEO Premium plugin exists, then update seo sitemap cache. |
| 55 | 55 | $yoast_sitemaps_cache = new WPSEO_Sitemaps_Cache(); |
| 56 | - if ( method_exists( $yoast_sitemaps_cache, 'clear' ) ) { |
|
| 56 | + if (method_exists($yoast_sitemaps_cache, 'clear')) { |
|
| 57 | 57 | WPSEO_Sitemaps_Cache::clear(); |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | -add_action( 'give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change' ); |
|
| 63 | +add_action('give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change'); |
|
@@ -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 | |
@@ -93,19 +93,19 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function get_predefined_dates() { |
| 95 | 95 | $predefined = array( |
| 96 | - 'today' => esc_html__( 'Today', 'give' ), |
|
| 97 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
| 98 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
| 99 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
| 100 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
| 101 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
| 102 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
| 103 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
| 104 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
| 105 | - 'last_year' => esc_html__( 'Last Year', 'give' ), |
|
| 96 | + 'today' => esc_html__('Today', 'give'), |
|
| 97 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
| 98 | + 'this_week' => esc_html__('This Week', 'give'), |
|
| 99 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
| 100 | + 'this_month' => esc_html__('This Month', 'give'), |
|
| 101 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
| 102 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
| 103 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
| 104 | + 'this_year' => esc_html__('This Year', 'give'), |
|
| 105 | + 'last_year' => esc_html__('Last Year', 'give'), |
|
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
| 108 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -121,18 +121,18 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @return void |
| 123 | 123 | */ |
| 124 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
| 124 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
| 125 | 125 | |
| 126 | - if ( empty( $_start_date ) ) { |
|
| 126 | + if (empty($_start_date)) { |
|
| 127 | 127 | $_start_date = 'this_month'; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( empty( $_end_date ) ) { |
|
| 130 | + if (empty($_end_date)) { |
|
| 131 | 131 | $_end_date = $_start_date; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - $this->start_date = $this->convert_date( $_start_date ); |
|
| 135 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
| 134 | + $this->start_date = $this->convert_date($_start_date); |
|
| 135 | + $this->end_date = $this->convert_date($_end_date, true); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -148,26 +148,26 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned. |
| 150 | 150 | */ |
| 151 | - public function convert_date( $date, $end_date = false ) { |
|
| 151 | + public function convert_date($date, $end_date = false) { |
|
| 152 | 152 | |
| 153 | 153 | $this->timestamp = false; |
| 154 | 154 | $second = $end_date ? 59 : 0; |
| 155 | 155 | $minute = $end_date ? 59 : 0; |
| 156 | 156 | $hour = $end_date ? 23 : 0; |
| 157 | 157 | $day = 1; |
| 158 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
| 159 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
| 158 | + $month = date('n', current_time('timestamp')); |
|
| 159 | + $year = date('Y', current_time('timestamp')); |
|
| 160 | 160 | |
| 161 | - if ( array_key_exists( (string) $date, $this->get_predefined_dates() ) ) { |
|
| 161 | + if (array_key_exists((string) $date, $this->get_predefined_dates())) { |
|
| 162 | 162 | |
| 163 | 163 | // This is a predefined date rate, such as last_week |
| 164 | - switch ( $date ) { |
|
| 164 | + switch ($date) { |
|
| 165 | 165 | |
| 166 | 166 | case 'this_month' : |
| 167 | 167 | |
| 168 | - if ( $end_date ) { |
|
| 168 | + if ($end_date) { |
|
| 169 | 169 | |
| 170 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 170 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 171 | 171 | $hour = 23; |
| 172 | 172 | $minute = 59; |
| 173 | 173 | $second = 59; |
@@ -177,28 +177,28 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | case 'last_month' : |
| 179 | 179 | |
| 180 | - if ( $month == 1 ) { |
|
| 180 | + if ($month == 1) { |
|
| 181 | 181 | |
| 182 | 182 | $month = 12; |
| 183 | - $year --; |
|
| 183 | + $year--; |
|
| 184 | 184 | |
| 185 | 185 | } else { |
| 186 | 186 | |
| 187 | - $month --; |
|
| 187 | + $month--; |
|
| 188 | 188 | |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if ( $end_date ) { |
|
| 192 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 191 | + if ($end_date) { |
|
| 192 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | break; |
| 196 | 196 | |
| 197 | 197 | case 'today' : |
| 198 | 198 | |
| 199 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
| 199 | + $day = date('d', current_time('timestamp')); |
|
| 200 | 200 | |
| 201 | - if ( $end_date ) { |
|
| 201 | + if ($end_date) { |
|
| 202 | 202 | $hour = 23; |
| 203 | 203 | $minute = 59; |
| 204 | 204 | $second = 59; |
@@ -208,23 +208,23 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | case 'yesterday' : |
| 210 | 210 | |
| 211 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
| 211 | + $day = date('d', current_time('timestamp')) - 1; |
|
| 212 | 212 | |
| 213 | 213 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
| 214 | - if ( $day < 1 ) { |
|
| 214 | + if ($day < 1) { |
|
| 215 | 215 | |
| 216 | 216 | // If current month is 1 |
| 217 | - if ( 1 == $month ) { |
|
| 217 | + if (1 == $month) { |
|
| 218 | 218 | |
| 219 | 219 | $year -= 1; // Today is January 1, so skip back to last day of December |
| 220 | 220 | $month = 12; |
| 221 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 221 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 222 | 222 | |
| 223 | 223 | } else { |
| 224 | 224 | |
| 225 | 225 | // Go back one month and get the last day of the month |
| 226 | 226 | $month -= 1; |
| 227 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 227 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 228 | 228 | |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -233,12 +233,12 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | case 'this_week' : |
| 235 | 235 | |
| 236 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
| 237 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
| 236 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
| 237 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
| 238 | 238 | |
| 239 | - if ( $today < $days_to_week_start ) { |
|
| 239 | + if ($today < $days_to_week_start) { |
|
| 240 | 240 | |
| 241 | - if ( $month > 1 ) { |
|
| 241 | + if ($month > 1) { |
|
| 242 | 242 | $month -= 1; |
| 243 | 243 | } else { |
| 244 | 244 | $month = 12; |
@@ -246,19 +246,19 @@ discard block |
||
| 246 | 246 | |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if ( ! $end_date ) { |
|
| 249 | + if ( ! $end_date) { |
|
| 250 | 250 | |
| 251 | 251 | // Getting the start day |
| 252 | 252 | |
| 253 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
| 254 | - $day += get_option( 'start_of_week' ); |
|
| 253 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
| 254 | + $day += get_option('start_of_week'); |
|
| 255 | 255 | |
| 256 | 256 | } else { |
| 257 | 257 | |
| 258 | 258 | // Getting the end day |
| 259 | 259 | |
| 260 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
| 261 | - $day += get_option( 'start_of_week' ) + 6; |
|
| 260 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
| 261 | + $day += get_option('start_of_week') + 6; |
|
| 262 | 262 | |
| 263 | 263 | } |
| 264 | 264 | |
@@ -266,12 +266,12 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | case 'last_week' : |
| 268 | 268 | |
| 269 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
| 270 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
| 269 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
| 270 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
| 271 | 271 | |
| 272 | - if ( $today < $days_to_week_start ) { |
|
| 272 | + if ($today < $days_to_week_start) { |
|
| 273 | 273 | |
| 274 | - if ( $month > 1 ) { |
|
| 274 | + if ($month > 1) { |
|
| 275 | 275 | $month -= 1; |
| 276 | 276 | } else { |
| 277 | 277 | $month = 12; |
@@ -279,19 +279,19 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - if ( ! $end_date ) { |
|
| 282 | + if ( ! $end_date) { |
|
| 283 | 283 | |
| 284 | 284 | // Getting the start day |
| 285 | 285 | |
| 286 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
| 287 | - $day += get_option( 'start_of_week' ); |
|
| 286 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
| 287 | + $day += get_option('start_of_week'); |
|
| 288 | 288 | |
| 289 | 289 | } else { |
| 290 | 290 | |
| 291 | 291 | // Getting the end day |
| 292 | 292 | |
| 293 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
| 294 | - $day += get_option( 'start_of_week' ) + 6; |
|
| 293 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
| 294 | + $day += get_option('start_of_week') + 6; |
|
| 295 | 295 | |
| 296 | 296 | } |
| 297 | 297 | |
@@ -299,39 +299,39 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | case 'this_quarter' : |
| 301 | 301 | |
| 302 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
| 302 | + $month_now = date('n', current_time('timestamp')); |
|
| 303 | 303 | |
| 304 | - if ( $month_now <= 3 ) { |
|
| 304 | + if ($month_now <= 3) { |
|
| 305 | 305 | |
| 306 | - if ( ! $end_date ) { |
|
| 306 | + if ( ! $end_date) { |
|
| 307 | 307 | $month = 1; |
| 308 | 308 | } else { |
| 309 | 309 | $month = 3; |
| 310 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 310 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 311 | 311 | $hour = 23; |
| 312 | 312 | $minute = 59; |
| 313 | 313 | $second = 59; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - } else if ( $month_now <= 6 ) { |
|
| 316 | + } else if ($month_now <= 6) { |
|
| 317 | 317 | |
| 318 | - if ( ! $end_date ) { |
|
| 318 | + if ( ! $end_date) { |
|
| 319 | 319 | $month = 4; |
| 320 | 320 | } else { |
| 321 | 321 | $month = 6; |
| 322 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 322 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 323 | 323 | $hour = 23; |
| 324 | 324 | $minute = 59; |
| 325 | 325 | $second = 59; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - } else if ( $month_now <= 9 ) { |
|
| 328 | + } else if ($month_now <= 9) { |
|
| 329 | 329 | |
| 330 | - if ( ! $end_date ) { |
|
| 330 | + if ( ! $end_date) { |
|
| 331 | 331 | $month = 7; |
| 332 | 332 | } else { |
| 333 | 333 | $month = 9; |
| 334 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 334 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 335 | 335 | $hour = 23; |
| 336 | 336 | $minute = 59; |
| 337 | 337 | $second = 59; |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | } else { |
| 341 | 341 | |
| 342 | - if ( ! $end_date ) { |
|
| 342 | + if ( ! $end_date) { |
|
| 343 | 343 | $month = 10; |
| 344 | 344 | } else { |
| 345 | 345 | $month = 12; |
| 346 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 346 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 347 | 347 | $hour = 23; |
| 348 | 348 | $minute = 59; |
| 349 | 349 | $second = 59; |
@@ -355,40 +355,40 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | case 'last_quarter' : |
| 357 | 357 | |
| 358 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
| 358 | + $month_now = date('n', current_time('timestamp')); |
|
| 359 | 359 | |
| 360 | - if ( $month_now <= 3 ) { |
|
| 360 | + if ($month_now <= 3) { |
|
| 361 | 361 | |
| 362 | - if ( ! $end_date ) { |
|
| 362 | + if ( ! $end_date) { |
|
| 363 | 363 | $month = 10; |
| 364 | 364 | } else { |
| 365 | 365 | $year -= 1; |
| 366 | 366 | $month = 12; |
| 367 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 367 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 368 | 368 | $hour = 23; |
| 369 | 369 | $minute = 59; |
| 370 | 370 | $second = 59; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - } else if ( $month_now <= 6 ) { |
|
| 373 | + } else if ($month_now <= 6) { |
|
| 374 | 374 | |
| 375 | - if ( ! $end_date ) { |
|
| 375 | + if ( ! $end_date) { |
|
| 376 | 376 | $month = 1; |
| 377 | 377 | } else { |
| 378 | 378 | $month = 3; |
| 379 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 379 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 380 | 380 | $hour = 23; |
| 381 | 381 | $minute = 59; |
| 382 | 382 | $second = 59; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - } else if ( $month_now <= 9 ) { |
|
| 385 | + } else if ($month_now <= 9) { |
|
| 386 | 386 | |
| 387 | - if ( ! $end_date ) { |
|
| 387 | + if ( ! $end_date) { |
|
| 388 | 388 | $month = 4; |
| 389 | 389 | } else { |
| 390 | 390 | $month = 6; |
| 391 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 391 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 392 | 392 | $hour = 23; |
| 393 | 393 | $minute = 59; |
| 394 | 394 | $second = 59; |
@@ -396,11 +396,11 @@ discard block |
||
| 396 | 396 | |
| 397 | 397 | } else { |
| 398 | 398 | |
| 399 | - if ( ! $end_date ) { |
|
| 399 | + if ( ! $end_date) { |
|
| 400 | 400 | $month = 7; |
| 401 | 401 | } else { |
| 402 | 402 | $month = 9; |
| 403 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 403 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 404 | 404 | $hour = 23; |
| 405 | 405 | $minute = 59; |
| 406 | 406 | $second = 59; |
@@ -412,11 +412,11 @@ discard block |
||
| 412 | 412 | |
| 413 | 413 | case 'this_year' : |
| 414 | 414 | |
| 415 | - if ( ! $end_date ) { |
|
| 415 | + if ( ! $end_date) { |
|
| 416 | 416 | $month = 1; |
| 417 | 417 | } else { |
| 418 | 418 | $month = 12; |
| 419 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 419 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 420 | 420 | $hour = 23; |
| 421 | 421 | $minute = 59; |
| 422 | 422 | $second = 59; |
@@ -427,11 +427,11 @@ discard block |
||
| 427 | 427 | case 'last_year' : |
| 428 | 428 | |
| 429 | 429 | $year -= 1; |
| 430 | - if ( ! $end_date ) { |
|
| 430 | + if ( ! $end_date) { |
|
| 431 | 431 | $month = 1; |
| 432 | 432 | } else { |
| 433 | 433 | $month = 12; |
| 434 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 434 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 435 | 435 | $hour = 23; |
| 436 | 436 | $minute = 59; |
| 437 | 437 | $second = 59; |
@@ -442,30 +442,30 @@ discard block |
||
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | |
| 445 | - } else if ( is_numeric( $date ) ) { |
|
| 445 | + } else if (is_numeric($date)) { |
|
| 446 | 446 | |
| 447 | 447 | // return $date unchanged since it is a timestamp |
| 448 | 448 | $this->timestamp = true; |
| 449 | 449 | |
| 450 | - } else if ( false !== strtotime( $date ) ) { |
|
| 450 | + } else if (false !== strtotime($date)) { |
|
| 451 | 451 | |
| 452 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
| 453 | - $year = date( 'Y', $date ); |
|
| 454 | - $month = date( 'm', $date ); |
|
| 455 | - $day = date( 'd', $date ); |
|
| 452 | + $date = strtotime($date, current_time('timestamp')); |
|
| 453 | + $year = date('Y', $date); |
|
| 454 | + $month = date('m', $date); |
|
| 455 | + $day = date('d', $date); |
|
| 456 | 456 | |
| 457 | 457 | } else { |
| 458 | 458 | |
| 459 | - return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) ); |
|
| 459 | + return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give')); |
|
| 460 | 460 | |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - if ( false === $this->timestamp ) { |
|
| 463 | + if (false === $this->timestamp) { |
|
| 464 | 464 | // Create an exact timestamp |
| 465 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
| 465 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
| 468 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
| 469 | 469 | |
| 470 | 470 | } |
| 471 | 471 | |
@@ -481,33 +481,33 @@ discard block |
||
| 481 | 481 | * |
| 482 | 482 | * @return string |
| 483 | 483 | */ |
| 484 | - public function count_where( $where = '' ) { |
|
| 484 | + public function count_where($where = '') { |
|
| 485 | 485 | // Only get payments in our date range |
| 486 | 486 | |
| 487 | 487 | $start_where = ''; |
| 488 | 488 | $end_where = ''; |
| 489 | 489 | |
| 490 | - if ( $this->start_date ) { |
|
| 490 | + if ($this->start_date) { |
|
| 491 | 491 | |
| 492 | - if ( $this->timestamp ) { |
|
| 492 | + if ($this->timestamp) { |
|
| 493 | 493 | $format = 'Y-m-d H:i:s'; |
| 494 | 494 | } else { |
| 495 | 495 | $format = 'Y-m-d 00:00:00'; |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | - $start_date = date( $format, $this->start_date ); |
|
| 498 | + $start_date = date($format, $this->start_date); |
|
| 499 | 499 | $start_where = " AND p.post_date >= '{$start_date}'"; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - if ( $this->end_date ) { |
|
| 502 | + if ($this->end_date) { |
|
| 503 | 503 | |
| 504 | - if ( $this->timestamp ) { |
|
| 504 | + if ($this->timestamp) { |
|
| 505 | 505 | $format = 'Y-m-d H:i:s'; |
| 506 | 506 | } else { |
| 507 | 507 | $format = 'Y-m-d 23:59:59'; |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - $end_date = date( $format, $this->end_date ); |
|
| 510 | + $end_date = date($format, $this->end_date); |
|
| 511 | 511 | |
| 512 | 512 | $end_where = " AND p.post_date <= '{$end_date}'"; |
| 513 | 513 | } |
@@ -529,34 +529,34 @@ discard block |
||
| 529 | 529 | * |
| 530 | 530 | * @return string |
| 531 | 531 | */ |
| 532 | - public function payments_where( $where = '' ) { |
|
| 532 | + public function payments_where($where = '') { |
|
| 533 | 533 | |
| 534 | 534 | global $wpdb; |
| 535 | 535 | |
| 536 | 536 | $start_where = ''; |
| 537 | 537 | $end_where = ''; |
| 538 | 538 | |
| 539 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
| 539 | + if ( ! is_wp_error($this->start_date)) { |
|
| 540 | 540 | |
| 541 | - if ( $this->timestamp ) { |
|
| 541 | + if ($this->timestamp) { |
|
| 542 | 542 | $format = 'Y-m-d H:i:s'; |
| 543 | 543 | } else { |
| 544 | 544 | $format = 'Y-m-d 00:00:00'; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - $start_date = date( $format, $this->start_date ); |
|
| 547 | + $start_date = date($format, $this->start_date); |
|
| 548 | 548 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
| 551 | + if ( ! is_wp_error($this->end_date)) { |
|
| 552 | 552 | |
| 553 | - if ( $this->timestamp ) { |
|
| 553 | + if ($this->timestamp) { |
|
| 554 | 554 | $format = 'Y-m-d H:i:s'; |
| 555 | 555 | } else { |
| 556 | 556 | $format = 'Y-m-d 23:59:59'; |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - $end_date = date( $format, $this->end_date ); |
|
| 559 | + $end_date = date($format, $this->end_date); |
|
| 560 | 560 | |
| 561 | 561 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
| 562 | 562 | } |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * Return the calculated completion percentage. |
| 217 | 217 | * |
| 218 | 218 | * @since 1.8.12 |
| 219 | - * @return int |
|
| 219 | + * @return double |
|
| 220 | 220 | */ |
| 221 | 221 | public function get_percentage_complete() { |
| 222 | 222 | return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
@@ -353,6 +353,9 @@ discard block |
||
| 353 | 353 | return true; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | + /** |
|
| 357 | + * @param integer $page |
|
| 358 | + */ |
|
| 356 | 359 | public function get_delete_ids( $donation_ids, $page ) { |
| 357 | 360 | $index = $page --; |
| 358 | 361 | $count = count( $donation_ids ); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -116,34 +116,34 @@ discard block |
||
| 116 | 116 | $donor_ids = array(); |
| 117 | 117 | |
| 118 | 118 | // Check if the ajax request if running for the first time. |
| 119 | - if ( 1 === (int) $this->step ) { |
|
| 119 | + if (1 === (int) $this->step) { |
|
| 120 | 120 | // Delete all the form ids. |
| 121 | - $this->delete_option( $this->form_key ); |
|
| 121 | + $this->delete_option($this->form_key); |
|
| 122 | 122 | // Delete all the donation ids. |
| 123 | - $this->delete_option( $this->donation_key ); |
|
| 123 | + $this->delete_option($this->donation_key); |
|
| 124 | 124 | // Delete all the donor ids. |
| 125 | - $this->delete_option( $this->donor_key ); |
|
| 125 | + $this->delete_option($this->donor_key); |
|
| 126 | 126 | |
| 127 | 127 | // Delete all the step and set to 'count' which if the first step in the process of deleting the donors. |
| 128 | - $this->update_option( $this->step_key, 'count' ); |
|
| 128 | + $this->update_option($this->step_key, 'count'); |
|
| 129 | 129 | |
| 130 | 130 | // Delete tha page count of the step. |
| 131 | - $this->update_option( $this->step_on_key, '0' ); |
|
| 131 | + $this->update_option($this->step_on_key, '0'); |
|
| 132 | 132 | } else { |
| 133 | 133 | // Get the old donors list. |
| 134 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
| 134 | + $donor_ids = $this->get_option($this->donor_key); |
|
| 135 | 135 | |
| 136 | 136 | // Get the old donation list. |
| 137 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
| 137 | + $donation_ids = $this->get_option($this->donation_key); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Get the step and check for it if it's on the first step( 'count' ) or not. |
| 141 | 141 | $step = (int) $this->get_step(); |
| 142 | - if ( 1 === $step ) { |
|
| 142 | + if (1 === $step) { |
|
| 143 | 143 | /** |
| 144 | 144 | * Will add or update the donation and donor data by running wp query. |
| 145 | 145 | */ |
| 146 | - $this->count( $step, $donation_ids, $donor_ids ); |
|
| 146 | + $this->count($step, $donation_ids, $donor_ids); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
@@ -154,17 +154,17 @@ discard block |
||
| 154 | 154 | * @param array $donation_ids Contain the list of all the donation id's that has being add before this |
| 155 | 155 | * @param array $donor_ids Contain the list of all the donors id's that has being add before this |
| 156 | 156 | */ |
| 157 | - private function count( $step, $donation_ids = array(), $donor_ids = array() ) { |
|
| 157 | + private function count($step, $donation_ids = array(), $donor_ids = array()) { |
|
| 158 | 158 | |
| 159 | 159 | // Get the Page count by default it's zero. |
| 160 | 160 | $paged = (int) $this->get_step_page(); |
| 161 | 161 | // Incresed the page count by one. |
| 162 | - ++ $paged; |
|
| 162 | + ++$paged; |
|
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | 165 | * Filter add to alter the argument before the wp quest run |
| 166 | 166 | */ |
| 167 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 167 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 168 | 168 | 'post_type' => 'give_payment', |
| 169 | 169 | 'post_status' => 'any', |
| 170 | 170 | 'posts_per_page' => $this->per_step, |
@@ -172,40 +172,40 @@ discard block |
||
| 172 | 172 | 'meta_key' => '_give_payment_import', |
| 173 | 173 | 'meta_value_num' => 1, |
| 174 | 174 | 'meta_compare' => '=', |
| 175 | - ) ); |
|
| 175 | + )); |
|
| 176 | 176 | |
| 177 | 177 | // Reset the post data. |
| 178 | 178 | wp_reset_postdata(); |
| 179 | 179 | // Getting the new donation. |
| 180 | - $donation_posts = new WP_Query( $args ); |
|
| 180 | + $donation_posts = new WP_Query($args); |
|
| 181 | 181 | |
| 182 | 182 | // The Loop. |
| 183 | - if ( $donation_posts->have_posts() ) { |
|
| 184 | - while ( $donation_posts->have_posts() ) { |
|
| 183 | + if ($donation_posts->have_posts()) { |
|
| 184 | + while ($donation_posts->have_posts()) { |
|
| 185 | 185 | $add_author = true; |
| 186 | 186 | $donation_posts->the_post(); |
| 187 | 187 | global $post; |
| 188 | 188 | // Add the donation id in side the array. |
| 189 | 189 | $donation_ids[] = $post->ID; |
| 190 | 190 | |
| 191 | - $donor_id = (int) get_post_meta( $post->ID, '_give_payment_customer_id', true ); |
|
| 192 | - if ( ! empty( $donor_id ) ) { |
|
| 193 | - $donor = new Give_Donor( $donor_id ); |
|
| 194 | - if ( ! empty( $donor->id ) ) { |
|
| 195 | - if ( empty( $donor->user_id ) && ! empty( $donor->payment_ids ) ) { |
|
| 191 | + $donor_id = (int) get_post_meta($post->ID, '_give_payment_customer_id', true); |
|
| 192 | + if ( ! empty($donor_id)) { |
|
| 193 | + $donor = new Give_Donor($donor_id); |
|
| 194 | + if ( ! empty($donor->id)) { |
|
| 195 | + if (empty($donor->user_id) && ! empty($donor->payment_ids)) { |
|
| 196 | 196 | $add_author = false; |
| 197 | - $count = (int) count( $donor->payment_ids ); |
|
| 198 | - if ( 1 === $count ) { |
|
| 199 | - Give()->donors->delete( $donor->id ); |
|
| 197 | + $count = (int) count($donor->payment_ids); |
|
| 198 | + if (1 === $count) { |
|
| 199 | + Give()->donors->delete($donor->id); |
|
| 200 | 200 | } else { |
| 201 | - $donor->remove_payment( $post->ID ); |
|
| 201 | + $donor->remove_payment($post->ID); |
|
| 202 | 202 | $donor->decrease_donation_count(); |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if ( ! empty( $add_author ) ) { |
|
| 208 | + if ( ! empty($add_author)) { |
|
| 209 | 209 | // Add the donor id in side the array. |
| 210 | 210 | $donor_ids[] = (int) $post->post_author; |
| 211 | 211 | } |
@@ -220,23 +220,23 @@ discard block |
||
| 220 | 220 | $max_num_pages = (int) $donation_posts->max_num_pages; |
| 221 | 221 | |
| 222 | 222 | // Check current page is less then max number of page or not |
| 223 | - if ( $paged < $max_num_pages ) { |
|
| 223 | + if ($paged < $max_num_pages) { |
|
| 224 | 224 | // Update the curretn page virable for the next step |
| 225 | - $this->update_option( $this->step_on_key, $paged ); |
|
| 225 | + $this->update_option($this->step_on_key, $paged); |
|
| 226 | 226 | |
| 227 | 227 | // Calculating percentage. |
| 228 | 228 | $page_remain = $max_num_pages - $paged; |
| 229 | - $this->total_step = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) ); |
|
| 229 | + $this->total_step = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids)); |
|
| 230 | 230 | $this->step_completed = $paged; |
| 231 | 231 | } else { |
| 232 | - $donation_ids_count = count( $donor_ids ); |
|
| 233 | - $this->update_option( $this->step_key, 'donation' ); |
|
| 234 | - $this->update_option( $this->step_on_key, '0' ); |
|
| 232 | + $donation_ids_count = count($donor_ids); |
|
| 233 | + $this->update_option($this->step_key, 'donation'); |
|
| 234 | + $this->update_option($this->step_on_key, '0'); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $donor_ids = array_unique( $donor_ids ); |
|
| 238 | - $this->update_option( $this->donor_key, $donor_ids ); |
|
| 239 | - $this->update_option( $this->donation_key, $donation_ids ); |
|
| 237 | + $donor_ids = array_unique($donor_ids); |
|
| 238 | + $this->update_option($this->donor_key, $donor_ids); |
|
| 239 | + $this->update_option($this->donation_key, $donation_ids); |
|
| 240 | 240 | |
| 241 | 241 | wp_reset_postdata(); |
| 242 | 242 | } |
@@ -248,34 +248,34 @@ discard block |
||
| 248 | 248 | * @return int |
| 249 | 249 | */ |
| 250 | 250 | public function get_percentage_complete() { |
| 251 | - return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
|
| 251 | + return ceil((100 * $this->step_completed) / $this->total_step); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | public function process_step() { |
| 255 | 255 | |
| 256 | - if ( ! $this->can_export() ) { |
|
| 257 | - wp_die( __( 'You do not have permission to delete Import transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 256 | + if ( ! $this->can_export()) { |
|
| 257 | + wp_die(__('You do not have permission to delete Import transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | $had_data = $this->get_data(); |
| 261 | 261 | |
| 262 | - if ( $had_data ) { |
|
| 262 | + if ($had_data) { |
|
| 263 | 263 | $this->done = false; |
| 264 | 264 | |
| 265 | 265 | return true; |
| 266 | 266 | } else { |
| 267 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
| 268 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
| 267 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
| 268 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
| 269 | 269 | |
| 270 | - $this->delete_option( $this->donation_key ); |
|
| 270 | + $this->delete_option($this->donation_key); |
|
| 271 | 271 | |
| 272 | 272 | // Reset the sequential order numbers |
| 273 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 274 | - delete_option( 'give_last_payment_number' ); |
|
| 273 | + if (give_get_option('enable_sequential')) { |
|
| 274 | + delete_option('give_last_payment_number'); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | $this->done = true; |
| 278 | - $this->message = __( 'Imported donor and transactions successfully deleted.', 'give' ); |
|
| 278 | + $this->message = __('Imported donor and transactions successfully deleted.', 'give'); |
|
| 279 | 279 | |
| 280 | 280 | return false; |
| 281 | 281 | } |
@@ -293,12 +293,12 @@ discard block |
||
| 293 | 293 | public function get_data() { |
| 294 | 294 | |
| 295 | 295 | // Get the donation id's. |
| 296 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
| 296 | + $donation_ids = $this->get_option($this->donation_key); |
|
| 297 | 297 | |
| 298 | 298 | /** |
| 299 | 299 | * Return false id not Import donation is found. |
| 300 | 300 | */ |
| 301 | - if ( empty( $donation_ids ) ) { |
|
| 301 | + if (empty($donation_ids)) { |
|
| 302 | 302 | $this->is_empty = true; |
| 303 | 303 | $this->total_step = 1; |
| 304 | 304 | |
@@ -309,110 +309,110 @@ discard block |
||
| 309 | 309 | $step = (int) $this->get_step(); |
| 310 | 310 | |
| 311 | 311 | // get teh donor ids. |
| 312 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
| 312 | + $donor_ids = $this->get_option($this->donor_key); |
|
| 313 | 313 | |
| 314 | 314 | // In step to we delete all the donation in loop. |
| 315 | - if ( 2 === $step ) { |
|
| 315 | + if (2 === $step) { |
|
| 316 | 316 | $pass_to_donor = false; |
| 317 | 317 | $page = (int) $this->get_step_page(); |
| 318 | - $page ++; |
|
| 319 | - $count = count( $donation_ids ); |
|
| 318 | + $page++; |
|
| 319 | + $count = count($donation_ids); |
|
| 320 | 320 | |
| 321 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
| 321 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
| 322 | 322 | $this->step_completed = $page; |
| 323 | 323 | |
| 324 | 324 | |
| 325 | - if ( $count > $this->per_step ) { |
|
| 325 | + if ($count > $this->per_step) { |
|
| 326 | 326 | |
| 327 | - $this->update_option( $this->step_on_key, $page ); |
|
| 328 | - $donation_ids = $this->get_delete_ids( $donation_ids, $page ); |
|
| 329 | - $current_page = (int) ceil( $count / $this->per_step ); |
|
| 327 | + $this->update_option($this->step_on_key, $page); |
|
| 328 | + $donation_ids = $this->get_delete_ids($donation_ids, $page); |
|
| 329 | + $current_page = (int) ceil($count / $this->per_step); |
|
| 330 | 330 | |
| 331 | - if ( $page === $current_page ) { |
|
| 331 | + if ($page === $current_page) { |
|
| 332 | 332 | $pass_to_donor = true; |
| 333 | 333 | } |
| 334 | 334 | } else { |
| 335 | 335 | $pass_to_donor = true; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - if ( true === $pass_to_donor ) { |
|
| 339 | - $this->update_option( $this->step_key, 'donor' ); |
|
| 340 | - $this->update_option( $this->step_on_key, '0' ); |
|
| 338 | + if (true === $pass_to_donor) { |
|
| 339 | + $this->update_option($this->step_key, 'donor'); |
|
| 340 | + $this->update_option($this->step_on_key, '0'); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | // Get the old form list. |
| 344 | - $form_ids = (array) $this->get_option( $this->form_key ); |
|
| 344 | + $form_ids = (array) $this->get_option($this->form_key); |
|
| 345 | 345 | |
| 346 | - foreach ( $donation_ids as $item ) { |
|
| 347 | - $form_ids[] = get_post_meta( $item, '_give_payment_form_id', true ); |
|
| 346 | + foreach ($donation_ids as $item) { |
|
| 347 | + $form_ids[] = get_post_meta($item, '_give_payment_form_id', true); |
|
| 348 | 348 | |
| 349 | 349 | // Delete the main payment. |
| 350 | - give_delete_donation( absint( $item ) ); |
|
| 350 | + give_delete_donation(absint($item)); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | // update the new form list. |
| 354 | - $this->update_option( $this->form_key, $form_ids ); |
|
| 354 | + $this->update_option($this->form_key, $form_ids); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | |
| 358 | 358 | // Here we delete all the donor |
| 359 | - if ( 3 === $step ) { |
|
| 359 | + if (3 === $step) { |
|
| 360 | 360 | |
| 361 | 361 | // Get the old form list. |
| 362 | - $form_ids = (array) $this->get_option( $this->form_key ); |
|
| 363 | - if ( ! empty( $form_ids ) ) { |
|
| 364 | - $form_ids = array_unique( $form_ids ); |
|
| 365 | - foreach ( $form_ids as $form_id ) { |
|
| 366 | - give_recount_form_income_donation( (int) $form_id ); |
|
| 362 | + $form_ids = (array) $this->get_option($this->form_key); |
|
| 363 | + if ( ! empty($form_ids)) { |
|
| 364 | + $form_ids = array_unique($form_ids); |
|
| 365 | + foreach ($form_ids as $form_id) { |
|
| 366 | + give_recount_form_income_donation((int) $form_id); |
|
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | // update the new form list. |
| 370 | - $this->update_option( $this->form_key, array() ); |
|
| 370 | + $this->update_option($this->form_key, array()); |
|
| 371 | 371 | |
| 372 | 372 | $page = (int) $this->get_step_page(); |
| 373 | - $count = count( $donor_ids ); |
|
| 373 | + $count = count($donor_ids); |
|
| 374 | 374 | |
| 375 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
| 376 | - $this->step_completed = $page + ( count( $donation_ids ) / $this->per_step ); |
|
| 375 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
| 376 | + $this->step_completed = $page + (count($donation_ids) / $this->per_step); |
|
| 377 | 377 | |
| 378 | - if ( ! empty( $donor_ids[ $page ] ) ) { |
|
| 379 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 378 | + if ( ! empty($donor_ids[$page])) { |
|
| 379 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 380 | 380 | 'post_status' => 'any', |
| 381 | 381 | 'posts_per_page' => 1, |
| 382 | - 'author' => $donor_ids[ $page ] |
|
| 383 | - ) ); |
|
| 382 | + 'author' => $donor_ids[$page] |
|
| 383 | + )); |
|
| 384 | 384 | |
| 385 | 385 | $donations = array(); |
| 386 | - $payments = new Give_Payments_Query( $args ); |
|
| 386 | + $payments = new Give_Payments_Query($args); |
|
| 387 | 387 | $payments = $payments->get_payments(); |
| 388 | - if ( empty( $payments ) ) { |
|
| 389 | - Give()->donors->delete_by_user_id( $donor_ids[ $page ] ); |
|
| 388 | + if (empty($payments)) { |
|
| 389 | + Give()->donors->delete_by_user_id($donor_ids[$page]); |
|
| 390 | 390 | |
| 391 | 391 | /** |
| 392 | 392 | * If Checked then delete WP user. |
| 393 | 393 | * |
| 394 | 394 | * @since 1.8.14 |
| 395 | 395 | */ |
| 396 | - if ( 'on' === (string) $_REQUEST['delete-import-donors'] ) { |
|
| 397 | - wp_delete_user( $donor_ids[ $page ] ); |
|
| 396 | + if ('on' === (string) $_REQUEST['delete-import-donors']) { |
|
| 397 | + wp_delete_user($donor_ids[$page]); |
|
| 398 | 398 | } |
| 399 | 399 | } else { |
| 400 | - foreach ( $payments as $payment ) { |
|
| 400 | + foreach ($payments as $payment) { |
|
| 401 | 401 | $donations[] = $payment->ID; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - $donor = new Give_Donor( $donor_ids[ $page ], true ); |
|
| 404 | + $donor = new Give_Donor($donor_ids[$page], true); |
|
| 405 | 405 | $data_to_update = array( |
| 406 | - 'purchase_count' => count( $donations ), |
|
| 407 | - 'payment_ids' => implode( ',', $donations ), |
|
| 406 | + 'purchase_count' => count($donations), |
|
| 407 | + 'payment_ids' => implode(',', $donations), |
|
| 408 | 408 | ); |
| 409 | - $donor->update( $data_to_update ); |
|
| 409 | + $donor->update($data_to_update); |
|
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - $page ++; |
|
| 414 | - $this->update_option( $this->step_on_key, $page ); |
|
| 415 | - if ( $count === $page ) { |
|
| 413 | + $page++; |
|
| 414 | + $this->update_option($this->step_on_key, $page); |
|
| 415 | + if ($count === $page) { |
|
| 416 | 416 | $this->is_empty = false; |
| 417 | 417 | |
| 418 | 418 | return false; |
@@ -424,24 +424,24 @@ discard block |
||
| 424 | 424 | return true; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - public function get_delete_ids( $donation_ids, $page ) { |
|
| 428 | - $index = $page --; |
|
| 429 | - $count = count( $donation_ids ); |
|
| 427 | + public function get_delete_ids($donation_ids, $page) { |
|
| 428 | + $index = $page--; |
|
| 429 | + $count = count($donation_ids); |
|
| 430 | 430 | $temp = 0; |
| 431 | 431 | $current_page = 0; |
| 432 | 432 | $post_delete = $this->per_step; |
| 433 | 433 | $page_donation_id = array(); |
| 434 | 434 | |
| 435 | - foreach ( $donation_ids as $item ) { |
|
| 436 | - $temp ++; |
|
| 437 | - $page_donation_id[ $current_page ][] = $item; |
|
| 438 | - if ( $temp === $post_delete ) { |
|
| 439 | - $current_page ++; |
|
| 435 | + foreach ($donation_ids as $item) { |
|
| 436 | + $temp++; |
|
| 437 | + $page_donation_id[$current_page][] = $item; |
|
| 438 | + if ($temp === $post_delete) { |
|
| 439 | + $current_page++; |
|
| 440 | 440 | $temp = 0; |
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - return $page_donation_id[ $page ]; |
|
| 444 | + return $page_donation_id[$page]; |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | /** |
@@ -453,8 +453,8 @@ discard block |
||
| 453 | 453 | * |
| 454 | 454 | * @return mixed Returns the data from the database |
| 455 | 455 | */ |
| 456 | - public function get_option( $key, $defalut_value = false ) { |
|
| 457 | - return get_option( $key, $defalut_value ); |
|
| 456 | + public function get_option($key, $defalut_value = false) { |
|
| 457 | + return get_option($key, $defalut_value); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | /** |
@@ -467,8 +467,8 @@ discard block |
||
| 467 | 467 | * |
| 468 | 468 | * @return void |
| 469 | 469 | */ |
| 470 | - public function update_option( $key, $value ) { |
|
| 471 | - update_option( $key, $value, false ); |
|
| 470 | + public function update_option($key, $value) { |
|
| 471 | + update_option($key, $value, false); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -480,8 +480,8 @@ discard block |
||
| 480 | 480 | * |
| 481 | 481 | * @return void |
| 482 | 482 | */ |
| 483 | - public function delete_option( $key ) { |
|
| 484 | - delete_option( $key ); |
|
| 483 | + public function delete_option($key) { |
|
| 484 | + delete_option($key); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -492,12 +492,12 @@ discard block |
||
| 492 | 492 | * @return int|string |
| 493 | 493 | */ |
| 494 | 494 | private function get_step() { |
| 495 | - $step_key = (string) $this->get_option( $this->step_key, false ); |
|
| 496 | - if ( 'count' === $step_key ) { |
|
| 495 | + $step_key = (string) $this->get_option($this->step_key, false); |
|
| 496 | + if ('count' === $step_key) { |
|
| 497 | 497 | return 1; |
| 498 | - } elseif ( 'donation' === $step_key ) { |
|
| 498 | + } elseif ('donation' === $step_key) { |
|
| 499 | 499 | return 2; |
| 500 | - } elseif ( 'donor' === $step_key ) { |
|
| 500 | + } elseif ('donor' === $step_key) { |
|
| 501 | 501 | return 3; |
| 502 | 502 | } else { |
| 503 | 503 | return $step_key; |
@@ -508,6 +508,6 @@ discard block |
||
| 508 | 508 | * Get the current $page value in the ajax. |
| 509 | 509 | */ |
| 510 | 510 | private function get_step_page() { |
| 511 | - return $this->get_option( $this->step_on_key, false ); |
|
| 511 | + return $this->get_option($this->step_on_key, false); |
|
| 512 | 512 | } |
| 513 | 513 | } |
@@ -918,7 +918,7 @@ |
||
| 918 | 918 | * @access public |
| 919 | 919 | * |
| 920 | 920 | * @param string $meta_key Metadata name. Default is empty. |
| 921 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
| 921 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
| 922 | 922 | * |
| 923 | 923 | * @return bool False for failure. True for success. |
| 924 | 924 | */ |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -149,32 +149,32 @@ discard block |
||
| 149 | 149 | * @param bool $_id_or_email |
| 150 | 150 | * @param bool $by_user_id |
| 151 | 151 | */ |
| 152 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
| 152 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
| 153 | 153 | |
| 154 | 154 | $this->db = Give()->donors; |
| 155 | 155 | |
| 156 | 156 | if ( |
| 157 | 157 | false === $_id_or_email |
| 158 | - || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) |
|
| 158 | + || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email)) |
|
| 159 | 159 | ) { |
| 160 | 160 | return false; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
| 163 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
| 164 | 164 | |
| 165 | - if ( is_numeric( $_id_or_email ) ) { |
|
| 165 | + if (is_numeric($_id_or_email)) { |
|
| 166 | 166 | $field = $by_user_id ? 'user_id' : 'id'; |
| 167 | 167 | } else { |
| 168 | 168 | $field = 'email'; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $donor = $this->db->get_donor_by( $field, $_id_or_email ); |
|
| 171 | + $donor = $this->db->get_donor_by($field, $_id_or_email); |
|
| 172 | 172 | |
| 173 | - if ( empty( $donor ) || ! is_object( $donor ) ) { |
|
| 173 | + if (empty($donor) || ! is_object($donor)) { |
|
| 174 | 174 | return false; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - $this->setup_donor( $donor ); |
|
| 177 | + $this->setup_donor($donor); |
|
| 178 | 178 | |
| 179 | 179 | } |
| 180 | 180 | |
@@ -190,19 +190,19 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @return bool If the setup was successful or not. |
| 192 | 192 | */ |
| 193 | - private function setup_donor( $donor ) { |
|
| 193 | + private function setup_donor($donor) { |
|
| 194 | 194 | |
| 195 | - if ( ! is_object( $donor ) ) { |
|
| 195 | + if ( ! is_object($donor)) { |
|
| 196 | 196 | return false; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Get cached donors. |
| 200 | - $donor_vars = Give_Cache::get_group( $donor->id, 'give-donors' ); |
|
| 200 | + $donor_vars = Give_Cache::get_group($donor->id, 'give-donors'); |
|
| 201 | 201 | |
| 202 | - if( is_null( $donor_vars ) ){ |
|
| 203 | - foreach ( $donor as $key => $value ) { |
|
| 202 | + if (is_null($donor_vars)) { |
|
| 203 | + foreach ($donor as $key => $value) { |
|
| 204 | 204 | |
| 205 | - switch ( $key ) { |
|
| 205 | + switch ($key) { |
|
| 206 | 206 | |
| 207 | 207 | case 'notes': |
| 208 | 208 | $this->$key = $this->get_notes(); |
@@ -216,20 +216,20 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Get donor's all email including primary email. |
| 219 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
| 220 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
| 219 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
| 220 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
| 221 | 221 | |
| 222 | 222 | $this->setup_address(); |
| 223 | 223 | |
| 224 | - Give_Cache::set_group( $donor->id, get_object_vars( $this ), 'give-donors' ); |
|
| 225 | - } else{ |
|
| 226 | - foreach ( $donor_vars as $donor_var => $value ) { |
|
| 224 | + Give_Cache::set_group($donor->id, get_object_vars($this), 'give-donors'); |
|
| 225 | + } else { |
|
| 226 | + foreach ($donor_vars as $donor_var => $value) { |
|
| 227 | 227 | $this->$donor_var = $value; |
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // Donor ID and email are the only things that are necessary, make sure they exist. |
| 232 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
| 232 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
| 233 | 233 | return true; |
| 234 | 234 | } |
| 235 | 235 | |
@@ -262,18 +262,18 @@ discard block |
||
| 262 | 262 | ARRAY_N |
| 263 | 263 | ); |
| 264 | 264 | |
| 265 | - if ( empty( $addresses ) ) { |
|
| 265 | + if (empty($addresses)) { |
|
| 266 | 266 | return $this->address; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - foreach ( $addresses as $address ) { |
|
| 270 | - $address[0] = str_replace( '_give_donor_address_', '', $address[0] ); |
|
| 271 | - $address[0] = explode( '_', $address[0] ); |
|
| 269 | + foreach ($addresses as $address) { |
|
| 270 | + $address[0] = str_replace('_give_donor_address_', '', $address[0]); |
|
| 271 | + $address[0] = explode('_', $address[0]); |
|
| 272 | 272 | |
| 273 | - if ( 3 === count( $address[0] ) ) { |
|
| 274 | - $this->address[ $address[0][0] ][ $address[0][2] ][ $address[0][1] ] = $address[1]; |
|
| 273 | + if (3 === count($address[0])) { |
|
| 274 | + $this->address[$address[0][0]][$address[0][2]][$address[0][1]] = $address[1]; |
|
| 275 | 275 | } else { |
| 276 | - $this->address[ $address[0][0] ][ $address[0][1] ] = $address[1]; |
|
| 276 | + $this->address[$address[0][0]][$address[0][1]] = $address[1]; |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | } |
@@ -287,16 +287,16 @@ discard block |
||
| 287 | 287 | * |
| 288 | 288 | * @return mixed|\WP_Error |
| 289 | 289 | */ |
| 290 | - public function __get( $key ) { |
|
| 290 | + public function __get($key) { |
|
| 291 | 291 | |
| 292 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 292 | + if (method_exists($this, 'get_'.$key)) { |
|
| 293 | 293 | |
| 294 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
| 294 | + return call_user_func(array($this, 'get_'.$key)); |
|
| 295 | 295 | |
| 296 | 296 | } else { |
| 297 | 297 | |
| 298 | 298 | /* translators: %s: property key */ |
| 299 | - return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
| 299 | + return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
| 300 | 300 | |
| 301 | 301 | } |
| 302 | 302 | |
@@ -312,9 +312,9 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @return bool|int False if not a valid creation, donor ID if user is found or valid creation. |
| 314 | 314 | */ |
| 315 | - public function create( $data = array() ) { |
|
| 315 | + public function create($data = array()) { |
|
| 316 | 316 | |
| 317 | - if ( $this->id != 0 || empty( $data ) ) { |
|
| 317 | + if ($this->id != 0 || empty($data)) { |
|
| 318 | 318 | return false; |
| 319 | 319 | } |
| 320 | 320 | |
@@ -322,15 +322,15 @@ discard block |
||
| 322 | 322 | 'payment_ids' => '', |
| 323 | 323 | ); |
| 324 | 324 | |
| 325 | - $args = wp_parse_args( $data, $defaults ); |
|
| 326 | - $args = $this->sanitize_columns( $args ); |
|
| 325 | + $args = wp_parse_args($data, $defaults); |
|
| 326 | + $args = $this->sanitize_columns($args); |
|
| 327 | 327 | |
| 328 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
| 328 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
| 329 | 329 | return false; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
| 333 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
| 332 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
| 333 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /** |
@@ -340,18 +340,18 @@ discard block |
||
| 340 | 340 | * |
| 341 | 341 | * @param array $args Donor attributes. |
| 342 | 342 | */ |
| 343 | - do_action( 'give_donor_pre_create', $args ); |
|
| 343 | + do_action('give_donor_pre_create', $args); |
|
| 344 | 344 | |
| 345 | 345 | $created = false; |
| 346 | 346 | |
| 347 | 347 | // The DB class 'add' implies an update if the donor being asked to be created already exists |
| 348 | - if ( $this->db->add( $data ) ) { |
|
| 348 | + if ($this->db->add($data)) { |
|
| 349 | 349 | |
| 350 | 350 | // We've successfully added/updated the donor, reset the class vars with the new data |
| 351 | - $donor = $this->db->get_donor_by( 'email', $args['email'] ); |
|
| 351 | + $donor = $this->db->get_donor_by('email', $args['email']); |
|
| 352 | 352 | |
| 353 | 353 | // Setup the donor data with the values from DB |
| 354 | - $this->setup_donor( $donor ); |
|
| 354 | + $this->setup_donor($donor); |
|
| 355 | 355 | |
| 356 | 356 | $created = $this->id; |
| 357 | 357 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation. |
| 365 | 365 | * @param array $args Customer attributes. |
| 366 | 366 | */ |
| 367 | - do_action( 'give_donor_post_create', $created, $args ); |
|
| 367 | + do_action('give_donor_post_create', $created, $args); |
|
| 368 | 368 | |
| 369 | 369 | return $created; |
| 370 | 370 | |
@@ -380,13 +380,13 @@ discard block |
||
| 380 | 380 | * |
| 381 | 381 | * @return bool If the update was successful or not. |
| 382 | 382 | */ |
| 383 | - public function update( $data = array() ) { |
|
| 383 | + public function update($data = array()) { |
|
| 384 | 384 | |
| 385 | - if ( empty( $data ) ) { |
|
| 385 | + if (empty($data)) { |
|
| 386 | 386 | return false; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - $data = $this->sanitize_columns( $data ); |
|
| 389 | + $data = $this->sanitize_columns($data); |
|
| 390 | 390 | |
| 391 | 391 | /** |
| 392 | 392 | * Fires before updating donors. |
@@ -396,15 +396,15 @@ discard block |
||
| 396 | 396 | * @param int $donor_id Donor id. |
| 397 | 397 | * @param array $data Donor attributes. |
| 398 | 398 | */ |
| 399 | - do_action( 'give_donor_pre_update', $this->id, $data ); |
|
| 399 | + do_action('give_donor_pre_update', $this->id, $data); |
|
| 400 | 400 | |
| 401 | 401 | $updated = false; |
| 402 | 402 | |
| 403 | - if ( $this->db->update( $this->id, $data ) ) { |
|
| 403 | + if ($this->db->update($this->id, $data)) { |
|
| 404 | 404 | |
| 405 | - $donor = $this->db->get_donor_by( 'id', $this->id ); |
|
| 405 | + $donor = $this->db->get_donor_by('id', $this->id); |
|
| 406 | 406 | |
| 407 | - $this->setup_donor( $donor ); |
|
| 407 | + $this->setup_donor($donor); |
|
| 408 | 408 | |
| 409 | 409 | $updated = true; |
| 410 | 410 | } |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | * @param int $donor_id Donor id. |
| 419 | 419 | * @param array $data Donor attributes. |
| 420 | 420 | */ |
| 421 | - do_action( 'give_donor_post_update', $updated, $this->id, $data ); |
|
| 421 | + do_action('give_donor_post_update', $updated, $this->id, $data); |
|
| 422 | 422 | |
| 423 | 423 | return $updated; |
| 424 | 424 | } |
@@ -436,27 +436,27 @@ discard block |
||
| 436 | 436 | * |
| 437 | 437 | * @return bool If the attachment was successfully. |
| 438 | 438 | */ |
| 439 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
| 439 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
| 440 | 440 | |
| 441 | - if ( empty( $payment_id ) ) { |
|
| 441 | + if (empty($payment_id)) { |
|
| 442 | 442 | return false; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if ( empty( $this->payment_ids ) ) { |
|
| 445 | + if (empty($this->payment_ids)) { |
|
| 446 | 446 | |
| 447 | 447 | $new_payment_ids = $payment_id; |
| 448 | 448 | |
| 449 | 449 | } else { |
| 450 | 450 | |
| 451 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 451 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 452 | 452 | |
| 453 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
| 453 | + if (in_array($payment_id, $payment_ids)) { |
|
| 454 | 454 | $update_stats = false; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | $payment_ids[] = $payment_id; |
| 458 | 458 | |
| 459 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 459 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 460 | 460 | |
| 461 | 461 | } |
| 462 | 462 | |
@@ -468,20 +468,20 @@ discard block |
||
| 468 | 468 | * @param int $payment_id Payment id. |
| 469 | 469 | * @param int $donor_id Customer id. |
| 470 | 470 | */ |
| 471 | - do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id ); |
|
| 471 | + do_action('give_donor_pre_attach_payment', $payment_id, $this->id); |
|
| 472 | 472 | |
| 473 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 473 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 474 | 474 | |
| 475 | - if ( $payment_added ) { |
|
| 475 | + if ($payment_added) { |
|
| 476 | 476 | |
| 477 | 477 | $this->payment_ids = $new_payment_ids; |
| 478 | 478 | |
| 479 | 479 | // We added this payment successfully, increment the stats |
| 480 | - if ( $update_stats ) { |
|
| 481 | - $payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) ); |
|
| 480 | + if ($update_stats) { |
|
| 481 | + $payment_amount = give_donation_amount($payment_id, array('type' => 'stats')); |
|
| 482 | 482 | |
| 483 | - if ( ! empty( $payment_amount ) ) { |
|
| 484 | - $this->increase_value( $payment_amount ); |
|
| 483 | + if ( ! empty($payment_amount)) { |
|
| 484 | + $this->increase_value($payment_amount); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | $this->increase_purchase_count(); |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | * @param int $payment_id Payment id. |
| 498 | 498 | * @param int $donor_id Donor id. |
| 499 | 499 | */ |
| 500 | - do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
| 500 | + do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
| 501 | 501 | |
| 502 | 502 | return $payment_added; |
| 503 | 503 | } |
@@ -515,33 +515,33 @@ discard block |
||
| 515 | 515 | * |
| 516 | 516 | * @return boolean If the removal was successful. |
| 517 | 517 | */ |
| 518 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
| 518 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
| 519 | 519 | |
| 520 | - if ( empty( $payment_id ) ) { |
|
| 520 | + if (empty($payment_id)) { |
|
| 521 | 521 | return false; |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | - $payment = new Give_Payment( $payment_id ); |
|
| 524 | + $payment = new Give_Payment($payment_id); |
|
| 525 | 525 | |
| 526 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
| 526 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
| 527 | 527 | $update_stats = false; |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | $new_payment_ids = ''; |
| 531 | 531 | |
| 532 | - if ( ! empty( $this->payment_ids ) ) { |
|
| 532 | + if ( ! empty($this->payment_ids)) { |
|
| 533 | 533 | |
| 534 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 534 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 535 | 535 | |
| 536 | - $pos = array_search( $payment_id, $payment_ids ); |
|
| 537 | - if ( false === $pos ) { |
|
| 536 | + $pos = array_search($payment_id, $payment_ids); |
|
| 537 | + if (false === $pos) { |
|
| 538 | 538 | return false; |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | - unset( $payment_ids[ $pos ] ); |
|
| 542 | - $payment_ids = array_filter( $payment_ids ); |
|
| 541 | + unset($payment_ids[$pos]); |
|
| 542 | + $payment_ids = array_filter($payment_ids); |
|
| 543 | 543 | |
| 544 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 544 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 545 | 545 | |
| 546 | 546 | } |
| 547 | 547 | |
@@ -553,20 +553,20 @@ discard block |
||
| 553 | 553 | * @param int $payment_id Payment id. |
| 554 | 554 | * @param int $donor_id Customer id. |
| 555 | 555 | */ |
| 556 | - do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id ); |
|
| 556 | + do_action('give_donor_pre_remove_payment', $payment_id, $this->id); |
|
| 557 | 557 | |
| 558 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 558 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 559 | 559 | |
| 560 | - if ( $payment_removed ) { |
|
| 560 | + if ($payment_removed) { |
|
| 561 | 561 | |
| 562 | 562 | $this->payment_ids = $new_payment_ids; |
| 563 | 563 | |
| 564 | - if ( $update_stats ) { |
|
| 564 | + if ($update_stats) { |
|
| 565 | 565 | // We removed this payment successfully, decrement the stats |
| 566 | - $payment_amount = give_donation_amount( $payment_id ); |
|
| 566 | + $payment_amount = give_donation_amount($payment_id); |
|
| 567 | 567 | |
| 568 | - if ( ! empty( $payment_amount ) ) { |
|
| 569 | - $this->decrease_value( $payment_amount ); |
|
| 568 | + if ( ! empty($payment_amount)) { |
|
| 569 | + $this->decrease_value($payment_amount); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | $this->decrease_donation_count(); |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | * @param int $payment_id Payment id. |
| 583 | 583 | * @param int $donor_id Donor id. |
| 584 | 584 | */ |
| 585 | - do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
| 585 | + do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
| 586 | 586 | |
| 587 | 587 | return $payment_removed; |
| 588 | 588 | |
@@ -598,10 +598,10 @@ discard block |
||
| 598 | 598 | * |
| 599 | 599 | * @return int The donation count. |
| 600 | 600 | */ |
| 601 | - public function increase_purchase_count( $count = 1 ) { |
|
| 601 | + public function increase_purchase_count($count = 1) { |
|
| 602 | 602 | |
| 603 | 603 | // Make sure it's numeric and not negative. |
| 604 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 604 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 605 | 605 | return false; |
| 606 | 606 | } |
| 607 | 607 | |
@@ -615,9 +615,9 @@ discard block |
||
| 615 | 615 | * @param int $count The number to increase by. |
| 616 | 616 | * @param int $donor_id Donor id. |
| 617 | 617 | */ |
| 618 | - do_action( 'give_donor_pre_increase_donation_count', $count, $this->id ); |
|
| 618 | + do_action('give_donor_pre_increase_donation_count', $count, $this->id); |
|
| 619 | 619 | |
| 620 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 620 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 621 | 621 | $this->purchase_count = $new_total; |
| 622 | 622 | } |
| 623 | 623 | |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | * @param int $count The number increased by. |
| 631 | 631 | * @param int $donor_id Donor id. |
| 632 | 632 | */ |
| 633 | - do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id ); |
|
| 633 | + do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id); |
|
| 634 | 634 | |
| 635 | 635 | return $this->purchase_count; |
| 636 | 636 | } |
@@ -645,16 +645,16 @@ discard block |
||
| 645 | 645 | * |
| 646 | 646 | * @return mixed If successful, the new count, otherwise false. |
| 647 | 647 | */ |
| 648 | - public function decrease_donation_count( $count = 1 ) { |
|
| 648 | + public function decrease_donation_count($count = 1) { |
|
| 649 | 649 | |
| 650 | 650 | // Make sure it's numeric and not negative |
| 651 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 651 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 652 | 652 | return false; |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | $new_total = (int) $this->purchase_count - (int) $count; |
| 656 | 656 | |
| 657 | - if ( $new_total < 0 ) { |
|
| 657 | + if ($new_total < 0) { |
|
| 658 | 658 | $new_total = 0; |
| 659 | 659 | } |
| 660 | 660 | |
@@ -666,9 +666,9 @@ discard block |
||
| 666 | 666 | * @param int $count The number to decrease by. |
| 667 | 667 | * @param int $donor_id Customer id. |
| 668 | 668 | */ |
| 669 | - do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id ); |
|
| 669 | + do_action('give_donor_pre_decrease_donation_count', $count, $this->id); |
|
| 670 | 670 | |
| 671 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 671 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 672 | 672 | $this->purchase_count = $new_total; |
| 673 | 673 | } |
| 674 | 674 | |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | * @param int $count The number decreased by. |
| 682 | 682 | * @param int $donor_id Donor id. |
| 683 | 683 | */ |
| 684 | - do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id ); |
|
| 684 | + do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id); |
|
| 685 | 685 | |
| 686 | 686 | return $this->purchase_count; |
| 687 | 687 | } |
@@ -696,9 +696,9 @@ discard block |
||
| 696 | 696 | * |
| 697 | 697 | * @return mixed If successful, the new value, otherwise false. |
| 698 | 698 | */ |
| 699 | - public function increase_value( $value = 0.00 ) { |
|
| 699 | + public function increase_value($value = 0.00) { |
|
| 700 | 700 | |
| 701 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
| 701 | + $new_value = floatval($this->purchase_value) + $value; |
|
| 702 | 702 | |
| 703 | 703 | /** |
| 704 | 704 | * Fires before increasing donor lifetime value. |
@@ -708,9 +708,9 @@ discard block |
||
| 708 | 708 | * @param float $value The value to increase by. |
| 709 | 709 | * @param int $donor_id Customer id. |
| 710 | 710 | */ |
| 711 | - do_action( 'give_donor_pre_increase_value', $value, $this->id ); |
|
| 711 | + do_action('give_donor_pre_increase_value', $value, $this->id); |
|
| 712 | 712 | |
| 713 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 713 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 714 | 714 | $this->purchase_value = $new_value; |
| 715 | 715 | } |
| 716 | 716 | |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | * @param float $value The value increased by. |
| 724 | 724 | * @param int $donor_id Donor id. |
| 725 | 725 | */ |
| 726 | - do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
| 726 | + do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id); |
|
| 727 | 727 | |
| 728 | 728 | return $this->purchase_value; |
| 729 | 729 | } |
@@ -738,11 +738,11 @@ discard block |
||
| 738 | 738 | * |
| 739 | 739 | * @return mixed If successful, the new value, otherwise false. |
| 740 | 740 | */ |
| 741 | - public function decrease_value( $value = 0.00 ) { |
|
| 741 | + public function decrease_value($value = 0.00) { |
|
| 742 | 742 | |
| 743 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
| 743 | + $new_value = floatval($this->purchase_value) - $value; |
|
| 744 | 744 | |
| 745 | - if ( $new_value < 0 ) { |
|
| 745 | + if ($new_value < 0) { |
|
| 746 | 746 | $new_value = 0.00; |
| 747 | 747 | } |
| 748 | 748 | |
@@ -754,9 +754,9 @@ discard block |
||
| 754 | 754 | * @param float $value The value to decrease by. |
| 755 | 755 | * @param int $donor_id Donor id. |
| 756 | 756 | */ |
| 757 | - do_action( 'give_donor_pre_decrease_value', $value, $this->id ); |
|
| 757 | + do_action('give_donor_pre_decrease_value', $value, $this->id); |
|
| 758 | 758 | |
| 759 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 759 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 760 | 760 | $this->purchase_value = $new_value; |
| 761 | 761 | } |
| 762 | 762 | |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | * @param float $value The value decreased by. |
| 770 | 770 | * @param int $donor_id Donor id. |
| 771 | 771 | */ |
| 772 | - do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
| 772 | + do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
| 773 | 773 | |
| 774 | 774 | return $this->purchase_value; |
| 775 | 775 | } |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | * |
| 789 | 789 | * @return mixed If successful, the new donation stat value, otherwise false. |
| 790 | 790 | */ |
| 791 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
| 791 | + public function update_donation_value($curr_amount, $new_amount) { |
|
| 792 | 792 | /** |
| 793 | 793 | * Payment total difference value can be: |
| 794 | 794 | * zero (in case amount not change) |
@@ -798,15 +798,15 @@ discard block |
||
| 798 | 798 | $payment_total_diff = $new_amount - $curr_amount; |
| 799 | 799 | |
| 800 | 800 | // We do not need to update donation stat if donation did not change. |
| 801 | - if ( ! $payment_total_diff ) { |
|
| 801 | + if ( ! $payment_total_diff) { |
|
| 802 | 802 | return false; |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | - if ( $payment_total_diff > 0 ) { |
|
| 806 | - $this->increase_value( $payment_total_diff ); |
|
| 805 | + if ($payment_total_diff > 0) { |
|
| 806 | + $this->increase_value($payment_total_diff); |
|
| 807 | 807 | } else { |
| 808 | 808 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
| 809 | - $this->decrease_value( - $payment_total_diff ); |
|
| 809 | + $this->decrease_value( -$payment_total_diff ); |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | return $this->purchase_value; |
@@ -823,15 +823,15 @@ discard block |
||
| 823 | 823 | * |
| 824 | 824 | * @return array The notes requested. |
| 825 | 825 | */ |
| 826 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
| 826 | + public function get_notes($length = 20, $paged = 1) { |
|
| 827 | 827 | |
| 828 | - $length = is_numeric( $length ) ? $length : 20; |
|
| 829 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
| 828 | + $length = is_numeric($length) ? $length : 20; |
|
| 829 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
| 830 | 830 | |
| 831 | 831 | $all_notes = $this->get_raw_notes(); |
| 832 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 832 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 833 | 833 | |
| 834 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
| 834 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
| 835 | 835 | |
| 836 | 836 | return $desired_notes; |
| 837 | 837 | |
@@ -848,9 +848,9 @@ discard block |
||
| 848 | 848 | public function get_notes_count() { |
| 849 | 849 | |
| 850 | 850 | $all_notes = $this->get_raw_notes(); |
| 851 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 851 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 852 | 852 | |
| 853 | - return count( $notes_array ); |
|
| 853 | + return count($notes_array); |
|
| 854 | 854 | |
| 855 | 855 | } |
| 856 | 856 | |
@@ -863,7 +863,7 @@ discard block |
||
| 863 | 863 | * |
| 864 | 864 | * @return string|float |
| 865 | 865 | */ |
| 866 | - public function get_total_donation_amount( $args = array() ) { |
|
| 866 | + public function get_total_donation_amount($args = array()) { |
|
| 867 | 867 | |
| 868 | 868 | /** |
| 869 | 869 | * Filter total donation amount. |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | * @param integer $donor_id Donor ID. |
| 875 | 875 | * @param array $args Pass additional data. |
| 876 | 876 | */ |
| 877 | - return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args ); |
|
| 877 | + return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | /** |
@@ -887,22 +887,22 @@ discard block |
||
| 887 | 887 | * |
| 888 | 888 | * @return string|boolean The new note if added successfully, false otherwise. |
| 889 | 889 | */ |
| 890 | - public function add_note( $note = '' ) { |
|
| 890 | + public function add_note($note = '') { |
|
| 891 | 891 | |
| 892 | - $note = trim( $note ); |
|
| 893 | - if ( empty( $note ) ) { |
|
| 892 | + $note = trim($note); |
|
| 893 | + if (empty($note)) { |
|
| 894 | 894 | return false; |
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | $notes = $this->get_raw_notes(); |
| 898 | 898 | |
| 899 | - if ( empty( $notes ) ) { |
|
| 899 | + if (empty($notes)) { |
|
| 900 | 900 | $notes = ''; |
| 901 | 901 | } |
| 902 | 902 | |
| 903 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
| 904 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
| 905 | - $notes .= "\n\n" . $new_note; |
|
| 903 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
| 904 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
| 905 | + $notes .= "\n\n".$new_note; |
|
| 906 | 906 | |
| 907 | 907 | /** |
| 908 | 908 | * Fires before donor note is added. |
@@ -912,11 +912,11 @@ discard block |
||
| 912 | 912 | * @param string $new_note New note to add. |
| 913 | 913 | * @param int $donor_id Donor id. |
| 914 | 914 | */ |
| 915 | - do_action( 'give_donor_pre_add_note', $new_note, $this->id ); |
|
| 915 | + do_action('give_donor_pre_add_note', $new_note, $this->id); |
|
| 916 | 916 | |
| 917 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
| 917 | + $updated = $this->update(array('notes' => $notes)); |
|
| 918 | 918 | |
| 919 | - if ( $updated ) { |
|
| 919 | + if ($updated) { |
|
| 920 | 920 | $this->notes = $this->get_notes(); |
| 921 | 921 | } |
| 922 | 922 | |
@@ -929,7 +929,7 @@ discard block |
||
| 929 | 929 | * @param string $new_note New note added. |
| 930 | 930 | * @param int $donor_id Donor id. |
| 931 | 931 | */ |
| 932 | - do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id ); |
|
| 932 | + do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id); |
|
| 933 | 933 | |
| 934 | 934 | // Return the formatted note, so we can test, as well as update any displays |
| 935 | 935 | return $new_note; |
@@ -946,7 +946,7 @@ discard block |
||
| 946 | 946 | */ |
| 947 | 947 | private function get_raw_notes() { |
| 948 | 948 | |
| 949 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
| 949 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
| 950 | 950 | |
| 951 | 951 | return $all_notes; |
| 952 | 952 | |
@@ -963,8 +963,8 @@ discard block |
||
| 963 | 963 | * |
| 964 | 964 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
| 965 | 965 | */ |
| 966 | - public function get_meta( $meta_key = '', $single = true ) { |
|
| 967 | - return Give()->donor_meta->get_meta( $this->id, $meta_key, $single ); |
|
| 966 | + public function get_meta($meta_key = '', $single = true) { |
|
| 967 | + return Give()->donor_meta->get_meta($this->id, $meta_key, $single); |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | /** |
@@ -979,8 +979,8 @@ discard block |
||
| 979 | 979 | * |
| 980 | 980 | * @return bool False for failure. True for success. |
| 981 | 981 | */ |
| 982 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
| 983 | - return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
| 982 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
| 983 | + return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
| 984 | 984 | } |
| 985 | 985 | |
| 986 | 986 | /** |
@@ -995,8 +995,8 @@ discard block |
||
| 995 | 995 | * |
| 996 | 996 | * @return bool False on failure, true if success. |
| 997 | 997 | */ |
| 998 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
| 999 | - return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
| 998 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
| 999 | + return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
@@ -1010,8 +1010,8 @@ discard block |
||
| 1010 | 1010 | * |
| 1011 | 1011 | * @return bool False for failure. True for success. |
| 1012 | 1012 | */ |
| 1013 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
| 1014 | - return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
| 1013 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
| 1014 | + return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | /** |
@@ -1024,51 +1024,51 @@ discard block |
||
| 1024 | 1024 | * |
| 1025 | 1025 | * @return array The sanitized data, based off column defaults. |
| 1026 | 1026 | */ |
| 1027 | - private function sanitize_columns( $data ) { |
|
| 1027 | + private function sanitize_columns($data) { |
|
| 1028 | 1028 | |
| 1029 | 1029 | $columns = $this->db->get_columns(); |
| 1030 | 1030 | $default_values = $this->db->get_column_defaults(); |
| 1031 | 1031 | |
| 1032 | - foreach ( $columns as $key => $type ) { |
|
| 1032 | + foreach ($columns as $key => $type) { |
|
| 1033 | 1033 | |
| 1034 | 1034 | // Only sanitize data that we were provided |
| 1035 | - if ( ! array_key_exists( $key, $data ) ) { |
|
| 1035 | + if ( ! array_key_exists($key, $data)) { |
|
| 1036 | 1036 | continue; |
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | - switch ( $type ) { |
|
| 1039 | + switch ($type) { |
|
| 1040 | 1040 | |
| 1041 | 1041 | case '%s': |
| 1042 | - if ( 'email' == $key ) { |
|
| 1043 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
| 1044 | - } elseif ( 'notes' == $key ) { |
|
| 1045 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
| 1042 | + if ('email' == $key) { |
|
| 1043 | + $data[$key] = sanitize_email($data[$key]); |
|
| 1044 | + } elseif ('notes' == $key) { |
|
| 1045 | + $data[$key] = strip_tags($data[$key]); |
|
| 1046 | 1046 | } else { |
| 1047 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 1047 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 1048 | 1048 | } |
| 1049 | 1049 | break; |
| 1050 | 1050 | |
| 1051 | 1051 | case '%d': |
| 1052 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
| 1053 | - $data[ $key ] = $default_values[ $key ]; |
|
| 1052 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
| 1053 | + $data[$key] = $default_values[$key]; |
|
| 1054 | 1054 | } else { |
| 1055 | - $data[ $key ] = absint( $data[ $key ] ); |
|
| 1055 | + $data[$key] = absint($data[$key]); |
|
| 1056 | 1056 | } |
| 1057 | 1057 | break; |
| 1058 | 1058 | |
| 1059 | 1059 | case '%f': |
| 1060 | 1060 | // Convert what was given to a float |
| 1061 | - $value = floatval( $data[ $key ] ); |
|
| 1061 | + $value = floatval($data[$key]); |
|
| 1062 | 1062 | |
| 1063 | - if ( ! is_float( $value ) ) { |
|
| 1064 | - $data[ $key ] = $default_values[ $key ]; |
|
| 1063 | + if ( ! is_float($value)) { |
|
| 1064 | + $data[$key] = $default_values[$key]; |
|
| 1065 | 1065 | } else { |
| 1066 | - $data[ $key ] = $value; |
|
| 1066 | + $data[$key] = $value; |
|
| 1067 | 1067 | } |
| 1068 | 1068 | break; |
| 1069 | 1069 | |
| 1070 | 1070 | default: |
| 1071 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 1071 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 1072 | 1072 | break; |
| 1073 | 1073 | |
| 1074 | 1074 | } |
@@ -1088,33 +1088,33 @@ discard block |
||
| 1088 | 1088 | * |
| 1089 | 1089 | * @return bool If the email was added successfully |
| 1090 | 1090 | */ |
| 1091 | - public function add_email( $email = '', $primary = false ) { |
|
| 1092 | - if ( ! is_email( $email ) ) { |
|
| 1091 | + public function add_email($email = '', $primary = false) { |
|
| 1092 | + if ( ! is_email($email)) { |
|
| 1093 | 1093 | return false; |
| 1094 | 1094 | } |
| 1095 | - $existing = new Give_Donor( $email ); |
|
| 1095 | + $existing = new Give_Donor($email); |
|
| 1096 | 1096 | |
| 1097 | - if ( $existing->id > 0 ) { |
|
| 1097 | + if ($existing->id > 0) { |
|
| 1098 | 1098 | // Email address already belongs to another donor |
| 1099 | 1099 | return false; |
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | - if ( email_exists( $email ) ) { |
|
| 1103 | - $user = get_user_by( 'email', $email ); |
|
| 1104 | - if ( $user->ID != $this->user_id ) { |
|
| 1102 | + if (email_exists($email)) { |
|
| 1103 | + $user = get_user_by('email', $email); |
|
| 1104 | + if ($user->ID != $this->user_id) { |
|
| 1105 | 1105 | return false; |
| 1106 | 1106 | } |
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
| 1109 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
| 1110 | 1110 | |
| 1111 | 1111 | // Add is used to ensure duplicate emails are not added |
| 1112 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
| 1112 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
| 1113 | 1113 | |
| 1114 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
| 1114 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
| 1115 | 1115 | |
| 1116 | - if ( $ret && true === $primary ) { |
|
| 1117 | - $this->set_primary_email( $email ); |
|
| 1116 | + if ($ret && true === $primary) { |
|
| 1117 | + $this->set_primary_email($email); |
|
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | 1120 | return $ret; |
@@ -1130,16 +1130,16 @@ discard block |
||
| 1130 | 1130 | * |
| 1131 | 1131 | * @return bool If the email was removed successfully. |
| 1132 | 1132 | */ |
| 1133 | - public function remove_email( $email = '' ) { |
|
| 1134 | - if ( ! is_email( $email ) ) { |
|
| 1133 | + public function remove_email($email = '') { |
|
| 1134 | + if ( ! is_email($email)) { |
|
| 1135 | 1135 | return false; |
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
| 1138 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
| 1139 | 1139 | |
| 1140 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
| 1140 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
| 1141 | 1141 | |
| 1142 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
| 1142 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
| 1143 | 1143 | |
| 1144 | 1144 | return $ret; |
| 1145 | 1145 | } |
@@ -1156,16 +1156,16 @@ discard block |
||
| 1156 | 1156 | * |
| 1157 | 1157 | * @return bool If the email was set as primary successfully. |
| 1158 | 1158 | */ |
| 1159 | - public function set_primary_email( $new_primary_email = '' ) { |
|
| 1160 | - if ( ! is_email( $new_primary_email ) ) { |
|
| 1159 | + public function set_primary_email($new_primary_email = '') { |
|
| 1160 | + if ( ! is_email($new_primary_email)) { |
|
| 1161 | 1161 | return false; |
| 1162 | 1162 | } |
| 1163 | 1163 | |
| 1164 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
| 1164 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
| 1165 | 1165 | |
| 1166 | - $existing = new Give_Donor( $new_primary_email ); |
|
| 1166 | + $existing = new Give_Donor($new_primary_email); |
|
| 1167 | 1167 | |
| 1168 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
| 1168 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
| 1169 | 1169 | // This email belongs to another donor. |
| 1170 | 1170 | return false; |
| 1171 | 1171 | } |
@@ -1173,21 +1173,21 @@ discard block |
||
| 1173 | 1173 | $old_email = $this->email; |
| 1174 | 1174 | |
| 1175 | 1175 | // Update donor record with new email. |
| 1176 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
| 1176 | + $update = $this->update(array('email' => $new_primary_email)); |
|
| 1177 | 1177 | |
| 1178 | 1178 | // Remove new primary from list of additional emails. |
| 1179 | - $remove = $this->remove_email( $new_primary_email ); |
|
| 1179 | + $remove = $this->remove_email($new_primary_email); |
|
| 1180 | 1180 | |
| 1181 | 1181 | // Add old email to additional emails list. |
| 1182 | - $add = $this->add_email( $old_email ); |
|
| 1182 | + $add = $this->add_email($old_email); |
|
| 1183 | 1183 | |
| 1184 | 1184 | $ret = $update && $remove && $add; |
| 1185 | 1185 | |
| 1186 | - if ( $ret ) { |
|
| 1186 | + if ($ret) { |
|
| 1187 | 1187 | $this->email = $new_primary_email; |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
| 1190 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
| 1191 | 1191 | |
| 1192 | 1192 | return $ret; |
| 1193 | 1193 | } |
@@ -1202,17 +1202,17 @@ discard block |
||
| 1202 | 1202 | * |
| 1203 | 1203 | * @return bool |
| 1204 | 1204 | */ |
| 1205 | - private function is_valid_address( $address ) { |
|
| 1205 | + private function is_valid_address($address) { |
|
| 1206 | 1206 | $is_valid_address = true; |
| 1207 | 1207 | |
| 1208 | 1208 | // Address ready to process even if only one value set. |
| 1209 | - foreach ( $address as $address_type => $value ) { |
|
| 1209 | + foreach ($address as $address_type => $value) { |
|
| 1210 | 1210 | // @todo: Handle state field validation on basis of country. |
| 1211 | - if( in_array( $address_type, array( 'line2', 'state' )) ) { |
|
| 1211 | + if (in_array($address_type, array('line2', 'state'))) { |
|
| 1212 | 1212 | continue; |
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | - if ( empty( $value ) ) { |
|
| 1215 | + if (empty($value)) { |
|
| 1216 | 1216 | $is_valid_address = false; |
| 1217 | 1217 | break; |
| 1218 | 1218 | } |
@@ -1239,30 +1239,27 @@ discard block |
||
| 1239 | 1239 | * |
| 1240 | 1240 | * @return bool |
| 1241 | 1241 | */ |
| 1242 | - public function add_address( $address_type, $address ) { |
|
| 1242 | + public function add_address($address_type, $address) { |
|
| 1243 | 1243 | // Bailout. |
| 1244 | - if ( empty( $address_type ) || ! $this->is_valid_address( $address ) || ! $this->id ) { |
|
| 1244 | + if (empty($address_type) || ! $this->is_valid_address($address) || ! $this->id) { |
|
| 1245 | 1245 | return false; |
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | 1248 | // Check if multiple address exist or not and set params. |
| 1249 | 1249 | $multi_address_id = null; |
| 1250 | - if( $is_multi_address = ( false !== strpos( $address_type, '[]' ) ) ) { |
|
| 1251 | - $address_type = $is_multi_address ? |
|
| 1252 | - str_replace( '[]', '', $address_type ) : |
|
| 1253 | - $address_type; |
|
| 1254 | - } elseif ( $is_multi_address = ( false !== strpos( $address_type, '_' ) ) ){ |
|
| 1255 | - $multi_address_id = $is_multi_address ? |
|
| 1256 | - array_pop( explode( '_', $address_type ) ) : |
|
| 1257 | - $address_type; |
|
| 1258 | - |
|
| 1259 | - $address_type = $is_multi_address ? |
|
| 1260 | - array_shift( explode( '_', $address_type ) ) : |
|
| 1261 | - $address_type; |
|
| 1250 | + if ($is_multi_address = (false !== strpos($address_type, '[]'))) { |
|
| 1251 | + $address_type = $is_multi_address ? |
|
| 1252 | + str_replace('[]', '', $address_type) : $address_type; |
|
| 1253 | + } elseif ($is_multi_address = (false !== strpos($address_type, '_'))) { |
|
| 1254 | + $multi_address_id = $is_multi_address ? |
|
| 1255 | + array_pop(explode('_', $address_type)) : $address_type; |
|
| 1256 | + |
|
| 1257 | + $address_type = $is_multi_address ? |
|
| 1258 | + array_shift(explode('_', $address_type)) : $address_type; |
|
| 1262 | 1259 | } |
| 1263 | 1260 | |
| 1264 | 1261 | // Bailout: do not save duplicate orders |
| 1265 | - if( $this->is_address_exist( $address_type, $address ) ) { |
|
| 1262 | + if ($this->is_address_exist($address_type, $address)) { |
|
| 1266 | 1263 | return false; |
| 1267 | 1264 | } |
| 1268 | 1265 | |
@@ -1284,8 +1281,8 @@ discard block |
||
| 1284 | 1281 | $meta_key_prefix = "_give_donor_address_{$address_type}_{address_name}"; |
| 1285 | 1282 | $meta_type = Give()->donor_meta->meta_type; |
| 1286 | 1283 | |
| 1287 | - if ( $is_multi_address ) { |
|
| 1288 | - if ( is_null( $multi_address_id ) ) { |
|
| 1284 | + if ($is_multi_address) { |
|
| 1285 | + if (is_null($multi_address_id)) { |
|
| 1289 | 1286 | // Get latest address key to set multi address id. |
| 1290 | 1287 | $multi_address_id = $wpdb->get_var( |
| 1291 | 1288 | $wpdb->prepare( |
@@ -1302,10 +1299,10 @@ discard block |
||
| 1302 | 1299 | ) |
| 1303 | 1300 | ); |
| 1304 | 1301 | |
| 1305 | - if( ! empty( $multi_address_id ) ) { |
|
| 1306 | - $multi_address_id = absint( substr( strrchr( $multi_address_id, '_' ), 1 ) ); |
|
| 1302 | + if ( ! empty($multi_address_id)) { |
|
| 1303 | + $multi_address_id = absint(substr(strrchr($multi_address_id, '_'), 1)); |
|
| 1307 | 1304 | $multi_address_id++; |
| 1308 | - } else{ |
|
| 1305 | + } else { |
|
| 1309 | 1306 | $multi_address_id = 0; |
| 1310 | 1307 | } |
| 1311 | 1308 | } |
@@ -1314,9 +1311,9 @@ discard block |
||
| 1314 | 1311 | } |
| 1315 | 1312 | |
| 1316 | 1313 | // Save donor address. |
| 1317 | - foreach ( $address as $type => $value ) { |
|
| 1318 | - $meta_key = str_replace( '{address_name}', $type, $meta_key_prefix ); |
|
| 1319 | - Give()->donor_meta->update_meta( $this->id, $meta_key, $value ); |
|
| 1314 | + foreach ($address as $type => $value) { |
|
| 1315 | + $meta_key = str_replace('{address_name}', $type, $meta_key_prefix); |
|
| 1316 | + Give()->donor_meta->update_meta($this->id, $meta_key, $value); |
|
| 1320 | 1317 | } |
| 1321 | 1318 | |
| 1322 | 1319 | $this->setup_address(); |
@@ -1335,23 +1332,21 @@ discard block |
||
| 1335 | 1332 | * |
| 1336 | 1333 | * @return bool |
| 1337 | 1334 | */ |
| 1338 | - public function remove_address( $address_id ) { |
|
| 1335 | + public function remove_address($address_id) { |
|
| 1339 | 1336 | global $wpdb; |
| 1340 | 1337 | |
| 1341 | 1338 | // Get address type. |
| 1342 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; |
|
| 1339 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; |
|
| 1343 | 1340 | |
| 1344 | - $address_type = false !== strpos( $address_id, '_' ) ? |
|
| 1345 | - array_shift( explode( '_', $address_id ) ) : |
|
| 1346 | - $address_id; |
|
| 1341 | + $address_type = false !== strpos($address_id, '_') ? |
|
| 1342 | + array_shift(explode('_', $address_id)) : $address_id; |
|
| 1347 | 1343 | |
| 1348 | - $address_count = false !== strpos( $address_id, '_' ) ? |
|
| 1349 | - array_pop( explode( '_', $address_id ) ) : |
|
| 1350 | - null; |
|
| 1344 | + $address_count = false !== strpos($address_id, '_') ? |
|
| 1345 | + array_pop(explode('_', $address_id)) : null; |
|
| 1351 | 1346 | |
| 1352 | 1347 | // Set meta key prefix. |
| 1353 | 1348 | $meta_key_prefix = "_give_donor_address_{$address_type}_%"; |
| 1354 | - if ( $is_multi_address && is_numeric( $address_count ) ) { |
|
| 1349 | + if ($is_multi_address && is_numeric($address_count)) { |
|
| 1355 | 1350 | $meta_key_prefix .= "_{$address_count}"; |
| 1356 | 1351 | } |
| 1357 | 1352 | |
@@ -1388,23 +1383,21 @@ discard block |
||
| 1388 | 1383 | * |
| 1389 | 1384 | * @return bool |
| 1390 | 1385 | */ |
| 1391 | - public function update_address( $address_id, $address ) { |
|
| 1386 | + public function update_address($address_id, $address) { |
|
| 1392 | 1387 | global $wpdb; |
| 1393 | 1388 | |
| 1394 | 1389 | // Get address type. |
| 1395 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; |
|
| 1390 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; |
|
| 1396 | 1391 | |
| 1397 | - $address_type = false !== strpos( $address_id, '_' ) ? |
|
| 1398 | - array_shift( explode( '_', $address_id ) ) : |
|
| 1399 | - $address_id; |
|
| 1392 | + $address_type = false !== strpos($address_id, '_') ? |
|
| 1393 | + array_shift(explode('_', $address_id)) : $address_id; |
|
| 1400 | 1394 | |
| 1401 | - $address_count = false !== strpos( $address_id, '_' ) ? |
|
| 1402 | - array_pop( explode( '_', $address_id ) ) : |
|
| 1403 | - null; |
|
| 1395 | + $address_count = false !== strpos($address_id, '_') ? |
|
| 1396 | + array_pop(explode('_', $address_id)) : null; |
|
| 1404 | 1397 | |
| 1405 | 1398 | // Set meta key prefix. |
| 1406 | 1399 | $meta_key_prefix = "_give_donor_address_{$address_type}_%"; |
| 1407 | - if ( $is_multi_address && is_numeric( $address_count ) ) { |
|
| 1400 | + if ($is_multi_address && is_numeric($address_count)) { |
|
| 1408 | 1401 | $meta_key_prefix .= "_{$address_count}"; |
| 1409 | 1402 | } |
| 1410 | 1403 | |
@@ -1425,12 +1418,12 @@ discard block |
||
| 1425 | 1418 | ); |
| 1426 | 1419 | |
| 1427 | 1420 | // Return result. |
| 1428 | - if( ! count( $row_affected ) ) { |
|
| 1421 | + if ( ! count($row_affected)) { |
|
| 1429 | 1422 | return false; |
| 1430 | 1423 | } |
| 1431 | 1424 | |
| 1432 | 1425 | // Update address. |
| 1433 | - if( ! $this->add_address( $address_id, $address ) ) { |
|
| 1426 | + if ( ! $this->add_address($address_id, $address)) { |
|
| 1434 | 1427 | return false; |
| 1435 | 1428 | } |
| 1436 | 1429 | |
@@ -1449,39 +1442,39 @@ discard block |
||
| 1449 | 1442 | * |
| 1450 | 1443 | * @return bool|null |
| 1451 | 1444 | */ |
| 1452 | - public function is_address_exist( $current_address_type, $current_address ) { |
|
| 1445 | + public function is_address_exist($current_address_type, $current_address) { |
|
| 1453 | 1446 | $status = false; |
| 1454 | 1447 | |
| 1455 | 1448 | // Bailout. |
| 1456 | - if( empty( $current_address_type ) || empty( $current_address ) ) { |
|
| 1449 | + if (empty($current_address_type) || empty($current_address)) { |
|
| 1457 | 1450 | return null; |
| 1458 | 1451 | } |
| 1459 | 1452 | |
| 1460 | 1453 | // Bailout. |
| 1461 | - if( empty( $this->address ) || empty( $this->address[ $current_address_type ] ) ) { |
|
| 1454 | + if (empty($this->address) || empty($this->address[$current_address_type])) { |
|
| 1462 | 1455 | return $status; |
| 1463 | 1456 | } |
| 1464 | 1457 | |
| 1465 | 1458 | // Get address. |
| 1466 | - $address = $this->address[ $current_address_type ]; |
|
| 1459 | + $address = $this->address[$current_address_type]; |
|
| 1467 | 1460 | |
| 1468 | - switch ( true ){ |
|
| 1461 | + switch (true) { |
|
| 1469 | 1462 | |
| 1470 | 1463 | // Single address. |
| 1471 | - case is_string( end( $address ) ) : |
|
| 1472 | - $status = $this->is_address_match( $current_address, $address ); |
|
| 1464 | + case is_string(end($address)) : |
|
| 1465 | + $status = $this->is_address_match($current_address, $address); |
|
| 1473 | 1466 | break; |
| 1474 | 1467 | |
| 1475 | 1468 | // Multi address. |
| 1476 | - case is_array( end( $address ) ): |
|
| 1469 | + case is_array(end($address)): |
|
| 1477 | 1470 | // Compare address. |
| 1478 | - foreach ( $address as $saved_address ) { |
|
| 1479 | - if( empty( $saved_address ) ) { |
|
| 1471 | + foreach ($address as $saved_address) { |
|
| 1472 | + if (empty($saved_address)) { |
|
| 1480 | 1473 | continue; |
| 1481 | 1474 | } |
| 1482 | 1475 | |
| 1483 | 1476 | // Exit loop immediately if address exist. |
| 1484 | - if( $status = $this->is_address_match( $current_address, $saved_address ) ) { |
|
| 1477 | + if ($status = $this->is_address_match($current_address, $saved_address)) { |
|
| 1485 | 1478 | break; |
| 1486 | 1479 | } |
| 1487 | 1480 | } |
@@ -1502,10 +1495,10 @@ discard block |
||
| 1502 | 1495 | * |
| 1503 | 1496 | * @return bool |
| 1504 | 1497 | */ |
| 1505 | - private function is_address_match( $address_1, $address_2 ) { |
|
| 1506 | - $result = array_diff( $address_1, $address_2 ); |
|
| 1498 | + private function is_address_match($address_1, $address_2) { |
|
| 1499 | + $result = array_diff($address_1, $address_2); |
|
| 1507 | 1500 | |
| 1508 | - return empty( $result ); |
|
| 1501 | + return empty($result); |
|
| 1509 | 1502 | } |
| 1510 | 1503 | |
| 1511 | 1504 | /** |
@@ -1515,22 +1508,22 @@ discard block |
||
| 1515 | 1508 | * @since 2.0 |
| 1516 | 1509 | * @return object |
| 1517 | 1510 | */ |
| 1518 | - public function split_donor_name( $id ) { |
|
| 1519 | - $first_name = $last_name = ''; |
|
| 1520 | - $donor = new Give_Donor( $id ); |
|
| 1511 | + public function split_donor_name($id) { |
|
| 1512 | + $first_name = $last_name = ''; |
|
| 1513 | + $donor = new Give_Donor($id); |
|
| 1521 | 1514 | |
| 1522 | - $split_donor_name = explode( ' ', $donor->name, 2 ); |
|
| 1515 | + $split_donor_name = explode(' ', $donor->name, 2); |
|
| 1523 | 1516 | |
| 1524 | 1517 | // Check for existence of first name after split of donor name. |
| 1525 | - if( is_array( $split_donor_name ) && ! empty( $split_donor_name[0] ) ) { |
|
| 1518 | + if (is_array($split_donor_name) && ! empty($split_donor_name[0])) { |
|
| 1526 | 1519 | $first_name = $split_donor_name[0]; |
| 1527 | 1520 | } |
| 1528 | 1521 | |
| 1529 | 1522 | // Check for existence of last name after split of donor name. |
| 1530 | - if( is_array( $split_donor_name ) && ! empty( $split_donor_name[1] ) ) { |
|
| 1523 | + if (is_array($split_donor_name) && ! empty($split_donor_name[1])) { |
|
| 1531 | 1524 | $last_name = $split_donor_name[1]; |
| 1532 | 1525 | } |
| 1533 | - return (object) array( 'first_name' => $first_name, 'last_name' => $last_name ); |
|
| 1526 | + return (object) array('first_name' => $first_name, 'last_name' => $last_name); |
|
| 1534 | 1527 | } |
| 1535 | 1528 | |
| 1536 | 1529 | /** |
@@ -1540,9 +1533,9 @@ discard block |
||
| 1540 | 1533 | * @return string |
| 1541 | 1534 | */ |
| 1542 | 1535 | public function get_first_name() { |
| 1543 | - $first_name = $this->get_meta( '_give_donor_first_name'); |
|
| 1544 | - if( ! $first_name ) { |
|
| 1545 | - $first_name = $this->split_donor_name( $this->id )->first_name; |
|
| 1536 | + $first_name = $this->get_meta('_give_donor_first_name'); |
|
| 1537 | + if ( ! $first_name) { |
|
| 1538 | + $first_name = $this->split_donor_name($this->id)->first_name; |
|
| 1546 | 1539 | } |
| 1547 | 1540 | |
| 1548 | 1541 | return $first_name; |
@@ -1555,14 +1548,14 @@ discard block |
||
| 1555 | 1548 | * @return string |
| 1556 | 1549 | */ |
| 1557 | 1550 | public function get_last_name() { |
| 1558 | - $first_name = $this->get_meta( '_give_donor_first_name'); |
|
| 1559 | - $last_name = $this->get_meta( '_give_donor_last_name'); |
|
| 1551 | + $first_name = $this->get_meta('_give_donor_first_name'); |
|
| 1552 | + $last_name = $this->get_meta('_give_donor_last_name'); |
|
| 1560 | 1553 | |
| 1561 | 1554 | // This condition will prevent unnecessary splitting of donor name to fetch last name. |
| 1562 | - if( ! $first_name && ! $last_name ) { |
|
| 1563 | - $last_name = $this->split_donor_name( $this->id )->last_name; |
|
| 1555 | + if ( ! $first_name && ! $last_name) { |
|
| 1556 | + $last_name = $this->split_donor_name($this->id)->last_name; |
|
| 1564 | 1557 | } |
| 1565 | 1558 | |
| 1566 | - return ( $last_name ) ? $last_name : ''; |
|
| 1559 | + return ($last_name) ? $last_name : ''; |
|
| 1567 | 1560 | } |
| 1568 | 1561 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -74,57 +74,57 @@ discard block |
||
| 74 | 74 | public function __construct() { |
| 75 | 75 | |
| 76 | 76 | $this->use_php_sessions = $this->use_php_sessions(); |
| 77 | - $this->exp_option = give_get_option( 'session_lifetime' ); |
|
| 77 | + $this->exp_option = give_get_option('session_lifetime'); |
|
| 78 | 78 | |
| 79 | 79 | // PHP Sessions. |
| 80 | - if ( $this->use_php_sessions ) { |
|
| 80 | + if ($this->use_php_sessions) { |
|
| 81 | 81 | |
| 82 | - if ( is_multisite() ) { |
|
| 82 | + if (is_multisite()) { |
|
| 83 | 83 | |
| 84 | - $this->prefix = '_' . get_current_blog_id(); |
|
| 84 | + $this->prefix = '_'.get_current_blog_id(); |
|
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - add_action( 'init', array( $this, 'maybe_start_session' ), - 2 ); |
|
| 88 | + add_action('init', array($this, 'maybe_start_session'), - 2); |
|
| 89 | 89 | |
| 90 | 90 | } else { |
| 91 | 91 | |
| 92 | - if ( ! $this->should_start_session() ) { |
|
| 92 | + if ( ! $this->should_start_session()) { |
|
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | // Use WP_Session. |
| 97 | - if ( ! defined( 'WP_SESSION_COOKIE' ) ) { |
|
| 98 | - define( 'WP_SESSION_COOKIE', 'give_wp_session' ); |
|
| 97 | + if ( ! defined('WP_SESSION_COOKIE')) { |
|
| 98 | + define('WP_SESSION_COOKIE', 'give_wp_session'); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if ( ! class_exists( 'Recursive_ArrayAccess' ) ) { |
|
| 102 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
| 101 | + if ( ! class_exists('Recursive_ArrayAccess')) { |
|
| 102 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // Include utilities class |
| 106 | - if ( ! class_exists( 'WP_Session_Utils' ) ) { |
|
| 107 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php'; |
|
| 106 | + if ( ! class_exists('WP_Session_Utils')) { |
|
| 107 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php'; |
|
| 108 | 108 | } |
| 109 | - if ( ! class_exists( 'WP_Session' ) ) { |
|
| 110 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php'; |
|
| 111 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php'; |
|
| 109 | + if ( ! class_exists('WP_Session')) { |
|
| 110 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php'; |
|
| 111 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php'; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
| 115 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
| 114 | + add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); |
|
| 115 | + add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); |
|
| 116 | 116 | |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Init Session. |
| 120 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
| 121 | - add_action( 'plugins_loaded', array( $this, 'init' ), 9999 ); |
|
| 120 | + if (empty($this->session) && ! $this->use_php_sessions) { |
|
| 121 | + add_action('plugins_loaded', array($this, 'init'), 9999); |
|
| 122 | 122 | } else { |
| 123 | - add_action( 'init', array( $this, 'init' ), - 1 ); |
|
| 123 | + add_action('init', array($this, 'init'), - 1); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // Set cookie on Donation Completion page. |
| 127 | - add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) ); |
|
| 127 | + add_action('give_pre_process_donation', array($this, 'set_session_cookies')); |
|
| 128 | 128 | |
| 129 | 129 | } |
| 130 | 130 | |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function init() { |
| 142 | 142 | |
| 143 | - if ( $this->use_php_sessions ) { |
|
| 144 | - $this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array(); |
|
| 143 | + if ($this->use_php_sessions) { |
|
| 144 | + $this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array(); |
|
| 145 | 145 | } else { |
| 146 | 146 | $this->session = WP_Session::get_instance(); |
| 147 | 147 | } |
@@ -176,37 +176,37 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @return string|array Session variable. |
| 178 | 178 | */ |
| 179 | - public function get( $key ) { |
|
| 180 | - $key = sanitize_key( $key ); |
|
| 179 | + public function get($key) { |
|
| 180 | + $key = sanitize_key($key); |
|
| 181 | 181 | $return = false; |
| 182 | 182 | |
| 183 | - if ( isset( $this->session[ $key ] ) && ! empty( $this->session[ $key ] ) ) { |
|
| 183 | + if (isset($this->session[$key]) && ! empty($this->session[$key])) { |
|
| 184 | 184 | |
| 185 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[ $key ], $matches ); |
|
| 186 | - if ( ! empty( $matches ) ) { |
|
| 187 | - $this->set( $key, null ); |
|
| 185 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[$key], $matches); |
|
| 186 | + if ( ! empty($matches)) { |
|
| 187 | + $this->set($key, null); |
|
| 188 | 188 | |
| 189 | 189 | return false; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - if ( is_numeric( $this->session[ $key ] ) ) { |
|
| 193 | - $return = $this->session[ $key ]; |
|
| 192 | + if (is_numeric($this->session[$key])) { |
|
| 193 | + $return = $this->session[$key]; |
|
| 194 | 194 | } else { |
| 195 | 195 | |
| 196 | - $maybe_json = json_decode( $this->session[ $key ] ); |
|
| 196 | + $maybe_json = json_decode($this->session[$key]); |
|
| 197 | 197 | |
| 198 | 198 | // Since json_last_error is PHP 5.3+, we have to rely on a `null` value for failing to parse JSON. |
| 199 | - if ( is_null( $maybe_json ) ) { |
|
| 200 | - $is_serialized = is_serialized( $this->session[ $key ] ); |
|
| 201 | - if ( $is_serialized ) { |
|
| 202 | - $value = @unserialize( $this->session[ $key ] ); |
|
| 203 | - $this->set( $key, (array) $value ); |
|
| 199 | + if (is_null($maybe_json)) { |
|
| 200 | + $is_serialized = is_serialized($this->session[$key]); |
|
| 201 | + if ($is_serialized) { |
|
| 202 | + $value = @unserialize($this->session[$key]); |
|
| 203 | + $this->set($key, (array) $value); |
|
| 204 | 204 | $return = $value; |
| 205 | 205 | } else { |
| 206 | - $return = $this->session[ $key ]; |
|
| 206 | + $return = $this->session[$key]; |
|
| 207 | 207 | } |
| 208 | 208 | } else { |
| 209 | - $return = json_decode( $this->session[ $key ], true ); |
|
| 209 | + $return = json_decode($this->session[$key], true); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | } |
@@ -229,21 +229,21 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @return string Session variable. |
| 231 | 231 | */ |
| 232 | - public function set( $key, $value ) { |
|
| 232 | + public function set($key, $value) { |
|
| 233 | 233 | |
| 234 | - $key = sanitize_key( $key ); |
|
| 234 | + $key = sanitize_key($key); |
|
| 235 | 235 | |
| 236 | - if ( is_array( $value ) ) { |
|
| 237 | - $this->session[ $key ] = wp_json_encode( $value ); |
|
| 236 | + if (is_array($value)) { |
|
| 237 | + $this->session[$key] = wp_json_encode($value); |
|
| 238 | 238 | } else { |
| 239 | - $this->session[ $key ] = esc_attr( $value ); |
|
| 239 | + $this->session[$key] = esc_attr($value); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - if ( $this->use_php_sessions ) { |
|
| 243 | - $_SESSION[ 'give' . $this->prefix ] = $this->session; |
|
| 242 | + if ($this->use_php_sessions) { |
|
| 243 | + $_SESSION['give'.$this->prefix] = $this->session; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - return $this->session[ $key ]; |
|
| 246 | + return $this->session[$key]; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -258,10 +258,10 @@ discard block |
||
| 258 | 258 | * @hook |
| 259 | 259 | */ |
| 260 | 260 | public function set_session_cookies() { |
| 261 | - if ( ! headers_sent() ) { |
|
| 262 | - $lifetime = current_time( 'timestamp' ) + $this->set_expiration_time(); |
|
| 263 | - @setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
| 264 | - @setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
| 261 | + if ( ! headers_sent()) { |
|
| 262 | + $lifetime = current_time('timestamp') + $this->set_expiration_time(); |
|
| 263 | + @setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
| 264 | + @setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | public function set_expiration_variant_time() { |
| 279 | 279 | |
| 280 | - return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 ); |
|
| 280 | + return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | public function set_expiration_time() { |
| 294 | 294 | |
| 295 | - return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 ); |
|
| 295 | + return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -310,21 +310,21 @@ discard block |
||
| 310 | 310 | $ret = false; |
| 311 | 311 | |
| 312 | 312 | // If the database variable is already set, no need to run auto detection. |
| 313 | - $give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' ); |
|
| 313 | + $give_use_php_sessions = (bool) get_option('give_use_php_sessions'); |
|
| 314 | 314 | |
| 315 | - if ( ! $give_use_php_sessions ) { |
|
| 315 | + if ( ! $give_use_php_sessions) { |
|
| 316 | 316 | |
| 317 | 317 | // Attempt to detect if the server supports PHP sessions. |
| 318 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 318 | + if (function_exists('session_start') && ! ini_get('safe_mode')) { |
|
| 319 | 319 | |
| 320 | - $this->set( 'give_use_php_sessions', 1 ); |
|
| 320 | + $this->set('give_use_php_sessions', 1); |
|
| 321 | 321 | |
| 322 | - if ( $this->get( 'give_use_php_sessions' ) ) { |
|
| 322 | + if ($this->get('give_use_php_sessions')) { |
|
| 323 | 323 | |
| 324 | 324 | $ret = true; |
| 325 | 325 | |
| 326 | 326 | // Set the database option. |
| 327 | - update_option( 'give_use_php_sessions', true ); |
|
| 327 | + update_option('give_use_php_sessions', true); |
|
| 328 | 328 | |
| 329 | 329 | } |
| 330 | 330 | } |
@@ -334,13 +334,13 @@ discard block |
||
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | // Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant. |
| 337 | - if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) { |
|
| 337 | + if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) { |
|
| 338 | 338 | $ret = true; |
| 339 | - } elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) { |
|
| 339 | + } elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) { |
|
| 340 | 340 | $ret = false; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - return (bool) apply_filters( 'give_use_php_sessions', $ret ); |
|
| 343 | + return (bool) apply_filters('give_use_php_sessions', $ret); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | /** |
@@ -357,9 +357,9 @@ discard block |
||
| 357 | 357 | |
| 358 | 358 | $start_session = true; |
| 359 | 359 | |
| 360 | - if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { |
|
| 360 | + if ( ! empty($_SERVER['REQUEST_URI'])) { |
|
| 361 | 361 | |
| 362 | - $blacklist = apply_filters( 'give_session_start_uri_blacklist', array( |
|
| 362 | + $blacklist = apply_filters('give_session_start_uri_blacklist', array( |
|
| 363 | 363 | 'feed', |
| 364 | 364 | 'feed', |
| 365 | 365 | 'feed/rss', |
@@ -367,21 +367,21 @@ discard block |
||
| 367 | 367 | 'feed/rdf', |
| 368 | 368 | 'feed/atom', |
| 369 | 369 | 'comments/feed/', |
| 370 | - ) ); |
|
| 371 | - $uri = ltrim( $_SERVER['REQUEST_URI'], '/' ); |
|
| 372 | - $uri = untrailingslashit( $uri ); |
|
| 373 | - if ( in_array( $uri, $blacklist ) ) { |
|
| 370 | + )); |
|
| 371 | + $uri = ltrim($_SERVER['REQUEST_URI'], '/'); |
|
| 372 | + $uri = untrailingslashit($uri); |
|
| 373 | + if (in_array($uri, $blacklist)) { |
|
| 374 | 374 | $start_session = false; |
| 375 | 375 | } |
| 376 | - if ( false !== strpos( $uri, 'feed=' ) ) { |
|
| 376 | + if (false !== strpos($uri, 'feed=')) { |
|
| 377 | 377 | $start_session = false; |
| 378 | 378 | } |
| 379 | - if ( is_admin() ) { |
|
| 379 | + if (is_admin()) { |
|
| 380 | 380 | $start_session = false; |
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - return apply_filters( 'give_start_session', $start_session ); |
|
| 384 | + return apply_filters('give_start_session', $start_session); |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | /** |
@@ -397,11 +397,11 @@ discard block |
||
| 397 | 397 | */ |
| 398 | 398 | public function maybe_start_session() { |
| 399 | 399 | |
| 400 | - if ( ! $this->should_start_session() ) { |
|
| 400 | + if ( ! $this->should_start_session()) { |
|
| 401 | 401 | return; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - if ( ! session_id() && ! headers_sent() ) { |
|
| 404 | + if ( ! session_id() && ! headers_sent()) { |
|
| 405 | 405 | session_start(); |
| 406 | 406 | } |
| 407 | 407 | |
@@ -420,9 +420,9 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | $expiration = false; |
| 422 | 422 | |
| 423 | - if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) { |
|
| 423 | + if (session_id() && isset($_COOKIE[session_name().'_expiration'])) { |
|
| 424 | 424 | |
| 425 | - $expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) ); |
|
| 425 | + $expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration'])); |
|
| 426 | 426 | |
| 427 | 427 | } |
| 428 | 428 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.8.13 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -75,63 +75,63 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function init() { |
| 77 | 77 | // Bail early if screen cannot be detected. |
| 78 | - if ( empty( $this->screen ) ) { |
|
| 78 | + if (empty($this->screen)) { |
|
| 79 | 79 | return null; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $content = array(); |
| 83 | 83 | |
| 84 | 84 | // Define content and hook into the appropriate action. |
| 85 | - switch ( $this->screen ) { |
|
| 85 | + switch ($this->screen) { |
|
| 86 | 86 | // Forms screen. |
| 87 | 87 | case 'edit-give_forms': |
| 88 | - $this->form = $this->post_exists( 'give_forms' ); |
|
| 88 | + $this->form = $this->post_exists('give_forms'); |
|
| 89 | 89 | |
| 90 | - if ( $this->form ) { |
|
| 90 | + if ($this->form) { |
|
| 91 | 91 | // Form exists. Bail out. |
| 92 | 92 | return false; |
| 93 | 93 | } else { |
| 94 | 94 | // No forms exist. |
| 95 | - $content = $this->get_content( 'no_forms' ); |
|
| 95 | + $content = $this->get_content('no_forms'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - add_action( 'manage_posts_extra_tablenav', array( $this, 'render' ) ); |
|
| 98 | + add_action('manage_posts_extra_tablenav', array($this, 'render')); |
|
| 99 | 99 | break; |
| 100 | 100 | // Donations screen. |
| 101 | 101 | case 'give_forms_page_give-payment-history': |
| 102 | - $this->form = $this->post_exists( 'give_forms' ); |
|
| 103 | - $this->donation = $this->post_exists( 'give_payment' ); |
|
| 102 | + $this->form = $this->post_exists('give_forms'); |
|
| 103 | + $this->donation = $this->post_exists('give_payment'); |
|
| 104 | 104 | |
| 105 | - if ( $this->donation ) { |
|
| 105 | + if ($this->donation) { |
|
| 106 | 106 | // Donation exists. Bail out. |
| 107 | 107 | return false; |
| 108 | - } elseif ( ! $this->form ) { |
|
| 108 | + } elseif ( ! $this->form) { |
|
| 109 | 109 | // No forms and no donations exist. |
| 110 | - $content = $this->get_content( 'no_donations_or_forms' ); |
|
| 110 | + $content = $this->get_content('no_donations_or_forms'); |
|
| 111 | 111 | } else { |
| 112 | 112 | // No donations exist but a form does exist. |
| 113 | - $content = $this->get_content( 'no_donations' ); |
|
| 113 | + $content = $this->get_content('no_donations'); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - add_action( 'give_payments_page_bottom', array( $this, 'render' ) ); |
|
| 116 | + add_action('give_payments_page_bottom', array($this, 'render')); |
|
| 117 | 117 | break; |
| 118 | 118 | // Donors screen. |
| 119 | 119 | case 'give_forms_page_give-donors': |
| 120 | - $this->form = $this->post_exists( 'give_forms' ); |
|
| 120 | + $this->form = $this->post_exists('give_forms'); |
|
| 121 | 121 | $this->donor = $this->donor_exists(); |
| 122 | 122 | |
| 123 | - if ( $this->donor ) { |
|
| 123 | + if ($this->donor) { |
|
| 124 | 124 | // Donor exists. Bail out. |
| 125 | 125 | return false; |
| 126 | - } elseif ( ! $this->form ) { |
|
| 126 | + } elseif ( ! $this->form) { |
|
| 127 | 127 | // No forms and no donors exist. |
| 128 | - $content = $this->get_content( 'no_donors_or_forms' ); |
|
| 128 | + $content = $this->get_content('no_donors_or_forms'); |
|
| 129 | 129 | } else { |
| 130 | 130 | // No donors exist but a form does exist. |
| 131 | - $content = $this->get_content( 'no_donors' ); |
|
| 131 | + $content = $this->get_content('no_donors'); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - add_action( 'give_donors_table_bottom', array( $this, 'render' ) ); |
|
| 134 | + add_action('give_donors_table_bottom', array($this, 'render')); |
|
| 135 | 135 | break; |
| 136 | 136 | default: |
| 137 | 137 | return null; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $this->content = $content; |
| 141 | 141 | |
| 142 | 142 | // Hide non-essential UI elements. |
| 143 | - add_action( 'admin_head', array( $this, 'hide_ui' ) ); |
|
| 143 | + add_action('admin_head', array($this, 'hide_ui')); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @param string $which The location of the list table hook: 'top' or 'bottom'. |
| 152 | 152 | */ |
| 153 | - public function render( $which = 'bottom') { |
|
| 153 | + public function render($which = 'bottom') { |
|
| 154 | 154 | // Bail out to prevent content from rendering twice. |
| 155 | - if ( 'top' === $which ) { |
|
| 155 | + if ('top' === $which) { |
|
| 156 | 156 | return null; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -177,9 +177,9 @@ discard block |
||
| 177 | 177 | * |
| 178 | 178 | * @param string $screen The current screen ID. |
| 179 | 179 | */ |
| 180 | - $content = apply_filters( 'give_blank_slate_content', $this->content, $screen ); |
|
| 180 | + $content = apply_filters('give_blank_slate_content', $this->content, $screen); |
|
| 181 | 181 | |
| 182 | - $template_path = GIVE_PLUGIN_DIR . 'includes/admin/views/blank-slate.php'; |
|
| 182 | + $template_path = GIVE_PLUGIN_DIR.'includes/admin/views/blank-slate.php'; |
|
| 183 | 183 | |
| 184 | 184 | include $template_path; |
| 185 | 185 | } |
@@ -201,17 +201,17 @@ discard block |
||
| 201 | 201 | * @param string $post_type Post type used in the query. |
| 202 | 202 | * @return bool True if post exists, otherwise false. |
| 203 | 203 | */ |
| 204 | - private function post_exists( $post_type ) { |
|
| 204 | + private function post_exists($post_type) { |
|
| 205 | 205 | // Attempt to get a single post of the post type. |
| 206 | - $query = new WP_Query( array( |
|
| 206 | + $query = new WP_Query(array( |
|
| 207 | 207 | 'post_type' => $post_type, |
| 208 | 208 | 'posts_per_page' => 1, |
| 209 | 209 | 'no_found_rows' => false, |
| 210 | 210 | 'update_post_meta_cache' => false, |
| 211 | 211 | 'update_post_term_cache' => false, |
| 212 | 212 | 'fields' => 'ids', |
| 213 | - 'post_status' => array( 'any', 'trash' ), |
|
| 214 | - ) ); |
|
| 213 | + 'post_status' => array('any', 'trash'), |
|
| 214 | + )); |
|
| 215 | 215 | |
| 216 | 216 | return $query->have_posts(); |
| 217 | 217 | } |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | * @return bool True if donor exists, otherwise false. |
| 225 | 225 | */ |
| 226 | 226 | private function donor_exists() { |
| 227 | - $donors = Give()->donors->get_donors( array( 'number' => 1 ) ); |
|
| 227 | + $donors = Give()->donors->get_donors(array('number' => 1)); |
|
| 228 | 228 | |
| 229 | - return ! empty( $donors ); |
|
| 229 | + return ! empty($donors); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -237,17 +237,17 @@ discard block |
||
| 237 | 237 | * @param string $context The key used to determine which content is returned. |
| 238 | 238 | * @return array Blank slate content. |
| 239 | 239 | */ |
| 240 | - private function get_content( $context ) { |
|
| 240 | + private function get_content($context) { |
|
| 241 | 241 | // Define default content. |
| 242 | 242 | $defaults = array( |
| 243 | - 'image_url' => GIVE_PLUGIN_URL . 'assets/images/svg/give-icon-full-circle.svg', |
|
| 244 | - 'image_alt' => __( 'Give Icon', 'give' ), |
|
| 245 | - 'heading' => __( 'No donation forms found.', 'give' ), |
|
| 246 | - 'message' => __( 'The first step towards accepting online donations is to create a form.', 'give' ), |
|
| 247 | - 'cta_text' => __( 'Create Donation Form', 'give' ), |
|
| 248 | - 'cta_link' => admin_url( 'post-new.php?post_type=give_forms' ), |
|
| 243 | + 'image_url' => GIVE_PLUGIN_URL.'assets/images/svg/give-icon-full-circle.svg', |
|
| 244 | + 'image_alt' => __('Give Icon', 'give'), |
|
| 245 | + 'heading' => __('No donation forms found.', 'give'), |
|
| 246 | + 'message' => __('The first step towards accepting online donations is to create a form.', 'give'), |
|
| 247 | + 'cta_text' => __('Create Donation Form', 'give'), |
|
| 248 | + 'cta_link' => admin_url('post-new.php?post_type=give_forms'), |
|
| 249 | 249 | 'help' => sprintf( |
| 250 | - __( 'Need help? Get started with %sGive 101%s.', 'wbpr' ), |
|
| 250 | + __('Need help? Get started with %sGive 101%s.', 'wbpr'), |
|
| 251 | 251 | '<a href="http://docs.givewp.com/give101/" target="_blank">', |
| 252 | 252 | '</a>' |
| 253 | 253 | ), |
@@ -256,40 +256,40 @@ discard block |
||
| 256 | 256 | // Define contextual content. |
| 257 | 257 | $content = array( |
| 258 | 258 | 'no_donations_or_forms' => array( |
| 259 | - 'heading' => __( 'No donations found.', 'give' ), |
|
| 260 | - 'message' => __( 'Your donation history will appear here, but first, you need a donation form!', 'give' ), |
|
| 259 | + 'heading' => __('No donations found.', 'give'), |
|
| 260 | + 'message' => __('Your donation history will appear here, but first, you need a donation form!', 'give'), |
|
| 261 | 261 | ), |
| 262 | 262 | 'no_donations' => array( |
| 263 | - 'heading' => __( 'No donations found.', 'give' ), |
|
| 264 | - 'message' => __( 'When your first donation arrives, a record of the donation will appear here.', 'give' ), |
|
| 265 | - 'cta_text' => __( 'View All Forms', 'give' ), |
|
| 266 | - 'cta_link' => admin_url( 'edit.php?post_type=give_forms' ), |
|
| 263 | + 'heading' => __('No donations found.', 'give'), |
|
| 264 | + 'message' => __('When your first donation arrives, a record of the donation will appear here.', 'give'), |
|
| 265 | + 'cta_text' => __('View All Forms', 'give'), |
|
| 266 | + 'cta_link' => admin_url('edit.php?post_type=give_forms'), |
|
| 267 | 267 | 'help' => sprintf( |
| 268 | - __( 'Need help? Learn more about %sDonations%s.', 'wbpr' ), |
|
| 268 | + __('Need help? Learn more about %sDonations%s.', 'wbpr'), |
|
| 269 | 269 | '<a href="http://docs.givewp.com/core-donations/">', |
| 270 | 270 | '</a>' |
| 271 | 271 | ), |
| 272 | 272 | ), |
| 273 | 273 | 'no_donors_or_forms' => array( |
| 274 | - 'heading' => __( 'No donors found.', 'give' ), |
|
| 275 | - 'message' => __( 'Your donor history will appear here, but first, you need a donation form!', 'give' ), |
|
| 274 | + 'heading' => __('No donors found.', 'give'), |
|
| 275 | + 'message' => __('Your donor history will appear here, but first, you need a donation form!', 'give'), |
|
| 276 | 276 | ), |
| 277 | 277 | 'no_donors' => array( |
| 278 | - 'heading' => __( 'No donors found.', 'give' ), |
|
| 279 | - 'message' => __( 'When your first donation arrives, the donor will appear here.', 'give' ), |
|
| 280 | - 'cta_text' => __( 'View All Forms', 'give' ), |
|
| 281 | - 'cta_link' => admin_url( 'edit.php?post_type=give_forms' ), |
|
| 278 | + 'heading' => __('No donors found.', 'give'), |
|
| 279 | + 'message' => __('When your first donation arrives, the donor will appear here.', 'give'), |
|
| 280 | + 'cta_text' => __('View All Forms', 'give'), |
|
| 281 | + 'cta_link' => admin_url('edit.php?post_type=give_forms'), |
|
| 282 | 282 | 'help' => sprintf( |
| 283 | - __( 'Need help? Learn more about %sDonors%s.', 'wbpr' ), |
|
| 283 | + __('Need help? Learn more about %sDonors%s.', 'wbpr'), |
|
| 284 | 284 | '<a href="http://docs.givewp.com/core-donors/">', |
| 285 | 285 | '</a>' |
| 286 | 286 | ), |
| 287 | 287 | ), |
| 288 | 288 | ); |
| 289 | 289 | |
| 290 | - if ( isset( $content[ $context ] ) ) { |
|
| 290 | + if (isset($content[$context])) { |
|
| 291 | 291 | // Merge contextual content with defaults. |
| 292 | - return wp_parse_args( $content[ $context ], $defaults ); |
|
| 292 | + return wp_parse_args($content[$context], $defaults); |
|
| 293 | 293 | } else { |
| 294 | 294 | // Return defaults if context is undefined. |
| 295 | 295 | return $defaults; |
@@ -95,5 +95,8 @@ |
||
| 95 | 95 | <?php endif; ?> |
| 96 | 96 | <?php echo $form_close_tag; ?> |
| 97 | 97 | </div> |
| 98 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
| 98 | +<?php else { |
|
| 99 | + : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; |
|
| 100 | +} |
|
| 101 | +?> |
|
| 99 | 102 | <?php endif; ?> |
| 100 | 103 | \ No newline at end of file |
@@ -2,12 +2,12 @@ discard block |
||
| 2 | 2 | /** |
| 3 | 3 | * Admin View: Settings |
| 4 | 4 | */ |
| 5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 5 | +if ( ! defined('ABSPATH')) { |
|
| 6 | 6 | exit; |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | // Bailout: Do not output anything if setting tab is not defined. |
| 10 | -if ( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) : |
|
| 10 | +if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) : |
|
| 11 | 11 | /** |
| 12 | 12 | * Filter the form action. |
| 13 | 13 | * |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * |
| 18 | 18 | * @since 1.8 |
| 19 | 19 | */ |
| 20 | - $form_method = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' ); |
|
| 20 | + $form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post'); |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * Filter the main form tab. |
@@ -29,14 +29,14 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @since 1.8 |
| 31 | 31 | */ |
| 32 | - $form_open_tag = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method . '" id="give-mainform" action="" enctype="multipart/form-data">' ); |
|
| 33 | - $form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' ); |
|
| 32 | + $form_open_tag = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">'); |
|
| 33 | + $form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>'); |
|
| 34 | 34 | |
| 35 | - $wrapper_class = implode( ' ', |
|
| 35 | + $wrapper_class = implode(' ', |
|
| 36 | 36 | array( |
| 37 | - self::$setting_filter_prefix . '-setting-page', |
|
| 38 | - self::$setting_filter_prefix . '-' . give_get_current_setting_section() . '-section', |
|
| 39 | - self::$setting_filter_prefix . '-' . give_get_current_setting_tab() . '-tab', |
|
| 37 | + self::$setting_filter_prefix.'-setting-page', |
|
| 38 | + self::$setting_filter_prefix.'-'.give_get_current_setting_section().'-section', |
|
| 39 | + self::$setting_filter_prefix.'-'.give_get_current_setting_tab().'-tab', |
|
| 40 | 40 | ) |
| 41 | 41 | ); |
| 42 | 42 | ?> |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | /* @var Give_Settings_Page $current_setting_obj */ |
| 48 | 48 | if ( |
| 49 | - ! empty( $current_setting_obj ) && |
|
| 50 | - method_exists( $current_setting_obj, 'get_heading_html' ) |
|
| 49 | + ! empty($current_setting_obj) && |
|
| 50 | + method_exists($current_setting_obj, 'get_heading_html') |
|
| 51 | 51 | ) { |
| 52 | 52 | echo $current_setting_obj->get_heading_html(); |
| 53 | 53 | } else { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | // Backward compatibility. |
| 56 | 56 | echo sprintf( |
| 57 | 57 | '<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">', |
| 58 | - esc_html( $tabs[ $current_tab ] ) |
|
| 58 | + esc_html($tabs[$current_tab]) |
|
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | ?> |
| 64 | 64 | <div class="nav-tab-wrapper give-nav-tab-wrapper"> |
| 65 | 65 | <?php |
| 66 | - foreach ( $tabs as $name => $label ) { |
|
| 67 | - echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden' ) . '">' . $label . '</a>'; |
|
| 66 | + foreach ($tabs as $name => $label) { |
|
| 67 | + echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden').'">'.$label.'</a>'; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -76,10 +76,10 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @since 1.8 |
| 78 | 78 | */ |
| 79 | - do_action( self::$setting_filter_prefix . '_tabs' ); |
|
| 79 | + do_action(self::$setting_filter_prefix.'_tabs'); |
|
| 80 | 80 | ?> |
| 81 | 81 | <div class="give-sub-nav-tab-wrapper"> |
| 82 | - <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e( 'View remaining setting tabs', 'give' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span> |
|
| 82 | + <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e('View remaining setting tabs', 'give'); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span> |
|
| 83 | 83 | </a> |
| 84 | 84 | <nav class="give-sub-nav-tab give-hidden"></nav> |
| 85 | 85 | </div> |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @since 1.8 |
| 97 | 97 | */ |
| 98 | - do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" ); |
|
| 98 | + do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page"); |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Trigger Action. |
@@ -106,15 +106,15 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @since 1.8 |
| 108 | 108 | */ |
| 109 | - do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" ); |
|
| 109 | + do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page"); |
|
| 110 | 110 | |
| 111 | - if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?> |
|
| 111 | + if (empty($GLOBALS['give_hide_save_button'])) : ?> |
|
| 112 | 112 | <div class="give-submit-wrap"> |
| 113 | - <?php wp_nonce_field( 'give-save-settings', '_give-save-settings' ); ?> |
|
| 114 | - <input name="save" class="button-primary give-save-button" type="submit" value="<?php _e( 'Save changes', 'give' ); ?>"/> |
|
| 113 | + <?php wp_nonce_field('give-save-settings', '_give-save-settings'); ?> |
|
| 114 | + <input name="save" class="button-primary give-save-button" type="submit" value="<?php _e('Save changes', 'give'); ?>"/> |
|
| 115 | 115 | </div> |
| 116 | 116 | <?php endif; ?> |
| 117 | 117 | <?php echo $form_close_tag; ?> |
| 118 | 118 | </div> |
| 119 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
| 119 | +<?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?> |
|
| 120 | 120 | <?php endif; ?> |
| 121 | 121 | \ No newline at end of file |
@@ -17,23 +17,23 @@ discard block |
||
| 17 | 17 | ?> |
| 18 | 18 | |
| 19 | 19 | <div class="give-blank-slate"> |
| 20 | - <?php if ( ! empty( $content['image_url'] ) ) : ?> |
|
| 21 | - <img class="give-blank-slate__image" src="<?php echo esc_url( $content['image_url'] ); ?>" alt="<?php echo esc_attr( $content['image_alt'] ); ?>"> |
|
| 20 | + <?php if ( ! empty($content['image_url'])) : ?> |
|
| 21 | + <img class="give-blank-slate__image" src="<?php echo esc_url($content['image_url']); ?>" alt="<?php echo esc_attr($content['image_alt']); ?>"> |
|
| 22 | 22 | <?php endif; ?> |
| 23 | 23 | |
| 24 | - <?php if ( ! empty( $content['heading'] ) ) : ?> |
|
| 25 | - <h2 class="give-blank-slate__heading"><?php esc_html_e( $content['heading'] ); ?></h2> |
|
| 24 | + <?php if ( ! empty($content['heading'])) : ?> |
|
| 25 | + <h2 class="give-blank-slate__heading"><?php esc_html_e($content['heading']); ?></h2> |
|
| 26 | 26 | <?php endif; ?> |
| 27 | 27 | |
| 28 | - <?php if ( ! empty( $content['message'] ) ) : ?> |
|
| 29 | - <p class="give-blank-slate__message"><?php esc_html_e( $content['message'] ); ?></p> |
|
| 28 | + <?php if ( ! empty($content['message'])) : ?> |
|
| 29 | + <p class="give-blank-slate__message"><?php esc_html_e($content['message']); ?></p> |
|
| 30 | 30 | <?php endif; ?> |
| 31 | 31 | |
| 32 | - <?php if ( ! empty( $content['cta_text']) && ! empty( $content['cta_link'] ) ) : ?> |
|
| 33 | - <a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url( $content['cta_link'] ); ?>"><?php esc_html_e( $content['cta_text'] ); ?></a> |
|
| 32 | + <?php if ( ! empty($content['cta_text']) && ! empty($content['cta_link'])) : ?> |
|
| 33 | + <a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url($content['cta_link']); ?>"><?php esc_html_e($content['cta_text']); ?></a> |
|
| 34 | 34 | <?php endif; ?> |
| 35 | 35 | |
| 36 | - <?php if ( ! empty( $content['help'] ) ) : ?> |
|
| 36 | + <?php if ( ! empty($content['help'])) : ?> |
|
| 37 | 37 | <p class="give-blank-slate__help"> |
| 38 | 38 | <?php |
| 39 | 39 | $allowed_html = array( |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | 'code' => array(), |
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | - echo wp_kses( $content['help'], $allowed_html ); |
|
| 50 | + echo wp_kses($content['help'], $allowed_html); |
|
| 51 | 51 | ?> |
| 52 | 52 | </p> |
| 53 | 53 | <?php endif; ?> |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | * @since 1.5 |
| 21 | 21 | */ |
| 22 | 22 | function give_register_batch_recount_export_classes() { |
| 23 | - add_action( 'give_batch_export_class_include', 'give_include_batch_export_class', 10, 1 ); |
|
| 23 | + add_action('give_batch_export_class_include', 'give_include_batch_export_class', 10, 1); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10 ); |
|
| 26 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10); |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -35,39 +35,39 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @return void |
| 37 | 37 | */ |
| 38 | -function give_include_batch_export_class( $class ) { |
|
| 39 | - switch ( $class ) { |
|
| 38 | +function give_include_batch_export_class($class) { |
|
| 39 | + switch ($class) { |
|
| 40 | 40 | |
| 41 | 41 | case 'Give_Tools_Delete_Donors': |
| 42 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-donors.php'; |
|
| 42 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-donors.php'; |
|
| 43 | 43 | break; |
| 44 | 44 | |
| 45 | 45 | case 'Give_Tools_Import_Donors': |
| 46 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-import-donors.php'; |
|
| 46 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-import-donors.php'; |
|
| 47 | 47 | break; |
| 48 | 48 | |
| 49 | 49 | case 'Give_Tools_Delete_Test_Transactions': |
| 50 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-transactions.php'; |
|
| 50 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-transactions.php'; |
|
| 51 | 51 | break; |
| 52 | 52 | |
| 53 | 53 | case 'Give_Tools_Recount_Donor_Stats': |
| 54 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-donor-stats.php'; |
|
| 54 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-donor-stats.php'; |
|
| 55 | 55 | break; |
| 56 | 56 | |
| 57 | 57 | case 'Give_Tools_Reset_Stats': |
| 58 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-reset-stats.php'; |
|
| 58 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-reset-stats.php'; |
|
| 59 | 59 | break; |
| 60 | 60 | |
| 61 | 61 | case 'Give_Tools_Recount_All_Stats': |
| 62 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-all-stats.php'; |
|
| 62 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-all-stats.php'; |
|
| 63 | 63 | break; |
| 64 | 64 | |
| 65 | 65 | case 'Give_Tools_Recount_Form_Stats': |
| 66 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-form-stats.php'; |
|
| 66 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-form-stats.php'; |
|
| 67 | 67 | break; |
| 68 | 68 | |
| 69 | 69 | case 'Give_Tools_Recount_Income': |
| 70 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-income.php'; |
|
| 70 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-income.php'; |
|
| 71 | 71 | break; |
| 72 | 72 | } |
| 73 | 73 | } |