@@ -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 | |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | * |
697 | 697 | * @param array $input A multi-dimensional array (record set) from which to pull |
698 | 698 | * a column of values. |
699 | - * @param mixed $columnKey The column of values to return. This value may be the |
|
699 | + * @param string $columnKey The column of values to return. This value may be the |
|
700 | 700 | * integer key of the column you wish to retrieve, or it |
701 | 701 | * may be the string key name for an associative array. |
702 | 702 | * @param mixed $indexKey (Optional.) The column to use as the index/keys for |
@@ -687,106 +687,106 @@ |
||
687 | 687 | */ |
688 | 688 | |
689 | 689 | if (!function_exists('array_column')) { |
690 | - /** |
|
691 | - * Returns the values from a single column of the input array, identified by |
|
692 | - * the $columnKey. |
|
693 | - * |
|
694 | - * Optionally, you may provide an $indexKey to index the values in the returned |
|
695 | - * array by the values from the $indexKey column in the input array. |
|
696 | - * |
|
697 | - * @param array $input A multi-dimensional array (record set) from which to pull |
|
698 | - * a column of values. |
|
699 | - * @param mixed $columnKey The column of values to return. This value may be the |
|
700 | - * integer key of the column you wish to retrieve, or it |
|
701 | - * may be the string key name for an associative array. |
|
702 | - * @param mixed $indexKey (Optional.) The column to use as the index/keys for |
|
703 | - * the returned array. This value may be the integer key |
|
704 | - * of the column, or it may be the string key name. |
|
705 | - * @return array |
|
706 | - */ |
|
707 | - function array_column($input = null, $columnKey = null, $indexKey = null) |
|
708 | - { |
|
709 | - // Using func_get_args() in order to check for proper number of |
|
710 | - // parameters and trigger errors exactly as the built-in array_column() |
|
711 | - // does in PHP 5.5. |
|
712 | - $argc = func_num_args(); |
|
713 | - $params = func_get_args(); |
|
714 | - |
|
715 | - if ($argc < 2) { |
|
716 | - trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); |
|
717 | - return null; |
|
718 | - } |
|
719 | - |
|
720 | - if (!is_array($params[0])) { |
|
721 | - trigger_error( |
|
722 | - 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given', |
|
723 | - E_USER_WARNING |
|
724 | - ); |
|
725 | - return null; |
|
726 | - } |
|
727 | - |
|
728 | - if (!is_int($params[1]) |
|
729 | - && !is_float($params[1]) |
|
730 | - && !is_string($params[1]) |
|
731 | - && $params[1] !== null |
|
732 | - && !(is_object($params[1]) && method_exists($params[1], '__toString')) |
|
733 | - ) { |
|
734 | - trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); |
|
735 | - return false; |
|
736 | - } |
|
737 | - |
|
738 | - if (isset($params[2]) |
|
739 | - && !is_int($params[2]) |
|
740 | - && !is_float($params[2]) |
|
741 | - && !is_string($params[2]) |
|
742 | - && !(is_object($params[2]) && method_exists($params[2], '__toString')) |
|
743 | - ) { |
|
744 | - trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); |
|
745 | - return false; |
|
746 | - } |
|
747 | - |
|
748 | - $paramsInput = $params[0]; |
|
749 | - $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
750 | - |
|
751 | - $paramsIndexKey = null; |
|
752 | - if (isset($params[2])) { |
|
753 | - if (is_float($params[2]) || is_int($params[2])) { |
|
754 | - $paramsIndexKey = (int) $params[2]; |
|
755 | - } else { |
|
756 | - $paramsIndexKey = (string) $params[2]; |
|
757 | - } |
|
758 | - } |
|
759 | - |
|
760 | - $resultArray = array(); |
|
761 | - |
|
762 | - foreach ($paramsInput as $row) { |
|
763 | - $key = $value = null; |
|
764 | - $keySet = $valueSet = false; |
|
765 | - |
|
766 | - if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
767 | - $keySet = true; |
|
768 | - $key = (string) $row[$paramsIndexKey]; |
|
769 | - } |
|
770 | - |
|
771 | - if ($paramsColumnKey === null) { |
|
772 | - $valueSet = true; |
|
773 | - $value = $row; |
|
774 | - } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
775 | - $valueSet = true; |
|
776 | - $value = $row[$paramsColumnKey]; |
|
777 | - } |
|
778 | - |
|
779 | - if ($valueSet) { |
|
780 | - if ($keySet) { |
|
781 | - $resultArray[$key] = $value; |
|
782 | - } else { |
|
783 | - $resultArray[] = $value; |
|
784 | - } |
|
785 | - } |
|
786 | - |
|
787 | - } |
|
788 | - |
|
789 | - return $resultArray; |
|
790 | - } |
|
690 | + /** |
|
691 | + * Returns the values from a single column of the input array, identified by |
|
692 | + * the $columnKey. |
|
693 | + * |
|
694 | + * Optionally, you may provide an $indexKey to index the values in the returned |
|
695 | + * array by the values from the $indexKey column in the input array. |
|
696 | + * |
|
697 | + * @param array $input A multi-dimensional array (record set) from which to pull |
|
698 | + * a column of values. |
|
699 | + * @param mixed $columnKey The column of values to return. This value may be the |
|
700 | + * integer key of the column you wish to retrieve, or it |
|
701 | + * may be the string key name for an associative array. |
|
702 | + * @param mixed $indexKey (Optional.) The column to use as the index/keys for |
|
703 | + * the returned array. This value may be the integer key |
|
704 | + * of the column, or it may be the string key name. |
|
705 | + * @return array |
|
706 | + */ |
|
707 | + function array_column($input = null, $columnKey = null, $indexKey = null) |
|
708 | + { |
|
709 | + // Using func_get_args() in order to check for proper number of |
|
710 | + // parameters and trigger errors exactly as the built-in array_column() |
|
711 | + // does in PHP 5.5. |
|
712 | + $argc = func_num_args(); |
|
713 | + $params = func_get_args(); |
|
714 | + |
|
715 | + if ($argc < 2) { |
|
716 | + trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); |
|
717 | + return null; |
|
718 | + } |
|
719 | + |
|
720 | + if (!is_array($params[0])) { |
|
721 | + trigger_error( |
|
722 | + 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given', |
|
723 | + E_USER_WARNING |
|
724 | + ); |
|
725 | + return null; |
|
726 | + } |
|
727 | + |
|
728 | + if (!is_int($params[1]) |
|
729 | + && !is_float($params[1]) |
|
730 | + && !is_string($params[1]) |
|
731 | + && $params[1] !== null |
|
732 | + && !(is_object($params[1]) && method_exists($params[1], '__toString')) |
|
733 | + ) { |
|
734 | + trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); |
|
735 | + return false; |
|
736 | + } |
|
737 | + |
|
738 | + if (isset($params[2]) |
|
739 | + && !is_int($params[2]) |
|
740 | + && !is_float($params[2]) |
|
741 | + && !is_string($params[2]) |
|
742 | + && !(is_object($params[2]) && method_exists($params[2], '__toString')) |
|
743 | + ) { |
|
744 | + trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); |
|
745 | + return false; |
|
746 | + } |
|
747 | + |
|
748 | + $paramsInput = $params[0]; |
|
749 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
750 | + |
|
751 | + $paramsIndexKey = null; |
|
752 | + if (isset($params[2])) { |
|
753 | + if (is_float($params[2]) || is_int($params[2])) { |
|
754 | + $paramsIndexKey = (int) $params[2]; |
|
755 | + } else { |
|
756 | + $paramsIndexKey = (string) $params[2]; |
|
757 | + } |
|
758 | + } |
|
759 | + |
|
760 | + $resultArray = array(); |
|
761 | + |
|
762 | + foreach ($paramsInput as $row) { |
|
763 | + $key = $value = null; |
|
764 | + $keySet = $valueSet = false; |
|
765 | + |
|
766 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
767 | + $keySet = true; |
|
768 | + $key = (string) $row[$paramsIndexKey]; |
|
769 | + } |
|
770 | + |
|
771 | + if ($paramsColumnKey === null) { |
|
772 | + $valueSet = true; |
|
773 | + $value = $row; |
|
774 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
775 | + $valueSet = true; |
|
776 | + $value = $row[$paramsColumnKey]; |
|
777 | + } |
|
778 | + |
|
779 | + if ($valueSet) { |
|
780 | + if ($keySet) { |
|
781 | + $resultArray[$key] = $value; |
|
782 | + } else { |
|
783 | + $resultArray[] = $value; |
|
784 | + } |
|
785 | + } |
|
786 | + |
|
787 | + } |
|
788 | + |
|
789 | + return $resultArray; |
|
790 | + } |
|
791 | 791 | |
792 | 792 | } |
793 | 793 | \ 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 | |
@@ -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 | /** |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | * @license http://opensource.org/licenses/MIT MIT |
687 | 687 | */ |
688 | 688 | |
689 | -if (!function_exists('array_column')) { |
|
689 | +if ( ! function_exists('array_column')) { |
|
690 | 690 | /** |
691 | 691 | * Returns the values from a single column of the input array, identified by |
692 | 692 | * the $columnKey. |
@@ -717,29 +717,29 @@ discard block |
||
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 | return null; |
726 | 726 | } |
727 | 727 | |
728 | - if (!is_int($params[1]) |
|
729 | - && !is_float($params[1]) |
|
730 | - && !is_string($params[1]) |
|
728 | + if ( ! is_int($params[1]) |
|
729 | + && ! is_float($params[1]) |
|
730 | + && ! is_string($params[1]) |
|
731 | 731 | && $params[1] !== null |
732 | - && !(is_object($params[1]) && method_exists($params[1], '__toString')) |
|
732 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
733 | 733 | ) { |
734 | 734 | trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); |
735 | 735 | return false; |
736 | 736 | } |
737 | 737 | |
738 | 738 | if (isset($params[2]) |
739 | - && !is_int($params[2]) |
|
740 | - && !is_float($params[2]) |
|
741 | - && !is_string($params[2]) |
|
742 | - && !(is_object($params[2]) && method_exists($params[2], '__toString')) |
|
739 | + && ! is_int($params[2]) |
|
740 | + && ! is_float($params[2]) |
|
741 | + && ! is_string($params[2]) |
|
742 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
743 | 743 | ) { |
744 | 744 | trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); |
745 | 745 | return false; |
@@ -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"; |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | * @param int $year Year |
625 | 625 | * @param int $hour Hour |
626 | 626 | * |
627 | - * @return int $earnings Earnings |
|
627 | + * @return double $earnings Earnings |
|
628 | 628 | */ |
629 | 629 | function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
630 | 630 | |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | * |
947 | 947 | * @param int $payment_id Payment ID |
948 | 948 | * |
949 | - * @return array $user_info User Info Meta Values |
|
949 | + * @return string $user_info User Info Meta Values |
|
950 | 950 | */ |
951 | 951 | function give_get_payment_meta_user_info( $payment_id ) { |
952 | 952 | $payment_meta = give_get_payment_meta( $payment_id ); |
@@ -1639,7 +1639,7 @@ discard block |
||
1639 | 1639 | * @param array $where |
1640 | 1640 | * @param obj $wp_comment_query WordPress Comment Query Object |
1641 | 1641 | * |
1642 | - * @return array $where |
|
1642 | + * @return string $where |
|
1643 | 1643 | */ |
1644 | 1644 | function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
1645 | 1645 | global $wpdb; |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Payment Functions |
|
4 | - * |
|
5 | - * @package Give |
|
6 | - * @subpackage Payments |
|
7 | - * @copyright Copyright (c) 2015, WordImpress |
|
8 | - * @license http://opensource.org/licenses/gpl-1.0.php GNU Public License |
|
9 | - * @since 1.0 |
|
10 | - */ |
|
3 | + * Payment Functions |
|
4 | + * |
|
5 | + * @package Give |
|
6 | + * @subpackage Payments |
|
7 | + * @copyright Copyright (c) 2015, WordImpress |
|
8 | + * @license http://opensource.org/licenses/gpl-1.0.php GNU Public License |
|
9 | + * @since 1.0 |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -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 | |
@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return object $payments Payments retrieved from the database |
34 | 34 | */ |
35 | -function give_get_payments( $args = array() ) { |
|
35 | +function give_get_payments($args = array()) { |
|
36 | 36 | |
37 | 37 | // Fallback to post objects to ensure backwards compatibility |
38 | - if ( ! isset( $args['output'] ) ) { |
|
38 | + if ( ! isset($args['output'])) { |
|
39 | 39 | $args['output'] = 'posts'; |
40 | 40 | } |
41 | 41 | |
42 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
43 | - $payments = new Give_Payments_Query( $args ); |
|
42 | + $args = apply_filters('give_get_payments_args', $args); |
|
43 | + $payments = new Give_Payments_Query($args); |
|
44 | 44 | |
45 | 45 | return $payments->get_payments(); |
46 | 46 | } |
@@ -55,44 +55,44 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return mixed |
57 | 57 | */ |
58 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
58 | +function give_get_payment_by($field = '', $value = '') { |
|
59 | 59 | |
60 | - if ( empty( $field ) || empty( $value ) ) { |
|
60 | + if (empty($field) || empty($value)) { |
|
61 | 61 | return false; |
62 | 62 | } |
63 | 63 | |
64 | - switch ( strtolower( $field ) ) { |
|
64 | + switch (strtolower($field)) { |
|
65 | 65 | |
66 | 66 | case 'id': |
67 | - $payment = get_post( $value ); |
|
67 | + $payment = get_post($value); |
|
68 | 68 | |
69 | - if ( get_post_type( $payment ) != 'give_payment' ) { |
|
69 | + if (get_post_type($payment) != 'give_payment') { |
|
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | |
73 | 73 | break; |
74 | 74 | |
75 | 75 | case 'key': |
76 | - $payment = give_get_payments( array( |
|
76 | + $payment = give_get_payments(array( |
|
77 | 77 | 'meta_key' => '_give_payment_purchase_key', |
78 | 78 | 'meta_value' => $value, |
79 | 79 | 'posts_per_page' => 1 |
80 | - ) ); |
|
80 | + )); |
|
81 | 81 | |
82 | - if ( $payment ) { |
|
82 | + if ($payment) { |
|
83 | 83 | $payment = $payment[0]; |
84 | 84 | } |
85 | 85 | |
86 | 86 | break; |
87 | 87 | |
88 | 88 | case 'payment_number': |
89 | - $payment = give_get_payments( array( |
|
89 | + $payment = give_get_payments(array( |
|
90 | 90 | 'meta_key' => '_give_payment_number', |
91 | 91 | 'meta_value' => $value, |
92 | 92 | 'posts_per_page' => 1 |
93 | - ) ); |
|
93 | + )); |
|
94 | 94 | |
95 | - if ( $payment ) { |
|
95 | + if ($payment) { |
|
96 | 96 | $payment = $payment[0]; |
97 | 97 | } |
98 | 98 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | return false; |
103 | 103 | } |
104 | 104 | |
105 | - if ( $payment ) { |
|
105 | + if ($payment) { |
|
106 | 106 | return $payment; |
107 | 107 | } |
108 | 108 | |
@@ -118,98 +118,98 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return int|bool Payment ID if payment is inserted, false otherwise |
120 | 120 | */ |
121 | -function give_insert_payment( $payment_data = array() ) { |
|
122 | - if ( empty( $payment_data ) ) { |
|
121 | +function give_insert_payment($payment_data = array()) { |
|
122 | + if (empty($payment_data)) { |
|
123 | 123 | return false; |
124 | 124 | } |
125 | 125 | |
126 | 126 | // Make sure the payment is inserted with the correct timezone |
127 | - date_default_timezone_set( give_get_timezone_id() ); |
|
127 | + date_default_timezone_set(give_get_timezone_id()); |
|
128 | 128 | |
129 | 129 | // Construct the payment title |
130 | - if ( isset( $payment_data['user_info']['first_name'] ) || isset( $payment_data['user_info']['last_name'] ) ) { |
|
131 | - $payment_title = $payment_data['user_info']['first_name'] . ' ' . $payment_data['user_info']['last_name']; |
|
130 | + if (isset($payment_data['user_info']['first_name']) || isset($payment_data['user_info']['last_name'])) { |
|
131 | + $payment_title = $payment_data['user_info']['first_name'].' '.$payment_data['user_info']['last_name']; |
|
132 | 132 | } else { |
133 | 133 | $payment_title = $payment_data['user_email']; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Find the next payment number, if enabled |
137 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
137 | + if (give_get_option('enable_sequential')) { |
|
138 | 138 | $number = give_get_next_payment_number(); |
139 | 139 | } |
140 | 140 | |
141 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
141 | + $args = apply_filters('give_insert_payment_args', array( |
|
142 | 142 | 'post_title' => $payment_title, |
143 | - 'post_status' => isset( $payment_data['status'] ) ? $payment_data['status'] : 'pending', |
|
143 | + 'post_status' => isset($payment_data['status']) ? $payment_data['status'] : 'pending', |
|
144 | 144 | 'post_type' => 'give_payment', |
145 | - 'post_parent' => isset( $payment_data['parent'] ) ? $payment_data['parent'] : null, |
|
146 | - 'post_date' => isset( $payment_data['post_date'] ) ? $payment_data['post_date'] : null, |
|
147 | - 'post_date_gmt' => isset( $payment_data['post_date'] ) ? get_gmt_from_date( $payment_data['post_date'] ) : null |
|
148 | - ), $payment_data ); |
|
145 | + 'post_parent' => isset($payment_data['parent']) ? $payment_data['parent'] : null, |
|
146 | + 'post_date' => isset($payment_data['post_date']) ? $payment_data['post_date'] : null, |
|
147 | + 'post_date_gmt' => isset($payment_data['post_date']) ? get_gmt_from_date($payment_data['post_date']) : null |
|
148 | + ), $payment_data); |
|
149 | 149 | |
150 | 150 | // Create a blank payment |
151 | - $payment = wp_insert_post( $args ); |
|
151 | + $payment = wp_insert_post($args); |
|
152 | 152 | |
153 | - if ( $payment ) { |
|
153 | + if ($payment) { |
|
154 | 154 | |
155 | 155 | $payment_meta = array( |
156 | 156 | 'currency' => $payment_data['currency'], |
157 | 157 | 'form_title' => $payment_data['give_form_title'], |
158 | 158 | 'form_id' => $payment_data['give_form_id'], |
159 | - 'price_id' => give_get_price_id( $payment_data['give_form_id'], $payment_data['price'] ), |
|
159 | + 'price_id' => give_get_price_id($payment_data['give_form_id'], $payment_data['price']), |
|
160 | 160 | 'user_info' => $payment_data['user_info'], |
161 | 161 | ); |
162 | 162 | |
163 | 163 | $mode = give_is_test_mode() ? 'test' : 'live'; |
164 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
165 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
164 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
165 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
166 | 166 | |
167 | - if ( ! $payment_data['price'] ) { |
|
167 | + if ( ! $payment_data['price']) { |
|
168 | 168 | // Ensures the _give_payment_total meta key is created for donations with an amount of 0 |
169 | 169 | $payment_data['price'] = '0.00'; |
170 | 170 | } |
171 | 171 | |
172 | 172 | // Create or update a customer |
173 | - $customer = new Give_Customer( $payment_data['user_email'] ); |
|
173 | + $customer = new Give_Customer($payment_data['user_email']); |
|
174 | 174 | $customer_data = array( |
175 | - 'name' => $payment_data['user_info']['first_name'] . ' ' . $payment_data['user_info']['last_name'], |
|
175 | + 'name' => $payment_data['user_info']['first_name'].' '.$payment_data['user_info']['last_name'], |
|
176 | 176 | 'email' => $payment_data['user_email'], |
177 | 177 | 'user_id' => $payment_data['user_info']['id'] |
178 | 178 | ); |
179 | 179 | |
180 | - if ( empty( $customer->id ) ) { |
|
181 | - $customer->create( $customer_data ); |
|
180 | + if (empty($customer->id)) { |
|
181 | + $customer->create($customer_data); |
|
182 | 182 | } else { |
183 | 183 | // Only update the customer if their name or email has changed |
184 | - if ( $customer_data['email'] !== $customer->email || $customer_data['name'] !== $customer->name ) { |
|
184 | + if ($customer_data['email'] !== $customer->email || $customer_data['name'] !== $customer->name) { |
|
185 | 185 | // We shouldn't be updating the User ID here, that is an admin task |
186 | - unset( $customer_data['user_id'] ); |
|
187 | - $customer->update( $customer_data ); |
|
186 | + unset($customer_data['user_id']); |
|
187 | + $customer->update($customer_data); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - $customer->attach_payment( $payment, false ); |
|
191 | + $customer->attach_payment($payment, false); |
|
192 | 192 | |
193 | 193 | // Record the payment details |
194 | - give_update_payment_meta( $payment, '_give_payment_meta', apply_filters( 'give_payment_meta', $payment_meta, $payment_data ) ); |
|
195 | - give_update_payment_meta( $payment, '_give_payment_user_id', $payment_data['user_info']['id'] ); |
|
196 | - give_update_payment_meta( $payment, '_give_payment_donor_id', $customer->id ); |
|
197 | - give_update_payment_meta( $payment, '_give_payment_user_email', $payment_data['user_email'] ); |
|
198 | - give_update_payment_meta( $payment, '_give_payment_user_ip', give_get_ip() ); |
|
199 | - give_update_payment_meta( $payment, '_give_payment_purchase_key', $payment_data['purchase_key'] ); |
|
200 | - give_update_payment_meta( $payment, '_give_payment_total', $payment_data['price'] ); |
|
201 | - give_update_payment_meta( $payment, '_give_payment_mode', $mode ); |
|
202 | - give_update_payment_meta( $payment, '_give_payment_gateway', $gateway ); |
|
203 | - |
|
204 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
205 | - give_update_payment_meta( $payment, '_give_payment_number', give_format_payment_number( $number ) ); |
|
206 | - update_option( 'give_last_payment_number', $number ); |
|
194 | + give_update_payment_meta($payment, '_give_payment_meta', apply_filters('give_payment_meta', $payment_meta, $payment_data)); |
|
195 | + give_update_payment_meta($payment, '_give_payment_user_id', $payment_data['user_info']['id']); |
|
196 | + give_update_payment_meta($payment, '_give_payment_donor_id', $customer->id); |
|
197 | + give_update_payment_meta($payment, '_give_payment_user_email', $payment_data['user_email']); |
|
198 | + give_update_payment_meta($payment, '_give_payment_user_ip', give_get_ip()); |
|
199 | + give_update_payment_meta($payment, '_give_payment_purchase_key', $payment_data['purchase_key']); |
|
200 | + give_update_payment_meta($payment, '_give_payment_total', $payment_data['price']); |
|
201 | + give_update_payment_meta($payment, '_give_payment_mode', $mode); |
|
202 | + give_update_payment_meta($payment, '_give_payment_gateway', $gateway); |
|
203 | + |
|
204 | + if (give_get_option('enable_sequential')) { |
|
205 | + give_update_payment_meta($payment, '_give_payment_number', give_format_payment_number($number)); |
|
206 | + update_option('give_last_payment_number', $number); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | // Clear the user's purchased cache |
210 | - delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' ); |
|
210 | + delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases'); |
|
211 | 211 | |
212 | - do_action( 'give_insert_payment', $payment, $payment_data ); |
|
212 | + do_action('give_insert_payment', $payment, $payment_data); |
|
213 | 213 | |
214 | 214 | return $payment; // Return the ID |
215 | 215 | |
@@ -229,43 +229,43 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return void |
231 | 231 | */ |
232 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
232 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
233 | 233 | |
234 | - if ( $new_status == 'completed' || $new_status == 'complete' ) { |
|
234 | + if ($new_status == 'completed' || $new_status == 'complete') { |
|
235 | 235 | $new_status = 'publish'; |
236 | 236 | } |
237 | 237 | |
238 | - if ( empty( $payment_id ) ) { |
|
238 | + if (empty($payment_id)) { |
|
239 | 239 | return; |
240 | 240 | } |
241 | 241 | |
242 | - $payment = get_post( $payment_id ); |
|
242 | + $payment = get_post($payment_id); |
|
243 | 243 | |
244 | - if ( is_wp_error( $payment ) || ! is_object( $payment ) ) { |
|
244 | + if (is_wp_error($payment) || ! is_object($payment)) { |
|
245 | 245 | return; |
246 | 246 | } |
247 | 247 | |
248 | 248 | $old_status = $payment->post_status; |
249 | 249 | |
250 | - if ( $old_status === $new_status ) { |
|
250 | + if ($old_status === $new_status) { |
|
251 | 251 | return; // Don't permit status changes that aren't changes |
252 | 252 | } |
253 | 253 | |
254 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $payment_id, $new_status, $old_status ); |
|
254 | + $do_change = apply_filters('give_should_update_payment_status', true, $payment_id, $new_status, $old_status); |
|
255 | 255 | |
256 | - if ( $do_change ) { |
|
256 | + if ($do_change) { |
|
257 | 257 | |
258 | - do_action( 'give_before_payment_status_change', $payment_id, $new_status, $old_status ); |
|
258 | + do_action('give_before_payment_status_change', $payment_id, $new_status, $old_status); |
|
259 | 259 | |
260 | 260 | $update_fields = array( |
261 | 261 | 'ID' => $payment_id, |
262 | 262 | 'post_status' => $new_status, |
263 | - 'edit_date' => current_time( 'mysql' ) |
|
263 | + 'edit_date' => current_time('mysql') |
|
264 | 264 | ); |
265 | 265 | |
266 | - wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
266 | + wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
267 | 267 | |
268 | - do_action( 'give_update_payment_status', $payment_id, $new_status, $old_status ); |
|
268 | + do_action('give_update_payment_status', $payment_id, $new_status, $old_status); |
|
269 | 269 | |
270 | 270 | } |
271 | 271 | } |
@@ -281,48 +281,48 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return void |
283 | 283 | */ |
284 | -function give_delete_purchase( $payment_id = 0 ) { |
|
284 | +function give_delete_purchase($payment_id = 0) { |
|
285 | 285 | global $give_logs; |
286 | 286 | |
287 | - $post = get_post( $payment_id ); |
|
287 | + $post = get_post($payment_id); |
|
288 | 288 | |
289 | - if ( ! $post ) { |
|
289 | + if ( ! $post) { |
|
290 | 290 | return; |
291 | 291 | } |
292 | 292 | |
293 | - $form_id = give_get_payment_form_id( $payment_id ); |
|
293 | + $form_id = give_get_payment_form_id($payment_id); |
|
294 | 294 | |
295 | - give_undo_purchase( $form_id, $payment_id ); |
|
295 | + give_undo_purchase($form_id, $payment_id); |
|
296 | 296 | |
297 | - $amount = give_get_payment_amount( $payment_id ); |
|
297 | + $amount = give_get_payment_amount($payment_id); |
|
298 | 298 | $status = $post->post_status; |
299 | - $donor_id = give_get_payment_customer_id( $payment_id ); |
|
299 | + $donor_id = give_get_payment_customer_id($payment_id); |
|
300 | 300 | |
301 | - if ( $status == 'revoked' || $status == 'publish' ) { |
|
301 | + if ($status == 'revoked' || $status == 'publish') { |
|
302 | 302 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment) |
303 | - give_decrease_total_earnings( $amount ); |
|
303 | + give_decrease_total_earnings($amount); |
|
304 | 304 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
305 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
305 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
306 | 306 | |
307 | - if ( $donor_id ) { |
|
307 | + if ($donor_id) { |
|
308 | 308 | |
309 | 309 | // Decrement the stats for the donor |
310 | - Give()->customers->decrement_stats( $donor_id, $amount ); |
|
310 | + Give()->customers->decrement_stats($donor_id, $amount); |
|
311 | 311 | |
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | - do_action( 'give_payment_delete', $payment_id ); |
|
315 | + do_action('give_payment_delete', $payment_id); |
|
316 | 316 | |
317 | - if ( $donor_id ) { |
|
317 | + if ($donor_id) { |
|
318 | 318 | |
319 | 319 | // Remove the payment ID from the donor |
320 | - Give()->customers->remove_payment( $donor_id, $payment_id ); |
|
320 | + Give()->customers->remove_payment($donor_id, $payment_id); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
324 | 324 | // Remove the payment |
325 | - wp_delete_post( $payment_id, true ); |
|
325 | + wp_delete_post($payment_id, true); |
|
326 | 326 | |
327 | 327 | // Remove related sale log entries |
328 | 328 | $give_logs->delete_logs( |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | ) |
337 | 337 | ); |
338 | 338 | |
339 | - do_action( 'give_payment_deleted', $payment_id ); |
|
339 | + do_action('give_payment_deleted', $payment_id); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
@@ -349,19 +349,19 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @return void |
351 | 351 | */ |
352 | -function give_undo_purchase( $form_id, $payment_id ) { |
|
352 | +function give_undo_purchase($form_id, $payment_id) { |
|
353 | 353 | |
354 | - if ( give_is_test_mode() ) { |
|
354 | + if (give_is_test_mode()) { |
|
355 | 355 | return; |
356 | 356 | } |
357 | 357 | |
358 | - $amount = give_get_payment_amount( $payment_id ); |
|
358 | + $amount = give_get_payment_amount($payment_id); |
|
359 | 359 | |
360 | 360 | // decrease earnings |
361 | - give_decrease_earnings( $form_id, $amount ); |
|
361 | + give_decrease_earnings($form_id, $amount); |
|
362 | 362 | |
363 | 363 | // decrease purchase count |
364 | - give_decrease_purchase_count( $form_id ); |
|
364 | + give_decrease_purchase_count($form_id); |
|
365 | 365 | |
366 | 366 | |
367 | 367 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * |
379 | 379 | * @return array $count Number of payments sorted by payment status |
380 | 380 | */ |
381 | -function give_count_payments( $args = array() ) { |
|
381 | +function give_count_payments($args = array()) { |
|
382 | 382 | |
383 | 383 | global $wpdb; |
384 | 384 | |
@@ -389,17 +389,17 @@ discard block |
||
389 | 389 | 'end-date' => null, |
390 | 390 | ); |
391 | 391 | |
392 | - $args = wp_parse_args( $args, $defaults ); |
|
392 | + $args = wp_parse_args($args, $defaults); |
|
393 | 393 | |
394 | 394 | $join = ''; |
395 | 395 | $where = "WHERE p.post_type = 'give_payment'"; |
396 | 396 | |
397 | 397 | // Count payments for a specific user |
398 | - if ( ! empty( $args['user'] ) ) { |
|
398 | + if ( ! empty($args['user'])) { |
|
399 | 399 | |
400 | - if ( is_email( $args['user'] ) ) { |
|
400 | + if (is_email($args['user'])) { |
|
401 | 401 | $field = 'email'; |
402 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
402 | + } elseif (is_numeric($args['user'])) { |
|
403 | 403 | $field = 'id'; |
404 | 404 | } else { |
405 | 405 | $field = ''; |
@@ -407,18 +407,18 @@ discard block |
||
407 | 407 | |
408 | 408 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
409 | 409 | |
410 | - if ( ! empty( $field ) ) { |
|
410 | + if ( ! empty($field)) { |
|
411 | 411 | $where .= " |
412 | 412 | AND m.meta_key = '_give_payment_user_{$field}' |
413 | 413 | AND m.meta_value = '{$args['user']}'"; |
414 | 414 | } |
415 | 415 | |
416 | 416 | // Count payments for a search |
417 | - } elseif ( ! empty( $args['s'] ) ) { |
|
417 | + } elseif ( ! empty($args['s'])) { |
|
418 | 418 | |
419 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
419 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
420 | 420 | |
421 | - if ( is_email( $args['s'] ) ) { |
|
421 | + if (is_email($args['s'])) { |
|
422 | 422 | $field = '_give_payment_user_email'; |
423 | 423 | } else { |
424 | 424 | $field = '_give_payment_purchase_key'; |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | AND m.meta_key = '{$field}' |
431 | 431 | AND m.meta_value = '{$args['s']}'"; |
432 | 432 | |
433 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
433 | + } elseif (is_numeric($args['s'])) { |
|
434 | 434 | |
435 | 435 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
436 | 436 | $where .= " |
@@ -444,48 +444,48 @@ discard block |
||
444 | 444 | } |
445 | 445 | |
446 | 446 | // Limit payments count by date |
447 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
447 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
448 | 448 | |
449 | - $date_parts = explode( '/', $args['start-date'] ); |
|
450 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
451 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
452 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
449 | + $date_parts = explode('/', $args['start-date']); |
|
450 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
451 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
452 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
453 | 453 | |
454 | - $is_date = checkdate( $month, $day, $year ); |
|
455 | - if ( false !== $is_date ) { |
|
454 | + $is_date = checkdate($month, $day, $year); |
|
455 | + if (false !== $is_date) { |
|
456 | 456 | |
457 | - $date = new DateTime( $args['start-date'] ); |
|
458 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
457 | + $date = new DateTime($args['start-date']); |
|
458 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
459 | 459 | |
460 | 460 | } |
461 | 461 | |
462 | 462 | // Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class) |
463 | - if ( empty( $args['end-date'] ) ) { |
|
463 | + if (empty($args['end-date'])) { |
|
464 | 464 | $args['end-date'] = $args['start-date']; |
465 | 465 | } |
466 | 466 | |
467 | 467 | } |
468 | 468 | |
469 | - if ( ! empty ( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
469 | + if ( ! empty ($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
470 | 470 | |
471 | - $date_parts = explode( '/', $args['end-date'] ); |
|
471 | + $date_parts = explode('/', $args['end-date']); |
|
472 | 472 | |
473 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
474 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
475 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
473 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
474 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
475 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
476 | 476 | |
477 | - $is_date = checkdate( $month, $day, $year ); |
|
478 | - if ( false !== $is_date ) { |
|
477 | + $is_date = checkdate($month, $day, $year); |
|
478 | + if (false !== $is_date) { |
|
479 | 479 | |
480 | - $date = new DateTime( $args['end-date'] ); |
|
481 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
480 | + $date = new DateTime($args['end-date']); |
|
481 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | |
485 | 485 | } |
486 | 486 | |
487 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
488 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
487 | + $where = apply_filters('give_count_payments_where', $where); |
|
488 | + $join = apply_filters('give_count_payments_join', $join); |
|
489 | 489 | |
490 | 490 | $query = "SELECT p.post_status,count( * ) AS num_posts |
491 | 491 | FROM $wpdb->posts p |
@@ -494,35 +494,35 @@ discard block |
||
494 | 494 | GROUP BY p.post_status |
495 | 495 | "; |
496 | 496 | |
497 | - $cache_key = md5( implode( '|', $args ) . $where ); |
|
497 | + $cache_key = md5(implode('|', $args).$where); |
|
498 | 498 | |
499 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
500 | - if ( false !== $count ) { |
|
499 | + $count = wp_cache_get($cache_key, 'counts'); |
|
500 | + if (false !== $count) { |
|
501 | 501 | return $count; |
502 | 502 | } |
503 | 503 | |
504 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
504 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
505 | 505 | |
506 | 506 | $stats = array(); |
507 | 507 | $statuses = get_post_stati(); |
508 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
509 | - unset( $statuses['private'] ); |
|
508 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
509 | + unset($statuses['private']); |
|
510 | 510 | } |
511 | 511 | |
512 | - foreach ( $statuses as $state ) { |
|
513 | - $stats[ $state ] = 0; |
|
512 | + foreach ($statuses as $state) { |
|
513 | + $stats[$state] = 0; |
|
514 | 514 | } |
515 | 515 | |
516 | - foreach ( (array) $count as $row ) { |
|
517 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
516 | + foreach ((array) $count as $row) { |
|
517 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
518 | 518 | continue; |
519 | 519 | } |
520 | 520 | |
521 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
521 | + $stats[$row['post_status']] = $row['num_posts']; |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | $stats = (object) $stats; |
525 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
525 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
526 | 526 | |
527 | 527 | return $stats; |
528 | 528 | } |
@@ -537,10 +537,10 @@ discard block |
||
537 | 537 | * |
538 | 538 | * @return bool true if payment exists, false otherwise |
539 | 539 | */ |
540 | -function give_check_for_existing_payment( $payment_id ) { |
|
541 | - $payment = get_post( $payment_id ); |
|
540 | +function give_check_for_existing_payment($payment_id) { |
|
541 | + $payment = get_post($payment_id); |
|
542 | 542 | |
543 | - if ( $payment && $payment->post_status == 'publish' ) { |
|
543 | + if ($payment && $payment->post_status == 'publish') { |
|
544 | 544 | return true; // Payment exists |
545 | 545 | } |
546 | 546 | |
@@ -557,21 +557,21 @@ discard block |
||
557 | 557 | * |
558 | 558 | * @return bool|mixed if payment status exists, false otherwise |
559 | 559 | */ |
560 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
561 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
560 | +function give_get_payment_status($payment, $return_label = false) { |
|
561 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
562 | 562 | return false; |
563 | 563 | } |
564 | 564 | |
565 | 565 | $statuses = give_get_payment_statuses(); |
566 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
566 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
567 | 567 | return false; |
568 | 568 | } |
569 | 569 | |
570 | - if ( array_key_exists( $payment->post_status, $statuses ) ) { |
|
571 | - if ( true === $return_label ) { |
|
572 | - return $statuses[ $payment->post_status ]; |
|
570 | + if (array_key_exists($payment->post_status, $statuses)) { |
|
571 | + if (true === $return_label) { |
|
572 | + return $statuses[$payment->post_status]; |
|
573 | 573 | } else { |
574 | - return array_search( $payment->post_status, $statuses ); |
|
574 | + return array_search($payment->post_status, $statuses); |
|
575 | 575 | } |
576 | 576 | } |
577 | 577 | |
@@ -586,17 +586,17 @@ discard block |
||
586 | 586 | */ |
587 | 587 | function give_get_payment_statuses() { |
588 | 588 | $payment_statuses = array( |
589 | - 'pending' => __( 'Pending', 'give' ), |
|
590 | - 'publish' => __( 'Complete', 'give' ), |
|
591 | - 'refunded' => __( 'Refunded', 'give' ), |
|
592 | - 'failed' => __( 'Failed', 'give' ), |
|
593 | - 'cancelled' => __( 'Cancelled', 'give' ), |
|
594 | - 'abandoned' => __( 'Abandoned', 'give' ), |
|
595 | - 'preapproval' => __( 'Pre-Approved', 'give' ), |
|
596 | - 'revoked' => __( 'Revoked', 'give' ) |
|
589 | + 'pending' => __('Pending', 'give'), |
|
590 | + 'publish' => __('Complete', 'give'), |
|
591 | + 'refunded' => __('Refunded', 'give'), |
|
592 | + 'failed' => __('Failed', 'give'), |
|
593 | + 'cancelled' => __('Cancelled', 'give'), |
|
594 | + 'abandoned' => __('Abandoned', 'give'), |
|
595 | + 'preapproval' => __('Pre-Approved', 'give'), |
|
596 | + 'revoked' => __('Revoked', 'give') |
|
597 | 597 | ); |
598 | 598 | |
599 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
599 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | /** |
@@ -608,10 +608,10 @@ discard block |
||
608 | 608 | * @return array $payment_status All the available payment statuses |
609 | 609 | */ |
610 | 610 | function give_get_payment_status_keys() { |
611 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
612 | - asort( $statuses ); |
|
611 | + $statuses = array_keys(give_get_payment_statuses()); |
|
612 | + asort($statuses); |
|
613 | 613 | |
614 | - return array_values( $statuses ); |
|
614 | + return array_values($statuses); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | * |
627 | 627 | * @return int $earnings Earnings |
628 | 628 | */ |
629 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
629 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
630 | 630 | |
631 | 631 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead |
632 | 632 | |
@@ -637,40 +637,40 @@ discard block |
||
637 | 637 | 'nopaging' => true, |
638 | 638 | 'year' => $year, |
639 | 639 | 'monthnum' => $month_num, |
640 | - 'post_status' => array( 'publish', 'revoked' ), |
|
640 | + 'post_status' => array('publish', 'revoked'), |
|
641 | 641 | 'fields' => 'ids', |
642 | 642 | 'update_post_term_cache' => false |
643 | 643 | ); |
644 | - if ( ! empty( $day ) ) { |
|
644 | + if ( ! empty($day)) { |
|
645 | 645 | $args['day'] = $day; |
646 | 646 | } |
647 | 647 | |
648 | - if ( ! empty( $hour ) ) { |
|
648 | + if ( ! empty($hour)) { |
|
649 | 649 | $args['hour'] = $hour; |
650 | 650 | } |
651 | 651 | |
652 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
653 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
652 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
653 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
654 | 654 | |
655 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
655 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
656 | 656 | $earnings = false; |
657 | 657 | } else { |
658 | - $earnings = get_transient( $key ); |
|
658 | + $earnings = get_transient($key); |
|
659 | 659 | } |
660 | 660 | |
661 | - if ( false === $earnings ) { |
|
662 | - $sales = get_posts( $args ); |
|
661 | + if (false === $earnings) { |
|
662 | + $sales = get_posts($args); |
|
663 | 663 | $earnings = 0; |
664 | - if ( $sales ) { |
|
665 | - $sales = implode( ',', $sales ); |
|
666 | - $earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" ); |
|
664 | + if ($sales) { |
|
665 | + $sales = implode(',', $sales); |
|
666 | + $earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})"); |
|
667 | 667 | |
668 | 668 | } |
669 | 669 | // Cache the results for one hour |
670 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
670 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
671 | 671 | } |
672 | 672 | |
673 | - return round( $earnings, 2 ); |
|
673 | + return round($earnings, 2); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | * |
686 | 686 | * @return int $count Sales |
687 | 687 | */ |
688 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
688 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
689 | 689 | |
690 | 690 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead |
691 | 691 | $args = array( |
@@ -693,37 +693,37 @@ discard block |
||
693 | 693 | 'nopaging' => true, |
694 | 694 | 'year' => $year, |
695 | 695 | 'fields' => 'ids', |
696 | - 'post_status' => array( 'publish', 'revoked' ), |
|
696 | + 'post_status' => array('publish', 'revoked'), |
|
697 | 697 | 'update_post_meta_cache' => false, |
698 | 698 | 'update_post_term_cache' => false |
699 | 699 | ); |
700 | 700 | |
701 | - if ( ! empty( $month_num ) ) { |
|
701 | + if ( ! empty($month_num)) { |
|
702 | 702 | $args['monthnum'] = $month_num; |
703 | 703 | } |
704 | 704 | |
705 | - if ( ! empty( $day ) ) { |
|
705 | + if ( ! empty($day)) { |
|
706 | 706 | $args['day'] = $day; |
707 | 707 | } |
708 | 708 | |
709 | - if ( ! empty( $hour ) ) { |
|
709 | + if ( ! empty($hour)) { |
|
710 | 710 | $args['hour'] = $hour; |
711 | 711 | } |
712 | 712 | |
713 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
714 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
713 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
714 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
715 | 715 | |
716 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
716 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
717 | 717 | $count = false; |
718 | 718 | } else { |
719 | - $count = get_transient( $key ); |
|
719 | + $count = get_transient($key); |
|
720 | 720 | } |
721 | 721 | |
722 | - if ( false === $count ) { |
|
723 | - $sales = new WP_Query( $args ); |
|
722 | + if (false === $count) { |
|
723 | + $sales = new WP_Query($args); |
|
724 | 724 | $count = (int) $sales->post_count; |
725 | 725 | // Cache the results for one hour |
726 | - set_transient( $key, $count, HOUR_IN_SECONDS ); |
|
726 | + set_transient($key, $count, HOUR_IN_SECONDS); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | return $count; |
@@ -738,14 +738,14 @@ discard block |
||
738 | 738 | * |
739 | 739 | * @return bool true if complete, false otherwise |
740 | 740 | */ |
741 | -function give_is_payment_complete( $payment_id ) { |
|
742 | - $payment = get_post( $payment_id ); |
|
741 | +function give_is_payment_complete($payment_id) { |
|
742 | + $payment = get_post($payment_id); |
|
743 | 743 | $ret = false; |
744 | - if ( $payment && $payment->post_status == 'publish' ) { |
|
744 | + if ($payment && $payment->post_status == 'publish') { |
|
745 | 745 | $ret = true; |
746 | 746 | } |
747 | 747 | |
748 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
748 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | /** |
@@ -769,29 +769,29 @@ discard block |
||
769 | 769 | */ |
770 | 770 | function give_get_total_earnings() { |
771 | 771 | |
772 | - $total = get_option( 'give_earnings_total', 0 ); |
|
772 | + $total = get_option('give_earnings_total', 0); |
|
773 | 773 | |
774 | 774 | // If no total stored in DB, use old method of calculating total earnings |
775 | - if ( ! $total ) { |
|
775 | + if ( ! $total) { |
|
776 | 776 | |
777 | 777 | global $wpdb; |
778 | 778 | |
779 | - $total = get_transient( 'give_earnings_total' ); |
|
779 | + $total = get_transient('give_earnings_total'); |
|
780 | 780 | |
781 | - if ( false === $total ) { |
|
781 | + if (false === $total) { |
|
782 | 782 | |
783 | 783 | $total = (float) 0; |
784 | 784 | |
785 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
785 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
786 | 786 | 'offset' => 0, |
787 | - 'number' => - 1, |
|
788 | - 'status' => array( 'publish', 'revoked' ), |
|
787 | + 'number' => -1, |
|
788 | + 'status' => array('publish', 'revoked'), |
|
789 | 789 | 'fields' => 'ids' |
790 | - ) ); |
|
790 | + )); |
|
791 | 791 | |
792 | 792 | |
793 | - $payments = give_get_payments( $args ); |
|
794 | - if ( $payments ) { |
|
793 | + $payments = give_get_payments($args); |
|
794 | + if ($payments) { |
|
795 | 795 | |
796 | 796 | /* |
797 | 797 | * If performing a purchase, we need to skip the very last payment in the database, since it calls |
@@ -799,30 +799,30 @@ discard block |
||
799 | 799 | * first purchase |
800 | 800 | */ |
801 | 801 | |
802 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
803 | - array_pop( $payments ); |
|
802 | + if (did_action('give_update_payment_status')) { |
|
803 | + array_pop($payments); |
|
804 | 804 | } |
805 | 805 | |
806 | - if ( ! empty( $payments ) ) { |
|
807 | - $payments = implode( ',', $payments ); |
|
808 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
806 | + if ( ! empty($payments)) { |
|
807 | + $payments = implode(',', $payments); |
|
808 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | } |
812 | 812 | |
813 | 813 | // Cache results for 1 day. This cache is cleared automatically when a payment is made |
814 | - set_transient( 'give_earnings_total', $total, 86400 ); |
|
814 | + set_transient('give_earnings_total', $total, 86400); |
|
815 | 815 | |
816 | 816 | // Store the total for the first time |
817 | - update_option( 'give_earnings_total', $total ); |
|
817 | + update_option('give_earnings_total', $total); |
|
818 | 818 | } |
819 | 819 | } |
820 | 820 | |
821 | - if ( $total < 0 ) { |
|
821 | + if ($total < 0) { |
|
822 | 822 | $total = 0; // Don't ever show negative earnings |
823 | 823 | } |
824 | 824 | |
825 | - return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) ); |
|
825 | + return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter())); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -834,10 +834,10 @@ discard block |
||
834 | 834 | * |
835 | 835 | * @return float $total Total earnings |
836 | 836 | */ |
837 | -function give_increase_total_earnings( $amount = 0 ) { |
|
837 | +function give_increase_total_earnings($amount = 0) { |
|
838 | 838 | $total = give_get_total_earnings(); |
839 | 839 | $total += $amount; |
840 | - update_option( 'give_earnings_total', $total ); |
|
840 | + update_option('give_earnings_total', $total); |
|
841 | 841 | |
842 | 842 | return $total; |
843 | 843 | } |
@@ -851,13 +851,13 @@ discard block |
||
851 | 851 | * |
852 | 852 | * @return float $total Total earnings |
853 | 853 | */ |
854 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
854 | +function give_decrease_total_earnings($amount = 0) { |
|
855 | 855 | $total = give_get_total_earnings(); |
856 | 856 | $total -= $amount; |
857 | - if ( $total < 0 ) { |
|
857 | + if ($total < 0) { |
|
858 | 858 | $total = 0; |
859 | 859 | } |
860 | - update_option( 'give_earnings_total', $total ); |
|
860 | + update_option('give_earnings_total', $total); |
|
861 | 861 | |
862 | 862 | return $total; |
863 | 863 | } |
@@ -873,28 +873,28 @@ discard block |
||
873 | 873 | * |
874 | 874 | * @return mixed $meta Payment Meta |
875 | 875 | */ |
876 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
876 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
877 | 877 | |
878 | - $meta = get_post_meta( $payment_id, $meta_key, $single ); |
|
878 | + $meta = get_post_meta($payment_id, $meta_key, $single); |
|
879 | 879 | |
880 | - if ( $meta_key === '_give_payment_meta' ) { |
|
880 | + if ($meta_key === '_give_payment_meta') { |
|
881 | 881 | |
882 | - if ( empty( $meta['key'] ) ) { |
|
883 | - $meta['key'] = give_get_payment_key( $payment_id ); |
|
882 | + if (empty($meta['key'])) { |
|
883 | + $meta['key'] = give_get_payment_key($payment_id); |
|
884 | 884 | } |
885 | 885 | |
886 | - if ( empty( $meta['email'] ) ) { |
|
887 | - $meta['email'] = give_get_payment_user_email( $payment_id ); |
|
886 | + if (empty($meta['email'])) { |
|
887 | + $meta['email'] = give_get_payment_user_email($payment_id); |
|
888 | 888 | } |
889 | 889 | |
890 | - if ( empty( $meta['date'] ) ) { |
|
891 | - $meta['date'] = get_post_field( 'post_date', $payment_id ); |
|
890 | + if (empty($meta['date'])) { |
|
891 | + $meta['date'] = get_post_field('post_date', $payment_id); |
|
892 | 892 | } |
893 | 893 | } |
894 | 894 | |
895 | - $meta = apply_filters( 'give_get_payment_meta_' . $meta_key, $meta, $payment_id ); |
|
895 | + $meta = apply_filters('give_get_payment_meta_'.$meta_key, $meta, $payment_id); |
|
896 | 896 | |
897 | - return apply_filters( 'give_get_payment_meta', $meta, $payment_id, $meta_key ); |
|
897 | + return apply_filters('give_get_payment_meta', $meta, $payment_id, $meta_key); |
|
898 | 898 | } |
899 | 899 | |
900 | 900 | /** |
@@ -907,26 +907,26 @@ discard block |
||
907 | 907 | * |
908 | 908 | * @return mixed Meta ID if successful, false if unsuccessful |
909 | 909 | */ |
910 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
910 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
911 | 911 | |
912 | - if ( empty( $payment_id ) || empty( $meta_key ) ) { |
|
912 | + if (empty($payment_id) || empty($meta_key)) { |
|
913 | 913 | return; |
914 | 914 | } |
915 | 915 | |
916 | - if ( $meta_key == 'key' || $meta_key == 'date' ) { |
|
916 | + if ($meta_key == 'key' || $meta_key == 'date') { |
|
917 | 917 | |
918 | - $current_meta = give_get_payment_meta( $payment_id ); |
|
919 | - $current_meta[ $meta_key ] = $meta_value; |
|
918 | + $current_meta = give_get_payment_meta($payment_id); |
|
919 | + $current_meta[$meta_key] = $meta_value; |
|
920 | 920 | |
921 | 921 | $meta_key = '_give_payment_meta'; |
922 | 922 | $meta_value = $current_meta; |
923 | 923 | |
924 | - } else if ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) { |
|
924 | + } else if ($meta_key == 'email' || $meta_key == '_give_payment_user_email') { |
|
925 | 925 | |
926 | - $meta_value = apply_filters( 'give_give_update_payment_meta_' . $meta_key, $meta_value, $payment_id ); |
|
927 | - update_post_meta( $payment_id, '_give_payment_user_email', $meta_value ); |
|
926 | + $meta_value = apply_filters('give_give_update_payment_meta_'.$meta_key, $meta_value, $payment_id); |
|
927 | + update_post_meta($payment_id, '_give_payment_user_email', $meta_value); |
|
928 | 928 | |
929 | - $current_meta = give_get_payment_meta( $payment_id ); |
|
929 | + $current_meta = give_get_payment_meta($payment_id); |
|
930 | 930 | $current_meta['user_info']['email'] = $meta_value; |
931 | 931 | |
932 | 932 | $meta_key = '_give_payment_meta'; |
@@ -934,9 +934,9 @@ discard block |
||
934 | 934 | |
935 | 935 | } |
936 | 936 | |
937 | - $meta_value = apply_filters( 'give_give_update_payment_meta_' . $meta_key, $meta_value, $payment_id ); |
|
937 | + $meta_value = apply_filters('give_give_update_payment_meta_'.$meta_key, $meta_value, $payment_id); |
|
938 | 938 | |
939 | - return update_post_meta( $payment_id, $meta_key, $meta_value, $prev_value ); |
|
939 | + return update_post_meta($payment_id, $meta_key, $meta_value, $prev_value); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | /** |
@@ -948,11 +948,11 @@ discard block |
||
948 | 948 | * |
949 | 949 | * @return array $user_info User Info Meta Values |
950 | 950 | */ |
951 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
952 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
953 | - $user_info = isset( $payment_meta['user_info'] ) ? maybe_unserialize( $payment_meta['user_info'] ) : false; |
|
951 | +function give_get_payment_meta_user_info($payment_id) { |
|
952 | + $payment_meta = give_get_payment_meta($payment_id); |
|
953 | + $user_info = isset($payment_meta['user_info']) ? maybe_unserialize($payment_meta['user_info']) : false; |
|
954 | 954 | |
955 | - return apply_filters( 'give_payment_meta_user_info', $user_info ); |
|
955 | + return apply_filters('give_payment_meta_user_info', $user_info); |
|
956 | 956 | } |
957 | 957 | |
958 | 958 | /** |
@@ -965,12 +965,12 @@ discard block |
||
965 | 965 | * |
966 | 966 | * @return int $form_id |
967 | 967 | */ |
968 | -function give_get_payment_form_id( $payment_id ) { |
|
969 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
968 | +function give_get_payment_form_id($payment_id) { |
|
969 | + $payment_meta = give_get_payment_meta($payment_id); |
|
970 | 970 | |
971 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
971 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
972 | 972 | |
973 | - return apply_filters( 'give_get_payment_form_id', $form_id ); |
|
973 | + return apply_filters('give_get_payment_form_id', $form_id); |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | /** |
@@ -982,10 +982,10 @@ discard block |
||
982 | 982 | * |
983 | 983 | * @return string $email User Email |
984 | 984 | */ |
985 | -function give_get_payment_user_email( $payment_id ) { |
|
986 | - $email = give_get_payment_meta( $payment_id, '_give_payment_user_email', true ); |
|
985 | +function give_get_payment_user_email($payment_id) { |
|
986 | + $email = give_get_payment_meta($payment_id, '_give_payment_user_email', true); |
|
987 | 987 | |
988 | - return apply_filters( 'give_payment_user_email', $email ); |
|
988 | + return apply_filters('give_payment_user_email', $email); |
|
989 | 989 | } |
990 | 990 | |
991 | 991 | /** |
@@ -997,11 +997,11 @@ discard block |
||
997 | 997 | * |
998 | 998 | * @return bool If the payment is associted with a user (false) or not (true) |
999 | 999 | */ |
1000 | -function give_is_guest_payment( $payment_id ) { |
|
1001 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
1002 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
1000 | +function give_is_guest_payment($payment_id) { |
|
1001 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
1002 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
1003 | 1003 | |
1004 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
1004 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | /** |
@@ -1013,38 +1013,38 @@ discard block |
||
1013 | 1013 | * |
1014 | 1014 | * @return string $user_id User ID |
1015 | 1015 | */ |
1016 | -function give_get_payment_user_id( $payment_id ) { |
|
1016 | +function give_get_payment_user_id($payment_id) { |
|
1017 | 1017 | |
1018 | 1018 | $user_id = - 1; |
1019 | 1019 | |
1020 | 1020 | // check the customer record first |
1021 | - $customer_id = give_get_payment_customer_id( $payment_id ); |
|
1022 | - $customer = new Give_Customer( $customer_id ); |
|
1021 | + $customer_id = give_get_payment_customer_id($payment_id); |
|
1022 | + $customer = new Give_Customer($customer_id); |
|
1023 | 1023 | |
1024 | - if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) { |
|
1024 | + if ( ! empty($customer->user_id) && $customer->user_id > 0) { |
|
1025 | 1025 | $user_id = $customer->user_id; |
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | // check the payment meta if we're still not finding a user with the customer record |
1029 | - if ( empty( $user_id ) || $user_id < 1 ) { |
|
1030 | - $payment_meta_user_id = give_get_payment_meta( $payment_id, '_give_payment_user_id', true ); |
|
1029 | + if (empty($user_id) || $user_id < 1) { |
|
1030 | + $payment_meta_user_id = give_get_payment_meta($payment_id, '_give_payment_user_id', true); |
|
1031 | 1031 | |
1032 | - if ( ! empty( $payment_meta_user_id ) ) { |
|
1032 | + if ( ! empty($payment_meta_user_id)) { |
|
1033 | 1033 | $user_id = $payment_meta_user_id; |
1034 | 1034 | } |
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | // Last ditch effort is to connect payment email with a user in the user table |
1038 | - if ( empty( $user_id ) || $user_id < 1 ) { |
|
1039 | - $payment_email = give_get_payment_user_email( $payment_id ); |
|
1040 | - $user = get_user_by( 'email', $payment_email ); |
|
1038 | + if (empty($user_id) || $user_id < 1) { |
|
1039 | + $payment_email = give_get_payment_user_email($payment_id); |
|
1040 | + $user = get_user_by('email', $payment_email); |
|
1041 | 1041 | |
1042 | - if ( false !== $user ) { |
|
1042 | + if (false !== $user) { |
|
1043 | 1043 | $user_id = $user->ID; |
1044 | 1044 | } |
1045 | 1045 | } |
1046 | 1046 | |
1047 | - return apply_filters( 'give_payment_user_id', (int) $user_id ); |
|
1047 | + return apply_filters('give_payment_user_id', (int) $user_id); |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | /** |
@@ -1056,10 +1056,10 @@ discard block |
||
1056 | 1056 | * |
1057 | 1057 | * @return string $donor_id Donor ID |
1058 | 1058 | */ |
1059 | -function give_get_payment_customer_id( $payment_id ) { |
|
1060 | - $customer_id = get_post_meta( $payment_id, '_give_payment_donor_id', true ); |
|
1059 | +function give_get_payment_customer_id($payment_id) { |
|
1060 | + $customer_id = get_post_meta($payment_id, '_give_payment_donor_id', true); |
|
1061 | 1061 | |
1062 | - return apply_filters( 'give_payment_donor_id', $customer_id ); |
|
1062 | + return apply_filters('give_payment_donor_id', $customer_id); |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | /** |
@@ -1071,10 +1071,10 @@ discard block |
||
1071 | 1071 | * |
1072 | 1072 | * @return string $ip User IP |
1073 | 1073 | */ |
1074 | -function give_get_payment_user_ip( $payment_id ) { |
|
1075 | - $ip = give_get_payment_meta( $payment_id, '_give_payment_user_ip', true ); |
|
1074 | +function give_get_payment_user_ip($payment_id) { |
|
1075 | + $ip = give_get_payment_meta($payment_id, '_give_payment_user_ip', true); |
|
1076 | 1076 | |
1077 | - return apply_filters( 'give_payment_user_ip', $ip ); |
|
1077 | + return apply_filters('give_payment_user_ip', $ip); |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | /** |
@@ -1086,17 +1086,17 @@ discard block |
||
1086 | 1086 | * |
1087 | 1087 | * @return string $date The date the payment was completed |
1088 | 1088 | */ |
1089 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
1089 | +function give_get_payment_completed_date($payment_id = 0) { |
|
1090 | 1090 | |
1091 | - $payment = get_post( $payment_id ); |
|
1091 | + $payment = get_post($payment_id); |
|
1092 | 1092 | |
1093 | - if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) { |
|
1093 | + if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) { |
|
1094 | 1094 | return false; // This payment was never completed |
1095 | 1095 | } |
1096 | 1096 | |
1097 | - $date = ( $date = give_get_payment_meta( $payment_id, '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
1097 | + $date = ($date = give_get_payment_meta($payment_id, '_give_completed_date', true)) ? $date : $payment->modified_date; |
|
1098 | 1098 | |
1099 | - return apply_filters( 'give_payment_completed_date', $date, $payment_id ); |
|
1099 | + return apply_filters('give_payment_completed_date', $date, $payment_id); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | /** |
@@ -1108,10 +1108,10 @@ discard block |
||
1108 | 1108 | * |
1109 | 1109 | * @return string $gateway Gateway |
1110 | 1110 | */ |
1111 | -function give_get_payment_gateway( $payment_id ) { |
|
1112 | - $gateway = give_get_payment_meta( $payment_id, '_give_payment_gateway', true ); |
|
1111 | +function give_get_payment_gateway($payment_id) { |
|
1112 | + $gateway = give_get_payment_meta($payment_id, '_give_payment_gateway', true); |
|
1113 | 1113 | |
1114 | - return apply_filters( 'give_payment_gateway', $gateway ); |
|
1114 | + return apply_filters('give_payment_gateway', $gateway); |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | /** |
@@ -1123,11 +1123,11 @@ discard block |
||
1123 | 1123 | * |
1124 | 1124 | * @return string $currency The currency code |
1125 | 1125 | */ |
1126 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
1127 | - $meta = give_get_payment_meta( $payment_id ); |
|
1128 | - $currency = isset( $meta['currency'] ) ? $meta['currency'] : give_get_currency(); |
|
1126 | +function give_get_payment_currency_code($payment_id = 0) { |
|
1127 | + $meta = give_get_payment_meta($payment_id); |
|
1128 | + $currency = isset($meta['currency']) ? $meta['currency'] : give_get_currency(); |
|
1129 | 1129 | |
1130 | - return apply_filters( 'give_payment_currency_code', $currency, $payment_id ); |
|
1130 | + return apply_filters('give_payment_currency_code', $currency, $payment_id); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | /** |
@@ -1139,10 +1139,10 @@ discard block |
||
1139 | 1139 | * |
1140 | 1140 | * @return string $currency The currency name |
1141 | 1141 | */ |
1142 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
1143 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
1142 | +function give_get_payment_currency($payment_id = 0) { |
|
1143 | + $currency = give_get_payment_currency_code($payment_id); |
|
1144 | 1144 | |
1145 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
1145 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | /** |
@@ -1154,10 +1154,10 @@ discard block |
||
1154 | 1154 | * |
1155 | 1155 | * @return string $key Purchase key |
1156 | 1156 | */ |
1157 | -function give_get_payment_key( $payment_id = 0 ) { |
|
1158 | - $key = give_get_payment_meta( $payment_id, '_give_payment_purchase_key', true ); |
|
1157 | +function give_get_payment_key($payment_id = 0) { |
|
1158 | + $key = give_get_payment_meta($payment_id, '_give_payment_purchase_key', true); |
|
1159 | 1159 | |
1160 | - return apply_filters( 'give_payment_key', $key, $payment_id ); |
|
1160 | + return apply_filters('give_payment_key', $key, $payment_id); |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | /** |
@@ -1171,15 +1171,15 @@ discard block |
||
1171 | 1171 | * |
1172 | 1172 | * @return string $number Payment order number |
1173 | 1173 | */ |
1174 | -function give_get_payment_number( $payment_id = 0 ) { |
|
1174 | +function give_get_payment_number($payment_id = 0) { |
|
1175 | 1175 | |
1176 | 1176 | $number = $payment_id; |
1177 | 1177 | |
1178 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
1178 | + if (give_get_option('enable_sequential')) { |
|
1179 | 1179 | |
1180 | - $number = give_get_payment_meta( $payment_id, '_give_payment_number', true ); |
|
1180 | + $number = give_get_payment_meta($payment_id, '_give_payment_number', true); |
|
1181 | 1181 | |
1182 | - if ( ! $number ) { |
|
1182 | + if ( ! $number) { |
|
1183 | 1183 | |
1184 | 1184 | $number = $payment_id; |
1185 | 1185 | |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | |
1188 | 1188 | } |
1189 | 1189 | |
1190 | - return apply_filters( 'give_payment_number', $number, $payment_id ); |
|
1190 | + return apply_filters('give_payment_number', $number, $payment_id); |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | /** |
@@ -1199,23 +1199,23 @@ discard block |
||
1199 | 1199 | * |
1200 | 1200 | * @return string The formatted payment number |
1201 | 1201 | */ |
1202 | -function give_format_payment_number( $number ) { |
|
1202 | +function give_format_payment_number($number) { |
|
1203 | 1203 | |
1204 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1204 | + if ( ! give_get_option('enable_sequential')) { |
|
1205 | 1205 | return $number; |
1206 | 1206 | } |
1207 | 1207 | |
1208 | - if ( ! is_numeric( $number ) ) { |
|
1208 | + if ( ! is_numeric($number)) { |
|
1209 | 1209 | return $number; |
1210 | 1210 | } |
1211 | 1211 | |
1212 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1213 | - $number = absint( $number ); |
|
1214 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1212 | + $prefix = give_get_option('sequential_prefix'); |
|
1213 | + $number = absint($number); |
|
1214 | + $postfix = give_get_option('sequential_postfix'); |
|
1215 | 1215 | |
1216 | - $formatted_number = $prefix . $number . $postfix; |
|
1216 | + $formatted_number = $prefix.$number.$postfix; |
|
1217 | 1217 | |
1218 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
1218 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
1219 | 1219 | } |
1220 | 1220 | |
1221 | 1221 | /** |
@@ -1228,17 +1228,17 @@ discard block |
||
1228 | 1228 | */ |
1229 | 1229 | function give_get_next_payment_number() { |
1230 | 1230 | |
1231 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1231 | + if ( ! give_get_option('enable_sequential')) { |
|
1232 | 1232 | return false; |
1233 | 1233 | } |
1234 | 1234 | |
1235 | - $number = get_option( 'give_last_payment_number' ); |
|
1236 | - $start = give_get_option( 'sequential_start', 1 ); |
|
1235 | + $number = get_option('give_last_payment_number'); |
|
1236 | + $start = give_get_option('sequential_start', 1); |
|
1237 | 1237 | $increment_number = true; |
1238 | 1238 | |
1239 | - if ( false !== $number ) { |
|
1239 | + if (false !== $number) { |
|
1240 | 1240 | |
1241 | - if ( empty( $number ) ) { |
|
1241 | + if (empty($number)) { |
|
1242 | 1242 | |
1243 | 1243 | $number = $start; |
1244 | 1244 | $increment_number = false; |
@@ -1248,24 +1248,24 @@ discard block |
||
1248 | 1248 | } else { |
1249 | 1249 | |
1250 | 1250 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason |
1251 | - $payments = new Give_Payments_Query( array( |
|
1251 | + $payments = new Give_Payments_Query(array( |
|
1252 | 1252 | 'number' => 1, |
1253 | 1253 | 'order' => 'DESC', |
1254 | 1254 | 'orderby' => 'ID', |
1255 | 1255 | 'output' => 'posts', |
1256 | 1256 | 'fields' => 'ids' |
1257 | - ) ); |
|
1257 | + )); |
|
1258 | 1258 | $last_payment = $payments->get_payments(); |
1259 | 1259 | |
1260 | - if ( $last_payment ) { |
|
1260 | + if ($last_payment) { |
|
1261 | 1261 | |
1262 | - $number = give_get_payment_number( $last_payment[0] ); |
|
1262 | + $number = give_get_payment_number($last_payment[0]); |
|
1263 | 1263 | |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - if ( ! empty( $number ) && $number !== $last_payment[0] ) { |
|
1266 | + if ( ! empty($number) && $number !== $last_payment[0]) { |
|
1267 | 1267 | |
1268 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
1268 | + $number = give_remove_payment_prefix_postfix($number); |
|
1269 | 1269 | |
1270 | 1270 | } else { |
1271 | 1271 | |
@@ -1275,13 +1275,13 @@ discard block |
||
1275 | 1275 | |
1276 | 1276 | } |
1277 | 1277 | |
1278 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
1278 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
1279 | 1279 | |
1280 | - if ( $increment_number ) { |
|
1281 | - $number ++; |
|
1280 | + if ($increment_number) { |
|
1281 | + $number++; |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
1284 | + return apply_filters('give_get_next_payment_number', $number); |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | /** |
@@ -1293,25 +1293,25 @@ discard block |
||
1293 | 1293 | * |
1294 | 1294 | * @return string The new Payment number without prefix and postfix |
1295 | 1295 | */ |
1296 | -function give_remove_payment_prefix_postfix( $number ) { |
|
1296 | +function give_remove_payment_prefix_postfix($number) { |
|
1297 | 1297 | |
1298 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1299 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1298 | + $prefix = give_get_option('sequential_prefix'); |
|
1299 | + $postfix = give_get_option('sequential_postfix'); |
|
1300 | 1300 | |
1301 | 1301 | // Remove prefix |
1302 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
1302 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
1303 | 1303 | |
1304 | 1304 | // Remove the postfix |
1305 | - $length = strlen( $number ); |
|
1306 | - $postfix_pos = strrpos( $number, $postfix ); |
|
1307 | - if ( false !== $postfix_pos ) { |
|
1308 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
1305 | + $length = strlen($number); |
|
1306 | + $postfix_pos = strrpos($number, $postfix); |
|
1307 | + if (false !== $postfix_pos) { |
|
1308 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
1309 | 1309 | } |
1310 | 1310 | |
1311 | 1311 | // Ensure it's a whole number |
1312 | - $number = intval( $number ); |
|
1312 | + $number = intval($number); |
|
1313 | 1313 | |
1314 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
1314 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
1315 | 1315 | |
1316 | 1316 | } |
1317 | 1317 | |
@@ -1327,10 +1327,10 @@ discard block |
||
1327 | 1327 | * |
1328 | 1328 | * @return string $amount Fully formatted payment amount |
1329 | 1329 | */ |
1330 | -function give_payment_amount( $payment_id = 0 ) { |
|
1331 | - $amount = give_get_payment_amount( $payment_id ); |
|
1330 | +function give_payment_amount($payment_id = 0) { |
|
1331 | + $amount = give_get_payment_amount($payment_id); |
|
1332 | 1332 | |
1333 | - return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) ); |
|
1333 | + return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id)); |
|
1334 | 1334 | } |
1335 | 1335 | |
1336 | 1336 | /** |
@@ -1343,20 +1343,20 @@ discard block |
||
1343 | 1343 | * |
1344 | 1344 | * @return mixed|void |
1345 | 1345 | */ |
1346 | -function give_get_payment_amount( $payment_id ) { |
|
1346 | +function give_get_payment_amount($payment_id) { |
|
1347 | 1347 | |
1348 | - $amount = give_get_payment_meta( $payment_id, '_give_payment_total', true ); |
|
1348 | + $amount = give_get_payment_meta($payment_id, '_give_payment_total', true); |
|
1349 | 1349 | |
1350 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
1351 | - $meta = give_get_payment_meta( $payment_id, '_give_payment_meta', true ); |
|
1352 | - $meta = maybe_unserialize( $meta ); |
|
1350 | + if (empty($amount) && '0.00' != $amount) { |
|
1351 | + $meta = give_get_payment_meta($payment_id, '_give_payment_meta', true); |
|
1352 | + $meta = maybe_unserialize($meta); |
|
1353 | 1353 | |
1354 | - if ( isset( $meta['amount'] ) ) { |
|
1354 | + if (isset($meta['amount'])) { |
|
1355 | 1355 | $amount = $meta['amount']; |
1356 | 1356 | } |
1357 | 1357 | } |
1358 | 1358 | |
1359 | - return apply_filters( 'give_payment_amount', floatval( $amount ), $payment_id ); |
|
1359 | + return apply_filters('give_payment_amount', floatval($amount), $payment_id); |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | |
@@ -1369,19 +1369,19 @@ discard block |
||
1369 | 1369 | * |
1370 | 1370 | * @return string The Transaction ID |
1371 | 1371 | */ |
1372 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
1372 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
1373 | 1373 | |
1374 | 1374 | $transaction_id = false; |
1375 | - $transaction_id = give_get_payment_meta( $payment_id, '_give_payment_transaction_id', true ); |
|
1375 | + $transaction_id = give_get_payment_meta($payment_id, '_give_payment_transaction_id', true); |
|
1376 | 1376 | |
1377 | - if ( empty( $transaction_id ) ) { |
|
1377 | + if (empty($transaction_id)) { |
|
1378 | 1378 | |
1379 | - $gateway = give_get_payment_gateway( $payment_id ); |
|
1380 | - $transaction_id = apply_filters( 'give_get_payment_transaction_id-' . $gateway, $payment_id ); |
|
1379 | + $gateway = give_get_payment_gateway($payment_id); |
|
1380 | + $transaction_id = apply_filters('give_get_payment_transaction_id-'.$gateway, $payment_id); |
|
1381 | 1381 | |
1382 | 1382 | } |
1383 | 1383 | |
1384 | - return apply_filters( 'give_get_payment_transaction_id', $transaction_id, $payment_id ); |
|
1384 | + return apply_filters('give_get_payment_transaction_id', $transaction_id, $payment_id); |
|
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | /** |
@@ -1394,15 +1394,15 @@ discard block |
||
1394 | 1394 | * |
1395 | 1395 | * @return bool|mixed |
1396 | 1396 | */ |
1397 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
1397 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
1398 | 1398 | |
1399 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
1399 | + if (empty($payment_id) || empty($transaction_id)) { |
|
1400 | 1400 | return false; |
1401 | 1401 | } |
1402 | 1402 | |
1403 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
1403 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
1404 | 1404 | |
1405 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
1405 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
1406 | 1406 | } |
1407 | 1407 | |
1408 | 1408 | /** |
@@ -1416,12 +1416,12 @@ discard block |
||
1416 | 1416 | * |
1417 | 1417 | * @return int $purchase Purchase ID |
1418 | 1418 | */ |
1419 | -function give_get_purchase_id_by_key( $key ) { |
|
1419 | +function give_get_purchase_id_by_key($key) { |
|
1420 | 1420 | global $wpdb; |
1421 | 1421 | |
1422 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1422 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key)); |
|
1423 | 1423 | |
1424 | - if ( $purchase != null ) { |
|
1424 | + if ($purchase != null) { |
|
1425 | 1425 | return $purchase; |
1426 | 1426 | } |
1427 | 1427 | |
@@ -1440,12 +1440,12 @@ discard block |
||
1440 | 1440 | * |
1441 | 1441 | * @return int $purchase Purchase ID |
1442 | 1442 | */ |
1443 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
1443 | +function give_get_purchase_id_by_transaction_id($key) { |
|
1444 | 1444 | global $wpdb; |
1445 | 1445 | |
1446 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
1446 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
1447 | 1447 | |
1448 | - if ( $purchase != null ) { |
|
1448 | + if ($purchase != null) { |
|
1449 | 1449 | return $purchase; |
1450 | 1450 | } |
1451 | 1451 | |
@@ -1462,19 +1462,19 @@ discard block |
||
1462 | 1462 | * |
1463 | 1463 | * @return array $notes Payment Notes |
1464 | 1464 | */ |
1465 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
1465 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
1466 | 1466 | |
1467 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
1467 | + if (empty($payment_id) && empty($search)) { |
|
1468 | 1468 | return false; |
1469 | 1469 | } |
1470 | 1470 | |
1471 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1472 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1471 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1472 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1473 | 1473 | |
1474 | - $notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) ); |
|
1474 | + $notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search)); |
|
1475 | 1475 | |
1476 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1477 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1476 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1477 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1478 | 1478 | |
1479 | 1479 | return $notes; |
1480 | 1480 | } |
@@ -1490,19 +1490,19 @@ discard block |
||
1490 | 1490 | * |
1491 | 1491 | * @return int The new note ID |
1492 | 1492 | */ |
1493 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
1494 | - if ( empty( $payment_id ) ) { |
|
1493 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
1494 | + if (empty($payment_id)) { |
|
1495 | 1495 | return false; |
1496 | 1496 | } |
1497 | 1497 | |
1498 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
1498 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
1499 | 1499 | |
1500 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
1500 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
1501 | 1501 | 'comment_post_ID' => $payment_id, |
1502 | 1502 | 'comment_content' => $note, |
1503 | 1503 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1504 | - 'comment_date' => current_time( 'mysql' ), |
|
1505 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1504 | + 'comment_date' => current_time('mysql'), |
|
1505 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1506 | 1506 | 'comment_approved' => 1, |
1507 | 1507 | 'comment_parent' => 0, |
1508 | 1508 | 'comment_author' => '', |
@@ -1511,9 +1511,9 @@ discard block |
||
1511 | 1511 | 'comment_author_email' => '', |
1512 | 1512 | 'comment_type' => 'give_payment_note' |
1513 | 1513 | |
1514 | - ) ) ); |
|
1514 | + ))); |
|
1515 | 1515 | |
1516 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
1516 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
1517 | 1517 | |
1518 | 1518 | return $note_id; |
1519 | 1519 | } |
@@ -1528,14 +1528,14 @@ discard block |
||
1528 | 1528 | * |
1529 | 1529 | * @return bool True on success, false otherwise |
1530 | 1530 | */ |
1531 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
1532 | - if ( empty( $comment_id ) ) { |
|
1531 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
1532 | + if (empty($comment_id)) { |
|
1533 | 1533 | return false; |
1534 | 1534 | } |
1535 | 1535 | |
1536 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
1537 | - $ret = wp_delete_comment( $comment_id, true ); |
|
1538 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
1536 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
1537 | + $ret = wp_delete_comment($comment_id, true); |
|
1538 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
1539 | 1539 | |
1540 | 1540 | return $ret; |
1541 | 1541 | } |
@@ -1550,32 +1550,32 @@ discard block |
||
1550 | 1550 | * |
1551 | 1551 | * @return string |
1552 | 1552 | */ |
1553 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
1553 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
1554 | 1554 | |
1555 | - if ( is_numeric( $note ) ) { |
|
1556 | - $note = get_comment( $note ); |
|
1555 | + if (is_numeric($note)) { |
|
1556 | + $note = get_comment($note); |
|
1557 | 1557 | } |
1558 | 1558 | |
1559 | - if ( ! empty( $note->user_id ) ) { |
|
1560 | - $user = get_userdata( $note->user_id ); |
|
1559 | + if ( ! empty($note->user_id)) { |
|
1560 | + $user = get_userdata($note->user_id); |
|
1561 | 1561 | $user = $user->display_name; |
1562 | 1562 | } else { |
1563 | - $user = __( 'System', 'give' ); |
|
1563 | + $user = __('System', 'give'); |
|
1564 | 1564 | } |
1565 | 1565 | |
1566 | - $date_format = get_option( 'date_format' ) . ', ' . get_option( 'time_format' ); |
|
1566 | + $date_format = get_option('date_format').', '.get_option('time_format'); |
|
1567 | 1567 | |
1568 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
1568 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
1569 | 1569 | 'give-action' => 'delete_payment_note', |
1570 | 1570 | 'note_id' => $note->comment_ID, |
1571 | 1571 | 'payment_id' => $payment_id |
1572 | - ) ), 'give_delete_payment_note_' . $note->comment_ID ); |
|
1572 | + )), 'give_delete_payment_note_'.$note->comment_ID); |
|
1573 | 1573 | |
1574 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
1574 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
1575 | 1575 | $note_html .= '<p>'; |
1576 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
1576 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
1577 | 1577 | $note_html .= $note->comment_content; |
1578 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" title="' . __( 'Delete this payment note', 'give' ) . '">' . __( 'Delete', 'give' ) . '</a>'; |
|
1578 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" title="'.__('Delete this payment note', 'give').'">'.__('Delete', 'give').'</a>'; |
|
1579 | 1579 | $note_html .= '</p>'; |
1580 | 1580 | $note_html .= '</div>'; |
1581 | 1581 | |
@@ -1593,20 +1593,20 @@ discard block |
||
1593 | 1593 | * |
1594 | 1594 | * @return void |
1595 | 1595 | */ |
1596 | -function give_hide_payment_notes( $query ) { |
|
1596 | +function give_hide_payment_notes($query) { |
|
1597 | 1597 | global $wp_version; |
1598 | 1598 | |
1599 | - if ( version_compare( floatval( $wp_version ), '4.1', '>=' ) ) { |
|
1600 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
1601 | - if ( ! is_array( $types ) ) { |
|
1602 | - $types = array( $types ); |
|
1599 | + if (version_compare(floatval($wp_version), '4.1', '>=')) { |
|
1600 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
1601 | + if ( ! is_array($types)) { |
|
1602 | + $types = array($types); |
|
1603 | 1603 | } |
1604 | 1604 | $types[] = 'give_payment_note'; |
1605 | 1605 | $query->query_vars['type__not_in'] = $types; |
1606 | 1606 | } |
1607 | 1607 | } |
1608 | 1608 | |
1609 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1609 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1610 | 1610 | |
1611 | 1611 | /** |
1612 | 1612 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1618,17 +1618,17 @@ discard block |
||
1618 | 1618 | * |
1619 | 1619 | * @return array $clauses Updated comment clauses |
1620 | 1620 | */ |
1621 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
1621 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
1622 | 1622 | global $wpdb, $wp_version; |
1623 | 1623 | |
1624 | - if ( version_compare( floatval( $wp_version ), '4.1', '<' ) ) { |
|
1624 | + if (version_compare(floatval($wp_version), '4.1', '<')) { |
|
1625 | 1625 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
1626 | 1626 | } |
1627 | 1627 | |
1628 | 1628 | return $clauses; |
1629 | 1629 | } |
1630 | 1630 | |
1631 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1631 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1632 | 1632 | |
1633 | 1633 | |
1634 | 1634 | /** |
@@ -1641,15 +1641,15 @@ discard block |
||
1641 | 1641 | * |
1642 | 1642 | * @return array $where |
1643 | 1643 | */ |
1644 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
1644 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
1645 | 1645 | global $wpdb; |
1646 | 1646 | |
1647 | - $where .= $wpdb->prepare( " AND comment_type != %s", 'give_payment_note' ); |
|
1647 | + $where .= $wpdb->prepare(" AND comment_type != %s", 'give_payment_note'); |
|
1648 | 1648 | |
1649 | 1649 | return $where; |
1650 | 1650 | } |
1651 | 1651 | |
1652 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
1652 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
1653 | 1653 | |
1654 | 1654 | |
1655 | 1655 | /** |
@@ -1663,32 +1663,32 @@ discard block |
||
1663 | 1663 | * |
1664 | 1664 | * @return array Array of comment counts |
1665 | 1665 | */ |
1666 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
1666 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
1667 | 1667 | global $wpdb, $pagenow; |
1668 | 1668 | |
1669 | - if ( 'index.php' != $pagenow ) { |
|
1669 | + if ('index.php' != $pagenow) { |
|
1670 | 1670 | return $stats; |
1671 | 1671 | } |
1672 | 1672 | |
1673 | 1673 | $post_id = (int) $post_id; |
1674 | 1674 | |
1675 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
1675 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
1676 | 1676 | return $stats; |
1677 | 1677 | } |
1678 | 1678 | |
1679 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
1679 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1680 | 1680 | |
1681 | - if ( false !== $stats ) { |
|
1681 | + if (false !== $stats) { |
|
1682 | 1682 | return $stats; |
1683 | 1683 | } |
1684 | 1684 | |
1685 | 1685 | $where = 'WHERE comment_type != "give_payment_note"'; |
1686 | 1686 | |
1687 | - if ( $post_id > 0 ) { |
|
1688 | - $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
1687 | + if ($post_id > 0) { |
|
1688 | + $where .= $wpdb->prepare(" AND comment_post_ID = %d", $post_id); |
|
1689 | 1689 | } |
1690 | 1690 | |
1691 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1691 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1692 | 1692 | |
1693 | 1693 | $total = 0; |
1694 | 1694 | $approved = array( |
@@ -1698,30 +1698,30 @@ discard block |
||
1698 | 1698 | 'trash' => 'trash', |
1699 | 1699 | 'post-trashed' => 'post-trashed' |
1700 | 1700 | ); |
1701 | - foreach ( (array) $count as $row ) { |
|
1701 | + foreach ((array) $count as $row) { |
|
1702 | 1702 | // Don't count post-trashed toward totals |
1703 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1703 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
1704 | 1704 | $total += $row['num_comments']; |
1705 | 1705 | } |
1706 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
1707 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
1706 | + if (isset($approved[$row['comment_approved']])) { |
|
1707 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1708 | 1708 | } |
1709 | 1709 | } |
1710 | 1710 | |
1711 | 1711 | $stats['total_comments'] = $total; |
1712 | - foreach ( $approved as $key ) { |
|
1713 | - if ( empty( $stats[ $key ] ) ) { |
|
1714 | - $stats[ $key ] = 0; |
|
1712 | + foreach ($approved as $key) { |
|
1713 | + if (empty($stats[$key])) { |
|
1714 | + $stats[$key] = 0; |
|
1715 | 1715 | } |
1716 | 1716 | } |
1717 | 1717 | |
1718 | 1718 | $stats = (object) $stats; |
1719 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
1719 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1720 | 1720 | |
1721 | 1721 | return $stats; |
1722 | 1722 | } |
1723 | 1723 | |
1724 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
1724 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
1725 | 1725 | |
1726 | 1726 | |
1727 | 1727 | /** |
@@ -1734,9 +1734,9 @@ discard block |
||
1734 | 1734 | * |
1735 | 1735 | * @return string $where Modified where clause |
1736 | 1736 | */ |
1737 | -function give_filter_where_older_than_week( $where = '' ) { |
|
1737 | +function give_filter_where_older_than_week($where = '') { |
|
1738 | 1738 | // Payments older than one week |
1739 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
1739 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
1740 | 1740 | $where .= " AND post_date <= '{$start}'"; |
1741 | 1741 | |
1742 | 1742 | return $where; |
@@ -1753,20 +1753,20 @@ discard block |
||
1753 | 1753 | * |
1754 | 1754 | * @return string $price_id |
1755 | 1755 | */ |
1756 | -function give_get_price_id( $form_id, $price ) { |
|
1756 | +function give_get_price_id($form_id, $price) { |
|
1757 | 1757 | |
1758 | 1758 | $price_id = 0; |
1759 | 1759 | |
1760 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1760 | + if (give_has_variable_prices($form_id)) { |
|
1761 | 1761 | |
1762 | - $levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
1762 | + $levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
1763 | 1763 | |
1764 | - foreach ( $levels as $level ) { |
|
1764 | + foreach ($levels as $level) { |
|
1765 | 1765 | |
1766 | - $level_amount = (float) give_sanitize_amount( $level['_give_amount'] ); |
|
1766 | + $level_amount = (float) give_sanitize_amount($level['_give_amount']); |
|
1767 | 1767 | |
1768 | 1768 | //check that this indeed the recurring price |
1769 | - if ( $level_amount == $price ) { |
|
1769 | + if ($level_amount == $price) { |
|
1770 | 1770 | |
1771 | 1771 | $price_id = $level['_give_id']['level_id']; |
1772 | 1772 | |
@@ -1790,14 +1790,14 @@ discard block |
||
1790 | 1790 | * |
1791 | 1791 | * @return mixed array if payment fees found, false otherwise |
1792 | 1792 | */ |
1793 | -function give_get_payment_fees( $payment_id = 0, $type = 'all' ) { |
|
1794 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
1793 | +function give_get_payment_fees($payment_id = 0, $type = 'all') { |
|
1794 | + $payment_meta = give_get_payment_meta($payment_id); |
|
1795 | 1795 | $fees = array(); |
1796 | - $payment_fees = isset( $payment_meta['fees'] ) ? $payment_meta['fees'] : false; |
|
1797 | - if ( ! empty( $payment_fees ) && is_array( $payment_fees ) ) { |
|
1798 | - foreach ( $payment_fees as $fee_id => $fee ) { |
|
1799 | - if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
1800 | - unset( $payment_fees[ $fee_id ] ); |
|
1796 | + $payment_fees = isset($payment_meta['fees']) ? $payment_meta['fees'] : false; |
|
1797 | + if ( ! empty($payment_fees) && is_array($payment_fees)) { |
|
1798 | + foreach ($payment_fees as $fee_id => $fee) { |
|
1799 | + if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) { |
|
1800 | + unset($payment_fees[$fee_id]); |
|
1801 | 1801 | } else { |
1802 | 1802 | $fees[] = array( |
1803 | 1803 | 'id' => $fee_id, |
@@ -1808,5 +1808,5 @@ discard block |
||
1808 | 1808 | } |
1809 | 1809 | } |
1810 | 1810 | |
1811 | - return apply_filters( 'give_get_payment_fees', $fees, $payment_id ); |
|
1811 | + return apply_filters('give_get_payment_fees', $fees, $payment_id); |
|
1812 | 1812 | } |
1813 | 1813 | \ No newline at end of file |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @access private |
23 | 23 | * @since 1.0 |
24 | - * @return void |
|
24 | + * @return false|null |
|
25 | 25 | */ |
26 | 26 | function give_process_purchase_form() { |
27 | 27 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @since 1.0.1 |
328 | 328 | * |
329 | - * @param $payment_mode |
|
329 | + * @param string $payment_mode |
|
330 | 330 | * |
331 | 331 | * @return mixed|void |
332 | 332 | */ |
@@ -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,34 +25,34 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_process_purchase_form() { |
27 | 27 | |
28 | - do_action( 'give_pre_process_purchase' ); |
|
28 | + do_action('give_pre_process_purchase'); |
|
29 | 29 | |
30 | 30 | // Validate the form $_POST data |
31 | 31 | $valid_data = give_purchase_form_validate_fields(); |
32 | 32 | |
33 | 33 | // Allow themes and plugins to hook to errors |
34 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
34 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
35 | 35 | |
36 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
36 | + $is_ajax = isset($_POST['give_ajax']); |
|
37 | 37 | |
38 | 38 | // Process the login form |
39 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
39 | + if (isset($_POST['give_login_submit'])) { |
|
40 | 40 | give_process_form_login(); |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Validate the user |
44 | - $user = give_get_purchase_form_user( $valid_data ); |
|
44 | + $user = give_get_purchase_form_user($valid_data); |
|
45 | 45 | |
46 | - if ( give_get_errors() || ! $user ) { |
|
47 | - if ( $is_ajax ) { |
|
48 | - do_action( 'give_ajax_checkout_errors' ); |
|
46 | + if (give_get_errors() || ! $user) { |
|
47 | + if ($is_ajax) { |
|
48 | + do_action('give_ajax_checkout_errors'); |
|
49 | 49 | give_die(); |
50 | 50 | } else { |
51 | 51 | return false; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - if ( $is_ajax ) { |
|
55 | + if ($is_ajax) { |
|
56 | 56 | echo 'success'; |
57 | 57 | give_die(); |
58 | 58 | } |
@@ -66,15 +66,15 @@ discard block |
||
66 | 66 | 'address' => $user['address'] |
67 | 67 | ); |
68 | 68 | |
69 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
69 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
70 | 70 | |
71 | 71 | // Setup purchase information |
72 | 72 | $purchase_data = array( |
73 | - 'price' => ( isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00' ), |
|
74 | - 'purchase_key' => strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ), |
|
73 | + 'price' => (isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'), |
|
74 | + 'purchase_key' => strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))), |
|
75 | 75 | 'user_email' => $user['user_email'], |
76 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
77 | - 'user_info' => stripslashes_deep( $user_info ), |
|
76 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
77 | + 'user_info' => stripslashes_deep($user_info), |
|
78 | 78 | 'post_data' => $_POST, |
79 | 79 | 'gateway' => $valid_data['gateway'], |
80 | 80 | 'card_info' => $valid_data['cc_info'] |
@@ -84,36 +84,36 @@ discard block |
||
84 | 84 | $valid_data['user'] = $user; |
85 | 85 | |
86 | 86 | // Allow themes and plugins to hook before the gateway |
87 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
87 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
88 | 88 | |
89 | 89 | |
90 | - if ( ! $purchase_data['price'] ) { |
|
90 | + if ( ! $purchase_data['price']) { |
|
91 | 91 | // Revert to manual |
92 | 92 | $purchase_data['gateway'] = 'manual'; |
93 | 93 | $_POST['give-gateway'] = 'manual'; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Allow the purchase data to be modified before it is sent to the gateway |
97 | - $purchase_data = apply_filters( 'give_purchase_data_before_gateway', $purchase_data, $valid_data ); |
|
97 | + $purchase_data = apply_filters('give_purchase_data_before_gateway', $purchase_data, $valid_data); |
|
98 | 98 | |
99 | 99 | // Setup the data we're storing in the purchase session |
100 | 100 | $session_data = $purchase_data; |
101 | 101 | |
102 | 102 | // Make sure credit card numbers are never stored in sessions |
103 | - unset( $session_data['card_info']['card_number'] ); |
|
103 | + unset($session_data['card_info']['card_number']); |
|
104 | 104 | |
105 | 105 | // Used for showing data to non logged-in users after purchase, and for other plugins needing purchase data. |
106 | - give_set_purchase_session( $session_data ); |
|
106 | + give_set_purchase_session($session_data); |
|
107 | 107 | |
108 | 108 | // Send info to the gateway for payment processing |
109 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data ); |
|
109 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data); |
|
110 | 110 | give_die(); |
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | -add_action( 'give_purchase', 'give_process_purchase_form' ); |
|
115 | -add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' ); |
|
116 | -add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' ); |
|
114 | +add_action('give_purchase', 'give_process_purchase_form'); |
|
115 | +add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form'); |
|
116 | +add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form'); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Process the checkout login form |
@@ -124,32 +124,32 @@ discard block |
||
124 | 124 | */ |
125 | 125 | function give_process_form_login() { |
126 | 126 | |
127 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
127 | + $is_ajax = isset($_POST['give_ajax']); |
|
128 | 128 | |
129 | 129 | $user_data = give_purchase_form_validate_user_login(); |
130 | 130 | |
131 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
132 | - if ( $is_ajax ) { |
|
133 | - do_action( 'give_ajax_checkout_errors' ); |
|
131 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
132 | + if ($is_ajax) { |
|
133 | + do_action('give_ajax_checkout_errors'); |
|
134 | 134 | give_die(); |
135 | 135 | } else { |
136 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
136 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
137 | 137 | exit; |
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
141 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
142 | 142 | |
143 | - if ( $is_ajax ) { |
|
143 | + if ($is_ajax) { |
|
144 | 144 | echo 'success'; |
145 | 145 | give_die(); |
146 | 146 | } else { |
147 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
147 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | -add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' ); |
|
152 | -add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' ); |
|
151 | +add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login'); |
|
152 | +add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login'); |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Purchase Form Validate Fields |
@@ -163,43 +163,43 @@ discard block |
||
163 | 163 | global $give_options; |
164 | 164 | |
165 | 165 | // Check if there is $_POST |
166 | - if ( empty( $_POST ) ) { |
|
166 | + if (empty($_POST)) { |
|
167 | 167 | return false; |
168 | 168 | } |
169 | 169 | |
170 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
170 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
171 | 171 | |
172 | 172 | // Start an array to collect valid data |
173 | 173 | $valid_data = array( |
174 | 174 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback |
175 | - 'need_new_user' => false, // New user flag |
|
176 | - 'need_user_login' => false, // Login user flag |
|
177 | - 'logged_user_data' => array(), // Logged user collected data |
|
178 | - 'new_user_data' => array(), // New user collected data |
|
179 | - 'login_user_data' => array(), // Login user collected data |
|
180 | - 'guest_user_data' => array(), // Guest user collected data |
|
175 | + 'need_new_user' => false, // New user flag |
|
176 | + 'need_user_login' => false, // Login user flag |
|
177 | + 'logged_user_data' => array(), // Logged user collected data |
|
178 | + 'new_user_data' => array(), // New user collected data |
|
179 | + 'login_user_data' => array(), // Login user collected data |
|
180 | + 'guest_user_data' => array(), // Guest user collected data |
|
181 | 181 | 'cc_info' => give_purchase_form_validate_cc() // Credit card info |
182 | 182 | ); |
183 | 183 | |
184 | 184 | // Validate agree to terms |
185 | - $terms_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
186 | - if ( isset( $terms_option ) && $terms_option === 'yes' ) { |
|
185 | + $terms_option = get_post_meta($form_id, '_give_terms_option', true); |
|
186 | + if (isset($terms_option) && $terms_option === 'yes') { |
|
187 | 187 | give_purchase_form_validate_agree_to_terms(); |
188 | 188 | } |
189 | 189 | |
190 | 190 | //Validate amount is more than 0 |
191 | 191 | |
192 | 192 | |
193 | - if ( is_user_logged_in() ) { |
|
193 | + if (is_user_logged_in()) { |
|
194 | 194 | // Collect logged in user data |
195 | 195 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user(); |
196 | - } else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
196 | + } else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
197 | 197 | // Set new user registration as required |
198 | 198 | $valid_data['need_new_user'] = true; |
199 | 199 | // Validate new user data |
200 | 200 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user(); |
201 | 201 | // Check if login validation is needed |
202 | - } else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
202 | + } else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
203 | 203 | // Set user login as required |
204 | 204 | $valid_data['need_user_login'] = true; |
205 | 205 | // Validate users login info |
@@ -222,27 +222,27 @@ discard block |
||
222 | 222 | */ |
223 | 223 | function give_purchase_form_validate_gateway() { |
224 | 224 | |
225 | - $gateway = give_get_default_gateway( $_REQUEST['give-form-id'] ); |
|
225 | + $gateway = give_get_default_gateway($_REQUEST['give-form-id']); |
|
226 | 226 | |
227 | 227 | // Check if a gateway value is present |
228 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
228 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
229 | 229 | |
230 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
230 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
231 | 231 | |
232 | 232 | //Is amount being donated in LIVE mode above 0.00? |
233 | - if ( '0.00' == $_REQUEST['give-amount'] && ! give_is_test_mode() ) { |
|
233 | + if ('0.00' == $_REQUEST['give-amount'] && ! give_is_test_mode()) { |
|
234 | 234 | |
235 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
235 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
236 | 236 | |
237 | 237 | } //Is this test mode zero donation? Let it through but set to manual gateway |
238 | - elseif ( '0.00' == $_REQUEST['give-amount'] && give_is_test_mode() ) { |
|
238 | + elseif ('0.00' == $_REQUEST['give-amount'] && give_is_test_mode()) { |
|
239 | 239 | |
240 | 240 | $gateway = 'manual'; |
241 | 241 | |
242 | 242 | } //Check if this gateway is active |
243 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
243 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
244 | 244 | |
245 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled', 'give' ) ); |
|
245 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled', 'give')); |
|
246 | 246 | |
247 | 247 | } |
248 | 248 | |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | */ |
262 | 262 | function give_purchase_form_validate_agree_to_terms() { |
263 | 263 | // Validate agree to terms |
264 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
264 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
265 | 265 | // User did not agree |
266 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms of use', 'give' ) ) ); |
|
266 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms of use', 'give'))); |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
@@ -277,47 +277,47 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return array |
279 | 279 | */ |
280 | -function give_purchase_form_required_fields( $form_id ) { |
|
280 | +function give_purchase_form_required_fields($form_id) { |
|
281 | 281 | |
282 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
282 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
283 | 283 | |
284 | 284 | $required_fields = array( |
285 | 285 | 'give_email' => array( |
286 | 286 | 'error_id' => 'invalid_email', |
287 | - 'error_message' => __( 'Please enter a valid email address', 'give' ) |
|
287 | + 'error_message' => __('Please enter a valid email address', 'give') |
|
288 | 288 | ), |
289 | 289 | 'give_first' => array( |
290 | 290 | 'error_id' => 'invalid_first_name', |
291 | - 'error_message' => __( 'Please enter your first name', 'give' ) |
|
291 | + 'error_message' => __('Please enter your first name', 'give') |
|
292 | 292 | ) |
293 | 293 | ); |
294 | 294 | |
295 | - $require_address = give_require_billing_address( $payment_mode ); |
|
295 | + $require_address = give_require_billing_address($payment_mode); |
|
296 | 296 | |
297 | - if ( $require_address ) { |
|
298 | - $required_fields['card_address'] = array( |
|
297 | + if ($require_address) { |
|
298 | + $required_fields['card_address'] = array( |
|
299 | 299 | 'error_id' => 'invalid_card_address', |
300 | - 'error_message' => __( 'Please enter your primary billing address', 'give' ) |
|
300 | + 'error_message' => __('Please enter your primary billing address', 'give') |
|
301 | 301 | ); |
302 | - $required_fields['card_zip'] = array( |
|
302 | + $required_fields['card_zip'] = array( |
|
303 | 303 | 'error_id' => 'invalid_zip_code', |
304 | - 'error_message' => __( 'Please enter your zip / postal code', 'give' ) |
|
304 | + 'error_message' => __('Please enter your zip / postal code', 'give') |
|
305 | 305 | ); |
306 | - $required_fields['card_city'] = array( |
|
306 | + $required_fields['card_city'] = array( |
|
307 | 307 | 'error_id' => 'invalid_city', |
308 | - 'error_message' => __( 'Please enter your billing city', 'give' ) |
|
308 | + 'error_message' => __('Please enter your billing city', 'give') |
|
309 | 309 | ); |
310 | 310 | $required_fields['billing_country'] = array( |
311 | 311 | 'error_id' => 'invalid_country', |
312 | - 'error_message' => __( 'Please select your billing country', 'give' ) |
|
312 | + 'error_message' => __('Please select your billing country', 'give') |
|
313 | 313 | ); |
314 | - $required_fields['card_state'] = array( |
|
314 | + $required_fields['card_state'] = array( |
|
315 | 315 | 'error_id' => 'invalid_state', |
316 | - 'error_message' => __( 'Please enter billing state / province', 'give' ) |
|
316 | + 'error_message' => __('Please enter billing state / province', 'give') |
|
317 | 317 | ); |
318 | 318 | } |
319 | 319 | |
320 | - return apply_filters( 'give_purchase_form_required_fields', $required_fields, $form_id ); |
|
320 | + return apply_filters('give_purchase_form_required_fields', $required_fields, $form_id); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -330,16 +330,16 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @return mixed|void |
332 | 332 | */ |
333 | -function give_require_billing_address( $payment_mode ) { |
|
333 | +function give_require_billing_address($payment_mode) { |
|
334 | 334 | |
335 | 335 | $return = false; |
336 | 336 | |
337 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
337 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
338 | 338 | $return = true; |
339 | 339 | } |
340 | 340 | |
341 | 341 | // Let payment gateways and other extensions determine if address fields should be required |
342 | - return apply_filters( 'give_require_billing_address', $return ); |
|
342 | + return apply_filters('give_require_billing_address', $return); |
|
343 | 343 | |
344 | 344 | } |
345 | 345 | |
@@ -353,43 +353,43 @@ discard block |
||
353 | 353 | function give_purchase_form_validate_logged_in_user() { |
354 | 354 | global $user_ID; |
355 | 355 | |
356 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
356 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
357 | 357 | |
358 | 358 | // Start empty array to collect valid user data |
359 | 359 | $valid_user_data = array( |
360 | 360 | // Assume there will be errors |
361 | - 'user_id' => - 1 |
|
361 | + 'user_id' => -1 |
|
362 | 362 | ); |
363 | 363 | |
364 | 364 | // Verify there is a user_ID |
365 | - if ( $user_ID > 0 ) { |
|
365 | + if ($user_ID > 0) { |
|
366 | 366 | // Get the logged in user data |
367 | - $user_data = get_userdata( $user_ID ); |
|
367 | + $user_data = get_userdata($user_ID); |
|
368 | 368 | |
369 | 369 | // Loop through required fields and show error messages |
370 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
371 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
372 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
370 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
371 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
372 | + give_set_error($value['error_id'], $value['error_message']); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | 376 | // Verify data |
377 | - if ( $user_data ) { |
|
377 | + if ($user_data) { |
|
378 | 378 | // Collected logged in user data |
379 | 379 | $valid_user_data = array( |
380 | 380 | 'user_id' => $user_ID, |
381 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
382 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
383 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
381 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
382 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
383 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
384 | 384 | ); |
385 | 385 | |
386 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
387 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
386 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
387 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | } else { |
391 | 391 | // Set invalid user error |
392 | - give_set_error( 'invalid_user', __( 'The user information is invalid', 'give' ) ); |
|
392 | + give_set_error('invalid_user', __('The user information is invalid', 'give')); |
|
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
@@ -407,92 +407,92 @@ discard block |
||
407 | 407 | function give_purchase_form_validate_new_user() { |
408 | 408 | $registering_new_user = false; |
409 | 409 | |
410 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
410 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
411 | 411 | |
412 | 412 | // Start an empty array to collect valid user data |
413 | 413 | $valid_user_data = array( |
414 | 414 | // Assume there will be errors |
415 | - 'user_id' => - 1, |
|
415 | + 'user_id' => -1, |
|
416 | 416 | // Get first name |
417 | - 'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '', |
|
417 | + 'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '', |
|
418 | 418 | // Get last name |
419 | - 'user_last' => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '', |
|
419 | + 'user_last' => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '', |
|
420 | 420 | ); |
421 | 421 | |
422 | 422 | // Check the new user's credentials against existing ones |
423 | - $user_login = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false; |
|
424 | - $user_email = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false; |
|
425 | - $user_pass = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false; |
|
426 | - $pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false; |
|
423 | + $user_login = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false; |
|
424 | + $user_email = isset($_POST['give_email']) ? trim($_POST['give_email']) : false; |
|
425 | + $user_pass = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false; |
|
426 | + $pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false; |
|
427 | 427 | |
428 | 428 | // Loop through required fields and show error messages |
429 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
430 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
431 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
429 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
430 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
431 | + give_set_error($value['error_id'], $value['error_message']); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | 435 | // Check if we have an username to register |
436 | - if ( $user_login && strlen( $user_login ) > 0 ) { |
|
436 | + if ($user_login && strlen($user_login) > 0) { |
|
437 | 437 | $registering_new_user = true; |
438 | 438 | |
439 | 439 | // We have an user name, check if it already exists |
440 | - if ( username_exists( $user_login ) ) { |
|
440 | + if (username_exists($user_login)) { |
|
441 | 441 | // Username already registered |
442 | - give_set_error( 'username_unavailable', __( 'Username already taken', 'give' ) ); |
|
442 | + give_set_error('username_unavailable', __('Username already taken', 'give')); |
|
443 | 443 | // Check if it's valid |
444 | - } else if ( ! give_validate_username( $user_login ) ) { |
|
444 | + } else if ( ! give_validate_username($user_login)) { |
|
445 | 445 | // Invalid username |
446 | - if ( is_multisite() ) { |
|
447 | - give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed', 'give' ) ); |
|
446 | + if (is_multisite()) { |
|
447 | + give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed', 'give')); |
|
448 | 448 | } else { |
449 | - give_set_error( 'username_invalid', __( 'Invalid username', 'give' ) ); |
|
449 | + give_set_error('username_invalid', __('Invalid username', 'give')); |
|
450 | 450 | } |
451 | 451 | } else { |
452 | 452 | // All the checks have run and it's good to go |
453 | 453 | $valid_user_data['user_login'] = $user_login; |
454 | 454 | } |
455 | 455 | } else { |
456 | - if ( give_no_guest_checkout( $form_id ) ) { |
|
457 | - give_set_error( 'registration_required', __( 'You must register or login to complete your donation', 'give' ) ); |
|
456 | + if (give_no_guest_checkout($form_id)) { |
|
457 | + give_set_error('registration_required', __('You must register or login to complete your donation', 'give')); |
|
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
461 | 461 | // Check if we have an email to verify |
462 | - if ( $user_email && strlen( $user_email ) > 0 ) { |
|
462 | + if ($user_email && strlen($user_email) > 0) { |
|
463 | 463 | // Validate email |
464 | - if ( ! is_email( $user_email ) ) { |
|
465 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
464 | + if ( ! is_email($user_email)) { |
|
465 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
466 | 466 | // Check if email exists |
467 | - } else if ( email_exists( $user_email ) && $registering_new_user ) { |
|
468 | - give_set_error( 'email_used', __( 'Email already used', 'give' ) ); |
|
467 | + } else if (email_exists($user_email) && $registering_new_user) { |
|
468 | + give_set_error('email_used', __('Email already used', 'give')); |
|
469 | 469 | } else { |
470 | 470 | // All the checks have run and it's good to go |
471 | 471 | $valid_user_data['user_email'] = $user_email; |
472 | 472 | } |
473 | 473 | } else { |
474 | 474 | // No email |
475 | - give_set_error( 'email_empty', __( 'Enter an email', 'give' ) ); |
|
475 | + give_set_error('email_empty', __('Enter an email', 'give')); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | // Check password |
479 | - if ( $user_pass && $pass_confirm ) { |
|
479 | + if ($user_pass && $pass_confirm) { |
|
480 | 480 | // Verify confirmation matches |
481 | - if ( $user_pass != $pass_confirm ) { |
|
481 | + if ($user_pass != $pass_confirm) { |
|
482 | 482 | // Passwords do not match |
483 | - give_set_error( 'password_mismatch', __( 'Passwords don\'t match', 'give' ) ); |
|
483 | + give_set_error('password_mismatch', __('Passwords don\'t match', 'give')); |
|
484 | 484 | } else { |
485 | 485 | // All is good to go |
486 | 486 | $valid_user_data['user_pass'] = $user_pass; |
487 | 487 | } |
488 | 488 | } else { |
489 | 489 | // Password or confirmation missing |
490 | - if ( ! $user_pass && $registering_new_user ) { |
|
490 | + if ( ! $user_pass && $registering_new_user) { |
|
491 | 491 | // The password is invalid |
492 | - give_set_error( 'password_empty', __( 'Enter a password', 'give' ) ); |
|
493 | - } else if ( ! $pass_confirm && $registering_new_user ) { |
|
492 | + give_set_error('password_empty', __('Enter a password', 'give')); |
|
493 | + } else if ( ! $pass_confirm && $registering_new_user) { |
|
494 | 494 | // Confirmation password is invalid |
495 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation', 'give' ) ); |
|
495 | + give_set_error('confirmation_empty', __('Enter the password confirmation', 'give')); |
|
496 | 496 | } |
497 | 497 | } |
498 | 498 | |
@@ -511,34 +511,34 @@ discard block |
||
511 | 511 | // Start an array to collect valid user data |
512 | 512 | $valid_user_data = array( |
513 | 513 | // Assume there will be errors |
514 | - 'user_id' => - 1 |
|
514 | + 'user_id' => -1 |
|
515 | 515 | ); |
516 | 516 | |
517 | 517 | // Username |
518 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
519 | - give_set_error( 'must_log_in', __( 'You must login or register to complete your donation', 'give' ) ); |
|
518 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
519 | + give_set_error('must_log_in', __('You must login or register to complete your donation', 'give')); |
|
520 | 520 | |
521 | 521 | return $valid_user_data; |
522 | 522 | } |
523 | 523 | |
524 | 524 | // Get the user by login |
525 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
525 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
526 | 526 | |
527 | 527 | // Check if user exists |
528 | - if ( $user_data ) { |
|
528 | + if ($user_data) { |
|
529 | 529 | // Get password |
530 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
530 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
531 | 531 | |
532 | 532 | // Check user_pass |
533 | - if ( $user_pass ) { |
|
533 | + if ($user_pass) { |
|
534 | 534 | // Check if password is valid |
535 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
535 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
536 | 536 | // Incorrect password |
537 | 537 | give_set_error( |
538 | 538 | 'password_incorrect', |
539 | 539 | sprintf( |
540 | - __( 'The password you entered is incorrect. %sReset Password%s', 'give' ), |
|
541 | - '<a href="' . wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ) . '" title="' . __( 'Lost Password', 'give' ) . '">', |
|
540 | + __('The password you entered is incorrect. %sReset Password%s', 'give'), |
|
541 | + '<a href="'.wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]").'" title="'.__('Lost Password', 'give').'">', |
|
542 | 542 | '</a>' |
543 | 543 | ) |
544 | 544 | ); |
@@ -556,11 +556,11 @@ discard block |
||
556 | 556 | } |
557 | 557 | } else { |
558 | 558 | // Empty password |
559 | - give_set_error( 'password_empty', __( 'Enter a password', 'give' ) ); |
|
559 | + give_set_error('password_empty', __('Enter a password', 'give')); |
|
560 | 560 | } |
561 | 561 | } else { |
562 | 562 | // no username |
563 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist', 'give' ) ); |
|
563 | + give_set_error('username_incorrect', __('The username you entered does not exist', 'give')); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | return $valid_user_data; |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | */ |
576 | 576 | function give_purchase_form_validate_guest_user() { |
577 | 577 | |
578 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
578 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
579 | 579 | |
580 | 580 | // Start an array to collect valid user data |
581 | 581 | $valid_user_data = array( |
@@ -584,32 +584,32 @@ discard block |
||
584 | 584 | ); |
585 | 585 | |
586 | 586 | // Show error message if user must be logged in |
587 | - if ( give_logged_in_only() ) { |
|
588 | - give_set_error( 'logged_in_only', __( 'You must be logged into an account to donation', 'give' ) ); |
|
587 | + if (give_logged_in_only()) { |
|
588 | + give_set_error('logged_in_only', __('You must be logged into an account to donation', 'give')); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | // Get the guest email |
592 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
592 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
593 | 593 | |
594 | 594 | // Check email |
595 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
595 | + if ($guest_email && strlen($guest_email) > 0) { |
|
596 | 596 | // Validate email |
597 | - if ( ! is_email( $guest_email ) ) { |
|
597 | + if ( ! is_email($guest_email)) { |
|
598 | 598 | // Invalid email |
599 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
599 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
600 | 600 | } else { |
601 | 601 | // All is good to go |
602 | 602 | $valid_user_data['user_email'] = $guest_email; |
603 | 603 | } |
604 | 604 | } else { |
605 | 605 | // No email |
606 | - give_set_error( 'email_empty', __( 'Enter an email', 'give' ) ); |
|
606 | + give_set_error('email_empty', __('Enter an email', 'give')); |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | // Loop through required fields and show error messages |
610 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
611 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
612 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
610 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
611 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
612 | + give_set_error($value['error_id'], $value['error_message']); |
|
613 | 613 | } |
614 | 614 | } |
615 | 615 | |
@@ -625,42 +625,42 @@ discard block |
||
625 | 625 | * @since 1.0 |
626 | 626 | * @return integer |
627 | 627 | */ |
628 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
628 | +function give_register_and_login_new_user($user_data = array()) { |
|
629 | 629 | // Verify the array |
630 | - if ( empty( $user_data ) ) { |
|
631 | - return - 1; |
|
630 | + if (empty($user_data)) { |
|
631 | + return -1; |
|
632 | 632 | } |
633 | 633 | |
634 | - if ( give_get_errors() ) { |
|
635 | - return - 1; |
|
634 | + if (give_get_errors()) { |
|
635 | + return -1; |
|
636 | 636 | } |
637 | 637 | |
638 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
639 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
640 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
641 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
642 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
643 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
644 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
645 | - 'role' => get_option( 'default_role' ) |
|
646 | - ), $user_data ); |
|
638 | + $user_args = apply_filters('give_insert_user_args', array( |
|
639 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
640 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
641 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
642 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
643 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
644 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
645 | + 'role' => get_option('default_role') |
|
646 | + ), $user_data); |
|
647 | 647 | |
648 | 648 | // Insert new user |
649 | - $user_id = wp_insert_user( $user_args ); |
|
649 | + $user_id = wp_insert_user($user_args); |
|
650 | 650 | |
651 | 651 | // Validate inserted user |
652 | - if ( is_wp_error( $user_id ) ) { |
|
653 | - return - 1; |
|
652 | + if (is_wp_error($user_id)) { |
|
653 | + return -1; |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | // Allow themes and plugins to filter the user data |
657 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
657 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
658 | 658 | |
659 | 659 | // Allow themes and plugins to hook |
660 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
660 | + do_action('give_insert_user', $user_id, $user_data); |
|
661 | 661 | |
662 | 662 | // Login new user |
663 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
663 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
664 | 664 | |
665 | 665 | // Return user id |
666 | 666 | return $user_id; |
@@ -675,27 +675,27 @@ discard block |
||
675 | 675 | * @since 1.0 |
676 | 676 | * @return array |
677 | 677 | */ |
678 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
678 | +function give_get_purchase_form_user($valid_data = array()) { |
|
679 | 679 | // Initialize user |
680 | 680 | $user = false; |
681 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
681 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
682 | 682 | |
683 | - if ( $is_ajax ) { |
|
683 | + if ($is_ajax) { |
|
684 | 684 | // Do not create or login the user during the ajax submission (check for errors only) |
685 | 685 | return true; |
686 | - } else if ( is_user_logged_in() ) { |
|
686 | + } else if (is_user_logged_in()) { |
|
687 | 687 | // Set the valid user as the logged in collected data |
688 | 688 | |
689 | 689 | $user = $valid_data['logged_in_user']; |
690 | - } else if ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
690 | + } else if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
691 | 691 | // New user registration |
692 | - if ( $valid_data['need_new_user'] === true ) { |
|
692 | + if ($valid_data['need_new_user'] === true) { |
|
693 | 693 | // Set user |
694 | 694 | $user = $valid_data['new_user_data']; |
695 | 695 | // Register and login new user |
696 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
696 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
697 | 697 | // User login |
698 | - } else if ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
698 | + } else if ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
699 | 699 | |
700 | 700 | /* |
701 | 701 | * The login form is now processed in the give_process_purchase_login() function. |
@@ -710,48 +710,48 @@ discard block |
||
710 | 710 | // Set user |
711 | 711 | $user = $valid_data['login_user_data']; |
712 | 712 | // Login user |
713 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
713 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
714 | 714 | } |
715 | 715 | } |
716 | 716 | |
717 | 717 | // Check guest checkout |
718 | - if ( false === $user && false === give_no_guest_checkout( $_POST['give-form-id'] ) ) { |
|
718 | + if (false === $user && false === give_no_guest_checkout($_POST['give-form-id'])) { |
|
719 | 719 | // Set user |
720 | 720 | $user = $valid_data['guest_user_data']; |
721 | 721 | } |
722 | 722 | |
723 | 723 | // Verify we have an user |
724 | - if ( false === $user || empty( $user ) ) { |
|
724 | + if (false === $user || empty($user)) { |
|
725 | 725 | // Return false |
726 | 726 | return false; |
727 | 727 | } |
728 | 728 | |
729 | 729 | // Get user first name |
730 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
731 | - $user['user_first'] = isset( $_POST["give_first"] ) ? strip_tags( trim( $_POST["give_first"] ) ) : ''; |
|
730 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
731 | + $user['user_first'] = isset($_POST["give_first"]) ? strip_tags(trim($_POST["give_first"])) : ''; |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | // Get user last name |
735 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
736 | - $user['user_last'] = isset( $_POST["give_last"] ) ? strip_tags( trim( $_POST["give_last"] ) ) : ''; |
|
735 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
736 | + $user['user_last'] = isset($_POST["give_last"]) ? strip_tags(trim($_POST["give_last"])) : ''; |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | // Get the user's billing address details |
740 | 740 | $user['address'] = array(); |
741 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
742 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
743 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
744 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
745 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
746 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
747 | - |
|
748 | - if ( empty( $user['address']['country'] ) ) { |
|
741 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
742 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
743 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
744 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
745 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
746 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
747 | + |
|
748 | + if (empty($user['address']['country'])) { |
|
749 | 749 | $user['address'] = false; |
750 | 750 | } // Country will always be set if address fields are present |
751 | 751 | |
752 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
752 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
753 | 753 | // Store the address in the user's meta so the cart can be pre-populated with it on return purchases |
754 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
754 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | // Return valid user |
@@ -770,16 +770,16 @@ discard block |
||
770 | 770 | $card_data = give_get_purchase_cc_info(); |
771 | 771 | |
772 | 772 | // Validate the card zip |
773 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
774 | - if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
775 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid', 'give' ) ); |
|
773 | + if ( ! empty($card_data['card_zip'])) { |
|
774 | + if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
775 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid', 'give')); |
|
776 | 776 | } |
777 | 777 | } |
778 | 778 | |
779 | 779 | //Ensure no spaces |
780 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
781 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); //no "+" signs |
|
782 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
780 | + if ( ! empty($card_data['card_number'])) { |
|
781 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); //no "+" signs |
|
782 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | // This should validate card numbers at some point too |
@@ -795,17 +795,17 @@ discard block |
||
795 | 795 | */ |
796 | 796 | function give_get_purchase_cc_info() { |
797 | 797 | $cc_info = array(); |
798 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
799 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
800 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
801 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
802 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
803 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
804 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
805 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
806 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
807 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
808 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
798 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
799 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
800 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
801 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
802 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
803 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
804 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
805 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
806 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
807 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
808 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
809 | 809 | |
810 | 810 | // Return cc info |
811 | 811 | return $cc_info; |
@@ -821,14 +821,14 @@ discard block |
||
821 | 821 | * |
822 | 822 | * @return bool|mixed|void |
823 | 823 | */ |
824 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
824 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
825 | 825 | $ret = false; |
826 | 826 | |
827 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
827 | + if (empty($zip) || empty($country_code)) { |
|
828 | 828 | return $ret; |
829 | 829 | } |
830 | 830 | |
831 | - $country_code = strtoupper( $country_code ); |
|
831 | + $country_code = strtoupper($country_code); |
|
832 | 832 | |
833 | 833 | $zip_regex = array( |
834 | 834 | "AD" => "AD\d{3}", |
@@ -988,11 +988,11 @@ discard block |
||
988 | 988 | "ZM" => "\d{5}" |
989 | 989 | ); |
990 | 990 | |
991 | - if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) { |
|
991 | + if ( ! isset ($zip_regex[$country_code]) || preg_match("/".$zip_regex[$country_code]."/i", $zip)) { |
|
992 | 992 | $ret = true; |
993 | 993 | } |
994 | 994 | |
995 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
995 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | |
@@ -1002,48 +1002,48 @@ discard block |
||
1002 | 1002 | * @since 1.0 |
1003 | 1003 | * @return void |
1004 | 1004 | */ |
1005 | -function give_check_purchase_email( $valid_data, $posted ) { |
|
1005 | +function give_check_purchase_email($valid_data, $posted) { |
|
1006 | 1006 | $is_banned = false; |
1007 | 1007 | $banned = give_get_banned_emails(); |
1008 | 1008 | |
1009 | - if ( empty( $banned ) ) { |
|
1009 | + if (empty($banned)) { |
|
1010 | 1010 | return; |
1011 | 1011 | } |
1012 | 1012 | |
1013 | - if ( is_user_logged_in() ) { |
|
1013 | + if (is_user_logged_in()) { |
|
1014 | 1014 | |
1015 | 1015 | // The user is logged in, check that their account email is not banned |
1016 | - $user_data = get_userdata( get_current_user_id() ); |
|
1017 | - if ( give_is_email_banned( $user_data->user_email ) ) { |
|
1016 | + $user_data = get_userdata(get_current_user_id()); |
|
1017 | + if (give_is_email_banned($user_data->user_email)) { |
|
1018 | 1018 | |
1019 | 1019 | $is_banned = true; |
1020 | 1020 | } |
1021 | 1021 | |
1022 | - if ( give_is_email_banned( $posted['give_email'] ) ) { |
|
1022 | + if (give_is_email_banned($posted['give_email'])) { |
|
1023 | 1023 | $is_banned = true; |
1024 | 1024 | } |
1025 | 1025 | |
1026 | - } elseif ( isset( $posted['give-purchase-var'] ) && $posted['give-purchase-var'] == 'needs-to-login' ) { |
|
1026 | + } elseif (isset($posted['give-purchase-var']) && $posted['give-purchase-var'] == 'needs-to-login') { |
|
1027 | 1027 | |
1028 | 1028 | // The user is logging in, check that their email is not banned |
1029 | - $user_data = get_user_by( 'login', $posted['give_user_login'] ); |
|
1030 | - if ( $user_data && give_is_email_banned( $user_data->user_email ) ) { |
|
1029 | + $user_data = get_user_by('login', $posted['give_user_login']); |
|
1030 | + if ($user_data && give_is_email_banned($user_data->user_email)) { |
|
1031 | 1031 | $is_banned = true; |
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | } else { |
1035 | 1035 | |
1036 | 1036 | // Guest purchase, check that the email is not banned |
1037 | - if ( give_is_email_banned( $posted['give_email'] ) ) { |
|
1037 | + if (give_is_email_banned($posted['give_email'])) { |
|
1038 | 1038 | $is_banned = true; |
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | } |
1042 | 1042 | |
1043 | - if ( $is_banned ) { |
|
1043 | + if ($is_banned) { |
|
1044 | 1044 | // Set an error and give the donor a general error (don't alert them that they were banned) |
1045 | - give_set_error( 'email_banned', __( 'An internal error has occurred, please try again or contact support.', 'give' ) ); |
|
1045 | + give_set_error('email_banned', __('An internal error has occurred, please try again or contact support.', 'give')); |
|
1046 | 1046 | } |
1047 | 1047 | } |
1048 | 1048 | |
1049 | -add_action( 'give_checkout_error_checks', 'give_check_purchase_email', 10, 2 ); |
|
1049 | +add_action('give_checkout_error_checks', 'give_check_purchase_email', 10, 2); |
@@ -270,7 +270,7 @@ |
||
270 | 270 | * @access public |
271 | 271 | * @since 1.0 |
272 | 272 | * |
273 | - * @param $username string - the username to validate |
|
273 | + * @param string $username string - the username to validate |
|
274 | 274 | * |
275 | 275 | * @return bool |
276 | 276 | */ |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * User Functions |
|
4 | - * |
|
5 | - * Functions related to users / donors |
|
6 | - * |
|
7 | - * @package Give |
|
8 | - * @subpackage Functions |
|
9 | - * @copyright Copyright (c) 2015, WordImpress |
|
10 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
11 | - * @since 1.0 |
|
12 | - */ |
|
3 | + * User Functions |
|
4 | + * |
|
5 | + * Functions related to users / donors |
|
6 | + * |
|
7 | + * @package Give |
|
8 | + * @subpackage Functions |
|
9 | + * @copyright Copyright (c) 2015, WordImpress |
|
10 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
11 | + * @since 1.0 |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool|object List of all user purchases |
32 | 32 | */ |
33 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
33 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
34 | 34 | |
35 | - if ( empty( $user ) ) { |
|
35 | + if (empty($user)) { |
|
36 | 36 | $user = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 0 === $user ) { |
|
39 | + if (0 === $user) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
44 | 44 | |
45 | - if ( $pagination ) { |
|
46 | - if ( get_query_var( 'paged' ) ) { |
|
47 | - $paged = get_query_var( 'paged' ); |
|
48 | - } else if ( get_query_var( 'page' ) ) { |
|
49 | - $paged = get_query_var( 'page' ); |
|
45 | + if ($pagination) { |
|
46 | + if (get_query_var('paged')) { |
|
47 | + $paged = get_query_var('paged'); |
|
48 | + } else if (get_query_var('page')) { |
|
49 | + $paged = get_query_var('page'); |
|
50 | 50 | } else { |
51 | 51 | $paged = 1; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - $args = apply_filters( 'give_get_users_purchases_args', array( |
|
55 | + $args = apply_filters('give_get_users_purchases_args', array( |
|
56 | 56 | 'user' => $user, |
57 | 57 | 'number' => $number, |
58 | 58 | 'status' => $status, |
59 | 59 | 'orderby' => 'date' |
60 | - ) ); |
|
60 | + )); |
|
61 | 61 | |
62 | - if ( $pagination ) { |
|
62 | + if ($pagination) { |
|
63 | 63 | |
64 | 64 | $args['page'] = $paged; |
65 | 65 | |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
73 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
72 | + $by_user_id = is_numeric($user) ? true : false; |
|
73 | + $customer = new Give_Customer($user, $by_user_id); |
|
74 | 74 | |
75 | - if ( ! empty( $customer->payment_ids ) ) { |
|
75 | + if ( ! empty($customer->payment_ids)) { |
|
76 | 76 | |
77 | - unset( $args['user'] ); |
|
78 | - $args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
77 | + unset($args['user']); |
|
78 | + $args['post__in'] = array_map('absint', explode(',', $customer->payment_ids)); |
|
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | - $purchases = give_get_payments( apply_filters( 'give_get_users_purchases_args', $args ) ); |
|
82 | + $purchases = give_get_payments(apply_filters('give_get_users_purchases_args', $args)); |
|
83 | 83 | |
84 | 84 | // No purchases |
85 | - if ( ! $purchases ) { |
|
85 | + if ( ! $purchases) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
@@ -101,64 +101,64 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return bool|object List of unique forms purchased by user |
103 | 103 | */ |
104 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
105 | - if ( empty( $user ) ) { |
|
104 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
105 | + if (empty($user)) { |
|
106 | 106 | $user = get_current_user_id(); |
107 | 107 | } |
108 | 108 | |
109 | - if ( empty( $user ) ) { |
|
109 | + if (empty($user)) { |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
113 | + $by_user_id = is_numeric($user) ? true : false; |
|
114 | 114 | |
115 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
115 | + $customer = new Give_Customer($user, $by_user_id); |
|
116 | 116 | |
117 | - if ( empty( $customer->payment_ids ) ) { |
|
117 | + if (empty($customer->payment_ids)) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Get all the items purchased |
122 | - $payment_ids = array_reverse( explode( ',', $customer->payment_ids ) ); |
|
123 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
124 | - if ( ! empty( $limit_payments ) ) { |
|
125 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
122 | + $payment_ids = array_reverse(explode(',', $customer->payment_ids)); |
|
123 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
124 | + if ( ! empty($limit_payments)) { |
|
125 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
126 | 126 | } |
127 | 127 | $donation_data = array(); |
128 | - foreach ( $payment_ids as $payment_id ) { |
|
129 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
128 | + foreach ($payment_ids as $payment_id) { |
|
129 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
130 | 130 | } |
131 | 131 | |
132 | - if ( empty( $donation_data ) ) { |
|
132 | + if (empty($donation_data)) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Grab only the post ids "form_id" of the forms purchased on this order |
137 | 137 | $completed_donations_ids = array(); |
138 | - foreach ( $donation_data as $purchase_meta ) { |
|
138 | + foreach ($donation_data as $purchase_meta) { |
|
139 | 139 | $completed_donations_ids[] = $purchase_meta['form_id']; |
140 | 140 | } |
141 | - if ( empty( $completed_donations_ids ) ) { |
|
141 | + if (empty($completed_donations_ids)) { |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | |
145 | 145 | // Only include each product purchased once |
146 | - $form_ids = array_unique( $completed_donations_ids ); |
|
146 | + $form_ids = array_unique($completed_donations_ids); |
|
147 | 147 | |
148 | 148 | // Make sure we still have some products and a first item |
149 | - if ( empty ( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
149 | + if (empty ($form_ids) || ! isset($form_ids[0])) { |
|
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
153 | - $post_type = get_post_type( $form_ids[0] ); |
|
153 | + $post_type = get_post_type($form_ids[0]); |
|
154 | 154 | |
155 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
155 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
156 | 156 | 'include' => $form_ids, |
157 | 157 | 'post_type' => $post_type, |
158 | - 'posts_per_page' => - 1 |
|
159 | - ) ); |
|
158 | + 'posts_per_page' => -1 |
|
159 | + )); |
|
160 | 160 | |
161 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
161 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @return bool - true if has purchased, false other wise. |
176 | 176 | */ |
177 | -function give_has_purchases( $user_id = null ) { |
|
178 | - if ( empty( $user_id ) ) { |
|
177 | +function give_has_purchases($user_id = null) { |
|
178 | + if (empty($user_id)) { |
|
179 | 179 | $user_id = get_current_user_id(); |
180 | 180 | } |
181 | 181 | |
182 | - if ( give_get_users_purchases( $user_id, 1 ) ) { |
|
182 | + if (give_get_users_purchases($user_id, 1)) { |
|
183 | 183 | return true; // User has at least one purchase |
184 | 184 | } |
185 | 185 | |
@@ -200,27 +200,27 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array |
202 | 202 | */ |
203 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
203 | +function give_get_purchase_stats_by_user($user = '') { |
|
204 | 204 | |
205 | - if ( is_email( $user ) ) { |
|
205 | + if (is_email($user)) { |
|
206 | 206 | |
207 | 207 | $field = 'email'; |
208 | 208 | |
209 | - } elseif ( is_numeric( $user ) ) { |
|
209 | + } elseif (is_numeric($user)) { |
|
210 | 210 | |
211 | 211 | $field = 'user_id'; |
212 | 212 | |
213 | 213 | } |
214 | 214 | |
215 | - $customer = Give()->customers->get_customer_by( $field, $user ); |
|
215 | + $customer = Give()->customers->get_customer_by($field, $user); |
|
216 | 216 | |
217 | - $customer = new Give_Customer( $customer->id ); |
|
217 | + $customer = new Give_Customer($customer->id); |
|
218 | 218 | |
219 | 219 | $stats = array(); |
220 | - $stats['purchases'] = absint( $customer->purchase_count ); |
|
221 | - $stats['total_spent'] = give_sanitize_amount( $customer->purchase_value ); |
|
220 | + $stats['purchases'] = absint($customer->purchase_count); |
|
221 | + $stats['total_spent'] = give_sanitize_amount($customer->purchase_value); |
|
222 | 222 | |
223 | - return (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
223 | + return (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -236,14 +236,14 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return int - the total number of purchases |
238 | 238 | */ |
239 | -function give_count_purchases_of_customer( $user = null ) { |
|
240 | - if ( empty( $user ) ) { |
|
239 | +function give_count_purchases_of_customer($user = null) { |
|
240 | + if (empty($user)) { |
|
241 | 241 | $user = get_current_user_id(); |
242 | 242 | } |
243 | 243 | |
244 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
244 | + $stats = give_get_purchase_stats_by_user($user); |
|
245 | 245 | |
246 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
246 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return float - the total amount the user has spent |
258 | 258 | */ |
259 | -function give_purchase_total_of_user( $user = null ) { |
|
259 | +function give_purchase_total_of_user($user = null) { |
|
260 | 260 | |
261 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
261 | + $stats = give_get_purchase_stats_by_user($user); |
|
262 | 262 | |
263 | 263 | return $stats['total_spent']; |
264 | 264 | } |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return bool |
276 | 276 | */ |
277 | -function give_validate_username( $username ) { |
|
278 | - $sanitized = sanitize_user( $username, false ); |
|
279 | - $valid = ( $sanitized == $username ); |
|
277 | +function give_validate_username($username) { |
|
278 | + $sanitized = sanitize_user($username, false); |
|
279 | + $valid = ($sanitized == $username); |
|
280 | 280 | |
281 | - return (bool) apply_filters( 'give_validate_username', $valid, $username ); |
|
281 | + return (bool) apply_filters('give_validate_username', $valid, $username); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -295,32 +295,32 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @return void |
297 | 297 | */ |
298 | -function give_add_past_purchases_to_new_user( $user_id ) { |
|
298 | +function give_add_past_purchases_to_new_user($user_id) { |
|
299 | 299 | |
300 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
300 | + $email = get_the_author_meta('user_email', $user_id); |
|
301 | 301 | |
302 | - $payments = give_get_payments( array( 's' => $email ) ); |
|
302 | + $payments = give_get_payments(array('s' => $email)); |
|
303 | 303 | |
304 | - if ( $payments ) { |
|
305 | - foreach ( $payments as $payment ) { |
|
306 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
304 | + if ($payments) { |
|
305 | + foreach ($payments as $payment) { |
|
306 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
307 | 307 | continue; |
308 | 308 | } // This payment already associated with an account |
309 | 309 | |
310 | - $meta = give_get_payment_meta( $payment->ID ); |
|
311 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] ); |
|
310 | + $meta = give_get_payment_meta($payment->ID); |
|
311 | + $meta['user_info'] = maybe_unserialize($meta['user_info']); |
|
312 | 312 | $meta['user_info']['id'] = $user_id; |
313 | 313 | $meta['user_info'] = $meta['user_info']; |
314 | 314 | |
315 | 315 | // Store the updated user ID in the payment meta |
316 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta ); |
|
317 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id ); |
|
316 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta); |
|
317 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
321 | 321 | } |
322 | 322 | |
323 | -add_action( 'user_register', 'give_add_past_purchases_to_new_user' ); |
|
323 | +add_action('user_register', 'give_add_past_purchases_to_new_user'); |
|
324 | 324 | |
325 | 325 | |
326 | 326 | /** |
@@ -342,34 +342,34 @@ discard block |
||
342 | 342 | * @since 1.0 |
343 | 343 | * @return array - The donor's address, if any |
344 | 344 | */ |
345 | -function give_get_donor_address( $user_id = 0 ) { |
|
346 | - if ( empty( $user_id ) ) { |
|
345 | +function give_get_donor_address($user_id = 0) { |
|
346 | + if (empty($user_id)) { |
|
347 | 347 | $user_id = get_current_user_id(); |
348 | 348 | } |
349 | 349 | |
350 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
350 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
351 | 351 | |
352 | - if ( ! isset( $address['line1'] ) ) { |
|
352 | + if ( ! isset($address['line1'])) { |
|
353 | 353 | $address['line1'] = ''; |
354 | 354 | } |
355 | 355 | |
356 | - if ( ! isset( $address['line2'] ) ) { |
|
356 | + if ( ! isset($address['line2'])) { |
|
357 | 357 | $address['line2'] = ''; |
358 | 358 | } |
359 | 359 | |
360 | - if ( ! isset( $address['city'] ) ) { |
|
360 | + if ( ! isset($address['city'])) { |
|
361 | 361 | $address['city'] = ''; |
362 | 362 | } |
363 | 363 | |
364 | - if ( ! isset( $address['zip'] ) ) { |
|
364 | + if ( ! isset($address['zip'])) { |
|
365 | 365 | $address['zip'] = ''; |
366 | 366 | } |
367 | 367 | |
368 | - if ( ! isset( $address['country'] ) ) { |
|
368 | + if ( ! isset($address['country'])) { |
|
369 | 369 | $address['country'] = ''; |
370 | 370 | } |
371 | 371 | |
372 | - if ( ! isset( $address['state'] ) ) { |
|
372 | + if ( ! isset($address['state'])) { |
|
373 | 373 | $address['state'] = ''; |
374 | 374 | } |
375 | 375 | |
@@ -383,13 +383,13 @@ discard block |
||
383 | 383 | * @since 1.0 |
384 | 384 | * @return void |
385 | 385 | */ |
386 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
386 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
387 | 387 | |
388 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
388 | + if (empty($user_id) || empty($user_data)) { |
|
389 | 389 | return; |
390 | 390 | } |
391 | 391 | |
392 | - wp_new_user_notification( $user_id, __( '[Password entered during donation]', 'give' ) ); |
|
392 | + wp_new_user_notification($user_id, __('[Password entered during donation]', 'give')); |
|
393 | 393 | } |
394 | 394 | |
395 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
395 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | * @return void |
24 | 24 | */ |
25 | 25 | function give_get_actions() { |
26 | - if ( isset( $_GET['give_action'] ) ) { |
|
27 | - do_action( 'give_' . $_GET['give_action'], $_GET ); |
|
26 | + if (isset($_GET['give_action'])) { |
|
27 | + do_action('give_'.$_GET['give_action'], $_GET); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -add_action( 'init', 'give_get_actions' ); |
|
31 | +add_action('init', 'give_get_actions'); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Hooks Give actions, when present in the $_POST superglobal. Every give_action |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | * @return void |
40 | 40 | */ |
41 | 41 | function give_post_actions() { |
42 | - if ( isset( $_POST['give_action'] ) ) { |
|
43 | - do_action( 'give_' . $_POST['give_action'], $_POST ); |
|
42 | + if (isset($_POST['give_action'])) { |
|
43 | + do_action('give_'.$_POST['give_action'], $_POST); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | -add_action( 'init', 'give_post_actions' ); |
|
48 | 47 | \ No newline at end of file |
48 | +add_action('init', 'give_post_actions'); |
|
49 | 49 | \ 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 | |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | function give_add_ons_page() { |
26 | 26 | ob_start(); ?> |
27 | 27 | <div class="wrap" id="give-add-ons"> |
28 | - <h2><?php _e( 'Give Add-ons', 'give' ); ?> |
|
29 | - — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" title="<?php _e( 'Browse All Extensions', 'give' ); ?>" target="_blank"><?php _e( 'View All Add-ons', 'give' ); ?> |
|
28 | + <h2><?php _e('Give Add-ons', 'give'); ?> |
|
29 | + — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" title="<?php _e('Browse All Extensions', 'give'); ?>" target="_blank"><?php _e('View All Add-ons', 'give'); ?> |
|
30 | 30 | <span class="dashicons dashicons-external"></span></a> |
31 | 31 | </h2> |
32 | 32 | |
33 | - <p><?php _e( 'The following Add-ons extend the functionality of Give.', 'give' ); ?></p> |
|
33 | + <p><?php _e('The following Add-ons extend the functionality of Give.', 'give'); ?></p> |
|
34 | 34 | <?php echo give_add_ons_get_feed(); ?> |
35 | 35 | </div> |
36 | 36 | <?php |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | function give_add_ons_get_feed() { |
49 | 49 | |
50 | 50 | $addons_debug = false; //set to true to debug |
51 | - $cache = get_transient( 'give_add_ons_feed' ); |
|
51 | + $cache = get_transient('give_add_ons_feed'); |
|
52 | 52 | |
53 | - if ( $cache === false || $addons_debug === true && WP_DEBUG === true ) { |
|
54 | - $feed = wp_remote_get( 'https://givewp.com/downloads/feed/', array( 'sslverify' => false ) ); |
|
53 | + if ($cache === false || $addons_debug === true && WP_DEBUG === true) { |
|
54 | + $feed = wp_remote_get('https://givewp.com/downloads/feed/', array('sslverify' => false)); |
|
55 | 55 | |
56 | - if ( ! is_wp_error( $feed ) ) { |
|
57 | - if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) { |
|
58 | - $cache = wp_remote_retrieve_body( $feed ); |
|
59 | - set_transient( 'give_add_ons_feed', $cache, 3600 ); |
|
56 | + if ( ! is_wp_error($feed)) { |
|
57 | + if (isset($feed['body']) && strlen($feed['body']) > 0) { |
|
58 | + $cache = wp_remote_retrieve_body($feed); |
|
59 | + set_transient('give_add_ons_feed', $cache, 3600); |
|
60 | 60 | } |
61 | 61 | } else { |
62 | - $cache = '<div class="error"><p>' . __( 'There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give' ) . '</div>'; |
|
62 | + $cache = '<div class="error"><p>'.__('There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give').'</div>'; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 |
@@ -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 | |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | * @return void |
23 | 23 | */ |
24 | 24 | function give_process_actions() { |
25 | - if ( isset( $_POST['give-action'] ) ) { |
|
26 | - do_action( 'give_' . $_POST['give-action'], $_POST ); |
|
25 | + if (isset($_POST['give-action'])) { |
|
26 | + do_action('give_'.$_POST['give-action'], $_POST); |
|
27 | 27 | } |
28 | 28 | |
29 | - if ( isset( $_GET['give-action'] ) ) { |
|
30 | - do_action( 'give_' . $_GET['give-action'], $_GET ); |
|
29 | + if (isset($_GET['give-action'])) { |
|
30 | + do_action('give_'.$_GET['give-action'], $_GET); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | -add_action( 'admin_init', 'give_process_actions' ); |
|
35 | 34 | \ No newline at end of file |
35 | +add_action('admin_init', 'give_process_actions'); |
|
36 | 36 | \ 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 | |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return string |
26 | 26 | */ |
27 | -function give_admin_rate_us( $footer_text ) { |
|
27 | +function give_admin_rate_us($footer_text) { |
|
28 | 28 | global $typenow; |
29 | 29 | |
30 | - if ( $typenow == 'give_forms' ) { |
|
31 | - $rate_text = sprintf( __( 'If you like <strong>Give</strong> please leave us a %s★★★★★%s rating. It takes a minute and helps a lot. Thanks in advance!', 'give' ), '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" data-rated="' . __( 'Thanks :)', 'give' ) . '">', '</a>' ); |
|
30 | + if ($typenow == 'give_forms') { |
|
31 | + $rate_text = sprintf(__('If you like <strong>Give</strong> please leave us a %s★★★★★%s rating. It takes a minute and helps a lot. Thanks in advance!', 'give'), '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" data-rated="'.__('Thanks :)', 'give').'">', '</a>'); |
|
32 | 32 | |
33 | 33 | return $rate_text; |
34 | 34 | } else { |
@@ -36,4 +36,4 @@ discard block |
||
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | -add_filter( 'admin_footer_text', 'give_admin_rate_us' ); |
|
39 | +add_filter('admin_footer_text', 'give_admin_rate_us'); |
@@ -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 | |
@@ -34,31 +34,31 @@ discard block |
||
34 | 34 | // $give_campaigns_page = add_submenu_page( 'edit.php?post_type=give_forms', $give_campaigns->labels->menu_name, $give_campaigns->labels->add_new, 'edit_' . $give_campaigns->capability_type . 's', 'post-new.php?post_type=give_campaigns', null ); |
35 | 35 | |
36 | 36 | //Payments |
37 | - $give_payment = get_post_type_object( 'give_payment' ); |
|
38 | - $give_payments_page = add_submenu_page( 'edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page' ); |
|
37 | + $give_payment = get_post_type_object('give_payment'); |
|
38 | + $give_payments_page = add_submenu_page('edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page'); |
|
39 | 39 | |
40 | 40 | //Donors |
41 | - $give_donors_page = add_submenu_page( 'edit.php?post_type=give_forms', __( 'Donors', 'give' ), __( 'Donors', 'give' ), 'view_give_reports', 'give-donors', 'give_customers_page' ); |
|
41 | + $give_donors_page = add_submenu_page('edit.php?post_type=give_forms', __('Donors', 'give'), __('Donors', 'give'), 'view_give_reports', 'give-donors', 'give_customers_page'); |
|
42 | 42 | |
43 | 43 | //Reports |
44 | - $give_reports_page = add_submenu_page( 'edit.php?post_type=give_forms', __( 'Donation Reports', 'give' ), __( 'Reports', 'give' ), 'view_give_reports', 'give-reports', 'give_reports_page' ); |
|
44 | + $give_reports_page = add_submenu_page('edit.php?post_type=give_forms', __('Donation Reports', 'give'), __('Reports', 'give'), 'view_give_reports', 'give-reports', 'give_reports_page'); |
|
45 | 45 | |
46 | 46 | //Settings |
47 | - $give_settings_page = add_submenu_page( 'edit.php?post_type=give_forms', __( 'Give Settings', 'give' ), __( 'Settings', 'give' ), 'manage_give_settings', 'give-settings', array( |
|
47 | + $give_settings_page = add_submenu_page('edit.php?post_type=give_forms', __('Give Settings', 'give'), __('Settings', 'give'), 'manage_give_settings', 'give-settings', array( |
|
48 | 48 | Give()->give_settings, |
49 | 49 | 'admin_page_display' |
50 | - ) ); |
|
50 | + )); |
|
51 | 51 | |
52 | 52 | //Add-ons |
53 | - $give_add_ons_page = add_submenu_page( 'edit.php?post_type=give_forms', __( 'Give Add-ons', 'give' ), __( 'Add-ons', 'give' ), 'install_plugins', 'give-addons', 'give_add_ons_page' ); |
|
53 | + $give_add_ons_page = add_submenu_page('edit.php?post_type=give_forms', __('Give Add-ons', 'give'), __('Add-ons', 'give'), 'install_plugins', 'give-addons', 'give_add_ons_page'); |
|
54 | 54 | |
55 | 55 | //Upgrades |
56 | - $give_upgrades_screen = add_submenu_page( null, __( 'Give Upgrades', 'give' ), __( 'Give Upgrades', 'give' ), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen' ); |
|
56 | + $give_upgrades_screen = add_submenu_page(null, __('Give Upgrades', 'give'), __('Give Upgrades', 'give'), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen'); |
|
57 | 57 | |
58 | 58 | |
59 | 59 | } |
60 | 60 | |
61 | -add_action( 'admin_menu', 'give_add_options_links', 10 ); |
|
61 | +add_action('admin_menu', 'give_add_options_links', 10); |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Determines whether the current admin page is a Give admin page. |
@@ -73,224 +73,224 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return bool True if Give admin page. |
75 | 75 | */ |
76 | -function give_is_admin_page( $passed_page = '', $passed_view = '' ) { |
|
76 | +function give_is_admin_page($passed_page = '', $passed_view = '') { |
|
77 | 77 | |
78 | 78 | global $pagenow, $typenow; |
79 | 79 | |
80 | 80 | $found = false; |
81 | - $post_type = isset( $_GET['post_type'] ) ? strtolower( $_GET['post_type'] ) : false; |
|
82 | - $action = isset( $_GET['action'] ) ? strtolower( $_GET['action'] ) : false; |
|
83 | - $taxonomy = isset( $_GET['taxonomy'] ) ? strtolower( $_GET['taxonomy'] ) : false; |
|
84 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
85 | - $view = isset( $_GET['view'] ) ? strtolower( $_GET['view'] ) : false; |
|
86 | - $tab = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : false; |
|
81 | + $post_type = isset($_GET['post_type']) ? strtolower($_GET['post_type']) : false; |
|
82 | + $action = isset($_GET['action']) ? strtolower($_GET['action']) : false; |
|
83 | + $taxonomy = isset($_GET['taxonomy']) ? strtolower($_GET['taxonomy']) : false; |
|
84 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
85 | + $view = isset($_GET['view']) ? strtolower($_GET['view']) : false; |
|
86 | + $tab = isset($_GET['tab']) ? strtolower($_GET['tab']) : false; |
|
87 | 87 | |
88 | - switch ( $passed_page ) { |
|
88 | + switch ($passed_page) { |
|
89 | 89 | case 'give_forms': |
90 | - switch ( $passed_view ) { |
|
90 | + switch ($passed_view) { |
|
91 | 91 | case 'list-table': |
92 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' ) { |
|
92 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php') { |
|
93 | 93 | $found = true; |
94 | 94 | } |
95 | 95 | break; |
96 | 96 | case 'edit': |
97 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post.php' ) { |
|
97 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post.php') { |
|
98 | 98 | $found = true; |
99 | 99 | } |
100 | 100 | break; |
101 | 101 | case 'new': |
102 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post-new.php' ) { |
|
102 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post-new.php') { |
|
103 | 103 | $found = true; |
104 | 104 | } |
105 | 105 | break; |
106 | 106 | default: |
107 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) || 'give_forms' === $post_type || ( 'post-new.php' == $pagenow && 'give_forms' === $post_type ) ) { |
|
107 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) || 'give_forms' === $post_type || ('post-new.php' == $pagenow && 'give_forms' === $post_type)) { |
|
108 | 108 | $found = true; |
109 | 109 | } |
110 | 110 | break; |
111 | 111 | } |
112 | 112 | break; |
113 | 113 | case 'categories': |
114 | - switch ( $passed_view ) { |
|
114 | + switch ($passed_view) { |
|
115 | 115 | case 'list-table': |
116 | 116 | case 'new': |
117 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy ) { |
|
117 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy) { |
|
118 | 118 | $found = true; |
119 | 119 | } |
120 | 120 | break; |
121 | 121 | case 'edit': |
122 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy ) { |
|
122 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy) { |
|
123 | 123 | $found = true; |
124 | 124 | } |
125 | 125 | break; |
126 | 126 | default: |
127 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy ) { |
|
127 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy) { |
|
128 | 128 | $found = true; |
129 | 129 | } |
130 | 130 | break; |
131 | 131 | } |
132 | 132 | break; |
133 | 133 | case 'tags': |
134 | - switch ( $passed_view ) { |
|
134 | + switch ($passed_view) { |
|
135 | 135 | case 'list-table': |
136 | 136 | case 'new': |
137 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy ) { |
|
137 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy) { |
|
138 | 138 | $found = true; |
139 | 139 | } |
140 | 140 | break; |
141 | 141 | case 'edit': |
142 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy ) { |
|
142 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy) { |
|
143 | 143 | $found = true; |
144 | 144 | } |
145 | 145 | break; |
146 | 146 | default: |
147 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy ) { |
|
147 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy) { |
|
148 | 148 | $found = true; |
149 | 149 | } |
150 | 150 | break; |
151 | 151 | } |
152 | 152 | break; |
153 | 153 | case 'payments': |
154 | - switch ( $passed_view ) { |
|
154 | + switch ($passed_view) { |
|
155 | 155 | case 'list-table': |
156 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view ) { |
|
156 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view) { |
|
157 | 157 | $found = true; |
158 | 158 | } |
159 | 159 | break; |
160 | 160 | case 'edit': |
161 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view ) { |
|
161 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view) { |
|
162 | 162 | $found = true; |
163 | 163 | } |
164 | 164 | break; |
165 | 165 | default: |
166 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page ) { |
|
166 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page) { |
|
167 | 167 | $found = true; |
168 | 168 | } |
169 | 169 | break; |
170 | 170 | } |
171 | 171 | break; |
172 | 172 | case 'reports': |
173 | - switch ( $passed_view ) { |
|
173 | + switch ($passed_view) { |
|
174 | 174 | // If you want to do something like enqueue a script on a particular report's duration, look at $_GET[ 'range' ] |
175 | 175 | case 'earnings': |
176 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) { |
|
176 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && ('earnings' === $view || '-1' === $view || false === $view)) { |
|
177 | 177 | $found = true; |
178 | 178 | } |
179 | 179 | break; |
180 | 180 | case 'donors': |
181 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view ) { |
|
181 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view) { |
|
182 | 182 | $found = true; |
183 | 183 | } |
184 | 184 | break; |
185 | 185 | case 'gateways': |
186 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view ) { |
|
186 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view) { |
|
187 | 187 | $found = true; |
188 | 188 | } |
189 | 189 | break; |
190 | 190 | case 'export': |
191 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view ) { |
|
191 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view) { |
|
192 | 192 | $found = true; |
193 | 193 | } |
194 | 194 | break; |
195 | 195 | case 'logs': |
196 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view ) { |
|
196 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view) { |
|
197 | 197 | $found = true; |
198 | 198 | } |
199 | 199 | break; |
200 | 200 | default: |
201 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) { |
|
201 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) { |
|
202 | 202 | $found = true; |
203 | 203 | } |
204 | 204 | break; |
205 | 205 | } |
206 | 206 | break; |
207 | 207 | case 'settings': |
208 | - switch ( $passed_view ) { |
|
208 | + switch ($passed_view) { |
|
209 | 209 | case 'general': |
210 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && ( 'general' === $tab || false === $tab ) ) { |
|
210 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && ('general' === $tab || false === $tab)) { |
|
211 | 211 | $found = true; |
212 | 212 | } |
213 | 213 | break; |
214 | 214 | case 'gateways': |
215 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab ) { |
|
215 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab) { |
|
216 | 216 | $found = true; |
217 | 217 | } |
218 | 218 | break; |
219 | 219 | case 'emails': |
220 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab ) { |
|
220 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab) { |
|
221 | 221 | $found = true; |
222 | 222 | } |
223 | 223 | break; |
224 | 224 | case 'display': |
225 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab ) { |
|
225 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab) { |
|
226 | 226 | $found = true; |
227 | 227 | } |
228 | 228 | break; |
229 | 229 | case 'licenses': |
230 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab ) { |
|
230 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab) { |
|
231 | 231 | $found = true; |
232 | 232 | } |
233 | 233 | break; |
234 | 234 | case 'api': |
235 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab ) { |
|
235 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab) { |
|
236 | 236 | $found = true; |
237 | 237 | } |
238 | 238 | break; |
239 | 239 | case 'advanced': |
240 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab ) { |
|
240 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab) { |
|
241 | 241 | $found = true; |
242 | 242 | } |
243 | 243 | break; |
244 | 244 | case 'system_info': |
245 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab ) { |
|
245 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab) { |
|
246 | 246 | $found = true; |
247 | 247 | } |
248 | 248 | break; |
249 | 249 | default: |
250 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page ) { |
|
250 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page) { |
|
251 | 251 | $found = true; |
252 | 252 | } |
253 | 253 | break; |
254 | 254 | } |
255 | 255 | break; |
256 | 256 | case 'addons': |
257 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-addons' === $page ) { |
|
257 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-addons' === $page) { |
|
258 | 258 | $found = true; |
259 | 259 | } |
260 | 260 | break; |
261 | 261 | case 'donors': |
262 | - switch ( $passed_view ) { |
|
262 | + switch ($passed_view) { |
|
263 | 263 | case 'list-table': |
264 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view ) { |
|
264 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view) { |
|
265 | 265 | $found = true; |
266 | 266 | } |
267 | 267 | break; |
268 | 268 | case 'overview': |
269 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view ) { |
|
269 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view) { |
|
270 | 270 | $found = true; |
271 | 271 | } |
272 | 272 | break; |
273 | 273 | case 'notes': |
274 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view ) { |
|
274 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view) { |
|
275 | 275 | $found = true; |
276 | 276 | } |
277 | 277 | break; |
278 | 278 | default: |
279 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page ) { |
|
279 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page) { |
|
280 | 280 | $found = true; |
281 | 281 | } |
282 | 282 | break; |
283 | 283 | } |
284 | 284 | break; |
285 | 285 | case 'reports': |
286 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) { |
|
286 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) { |
|
287 | 287 | $found = true; |
288 | 288 | } |
289 | 289 | break; |
290 | 290 | default: |
291 | 291 | global $give_payments_page, $give_settings_page, $give_reports_page, $give_system_info_page, $give_add_ons_page, $give_settings_export, $give_upgrades_screen, $give_customers_page; |
292 | 292 | |
293 | - $admin_pages = apply_filters( 'give_admin_pages', array( |
|
293 | + $admin_pages = apply_filters('give_admin_pages', array( |
|
294 | 294 | $give_payments_page, |
295 | 295 | $give_settings_page, |
296 | 296 | $give_reports_page, |
@@ -299,18 +299,18 @@ discard block |
||
299 | 299 | $give_upgrades_screen, |
300 | 300 | $give_settings_export, |
301 | 301 | $give_customers_page |
302 | - ) ); |
|
303 | - if ( 'give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow ) { |
|
302 | + )); |
|
303 | + if ('give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow) { |
|
304 | 304 | $found = true; |
305 | - if ( 'give-upgrades' === $page ) { |
|
305 | + if ('give-upgrades' === $page) { |
|
306 | 306 | $found = false; |
307 | 307 | } |
308 | - } elseif ( in_array( $pagenow, $admin_pages ) ) { |
|
308 | + } elseif (in_array($pagenow, $admin_pages)) { |
|
309 | 309 | $found = true; |
310 | 310 | } |
311 | 311 | break; |
312 | 312 | } |
313 | 313 | |
314 | - return (bool) apply_filters( 'give_is_admin_page', $found, $page, $view, $passed_page, $passed_view ); |
|
314 | + return (bool) apply_filters('give_is_admin_page', $found, $page, $view, $passed_page, $passed_view); |
|
315 | 315 | |
316 | 316 | } |
317 | 317 | \ No newline at end of file |