@@ -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 | |
@@ -29,33 +29,33 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @return void |
| 31 | 31 | */ |
| 32 | -function give_print_errors( $form_id ) { |
|
| 32 | +function give_print_errors($form_id) { |
|
| 33 | 33 | |
| 34 | 34 | $errors = give_get_errors(); |
| 35 | 35 | |
| 36 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? intval( $_REQUEST['form-id'] ) : 0; |
|
| 36 | + $request_form_id = isset($_REQUEST['form-id']) ? intval($_REQUEST['form-id']) : 0; |
|
| 37 | 37 | |
| 38 | 38 | //Sanity checks first: Ensure that gateway returned errors display on the appropriate form |
| 39 | - if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) { |
|
| 39 | + if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) { |
|
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if ( $errors ) { |
|
| 44 | - $classes = apply_filters( 'give_error_class', array( |
|
| 43 | + if ($errors) { |
|
| 44 | + $classes = apply_filters('give_error_class', array( |
|
| 45 | 45 | 'give_errors' |
| 46 | - ) ); |
|
| 47 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
| 46 | + )); |
|
| 47 | + echo '<div class="'.implode(' ', $classes).'">'; |
|
| 48 | 48 | // Loop error codes and display errors |
| 49 | - foreach ( $errors as $error_id => $error ) { |
|
| 50 | - echo '<div class="give_error" id="give_error_' . $error_id . '"><p><strong>' . __( 'Error', 'give' ) . '</strong>: ' . $error . '</p></div>'; |
|
| 49 | + foreach ($errors as $error_id => $error) { |
|
| 50 | + echo '<div class="give_error" id="give_error_'.$error_id.'"><p><strong>'.__('Error', 'give').'</strong>: '.$error.'</p></div>'; |
|
| 51 | 51 | } |
| 52 | 52 | echo '</div>'; |
| 53 | 53 | give_clear_errors(); |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | -add_action( 'give_purchase_form_before_personal_info', 'give_print_errors' ); |
|
| 58 | -add_action( 'give_ajax_checkout_errors', 'give_print_errors' ); |
|
| 57 | +add_action('give_purchase_form_before_personal_info', 'give_print_errors'); |
|
| 58 | +add_action('give_ajax_checkout_errors', 'give_print_errors'); |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Get Errors |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return mixed array if errors are present, false if none found |
| 69 | 69 | */ |
| 70 | 70 | function give_get_errors() { |
| 71 | - return Give()->session->get( 'give_errors' ); |
|
| 71 | + return Give()->session->get('give_errors'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -84,13 +84,13 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return void |
| 86 | 86 | */ |
| 87 | -function give_set_error( $error_id, $error_message ) { |
|
| 87 | +function give_set_error($error_id, $error_message) { |
|
| 88 | 88 | $errors = give_get_errors(); |
| 89 | - if ( ! $errors ) { |
|
| 89 | + if ( ! $errors) { |
|
| 90 | 90 | $errors = array(); |
| 91 | 91 | } |
| 92 | - $errors[ $error_id ] = $error_message; |
|
| 93 | - Give()->session->set( 'give_errors', $errors ); |
|
| 92 | + $errors[$error_id] = $error_message; |
|
| 93 | + Give()->session->set('give_errors', $errors); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @return void |
| 102 | 102 | */ |
| 103 | 103 | function give_clear_errors() { |
| 104 | - Give()->session->set( 'give_errors', null ); |
|
| 104 | + Give()->session->set('give_errors', null); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return string |
| 116 | 116 | */ |
| 117 | -function give_unset_error( $error_id ) { |
|
| 117 | +function give_unset_error($error_id) { |
|
| 118 | 118 | $errors = give_get_errors(); |
| 119 | - if ( $errors ) { |
|
| 120 | - unset( $errors[ $error_id ] ); |
|
| 121 | - Give()->session->set( 'give_errors', $errors ); |
|
| 119 | + if ($errors) { |
|
| 120 | + unset($errors[$error_id]); |
|
| 121 | + Give()->session->set('give_errors', $errors); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @return void |
| 130 | 130 | */ |
| 131 | 131 | function _give_die_handler() { |
| 132 | - if ( defined( 'GIVE_UNIT_TESTS' ) ) { |
|
| 132 | + if (defined('GIVE_UNIT_TESTS')) { |
|
| 133 | 133 | return '_give_die_handler'; |
| 134 | 134 | } else { |
| 135 | 135 | die(); |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | * @since 1.0 |
| 145 | 145 | * @return void |
| 146 | 146 | */ |
| 147 | -function give_die( $message = '', $title = '', $status = 400 ) { |
|
| 148 | - add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 ); |
|
| 149 | - add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 ); |
|
| 150 | - wp_die( $message, $title, array( 'response' => $status ) ); |
|
| 147 | +function give_die($message = '', $title = '', $status = 400) { |
|
| 148 | + add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3); |
|
| 149 | + add_filter('wp_die_handler', '_give_die_handler', 10, 3); |
|
| 150 | + wp_die($message, $title, array('response' => $status)); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @return string $error |
| 164 | 164 | */ |
| 165 | -function give_output_error( $message, $echo = true, $error_id = 'warning' ) { |
|
| 166 | - $error = '<div class="give_errors" id="give_error_' . $error_id . '"><p class="give_error give_' . $error_id . '">' . $message . '</p></div>'; |
|
| 165 | +function give_output_error($message, $echo = true, $error_id = 'warning') { |
|
| 166 | + $error = '<div class="give_errors" id="give_error_'.$error_id.'"><p class="give_error give_'.$error_id.'">'.$message.'</p></div>'; |
|
| 167 | 167 | |
| 168 | - if ( $echo ) { |
|
| 168 | + if ($echo) { |
|
| 169 | 169 | echo $error; |
| 170 | 170 | } else { |
| 171 | 171 | return $error; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -25,37 +25,37 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return string $amount Newly sanitized amount |
| 27 | 27 | */ |
| 28 | -function give_sanitize_amount( $amount ) { |
|
| 28 | +function give_sanitize_amount($amount) { |
|
| 29 | 29 | $is_negative = false; |
| 30 | - $thousands_sep = give_get_option( 'thousands_separator', ',' ); |
|
| 31 | - $decimal_sep = give_get_option( 'decimal_separator', '.' ); |
|
| 30 | + $thousands_sep = give_get_option('thousands_separator', ','); |
|
| 31 | + $decimal_sep = give_get_option('decimal_separator', '.'); |
|
| 32 | 32 | |
| 33 | 33 | // Sanitize the amount |
| 34 | - if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) { |
|
| 35 | - if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 36 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
| 37 | - } elseif ( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) { |
|
| 38 | - $amount = str_replace( '.', '', $amount ); |
|
| 34 | + if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) { |
|
| 35 | + if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 36 | + $amount = str_replace($thousands_sep, '', $amount); |
|
| 37 | + } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) { |
|
| 38 | + $amount = str_replace('.', '', $amount); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
| 42 | - } elseif ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 43 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
| 41 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
| 42 | + } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 43 | + $amount = str_replace($thousands_sep, '', $amount); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if ( $amount < 0 ) { |
|
| 46 | + if ($amount < 0) { |
|
| 47 | 47 | $is_negative = true; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - $amount = preg_replace( '/[^0-9\.]/', '', $amount ); |
|
| 51 | - $decimals = apply_filters( 'give_sanitize_amount_decimals', 2, $amount ); |
|
| 52 | - $amount = number_format( (double) $amount, $decimals, '.', '' ); |
|
| 50 | + $amount = preg_replace('/[^0-9\.]/', '', $amount); |
|
| 51 | + $decimals = apply_filters('give_sanitize_amount_decimals', 2, $amount); |
|
| 52 | + $amount = number_format((double) $amount, $decimals, '.', ''); |
|
| 53 | 53 | |
| 54 | - if ( $is_negative ) { |
|
| 54 | + if ($is_negative) { |
|
| 55 | 55 | $amount *= - 1; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - return apply_filters( 'give_sanitize_amount', $amount ); |
|
| 58 | + return apply_filters('give_sanitize_amount', $amount); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -68,47 +68,47 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @return string $amount Newly formatted amount or Price Not Available |
| 70 | 70 | */ |
| 71 | -function give_format_amount( $amount, $decimals = true ) { |
|
| 71 | +function give_format_amount($amount, $decimals = true) { |
|
| 72 | 72 | |
| 73 | - $thousands_sep = give_get_option( 'thousands_separator', ',' ); |
|
| 74 | - $decimal_sep = give_get_option( 'decimal_separator', '.' ); |
|
| 73 | + $thousands_sep = give_get_option('thousands_separator', ','); |
|
| 74 | + $decimal_sep = give_get_option('decimal_separator', '.'); |
|
| 75 | 75 | |
| 76 | 76 | // Format the amount |
| 77 | - if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) { |
|
| 78 | - $whole = substr( $amount, 0, $sep_found ); |
|
| 79 | - $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) ); |
|
| 80 | - $amount = $whole . '.' . $part; |
|
| 77 | + if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) { |
|
| 78 | + $whole = substr($amount, 0, $sep_found); |
|
| 79 | + $part = substr($amount, $sep_found + 1, (strlen($amount) - 1)); |
|
| 80 | + $amount = $whole.'.'.$part; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // Strip , from the amount (if set as the thousands separator) |
| 84 | - if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 85 | - $amount = str_replace( ',', '', $amount ); |
|
| 84 | + if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 85 | + $amount = str_replace(',', '', $amount); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // Strip . from the amount (if set as the thousands separator) AND , set to decimal separator |
| 89 | - if ( $thousands_sep == '.' && $decimal_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 90 | - $amount = explode( '.', $amount ); |
|
| 91 | - $array_count = count( $amount ); |
|
| 92 | - if ( $decimals == true ) { |
|
| 93 | - unset( $amount[ $array_count - 1 ] ); |
|
| 89 | + if ($thousands_sep == '.' && $decimal_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 90 | + $amount = explode('.', $amount); |
|
| 91 | + $array_count = count($amount); |
|
| 92 | + if ($decimals == true) { |
|
| 93 | + unset($amount[$array_count - 1]); |
|
| 94 | 94 | } |
| 95 | - $amount = implode( '', $amount ); |
|
| 95 | + $amount = implode('', $amount); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // Strip ' ' from the amount (if set as the thousands separator) |
| 99 | - if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 100 | - $amount = str_replace( ' ', '', $amount ); |
|
| 99 | + if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 100 | + $amount = str_replace(' ', '', $amount); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if ( empty( $amount ) ) { |
|
| 103 | + if (empty($amount)) { |
|
| 104 | 104 | $amount = 0; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - $decimals = apply_filters( 'give_format_amount_decimals', $decimals ? 2 : 0, $amount ); |
|
| 107 | + $decimals = apply_filters('give_format_amount_decimals', $decimals ? 2 : 0, $amount); |
|
| 108 | 108 | |
| 109 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 109 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 110 | 110 | |
| 111 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 111 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -119,13 +119,13 @@ discard block |
||
| 119 | 119 | * @param $field_args |
| 120 | 120 | * @param $field |
| 121 | 121 | */ |
| 122 | -function give_format_admin_multilevel_amount( $field_args, $field ) { |
|
| 122 | +function give_format_admin_multilevel_amount($field_args, $field) { |
|
| 123 | 123 | |
| 124 | - if ( empty( $field->value ) ) { |
|
| 124 | + if (empty($field->value)) { |
|
| 125 | 125 | return false; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $field->value = give_format_amount( $field->value ); |
|
| 128 | + $field->value = give_format_amount($field->value); |
|
| 129 | 129 | |
| 130 | 130 | } |
| 131 | 131 | |
@@ -138,25 +138,25 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @return array $currency Currencies displayed correctly |
| 140 | 140 | */ |
| 141 | -function give_currency_filter( $price = '', $currency = '' ) { |
|
| 142 | - if ( empty( $currency ) ) { |
|
| 141 | +function give_currency_filter($price = '', $currency = '') { |
|
| 142 | + if (empty($currency)) { |
|
| 143 | 143 | |
| 144 | 144 | $currency = give_get_currency(); |
| 145 | 145 | |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $position = give_get_option( 'currency_position', 'before' ); |
|
| 148 | + $position = give_get_option('currency_position', 'before'); |
|
| 149 | 149 | |
| 150 | 150 | $negative = $price < 0; |
| 151 | 151 | |
| 152 | - if ( $negative ) { |
|
| 153 | - $price = substr( $price, 1 ); // Remove proceeding "-" - |
|
| 152 | + if ($negative) { |
|
| 153 | + $price = substr($price, 1); // Remove proceeding "-" - |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - $symbol = give_currency_symbol( $currency ); |
|
| 156 | + $symbol = give_currency_symbol($currency); |
|
| 157 | 157 | |
| 158 | - if ( $position == 'before' ): |
|
| 159 | - switch ( $currency ): |
|
| 158 | + if ($position == 'before'): |
|
| 159 | + switch ($currency): |
|
| 160 | 160 | case "GBP" : |
| 161 | 161 | case "BRL" : |
| 162 | 162 | case "EUR" : |
@@ -168,18 +168,18 @@ discard block |
||
| 168 | 168 | case "NZD" : |
| 169 | 169 | case "SGD" : |
| 170 | 170 | case "JPY" : |
| 171 | - $formatted = $symbol . $price; |
|
| 171 | + $formatted = $symbol.$price; |
|
| 172 | 172 | break; |
| 173 | 173 | case "NOK" : |
| 174 | - $formatted = $symbol . ' ' . $price; |
|
| 174 | + $formatted = $symbol.' '.$price; |
|
| 175 | 175 | break; |
| 176 | 176 | default : |
| 177 | - $formatted = $currency . ' ' . $price; |
|
| 177 | + $formatted = $currency.' '.$price; |
|
| 178 | 178 | break; |
| 179 | 179 | endswitch; |
| 180 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . '_currency_filter_before', $formatted, $currency, $price ); |
|
| 180 | + $formatted = apply_filters('give_'.strtolower($currency).'_currency_filter_before', $formatted, $currency, $price); |
|
| 181 | 181 | else : |
| 182 | - switch ( $currency ) : |
|
| 182 | + switch ($currency) : |
|
| 183 | 183 | case "GBP" : |
| 184 | 184 | case "BRL" : |
| 185 | 185 | case "EUR" : |
@@ -190,18 +190,18 @@ discard block |
||
| 190 | 190 | case "MXN" : |
| 191 | 191 | case "SGD" : |
| 192 | 192 | case "JPY" : |
| 193 | - $formatted = $price . $symbol; |
|
| 193 | + $formatted = $price.$symbol; |
|
| 194 | 194 | break; |
| 195 | 195 | default : |
| 196 | - $formatted = $price . ' ' . $currency; |
|
| 196 | + $formatted = $price.' '.$currency; |
|
| 197 | 197 | break; |
| 198 | 198 | endswitch; |
| 199 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . '_currency_filter_after', $formatted, $currency, $price ); |
|
| 199 | + $formatted = apply_filters('give_'.strtolower($currency).'_currency_filter_after', $formatted, $currency, $price); |
|
| 200 | 200 | endif; |
| 201 | 201 | |
| 202 | - if ( $negative ) { |
|
| 202 | + if ($negative) { |
|
| 203 | 203 | // Prepend the mins sign before the currency sign |
| 204 | - $formatted = '-' . $formatted; |
|
| 204 | + $formatted = '-'.$formatted; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | return $formatted; |
@@ -216,11 +216,11 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @return int $decimals |
| 218 | 218 | */ |
| 219 | -function give_currency_decimal_filter( $decimals = 2 ) { |
|
| 219 | +function give_currency_decimal_filter($decimals = 2) { |
|
| 220 | 220 | |
| 221 | 221 | $currency = give_get_currency(); |
| 222 | 222 | |
| 223 | - switch ( $currency ) { |
|
| 223 | + switch ($currency) { |
|
| 224 | 224 | case 'RIAL' : |
| 225 | 225 | case 'JPY' : |
| 226 | 226 | case 'TWD' : |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | break; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - return apply_filters( 'give_currency_decimal_count', $decimals, $currency ); |
|
| 233 | + return apply_filters('give_currency_decimal_count', $decimals, $currency); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | -add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 237 | -add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 238 | 236 | \ No newline at end of file |
| 237 | +add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
| 238 | +add_filter('give_format_amount_decimals', 'give_currency_decimal_filter'); |
|
| 239 | 239 | \ No newline at end of file |
@@ -142,8 +142,10 @@ |
||
| 142 | 142 | |
| 143 | 143 | if ( is_front_page() ) : |
| 144 | 144 | $page_url = home_url(); |
| 145 | - else : |
|
| 145 | + else { |
|
| 146 | + : |
|
| 146 | 147 | $page_url = 'http'; |
| 148 | + } |
|
| 147 | 149 | |
| 148 | 150 | if ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) { |
| 149 | 151 | $page_url .= "s"; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -defined( 'ABSPATH' ) or exit; |
|
| 13 | +defined('ABSPATH') or exit; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Give Form widget |
@@ -31,18 +31,18 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function __construct() |
| 33 | 33 | { |
| 34 | - $this->self = get_class( $this ); |
|
| 34 | + $this->self = get_class($this); |
|
| 35 | 35 | |
| 36 | 36 | parent::__construct( |
| 37 | - strtolower( $this->self ), |
|
| 38 | - __( 'Give - Donation Form', 'give' ), |
|
| 37 | + strtolower($this->self), |
|
| 38 | + __('Give - Donation Form', 'give'), |
|
| 39 | 39 | array( |
| 40 | - 'description' => __( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
| 40 | + 'description' => __('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
| 41 | 41 | ) |
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
| 45 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
| 44 | + add_action('widgets_init', array($this, 'widget_init')); |
|
| 45 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -52,24 +52,24 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return void |
| 54 | 54 | */ |
| 55 | - public function admin_widget_scripts( $hook ) |
|
| 55 | + public function admin_widget_scripts($hook) |
|
| 56 | 56 | { |
| 57 | 57 | // Directories of assets |
| 58 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
| 59 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
| 60 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
| 58 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
| 59 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
| 60 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
| 61 | 61 | |
| 62 | 62 | // Use minified libraries if SCRIPT_DEBUG is turned off |
| 63 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 63 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 64 | 64 | |
| 65 | 65 | // Widget Script |
| 66 | - if ( $hook == 'widgets.php' ) { |
|
| 66 | + if ($hook == 'widgets.php') { |
|
| 67 | 67 | |
| 68 | - wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' ); |
|
| 68 | + wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css'); |
|
| 69 | 69 | |
| 70 | - wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
| 70 | + wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
| 71 | 71 | |
| 72 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 72 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
@@ -80,24 +80,24 @@ discard block |
||
| 80 | 80 | * before_widget, and after_widget. |
| 81 | 81 | * @param array $instance The settings for the particular instance of the widget. |
| 82 | 82 | */ |
| 83 | - public function widget( $args, $instance ) |
|
| 83 | + public function widget($args, $instance) |
|
| 84 | 84 | { |
| 85 | - extract( $args ); |
|
| 85 | + extract($args); |
|
| 86 | 86 | |
| 87 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
| 88 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
| 87 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
| 88 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
| 89 | 89 | |
| 90 | 90 | echo $before_widget; |
| 91 | 91 | |
| 92 | - do_action( 'give_before_forms_widget' ); |
|
| 92 | + do_action('give_before_forms_widget'); |
|
| 93 | 93 | |
| 94 | - echo $title ? $before_title . $title . $after_title : ''; |
|
| 94 | + echo $title ? $before_title.$title.$after_title : ''; |
|
| 95 | 95 | |
| 96 | - give_get_donation_form( $instance ); |
|
| 96 | + give_get_donation_form($instance); |
|
| 97 | 97 | |
| 98 | 98 | echo $after_widget; |
| 99 | 99 | |
| 100 | - do_action( 'give_after_forms_widget' ); |
|
| 100 | + do_action('give_after_forms_widget'); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return string |
| 109 | 109 | */ |
| 110 | - public function form( $instance ) |
|
| 110 | + public function form($instance) |
|
| 111 | 111 | { |
| 112 | 112 | $defaults = array( |
| 113 | 113 | 'title' => '', |
@@ -115,51 +115,51 @@ discard block |
||
| 115 | 115 | 'float_labels' => '', |
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
| 118 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
| 119 | 119 | |
| 120 | - extract( $instance ); |
|
| 120 | + extract($instance); |
|
| 121 | 121 | |
| 122 | 122 | // Query Give Forms |
| 123 | 123 | |
| 124 | 124 | $args = array( |
| 125 | 125 | 'post_type' => 'give_forms', |
| 126 | - 'posts_per_page' => - 1, |
|
| 126 | + 'posts_per_page' => -1, |
|
| 127 | 127 | 'post_status' => 'publish', |
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | - $give_forms = get_posts( $args ); |
|
| 130 | + $give_forms = get_posts($args); |
|
| 131 | 131 | |
| 132 | 132 | // Widget: Title |
| 133 | 133 | |
| 134 | 134 | ?><p> |
| 135 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'give' ); ?></label> |
|
| 136 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $title ); ?>" /><br> |
|
| 137 | - <small><?php _e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
| 135 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'give'); ?></label> |
|
| 136 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($title); ?>" /><br> |
|
| 137 | + <small><?php _e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
| 138 | 138 | </p><?php |
| 139 | 139 | |
| 140 | 140 | // Widget: Give Form |
| 141 | 141 | |
| 142 | 142 | ?><p> |
| 143 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php printf( __( 'Give %s:', 'give' ), give_get_forms_label_singular() ); ?></label> |
|
| 144 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
| 145 | - <option value="current"><?php _e( '— Select —', 'give' ); ?></option> |
|
| 146 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
| 147 | - <option <?php selected( absint( $id ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $give_form->post_title; ?></option> |
|
| 143 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php printf(__('Give %s:', 'give'), give_get_forms_label_singular()); ?></label> |
|
| 144 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
| 145 | + <option value="current"><?php _e('— Select —', 'give'); ?></option> |
|
| 146 | + <?php foreach ($give_forms as $give_form) { ?> |
|
| 147 | + <option <?php selected(absint($id), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $give_form->post_title; ?></option> |
|
| 148 | 148 | <?php } ?> |
| 149 | 149 | </select><br> |
| 150 | - <small><?php _e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
| 150 | + <small><?php _e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
| 151 | 151 | </p><?php |
| 152 | 152 | |
| 153 | 153 | // Widget: Floating Labels |
| 154 | 154 | |
| 155 | 155 | ?><p> |
| 156 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php _e( 'Floating Labels (optional):', 'give' ); ?></label> |
|
| 157 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'float_labels' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"> |
|
| 158 | - <option value="" <?php selected( esc_attr( $float_labels ), '' ) ?>>– <?php _e( 'Select', 'give' ); ?> –</option> |
|
| 159 | - <option value="enabled" <?php selected( esc_attr( $float_labels ), 'enabled' ) ?>><?php _e( 'Enabled', 'give' ); ?></option> |
|
| 160 | - <option value="disabled" <?php selected( esc_attr( $float_labels ), 'disabled' ) ?>><?php _e( 'Disabled', 'give' ); ?></option> |
|
| 156 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php _e('Floating Labels (optional):', 'give'); ?></label> |
|
| 157 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('float_labels')); ?>" id="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"> |
|
| 158 | + <option value="" <?php selected(esc_attr($float_labels), '') ?>>– <?php _e('Select', 'give'); ?> –</option> |
|
| 159 | + <option value="enabled" <?php selected(esc_attr($float_labels), 'enabled') ?>><?php _e('Enabled', 'give'); ?></option> |
|
| 160 | + <option value="disabled" <?php selected(esc_attr($float_labels), 'disabled') ?>><?php _e('Disabled', 'give'); ?></option> |
|
| 161 | 161 | </select><br> |
| 162 | - <small><?php printf( __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), esc_url( "http://bradfrost.com/blog/post/float-label-pattern/" ) ); ?></small> |
|
| 162 | + <small><?php printf(__('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), esc_url("http://bradfrost.com/blog/post/float-label-pattern/")); ?></small> |
|
| 163 | 163 | </p><?php |
| 164 | 164 | } |
| 165 | 165 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | function widget_init() |
| 172 | 172 | { |
| 173 | - register_widget( $this->self ); |
|
| 173 | + register_widget($this->self); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * |
| 182 | 182 | * @return array |
| 183 | 183 | */ |
| 184 | - public function update( $new_instance, $old_instance ) |
|
| 184 | + public function update($new_instance, $old_instance) |
|
| 185 | 185 | { |
| 186 | 186 | $this->flush_widget_cache(); |
| 187 | 187 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | public function flush_widget_cache() |
| 197 | 197 | { |
| 198 | - wp_cache_delete( $this->self, 'widget' ); |
|
| 198 | + wp_cache_delete($this->self, 'widget'); |
|
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Give Form Widget |
|
| 4 | - * |
|
| 5 | - * @package WordImpress |
|
| 6 | - * @subpackage Admin/Forms |
|
| 7 | - * @copyright Copyright (c) 2015, WordImpress |
|
| 8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
| 9 | - * @since 1.0 |
|
| 10 | - */ |
|
| 3 | + * Give Form Widget |
|
| 4 | + * |
|
| 5 | + * @package WordImpress |
|
| 6 | + * @subpackage Admin/Forms |
|
| 7 | + * @copyright Copyright (c) 2015, WordImpress |
|
| 8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
| 9 | + * @since 1.0 |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | 13 | defined( 'ABSPATH' ) or exit; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -21,14 +21,14 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param $data |
| 23 | 23 | */ |
| 24 | -function give_process_gateway_select( $data ) { |
|
| 25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
| 26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
| 24 | +function give_process_gateway_select($data) { |
|
| 25 | + if (isset($_POST['gateway_submit'])) { |
|
| 26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
| 27 | 27 | exit; |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
| 31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Loads a payment gateway via AJAX |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | * @return void |
| 38 | 38 | */ |
| 39 | 39 | function give_load_ajax_gateway() { |
| 40 | - if ( isset( $_POST['give_payment_mode'] ) ) { |
|
| 41 | - do_action( 'give_purchase_form', $_POST['give_form_id'] ); |
|
| 40 | + if (isset($_POST['give_payment_mode'])) { |
|
| 41 | + do_action('give_purchase_form', $_POST['give_form_id']); |
|
| 42 | 42 | exit(); |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
| 47 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
| 46 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
| 47 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Sets an error on checkout if no gateways are enabled |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | function give_no_gateway_error() { |
| 56 | 56 | $gateways = give_get_enabled_payment_gateways(); |
| 57 | 57 | |
| 58 | - if ( empty( $gateways ) ) { |
|
| 59 | - give_set_error( 'no_gateways', __( 'You must enable a payment gateway to use Give', 'give' ) ); |
|
| 58 | + if (empty($gateways)) { |
|
| 59 | + give_set_error('no_gateways', __('You must enable a payment gateway to use Give', 'give')); |
|
| 60 | 60 | } else { |
| 61 | - give_unset_error( 'no_gateways' ); |
|
| 61 | + give_unset_error('no_gateways'); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | -add_action( 'init', 'give_no_gateway_error' ); |
|
| 66 | 65 | \ No newline at end of file |
| 66 | +add_action('init', 'give_no_gateway_error'); |
|
| 67 | 67 | \ No newline at end of file |
@@ -97,10 +97,10 @@ |
||
| 97 | 97 | |
| 98 | 98 | //Single Form settings varies compared to the Global default settings |
| 99 | 99 | if ( ! empty( $form_default ) && |
| 100 | - $form_id !== null && |
|
| 101 | - $default !== $form_default && |
|
| 102 | - $form_default !== 'global' && |
|
| 103 | - give_is_gateway_active( $form_default ) |
|
| 100 | + $form_id !== null && |
|
| 101 | + $default !== $form_default && |
|
| 102 | + $form_default !== 'global' && |
|
| 103 | + give_is_gateway_active( $form_default ) |
|
| 104 | 104 | ) { |
| 105 | 105 | $default = $form_default; |
| 106 | 106 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -24,17 +24,17 @@ discard block |
||
| 24 | 24 | // Default, built-in gateways |
| 25 | 25 | $gateways = array( |
| 26 | 26 | 'paypal' => array( |
| 27 | - 'admin_label' => __( 'PayPal Standard', 'give' ), |
|
| 28 | - 'checkout_label' => __( 'PayPal', 'give' ), |
|
| 29 | - 'supports' => array( 'buy_now' ) |
|
| 27 | + 'admin_label' => __('PayPal Standard', 'give'), |
|
| 28 | + 'checkout_label' => __('PayPal', 'give'), |
|
| 29 | + 'supports' => array('buy_now') |
|
| 30 | 30 | ), |
| 31 | 31 | 'manual' => array( |
| 32 | - 'admin_label' => __( 'Test Payment', 'give' ), |
|
| 33 | - 'checkout_label' => __( 'Test Payment', 'give' ) |
|
| 32 | + 'admin_label' => __('Test Payment', 'give'), |
|
| 33 | + 'checkout_label' => __('Test Payment', 'give') |
|
| 34 | 34 | ), |
| 35 | 35 | ); |
| 36 | 36 | |
| 37 | - return apply_filters( 'give_payment_gateways', $gateways ); |
|
| 37 | + return apply_filters('give_payment_gateways', $gateways); |
|
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
@@ -48,17 +48,17 @@ discard block |
||
| 48 | 48 | global $give_options; |
| 49 | 49 | |
| 50 | 50 | $gateways = give_get_payment_gateways(); |
| 51 | - $enabled = isset( $give_options['gateways'] ) ? $give_options['gateways'] : false; |
|
| 51 | + $enabled = isset($give_options['gateways']) ? $give_options['gateways'] : false; |
|
| 52 | 52 | |
| 53 | 53 | $gateway_list = array(); |
| 54 | 54 | |
| 55 | - foreach ( $gateways as $key => $gateway ) { |
|
| 56 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
| 57 | - $gateway_list[ $key ] = $gateway; |
|
| 55 | + foreach ($gateways as $key => $gateway) { |
|
| 56 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
| 57 | + $gateway_list[$key] = $gateway; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - return apply_filters( 'give_enabled_payment_gateways', $gateway_list ); |
|
| 61 | + return apply_filters('give_enabled_payment_gateways', $gateway_list); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @return boolean true if enabled, false otherwise |
| 72 | 72 | */ |
| 73 | -function give_is_gateway_active( $gateway ) { |
|
| 73 | +function give_is_gateway_active($gateway) { |
|
| 74 | 74 | $gateways = give_get_enabled_payment_gateways(); |
| 75 | 75 | |
| 76 | - $ret = array_key_exists( $gateway, $gateways ); |
|
| 76 | + $ret = array_key_exists($gateway, $gateways); |
|
| 77 | 77 | |
| 78 | - return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways ); |
|
| 78 | + return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -88,24 +88,24 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return string Gateway ID |
| 90 | 90 | */ |
| 91 | -function give_get_default_gateway( $form_id ) { |
|
| 91 | +function give_get_default_gateway($form_id) { |
|
| 92 | 92 | |
| 93 | 93 | global $give_options; |
| 94 | 94 | |
| 95 | - $default = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal'; |
|
| 96 | - $form_default = get_post_meta( $form_id, '_give_default_gateway', true ); |
|
| 95 | + $default = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal'; |
|
| 96 | + $form_default = get_post_meta($form_id, '_give_default_gateway', true); |
|
| 97 | 97 | |
| 98 | 98 | //Single Form settings varies compared to the Global default settings |
| 99 | - if ( ! empty( $form_default ) && |
|
| 99 | + if ( ! empty($form_default) && |
|
| 100 | 100 | $form_id !== null && |
| 101 | 101 | $default !== $form_default && |
| 102 | 102 | $form_default !== 'global' && |
| 103 | - give_is_gateway_active( $form_default ) |
|
| 103 | + give_is_gateway_active($form_default) |
|
| 104 | 104 | ) { |
| 105 | 105 | $default = $form_default; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - return apply_filters( 'give_default_gateway', $default ); |
|
| 108 | + return apply_filters('give_default_gateway', $default); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -117,18 +117,18 @@ discard block |
||
| 117 | 117 | * |
| 118 | 118 | * @return string Gateway admin label |
| 119 | 119 | */ |
| 120 | -function give_get_gateway_admin_label( $gateway ) { |
|
| 120 | +function give_get_gateway_admin_label($gateway) { |
|
| 121 | 121 | $gateways = give_get_enabled_payment_gateways(); |
| 122 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
| 123 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
| 122 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
| 123 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
| 124 | 124 | |
| 125 | - if ( $gateway == 'manual' && $payment ) { |
|
| 126 | - if ( give_get_payment_amount( $payment ) == 0 ) { |
|
| 127 | - $label = __( 'Test Donation', 'give' ); |
|
| 125 | + if ($gateway == 'manual' && $payment) { |
|
| 126 | + if (give_get_payment_amount($payment) == 0) { |
|
| 127 | + $label = __('Test Donation', 'give'); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - return apply_filters( 'give_gateway_admin_label', $label, $gateway ); |
|
| 131 | + return apply_filters('give_gateway_admin_label', $label, $gateway); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -140,15 +140,15 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @return string Checkout label for the gateway |
| 142 | 142 | */ |
| 143 | -function give_get_gateway_checkout_label( $gateway ) { |
|
| 143 | +function give_get_gateway_checkout_label($gateway) { |
|
| 144 | 144 | $gateways = give_get_enabled_payment_gateways(); |
| 145 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
| 145 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
| 146 | 146 | |
| 147 | - if ( $gateway == 'manual' ) { |
|
| 148 | - $label = __( 'Test Donation', 'give' ); |
|
| 147 | + if ($gateway == 'manual') { |
|
| 148 | + $label = __('Test Donation', 'give'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - return apply_filters( 'give_gateway_checkout_label', $label, $gateway ); |
|
| 151 | + return apply_filters('give_gateway_checkout_label', $label, $gateway); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | * |
| 161 | 161 | * @return array Options the gateway supports |
| 162 | 162 | */ |
| 163 | -function give_get_gateway_supports( $gateway ) { |
|
| 163 | +function give_get_gateway_supports($gateway) { |
|
| 164 | 164 | $gateways = give_get_enabled_payment_gateways(); |
| 165 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
| 165 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
| 166 | 166 | |
| 167 | - return apply_filters( 'give_gateway_supports', $supports, $gateway ); |
|
| 167 | + return apply_filters('give_gateway_supports', $supports, $gateway); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @return bool |
| 178 | 178 | */ |
| 179 | -function give_gateway_supports_buy_now( $gateway ) { |
|
| 180 | - $supports = give_get_gateway_supports( $gateway ); |
|
| 181 | - $ret = in_array( 'buy_now', $supports ); |
|
| 179 | +function give_gateway_supports_buy_now($gateway) { |
|
| 180 | + $supports = give_get_gateway_supports($gateway); |
|
| 181 | + $ret = in_array('buy_now', $supports); |
|
| 182 | 182 | |
| 183 | - return apply_filters( 'give_gateway_supports_buy_now', $ret, $gateway ); |
|
| 183 | + return apply_filters('give_gateway_supports_buy_now', $ret, $gateway); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -193,16 +193,16 @@ discard block |
||
| 193 | 193 | $gateways = give_get_enabled_payment_gateways(); |
| 194 | 194 | $ret = false; |
| 195 | 195 | |
| 196 | - if ( $gateways ) { |
|
| 197 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 198 | - if ( give_gateway_supports_buy_now( $gateway_id ) ) { |
|
| 196 | + if ($gateways) { |
|
| 197 | + foreach ($gateways as $gateway_id => $gateway) { |
|
| 198 | + if (give_gateway_supports_buy_now($gateway_id)) { |
|
| 199 | 199 | $ret = true; |
| 200 | 200 | break; |
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - return apply_filters( 'give_give_supports_buy_now', $ret ); |
|
| 205 | + return apply_filters('give_give_supports_buy_now', $ret); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -215,12 +215,12 @@ discard block |
||
| 215 | 215 | * |
| 216 | 216 | * @return void |
| 217 | 217 | */ |
| 218 | -function give_send_to_gateway( $gateway, $payment_data ) { |
|
| 218 | +function give_send_to_gateway($gateway, $payment_data) { |
|
| 219 | 219 | |
| 220 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' ); |
|
| 220 | + $payment_data['gateway_nonce'] = wp_create_nonce('give-gateway'); |
|
| 221 | 221 | |
| 222 | 222 | // $gateway must match the ID used when registering the gateway |
| 223 | - do_action( 'give_gateway_' . $gateway, $payment_data ); |
|
| 223 | + do_action('give_gateway_'.$gateway, $payment_data); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | |
@@ -237,32 +237,32 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @return string $enabled_gateway The slug of the gateway |
| 239 | 239 | */ |
| 240 | -function give_get_chosen_gateway( $form_id ) { |
|
| 240 | +function give_get_chosen_gateway($form_id) { |
|
| 241 | 241 | $gateways = give_get_enabled_payment_gateways(); |
| 242 | - $request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0; |
|
| 243 | - if ( empty( $request_form_id ) ) { |
|
| 244 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0; |
|
| 242 | + $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0; |
|
| 243 | + if (empty($request_form_id)) { |
|
| 244 | + $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0; |
|
| 245 | 245 | } |
| 246 | - $chosen = give_get_default_gateway( $form_id ); |
|
| 246 | + $chosen = give_get_default_gateway($form_id); |
|
| 247 | 247 | $enabled_gateway = ''; |
| 248 | 248 | |
| 249 | 249 | //Take into account request Form ID args |
| 250 | - if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) { |
|
| 250 | + if ( ! empty($request_form_id) && $form_id == $request_form_id) { |
|
| 251 | 251 | $chosen = $_REQUEST['payment-mode']; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if ( $chosen ) { |
|
| 255 | - $enabled_gateway = urldecode( $chosen ); |
|
| 256 | - } else if ( count( $gateways ) >= 1 && ! $chosen ) { |
|
| 257 | - foreach ( $gateways as $gateway_id => $gateway ): |
|
| 254 | + if ($chosen) { |
|
| 255 | + $enabled_gateway = urldecode($chosen); |
|
| 256 | + } else if (count($gateways) >= 1 && ! $chosen) { |
|
| 257 | + foreach ($gateways as $gateway_id => $gateway): |
|
| 258 | 258 | $enabled_gateway = $gateway_id; |
| 259 | 259 | endforeach; |
| 260 | 260 | } else { |
| 261 | - $enabled_gateway = give_get_default_gateway( $form_id ); |
|
| 261 | + $enabled_gateway = give_get_default_gateway($form_id); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | |
| 265 | - return apply_filters( 'give_chosen_gateway', $enabled_gateway ); |
|
| 265 | + return apply_filters('give_chosen_gateway', $enabled_gateway); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | * |
| 280 | 280 | * @return int ID of the new log entry |
| 281 | 281 | */ |
| 282 | -function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
| 283 | - return give_record_log( $title, $message, $parent, 'gateway_error' ); |
|
| 282 | +function give_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
| 283 | + return give_record_log($title, $message, $parent, 'gateway_error'); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @return int |
| 295 | 295 | */ |
| 296 | -function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
| 296 | +function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
| 297 | 297 | |
| 298 | 298 | $ret = 0; |
| 299 | 299 | $args = array( |
@@ -305,9 +305,9 @@ discard block |
||
| 305 | 305 | 'fields' => 'ids' |
| 306 | 306 | ); |
| 307 | 307 | |
| 308 | - $payments = new WP_Query( $args ); |
|
| 308 | + $payments = new WP_Query($args); |
|
| 309 | 309 | |
| 310 | - if ( $payments ) { |
|
| 310 | + if ($payments) { |
|
| 311 | 311 | $ret = $payments->post_count; |
| 312 | 312 | } |
| 313 | 313 | |
@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @since 1.0 |
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | -add_action( 'give_manual_cc_form', '__return_false' ); |
|
| 23 | +add_action('give_manual_cc_form', '__return_false'); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Processes the purchase data and uses the Manual Payment gateway to record |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | -function give_manual_payment( $purchase_data ) { |
|
| 36 | +function give_manual_payment($purchase_data) { |
|
| 37 | 37 | |
| 38 | 38 | global $give_options; |
| 39 | 39 | |
| 40 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
| 41 | - wp_die( __( 'Nonce verification has failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 40 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
| 41 | + wp_die(__('Nonce verification has failed', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /* |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $payment_data = array( |
| 48 | 48 | 'price' => $purchase_data['price'], |
| 49 | 49 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
| 50 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
| 50 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
| 51 | 51 | 'date' => $purchase_data['date'], |
| 52 | 52 | 'user_email' => $purchase_data['user_email'], |
| 53 | 53 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -56,16 +56,16 @@ discard block |
||
| 56 | 56 | 'status' => 'pending' |
| 57 | 57 | ); |
| 58 | 58 | // Record the pending payment |
| 59 | - $payment = give_insert_payment( $payment_data ); |
|
| 59 | + $payment = give_insert_payment($payment_data); |
|
| 60 | 60 | |
| 61 | - if ( $payment ) { |
|
| 62 | - give_update_payment_status( $payment, 'publish' ); |
|
| 61 | + if ($payment) { |
|
| 62 | + give_update_payment_status($payment, 'publish'); |
|
| 63 | 63 | give_send_to_success_page(); |
| 64 | 64 | } else { |
| 65 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( __( 'Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment ); |
|
| 65 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf(__('Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'give'), json_encode($payment_data)), $payment); |
|
| 66 | 66 | // If errors are present, send the user back to the purchase page so they can be corrected |
| 67 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
| 67 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | -add_action( 'give_gateway_manual', 'give_manual_payment' ); |
|
| 71 | +add_action('give_gateway_manual', 'give_manual_payment'); |
|
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return string Login form |
| 27 | 27 | */ |
| 28 | -function give_login_form( $redirect = '' ) { |
|
| 28 | +function give_login_form($redirect = '') { |
|
| 29 | 29 | global $give_options, $give_login_redirect; |
| 30 | 30 | |
| 31 | - if ( empty( $redirect ) ) { |
|
| 31 | + if (empty($redirect)) { |
|
| 32 | 32 | $redirect = give_get_current_page_url(); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | ob_start(); |
| 38 | 38 | |
| 39 | - give_get_template_part( 'shortcode', 'login' ); |
|
| 39 | + give_get_template_part('shortcode', 'login'); |
|
| 40 | 40 | |
| 41 | - return apply_filters( 'give_login_form', ob_get_clean() ); |
|
| 41 | + return apply_filters('give_login_form', ob_get_clean()); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return string Register form |
| 54 | 54 | */ |
| 55 | -function give_register_form( $redirect = '' ) { |
|
| 55 | +function give_register_form($redirect = '') { |
|
| 56 | 56 | global $give_options, $give_register_redirect; |
| 57 | 57 | |
| 58 | - if ( empty( $redirect ) ) { |
|
| 58 | + if (empty($redirect)) { |
|
| 59 | 59 | $redirect = give_get_current_page_url(); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | ob_start(); |
| 65 | 65 | |
| 66 | - if ( ! is_user_logged_in() ) { |
|
| 67 | - give_get_template_part( 'shortcode', 'register' ); |
|
| 66 | + if ( ! is_user_logged_in()) { |
|
| 67 | + give_get_template_part('shortcode', 'register'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - return apply_filters( 'give_register_form', ob_get_clean() ); |
|
| 70 | + return apply_filters('give_register_form', ob_get_clean()); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -79,34 +79,34 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return void |
| 81 | 81 | */ |
| 82 | -function give_process_login_form( $data ) { |
|
| 83 | - if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) { |
|
| 84 | - $user_data = get_user_by( 'login', $data['give_user_login'] ); |
|
| 85 | - if ( ! $user_data ) { |
|
| 86 | - $user_data = get_user_by( 'email', $data['give_user_login'] ); |
|
| 82 | +function give_process_login_form($data) { |
|
| 83 | + if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) { |
|
| 84 | + $user_data = get_user_by('login', $data['give_user_login']); |
|
| 85 | + if ( ! $user_data) { |
|
| 86 | + $user_data = get_user_by('email', $data['give_user_login']); |
|
| 87 | 87 | } |
| 88 | - if ( $user_data ) { |
|
| 88 | + if ($user_data) { |
|
| 89 | 89 | $user_ID = $user_data->ID; |
| 90 | 90 | $user_email = $user_data->user_email; |
| 91 | - if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_data->ID ) ) { |
|
| 92 | - give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] ); |
|
| 91 | + if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_data->ID)) { |
|
| 92 | + give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']); |
|
| 93 | 93 | } else { |
| 94 | - give_set_error( 'password_incorrect', __( 'The password you entered is incorrect', 'give' ) ); |
|
| 94 | + give_set_error('password_incorrect', __('The password you entered is incorrect', 'give')); |
|
| 95 | 95 | } |
| 96 | 96 | } else { |
| 97 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist', 'give' ) ); |
|
| 97 | + give_set_error('username_incorrect', __('The username you entered does not exist', 'give')); |
|
| 98 | 98 | } |
| 99 | 99 | // Check for errors and redirect if none present |
| 100 | 100 | $errors = give_get_errors(); |
| 101 | - if ( ! $errors ) { |
|
| 102 | - $redirect = apply_filters( 'give_login_redirect', $data['give_redirect'], $user_ID ); |
|
| 103 | - wp_redirect( $redirect ); |
|
| 101 | + if ( ! $errors) { |
|
| 102 | + $redirect = apply_filters('give_login_redirect', $data['give_redirect'], $user_ID); |
|
| 103 | + wp_redirect($redirect); |
|
| 104 | 104 | give_die(); |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | -add_action( 'give_user_login', 'give_process_login_form' ); |
|
| 109 | +add_action('give_user_login', 'give_process_login_form'); |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * Log User In |
@@ -119,15 +119,15 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @return void |
| 121 | 121 | */ |
| 122 | -function give_log_user_in( $user_id, $user_login, $user_pass ) { |
|
| 123 | - if ( $user_id < 1 ) { |
|
| 122 | +function give_log_user_in($user_id, $user_login, $user_pass) { |
|
| 123 | + if ($user_id < 1) { |
|
| 124 | 124 | return; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - wp_set_auth_cookie( $user_id ); |
|
| 128 | - wp_set_current_user( $user_id, $user_login ); |
|
| 129 | - do_action( 'wp_login', $user_login, get_userdata( $user_id ) ); |
|
| 130 | - do_action( 'give_log_user_in', $user_id, $user_login, $user_pass ); |
|
| 127 | + wp_set_auth_cookie($user_id); |
|
| 128 | + wp_set_current_user($user_id, $user_login); |
|
| 129 | + do_action('wp_login', $user_login, get_userdata($user_id)); |
|
| 130 | + do_action('give_log_user_in', $user_id, $user_login, $user_pass); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -140,70 +140,70 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @return void |
| 142 | 142 | */ |
| 143 | -function give_process_register_form( $data ) { |
|
| 143 | +function give_process_register_form($data) { |
|
| 144 | 144 | |
| 145 | - if ( is_user_logged_in() ) { |
|
| 145 | + if (is_user_logged_in()) { |
|
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( empty( $_POST['give_register_submit'] ) ) { |
|
| 149 | + if (empty($_POST['give_register_submit'])) { |
|
| 150 | 150 | return; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - do_action( 'give_pre_process_register_form' ); |
|
| 153 | + do_action('give_pre_process_register_form'); |
|
| 154 | 154 | |
| 155 | - if ( empty( $data['give_user_login'] ) ) { |
|
| 156 | - give_set_error( 'empty_username', __( 'Invalid username', 'give' ) ); |
|
| 155 | + if (empty($data['give_user_login'])) { |
|
| 156 | + give_set_error('empty_username', __('Invalid username', 'give')); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( username_exists( $data['give_user_login'] ) ) { |
|
| 160 | - give_set_error( 'username_unavailable', __( 'Username already taken', 'give' ) ); |
|
| 159 | + if (username_exists($data['give_user_login'])) { |
|
| 160 | + give_set_error('username_unavailable', __('Username already taken', 'give')); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if ( ! validate_username( $data['give_user_login'] ) ) { |
|
| 164 | - give_set_error( 'username_invalid', __( 'Invalid username', 'give' ) ); |
|
| 163 | + if ( ! validate_username($data['give_user_login'])) { |
|
| 164 | + give_set_error('username_invalid', __('Invalid username', 'give')); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ( email_exists( $data['give_user_email'] ) ) { |
|
| 168 | - give_set_error( 'email_unavailable', __( 'Email address already taken', 'give' ) ); |
|
| 167 | + if (email_exists($data['give_user_email'])) { |
|
| 168 | + give_set_error('email_unavailable', __('Email address already taken', 'give')); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) { |
|
| 172 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
| 171 | + if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) { |
|
| 172 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) { |
|
| 176 | - give_set_error( 'payment_email_invalid', __( 'Invalid payment email', 'give' ) ); |
|
| 175 | + if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) { |
|
| 176 | + give_set_error('payment_email_invalid', __('Invalid payment email', 'give')); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( empty( $_POST['give_user_pass'] ) ) { |
|
| 180 | - give_set_error( 'empty_password', __( 'Please enter a password', 'give' ) ); |
|
| 179 | + if (empty($_POST['give_user_pass'])) { |
|
| 180 | + give_set_error('empty_password', __('Please enter a password', 'give')); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) { |
|
| 184 | - give_set_error( 'password_mismatch', __( 'Passwords do not match', 'give' ) ); |
|
| 183 | + if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) { |
|
| 184 | + give_set_error('password_mismatch', __('Passwords do not match', 'give')); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - do_action( 'give_process_register_form' ); |
|
| 187 | + do_action('give_process_register_form'); |
|
| 188 | 188 | |
| 189 | 189 | // Check for errors and redirect if none present |
| 190 | 190 | $errors = give_get_errors(); |
| 191 | 191 | |
| 192 | - if ( empty( $errors ) ) { |
|
| 192 | + if (empty($errors)) { |
|
| 193 | 193 | |
| 194 | - $redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] ); |
|
| 194 | + $redirect = apply_filters('give_register_redirect', $data['give_redirect']); |
|
| 195 | 195 | |
| 196 | - give_register_and_login_new_user( array( |
|
| 196 | + give_register_and_login_new_user(array( |
|
| 197 | 197 | 'user_login' => $data['give_user_login'], |
| 198 | 198 | 'user_pass' => $data['give_user_pass'], |
| 199 | 199 | 'user_email' => $data['give_user_email'], |
| 200 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 201 | - 'role' => get_option( 'default_role' ) |
|
| 202 | - ) ); |
|
| 200 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 201 | + 'role' => get_option('default_role') |
|
| 202 | + )); |
|
| 203 | 203 | |
| 204 | - wp_redirect( $redirect ); |
|
| 204 | + wp_redirect($redirect); |
|
| 205 | 205 | give_die(); |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | -add_action( 'give_user_register', 'give_process_register_form' ); |
|
| 210 | 209 | \ No newline at end of file |
| 210 | +add_action('give_user_register', 'give_process_register_form'); |
|
| 211 | 211 | \ No newline at end of file |
@@ -142,8 +142,10 @@ |
||
| 142 | 142 | |
| 143 | 143 | if ( is_front_page() ) : |
| 144 | 144 | $page_url = home_url(); |
| 145 | - else : |
|
| 145 | + else { |
|
| 146 | + : |
|
| 146 | 147 | $page_url = 'http'; |
| 148 | + } |
|
| 147 | 149 | |
| 148 | 150 | if ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) { |
| 149 | 151 | $page_url .= "s"; |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * Returns the webhost this site is using if possible |
| 336 | 336 | * |
| 337 | 337 | * @since 1.0 |
| 338 | - * @return mixed string $host if detected, false otherwise |
|
| 338 | + * @return string string $host if detected, false otherwise |
|
| 339 | 339 | */ |
| 340 | 340 | function give_get_host() { |
| 341 | 341 | $host = false; |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * |
| 507 | 507 | * @since 1.0 |
| 508 | 508 | * |
| 509 | - * @param unknown $n |
|
| 509 | + * @param integer $n |
|
| 510 | 510 | * |
| 511 | 511 | * @return string Short month name |
| 512 | 512 | */ |
@@ -636,9 +636,9 @@ discard block |
||
| 636 | 636 | /** |
| 637 | 637 | * Create SVG library function |
| 638 | 638 | * |
| 639 | - * @param $icon |
|
| 639 | + * @param string $icon |
|
| 640 | 640 | * |
| 641 | - * @return mixed |
|
| 641 | + * @return string |
|
| 642 | 642 | */ |
| 643 | 643 | function give_svg_icons( $icon ) { |
| 644 | 644 | |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | * |
| 696 | 696 | * @param array $input A multi-dimensional array (record set) from which to pull |
| 697 | 697 | * a column of values. |
| 698 | - * @param mixed $columnKey The column of values to return. This value may be the |
|
| 698 | + * @param string $columnKey The column of values to return. This value may be the |
|
| 699 | 699 | * integer key of the column you wish to retrieve, or it |
| 700 | 700 | * may be the string key name for an associative array. |
| 701 | 701 | * @param mixed $indexKey (Optional.) The column to use as the index/keys for |
@@ -727,10 +727,10 @@ discard block |
||
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | if ( ! is_int( $params[1] ) |
| 730 | - && ! is_float( $params[1] ) |
|
| 731 | - && ! is_string( $params[1] ) |
|
| 732 | - && $params[1] !== null |
|
| 733 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
| 730 | + && ! is_float( $params[1] ) |
|
| 731 | + && ! is_string( $params[1] ) |
|
| 732 | + && $params[1] !== null |
|
| 733 | + && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
| 734 | 734 | ) { |
| 735 | 735 | trigger_error( 'array_column(): The column key should be either a string or an integer', E_USER_WARNING ); |
| 736 | 736 | |
@@ -738,10 +738,10 @@ discard block |
||
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | if ( isset( $params[2] ) |
| 741 | - && ! is_int( $params[2] ) |
|
| 742 | - && ! is_float( $params[2] ) |
|
| 743 | - && ! is_string( $params[2] ) |
|
| 744 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
| 741 | + && ! is_int( $params[2] ) |
|
| 742 | + && ! is_float( $params[2] ) |
|
| 743 | + && ! is_string( $params[2] ) |
|
| 744 | + && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
| 745 | 745 | ) { |
| 746 | 746 | trigger_error( 'array_column(): The index key should be either a string or an integer', E_USER_WARNING ); |
| 747 | 747 | |
@@ -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 | function give_is_test_mode() { |
| 25 | 25 | global $give_options; |
| 26 | 26 | |
| 27 | - $ret = ! empty( $give_options['test_mode'] ); |
|
| 27 | + $ret = ! empty($give_options['test_mode']); |
|
| 28 | 28 | |
| 29 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
| 29 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function give_get_currency() { |
| 39 | 39 | global $give_options; |
| 40 | - $currency = isset( $give_options['currency'] ) ? $give_options['currency'] : 'USD'; |
|
| 40 | + $currency = isset($give_options['currency']) ? $give_options['currency'] : 'USD'; |
|
| 41 | 41 | |
| 42 | - return apply_filters( 'give_currency', $currency ); |
|
| 42 | + return apply_filters('give_currency', $currency); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -51,36 +51,36 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | function give_get_currencies() { |
| 53 | 53 | $currencies = array( |
| 54 | - 'USD' => __( 'US Dollars ($)', 'give' ), |
|
| 55 | - 'EUR' => __( 'Euros (€)', 'give' ), |
|
| 56 | - 'GBP' => __( 'Pounds Sterling (£)', 'give' ), |
|
| 57 | - 'AUD' => __( 'Australian Dollars ($)', 'give' ), |
|
| 58 | - 'BRL' => __( 'Brazilian Real (R$)', 'give' ), |
|
| 59 | - 'CAD' => __( 'Canadian Dollars ($)', 'give' ), |
|
| 60 | - 'CZK' => __( 'Czech Koruna', 'give' ), |
|
| 61 | - 'DKK' => __( 'Danish Krone', 'give' ), |
|
| 62 | - 'HKD' => __( 'Hong Kong Dollar ($)', 'give' ), |
|
| 63 | - 'HUF' => __( 'Hungarian Forint', 'give' ), |
|
| 64 | - 'ILS' => __( 'Israeli Shekel (₪)', 'give' ), |
|
| 65 | - 'JPY' => __( 'Japanese Yen (¥)', 'give' ), |
|
| 66 | - 'MYR' => __( 'Malaysian Ringgits', 'give' ), |
|
| 67 | - 'MXN' => __( 'Mexican Peso ($)', 'give' ), |
|
| 68 | - 'NZD' => __( 'New Zealand Dollar ($)', 'give' ), |
|
| 69 | - 'NOK' => __( 'Norwegian Krone (Kr.)', 'give' ), |
|
| 70 | - 'PHP' => __( 'Philippine Pesos', 'give' ), |
|
| 71 | - 'PLN' => __( 'Polish Zloty', 'give' ), |
|
| 72 | - 'SGD' => __( 'Singapore Dollar ($)', 'give' ), |
|
| 73 | - 'SEK' => __( 'Swedish Krona', 'give' ), |
|
| 74 | - 'CHF' => __( 'Swiss Franc', 'give' ), |
|
| 75 | - 'TWD' => __( 'Taiwan New Dollars', 'give' ), |
|
| 76 | - 'THB' => __( 'Thai Baht (฿)', 'give' ), |
|
| 77 | - 'INR' => __( 'Indian Rupee (₹)', 'give' ), |
|
| 78 | - 'TRY' => __( 'Turkish Lira (₺)', 'give' ), |
|
| 79 | - 'RIAL' => __( 'Iranian Rial (﷼)', 'give' ), |
|
| 80 | - 'RUB' => __( 'Russian Rubles', 'give' ) |
|
| 54 | + 'USD' => __('US Dollars ($)', 'give'), |
|
| 55 | + 'EUR' => __('Euros (€)', 'give'), |
|
| 56 | + 'GBP' => __('Pounds Sterling (£)', 'give'), |
|
| 57 | + 'AUD' => __('Australian Dollars ($)', 'give'), |
|
| 58 | + 'BRL' => __('Brazilian Real (R$)', 'give'), |
|
| 59 | + 'CAD' => __('Canadian Dollars ($)', 'give'), |
|
| 60 | + 'CZK' => __('Czech Koruna', 'give'), |
|
| 61 | + 'DKK' => __('Danish Krone', 'give'), |
|
| 62 | + 'HKD' => __('Hong Kong Dollar ($)', 'give'), |
|
| 63 | + 'HUF' => __('Hungarian Forint', 'give'), |
|
| 64 | + 'ILS' => __('Israeli Shekel (₪)', 'give'), |
|
| 65 | + 'JPY' => __('Japanese Yen (¥)', 'give'), |
|
| 66 | + 'MYR' => __('Malaysian Ringgits', 'give'), |
|
| 67 | + 'MXN' => __('Mexican Peso ($)', 'give'), |
|
| 68 | + 'NZD' => __('New Zealand Dollar ($)', 'give'), |
|
| 69 | + 'NOK' => __('Norwegian Krone (Kr.)', 'give'), |
|
| 70 | + 'PHP' => __('Philippine Pesos', 'give'), |
|
| 71 | + 'PLN' => __('Polish Zloty', 'give'), |
|
| 72 | + 'SGD' => __('Singapore Dollar ($)', 'give'), |
|
| 73 | + 'SEK' => __('Swedish Krona', 'give'), |
|
| 74 | + 'CHF' => __('Swiss Franc', 'give'), |
|
| 75 | + 'TWD' => __('Taiwan New Dollars', 'give'), |
|
| 76 | + 'THB' => __('Thai Baht (฿)', 'give'), |
|
| 77 | + 'INR' => __('Indian Rupee (₹)', 'give'), |
|
| 78 | + 'TRY' => __('Turkish Lira (₺)', 'give'), |
|
| 79 | + 'RIAL' => __('Iranian Rial (﷼)', 'give'), |
|
| 80 | + 'RUB' => __('Russian Rubles', 'give') |
|
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | - return apply_filters( 'give_currencies', $currencies ); |
|
| 83 | + return apply_filters('give_currencies', $currencies); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @return string The symbol to use for the currency |
| 96 | 96 | */ |
| 97 | -function give_currency_symbol( $currency = '' ) { |
|
| 97 | +function give_currency_symbol($currency = '') { |
|
| 98 | 98 | |
| 99 | - if ( empty( $currency ) ) { |
|
| 99 | + if (empty($currency)) { |
|
| 100 | 100 | $currency = give_get_currency(); |
| 101 | 101 | } |
| 102 | - switch ( $currency ) : |
|
| 102 | + switch ($currency) : |
|
| 103 | 103 | case "GBP" : |
| 104 | 104 | $symbol = '£'; |
| 105 | 105 | break; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | break; |
| 129 | 129 | endswitch; |
| 130 | 130 | |
| 131 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
| 131 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | |
@@ -140,25 +140,25 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | function give_get_current_page_url() { |
| 142 | 142 | |
| 143 | - if ( is_front_page() ) : |
|
| 143 | + if (is_front_page()) : |
|
| 144 | 144 | $page_url = home_url(); |
| 145 | 145 | else : |
| 146 | 146 | $page_url = 'http'; |
| 147 | 147 | |
| 148 | - if ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) { |
|
| 148 | + if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { |
|
| 149 | 149 | $page_url .= "s"; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | $page_url .= "://"; |
| 153 | 153 | |
| 154 | - if ( isset( $_SERVER["SERVER_PORT"] ) && $_SERVER["SERVER_PORT"] != "80" ) { |
|
| 155 | - $page_url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; |
|
| 154 | + if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] != "80") { |
|
| 155 | + $page_url .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; |
|
| 156 | 156 | } else { |
| 157 | - $page_url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; |
|
| 157 | + $page_url .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; |
|
| 158 | 158 | } |
| 159 | 159 | endif; |
| 160 | 160 | |
| 161 | - return apply_filters( 'give_get_current_page_url', esc_url( $page_url ) ); |
|
| 161 | + return apply_filters('give_get_current_page_url', esc_url($page_url)); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | |
@@ -179,15 +179,15 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | $gateways = give_get_enabled_payment_gateways(); |
| 181 | 181 | |
| 182 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
| 182 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
| 183 | 183 | $ret = true; |
| 184 | - } else if ( count( $gateways ) == 1 ) { |
|
| 184 | + } else if (count($gateways) == 1) { |
|
| 185 | 185 | $ret = false; |
| 186 | - } else if ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
| 186 | + } else if (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
| 187 | 187 | $ret = false; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - return (bool) apply_filters( 'give_verify_credit_cards', $ret ); |
|
| 190 | + return (bool) apply_filters('give_verify_credit_cards', $ret); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
@@ -202,9 +202,9 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | global $give_options; |
| 204 | 204 | |
| 205 | - $ret = ! empty( $give_options['logged_in_only'] ); |
|
| 205 | + $ret = ! empty($give_options['logged_in_only']); |
|
| 206 | 206 | |
| 207 | - return (bool) apply_filters( 'give_logged_in_only', $ret ); |
|
| 207 | + return (bool) apply_filters('give_logged_in_only', $ret); |
|
| 208 | 208 | |
| 209 | 209 | } |
| 210 | 210 | |
@@ -218,26 +218,26 @@ discard block |
||
| 218 | 218 | function give_get_timezone_id() { |
| 219 | 219 | |
| 220 | 220 | // if site timezone string exists, return it |
| 221 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
| 221 | + if ($timezone = get_option('timezone_string')) { |
|
| 222 | 222 | return $timezone; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // get UTC offset, if it isn't set return UTC |
| 226 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
| 226 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
| 227 | 227 | return 'UTC'; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | // attempt to guess the timezone string from the UTC offset |
| 231 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
| 231 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
| 232 | 232 | |
| 233 | 233 | // last try, guess timezone string manually |
| 234 | - if ( $timezone === false ) { |
|
| 234 | + if ($timezone === false) { |
|
| 235 | 235 | |
| 236 | - $is_dst = date( 'I' ); |
|
| 236 | + $is_dst = date('I'); |
|
| 237 | 237 | |
| 238 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
| 239 | - foreach ( $abbr as $city ) { |
|
| 240 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
| 238 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
| 239 | + foreach ($abbr as $city) { |
|
| 240 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
| 241 | 241 | return $city['timezone_id']; |
| 242 | 242 | } |
| 243 | 243 | } |
@@ -261,17 +261,17 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | $ip = '127.0.0.1'; |
| 263 | 263 | |
| 264 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
| 264 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 265 | 265 | //check ip from share internet |
| 266 | 266 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
| 267 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
| 267 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 268 | 268 | //to check ip is pass from proxy |
| 269 | 269 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
| 270 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 270 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
| 271 | 271 | $ip = $_SERVER['REMOTE_ADDR']; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - return apply_filters( 'give_get_ip', $ip ); |
|
| 274 | + return apply_filters('give_get_ip', $ip); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * @uses Give()->session->set() |
| 288 | 288 | */ |
| 289 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
| 290 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
| 289 | +function give_set_purchase_session($purchase_data = array()) { |
|
| 290 | + Give()->session->set('give_purchase', $purchase_data); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @return mixed array | false |
| 302 | 302 | */ |
| 303 | 303 | function give_get_purchase_session() { |
| 304 | - return Give()->session->get( 'give_purchase' ); |
|
| 304 | + return Give()->session->get('give_purchase'); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -316,14 +316,14 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * @return string |
| 318 | 318 | */ |
| 319 | -function give_get_purchase_summary( $purchase_data, $email = true ) { |
|
| 319 | +function give_get_purchase_summary($purchase_data, $email = true) { |
|
| 320 | 320 | $summary = ''; |
| 321 | 321 | |
| 322 | - if ( $email ) { |
|
| 323 | - $summary .= $purchase_data['user_email'] . ' - '; |
|
| 322 | + if ($email) { |
|
| 323 | + $summary .= $purchase_data['user_email'].' - '; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - $summary .= get_the_title( $purchase_data['post_data']['give-form-id'] ); |
|
| 326 | + $summary .= get_the_title($purchase_data['post_data']['give-form-id']); |
|
| 327 | 327 | |
| 328 | 328 | return $summary; |
| 329 | 329 | } |
@@ -340,31 +340,31 @@ discard block |
||
| 340 | 340 | function give_get_host() { |
| 341 | 341 | $host = false; |
| 342 | 342 | |
| 343 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 343 | + if (defined('WPE_APIKEY')) { |
|
| 344 | 344 | $host = 'WP Engine'; |
| 345 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
| 345 | + } elseif (defined('PAGELYBIN')) { |
|
| 346 | 346 | $host = 'Pagely'; |
| 347 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 347 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 348 | 348 | $host = 'ICDSoft'; |
| 349 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
| 349 | + } elseif (DB_HOST == 'mysqlv5') { |
|
| 350 | 350 | $host = 'NetworkSolutions'; |
| 351 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 351 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 352 | 352 | $host = 'iPage'; |
| 353 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 353 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 354 | 354 | $host = 'IPower'; |
| 355 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 355 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 356 | 356 | $host = 'MediaTemple Grid'; |
| 357 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 357 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 358 | 358 | $host = 'pair Networks'; |
| 359 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 359 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 360 | 360 | $host = 'Rackspace Cloud'; |
| 361 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 361 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 362 | 362 | $host = 'SysFix.eu Power Hosting'; |
| 363 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 363 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 364 | 364 | $host = 'Flywheel'; |
| 365 | 365 | } else { |
| 366 | 366 | // Adding a general fallback for data gathering |
| 367 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
| 367 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | return $host; |
@@ -380,67 +380,67 @@ discard block |
||
| 380 | 380 | * |
| 381 | 381 | * @return bool true if host matches, false if not |
| 382 | 382 | */ |
| 383 | -function give_is_host( $host = false ) { |
|
| 383 | +function give_is_host($host = false) { |
|
| 384 | 384 | |
| 385 | 385 | $return = false; |
| 386 | 386 | |
| 387 | - if ( $host ) { |
|
| 388 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
| 387 | + if ($host) { |
|
| 388 | + $host = str_replace(' ', '', strtolower($host)); |
|
| 389 | 389 | |
| 390 | - switch ( $host ) { |
|
| 390 | + switch ($host) { |
|
| 391 | 391 | case 'wpengine': |
| 392 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 392 | + if (defined('WPE_APIKEY')) { |
|
| 393 | 393 | $return = true; |
| 394 | 394 | } |
| 395 | 395 | break; |
| 396 | 396 | case 'pagely': |
| 397 | - if ( defined( 'PAGELYBIN' ) ) { |
|
| 397 | + if (defined('PAGELYBIN')) { |
|
| 398 | 398 | $return = true; |
| 399 | 399 | } |
| 400 | 400 | break; |
| 401 | 401 | case 'icdsoft': |
| 402 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 402 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 403 | 403 | $return = true; |
| 404 | 404 | } |
| 405 | 405 | break; |
| 406 | 406 | case 'networksolutions': |
| 407 | - if ( DB_HOST == 'mysqlv5' ) { |
|
| 407 | + if (DB_HOST == 'mysqlv5') { |
|
| 408 | 408 | $return = true; |
| 409 | 409 | } |
| 410 | 410 | break; |
| 411 | 411 | case 'ipage': |
| 412 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 412 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 413 | 413 | $return = true; |
| 414 | 414 | } |
| 415 | 415 | break; |
| 416 | 416 | case 'ipower': |
| 417 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 417 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 418 | 418 | $return = true; |
| 419 | 419 | } |
| 420 | 420 | break; |
| 421 | 421 | case 'mediatemplegrid': |
| 422 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 422 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 423 | 423 | $return = true; |
| 424 | 424 | } |
| 425 | 425 | break; |
| 426 | 426 | case 'pairnetworks': |
| 427 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 427 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 428 | 428 | $return = true; |
| 429 | 429 | } |
| 430 | 430 | break; |
| 431 | 431 | case 'rackspacecloud': |
| 432 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 432 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 433 | 433 | $return = true; |
| 434 | 434 | } |
| 435 | 435 | break; |
| 436 | 436 | case 'sysfix.eu': |
| 437 | 437 | case 'sysfix.eupowerhosting': |
| 438 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 438 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 439 | 439 | $return = true; |
| 440 | 440 | } |
| 441 | 441 | break; |
| 442 | 442 | case 'flywheel': |
| 443 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 443 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 444 | 444 | $return = true; |
| 445 | 445 | } |
| 446 | 446 | break; |
@@ -461,8 +461,8 @@ discard block |
||
| 461 | 461 | * @return string $post_id |
| 462 | 462 | */ |
| 463 | 463 | function give_get_admin_post_id() { |
| 464 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
| 465 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
| 464 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
| 465 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
| 466 | 466 | $post_id = $_POST['post_id']; |
| 467 | 467 | } |
| 468 | 468 | |
@@ -480,11 +480,11 @@ discard block |
||
| 480 | 480 | * |
| 481 | 481 | * @return bool $ret True if guest checkout is enabled, false otherwise |
| 482 | 482 | */ |
| 483 | -function give_no_guest_checkout( $form_id ) { |
|
| 483 | +function give_no_guest_checkout($form_id) { |
|
| 484 | 484 | |
| 485 | - $ret = get_post_meta( $form_id, '_give_logged_in_only', true ); |
|
| 485 | + $ret = get_post_meta($form_id, '_give_logged_in_only', true); |
|
| 486 | 486 | |
| 487 | - return (bool) apply_filters( 'give_no_guest_checkout', $ret ); |
|
| 487 | + return (bool) apply_filters('give_no_guest_checkout', $ret); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | * @return string Arg separator output |
| 496 | 496 | */ |
| 497 | 497 | function give_get_php_arg_separator_output() { |
| 498 | - return ini_get( 'arg_separator.output' ); |
|
| 498 | + return ini_get('arg_separator.output'); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | |
@@ -510,10 +510,10 @@ discard block |
||
| 510 | 510 | * |
| 511 | 511 | * @return string Short month name |
| 512 | 512 | */ |
| 513 | -function give_month_num_to_name( $n ) { |
|
| 514 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
| 513 | +function give_month_num_to_name($n) { |
|
| 514 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
| 515 | 515 | |
| 516 | - return date_i18n( "M", $timestamp ); |
|
| 516 | + return date_i18n("M", $timestamp); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | |
@@ -526,10 +526,10 @@ discard block |
||
| 526 | 526 | * |
| 527 | 527 | * @return bool Whether or not function is disabled. |
| 528 | 528 | */ |
| 529 | -function give_is_func_disabled( $function ) { |
|
| 530 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
| 529 | +function give_is_func_disabled($function) { |
|
| 530 | + $disabled = explode(',', ini_get('disable_functions')); |
|
| 531 | 531 | |
| 532 | - return in_array( $function, $disabled ); |
|
| 532 | + return in_array($function, $disabled); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | |
| 545 | 545 | <form action="//givewp.us3.list-manage.com/subscribe/post?u=3ccb75d68bda4381e2f45794c&id=12a081aa13" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate> |
| 546 | 546 | <div class="give-newsletter-confirmation"> |
| 547 | - <p><?php _e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
| 547 | + <p><?php _e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
| 548 | 548 | </div> |
| 549 | 549 | |
| 550 | 550 | <table class="form-table give-newsletter-form"> |
@@ -640,7 +640,7 @@ discard block |
||
| 640 | 640 | * |
| 641 | 641 | * @return mixed |
| 642 | 642 | */ |
| 643 | -function give_svg_icons( $icon ) { |
|
| 643 | +function give_svg_icons($icon) { |
|
| 644 | 644 | |
| 645 | 645 | // Store your SVGs in an associative array |
| 646 | 646 | $svgs = array( |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | ); |
| 653 | 653 | |
| 654 | 654 | // Return the chosen icon's SVG string |
| 655 | - return $svgs[ $icon ]; |
|
| 655 | + return $svgs[$icon]; |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | /** |
@@ -664,15 +664,15 @@ discard block |
||
| 664 | 664 | * |
| 665 | 665 | * @return mixed |
| 666 | 666 | */ |
| 667 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
| 668 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
| 667 | +function modify_nav_menu_meta_box_object($post_type) { |
|
| 668 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
| 669 | 669 | $post_type->labels->name = 'Donation Forms'; |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | return $post_type; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
| 675 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
| 676 | 676 | |
| 677 | 677 | |
| 678 | 678 | /** |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | * @license http://opensource.org/licenses/MIT MIT |
| 686 | 686 | */ |
| 687 | 687 | |
| 688 | -if ( ! function_exists( 'array_column' ) ) { |
|
| 688 | +if ( ! function_exists('array_column')) { |
|
| 689 | 689 | /** |
| 690 | 690 | * Returns the values from a single column of the input array, identified by |
| 691 | 691 | * the $columnKey. |
@@ -704,56 +704,56 @@ discard block |
||
| 704 | 704 | * |
| 705 | 705 | * @return array |
| 706 | 706 | */ |
| 707 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
| 707 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
| 708 | 708 | // Using func_get_args() in order to check for proper number of |
| 709 | 709 | // parameters and trigger errors exactly as the built-in array_column() |
| 710 | 710 | // does in PHP 5.5. |
| 711 | 711 | $argc = func_num_args(); |
| 712 | 712 | $params = func_get_args(); |
| 713 | 713 | |
| 714 | - if ( $argc < 2 ) { |
|
| 715 | - trigger_error( "array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING ); |
|
| 714 | + if ($argc < 2) { |
|
| 715 | + trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); |
|
| 716 | 716 | |
| 717 | 717 | return null; |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - if ( ! is_array( $params[0] ) ) { |
|
| 720 | + if ( ! is_array($params[0])) { |
|
| 721 | 721 | trigger_error( |
| 722 | - 'array_column() expects parameter 1 to be array, ' . gettype( $params[0] ) . ' given', |
|
| 722 | + 'array_column() expects parameter 1 to be array, '.gettype($params[0]).' given', |
|
| 723 | 723 | E_USER_WARNING |
| 724 | 724 | ); |
| 725 | 725 | |
| 726 | 726 | return null; |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | - if ( ! is_int( $params[1] ) |
|
| 730 | - && ! is_float( $params[1] ) |
|
| 731 | - && ! is_string( $params[1] ) |
|
| 729 | + if ( ! is_int($params[1]) |
|
| 730 | + && ! is_float($params[1]) |
|
| 731 | + && ! is_string($params[1]) |
|
| 732 | 732 | && $params[1] !== null |
| 733 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
| 733 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
| 734 | 734 | ) { |
| 735 | - trigger_error( 'array_column(): The column key should be either a string or an integer', E_USER_WARNING ); |
|
| 735 | + trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); |
|
| 736 | 736 | |
| 737 | 737 | return false; |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | - if ( isset( $params[2] ) |
|
| 741 | - && ! is_int( $params[2] ) |
|
| 742 | - && ! is_float( $params[2] ) |
|
| 743 | - && ! is_string( $params[2] ) |
|
| 744 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
| 740 | + if (isset($params[2]) |
|
| 741 | + && ! is_int($params[2]) |
|
| 742 | + && ! is_float($params[2]) |
|
| 743 | + && ! is_string($params[2]) |
|
| 744 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
| 745 | 745 | ) { |
| 746 | - trigger_error( 'array_column(): The index key should be either a string or an integer', E_USER_WARNING ); |
|
| 746 | + trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); |
|
| 747 | 747 | |
| 748 | 748 | return false; |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | $paramsInput = $params[0]; |
| 752 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
| 752 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
| 753 | 753 | |
| 754 | 754 | $paramsIndexKey = null; |
| 755 | - if ( isset( $params[2] ) ) { |
|
| 756 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
| 755 | + if (isset($params[2])) { |
|
| 756 | + if (is_float($params[2]) || is_int($params[2])) { |
|
| 757 | 757 | $paramsIndexKey = (int) $params[2]; |
| 758 | 758 | } else { |
| 759 | 759 | $paramsIndexKey = (string) $params[2]; |
@@ -762,26 +762,26 @@ discard block |
||
| 762 | 762 | |
| 763 | 763 | $resultArray = array(); |
| 764 | 764 | |
| 765 | - foreach ( $paramsInput as $row ) { |
|
| 765 | + foreach ($paramsInput as $row) { |
|
| 766 | 766 | $key = $value = null; |
| 767 | 767 | $keySet = $valueSet = false; |
| 768 | 768 | |
| 769 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
| 769 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
| 770 | 770 | $keySet = true; |
| 771 | - $key = (string) $row[ $paramsIndexKey ]; |
|
| 771 | + $key = (string) $row[$paramsIndexKey]; |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - if ( $paramsColumnKey === null ) { |
|
| 774 | + if ($paramsColumnKey === null) { |
|
| 775 | 775 | $valueSet = true; |
| 776 | 776 | $value = $row; |
| 777 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
| 777 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
| 778 | 778 | $valueSet = true; |
| 779 | - $value = $row[ $paramsColumnKey ]; |
|
| 779 | + $value = $row[$paramsColumnKey]; |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | - if ( $valueSet ) { |
|
| 783 | - if ( $keySet ) { |
|
| 784 | - $resultArray[ $key ] = $value; |
|
| 782 | + if ($valueSet) { |
|
| 783 | + if ($keySet) { |
|
| 784 | + $resultArray[$key] = $value; |
|
| 785 | 785 | } else { |
| 786 | 786 | $resultArray[] = $value; |
| 787 | 787 | } |
@@ -803,39 +803,39 @@ discard block |
||
| 803 | 803 | * |
| 804 | 804 | * @return bool Whether the receipt is visible or not. |
| 805 | 805 | */ |
| 806 | -function give_can_view_receipt( $payment_key = '' ) { |
|
| 806 | +function give_can_view_receipt($payment_key = '') { |
|
| 807 | 807 | |
| 808 | 808 | $return = false; |
| 809 | 809 | |
| 810 | - if ( empty( $payment_key ) ) { |
|
| 810 | + if (empty($payment_key)) { |
|
| 811 | 811 | return $return; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | global $give_receipt_args; |
| 815 | 815 | |
| 816 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
| 816 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
| 817 | 817 | |
| 818 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
| 818 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
| 819 | 819 | |
| 820 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
| 820 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
| 821 | 821 | |
| 822 | - if ( is_user_logged_in() ) { |
|
| 823 | - if ( $user_id === (int) get_current_user_id() ) { |
|
| 822 | + if (is_user_logged_in()) { |
|
| 823 | + if ($user_id === (int) get_current_user_id()) { |
|
| 824 | 824 | $return = true; |
| 825 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
| 825 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
| 826 | 826 | $return = true; |
| 827 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
| 827 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
| 828 | 828 | $return = true; |
| 829 | 829 | } |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | $session = give_get_purchase_session(); |
| 833 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
| 834 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
| 833 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
| 834 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
| 835 | 835 | $return = true; |
| 836 | 836 | } |
| 837 | 837 | } |
| 838 | 838 | |
| 839 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
| 839 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
| 840 | 840 | |
| 841 | 841 | } |
| 842 | 842 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -50,50 +50,50 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | |
| 52 | 52 | // https://gist.github.com/justinph/5197810 |
| 53 | - function validate_gravatar( $id_or_email ) { |
|
| 53 | + function validate_gravatar($id_or_email) { |
|
| 54 | 54 | //id or email code borrowed from wp-includes/pluggable.php |
| 55 | 55 | $email = ''; |
| 56 | - if ( is_numeric( $id_or_email ) ) { |
|
| 56 | + if (is_numeric($id_or_email)) { |
|
| 57 | 57 | $id = (int) $id_or_email; |
| 58 | - $user = get_userdata( $id ); |
|
| 59 | - if ( $user ) { |
|
| 58 | + $user = get_userdata($id); |
|
| 59 | + if ($user) { |
|
| 60 | 60 | $email = $user->user_email; |
| 61 | 61 | } |
| 62 | - } elseif ( is_object( $id_or_email ) ) { |
|
| 62 | + } elseif (is_object($id_or_email)) { |
|
| 63 | 63 | // No avatar for pingbacks or trackbacks |
| 64 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
| 65 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
| 64 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
| 65 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
| 66 | 66 | return false; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
| 69 | + if ( ! empty($id_or_email->user_id)) { |
|
| 70 | 70 | $id = (int) $id_or_email->user_id; |
| 71 | - $user = get_userdata( $id ); |
|
| 72 | - if ( $user ) { |
|
| 71 | + $user = get_userdata($id); |
|
| 72 | + if ($user) { |
|
| 73 | 73 | $email = $user->user_email; |
| 74 | 74 | } |
| 75 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
| 75 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
| 76 | 76 | $email = $id_or_email->comment_author_email; |
| 77 | 77 | } |
| 78 | 78 | } else { |
| 79 | 79 | $email = $id_or_email; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
| 83 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
| 82 | + $hashkey = md5(strtolower(trim($email))); |
|
| 83 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
| 84 | 84 | |
| 85 | - $data = wp_cache_get( $hashkey ); |
|
| 86 | - if ( false === $data ) { |
|
| 87 | - $response = wp_remote_head( $uri ); |
|
| 88 | - if ( is_wp_error( $response ) ) { |
|
| 85 | + $data = wp_cache_get($hashkey); |
|
| 86 | + if (false === $data) { |
|
| 87 | + $response = wp_remote_head($uri); |
|
| 88 | + if (is_wp_error($response)) { |
|
| 89 | 89 | $data = 'not200'; |
| 90 | 90 | } else { |
| 91 | 91 | $data = $response['response']['code']; |
| 92 | 92 | } |
| 93 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
| 93 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
| 94 | 94 | |
| 95 | 95 | } |
| 96 | - if ( $data == '200' ) { |
|
| 96 | + if ($data == '200') { |
|
| 97 | 97 | return true; |
| 98 | 98 | } else { |
| 99 | 99 | return false; |
@@ -108,17 +108,17 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param int $form_id |
| 110 | 110 | */ |
| 111 | - function get_log_ids( $form_id = '' ) { |
|
| 111 | + function get_log_ids($form_id = '') { |
|
| 112 | 112 | |
| 113 | 113 | // get Give_Logging class |
| 114 | 114 | global $give_logs; |
| 115 | 115 | |
| 116 | 116 | // get log for this form |
| 117 | - $logs = $give_logs->get_logs( $form_id ); |
|
| 117 | + $logs = $give_logs->get_logs($form_id); |
|
| 118 | 118 | |
| 119 | - if ( $logs ) { |
|
| 119 | + if ($logs) { |
|
| 120 | 120 | // make an array with all the donor IDs |
| 121 | - foreach ( $logs as $log ) { |
|
| 121 | + foreach ($logs as $log) { |
|
| 122 | 122 | $log_ids[] = $log->ID; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -135,49 +135,49 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @since 1.0 |
| 137 | 137 | */ |
| 138 | - function get_payment_ids( $form_id = '' ) { |
|
| 138 | + function get_payment_ids($form_id = '') { |
|
| 139 | 139 | |
| 140 | 140 | global $give_options; |
| 141 | 141 | |
| 142 | - $log_ids = $this->get_log_ids( $form_id ); |
|
| 142 | + $log_ids = $this->get_log_ids($form_id); |
|
| 143 | 143 | |
| 144 | - if ( $log_ids ) { |
|
| 144 | + if ($log_ids) { |
|
| 145 | 145 | |
| 146 | 146 | $payment_ids = array(); |
| 147 | 147 | |
| 148 | - foreach ( $log_ids as $id ) { |
|
| 148 | + foreach ($log_ids as $id) { |
|
| 149 | 149 | // get the payment ID for each corresponding log ID |
| 150 | - $payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true ); |
|
| 150 | + $payment_ids[] = get_post_meta($id, '_give_log_payment_id', true); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // remove donors who have purchased more than once so we can have unique avatars |
| 154 | 154 | $unique_emails = array(); |
| 155 | 155 | |
| 156 | - foreach ( $payment_ids as $key => $id ) { |
|
| 156 | + foreach ($payment_ids as $key => $id) { |
|
| 157 | 157 | |
| 158 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
| 158 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
| 159 | 159 | |
| 160 | - if ( isset ( $give_options['give_donators_gravatars_has_gravatar_account'] ) ) { |
|
| 161 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
| 160 | + if (isset ($give_options['give_donators_gravatars_has_gravatar_account'])) { |
|
| 161 | + if ( ! $this->validate_gravatar($email)) { |
|
| 162 | 162 | continue; |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true ); |
|
| 166 | + $unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true); |
|
| 167 | 167 | |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | // strip duplicate emails |
| 171 | - $unique_emails = array_unique( $unique_emails ); |
|
| 171 | + $unique_emails = array_unique($unique_emails); |
|
| 172 | 172 | |
| 173 | 173 | // convert the unique IDs back into simple array |
| 174 | - foreach ( $unique_emails as $id => $email ) { |
|
| 174 | + foreach ($unique_emails as $id => $email) { |
|
| 175 | 175 | $unique_ids[] = $id; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // randomize the payment IDs if enabled |
| 179 | - if ( isset( $give_options['give_donators_gravatars_random_gravatars'] ) ) { |
|
| 180 | - shuffle( $unique_ids ); |
|
| 179 | + if (isset($give_options['give_donators_gravatars_random_gravatars'])) { |
|
| 180 | + shuffle($unique_ids); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // return our unique IDs |
@@ -193,10 +193,10 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @since 1.0 |
| 195 | 195 | */ |
| 196 | - function gravatars( $form_id = false, $title = '' ) { |
|
| 196 | + function gravatars($form_id = false, $title = '') { |
|
| 197 | 197 | |
| 198 | 198 | // unique $payment_ids |
| 199 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
| 199 | + $payment_ids = $this->get_payment_ids($form_id); |
|
| 200 | 200 | |
| 201 | 201 | // var_dump( $payment_ids ); |
| 202 | 202 | // var_dump( $this->get_log_ids( get_the_ID() ) ); |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | global $give_options; |
| 205 | 205 | |
| 206 | 206 | // return if no ID |
| 207 | - if ( ! $form_id ) { |
|
| 207 | + if ( ! $form_id) { |
|
| 208 | 208 | return; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | // minimum amount of purchases before showing gravatars |
| 212 | 212 | // if the number of items in array is not greater or equal to the number specified, then exit |
| 213 | - if ( isset( $give_options['give_donators_gravatars_min_purchases_required'] ) && '' != $give_options['give_donators_gravatars_min_purchases_required'] ) { |
|
| 214 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donators_gravatars_min_purchases_required'] ) ) { |
|
| 213 | + if (isset($give_options['give_donators_gravatars_min_purchases_required']) && '' != $give_options['give_donators_gravatars_min_purchases_required']) { |
|
| 214 | + if ( ! (count($payment_ids) >= $give_options['give_donators_gravatars_min_purchases_required'])) { |
|
| 215 | 215 | return; |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -222,51 +222,51 @@ discard block |
||
| 222 | 222 | echo '<div id="give-purchase-gravatars">'; |
| 223 | 223 | |
| 224 | 224 | |
| 225 | - if ( isset ( $title ) ) { |
|
| 225 | + if (isset ($title)) { |
|
| 226 | 226 | |
| 227 | - if ( $title ) { |
|
| 228 | - echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ); |
|
| 229 | - } elseif ( isset( $give_options['give_donators_gravatars_heading'] ) ) { |
|
| 230 | - echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donators_gravatars_heading'] ) . '</h2>' ); |
|
| 227 | + if ($title) { |
|
| 228 | + echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>'); |
|
| 229 | + } elseif (isset($give_options['give_donators_gravatars_heading'])) { |
|
| 230 | + echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donators_gravatars_heading']).'</h2>'); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | } |
| 234 | 234 | echo '<ul class="give-purchase-gravatars-list">'; |
| 235 | 235 | $i = 0; |
| 236 | 236 | |
| 237 | - if ( $payment_ids ) { |
|
| 238 | - foreach ( $payment_ids as $id ) { |
|
| 237 | + if ($payment_ids) { |
|
| 238 | + foreach ($payment_ids as $id) { |
|
| 239 | 239 | |
| 240 | 240 | // Give saves a blank option even when the control is turned off, hence the extra check |
| 241 | - if ( isset( $give_options['give_donators_gravatars_maximum_number'] ) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number'] ) { |
|
| 241 | + if (isset($give_options['give_donators_gravatars_maximum_number']) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number']) { |
|
| 242 | 242 | continue; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // get the payment meta |
| 246 | - $payment_meta = get_post_meta( $id, '_give_payment_meta', true ); |
|
| 246 | + $payment_meta = get_post_meta($id, '_give_payment_meta', true); |
|
| 247 | 247 | |
| 248 | 248 | // unserialize the payment meta |
| 249 | - $user_info = maybe_unserialize( $payment_meta['user_info'] ); |
|
| 249 | + $user_info = maybe_unserialize($payment_meta['user_info']); |
|
| 250 | 250 | |
| 251 | 251 | // get donor's first name |
| 252 | 252 | $name = $user_info['first_name']; |
| 253 | 253 | |
| 254 | 254 | // get donor's email |
| 255 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
| 255 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
| 256 | 256 | |
| 257 | 257 | // set gravatar size and provide filter |
| 258 | - $size = isset( $give_options['give_donators_gravatars_gravatar_size'] ) ? apply_filters( 'give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size'] ) : ''; |
|
| 258 | + $size = isset($give_options['give_donators_gravatars_gravatar_size']) ? apply_filters('give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size']) : ''; |
|
| 259 | 259 | |
| 260 | 260 | // default image |
| 261 | - $default_image = apply_filters( 'give_donators_gravatars_gravatar_default_image', false ); |
|
| 261 | + $default_image = apply_filters('give_donators_gravatars_gravatar_default_image', false); |
|
| 262 | 262 | |
| 263 | 263 | // assemble output |
| 264 | 264 | $output .= '<li>'; |
| 265 | 265 | |
| 266 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
| 266 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
| 267 | 267 | $output .= '</li>'; |
| 268 | 268 | |
| 269 | - $i ++; |
|
| 269 | + $i++; |
|
| 270 | 270 | |
| 271 | 271 | } // end foreach |
| 272 | 272 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | echo '</ul>'; |
| 276 | 276 | echo '</div>'; |
| 277 | 277 | |
| 278 | - return apply_filters( 'give_donators_gravatars', ob_get_clean() ); |
|
| 278 | + return apply_filters('give_donators_gravatars', ob_get_clean()); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @since 1.0 |
| 285 | 285 | */ |
| 286 | 286 | function register_widget() { |
| 287 | - register_widget( 'Give_Donators_Gravatars_Widget' ); |
|
| 287 | + register_widget('Give_Donators_Gravatars_Widget'); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -293,19 +293,19 @@ discard block |
||
| 293 | 293 | * @since 1.0 |
| 294 | 294 | * @todo set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars |
| 295 | 295 | */ |
| 296 | - function shortcode( $atts, $content = null ) { |
|
| 296 | + function shortcode($atts, $content = null) { |
|
| 297 | 297 | |
| 298 | - $atts = shortcode_atts( array( |
|
| 298 | + $atts = shortcode_atts(array( |
|
| 299 | 299 | 'id' => '', |
| 300 | 300 | 'title' => '' |
| 301 | - ), $atts, 'give_donators_gravatars' ); |
|
| 301 | + ), $atts, 'give_donators_gravatars'); |
|
| 302 | 302 | |
| 303 | 303 | // if no ID is passed on single give_forms pages, get the correct ID |
| 304 | - if ( is_singular( 'give_forms' ) ) { |
|
| 304 | + if (is_singular('give_forms')) { |
|
| 305 | 305 | $id = get_the_ID(); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
| 308 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
| 309 | 309 | |
| 310 | 310 | return $content; |
| 311 | 311 | |
@@ -316,56 +316,56 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * @since 1.0 |
| 318 | 318 | */ |
| 319 | - function settings( $settings ) { |
|
| 319 | + function settings($settings) { |
|
| 320 | 320 | |
| 321 | 321 | $give_gravatar_settings = array( |
| 322 | 322 | array( |
| 323 | - 'name' => __( 'Donator Gravatars', 'give' ), |
|
| 323 | + 'name' => __('Donator Gravatars', 'give'), |
|
| 324 | 324 | 'desc' => '<hr>', |
| 325 | 325 | 'id' => 'give_title', |
| 326 | 326 | 'type' => 'give_title' |
| 327 | 327 | ), |
| 328 | 328 | array( |
| 329 | - 'name' => __( 'Heading', 'give' ), |
|
| 330 | - 'desc' => __( 'The heading to display above the Gravatars', 'give' ), |
|
| 329 | + 'name' => __('Heading', 'give'), |
|
| 330 | + 'desc' => __('The heading to display above the Gravatars', 'give'), |
|
| 331 | 331 | 'type' => 'text', |
| 332 | 332 | 'id' => 'give_donators_gravatars_heading' |
| 333 | 333 | ), |
| 334 | 334 | array( |
| 335 | - 'name' => __( 'Gravatar Size', 'give' ), |
|
| 336 | - 'desc' => __( 'The size of each Gravatar in pixels (512px maximum)', 'give' ), |
|
| 335 | + 'name' => __('Gravatar Size', 'give'), |
|
| 336 | + 'desc' => __('The size of each Gravatar in pixels (512px maximum)', 'give'), |
|
| 337 | 337 | 'type' => 'text_small', |
| 338 | 338 | 'id' => 'give_donators_gravatars_gravatar_size', |
| 339 | 339 | 'default' => '64' |
| 340 | 340 | ), |
| 341 | 341 | array( |
| 342 | - 'name' => __( 'Minimum Unique Purchases Required', 'give' ), |
|
| 343 | - 'desc' => sprintf( __( 'The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), strtolower( give_get_forms_label_singular() ) ), |
|
| 342 | + 'name' => __('Minimum Unique Purchases Required', 'give'), |
|
| 343 | + 'desc' => sprintf(__('The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), strtolower(give_get_forms_label_singular())), |
|
| 344 | 344 | 'type' => 'text_small', |
| 345 | 345 | 'id' => 'give_donators_gravatars_min_purchases_required', |
| 346 | 346 | ), |
| 347 | 347 | array( |
| 348 | - 'name' => __( 'Maximum Gravatars To Show', 'give' ), |
|
| 349 | - 'desc' => __( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
| 348 | + 'name' => __('Maximum Gravatars To Show', 'give'), |
|
| 349 | + 'desc' => __('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
| 350 | 350 | 'type' => 'text', |
| 351 | 351 | 'id' => 'give_donators_gravatars_maximum_number', |
| 352 | 352 | 'default' => '20', |
| 353 | 353 | ), |
| 354 | 354 | array( |
| 355 | - 'name' => __( 'Gravatar Visibility', 'give' ), |
|
| 356 | - 'desc' => __( 'Only show donators with a Gravatar account', 'give' ), |
|
| 355 | + 'name' => __('Gravatar Visibility', 'give'), |
|
| 356 | + 'desc' => __('Only show donators with a Gravatar account', 'give'), |
|
| 357 | 357 | 'id' => 'give_donators_gravatars_has_gravatar_account', |
| 358 | 358 | 'type' => 'checkbox', |
| 359 | 359 | ), |
| 360 | 360 | array( |
| 361 | - 'name' => __( 'Randomize Gravatars', 'give' ), |
|
| 362 | - 'desc' => __( 'Randomize the Gravatars', 'give' ), |
|
| 361 | + 'name' => __('Randomize Gravatars', 'give'), |
|
| 362 | + 'desc' => __('Randomize the Gravatars', 'give'), |
|
| 363 | 363 | 'id' => 'give_donators_gravatars_random_gravatars', |
| 364 | 364 | 'type' => 'checkbox', |
| 365 | 365 | ), |
| 366 | 366 | ); |
| 367 | 367 | |
| 368 | - return array_merge( $settings, $give_gravatar_settings ); |
|
| 368 | + return array_merge($settings, $give_gravatar_settings); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | } |
@@ -383,12 +383,12 @@ discard block |
||
| 383 | 383 | */ |
| 384 | 384 | function give_donators_gravatars_widget() { |
| 385 | 385 | |
| 386 | - $give_label_singular = function_exists( 'give_get_forms_label_singular' ) ? strtolower( give_get_forms_label_singular() ) : null; |
|
| 386 | + $give_label_singular = function_exists('give_get_forms_label_singular') ? strtolower(give_get_forms_label_singular()) : null; |
|
| 387 | 387 | |
| 388 | 388 | // widget settings |
| 389 | 389 | $widget_ops = array( |
| 390 | 390 | 'classname' => 'give-donators-gravatars', |
| 391 | - 'description' => sprintf( __( 'Displays gravatars of people who have donated using your your %s. Will only show on the single %s page.', 'give' ), $give_label_singular, $give_label_singular ) |
|
| 391 | + 'description' => sprintf(__('Displays gravatars of people who have donated using your your %s. Will only show on the single %s page.', 'give'), $give_label_singular, $give_label_singular) |
|
| 392 | 392 | ); |
| 393 | 393 | |
| 394 | 394 | // widget control settings |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | // create the widget |
| 402 | 402 | $this->WP_Widget( |
| 403 | 403 | 'give_donators_gravatars_widget', |
| 404 | - __( 'Give Donators Gravatars', 'give' ), |
|
| 404 | + __('Give Donators Gravatars', 'give'), |
|
| 405 | 405 | $widget_ops, |
| 406 | 406 | $control_ops |
| 407 | 407 | ); |
@@ -412,29 +412,29 @@ discard block |
||
| 412 | 412 | /* |
| 413 | 413 | * Outputs the content of the widget |
| 414 | 414 | */ |
| 415 | - function widget( $args, $instance ) { |
|
| 415 | + function widget($args, $instance) { |
|
| 416 | 416 | global $give_options; |
| 417 | 417 | |
| 418 | - extract( $args ); |
|
| 418 | + extract($args); |
|
| 419 | 419 | |
| 420 | - if ( ! is_singular( 'give_forms' ) ) { |
|
| 420 | + if ( ! is_singular('give_forms')) { |
|
| 421 | 421 | return; |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | // Variables from widget settings |
| 425 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
| 425 | + $title = apply_filters('widget_title', $instance['title']); |
|
| 426 | 426 | |
| 427 | 427 | // Used by themes. Opens the widget |
| 428 | 428 | echo $before_widget; |
| 429 | 429 | |
| 430 | 430 | // Display the widget title |
| 431 | - if ( $title ) { |
|
| 432 | - echo $before_title . $title . $after_title; |
|
| 431 | + if ($title) { |
|
| 432 | + echo $before_title.$title.$after_title; |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | $gravatars = new Give_Donators_Gravatars(); |
| 436 | 436 | |
| 437 | - echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
| 437 | + echo $gravatars->gravatars(get_the_ID(), null); // remove title |
|
| 438 | 438 | |
| 439 | 439 | // Used by themes. Closes the widget |
| 440 | 440 | echo $after_widget; |
@@ -444,11 +444,11 @@ discard block |
||
| 444 | 444 | /* |
| 445 | 445 | * Update function. Processes widget options to be saved |
| 446 | 446 | */ |
| 447 | - function update( $new_instance, $old_instance ) { |
|
| 447 | + function update($new_instance, $old_instance) { |
|
| 448 | 448 | |
| 449 | 449 | $instance = $old_instance; |
| 450 | 450 | |
| 451 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
| 451 | + $instance['title'] = strip_tags($new_instance['title']); |
|
| 452 | 452 | |
| 453 | 453 | return $instance; |
| 454 | 454 | |
@@ -457,19 +457,19 @@ discard block |
||
| 457 | 457 | /* |
| 458 | 458 | * Form function. Displays the actual form on the widget page |
| 459 | 459 | */ |
| 460 | - function form( $instance ) { |
|
| 460 | + function form($instance) { |
|
| 461 | 461 | |
| 462 | 462 | // Set up some default widget settings. |
| 463 | 463 | $defaults = array( |
| 464 | 464 | 'title' => '', |
| 465 | 465 | ); |
| 466 | 466 | |
| 467 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
| 467 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
| 468 | 468 | |
| 469 | 469 | <!-- Title --> |
| 470 | 470 | <p> |
| 471 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'give' ) ?></label> |
|
| 472 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
| 471 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'give') ?></label> |
|
| 472 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
| 473 | 473 | </p> |
| 474 | 474 | |
| 475 | 475 | |