@@ -6,7 +6,7 @@ |
||
| 6 | 6 | * @version 1.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
| 9 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly. |
|
| 10 | 10 | |
| 11 | 11 | // {email} is replaced by the content entered in Donations > Settings > Emails |
| 12 | 12 | |
@@ -6,7 +6,10 @@ |
||
| 6 | 6 | * @version 1.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
| 9 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | + exit; |
|
| 11 | +} |
|
| 12 | +// Exit if accessed directly. |
|
| 10 | 13 | |
| 11 | 14 | // {email} is replaced by the content entered in Donations > Settings > Emails |
| 12 | 15 | |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | * @version 1.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
| 9 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly. |
|
| 10 | 10 | |
| 11 | 11 | // This is the footer used if no others are available |
| 12 | 12 | |
@@ -6,7 +6,10 @@ |
||
| 6 | 6 | * @version 1.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
| 9 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | + exit; |
|
| 11 | +} |
|
| 12 | +// Exit if accessed directly. |
|
| 10 | 13 | |
| 11 | 14 | // This is the footer used if no others are available |
| 12 | 15 | |
@@ -6,16 +6,16 @@ discard block |
||
| 6 | 6 | * @version 1.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if ( ! defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } // Exit if accessed directly. |
| 12 | 12 | |
| 13 | 13 | // For gmail compatibility, including CSS styles in head/body are stripped out therefore styles need to be inline. These variables contain rules which are added to the template inline. !important; is a gmail hack to prevent styles being stripped if it doesn't like something. |
| 14 | -$body = " |
|
| 14 | +$body = " |
|
| 15 | 15 | background-color: #f6f6f6; |
| 16 | 16 | font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; |
| 17 | 17 | "; |
| 18 | -$wrapper = " |
|
| 18 | +$wrapper = " |
|
| 19 | 19 | width:100%; |
| 20 | 20 | -webkit-text-size-adjust:none !important; |
| 21 | 21 | margin:0; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | text-align: center; |
| 43 | 43 | vertical-align:middle; |
| 44 | 44 | "; |
| 45 | -$body_content = " |
|
| 45 | +$body_content = " |
|
| 46 | 46 | border-radius:3px !important; |
| 47 | 47 | font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; |
| 48 | 48 | "; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | line-height:150%; |
| 54 | 54 | text-align:left; |
| 55 | 55 | "; |
| 56 | -$header_content_h1 = " |
|
| 56 | +$header_content_h1 = " |
|
| 57 | 57 | color: #000000; |
| 58 | 58 | margin:0; |
| 59 | 59 | padding: 28px 24px; |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | font-weight: 500; |
| 64 | 64 | line-height: 1.2; |
| 65 | 65 | "; |
| 66 | -$header_img = give_get_option( 'email_logo', '' ); |
|
| 66 | +$header_img = give_get_option('email_logo', ''); |
|
| 67 | 67 | ?> |
| 68 | 68 | <!DOCTYPE html> |
| 69 | 69 | <html> |
| 70 | 70 | <head> |
| 71 | 71 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 72 | - <title><?php echo get_bloginfo( 'name' ); ?></title> |
|
| 72 | + <title><?php echo get_bloginfo('name'); ?></title> |
|
| 73 | 73 | </head> |
| 74 | 74 | <body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" style="<?php echo $body; ?>"> |
| 75 | 75 | <div style="<?php echo $wrapper; ?>"> |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | <tr> |
| 78 | 78 | <td align="center" valign="top"> |
| 79 | 79 | <?php |
| 80 | - if ( ! empty( $header_img ) ) : ?> |
|
| 80 | + if ( ! empty($header_img)) : ?> |
|
| 81 | 81 | <div id="template_header_image"> |
| 82 | - <?php echo '<p style="margin-top:0;"><img style="' . $template_image . '" src="' . esc_url( $header_img ) . '" alt="' . get_bloginfo( 'name' ) . '" /></p>'; ?> |
|
| 82 | + <?php echo '<p style="margin-top:0;"><img style="'.$template_image.'" src="'.esc_url($header_img).'" alt="'.get_bloginfo('name').'" /></p>'; ?> |
|
| 83 | 83 | </div> |
| 84 | 84 | <?php endif; ?> |
| 85 | 85 | <table border="0" cellpadding="0" cellspacing="0" width="600" id="template_container" style="<?php echo $template_container; ?>"> |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | * @version 1.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
| 9 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly. |
|
| 10 | 10 | |
| 11 | 11 | // {email} is replaced by the content entered in Donations > Settings > Emails |
| 12 | 12 | |
@@ -6,7 +6,10 @@ |
||
| 6 | 6 | * @version 1.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
| 9 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | + exit; |
|
| 11 | +} |
|
| 12 | +// Exit if accessed directly. |
|
| 10 | 13 | |
| 11 | 14 | // {email} is replaced by the content entered in Donations > Settings > Emails |
| 12 | 15 | |
@@ -39,8 +39,8 @@ |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | if ( ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
| 42 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
| 43 | - && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
| 42 | + || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
| 43 | + && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
| 44 | 44 | ) { |
| 45 | 45 | |
| 46 | 46 | $forms_singular_option = give_get_option( 'forms_singular' ); |
@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | * @return void |
| 20 | 20 | */ |
| 21 | 21 | function give_disable_mandrill_nl2br() { |
| 22 | - add_filter( 'mandrill_nl2br', '__return_false' ); |
|
| 22 | + add_filter('mandrill_nl2br', '__return_false'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br' ); |
|
| 25 | +add_action('give_email_send_before', 'give_disable_mandrill_nl2br'); |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -34,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 | } |
@@ -671,7 +671,7 @@ |
||
| 671 | 671 | /** |
| 672 | 672 | * This function will check whether the donor email is primary or additional. |
| 673 | 673 | * |
| 674 | - * @param $email Donor Email. |
|
| 674 | + * @param string $email Donor Email. |
|
| 675 | 675 | * |
| 676 | 676 | * @since 1.8.13 |
| 677 | 677 | * |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly. |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -30,54 +30,54 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return bool|array List of all user donations. |
| 32 | 32 | */ |
| 33 | -function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
| 33 | +function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
| 34 | 34 | |
| 35 | - if ( empty( $user ) ) { |
|
| 35 | + if (empty($user)) { |
|
| 36 | 36 | $user = get_current_user_id(); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
| 39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
| 40 | 40 | return false; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
| 44 | 44 | $paged = 1; |
| 45 | 45 | |
| 46 | - if ( $pagination ) { |
|
| 47 | - if ( get_query_var( 'paged' ) ) { |
|
| 48 | - $paged = get_query_var( 'paged' ); |
|
| 49 | - } elseif ( get_query_var( 'page' ) ) { |
|
| 50 | - $paged = get_query_var( 'page' ); |
|
| 46 | + if ($pagination) { |
|
| 47 | + if (get_query_var('paged')) { |
|
| 48 | + $paged = get_query_var('paged'); |
|
| 49 | + } elseif (get_query_var('page')) { |
|
| 50 | + $paged = get_query_var('page'); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $args = apply_filters( 'give_get_users_donations_args', array( |
|
| 54 | + $args = apply_filters('give_get_users_donations_args', array( |
|
| 55 | 55 | 'user' => $user, |
| 56 | 56 | 'number' => $number, |
| 57 | 57 | 'status' => $status, |
| 58 | 58 | 'orderby' => 'date', |
| 59 | - ) ); |
|
| 59 | + )); |
|
| 60 | 60 | |
| 61 | - if ( $pagination ) { |
|
| 61 | + if ($pagination) { |
|
| 62 | 62 | $args['page'] = $paged; |
| 63 | 63 | } else { |
| 64 | 64 | $args['nopaging'] = true; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
| 68 | - $donor = new Give_Donor( $user, $by_user_id ); |
|
| 67 | + $by_user_id = is_numeric($user) ? true : false; |
|
| 68 | + $donor = new Give_Donor($user, $by_user_id); |
|
| 69 | 69 | |
| 70 | - if ( ! empty( $donor->payment_ids ) ) { |
|
| 70 | + if ( ! empty($donor->payment_ids)) { |
|
| 71 | 71 | |
| 72 | - unset( $args['user'] ); |
|
| 73 | - $args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) ); |
|
| 72 | + unset($args['user']); |
|
| 73 | + $args['post__in'] = array_map('absint', explode(',', $donor->payment_ids)); |
|
| 74 | 74 | |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
| 77 | + $donations = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
| 78 | 78 | |
| 79 | 79 | // No donations |
| 80 | - if ( ! $donations ) { |
|
| 80 | + if ( ! $donations) { |
|
| 81 | 81 | return false; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -96,65 +96,65 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @return bool|object List of unique forms donated by user |
| 98 | 98 | */ |
| 99 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
| 100 | - if ( empty( $user ) ) { |
|
| 99 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
| 100 | + if (empty($user)) { |
|
| 101 | 101 | $user = get_current_user_id(); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - if ( empty( $user ) ) { |
|
| 104 | + if (empty($user)) { |
|
| 105 | 105 | return false; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
| 108 | + $by_user_id = is_numeric($user) ? true : false; |
|
| 109 | 109 | |
| 110 | - $donor = new Give_Donor( $user, $by_user_id ); |
|
| 110 | + $donor = new Give_Donor($user, $by_user_id); |
|
| 111 | 111 | |
| 112 | - if ( empty( $donor->payment_ids ) ) { |
|
| 112 | + if (empty($donor->payment_ids)) { |
|
| 113 | 113 | return false; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // Get all the items donated. |
| 117 | - $payment_ids = array_reverse( explode( ',', $donor->payment_ids ) ); |
|
| 118 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
| 119 | - if ( ! empty( $limit_payments ) ) { |
|
| 120 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
| 117 | + $payment_ids = array_reverse(explode(',', $donor->payment_ids)); |
|
| 118 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
| 119 | + if ( ! empty($limit_payments)) { |
|
| 120 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
| 121 | 121 | } |
| 122 | 122 | $donation_data = array(); |
| 123 | - foreach ( $payment_ids as $payment_id ) { |
|
| 124 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
| 123 | + foreach ($payment_ids as $payment_id) { |
|
| 124 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if ( empty( $donation_data ) ) { |
|
| 127 | + if (empty($donation_data)) { |
|
| 128 | 128 | return false; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // Grab only the post ids "form_id" of the forms donated on this order |
| 132 | 132 | $completed_donations_ids = array(); |
| 133 | - foreach ( $donation_data as $donation_meta ) { |
|
| 134 | - $completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : ''; |
|
| 133 | + foreach ($donation_data as $donation_meta) { |
|
| 134 | + $completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : ''; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if ( empty( $completed_donations_ids ) ) { |
|
| 137 | + if (empty($completed_donations_ids)) { |
|
| 138 | 138 | return false; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // Only include each donation once |
| 142 | - $form_ids = array_unique( $completed_donations_ids ); |
|
| 142 | + $form_ids = array_unique($completed_donations_ids); |
|
| 143 | 143 | |
| 144 | 144 | // Make sure we still have some products and a first item |
| 145 | - if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
| 145 | + if (empty($form_ids) || ! isset($form_ids[0])) { |
|
| 146 | 146 | return false; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - $post_type = get_post_type( $form_ids[0] ); |
|
| 149 | + $post_type = get_post_type($form_ids[0]); |
|
| 150 | 150 | |
| 151 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
| 151 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
| 152 | 152 | 'include' => $form_ids, |
| 153 | 153 | 'post_type' => $post_type, |
| 154 | - 'posts_per_page' => - 1, |
|
| 155 | - ) ); |
|
| 154 | + 'posts_per_page' => -1, |
|
| 155 | + )); |
|
| 156 | 156 | |
| 157 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
| 157 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
@@ -170,12 +170,12 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @return bool True if has donated, false other wise. |
| 172 | 172 | */ |
| 173 | -function give_has_donations( $user_id = null ) { |
|
| 174 | - if ( empty( $user_id ) ) { |
|
| 173 | +function give_has_donations($user_id = null) { |
|
| 174 | + if (empty($user_id)) { |
|
| 175 | 175 | $user_id = get_current_user_id(); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if ( give_get_users_donations( $user_id, 1 ) ) { |
|
| 178 | + if (give_get_users_donations($user_id, 1)) { |
|
| 179 | 179 | return true; // User has at least one donation. |
| 180 | 180 | } |
| 181 | 181 | |
@@ -196,23 +196,23 @@ discard block |
||
| 196 | 196 | * |
| 197 | 197 | * @return array |
| 198 | 198 | */ |
| 199 | -function give_get_donation_stats_by_user( $user = '' ) { |
|
| 199 | +function give_get_donation_stats_by_user($user = '') { |
|
| 200 | 200 | |
| 201 | 201 | $field = ''; |
| 202 | 202 | |
| 203 | - if ( is_email( $user ) ) { |
|
| 203 | + if (is_email($user)) { |
|
| 204 | 204 | $field = 'email'; |
| 205 | - } elseif ( is_numeric( $user ) ) { |
|
| 205 | + } elseif (is_numeric($user)) { |
|
| 206 | 206 | $field = 'user_id'; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - $stats = array(); |
|
| 210 | - $donor = Give()->donors->get_donor_by( $field, $user ); |
|
| 209 | + $stats = array(); |
|
| 210 | + $donor = Give()->donors->get_donor_by($field, $user); |
|
| 211 | 211 | |
| 212 | - if ( $donor ) { |
|
| 213 | - $donor = new Give_Donor( $donor->id ); |
|
| 214 | - $stats['purchases'] = absint( $donor->purchase_count ); |
|
| 215 | - $stats['total_spent'] = give_maybe_sanitize_amount( $donor->get_total_donation_amount() ); |
|
| 212 | + if ($donor) { |
|
| 213 | + $donor = new Give_Donor($donor->id); |
|
| 214 | + $stats['purchases'] = absint($donor->purchase_count); |
|
| 215 | + $stats['total_spent'] = give_maybe_sanitize_amount($donor->get_total_donation_amount()); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @since 1.7 |
| 222 | 222 | */ |
| 223 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
| 223 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
| 224 | 224 | |
| 225 | 225 | return $stats; |
| 226 | 226 | } |
@@ -238,21 +238,21 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @return int The total number of donations. |
| 240 | 240 | */ |
| 241 | -function give_count_donations_of_donor( $user = null ) { |
|
| 241 | +function give_count_donations_of_donor($user = null) { |
|
| 242 | 242 | |
| 243 | 243 | // Logged in? |
| 244 | - if ( empty( $user ) ) { |
|
| 244 | + if (empty($user)) { |
|
| 245 | 245 | $user = get_current_user_id(); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | // Email access? |
| 249 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
| 249 | + if (empty($user) && Give()->email_access->token_email) { |
|
| 250 | 250 | $user = Give()->email_access->token_email; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false; |
|
| 253 | + $stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false; |
|
| 254 | 254 | |
| 255 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
| 255 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -265,9 +265,9 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @return float The total amount the user has spent |
| 267 | 267 | */ |
| 268 | -function give_donation_total_of_user( $user = null ) { |
|
| 268 | +function give_donation_total_of_user($user = null) { |
|
| 269 | 269 | |
| 270 | - $stats = give_get_donation_stats_by_user( $user ); |
|
| 270 | + $stats = give_get_donation_stats_by_user($user); |
|
| 271 | 271 | |
| 272 | 272 | return $stats['total_spent']; |
| 273 | 273 | } |
@@ -283,40 +283,40 @@ discard block |
||
| 283 | 283 | * |
| 284 | 284 | * @return bool |
| 285 | 285 | */ |
| 286 | -function give_validate_username( $username, $form_id = 0 ) { |
|
| 286 | +function give_validate_username($username, $form_id = 0) { |
|
| 287 | 287 | $valid = true; |
| 288 | 288 | |
| 289 | 289 | // Validate username. |
| 290 | - if ( ! empty( $username ) ) { |
|
| 290 | + if ( ! empty($username)) { |
|
| 291 | 291 | |
| 292 | 292 | // Sanitize username. |
| 293 | - $sanitized_user_name = sanitize_user( $username, false ); |
|
| 293 | + $sanitized_user_name = sanitize_user($username, false); |
|
| 294 | 294 | |
| 295 | 295 | // We have an user name, check if it already exists. |
| 296 | - if ( username_exists( $username ) ) { |
|
| 296 | + if (username_exists($username)) { |
|
| 297 | 297 | // Username already registered. |
| 298 | - give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) ); |
|
| 298 | + give_set_error('username_unavailable', __('Username already taken.', 'give')); |
|
| 299 | 299 | $valid = false; |
| 300 | 300 | |
| 301 | 301 | // Check if it's valid. |
| 302 | - } elseif ( $sanitized_user_name !== $username ) { |
|
| 302 | + } elseif ($sanitized_user_name !== $username) { |
|
| 303 | 303 | // Invalid username. |
| 304 | - if ( is_multisite() ) { |
|
| 305 | - give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
| 304 | + if (is_multisite()) { |
|
| 305 | + give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
| 306 | 306 | $valid = false; |
| 307 | 307 | } else { |
| 308 | - give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) ); |
|
| 308 | + give_set_error('username_invalid', __('Invalid username.', 'give')); |
|
| 309 | 309 | $valid = false; |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | } else { |
| 313 | 313 | // Username is empty. |
| 314 | - give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) ); |
|
| 314 | + give_set_error('username_empty', __('Enter a username.', 'give')); |
|
| 315 | 315 | $valid = false; |
| 316 | 316 | |
| 317 | 317 | // Check if guest checkout is disable for form. |
| 318 | - if ( $form_id && give_logged_in_only( $form_id ) ) { |
|
| 319 | - give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
| 318 | + if ($form_id && give_logged_in_only($form_id)) { |
|
| 319 | + give_set_error('registration_required', __('You must register or login to complete your donation.', 'give')); |
|
| 320 | 320 | $valid = false; |
| 321 | 321 | } |
| 322 | 322 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * @param string $username |
| 331 | 331 | * @param bool $form_id |
| 332 | 332 | */ |
| 333 | - $valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id ); |
|
| 333 | + $valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id); |
|
| 334 | 334 | |
| 335 | 335 | return $valid; |
| 336 | 336 | } |
@@ -346,25 +346,25 @@ discard block |
||
| 346 | 346 | * |
| 347 | 347 | * @return bool |
| 348 | 348 | */ |
| 349 | -function give_validate_user_email( $email, $registering_new_user = false ) { |
|
| 349 | +function give_validate_user_email($email, $registering_new_user = false) { |
|
| 350 | 350 | $valid = true; |
| 351 | 351 | |
| 352 | - if ( empty( $email ) ) { |
|
| 352 | + if (empty($email)) { |
|
| 353 | 353 | // No email. |
| 354 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
| 354 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
| 355 | 355 | $valid = false; |
| 356 | 356 | |
| 357 | - } elseif ( ! is_email( $email ) ) { |
|
| 357 | + } elseif ( ! is_email($email)) { |
|
| 358 | 358 | // Validate email. |
| 359 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
| 359 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
| 360 | 360 | $valid = false; |
| 361 | 361 | |
| 362 | - } elseif ( $registering_new_user ) { |
|
| 362 | + } elseif ($registering_new_user) { |
|
| 363 | 363 | |
| 364 | 364 | // If donor email is not primary |
| 365 | - if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) { |
|
| 365 | + if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) { |
|
| 366 | 366 | // Check if email exists. |
| 367 | - give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) ); |
|
| 367 | + give_set_error('email_used', __('The email address provided is already active for another user.', 'give')); |
|
| 368 | 368 | $valid = false; |
| 369 | 369 | } |
| 370 | 370 | } |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * @param string $email |
| 379 | 379 | * @param bool $registering_new_user |
| 380 | 380 | */ |
| 381 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user ); |
|
| 381 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user); |
|
| 382 | 382 | |
| 383 | 383 | return $valid; |
| 384 | 384 | } |
@@ -394,34 +394,34 @@ discard block |
||
| 394 | 394 | * |
| 395 | 395 | * @return bool |
| 396 | 396 | */ |
| 397 | -function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) { |
|
| 397 | +function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) { |
|
| 398 | 398 | $valid = true; |
| 399 | 399 | |
| 400 | 400 | // Passwords Validation For New Donors Only |
| 401 | - if ( $registering_new_user ) { |
|
| 401 | + if ($registering_new_user) { |
|
| 402 | 402 | // Password or confirmation missing. |
| 403 | - if ( ! $password ) { |
|
| 403 | + if ( ! $password) { |
|
| 404 | 404 | // The password is invalid. |
| 405 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
| 405 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
| 406 | 406 | $valid = false; |
| 407 | - } elseif ( ! $confirm_password ) { |
|
| 407 | + } elseif ( ! $confirm_password) { |
|
| 408 | 408 | // Confirmation password is invalid. |
| 409 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) ); |
|
| 409 | + give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give')); |
|
| 410 | 410 | $valid = false; |
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | // Passwords Validation For New Donors as well as Existing Donors |
| 414 | - if ( $password || $confirm_password ) { |
|
| 415 | - if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) { |
|
| 414 | + if ($password || $confirm_password) { |
|
| 415 | + if (strlen($password) < 6 || strlen($confirm_password) < 6) { |
|
| 416 | 416 | // Seems Weak Password |
| 417 | - give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) ); |
|
| 417 | + give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give')); |
|
| 418 | 418 | $valid = false; |
| 419 | 419 | } |
| 420 | - if ( $password && $confirm_password ) { |
|
| 420 | + if ($password && $confirm_password) { |
|
| 421 | 421 | // Verify confirmation matches. |
| 422 | - if ( $password != $confirm_password ) { |
|
| 422 | + if ($password != $confirm_password) { |
|
| 423 | 423 | // Passwords do not match |
| 424 | - give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) ); |
|
| 424 | + give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give')); |
|
| 425 | 425 | $valid = false; |
| 426 | 426 | } |
| 427 | 427 | } |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | * @param string $confirm_password |
| 438 | 438 | * @param bool $registering_new_user |
| 439 | 439 | */ |
| 440 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user ); |
|
| 440 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); |
|
| 441 | 441 | |
| 442 | 442 | return $valid; |
| 443 | 443 | } |
@@ -455,20 +455,20 @@ discard block |
||
| 455 | 455 | * |
| 456 | 456 | * @return void |
| 457 | 457 | */ |
| 458 | -function give_add_past_donations_to_new_user( $user_id ) { |
|
| 458 | +function give_add_past_donations_to_new_user($user_id) { |
|
| 459 | 459 | |
| 460 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
| 460 | + $email = get_the_author_meta('user_email', $user_id); |
|
| 461 | 461 | |
| 462 | - $payments = give_get_payments( array( |
|
| 462 | + $payments = give_get_payments(array( |
|
| 463 | 463 | 'output' => 'payments', |
| 464 | 464 | 's' => $email, |
| 465 | - ) ); |
|
| 465 | + )); |
|
| 466 | 466 | |
| 467 | - if ( $payments ) { |
|
| 468 | - foreach ( $payments as $payment ) { |
|
| 467 | + if ($payments) { |
|
| 468 | + foreach ($payments as $payment) { |
|
| 469 | 469 | /* @var $payment \Give_Payment */ |
| 470 | 470 | |
| 471 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
| 471 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
| 472 | 472 | continue; |
| 473 | 473 | } |
| 474 | 474 | |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | -add_action( 'user_register', 'give_add_past_donations_to_new_user' ); |
|
| 483 | +add_action('user_register', 'give_add_past_donations_to_new_user'); |
|
| 484 | 484 | |
| 485 | 485 | |
| 486 | 486 | /** |
@@ -506,34 +506,34 @@ discard block |
||
| 506 | 506 | * |
| 507 | 507 | * @return array The donor's address, if any |
| 508 | 508 | */ |
| 509 | -function give_get_donor_address( $user_id = 0 ) { |
|
| 510 | - if ( empty( $user_id ) ) { |
|
| 509 | +function give_get_donor_address($user_id = 0) { |
|
| 510 | + if (empty($user_id)) { |
|
| 511 | 511 | $user_id = get_current_user_id(); |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - $address = (array) get_user_meta( $user_id, '_give_user_address', true ); |
|
| 514 | + $address = (array) get_user_meta($user_id, '_give_user_address', true); |
|
| 515 | 515 | |
| 516 | - if ( ! isset( $address['line1'] ) ) { |
|
| 516 | + if ( ! isset($address['line1'])) { |
|
| 517 | 517 | $address['line1'] = ''; |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - if ( ! isset( $address['line2'] ) ) { |
|
| 520 | + if ( ! isset($address['line2'])) { |
|
| 521 | 521 | $address['line2'] = ''; |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | - if ( ! isset( $address['city'] ) ) { |
|
| 524 | + if ( ! isset($address['city'])) { |
|
| 525 | 525 | $address['city'] = ''; |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - if ( ! isset( $address['zip'] ) ) { |
|
| 528 | + if ( ! isset($address['zip'])) { |
|
| 529 | 529 | $address['zip'] = ''; |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - if ( ! isset( $address['country'] ) ) { |
|
| 532 | + if ( ! isset($address['country'])) { |
|
| 533 | 533 | $address['country'] = ''; |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - if ( ! isset( $address['state'] ) ) { |
|
| 536 | + if ( ! isset($address['state'])) { |
|
| 537 | 537 | $address['state'] = ''; |
| 538 | 538 | } |
| 539 | 539 | |
@@ -553,53 +553,53 @@ discard block |
||
| 553 | 553 | * |
| 554 | 554 | * @return void |
| 555 | 555 | */ |
| 556 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
| 556 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
| 557 | 557 | |
| 558 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
| 558 | + if (empty($user_id) || empty($user_data)) { |
|
| 559 | 559 | return; |
| 560 | 560 | } |
| 561 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
| 561 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
| 562 | 562 | |
| 563 | 563 | // New User Registration: Email sends to the site admin. |
| 564 | 564 | $emails = Give()->emails; |
| 565 | - $emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) ); |
|
| 565 | + $emails->__set('heading', esc_html__('New User Registration', 'give')); |
|
| 566 | 566 | |
| 567 | 567 | /* translators: %s: site name */ |
| 568 | - $message = sprintf( esc_attr__( 'A new user has registered on %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
| 568 | + $message = sprintf(esc_attr__('A new user has registered on %s:', 'give'), $blogname)."\r\n\r\n"; |
|
| 569 | 569 | /* translators: %s: user login */ |
| 570 | - $message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n"; |
|
| 570 | + $message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n"; |
|
| 571 | 571 | /* translators: %s: user email */ |
| 572 | - $message .= '<strong>' . esc_attr__( 'E-mail:', 'give' ) . '</strong> ' . $user_data['user_email'] . "\r\n\r\n"; |
|
| 572 | + $message .= '<strong>'.esc_attr__('E-mail:', 'give').'</strong> '.$user_data['user_email']."\r\n\r\n"; |
|
| 573 | 573 | |
| 574 | - $message .= '<a href="' . admin_url( 'user-edit.php?user_id=' . $user_id ) . '" target="_blank"> ' . esc_attr__( 'Click here to view »', 'give' ) . '</a>' . "\r\n"; |
|
| 574 | + $message .= '<a href="'.admin_url('user-edit.php?user_id='.$user_id).'" target="_blank"> '.esc_attr__('Click here to view »', 'give').'</a>'."\r\n"; |
|
| 575 | 575 | |
| 576 | 576 | $emails->send( |
| 577 | - get_option( 'admin_email' ), |
|
| 577 | + get_option('admin_email'), |
|
| 578 | 578 | sprintf( |
| 579 | 579 | /* translators: %s: site name */ |
| 580 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
| 580 | + esc_attr__('[%s] New User Registration', 'give'), |
|
| 581 | 581 | $blogname |
| 582 | 582 | ), |
| 583 | 583 | $message |
| 584 | 584 | ); |
| 585 | 585 | |
| 586 | 586 | // Account Information: Email sends to donor who registered. |
| 587 | - $emails->__set( 'heading', esc_html__( 'Account Information', 'give' ) ); |
|
| 587 | + $emails->__set('heading', esc_html__('Account Information', 'give')); |
|
| 588 | 588 | |
| 589 | - $message = sprintf( esc_attr__( 'The following email contains your account information for %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
| 589 | + $message = sprintf(esc_attr__('The following email contains your account information for %s:', 'give'), $blogname)."\r\n\r\n"; |
|
| 590 | 590 | |
| 591 | 591 | /* translators: %s: user login */ |
| 592 | - $message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n"; |
|
| 592 | + $message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n"; |
|
| 593 | 593 | /* translators: %s: password */ |
| 594 | - $message .= '<strong>' . esc_attr__( 'Password:', 'give' ) . '</strong> ' . esc_attr__( '[Password entered during donation]', 'give' ) . "\r\n\r\n"; |
|
| 594 | + $message .= '<strong>'.esc_attr__('Password:', 'give').'</strong> '.esc_attr__('[Password entered during donation]', 'give')."\r\n\r\n"; |
|
| 595 | 595 | |
| 596 | - $message .= '<a href="' . wp_login_url() . '" target="_blank"> ' . esc_attr__( 'Click here to login »', 'give' ) . '</a>' . "\r\n"; |
|
| 596 | + $message .= '<a href="'.wp_login_url().'" target="_blank"> '.esc_attr__('Click here to login »', 'give').'</a>'."\r\n"; |
|
| 597 | 597 | |
| 598 | 598 | $emails->send( |
| 599 | 599 | $user_data['user_email'], |
| 600 | 600 | sprintf( |
| 601 | 601 | /* translators: %s: site name */ |
| 602 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
| 602 | + esc_attr__('[%s] Your username and password', 'give'), |
|
| 603 | 603 | $blogname |
| 604 | 604 | ), |
| 605 | 605 | $message |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
| 610 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
| 611 | 611 | |
| 612 | 612 | |
| 613 | 613 | /** |
@@ -623,34 +623,34 @@ discard block |
||
| 623 | 623 | * |
| 624 | 624 | * @return string |
| 625 | 625 | */ |
| 626 | -function give_get_donor_name_by( $id = 0, $from = 'donation' ) { |
|
| 626 | +function give_get_donor_name_by($id = 0, $from = 'donation') { |
|
| 627 | 627 | |
| 628 | 628 | // ID shouldn't be empty |
| 629 | - if ( empty( $id ) ) { |
|
| 629 | + if (empty($id)) { |
|
| 630 | 630 | return; |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | $name = ''; |
| 634 | 634 | |
| 635 | - switch ( $from ) { |
|
| 635 | + switch ($from) { |
|
| 636 | 636 | |
| 637 | 637 | case 'donation': |
| 638 | 638 | |
| 639 | - $user_info = give_get_payment_meta_user_info( $id ); |
|
| 640 | - $name = trim( "{$user_info['first_name']} {$user_info['last_name']}" ); |
|
| 639 | + $user_info = give_get_payment_meta_user_info($id); |
|
| 640 | + $name = trim("{$user_info['first_name']} {$user_info['last_name']}"); |
|
| 641 | 641 | |
| 642 | 642 | break; |
| 643 | 643 | |
| 644 | 644 | case 'donor': |
| 645 | 645 | |
| 646 | - $donor = new Give_Donor( $id ); |
|
| 646 | + $donor = new Give_Donor($id); |
|
| 647 | 647 | $name = $donor->name; |
| 648 | 648 | |
| 649 | 649 | break; |
| 650 | 650 | |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - return trim( $name ); |
|
| 653 | + return trim($name); |
|
| 654 | 654 | |
| 655 | 655 | } |
| 656 | 656 | |
@@ -662,8 +662,8 @@ discard block |
||
| 662 | 662 | * @param string $email Donor Email. |
| 663 | 663 | * @return boolean The user's ID on success, and false on failure. |
| 664 | 664 | */ |
| 665 | -function give_donor_email_exists( $email ) { |
|
| 666 | - if ( Give()->donors->get_donor_by( 'email', $email ) ) { |
|
| 665 | +function give_donor_email_exists($email) { |
|
| 666 | + if (Give()->donors->get_donor_by('email', $email)) { |
|
| 667 | 667 | return true; |
| 668 | 668 | } |
| 669 | 669 | return false; |
@@ -678,12 +678,12 @@ discard block |
||
| 678 | 678 | * |
| 679 | 679 | * @return bool |
| 680 | 680 | */ |
| 681 | -function give_is_additional_email( $email ) { |
|
| 681 | +function give_is_additional_email($email) { |
|
| 682 | 682 | global $wpdb; |
| 683 | - $meta_table = Give()->donor_meta->table_name; |
|
| 684 | - $donor_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) ); |
|
| 683 | + $meta_table = Give()->donor_meta->table_name; |
|
| 684 | + $donor_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email)); |
|
| 685 | 685 | |
| 686 | - if ( empty( $donor_id ) ) { |
|
| 686 | + if (empty($donor_id)) { |
|
| 687 | 687 | return false; |
| 688 | 688 | } |
| 689 | 689 | return true; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @return mixed array if errors are present, false if none found |
| 26 | 26 | */ |
| 27 | 27 | function give_get_errors() { |
| 28 | - return Give()->session->get( 'give_errors' ); |
|
| 28 | + return Give()->session->get('give_errors'); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -42,23 +42,23 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | -function give_set_error( $error_id, $error_message, $notice_args = array() ) { |
|
| 45 | +function give_set_error($error_id, $error_message, $notice_args = array()) { |
|
| 46 | 46 | $errors = give_get_errors(); |
| 47 | - if ( ! $errors ) { |
|
| 47 | + if ( ! $errors) { |
|
| 48 | 48 | $errors = array(); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if( is_array( $notice_args ) && ! empty( $notice_args ) ) { |
|
| 52 | - $errors[ $error_id ] = array( |
|
| 51 | + if (is_array($notice_args) && ! empty($notice_args)) { |
|
| 52 | + $errors[$error_id] = array( |
|
| 53 | 53 | 'message' => $error_message, |
| 54 | 54 | 'notice_args' => $notice_args, |
| 55 | 55 | ); |
| 56 | 56 | } else { |
| 57 | 57 | // Backward compatibility v<1.8.11. |
| 58 | - $errors[ $error_id ] = $error_message; |
|
| 58 | + $errors[$error_id] = $error_message; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - Give()->session->set( 'give_errors', $errors ); |
|
| 61 | + Give()->session->set('give_errors', $errors); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @return void |
| 70 | 70 | */ |
| 71 | 71 | function give_clear_errors() { |
| 72 | - Give()->session->set( 'give_errors', null ); |
|
| 72 | + Give()->session->set('give_errors', null); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -82,19 +82,19 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return void |
| 84 | 84 | */ |
| 85 | -function give_unset_error( $error_id ) { |
|
| 85 | +function give_unset_error($error_id) { |
|
| 86 | 86 | $errors = give_get_errors(); |
| 87 | - if ( $errors ) { |
|
| 87 | + if ($errors) { |
|
| 88 | 88 | /** |
| 89 | 89 | * Check If $error_id exists in the array. |
| 90 | 90 | * If exists then unset it. |
| 91 | 91 | * |
| 92 | 92 | * @since 1.8.13 |
| 93 | 93 | */ |
| 94 | - if ( isset( $errors[ $error_id ] ) ) { |
|
| 95 | - unset( $errors[ $error_id ] ); |
|
| 94 | + if (isset($errors[$error_id])) { |
|
| 95 | + unset($errors[$error_id]); |
|
| 96 | 96 | } |
| 97 | - Give()->session->set( 'give_errors', $errors ); |
|
| 97 | + Give()->session->set('give_errors', $errors); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | 107 | function _give_die_handler() { |
| 108 | - if ( defined( 'GIVE_UNIT_TESTS' ) ) { |
|
| 108 | + if (defined('GIVE_UNIT_TESTS')) { |
|
| 109 | 109 | return '_give_die_handler'; |
| 110 | 110 | } else { |
| 111 | 111 | die(); |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return void |
| 127 | 127 | */ |
| 128 | -function give_die( $message = '', $title = '', $status = 400 ) { |
|
| 129 | - add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 ); |
|
| 130 | - add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 ); |
|
| 131 | - wp_die( $message, $title, array( 'response' => $status ) ); |
|
| 128 | +function give_die($message = '', $title = '', $status = 400) { |
|
| 129 | + add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3); |
|
| 130 | + add_filter('wp_die_handler', '_give_die_handler', 10, 3); |
|
| 131 | + wp_die($message, $title, array('response' => $status)); |
|
| 132 | 132 | } |