@@ -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 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
| 87 | 87 | */ |
| 88 | - public function __construct( $args = array() ) { |
|
| 88 | + public function __construct($args = array()) { |
|
| 89 | 89 | $defaults = array( |
| 90 | 90 | 'number' => 20, |
| 91 | 91 | 'offset' => 0, |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | // 'form' => array(), |
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | - $this->args = wp_parse_args( $args, $defaults ); |
|
| 106 | + $this->args = wp_parse_args($args, $defaults); |
|
| 107 | 107 | |
| 108 | 108 | $this->table_name = Give()->donors->table_name; |
| 109 | 109 | $this->meta_table_name = Give()->donor_meta->table_name; |
@@ -146,12 +146,12 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @param Give_Donors_Query $this Donors query object. |
| 148 | 148 | */ |
| 149 | - do_action( 'give_pre_get_donors', $this ); |
|
| 149 | + do_action('give_pre_get_donors', $this); |
|
| 150 | 150 | |
| 151 | - if ( empty( $this->args['count'] ) ) { |
|
| 152 | - $this->donors = $wpdb->get_results( $this->get_sql() ); |
|
| 151 | + if (empty($this->args['count'])) { |
|
| 152 | + $this->donors = $wpdb->get_results($this->get_sql()); |
|
| 153 | 153 | } else { |
| 154 | - $this->donors = $wpdb->get_var( $this->get_sql() ); |
|
| 154 | + $this->donors = $wpdb->get_var($this->get_sql()); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * |
| 162 | 162 | * @param Give_Donors_Query $this Donors query object. |
| 163 | 163 | */ |
| 164 | - do_action( 'give_post_get_donors', $this ); |
|
| 164 | + do_action('give_post_get_donors', $this); |
|
| 165 | 165 | |
| 166 | 166 | return $this->donors; |
| 167 | 167 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | public function get_sql() { |
| 179 | 179 | global $wpdb; |
| 180 | 180 | |
| 181 | - if ( $this->args['number'] < 1 ) { |
|
| 181 | + if ($this->args['number'] < 1) { |
|
| 182 | 182 | $this->args['number'] = 999999999999; |
| 183 | 183 | } |
| 184 | 184 | |
@@ -186,22 +186,22 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | |
| 188 | 188 | // Set offset. |
| 189 | - if ( empty( $this->args['offset'] ) && ( 0 < $this->args['paged'] ) ) { |
|
| 190 | - $this->args['offset'] = $this->args['number'] * ( $this->args['paged'] - 1 ); |
|
| 189 | + if (empty($this->args['offset']) && (0 < $this->args['paged'])) { |
|
| 190 | + $this->args['offset'] = $this->args['number'] * ($this->args['paged'] - 1); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | // Set fields. |
| 194 | 194 | $fields = "{$this->table_name}.*"; |
| 195 | - if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) { |
|
| 196 | - if ( is_string( $this->args['fields'] ) ) { |
|
| 195 | + if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) { |
|
| 196 | + if (is_string($this->args['fields'])) { |
|
| 197 | 197 | $fields = "{$this->table_name}.{$this->args['fields']}"; |
| 198 | - } else if ( is_array( $this->args['fields'] ) ) { |
|
| 199 | - $fields = "{$this->table_name}." . implode( " , {$this->table_name}.", $this->args['fields'] ); |
|
| 198 | + } else if (is_array($this->args['fields'])) { |
|
| 199 | + $fields = "{$this->table_name}.".implode(" , {$this->table_name}.", $this->args['fields']); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // Set count. |
| 204 | - if ( ! empty( $this->args['count'] ) ) { |
|
| 204 | + if ( ! empty($this->args['count'])) { |
|
| 205 | 205 | $fields = "COUNT({$this->table_name}.id)"; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -209,8 +209,8 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | return $wpdb->prepare( |
| 211 | 211 | "SELECT {$fields} FROM {$this->table_name} {$where} {$orderby} {$this->args['order']} LIMIT %d,%d;", |
| 212 | - absint( $this->args['offset'] ), |
|
| 213 | - absint( $this->args['number'] ) |
|
| 212 | + absint($this->args['offset']), |
|
| 213 | + absint($this->args['number']) |
|
| 214 | 214 | ); |
| 215 | 215 | } |
| 216 | 216 | |
@@ -227,14 +227,14 @@ discard block |
||
| 227 | 227 | $where = ''; |
| 228 | 228 | |
| 229 | 229 | // Get sql query for meta. |
| 230 | - if ( ! empty( $this->args['meta_query'] ) ) { |
|
| 231 | - $meta_query_object = new WP_Meta_Query( $this->args['meta_query'] ); |
|
| 230 | + if ( ! empty($this->args['meta_query'])) { |
|
| 231 | + $meta_query_object = new WP_Meta_Query($this->args['meta_query']); |
|
| 232 | 232 | $meta_query = $meta_query_object->get_sql( |
| 233 | 233 | $this->meta_type, |
| 234 | 234 | $this->table_name, |
| 235 | 235 | 'id' |
| 236 | 236 | ); |
| 237 | - $where = implode( '', $meta_query ); |
|
| 237 | + $where = implode('', $meta_query); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | $where .= 'WHERE 1=1'; |
@@ -261,17 +261,17 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | $where = ''; |
| 263 | 263 | |
| 264 | - if ( ! empty( $this->args['email'] ) ) { |
|
| 264 | + if ( ! empty($this->args['email'])) { |
|
| 265 | 265 | |
| 266 | - if ( is_array( $this->args['email'] ) ) { |
|
| 266 | + if (is_array($this->args['email'])) { |
|
| 267 | 267 | |
| 268 | - $emails_count = count( $this->args['email'] ); |
|
| 269 | - $emails_placeholder = array_fill( 0, $emails_count, '%s' ); |
|
| 270 | - $emails = implode( ', ', $emails_placeholder ); |
|
| 268 | + $emails_count = count($this->args['email']); |
|
| 269 | + $emails_placeholder = array_fill(0, $emails_count, '%s'); |
|
| 270 | + $emails = implode(', ', $emails_placeholder); |
|
| 271 | 271 | |
| 272 | - $where .= $wpdb->prepare( " AND {$this->table_name}.email IN( $emails ) ", $this->args['email'] ); |
|
| 272 | + $where .= $wpdb->prepare(" AND {$this->table_name}.email IN( $emails ) ", $this->args['email']); |
|
| 273 | 273 | } else { |
| 274 | - $where .= $wpdb->prepare( " AND {$this->table_name}.email = %s ", $this->args['email'] ); |
|
| 274 | + $where .= $wpdb->prepare(" AND {$this->table_name}.email = %s ", $this->args['email']); |
|
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | |
@@ -291,11 +291,11 @@ discard block |
||
| 291 | 291 | $where = ''; |
| 292 | 292 | |
| 293 | 293 | // Specific donors. |
| 294 | - if ( ! empty( $this->args['donor'] ) ) { |
|
| 295 | - if ( ! is_array( $this->args['donor'] ) ) { |
|
| 296 | - $this->args['donor'] = explode( ',', $this->args['donor'] ); |
|
| 294 | + if ( ! empty($this->args['donor'])) { |
|
| 295 | + if ( ! is_array($this->args['donor'])) { |
|
| 296 | + $this->args['donor'] = explode(',', $this->args['donor']); |
|
| 297 | 297 | } |
| 298 | - $log_ids = implode( ',', array_map( 'intval', $this->args['donor'] ) ); |
|
| 298 | + $log_ids = implode(',', array_map('intval', $this->args['donor'])); |
|
| 299 | 299 | |
| 300 | 300 | $where .= " AND {$this->table_name}.id IN( {$log_ids} ) "; |
| 301 | 301 | } |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | $where = ''; |
| 317 | 317 | |
| 318 | 318 | // Donors created for a specific date or in a date range |
| 319 | - if ( ! empty( $this->args['date_query'] ) ) { |
|
| 319 | + if ( ! empty($this->args['date_query'])) { |
|
| 320 | 320 | $date_query_object = new WP_Date_Query( |
| 321 | 321 | $this->args['date_query'], |
| 322 | 322 | "{$this->table_name}.date_created" |
@@ -341,11 +341,11 @@ discard block |
||
| 341 | 341 | $where = ''; |
| 342 | 342 | |
| 343 | 343 | // Donors created for a specific date or in a date range |
| 344 | - if ( ! empty( $this->args['s'] ) && false !== strpos( $this->args['s'], ':' ) ) { |
|
| 345 | - $search_parts = explode( ':', $this->args['s'] ); |
|
| 344 | + if ( ! empty($this->args['s']) && false !== strpos($this->args['s'], ':')) { |
|
| 345 | + $search_parts = explode(':', $this->args['s']); |
|
| 346 | 346 | |
| 347 | - if ( ! empty( $search_parts[0] ) ) { |
|
| 348 | - switch ( $search_parts[0] ) { |
|
| 347 | + if ( ! empty($search_parts[0])) { |
|
| 348 | + switch ($search_parts[0]) { |
|
| 349 | 349 | case 'name': |
| 350 | 350 | $where = " AND {$this->table_name}.name LIKE '%{$search_parts[1]}%' "; |
| 351 | 351 | break; |
@@ -373,11 +373,11 @@ discard block |
||
| 373 | 373 | $where = ''; |
| 374 | 374 | |
| 375 | 375 | // Donors create for specific wp user. |
| 376 | - if ( ! empty( $this->args['user'] ) ) { |
|
| 377 | - if ( ! is_array( $this->args['user'] ) ) { |
|
| 378 | - $this->args['user'] = explode( ',', $this->args['user'] ); |
|
| 376 | + if ( ! empty($this->args['user'])) { |
|
| 377 | + if ( ! is_array($this->args['user'])) { |
|
| 378 | + $this->args['user'] = explode(',', $this->args['user']); |
|
| 379 | 379 | } |
| 380 | - $user_ids = implode( ',', array_map( 'intval', $this->args['user'] ) ); |
|
| 380 | + $user_ids = implode(',', array_map('intval', $this->args['user'])); |
|
| 381 | 381 | |
| 382 | 382 | $where .= " AND {$this->table_name}.user_id IN( {$user_ids} ) "; |
| 383 | 383 | } |
@@ -396,14 +396,13 @@ discard block |
||
| 396 | 396 | private function get_order_query() { |
| 397 | 397 | $table_columns = Give()->donors->get_columns(); |
| 398 | 398 | |
| 399 | - $this->args['orderby'] = ! array_key_exists( $this->args['orderby'], $table_columns ) ? |
|
| 400 | - 'id' : |
|
| 401 | - $this->args['orderby']; |
|
| 399 | + $this->args['orderby'] = ! array_key_exists($this->args['orderby'], $table_columns) ? |
|
| 400 | + 'id' : $this->args['orderby']; |
|
| 402 | 401 | |
| 403 | - $this->args['orderby'] = esc_sql( $this->args['orderby'] ); |
|
| 404 | - $this->args['order'] = esc_sql( $this->args['order'] ); |
|
| 402 | + $this->args['orderby'] = esc_sql($this->args['orderby']); |
|
| 403 | + $this->args['order'] = esc_sql($this->args['order']); |
|
| 405 | 404 | |
| 406 | - switch ( $table_columns[ $this->args['orderby'] ] ) { |
|
| 405 | + switch ($table_columns[$this->args['orderby']]) { |
|
| 407 | 406 | case '%d': |
| 408 | 407 | case '%f': |
| 409 | 408 | $query = "ORDER BY {$this->table_name}.{$this->args['orderby']}+0"; |
@@ -134,9 +134,9 @@ |
||
| 134 | 134 | // Handle thousand separator as '.' |
| 135 | 135 | // Handle sanitize database values. |
| 136 | 136 | $is_db_sanitize_val = ( 2 === count( $number_parts ) && |
| 137 | - is_numeric( $number_parts[0] ) && |
|
| 138 | - is_numeric( $number_parts[1] ) && |
|
| 139 | - ( 6 === strlen( $number_parts[1] ) ) ); |
|
| 137 | + is_numeric( $number_parts[0] ) && |
|
| 138 | + is_numeric( $number_parts[1] ) && |
|
| 139 | + ( 6 === strlen( $number_parts[1] ) ) ); |
|
| 140 | 140 | |
| 141 | 141 | if ( $is_db_sanitize_val ) { |
| 142 | 142 | // Sanitize database value. |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @return mixed |
| 24 | 24 | */ |
| 25 | 25 | function give_get_price_decimals() { |
| 26 | - return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
| 26 | + return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0)); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function give_get_price_thousand_separator() { |
| 37 | 37 | $give_options = give_get_settings(); |
| 38 | - $thousand_separator = isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ','; |
|
| 39 | - $thousand_separator = empty( $thousand_separator ) ? ' ' : $thousand_separator; |
|
| 38 | + $thousand_separator = isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ','; |
|
| 39 | + $thousand_separator = empty($thousand_separator) ? ' ' : $thousand_separator; |
|
| 40 | 40 | |
| 41 | 41 | return $thousand_separator; |
| 42 | 42 | } |
@@ -55,11 +55,10 @@ discard block |
||
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | 57 | $thousand_separator = give_get_price_thousand_separator(); |
| 58 | - $default_decimal_separator = in_array( $thousand_separator, $default_decimal_separators ) ? |
|
| 59 | - $default_decimal_separators[$thousand_separator] : |
|
| 60 | - '.'; |
|
| 58 | + $default_decimal_separator = in_array($thousand_separator, $default_decimal_separators) ? |
|
| 59 | + $default_decimal_separators[$thousand_separator] : '.'; |
|
| 61 | 60 | |
| 62 | - $decimal_separator = give_get_option( 'decimal_separator', $default_decimal_separator ); |
|
| 61 | + $decimal_separator = give_get_option('decimal_separator', $default_decimal_separator); |
|
| 63 | 62 | |
| 64 | 63 | return $decimal_separator; |
| 65 | 64 | } |
@@ -74,8 +73,8 @@ discard block |
||
| 74 | 73 | * |
| 75 | 74 | * @return string $amount Newly sanitized amount |
| 76 | 75 | */ |
| 77 | -function give_sanitize_amount_for_db( $number ) { |
|
| 78 | - return give_maybe_sanitize_amount( $number, 6 ); |
|
| 76 | +function give_sanitize_amount_for_db($number) { |
|
| 77 | + return give_maybe_sanitize_amount($number, 6); |
|
| 79 | 78 | } |
| 80 | 79 | |
| 81 | 80 | /** |
@@ -89,29 +88,29 @@ discard block |
||
| 89 | 88 | * |
| 90 | 89 | * @return string $amount Newly sanitized amount |
| 91 | 90 | */ |
| 92 | -function give_maybe_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
|
| 91 | +function give_maybe_sanitize_amount($number, $dp = false, $trim_zeros = false) { |
|
| 93 | 92 | $thousand_separator = give_get_price_thousand_separator(); |
| 94 | 93 | $decimal_separator = give_get_price_decimal_separator(); |
| 95 | - $number_decimals = is_bool( $dp ) ? give_get_price_decimals() : $dp; |
|
| 94 | + $number_decimals = is_bool($dp) ? give_get_price_decimals() : $dp; |
|
| 96 | 95 | |
| 97 | 96 | // Explode number by . decimal separator. |
| 98 | - $number_parts = explode( '.', $number ); |
|
| 97 | + $number_parts = explode('.', $number); |
|
| 99 | 98 | |
| 100 | 99 | /* |
| 101 | 100 | * Bailout: Quick format number |
| 102 | 101 | */ |
| 103 | - if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
|
| 102 | + if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) { |
|
| 104 | 103 | return $number; |
| 105 | 104 | } |
| 106 | 105 | |
| 107 | 106 | // Remove currency symbols from number if any. |
| 108 | - $number = trim( str_replace( give_currency_symbols( true ), '', $number ) ); |
|
| 107 | + $number = trim(str_replace(give_currency_symbols(true), '', $number)); |
|
| 109 | 108 | |
| 110 | 109 | if ( |
| 111 | 110 | // Non formatted number. |
| 112 | 111 | ( |
| 113 | - ( false === strpos( $number, $thousand_separator ) ) && |
|
| 114 | - ( false === strpos( $number, $decimal_separator ) ) |
|
| 112 | + (false === strpos($number, $thousand_separator)) && |
|
| 113 | + (false === strpos($number, $decimal_separator)) |
|
| 115 | 114 | ) || |
| 116 | 115 | |
| 117 | 116 | // Decimal formatted number. |
@@ -122,35 +121,35 @@ discard block |
||
| 122 | 121 | ( |
| 123 | 122 | $number_decimals && |
| 124 | 123 | '.' === $thousand_separator && |
| 125 | - false !== strpos( $number, $thousand_separator ) && |
|
| 126 | - false === strpos( $number, $decimal_separator ) && |
|
| 127 | - 2 === count( $number_parts ) && |
|
| 128 | - ( $number_decimals >= strlen( $number_parts[1] ) ) |
|
| 124 | + false !== strpos($number, $thousand_separator) && |
|
| 125 | + false === strpos($number, $decimal_separator) && |
|
| 126 | + 2 === count($number_parts) && |
|
| 127 | + ($number_decimals >= strlen($number_parts[1])) |
|
| 129 | 128 | ) |
| 130 | 129 | ) { |
| 131 | - return number_format( $number, $number_decimals, '.', '' ); |
|
| 130 | + return number_format($number, $number_decimals, '.', ''); |
|
| 132 | 131 | } |
| 133 | 132 | |
| 134 | 133 | // Handle thousand separator as '.' |
| 135 | 134 | // Handle sanitize database values. |
| 136 | - $is_db_sanitize_val = ( 2 === count( $number_parts ) && |
|
| 137 | - is_numeric( $number_parts[0] ) && |
|
| 138 | - is_numeric( $number_parts[1] ) && |
|
| 139 | - ( 6 === strlen( $number_parts[1] ) ) ); |
|
| 135 | + $is_db_sanitize_val = (2 === count($number_parts) && |
|
| 136 | + is_numeric($number_parts[0]) && |
|
| 137 | + is_numeric($number_parts[1]) && |
|
| 138 | + (6 === strlen($number_parts[1]))); |
|
| 140 | 139 | |
| 141 | - if ( $is_db_sanitize_val ) { |
|
| 140 | + if ($is_db_sanitize_val) { |
|
| 142 | 141 | // Sanitize database value. |
| 143 | - return number_format( $number, $number_decimals, '.', '' ); |
|
| 142 | + return number_format($number, $number_decimals, '.', ''); |
|
| 144 | 143 | |
| 145 | 144 | } elseif ( |
| 146 | 145 | '.' === $thousand_separator && |
| 147 | - false !== strpos( $number, $thousand_separator ) |
|
| 146 | + false !== strpos($number, $thousand_separator) |
|
| 148 | 147 | ) { |
| 149 | 148 | // Fix point thousand separator value. |
| 150 | - $number = str_replace( '.', '', $number ); |
|
| 149 | + $number = str_replace('.', '', $number); |
|
| 151 | 150 | } |
| 152 | 151 | |
| 153 | - return give_sanitize_amount( $number, $number_decimals, $trim_zeros ); |
|
| 152 | + return give_sanitize_amount($number, $number_decimals, $trim_zeros); |
|
| 154 | 153 | } |
| 155 | 154 | |
| 156 | 155 | /** |
@@ -168,67 +167,67 @@ discard block |
||
| 168 | 167 | * |
| 169 | 168 | * @return string $amount Newly sanitized amount |
| 170 | 169 | */ |
| 171 | -function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
|
| 170 | +function give_sanitize_amount($number, $dp = false, $trim_zeros = false) { |
|
| 172 | 171 | |
| 173 | 172 | // Bailout. |
| 174 | - if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
|
| 173 | + if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) { |
|
| 175 | 174 | return $number; |
| 176 | 175 | } |
| 177 | 176 | |
| 178 | 177 | // Remove slash from amount. |
| 179 | 178 | // If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number. |
| 180 | 179 | // To prevent notices and warning remove slash from amount/number. |
| 181 | - $number = wp_unslash( $number ); |
|
| 180 | + $number = wp_unslash($number); |
|
| 182 | 181 | |
| 183 | 182 | $thousand_separator = give_get_price_thousand_separator(); |
| 184 | 183 | |
| 185 | 184 | $locale = localeconv(); |
| 186 | - $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
| 185 | + $decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']); |
|
| 187 | 186 | |
| 188 | 187 | // Remove locale from string |
| 189 | - if ( ! is_float( $number ) ) { |
|
| 190 | - $number = str_replace( $decimals, '.', $number ); |
|
| 188 | + if ( ! is_float($number)) { |
|
| 189 | + $number = str_replace($decimals, '.', $number); |
|
| 191 | 190 | } |
| 192 | 191 | |
| 193 | 192 | // Remove thousand amount formatting if amount has. |
| 194 | 193 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
| 195 | 194 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
| 196 | - if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
| 197 | - $number = str_replace( $thousand_separator, '', $number ); |
|
| 198 | - } elseif ( in_array( $thousand_separator, $decimals ) ) { |
|
| 199 | - $number = preg_replace( '/\.(?=.*\.)/', '', $number ); |
|
| 195 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
| 196 | + $number = str_replace($thousand_separator, '', $number); |
|
| 197 | + } elseif (in_array($thousand_separator, $decimals)) { |
|
| 198 | + $number = preg_replace('/\.(?=.*\.)/', '', $number); |
|
| 200 | 199 | } |
| 201 | 200 | |
| 202 | 201 | // Remove non numeric entity before decimal separator. |
| 203 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
| 202 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
| 204 | 203 | $default_dp = give_get_price_decimals(); |
| 205 | 204 | |
| 206 | 205 | // Reset negative amount to zero. |
| 207 | - if ( 0 > $number ) { |
|
| 208 | - $number = number_format( 0, $default_dp, '.' ); |
|
| 206 | + if (0 > $number) { |
|
| 207 | + $number = number_format(0, $default_dp, '.'); |
|
| 209 | 208 | } |
| 210 | 209 | |
| 211 | 210 | // If number does not have decimal then add number of decimals to it. |
| 212 | 211 | if ( |
| 213 | - false === strpos( $number, '.' ) |
|
| 214 | - || ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) ) |
|
| 212 | + false === strpos($number, '.') |
|
| 213 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
| 215 | 214 | ) { |
| 216 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
| 215 | + $number = number_format($number, $default_dp, '.', ''); |
|
| 217 | 216 | } |
| 218 | 217 | |
| 219 | 218 | // Format number by custom number of decimals. |
| 220 | - if ( false !== $dp ) { |
|
| 221 | - $dp = intval( is_bool( $dp ) ? $default_dp : $dp ); |
|
| 222 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
| 223 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
| 219 | + if (false !== $dp) { |
|
| 220 | + $dp = intval(is_bool($dp) ? $default_dp : $dp); |
|
| 221 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
| 222 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
| 224 | 223 | } |
| 225 | 224 | |
| 226 | 225 | // Trim zeros. |
| 227 | - if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
| 228 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
| 226 | + if ($trim_zeros && strstr($number, '.')) { |
|
| 227 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
| 229 | 228 | } |
| 230 | 229 | |
| 231 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
| 230 | + return apply_filters('give_sanitize_amount', $number); |
|
| 232 | 231 | } |
| 233 | 232 | |
| 234 | 233 | /** |
@@ -241,10 +240,10 @@ discard block |
||
| 241 | 240 | * |
| 242 | 241 | * @return string $amount Newly formatted amount or Price Not Available |
| 243 | 242 | */ |
| 244 | -function give_format_amount( $amount, $args = array() ) { |
|
| 243 | +function give_format_amount($amount, $args = array()) { |
|
| 245 | 244 | // Backward compatibility. |
| 246 | - if( is_bool( $args ) ) { |
|
| 247 | - $args = array( 'decimal' => $args ); |
|
| 245 | + if (is_bool($args)) { |
|
| 246 | + $args = array('decimal' => $args); |
|
| 248 | 247 | } |
| 249 | 248 | |
| 250 | 249 | $default_args = array( |
@@ -253,60 +252,59 @@ discard block |
||
| 253 | 252 | 'currency' => give_get_currency(), |
| 254 | 253 | ); |
| 255 | 254 | |
| 256 | - $args = wp_parse_args( $args, $default_args ); |
|
| 255 | + $args = wp_parse_args($args, $default_args); |
|
| 257 | 256 | |
| 258 | 257 | $formatted = 0; |
| 259 | 258 | $thousands_sep = give_get_price_thousand_separator(); |
| 260 | 259 | $decimal_sep = give_get_price_decimal_separator(); |
| 261 | - $decimals = ! empty( $args['decimal'] ) ? give_get_price_decimals() : 0; |
|
| 260 | + $decimals = ! empty($args['decimal']) ? give_get_price_decimals() : 0; |
|
| 262 | 261 | $currency = $args['currency']; |
| 263 | 262 | |
| 264 | - if ( ! empty( $amount ) ) { |
|
| 263 | + if ( ! empty($amount)) { |
|
| 265 | 264 | // Sanitize amount before formatting. |
| 266 | - $amount = ! empty( $args['sanitize'] ) ? |
|
| 267 | - give_maybe_sanitize_amount( $amount, $decimals ) : |
|
| 268 | - number_format( $amount, $decimals, '.', '' ); |
|
| 265 | + $amount = ! empty($args['sanitize']) ? |
|
| 266 | + give_maybe_sanitize_amount($amount, $decimals) : number_format($amount, $decimals, '.', ''); |
|
| 269 | 267 | |
| 270 | - switch ( $currency ) { |
|
| 268 | + switch ($currency) { |
|
| 271 | 269 | case 'INR': |
| 272 | 270 | $decimal_amount = ''; |
| 273 | 271 | |
| 274 | 272 | // Extract decimals from amount |
| 275 | - if ( ( $pos = strpos( $amount, '.' ) ) !== false ) { |
|
| 276 | - if ( ! empty( $decimals ) ) { |
|
| 277 | - $decimal_amount = substr( round( substr( $amount, $pos ), $decimals ), 1 ); |
|
| 278 | - $amount = substr( $amount, 0, $pos ); |
|
| 279 | - |
|
| 280 | - if ( ! $decimal_amount ) { |
|
| 281 | - $decimal_amount = substr( '.0000000000', 0, ( $decimals + 1 ) ); |
|
| 282 | - } elseif ( ( $decimals + 1 ) > strlen( $decimal_amount ) ) { |
|
| 283 | - $decimal_amount = substr( "{$decimal_amount}000000000", 0, ( $decimals + 1 ) ); |
|
| 273 | + if (($pos = strpos($amount, '.')) !== false) { |
|
| 274 | + if ( ! empty($decimals)) { |
|
| 275 | + $decimal_amount = substr(round(substr($amount, $pos), $decimals), 1); |
|
| 276 | + $amount = substr($amount, 0, $pos); |
|
| 277 | + |
|
| 278 | + if ( ! $decimal_amount) { |
|
| 279 | + $decimal_amount = substr('.0000000000', 0, ($decimals + 1)); |
|
| 280 | + } elseif (($decimals + 1) > strlen($decimal_amount)) { |
|
| 281 | + $decimal_amount = substr("{$decimal_amount}000000000", 0, ($decimals + 1)); |
|
| 284 | 282 | } |
| 285 | 283 | |
| 286 | 284 | } else { |
| 287 | - $amount = number_format( $amount, $decimals, $decimal_sep, '' ); |
|
| 285 | + $amount = number_format($amount, $decimals, $decimal_sep, ''); |
|
| 288 | 286 | } |
| 289 | 287 | } |
| 290 | 288 | |
| 291 | 289 | // Extract last 3 from amount |
| 292 | - $result = substr( $amount, - 3 ); |
|
| 293 | - $amount = substr( $amount, 0, - 3 ); |
|
| 290 | + $result = substr($amount, - 3); |
|
| 291 | + $amount = substr($amount, 0, - 3); |
|
| 294 | 292 | |
| 295 | 293 | // Apply digits 2 by 2 |
| 296 | - while ( strlen( $amount ) > 0 ) { |
|
| 297 | - $result = substr( $amount, - 2 ) . $thousands_sep . $result; |
|
| 298 | - $amount = substr( $amount, 0, - 2 ); |
|
| 294 | + while (strlen($amount) > 0) { |
|
| 295 | + $result = substr($amount, - 2).$thousands_sep.$result; |
|
| 296 | + $amount = substr($amount, 0, - 2); |
|
| 299 | 297 | } |
| 300 | 298 | |
| 301 | - $formatted = $result . $decimal_amount; |
|
| 299 | + $formatted = $result.$decimal_amount; |
|
| 302 | 300 | break; |
| 303 | 301 | |
| 304 | 302 | default: |
| 305 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 303 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 306 | 304 | } |
| 307 | 305 | } |
| 308 | 306 | |
| 309 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args ); |
|
| 307 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args); |
|
| 310 | 308 | } |
| 311 | 309 | |
| 312 | 310 | |
@@ -324,51 +322,51 @@ discard block |
||
| 324 | 322 | * |
| 325 | 323 | * @return float|string formatted amount number with large number names. |
| 326 | 324 | */ |
| 327 | -function give_human_format_large_amount( $amount, $args = array() ) { |
|
| 325 | +function give_human_format_large_amount($amount, $args = array()) { |
|
| 328 | 326 | $default_args = array( |
| 329 | 327 | 'currency' => give_get_currency(), |
| 330 | 328 | ); |
| 331 | 329 | |
| 332 | - $args = wp_parse_args( $args, $default_args ); |
|
| 330 | + $args = wp_parse_args($args, $default_args); |
|
| 333 | 331 | |
| 334 | 332 | // Get thousand separator. |
| 335 | 333 | $thousands_sep = give_get_price_thousand_separator(); |
| 336 | 334 | |
| 337 | 335 | // Sanitize amount. |
| 338 | - $sanitize_amount = give_maybe_sanitize_amount( $amount ); |
|
| 336 | + $sanitize_amount = give_maybe_sanitize_amount($amount); |
|
| 339 | 337 | |
| 340 | 338 | // Explode amount to calculate name of large numbers. |
| 341 | - $amount_array = explode( $thousands_sep, $amount ); |
|
| 339 | + $amount_array = explode($thousands_sep, $amount); |
|
| 342 | 340 | |
| 343 | 341 | // Calculate amount parts count. |
| 344 | - $amount_count_parts = count( $amount_array ); |
|
| 342 | + $amount_count_parts = count($amount_array); |
|
| 345 | 343 | |
| 346 | 344 | // Human format amount (default). |
| 347 | 345 | $human_format_amount = $amount; |
| 348 | 346 | |
| 349 | - switch ( $args['currency'] ) { |
|
| 347 | + switch ($args['currency']) { |
|
| 350 | 348 | case 'INR': |
| 351 | 349 | // Calculate large number formatted amount. |
| 352 | - if ( 4 < $amount_count_parts ) { |
|
| 353 | - $human_format_amount = sprintf( esc_html__( '%s arab', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
| 354 | - } elseif ( 3 < $amount_count_parts ) { |
|
| 355 | - $human_format_amount = sprintf( esc_html__( '%s crore', 'give' ), round( ( $sanitize_amount / 10000000 ), 2 ) ); |
|
| 356 | - } elseif ( 2 < $amount_count_parts ) { |
|
| 357 | - $human_format_amount = sprintf( esc_html__( '%s lakh', 'give' ), round( ( $sanitize_amount / 100000 ), 2 ) ); |
|
| 350 | + if (4 < $amount_count_parts) { |
|
| 351 | + $human_format_amount = sprintf(esc_html__('%s arab', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
| 352 | + } elseif (3 < $amount_count_parts) { |
|
| 353 | + $human_format_amount = sprintf(esc_html__('%s crore', 'give'), round(($sanitize_amount / 10000000), 2)); |
|
| 354 | + } elseif (2 < $amount_count_parts) { |
|
| 355 | + $human_format_amount = sprintf(esc_html__('%s lakh', 'give'), round(($sanitize_amount / 100000), 2)); |
|
| 358 | 356 | } |
| 359 | 357 | break; |
| 360 | 358 | default: |
| 361 | 359 | // Calculate large number formatted amount. |
| 362 | - if ( 4 < $amount_count_parts ) { |
|
| 363 | - $human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
| 364 | - } elseif ( 3 < $amount_count_parts ) { |
|
| 365 | - $human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
| 366 | - } elseif ( 2 < $amount_count_parts ) { |
|
| 367 | - $human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) ); |
|
| 360 | + if (4 < $amount_count_parts) { |
|
| 361 | + $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
| 362 | + } elseif (3 < $amount_count_parts) { |
|
| 363 | + $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
| 364 | + } elseif (2 < $amount_count_parts) { |
|
| 365 | + $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
| 368 | 366 | } |
| 369 | 367 | } |
| 370 | 368 | |
| 371 | - return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount ); |
|
| 369 | + return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount); |
|
| 372 | 370 | } |
| 373 | 371 | |
| 374 | 372 | /** |
@@ -382,17 +380,16 @@ discard block |
||
| 382 | 380 | * |
| 383 | 381 | * @return string $amount Newly formatted amount or Price Not Available |
| 384 | 382 | */ |
| 385 | -function give_format_decimal( $amount, $dp = false, $sanitize = true ) { |
|
| 383 | +function give_format_decimal($amount, $dp = false, $sanitize = true) { |
|
| 386 | 384 | $decimal_separator = give_get_price_decimal_separator(); |
| 387 | 385 | $formatted_amount = $sanitize ? |
| 388 | - give_maybe_sanitize_amount( $amount, $dp ) : |
|
| 389 | - number_format( $amount, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' ); |
|
| 386 | + give_maybe_sanitize_amount($amount, $dp) : number_format($amount, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', ''); |
|
| 390 | 387 | |
| 391 | - if ( false !== strpos( $formatted_amount, '.' ) ) { |
|
| 392 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
| 388 | + if (false !== strpos($formatted_amount, '.')) { |
|
| 389 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
| 393 | 390 | } |
| 394 | 391 | |
| 395 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
| 392 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
| 396 | 393 | } |
| 397 | 394 | |
| 398 | 395 | /** |
@@ -406,24 +403,24 @@ discard block |
||
| 406 | 403 | * |
| 407 | 404 | * @return mixed|string |
| 408 | 405 | */ |
| 409 | -function give_currency_filter( $price = '', $currency = '', $decode_currency = false ) { |
|
| 406 | +function give_currency_filter($price = '', $currency = '', $decode_currency = false) { |
|
| 410 | 407 | |
| 411 | - if ( empty( $currency ) || ! array_key_exists( (string) $currency, give_get_currencies() ) ) { |
|
| 408 | + if (empty($currency) || ! array_key_exists((string) $currency, give_get_currencies())) { |
|
| 412 | 409 | $currency = give_get_currency(); |
| 413 | 410 | } |
| 414 | 411 | |
| 415 | - $position = give_get_option( 'currency_position', 'before' ); |
|
| 412 | + $position = give_get_option('currency_position', 'before'); |
|
| 416 | 413 | |
| 417 | 414 | $negative = $price < 0; |
| 418 | 415 | |
| 419 | - if ( $negative ) { |
|
| 416 | + if ($negative) { |
|
| 420 | 417 | // Remove proceeding "-". |
| 421 | - $price = substr( $price, 1 ); |
|
| 418 | + $price = substr($price, 1); |
|
| 422 | 419 | } |
| 423 | 420 | |
| 424 | - $symbol = give_currency_symbol( $currency, $decode_currency ); |
|
| 421 | + $symbol = give_currency_symbol($currency, $decode_currency); |
|
| 425 | 422 | |
| 426 | - switch ( $currency ) : |
|
| 423 | + switch ($currency) : |
|
| 427 | 424 | case 'GBP' : |
| 428 | 425 | case 'BRL' : |
| 429 | 426 | case 'EUR' : |
@@ -452,13 +449,13 @@ discard block |
||
| 452 | 449 | case 'MAD' : |
| 453 | 450 | case 'KRW' : |
| 454 | 451 | case 'ZAR' : |
| 455 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
| 452 | + $formatted = ('before' === $position ? $symbol.$price : $price.$symbol); |
|
| 456 | 453 | break; |
| 457 | 454 | case 'NOK' : |
| 458 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
| 455 | + $formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol); |
|
| 459 | 456 | break; |
| 460 | 457 | default : |
| 461 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
| 458 | + $formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency); |
|
| 462 | 459 | break; |
| 463 | 460 | endswitch; |
| 464 | 461 | |
@@ -473,11 +470,11 @@ discard block |
||
| 473 | 470 | * and if currency is USD and currency position is after then |
| 474 | 471 | * filter name will be give_usd_currency_filter_after |
| 475 | 472 | */ |
| 476 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
| 473 | + $formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price); |
|
| 477 | 474 | |
| 478 | - if ( $negative ) { |
|
| 475 | + if ($negative) { |
|
| 479 | 476 | // Prepend the minus sign before the currency sign. |
| 480 | - $formatted = '-' . $formatted; |
|
| 477 | + $formatted = '-'.$formatted; |
|
| 481 | 478 | } |
| 482 | 479 | |
| 483 | 480 | return $formatted; |
@@ -493,21 +490,21 @@ discard block |
||
| 493 | 490 | */ |
| 494 | 491 | function give_currency_decimal_filter() { |
| 495 | 492 | |
| 496 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 493 | + remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
| 497 | 494 | |
| 498 | 495 | // Set default number of decimals. |
| 499 | 496 | $decimals = give_get_price_decimals(); |
| 500 | 497 | |
| 501 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 498 | + add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
| 502 | 499 | |
| 503 | 500 | // Get number of decimals with backward compatibility ( version < 1.6 ) |
| 504 | - if ( 1 <= func_num_args() ) { |
|
| 505 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
| 501 | + if (1 <= func_num_args()) { |
|
| 502 | + $decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0))); |
|
| 506 | 503 | } |
| 507 | 504 | |
| 508 | 505 | $currency = give_get_currency(); |
| 509 | 506 | |
| 510 | - switch ( $currency ) { |
|
| 507 | + switch ($currency) { |
|
| 511 | 508 | case 'RIAL' : |
| 512 | 509 | case 'JPY' : |
| 513 | 510 | case 'TWD' : |
@@ -517,11 +514,11 @@ discard block |
||
| 517 | 514 | break; |
| 518 | 515 | } |
| 519 | 516 | |
| 520 | - return apply_filters( 'give_currency_decimal_count', $decimals, $currency ); |
|
| 517 | + return apply_filters('give_currency_decimal_count', $decimals, $currency); |
|
| 521 | 518 | } |
| 522 | 519 | |
| 523 | -add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 524 | -add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 520 | +add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
| 521 | +add_filter('give_format_amount_decimals', 'give_currency_decimal_filter'); |
|
| 525 | 522 | |
| 526 | 523 | |
| 527 | 524 | /** |
@@ -533,7 +530,7 @@ discard block |
||
| 533 | 530 | * |
| 534 | 531 | * @return string Date format string |
| 535 | 532 | */ |
| 536 | -function give_date_format( $date_context = '' ) { |
|
| 533 | +function give_date_format($date_context = '') { |
|
| 537 | 534 | /** |
| 538 | 535 | * Filter the date context |
| 539 | 536 | * |
@@ -554,19 +551,19 @@ discard block |
||
| 554 | 551 | * |
| 555 | 552 | * } |
| 556 | 553 | */ |
| 557 | - $date_format_contexts = apply_filters( 'give_date_format_contexts', array() ); |
|
| 554 | + $date_format_contexts = apply_filters('give_date_format_contexts', array()); |
|
| 558 | 555 | |
| 559 | 556 | // Set date format to default date format. |
| 560 | - $date_format = get_option( 'date_format' ); |
|
| 557 | + $date_format = get_option('date_format'); |
|
| 561 | 558 | |
| 562 | 559 | // Update date format if we have non empty date format context array and non empty date format string for that context. |
| 563 | - if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) { |
|
| 564 | - $date_format = ! empty( $date_format_contexts[ $date_context ] ) |
|
| 565 | - ? $date_format_contexts[ $date_context ] |
|
| 560 | + if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) { |
|
| 561 | + $date_format = ! empty($date_format_contexts[$date_context]) |
|
| 562 | + ? $date_format_contexts[$date_context] |
|
| 566 | 563 | : $date_format; |
| 567 | 564 | } |
| 568 | 565 | |
| 569 | - return apply_filters( 'give_date_format', $date_format ); |
|
| 566 | + return apply_filters('give_date_format', $date_format); |
|
| 570 | 567 | } |
| 571 | 568 | |
| 572 | 569 | /** |
@@ -580,8 +577,8 @@ discard block |
||
| 580 | 577 | * |
| 581 | 578 | * @return string |
| 582 | 579 | */ |
| 583 | -function give_get_cache_key( $action, $query_args ) { |
|
| 584 | - return Give_Cache::get_key( $action, $query_args ); |
|
| 580 | +function give_get_cache_key($action, $query_args) { |
|
| 581 | + return Give_Cache::get_key($action, $query_args); |
|
| 585 | 582 | } |
| 586 | 583 | |
| 587 | 584 | /** |
@@ -594,11 +591,11 @@ discard block |
||
| 594 | 591 | * |
| 595 | 592 | * @return string|array |
| 596 | 593 | */ |
| 597 | -function give_clean( $var ) { |
|
| 598 | - if ( is_array( $var ) ) { |
|
| 599 | - return array_map( 'give_clean', $var ); |
|
| 594 | +function give_clean($var) { |
|
| 595 | + if (is_array($var)) { |
|
| 596 | + return array_map('give_clean', $var); |
|
| 600 | 597 | } else { |
| 601 | - return is_scalar( $var ) ? sanitize_text_field( $var ) : $var; |
|
| 598 | + return is_scalar($var) ? sanitize_text_field($var) : $var; |
|
| 602 | 599 | } |
| 603 | 600 | } |
| 604 | 601 | |
@@ -611,10 +608,10 @@ discard block |
||
| 611 | 608 | * |
| 612 | 609 | * @return int |
| 613 | 610 | */ |
| 614 | -function give_let_to_num( $size ) { |
|
| 615 | - $l = substr( $size, - 1 ); |
|
| 616 | - $ret = substr( $size, 0, - 1 ); |
|
| 617 | - switch ( strtoupper( $l ) ) { |
|
| 611 | +function give_let_to_num($size) { |
|
| 612 | + $l = substr($size, - 1); |
|
| 613 | + $ret = substr($size, 0, - 1); |
|
| 614 | + switch (strtoupper($l)) { |
|
| 618 | 615 | case 'P': |
| 619 | 616 | $ret *= 1024; |
| 620 | 617 | case 'T': |
@@ -639,19 +636,19 @@ discard block |
||
| 639 | 636 | * @param int $action |
| 640 | 637 | * @param array $wp_die_args |
| 641 | 638 | */ |
| 642 | -function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) { |
|
| 639 | +function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) { |
|
| 643 | 640 | |
| 644 | 641 | $default_wp_die_args = array( |
| 645 | - 'message' => esc_html__( 'Nonce verification has failed.', 'give' ), |
|
| 646 | - 'title' => esc_html__( 'Error', 'give' ), |
|
| 642 | + 'message' => esc_html__('Nonce verification has failed.', 'give'), |
|
| 643 | + 'title' => esc_html__('Error', 'give'), |
|
| 647 | 644 | 'args' => array( |
| 648 | 645 | 'response' => 403, |
| 649 | 646 | ), |
| 650 | 647 | ); |
| 651 | 648 | |
| 652 | - $wp_die_args = wp_parse_args( $wp_die_args, $default_wp_die_args ); |
|
| 649 | + $wp_die_args = wp_parse_args($wp_die_args, $default_wp_die_args); |
|
| 653 | 650 | |
| 654 | - if ( ! wp_verify_nonce( $nonce, $action ) ) { |
|
| 651 | + if ( ! wp_verify_nonce($nonce, $action)) { |
|
| 655 | 652 | wp_die( |
| 656 | 653 | $wp_die_args['message'], |
| 657 | 654 | $wp_die_args['title'], |
@@ -673,23 +670,23 @@ discard block |
||
| 673 | 670 | * |
| 674 | 671 | * @return mixed |
| 675 | 672 | */ |
| 676 | -function give_check_variable( $variable, $conditional = '', $default = false ) { |
|
| 673 | +function give_check_variable($variable, $conditional = '', $default = false) { |
|
| 677 | 674 | |
| 678 | - switch ( $conditional ) { |
|
| 675 | + switch ($conditional) { |
|
| 679 | 676 | case 'isset_empty': |
| 680 | - $variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default; |
|
| 677 | + $variable = (isset($variable) && ! empty($variable)) ? $variable : $default; |
|
| 681 | 678 | break; |
| 682 | 679 | |
| 683 | 680 | case 'empty': |
| 684 | - $variable = ! empty( $variable ) ? $variable : $default; |
|
| 681 | + $variable = ! empty($variable) ? $variable : $default; |
|
| 685 | 682 | break; |
| 686 | 683 | |
| 687 | 684 | case 'null': |
| 688 | - $variable = ! is_null( $variable ) ? $variable : $default; |
|
| 685 | + $variable = ! is_null($variable) ? $variable : $default; |
|
| 689 | 686 | break; |
| 690 | 687 | |
| 691 | 688 | default: |
| 692 | - $variable = isset( $variable ) ? $variable : $default; |
|
| 689 | + $variable = isset($variable) ? $variable : $default; |
|
| 693 | 690 | |
| 694 | 691 | } |
| 695 | 692 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | -function give_email_donation_receipt( $payment_id, $admin_notice = true ) { |
|
| 29 | +function give_email_donation_receipt($payment_id, $admin_notice = true) { |
|
| 30 | 30 | |
| 31 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
| 31 | + $payment_data = give_get_payment_meta($payment_id); |
|
| 32 | 32 | |
| 33 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
| 33 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Filters the from name. |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @since 1.0 |
| 42 | 42 | */ |
| 43 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
| 43 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
| 44 | 44 | |
| 45 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
| 45 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Filters the from email. |
@@ -52,19 +52,19 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @since 1.0 |
| 54 | 54 | */ |
| 55 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
| 55 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
| 56 | 56 | |
| 57 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
| 57 | + $to_email = give_get_payment_user_email($payment_id); |
|
| 58 | 58 | |
| 59 | - $subject = give_get_option( 'donation_subject', __( 'Donation Receipt', 'give' ) ); |
|
| 59 | + $subject = give_get_option('donation_subject', __('Donation Receipt', 'give')); |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Filters the donation email receipt subject. |
| 63 | 63 | * |
| 64 | 64 | * @since 1.0 |
| 65 | 65 | */ |
| 66 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
| 67 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
| 66 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
| 67 | + $subject = give_do_email_tags($subject, $payment_id); |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * Filters the donation email receipt attachments. By default, there is no attachment but plugins can hook in to provide one more multiple for the donor. Examples would be a printable ticket or PDF receipt. |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @since 1.0 |
| 76 | 76 | */ |
| 77 | - $attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data ); |
|
| 78 | - $message = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id ); |
|
| 77 | + $attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data); |
|
| 78 | + $message = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id); |
|
| 79 | 79 | |
| 80 | 80 | $emails = Give()->emails; |
| 81 | 81 | |
| 82 | - $emails->__set( 'from_name', $from_name ); |
|
| 83 | - $emails->__set( 'from_email', $from_email ); |
|
| 84 | - $emails->__set( 'heading', __( 'Donation Receipt', 'give' ) ); |
|
| 82 | + $emails->__set('from_name', $from_name); |
|
| 83 | + $emails->__set('from_email', $from_email); |
|
| 84 | + $emails->__set('heading', __('Donation Receipt', 'give')); |
|
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * Filters the donation receipt's email headers. |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @since 1.0 |
| 93 | 93 | */ |
| 94 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
| 95 | - $emails->__set( 'headers', $headers ); |
|
| 94 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
| 95 | + $emails->__set('headers', $headers); |
|
| 96 | 96 | |
| 97 | 97 | //Send the donation receipt. |
| 98 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
| 98 | + $emails->send($to_email, $subject, $message, $attachments); |
|
| 99 | 99 | |
| 100 | 100 | //If admin notifications are on, send the admin notice. |
| 101 | - if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) { |
|
| 101 | + if ($admin_notice && ! give_admin_notices_disabled($payment_id)) { |
|
| 102 | 102 | /** |
| 103 | 103 | * Fires in the donation email receipt. |
| 104 | 104 | * |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @param int $payment_id Payment id. |
| 110 | 110 | * @param mixed $payment_data Payment meta data. |
| 111 | 111 | */ |
| 112 | - do_action( 'give_admin_donation_email', $payment_id, $payment_data ); |
|
| 112 | + do_action('give_admin_donation_email', $payment_id, $payment_data); |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
@@ -122,41 +122,41 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | function give_email_test_donation_receipt() { |
| 124 | 124 | |
| 125 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
| 125 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * Filters the from name. |
| 129 | 129 | * |
| 130 | 130 | * @since 1.7 |
| 131 | 131 | */ |
| 132 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, 0, array() ); |
|
| 132 | + $from_name = apply_filters('give_donation_from_name', $from_name, 0, array()); |
|
| 133 | 133 | |
| 134 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
| 134 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | 137 | * Filters the from email. |
| 138 | 138 | * |
| 139 | 139 | * @since 1.7 |
| 140 | 140 | */ |
| 141 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, 0, array() ); |
|
| 141 | + $from_email = apply_filters('give_donation_from_address', $from_email, 0, array()); |
|
| 142 | 142 | |
| 143 | - $subject = give_get_option( 'donation_subject', __( 'Donation Receipt', 'give' ) ); |
|
| 144 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 ); |
|
| 145 | - $subject = give_do_email_tags( $subject, 0 ); |
|
| 143 | + $subject = give_get_option('donation_subject', __('Donation Receipt', 'give')); |
|
| 144 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0); |
|
| 145 | + $subject = give_do_email_tags($subject, 0); |
|
| 146 | 146 | |
| 147 | - $attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() ); |
|
| 147 | + $attachments = apply_filters('give_receipt_attachments', array(), 0, array()); |
|
| 148 | 148 | |
| 149 | - $message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
| 149 | + $message = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
| 150 | 150 | |
| 151 | 151 | $emails = Give()->emails; |
| 152 | - $emails->__set( 'from_name', $from_name ); |
|
| 153 | - $emails->__set( 'from_email', $from_email ); |
|
| 154 | - $emails->__set( 'heading', __( 'Donation Receipt', 'give' ) ); |
|
| 152 | + $emails->__set('from_name', $from_name); |
|
| 153 | + $emails->__set('from_email', $from_email); |
|
| 154 | + $emails->__set('heading', __('Donation Receipt', 'give')); |
|
| 155 | 155 | |
| 156 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() ); |
|
| 157 | - $emails->__set( 'headers', $headers ); |
|
| 156 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array()); |
|
| 157 | + $emails->__set('headers', $headers); |
|
| 158 | 158 | |
| 159 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
| 159 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
| 160 | 160 | |
| 161 | 161 | } |
| 162 | 162 | |
@@ -170,49 +170,49 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @return void |
| 172 | 172 | */ |
| 173 | -function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) { |
|
| 173 | +function give_admin_email_notice($payment_id = 0, $payment_data = array()) { |
|
| 174 | 174 | |
| 175 | - $payment_id = absint( $payment_id ); |
|
| 175 | + $payment_id = absint($payment_id); |
|
| 176 | 176 | |
| 177 | - if ( empty( $payment_id ) ) { |
|
| 177 | + if (empty($payment_id)) { |
|
| 178 | 178 | return; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if ( ! give_get_payment_by( 'id', $payment_id ) ) { |
|
| 181 | + if ( ! give_get_payment_by('id', $payment_id)) { |
|
| 182 | 182 | return; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
| 185 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
| 186 | 186 | |
| 187 | 187 | /** |
| 188 | 188 | * Filters the from name. |
| 189 | 189 | * |
| 190 | 190 | * @since 1.0 |
| 191 | 191 | */ |
| 192 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
| 192 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
| 193 | 193 | |
| 194 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
| 194 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | 197 | * Filters the from email. |
| 198 | 198 | * |
| 199 | 199 | * @since 1.0 |
| 200 | 200 | */ |
| 201 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
| 201 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
| 202 | 202 | |
| 203 | 203 | /* translators: %s: payment id */ |
| 204 | - $subject = give_get_option( 'donation_notification_subject', sprintf( esc_html__( 'New Donation - Payment #%s', 'give' ), $payment_id ) ); |
|
| 204 | + $subject = give_get_option('donation_notification_subject', sprintf(esc_html__('New Donation - Payment #%s', 'give'), $payment_id)); |
|
| 205 | 205 | |
| 206 | 206 | /** |
| 207 | 207 | * Filters the donation notification subject. |
| 208 | 208 | * |
| 209 | 209 | * @since 1.0 |
| 210 | 210 | */ |
| 211 | - $subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
| 212 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
| 211 | + $subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id); |
|
| 212 | + $subject = give_do_email_tags($subject, $payment_id); |
|
| 213 | 213 | |
| 214 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
| 215 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
| 214 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
| 215 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
| 216 | 216 | //$headers .= "MIME-Version: 1.0\r\n"; |
| 217 | 217 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
| 218 | 218 | |
@@ -221,28 +221,28 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @since 1.0 |
| 223 | 223 | */ |
| 224 | - $headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data ); |
|
| 224 | + $headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data); |
|
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | 227 | * Filters the donation notification email attachments. By default, there is no attachment but plugins can hook in to provide one more multiple. |
| 228 | 228 | * |
| 229 | 229 | * @since 1.0 |
| 230 | 230 | */ |
| 231 | - $attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data ); |
|
| 231 | + $attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data); |
|
| 232 | 232 | |
| 233 | - $message = give_get_donation_notification_body_content( $payment_id, $payment_data ); |
|
| 233 | + $message = give_get_donation_notification_body_content($payment_id, $payment_data); |
|
| 234 | 234 | |
| 235 | 235 | $emails = Give()->emails; |
| 236 | - $emails->__set( 'from_name', $from_name ); |
|
| 237 | - $emails->__set( 'from_email', $from_email ); |
|
| 238 | - $emails->__set( 'headers', $headers ); |
|
| 239 | - $emails->__set( 'heading', __( 'New Donation!', 'give' ) ); |
|
| 236 | + $emails->__set('from_name', $from_name); |
|
| 237 | + $emails->__set('from_email', $from_email); |
|
| 238 | + $emails->__set('headers', $headers); |
|
| 239 | + $emails->__set('heading', __('New Donation!', 'give')); |
|
| 240 | 240 | |
| 241 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
| 241 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
| 242 | 242 | |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | -add_action( 'give_admin_donation_email', 'give_admin_email_notice', 10, 2 ); |
|
| 245 | +add_action('give_admin_donation_email', 'give_admin_email_notice', 10, 2); |
|
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * Retrieves the emails for which admin notifications are sent to (these can be changed in the Give Settings). |
@@ -252,12 +252,12 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | function give_get_admin_notice_emails() { |
| 254 | 254 | |
| 255 | - $email_option = give_get_option( 'admin_notice_emails' ); |
|
| 255 | + $email_option = give_get_option('admin_notice_emails'); |
|
| 256 | 256 | |
| 257 | - $emails = ! empty( $email_option ) && strlen( trim( $email_option ) ) > 0 ? $email_option : get_bloginfo( 'admin_email' ); |
|
| 258 | - $emails = array_map( 'trim', explode( "\n", $emails ) ); |
|
| 257 | + $emails = ! empty($email_option) && strlen(trim($email_option)) > 0 ? $email_option : get_bloginfo('admin_email'); |
|
| 258 | + $emails = array_map('trim', explode("\n", $emails)); |
|
| 259 | 259 | |
| 260 | - return apply_filters( 'give_admin_notice_emails', $emails ); |
|
| 260 | + return apply_filters('give_admin_notice_emails', $emails); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -269,11 +269,11 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return mixed |
| 271 | 271 | */ |
| 272 | -function give_admin_notices_disabled( $payment_id = 0 ) { |
|
| 272 | +function give_admin_notices_disabled($payment_id = 0) { |
|
| 273 | 273 | |
| 274 | 274 | return apply_filters( |
| 275 | 275 | 'give_admin_notices_disabled', |
| 276 | - ! give_is_setting_enabled( give_get_option( 'admin_notices' ) ), |
|
| 276 | + ! give_is_setting_enabled(give_get_option('admin_notices')), |
|
| 277 | 277 | $payment_id |
| 278 | 278 | ); |
| 279 | 279 | } |
@@ -288,19 +288,19 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | function give_get_default_donation_notification_email() { |
| 290 | 290 | |
| 291 | - $default_email_body = __( 'Hi there,', 'give' ) . "\n\n"; |
|
| 292 | - $default_email_body .= __( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n"; |
|
| 293 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n"; |
|
| 294 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
| 295 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
| 296 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n"; |
|
| 297 | - $default_email_body .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
| 298 | - $default_email_body .= '{sitename}' . "\n"; |
|
| 291 | + $default_email_body = __('Hi there,', 'give')."\n\n"; |
|
| 292 | + $default_email_body .= __('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n"; |
|
| 293 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {name}'."\n"; |
|
| 294 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
| 295 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
| 296 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n"; |
|
| 297 | + $default_email_body .= __('Thank you,', 'give')."\n\n"; |
|
| 298 | + $default_email_body .= '{sitename}'."\n"; |
|
| 299 | 299 | |
| 300 | - $custom_message = give_get_option( 'donation_notification' ); |
|
| 301 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
| 300 | + $custom_message = give_get_option('donation_notification'); |
|
| 301 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
| 302 | 302 | |
| 303 | - return apply_filters( 'give_default_donation_notification_email', $message ); |
|
| 303 | + return apply_filters('give_default_donation_notification_email', $message); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | |
@@ -314,25 +314,25 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | function give_get_default_donation_receipt_email() { |
| 316 | 316 | |
| 317 | - $default_email_body = __( 'Dear', 'give' ) . " {name},\n\n"; |
|
| 318 | - $default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n"; |
|
| 319 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
| 320 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
| 321 | - $default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n"; |
|
| 322 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
| 323 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n"; |
|
| 324 | - $default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n"; |
|
| 325 | - $default_email_body .= '<strong>' . __( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n"; |
|
| 326 | - $default_email_body .= '{receipt_link}' . "\n\n"; |
|
| 317 | + $default_email_body = __('Dear', 'give')." {name},\n\n"; |
|
| 318 | + $default_email_body .= __('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n"; |
|
| 319 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
| 320 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
| 321 | + $default_email_body .= '<strong>'.__('Donation Date:', 'give').'</strong> {date}'."\n"; |
|
| 322 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
| 323 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n"; |
|
| 324 | + $default_email_body .= '<strong>'.__('Payment ID:', 'give').'</strong> {payment_id}'."\n"; |
|
| 325 | + $default_email_body .= '<strong>'.__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n"; |
|
| 326 | + $default_email_body .= '{receipt_link}'."\n\n"; |
|
| 327 | 327 | $default_email_body .= "\n\n"; |
| 328 | - $default_email_body .= __( 'Sincerely,', 'give' ) . "\n"; |
|
| 329 | - $default_email_body .= '{sitename}' . "\n"; |
|
| 328 | + $default_email_body .= __('Sincerely,', 'give')."\n"; |
|
| 329 | + $default_email_body .= '{sitename}'."\n"; |
|
| 330 | 330 | |
| 331 | - $custom_message = give_get_option( 'donation_receipt' ); |
|
| 331 | + $custom_message = give_get_option('donation_receipt'); |
|
| 332 | 332 | |
| 333 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
| 333 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
| 334 | 334 | |
| 335 | - return apply_filters( 'give_default_donation_receipt_email', $message ); |
|
| 335 | + return apply_filters('give_default_donation_receipt_email', $message); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
@@ -345,22 +345,22 @@ discard block |
||
| 345 | 345 | * |
| 346 | 346 | * @return array $email_names |
| 347 | 347 | */ |
| 348 | -function give_get_email_names( $user_info, $payment = false ) { |
|
| 348 | +function give_get_email_names($user_info, $payment = false) { |
|
| 349 | 349 | $email_names = array(); |
| 350 | 350 | |
| 351 | - if ( is_a( $payment, 'Give_Payment' ) ) { |
|
| 351 | + if (is_a($payment, 'Give_Payment')) { |
|
| 352 | 352 | |
| 353 | - if ( $payment->user_id > 0 ) { |
|
| 353 | + if ($payment->user_id > 0) { |
|
| 354 | 354 | |
| 355 | - $user_data = get_userdata( $payment->user_id ); |
|
| 355 | + $user_data = get_userdata($payment->user_id); |
|
| 356 | 356 | $email_names['name'] = $payment->first_name; |
| 357 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
| 357 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
| 358 | 358 | $email_names['username'] = $user_data->user_login; |
| 359 | 359 | |
| 360 | - } elseif ( ! empty( $payment->first_name ) ) { |
|
| 360 | + } elseif ( ! empty($payment->first_name)) { |
|
| 361 | 361 | |
| 362 | 362 | $email_names['name'] = $payment->first_name; |
| 363 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
| 363 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
| 364 | 364 | $email_names['username'] = $payment->first_name; |
| 365 | 365 | |
| 366 | 366 | } else { |
@@ -373,30 +373,30 @@ discard block |
||
| 373 | 373 | } else { |
| 374 | 374 | |
| 375 | 375 | // Support for old serialized data. |
| 376 | - if ( is_serialized( $user_info ) ) { |
|
| 376 | + if (is_serialized($user_info)) { |
|
| 377 | 377 | |
| 378 | 378 | // Security check. |
| 379 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches ); |
|
| 380 | - if ( ! empty( $matches ) ) { |
|
| 379 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches); |
|
| 380 | + if ( ! empty($matches)) { |
|
| 381 | 381 | return array( |
| 382 | 382 | 'name' => '', |
| 383 | 383 | 'fullname' => '', |
| 384 | 384 | 'username' => '', |
| 385 | 385 | ); |
| 386 | 386 | } else { |
| 387 | - $user_info = maybe_unserialize( $user_info ); |
|
| 387 | + $user_info = maybe_unserialize($user_info); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) { |
|
| 393 | - $user_data = get_userdata( $user_info['id'] ); |
|
| 392 | + if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) { |
|
| 393 | + $user_data = get_userdata($user_info['id']); |
|
| 394 | 394 | $email_names['name'] = $user_info['first_name']; |
| 395 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
| 395 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
| 396 | 396 | $email_names['username'] = $user_data->user_login; |
| 397 | - } elseif ( isset( $user_info['first_name'] ) ) { |
|
| 397 | + } elseif (isset($user_info['first_name'])) { |
|
| 398 | 398 | $email_names['name'] = $user_info['first_name']; |
| 399 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
| 399 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
| 400 | 400 | $email_names['username'] = $user_info['first_name']; |
| 401 | 401 | } else { |
| 402 | 402 | $email_names['name'] = $user_info['email']; |
@@ -416,37 +416,37 @@ discard block |
||
| 416 | 416 | * |
| 417 | 417 | * @since 1.8.14 |
| 418 | 418 | */ |
| 419 | -function give_admin_email_user_donor_disconnection( $user_id, $donor_id ) { |
|
| 419 | +function give_admin_email_user_donor_disconnection($user_id, $donor_id) { |
|
| 420 | 420 | |
| 421 | - $user_id = absint( $user_id ); |
|
| 422 | - $donor_id = absint( $donor_id ); |
|
| 421 | + $user_id = absint($user_id); |
|
| 422 | + $donor_id = absint($donor_id); |
|
| 423 | 423 | |
| 424 | 424 | // Bail Out, if user id doesn't exists. |
| 425 | - if ( empty( $user_id ) ) { |
|
| 425 | + if (empty($user_id)) { |
|
| 426 | 426 | return; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | // Bail Out, if donor id doesn't exists. |
| 430 | - if ( empty( $donor_id ) ) { |
|
| 430 | + if (empty($donor_id)) { |
|
| 431 | 431 | return; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
| 434 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
| 435 | 435 | |
| 436 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
| 436 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
| 437 | 437 | |
| 438 | 438 | /* translators: %s: payment id */ |
| 439 | - $subject = __( 'Attention: User tries to login whose Donor profile is disconnected!', 'give' ); |
|
| 439 | + $subject = __('Attention: User tries to login whose Donor profile is disconnected!', 'give'); |
|
| 440 | 440 | |
| 441 | 441 | /** |
| 442 | 442 | * Filters the Donor-User Disconnection notification subject. |
| 443 | 443 | * |
| 444 | 444 | * @since 1.8.14 |
| 445 | 445 | */ |
| 446 | - $subject = apply_filters( 'give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags( $subject ) ); |
|
| 446 | + $subject = apply_filters('give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags($subject)); |
|
| 447 | 447 | |
| 448 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
| 449 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
| 448 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
| 449 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
| 450 | 450 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
| 451 | 451 | |
| 452 | 452 | /** |
@@ -454,25 +454,25 @@ discard block |
||
| 454 | 454 | * |
| 455 | 455 | * @since 1.8.14 |
| 456 | 456 | */ |
| 457 | - $headers = apply_filters( 'give_admin_donor_user_disconnection_notification_headers', $headers ); |
|
| 457 | + $headers = apply_filters('give_admin_donor_user_disconnection_notification_headers', $headers); |
|
| 458 | 458 | |
| 459 | - $message = __( 'Hi Admin,', 'give' ) . "\n\n"; |
|
| 460 | - $message .= __( 'This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give' ) . "\n\n"; |
|
| 461 | - $message .= __( 'Do you want to reconnect User and Donor profile again?', 'give' ) . "\n\n"; |
|
| 459 | + $message = __('Hi Admin,', 'give')."\n\n"; |
|
| 460 | + $message .= __('This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give')."\n\n"; |
|
| 461 | + $message .= __('Do you want to reconnect User and Donor profile again?', 'give')."\n\n"; |
|
| 462 | 462 | $message .= sprintf( |
| 463 | 463 | '<a href="%1$s">%2$s</a>', |
| 464 | - esc_url( admin_url() . 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&user_id=' . $user_id . '&give-message=reconnect-user' ), |
|
| 465 | - __( 'Reconnect User', 'give' ) . "\n\n" |
|
| 464 | + esc_url(admin_url().'edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&user_id='.$user_id.'&give-message=reconnect-user'), |
|
| 465 | + __('Reconnect User', 'give')."\n\n" |
|
| 466 | 466 | ); |
| 467 | - $message .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
| 468 | - $message .= '{sitename}' . "\n"; |
|
| 467 | + $message .= __('Thank you,', 'give')."\n\n"; |
|
| 468 | + $message .= '{sitename}'."\n"; |
|
| 469 | 469 | |
| 470 | 470 | $emails = Give()->emails; |
| 471 | - $emails->__set( 'from_name', $from_name ); |
|
| 472 | - $emails->__set( 'from_email', $from_email ); |
|
| 473 | - $emails->__set( 'headers', $headers ); |
|
| 474 | - $emails->__set( 'heading', __( 'User - Donor Profile Disconnection', 'give' ) ); |
|
| 471 | + $emails->__set('from_name', $from_name); |
|
| 472 | + $emails->__set('from_email', $from_email); |
|
| 473 | + $emails->__set('headers', $headers); |
|
| 474 | + $emails->__set('heading', __('User - Donor Profile Disconnection', 'give')); |
|
| 475 | 475 | |
| 476 | - $emails->send( give_get_admin_notice_emails(), $subject, give_do_email_tags( $message ) ); |
|
| 476 | + $emails->send(give_get_admin_notice_emails(), $subject, give_do_email_tags($message)); |
|
| 477 | 477 | |
| 478 | 478 | } |
@@ -2,13 +2,13 @@ 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 | |
| 10 | 10 | // Bailout: Do not output anything if setting tab is not defined. |
| 11 | -if( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) : |
|
| 11 | +if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) : |
|
| 12 | 12 | /** |
| 13 | 13 | * Filter the form action. |
| 14 | 14 | * |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @since 1.8 |
| 20 | 20 | */ |
| 21 | - $form_method = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' ); |
|
| 21 | + $form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post'); |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Filter the main form tab. |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @since 1.8 |
| 32 | 32 | */ |
| 33 | - $form_open_tag = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method . '" id="give-mainform" action="" enctype="multipart/form-data">' ); |
|
| 34 | - $form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' ); |
|
| 33 | + $form_open_tag = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">'); |
|
| 34 | + $form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>'); |
|
| 35 | 35 | ?> |
| 36 | - <div class="wrap give-settings-page <?php echo self::$setting_filter_prefix . '-setting-page'; ?>"> |
|
| 36 | + <div class="wrap give-settings-page <?php echo self::$setting_filter_prefix.'-setting-page'; ?>"> |
|
| 37 | 37 | <?php echo $form_open_tag; ?> |
| 38 | - <h1 class="wp-heading-inline"><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1> |
|
| 38 | + <h1 class="wp-heading-inline"><?php echo esc_html($tabs[$current_tab]); ?></h1> |
|
| 39 | 39 | <?php |
| 40 | 40 | // Show messages. |
| 41 | 41 | self::show_messages(); |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | <div class="nav-tab-wrapper give-nav-tab-wrapper"> |
| 47 | 47 | <?php |
| 48 | - foreach ( $tabs as $name => $label ) { |
|
| 49 | - 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' : '' ) . '">' . $label . '</a>'; |
|
| 48 | + foreach ($tabs as $name => $label) { |
|
| 49 | + 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' : '').'">'.$label.'</a>'; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @since 1.8 |
| 60 | 60 | */ |
| 61 | - do_action( self::$setting_filter_prefix . '_tabs' ); |
|
| 61 | + do_action(self::$setting_filter_prefix.'_tabs'); |
|
| 62 | 62 | ?> |
| 63 | 63 | </div> |
| 64 | 64 | <div class="give-sub-nav-tab-wrapper"> |
| 65 | - <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></a> |
|
| 65 | + <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></a> |
|
| 66 | 66 | <nav class="give-sub-nav-tab give-hidden"></nav> |
| 67 | 67 | </div> |
| 68 | 68 | <?php |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @since 1.8 |
| 78 | 78 | */ |
| 79 | - do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" ); |
|
| 79 | + do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page"); |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Trigger Action. |
@@ -87,15 +87,15 @@ discard block |
||
| 87 | 87 | * |
| 88 | 88 | * @since 1.8 |
| 89 | 89 | */ |
| 90 | - do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" ); |
|
| 90 | + do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page"); |
|
| 91 | 91 | |
| 92 | - if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?> |
|
| 92 | + if (empty($GLOBALS['give_hide_save_button'])) : ?> |
|
| 93 | 93 | <div class="give-submit-wrap"> |
| 94 | - <?php wp_nonce_field( 'give-save-settings', '_give-save-settings' ); ?> |
|
| 95 | - <input name="save" class="button-primary give-save-button" type="submit" value="<?php esc_attr_e( 'Save changes', 'give' ); ?>" /> |
|
| 94 | + <?php wp_nonce_field('give-save-settings', '_give-save-settings'); ?> |
|
| 95 | + <input name="save" class="button-primary give-save-button" type="submit" value="<?php esc_attr_e('Save changes', 'give'); ?>" /> |
|
| 96 | 96 | </div> |
| 97 | 97 | <?php endif; ?> |
| 98 | 98 | <?php echo $form_close_tag; ?> |
| 99 | 99 | </div> |
| 100 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
| 100 | +<?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?> |
|
| 101 | 101 | <?php endif; ?> |
| 102 | 102 | \ No newline at end of file |
@@ -12,13 +12,13 @@ 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 | |
| 19 | 19 | // Load WP_List_Table if not loaded |
| 20 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 21 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 20 | +if ( ! class_exists('WP_List_Table')) { |
|
| 21 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -61,11 +61,11 @@ discard block |
||
| 61 | 61 | public function __construct() { |
| 62 | 62 | |
| 63 | 63 | // Set parent defaults |
| 64 | - parent::__construct( array( |
|
| 65 | - 'singular' => __( 'Donor', 'give' ), // Singular name of the listed records. |
|
| 66 | - 'plural' => __( 'Donors', 'give' ), // Plural name of the listed records. |
|
| 67 | - 'ajax' => false,// Does this table support ajax?. |
|
| 68 | - ) ); |
|
| 64 | + parent::__construct(array( |
|
| 65 | + 'singular' => __('Donor', 'give'), // Singular name of the listed records. |
|
| 66 | + 'plural' => __('Donors', 'give'), // Plural name of the listed records. |
|
| 67 | + 'ajax' => false, // Does this table support ajax?. |
|
| 68 | + )); |
|
| 69 | 69 | |
| 70 | 70 | } |
| 71 | 71 | |
@@ -80,22 +80,22 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return void |
| 82 | 82 | */ |
| 83 | - public function search_box( $text, $input_id ) { |
|
| 84 | - $input_id = $input_id . '-search-input'; |
|
| 83 | + public function search_box($text, $input_id) { |
|
| 84 | + $input_id = $input_id.'-search-input'; |
|
| 85 | 85 | |
| 86 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
| 87 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
| 86 | + if ( ! empty($_REQUEST['orderby'])) { |
|
| 87 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
| 88 | 88 | } |
| 89 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
| 90 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
| 89 | + if ( ! empty($_REQUEST['order'])) { |
|
| 90 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
| 91 | 91 | } |
| 92 | 92 | ?> |
| 93 | 93 | <p class="search-box" role="search"> |
| 94 | 94 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
| 95 | 95 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
| 96 | - <?php submit_button( $text, 'button', false, false, array( |
|
| 96 | + <?php submit_button($text, 'button', false, false, array( |
|
| 97 | 97 | 'ID' => 'search-submit', |
| 98 | - ) ); ?> |
|
| 98 | + )); ?> |
|
| 99 | 99 | </p> |
| 100 | 100 | <?php |
| 101 | 101 | } |
@@ -111,31 +111,31 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @return string Column Name. |
| 113 | 113 | */ |
| 114 | - public function column_default( $donor, $column_name ) { |
|
| 115 | - switch ( $column_name ) { |
|
| 114 | + public function column_default($donor, $column_name) { |
|
| 115 | + switch ($column_name) { |
|
| 116 | 116 | |
| 117 | 117 | case 'num_donations' : |
| 118 | 118 | $value = sprintf( |
| 119 | 119 | '<a href="%s">%s</a>', |
| 120 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor['id'] ) ), |
|
| 121 | - esc_html( $donor['num_donations'] ) |
|
| 120 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor['id'])), |
|
| 121 | + esc_html($donor['num_donations']) |
|
| 122 | 122 | ); |
| 123 | 123 | break; |
| 124 | 124 | |
| 125 | 125 | case 'amount_spent' : |
| 126 | - $value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) ); |
|
| 126 | + $value = give_currency_filter(give_format_amount($donor[$column_name], array('sanitize' => false))); |
|
| 127 | 127 | break; |
| 128 | 128 | |
| 129 | 129 | case 'date_created' : |
| 130 | - $value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) ); |
|
| 130 | + $value = date_i18n(give_date_format(), strtotime($donor['date_created'])); |
|
| 131 | 131 | break; |
| 132 | 132 | |
| 133 | 133 | default: |
| 134 | - $value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null; |
|
| 134 | + $value = isset($donor[$column_name]) ? $donor[$column_name] : null; |
|
| 135 | 135 | break; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - return apply_filters( "give_donors_column_{$column_name}", $value, $donor['id'] ); |
|
| 138 | + return apply_filters("give_donors_column_{$column_name}", $value, $donor['id']); |
|
| 139 | 139 | |
| 140 | 140 | } |
| 141 | 141 | |
@@ -146,13 +146,13 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @return string |
| 148 | 148 | */ |
| 149 | - public function column_name( $donor ) { |
|
| 150 | - $name = '#' . $donor['id'] . ' '; |
|
| 151 | - $name .= ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
| 152 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ); |
|
| 153 | - $actions = $this->get_row_actions( $donor ); |
|
| 149 | + public function column_name($donor) { |
|
| 150 | + $name = '#'.$donor['id'].' '; |
|
| 151 | + $name .= ! empty($donor['name']) ? $donor['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
| 152 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']); |
|
| 153 | + $actions = $this->get_row_actions($donor); |
|
| 154 | 154 | |
| 155 | - return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions ); |
|
| 155 | + return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -164,14 +164,14 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public function get_columns() { |
| 166 | 166 | $columns = array( |
| 167 | - 'name' => __( 'Name', 'give' ), |
|
| 168 | - 'email' => __( 'Email', 'give' ), |
|
| 169 | - 'num_donations' => __( 'Donations', 'give' ), |
|
| 170 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
| 171 | - 'date_created' => __( 'Date Created', 'give' ), |
|
| 167 | + 'name' => __('Name', 'give'), |
|
| 168 | + 'email' => __('Email', 'give'), |
|
| 169 | + 'num_donations' => __('Donations', 'give'), |
|
| 170 | + 'amount_spent' => __('Total Donated', 'give'), |
|
| 171 | + 'date_created' => __('Date Created', 'give'), |
|
| 172 | 172 | ); |
| 173 | 173 | |
| 174 | - return apply_filters( 'give_list_donors_columns', $columns ); |
|
| 174 | + return apply_filters('give_list_donors_columns', $columns); |
|
| 175 | 175 | |
| 176 | 176 | } |
| 177 | 177 | |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | public function get_sortable_columns() { |
| 186 | 186 | |
| 187 | 187 | $columns = array( |
| 188 | - 'date_created' => array( 'date_created', true ), |
|
| 189 | - 'name' => array( 'name', true ), |
|
| 190 | - 'num_donations' => array( 'purchase_count', false ), |
|
| 191 | - 'amount_spent' => array( 'purchase_value', false ), |
|
| 188 | + 'date_created' => array('date_created', true), |
|
| 189 | + 'name' => array('name', true), |
|
| 190 | + 'num_donations' => array('purchase_count', false), |
|
| 191 | + 'amount_spent' => array('purchase_value', false), |
|
| 192 | 192 | ); |
| 193 | 193 | |
| 194 | - return apply_filters( 'give_list_donors_sortable_columns', $columns ); |
|
| 194 | + return apply_filters('give_list_donors_sortable_columns', $columns); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -204,19 +204,19 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @return array An array of action links. |
| 206 | 206 | */ |
| 207 | - public function get_row_actions( $donor ) { |
|
| 207 | + public function get_row_actions($donor) { |
|
| 208 | 208 | |
| 209 | 209 | $actions = array( |
| 210 | 210 | |
| 211 | - 'view' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ), |
|
| 211 | + 'view' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')), |
|
| 212 | 212 | |
| 213 | - 'notes' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ), |
|
| 213 | + 'notes' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')), |
|
| 214 | 214 | |
| 215 | - 'delete' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor['id'] ), sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ), |
|
| 215 | + 'delete' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor['id']), sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')), |
|
| 216 | 216 | |
| 217 | 217 | ); |
| 218 | 218 | |
| 219 | - return apply_filters( 'give_donor_row_actions', $actions, $donor ); |
|
| 219 | + return apply_filters('give_donor_row_actions', $actions, $donor); |
|
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * @since 1.0 |
| 231 | 231 | * @return void |
| 232 | 232 | */ |
| 233 | - public function bulk_actions( $which = '' ) { |
|
| 233 | + public function bulk_actions($which = '') { |
|
| 234 | 234 | // These aren't really bulk actions but this outputs the markup in the right place. |
| 235 | 235 | } |
| 236 | 236 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * @return int Current page number. |
| 243 | 243 | */ |
| 244 | 244 | public function get_paged() { |
| 245 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 245 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * @return mixed string If search is present, false otherwise. |
| 254 | 254 | */ |
| 255 | 255 | public function get_search() { |
| 256 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
| 256 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -270,13 +270,13 @@ discard block |
||
| 270 | 270 | |
| 271 | 271 | // Get donor query. |
| 272 | 272 | $args = $this->get_donor_query(); |
| 273 | - $donors = Give()->donors->get_donors( $args ); |
|
| 273 | + $donors = Give()->donors->get_donors($args); |
|
| 274 | 274 | |
| 275 | - if ( $donors ) { |
|
| 275 | + if ($donors) { |
|
| 276 | 276 | |
| 277 | - foreach ( $donors as $donor ) { |
|
| 277 | + foreach ($donors as $donor) { |
|
| 278 | 278 | |
| 279 | - $user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0; |
|
| 279 | + $user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0; |
|
| 280 | 280 | |
| 281 | 281 | $data[] = array( |
| 282 | 282 | 'id' => $donor->id, |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - return apply_filters( 'give_donors_column_query_data', $data ); |
|
| 293 | + return apply_filters('give_donors_column_query_data', $data); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -305,9 +305,9 @@ discard block |
||
| 305 | 305 | |
| 306 | 306 | $_donor_query['number'] = - 1; |
| 307 | 307 | $_donor_query['offset'] = 0; |
| 308 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
| 308 | + $donors = Give()->donors->get_donors($_donor_query); |
|
| 309 | 309 | |
| 310 | - return count( $donors ); |
|
| 310 | + return count($donors); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
@@ -319,10 +319,10 @@ discard block |
||
| 319 | 319 | */ |
| 320 | 320 | public function get_donor_query() { |
| 321 | 321 | $paged = $this->get_paged(); |
| 322 | - $offset = $this->per_page * ( $paged - 1 ); |
|
| 322 | + $offset = $this->per_page * ($paged - 1); |
|
| 323 | 323 | $search = $this->get_search(); |
| 324 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
| 325 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
| 324 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
| 325 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
| 326 | 326 | |
| 327 | 327 | $args = array( |
| 328 | 328 | 'number' => $this->per_page, |
@@ -331,10 +331,10 @@ discard block |
||
| 331 | 331 | 'orderby' => $orderby, |
| 332 | 332 | ); |
| 333 | 333 | |
| 334 | - if ( $search ) { |
|
| 335 | - if ( is_email( $search ) ) { |
|
| 334 | + if ($search) { |
|
| 335 | + if (is_email($search)) { |
|
| 336 | 336 | $args['email'] = $search; |
| 337 | - } elseif ( is_numeric( $search ) ) { |
|
| 337 | + } elseif (is_numeric($search)) { |
|
| 338 | 338 | $args['id'] = $search; |
| 339 | 339 | } else { |
| 340 | 340 | $args['name'] = $search; |
@@ -357,16 +357,16 @@ discard block |
||
| 357 | 357 | $hidden = array(); // No hidden columns. |
| 358 | 358 | $sortable = $this->get_sortable_columns(); |
| 359 | 359 | |
| 360 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 360 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 361 | 361 | |
| 362 | 362 | $this->items = $this->donor_data(); |
| 363 | 363 | |
| 364 | 364 | $this->total = $this->get_donor_count(); |
| 365 | 365 | |
| 366 | - $this->set_pagination_args( array( |
|
| 366 | + $this->set_pagination_args(array( |
|
| 367 | 367 | 'total_items' => $this->total, |
| 368 | 368 | 'per_page' => $this->per_page, |
| 369 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
| 370 | - ) ); |
|
| 369 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
| 370 | + )); |
|
| 371 | 371 | } |
| 372 | 372 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,17 +23,17 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array|bool $output Response messages |
| 25 | 25 | */ |
| 26 | -function give_edit_donor( $args ) { |
|
| 26 | +function give_edit_donor($args) { |
|
| 27 | 27 | |
| 28 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
| 28 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
| 29 | 29 | |
| 30 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
| 31 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
| 30 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
| 31 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
| 32 | 32 | 'response' => 403, |
| 33 | - ) ); |
|
| 33 | + )); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if ( empty( $args ) ) { |
|
| 36 | + if (empty($args)) { |
|
| 37 | 37 | return false; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -41,15 +41,15 @@ discard block |
||
| 41 | 41 | $donor_id = (int) $args['customerinfo']['id']; |
| 42 | 42 | $nonce = $args['_wpnonce']; |
| 43 | 43 | |
| 44 | - if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) { |
|
| 45 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
| 44 | + if ( ! wp_verify_nonce($nonce, 'edit-donor')) { |
|
| 45 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
| 46 | 46 | 'response' => 400, |
| 47 | - ) ); |
|
| 47 | + )); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - $donor = new Give_Donor( $donor_id ); |
|
| 50 | + $donor = new Give_Donor($donor_id); |
|
| 51 | 51 | |
| 52 | - if ( empty( $donor->id ) ) { |
|
| 52 | + if (empty($donor->id)) { |
|
| 53 | 53 | return false; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -64,67 +64,67 @@ discard block |
||
| 64 | 64 | 'country' => '', |
| 65 | 65 | ); |
| 66 | 66 | |
| 67 | - $donor_info = wp_parse_args( $donor_info, $defaults ); |
|
| 67 | + $donor_info = wp_parse_args($donor_info, $defaults); |
|
| 68 | 68 | |
| 69 | - if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) { |
|
| 69 | + if ((int) $donor_info['user_id'] !== (int) $donor->user_id) { |
|
| 70 | 70 | |
| 71 | 71 | // Make sure we don't already have this user attached to a donor. |
| 72 | - if ( ! empty( $donor_info['user_id'] ) && false !== Give()->donors->get_donor_by( 'user_id', $donor_info['user_id'] ) ) { |
|
| 73 | - give_set_error( 'give-invalid-donor-user_id', sprintf( __( 'The User ID #%d is already associated with a different donor.', 'give' ), $donor_info['user_id'] ) ); |
|
| 72 | + if ( ! empty($donor_info['user_id']) && false !== Give()->donors->get_donor_by('user_id', $donor_info['user_id'])) { |
|
| 73 | + give_set_error('give-invalid-donor-user_id', sprintf(__('The User ID #%d is already associated with a different donor.', 'give'), $donor_info['user_id'])); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // Make sure it's actually a user. |
| 77 | - $user = get_user_by( 'id', $donor_info['user_id'] ); |
|
| 78 | - if ( ! empty( $donor_info['user_id'] ) && false === $user ) { |
|
| 79 | - give_set_error( 'give-invalid-user_id', sprintf( __( 'The User ID #%d does not exist. Please assign an existing user.', 'give' ), $donor_info['user_id'] ) ); |
|
| 77 | + $user = get_user_by('id', $donor_info['user_id']); |
|
| 78 | + if ( ! empty($donor_info['user_id']) && false === $user) { |
|
| 79 | + give_set_error('give-invalid-user_id', sprintf(__('The User ID #%d does not exist. Please assign an existing user.', 'give'), $donor_info['user_id'])); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( give_get_errors() ) { |
|
| 83 | + if (give_get_errors()) { |
|
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // Setup the donor address, if present. |
| 88 | 88 | $address = array(); |
| 89 | - if ( intval( $donor_info['user_id'] ) > 0 ) { |
|
| 90 | - |
|
| 91 | - $current_address = (array) get_user_meta( $donor_info['user_id'], '_give_user_address', true ); |
|
| 92 | - |
|
| 93 | - if ( is_array( $current_address ) && 0 < count( $current_address ) ) { |
|
| 94 | - $current_address = wp_parse_args( $current_address, $defaults ); |
|
| 95 | - $address['line1'] = ! empty( $donor_info['line1'] ) ? $donor_info['line1'] : $current_address['line1']; |
|
| 96 | - $address['line2'] = ! empty( $donor_info['line2'] ) ? $donor_info['line2'] : $current_address['line2']; |
|
| 97 | - $address['city'] = ! empty( $donor_info['city'] ) ? $donor_info['city'] : $current_address['city']; |
|
| 98 | - $address['country'] = ! empty( $donor_info['country'] ) ? $donor_info['country'] : $current_address['country']; |
|
| 99 | - $address['zip'] = ! empty( $donor_info['zip'] ) ? $donor_info['zip'] : $current_address['zip']; |
|
| 100 | - $address['state'] = ! empty( $donor_info['state'] ) ? $donor_info['state'] : $current_address['state']; |
|
| 89 | + if (intval($donor_info['user_id']) > 0) { |
|
| 90 | + |
|
| 91 | + $current_address = (array) get_user_meta($donor_info['user_id'], '_give_user_address', true); |
|
| 92 | + |
|
| 93 | + if (is_array($current_address) && 0 < count($current_address)) { |
|
| 94 | + $current_address = wp_parse_args($current_address, $defaults); |
|
| 95 | + $address['line1'] = ! empty($donor_info['line1']) ? $donor_info['line1'] : $current_address['line1']; |
|
| 96 | + $address['line2'] = ! empty($donor_info['line2']) ? $donor_info['line2'] : $current_address['line2']; |
|
| 97 | + $address['city'] = ! empty($donor_info['city']) ? $donor_info['city'] : $current_address['city']; |
|
| 98 | + $address['country'] = ! empty($donor_info['country']) ? $donor_info['country'] : $current_address['country']; |
|
| 99 | + $address['zip'] = ! empty($donor_info['zip']) ? $donor_info['zip'] : $current_address['zip']; |
|
| 100 | + $address['state'] = ! empty($donor_info['state']) ? $donor_info['state'] : $current_address['state']; |
|
| 101 | 101 | } else { |
| 102 | - $address['line1'] = ! empty( $donor_info['line1'] ) ? $donor_info['line1'] : ''; |
|
| 103 | - $address['line2'] = ! empty( $donor_info['line2'] ) ? $donor_info['line2'] : ''; |
|
| 104 | - $address['city'] = ! empty( $donor_info['city'] ) ? $donor_info['city'] : ''; |
|
| 105 | - $address['country'] = ! empty( $donor_info['country'] ) ? $donor_info['country'] : ''; |
|
| 106 | - $address['zip'] = ! empty( $donor_info['zip'] ) ? $donor_info['zip'] : ''; |
|
| 107 | - $address['state'] = ! empty( $donor_info['state'] ) ? $donor_info['state'] : ''; |
|
| 102 | + $address['line1'] = ! empty($donor_info['line1']) ? $donor_info['line1'] : ''; |
|
| 103 | + $address['line2'] = ! empty($donor_info['line2']) ? $donor_info['line2'] : ''; |
|
| 104 | + $address['city'] = ! empty($donor_info['city']) ? $donor_info['city'] : ''; |
|
| 105 | + $address['country'] = ! empty($donor_info['country']) ? $donor_info['country'] : ''; |
|
| 106 | + $address['zip'] = ! empty($donor_info['zip']) ? $donor_info['zip'] : ''; |
|
| 107 | + $address['state'] = ! empty($donor_info['state']) ? $donor_info['state'] : ''; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // Sanitize the inputs. |
| 113 | 113 | $donor_data = array(); |
| 114 | - $donor_data['name'] = strip_tags( stripslashes( $donor_info['name'] ) ); |
|
| 114 | + $donor_data['name'] = strip_tags(stripslashes($donor_info['name'])); |
|
| 115 | 115 | $donor_data['user_id'] = $donor_info['user_id']; |
| 116 | 116 | |
| 117 | - $donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id ); |
|
| 118 | - $address = apply_filters( 'give_edit_donor_address', $address, $donor_id ); |
|
| 117 | + $donor_data = apply_filters('give_edit_donor_info', $donor_data, $donor_id); |
|
| 118 | + $address = apply_filters('give_edit_donor_address', $address, $donor_id); |
|
| 119 | 119 | |
| 120 | - $donor_data = array_map( 'sanitize_text_field', $donor_data ); |
|
| 121 | - $address = array_map( 'sanitize_text_field', $address ); |
|
| 120 | + $donor_data = array_map('sanitize_text_field', $donor_data); |
|
| 121 | + $address = array_map('sanitize_text_field', $address); |
|
| 122 | 122 | |
| 123 | - $output = give_connect_user_donor_profile( $donor, $donor_data, $address ); |
|
| 123 | + $output = give_connect_user_donor_profile($donor, $donor_data, $address); |
|
| 124 | 124 | |
| 125 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 126 | - header( 'Content-Type: application/json' ); |
|
| 127 | - echo json_encode( $output ); |
|
| 125 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 126 | + header('Content-Type: application/json'); |
|
| 127 | + echo json_encode($output); |
|
| 128 | 128 | wp_die(); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | -add_action( 'give_edit-donor', 'give_edit_donor', 10, 1 ); |
|
| 135 | +add_action('give_edit-donor', 'give_edit_donor', 10, 1); |
|
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * Save a donor note. |
@@ -143,40 +143,40 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @return int The Note ID that was saved, or 0 if nothing was saved. |
| 145 | 145 | */ |
| 146 | -function give_donor_save_note( $args ) { |
|
| 146 | +function give_donor_save_note($args) { |
|
| 147 | 147 | |
| 148 | - $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' ); |
|
| 148 | + $donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports'); |
|
| 149 | 149 | |
| 150 | - if ( ! is_admin() || ! current_user_can( $donor_view_role ) ) { |
|
| 151 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
| 150 | + if ( ! is_admin() || ! current_user_can($donor_view_role)) { |
|
| 151 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
| 152 | 152 | 'response' => 403, |
| 153 | - ) ); |
|
| 153 | + )); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if ( empty( $args ) ) { |
|
| 156 | + if (empty($args)) { |
|
| 157 | 157 | return false; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - $donor_note = trim( sanitize_text_field( $args['donor_note'] ) ); |
|
| 160 | + $donor_note = trim(sanitize_text_field($args['donor_note'])); |
|
| 161 | 161 | $donor_id = (int) $args['customer_id']; |
| 162 | 162 | $nonce = $args['add_donor_note_nonce']; |
| 163 | 163 | |
| 164 | - if ( ! wp_verify_nonce( $nonce, 'add-donor-note' ) ) { |
|
| 165 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
| 164 | + if ( ! wp_verify_nonce($nonce, 'add-donor-note')) { |
|
| 165 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
| 166 | 166 | 'response' => 400, |
| 167 | - ) ); |
|
| 167 | + )); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( empty( $donor_note ) ) { |
|
| 171 | - give_set_error( 'empty-donor-note', __( 'A note is required.', 'give' ) ); |
|
| 170 | + if (empty($donor_note)) { |
|
| 171 | + give_set_error('empty-donor-note', __('A note is required.', 'give')); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if ( give_get_errors() ) { |
|
| 174 | + if (give_get_errors()) { |
|
| 175 | 175 | return false; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - $donor = new Give_Donor( $donor_id ); |
|
| 179 | - $new_note = $donor->add_note( $donor_note ); |
|
| 178 | + $donor = new Give_Donor($donor_id); |
|
| 179 | + $new_note = $donor->add_note($donor_note); |
|
| 180 | 180 | |
| 181 | 181 | /** |
| 182 | 182 | * Fires before inserting donor note. |
@@ -186,22 +186,22 @@ discard block |
||
| 186 | 186 | * @param int $donor_id The ID of the donor. |
| 187 | 187 | * @param string $new_note Note content. |
| 188 | 188 | */ |
| 189 | - do_action( 'give_pre_insert_donor_note', $donor_id, $new_note ); |
|
| 189 | + do_action('give_pre_insert_donor_note', $donor_id, $new_note); |
|
| 190 | 190 | |
| 191 | - if ( ! empty( $new_note ) && ! empty( $donor->id ) ) { |
|
| 191 | + if ( ! empty($new_note) && ! empty($donor->id)) { |
|
| 192 | 192 | |
| 193 | 193 | ob_start(); |
| 194 | 194 | ?> |
| 195 | 195 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
| 196 | 196 | <span class="note-content-wrap"> |
| 197 | - <?php echo stripslashes( $new_note ); ?> |
|
| 197 | + <?php echo stripslashes($new_note); ?> |
|
| 198 | 198 | </span> |
| 199 | 199 | </div> |
| 200 | 200 | <?php |
| 201 | 201 | $output = ob_get_contents(); |
| 202 | 202 | ob_end_clean(); |
| 203 | 203 | |
| 204 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 204 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 205 | 205 | echo $output; |
| 206 | 206 | exit; |
| 207 | 207 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | -add_action( 'give_add-donor-note', 'give_donor_save_note', 10, 1 ); |
|
| 217 | +add_action('give_add-donor-note', 'give_donor_save_note', 10, 1); |
|
| 218 | 218 | |
| 219 | 219 | /** |
| 220 | 220 | * Delete a donor. |
@@ -225,41 +225,41 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @return int Whether it was a successful deletion. |
| 227 | 227 | */ |
| 228 | -function give_donor_delete( $args ) { |
|
| 228 | +function give_donor_delete($args) { |
|
| 229 | 229 | |
| 230 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
| 230 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
| 231 | 231 | |
| 232 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
| 233 | - wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array( |
|
| 232 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
| 233 | + wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array( |
|
| 234 | 234 | 'response' => 403, |
| 235 | - ) ); |
|
| 235 | + )); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - if ( empty( $args ) ) { |
|
| 238 | + if (empty($args)) { |
|
| 239 | 239 | return false; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $donor_id = (int) $args['customer_id']; |
| 243 | - $confirm = ! empty( $args['give-donor-delete-confirm'] ) ? true : false; |
|
| 244 | - $remove_data = ! empty( $args['give-donor-delete-records'] ) ? true : false; |
|
| 243 | + $confirm = ! empty($args['give-donor-delete-confirm']) ? true : false; |
|
| 244 | + $remove_data = ! empty($args['give-donor-delete-records']) ? true : false; |
|
| 245 | 245 | $nonce = $args['_wpnonce']; |
| 246 | 246 | |
| 247 | - if ( ! wp_verify_nonce( $nonce, 'delete-donor' ) ) { |
|
| 248 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
| 247 | + if ( ! wp_verify_nonce($nonce, 'delete-donor')) { |
|
| 248 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
| 249 | 249 | 'response' => 400, |
| 250 | - ) ); |
|
| 250 | + )); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - if ( ! $confirm ) { |
|
| 254 | - give_set_error( 'donor-delete-no-confirm', __( 'Please confirm you want to delete this donor.', 'give' ) ); |
|
| 253 | + if ( ! $confirm) { |
|
| 254 | + give_set_error('donor-delete-no-confirm', __('Please confirm you want to delete this donor.', 'give')); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if ( give_get_errors() ) { |
|
| 258 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id ) ); |
|
| 257 | + if (give_get_errors()) { |
|
| 258 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id)); |
|
| 259 | 259 | exit; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - $donor = new Give_Donor( $donor_id ); |
|
| 262 | + $donor = new Give_Donor($donor_id); |
|
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | 265 | * Fires before deleting donor. |
@@ -270,50 +270,50 @@ discard block |
||
| 270 | 270 | * @param bool $confirm Delete confirmation. |
| 271 | 271 | * @param bool $remove_data Records delete confirmation. |
| 272 | 272 | */ |
| 273 | - do_action( 'give_pre_delete_donor', $donor_id, $confirm, $remove_data ); |
|
| 273 | + do_action('give_pre_delete_donor', $donor_id, $confirm, $remove_data); |
|
| 274 | 274 | |
| 275 | - if ( $donor->id > 0 ) { |
|
| 275 | + if ($donor->id > 0) { |
|
| 276 | 276 | |
| 277 | - $payments_array = explode( ',', $donor->payment_ids ); |
|
| 278 | - $success = Give()->donors->delete( $donor->id ); |
|
| 277 | + $payments_array = explode(',', $donor->payment_ids); |
|
| 278 | + $success = Give()->donors->delete($donor->id); |
|
| 279 | 279 | |
| 280 | - if ( $success ) { |
|
| 280 | + if ($success) { |
|
| 281 | 281 | |
| 282 | - if ( $remove_data ) { |
|
| 282 | + if ($remove_data) { |
|
| 283 | 283 | |
| 284 | 284 | // Remove all donations, logs, etc. |
| 285 | - foreach ( $payments_array as $payment_id ) { |
|
| 286 | - give_delete_donation( $payment_id ); |
|
| 285 | + foreach ($payments_array as $payment_id) { |
|
| 286 | + give_delete_donation($payment_id); |
|
| 287 | 287 | } |
| 288 | 288 | } else { |
| 289 | 289 | |
| 290 | 290 | // Just set the donations to customer_id of 0. |
| 291 | - foreach ( $payments_array as $payment_id ) { |
|
| 292 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
| 291 | + foreach ($payments_array as $payment_id) { |
|
| 292 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted' ); |
|
| 296 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted'); |
|
| 297 | 297 | |
| 298 | 298 | } else { |
| 299 | 299 | |
| 300 | - give_set_error( 'give-donor-delete-failed', __( 'Error deleting donor.', 'give' ) ); |
|
| 301 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor_id ); |
|
| 300 | + give_set_error('give-donor-delete-failed', __('Error deleting donor.', 'give')); |
|
| 301 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor_id); |
|
| 302 | 302 | |
| 303 | 303 | } |
| 304 | 304 | } else { |
| 305 | 305 | |
| 306 | - give_set_error( 'give-donor-delete-invalid-id', __( 'Invalid Donor ID.', 'give' ) ); |
|
| 307 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
| 306 | + give_set_error('give-donor-delete-invalid-id', __('Invalid Donor ID.', 'give')); |
|
| 307 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
| 308 | 308 | |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - wp_redirect( $redirect ); |
|
| 311 | + wp_redirect($redirect); |
|
| 312 | 312 | exit; |
| 313 | 313 | |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | -add_action( 'give_delete-donor', 'give_donor_delete', 10, 1 ); |
|
| 316 | +add_action('give_delete-donor', 'give_donor_delete', 10, 1); |
|
| 317 | 317 | |
| 318 | 318 | /** |
| 319 | 319 | * Disconnect a user ID from a donor |
@@ -324,17 +324,17 @@ discard block |
||
| 324 | 324 | * |
| 325 | 325 | * @return bool|array If the disconnect was successful. |
| 326 | 326 | */ |
| 327 | -function give_disconnect_donor_user_id( $args ) { |
|
| 327 | +function give_disconnect_donor_user_id($args) { |
|
| 328 | 328 | |
| 329 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
| 329 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
| 330 | 330 | |
| 331 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
| 332 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
| 331 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
| 332 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
| 333 | 333 | 'response' => 403, |
| 334 | - ) ); |
|
| 334 | + )); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - if ( empty( $args ) ) { |
|
| 337 | + if (empty($args)) { |
|
| 338 | 338 | return false; |
| 339 | 339 | } |
| 340 | 340 | |
@@ -342,14 +342,14 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | $nonce = $args['_wpnonce']; |
| 344 | 344 | |
| 345 | - if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) { |
|
| 346 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
| 345 | + if ( ! wp_verify_nonce($nonce, 'edit-donor')) { |
|
| 346 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
| 347 | 347 | 'response' => 400, |
| 348 | - ) ); |
|
| 348 | + )); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - $donor = new Give_Donor( $donor_id ); |
|
| 352 | - if ( empty( $donor->id ) ) { |
|
| 351 | + $donor = new Give_Donor($donor_id); |
|
| 352 | + if (empty($donor->id)) { |
|
| 353 | 353 | return false; |
| 354 | 354 | } |
| 355 | 355 | |
@@ -363,34 +363,34 @@ discard block |
||
| 363 | 363 | * @param int $donor_id The ID of the donor. |
| 364 | 364 | * @param int $user_id The ID of the user. |
| 365 | 365 | */ |
| 366 | - do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id ); |
|
| 366 | + do_action('give_pre_donor_disconnect_user_id', $donor_id, $user_id); |
|
| 367 | 367 | |
| 368 | 368 | $output = array(); |
| 369 | 369 | $donor_args = array( |
| 370 | 370 | 'user_id' => 0, |
| 371 | 371 | ); |
| 372 | 372 | |
| 373 | - if ( $donor->update( $donor_args ) ) { |
|
| 373 | + if ($donor->update($donor_args)) { |
|
| 374 | 374 | global $wpdb; |
| 375 | 375 | |
| 376 | - if ( ! empty( $donor->payment_ids ) ) { |
|
| 377 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )" ); |
|
| 376 | + if ( ! empty($donor->payment_ids)) { |
|
| 377 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )"); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | // Set Donor Disconnection status true, if user and donor are disconnected with each other. |
| 381 | - update_user_meta( $user_id, '_give_is_donor_disconnected', true ); |
|
| 382 | - update_user_meta( $user_id, '_give_disconnected_donor_id', $donor->id ); |
|
| 383 | - $donor->update_meta( '_give_disconnected_user_id', $user_id ); |
|
| 381 | + update_user_meta($user_id, '_give_is_donor_disconnected', true); |
|
| 382 | + update_user_meta($user_id, '_give_disconnected_donor_id', $donor->id); |
|
| 383 | + $donor->update_meta('_give_disconnected_user_id', $user_id); |
|
| 384 | 384 | |
| 385 | 385 | $output['success'] = true; |
| 386 | 386 | |
| 387 | 387 | } else { |
| 388 | 388 | |
| 389 | 389 | $output['success'] = false; |
| 390 | - give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) ); |
|
| 390 | + give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give')); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - $output['redirect'] = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' ) . $donor_id; |
|
| 393 | + $output['redirect'] = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id=').$donor_id; |
|
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | 396 | * Fires after disconnecting user ID from a donor. |
@@ -399,11 +399,11 @@ discard block |
||
| 399 | 399 | * |
| 400 | 400 | * @param int $donor_id The ID of the donor. |
| 401 | 401 | */ |
| 402 | - do_action( 'give_post_donor_disconnect_user_id', $donor_id ); |
|
| 402 | + do_action('give_post_donor_disconnect_user_id', $donor_id); |
|
| 403 | 403 | |
| 404 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 405 | - header( 'Content-Type: application/json' ); |
|
| 406 | - echo json_encode( $output ); |
|
| 404 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 405 | + header('Content-Type: application/json'); |
|
| 406 | + echo json_encode($output); |
|
| 407 | 407 | wp_die(); |
| 408 | 408 | } |
| 409 | 409 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | -add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 ); |
|
| 414 | +add_action('give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1); |
|
| 415 | 415 | |
| 416 | 416 | /** |
| 417 | 417 | * Add an email address to the donor from within the admin and log a donor note. |
@@ -422,90 +422,90 @@ discard block |
||
| 422 | 422 | * |
| 423 | 423 | * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string). |
| 424 | 424 | */ |
| 425 | -function give_add_donor_email( $args ) { |
|
| 425 | +function give_add_donor_email($args) { |
|
| 426 | 426 | /** |
| 427 | 427 | * Define variable |
| 428 | 428 | * |
| 429 | 429 | * @since 1.8.14 |
| 430 | 430 | */ |
| 431 | 431 | $donor_id = ''; |
| 432 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
| 432 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
| 433 | 433 | |
| 434 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
| 435 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
| 434 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
| 435 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
| 436 | 436 | 'response' => 403, |
| 437 | - ) ); |
|
| 437 | + )); |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | $output = array(); |
| 441 | - if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) { |
|
| 441 | + if (empty($args) || empty($args['email']) || empty($args['customer_id'])) { |
|
| 442 | 442 | $output['success'] = false; |
| 443 | - if ( empty( $args['email'] ) ) { |
|
| 444 | - $output['message'] = __( 'Email address is required.', 'give' ); |
|
| 445 | - } elseif ( empty( $args['customer_id'] ) ) { |
|
| 446 | - $output['message'] = __( 'Donor ID is required.', 'give' ); |
|
| 443 | + if (empty($args['email'])) { |
|
| 444 | + $output['message'] = __('Email address is required.', 'give'); |
|
| 445 | + } elseif (empty($args['customer_id'])) { |
|
| 446 | + $output['message'] = __('Donor ID is required.', 'give'); |
|
| 447 | 447 | } else { |
| 448 | - $output['message'] = __( 'An error has occurred. Please try again.', 'give' ); |
|
| 448 | + $output['message'] = __('An error has occurred. Please try again.', 'give'); |
|
| 449 | 449 | } |
| 450 | - } elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) { |
|
| 450 | + } elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) { |
|
| 451 | 451 | $output = array( |
| 452 | 452 | 'success' => false, |
| 453 | - 'message' => __( 'Nonce verification failed.', 'give' ), |
|
| 453 | + 'message' => __('Nonce verification failed.', 'give'), |
|
| 454 | 454 | ); |
| 455 | - } elseif ( ! is_email( $args['email'] ) ) { |
|
| 455 | + } elseif ( ! is_email($args['email'])) { |
|
| 456 | 456 | $output = array( |
| 457 | 457 | 'success' => false, |
| 458 | - 'message' => __( 'Invalid email.', 'give' ), |
|
| 458 | + 'message' => __('Invalid email.', 'give'), |
|
| 459 | 459 | ); |
| 460 | 460 | } else { |
| 461 | - $email = sanitize_email( $args['email'] ); |
|
| 461 | + $email = sanitize_email($args['email']); |
|
| 462 | 462 | $donor_id = (int) $args['customer_id']; |
| 463 | 463 | $primary = 'true' === $args['primary'] ? true : false; |
| 464 | - $donor = new Give_Donor( $donor_id ); |
|
| 465 | - if ( false === $donor->add_email( $email, $primary ) ) { |
|
| 466 | - if ( in_array( $email, $donor->emails ) ) { |
|
| 464 | + $donor = new Give_Donor($donor_id); |
|
| 465 | + if (false === $donor->add_email($email, $primary)) { |
|
| 466 | + if (in_array($email, $donor->emails)) { |
|
| 467 | 467 | $output = array( |
| 468 | 468 | 'success' => false, |
| 469 | - 'message' => __( 'Email already associated with this donor.', 'give' ), |
|
| 469 | + 'message' => __('Email already associated with this donor.', 'give'), |
|
| 470 | 470 | ); |
| 471 | 471 | } else { |
| 472 | 472 | $output = array( |
| 473 | 473 | 'success' => false, |
| 474 | - 'message' => __( 'Email address is already associated with another donor.', 'give' ), |
|
| 474 | + 'message' => __('Email address is already associated with another donor.', 'give'), |
|
| 475 | 475 | ); |
| 476 | 476 | } |
| 477 | 477 | } else { |
| 478 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&give-message=email-added' ); |
|
| 478 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&give-message=email-added'); |
|
| 479 | 479 | $output = array( |
| 480 | 480 | 'success' => true, |
| 481 | - 'message' => __( 'Email successfully added to donor.', 'give' ), |
|
| 481 | + 'message' => __('Email successfully added to donor.', 'give'), |
|
| 482 | 482 | 'redirect' => $redirect, |
| 483 | 483 | ); |
| 484 | 484 | |
| 485 | 485 | $user = wp_get_current_user(); |
| 486 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
| 487 | - $donor_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login ); |
|
| 488 | - $donor->add_note( $donor_note ); |
|
| 486 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
| 487 | + $donor_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login); |
|
| 488 | + $donor->add_note($donor_note); |
|
| 489 | 489 | |
| 490 | - if ( $primary ) { |
|
| 491 | - $donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login ); |
|
| 492 | - $donor->add_note( $donor_note ); |
|
| 490 | + if ($primary) { |
|
| 491 | + $donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login); |
|
| 492 | + $donor->add_note($donor_note); |
|
| 493 | 493 | } |
| 494 | 494 | } |
| 495 | 495 | }// End if(). |
| 496 | 496 | |
| 497 | - do_action( 'give_post_add_donor_email', $donor_id, $args ); |
|
| 497 | + do_action('give_post_add_donor_email', $donor_id, $args); |
|
| 498 | 498 | |
| 499 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 500 | - header( 'Content-Type: application/json' ); |
|
| 501 | - echo json_encode( $output ); |
|
| 499 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 500 | + header('Content-Type: application/json'); |
|
| 501 | + echo json_encode($output); |
|
| 502 | 502 | wp_die(); |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | return $output; |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | -add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 ); |
|
| 508 | +add_action('give_add_donor_email', 'give_add_donor_email', 10, 1); |
|
| 509 | 509 | |
| 510 | 510 | |
| 511 | 511 | /** |
@@ -515,39 +515,39 @@ discard block |
||
| 515 | 515 | * @return bool|null |
| 516 | 516 | */ |
| 517 | 517 | function give_remove_donor_email() { |
| 518 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
| 518 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
| 519 | 519 | return false; |
| 520 | 520 | } |
| 521 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
| 521 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
| 522 | 522 | return false; |
| 523 | 523 | } |
| 524 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
| 524 | + if (empty($_GET['_wpnonce'])) { |
|
| 525 | 525 | return false; |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | $nonce = $_GET['_wpnonce']; |
| 529 | - if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) { |
|
| 530 | - wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( |
|
| 529 | + if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) { |
|
| 530 | + wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array( |
|
| 531 | 531 | 'response' => 403, |
| 532 | - ) ); |
|
| 532 | + )); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - $donor = new Give_Donor( $_GET['id'] ); |
|
| 536 | - if ( $donor->remove_email( $_GET['email'] ) ) { |
|
| 537 | - $url = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
| 535 | + $donor = new Give_Donor($_GET['id']); |
|
| 536 | + if ($donor->remove_email($_GET['email'])) { |
|
| 537 | + $url = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
| 538 | 538 | $user = wp_get_current_user(); |
| 539 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
| 540 | - $donor_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
| 541 | - $donor->add_note( $donor_note ); |
|
| 539 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
| 540 | + $donor_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login); |
|
| 541 | + $donor->add_note($donor_note); |
|
| 542 | 542 | } else { |
| 543 | - $url = add_query_arg( 'give-message', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
| 543 | + $url = add_query_arg('give-message', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - wp_safe_redirect( $url ); |
|
| 546 | + wp_safe_redirect($url); |
|
| 547 | 547 | exit; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | -add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 ); |
|
| 550 | +add_action('give_remove_donor_email', 'give_remove_donor_email', 10); |
|
| 551 | 551 | |
| 552 | 552 | |
| 553 | 553 | /** |
@@ -558,41 +558,41 @@ discard block |
||
| 558 | 558 | * @return bool|null |
| 559 | 559 | */ |
| 560 | 560 | function give_set_donor_primary_email() { |
| 561 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
| 561 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
| 562 | 562 | return false; |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
| 565 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
| 566 | 566 | return false; |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
| 569 | + if (empty($_GET['_wpnonce'])) { |
|
| 570 | 570 | return false; |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | $nonce = $_GET['_wpnonce']; |
| 574 | 574 | |
| 575 | - if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) { |
|
| 576 | - wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( |
|
| 575 | + if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) { |
|
| 576 | + wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array( |
|
| 577 | 577 | 'response' => 403, |
| 578 | - ) ); |
|
| 578 | + )); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - $donor = new Give_Donor( $_GET['id'] ); |
|
| 581 | + $donor = new Give_Donor($_GET['id']); |
|
| 582 | 582 | |
| 583 | - if ( $donor->set_primary_email( $_GET['email'] ) ) { |
|
| 584 | - $url = add_query_arg( 'give-message', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
| 583 | + if ($donor->set_primary_email($_GET['email'])) { |
|
| 584 | + $url = add_query_arg('give-message', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
| 585 | 585 | $user = wp_get_current_user(); |
| 586 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
| 587 | - $donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
| 586 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
| 587 | + $donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login); |
|
| 588 | 588 | |
| 589 | - $donor->add_note( $donor_note ); |
|
| 589 | + $donor->add_note($donor_note); |
|
| 590 | 590 | } else { |
| 591 | - $url = add_query_arg( 'give-message', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
| 591 | + $url = add_query_arg('give-message', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - wp_safe_redirect( $url ); |
|
| 594 | + wp_safe_redirect($url); |
|
| 595 | 595 | exit; |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | -add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 ); |
|
| 598 | +add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10); |
|
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | function give_donors_page() { |
| 26 | 26 | $default_views = give_donor_views(); |
| 27 | - $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'donors'; |
|
| 28 | - if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
|
| 29 | - give_render_donor_view( $requested_view, $default_views ); |
|
| 27 | + $requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'donors'; |
|
| 28 | + if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) { |
|
| 29 | + give_render_donor_view($requested_view, $default_views); |
|
| 30 | 30 | } else { |
| 31 | 31 | give_donors_list(); |
| 32 | 32 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $views = array(); |
| 44 | 44 | |
| 45 | - return apply_filters( 'give_donor_views', $views ); |
|
| 45 | + return apply_filters('give_donor_views', $views); |
|
| 46 | 46 | |
| 47 | 47 | } |
| 48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $tabs = array(); |
| 58 | 58 | |
| 59 | - return apply_filters( 'give_donor_tabs', $tabs ); |
|
| 59 | + return apply_filters('give_donor_tabs', $tabs); |
|
| 60 | 60 | |
| 61 | 61 | } |
| 62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @return void |
| 68 | 68 | */ |
| 69 | 69 | function give_donors_list() { |
| 70 | - include dirname( __FILE__ ) . '/class-donor-table.php'; |
|
| 70 | + include dirname(__FILE__).'/class-donor-table.php'; |
|
| 71 | 71 | |
| 72 | 72 | $donors_table = new Give_Donor_List_Table(); |
| 73 | 73 | $donors_table->prepare_items(); |
@@ -80,14 +80,14 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @since 1.0 |
| 82 | 82 | */ |
| 83 | - do_action( 'give_donors_table_top' ); |
|
| 83 | + do_action('give_donors_table_top'); |
|
| 84 | 84 | ?> |
| 85 | 85 | |
| 86 | 86 | <hr class="wp-header-end"> |
| 87 | 87 | |
| 88 | - <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
|
| 88 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>"> |
|
| 89 | 89 | <?php |
| 90 | - $donors_table->search_box( __( 'Search Donors', 'give' ), 'give-donors' ); |
|
| 90 | + $donors_table->search_box(__('Search Donors', 'give'), 'give-donors'); |
|
| 91 | 91 | $donors_table->display(); |
| 92 | 92 | ?> |
| 93 | 93 | <input type="hidden" name="post_type" value="give_forms" /> |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @since 1.0 |
| 102 | 102 | */ |
| 103 | - do_action( 'give_donors_table_bottom' ); |
|
| 103 | + do_action('give_donors_table_bottom'); |
|
| 104 | 104 | ?> |
| 105 | 105 | </div> |
| 106 | 106 | <?php |
@@ -116,33 +116,33 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @return void |
| 118 | 118 | */ |
| 119 | -function give_render_donor_view( $view, $callbacks ) { |
|
| 119 | +function give_render_donor_view($view, $callbacks) { |
|
| 120 | 120 | |
| 121 | 121 | $render = true; |
| 122 | 122 | |
| 123 | - $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' ); |
|
| 123 | + $donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports'); |
|
| 124 | 124 | |
| 125 | - if ( ! current_user_can( $donor_view_role ) ) { |
|
| 126 | - give_set_error( 'give-no-access', __( 'You are not permitted to view this data.', 'give' ) ); |
|
| 125 | + if ( ! current_user_can($donor_view_role)) { |
|
| 126 | + give_set_error('give-no-access', __('You are not permitted to view this data.', 'give')); |
|
| 127 | 127 | $render = false; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
| 131 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
| 130 | + if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
| 131 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
| 132 | 132 | $render = false; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $donor_id = (int) $_GET['id']; |
| 136 | - $reconnect_user_id = ! empty( $_GET['user_id'] ) ? (int) $_GET['user_id'] : ''; |
|
| 137 | - $donor = new Give_Donor( $donor_id ); |
|
| 136 | + $reconnect_user_id = ! empty($_GET['user_id']) ? (int) $_GET['user_id'] : ''; |
|
| 137 | + $donor = new Give_Donor($donor_id); |
|
| 138 | 138 | |
| 139 | 139 | // Reconnect User with Donor profile. |
| 140 | - if( $reconnect_user_id ) { |
|
| 141 | - give_connect_user_donor_profile( $donor, array( 'user_id' => $reconnect_user_id ), array() ); |
|
| 140 | + if ($reconnect_user_id) { |
|
| 141 | + give_connect_user_donor_profile($donor, array('user_id' => $reconnect_user_id), array()); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if ( empty( $donor->id ) ) { |
|
| 145 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
| 144 | + if (empty($donor->id)) { |
|
| 145 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
| 146 | 146 | $render = false; |
| 147 | 147 | } |
| 148 | 148 | |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | <div class='wrap'> |
| 153 | 153 | |
| 154 | - <?php if ( give_get_errors() ) : ?> |
|
| 154 | + <?php if (give_get_errors()) : ?> |
|
| 155 | 155 | <div class="error settings-error"> |
| 156 | - <?php Give()->notices->render_frontend_notices( 0 ); ?> |
|
| 156 | + <?php Give()->notices->render_frontend_notices(0); ?> |
|
| 157 | 157 | </div> |
| 158 | 158 | <?php endif; ?> |
| 159 | 159 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | <?php |
| 162 | 162 | printf( |
| 163 | 163 | /* translators: %s: donor number */ |
| 164 | - esc_html__( 'Donor %s', 'give' ), |
|
| 164 | + esc_html__('Donor %s', 'give'), |
|
| 165 | 165 | $donor_id |
| 166 | 166 | ); |
| 167 | 167 | ?> |
@@ -169,26 +169,26 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | <hr class="wp-header-end"> |
| 171 | 171 | |
| 172 | - <?php if ( $donor && $render ) : ?> |
|
| 172 | + <?php if ($donor && $render) : ?> |
|
| 173 | 173 | |
| 174 | 174 | <h2 class="nav-tab-wrapper"> |
| 175 | 175 | <?php |
| 176 | - foreach ( $donor_tabs as $key => $tab ) : |
|
| 176 | + foreach ($donor_tabs as $key => $tab) : |
|
| 177 | 177 | $active = $key === $view ? true : false; |
| 178 | 178 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
| 179 | 179 | printf( |
| 180 | - '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>' . "\n", |
|
| 181 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $donor->id ) ), |
|
| 182 | - esc_attr( $class ), |
|
| 183 | - sanitize_html_class( $tab['dashicon'] ), |
|
| 184 | - esc_html( $tab['title'] ) |
|
| 180 | + '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n", |
|
| 181 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$donor->id)), |
|
| 182 | + esc_attr($class), |
|
| 183 | + sanitize_html_class($tab['dashicon']), |
|
| 184 | + esc_html($tab['title']) |
|
| 185 | 185 | ); |
| 186 | 186 | endforeach; |
| 187 | 187 | ?> |
| 188 | 188 | </h2> |
| 189 | 189 | |
| 190 | 190 | <div id="give-donor-card-wrapper"> |
| 191 | - <?php $callbacks[ $view ]( $donor ) ?> |
|
| 191 | + <?php $callbacks[$view]($donor) ?> |
|
| 192 | 192 | </div> |
| 193 | 193 | |
| 194 | 194 | <?php endif; ?> |
@@ -208,9 +208,9 @@ discard block |
||
| 208 | 208 | * |
| 209 | 209 | * @return void |
| 210 | 210 | */ |
| 211 | -function give_donor_view( $donor ) { |
|
| 211 | +function give_donor_view($donor) { |
|
| 212 | 212 | |
| 213 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
| 213 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | 216 | * Fires in donor profile screen, above the donor card. |
@@ -219,32 +219,32 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @param object $donor The donor object being displayed. |
| 221 | 221 | */ |
| 222 | - do_action( 'give_donor_card_top', $donor ); |
|
| 222 | + do_action('give_donor_card_top', $donor); |
|
| 223 | 223 | ?> |
| 224 | 224 | |
| 225 | 225 | <div id="donor-summary" class="info-wrapper donor-section postbox"> |
| 226 | 226 | |
| 227 | - <form id="edit-donor-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>"> |
|
| 227 | + <form id="edit-donor-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>"> |
|
| 228 | 228 | |
| 229 | 229 | <div class="donor-info"> |
| 230 | 230 | |
| 231 | 231 | <div class="donor-bio-header clearfix"> |
| 232 | 232 | |
| 233 | 233 | <div class="avatar-wrap left" id="donor-avatar"> |
| 234 | - <?php echo get_avatar( $donor->email ); ?> |
|
| 234 | + <?php echo get_avatar($donor->email); ?> |
|
| 235 | 235 | </div> |
| 236 | 236 | |
| 237 | 237 | <div id="donor-name-wrap" class="left"> |
| 238 | 238 | <span class="donor-id">#<?php echo $donor->id; ?></span> |
| 239 | - <span class="donor-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $donor->name ); ?>" placeholder="<?php _e( 'Donor Name', 'give' ); ?>" /></span> |
|
| 239 | + <span class="donor-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($donor->name); ?>" placeholder="<?php _e('Donor Name', 'give'); ?>" /></span> |
|
| 240 | 240 | <span class="donor-name info-item editable"><span data-key="name"><?php echo $donor->name; ?></span></span> |
| 241 | 241 | </div> |
| 242 | 242 | <p class="donor-since info-item"> |
| 243 | - <?php _e( 'Donor since', 'give' ); ?> |
|
| 244 | - <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?> |
|
| 243 | + <?php _e('Donor since', 'give'); ?> |
|
| 244 | + <?php echo date_i18n(give_date_format(), strtotime($donor->date_created)) ?> |
|
| 245 | 245 | </p> |
| 246 | - <?php if ( current_user_can( $donor_edit_role ) ) : ?> |
|
| 247 | - <a href="#" id="edit-donor" class="button info-item editable donor-edit-link"><?php _e( 'Edit Donor', 'give' ); ?></a> |
|
| 246 | + <?php if (current_user_can($donor_edit_role)) : ?> |
|
| 247 | + <a href="#" id="edit-donor" class="button info-item editable donor-edit-link"><?php _e('Edit Donor', 'give'); ?></a> |
|
| 248 | 248 | <?php endif; ?> |
| 249 | 249 | </div> |
| 250 | 250 | <!-- /donor-bio-header --> |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | <table class="widefat"> |
| 255 | 255 | <tbody> |
| 256 | 256 | <tr class="alternate"> |
| 257 | - <th scope="col"><label for="tablecell"><?php _e( 'User:', 'give' ); ?></label></th> |
|
| 257 | + <th scope="col"><label for="tablecell"><?php _e('User:', 'give'); ?></label></th> |
|
| 258 | 258 | <td> |
| 259 | 259 | <span class="donor-user-id info-item edit-item"> |
| 260 | 260 | <?php |
@@ -271,48 +271,48 @@ discard block |
||
| 271 | 271 | 'data' => $data_atts, |
| 272 | 272 | ); |
| 273 | 273 | |
| 274 | - if ( ! empty( $user_id ) ) { |
|
| 275 | - $userdata = get_userdata( $user_id ); |
|
| 274 | + if ( ! empty($user_id)) { |
|
| 275 | + $userdata = get_userdata($user_id); |
|
| 276 | 276 | $user_args['selected'] = $user_id; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - echo Give()->html->ajax_user_search( $user_args ); |
|
| 279 | + echo Give()->html->ajax_user_search($user_args); |
|
| 280 | 280 | ?> |
| 281 | 281 | </span> |
| 282 | 282 | |
| 283 | 283 | <span class="donor-user-id info-item editable"> |
| 284 | - <?php if ( ! empty( $userdata ) ) { ?> |
|
| 285 | - <span data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span> |
|
| 284 | + <?php if ( ! empty($userdata)) { ?> |
|
| 285 | + <span data-key="user_id">#<?php echo $donor->user_id.' - '.$userdata->display_name; ?></span> |
|
| 286 | 286 | <?php } else { ?> |
| 287 | - <span data-key="user_id"><?php _e( 'None', 'give' ); ?></span> |
|
| 287 | + <span data-key="user_id"><?php _e('None', 'give'); ?></span> |
|
| 288 | 288 | <?php } ?> |
| 289 | - <?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ) { ?> |
|
| 289 | + <?php if (current_user_can($donor_edit_role) && intval($donor->user_id) > 0) { ?> |
|
| 290 | 290 | <span class="disconnect-user"> |
| 291 | 291 | - |
| 292 | - <a id="disconnect-donor" href="#disconnect" aria-label="<?php _e( 'Disconnects the current user ID from this donor record.', 'give' ); ?>"> |
|
| 293 | - <?php _e( 'Disconnect User', 'give' ); ?> |
|
| 292 | + <a id="disconnect-donor" href="#disconnect" aria-label="<?php _e('Disconnects the current user ID from this donor record.', 'give'); ?>"> |
|
| 293 | + <?php _e('Disconnect User', 'give'); ?> |
|
| 294 | 294 | </a> |
| 295 | 295 | </span> |
| 296 | 296 | <span class="view-user-profile"> |
| 297 | 297 | | |
| 298 | - <a id="view-user-profile" href="<?php echo 'user-edit.php?user_id=' . $donor->user_id; ?>" aria-label="<?php _e( 'View User Profile of current user ID.', 'give' ); ?>"> |
|
| 299 | - <?php _e( 'View User Profile', 'give' ); ?> |
|
| 298 | + <a id="view-user-profile" href="<?php echo 'user-edit.php?user_id='.$donor->user_id; ?>" aria-label="<?php _e('View User Profile of current user ID.', 'give'); ?>"> |
|
| 299 | + <?php _e('View User Profile', 'give'); ?> |
|
| 300 | 300 | </a> |
| 301 | 301 | </span> |
| 302 | 302 | <?php } ?> |
| 303 | 303 | </span> |
| 304 | 304 | </td> |
| 305 | 305 | </tr> |
| 306 | - <?php if ( isset( $donor->user_id ) && $donor->user_id > 0 ) : ?> |
|
| 306 | + <?php if (isset($donor->user_id) && $donor->user_id > 0) : ?> |
|
| 307 | 307 | |
| 308 | 308 | <tr> |
| 309 | - <th scope="col"><?php _e( 'Address:', 'give' ); ?></th> |
|
| 309 | + <th scope="col"><?php _e('Address:', 'give'); ?></th> |
|
| 310 | 310 | <td class="row-title"> |
| 311 | 311 | |
| 312 | 312 | <div class="donor-address-wrapper"> |
| 313 | 313 | |
| 314 | 314 | <?php |
| 315 | - $address = get_user_meta( $donor->user_id, '_give_user_address', true ); |
|
| 315 | + $address = get_user_meta($donor->user_id, '_give_user_address', true); |
|
| 316 | 316 | $defaults = array( |
| 317 | 317 | 'line1' => '', |
| 318 | 318 | 'line2' => '', |
@@ -322,10 +322,10 @@ discard block |
||
| 322 | 322 | 'zip' => '', |
| 323 | 323 | ); |
| 324 | 324 | |
| 325 | - $address = wp_parse_args( $address, $defaults ); |
|
| 325 | + $address = wp_parse_args($address, $defaults); |
|
| 326 | 326 | ?> |
| 327 | 327 | |
| 328 | - <?php if ( ! empty( $address ) ) { ?> |
|
| 328 | + <?php if ( ! empty($address)) { ?> |
|
| 329 | 329 | <span class="donor-address info-item editable"> |
| 330 | 330 | <span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span> |
| 331 | 331 | <span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span> |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | // For State. |
| 344 | 344 | $selected_state = give_get_state(); |
| 345 | - $states = give_get_states( $selected_country ); |
|
| 346 | - $selected_state = ( isset( $address['state'] ) ? $address['state'] : $selected_state ); |
|
| 345 | + $states = give_get_states($selected_country); |
|
| 346 | + $selected_state = (isset($address['state']) ? $address['state'] : $selected_state); |
|
| 347 | 347 | |
| 348 | 348 | // Get the country list that does not have any states init. |
| 349 | 349 | $no_states_country = give_no_states_country_list(); |
@@ -351,32 +351,32 @@ discard block |
||
| 351 | 351 | <span class="donor-address info-item edit-item"> |
| 352 | 352 | <select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item"> |
| 353 | 353 | <?php |
| 354 | - foreach ( $countries as $country_code => $country ) { |
|
| 355 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
| 354 | + foreach ($countries as $country_code => $country) { |
|
| 355 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
| 356 | 356 | } |
| 357 | 357 | ?> |
| 358 | 358 | </select> |
| 359 | - <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php _e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" /> |
|
| 360 | - <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php _e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" /> |
|
| 359 | + <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php _e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" /> |
|
| 360 | + <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php _e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" /> |
|
| 361 | 361 | <?php |
| 362 | - if ( ! empty( $states ) ) { |
|
| 362 | + if ( ! empty($states)) { |
|
| 363 | 363 | ?> |
| 364 | 364 | <select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item"> |
| 365 | 365 | <?php |
| 366 | - foreach ( $states as $state_code => $state ) { |
|
| 367 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
| 366 | + foreach ($states as $state_code => $state) { |
|
| 367 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
| 368 | 368 | } |
| 369 | 369 | ?> |
| 370 | 370 | </select> |
| 371 | 371 | <?php |
| 372 | 372 | } else { |
| 373 | 373 | ?> |
| 374 | - <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ? 'give-hidden' : '' ); ?>" placeholder="<?php _e( 'State / Province / County', 'give' ); ?>" /> |
|
| 374 | + <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country) ? 'give-hidden' : ''); ?>" placeholder="<?php _e('State / Province / County', 'give'); ?>" /> |
|
| 375 | 375 | <?php |
| 376 | 376 | } |
| 377 | 377 | ?> |
| 378 | - <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php _e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" /> |
|
| 379 | - <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php _e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $address['zip']; ?>" /> |
|
| 378 | + <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php _e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" /> |
|
| 379 | + <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php _e('Zip / Postal Code', 'give'); ?>" value="<?php echo $address['zip']; ?>" /> |
|
| 380 | 380 | </span> |
| 381 | 381 | |
| 382 | 382 | </div> |
@@ -392,10 +392,10 @@ discard block |
||
| 392 | 392 | |
| 393 | 393 | <span id="donor-edit-actions" class="edit-item"> |
| 394 | 394 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $donor->id; ?>" /> |
| 395 | - <?php wp_nonce_field( 'edit-donor', '_wpnonce', false, true ); ?> |
|
| 395 | + <?php wp_nonce_field('edit-donor', '_wpnonce', false, true); ?> |
|
| 396 | 396 | <input type="hidden" name="give_action" value="edit-donor" /> |
| 397 | - <input type="submit" id="give-edit-donor-save" class="button-secondary" value="<?php _e( 'Update Donor', 'give' ); ?>" /> |
|
| 398 | - <a id="give-edit-donor-cancel" href="" class="delete"><?php _e( 'Cancel', 'give' ); ?></a> |
|
| 397 | + <input type="submit" id="give-edit-donor-save" class="button-secondary" value="<?php _e('Update Donor', 'give'); ?>" /> |
|
| 398 | + <a id="give-edit-donor-cancel" href="" class="delete"><?php _e('Cancel', 'give'); ?></a> |
|
| 399 | 399 | </span> |
| 400 | 400 | |
| 401 | 401 | </form> |
@@ -410,24 +410,24 @@ discard block |
||
| 410 | 410 | * |
| 411 | 411 | * @param object $donor The donor object being displayed. |
| 412 | 412 | */ |
| 413 | - do_action( 'give_donor_before_stats', $donor ); |
|
| 413 | + do_action('give_donor_before_stats', $donor); |
|
| 414 | 414 | ?> |
| 415 | 415 | |
| 416 | 416 | <div id="donor-stats-wrapper" class="donor-section postbox clear"> |
| 417 | 417 | <ul> |
| 418 | 418 | <li> |
| 419 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor->id ) ); ?>"> |
|
| 419 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor->id)); ?>"> |
|
| 420 | 420 | <span class="dashicons dashicons-heart"></span> |
| 421 | 421 | <?php |
| 422 | 422 | // Completed Donations. |
| 423 | - $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give' ), $donor->purchase_count ); |
|
| 424 | - echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $donor ); |
|
| 423 | + $completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give'), $donor->purchase_count); |
|
| 424 | + echo apply_filters('give_donor_completed_donations', $completed_donations_text, $donor); |
|
| 425 | 425 | ?> |
| 426 | 426 | </a> |
| 427 | 427 | </li> |
| 428 | 428 | <li> |
| 429 | 429 | <span class="dashicons dashicons-chart-area"></span> |
| 430 | - <?php echo give_currency_filter( give_format_amount( $donor->purchase_value, array( 'sanitize' => false ) ) ); ?> <?php _e( 'Lifetime Donations', 'give' ); ?> |
|
| 430 | + <?php echo give_currency_filter(give_format_amount($donor->purchase_value, array('sanitize' => false))); ?> <?php _e('Lifetime Donations', 'give'); ?> |
|
| 431 | 431 | </li> |
| 432 | 432 | <?php |
| 433 | 433 | /** |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | * |
| 440 | 440 | * @param object $donor The donor object being displayed. |
| 441 | 441 | */ |
| 442 | - do_action( 'give_donor_stats_list', $donor ); |
|
| 442 | + do_action('give_donor_stats_list', $donor); |
|
| 443 | 443 | ?> |
| 444 | 444 | </ul> |
| 445 | 445 | </div> |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | * |
| 453 | 453 | * @param object $donor The donor object being displayed. |
| 454 | 454 | */ |
| 455 | - do_action( 'give_donor_before_tables_wrapper', $donor ); |
|
| 455 | + do_action('give_donor_before_tables_wrapper', $donor); |
|
| 456 | 456 | ?> |
| 457 | 457 | |
| 458 | 458 | <div id="donor-tables-wrapper" class="donor-section"> |
@@ -465,46 +465,46 @@ discard block |
||
| 465 | 465 | * |
| 466 | 466 | * @param object $donor The donor object being displayed. |
| 467 | 467 | */ |
| 468 | - do_action( 'give_donor_before_tables', $donor ); |
|
| 468 | + do_action('give_donor_before_tables', $donor); |
|
| 469 | 469 | ?> |
| 470 | 470 | |
| 471 | - <h3><?php _e( 'Donor Emails', 'give' ); ?></h3> |
|
| 471 | + <h3><?php _e('Donor Emails', 'give'); ?></h3> |
|
| 472 | 472 | |
| 473 | 473 | <table class="wp-list-table widefat striped emails"> |
| 474 | 474 | <thead> |
| 475 | 475 | <tr> |
| 476 | - <th><?php _e( 'Email', 'give' ); ?></th> |
|
| 477 | - <th><?php _e( 'Actions', 'give' ); ?></th> |
|
| 476 | + <th><?php _e('Email', 'give'); ?></th> |
|
| 477 | + <th><?php _e('Actions', 'give'); ?></th> |
|
| 478 | 478 | </tr> |
| 479 | 479 | </thead> |
| 480 | 480 | |
| 481 | 481 | <tbody> |
| 482 | - <?php if ( ! empty( $donor->emails ) ) { ?> |
|
| 482 | + <?php if ( ! empty($donor->emails)) { ?> |
|
| 483 | 483 | |
| 484 | - <?php foreach ( $donor->emails as $key => $email ) : ?> |
|
| 484 | + <?php foreach ($donor->emails as $key => $email) : ?> |
|
| 485 | 485 | <tr data-key="<?php echo $key; ?>"> |
| 486 | 486 | <td> |
| 487 | 487 | <?php echo $email; ?> |
| 488 | - <?php if ( 'primary' === $key ) : ?> |
|
| 488 | + <?php if ('primary' === $key) : ?> |
|
| 489 | 489 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
| 490 | 490 | <?php endif; ?> |
| 491 | 491 | </td> |
| 492 | 492 | <td> |
| 493 | - <?php if ( 'primary' !== $key ) : ?> |
|
| 493 | + <?php if ('primary' !== $key) : ?> |
|
| 494 | 494 | <?php |
| 495 | - $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); |
|
| 496 | - $promote_url = wp_nonce_url( add_query_arg( array( |
|
| 497 | - 'email' => rawurlencode( $email ), |
|
| 495 | + $base_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); |
|
| 496 | + $promote_url = wp_nonce_url(add_query_arg(array( |
|
| 497 | + 'email' => rawurlencode($email), |
|
| 498 | 498 | 'give_action' => 'set_donor_primary_email', |
| 499 | - ), $base_url ), 'give-set-donor-primary-email' ); |
|
| 500 | - $remove_url = wp_nonce_url( add_query_arg( array( |
|
| 501 | - 'email' => rawurlencode( $email ), |
|
| 499 | + ), $base_url), 'give-set-donor-primary-email'); |
|
| 500 | + $remove_url = wp_nonce_url(add_query_arg(array( |
|
| 501 | + 'email' => rawurlencode($email), |
|
| 502 | 502 | 'give_action' => 'remove_donor_email', |
| 503 | - ), $base_url ), 'give-remove-donor-email' ); |
|
| 503 | + ), $base_url), 'give-remove-donor-email'); |
|
| 504 | 504 | ?> |
| 505 | - <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> |
|
| 505 | + <a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a> |
|
| 506 | 506 | | |
| 507 | - <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> |
|
| 507 | + <a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a> |
|
| 508 | 508 | <?php endif; ?> |
| 509 | 509 | </td> |
| 510 | 510 | </tr> |
@@ -514,59 +514,59 @@ discard block |
||
| 514 | 514 | <td colspan="2" class="add-donor-email-td"> |
| 515 | 515 | <div class="add-donor-email-wrapper"> |
| 516 | 516 | <input type="hidden" name="donor-id" value="<?php echo $donor->id; ?>" /> |
| 517 | - <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
|
| 518 | - <input type="email" name="additional-email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" /> |
|
| 519 | - <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
|
| 520 | - <button class="button-secondary give-add-donor-email" id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button> |
|
| 517 | + <?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?> |
|
| 518 | + <input type="email" name="additional-email" value="" placeholder="<?php _e('Email Address', 'give'); ?>" /> |
|
| 519 | + <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label> |
|
| 520 | + <button class="button-secondary give-add-donor-email" id="add-donor-email"><?php _e('Add Email', 'give'); ?></button> |
|
| 521 | 521 | <span class="spinner"></span> |
| 522 | 522 | </div> |
| 523 | 523 | <div class="notice-wrap"></div> |
| 524 | 524 | </td> |
| 525 | 525 | </tr> |
| 526 | 526 | <?php } else { ?> |
| 527 | - <tr><td colspan="2"><?php _e( 'No Emails Found', 'give' ); ?></td></tr> |
|
| 527 | + <tr><td colspan="2"><?php _e('No Emails Found', 'give'); ?></td></tr> |
|
| 528 | 528 | <?php }// End if(). |
| 529 | 529 | ?> |
| 530 | 530 | </tbody> |
| 531 | 531 | </table> |
| 532 | 532 | |
| 533 | - <h3><?php _e( 'Recent Donations', 'give' ); ?></h3> |
|
| 533 | + <h3><?php _e('Recent Donations', 'give'); ?></h3> |
|
| 534 | 534 | <?php |
| 535 | - $payment_ids = explode( ',', $donor->payment_ids ); |
|
| 536 | - $payments = give_get_payments( array( |
|
| 535 | + $payment_ids = explode(',', $donor->payment_ids); |
|
| 536 | + $payments = give_get_payments(array( |
|
| 537 | 537 | 'post__in' => $payment_ids, |
| 538 | - ) ); |
|
| 539 | - $payments = array_slice( $payments, 0, 10 ); |
|
| 538 | + )); |
|
| 539 | + $payments = array_slice($payments, 0, 10); |
|
| 540 | 540 | ?> |
| 541 | 541 | <table class="wp-list-table widefat striped payments"> |
| 542 | 542 | <thead> |
| 543 | 543 | <tr> |
| 544 | - <th scope="col"><?php _e( 'ID', 'give' ); ?></th> |
|
| 545 | - <th scope="col"><?php _e( 'Amount', 'give' ); ?></th> |
|
| 546 | - <th scope="col"><?php _e( 'Date', 'give' ); ?></th> |
|
| 547 | - <th scope="col"><?php _e( 'Status', 'give' ); ?></th> |
|
| 548 | - <th scope="col"><?php _e( 'Actions', 'give' ); ?></th> |
|
| 544 | + <th scope="col"><?php _e('ID', 'give'); ?></th> |
|
| 545 | + <th scope="col"><?php _e('Amount', 'give'); ?></th> |
|
| 546 | + <th scope="col"><?php _e('Date', 'give'); ?></th> |
|
| 547 | + <th scope="col"><?php _e('Status', 'give'); ?></th> |
|
| 548 | + <th scope="col"><?php _e('Actions', 'give'); ?></th> |
|
| 549 | 549 | </tr> |
| 550 | 550 | </thead> |
| 551 | 551 | <tbody> |
| 552 | - <?php if ( ! empty( $payments ) ) { ?> |
|
| 553 | - <?php foreach ( $payments as $payment ) : ?> |
|
| 552 | + <?php if ( ! empty($payments)) { ?> |
|
| 553 | + <?php foreach ($payments as $payment) : ?> |
|
| 554 | 554 | <tr> |
| 555 | 555 | <td><?php echo $payment->ID; ?></td> |
| 556 | - <td><?php echo give_payment_amount( $payment->ID ); ?></td> |
|
| 557 | - <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
|
| 558 | - <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
|
| 556 | + <td><?php echo give_payment_amount($payment->ID); ?></td> |
|
| 557 | + <td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td> |
|
| 558 | + <td><?php echo give_get_payment_status($payment, true); ?></td> |
|
| 559 | 559 | <td> |
| 560 | 560 | <?php |
| 561 | 561 | printf( |
| 562 | 562 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
| 563 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment->ID ), |
|
| 563 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment->ID), |
|
| 564 | 564 | sprintf( |
| 565 | 565 | /* translators: %s: Donation ID */ |
| 566 | - esc_attr__( 'View Donation %s.', 'give' ), |
|
| 566 | + esc_attr__('View Donation %s.', 'give'), |
|
| 567 | 567 | $payment->ID |
| 568 | 568 | ), |
| 569 | - __( 'View Donation', 'give' ) |
|
| 569 | + __('View Donation', 'give') |
|
| 570 | 570 | ); |
| 571 | 571 | ?> |
| 572 | 572 | |
@@ -581,47 +581,47 @@ discard block |
||
| 581 | 581 | * @param object $donor The donor object being displayed. |
| 582 | 582 | * @param object $payment The payment object being displayed. |
| 583 | 583 | */ |
| 584 | - do_action( 'give_donor_recent_purchases_actions', $donor, $payment ); |
|
| 584 | + do_action('give_donor_recent_purchases_actions', $donor, $payment); |
|
| 585 | 585 | ?> |
| 586 | 586 | </td> |
| 587 | 587 | </tr> |
| 588 | 588 | <?php endforeach; ?> |
| 589 | 589 | <?php } else { ?> |
| 590 | 590 | <tr> |
| 591 | - <td colspan="5"><?php _e( 'No donations found.', 'give' ); ?></td> |
|
| 591 | + <td colspan="5"><?php _e('No donations found.', 'give'); ?></td> |
|
| 592 | 592 | </tr> |
| 593 | 593 | <?php }// End if(). |
| 594 | 594 | ?> |
| 595 | 595 | </tbody> |
| 596 | 596 | </table> |
| 597 | 597 | |
| 598 | - <h3><?php _e( 'Completed Forms', 'give' ); ?></h3> |
|
| 598 | + <h3><?php _e('Completed Forms', 'give'); ?></h3> |
|
| 599 | 599 | <?php |
| 600 | - $donations = give_get_users_completed_donations( $donor->email ); |
|
| 600 | + $donations = give_get_users_completed_donations($donor->email); |
|
| 601 | 601 | ?> |
| 602 | 602 | <table class="wp-list-table widefat striped donations"> |
| 603 | 603 | <thead> |
| 604 | 604 | <tr> |
| 605 | - <th scope="col"><?php _e( 'Form', 'give' ); ?></th> |
|
| 606 | - <th scope="col" width="120px"><?php _e( 'Actions', 'give' ); ?></th> |
|
| 605 | + <th scope="col"><?php _e('Form', 'give'); ?></th> |
|
| 606 | + <th scope="col" width="120px"><?php _e('Actions', 'give'); ?></th> |
|
| 607 | 607 | </tr> |
| 608 | 608 | </thead> |
| 609 | 609 | <tbody> |
| 610 | - <?php if ( ! empty( $donations ) ) { ?> |
|
| 611 | - <?php foreach ( $donations as $donation ) : ?> |
|
| 610 | + <?php if ( ! empty($donations)) { ?> |
|
| 611 | + <?php foreach ($donations as $donation) : ?> |
|
| 612 | 612 | <tr> |
| 613 | 613 | <td><?php echo $donation->post_title; ?></td> |
| 614 | 614 | <td> |
| 615 | 615 | <?php |
| 616 | 616 | printf( |
| 617 | 617 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
| 618 | - esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
|
| 618 | + esc_url(admin_url('post.php?action=edit&post='.$donation->ID)), |
|
| 619 | 619 | sprintf( |
| 620 | 620 | /* translators: %s: form name */ |
| 621 | - esc_attr__( 'View Form %s.', 'give' ), |
|
| 621 | + esc_attr__('View Form %s.', 'give'), |
|
| 622 | 622 | $donation->post_title |
| 623 | 623 | ), |
| 624 | - __( 'View Form', 'give' ) |
|
| 624 | + __('View Form', 'give') |
|
| 625 | 625 | ); |
| 626 | 626 | ?> |
| 627 | 627 | </td> |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | <?php endforeach; ?> |
| 630 | 630 | <?php } else { ?> |
| 631 | 631 | <tr> |
| 632 | - <td colspan="2"><?php _e( 'No completed donations found.', 'give' ); ?></td> |
|
| 632 | + <td colspan="2"><?php _e('No completed donations found.', 'give'); ?></td> |
|
| 633 | 633 | </tr> |
| 634 | 634 | <?php } ?> |
| 635 | 635 | </tbody> |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | * |
| 644 | 644 | * @param object $donor The donor object being displayed. |
| 645 | 645 | */ |
| 646 | - do_action( 'give_donor_after_tables', $donor ); |
|
| 646 | + do_action('give_donor_after_tables', $donor); |
|
| 647 | 647 | ?> |
| 648 | 648 | |
| 649 | 649 | </div> |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | * |
| 657 | 657 | * @param object $donor The donor object being displayed. |
| 658 | 658 | */ |
| 659 | - do_action( 'give_donor_card_bottom', $donor ); |
|
| 659 | + do_action('give_donor_card_bottom', $donor); |
|
| 660 | 660 | |
| 661 | 661 | } |
| 662 | 662 | |
@@ -669,30 +669,30 @@ discard block |
||
| 669 | 669 | * |
| 670 | 670 | * @return void |
| 671 | 671 | */ |
| 672 | -function give_donor_notes_view( $donor ) { |
|
| 672 | +function give_donor_notes_view($donor) { |
|
| 673 | 673 | |
| 674 | - $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
| 675 | - $paged = absint( $paged ); |
|
| 674 | + $paged = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1; |
|
| 675 | + $paged = absint($paged); |
|
| 676 | 676 | $note_count = $donor->get_notes_count(); |
| 677 | - $per_page = apply_filters( 'give_donor_notes_per_page', 20 ); |
|
| 678 | - $total_pages = ceil( $note_count / $per_page ); |
|
| 679 | - $donor_notes = $donor->get_notes( $per_page, $paged ); |
|
| 677 | + $per_page = apply_filters('give_donor_notes_per_page', 20); |
|
| 678 | + $total_pages = ceil($note_count / $per_page); |
|
| 679 | + $donor_notes = $donor->get_notes($per_page, $paged); |
|
| 680 | 680 | ?> |
| 681 | 681 | |
| 682 | 682 | <div id="donor-notes-wrapper"> |
| 683 | 683 | <div class="donor-notes-header"> |
| 684 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
| 684 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
| 685 | 685 | </div> |
| 686 | - <h3><?php _e( 'Notes', 'give' ); ?></h3> |
|
| 686 | + <h3><?php _e('Notes', 'give'); ?></h3> |
|
| 687 | 687 | |
| 688 | - <?php if ( 1 == $paged ) : ?> |
|
| 688 | + <?php if (1 == $paged) : ?> |
|
| 689 | 689 | <div style="display: block; margin-bottom: 55px;"> |
| 690 | - <form id="give-add-donor-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor->id ); ?>"> |
|
| 690 | + <form id="give-add-donor-note" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor->id); ?>"> |
|
| 691 | 691 | <textarea id="donor-note" name="donor_note" class="donor-note-input" rows="10"></textarea> |
| 692 | 692 | <br /> |
| 693 | 693 | <input type="hidden" id="donor-id" name="customer_id" value="<?php echo $donor->id; ?>" /> |
| 694 | 694 | <input type="hidden" name="give_action" value="add-donor-note" /> |
| 695 | - <?php wp_nonce_field( 'add-donor-note', 'add_donor_note_nonce', true, true ); ?> |
|
| 695 | + <?php wp_nonce_field('add-donor-note', 'add_donor_note_nonce', true, true); ?> |
|
| 696 | 696 | <input id="add-donor-note" class="right button-primary" type="submit" value="Add Note" /> |
| 697 | 697 | </form> |
| 698 | 698 | </div> |
@@ -707,26 +707,26 @@ discard block |
||
| 707 | 707 | 'show_all' => true, |
| 708 | 708 | ); |
| 709 | 709 | |
| 710 | - echo paginate_links( $pagination_args ); |
|
| 710 | + echo paginate_links($pagination_args); |
|
| 711 | 711 | ?> |
| 712 | 712 | |
| 713 | 713 | <div id="give-donor-notes" class="postbox"> |
| 714 | - <?php if ( count( $donor_notes ) > 0 ) { ?> |
|
| 715 | - <?php foreach ( $donor_notes as $key => $note ) : ?> |
|
| 714 | + <?php if (count($donor_notes) > 0) { ?> |
|
| 715 | + <?php foreach ($donor_notes as $key => $note) : ?> |
|
| 716 | 716 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
| 717 | 717 | <span class="note-content-wrap"> |
| 718 | - <?php echo stripslashes( $note ); ?> |
|
| 718 | + <?php echo stripslashes($note); ?> |
|
| 719 | 719 | </span> |
| 720 | 720 | </div> |
| 721 | 721 | <?php endforeach; ?> |
| 722 | 722 | <?php } else { ?> |
| 723 | 723 | <div class="give-no-donor-notes"> |
| 724 | - <?php _e( 'No donor notes found.', 'give' ); ?> |
|
| 724 | + <?php _e('No donor notes found.', 'give'); ?> |
|
| 725 | 725 | </div> |
| 726 | 726 | <?php } ?> |
| 727 | 727 | </div> |
| 728 | 728 | |
| 729 | - <?php echo paginate_links( $pagination_args ); ?> |
|
| 729 | + <?php echo paginate_links($pagination_args); ?> |
|
| 730 | 730 | |
| 731 | 731 | </div> |
| 732 | 732 | |
@@ -742,9 +742,9 @@ discard block |
||
| 742 | 742 | * |
| 743 | 743 | * @return void |
| 744 | 744 | */ |
| 745 | -function give_donor_delete_view( $donor ) { |
|
| 745 | +function give_donor_delete_view($donor) { |
|
| 746 | 746 | |
| 747 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
| 747 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
| 748 | 748 | |
| 749 | 749 | /** |
| 750 | 750 | * Fires in donor delete screen, above the content. |
@@ -753,15 +753,15 @@ discard block |
||
| 753 | 753 | * |
| 754 | 754 | * @param object $donor The donor object being displayed. |
| 755 | 755 | */ |
| 756 | - do_action( 'give_donor_delete_top', $donor ); |
|
| 756 | + do_action('give_donor_delete_top', $donor); |
|
| 757 | 757 | ?> |
| 758 | 758 | |
| 759 | 759 | <div class="info-wrapper donor-section"> |
| 760 | 760 | |
| 761 | - <form id="delete-donor" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor->id ); ?>"> |
|
| 761 | + <form id="delete-donor" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor->id); ?>"> |
|
| 762 | 762 | |
| 763 | 763 | <div class="donor-notes-header"> |
| 764 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
| 764 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
| 765 | 765 | </div> |
| 766 | 766 | |
| 767 | 767 | |
@@ -769,20 +769,20 @@ discard block |
||
| 769 | 769 | |
| 770 | 770 | <span class="delete-donor-options"> |
| 771 | 771 | <p> |
| 772 | - <?php echo Give()->html->checkbox( array( |
|
| 772 | + <?php echo Give()->html->checkbox(array( |
|
| 773 | 773 | 'name' => 'give-donor-delete-confirm', |
| 774 | - ) ); ?> |
|
| 775 | - <label for="give-donor-delete-confirm"><?php _e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
|
| 774 | + )); ?> |
|
| 775 | + <label for="give-donor-delete-confirm"><?php _e('Are you sure you want to delete this donor?', 'give'); ?></label> |
|
| 776 | 776 | </p> |
| 777 | 777 | |
| 778 | 778 | <p> |
| 779 | - <?php echo Give()->html->checkbox( array( |
|
| 779 | + <?php echo Give()->html->checkbox(array( |
|
| 780 | 780 | 'name' => 'give-donor-delete-records', |
| 781 | 781 | 'options' => array( |
| 782 | 782 | 'disabled' => true, |
| 783 | 783 | ), |
| 784 | - ) ); ?> |
|
| 785 | - <label for="give-donor-delete-records"><?php _e( 'Delete all associated donations and records?', 'give' ); ?></label> |
|
| 784 | + )); ?> |
|
| 785 | + <label for="give-donor-delete-records"><?php _e('Delete all associated donations and records?', 'give'); ?></label> |
|
| 786 | 786 | </p> |
| 787 | 787 | |
| 788 | 788 | <?php |
@@ -795,16 +795,16 @@ discard block |
||
| 795 | 795 | * |
| 796 | 796 | * @param object $donor The donor object being displayed. |
| 797 | 797 | */ |
| 798 | - do_action( 'give_donor_delete_inputs', $donor ); |
|
| 798 | + do_action('give_donor_delete_inputs', $donor); |
|
| 799 | 799 | ?> |
| 800 | 800 | </span> |
| 801 | 801 | |
| 802 | 802 | <span id="donor-edit-actions"> |
| 803 | 803 | <input type="hidden" name="customer_id" value="<?php echo $donor->id; ?>" /> |
| 804 | - <?php wp_nonce_field( 'delete-donor', '_wpnonce', false, true ); ?> |
|
| 804 | + <?php wp_nonce_field('delete-donor', '_wpnonce', false, true); ?> |
|
| 805 | 805 | <input type="hidden" name="give_action" value="delete-donor" /> |
| 806 | - <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" value="<?php _e( 'Delete Donor', 'give' ); ?>" /> |
|
| 807 | - <a id="give-delete-donor-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>" class="delete"><?php _e( 'Cancel', 'give' ); ?></a> |
|
| 806 | + <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" value="<?php _e('Delete Donor', 'give'); ?>" /> |
|
| 807 | + <a id="give-delete-donor-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>" class="delete"><?php _e('Cancel', 'give'); ?></a> |
|
| 808 | 808 | </span> |
| 809 | 809 | |
| 810 | 810 | </div> |
@@ -820,5 +820,5 @@ discard block |
||
| 820 | 820 | * |
| 821 | 821 | * @param object $donor The donor object being displayed. |
| 822 | 822 | */ |
| 823 | - do_action( 'give_donor_delete_bottom', $donor ); |
|
| 823 | + do_action('give_donor_delete_bottom', $donor); |
|
| 824 | 824 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array The altered list of views. |
| 25 | 25 | */ |
| 26 | -function give_register_default_donor_views( $views ) { |
|
| 26 | +function give_register_default_donor_views($views) { |
|
| 27 | 27 | |
| 28 | 28 | $default_views = array( |
| 29 | 29 | 'overview' => 'give_donor_view', |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | 'notes' => 'give_donor_notes_view', |
| 32 | 32 | ); |
| 33 | 33 | |
| 34 | - return array_merge( $views, $default_views ); |
|
| 34 | + return array_merge($views, $default_views); |
|
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -add_filter( 'give_donor_views', 'give_register_default_donor_views', 1, 1 ); |
|
| 38 | +add_filter('give_donor_views', 'give_register_default_donor_views', 1, 1); |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * Register a tab for the single donor view. |
@@ -46,23 +46,23 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return array The altered list of tabs |
| 48 | 48 | */ |
| 49 | -function give_register_default_donor_tabs( $tabs ) { |
|
| 49 | +function give_register_default_donor_tabs($tabs) { |
|
| 50 | 50 | |
| 51 | 51 | $default_tabs = array( |
| 52 | 52 | 'overview' => array( |
| 53 | 53 | 'dashicon' => 'dashicons-admin-users', |
| 54 | - 'title' => __( 'Donor Profile', 'give' ), |
|
| 54 | + 'title' => __('Donor Profile', 'give'), |
|
| 55 | 55 | ), |
| 56 | 56 | 'notes' => array( |
| 57 | 57 | 'dashicon' => 'dashicons-admin-comments', |
| 58 | - 'title' => __( 'Donor Notes', 'give' ), |
|
| 58 | + 'title' => __('Donor Notes', 'give'), |
|
| 59 | 59 | ), |
| 60 | 60 | ); |
| 61 | 61 | |
| 62 | - return array_merge( $tabs, $default_tabs ); |
|
| 62 | + return array_merge($tabs, $default_tabs); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | -add_filter( 'give_donor_tabs', 'give_register_default_donor_tabs', 1, 1 ); |
|
| 65 | +add_filter('give_donor_tabs', 'give_register_default_donor_tabs', 1, 1); |
|
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * Register the Delete icon as late as possible so it's at the bottom. |
@@ -73,17 +73,17 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return array The altered list of tabs, with 'delete' at the bottom. |
| 75 | 75 | */ |
| 76 | -function give_register_delete_donor_tab( $tabs ) { |
|
| 76 | +function give_register_delete_donor_tab($tabs) { |
|
| 77 | 77 | |
| 78 | 78 | $tabs['delete'] = array( |
| 79 | 79 | 'dashicon' => 'dashicons-trash', |
| 80 | - 'title' => __( 'Delete Donor', 'give' ), |
|
| 80 | + 'title' => __('Delete Donor', 'give'), |
|
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | 83 | return $tabs; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | -add_filter( 'give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1 ); |
|
| 86 | +add_filter('give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1); |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Connect and Reconnect Donor with User profile. |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @return array |
| 98 | 98 | */ |
| 99 | -function give_connect_user_donor_profile( $donor, $donor_data, $address ) { |
|
| 99 | +function give_connect_user_donor_profile($donor, $donor_data, $address) { |
|
| 100 | 100 | |
| 101 | 101 | $donor_id = $donor->id; |
| 102 | 102 | $previous_user_id = $donor->user_id; |
@@ -110,40 +110,40 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @since 1.0 |
| 112 | 112 | */ |
| 113 | - do_action( 'give_pre_edit_donor', $donor_id, $donor_data, $address ); |
|
| 113 | + do_action('give_pre_edit_donor', $donor_id, $donor_data, $address); |
|
| 114 | 114 | |
| 115 | 115 | $output = array(); |
| 116 | 116 | |
| 117 | - if ( $donor->update( $donor_data ) ) { |
|
| 117 | + if ($donor->update($donor_data)) { |
|
| 118 | 118 | |
| 119 | - if ( ! empty( $donor->user_id ) && $donor->user_id > 0 ) { |
|
| 120 | - update_user_meta( $donor->user_id, '_give_user_address', $address ); |
|
| 119 | + if ( ! empty($donor->user_id) && $donor->user_id > 0) { |
|
| 120 | + update_user_meta($donor->user_id, '_give_user_address', $address); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // Update some donation meta if we need to. |
| 124 | - $payments_array = explode( ',', $donor->payment_ids ); |
|
| 124 | + $payments_array = explode(',', $donor->payment_ids); |
|
| 125 | 125 | |
| 126 | - if ( $donor->user_id !== $previous_user_id ) { |
|
| 127 | - foreach ( $payments_array as $payment_id ) { |
|
| 128 | - give_update_payment_meta( $payment_id, '_give_payment_user_id', $donor->user_id ); |
|
| 126 | + if ($donor->user_id !== $previous_user_id) { |
|
| 127 | + foreach ($payments_array as $payment_id) { |
|
| 128 | + give_update_payment_meta($payment_id, '_give_payment_user_id', $donor->user_id); |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // Fetch disconnected user id, if exists. |
| 133 | - $disconnected_user_id = $donor->get_meta( '_give_disconnected_user_id', true ); |
|
| 133 | + $disconnected_user_id = $donor->get_meta('_give_disconnected_user_id', true); |
|
| 134 | 134 | |
| 135 | 135 | // Flag User and Donor Disconnection. |
| 136 | - delete_user_meta( $disconnected_user_id, '_give_is_donor_disconnected' ); |
|
| 136 | + delete_user_meta($disconnected_user_id, '_give_is_donor_disconnected'); |
|
| 137 | 137 | |
| 138 | 138 | // Check whether the disconnected user id and the reconnected user id are same or not. |
| 139 | 139 | // If both are same then delete user id store in donor meta. |
| 140 | - if( $donor_data['user_id'] === $disconnected_user_id ) { |
|
| 141 | - delete_user_meta( $disconnected_user_id, '_give_disconnected_donor_id' ); |
|
| 142 | - $donor->delete_meta( '_give_disconnected_user_id' ); |
|
| 140 | + if ($donor_data['user_id'] === $disconnected_user_id) { |
|
| 141 | + delete_user_meta($disconnected_user_id, '_give_disconnected_donor_id'); |
|
| 142 | + $donor->delete_meta('_give_disconnected_user_id'); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $output['success'] = true; |
| 146 | - $donor_data = array_merge( $donor_data, $address ); |
|
| 146 | + $donor_data = array_merge($donor_data, $address); |
|
| 147 | 147 | $output['customer_info'] = $donor_data; |
| 148 | 148 | |
| 149 | 149 | } else { |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * |
| 161 | 161 | * @since 1.0 |
| 162 | 162 | */ |
| 163 | - do_action( 'give_post_edit_donor', $donor_id, $donor_data ); |
|
| 163 | + do_action('give_post_edit_donor', $donor_id, $donor_data); |
|
| 164 | 164 | |
| 165 | 165 | |
| 166 | 166 | return $output; |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | // Show error message if Akismet not configured and Admin try to save 'enabled' option. |
| 95 | 95 | if ( isset( $_POST['akismet_spam_protection'] ) |
| 96 | - && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
| 97 | - && ! give_check_akismet_key() |
|
| 96 | + && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
| 97 | + && ! give_check_akismet_key() |
|
| 98 | 98 | ) { |
| 99 | 99 | self::add_error( 'give-akismet-protection', __( 'Please properly configure Akismet to enable SPAM protection.', 'give' ) ); |
| 100 | 100 | |
@@ -763,9 +763,9 @@ discard block |
||
| 763 | 763 | <td class="give-docs-link" colspan="2"> |
| 764 | 764 | <?php |
| 765 | 765 | echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
| 766 | - . '" target="_blank">' |
|
| 767 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
| 768 | - . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
| 766 | + . '" target="_blank">' |
|
| 767 | + . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
| 768 | + . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
| 769 | 769 | ?> |
| 770 | 770 | </td> |
| 771 | 771 | </tr><?php |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Admin_Settings' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Admin_Settings')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Admin_Settings Class. |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param array $settings Array of settings class object. |
| 74 | 74 | */ |
| 75 | - self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() ); |
|
| 75 | + self::$settings = apply_filters(self::$setting_filter_prefix.'_get_settings_pages', array()); |
|
| 76 | 76 | |
| 77 | 77 | return self::$settings; |
| 78 | 78 | } |
@@ -86,17 +86,17 @@ discard block |
||
| 86 | 86 | public static function save() { |
| 87 | 87 | $current_tab = give_get_current_setting_tab(); |
| 88 | 88 | |
| 89 | - if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) { |
|
| 90 | - echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>'; |
|
| 89 | + if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) { |
|
| 90 | + echo '<div class="notice error"><p>'.__('Action failed. Please refresh the page and retry.', 'give').'</p></div>'; |
|
| 91 | 91 | die(); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | // Show error message if Akismet not configured and Admin try to save 'enabled' option. |
| 95 | - if ( isset( $_POST['akismet_spam_protection'] ) |
|
| 96 | - && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
| 95 | + if (isset($_POST['akismet_spam_protection']) |
|
| 96 | + && give_is_setting_enabled($_POST['akismet_spam_protection']) |
|
| 97 | 97 | && ! give_check_akismet_key() |
| 98 | 98 | ) { |
| 99 | - self::add_error( 'give-akismet-protection', __( 'Please properly configure Akismet to enable SPAM protection.', 'give' ) ); |
|
| 99 | + self::add_error('give-akismet-protection', __('Please properly configure Akismet to enable SPAM protection.', 'give')); |
|
| 100 | 100 | |
| 101 | 101 | return; |
| 102 | 102 | } |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @since 1.8 |
| 112 | 112 | */ |
| 113 | - do_action( self::$setting_filter_prefix . '_save_' . $current_tab ); |
|
| 113 | + do_action(self::$setting_filter_prefix.'_save_'.$current_tab); |
|
| 114 | 114 | |
| 115 | - self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) ); |
|
| 115 | + self::add_message('give-setting-updated', __('Your settings have been saved.', 'give')); |
|
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * Trigger Action. |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @since 1.8 |
| 125 | 125 | */ |
| 126 | - do_action( self::$setting_filter_prefix . '_saved' ); |
|
| 126 | + do_action(self::$setting_filter_prefix.'_saved'); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @return void |
| 138 | 138 | */ |
| 139 | - public static function add_message( $code, $message ) { |
|
| 140 | - self::$messages[ $code ] = $message; |
|
| 139 | + public static function add_message($code, $message) { |
|
| 140 | + self::$messages[$code] = $message; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -150,8 +150,8 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @return void |
| 152 | 152 | */ |
| 153 | - public static function add_error( $code, $message ) { |
|
| 154 | - self::$errors[ $code ] = $message; |
|
| 153 | + public static function add_error($code, $message) { |
|
| 154 | + self::$errors[$code] = $message; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -164,18 +164,18 @@ discard block |
||
| 164 | 164 | $notice_html = ''; |
| 165 | 165 | $classes = 'give-notice settings-error notice is-dismissible'; |
| 166 | 166 | |
| 167 | - self::$errors = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors ); |
|
| 168 | - self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages ); |
|
| 167 | + self::$errors = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors); |
|
| 168 | + self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages); |
|
| 169 | 169 | |
| 170 | - if ( 0 < count( self::$errors ) ) { |
|
| 171 | - foreach ( self::$errors as $code => $message ) { |
|
| 172 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' error"><p><strong>' . $message . '</strong></p></div>'; |
|
| 170 | + if (0 < count(self::$errors)) { |
|
| 171 | + foreach (self::$errors as $code => $message) { |
|
| 172 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' error"><p><strong>'.$message.'</strong></p></div>'; |
|
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ( 0 < count( self::$messages ) ) { |
|
| 177 | - foreach ( self::$messages as $code => $message ) { |
|
| 178 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' updated"><p><strong>' . $message . '</strong></p></div>'; |
|
| 176 | + if (0 < count(self::$messages)) { |
|
| 177 | + foreach (self::$messages as $code => $message) { |
|
| 178 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' updated"><p><strong>'.$message.'</strong></p></div>'; |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | self::$setting_filter_prefix = give_get_current_setting_page(); |
| 196 | 196 | |
| 197 | 197 | // Bailout: Exit if setting page is not defined. |
| 198 | - if ( empty( self::$setting_filter_prefix ) ) { |
|
| 198 | + if (empty(self::$setting_filter_prefix)) { |
|
| 199 | 199 | return false; |
| 200 | 200 | } |
| 201 | 201 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * |
| 209 | 209 | * @since 1.8 |
| 210 | 210 | */ |
| 211 | - do_action( self::$setting_filter_prefix . '_start' ); |
|
| 211 | + do_action(self::$setting_filter_prefix.'_start'); |
|
| 212 | 212 | |
| 213 | 213 | $current_tab = give_get_current_setting_tab(); |
| 214 | 214 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | self::get_settings_pages(); |
| 217 | 217 | |
| 218 | 218 | // Save settings if data has been posted. |
| 219 | - if ( ! empty( $_POST ) ) { |
|
| 219 | + if ( ! empty($_POST)) { |
|
| 220 | 220 | self::save(); |
| 221 | 221 | } |
| 222 | 222 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @since 1.8 |
| 231 | 231 | */ |
| 232 | - $tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() ); |
|
| 232 | + $tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array()); |
|
| 233 | 233 | |
| 234 | 234 | include 'views/html-admin-settings.php'; |
| 235 | 235 | |
@@ -247,25 +247,25 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @return string|bool |
| 249 | 249 | */ |
| 250 | - public static function get_option( $option_name = '', $field_id = '', $default = false ) { |
|
| 250 | + public static function get_option($option_name = '', $field_id = '', $default = false) { |
|
| 251 | 251 | // Bailout. |
| 252 | - if ( empty( $option_name ) && empty( $field_id ) ) { |
|
| 252 | + if (empty($option_name) && empty($field_id)) { |
|
| 253 | 253 | return false; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if ( ! empty( $field_id ) && ! empty( $option_name ) ) { |
|
| 256 | + if ( ! empty($field_id) && ! empty($option_name)) { |
|
| 257 | 257 | // Get field value if any. |
| 258 | - $option_value = get_option( $option_name ); |
|
| 258 | + $option_value = get_option($option_name); |
|
| 259 | 259 | |
| 260 | - $option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) ) |
|
| 261 | - ? $option_value[ $field_id ] |
|
| 260 | + $option_value = (is_array($option_value) && array_key_exists($field_id, $option_value)) |
|
| 261 | + ? $option_value[$field_id] |
|
| 262 | 262 | : $default; |
| 263 | 263 | } else { |
| 264 | 264 | // If option name is empty but not field name then this means, setting is direct store to option table under there field name. |
| 265 | 265 | $option_name = ! $option_name ? $field_id : $option_name; |
| 266 | 266 | |
| 267 | 267 | // Get option value if any. |
| 268 | - $option_value = get_option( $option_name, $default ); |
|
| 268 | + $option_value = get_option($option_name, $default); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | return $option_value; |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | * |
| 284 | 284 | * @return void |
| 285 | 285 | */ |
| 286 | - public static function output_fields( $options, $option_name = '' ) { |
|
| 286 | + public static function output_fields($options, $option_name = '') { |
|
| 287 | 287 | $current_tab = give_get_current_setting_tab(); |
| 288 | 288 | |
| 289 | 289 | // Field Default values. |
@@ -296,52 +296,52 @@ discard block |
||
| 296 | 296 | 'table_html' => true, |
| 297 | 297 | ); |
| 298 | 298 | |
| 299 | - foreach ( $options as $value ) { |
|
| 300 | - if ( ! isset( $value['type'] ) ) { |
|
| 299 | + foreach ($options as $value) { |
|
| 300 | + if ( ! isset($value['type'])) { |
|
| 301 | 301 | continue; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | // Set title. |
| 305 | - $defaults['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
| 305 | + $defaults['title'] = isset($value['name']) ? $value['name'] : ''; |
|
| 306 | 306 | |
| 307 | 307 | // Set default setting. |
| 308 | - $value = wp_parse_args( $value, $defaults ); |
|
| 308 | + $value = wp_parse_args($value, $defaults); |
|
| 309 | 309 | |
| 310 | 310 | // Colorpicker field. |
| 311 | - $value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] ); |
|
| 312 | - $value['type'] = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] ); |
|
| 311 | + $value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']); |
|
| 312 | + $value['type'] = ('colorpicker' === $value['type'] ? 'text' : $value['type']); |
|
| 313 | 313 | |
| 314 | 314 | |
| 315 | 315 | // Custom attribute handling. |
| 316 | 316 | $custom_attributes = array(); |
| 317 | 317 | |
| 318 | - if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) { |
|
| 319 | - foreach ( $value['attributes'] as $attribute => $attribute_value ) { |
|
| 320 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
| 318 | + if ( ! empty($value['attributes']) && is_array($value['attributes'])) { |
|
| 319 | + foreach ($value['attributes'] as $attribute => $attribute_value) { |
|
| 320 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | // Description handling. |
| 325 | - $description = self::get_field_description( $value ); |
|
| 325 | + $description = self::get_field_description($value); |
|
| 326 | 326 | |
| 327 | 327 | // Switch based on type. |
| 328 | - switch ( $value['type'] ) { |
|
| 328 | + switch ($value['type']) { |
|
| 329 | 329 | |
| 330 | 330 | // Section Titles |
| 331 | 331 | case 'title': |
| 332 | - if ( ! empty( $value['title'] ) ) { |
|
| 333 | - echo '<div class="give-setting-tab-header give-setting-tab-header-' . $current_tab . '"><h2>' . self::get_field_title( $value ) . '</h2><hr></div>'; |
|
| 332 | + if ( ! empty($value['title'])) { |
|
| 333 | + echo '<div class="give-setting-tab-header give-setting-tab-header-'.$current_tab.'"><h2>'.self::get_field_title($value).'</h2><hr></div>'; |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if ( ! empty( $value['desc'] ) ) { |
|
| 337 | - echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); |
|
| 336 | + if ( ! empty($value['desc'])) { |
|
| 337 | + echo wpautop(wptexturize(wp_kses_post($value['desc']))); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if ( $value['table_html'] ) { |
|
| 341 | - echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n"; |
|
| 340 | + if ($value['table_html']) { |
|
| 341 | + echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n"; |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - if ( ! empty( $value['id'] ) ) { |
|
| 344 | + if ( ! empty($value['id'])) { |
|
| 345 | 345 | |
| 346 | 346 | /** |
| 347 | 347 | * Trigger Action. |
@@ -350,14 +350,14 @@ discard block |
||
| 350 | 350 | * |
| 351 | 351 | * @since 1.8 |
| 352 | 352 | */ |
| 353 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) ); |
|
| 353 | + do_action('give_settings_'.sanitize_title($value['id'])); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | break; |
| 357 | 357 | |
| 358 | 358 | // Section Ends. |
| 359 | 359 | case 'sectionend': |
| 360 | - if ( ! empty( $value['id'] ) ) { |
|
| 360 | + if ( ! empty($value['id'])) { |
|
| 361 | 361 | |
| 362 | 362 | /** |
| 363 | 363 | * Trigger Action. |
@@ -366,14 +366,14 @@ discard block |
||
| 366 | 366 | * |
| 367 | 367 | * @since 1.8 |
| 368 | 368 | */ |
| 369 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
| 369 | + do_action('give_settings_'.sanitize_title($value['id']).'_end'); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if ( $value['table_html'] ) { |
|
| 372 | + if ($value['table_html']) { |
|
| 373 | 373 | echo '</table>'; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - if ( ! empty( $value['id'] ) ) { |
|
| 376 | + if ( ! empty($value['id'])) { |
|
| 377 | 377 | |
| 378 | 378 | /** |
| 379 | 379 | * Trigger Action. |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | * |
| 383 | 383 | * @since 1.8 |
| 384 | 384 | */ |
| 385 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
| 385 | + do_action('give_settings_'.sanitize_title($value['id']).'_after'); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | break; |
@@ -390,27 +390,27 @@ discard block |
||
| 390 | 390 | // Standard text inputs and subtypes like 'number'. |
| 391 | 391 | case 'colorpicker': |
| 392 | 392 | case 'hidden' : |
| 393 | - $value['wrapper_class'] = empty( $value['wrapper_class'] ) ? 'give-hidden' : trim( $value['wrapper_class'] ) . ' give-hidden'; |
|
| 393 | + $value['wrapper_class'] = empty($value['wrapper_class']) ? 'give-hidden' : trim($value['wrapper_class']).' give-hidden'; |
|
| 394 | 394 | case 'text': |
| 395 | 395 | case 'email': |
| 396 | 396 | case 'number': |
| 397 | 397 | case 'password' : |
| 398 | 398 | $type = $value['type']; |
| 399 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 399 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 400 | 400 | ?> |
| 401 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 401 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 402 | 402 | <th scope="row" class="titledesc"> |
| 403 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 403 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 404 | 404 | </th> |
| 405 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 405 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 406 | 406 | <input |
| 407 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 408 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 409 | - type="<?php echo esc_attr( $type ); ?>" |
|
| 410 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 411 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
| 412 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
| 413 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 407 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 408 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 409 | + type="<?php echo esc_attr($type); ?>" |
|
| 410 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 411 | + value="<?php echo esc_attr($option_value); ?>" |
|
| 412 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
| 413 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 414 | 414 | /> <?php echo $description; ?> |
| 415 | 415 | </td> |
| 416 | 416 | </tr> |
@@ -420,23 +420,23 @@ discard block |
||
| 420 | 420 | // Textarea. |
| 421 | 421 | case 'textarea': |
| 422 | 422 | |
| 423 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 423 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 424 | 424 | |
| 425 | 425 | ?> |
| 426 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 426 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 427 | 427 | <th scope="row" class="titledesc"> |
| 428 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 428 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 429 | 429 | </th> |
| 430 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 430 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 431 | 431 | <textarea |
| 432 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 433 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 434 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 435 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 432 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 433 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 434 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 435 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 436 | 436 | rows="10" |
| 437 | 437 | cols="60" |
| 438 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 439 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
| 438 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 439 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
| 440 | 440 | <?php echo $description; ?> |
| 441 | 441 | </td> |
| 442 | 442 | </tr><?php |
@@ -446,35 +446,35 @@ discard block |
||
| 446 | 446 | case 'select' : |
| 447 | 447 | case 'multiselect' : |
| 448 | 448 | |
| 449 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 449 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 450 | 450 | |
| 451 | 451 | ?> |
| 452 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 452 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 453 | 453 | <th scope="row" class="titledesc"> |
| 454 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 454 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 455 | 455 | </th> |
| 456 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 456 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 457 | 457 | <select |
| 458 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) { |
|
| 458 | + name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') { |
|
| 459 | 459 | echo '[]'; |
| 460 | 460 | } ?>" |
| 461 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 462 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 463 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 464 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 465 | - <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?> |
|
| 461 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 462 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 463 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 464 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 465 | + <?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?> |
|
| 466 | 466 | > |
| 467 | 467 | |
| 468 | 468 | <?php |
| 469 | - if ( ! empty( $value['options'] ) ) { |
|
| 470 | - foreach ( $value['options'] as $key => $val ) { |
|
| 469 | + if ( ! empty($value['options'])) { |
|
| 470 | + foreach ($value['options'] as $key => $val) { |
|
| 471 | 471 | ?> |
| 472 | - <option value="<?php echo esc_attr( $key ); ?>" <?php |
|
| 472 | + <option value="<?php echo esc_attr($key); ?>" <?php |
|
| 473 | 473 | |
| 474 | - if ( is_array( $option_value ) ) { |
|
| 475 | - selected( in_array( $key, $option_value ), true ); |
|
| 474 | + if (is_array($option_value)) { |
|
| 475 | + selected(in_array($key, $option_value), true); |
|
| 476 | 476 | } else { |
| 477 | - selected( $option_value, $key ); |
|
| 477 | + selected($option_value, $key); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | ?>><?php echo $val ?></option> |
@@ -490,28 +490,28 @@ discard block |
||
| 490 | 490 | |
| 491 | 491 | // Radio inputs. |
| 492 | 492 | case 'radio_inline' : |
| 493 | - $value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline'; |
|
| 493 | + $value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline'; |
|
| 494 | 494 | case 'radio' : |
| 495 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 495 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 496 | 496 | ?> |
| 497 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 497 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 498 | 498 | <th scope="row" class="titledesc"> |
| 499 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 499 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 500 | 500 | </th> |
| 501 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
| 501 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
| 502 | 502 | <fieldset> |
| 503 | 503 | <ul> |
| 504 | 504 | <?php |
| 505 | - foreach ( $value['options'] as $key => $val ) { |
|
| 505 | + foreach ($value['options'] as $key => $val) { |
|
| 506 | 506 | ?> |
| 507 | 507 | <li> |
| 508 | 508 | <label><input |
| 509 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 509 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 510 | 510 | value="<?php echo $key; ?>" |
| 511 | 511 | type="radio" |
| 512 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 513 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 514 | - <?php checked( $key, $option_value ); ?> |
|
| 512 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 513 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 514 | + <?php checked($key, $option_value); ?> |
|
| 515 | 515 | /> <?php echo $val ?></label> |
| 516 | 516 | </li> |
| 517 | 517 | <?php |
@@ -525,21 +525,21 @@ discard block |
||
| 525 | 525 | |
| 526 | 526 | // Checkbox input. |
| 527 | 527 | case 'checkbox' : |
| 528 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 528 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 529 | 529 | ?> |
| 530 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 530 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 531 | 531 | <th scope="row" class="titledesc"> |
| 532 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 532 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 533 | 533 | </th> |
| 534 | 534 | <td class="give-forminp"> |
| 535 | 535 | <input |
| 536 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 537 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 536 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 537 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 538 | 538 | type="checkbox" |
| 539 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
| 539 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
| 540 | 540 | value="1" |
| 541 | - <?php checked( $option_value, 'on' ); ?> |
|
| 542 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 541 | + <?php checked($option_value, 'on'); ?> |
|
| 542 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 543 | 543 | /> |
| 544 | 544 | <?php echo $description; ?> |
| 545 | 545 | </td> |
@@ -549,28 +549,28 @@ discard block |
||
| 549 | 549 | |
| 550 | 550 | // Multi Checkbox input. |
| 551 | 551 | case 'multicheck' : |
| 552 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 553 | - $option_value = is_array( $option_value ) ? $option_value : array(); |
|
| 552 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 553 | + $option_value = is_array($option_value) ? $option_value : array(); |
|
| 554 | 554 | ?> |
| 555 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 555 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 556 | 556 | <th scope="row" class="titledesc"> |
| 557 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 557 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 558 | 558 | </th> |
| 559 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
| 559 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
| 560 | 560 | <fieldset> |
| 561 | 561 | <ul> |
| 562 | 562 | <?php |
| 563 | - foreach ( $value['options'] as $key => $val ) { |
|
| 563 | + foreach ($value['options'] as $key => $val) { |
|
| 564 | 564 | ?> |
| 565 | 565 | <li> |
| 566 | 566 | <label> |
| 567 | 567 | <input |
| 568 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
| 568 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
| 569 | 569 | value="<?php echo $key; ?>" |
| 570 | 570 | type="checkbox" |
| 571 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 572 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 573 | - <?php if ( in_array( $key, $option_value ) ) { |
|
| 571 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 572 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 573 | + <?php if (in_array($key, $option_value)) { |
|
| 574 | 574 | echo 'checked="checked"'; |
| 575 | 575 | } ?> |
| 576 | 576 | /> <?php echo $val ?> |
@@ -589,35 +589,35 @@ discard block |
||
| 589 | 589 | // File input field. |
| 590 | 590 | case 'file' : |
| 591 | 591 | case 'media' : |
| 592 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 593 | - $button_label = esc_html__( sprintf( 'Add or Upload %s', ( 'file' === $value['type'] ? 'File' : 'Image' ) ), 'give' ); |
|
| 594 | - $fvalue = empty( $value['fvalue'] ) ? 'url' : $value['fvalue']; |
|
| 595 | - |
|
| 596 | - $allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' ); |
|
| 597 | - $preview_image_src = $option_value ? ( 'id' === $fvalue ? wp_get_attachment_url( $option_value ) : $option_value ) : '#'; |
|
| 598 | - $preview_image_extension = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : ''; |
|
| 599 | - $is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags ); |
|
| 592 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 593 | + $button_label = esc_html__(sprintf('Add or Upload %s', ('file' === $value['type'] ? 'File' : 'Image')), 'give'); |
|
| 594 | + $fvalue = empty($value['fvalue']) ? 'url' : $value['fvalue']; |
|
| 595 | + |
|
| 596 | + $allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico'); |
|
| 597 | + $preview_image_src = $option_value ? ('id' === $fvalue ? wp_get_attachment_url($option_value) : $option_value) : '#'; |
|
| 598 | + $preview_image_extension = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : ''; |
|
| 599 | + $is_show_preview = in_array($preview_image_extension, $allow_media_preview_tags); |
|
| 600 | 600 | ?> |
| 601 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 601 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 602 | 602 | <th scope="row" class="titledesc"> |
| 603 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 603 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 604 | 604 | </th> |
| 605 | 605 | <td class="give-forminp"> |
| 606 | 606 | <div class="give-field-wrap"> |
| 607 | 607 | <label for="<?php echo $value['id'] ?>"> |
| 608 | 608 | <input |
| 609 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 610 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 609 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 610 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 611 | 611 | type="text" |
| 612 | - class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>" |
|
| 612 | + class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>" |
|
| 613 | 613 | value="<?php echo $option_value; ?>" |
| 614 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 615 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 614 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 615 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 616 | 616 | /> <input class="give-upload-button button" type="button" data-fvalue="<?php echo $fvalue; ?>" data-field-type="<?php echo $value['type']; ?>" value="<?php echo $button_label; ?>"> |
| 617 | 617 | <?php echo $description ?> |
| 618 | 618 | <div class="give-image-thumb<?php echo ! $option_value || ! $is_show_preview ? ' give-hidden' : ''; ?>"> |
| 619 | 619 | <span class="give-delete-image-thumb dashicons dashicons-no-alt"></span> |
| 620 | - <img src="<?php echo $preview_image_src ; ?>" alt=""> |
|
| 620 | + <img src="<?php echo $preview_image_src; ?>" alt=""> |
|
| 621 | 621 | </div> |
| 622 | 622 | </label> |
| 623 | 623 | </div> |
@@ -629,17 +629,17 @@ discard block |
||
| 629 | 629 | // WordPress Editor. |
| 630 | 630 | case 'wysiwyg' : |
| 631 | 631 | // Get option value. |
| 632 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 632 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 633 | 633 | |
| 634 | 634 | // Get editor settings. |
| 635 | - $editor_settings = ! empty( $value['options'] ) ? $value['options'] : array(); |
|
| 635 | + $editor_settings = ! empty($value['options']) ? $value['options'] : array(); |
|
| 636 | 636 | ?> |
| 637 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 637 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 638 | 638 | <th scope="row" class="titledesc"> |
| 639 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 639 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 640 | 640 | </th> |
| 641 | 641 | <td class="give-forminp"> |
| 642 | - <?php wp_editor( $option_value, $value['id'], $editor_settings ); ?> |
|
| 642 | + <?php wp_editor($option_value, $value['id'], $editor_settings); ?> |
|
| 643 | 643 | <?php echo $description; ?> |
| 644 | 644 | </td> |
| 645 | 645 | </tr><?php |
@@ -648,9 +648,9 @@ discard block |
||
| 648 | 648 | // Custom: System setting field. |
| 649 | 649 | case 'system_info' : |
| 650 | 650 | ?> |
| 651 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 651 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 652 | 652 | <th scope="row" class="titledesc"> |
| 653 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 653 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 654 | 654 | </th> |
| 655 | 655 | <td class="give-forminp"> |
| 656 | 656 | <?php give_system_info_callback(); ?> |
@@ -661,14 +661,14 @@ discard block |
||
| 661 | 661 | |
| 662 | 662 | // Custom: Default gateways setting field. |
| 663 | 663 | case 'default_gateway' : |
| 664 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 664 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 665 | 665 | ?> |
| 666 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 666 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 667 | 667 | <th scope="row" class="titledesc"> |
| 668 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 668 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 669 | 669 | </th> |
| 670 | 670 | <td class="give-forminp"> |
| 671 | - <?php give_default_gateway_callback( $value, $option_value ); ?> |
|
| 671 | + <?php give_default_gateway_callback($value, $option_value); ?> |
|
| 672 | 672 | <?php echo $description; ?> |
| 673 | 673 | </td> |
| 674 | 674 | </tr><?php |
@@ -676,14 +676,14 @@ discard block |
||
| 676 | 676 | |
| 677 | 677 | // Custom: Enable gateways setting field. |
| 678 | 678 | case 'enabled_gateways' : |
| 679 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 679 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 680 | 680 | ?> |
| 681 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 681 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 682 | 682 | <th scope="row" class="titledesc"> |
| 683 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 683 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 684 | 684 | </th> |
| 685 | 685 | <td class="give-forminp"> |
| 686 | - <?php give_enabled_gateways_callback( $value, $option_value ); ?> |
|
| 686 | + <?php give_enabled_gateways_callback($value, $option_value); ?> |
|
| 687 | 687 | <?php echo $description; ?> |
| 688 | 688 | </td> |
| 689 | 689 | </tr><?php |
@@ -692,9 +692,9 @@ discard block |
||
| 692 | 692 | // Custom: Email preview buttons field. |
| 693 | 693 | case 'email_preview_buttons' : |
| 694 | 694 | ?> |
| 695 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 695 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 696 | 696 | <th scope="row" class="titledesc"> |
| 697 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 697 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 698 | 698 | </th> |
| 699 | 699 | <td class="give-forminp"> |
| 700 | 700 | <?php give_email_preview_buttons_callback(); ?> |
@@ -711,22 +711,22 @@ discard block |
||
| 711 | 711 | |
| 712 | 712 | // Custom: Gateway API key. |
| 713 | 713 | case 'api_key' : |
| 714 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 715 | - $type = ! empty( $option_value ) ? 'password' : 'text'; |
|
| 714 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 715 | + $type = ! empty($option_value) ? 'password' : 'text'; |
|
| 716 | 716 | ?> |
| 717 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 717 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 718 | 718 | <th scope="row" class="titledesc"> |
| 719 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 719 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 720 | 720 | </th> |
| 721 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 721 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 722 | 722 | <input |
| 723 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 724 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 725 | - type="<?php echo esc_attr( $type ); ?>" |
|
| 726 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 727 | - value="<?php echo esc_attr( trim( $option_value ) ); ?>" |
|
| 728 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
| 729 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 723 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 724 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 725 | + type="<?php echo esc_attr($type); ?>" |
|
| 726 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 727 | + value="<?php echo esc_attr(trim($option_value)); ?>" |
|
| 728 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
| 729 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 730 | 730 | /> <?php echo $description; ?> |
| 731 | 731 | </td> |
| 732 | 732 | </tr><?php |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | * |
| 744 | 744 | * @since 1.0 |
| 745 | 745 | */ |
| 746 | - do_action( "give_logs_view_{$current_section}" ); |
|
| 746 | + do_action("give_logs_view_{$current_section}"); |
|
| 747 | 747 | |
| 748 | 748 | echo $description; |
| 749 | 749 | break; |
@@ -751,7 +751,7 @@ discard block |
||
| 751 | 751 | // Custom: Data field. |
| 752 | 752 | case 'data' : |
| 753 | 753 | |
| 754 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php'; |
|
| 754 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-data.php'; |
|
| 755 | 755 | |
| 756 | 756 | echo $description; |
| 757 | 757 | break; |
@@ -759,12 +759,12 @@ discard block |
||
| 759 | 759 | // Custom: Give Docs Link field type. |
| 760 | 760 | case 'give_docs_link' : |
| 761 | 761 | ?> |
| 762 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 762 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 763 | 763 | <td class="give-docs-link" colspan="2"> |
| 764 | 764 | <?php |
| 765 | - echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
|
| 765 | + echo '<p class="give-docs-link"><a href="'.esc_url($value['url']) |
|
| 766 | 766 | . '" target="_blank">' |
| 767 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
| 767 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $value['title']) |
|
| 768 | 768 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
| 769 | 769 | ?> |
| 770 | 770 | </td> |
@@ -775,8 +775,8 @@ discard block |
||
| 775 | 775 | // You can add or handle your custom field action. |
| 776 | 776 | default: |
| 777 | 777 | // Get option value. |
| 778 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 779 | - do_action( 'give_admin_field_' . $value['type'], $value, $option_value ); |
|
| 778 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 779 | + do_action('give_admin_field_'.$value['type'], $value, $option_value); |
|
| 780 | 780 | break; |
| 781 | 781 | } |
| 782 | 782 | } |
@@ -792,15 +792,15 @@ discard block |
||
| 792 | 792 | * |
| 793 | 793 | * @return string The HTML description of the field. |
| 794 | 794 | */ |
| 795 | - public static function get_field_description( $value ) { |
|
| 795 | + public static function get_field_description($value) { |
|
| 796 | 796 | $description = ''; |
| 797 | 797 | |
| 798 | 798 | // Support for both 'description' and 'desc' args. |
| 799 | - $description_key = isset( $value['description'] ) ? 'description' : 'desc'; |
|
| 800 | - $value = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : ''; |
|
| 799 | + $description_key = isset($value['description']) ? 'description' : 'desc'; |
|
| 800 | + $value = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : ''; |
|
| 801 | 801 | |
| 802 | - if ( ! empty( $value ) ) { |
|
| 803 | - $description = '<p class="give-field-description">' . wp_kses_post( $value ) . '</p>'; |
|
| 802 | + if ( ! empty($value)) { |
|
| 803 | + $description = '<p class="give-field-description">'.wp_kses_post($value).'</p>'; |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | return $description; |
@@ -817,11 +817,11 @@ discard block |
||
| 817 | 817 | * |
| 818 | 818 | * @return array The description and tip as a 2 element array |
| 819 | 819 | */ |
| 820 | - public static function get_field_title( $value ) { |
|
| 821 | - $title = esc_html( $value['title'] ); |
|
| 820 | + public static function get_field_title($value) { |
|
| 821 | + $title = esc_html($value['title']); |
|
| 822 | 822 | |
| 823 | 823 | // If html tag detected then allow them to print. |
| 824 | - if ( strip_tags( $title ) ) { |
|
| 824 | + if (strip_tags($title)) { |
|
| 825 | 825 | $title = $value['title']; |
| 826 | 826 | } |
| 827 | 827 | |
@@ -840,8 +840,8 @@ discard block |
||
| 840 | 840 | * |
| 841 | 841 | * @return bool |
| 842 | 842 | */ |
| 843 | - public static function save_fields( $options, $option_name = '' ) { |
|
| 844 | - if ( empty( $_POST ) ) { |
|
| 843 | + public static function save_fields($options, $option_name = '') { |
|
| 844 | + if (empty($_POST)) { |
|
| 845 | 845 | return false; |
| 846 | 846 | } |
| 847 | 847 | |
@@ -849,37 +849,37 @@ discard block |
||
| 849 | 849 | $update_options = array(); |
| 850 | 850 | |
| 851 | 851 | // Loop options and get values to save. |
| 852 | - foreach ( $options as $option ) { |
|
| 853 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
| 852 | + foreach ($options as $option) { |
|
| 853 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
| 854 | 854 | continue; |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | // Get posted value. |
| 858 | - if ( strstr( $option['id'], '[' ) ) { |
|
| 859 | - parse_str( $option['id'], $option_name_array ); |
|
| 860 | - $field_option_name = current( array_keys( $option_name_array ) ); |
|
| 861 | - $setting_name = key( $option_name_array[ $field_option_name ] ); |
|
| 862 | - $raw_value = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null; |
|
| 858 | + if (strstr($option['id'], '[')) { |
|
| 859 | + parse_str($option['id'], $option_name_array); |
|
| 860 | + $field_option_name = current(array_keys($option_name_array)); |
|
| 861 | + $setting_name = key($option_name_array[$field_option_name]); |
|
| 862 | + $raw_value = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null; |
|
| 863 | 863 | } else { |
| 864 | 864 | $field_option_name = $option['id']; |
| 865 | 865 | $setting_name = ''; |
| 866 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
| 866 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
| 867 | 867 | } |
| 868 | 868 | |
| 869 | 869 | // Format the value based on option type. |
| 870 | - switch ( $option['type'] ) { |
|
| 870 | + switch ($option['type']) { |
|
| 871 | 871 | case 'checkbox' : |
| 872 | - $value = is_null( $raw_value ) ? '' : 'on'; |
|
| 872 | + $value = is_null($raw_value) ? '' : 'on'; |
|
| 873 | 873 | break; |
| 874 | 874 | case 'wysiwyg' : |
| 875 | 875 | case 'textarea' : |
| 876 | - $value = wp_kses_post( trim( $raw_value ) ); |
|
| 876 | + $value = wp_kses_post(trim($raw_value)); |
|
| 877 | 877 | break; |
| 878 | 878 | case 'multiselect' : |
| 879 | - $value = array_filter( array_map( 'give_clean', (array) $raw_value ) ); |
|
| 879 | + $value = array_filter(array_map('give_clean', (array) $raw_value)); |
|
| 880 | 880 | break; |
| 881 | 881 | default : |
| 882 | - $value = give_clean( $raw_value ); |
|
| 882 | + $value = give_clean($raw_value); |
|
| 883 | 883 | break; |
| 884 | 884 | } |
| 885 | 885 | |
@@ -888,37 +888,37 @@ discard block |
||
| 888 | 888 | * |
| 889 | 889 | * @since 1.8 |
| 890 | 890 | */ |
| 891 | - $value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value ); |
|
| 891 | + $value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value); |
|
| 892 | 892 | |
| 893 | 893 | /** |
| 894 | 894 | * Sanitize the value of an option by option name. |
| 895 | 895 | * |
| 896 | 896 | * @since 1.8 |
| 897 | 897 | */ |
| 898 | - $value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value ); |
|
| 898 | + $value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value); |
|
| 899 | 899 | |
| 900 | - if ( is_null( $value ) ) { |
|
| 900 | + if (is_null($value)) { |
|
| 901 | 901 | continue; |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | 904 | // Check if option is an array and handle that differently to single values. |
| 905 | - if ( $field_option_name && $setting_name ) { |
|
| 906 | - if ( ! isset( $update_options[ $field_option_name ] ) ) { |
|
| 907 | - $update_options[ $field_option_name ] = get_option( $field_option_name, array() ); |
|
| 905 | + if ($field_option_name && $setting_name) { |
|
| 906 | + if ( ! isset($update_options[$field_option_name])) { |
|
| 907 | + $update_options[$field_option_name] = get_option($field_option_name, array()); |
|
| 908 | 908 | } |
| 909 | - if ( ! is_array( $update_options[ $field_option_name ] ) ) { |
|
| 910 | - $update_options[ $field_option_name ] = array(); |
|
| 909 | + if ( ! is_array($update_options[$field_option_name])) { |
|
| 910 | + $update_options[$field_option_name] = array(); |
|
| 911 | 911 | } |
| 912 | - $update_options[ $field_option_name ][ $setting_name ] = $value; |
|
| 912 | + $update_options[$field_option_name][$setting_name] = $value; |
|
| 913 | 913 | } else { |
| 914 | - $update_options[ $field_option_name ] = $value; |
|
| 914 | + $update_options[$field_option_name] = $value; |
|
| 915 | 915 | } |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | // Save all options in our array or there own option name i.e. option id. |
| 919 | - if ( empty( $option_name ) ) { |
|
| 920 | - foreach ( $update_options as $name => $value ) { |
|
| 921 | - update_option( $name, $value ); |
|
| 919 | + if (empty($option_name)) { |
|
| 920 | + foreach ($update_options as $name => $value) { |
|
| 921 | + update_option($name, $value); |
|
| 922 | 922 | |
| 923 | 923 | /** |
| 924 | 924 | * Trigger action. |
@@ -927,13 +927,13 @@ discard block |
||
| 927 | 927 | * |
| 928 | 928 | * @since 1.8 |
| 929 | 929 | */ |
| 930 | - do_action( "give_save_option_{$name}", $value, $name ); |
|
| 930 | + do_action("give_save_option_{$name}", $value, $name); |
|
| 931 | 931 | } |
| 932 | 932 | } else { |
| 933 | - $old_options = ( $old_options = get_option( $option_name ) ) ? $old_options : array(); |
|
| 934 | - $update_options = array_merge( $old_options, $update_options ); |
|
| 933 | + $old_options = ($old_options = get_option($option_name)) ? $old_options : array(); |
|
| 934 | + $update_options = array_merge($old_options, $update_options); |
|
| 935 | 935 | |
| 936 | - update_option( $option_name, $update_options ); |
|
| 936 | + update_option($option_name, $update_options); |
|
| 937 | 937 | |
| 938 | 938 | /** |
| 939 | 939 | * Trigger action. |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | * |
| 943 | 943 | * @since 1.8 |
| 944 | 944 | */ |
| 945 | - do_action( "give_save_settings_{$option_name}", $update_options, $option_name ); |
|
| 945 | + do_action("give_save_settings_{$option_name}", $update_options, $option_name); |
|
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | return true; |