@@ -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,10 +24,10 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function __construct() { |
26 | 26 | |
27 | - $this->shortcode['title'] = esc_html__( 'Donation Receipt', 'give' ); |
|
28 | - $this->shortcode['label'] = esc_html__( 'Donation Receipt', 'give' ); |
|
27 | + $this->shortcode['title'] = esc_html__('Donation Receipt', 'give'); |
|
28 | + $this->shortcode['label'] = esc_html__('Donation Receipt', 'give'); |
|
29 | 29 | |
30 | - parent::__construct( 'give_receipt' ); |
|
30 | + parent::__construct('give_receipt'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -40,60 +40,60 @@ discard block |
||
40 | 40 | return array( |
41 | 41 | array( |
42 | 42 | 'type' => 'container', |
43 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
43 | + 'html' => sprintf('<p class="strong">%s</p>', esc_html__('Optional settings', 'give')), |
|
44 | 44 | ), |
45 | 45 | array( |
46 | 46 | 'type' => 'listbox', |
47 | 47 | 'name' => 'price', |
48 | - 'label' => esc_html__( 'Show Donation Amount:', 'give' ), |
|
48 | + 'label' => esc_html__('Show Donation Amount:', 'give'), |
|
49 | 49 | 'options' => array( |
50 | - 'true' => esc_html__( 'Show', 'give' ), |
|
51 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
50 | + 'true' => esc_html__('Show', 'give'), |
|
51 | + 'false' => esc_html__('Hide', 'give'), |
|
52 | 52 | ), |
53 | 53 | ), |
54 | 54 | array( |
55 | 55 | 'type' => 'listbox', |
56 | 56 | 'name' => 'donor', |
57 | - 'label' => esc_html__( 'Show Donor Name:', 'give' ), |
|
57 | + 'label' => esc_html__('Show Donor Name:', 'give'), |
|
58 | 58 | 'options' => array( |
59 | - 'true' => esc_html__( 'Show', 'give' ), |
|
60 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
59 | + 'true' => esc_html__('Show', 'give'), |
|
60 | + 'false' => esc_html__('Hide', 'give'), |
|
61 | 61 | ), |
62 | 62 | ), |
63 | 63 | array( |
64 | 64 | 'type' => 'listbox', |
65 | 65 | 'name' => 'date', |
66 | - 'label' => esc_html__( 'Show Date:', 'give' ), |
|
66 | + 'label' => esc_html__('Show Date:', 'give'), |
|
67 | 67 | 'options' => array( |
68 | - 'true' => esc_html__( 'Show', 'give' ), |
|
69 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
68 | + 'true' => esc_html__('Show', 'give'), |
|
69 | + 'false' => esc_html__('Hide', 'give'), |
|
70 | 70 | ), |
71 | 71 | ), |
72 | 72 | array( |
73 | 73 | 'type' => 'listbox', |
74 | 74 | 'name' => 'payment_key', |
75 | - 'label' => esc_html__( 'Show Payment Key:', 'give' ), |
|
75 | + 'label' => esc_html__('Show Payment Key:', 'give'), |
|
76 | 76 | 'options' => array( |
77 | - 'true' => esc_html__( 'Show', 'give' ), |
|
78 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
77 | + 'true' => esc_html__('Show', 'give'), |
|
78 | + 'false' => esc_html__('Hide', 'give'), |
|
79 | 79 | ), |
80 | 80 | ), |
81 | 81 | array( |
82 | 82 | 'type' => 'listbox', |
83 | 83 | 'name' => 'payment_method', |
84 | - 'label' => esc_html__( 'Show Payment Method:', 'give' ), |
|
84 | + 'label' => esc_html__('Show Payment Method:', 'give'), |
|
85 | 85 | 'options' => array( |
86 | - 'true' => esc_html__( 'Show', 'give' ), |
|
87 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
86 | + 'true' => esc_html__('Show', 'give'), |
|
87 | + 'false' => esc_html__('Hide', 'give'), |
|
88 | 88 | ), |
89 | 89 | ), |
90 | 90 | array( |
91 | 91 | 'type' => 'listbox', |
92 | 92 | 'name' => 'payment_id', |
93 | - 'label' => esc_html__( 'Show Payment ID:', 'give' ), |
|
93 | + 'label' => esc_html__('Show Payment ID:', 'give'), |
|
94 | 94 | 'options' => array( |
95 | - 'true' => esc_html__( 'Show', 'give' ), |
|
96 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
95 | + 'true' => esc_html__('Show', 'give'), |
|
96 | + 'false' => esc_html__('Hide', 'give'), |
|
97 | 97 | ), |
98 | 98 | ), |
99 | 99 | ); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | 23 | |
24 | - $this->shortcode['title'] = esc_html__( 'Register', 'give' ); |
|
25 | - $this->shortcode['label'] = esc_html__( 'Register', 'give' ); |
|
24 | + $this->shortcode['title'] = esc_html__('Register', 'give'); |
|
25 | + $this->shortcode['label'] = esc_html__('Register', 'give'); |
|
26 | 26 | |
27 | - parent::__construct( 'give_register' ); |
|
27 | + parent::__construct('give_register'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | return array( |
38 | 38 | array( |
39 | 39 | 'type' => 'container', |
40 | - 'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Redirect URL (optional):', 'give' ) ), |
|
40 | + 'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Redirect URL (optional):', 'give')), |
|
41 | 41 | ), |
42 | 42 | array( |
43 | 43 | 'type' => 'textbox', |
44 | 44 | 'name' => 'redirect', |
45 | 45 | 'minWidth' => 320, |
46 | - 'tooltip' => esc_attr__( 'Enter an URL here to redirect to after registering.', 'give' ), |
|
46 | + 'tooltip' => esc_attr__('Enter an URL here to redirect to after registering.', 'give'), |
|
47 | 47 | ), |
48 | 48 | ); |
49 | 49 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | 23 | |
24 | - $this->shortcode['label'] = esc_html__( 'Donation History', 'give' ); |
|
24 | + $this->shortcode['label'] = esc_html__('Donation History', 'give'); |
|
25 | 25 | |
26 | - parent::__construct( 'donation_history' ); |
|
26 | + parent::__construct('donation_history'); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 |
@@ -812,10 +812,10 @@ discard block |
||
812 | 812 | } |
813 | 813 | |
814 | 814 | if ( ! is_int( $params[1] ) |
815 | - && ! is_float( $params[1] ) |
|
816 | - && ! is_string( $params[1] ) |
|
817 | - && $params[1] !== null |
|
818 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
815 | + && ! is_float( $params[1] ) |
|
816 | + && ! is_string( $params[1] ) |
|
817 | + && $params[1] !== null |
|
818 | + && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
819 | 819 | ) { |
820 | 820 | trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
821 | 821 | |
@@ -823,10 +823,10 @@ discard block |
||
823 | 823 | } |
824 | 824 | |
825 | 825 | if ( isset( $params[2] ) |
826 | - && ! is_int( $params[2] ) |
|
827 | - && ! is_float( $params[2] ) |
|
828 | - && ! is_string( $params[2] ) |
|
829 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
826 | + && ! is_int( $params[2] ) |
|
827 | + && ! is_float( $params[2] ) |
|
828 | + && ! is_string( $params[2] ) |
|
829 | + && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
830 | 830 | ) { |
831 | 831 | trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
832 | 832 |
@@ -1481,6 +1481,7 @@ discard block |
||
1481 | 1481 | * Check if Import donation is duplicate |
1482 | 1482 | * |
1483 | 1483 | * @since 1.8.13 |
1484 | + * @param Give_Donate_Form $form |
|
1484 | 1485 | */ |
1485 | 1486 | function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) { |
1486 | 1487 | $return = false; |
@@ -1566,7 +1567,6 @@ discard block |
||
1566 | 1567 | * Import CSV in DB |
1567 | 1568 | * |
1568 | 1569 | * @param int $file_id CSV id |
1569 | - * @param array $mapto Map csv to meta key. |
|
1570 | 1570 | * @param int $start Start from which csv line. |
1571 | 1571 | * @param int $end End from which csv line. |
1572 | 1572 | */ |
@@ -2055,7 +2055,7 @@ discard block |
||
2055 | 2055 | * @since 1.8.13 |
2056 | 2056 | * |
2057 | 2057 | * @param array $list List of objects or arrays |
2058 | - * @param int|string $field Field from the object to place instead of the entire object |
|
2058 | + * @param string $field Field from the object to place instead of the entire object |
|
2059 | 2059 | * @param int|string $index_key Optional. Field from the object to use as keys for the new array. |
2060 | 2060 | * Default null. |
2061 | 2061 | * |
@@ -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,9 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function give_is_test_mode() { |
25 | 25 | |
26 | - $ret = give_is_setting_enabled( give_get_option( 'test_mode' ) ); |
|
26 | + $ret = give_is_setting_enabled(give_get_option('test_mode')); |
|
27 | 27 | |
28 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
28 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | function give_get_currency() { |
39 | 39 | |
40 | - $currency = give_get_option( 'currency', 'USD' ); |
|
40 | + $currency = give_get_option('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,9 +51,9 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function give_get_currency_position() { |
53 | 53 | |
54 | - $currency_pos = give_get_option( 'currency_position', 'before' ); |
|
54 | + $currency_pos = give_get_option('currency_position', 'before'); |
|
55 | 55 | |
56 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
56 | + return apply_filters('give_currency_position', $currency_pos); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -66,39 +66,39 @@ discard block |
||
66 | 66 | |
67 | 67 | function give_get_currencies() { |
68 | 68 | $currencies = array( |
69 | - 'USD' => __( 'US Dollars ($)', 'give' ), |
|
70 | - 'EUR' => __( 'Euros (€)', 'give' ), |
|
71 | - 'GBP' => __( 'Pounds Sterling (£)', 'give' ), |
|
72 | - 'AUD' => __( 'Australian Dollars ($)', 'give' ), |
|
73 | - 'BRL' => __( 'Brazilian Real (R$)', 'give' ), |
|
74 | - 'CAD' => __( 'Canadian Dollars ($)', 'give' ), |
|
75 | - 'CZK' => __( 'Czech Koruna (Kč)', 'give' ), |
|
76 | - 'DKK' => __( 'Danish Krone (kr.)', 'give' ), |
|
77 | - 'HKD' => __( 'Hong Kong Dollar ($)', 'give' ), |
|
78 | - 'HUF' => __( 'Hungarian Forint (Ft)', 'give' ), |
|
79 | - 'ILS' => __( 'Israeli Shekel (₪)', 'give' ), |
|
80 | - 'JPY' => __( 'Japanese Yen (¥)', 'give' ), |
|
81 | - 'MYR' => __( 'Malaysian Ringgits (RM)', 'give' ), |
|
82 | - 'MXN' => __( 'Mexican Peso ($)', 'give' ), |
|
83 | - 'MAD' => __( 'Moroccan Dirham (.د.م)', 'give' ), |
|
84 | - 'NZD' => __( 'New Zealand Dollar ($)', 'give' ), |
|
85 | - 'NOK' => __( 'Norwegian Krone (Kr.)', 'give' ), |
|
86 | - 'PHP' => __( 'Philippine Pesos (₱)', 'give' ), |
|
87 | - 'PLN' => __( 'Polish Zloty (zł)', 'give' ), |
|
88 | - 'SGD' => __( 'Singapore Dollar ($)', 'give' ), |
|
89 | - 'KRW' => __( 'South Korean Won (₩)', 'give' ), |
|
90 | - 'ZAR' => __( 'South African Rand (R)', 'give' ), |
|
91 | - 'SEK' => __( 'Swedish Krona (kr)', 'give' ), |
|
92 | - 'CHF' => __( 'Swiss Franc (CHF)', 'give' ), |
|
93 | - 'TWD' => __( 'Taiwan New Dollars (NT$)', 'give' ), |
|
94 | - 'THB' => __( 'Thai Baht (฿)', 'give' ), |
|
95 | - 'INR' => __( 'Indian Rupee (₹)', 'give' ), |
|
96 | - 'TRY' => __( 'Turkish Lira (₺)', 'give' ), |
|
97 | - 'RIAL' => __( 'Iranian Rial (﷼)', 'give' ), |
|
98 | - 'RUB' => __( 'Russian Rubles (руб)', 'give' ), |
|
69 | + 'USD' => __('US Dollars ($)', 'give'), |
|
70 | + 'EUR' => __('Euros (€)', 'give'), |
|
71 | + 'GBP' => __('Pounds Sterling (£)', 'give'), |
|
72 | + 'AUD' => __('Australian Dollars ($)', 'give'), |
|
73 | + 'BRL' => __('Brazilian Real (R$)', 'give'), |
|
74 | + 'CAD' => __('Canadian Dollars ($)', 'give'), |
|
75 | + 'CZK' => __('Czech Koruna (Kč)', 'give'), |
|
76 | + 'DKK' => __('Danish Krone (kr.)', 'give'), |
|
77 | + 'HKD' => __('Hong Kong Dollar ($)', 'give'), |
|
78 | + 'HUF' => __('Hungarian Forint (Ft)', 'give'), |
|
79 | + 'ILS' => __('Israeli Shekel (₪)', 'give'), |
|
80 | + 'JPY' => __('Japanese Yen (¥)', 'give'), |
|
81 | + 'MYR' => __('Malaysian Ringgits (RM)', 'give'), |
|
82 | + 'MXN' => __('Mexican Peso ($)', 'give'), |
|
83 | + 'MAD' => __('Moroccan Dirham (.د.م)', 'give'), |
|
84 | + 'NZD' => __('New Zealand Dollar ($)', 'give'), |
|
85 | + 'NOK' => __('Norwegian Krone (Kr.)', 'give'), |
|
86 | + 'PHP' => __('Philippine Pesos (₱)', 'give'), |
|
87 | + 'PLN' => __('Polish Zloty (zł)', 'give'), |
|
88 | + 'SGD' => __('Singapore Dollar ($)', 'give'), |
|
89 | + 'KRW' => __('South Korean Won (₩)', 'give'), |
|
90 | + 'ZAR' => __('South African Rand (R)', 'give'), |
|
91 | + 'SEK' => __('Swedish Krona (kr)', 'give'), |
|
92 | + 'CHF' => __('Swiss Franc (CHF)', 'give'), |
|
93 | + 'TWD' => __('Taiwan New Dollars (NT$)', 'give'), |
|
94 | + 'THB' => __('Thai Baht (฿)', 'give'), |
|
95 | + 'INR' => __('Indian Rupee (₹)', 'give'), |
|
96 | + 'TRY' => __('Turkish Lira (₺)', 'give'), |
|
97 | + 'RIAL' => __('Iranian Rial (﷼)', 'give'), |
|
98 | + 'RUB' => __('Russian Rubles (руб)', 'give'), |
|
99 | 99 | ); |
100 | 100 | |
101 | - return apply_filters( 'give_currencies', $currencies ); |
|
101 | + return apply_filters('give_currencies', $currencies); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return string The symbol to use for the currency |
117 | 117 | */ |
118 | -function give_currency_symbol( $currency = '', $decode_currency = false ) { |
|
118 | +function give_currency_symbol($currency = '', $decode_currency = false) { |
|
119 | 119 | |
120 | - if ( empty( $currency ) ) { |
|
120 | + if (empty($currency)) { |
|
121 | 121 | $currency = give_get_currency(); |
122 | 122 | } |
123 | - switch ( $currency ) : |
|
123 | + switch ($currency) : |
|
124 | 124 | case 'GBP' : |
125 | 125 | $symbol = '£'; |
126 | 126 | break; |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | break; |
199 | 199 | endswitch; |
200 | 200 | |
201 | - $symbol = ( ! $decode_currency ? $symbol : html_entity_decode( $symbol ) ); |
|
201 | + $symbol = ( ! $decode_currency ? $symbol : html_entity_decode($symbol)); |
|
202 | 202 | |
203 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
203 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | |
@@ -213,16 +213,16 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @return string |
215 | 215 | */ |
216 | -function give_get_currency_name( $currency_code ) { |
|
216 | +function give_get_currency_name($currency_code) { |
|
217 | 217 | $currency_name = ''; |
218 | 218 | $currency_names = give_get_currencies(); |
219 | 219 | |
220 | - if ( $currency_code && array_key_exists( $currency_code, $currency_names ) ) { |
|
221 | - $currency_name = explode( '(', $currency_names[ $currency_code ] ); |
|
222 | - $currency_name = trim( current( $currency_name ) ); |
|
220 | + if ($currency_code && array_key_exists($currency_code, $currency_names)) { |
|
221 | + $currency_name = explode('(', $currency_names[$currency_code]); |
|
222 | + $currency_name = trim(current($currency_name)); |
|
223 | 223 | } |
224 | 224 | |
225 | - return apply_filters( 'give_currency_name', $currency_name, $currency_code ); |
|
225 | + return apply_filters('give_currency_name', $currency_name, $currency_code); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -236,21 +236,21 @@ discard block |
||
236 | 236 | |
237 | 237 | global $wp; |
238 | 238 | |
239 | - if ( get_option( 'permalink_structure' ) ) { |
|
240 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
239 | + if (get_option('permalink_structure')) { |
|
240 | + $base = trailingslashit(home_url($wp->request)); |
|
241 | 241 | } else { |
242 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
243 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
242 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
243 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | $scheme = is_ssl() ? 'https' : 'http'; |
247 | - $current_uri = set_url_scheme( $base, $scheme ); |
|
247 | + $current_uri = set_url_scheme($base, $scheme); |
|
248 | 248 | |
249 | - if ( is_front_page() ) { |
|
250 | - $current_uri = home_url( '/' ); |
|
249 | + if (is_front_page()) { |
|
250 | + $current_uri = home_url('/'); |
|
251 | 251 | } |
252 | 252 | |
253 | - return apply_filters( 'give_get_current_page_url', $current_uri ); |
|
253 | + return apply_filters('give_get_current_page_url', $current_uri); |
|
254 | 254 | |
255 | 255 | } |
256 | 256 | |
@@ -272,15 +272,15 @@ discard block |
||
272 | 272 | */ |
273 | 273 | $gateways = give_get_enabled_payment_gateways(); |
274 | 274 | |
275 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
275 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
276 | 276 | $ret = true; |
277 | - } elseif ( count( $gateways ) == 1 ) { |
|
277 | + } elseif (count($gateways) == 1) { |
|
278 | 278 | $ret = false; |
279 | - } elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
279 | + } elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
280 | 280 | $ret = false; |
281 | 281 | } |
282 | 282 | |
283 | - return (bool) apply_filters( 'give_verify_credit_cards', $ret ); |
|
283 | + return (bool) apply_filters('give_verify_credit_cards', $ret); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -292,26 +292,26 @@ discard block |
||
292 | 292 | function give_get_timezone_id() { |
293 | 293 | |
294 | 294 | // if site timezone string exists, return it. |
295 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
295 | + if ($timezone = get_option('timezone_string')) { |
|
296 | 296 | return $timezone; |
297 | 297 | } |
298 | 298 | |
299 | 299 | // get UTC offset, if it isn't set return UTC. |
300 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
300 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
301 | 301 | return 'UTC'; |
302 | 302 | } |
303 | 303 | |
304 | 304 | // attempt to guess the timezone string from the UTC offset. |
305 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
305 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
306 | 306 | |
307 | 307 | // last try, guess timezone string manually. |
308 | - if ( $timezone === false ) { |
|
308 | + if ($timezone === false) { |
|
309 | 309 | |
310 | - $is_dst = date( 'I' ); |
|
310 | + $is_dst = date('I'); |
|
311 | 311 | |
312 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
313 | - foreach ( $abbr as $city ) { |
|
314 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
312 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
313 | + foreach ($abbr as $city) { |
|
314 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
315 | 315 | return $city['timezone_id']; |
316 | 316 | } |
317 | 317 | } |
@@ -335,17 +335,17 @@ discard block |
||
335 | 335 | |
336 | 336 | $ip = '127.0.0.1'; |
337 | 337 | |
338 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
338 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
339 | 339 | // check ip from share internet |
340 | 340 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
341 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
341 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
342 | 342 | // to check ip is pass from proxy |
343 | 343 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
344 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
344 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
345 | 345 | $ip = $_SERVER['REMOTE_ADDR']; |
346 | 346 | } |
347 | 347 | |
348 | - return apply_filters( 'give_get_ip', $ip ); |
|
348 | + return apply_filters('give_get_ip', $ip); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @uses Give()->session->set() |
362 | 362 | */ |
363 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
364 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
365 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
363 | +function give_set_purchase_session($purchase_data = array()) { |
|
364 | + Give()->session->set('give_purchase', $purchase_data); |
|
365 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | * @return mixed array | false |
377 | 377 | */ |
378 | 378 | function give_get_purchase_session() { |
379 | - return Give()->session->get( 'give_purchase' ); |
|
379 | + return Give()->session->get('give_purchase'); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | /** |
@@ -392,40 +392,40 @@ discard block |
||
392 | 392 | * |
393 | 393 | * @return string |
394 | 394 | */ |
395 | -function give_payment_gateway_donation_summary( $donation_data, $name_and_email = true, $length = 255 ) { |
|
395 | +function give_payment_gateway_donation_summary($donation_data, $name_and_email = true, $length = 255) { |
|
396 | 396 | |
397 | 397 | $summary = ''; |
398 | 398 | |
399 | - $form_id = isset( $donation_data['post_data']['give-form-id'] ) ? $donation_data['post_data']['give-form-id'] : ''; |
|
399 | + $form_id = isset($donation_data['post_data']['give-form-id']) ? $donation_data['post_data']['give-form-id'] : ''; |
|
400 | 400 | |
401 | 401 | // Form title. |
402 | - if ( isset( $donation_data['post_data']['give-form-title'] ) ) { |
|
402 | + if (isset($donation_data['post_data']['give-form-title'])) { |
|
403 | 403 | $summary .= $donation_data['post_data']['give-form-title']; |
404 | 404 | } |
405 | 405 | // Form multilevel if applicable. |
406 | - if ( isset( $donation_data['post_data']['give-price-id'] ) ) { |
|
407 | - $summary .= ': ' . give_get_price_option_name( $form_id, $donation_data['post_data']['give-price-id'] ); |
|
406 | + if (isset($donation_data['post_data']['give-price-id'])) { |
|
407 | + $summary .= ': '.give_get_price_option_name($form_id, $donation_data['post_data']['give-price-id']); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | // Add Donor's name + email if requested. |
411 | - if ( $name_and_email ) { |
|
411 | + if ($name_and_email) { |
|
412 | 412 | |
413 | 413 | // First name |
414 | - if ( isset( $donation_data['user_info']['first_name'] ) && ! empty( $donation_data['user_info']['first_name'] ) ) { |
|
415 | - $summary .= ' - ' . $donation_data['user_info']['first_name']; |
|
414 | + if (isset($donation_data['user_info']['first_name']) && ! empty($donation_data['user_info']['first_name'])) { |
|
415 | + $summary .= ' - '.$donation_data['user_info']['first_name']; |
|
416 | 416 | } |
417 | 417 | |
418 | - if ( isset( $donation_data['user_info']['last_name'] ) && ! empty( $donation_data['user_info']['last_name'] ) ) { |
|
419 | - $summary .= ' ' . $donation_data['user_info']['last_name']; |
|
418 | + if (isset($donation_data['user_info']['last_name']) && ! empty($donation_data['user_info']['last_name'])) { |
|
419 | + $summary .= ' '.$donation_data['user_info']['last_name']; |
|
420 | 420 | } |
421 | 421 | |
422 | - $summary .= ' (' . $donation_data['user_email'] . ')'; |
|
422 | + $summary .= ' ('.$donation_data['user_email'].')'; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | // Cut the length |
426 | - $summary = substr( $summary, 0, $length ); |
|
426 | + $summary = substr($summary, 0, $length); |
|
427 | 427 | |
428 | - return apply_filters( 'give_payment_gateway_donation_summary', $summary ); |
|
428 | + return apply_filters('give_payment_gateway_donation_summary', $summary); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | |
@@ -440,31 +440,31 @@ discard block |
||
440 | 440 | function give_get_host() { |
441 | 441 | $host = false; |
442 | 442 | |
443 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
443 | + if (defined('WPE_APIKEY')) { |
|
444 | 444 | $host = 'WP Engine'; |
445 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
445 | + } elseif (defined('PAGELYBIN')) { |
|
446 | 446 | $host = 'Pagely'; |
447 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
447 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
448 | 448 | $host = 'ICDSoft'; |
449 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
449 | + } elseif (DB_HOST == 'mysqlv5') { |
|
450 | 450 | $host = 'NetworkSolutions'; |
451 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
451 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
452 | 452 | $host = 'iPage'; |
453 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
453 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
454 | 454 | $host = 'IPower'; |
455 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
455 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
456 | 456 | $host = 'MediaTemple Grid'; |
457 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
457 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
458 | 458 | $host = 'pair Networks'; |
459 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
459 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
460 | 460 | $host = 'Rackspace Cloud'; |
461 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
461 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
462 | 462 | $host = 'SysFix.eu Power Hosting'; |
463 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
463 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
464 | 464 | $host = 'Flywheel'; |
465 | 465 | } else { |
466 | 466 | // Adding a general fallback for data gathering |
467 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
467 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | return $host; |
@@ -480,67 +480,67 @@ discard block |
||
480 | 480 | * |
481 | 481 | * @return bool true if host matches, false if not |
482 | 482 | */ |
483 | -function give_is_host( $host = false ) { |
|
483 | +function give_is_host($host = false) { |
|
484 | 484 | |
485 | 485 | $return = false; |
486 | 486 | |
487 | - if ( $host ) { |
|
488 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
487 | + if ($host) { |
|
488 | + $host = str_replace(' ', '', strtolower($host)); |
|
489 | 489 | |
490 | - switch ( $host ) { |
|
490 | + switch ($host) { |
|
491 | 491 | case 'wpengine': |
492 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
492 | + if (defined('WPE_APIKEY')) { |
|
493 | 493 | $return = true; |
494 | 494 | } |
495 | 495 | break; |
496 | 496 | case 'pagely': |
497 | - if ( defined( 'PAGELYBIN' ) ) { |
|
497 | + if (defined('PAGELYBIN')) { |
|
498 | 498 | $return = true; |
499 | 499 | } |
500 | 500 | break; |
501 | 501 | case 'icdsoft': |
502 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
502 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
503 | 503 | $return = true; |
504 | 504 | } |
505 | 505 | break; |
506 | 506 | case 'networksolutions': |
507 | - if ( DB_HOST == 'mysqlv5' ) { |
|
507 | + if (DB_HOST == 'mysqlv5') { |
|
508 | 508 | $return = true; |
509 | 509 | } |
510 | 510 | break; |
511 | 511 | case 'ipage': |
512 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
512 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
513 | 513 | $return = true; |
514 | 514 | } |
515 | 515 | break; |
516 | 516 | case 'ipower': |
517 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
517 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
518 | 518 | $return = true; |
519 | 519 | } |
520 | 520 | break; |
521 | 521 | case 'mediatemplegrid': |
522 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
522 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
523 | 523 | $return = true; |
524 | 524 | } |
525 | 525 | break; |
526 | 526 | case 'pairnetworks': |
527 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
527 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
528 | 528 | $return = true; |
529 | 529 | } |
530 | 530 | break; |
531 | 531 | case 'rackspacecloud': |
532 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
532 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
533 | 533 | $return = true; |
534 | 534 | } |
535 | 535 | break; |
536 | 536 | case 'sysfix.eu': |
537 | 537 | case 'sysfix.eupowerhosting': |
538 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
538 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
539 | 539 | $return = true; |
540 | 540 | } |
541 | 541 | break; |
542 | 542 | case 'flywheel': |
543 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
543 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
544 | 544 | $return = true; |
545 | 545 | } |
546 | 546 | break; |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | * @param string $replacement Optional. The function that should have been called. |
574 | 574 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
575 | 575 | */ |
576 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
576 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
577 | 577 | |
578 | 578 | /** |
579 | 579 | * Fires while give deprecated function call occurs. |
@@ -586,19 +586,19 @@ discard block |
||
586 | 586 | * @param string $replacement Optional. The function that should have been called. |
587 | 587 | * @param string $version The plugin version that deprecated the function. |
588 | 588 | */ |
589 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
589 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
590 | 590 | |
591 | - $show_errors = current_user_can( 'manage_options' ); |
|
591 | + $show_errors = current_user_can('manage_options'); |
|
592 | 592 | |
593 | 593 | // Allow plugin to filter the output error trigger. |
594 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
595 | - if ( ! is_null( $replacement ) ) { |
|
596 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
597 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
594 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
595 | + if ( ! is_null($replacement)) { |
|
596 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
597 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
598 | 598 | // Alternatively we could dump this to a file. |
599 | 599 | } else { |
600 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
601 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
600 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
601 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
602 | 602 | // Alternatively we could dump this to a file. |
603 | 603 | } |
604 | 604 | } |
@@ -612,8 +612,8 @@ discard block |
||
612 | 612 | * @return string $post_id |
613 | 613 | */ |
614 | 614 | function give_get_admin_post_id() { |
615 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
616 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
615 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
616 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
617 | 617 | $post_id = $_POST['post_id']; |
618 | 618 | } |
619 | 619 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | * @return string Arg separator output |
628 | 628 | */ |
629 | 629 | function give_get_php_arg_separator_output() { |
630 | - return ini_get( 'arg_separator.output' ); |
|
630 | + return ini_get('arg_separator.output'); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | |
@@ -642,10 +642,10 @@ discard block |
||
642 | 642 | * |
643 | 643 | * @return string Short month name |
644 | 644 | */ |
645 | -function give_month_num_to_name( $n ) { |
|
646 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
645 | +function give_month_num_to_name($n) { |
|
646 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
647 | 647 | |
648 | - return date_i18n( 'M', $timestamp ); |
|
648 | + return date_i18n('M', $timestamp); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | |
@@ -658,10 +658,10 @@ discard block |
||
658 | 658 | * |
659 | 659 | * @return bool Whether or not function is disabled. |
660 | 660 | */ |
661 | -function give_is_func_disabled( $function ) { |
|
662 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
661 | +function give_is_func_disabled($function) { |
|
662 | + $disabled = explode(',', ini_get('disable_functions')); |
|
663 | 663 | |
664 | - return in_array( $function, $disabled ); |
|
664 | + return in_array($function, $disabled); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | function give_get_newsletter() { |
674 | 674 | ?> |
675 | 675 | |
676 | - <p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> |
|
676 | + <p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> |
|
677 | 677 | |
678 | 678 | <div class="give-newsletter-form-wrap"> |
679 | 679 | |
@@ -681,33 +681,33 @@ discard block |
||
681 | 681 | method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" |
682 | 682 | target="_blank" novalidate> |
683 | 683 | <div class="give-newsletter-confirmation"> |
684 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
684 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
685 | 685 | </div> |
686 | 686 | |
687 | 687 | <table class="form-table give-newsletter-form"> |
688 | 688 | <tr valign="middle"> |
689 | 689 | <td> |
690 | 690 | <label for="mce-EMAIL" |
691 | - class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label> |
|
691 | + class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label> |
|
692 | 692 | <input type="email" name="EMAIL" id="mce-EMAIL" |
693 | - placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" |
|
693 | + placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" |
|
694 | 694 | class="required email" value=""> |
695 | 695 | </td> |
696 | 696 | <td> |
697 | 697 | <label for="mce-FNAME" |
698 | - class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label> |
|
698 | + class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label> |
|
699 | 699 | <input type="text" name="FNAME" id="mce-FNAME" |
700 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value=""> |
|
700 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value=""> |
|
701 | 701 | </td> |
702 | 702 | <td> |
703 | 703 | <label for="mce-LNAME" |
704 | - class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label> |
|
704 | + class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label> |
|
705 | 705 | <input type="text" name="LNAME" id="mce-LNAME" |
706 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value=""> |
|
706 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value=""> |
|
707 | 707 | </td> |
708 | 708 | <td> |
709 | 709 | <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" |
710 | - value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>"> |
|
710 | + value="<?php esc_attr_e('Subscribe', 'give'); ?>"> |
|
711 | 711 | </td> |
712 | 712 | </tr> |
713 | 713 | </table> |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | * |
760 | 760 | * @return string |
761 | 761 | */ |
762 | -function give_svg_icons( $icon ) { |
|
762 | +function give_svg_icons($icon) { |
|
763 | 763 | |
764 | 764 | // Store your SVGs in an associative array |
765 | 765 | $svgs = array( |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | ); |
772 | 772 | |
773 | 773 | // Return the chosen icon's SVG string |
774 | - return $svgs[ $icon ]; |
|
774 | + return $svgs[$icon]; |
|
775 | 775 | } |
776 | 776 | |
777 | 777 | /** |
@@ -783,15 +783,15 @@ discard block |
||
783 | 783 | * |
784 | 784 | * @return mixed |
785 | 785 | */ |
786 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
787 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
788 | - $post_type->labels->name = esc_html__( 'Donation Forms', 'give' ); |
|
786 | +function modify_nav_menu_meta_box_object($post_type) { |
|
787 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
788 | + $post_type->labels->name = esc_html__('Donation Forms', 'give'); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | return $post_type; |
792 | 792 | } |
793 | 793 | |
794 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
794 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
795 | 795 | |
796 | 796 | /** |
797 | 797 | * Enable 'Donation Form' meta enabled by default on Menu page. |
@@ -801,22 +801,22 @@ discard block |
||
801 | 801 | function give_nav_donation_metabox_enabled() { |
802 | 802 | |
803 | 803 | // Return false, if it fails to retrieve hidden meta box list and is not admin. |
804 | - if ( ( ! $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus' ) ) || ! is_admin() ) { |
|
804 | + if (( ! $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus')) || ! is_admin()) { |
|
805 | 805 | return false; |
806 | 806 | } |
807 | 807 | |
808 | 808 | // Return false, In case, we don't find 'Donation Form' in hidden meta box list. |
809 | - if ( ! in_array( 'add-post-type-give_forms', $hidden_meta_boxes, true ) ) { |
|
809 | + if ( ! in_array('add-post-type-give_forms', $hidden_meta_boxes, true)) { |
|
810 | 810 | return false; |
811 | 811 | } |
812 | 812 | |
813 | 813 | // Exclude 'Donation Form' value from hidden meta box's list. |
814 | - $hidden_meta_boxes = array_diff( $hidden_meta_boxes, array( 'add-post-type-give_forms' ) ); |
|
814 | + $hidden_meta_boxes = array_diff($hidden_meta_boxes, array('add-post-type-give_forms')); |
|
815 | 815 | |
816 | 816 | // Get current user ID. |
817 | 817 | $user = wp_get_current_user(); |
818 | 818 | |
819 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
819 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | /** |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | * @license https://opensource.org/licenses/MIT MIT |
831 | 831 | */ |
832 | 832 | |
833 | -if ( ! function_exists( 'array_column' ) ) { |
|
833 | +if ( ! function_exists('array_column')) { |
|
834 | 834 | /** |
835 | 835 | * Returns the values from a single column of the input array, identified by |
836 | 836 | * the $columnKey. |
@@ -849,53 +849,53 @@ discard block |
||
849 | 849 | * |
850 | 850 | * @return array |
851 | 851 | */ |
852 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
852 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
853 | 853 | // Using func_get_args() in order to check for proper number of |
854 | 854 | // parameters and trigger errors exactly as the built-in array_column() |
855 | 855 | // does in PHP 5.5. |
856 | 856 | $argc = func_num_args(); |
857 | 857 | $params = func_get_args(); |
858 | 858 | |
859 | - if ( $argc < 2 ) { |
|
860 | - trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING ); |
|
859 | + if ($argc < 2) { |
|
860 | + trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING); |
|
861 | 861 | |
862 | 862 | return null; |
863 | 863 | } |
864 | 864 | |
865 | - if ( ! is_array( $params[0] ) ) { |
|
866 | - trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING ); |
|
865 | + if ( ! is_array($params[0])) { |
|
866 | + trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING); |
|
867 | 867 | |
868 | 868 | return null; |
869 | 869 | } |
870 | 870 | |
871 | - if ( ! is_int( $params[1] ) |
|
872 | - && ! is_float( $params[1] ) |
|
873 | - && ! is_string( $params[1] ) |
|
871 | + if ( ! is_int($params[1]) |
|
872 | + && ! is_float($params[1]) |
|
873 | + && ! is_string($params[1]) |
|
874 | 874 | && $params[1] !== null |
875 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
875 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
876 | 876 | ) { |
877 | - trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
877 | + trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
878 | 878 | |
879 | 879 | return false; |
880 | 880 | } |
881 | 881 | |
882 | - if ( isset( $params[2] ) |
|
883 | - && ! is_int( $params[2] ) |
|
884 | - && ! is_float( $params[2] ) |
|
885 | - && ! is_string( $params[2] ) |
|
886 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
882 | + if (isset($params[2]) |
|
883 | + && ! is_int($params[2]) |
|
884 | + && ! is_float($params[2]) |
|
885 | + && ! is_string($params[2]) |
|
886 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
887 | 887 | ) { |
888 | - trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
888 | + trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
889 | 889 | |
890 | 890 | return false; |
891 | 891 | } |
892 | 892 | |
893 | 893 | $paramsInput = $params[0]; |
894 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
894 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
895 | 895 | |
896 | 896 | $paramsIndexKey = null; |
897 | - if ( isset( $params[2] ) ) { |
|
898 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
897 | + if (isset($params[2])) { |
|
898 | + if (is_float($params[2]) || is_int($params[2])) { |
|
899 | 899 | $paramsIndexKey = (int) $params[2]; |
900 | 900 | } else { |
901 | 901 | $paramsIndexKey = (string) $params[2]; |
@@ -904,26 +904,26 @@ discard block |
||
904 | 904 | |
905 | 905 | $resultArray = array(); |
906 | 906 | |
907 | - foreach ( $paramsInput as $row ) { |
|
907 | + foreach ($paramsInput as $row) { |
|
908 | 908 | $key = $value = null; |
909 | 909 | $keySet = $valueSet = false; |
910 | 910 | |
911 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
911 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
912 | 912 | $keySet = true; |
913 | - $key = (string) $row[ $paramsIndexKey ]; |
|
913 | + $key = (string) $row[$paramsIndexKey]; |
|
914 | 914 | } |
915 | 915 | |
916 | - if ( $paramsColumnKey === null ) { |
|
916 | + if ($paramsColumnKey === null) { |
|
917 | 917 | $valueSet = true; |
918 | 918 | $value = $row; |
919 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
919 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
920 | 920 | $valueSet = true; |
921 | - $value = $row[ $paramsColumnKey ]; |
|
921 | + $value = $row[$paramsColumnKey]; |
|
922 | 922 | } |
923 | 923 | |
924 | - if ( $valueSet ) { |
|
925 | - if ( $keySet ) { |
|
926 | - $resultArray[ $key ] = $value; |
|
924 | + if ($valueSet) { |
|
925 | + if ($keySet) { |
|
926 | + $resultArray[$key] = $value; |
|
927 | 927 | } else { |
928 | 928 | $resultArray[] = $value; |
929 | 929 | } |
@@ -943,40 +943,40 @@ discard block |
||
943 | 943 | * |
944 | 944 | * @return bool Whether the receipt is visible or not. |
945 | 945 | */ |
946 | -function give_can_view_receipt( $payment_key = '' ) { |
|
946 | +function give_can_view_receipt($payment_key = '') { |
|
947 | 947 | |
948 | 948 | $return = false; |
949 | 949 | |
950 | - if ( empty( $payment_key ) ) { |
|
950 | + if (empty($payment_key)) { |
|
951 | 951 | return $return; |
952 | 952 | } |
953 | 953 | |
954 | 954 | global $give_receipt_args; |
955 | 955 | |
956 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
956 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
957 | 957 | |
958 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
958 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
959 | 959 | |
960 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
960 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
961 | 961 | |
962 | - if ( is_user_logged_in() ) { |
|
963 | - if ( $user_id === (int) get_current_user_id() ) { |
|
962 | + if (is_user_logged_in()) { |
|
963 | + if ($user_id === (int) get_current_user_id()) { |
|
964 | 964 | $return = true; |
965 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
965 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
966 | 966 | $return = true; |
967 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
967 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
968 | 968 | $return = true; |
969 | 969 | } |
970 | 970 | } |
971 | 971 | |
972 | 972 | $session = give_get_purchase_session(); |
973 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
974 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
973 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
974 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
975 | 975 | $return = true; |
976 | 976 | } |
977 | 977 | } |
978 | 978 | |
979 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
979 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
980 | 980 | |
981 | 981 | } |
982 | 982 | |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | * |
986 | 986 | * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
987 | 987 | */ |
988 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
988 | +if ( ! function_exists('cal_days_in_month')) { |
|
989 | 989 | /** |
990 | 990 | * cal_days_in_month |
991 | 991 | * |
@@ -995,8 +995,8 @@ discard block |
||
995 | 995 | * |
996 | 996 | * @return bool|string |
997 | 997 | */ |
998 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
999 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
998 | + function cal_days_in_month($calendar, $month, $year) { |
|
999 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
1000 | 1000 | } |
1001 | 1001 | } |
1002 | 1002 | |
@@ -1015,42 +1015,42 @@ discard block |
||
1015 | 1015 | */ |
1016 | 1016 | function give_get_plugins() { |
1017 | 1017 | $plugins = get_plugins(); |
1018 | - $active_plugin_paths = (array) get_option( 'active_plugins', array() ); |
|
1018 | + $active_plugin_paths = (array) get_option('active_plugins', array()); |
|
1019 | 1019 | |
1020 | - if ( is_multisite() ) { |
|
1021 | - $network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
1022 | - $active_plugin_paths = array_merge( $active_plugin_paths, $network_activated_plugin_paths ); |
|
1020 | + if (is_multisite()) { |
|
1021 | + $network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
1022 | + $active_plugin_paths = array_merge($active_plugin_paths, $network_activated_plugin_paths); |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | - foreach ( $plugins as $plugin_path => $plugin_data ) { |
|
1025 | + foreach ($plugins as $plugin_path => $plugin_data) { |
|
1026 | 1026 | // Is plugin active? |
1027 | - if ( in_array( $plugin_path, $active_plugin_paths ) ) { |
|
1028 | - $plugins[ $plugin_path ]['Status'] = 'active'; |
|
1027 | + if (in_array($plugin_path, $active_plugin_paths)) { |
|
1028 | + $plugins[$plugin_path]['Status'] = 'active'; |
|
1029 | 1029 | } else { |
1030 | - $plugins[ $plugin_path ]['Status'] = 'inactive'; |
|
1030 | + $plugins[$plugin_path]['Status'] = 'inactive'; |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | - $dirname = strtolower( dirname( $plugin_path ) ); |
|
1033 | + $dirname = strtolower(dirname($plugin_path)); |
|
1034 | 1034 | |
1035 | 1035 | // Is plugin a Give add-on by WordImpress? |
1036 | - if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) { |
|
1036 | + if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) { |
|
1037 | 1037 | // Plugin is a Give-addon. |
1038 | - $plugins[ $plugin_path ]['Type'] = 'add-on'; |
|
1038 | + $plugins[$plugin_path]['Type'] = 'add-on'; |
|
1039 | 1039 | |
1040 | 1040 | // Get license info from database. |
1041 | - $plugin_name = str_replace( 'Give - ', '', $plugin_data['Name'] ); |
|
1042 | - $db_option = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active'; |
|
1043 | - $license_active = get_option( $db_option ); |
|
1041 | + $plugin_name = str_replace('Give - ', '', $plugin_data['Name']); |
|
1042 | + $db_option = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active'; |
|
1043 | + $license_active = get_option($db_option); |
|
1044 | 1044 | |
1045 | 1045 | // Does a valid license exist? |
1046 | - if ( ! empty( $license_active ) && 'valid' === $license_active->license ) { |
|
1047 | - $plugins[ $plugin_path ]['License'] = true; |
|
1046 | + if ( ! empty($license_active) && 'valid' === $license_active->license) { |
|
1047 | + $plugins[$plugin_path]['License'] = true; |
|
1048 | 1048 | } else { |
1049 | - $plugins[ $plugin_path ]['License'] = false; |
|
1049 | + $plugins[$plugin_path]['License'] = false; |
|
1050 | 1050 | } |
1051 | 1051 | } else { |
1052 | 1052 | // Plugin is not a Give add-on. |
1053 | - $plugins[ $plugin_path ]['Type'] = 'other'; |
|
1053 | + $plugins[$plugin_path]['Type'] = 'other'; |
|
1054 | 1054 | } |
1055 | 1055 | } |
1056 | 1056 | |
@@ -1067,16 +1067,16 @@ discard block |
||
1067 | 1067 | * |
1068 | 1068 | * @return bool |
1069 | 1069 | */ |
1070 | -function give_is_terms_enabled( $form_id ) { |
|
1071 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
1070 | +function give_is_terms_enabled($form_id) { |
|
1071 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
1072 | 1072 | |
1073 | 1073 | if ( |
1074 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1075 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1074 | + give_is_setting_enabled($form_option, 'global') |
|
1075 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1076 | 1076 | ) { |
1077 | 1077 | return true; |
1078 | 1078 | |
1079 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1079 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1080 | 1080 | return true; |
1081 | 1081 | |
1082 | 1082 | } else { |
@@ -1100,9 +1100,9 @@ discard block |
||
1100 | 1100 | * |
1101 | 1101 | * @return WP_Error|bool |
1102 | 1102 | */ |
1103 | -function give_delete_donation_stats( $date_range = '', $args = array() ) { |
|
1103 | +function give_delete_donation_stats($date_range = '', $args = array()) { |
|
1104 | 1104 | // Delete all cache. |
1105 | - $status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) ); |
|
1105 | + $status = Give_Cache::delete(Give_Cache::get_options_like('give_stats')); |
|
1106 | 1106 | |
1107 | 1107 | /** |
1108 | 1108 | * Fire the action when donation stats delete. |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | * @param string|array $date_range |
1113 | 1113 | * @param array $args |
1114 | 1114 | */ |
1115 | - do_action( 'give_delete_donation_stats', $status, $date_range, $args ); |
|
1115 | + do_action('give_delete_donation_stats', $status, $date_range, $args); |
|
1116 | 1116 | |
1117 | 1117 | return $status; |
1118 | 1118 | } |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | * |
1131 | 1131 | * @return mixed |
1132 | 1132 | */ |
1133 | -function give_get_meta( $id, $meta_key, $single = false, $default = false ) { |
|
1133 | +function give_get_meta($id, $meta_key, $single = false, $default = false) { |
|
1134 | 1134 | /** |
1135 | 1135 | * Filter the meta value |
1136 | 1136 | * |
@@ -1138,14 +1138,14 @@ discard block |
||
1138 | 1138 | */ |
1139 | 1139 | $meta_value = apply_filters( |
1140 | 1140 | 'give_get_meta', |
1141 | - get_post_meta( $id, $meta_key, $single ), |
|
1141 | + get_post_meta($id, $meta_key, $single), |
|
1142 | 1142 | $id, |
1143 | 1143 | $meta_key, |
1144 | 1144 | $default |
1145 | 1145 | ); |
1146 | 1146 | |
1147 | 1147 | if ( |
1148 | - ( empty( $meta_key ) || empty( $meta_value ) ) |
|
1148 | + (empty($meta_key) || empty($meta_value)) |
|
1149 | 1149 | && $default |
1150 | 1150 | ) { |
1151 | 1151 | $meta_value = $default; |
@@ -1166,15 +1166,15 @@ discard block |
||
1166 | 1166 | * |
1167 | 1167 | * @return mixed |
1168 | 1168 | */ |
1169 | -function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) { |
|
1170 | - $status = update_post_meta( $id, $meta_key, $meta_value, $prev_value ); |
|
1169 | +function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') { |
|
1170 | + $status = update_post_meta($id, $meta_key, $meta_value, $prev_value); |
|
1171 | 1171 | |
1172 | 1172 | /** |
1173 | 1173 | * Filter the meta value update status |
1174 | 1174 | * |
1175 | 1175 | * @since 1.8.8 |
1176 | 1176 | */ |
1177 | - return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value ); |
|
1177 | + return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value); |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | /** |
@@ -1188,15 +1188,15 @@ discard block |
||
1188 | 1188 | * |
1189 | 1189 | * @return mixed |
1190 | 1190 | */ |
1191 | -function give_delete_meta( $id, $meta_key, $meta_value = '' ) { |
|
1192 | - $status = delete_post_meta( $id, $meta_key, $meta_value ); |
|
1191 | +function give_delete_meta($id, $meta_key, $meta_value = '') { |
|
1192 | + $status = delete_post_meta($id, $meta_key, $meta_value); |
|
1193 | 1193 | |
1194 | 1194 | /** |
1195 | 1195 | * Filter the meta value delete status |
1196 | 1196 | * |
1197 | 1197 | * @since 1.8.8 |
1198 | 1198 | */ |
1199 | - return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value ); |
|
1199 | + return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value); |
|
1200 | 1200 | } |
1201 | 1201 | |
1202 | 1202 | /** |
@@ -1208,15 +1208,15 @@ discard block |
||
1208 | 1208 | * |
1209 | 1209 | * @return bool If the action has been added to the completed actions array |
1210 | 1210 | */ |
1211 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
1211 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
1212 | 1212 | |
1213 | - if ( empty( $upgrade_action ) ) { |
|
1213 | + if (empty($upgrade_action)) { |
|
1214 | 1214 | return false; |
1215 | 1215 | } |
1216 | 1216 | |
1217 | 1217 | $completed_upgrades = give_get_completed_upgrades(); |
1218 | 1218 | |
1219 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
1219 | + return in_array($upgrade_action, $completed_upgrades); |
|
1220 | 1220 | |
1221 | 1221 | } |
1222 | 1222 | |
@@ -1228,8 +1228,8 @@ discard block |
||
1228 | 1228 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off |
1229 | 1229 | */ |
1230 | 1230 | function give_maybe_resume_upgrade() { |
1231 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); |
|
1232 | - if ( empty( $doing_upgrade ) ) { |
|
1231 | + $doing_upgrade = get_option('give_doing_upgrade', false); |
|
1232 | + if (empty($doing_upgrade)) { |
|
1233 | 1233 | return false; |
1234 | 1234 | } |
1235 | 1235 | |
@@ -1245,9 +1245,9 @@ discard block |
||
1245 | 1245 | * |
1246 | 1246 | * @return bool If the function was successfully added |
1247 | 1247 | */ |
1248 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
1248 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
1249 | 1249 | |
1250 | - if ( empty( $upgrade_action ) ) { |
|
1250 | + if (empty($upgrade_action)) { |
|
1251 | 1251 | return false; |
1252 | 1252 | } |
1253 | 1253 | |
@@ -1255,16 +1255,16 @@ discard block |
||
1255 | 1255 | $completed_upgrades[] = $upgrade_action; |
1256 | 1256 | |
1257 | 1257 | // Remove any blanks, and only show uniques. |
1258 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
1258 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
1259 | 1259 | |
1260 | 1260 | /** |
1261 | 1261 | * Fire the action when any upgrade set to complete. |
1262 | 1262 | * |
1263 | 1263 | * @since 1.8.12 |
1264 | 1264 | */ |
1265 | - do_action( 'give_set_upgrade_completed', $upgrade_action, $completed_upgrades ); |
|
1265 | + do_action('give_set_upgrade_completed', $upgrade_action, $completed_upgrades); |
|
1266 | 1266 | |
1267 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
1267 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | /** |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | * @return array The array of completed upgrades |
1275 | 1275 | */ |
1276 | 1276 | function give_get_completed_upgrades() { |
1277 | - return (array) get_option( 'give_completed_upgrades' ); |
|
1277 | + return (array) get_option('give_completed_upgrades'); |
|
1278 | 1278 | } |
1279 | 1279 | |
1280 | 1280 | |
@@ -1287,15 +1287,15 @@ discard block |
||
1287 | 1287 | * |
1288 | 1288 | * @return string URL |
1289 | 1289 | */ |
1290 | -function give_import_page_url( $parameter = array() ) { |
|
1290 | +function give_import_page_url($parameter = array()) { |
|
1291 | 1291 | $defalut_query_arg = array( |
1292 | 1292 | 'post_type' => 'give_forms', |
1293 | 1293 | 'page' => 'give-tools', |
1294 | 1294 | 'tab' => 'import', |
1295 | 1295 | ); |
1296 | - $import_query_arg = wp_parse_args( $parameter, $defalut_query_arg ); |
|
1296 | + $import_query_arg = wp_parse_args($parameter, $defalut_query_arg); |
|
1297 | 1297 | |
1298 | - return add_query_arg( $import_query_arg, admin_url( 'edit.php' ) ); |
|
1298 | + return add_query_arg($import_query_arg, admin_url('edit.php')); |
|
1299 | 1299 | } |
1300 | 1300 | |
1301 | 1301 | /** |
@@ -1308,24 +1308,24 @@ discard block |
||
1308 | 1308 | * @param array $main_key First row from the CSV |
1309 | 1309 | * @param array $import_setting Contain the global variable. |
1310 | 1310 | */ |
1311 | -function give_save_import_donation_to_db( $raw_key, $row_data, $main_key = array(), $import_setting = array() ) { |
|
1312 | - $data = array_combine( $raw_key, $row_data ); |
|
1311 | +function give_save_import_donation_to_db($raw_key, $row_data, $main_key = array(), $import_setting = array()) { |
|
1312 | + $data = array_combine($raw_key, $row_data); |
|
1313 | 1313 | $price_id = false; |
1314 | 1314 | $customer_id = 0; |
1315 | - $import_setting['create_user'] = ( isset( $import_setting['create_user'] ) ? $import_setting['create_user'] : 1 ); |
|
1315 | + $import_setting['create_user'] = (isset($import_setting['create_user']) ? $import_setting['create_user'] : 1); |
|
1316 | 1316 | |
1317 | - $data = (array) apply_filters( 'give_save_import_donation_to_db', $data ); |
|
1317 | + $data = (array) apply_filters('give_save_import_donation_to_db', $data); |
|
1318 | 1318 | |
1319 | - if ( ! strpos( $data['amount'], '.' ) ) { |
|
1320 | - $data['amount'] = $data['amount'] . '.00'; |
|
1319 | + if ( ! strpos($data['amount'], '.')) { |
|
1320 | + $data['amount'] = $data['amount'].'.00'; |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | 1323 | // Here come the login function. |
1324 | - $donor_data = give_import_get_user_from_csv( $data, $import_setting ); |
|
1325 | - if ( ! empty( $donor_data->id ) ) { |
|
1326 | - if ( ! empty( $donor_data->user_id ) ) { |
|
1324 | + $donor_data = give_import_get_user_from_csv($data, $import_setting); |
|
1325 | + if ( ! empty($donor_data->id)) { |
|
1326 | + if ( ! empty($donor_data->user_id)) { |
|
1327 | 1327 | $customer_id = $donor_data->user_id; |
1328 | - } elseif ( ! empty( $data['user_id'] ) ) { |
|
1328 | + } elseif ( ! empty($data['user_id'])) { |
|
1329 | 1329 | $customer_id = $data['user_id']; |
1330 | 1330 | } |
1331 | 1331 | } else { |
@@ -1333,95 +1333,95 @@ discard block |
||
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | // get form data or register a form data. |
1336 | - $form = give_import_get_form_data_from_csv( $data, $import_setting ); |
|
1337 | - if ( false == $form ) { |
|
1336 | + $form = give_import_get_form_data_from_csv($data, $import_setting); |
|
1337 | + if (false == $form) { |
|
1338 | 1338 | return false; |
1339 | 1339 | } else { |
1340 | - $price_id = ( ! empty( $form->price_id ) ) ? $form->price_id : false; |
|
1340 | + $price_id = ( ! empty($form->price_id)) ? $form->price_id : false; |
|
1341 | 1341 | } |
1342 | 1342 | |
1343 | 1343 | |
1344 | 1344 | $address = array( |
1345 | - 'line1' => ( ! empty( $data['line1'] ) ? give_clean( $data['line1'] ) : '' ), |
|
1346 | - 'line2' => ( ! empty( $data['line1'] ) ? give_clean( $data['line2'] ) : '' ), |
|
1347 | - 'city' => ( ! empty( $data['line1'] ) ? give_clean( $data['city'] ) : '' ), |
|
1348 | - 'zip' => ( ! empty( $data['zip'] ) ? give_clean( $data['zip'] ) : '' ), |
|
1349 | - 'state' => ( ! empty( $data['state'] ) ? give_clean( $data['state'] ) : '' ), |
|
1350 | - 'country' => ( ! empty( $data['country'] ) ? ( ( $country_code = array_search( $data['country'], give_get_country_list() ) ) ? $country_code : $data['country'] ) : '' ), |
|
1345 | + 'line1' => ( ! empty($data['line1']) ? give_clean($data['line1']) : ''), |
|
1346 | + 'line2' => ( ! empty($data['line1']) ? give_clean($data['line2']) : ''), |
|
1347 | + 'city' => ( ! empty($data['line1']) ? give_clean($data['city']) : ''), |
|
1348 | + 'zip' => ( ! empty($data['zip']) ? give_clean($data['zip']) : ''), |
|
1349 | + 'state' => ( ! empty($data['state']) ? give_clean($data['state']) : ''), |
|
1350 | + 'country' => ( ! empty($data['country']) ? (($country_code = array_search($data['country'], give_get_country_list())) ? $country_code : $data['country']) : ''), |
|
1351 | 1351 | ); |
1352 | 1352 | |
1353 | 1353 | //Create payment_data array |
1354 | 1354 | $payment_data = array( |
1355 | 1355 | 'donor_id' => $donor_data->id, |
1356 | 1356 | 'price' => $data['amount'], |
1357 | - 'status' => ( ! empty( $data['post_status'] ) ? $data['post_status'] : 'publish' ), |
|
1357 | + 'status' => ( ! empty($data['post_status']) ? $data['post_status'] : 'publish'), |
|
1358 | 1358 | 'currency' => give_get_currency(), |
1359 | 1359 | 'user_info' => array( |
1360 | 1360 | 'id' => $customer_id, |
1361 | - 'email' => ( ! empty( $data['email'] ) ? $data['email'] : ( isset( $donor_data->email ) ? $donor_data->email : false ) ), |
|
1362 | - 'first_name' => ( ! empty( $data['first_name'] ) ? $data['first_name'] : ( ! empty( $customer_id ) && ( $first_name = get_user_meta( $customer_id, 'first_name', true ) ) ? $first_name : $donor_data->name ) ), |
|
1363 | - 'last_name' => ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ! empty( $customer_id ) && ( $last_name = get_user_meta( $customer_id, 'last_name', true ) ) ? $last_name : $donor_data->name ) ), |
|
1361 | + 'email' => ( ! empty($data['email']) ? $data['email'] : (isset($donor_data->email) ? $donor_data->email : false)), |
|
1362 | + 'first_name' => ( ! empty($data['first_name']) ? $data['first_name'] : ( ! empty($customer_id) && ($first_name = get_user_meta($customer_id, 'first_name', true)) ? $first_name : $donor_data->name)), |
|
1363 | + 'last_name' => ( ! empty($data['last_name']) ? $data['last_name'] : ( ! empty($customer_id) && ($last_name = get_user_meta($customer_id, 'last_name', true)) ? $last_name : $donor_data->name)), |
|
1364 | 1364 | 'address' => $address, |
1365 | 1365 | ), |
1366 | - 'gateway' => ( ! empty( $data['gateway'] ) && 'offline' != strtolower( $data['gateway'] ) ? strtolower( $data['gateway'] ) : 'manual' ), |
|
1367 | - 'give_form_title' => ( ! empty( $data['form_title'] ) ? $data['form_title'] : $form->get_name() ), |
|
1366 | + 'gateway' => ( ! empty($data['gateway']) && 'offline' != strtolower($data['gateway']) ? strtolower($data['gateway']) : 'manual'), |
|
1367 | + 'give_form_title' => ( ! empty($data['form_title']) ? $data['form_title'] : $form->get_name()), |
|
1368 | 1368 | 'give_form_id' => (string) $form->get_ID(), |
1369 | 1369 | 'give_price_id' => $price_id, |
1370 | - 'purchase_key' => strtolower( md5( uniqid() ) ), |
|
1370 | + 'purchase_key' => strtolower(md5(uniqid())), |
|
1371 | 1371 | 'user_email' => $data['email'], |
1372 | - 'post_date' => ( ! empty( $data['post_date'] ) ? mysql2date( 'Y-m-d H:i:s', $data['post_date'] ) : current_time( 'mysql' ) ), |
|
1373 | - 'mode' => ( ! empty( $data['mode'] ) ? ( 'true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live' ) : ( isset( $import_setting['mode'] ) ? ( true == (bool) $import_setting['mode'] ? 'test' : 'live' ) : ( give_is_test_mode() ? 'test' : 'live' ) ) ), |
|
1372 | + 'post_date' => ( ! empty($data['post_date']) ? mysql2date('Y-m-d H:i:s', $data['post_date']) : current_time('mysql')), |
|
1373 | + 'mode' => ( ! empty($data['mode']) ? ('true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live') : (isset($import_setting['mode']) ? (true == (bool) $import_setting['mode'] ? 'test' : 'live') : (give_is_test_mode() ? 'test' : 'live'))), |
|
1374 | 1374 | ); |
1375 | 1375 | |
1376 | - $payment_data = apply_filters( 'give_import_before_import_payment', $payment_data, $data, $donor_data, $form ); |
|
1376 | + $payment_data = apply_filters('give_import_before_import_payment', $payment_data, $data, $donor_data, $form); |
|
1377 | 1377 | |
1378 | 1378 | // Get the report |
1379 | 1379 | $report = give_import_donation_report(); |
1380 | 1380 | |
1381 | 1381 | // Check for duplicate code. |
1382 | - if ( true === give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) ) { |
|
1383 | - $report['duplicate_donation'] = ( ! empty( $report['duplicate_donation'] ) ? ( absint( $report['duplicate_donation'] ) + 1 ) : 1 ); |
|
1382 | + if (true === give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data)) { |
|
1383 | + $report['duplicate_donation'] = ( ! empty($report['duplicate_donation']) ? (absint($report['duplicate_donation']) + 1) : 1); |
|
1384 | 1384 | } else { |
1385 | - add_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1 ); |
|
1386 | - add_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2 ); |
|
1387 | - add_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3 ); |
|
1388 | - add_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11, 2 ); |
|
1389 | - $payment = give_insert_payment( $payment_data ); |
|
1390 | - remove_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1 ); |
|
1391 | - remove_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11 ); |
|
1392 | - remove_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11 ); |
|
1393 | - remove_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11 ); |
|
1385 | + add_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1); |
|
1386 | + add_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2); |
|
1387 | + add_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3); |
|
1388 | + add_action('give_insert_payment', 'give_import_donation_insert_payment', 11, 2); |
|
1389 | + $payment = give_insert_payment($payment_data); |
|
1390 | + remove_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1); |
|
1391 | + remove_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11); |
|
1392 | + remove_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11); |
|
1393 | + remove_action('give_insert_payment', 'give_import_donation_insert_payment', 11); |
|
1394 | 1394 | |
1395 | - if ( $payment ) { |
|
1395 | + if ($payment) { |
|
1396 | 1396 | |
1397 | - $report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 ); |
|
1397 | + $report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1); |
|
1398 | 1398 | |
1399 | - update_post_meta( $payment, '_give_payment_import', true ); |
|
1399 | + update_post_meta($payment, '_give_payment_import', true); |
|
1400 | 1400 | |
1401 | - if ( ! empty( $import_setting['csv'] ) ) { |
|
1402 | - update_post_meta( $payment, '_give_payment_import_id', $import_setting['csv'] ); |
|
1401 | + if ( ! empty($import_setting['csv'])) { |
|
1402 | + update_post_meta($payment, '_give_payment_import_id', $import_setting['csv']); |
|
1403 | 1403 | } |
1404 | 1404 | |
1405 | 1405 | // Insert Notes. |
1406 | - if ( ! empty( $data['notes'] ) ) { |
|
1407 | - give_insert_payment_note( $payment, $data['notes'] ); |
|
1406 | + if ( ! empty($data['notes'])) { |
|
1407 | + give_insert_payment_note($payment, $data['notes']); |
|
1408 | 1408 | } |
1409 | 1409 | |
1410 | - $meta_exists = array_keys( $raw_key, 'post_meta' ); |
|
1411 | - if ( ! empty( $main_key ) && ! empty( $meta_exists ) ) { |
|
1412 | - foreach ( $meta_exists as $meta_exist ) { |
|
1413 | - if ( ! empty( $main_key[ $meta_exist ] ) && ! empty( $row_data[ $meta_exist ] ) ) { |
|
1414 | - update_post_meta( $payment, $main_key[ $meta_exist ], $row_data[ $meta_exist ] ); |
|
1410 | + $meta_exists = array_keys($raw_key, 'post_meta'); |
|
1411 | + if ( ! empty($main_key) && ! empty($meta_exists)) { |
|
1412 | + foreach ($meta_exists as $meta_exist) { |
|
1413 | + if ( ! empty($main_key[$meta_exist]) && ! empty($row_data[$meta_exist])) { |
|
1414 | + update_post_meta($payment, $main_key[$meta_exist], $row_data[$meta_exist]); |
|
1415 | 1415 | } |
1416 | 1416 | } |
1417 | 1417 | } |
1418 | 1418 | } else { |
1419 | - $report['failed_donation'] = ( ! empty( $report['failed_donation'] ) ? ( absint( $report['failed_donation'] ) + 1 ) : 1 ); |
|
1419 | + $report['failed_donation'] = ( ! empty($report['failed_donation']) ? (absint($report['failed_donation']) + 1) : 1); |
|
1420 | 1420 | } |
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | // update the report |
1424 | - give_import_donation_report_update( $report ); |
|
1424 | + give_import_donation_report_update($report); |
|
1425 | 1425 | } |
1426 | 1426 | |
1427 | 1427 | /** |
@@ -1435,12 +1435,12 @@ discard block |
||
1435 | 1435 | * |
1436 | 1436 | * @return Give_Donor |
1437 | 1437 | */ |
1438 | -function give_donation_import_update_donor_information( $donor, $payment_id, $payment_data ) { |
|
1438 | +function give_donation_import_update_donor_information($donor, $payment_id, $payment_data) { |
|
1439 | 1439 | $old_donor = $donor; |
1440 | - if ( ! empty( $payment_data['donor_id'] ) ) { |
|
1441 | - $donor_id = absint( $payment_data['donor_id'] ); |
|
1442 | - $donor = new Give_Donor( $donor_id ); |
|
1443 | - if ( ! empty( $donor->id ) ) { |
|
1440 | + if ( ! empty($payment_data['donor_id'])) { |
|
1441 | + $donor_id = absint($payment_data['donor_id']); |
|
1442 | + $donor = new Give_Donor($donor_id); |
|
1443 | + if ( ! empty($donor->id)) { |
|
1444 | 1444 | return $donor; |
1445 | 1445 | } |
1446 | 1446 | } |
@@ -1453,12 +1453,12 @@ discard block |
||
1453 | 1453 | * |
1454 | 1454 | * @since 1.8.13 |
1455 | 1455 | */ |
1456 | -function give_import_donation_insert_payment( $payment_id, $payment_data ) { |
|
1456 | +function give_import_donation_insert_payment($payment_id, $payment_data) { |
|
1457 | 1457 | // Update Give Customers purchase_count |
1458 | - if ( ! empty( $payment_data['status'] ) && ( 'complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'] ) ) { |
|
1459 | - $donor_id = (int) get_post_meta( $payment_id, '_give_payment_customer_id', true ); |
|
1460 | - if ( ! empty( $donor_id ) ) { |
|
1461 | - $donor = new Give_Donor( $donor_id ); |
|
1458 | + if ( ! empty($payment_data['status']) && ('complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'])) { |
|
1459 | + $donor_id = (int) get_post_meta($payment_id, '_give_payment_customer_id', true); |
|
1460 | + if ( ! empty($donor_id)) { |
|
1461 | + $donor = new Give_Donor($donor_id); |
|
1462 | 1462 | $donor->increase_purchase_count(); |
1463 | 1463 | } |
1464 | 1464 | } |
@@ -1469,8 +1469,8 @@ discard block |
||
1469 | 1469 | * |
1470 | 1470 | * @since 8.1.13 |
1471 | 1471 | */ |
1472 | -function give_donation_import_give_insert_payment_args( $args, $payment_data ) { |
|
1473 | - if ( ! empty( $payment_data['user_info']['id'] ) ) { |
|
1472 | +function give_donation_import_give_insert_payment_args($args, $payment_data) { |
|
1473 | + if ( ! empty($payment_data['user_info']['id'])) { |
|
1474 | 1474 | $args['post_author'] = (int) $payment_data['user_info']['id']; |
1475 | 1475 | } |
1476 | 1476 | |
@@ -1482,11 +1482,11 @@ discard block |
||
1482 | 1482 | * |
1483 | 1483 | * @since 1.8.13 |
1484 | 1484 | */ |
1485 | -function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) { |
|
1485 | +function give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data) { |
|
1486 | 1486 | $return = false; |
1487 | - if ( ! empty( $data['post_date'] ) ) { |
|
1488 | - $post_date = mysql2date( 'Y-m-d-H-i-s', $data['post_date'] ); |
|
1489 | - $post_date = explode( '-', $post_date ); |
|
1487 | + if ( ! empty($data['post_date'])) { |
|
1488 | + $post_date = mysql2date('Y-m-d-H-i-s', $data['post_date']); |
|
1489 | + $post_date = explode('-', $post_date); |
|
1490 | 1490 | $args = array( |
1491 | 1491 | 'post_type' => 'give_payment', |
1492 | 1492 | 'cache_results' => false, |
@@ -1507,7 +1507,7 @@ discard block |
||
1507 | 1507 | 'meta_query' => array( |
1508 | 1508 | array( |
1509 | 1509 | 'key' => '_give_payment_total', |
1510 | - 'value' => preg_replace( '/[\$,]/', '', $payment_data['price'] ), |
|
1510 | + 'value' => preg_replace('/[\$,]/', '', $payment_data['price']), |
|
1511 | 1511 | 'compare' => 'LIKE', |
1512 | 1512 | ), |
1513 | 1513 | array( |
@@ -1524,9 +1524,9 @@ discard block |
||
1524 | 1524 | ), |
1525 | 1525 | ); |
1526 | 1526 | |
1527 | - $payments = new Give_Payments_Query( $args ); |
|
1527 | + $payments = new Give_Payments_Query($args); |
|
1528 | 1528 | $donations = $payments->get_payments(); |
1529 | - if ( ! empty( $donations ) ) { |
|
1529 | + if ( ! empty($donations)) { |
|
1530 | 1530 | return true; |
1531 | 1531 | } |
1532 | 1532 | } |
@@ -1543,9 +1543,9 @@ discard block |
||
1543 | 1543 | * |
1544 | 1544 | * @return void |
1545 | 1545 | */ |
1546 | -function give_donation_import_insert_default_payment_note( $payment_id ) { |
|
1546 | +function give_donation_import_insert_default_payment_note($payment_id) { |
|
1547 | 1547 | $current_user = wp_get_current_user(); |
1548 | - give_insert_payment_note( $payment_id, esc_html( wp_sprintf( __( 'This donation was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
1548 | + give_insert_payment_note($payment_id, esc_html(wp_sprintf(__('This donation was imported by %s', 'give'), $current_user->user_email))); |
|
1549 | 1549 | } |
1550 | 1550 | |
1551 | 1551 | |
@@ -1558,7 +1558,7 @@ discard block |
||
1558 | 1558 | * |
1559 | 1559 | * @return bool |
1560 | 1560 | */ |
1561 | -function give_log_user_in_on_register_callback( $value ) { |
|
1561 | +function give_log_user_in_on_register_callback($value) { |
|
1562 | 1562 | return false; |
1563 | 1563 | } |
1564 | 1564 | |
@@ -1570,18 +1570,18 @@ discard block |
||
1570 | 1570 | * @param int $start Start from which csv line. |
1571 | 1571 | * @param int $end End from which csv line. |
1572 | 1572 | */ |
1573 | -function give_get_donation_data_from_csv( $file_id, $start, $end, $delimiter = ',' ) { |
|
1573 | +function give_get_donation_data_from_csv($file_id, $start, $end, $delimiter = ',') { |
|
1574 | 1574 | $raw_data = array(); |
1575 | - $file_dir = get_attached_file( $file_id ); |
|
1575 | + $file_dir = get_attached_file($file_id); |
|
1576 | 1576 | $count = 0; |
1577 | - if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) { |
|
1578 | - while ( false !== ( $row = fgetcsv( $handle, 0, $delimiter ) ) ) { |
|
1579 | - if ( $count >= $start && $count <= $end ) { |
|
1577 | + if (false !== ($handle = fopen($file_dir, 'r'))) { |
|
1578 | + while (false !== ($row = fgetcsv($handle, 0, $delimiter))) { |
|
1579 | + if ($count >= $start && $count <= $end) { |
|
1580 | 1580 | $raw_data[] = $row; |
1581 | 1581 | } |
1582 | - $count ++; |
|
1582 | + $count++; |
|
1583 | 1583 | } |
1584 | - fclose( $handle ); |
|
1584 | + fclose($handle); |
|
1585 | 1585 | } |
1586 | 1586 | |
1587 | 1587 | return $raw_data; |
@@ -1601,9 +1601,9 @@ discard block |
||
1601 | 1601 | * |
1602 | 1602 | * @return array |
1603 | 1603 | */ |
1604 | - return (array) apply_filters( 'give_import_default_options', array( |
|
1605 | - '' => __( 'Do not import', 'give' ), |
|
1606 | - ) ); |
|
1604 | + return (array) apply_filters('give_import_default_options', array( |
|
1605 | + '' => __('Do not import', 'give'), |
|
1606 | + )); |
|
1607 | 1607 | } |
1608 | 1608 | |
1609 | 1609 | /** |
@@ -1619,26 +1619,26 @@ discard block |
||
1619 | 1619 | * |
1620 | 1620 | * @return array |
1621 | 1621 | */ |
1622 | - return (array) apply_filters( 'give_import_donations_options', array( |
|
1623 | - '' => __( 'Do not import', 'give' ), |
|
1624 | - 'id' => __( 'Donation ID', 'give' ), |
|
1625 | - 'amount' => __( 'Donation Amount', 'give' ), |
|
1626 | - 'post_date' => __( 'Donation Date', 'give' ), |
|
1627 | - 'first_name' => __( 'Donor First Name', 'give' ), |
|
1628 | - 'last_name' => __( 'Donor Last Name', 'give' ), |
|
1629 | - 'line1' => __( 'Address 1', 'give' ), |
|
1630 | - 'line2' => __( 'Address 2', 'give' ), |
|
1631 | - 'city' => __( 'City', 'give' ), |
|
1632 | - 'state' => __( 'State', 'give' ), |
|
1633 | - 'country' => __( 'Country', 'give' ), |
|
1634 | - 'zip' => __( 'Zip', 'give' ), |
|
1635 | - 'email' => __( 'Donor Email', 'give' ), |
|
1636 | - 'post_status' => __( 'Donation Status', 'give' ), |
|
1637 | - 'gateway' => __( 'Payment Method', 'give' ), |
|
1638 | - 'notes' => __( 'Notes', 'give' ), |
|
1639 | - 'mode' => __( 'Test Mode', 'give' ), |
|
1640 | - 'post_meta' => __( 'Import as Meta', 'give' ), |
|
1641 | - ) ); |
|
1622 | + return (array) apply_filters('give_import_donations_options', array( |
|
1623 | + '' => __('Do not import', 'give'), |
|
1624 | + 'id' => __('Donation ID', 'give'), |
|
1625 | + 'amount' => __('Donation Amount', 'give'), |
|
1626 | + 'post_date' => __('Donation Date', 'give'), |
|
1627 | + 'first_name' => __('Donor First Name', 'give'), |
|
1628 | + 'last_name' => __('Donor Last Name', 'give'), |
|
1629 | + 'line1' => __('Address 1', 'give'), |
|
1630 | + 'line2' => __('Address 2', 'give'), |
|
1631 | + 'city' => __('City', 'give'), |
|
1632 | + 'state' => __('State', 'give'), |
|
1633 | + 'country' => __('Country', 'give'), |
|
1634 | + 'zip' => __('Zip', 'give'), |
|
1635 | + 'email' => __('Donor Email', 'give'), |
|
1636 | + 'post_status' => __('Donation Status', 'give'), |
|
1637 | + 'gateway' => __('Payment Method', 'give'), |
|
1638 | + 'notes' => __('Notes', 'give'), |
|
1639 | + 'mode' => __('Test Mode', 'give'), |
|
1640 | + 'post_meta' => __('Import as Meta', 'give'), |
|
1641 | + )); |
|
1642 | 1642 | } |
1643 | 1643 | |
1644 | 1644 | /** |
@@ -1654,10 +1654,10 @@ discard block |
||
1654 | 1654 | * |
1655 | 1655 | * @return array |
1656 | 1656 | */ |
1657 | - return (array) apply_filters( 'give_import_donor_options', array( |
|
1658 | - 'donor_id' => __( 'Donor ID', 'give' ), |
|
1659 | - 'user_id' => __( 'User ID', 'give' ), |
|
1660 | - ) ); |
|
1657 | + return (array) apply_filters('give_import_donor_options', array( |
|
1658 | + 'donor_id' => __('Donor ID', 'give'), |
|
1659 | + 'user_id' => __('User ID', 'give'), |
|
1660 | + )); |
|
1661 | 1661 | } |
1662 | 1662 | |
1663 | 1663 | /** |
@@ -1673,12 +1673,12 @@ discard block |
||
1673 | 1673 | * |
1674 | 1674 | * @return array |
1675 | 1675 | */ |
1676 | - return (array) apply_filters( 'give_import_donation_form_options', array( |
|
1677 | - 'form_id' => __( 'Donation Form ID', 'give' ), |
|
1678 | - 'form_title' => __( 'Donation Form', 'give' ), |
|
1679 | - 'form_level' => __( 'Donation Level', 'give' ), |
|
1680 | - 'form_custom_amount_text' => __( 'Custom Amount Text', 'give' ), |
|
1681 | - ) ); |
|
1676 | + return (array) apply_filters('give_import_donation_form_options', array( |
|
1677 | + 'form_id' => __('Donation Form ID', 'give'), |
|
1678 | + 'form_title' => __('Donation Form', 'give'), |
|
1679 | + 'form_level' => __('Donation Level', 'give'), |
|
1680 | + 'form_custom_amount_text' => __('Custom Amount Text', 'give'), |
|
1681 | + )); |
|
1682 | 1682 | } |
1683 | 1683 | |
1684 | 1684 | /** |
@@ -1690,30 +1690,30 @@ discard block |
||
1690 | 1690 | * |
1691 | 1691 | * @return bool|false|WP_User |
1692 | 1692 | */ |
1693 | -function give_import_get_user_from_csv( $data, $import_setting = array() ) { |
|
1693 | +function give_import_get_user_from_csv($data, $import_setting = array()) { |
|
1694 | 1694 | $report = give_import_donation_report(); |
1695 | 1695 | $donor_data = false; |
1696 | 1696 | $customer_id = false; |
1697 | 1697 | |
1698 | 1698 | // check if donor id is not empty |
1699 | - if ( ! empty( $data['donor_id'] ) ) { |
|
1700 | - $donor_data = new Give_Donor( (int) $data['donor_id'] ); |
|
1701 | - if ( ! empty( $donor_data->id ) ) { |
|
1702 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
1699 | + if ( ! empty($data['donor_id'])) { |
|
1700 | + $donor_data = new Give_Donor((int) $data['donor_id']); |
|
1701 | + if ( ! empty($donor_data->id)) { |
|
1702 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
1703 | 1703 | } |
1704 | 1704 | } |
1705 | 1705 | |
1706 | - if ( empty( $donor_data->id ) && ! empty( $data['user_id'] ) ) { |
|
1706 | + if (empty($donor_data->id) && ! empty($data['user_id'])) { |
|
1707 | 1707 | $user_id = (int) $data['user_id']; |
1708 | - $donor_data = new Give_Donor( $user_id, true ); |
|
1708 | + $donor_data = new Give_Donor($user_id, true); |
|
1709 | 1709 | |
1710 | 1710 | |
1711 | - if ( empty( $donor_data->id ) ) { |
|
1712 | - $donor_data = get_user_by( 'id', $user_id ); |
|
1713 | - if ( ! empty( $donor_data->ID ) ) { |
|
1714 | - $first_name = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $donor_data->user_nicename ); |
|
1715 | - $last_name = ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ( $lastname = get_user_meta( $donor_data->ID, 'last_name', true ) ) ? $lastname : '' ) ); |
|
1716 | - $name = $first_name . ' ' . $last_name; |
|
1711 | + if (empty($donor_data->id)) { |
|
1712 | + $donor_data = get_user_by('id', $user_id); |
|
1713 | + if ( ! empty($donor_data->ID)) { |
|
1714 | + $first_name = ( ! empty($data['first_name']) ? $data['first_name'] : $donor_data->user_nicename); |
|
1715 | + $last_name = ( ! empty($data['last_name']) ? $data['last_name'] : (($lastname = get_user_meta($donor_data->ID, 'last_name', true)) ? $lastname : '')); |
|
1716 | + $name = $first_name.' '.$last_name; |
|
1717 | 1717 | $user_email = $donor_data->user_email; |
1718 | 1718 | $donor_args = array( |
1719 | 1719 | 'name' => $name, |
@@ -1722,44 +1722,44 @@ discard block |
||
1722 | 1722 | ); |
1723 | 1723 | |
1724 | 1724 | $donor_data = new Give_Donor(); |
1725 | - $donor_data->create( $donor_args ); |
|
1725 | + $donor_data->create($donor_args); |
|
1726 | 1726 | |
1727 | 1727 | // Adding notes that donor is being imported from CSV. |
1728 | 1728 | $current_user = wp_get_current_user(); |
1729 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
1729 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
1730 | 1730 | |
1731 | 1731 | // Add is used to ensure duplicate emails are not added |
1732 | - if ( $user_email != $data['email'] && ! empty( $data['email'] ) ) { |
|
1733 | - $donor_data->add_meta( 'additional_email', $data['email'] ); |
|
1732 | + if ($user_email != $data['email'] && ! empty($data['email'])) { |
|
1733 | + $donor_data->add_meta('additional_email', $data['email']); |
|
1734 | 1734 | } |
1735 | 1735 | |
1736 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
1736 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
1737 | 1737 | } else { |
1738 | 1738 | } |
1739 | 1739 | } else { |
1740 | 1740 | // Add is used to ensure duplicate emails are not added |
1741 | - if ( $donor_data->email != $data['email'] ) { |
|
1742 | - $donor_data->add_meta( 'additional_email', ( ! empty( $data['email'] ) ? $data['email'] : $donor_data->email ) ); |
|
1741 | + if ($donor_data->email != $data['email']) { |
|
1742 | + $donor_data->add_meta('additional_email', ( ! empty($data['email']) ? $data['email'] : $donor_data->email)); |
|
1743 | 1743 | } |
1744 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
1744 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
1745 | 1745 | } |
1746 | 1746 | } |
1747 | 1747 | |
1748 | - if ( empty( $donor_data->id ) && ! empty( $data['email'] ) ) { |
|
1748 | + if (empty($donor_data->id) && ! empty($data['email'])) { |
|
1749 | 1749 | |
1750 | - $donor_data = new Give_Donor( $data['email'] ); |
|
1751 | - if ( empty( $donor_data->id ) ) { |
|
1752 | - $donor_data = get_user_by( 'email', $data['email'] ); |
|
1750 | + $donor_data = new Give_Donor($data['email']); |
|
1751 | + if (empty($donor_data->id)) { |
|
1752 | + $donor_data = get_user_by('email', $data['email']); |
|
1753 | 1753 | |
1754 | - if ( empty( $donor_data->ID ) && ! empty( $data['first_name'] ) && ! empty( $data['last_name'] ) && isset( $import_setting['create_user'] ) && 1 === absint( $import_setting['create_user'] ) ) { |
|
1755 | - $give_role = (array) give_get_option( 'donor_default_user_role', get_option( 'default_role', ( ( $give_donor = wp_roles()->is_role( 'give_donor' ) ) && ! empty( $give_donor ) ? 'give_donor' : 'subscriber' ) ) ); |
|
1754 | + if (empty($donor_data->ID) && ! empty($data['first_name']) && ! empty($data['last_name']) && isset($import_setting['create_user']) && 1 === absint($import_setting['create_user'])) { |
|
1755 | + $give_role = (array) give_get_option('donor_default_user_role', get_option('default_role', (($give_donor = wp_roles()->is_role('give_donor')) && ! empty($give_donor) ? 'give_donor' : 'subscriber'))); |
|
1756 | 1756 | $donor_args = array( |
1757 | 1757 | 'user_login' => $data['email'], |
1758 | 1758 | 'user_email' => $data['email'], |
1759 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
1759 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
1760 | 1760 | 'user_first' => $data['first_name'], |
1761 | 1761 | 'user_last' => $data['last_name'], |
1762 | - 'user_pass' => wp_generate_password( 8, true ), |
|
1762 | + 'user_pass' => wp_generate_password(8, true), |
|
1763 | 1763 | 'role' => $give_role, |
1764 | 1764 | ); |
1765 | 1765 | |
@@ -1768,56 +1768,56 @@ discard block |
||
1768 | 1768 | * |
1769 | 1769 | * @since 1.8.13 |
1770 | 1770 | */ |
1771 | - $donor_args = (array) apply_filters( 'give_import_insert_user_args', $donor_args, $data, $import_setting ); |
|
1771 | + $donor_args = (array) apply_filters('give_import_insert_user_args', $donor_args, $data, $import_setting); |
|
1772 | 1772 | |
1773 | 1773 | // This action was added to remove the login when using the give register function. |
1774 | - add_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
1775 | - $customer_id = give_register_and_login_new_user( $donor_args ); |
|
1776 | - remove_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
1774 | + add_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
1775 | + $customer_id = give_register_and_login_new_user($donor_args); |
|
1776 | + remove_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
1777 | 1777 | |
1778 | - update_user_meta( $customer_id, '_give_payment_import', true ); |
|
1779 | - $donor_data = new Give_Donor( $customer_id, true ); |
|
1778 | + update_user_meta($customer_id, '_give_payment_import', true); |
|
1779 | + $donor_data = new Give_Donor($customer_id, true); |
|
1780 | 1780 | } else { |
1781 | - $customer_id = ( ! empty( $donor_data->ID ) ? $donor_data->ID : false ); |
|
1781 | + $customer_id = ( ! empty($donor_data->ID) ? $donor_data->ID : false); |
|
1782 | 1782 | } |
1783 | 1783 | |
1784 | - if ( ! empty( $customer_id ) || ( isset( $import_setting['create_user'] ) && 0 === absint( $import_setting['create_user'] ) ) ) { |
|
1785 | - $donor_data = new Give_Donor( $customer_id, true ); |
|
1784 | + if ( ! empty($customer_id) || (isset($import_setting['create_user']) && 0 === absint($import_setting['create_user']))) { |
|
1785 | + $donor_data = new Give_Donor($customer_id, true); |
|
1786 | 1786 | |
1787 | - if ( empty( $donor_data->id ) ) { |
|
1787 | + if (empty($donor_data->id)) { |
|
1788 | 1788 | |
1789 | - if ( ! empty( $data['form_id'] ) ) { |
|
1790 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
1789 | + if ( ! empty($data['form_id'])) { |
|
1790 | + $form = new Give_Donate_Form($data['form_id']); |
|
1791 | 1791 | } |
1792 | 1792 | |
1793 | - $payment_title = ( isset( $data['form_title'] ) ? $data['form_title'] : ( isset( $form ) ? $form->get_name() : esc_html__( 'New Form', 'give' ) ) ); |
|
1793 | + $payment_title = (isset($data['form_title']) ? $data['form_title'] : (isset($form) ? $form->get_name() : esc_html__('New Form', 'give'))); |
|
1794 | 1794 | $donor_args = array( |
1795 | - 'name' => ! is_email( $payment_title ) ? $data['first_name'] . ' ' . $data['last_name'] : '', |
|
1795 | + 'name' => ! is_email($payment_title) ? $data['first_name'].' '.$data['last_name'] : '', |
|
1796 | 1796 | 'email' => $data['email'], |
1797 | 1797 | ); |
1798 | 1798 | |
1799 | - if ( ! empty( $customer_id ) ) { |
|
1799 | + if ( ! empty($customer_id)) { |
|
1800 | 1800 | $donor_args['user_id'] = $customer_id; |
1801 | 1801 | } |
1802 | 1802 | |
1803 | - $donor_data->create( $donor_args ); |
|
1803 | + $donor_data->create($donor_args); |
|
1804 | 1804 | |
1805 | 1805 | // Adding notes that donor is being imported from CSV. |
1806 | 1806 | $current_user = wp_get_current_user(); |
1807 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
1807 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
1808 | 1808 | |
1809 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
1809 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
1810 | 1810 | } else { |
1811 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
1811 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
1812 | 1812 | } |
1813 | 1813 | } |
1814 | 1814 | } else { |
1815 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
1815 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
1816 | 1816 | } |
1817 | 1817 | } |
1818 | 1818 | |
1819 | 1819 | // update the report |
1820 | - give_import_donation_report_update( $report ); |
|
1820 | + give_import_donation_report_update($report); |
|
1821 | 1821 | |
1822 | 1822 | return $donor_data; |
1823 | 1823 | } |
@@ -1831,7 +1831,7 @@ discard block |
||
1831 | 1831 | * |
1832 | 1832 | * @return array|bool|Give_Donate_Form|int|null|WP_Post |
1833 | 1833 | */ |
1834 | -function give_import_get_form_data_from_csv( $data, $import_setting = array() ) { |
|
1834 | +function give_import_get_form_data_from_csv($data, $import_setting = array()) { |
|
1835 | 1835 | $new_form = false; |
1836 | 1836 | |
1837 | 1837 | // Get the import report |
@@ -1840,58 +1840,58 @@ discard block |
||
1840 | 1840 | $form = false; |
1841 | 1841 | $meta = array(); |
1842 | 1842 | |
1843 | - if ( ! empty( $data['form_id'] ) ) { |
|
1844 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
1843 | + if ( ! empty($data['form_id'])) { |
|
1844 | + $form = new Give_Donate_Form($data['form_id']); |
|
1845 | 1845 | // Add support to older php version. |
1846 | 1846 | $form_id = $form->get_ID(); |
1847 | - if ( empty( $form_id ) ) { |
|
1848 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
1847 | + if (empty($form_id)) { |
|
1848 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
1849 | 1849 | $form = false; |
1850 | 1850 | } |
1851 | 1851 | } |
1852 | 1852 | |
1853 | - if ( false === $form && ! empty( $data['form_title'] ) ) { |
|
1854 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
1853 | + if (false === $form && ! empty($data['form_title'])) { |
|
1854 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
1855 | 1855 | |
1856 | - if ( ! empty( $form->ID ) ) { |
|
1856 | + if ( ! empty($form->ID)) { |
|
1857 | 1857 | |
1858 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
1858 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
1859 | 1859 | |
1860 | - $form = new Give_Donate_Form( $form->ID ); |
|
1860 | + $form = new Give_Donate_Form($form->ID); |
|
1861 | 1861 | } else { |
1862 | 1862 | $form = new Give_Donate_Form(); |
1863 | 1863 | $args = array( |
1864 | 1864 | 'post_title' => $data['form_title'], |
1865 | 1865 | 'post_status' => 'publish', |
1866 | 1866 | ); |
1867 | - $form = $form->create( $args ); |
|
1868 | - $report['create_form'] = ( ! empty( $report['create_form'] ) ? ( absint( $report['create_form'] ) + 1 ) : 1 ); |
|
1867 | + $form = $form->create($args); |
|
1868 | + $report['create_form'] = ( ! empty($report['create_form']) ? (absint($report['create_form']) + 1) : 1); |
|
1869 | 1869 | $new_form = true; |
1870 | 1870 | |
1871 | 1871 | } |
1872 | 1872 | |
1873 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
1874 | - $form = new Give_Donate_Form( $form->ID ); |
|
1873 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
1874 | + $form = new Give_Donate_Form($form->ID); |
|
1875 | 1875 | } |
1876 | 1876 | |
1877 | - if ( ! empty( $form ) && $form->get_ID() ) { |
|
1878 | - if ( ! empty( $data['form_level'] ) && 'custom' != (string) strtolower( $data['form_level'] ) ) { |
|
1877 | + if ( ! empty($form) && $form->get_ID()) { |
|
1878 | + if ( ! empty($data['form_level']) && 'custom' != (string) strtolower($data['form_level'])) { |
|
1879 | 1879 | $prices = (array) $form->get_prices(); |
1880 | 1880 | $price_text = array(); |
1881 | - foreach ( $prices as $key => $price ) { |
|
1882 | - if ( isset( $price['_give_id']['level_id'] ) ) { |
|
1883 | - $price_text[ $price['_give_id']['level_id'] ] = ( ! empty( $price['_give_text'] ) ? $price['_give_text'] : '' ); |
|
1881 | + foreach ($prices as $key => $price) { |
|
1882 | + if (isset($price['_give_id']['level_id'])) { |
|
1883 | + $price_text[$price['_give_id']['level_id']] = ( ! empty($price['_give_text']) ? $price['_give_text'] : ''); |
|
1884 | 1884 | } |
1885 | 1885 | } |
1886 | 1886 | |
1887 | - if ( ! in_array( $data['form_level'], $price_text ) ) { |
|
1887 | + if ( ! in_array($data['form_level'], $price_text)) { |
|
1888 | 1888 | |
1889 | 1889 | // For generating unquiet level id. |
1890 | 1890 | $count = 1; |
1891 | - $new_level = count( $prices ) + $count; |
|
1892 | - while ( array_key_exists( $new_level, $price_text ) ) { |
|
1893 | - $count ++; |
|
1894 | - $new_level = count( $prices ) + $count; |
|
1891 | + $new_level = count($prices) + $count; |
|
1892 | + while (array_key_exists($new_level, $price_text)) { |
|
1893 | + $count++; |
|
1894 | + $new_level = count($prices) + $count; |
|
1895 | 1895 | } |
1896 | 1896 | |
1897 | 1897 | $multi_level_donations = array( |
@@ -1899,45 +1899,45 @@ discard block |
||
1899 | 1899 | '_give_id' => array( |
1900 | 1900 | 'level_id' => $new_level, |
1901 | 1901 | ), |
1902 | - '_give_amount' => give_sanitize_amount_for_db( $data['amount'] ), |
|
1902 | + '_give_amount' => give_sanitize_amount_for_db($data['amount']), |
|
1903 | 1903 | '_give_text' => $data['form_level'], |
1904 | 1904 | ), |
1905 | 1905 | ); |
1906 | 1906 | |
1907 | - $price_text[ $new_level ] = $data['form_level']; |
|
1907 | + $price_text[$new_level] = $data['form_level']; |
|
1908 | 1908 | |
1909 | - if ( ! empty( $prices ) && is_array( $prices ) && ! empty( $prices[0] ) ) { |
|
1910 | - $prices = wp_parse_args( $multi_level_donations, $prices ); |
|
1909 | + if ( ! empty($prices) && is_array($prices) && ! empty($prices[0])) { |
|
1910 | + $prices = wp_parse_args($multi_level_donations, $prices); |
|
1911 | 1911 | } else { |
1912 | 1912 | $multi_level_donations[0]['_give_default'] = 'default'; |
1913 | 1913 | $prices = $multi_level_donations; |
1914 | 1914 | } |
1915 | 1915 | } |
1916 | - $form->price_id = array_search( $data['form_level'], $price_text ); |
|
1916 | + $form->price_id = array_search($data['form_level'], $price_text); |
|
1917 | 1917 | |
1918 | - $donation_levels_amounts = wp_list_pluck( $prices, '_give_amount' ); |
|
1919 | - $min_amount = min( $donation_levels_amounts ); |
|
1920 | - $max_amount = max( $donation_levels_amounts ); |
|
1918 | + $donation_levels_amounts = wp_list_pluck($prices, '_give_amount'); |
|
1919 | + $min_amount = min($donation_levels_amounts); |
|
1920 | + $max_amount = max($donation_levels_amounts); |
|
1921 | 1921 | |
1922 | 1922 | $meta = array( |
1923 | 1923 | '_give_levels_minimum_amount' => $min_amount, |
1924 | 1924 | '_give_levels_maximum_amount' => $max_amount, |
1925 | 1925 | '_give_price_option' => 'multi', |
1926 | - '_give_donation_levels' => array_values( $prices ), |
|
1926 | + '_give_donation_levels' => array_values($prices), |
|
1927 | 1927 | ); |
1928 | 1928 | } else { |
1929 | 1929 | $form->price_id = 'custom'; |
1930 | 1930 | } |
1931 | 1931 | |
1932 | 1932 | $defaults = array( |
1933 | - '_give_set_price' => give_sanitize_amount_for_db( $data['amount'] ), |
|
1933 | + '_give_set_price' => give_sanitize_amount_for_db($data['amount']), |
|
1934 | 1934 | '_give_price_option' => 'set', |
1935 | 1935 | ); |
1936 | 1936 | |
1937 | 1937 | // If new form is created. |
1938 | - if ( ! empty( $new_form ) ) { |
|
1938 | + if ( ! empty($new_form)) { |
|
1939 | 1939 | $new_form = array( |
1940 | - '_give_custom_amount_text' => ( ! empty( $data['form_custom_amount_text'] ) ? $data['form_custom_amount_text'] : 'Custom' ), |
|
1940 | + '_give_custom_amount_text' => ( ! empty($data['form_custom_amount_text']) ? $data['form_custom_amount_text'] : 'Custom'), |
|
1941 | 1941 | '_give_logged_in_only' => 'enabled', |
1942 | 1942 | '_give_custom_amount' => 'enabled', |
1943 | 1943 | '_give_payment_import' => true, |
@@ -1948,18 +1948,18 @@ discard block |
||
1948 | 1948 | '_give_default_gateway' => 'global', |
1949 | 1949 | '_give_show_register_form' => 'both', |
1950 | 1950 | ); |
1951 | - $defaults = wp_parse_args( $defaults, $new_form ); |
|
1951 | + $defaults = wp_parse_args($defaults, $new_form); |
|
1952 | 1952 | } |
1953 | 1953 | |
1954 | - $meta = wp_parse_args( $meta, $defaults ); |
|
1954 | + $meta = wp_parse_args($meta, $defaults); |
|
1955 | 1955 | |
1956 | - foreach ( $meta as $key => $value ) { |
|
1957 | - give_update_meta( $form->get_ID(), $key, $value ); |
|
1956 | + foreach ($meta as $key => $value) { |
|
1957 | + give_update_meta($form->get_ID(), $key, $value); |
|
1958 | 1958 | } |
1959 | 1959 | } |
1960 | 1960 | |
1961 | 1961 | // update the report |
1962 | - give_import_donation_report_update( $report ); |
|
1962 | + give_import_donation_report_update($report); |
|
1963 | 1963 | |
1964 | 1964 | return $form; |
1965 | 1965 | } |
@@ -1972,19 +1972,19 @@ discard block |
||
1972 | 1972 | * @param \WP_Query |
1973 | 1973 | * |
1974 | 1974 | */ |
1975 | -function give_remove_pages_from_search( $query ) { |
|
1976 | - if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) { |
|
1977 | - $transaction_failed = give_get_option( 'failure_page', 0 ); |
|
1978 | - $success_page = give_get_option( 'success_page', 0 ); |
|
1979 | - $args = apply_filters( 'give_remove_pages_from_search', array( |
|
1975 | +function give_remove_pages_from_search($query) { |
|
1976 | + if ( ! $query->is_admin && $query->is_search && $query->is_main_query()) { |
|
1977 | + $transaction_failed = give_get_option('failure_page', 0); |
|
1978 | + $success_page = give_get_option('success_page', 0); |
|
1979 | + $args = apply_filters('give_remove_pages_from_search', array( |
|
1980 | 1980 | $transaction_failed, |
1981 | 1981 | $success_page |
1982 | - ), $query ); |
|
1983 | - $query->set( 'post__not_in', $args ); |
|
1982 | + ), $query); |
|
1983 | + $query->set('post__not_in', $args); |
|
1984 | 1984 | } |
1985 | 1985 | } |
1986 | 1986 | |
1987 | -add_action( 'pre_get_posts', 'give_remove_pages_from_search', 10, 1 ); |
|
1987 | +add_action('pre_get_posts', 'give_remove_pages_from_search', 10, 1); |
|
1988 | 1988 | |
1989 | 1989 | /** |
1990 | 1990 | * Inserts a new key/value before a key in the array. |
@@ -2000,14 +2000,14 @@ discard block |
||
2000 | 2000 | * |
2001 | 2001 | * @see array_insert_before() |
2002 | 2002 | */ |
2003 | -function give_array_insert_before( $key, array &$array, $new_key, $new_value ) { |
|
2004 | - if ( array_key_exists( $key, $array ) ) { |
|
2003 | +function give_array_insert_before($key, array &$array, $new_key, $new_value) { |
|
2004 | + if (array_key_exists($key, $array)) { |
|
2005 | 2005 | $new = array(); |
2006 | - foreach ( $array as $k => $value ) { |
|
2007 | - if ( $k === $key ) { |
|
2008 | - $new[ $new_key ] = $new_value; |
|
2006 | + foreach ($array as $k => $value) { |
|
2007 | + if ($k === $key) { |
|
2008 | + $new[$new_key] = $new_value; |
|
2009 | 2009 | } |
2010 | - $new[ $k ] = $value; |
|
2010 | + $new[$k] = $value; |
|
2011 | 2011 | } |
2012 | 2012 | |
2013 | 2013 | return $new; |
@@ -2030,13 +2030,13 @@ discard block |
||
2030 | 2030 | * |
2031 | 2031 | * @see array_insert_before() |
2032 | 2032 | */ |
2033 | -function give_array_insert_after( $key, array &$array, $new_key, $new_value ) { |
|
2034 | - if ( array_key_exists( $key, $array ) ) { |
|
2033 | +function give_array_insert_after($key, array &$array, $new_key, $new_value) { |
|
2034 | + if (array_key_exists($key, $array)) { |
|
2035 | 2035 | $new = array(); |
2036 | - foreach ( $array as $k => $value ) { |
|
2037 | - $new[ $k ] = $value; |
|
2038 | - if ( $k === $key ) { |
|
2039 | - $new[ $new_key ] = $new_value; |
|
2036 | + foreach ($array as $k => $value) { |
|
2037 | + $new[$k] = $value; |
|
2038 | + if ($k === $key) { |
|
2039 | + $new[$new_key] = $new_value; |
|
2040 | 2040 | } |
2041 | 2041 | } |
2042 | 2042 | |
@@ -2063,21 +2063,21 @@ discard block |
||
2063 | 2063 | * corresponding to `$index_key`. If `$index_key` is null, array keys from the original |
2064 | 2064 | * `$list` will be preserved in the results. |
2065 | 2065 | */ |
2066 | -function give_list_pluck( $list, $field, $index_key = null ) { |
|
2066 | +function give_list_pluck($list, $field, $index_key = null) { |
|
2067 | 2067 | |
2068 | - if ( ! $index_key ) { |
|
2068 | + if ( ! $index_key) { |
|
2069 | 2069 | /* |
2070 | 2070 | * This is simple. Could at some point wrap array_column() |
2071 | 2071 | * if we knew we had an array of arrays. |
2072 | 2072 | */ |
2073 | - foreach ( $list as $key => $value ) { |
|
2074 | - if ( is_object( $value ) ) { |
|
2075 | - if ( isset( $value->$field ) ) { |
|
2076 | - $list[ $key ] = $value->$field; |
|
2073 | + foreach ($list as $key => $value) { |
|
2074 | + if (is_object($value)) { |
|
2075 | + if (isset($value->$field)) { |
|
2076 | + $list[$key] = $value->$field; |
|
2077 | 2077 | } |
2078 | 2078 | } else { |
2079 | - if ( isset( $value[ $field ] ) ) { |
|
2080 | - $list[ $key ] = $value[ $field ]; |
|
2079 | + if (isset($value[$field])) { |
|
2080 | + $list[$key] = $value[$field]; |
|
2081 | 2081 | } |
2082 | 2082 | } |
2083 | 2083 | } |
@@ -2090,18 +2090,18 @@ discard block |
||
2090 | 2090 | * to the end of the stack. This is how array_column() behaves. |
2091 | 2091 | */ |
2092 | 2092 | $newlist = array(); |
2093 | - foreach ( $list as $value ) { |
|
2094 | - if ( is_object( $value ) ) { |
|
2095 | - if ( isset( $value->$index_key ) ) { |
|
2096 | - $newlist[ $value->$index_key ] = $value->$field; |
|
2093 | + foreach ($list as $value) { |
|
2094 | + if (is_object($value)) { |
|
2095 | + if (isset($value->$index_key)) { |
|
2096 | + $newlist[$value->$index_key] = $value->$field; |
|
2097 | 2097 | } else { |
2098 | 2098 | $newlist[] = $value->$field; |
2099 | 2099 | } |
2100 | 2100 | } else { |
2101 | - if ( isset( $value[ $index_key ] ) ) { |
|
2102 | - $newlist[ $value[ $index_key ] ] = $value[ $field ]; |
|
2101 | + if (isset($value[$index_key])) { |
|
2102 | + $newlist[$value[$index_key]] = $value[$field]; |
|
2103 | 2103 | } else { |
2104 | - $newlist[] = $value[ $field ]; |
|
2104 | + $newlist[] = $value[$field]; |
|
2105 | 2105 | } |
2106 | 2106 | } |
2107 | 2107 | } |
@@ -2117,7 +2117,7 @@ discard block |
||
2117 | 2117 | * @since 1.8.13 |
2118 | 2118 | */ |
2119 | 2119 | function give_import_donation_report() { |
2120 | - return get_option( 'give_import_donation_report', array() ); |
|
2120 | + return get_option('give_import_donation_report', array()); |
|
2121 | 2121 | } |
2122 | 2122 | |
2123 | 2123 | |
@@ -2126,8 +2126,8 @@ discard block |
||
2126 | 2126 | * |
2127 | 2127 | * @since 1.8.13 |
2128 | 2128 | */ |
2129 | -function give_import_donation_report_update( $value = array() ) { |
|
2130 | - update_option( 'give_import_donation_report', $value ); |
|
2129 | +function give_import_donation_report_update($value = array()) { |
|
2130 | + update_option('give_import_donation_report', $value); |
|
2131 | 2131 | } |
2132 | 2132 | |
2133 | 2133 | |
@@ -2137,7 +2137,7 @@ discard block |
||
2137 | 2137 | * @since 1.8.13 |
2138 | 2138 | */ |
2139 | 2139 | function give_import_donation_report_reset() { |
2140 | - update_option( 'give_import_donation_report', array() ); |
|
2140 | + update_option('give_import_donation_report', array()); |
|
2141 | 2141 | } |
2142 | 2142 | |
2143 | 2143 | |
@@ -2154,8 +2154,8 @@ discard block |
||
2154 | 2154 | * |
2155 | 2155 | * @return int|false Meta ID on success, false on failure. |
2156 | 2156 | */ |
2157 | -function add_donor_meta( $donor_id, $meta_key, $meta_value, $unique = false ) { |
|
2158 | - return add_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $unique ); |
|
2157 | +function add_donor_meta($donor_id, $meta_key, $meta_value, $unique = false) { |
|
2158 | + return add_metadata('give_customer', $donor_id, $meta_key, $meta_value, $unique); |
|
2159 | 2159 | } |
2160 | 2160 | |
2161 | 2161 | /** |
@@ -2173,8 +2173,8 @@ discard block |
||
2173 | 2173 | * |
2174 | 2174 | * @return bool True on success, false on failure. |
2175 | 2175 | */ |
2176 | -function delete_donor_meta( $donor_id, $meta_key, $meta_value = '' ) { |
|
2177 | - return delete_metadata( 'give_customer', $donor_id, $meta_key, $meta_value ); |
|
2176 | +function delete_donor_meta($donor_id, $meta_key, $meta_value = '') { |
|
2177 | + return delete_metadata('give_customer', $donor_id, $meta_key, $meta_value); |
|
2178 | 2178 | } |
2179 | 2179 | |
2180 | 2180 | /** |
@@ -2189,8 +2189,8 @@ discard block |
||
2189 | 2189 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
2190 | 2190 | * is true. |
2191 | 2191 | */ |
2192 | -function get_donor_meta( $donor_id, $key = '', $single = false ) { |
|
2193 | - return get_metadata( 'give_customer', $donor_id, $key, $single ); |
|
2192 | +function get_donor_meta($donor_id, $key = '', $single = false) { |
|
2193 | + return get_metadata('give_customer', $donor_id, $key, $single); |
|
2194 | 2194 | } |
2195 | 2195 | |
2196 | 2196 | /** |
@@ -2207,8 +2207,8 @@ discard block |
||
2207 | 2207 | * |
2208 | 2208 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure. |
2209 | 2209 | */ |
2210 | -function update_donor_meta( $donor_id, $meta_key, $meta_value, $prev_value = '' ) { |
|
2211 | - return update_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $prev_value ); |
|
2210 | +function update_donor_meta($donor_id, $meta_key, $meta_value, $prev_value = '') { |
|
2211 | + return update_metadata('give_customer', $donor_id, $meta_key, $meta_value, $prev_value); |
|
2212 | 2212 | } |
2213 | 2213 | |
2214 | 2214 | /* |
@@ -2218,54 +2218,54 @@ discard block |
||
2218 | 2218 | * |
2219 | 2219 | * @param int $form_id Form id of which recalculation needs to be done. |
2220 | 2220 | */ |
2221 | -function give_recount_form_income_donation( $form_id = false ) { |
|
2221 | +function give_recount_form_income_donation($form_id = false) { |
|
2222 | 2222 | // Check if form id is not empty. |
2223 | - if ( ! empty( $form_id ) ) { |
|
2223 | + if ( ! empty($form_id)) { |
|
2224 | 2224 | /** |
2225 | 2225 | * Filter to modify payment status. |
2226 | 2226 | * |
2227 | 2227 | * @since 1.8.13 |
2228 | 2228 | */ |
2229 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
2229 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
2230 | 2230 | |
2231 | 2231 | /** |
2232 | 2232 | * Filter to modify args of payment query before recalculating the form total |
2233 | 2233 | * |
2234 | 2234 | * @since 1.8.13 |
2235 | 2235 | */ |
2236 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
2236 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
2237 | 2237 | 'give_forms' => $form_id, |
2238 | 2238 | 'status' => $accepted_statuses, |
2239 | - 'posts_per_page' => - 1, |
|
2239 | + 'posts_per_page' => -1, |
|
2240 | 2240 | 'fields' => 'ids', |
2241 | - ) ); |
|
2241 | + )); |
|
2242 | 2242 | |
2243 | 2243 | $totals = array( |
2244 | 2244 | 'sales' => 0, |
2245 | 2245 | 'earnings' => 0, |
2246 | 2246 | ); |
2247 | 2247 | |
2248 | - $payments = new Give_Payments_Query( $args ); |
|
2248 | + $payments = new Give_Payments_Query($args); |
|
2249 | 2249 | $payments = $payments->get_payments(); |
2250 | 2250 | |
2251 | - if ( $payments ) { |
|
2252 | - foreach ( $payments as $payment ) { |
|
2251 | + if ($payments) { |
|
2252 | + foreach ($payments as $payment) { |
|
2253 | 2253 | //Ensure acceptible status only |
2254 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
2254 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
2255 | 2255 | continue; |
2256 | 2256 | } |
2257 | 2257 | |
2258 | 2258 | //Ensure only payments for this form are counted |
2259 | - if ( $payment->form_id != $form_id ) { |
|
2259 | + if ($payment->form_id != $form_id) { |
|
2260 | 2260 | continue; |
2261 | 2261 | } |
2262 | 2262 | |
2263 | - $totals['sales'] ++; |
|
2263 | + $totals['sales']++; |
|
2264 | 2264 | $totals['earnings'] += $payment->total; |
2265 | 2265 | |
2266 | 2266 | } |
2267 | 2267 | } |
2268 | - give_update_meta( $form_id, '_give_form_sales', $totals['sales'] ); |
|
2269 | - give_update_meta( $form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
2268 | + give_update_meta($form_id, '_give_form_sales', $totals['sales']); |
|
2269 | + give_update_meta($form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
2270 | 2270 | } |
2271 | 2271 | } |
2272 | 2272 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
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 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param $data |
23 | 23 | */ |
24 | -function give_process_gateway_select( $data ) { |
|
25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
24 | +function give_process_gateway_select($data) { |
|
25 | + if (isset($_POST['gateway_submit'])) { |
|
26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Loads a payment gateway via AJAX. |
@@ -38,20 +38,20 @@ discard block |
||
38 | 38 | * @return void |
39 | 39 | */ |
40 | 40 | function give_load_ajax_gateway() { |
41 | - if ( isset( $_POST['give_payment_mode'] ) ) { |
|
41 | + if (isset($_POST['give_payment_mode'])) { |
|
42 | 42 | /** |
43 | 43 | * Fire to render donation form. |
44 | 44 | * |
45 | 45 | * @since 1.7 |
46 | 46 | */ |
47 | - do_action( 'give_donation_form', $_POST['give_form_id'] ); |
|
47 | + do_action('give_donation_form', $_POST['give_form_id']); |
|
48 | 48 | |
49 | 49 | exit(); |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
54 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
53 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
54 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Sets an error within the donation form if no gateways are enabled. |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | function give_no_gateway_error() { |
64 | 64 | $gateways = give_get_enabled_payment_gateways(); |
65 | 65 | |
66 | - if ( empty( $gateways ) ) { |
|
67 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
66 | + if (empty($gateways)) { |
|
67 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
68 | 68 | } else { |
69 | - give_unset_error( 'no_gateways' ); |
|
69 | + give_unset_error('no_gateways'); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | -add_action( 'init', 'give_no_gateway_error' ); |
|
73 | +add_action('init', 'give_no_gateway_error'); |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Page' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Page')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Page. |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | // Get current setting page. |
63 | 63 | $this->current_setting_page = give_get_current_setting_page(); |
64 | 64 | |
65 | - add_filter( "give_default_setting_tab_section_{$this->id}", array( $this, 'set_default_setting_tab' ), 10 ); |
|
66 | - add_filter( "{$this->current_setting_page}_tabs_array", array( $this, 'add_settings_page' ), 20 ); |
|
67 | - add_action( "{$this->current_setting_page}_sections_{$this->id}_page", array( $this, 'output_sections' ) ); |
|
68 | - add_action( "{$this->current_setting_page}_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
69 | - add_action( "{$this->current_setting_page}_save_{$this->id}", array( $this, 'save' ) ); |
|
65 | + add_filter("give_default_setting_tab_section_{$this->id}", array($this, 'set_default_setting_tab'), 10); |
|
66 | + add_filter("{$this->current_setting_page}_tabs_array", array($this, 'add_settings_page'), 20); |
|
67 | + add_action("{$this->current_setting_page}_sections_{$this->id}_page", array($this, 'output_sections')); |
|
68 | + add_action("{$this->current_setting_page}_settings_{$this->id}_page", array($this, 'output')); |
|
69 | + add_action("{$this->current_setting_page}_save_{$this->id}", array($this, 'save')); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return string |
80 | 80 | */ |
81 | - function set_default_setting_tab( $setting_tab ) { |
|
81 | + function set_default_setting_tab($setting_tab) { |
|
82 | 82 | return $this->default_tab; |
83 | 83 | } |
84 | 84 | |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return array |
93 | 93 | */ |
94 | - public function add_settings_page( $pages ) { |
|
95 | - $pages[ $this->id ] = $this->label; |
|
94 | + public function add_settings_page($pages) { |
|
95 | + $pages[$this->id] = $this->label; |
|
96 | 96 | |
97 | 97 | return $pages; |
98 | 98 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @param array $settings |
113 | 113 | */ |
114 | - $settings = apply_filters( 'give_get_settings_' . $this->id, array() ); |
|
114 | + $settings = apply_filters('give_get_settings_'.$this->id, array()); |
|
115 | 115 | |
116 | 116 | // Output. |
117 | 117 | return $settings; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @return array |
125 | 125 | */ |
126 | 126 | public function get_sections() { |
127 | - return apply_filters( 'give_get_sections_' . $this->id, array() ); |
|
127 | + return apply_filters('give_get_sections_'.$this->id, array()); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -141,29 +141,29 @@ discard block |
||
141 | 141 | $sections = $this->get_sections(); |
142 | 142 | |
143 | 143 | // Show section settings only if setting section exist. |
144 | - if ( $current_section && ! in_array( $current_section, array_keys( $sections ) ) ) { |
|
145 | - echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; |
|
144 | + if ($current_section && ! in_array($current_section, array_keys($sections))) { |
|
145 | + echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; |
|
146 | 146 | $GLOBALS['give_hide_save_button'] = true; |
147 | 147 | |
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Bailout. |
152 | - if ( empty( $sections ) ) { |
|
152 | + if (empty($sections)) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | - if ( is_null( $this->current_setting_page ) ) { |
|
156 | + if (is_null($this->current_setting_page)) { |
|
157 | 157 | $this->current_setting_page = give_get_current_setting_page(); |
158 | 158 | } |
159 | 159 | |
160 | 160 | echo '<ul class="subsubsub">'; |
161 | 161 | |
162 | 162 | // Get section keys. |
163 | - $array_keys = array_keys( $sections ); |
|
163 | + $array_keys = array_keys($sections); |
|
164 | 164 | |
165 | - foreach ( $sections as $id => $label ) { |
|
166 | - echo '<li><a href="' . admin_url( 'edit.php?post_type=give_forms&page=' . $this->current_setting_page . '&tab=' . $this->id . '§ion=' . sanitize_title( $id ) ) . '" class="' . ( $current_section == $id ? 'current' : '' ) . '">' . $label . '</a> ' . ( end( $array_keys ) == $id ? '' : '|' ) . ' </li>'; |
|
165 | + foreach ($sections as $id => $label) { |
|
166 | + echo '<li><a href="'.admin_url('edit.php?post_type=give_forms&page='.$this->current_setting_page.'&tab='.$this->id.'§ion='.sanitize_title($id)).'" class="'.($current_section == $id ? 'current' : '').'">'.$label.'</a> '.(end($array_keys) == $id ? '' : '|').' </li>'; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | echo '</ul><br class="clear" /><hr>'; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | public function output() { |
179 | 179 | $settings = $this->get_settings(); |
180 | 180 | |
181 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
181 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | $settings = $this->get_settings(); |
192 | 192 | $current_section = give_get_current_setting_section(); |
193 | 193 | |
194 | - Give_Admin_Settings::save_fields( $settings, 'give_settings' ); |
|
194 | + Give_Admin_Settings::save_fields($settings, 'give_settings'); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Trigger Action |
198 | 198 | * |
199 | 199 | * @since 1.8 |
200 | 200 | */ |
201 | - do_action( 'give_update_options_' . $this->id . '_' . $current_section ); |
|
201 | + do_action('give_update_options_'.$this->id.'_'.$current_section); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_General' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_General')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_General. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'general'; |
30 | - $this->label = esc_html__( 'General', 'give' ); |
|
30 | + $this->label = esc_html__('General', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'general-settings'; |
33 | 33 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $settings = array(); |
45 | 45 | $current_section = give_get_current_setting_section(); |
46 | 46 | |
47 | - switch ( $current_section ) { |
|
47 | + switch ($current_section) { |
|
48 | 48 | case 'access-control': |
49 | 49 | $settings = array( |
50 | 50 | // Section 3: Access control. |
@@ -54,47 +54,47 @@ discard block |
||
54 | 54 | ), |
55 | 55 | array( |
56 | 56 | 'id' => 'session_lifetime', |
57 | - 'name' => esc_html__( 'Session Lifetime', 'give' ), |
|
58 | - 'desc' => esc_html__( 'The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give' ), |
|
57 | + 'name' => esc_html__('Session Lifetime', 'give'), |
|
58 | + 'desc' => esc_html__('The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give'), |
|
59 | 59 | 'type' => 'select', |
60 | 60 | 'options' => array( |
61 | - '86400' => esc_html__( '24 Hours', 'give' ), |
|
62 | - '172800' => esc_html__( '48 Hours', 'give' ), |
|
63 | - '259200' => esc_html__( '72 Hours', 'give' ), |
|
64 | - '604800' => esc_html__( '1 Week', 'give' ), |
|
61 | + '86400' => esc_html__('24 Hours', 'give'), |
|
62 | + '172800' => esc_html__('48 Hours', 'give'), |
|
63 | + '259200' => esc_html__('72 Hours', 'give'), |
|
64 | + '604800' => esc_html__('1 Week', 'give'), |
|
65 | 65 | ) |
66 | 66 | ), |
67 | 67 | array( |
68 | - 'name' => esc_html__( 'Email Access', 'give' ), |
|
69 | - 'desc' => esc_html__( 'Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give' ), |
|
68 | + 'name' => esc_html__('Email Access', 'give'), |
|
69 | + 'desc' => esc_html__('Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give'), |
|
70 | 70 | 'id' => 'email_access', |
71 | 71 | 'type' => 'radio_inline', |
72 | 72 | 'default' => 'disabled', |
73 | 73 | 'options' => array( |
74 | - 'enabled' => __( 'Enabled', 'give' ), |
|
75 | - 'disabled' => __( 'Disabled', 'give' ), |
|
74 | + 'enabled' => __('Enabled', 'give'), |
|
75 | + 'disabled' => __('Disabled', 'give'), |
|
76 | 76 | ) |
77 | 77 | ), |
78 | 78 | array( |
79 | 79 | 'id' => 'recaptcha_key', |
80 | - 'name' => esc_html__( 'reCAPTCHA Site Key', 'give' ), |
|
80 | + 'name' => esc_html__('reCAPTCHA Site Key', 'give'), |
|
81 | 81 | /* translators: %s: https://www.google.com/recaptcha/ */ |
82 | - 'desc' => sprintf( __( 'Please paste your reCAPTCHA site key here. <br />If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), esc_url( 'http://docs.givewp.com/recaptcha' ) ), |
|
82 | + 'desc' => sprintf(__('Please paste your reCAPTCHA site key here. <br />If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give'), esc_url('http://docs.givewp.com/recaptcha')), |
|
83 | 83 | 'default' => '', |
84 | 84 | 'type' => 'text' |
85 | 85 | ), |
86 | 86 | array( |
87 | 87 | 'id' => 'recaptcha_secret', |
88 | - 'name' => esc_html__( 'reCAPTCHA Secret Key', 'give' ), |
|
89 | - 'desc' => esc_html__( 'Please paste the reCAPTCHA secret key here from your reCAPTCHA API Keys panel.', 'give' ), |
|
88 | + 'name' => esc_html__('reCAPTCHA Secret Key', 'give'), |
|
89 | + 'desc' => esc_html__('Please paste the reCAPTCHA secret key here from your reCAPTCHA API Keys panel.', 'give'), |
|
90 | 90 | 'default' => '', |
91 | 91 | 'type' => 'text' |
92 | 92 | ), |
93 | 93 | array( |
94 | - 'name' => esc_html__( 'Access Control Docs Link', 'give' ), |
|
94 | + 'name' => esc_html__('Access Control Docs Link', 'give'), |
|
95 | 95 | 'id' => 'access_control_docs_link', |
96 | - 'url' => esc_url( 'http://docs.givewp.com/settings-access-control' ), |
|
97 | - 'title' => __( 'Access Control', 'give' ), |
|
96 | + 'url' => esc_url('http://docs.givewp.com/settings-access-control'), |
|
97 | + 'title' => __('Access Control', 'give'), |
|
98 | 98 | 'type' => 'give_docs_link', |
99 | 99 | ), |
100 | 100 | array( |
@@ -112,61 +112,61 @@ discard block |
||
112 | 112 | 'id' => 'give_title_general_settings_2' |
113 | 113 | ), |
114 | 114 | array( |
115 | - 'name' => esc_html__( 'Currency Settings', 'give' ), |
|
115 | + 'name' => esc_html__('Currency Settings', 'give'), |
|
116 | 116 | 'desc' => '', |
117 | 117 | 'type' => 'give_title', |
118 | 118 | 'id' => 'give_title_general_settings_2' |
119 | 119 | ), |
120 | 120 | array( |
121 | - 'name' => esc_html__( 'Currency', 'give' ), |
|
122 | - 'desc' => esc_html__( 'The donation currency. Note that some payment gateways have currency restrictions.', 'give' ), |
|
121 | + 'name' => esc_html__('Currency', 'give'), |
|
122 | + 'desc' => esc_html__('The donation currency. Note that some payment gateways have currency restrictions.', 'give'), |
|
123 | 123 | 'id' => 'currency', |
124 | 124 | 'type' => 'select', |
125 | 125 | 'options' => give_get_currencies(), |
126 | 126 | 'default' => 'USD', |
127 | 127 | ), |
128 | 128 | array( |
129 | - 'name' => esc_html__( 'Currency Position', 'give' ), |
|
130 | - 'desc' => esc_html__( 'The position of the currency symbol.', 'give' ), |
|
129 | + 'name' => esc_html__('Currency Position', 'give'), |
|
130 | + 'desc' => esc_html__('The position of the currency symbol.', 'give'), |
|
131 | 131 | 'id' => 'currency_position', |
132 | 132 | 'type' => 'select', |
133 | 133 | 'options' => array( |
134 | 134 | /* translators: %s: currency symbol */ |
135 | - 'before' => sprintf( esc_html__( 'Before - %s10', 'give' ), give_currency_symbol( give_get_currency() ) ), |
|
135 | + 'before' => sprintf(esc_html__('Before - %s10', 'give'), give_currency_symbol(give_get_currency())), |
|
136 | 136 | /* translators: %s: currency symbol */ |
137 | - 'after' => sprintf( esc_html__( 'After - 10%s', 'give' ), give_currency_symbol( give_get_currency() ) ) |
|
137 | + 'after' => sprintf(esc_html__('After - 10%s', 'give'), give_currency_symbol(give_get_currency())) |
|
138 | 138 | ), |
139 | 139 | 'default' => 'before', |
140 | 140 | ), |
141 | 141 | array( |
142 | - 'name' => esc_html__( 'Thousands Separator', 'give' ), |
|
143 | - 'desc' => esc_html__( 'The symbol (typically , or .) to separate thousands.', 'give' ), |
|
142 | + 'name' => esc_html__('Thousands Separator', 'give'), |
|
143 | + 'desc' => esc_html__('The symbol (typically , or .) to separate thousands.', 'give'), |
|
144 | 144 | 'id' => 'thousands_separator', |
145 | 145 | 'type' => 'text', |
146 | 146 | 'default' => ',', |
147 | 147 | 'css' => 'width:12em;', |
148 | 148 | ), |
149 | 149 | array( |
150 | - 'name' => esc_html__( 'Decimal Separator', 'give' ), |
|
151 | - 'desc' => esc_html__( 'The symbol (usually , or .) to separate decimal points.', 'give' ), |
|
150 | + 'name' => esc_html__('Decimal Separator', 'give'), |
|
151 | + 'desc' => esc_html__('The symbol (usually , or .) to separate decimal points.', 'give'), |
|
152 | 152 | 'id' => 'decimal_separator', |
153 | 153 | 'type' => 'text', |
154 | 154 | 'default' => '.', |
155 | 155 | 'css' => 'width:12em;', |
156 | 156 | ), |
157 | 157 | array( |
158 | - 'name' => __( 'Number of Decimals', 'give' ), |
|
159 | - 'desc' => __( 'The number of decimal points displayed in amounts.', 'give' ), |
|
158 | + 'name' => __('Number of Decimals', 'give'), |
|
159 | + 'desc' => __('The number of decimal points displayed in amounts.', 'give'), |
|
160 | 160 | 'id' => 'number_decimals', |
161 | 161 | 'type' => 'text', |
162 | 162 | 'default' => 2, |
163 | 163 | 'css' => 'width:12em;', |
164 | 164 | ), |
165 | 165 | array( |
166 | - 'name' => esc_html__( 'Currency Options Docs Link', 'give' ), |
|
166 | + 'name' => esc_html__('Currency Options Docs Link', 'give'), |
|
167 | 167 | 'id' => 'currency_settings_docs_link', |
168 | - 'url' => esc_url( 'http://docs.givewp.com/settings-currency' ), |
|
169 | - 'title' => __( 'Currency Settings', 'give' ), |
|
168 | + 'url' => esc_url('http://docs.givewp.com/settings-currency'), |
|
169 | + 'title' => __('Currency Settings', 'give'), |
|
170 | 170 | 'type' => 'give_docs_link', |
171 | 171 | ), |
172 | 172 | array( |
@@ -184,55 +184,55 @@ discard block |
||
184 | 184 | 'id' => 'give_title_general_settings_1' |
185 | 185 | ), |
186 | 186 | array( |
187 | - 'name' => esc_html__( 'General Settings', 'give' ), |
|
187 | + 'name' => esc_html__('General Settings', 'give'), |
|
188 | 188 | 'desc' => '', |
189 | 189 | 'type' => 'give_title', |
190 | 190 | 'id' => 'give_title_general_settings_1' |
191 | 191 | ), |
192 | 192 | array( |
193 | - 'name' => esc_html__( 'Success Page', 'give' ), |
|
193 | + 'name' => esc_html__('Success Page', 'give'), |
|
194 | 194 | /* translators: %s: [give_receipt] */ |
195 | - 'desc' => sprintf( __( 'The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give' ), '<code>[give_receipt]</code>' ), |
|
195 | + 'desc' => sprintf(__('The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give'), '<code>[give_receipt]</code>'), |
|
196 | 196 | 'id' => 'success_page', |
197 | 197 | 'type' => 'select', |
198 | - 'options' => give_cmb2_get_post_options( array( |
|
198 | + 'options' => give_cmb2_get_post_options(array( |
|
199 | 199 | 'post_type' => 'page', |
200 | - 'numberposts' => - 1 |
|
201 | - ) ), |
|
200 | + 'numberposts' => -1 |
|
201 | + )), |
|
202 | 202 | ), |
203 | 203 | array( |
204 | - 'name' => esc_html__( 'Failed Donation Page', 'give' ), |
|
205 | - 'desc' => esc_html__( 'The page donors are sent to if their donation is cancelled or fails.', 'give' ), |
|
204 | + 'name' => esc_html__('Failed Donation Page', 'give'), |
|
205 | + 'desc' => esc_html__('The page donors are sent to if their donation is cancelled or fails.', 'give'), |
|
206 | 206 | 'id' => 'failure_page', |
207 | 207 | 'type' => 'select', |
208 | - 'options' => give_cmb2_get_post_options( array( |
|
208 | + 'options' => give_cmb2_get_post_options(array( |
|
209 | 209 | 'post_type' => 'page', |
210 | - 'numberposts' => - 1 |
|
211 | - ) ), |
|
210 | + 'numberposts' => -1 |
|
211 | + )), |
|
212 | 212 | ), |
213 | 213 | array( |
214 | - 'name' => esc_html__( 'Donation History Page', 'give' ), |
|
214 | + 'name' => esc_html__('Donation History Page', 'give'), |
|
215 | 215 | /* translators: %s: [donation_history] */ |
216 | - 'desc' => sprintf( __( 'The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give' ), '<code>[donation_history]</code>' ), |
|
216 | + 'desc' => sprintf(__('The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give'), '<code>[donation_history]</code>'), |
|
217 | 217 | 'id' => 'history_page', |
218 | 218 | 'type' => 'select', |
219 | - 'options' => give_cmb2_get_post_options( array( |
|
219 | + 'options' => give_cmb2_get_post_options(array( |
|
220 | 220 | 'post_type' => 'page', |
221 | - 'numberposts' => - 1 |
|
222 | - ) ), |
|
221 | + 'numberposts' => -1 |
|
222 | + )), |
|
223 | 223 | ), |
224 | 224 | array( |
225 | - 'name' => esc_html__( 'Base Country', 'give' ), |
|
226 | - 'desc' => esc_html__( 'The country your site operates from.', 'give' ), |
|
225 | + 'name' => esc_html__('Base Country', 'give'), |
|
226 | + 'desc' => esc_html__('The country your site operates from.', 'give'), |
|
227 | 227 | 'id' => 'base_country', |
228 | 228 | 'type' => 'select', |
229 | 229 | 'options' => give_get_country_list(), |
230 | 230 | ), |
231 | 231 | array( |
232 | - 'name' => esc_html__( 'General Options Docs Link', 'give' ), |
|
232 | + 'name' => esc_html__('General Options Docs Link', 'give'), |
|
233 | 233 | 'id' => 'general_options_docs_link', |
234 | - 'url' => esc_url( 'http://docs.givewp.com/settings-general' ), |
|
235 | - 'title' => __( 'General Options', 'give' ), |
|
234 | + 'url' => esc_url('http://docs.givewp.com/settings-general'), |
|
235 | + 'title' => __('General Options', 'give'), |
|
236 | 236 | 'type' => 'give_docs_link', |
237 | 237 | ), |
238 | 238 | array( |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * Filter the general settings. |
248 | 248 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
249 | 249 | */ |
250 | - $settings = apply_filters( 'give_settings_general', $settings ); |
|
250 | + $settings = apply_filters('give_settings_general', $settings); |
|
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Filter the settings. |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @param array $settings |
258 | 258 | */ |
259 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
259 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
260 | 260 | |
261 | 261 | // Output. |
262 | 262 | return $settings; |
@@ -270,12 +270,12 @@ discard block |
||
270 | 270 | */ |
271 | 271 | public function get_sections() { |
272 | 272 | $sections = array( |
273 | - 'general-settings' => esc_html__( 'General', 'give' ), |
|
274 | - 'currency-settings' => esc_html__( 'Currency', 'give' ), |
|
275 | - 'access-control' => esc_html__( 'Access Control', 'give' ) |
|
273 | + 'general-settings' => esc_html__('General', 'give'), |
|
274 | + 'currency-settings' => esc_html__('Currency', 'give'), |
|
275 | + 'access-control' => esc_html__('Access Control', 'give') |
|
276 | 276 | ); |
277 | 277 | |
278 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
278 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | 'default' => '', |
91 | 91 | 'type' => 'text' |
92 | 92 | ), |
93 | - array( |
|
94 | - 'name' => esc_html__( 'Access Control Docs Link', 'give' ), |
|
95 | - 'id' => 'access_control_docs_link', |
|
96 | - 'url' => esc_url( 'http://docs.givewp.com/settings-access-control' ), |
|
97 | - 'title' => __( 'Access Control', 'give' ), |
|
98 | - 'type' => 'give_docs_link', |
|
99 | - ), |
|
93 | + array( |
|
94 | + 'name' => esc_html__( 'Access Control Docs Link', 'give' ), |
|
95 | + 'id' => 'access_control_docs_link', |
|
96 | + 'url' => esc_url( 'http://docs.givewp.com/settings-access-control' ), |
|
97 | + 'title' => __( 'Access Control', 'give' ), |
|
98 | + 'type' => 'give_docs_link', |
|
99 | + ), |
|
100 | 100 | array( |
101 | 101 | 'id' => 'give_title_session_control_1', |
102 | 102 | 'type' => 'sectionend' |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | 'default' => 2, |
163 | 163 | 'css' => 'width:12em;', |
164 | 164 | ), |
165 | - array( |
|
166 | - 'name' => esc_html__( 'Currency Options Docs Link', 'give' ), |
|
167 | - 'id' => 'currency_settings_docs_link', |
|
168 | - 'url' => esc_url( 'http://docs.givewp.com/settings-currency' ), |
|
169 | - 'title' => __( 'Currency Settings', 'give' ), |
|
170 | - 'type' => 'give_docs_link', |
|
171 | - ), |
|
165 | + array( |
|
166 | + 'name' => esc_html__( 'Currency Options Docs Link', 'give' ), |
|
167 | + 'id' => 'currency_settings_docs_link', |
|
168 | + 'url' => esc_url( 'http://docs.givewp.com/settings-currency' ), |
|
169 | + 'title' => __( 'Currency Settings', 'give' ), |
|
170 | + 'type' => 'give_docs_link', |
|
171 | + ), |
|
172 | 172 | array( |
173 | 173 | 'type' => 'sectionend', |
174 | 174 | 'id' => 'give_title_general_settings_2' |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | 'type' => 'select', |
229 | 229 | 'options' => give_get_country_list(), |
230 | 230 | ), |
231 | - array( |
|
232 | - 'name' => esc_html__( 'General Options Docs Link', 'give' ), |
|
233 | - 'id' => 'general_options_docs_link', |
|
234 | - 'url' => esc_url( 'http://docs.givewp.com/settings-general' ), |
|
235 | - 'title' => __( 'General Options', 'give' ), |
|
236 | - 'type' => 'give_docs_link', |
|
237 | - ), |
|
231 | + array( |
|
232 | + 'name' => esc_html__( 'General Options Docs Link', 'give' ), |
|
233 | + 'id' => 'general_options_docs_link', |
|
234 | + 'url' => esc_url( 'http://docs.givewp.com/settings-general' ), |
|
235 | + 'title' => __( 'General Options', 'give' ), |
|
236 | + 'type' => 'give_docs_link', |
|
237 | + ), |
|
238 | 238 | array( |
239 | 239 | 'type' => 'sectionend', |
240 | 240 | 'id' => 'give_title_general_settings_1' |
@@ -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 | |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function __construct() { |
89 | 89 | |
90 | - if ( 'none' === $this->get_template() ) { |
|
90 | + if ('none' === $this->get_template()) { |
|
91 | 91 | $this->html = false; |
92 | 92 | } |
93 | 93 | |
94 | - add_action( 'give_email_send_before', array( $this, 'send_before' ) ); |
|
95 | - add_action( 'give_email_send_after', array( $this, 'send_after' ) ); |
|
94 | + add_action('give_email_send_before', array($this, 'send_before')); |
|
95 | + add_action('give_email_send_after', array($this, 'send_after')); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param $key |
105 | 105 | * @param $value |
106 | 106 | */ |
107 | - public function __set( $key, $value ) { |
|
107 | + public function __set($key, $value) { |
|
108 | 108 | $this->$key = $value; |
109 | 109 | } |
110 | 110 | |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | * @since 1.0 |
115 | 115 | */ |
116 | 116 | public function get_from_name() { |
117 | - if ( ! $this->from_name ) { |
|
118 | - $this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) ); |
|
117 | + if ( ! $this->from_name) { |
|
118 | + $this->from_name = give_get_option('from_name', get_bloginfo('name')); |
|
119 | 119 | } |
120 | 120 | |
121 | - return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this ); |
|
121 | + return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | * @since 1.0 |
128 | 128 | */ |
129 | 129 | public function get_from_address() { |
130 | - if ( ! $this->from_address ) { |
|
131 | - $this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) ); |
|
130 | + if ( ! $this->from_address) { |
|
131 | + $this->from_address = give_get_option('from_email', get_option('admin_email')); |
|
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( 'give_email_from_address', $this->from_address, $this ); |
|
134 | + return apply_filters('give_email_from_address', $this->from_address, $this); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | * @since 1.0 |
141 | 141 | */ |
142 | 142 | public function get_content_type() { |
143 | - if ( ! $this->content_type && $this->html ) { |
|
144 | - $this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this ); |
|
145 | - } else if ( ! $this->html ) { |
|
143 | + if ( ! $this->content_type && $this->html) { |
|
144 | + $this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this); |
|
145 | + } else if ( ! $this->html) { |
|
146 | 146 | $this->content_type = 'text/plain'; |
147 | 147 | } |
148 | 148 | |
149 | - return apply_filters( 'give_email_content_type', $this->content_type, $this ); |
|
149 | + return apply_filters('give_email_content_type', $this->content_type, $this); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * @since 1.0 |
156 | 156 | */ |
157 | 157 | public function get_headers() { |
158 | - if ( ! $this->headers ) { |
|
158 | + if ( ! $this->headers) { |
|
159 | 159 | $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n"; |
160 | 160 | $this->headers .= "Reply-To: {$this->get_from_address()}\r\n"; |
161 | 161 | $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n"; |
162 | 162 | } |
163 | 163 | |
164 | - return apply_filters( 'give_email_headers', $this->headers, $this ); |
|
164 | + return apply_filters('give_email_headers', $this->headers, $this); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function get_templates() { |
173 | 173 | $templates = array( |
174 | - 'default' => esc_html__( 'Default Template', 'give' ), |
|
175 | - 'none' => esc_html__( 'No template, plain text only', 'give' ) |
|
174 | + 'default' => esc_html__('Default Template', 'give'), |
|
175 | + 'none' => esc_html__('No template, plain text only', 'give') |
|
176 | 176 | ); |
177 | 177 | |
178 | - return apply_filters( 'give_email_templates', $templates ); |
|
178 | + return apply_filters('give_email_templates', $templates); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | * @since 1.0 |
185 | 185 | */ |
186 | 186 | public function get_template() { |
187 | - if ( ! $this->template ) { |
|
188 | - $this->template = give_get_option( 'email_template', 'default' ); |
|
187 | + if ( ! $this->template) { |
|
188 | + $this->template = give_get_option('email_template', 'default'); |
|
189 | 189 | } |
190 | 190 | |
191 | - return apply_filters( 'give_email_template', $this->template ); |
|
191 | + return apply_filters('give_email_template', $this->template); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @since 1.0 |
198 | 198 | */ |
199 | 199 | public function get_heading() { |
200 | - return apply_filters( 'give_email_heading', $this->heading ); |
|
200 | + return apply_filters('give_email_heading', $this->heading); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return mixed |
209 | 209 | */ |
210 | - public function parse_tags( $content ) { |
|
210 | + public function parse_tags($content) { |
|
211 | 211 | return $content; |
212 | 212 | } |
213 | 213 | |
@@ -220,19 +220,19 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - public function build_email( $message ) { |
|
223 | + public function build_email($message) { |
|
224 | 224 | |
225 | - if ( false === $this->html ) { |
|
226 | - return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this ); |
|
225 | + if (false === $this->html) { |
|
226 | + return apply_filters('give_email_message', wp_strip_all_tags($message), $this); |
|
227 | 227 | } |
228 | 228 | |
229 | - $message = $this->text_to_html( $message ); |
|
229 | + $message = $this->text_to_html($message); |
|
230 | 230 | |
231 | 231 | $template = $this->get_template(); |
232 | 232 | |
233 | 233 | ob_start(); |
234 | 234 | |
235 | - give_get_template_part( 'emails/header', $template, true ); |
|
235 | + give_get_template_part('emails/header', $template, true); |
|
236 | 236 | |
237 | 237 | /** |
238 | 238 | * Fires in the email head. |
@@ -241,17 +241,17 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @param Give_Emails $this The email object. |
243 | 243 | */ |
244 | - do_action( 'give_email_header', $this ); |
|
244 | + do_action('give_email_header', $this); |
|
245 | 245 | |
246 | - if ( has_action( 'give_email_template_' . $template ) ) { |
|
246 | + if (has_action('give_email_template_'.$template)) { |
|
247 | 247 | /** |
248 | 248 | * Fires in a specific email template. |
249 | 249 | * |
250 | 250 | * @since 1.0 |
251 | 251 | */ |
252 | - do_action( "give_email_template_{$template}" ); |
|
252 | + do_action("give_email_template_{$template}"); |
|
253 | 253 | } else { |
254 | - give_get_template_part( 'emails/body', $template, true ); |
|
254 | + give_get_template_part('emails/body', $template, true); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @param Give_Emails $this The email object. |
263 | 263 | */ |
264 | - do_action( 'give_email_body', $this ); |
|
264 | + do_action('give_email_body', $this); |
|
265 | 265 | |
266 | - give_get_template_part( 'emails/footer', $template, true ); |
|
266 | + give_get_template_part('emails/footer', $template, true); |
|
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Fires in the email footer. |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @param Give_Emails $this The email object. |
274 | 274 | */ |
275 | - do_action( 'give_email_footer', $this ); |
|
275 | + do_action('give_email_footer', $this); |
|
276 | 276 | |
277 | 277 | $body = ob_get_clean(); |
278 | - $message = str_replace( '{email}', $message, $body ); |
|
278 | + $message = str_replace('{email}', $message, $body); |
|
279 | 279 | |
280 | - return apply_filters( 'give_email_message', $message, $this ); |
|
280 | + return apply_filters('give_email_message', $message, $this); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @return bool |
292 | 292 | */ |
293 | - public function send( $to, $subject, $message, $attachments = '' ) { |
|
293 | + public function send($to, $subject, $message, $attachments = '') { |
|
294 | 294 | |
295 | - if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) { |
|
296 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null ); |
|
295 | + if ( ! did_action('init') && ! did_action('admin_init')) { |
|
296 | + _doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null); |
|
297 | 297 | |
298 | 298 | return false; |
299 | 299 | } |
@@ -305,16 +305,16 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @param Give_Emails $this The email object. |
307 | 307 | */ |
308 | - do_action( 'give_email_send_before', $this ); |
|
308 | + do_action('give_email_send_before', $this); |
|
309 | 309 | |
310 | - $subject = $this->parse_tags( $subject ); |
|
311 | - $message = $this->parse_tags( $message ); |
|
310 | + $subject = $this->parse_tags($subject); |
|
311 | + $message = $this->parse_tags($message); |
|
312 | 312 | |
313 | - $message = $this->build_email( $message ); |
|
313 | + $message = $this->build_email($message); |
|
314 | 314 | |
315 | - $attachments = apply_filters( 'give_email_attachments', $attachments, $this ); |
|
315 | + $attachments = apply_filters('give_email_attachments', $attachments, $this); |
|
316 | 316 | |
317 | - $sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments ); |
|
317 | + $sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments); |
|
318 | 318 | |
319 | 319 | /** |
320 | 320 | * Fires after sending an email. |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @param Give_Emails $this The email object. |
325 | 325 | */ |
326 | - do_action( 'give_email_send_after', $this ); |
|
326 | + do_action('give_email_send_after', $this); |
|
327 | 327 | |
328 | 328 | return $sent; |
329 | 329 | |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | * @since 1.0 |
336 | 336 | */ |
337 | 337 | public function send_before() { |
338 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
339 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
340 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
338 | + add_filter('wp_mail_from', array($this, 'get_from_address')); |
|
339 | + add_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
340 | + add_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -346,9 +346,9 @@ discard block |
||
346 | 346 | * @since 1.0 |
347 | 347 | */ |
348 | 348 | public function send_after() { |
349 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
350 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
351 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
349 | + remove_filter('wp_mail_from', array($this, 'get_from_address')); |
|
350 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
351 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
352 | 352 | |
353 | 353 | // Reset heading to an empty string |
354 | 354 | $this->heading = ''; |
@@ -359,10 +359,10 @@ discard block |
||
359 | 359 | * |
360 | 360 | * @since 1.0 |
361 | 361 | */ |
362 | - public function text_to_html( $message ) { |
|
362 | + public function text_to_html($message) { |
|
363 | 363 | |
364 | - if ( 'text/html' == $this->content_type || true === $this->html ) { |
|
365 | - $message = wpautop( $message ); |
|
364 | + if ('text/html' == $this->content_type || true === $this->html) { |
|
365 | + $message = wpautop($message); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | return $message; |