@@ -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 | |
@@ -27,30 +27,30 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return mixed |
29 | 29 | */ |
30 | -function __give_sanitize_number_decimals_setting_field( $value ) { |
|
30 | +function __give_sanitize_number_decimals_setting_field($value) { |
|
31 | 31 | $value_changed = false; |
32 | 32 | $old_value = $value; |
33 | 33 | |
34 | - if ( isset( $_POST['decimal_separator'] ) ) { |
|
35 | - $value = ! empty( $_POST['decimal_separator'] ) ? $value : 0; |
|
34 | + if (isset($_POST['decimal_separator'])) { |
|
35 | + $value = ! empty($_POST['decimal_separator']) ? $value : 0; |
|
36 | 36 | $value_changed = true; |
37 | 37 | } |
38 | 38 | |
39 | - if ( $value_changed && ( $old_value !== $value ) ) { |
|
40 | - Give_Admin_Settings::add_error( 'give-number-decimal', __( 'The \'Number of Decimals\' option has been automatically set to zero because the \'Decimal Separator\' is not set.', 'give' ) ); |
|
39 | + if ($value_changed && ($old_value !== $value)) { |
|
40 | + Give_Admin_Settings::add_error('give-number-decimal', __('The \'Number of Decimals\' option has been automatically set to zero because the \'Decimal Separator\' is not set.', 'give')); |
|
41 | 41 | } |
42 | 42 | |
43 | - $value = absint( $value ); |
|
43 | + $value = absint($value); |
|
44 | 44 | |
45 | - if ( 6 <= $value ) { |
|
45 | + if (6 <= $value) { |
|
46 | 46 | $value = 5; |
47 | - Give_Admin_Settings::add_error( 'give-number-decimal', __( 'The \'Number of Decimals\' option has been automatically set to 5 because you entered a number higher than the maximum allowed.', 'give' ) ); |
|
47 | + Give_Admin_Settings::add_error('give-number-decimal', __('The \'Number of Decimals\' option has been automatically set to 5 because you entered a number higher than the maximum allowed.', 'give')); |
|
48 | 48 | } |
49 | 49 | |
50 | - return absint( $value ); |
|
50 | + return absint($value); |
|
51 | 51 | } |
52 | 52 | |
53 | -add_filter( 'give_admin_settings_sanitize_option_number_decimals', '__give_sanitize_number_decimals_setting_field', 10 ); |
|
53 | +add_filter('give_admin_settings_sanitize_option_number_decimals', '__give_sanitize_number_decimals_setting_field', 10); |
|
54 | 54 | |
55 | 55 | |
56 | 56 | /** |
@@ -66,20 +66,20 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | -function __give_validate_decimal_separator_setting_field( $value ) { |
|
70 | - $thousand_separator = isset( $_POST['thousands_separator'] ) ? give_clean( $_POST['thousands_separator'] ) : ''; |
|
71 | - $decimal_separator = isset( $_POST['decimal_separator'] ) ? give_clean( $_POST['decimal_separator'] ) : ''; |
|
69 | +function __give_validate_decimal_separator_setting_field($value) { |
|
70 | + $thousand_separator = isset($_POST['thousands_separator']) ? give_clean($_POST['thousands_separator']) : ''; |
|
71 | + $decimal_separator = isset($_POST['decimal_separator']) ? give_clean($_POST['decimal_separator']) : ''; |
|
72 | 72 | |
73 | - if ( $decimal_separator === $thousand_separator ) { |
|
73 | + if ($decimal_separator === $thousand_separator) { |
|
74 | 74 | $value = ''; |
75 | 75 | $_POST['number_decimals'] = 0; |
76 | - Give_Admin_Settings::add_error( 'give-decimal-separator', __( 'The \'Decimal Separator\' option has automatically been set to empty because it can not be equal to the \'Thousand Separator\'', 'give' ) ); |
|
76 | + Give_Admin_Settings::add_error('give-decimal-separator', __('The \'Decimal Separator\' option has automatically been set to empty because it can not be equal to the \'Thousand Separator\'', 'give')); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | return $value; |
80 | 80 | } |
81 | 81 | |
82 | -add_filter( 'give_admin_settings_sanitize_option_decimal_separator', '__give_validate_decimal_separator_setting_field', 10 ); |
|
82 | +add_filter('give_admin_settings_sanitize_option_decimal_separator', '__give_validate_decimal_separator_setting_field', 10); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Change $delimiter text to symbol. |
@@ -90,16 +90,16 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return string $delimiter. |
92 | 92 | */ |
93 | -function __give_import_delimiter_set_callback( $delimiter ) { |
|
93 | +function __give_import_delimiter_set_callback($delimiter) { |
|
94 | 94 | $delimite_type = array( |
95 | 95 | 'csv' => ',', |
96 | 96 | 'tab-separated-values' => "\t", |
97 | 97 | ); |
98 | 98 | |
99 | - return ( array_key_exists( $delimiter, $delimite_type ) ? $delimite_type[ $delimiter ] : ',' ); |
|
99 | + return (array_key_exists($delimiter, $delimite_type) ? $delimite_type[$delimiter] : ','); |
|
100 | 100 | } |
101 | 101 | |
102 | -add_filter( 'give_import_delimiter_set', '__give_import_delimiter_set_callback', 10 ); |
|
102 | +add_filter('give_import_delimiter_set', '__give_import_delimiter_set_callback', 10); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Give unset the page id from the core setting data from the json files. |
@@ -111,17 +111,17 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return array $json_to_array |
113 | 113 | */ |
114 | -function give_import_core_settings_merge_pages( $json_to_array, $type ) { |
|
115 | - if ( 'merge' === $type ) { |
|
116 | - unset( $json_to_array['success_page'] ); |
|
117 | - unset( $json_to_array['failure_page'] ); |
|
118 | - unset( $json_to_array['history_page'] ); |
|
114 | +function give_import_core_settings_merge_pages($json_to_array, $type) { |
|
115 | + if ('merge' === $type) { |
|
116 | + unset($json_to_array['success_page']); |
|
117 | + unset($json_to_array['failure_page']); |
|
118 | + unset($json_to_array['history_page']); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | return $json_to_array; |
122 | 122 | } |
123 | 123 | |
124 | -add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_pages', 11, 2 ); |
|
124 | +add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_pages', 11, 2); |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Give check the image size from the core setting data from the json files. |
@@ -133,18 +133,18 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return array $json_to_array |
135 | 135 | */ |
136 | -function give_import_core_settings_merge_image_size( $json_to_array, $type ) { |
|
137 | - if ( 'merge' === $type ) { |
|
136 | +function give_import_core_settings_merge_image_size($json_to_array, $type) { |
|
137 | + if ('merge' === $type) { |
|
138 | 138 | // Featured image sizes import under Display Options > Post Types > Featured Image Size. |
139 | 139 | if ( |
140 | - ! empty( $json_to_array['form_featured_img'] ) |
|
141 | - && ! empty( $json_to_array['featured_image_size'] ) |
|
142 | - && give_is_setting_enabled( $json_to_array['form_featured_img'] ) |
|
140 | + ! empty($json_to_array['form_featured_img']) |
|
141 | + && ! empty($json_to_array['featured_image_size']) |
|
142 | + && give_is_setting_enabled($json_to_array['form_featured_img']) |
|
143 | 143 | ) { |
144 | 144 | $images_sizes = get_intermediate_image_sizes(); |
145 | 145 | |
146 | - if ( ! in_array( $json_to_array['featured_image_size'], $images_sizes, true ) ) { |
|
147 | - unset( $json_to_array['featured_image_size'] ); |
|
146 | + if ( ! in_array($json_to_array['featured_image_size'], $images_sizes, true)) { |
|
147 | + unset($json_to_array['featured_image_size']); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | return $json_to_array; |
153 | 153 | } |
154 | 154 | |
155 | -add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_image_size', 12, 2 ); |
|
155 | +add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_image_size', 12, 2); |
|
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Give upload the image logo from the core setting data from the json files. |
@@ -164,24 +164,24 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return array $json_to_array |
166 | 166 | */ |
167 | -function give_import_core_settings_merge_upload_image( $json_to_array, $type ) { |
|
168 | - if ( 'merge' === $type ) { |
|
167 | +function give_import_core_settings_merge_upload_image($json_to_array, $type) { |
|
168 | + if ('merge' === $type) { |
|
169 | 169 | // Emails > Email Settings > Logo. |
170 | - if ( ! empty( $json_to_array['email_logo'] ) ) { |
|
170 | + if ( ! empty($json_to_array['email_logo'])) { |
|
171 | 171 | |
172 | 172 | // Need to require these files. |
173 | - if ( ! function_exists( 'media_handle_upload' ) ) { |
|
174 | - require_once( ABSPATH . 'wp-admin/includes/image.php' ); |
|
175 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
176 | - require_once( ABSPATH . 'wp-admin/includes/media.php' ); |
|
173 | + if ( ! function_exists('media_handle_upload')) { |
|
174 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
175 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
176 | + require_once(ABSPATH.'wp-admin/includes/media.php'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | $url = $json_to_array['email_logo']; |
180 | - $new_url = media_sideload_image( $url, 0, null, 'src' ); |
|
181 | - if ( ! is_wp_error( $new_url ) ) { |
|
180 | + $new_url = media_sideload_image($url, 0, null, 'src'); |
|
181 | + if ( ! is_wp_error($new_url)) { |
|
182 | 182 | $json_to_array['email_logo'] = $new_url; |
183 | 183 | } else { |
184 | - unset( $json_to_array['email_logo'] ); |
|
184 | + unset($json_to_array['email_logo']); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | return $json_to_array; |
190 | 190 | } |
191 | 191 | |
192 | -add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_upload_image', 13, 2 ); |
|
192 | +add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_upload_image', 13, 2); |
|
193 | 193 | |
194 | 194 | /** |
195 | 195 | * Give unset the license key from the core setting data from the json files. |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return array $json_to_array |
203 | 203 | */ |
204 | -function give_import_core_settings_merge_license_key( $json_to_array, $type ) { |
|
205 | - if ( 'merge' === $type ) { |
|
206 | - foreach ( $json_to_array as $key => $value ) { |
|
207 | - $is_license_key = strpos( '_license_key', $key ); |
|
208 | - if ( ! empty( $is_license_key ) ) { |
|
209 | - unset( $json_to_array[ $key ] ); |
|
204 | +function give_import_core_settings_merge_license_key($json_to_array, $type) { |
|
205 | + if ('merge' === $type) { |
|
206 | + foreach ($json_to_array as $key => $value) { |
|
207 | + $is_license_key = strpos('_license_key', $key); |
|
208 | + if ( ! empty($is_license_key)) { |
|
209 | + unset($json_to_array[$key]); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | return $json_to_array; |
215 | 215 | } |
216 | 216 | |
217 | -add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_license_key', 14, 2 ); |
|
217 | +add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_license_key', 14, 2); |
|
218 | 218 | |
219 | 219 | /** |
220 | 220 | * Give merge the json data and setting data. |
@@ -227,16 +227,16 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @return array $json_to_array |
229 | 229 | */ |
230 | -function give_import_core_settings_merge_data( $json_to_array, $type, $host_give_options ) { |
|
231 | - if ( 'merge' === $type ) { |
|
232 | - $json_to_array_merge = array_merge( $host_give_options, $json_to_array ); |
|
230 | +function give_import_core_settings_merge_data($json_to_array, $type, $host_give_options) { |
|
231 | + if ('merge' === $type) { |
|
232 | + $json_to_array_merge = array_merge($host_give_options, $json_to_array); |
|
233 | 233 | $json_to_array = $json_to_array_merge; |
234 | 234 | } |
235 | 235 | |
236 | 236 | return $json_to_array; |
237 | 237 | } |
238 | 238 | |
239 | -add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_data', 1000, 3 ); |
|
239 | +add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_data', 1000, 3); |
|
240 | 240 | |
241 | 241 | /** |
242 | 242 | * Backward Compatibility - Cleanup User Roles. |
@@ -247,11 +247,11 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return mixed |
249 | 249 | */ |
250 | -function give_bc_1817_cleanup_user_roles( $caps ) { |
|
250 | +function give_bc_1817_cleanup_user_roles($caps) { |
|
251 | 251 | |
252 | 252 | if ( |
253 | - ! give_has_upgrade_completed( 'v1817_cleanup_user_roles' ) && |
|
254 | - ! isset( $caps['view_give_payments'] ) |
|
253 | + ! give_has_upgrade_completed('v1817_cleanup_user_roles') && |
|
254 | + ! isset($caps['view_give_payments']) |
|
255 | 255 | ) { |
256 | 256 | give_v1817_process_cleanup_user_roles(); |
257 | 257 | } |
@@ -259,4 +259,4 @@ discard block |
||
259 | 259 | return $caps; |
260 | 260 | } |
261 | 261 | |
262 | -add_filter( 'user_has_cap', 'give_bc_1817_cleanup_user_roles' ); |
|
262 | +add_filter('user_has_cap', 'give_bc_1817_cleanup_user_roles'); |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // Exit if accessed directly. |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if ( ! defined('ABSPATH')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | 14 | // Add give command. |
15 | -WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' ); |
|
15 | +WP_CLI::add_command('give', 'GIVE_CLI_COMMAND'); |
|
16 | 16 | |
17 | 17 | |
18 | 18 | /** |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @subcommand logo |
78 | 78 | */ |
79 | - public function ascii( $args, $assoc_args ) { |
|
80 | - WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/dist/images/give-ascii-logo.txt' ) ); |
|
79 | + public function ascii($args, $assoc_args) { |
|
80 | + WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/dist/images/give-ascii-logo.txt')); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -102,54 +102,54 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @subcommand details |
104 | 104 | */ |
105 | - public function details( $args, $assoc_args ) { |
|
105 | + public function details($args, $assoc_args) { |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Plugin Information |
109 | 109 | */ |
110 | - WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION ); |
|
110 | + WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION); |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * General Information. |
114 | 114 | */ |
115 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'General information', 'give' ) ) . ' ####' ); |
|
115 | + WP_CLI::log("\n#### ".$this->color_message(__('General information', 'give')).' ####'); |
|
116 | 116 | |
117 | - $success_page = give_get_option( 'success_page' ); |
|
118 | - $failure_page = give_get_option( 'failure_page' ); |
|
119 | - $history_page = give_get_option( 'history_page' ); |
|
117 | + $success_page = give_get_option('success_page'); |
|
118 | + $failure_page = give_get_option('failure_page'); |
|
119 | + $history_page = give_get_option('history_page'); |
|
120 | 120 | |
121 | - WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) ); |
|
122 | - WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) ); |
|
123 | - WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) ); |
|
124 | - WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() ); |
|
121 | + WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give'))); |
|
122 | + WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give'))); |
|
123 | + WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give'))); |
|
124 | + WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country()); |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Currency Information. |
128 | 128 | */ |
129 | - $default_gateway = give_get_option( 'default_gateway' ); |
|
129 | + $default_gateway = give_get_option('default_gateway'); |
|
130 | 130 | |
131 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'Currency Information', 'give' ) ) . ' ####' ); |
|
131 | + WP_CLI::log("\n#### ".$this->color_message(__('Currency Information', 'give')).' ####'); |
|
132 | 132 | |
133 | - WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) ); |
|
134 | - WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) ); |
|
135 | - WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) ); |
|
136 | - WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) ); |
|
137 | - WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) ); |
|
138 | - WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) ); |
|
139 | - WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) ); |
|
133 | + WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency())); |
|
134 | + WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position())); |
|
135 | + WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator())); |
|
136 | + WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator())); |
|
137 | + WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals())); |
|
138 | + WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give')))); |
|
139 | + WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give')))); |
|
140 | 140 | |
141 | 141 | // Payment gateways Information. |
142 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
143 | - WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) ); |
|
142 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
143 | + WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give'))); |
|
144 | 144 | |
145 | - if ( ! empty( $gateways ) ) { |
|
145 | + if ( ! empty($gateways)) { |
|
146 | 146 | self::$counter = 1; |
147 | - foreach ( $gateways as $gateway ) { |
|
148 | - WP_CLI::log( ' ' . $this->color_message( self::$counter, $gateway['admin_label'] ) ); |
|
149 | - self::$counter ++; |
|
147 | + foreach ($gateways as $gateway) { |
|
148 | + WP_CLI::log(' '.$this->color_message(self::$counter, $gateway['admin_label'])); |
|
149 | + self::$counter++; |
|
150 | 150 | } |
151 | 151 | } else { |
152 | - WP_CLI::log( __( 'Not any payment gateways found', 'give' ) ); |
|
152 | + WP_CLI::log(__('Not any payment gateways found', 'give')); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @subcommand forms |
183 | 183 | */ |
184 | - public function forms( $args, $assoc_args ) { |
|
184 | + public function forms($args, $assoc_args) { |
|
185 | 185 | global $wp_query; |
186 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
187 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10; |
|
186 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
187 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10; |
|
188 | 188 | $start = time(); |
189 | 189 | |
190 | 190 | // Cache previous number query var. |
191 | 191 | $is_set_number = $cache_per_page = false; |
192 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
192 | + if (isset($wp_query->query_vars['number'])) { |
|
193 | 193 | $cache_per_page = $wp_query->query_vars['number']; |
194 | 194 | $is_set_number = true; |
195 | 195 | } |
@@ -198,22 +198,22 @@ discard block |
||
198 | 198 | $wp_query->query_vars['number'] = $number; |
199 | 199 | |
200 | 200 | // Get forms. |
201 | - $forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms(); |
|
201 | + $forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms(); |
|
202 | 202 | |
203 | 203 | // Reset number query var. |
204 | - if ( $is_set_number ) { |
|
204 | + if ($is_set_number) { |
|
205 | 205 | $wp_query->query_vars['number'] = $cache_per_page; |
206 | 206 | } |
207 | 207 | |
208 | 208 | // Bailout. |
209 | - if ( array_key_exists( 'error', $forms ) ) { |
|
209 | + if (array_key_exists('error', $forms)) { |
|
210 | 210 | |
211 | - WP_CLI::warning( $forms['error'] ); |
|
211 | + WP_CLI::warning($forms['error']); |
|
212 | 212 | |
213 | 213 | return; |
214 | - } elseif ( empty( $forms['forms'] ) ) { |
|
214 | + } elseif (empty($forms['forms'])) { |
|
215 | 215 | |
216 | - WP_CLI::error( __( 'No forms found.', 'give' ) ); |
|
216 | + WP_CLI::error(__('No forms found.', 'give')); |
|
217 | 217 | |
218 | 218 | return; |
219 | 219 | } |
@@ -221,25 +221,25 @@ discard block |
||
221 | 221 | // Param to check if form typeis already showed or not. |
222 | 222 | $is_show_form_type = false; |
223 | 223 | |
224 | - if ( 1 === count( $forms ) && $form_id ) { |
|
224 | + if (1 === count($forms) && $form_id) { |
|
225 | 225 | // Show single form. |
226 | - foreach ( $forms['forms'][0] as $key => $info ) { |
|
227 | - switch ( $key ) { |
|
226 | + foreach ($forms['forms'][0] as $key => $info) { |
|
227 | + switch ($key) { |
|
228 | 228 | case 'stats': |
229 | - $this->color_main_heading( ucfirst( $key ) ); |
|
229 | + $this->color_main_heading(ucfirst($key)); |
|
230 | 230 | |
231 | - foreach ( $info as $heading => $data ) { |
|
232 | - $this->color_sub_heading( ucfirst( $heading ) ); |
|
233 | - switch ( $heading ) { |
|
231 | + foreach ($info as $heading => $data) { |
|
232 | + $this->color_sub_heading(ucfirst($heading)); |
|
233 | + switch ($heading) { |
|
234 | 234 | default: |
235 | - foreach ( $data as $subheading => $subdata ) { |
|
235 | + foreach ($data as $subheading => $subdata) { |
|
236 | 236 | |
237 | - switch ( $subheading ) { |
|
237 | + switch ($subheading) { |
|
238 | 238 | case 'earnings': |
239 | - WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) ); |
|
239 | + WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata))); |
|
240 | 240 | break; |
241 | 241 | default: |
242 | - WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) ); |
|
242 | + WP_CLI::log($this->color_message($subheading.': ', $subdata)); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | } |
@@ -249,26 +249,26 @@ discard block |
||
249 | 249 | case 'pricing': |
250 | 250 | case 'info': |
251 | 251 | default: |
252 | - $this->color_main_heading( ucfirst( $key ) ); |
|
252 | + $this->color_main_heading(ucfirst($key)); |
|
253 | 253 | |
254 | 254 | // Show form type. |
255 | - if ( ! $is_show_form_type ) { |
|
256 | - $form = new Give_Donate_Form( $form_id ); |
|
255 | + if ( ! $is_show_form_type) { |
|
256 | + $form = new Give_Donate_Form($form_id); |
|
257 | 257 | $is_show_form_type = true; |
258 | 258 | |
259 | - WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) ); |
|
259 | + WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type())); |
|
260 | 260 | } |
261 | 261 | |
262 | - foreach ( $info as $heading => $data ) { |
|
262 | + foreach ($info as $heading => $data) { |
|
263 | 263 | |
264 | - switch ( $heading ) { |
|
264 | + switch ($heading) { |
|
265 | 265 | case 'id': |
266 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
266 | + WP_CLI::log($this->color_message($heading, $data)); |
|
267 | 267 | break; |
268 | 268 | |
269 | 269 | default: |
270 | - $data = empty( $data ) ? __( 'Not set', 'give' ) : $data; |
|
271 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
270 | + $data = empty($data) ? __('Not set', 'give') : $data; |
|
271 | + WP_CLI::log($this->color_message($heading, $data)); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | }// End switch(). |
@@ -279,37 +279,37 @@ discard block |
||
279 | 279 | $is_table_first_row_set = false; |
280 | 280 | $table_column_count = 0; |
281 | 281 | |
282 | - WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) ); |
|
282 | + WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false)); |
|
283 | 283 | |
284 | - foreach ( $forms['forms'] as $index => $form_data ) { |
|
284 | + foreach ($forms['forms'] as $index => $form_data) { |
|
285 | 285 | |
286 | 286 | // Default table data. |
287 | 287 | $table_first_row = array(); |
288 | 288 | $table_row = array(); |
289 | 289 | |
290 | - foreach ( $form_data['info'] as $key => $form ) { |
|
290 | + foreach ($form_data['info'] as $key => $form) { |
|
291 | 291 | |
292 | 292 | // Do not show thumbnail, content and link in table. |
293 | - if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) { |
|
293 | + if (in_array($key, array('content', 'thumbnail', 'link'), true)) { |
|
294 | 294 | continue; |
295 | 295 | } |
296 | 296 | |
297 | - if ( ! $is_table_first_row_set ) { |
|
297 | + if ( ! $is_table_first_row_set) { |
|
298 | 298 | $table_first_row[] = $key; |
299 | 299 | } |
300 | 300 | |
301 | 301 | $table_row[] = $form; |
302 | 302 | |
303 | - if ( 'status' === $key ) { |
|
303 | + if ('status' === $key) { |
|
304 | 304 | // First array item will be an form id in our case. |
305 | - $form = new Give_Donate_Form( absint( $table_row[0] ) ); |
|
305 | + $form = new Give_Donate_Form(absint($table_row[0])); |
|
306 | 306 | |
307 | 307 | $table_row[] = $form->get_type(); |
308 | 308 | } |
309 | 309 | } |
310 | 310 | |
311 | 311 | // Set table first row. |
312 | - if ( ! $is_table_first_row_set ) { |
|
312 | + if ( ! $is_table_first_row_set) { |
|
313 | 313 | |
314 | 314 | // Add extra column to table. |
315 | 315 | $table_first_row[] = 'type'; |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $table_data[] = $table_row; |
323 | 323 | }// End foreach(). |
324 | 324 | |
325 | - $this->display_table( $table_data ); |
|
325 | + $this->display_table($table_data); |
|
326 | 326 | }// End if(). |
327 | 327 | } |
328 | 328 | |
@@ -375,59 +375,59 @@ discard block |
||
375 | 375 | * |
376 | 376 | * @subcommand donors |
377 | 377 | */ |
378 | - public function donors( $args, $assoc_args ) { |
|
378 | + public function donors($args, $assoc_args) { |
|
379 | 379 | global $wp_query; |
380 | - $donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
381 | - $email = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false; |
|
382 | - $name = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : ''; |
|
383 | - $create = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false; |
|
384 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
385 | - $form_id = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0; |
|
386 | - $format = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table'; |
|
380 | + $donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
381 | + $email = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false; |
|
382 | + $name = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : ''; |
|
383 | + $create = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false; |
|
384 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
385 | + $form_id = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0; |
|
386 | + $format = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table'; |
|
387 | 387 | $start = time(); |
388 | 388 | |
389 | - if ( $create ) { |
|
390 | - if ( 80 < $create ) { |
|
391 | - WP_CLI::warning( 'Currently we can only generate maximum 80 donors.', 'give' ); |
|
389 | + if ($create) { |
|
390 | + if (80 < $create) { |
|
391 | + WP_CLI::warning('Currently we can only generate maximum 80 donors.', 'give'); |
|
392 | 392 | $create = 80; |
393 | 393 | } |
394 | 394 | |
395 | 395 | $number = 1; |
396 | 396 | |
397 | - if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) { |
|
398 | - WP_CLI::warning( 'Wrong email address provided.', 'give' ); |
|
397 | + if (isset($assoc_args['email']) && ! is_email($email)) { |
|
398 | + WP_CLI::warning('Wrong email address provided.', 'give'); |
|
399 | 399 | |
400 | 400 | return; |
401 | 401 | } |
402 | 402 | |
403 | 403 | // Create one or more donors. |
404 | - if ( ! $email ) { |
|
404 | + if ( ! $email) { |
|
405 | 405 | // If no email is specified, look to see if we are generating arbitrary donor accounts. |
406 | - $number = is_numeric( $create ) ? absint( $create ) : 1; |
|
406 | + $number = is_numeric($create) ? absint($create) : 1; |
|
407 | 407 | } |
408 | 408 | |
409 | - for ( $i = 0; $i < $number; $i ++ ) { |
|
409 | + for ($i = 0; $i < $number; $i++) { |
|
410 | 410 | $name = $name ? $name : $this->get_random_name(); |
411 | - $email = $email ? $email : $this->get_random_email( $name ); |
|
411 | + $email = $email ? $email : $this->get_random_email($name); |
|
412 | 412 | |
413 | 413 | $args = array( |
414 | 414 | 'email' => $email, |
415 | 415 | 'name' => $name, |
416 | 416 | ); |
417 | 417 | |
418 | - $donor_id = Give()->donors->add( $args ); |
|
418 | + $donor_id = Give()->donors->add($args); |
|
419 | 419 | |
420 | - if ( $donor_id ) { |
|
421 | - WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $donor_id ) ) ); |
|
420 | + if ($donor_id) { |
|
421 | + WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $donor_id))); |
|
422 | 422 | } else { |
423 | - WP_CLI::error( __( 'Failed to create donor', 'give' ) ); |
|
423 | + WP_CLI::error(__('Failed to create donor', 'give')); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | // Reset email and name to false so it is generated on the next loop (if creating donors). |
427 | 427 | $email = $name = false; |
428 | 428 | } |
429 | 429 | |
430 | - WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) ); |
|
430 | + WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start))); |
|
431 | 431 | |
432 | 432 | } else { |
433 | 433 | // Counter. |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | */ |
442 | 442 | // Cache previous number query var. |
443 | 443 | $is_set_number = $cache_per_page = false; |
444 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
444 | + if (isset($wp_query->query_vars['number'])) { |
|
445 | 445 | $cache_per_page = $wp_query->query_vars['number']; |
446 | 446 | $is_set_number = true; |
447 | 447 | } |
@@ -450,24 +450,24 @@ discard block |
||
450 | 450 | $wp_query->query_vars['number'] = $number; |
451 | 451 | |
452 | 452 | // Get donors. |
453 | - if ( $form_id ) { |
|
453 | + if ($form_id) { |
|
454 | 454 | // @TODO: Allow user to get a list of donors by donation status. |
455 | - $donors = $this->get_donors_by_form_id( $form_id ); |
|
455 | + $donors = $this->get_donors_by_form_id($form_id); |
|
456 | 456 | } else { |
457 | - $donors = $this->api->get_donors( $search ); |
|
457 | + $donors = $this->api->get_donors($search); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | // Reset number query var. |
461 | - if ( $is_set_number ) { |
|
461 | + if ($is_set_number) { |
|
462 | 462 | $wp_query->query_vars['number'] = $cache_per_page; |
463 | 463 | } |
464 | 464 | |
465 | - if ( isset( $donors['error'] ) ) { |
|
466 | - WP_CLI::error( $donors['error'] ); |
|
465 | + if (isset($donors['error'])) { |
|
466 | + WP_CLI::error($donors['error']); |
|
467 | 467 | } |
468 | 468 | |
469 | - if ( empty( $donors ) ) { |
|
470 | - WP_CLI::error( __( 'No donors found.', 'give' ) ); |
|
469 | + if (empty($donors)) { |
|
470 | + WP_CLI::error(__('No donors found.', 'give')); |
|
471 | 471 | |
472 | 472 | return; |
473 | 473 | } |
@@ -475,24 +475,24 @@ discard block |
||
475 | 475 | $table_data = array(); |
476 | 476 | $is_table_first_row_set = false; |
477 | 477 | |
478 | - foreach ( $donors['donors'] as $donor_data ) { |
|
478 | + foreach ($donors['donors'] as $donor_data) { |
|
479 | 479 | // Set default table row data. |
480 | - $table_first_row = array( __( 's_no', 'give' ) ); |
|
481 | - $table_row = array( self::$counter ); |
|
480 | + $table_first_row = array(__('s_no', 'give')); |
|
481 | + $table_row = array(self::$counter); |
|
482 | 482 | |
483 | - foreach ( $donor_data as $key => $donor ) { |
|
484 | - switch ( $key ) { |
|
483 | + foreach ($donor_data as $key => $donor) { |
|
484 | + switch ($key) { |
|
485 | 485 | case 'stats': |
486 | - foreach ( $donor as $heading => $data ) { |
|
486 | + foreach ($donor as $heading => $data) { |
|
487 | 487 | |
488 | 488 | // Get first row. |
489 | - if ( ! $is_table_first_row_set ) { |
|
489 | + if ( ! $is_table_first_row_set) { |
|
490 | 490 | $table_first_row[] = $heading; |
491 | 491 | } |
492 | 492 | |
493 | - switch ( $heading ) { |
|
493 | + switch ($heading) { |
|
494 | 494 | case 'total_spent': |
495 | - $table_row[] = give_currency_filter( $data ); |
|
495 | + $table_row[] = give_currency_filter($data); |
|
496 | 496 | break; |
497 | 497 | |
498 | 498 | default: |
@@ -503,10 +503,10 @@ discard block |
||
503 | 503 | |
504 | 504 | case 'info': |
505 | 505 | default: |
506 | - foreach ( $donor as $heading => $data ) { |
|
506 | + foreach ($donor as $heading => $data) { |
|
507 | 507 | |
508 | 508 | // Get first row. |
509 | - if ( ! $is_table_first_row_set ) { |
|
509 | + if ( ! $is_table_first_row_set) { |
|
510 | 510 | $table_first_row[] = $heading; |
511 | 511 | } |
512 | 512 | |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | } |
517 | 517 | |
518 | 518 | // Add first row data to table data. |
519 | - if ( ! $is_table_first_row_set ) { |
|
519 | + if ( ! $is_table_first_row_set) { |
|
520 | 520 | $table_data[] = $table_first_row; |
521 | 521 | $is_table_first_row_set = true; |
522 | 522 | } |
@@ -525,44 +525,44 @@ discard block |
||
525 | 525 | $table_data[] = $table_row; |
526 | 526 | |
527 | 527 | // Increase counter. |
528 | - self::$counter ++; |
|
528 | + self::$counter++; |
|
529 | 529 | }// End foreach(). |
530 | 530 | |
531 | - switch ( $format ) { |
|
531 | + switch ($format) { |
|
532 | 532 | case 'json': |
533 | 533 | $table_column_name = $table_data[0]; |
534 | - unset( $table_data[0] ); |
|
534 | + unset($table_data[0]); |
|
535 | 535 | |
536 | 536 | $new_table_data = array(); |
537 | - foreach ( $table_data as $index => $data ) { |
|
538 | - foreach ( $data as $key => $value ) { |
|
539 | - $new_table_data[ $index ][ $table_column_name[ $key ] ] = $value; |
|
537 | + foreach ($table_data as $index => $data) { |
|
538 | + foreach ($data as $key => $value) { |
|
539 | + $new_table_data[$index][$table_column_name[$key]] = $value; |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | |
543 | - WP_CLI::log( json_encode( $new_table_data ) ); |
|
543 | + WP_CLI::log(json_encode($new_table_data)); |
|
544 | 544 | break; |
545 | 545 | |
546 | 546 | case 'csv': |
547 | - $file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv'; |
|
548 | - $fp = fopen( $file_path, 'w' ); |
|
547 | + $file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv'; |
|
548 | + $fp = fopen($file_path, 'w'); |
|
549 | 549 | |
550 | - if ( is_writable( $file_path ) ) { |
|
551 | - foreach ( $table_data as $fields ) { |
|
552 | - fputcsv( $fp, $fields ); |
|
550 | + if (is_writable($file_path)) { |
|
551 | + foreach ($table_data as $fields) { |
|
552 | + fputcsv($fp, $fields); |
|
553 | 553 | } |
554 | 554 | |
555 | - fclose( $fp ); |
|
555 | + fclose($fp); |
|
556 | 556 | |
557 | - WP_CLI::success( "Donors list csv created successfully: {$file_path}" ); |
|
557 | + WP_CLI::success("Donors list csv created successfully: {$file_path}"); |
|
558 | 558 | } else { |
559 | - WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" ); |
|
559 | + WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)"); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | break; |
563 | 563 | |
564 | 564 | default: |
565 | - $this->display_table( $table_data ); |
|
565 | + $this->display_table($table_data); |
|
566 | 566 | }// End switch(). |
567 | 567 | }// End if(). |
568 | 568 | } |
@@ -592,13 +592,13 @@ discard block |
||
592 | 592 | * |
593 | 593 | * @subcommand donations |
594 | 594 | */ |
595 | - public function donations( $args, $assoc_args ) { |
|
595 | + public function donations($args, $assoc_args) { |
|
596 | 596 | global $wp_query; |
597 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
597 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
598 | 598 | |
599 | 599 | // Cache previous number query var. |
600 | 600 | $is_set_number = $cache_per_page = false; |
601 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
601 | + if (isset($wp_query->query_vars['number'])) { |
|
602 | 602 | $cache_per_page = $wp_query->query_vars['number']; |
603 | 603 | $is_set_number = true; |
604 | 604 | } |
@@ -610,46 +610,46 @@ discard block |
||
610 | 610 | $donations = $this->api->get_recent_donations(); |
611 | 611 | |
612 | 612 | // Reset number query var. |
613 | - if ( $is_set_number ) { |
|
613 | + if ($is_set_number) { |
|
614 | 614 | $wp_query->query_vars['number'] = $cache_per_page; |
615 | 615 | } |
616 | 616 | |
617 | - if ( empty( $donations ) ) { |
|
618 | - WP_CLI::error( __( 'No donations found.', 'give' ) ); |
|
617 | + if (empty($donations)) { |
|
618 | + WP_CLI::error(__('No donations found.', 'give')); |
|
619 | 619 | |
620 | 620 | return; |
621 | 621 | } |
622 | 622 | |
623 | 623 | self::$counter = 1; |
624 | 624 | |
625 | - foreach ( $donations['donations'] as $key => $donation ) { |
|
626 | - $this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' ); |
|
627 | - self::$counter ++; |
|
625 | + foreach ($donations['donations'] as $key => $donation) { |
|
626 | + $this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y'); |
|
627 | + self::$counter++; |
|
628 | 628 | |
629 | - foreach ( $donation as $column => $data ) { |
|
629 | + foreach ($donation as $column => $data) { |
|
630 | 630 | |
631 | - if ( is_array( $data ) ) { |
|
632 | - $this->color_sub_heading( $column ); |
|
633 | - foreach ( $data as $subcolumn => $subdata ) { |
|
631 | + if (is_array($data)) { |
|
632 | + $this->color_sub_heading($column); |
|
633 | + foreach ($data as $subcolumn => $subdata) { |
|
634 | 634 | |
635 | 635 | // Decode html codes. |
636 | - switch ( $subcolumn ) { |
|
636 | + switch ($subcolumn) { |
|
637 | 637 | case 'name': |
638 | - $subdata = html_entity_decode( $subdata ); |
|
638 | + $subdata = html_entity_decode($subdata); |
|
639 | 639 | break; |
640 | 640 | } |
641 | 641 | |
642 | 642 | // @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta. |
643 | - if ( is_array( $subdata ) ) { |
|
643 | + if (is_array($subdata)) { |
|
644 | 644 | continue; |
645 | 645 | } |
646 | 646 | |
647 | - WP_CLI::log( $this->color_message( $subcolumn, $subdata ) ); |
|
647 | + WP_CLI::log($this->color_message($subcolumn, $subdata)); |
|
648 | 648 | } |
649 | 649 | continue; |
650 | 650 | } |
651 | 651 | |
652 | - WP_CLI::log( $this->color_message( $column, $data ) ); |
|
652 | + WP_CLI::log($this->color_message($column, $data)); |
|
653 | 653 | } |
654 | 654 | } |
655 | 655 | } |
@@ -689,27 +689,27 @@ discard block |
||
689 | 689 | * |
690 | 690 | * @return void |
691 | 691 | */ |
692 | - public function report( $args, $assoc_args ) { |
|
692 | + public function report($args, $assoc_args) { |
|
693 | 693 | $stats = new Give_Payment_Stats(); |
694 | - $date = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false; |
|
695 | - $start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false; |
|
696 | - $end_date = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false; |
|
697 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0; |
|
694 | + $date = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false; |
|
695 | + $start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false; |
|
696 | + $end_date = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false; |
|
697 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0; |
|
698 | 698 | |
699 | - if ( ! empty( $date ) ) { |
|
699 | + if ( ! empty($date)) { |
|
700 | 700 | $start_date = $date; |
701 | 701 | $end_date = false; |
702 | - } elseif ( empty( $date ) && empty( $start_date ) ) { |
|
702 | + } elseif (empty($date) && empty($start_date)) { |
|
703 | 703 | $start_date = 'this_month'; |
704 | 704 | $end_date = false; |
705 | 705 | } |
706 | 706 | |
707 | 707 | // Get stats. |
708 | - $earnings = $stats->get_earnings( $form_id, $start_date, $end_date ); |
|
709 | - $sales = $stats->get_sales( $form_id, $start_date, $end_date ); |
|
708 | + $earnings = $stats->get_earnings($form_id, $start_date, $end_date); |
|
709 | + $sales = $stats->get_sales($form_id, $start_date, $end_date); |
|
710 | 710 | |
711 | - WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings, array( 'decode_currency' => true ) ) ) ); |
|
712 | - WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) ); |
|
711 | + WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings, array('decode_currency' => true)))); |
|
712 | + WP_CLI::line($this->color_message(__('Sales', 'give'), $sales)); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | |
@@ -736,27 +736,27 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @subcommand cache |
738 | 738 | */ |
739 | - public function cache( $args, $assoc_args ) { |
|
740 | - $action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false; |
|
739 | + public function cache($args, $assoc_args) { |
|
740 | + $action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false; |
|
741 | 741 | |
742 | 742 | // Bailout. |
743 | - if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) { |
|
744 | - WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) ); |
|
743 | + if ( ! $action || ! in_array($action, array('delete'), true)) { |
|
744 | + WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give')); |
|
745 | 745 | |
746 | 746 | return; |
747 | 747 | } |
748 | 748 | |
749 | - switch ( $action ) { |
|
749 | + switch ($action) { |
|
750 | 750 | case 'delete': |
751 | 751 | // Reset counter. |
752 | 752 | self::$counter = 1; |
753 | 753 | |
754 | - if ( $this->delete_stats_transients() ) { |
|
754 | + if ($this->delete_stats_transients()) { |
|
755 | 755 | // Report .eading. |
756 | - WP_CLI::success( 'Give cache deleted.' ); |
|
756 | + WP_CLI::success('Give cache deleted.'); |
|
757 | 757 | } else { |
758 | 758 | // Report .eading. |
759 | - WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' ); |
|
759 | + WP_CLI::warning('We did not find any Give plugin cache to delete :)'); |
|
760 | 760 | } |
761 | 761 | break; |
762 | 762 | } |
@@ -785,27 +785,27 @@ discard block |
||
785 | 785 | ARRAY_A |
786 | 786 | ); |
787 | 787 | |
788 | - if ( ! empty( $stat_option_names ) ) { |
|
788 | + if ( ! empty($stat_option_names)) { |
|
789 | 789 | |
790 | - foreach ( $stat_option_names as $option_name ) { |
|
790 | + foreach ($stat_option_names as $option_name) { |
|
791 | 791 | $error = false; |
792 | 792 | $option_name = $option_name['option_name']; |
793 | 793 | |
794 | - switch ( true ) { |
|
795 | - case ( false !== strpos( $option_name, 'transient' ) ): |
|
796 | - $option_name = str_replace( '_transient_', '', $option_name ); |
|
797 | - $error = delete_transient( $option_name ); |
|
794 | + switch (true) { |
|
795 | + case (false !== strpos($option_name, 'transient')): |
|
796 | + $option_name = str_replace('_transient_', '', $option_name); |
|
797 | + $error = delete_transient($option_name); |
|
798 | 798 | break; |
799 | 799 | |
800 | 800 | default: |
801 | - $error = delete_option( $option_name ); |
|
801 | + $error = delete_option($option_name); |
|
802 | 802 | } |
803 | 803 | |
804 | - if ( $error ) { |
|
805 | - WP_CLI::log( $this->color_message( self::$counter, $option_name ) ); |
|
806 | - self::$counter ++; |
|
804 | + if ($error) { |
|
805 | + WP_CLI::log($this->color_message(self::$counter, $option_name)); |
|
806 | + self::$counter++; |
|
807 | 807 | } else { |
808 | - WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) ); |
|
808 | + WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name)); |
|
809 | 809 | } |
810 | 810 | } |
811 | 811 | |
@@ -826,13 +826,13 @@ discard block |
||
826 | 826 | * |
827 | 827 | * @return string |
828 | 828 | */ |
829 | - private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
|
829 | + private function color_message($heading, $message = '', $colon = true, $color = 'g') { |
|
830 | 830 | // Add colon. |
831 | - if ( $colon ) { |
|
832 | - $heading = $heading . ': '; |
|
831 | + if ($colon) { |
|
832 | + $heading = $heading.': '; |
|
833 | 833 | } |
834 | 834 | |
835 | - return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message; |
|
835 | + return WP_CLI::colorize("%{$color}".$heading.'%n').$message; |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | |
@@ -847,8 +847,8 @@ discard block |
||
847 | 847 | * |
848 | 848 | * @return void |
849 | 849 | */ |
850 | - private function color_main_heading( $heading, $color = 'g' ) { |
|
851 | - WP_CLI::log( "\n###### " . $this->color_message( $heading, '', false, $color ) . ' ######' ); |
|
850 | + private function color_main_heading($heading, $color = 'g') { |
|
851 | + WP_CLI::log("\n###### ".$this->color_message($heading, '', false, $color).' ######'); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | /** |
@@ -861,8 +861,8 @@ discard block |
||
861 | 861 | * |
862 | 862 | * @return void |
863 | 863 | */ |
864 | - private function color_sub_heading( $subheading ) { |
|
865 | - WP_CLI::log( "\n--->" . $subheading . '', '', false ); |
|
864 | + private function color_sub_heading($subheading) { |
|
865 | + WP_CLI::log("\n--->".$subheading.'', '', false); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | |
@@ -876,17 +876,17 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return void |
878 | 878 | */ |
879 | - private function display_table( $data ) { |
|
879 | + private function display_table($data) { |
|
880 | 880 | $table = new \cli\Table(); |
881 | 881 | |
882 | 882 | // Set table header. |
883 | - $table->setHeaders( $data[0] ); |
|
883 | + $table->setHeaders($data[0]); |
|
884 | 884 | |
885 | 885 | // Remove table header. |
886 | - unset( $data[0] ); |
|
886 | + unset($data[0]); |
|
887 | 887 | |
888 | 888 | // Set table data. |
889 | - $table->setRows( $data ); |
|
889 | + $table->setRows($data); |
|
890 | 890 | |
891 | 891 | // Display table. |
892 | 892 | $table->display(); |
@@ -903,14 +903,14 @@ discard block |
||
903 | 903 | * @return array |
904 | 904 | */ |
905 | 905 | |
906 | - private function get_donors_by_form_id( $form_id ) { |
|
906 | + private function get_donors_by_form_id($form_id) { |
|
907 | 907 | $donors = array(); |
908 | 908 | |
909 | 909 | $donations = new Give_Payments_Query( |
910 | 910 | array( |
911 | - 'give_forms' => array( $form_id ), |
|
912 | - 'number' => - 1, |
|
913 | - 'status' => array( 'publish' ), |
|
911 | + 'give_forms' => array($form_id), |
|
912 | + 'number' => -1, |
|
913 | + 'status' => array('publish'), |
|
914 | 914 | ) |
915 | 915 | ); |
916 | 916 | |
@@ -918,16 +918,16 @@ discard block |
||
918 | 918 | $skip_donors = array(); |
919 | 919 | |
920 | 920 | /* @var Give_Payment|object $donation Payment object. */ |
921 | - foreach ( $donations as $donation ) { |
|
921 | + foreach ($donations as $donation) { |
|
922 | 922 | |
923 | - if ( in_array( $donation->customer_id, $skip_donors, true ) ) { |
|
923 | + if (in_array($donation->customer_id, $skip_donors, true)) { |
|
924 | 924 | continue; |
925 | 925 | } |
926 | 926 | |
927 | - if ( ! empty( $donors ) ) { |
|
928 | - $donors['donors'][] = current( current( $this->api->get_donors( (int) $donation->customer_id ) ) ); |
|
927 | + if ( ! empty($donors)) { |
|
928 | + $donors['donors'][] = current(current($this->api->get_donors((int) $donation->customer_id))); |
|
929 | 929 | } else { |
930 | - $donors = array_merge( $donors, $this->api->get_donors( (int) $donation->customer_id ) ); |
|
930 | + $donors = array_merge($donors, $this->api->get_donors((int) $donation->customer_id)); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | $skip_donors[] = $donation->customer_id; |
@@ -972,15 +972,15 @@ discard block |
||
972 | 972 | ); |
973 | 973 | |
974 | 974 | // Generate a random forename. |
975 | - $random_name = $names[ mt_rand( 0, sizeof( $names ) - 1 ) ]; |
|
975 | + $random_name = $names[mt_rand(0, sizeof($names) - 1)]; |
|
976 | 976 | |
977 | 977 | // Generate a random surname. |
978 | - $random_surname = $surnames[ mt_rand( 0, sizeof( $surnames ) - 1 ) ]; |
|
978 | + $random_surname = $surnames[mt_rand(0, sizeof($surnames) - 1)]; |
|
979 | 979 | |
980 | 980 | // Generate name. |
981 | 981 | $name = "{$random_name} {$random_surname}"; |
982 | 982 | |
983 | - if ( in_array( $name, $this->new_donor_names ) ) { |
|
983 | + if (in_array($name, $this->new_donor_names)) { |
|
984 | 984 | $name = $this->get_random_name(); |
985 | 985 | } |
986 | 986 | |
@@ -999,8 +999,8 @@ discard block |
||
999 | 999 | * |
1000 | 1000 | * @return string |
1001 | 1001 | */ |
1002 | - private function get_random_email( $name ) { |
|
1003 | - return implode( '.', explode( ' ', strtolower( $name ) ) ) . '@test.com'; |
|
1002 | + private function get_random_email($name) { |
|
1003 | + return implode('.', explode(' ', strtolower($name))).'@test.com'; |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | /** |
@@ -1015,59 +1015,59 @@ discard block |
||
1015 | 1015 | * @when after_wp_load |
1016 | 1016 | * @subcommand test-mode |
1017 | 1017 | */ |
1018 | - public function test_mode( $args, $assoc ) { |
|
1018 | + public function test_mode($args, $assoc) { |
|
1019 | 1019 | |
1020 | 1020 | // Return if associative arguments are not specified. |
1021 | - if ( empty( $assoc ) ) { |
|
1022 | - WP_CLI::error( "--enable or --disable flag is missing." ); |
|
1021 | + if (empty($assoc)) { |
|
1022 | + WP_CLI::error("--enable or --disable flag is missing."); |
|
1023 | 1023 | return; |
1024 | 1024 | } |
1025 | 1025 | |
1026 | - $enabled_gateways = give_get_option( 'gateways' ); |
|
1027 | - $default_gateway = give_get_option( 'default_gateway' ); |
|
1026 | + $enabled_gateways = give_get_option('gateways'); |
|
1027 | + $default_gateway = give_get_option('default_gateway'); |
|
1028 | 1028 | |
1029 | 1029 | |
1030 | 1030 | // Enable Test Mode. |
1031 | - if ( true === WP_CLI\Utils\get_flag_value( $assoc, 'enable' ) ) { |
|
1031 | + if (true === WP_CLI\Utils\get_flag_value($assoc, 'enable')) { |
|
1032 | 1032 | |
1033 | 1033 | // Set `Test Mode` to `enabled`. |
1034 | - give_update_option( 'test_mode', 'enabled' ); |
|
1034 | + give_update_option('test_mode', 'enabled'); |
|
1035 | 1035 | |
1036 | 1036 | |
1037 | 1037 | // Enable `Test Donation` gateway. |
1038 | 1038 | $enabled_gateways['manual'] = "1"; |
1039 | - give_update_option( 'gateways', $enabled_gateways ); |
|
1039 | + give_update_option('gateways', $enabled_gateways); |
|
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | // Set `Test Donation` as default gateway. |
1043 | - add_option( 'give_test_mode_default_gateway', $default_gateway ); |
|
1044 | - give_update_option( 'default_gateway', 'manual' ); |
|
1043 | + add_option('give_test_mode_default_gateway', $default_gateway); |
|
1044 | + give_update_option('default_gateway', 'manual'); |
|
1045 | 1045 | |
1046 | 1046 | |
1047 | 1047 | // Show success message on completion. |
1048 | - WP_CLI::success( 'Give Test mode enabled' ); |
|
1048 | + WP_CLI::success('Give Test mode enabled'); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | // Disable Test Mode. |
1052 | - if ( true === WP_CLI\Utils\get_flag_value( $assoc, 'disable' ) ) { |
|
1052 | + if (true === WP_CLI\Utils\get_flag_value($assoc, 'disable')) { |
|
1053 | 1053 | |
1054 | 1054 | // Set `Test Mode` to `disabled`. |
1055 | - give_update_option( 'test_mode', 'disabled' ); |
|
1055 | + give_update_option('test_mode', 'disabled'); |
|
1056 | 1056 | |
1057 | 1057 | |
1058 | 1058 | // Disable `Test Donation` gateway. |
1059 | - unset( $enabled_gateways['manual'] ); |
|
1060 | - give_update_option( 'gateways', $enabled_gateways ); |
|
1059 | + unset($enabled_gateways['manual']); |
|
1060 | + give_update_option('gateways', $enabled_gateways); |
|
1061 | 1061 | |
1062 | 1062 | |
1063 | 1063 | // Backup `Default Gateway` setting for restore on test mode disable. |
1064 | - $default_gateway_backup = get_option( 'give_test_mode_default_gateway' ); |
|
1065 | - give_update_option( 'default_gateway', $default_gateway_backup ); |
|
1066 | - delete_option( 'give_test_mode_default_gateway' ); |
|
1064 | + $default_gateway_backup = get_option('give_test_mode_default_gateway'); |
|
1065 | + give_update_option('default_gateway', $default_gateway_backup); |
|
1066 | + delete_option('give_test_mode_default_gateway'); |
|
1067 | 1067 | |
1068 | 1068 | |
1069 | 1069 | // Show success message on completion. |
1070 | - WP_CLI::success( 'Give Test mode disabled' ); |
|
1070 | + WP_CLI::success('Give Test mode disabled'); |
|
1071 | 1071 | } |
1072 | 1072 | } |
1073 | 1073 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_get_actions() { |
27 | 27 | |
28 | - $_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null; |
|
28 | + $_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null; |
|
29 | 29 | |
30 | 30 | // Add backward compatibility to give-action param ( $_GET ) |
31 | - if ( empty( $_get_action ) ) { |
|
32 | - $_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null; |
|
31 | + if (empty($_get_action)) { |
|
32 | + $_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null; |
|
33 | 33 | } |
34 | 34 | |
35 | - if ( isset( $_get_action ) ) { |
|
35 | + if (isset($_get_action)) { |
|
36 | 36 | /** |
37 | 37 | * Fires in WordPress init or admin init, when give_action is present in $_GET. |
38 | 38 | * |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param array $_GET Array of HTTP GET variables. |
42 | 42 | */ |
43 | - do_action( "give_{$_get_action}", $_GET ); |
|
43 | + do_action("give_{$_get_action}", $_GET); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | } |
47 | 47 | |
48 | -add_action( 'init', 'give_get_actions' ); |
|
48 | +add_action('init', 'give_get_actions'); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Hooks Give actions, when present in the $_POST super global. Every give_action |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | */ |
59 | 59 | function give_post_actions() { |
60 | 60 | |
61 | - $_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null; |
|
61 | + $_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null; |
|
62 | 62 | |
63 | 63 | // Add backward compatibility to give-action param ( $_POST ). |
64 | - if ( empty( $_post_action ) ) { |
|
65 | - $_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null; |
|
64 | + if (empty($_post_action)) { |
|
65 | + $_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null; |
|
66 | 66 | } |
67 | 67 | |
68 | - if ( isset( $_post_action ) ) { |
|
68 | + if (isset($_post_action)) { |
|
69 | 69 | /** |
70 | 70 | * Fires in WordPress init or admin init, when give_action is present in $_POST. |
71 | 71 | * |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param array $_POST Array of HTTP POST variables. |
75 | 75 | */ |
76 | - do_action( "give_{$_post_action}", $_POST ); |
|
76 | + do_action("give_{$_post_action}", $_POST); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | -add_action( 'init', 'give_post_actions' ); |
|
81 | +add_action('init', 'give_post_actions'); |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * Connect WordPress user with Donor. |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return void |
92 | 92 | */ |
93 | -function give_connect_donor_to_wpuser( $user_id, $user_data ) { |
|
93 | +function give_connect_donor_to_wpuser($user_id, $user_data) { |
|
94 | 94 | /* @var Give_Donor $donor */ |
95 | - $donor = new Give_Donor( $user_data['user_email'] ); |
|
95 | + $donor = new Give_Donor($user_data['user_email']); |
|
96 | 96 | |
97 | 97 | // Validate donor id and check if do nor is already connect to wp user or not. |
98 | - if ( $donor->id && ! $donor->user_id ) { |
|
98 | + if ($donor->id && ! $donor->user_id) { |
|
99 | 99 | |
100 | 100 | // Update donor user_id. |
101 | - if ( $donor->update( array( 'user_id' => $user_id ) ) ) { |
|
102 | - $donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id ); |
|
103 | - $donor->add_note( $donor_note ); |
|
101 | + if ($donor->update(array('user_id' => $user_id))) { |
|
102 | + $donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id); |
|
103 | + $donor->add_note($donor_note); |
|
104 | 104 | |
105 | 105 | // Update user_id meta in payments. |
106 | 106 | // if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
116 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
117 | 117 | |
118 | 118 | |
119 | 119 | /** |
@@ -127,45 +127,45 @@ discard block |
||
127 | 127 | */ |
128 | 128 | function give_validate_license_when_site_migrated() { |
129 | 129 | // Store current site address if not already stored. |
130 | - $home_url_parts = parse_url( home_url() ); |
|
131 | - $home_url = isset( $home_url_parts['host'] ) ? $home_url_parts['host'] : false; |
|
132 | - $home_url .= isset( $home_url_parts['path'] ) ? $home_url_parts['path'] : ''; |
|
133 | - $site_address_before_migrate = get_option( 'give_site_address_before_migrate' ); |
|
130 | + $home_url_parts = parse_url(home_url()); |
|
131 | + $home_url = isset($home_url_parts['host']) ? $home_url_parts['host'] : false; |
|
132 | + $home_url .= isset($home_url_parts['path']) ? $home_url_parts['path'] : ''; |
|
133 | + $site_address_before_migrate = get_option('give_site_address_before_migrate'); |
|
134 | 134 | |
135 | 135 | // Need $home_url to proceed. |
136 | - if ( ! $home_url ) { |
|
136 | + if ( ! $home_url) { |
|
137 | 137 | return; |
138 | 138 | } |
139 | 139 | |
140 | 140 | // Save site address. |
141 | - if ( ! $site_address_before_migrate ) { |
|
141 | + if ( ! $site_address_before_migrate) { |
|
142 | 142 | // Update site address. |
143 | - update_option( 'give_site_address_before_migrate', $home_url ); |
|
143 | + update_option('give_site_address_before_migrate', $home_url); |
|
144 | 144 | |
145 | 145 | return; |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Backwards compat. for before when we were storing URL scheme. |
149 | - if ( strpos( $site_address_before_migrate, 'http' ) ) { |
|
150 | - $site_address_before_migrate = parse_url( $site_address_before_migrate ); |
|
151 | - $site_address_before_migrate = isset( $site_address_before_migrate['host'] ) ? $site_address_before_migrate['host'] : false; |
|
149 | + if (strpos($site_address_before_migrate, 'http')) { |
|
150 | + $site_address_before_migrate = parse_url($site_address_before_migrate); |
|
151 | + $site_address_before_migrate = isset($site_address_before_migrate['host']) ? $site_address_before_migrate['host'] : false; |
|
152 | 152 | |
153 | 153 | // Add path for multisite installs. |
154 | - $site_address_before_migrate .= isset( $site_address_before_migrate['path'] ) ? $site_address_before_migrate['path'] : ''; |
|
154 | + $site_address_before_migrate .= isset($site_address_before_migrate['path']) ? $site_address_before_migrate['path'] : ''; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | // If the two URLs don't match run CRON. |
158 | - if ( $home_url !== $site_address_before_migrate ) { |
|
158 | + if ($home_url !== $site_address_before_migrate) { |
|
159 | 159 | // Immediately run cron. |
160 | - wp_schedule_single_event( time(), 'give_validate_license_when_site_migrated' ); |
|
160 | + wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated'); |
|
161 | 161 | |
162 | 162 | // Update site address. |
163 | - update_option( 'give_site_address_before_migrate', $home_url ); |
|
163 | + update_option('give_site_address_before_migrate', $home_url); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | } |
167 | 167 | |
168 | -add_action( 'admin_init', 'give_validate_license_when_site_migrated' ); |
|
168 | +add_action('admin_init', 'give_validate_license_when_site_migrated'); |
|
169 | 169 | |
170 | 170 | |
171 | 171 | /** |
@@ -175,19 +175,19 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @param $data |
177 | 177 | */ |
178 | -function give_donor_batch_export_complete( $data ) { |
|
178 | +function give_donor_batch_export_complete($data) { |
|
179 | 179 | // Remove donor ids cache. |
180 | 180 | if ( |
181 | - isset( $data['class'] ) |
|
181 | + isset($data['class']) |
|
182 | 182 | && 'Give_Batch_Donors_Export' === $data['class'] |
183 | - && ! empty( $data['forms'] ) |
|
184 | - && isset( $data['give_export_option']['query_id'] ) |
|
183 | + && ! empty($data['forms']) |
|
184 | + && isset($data['give_export_option']['query_id']) |
|
185 | 185 | ) { |
186 | - Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) ); |
|
186 | + Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id'])); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | -add_action( 'give_file_export_complete', 'give_donor_batch_export_complete' ); |
|
190 | +add_action('give_file_export_complete', 'give_donor_batch_export_complete'); |
|
191 | 191 | |
192 | 192 | /** |
193 | 193 | * Print css for wordpress setting pages. |
@@ -198,12 +198,12 @@ discard block |
||
198 | 198 | /* @var WP_Screen $screen */ |
199 | 199 | $screen = get_current_screen(); |
200 | 200 | |
201 | - if ( ! ( $screen instanceof WP_Screen ) ) { |
|
201 | + if ( ! ($screen instanceof WP_Screen)) { |
|
202 | 202 | return false; |
203 | 203 | } |
204 | 204 | |
205 | - switch ( true ) { |
|
206 | - case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ): |
|
205 | + switch (true) { |
|
206 | + case ('plugins' === $screen->base || 'plugins-network' === $screen->base): |
|
207 | 207 | ?> |
208 | 208 | <style> |
209 | 209 | tr.active.update + tr.give-addon-notice-tr td { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
243 | -add_action( 'admin_head', 'give_admin_quick_css' ); |
|
243 | +add_action('admin_head', 'give_admin_quick_css'); |
|
244 | 244 | |
245 | 245 | |
246 | 246 | /** |
@@ -252,31 +252,31 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return void |
254 | 254 | */ |
255 | -function give_set_donation_levels_max_min_amount( $form_id ) { |
|
255 | +function give_set_donation_levels_max_min_amount($form_id) { |
|
256 | 256 | if ( |
257 | - ( 'set' === $_POST['_give_price_option'] ) || |
|
258 | - ( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) || |
|
259 | - ! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) ) |
|
257 | + ('set' === $_POST['_give_price_option']) || |
|
258 | + (in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) || |
|
259 | + ! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount')) |
|
260 | 260 | ) { |
261 | 261 | // Delete old meta. |
262 | - give_delete_meta( $form_id, '_give_levels_minimum_amount' ); |
|
263 | - give_delete_meta( $form_id, '_give_levels_maximum_amount' ); |
|
262 | + give_delete_meta($form_id, '_give_levels_minimum_amount'); |
|
263 | + give_delete_meta($form_id, '_give_levels_maximum_amount'); |
|
264 | 264 | |
265 | 265 | return; |
266 | 266 | } |
267 | 267 | |
268 | 268 | // Sanitize donation level amounts. |
269 | - $donation_levels_amounts = array_map( 'give_maybe_sanitize_amount', $donation_levels_amounts ); |
|
269 | + $donation_levels_amounts = array_map('give_maybe_sanitize_amount', $donation_levels_amounts); |
|
270 | 270 | |
271 | - $min_amount = min( $donation_levels_amounts ); |
|
272 | - $max_amount = max( $donation_levels_amounts ); |
|
271 | + $min_amount = min($donation_levels_amounts); |
|
272 | + $max_amount = max($donation_levels_amounts); |
|
273 | 273 | |
274 | 274 | // Set Minimum and Maximum amount for Multi Level Donation Forms. |
275 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 ); |
|
276 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db( $max_amount ) : 0 ); |
|
275 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0); |
|
276 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0); |
|
277 | 277 | } |
278 | 278 | |
279 | -add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 ); |
|
279 | +add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30); |
|
280 | 280 | |
281 | 281 | |
282 | 282 | /** |
@@ -286,23 +286,23 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @param int $payment_id |
288 | 288 | */ |
289 | -function _give_save_donor_billing_address( $payment_id ) { |
|
290 | - $donor_id = absint( give_get_payment_donor_id( $payment_id )); |
|
289 | +function _give_save_donor_billing_address($payment_id) { |
|
290 | + $donor_id = absint(give_get_payment_donor_id($payment_id)); |
|
291 | 291 | |
292 | 292 | // Bailout |
293 | - if ( ! $donor_id ) { |
|
293 | + if ( ! $donor_id) { |
|
294 | 294 | return; |
295 | 295 | } |
296 | 296 | |
297 | 297 | |
298 | 298 | /* @var Give_Donor $donor */ |
299 | - $donor = new Give_Donor( $donor_id ); |
|
299 | + $donor = new Give_Donor($donor_id); |
|
300 | 300 | |
301 | 301 | // Save address. |
302 | - $donor->add_address( 'billing[]', give_get_donation_address( $payment_id ) ); |
|
302 | + $donor->add_address('billing[]', give_get_donation_address($payment_id)); |
|
303 | 303 | } |
304 | 304 | |
305 | -add_action( 'give_complete_donation', '_give_save_donor_billing_address', 9999 ); |
|
305 | +add_action('give_complete_donation', '_give_save_donor_billing_address', 9999); |
|
306 | 306 | |
307 | 307 | |
308 | 308 | /** |
@@ -312,23 +312,23 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @param array $args |
314 | 314 | */ |
315 | -function give_update_log_form_id( $args ) { |
|
316 | - $new_form_id = absint( $args[0] ); |
|
317 | - $payment_id = absint( $args[1] ); |
|
318 | - $logs = Give()->logs->get_logs( $payment_id ); |
|
315 | +function give_update_log_form_id($args) { |
|
316 | + $new_form_id = absint($args[0]); |
|
317 | + $payment_id = absint($args[1]); |
|
318 | + $logs = Give()->logs->get_logs($payment_id); |
|
319 | 319 | |
320 | 320 | // Bailout. |
321 | - if ( empty( $logs ) ) { |
|
321 | + if (empty($logs)) { |
|
322 | 322 | return; |
323 | 323 | } |
324 | 324 | |
325 | 325 | /* @var object $log */ |
326 | - foreach ( $logs as $log ) { |
|
327 | - Give()->logs->logmeta_db->update_meta( $log->ID, '_give_log_form_id', $new_form_id ); |
|
326 | + foreach ($logs as $log) { |
|
327 | + Give()->logs->logmeta_db->update_meta($log->ID, '_give_log_form_id', $new_form_id); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | // Delete cache. |
331 | 331 | Give()->logs->delete_cache(); |
332 | 332 | } |
333 | 333 | |
334 | -add_action( 'give_update_log_form_id', 'give_update_log_form_id' ); |
|
335 | 334 | \ No newline at end of file |
335 | +add_action('give_update_log_form_id', 'give_update_log_form_id'); |
|
336 | 336 | \ No newline at end of file |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return static |
56 | 56 | */ |
57 | 57 | public static function get_instance() { |
58 | - if ( null === static::$instance ) { |
|
58 | + if (null === static::$instance) { |
|
59 | 59 | self::$instance = new static(); |
60 | 60 | } |
61 | 61 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @access public |
80 | 80 | */ |
81 | 81 | public function setup_hooks() { |
82 | - add_action( 'init', array( $this, 'load_translated_texts' ), 999 ); |
|
82 | + add_action('init', array($this, 'load_translated_texts'), 999); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return bool|WP_Error false on success otherwise WP_Error object |
112 | 112 | */ |
113 | - public static function add_text( $args = array() ) { |
|
113 | + public static function add_text($args = array()) { |
|
114 | 114 | $error = false; |
115 | 115 | |
116 | 116 | // Set text params. |
@@ -126,43 +126,43 @@ discard block |
||
126 | 126 | |
127 | 127 | try { |
128 | 128 | // Check for errors. |
129 | - if ( empty( $args['text'] ) ) { |
|
129 | + if (empty($args['text'])) { |
|
130 | 130 | /* @var WP_Error $error */ |
131 | - $error = new WP_Error( 'EMPTY_TEXT', __( 'Empty string is not allowed.', 'give' ), $args ); |
|
132 | - throw new Exception( $error->get_error_message( 'EMPTY_TEXT' ) ); |
|
131 | + $error = new WP_Error('EMPTY_TEXT', __('Empty string is not allowed.', 'give'), $args); |
|
132 | + throw new Exception($error->get_error_message('EMPTY_TEXT')); |
|
133 | 133 | |
134 | - } elseif ( empty( $args['id'] ) ) { |
|
134 | + } elseif (empty($args['id'])) { |
|
135 | 135 | /* @var WP_Error $error */ |
136 | - $error = new WP_Error( 'EMPTY_ID', __( 'Empty ID is not allowed.', 'give' ), $args ); |
|
137 | - throw new Exception( $error->get_error_message( 'EMPTY_ID' ) ); |
|
136 | + $error = new WP_Error('EMPTY_ID', __('Empty ID is not allowed.', 'give'), $args); |
|
137 | + throw new Exception($error->get_error_message('EMPTY_ID')); |
|
138 | 138 | |
139 | 139 | } elseif ( |
140 | - empty( $args['group'] ) && |
|
141 | - array_key_exists( $args['id'], self::$text_configs ) |
|
140 | + empty($args['group']) && |
|
141 | + array_key_exists($args['id'], self::$text_configs) |
|
142 | 142 | ) { |
143 | 143 | /* @var WP_Error $error */ |
144 | - $error = new WP_Error( 'TEXT_ID_ALREADY_EXIST', __( 'Text ID without a group already exists.', 'give' ), $args ); |
|
145 | - throw new Exception( $error->get_error_message( 'TEXT_ID_ALREADY_EXIST' ) ); |
|
144 | + $error = new WP_Error('TEXT_ID_ALREADY_EXIST', __('Text ID without a group already exists.', 'give'), $args); |
|
145 | + throw new Exception($error->get_error_message('TEXT_ID_ALREADY_EXIST')); |
|
146 | 146 | |
147 | 147 | } elseif ( |
148 | - ! empty( $args['group'] ) && |
|
149 | - ! empty( self::$text_configs[ $args['group'] ] ) && |
|
150 | - array_key_exists( $args['id'], self::$text_configs[ $args['group'] ] ) |
|
148 | + ! empty($args['group']) && |
|
149 | + ! empty(self::$text_configs[$args['group']]) && |
|
150 | + array_key_exists($args['id'], self::$text_configs[$args['group']]) |
|
151 | 151 | ) { |
152 | 152 | /* @var WP_Error $error */ |
153 | - $error = new WP_Error( 'TEXT_ID_WITHIN_GROUP_ALREADY_EXIST', __( 'Text ID within a group already exists.', 'give' ), $args ); |
|
154 | - throw new Exception( $error->get_error_message( 'TEXT_ID_WITHIN_GROUP_ALREADY_EXIST' ) ); |
|
153 | + $error = new WP_Error('TEXT_ID_WITHIN_GROUP_ALREADY_EXIST', __('Text ID within a group already exists.', 'give'), $args); |
|
154 | + throw new Exception($error->get_error_message('TEXT_ID_WITHIN_GROUP_ALREADY_EXIST')); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Add text. |
159 | - if ( ! empty( $args['group'] ) ) { |
|
160 | - self::$text_configs[ $args['group'] ][ $args['id'] ] = $args; |
|
159 | + if ( ! empty($args['group'])) { |
|
160 | + self::$text_configs[$args['group']][$args['id']] = $args; |
|
161 | 161 | } else { |
162 | - self::$text_configs[ $args['id'] ] = $args; |
|
162 | + self::$text_configs[$args['id']] = $args; |
|
163 | 163 | } |
164 | - } catch ( Exception $e ) { |
|
165 | - error_log( $e->getMessage() ); |
|
164 | + } catch (Exception $e) { |
|
165 | + error_log($e->getMessage()); |
|
166 | 166 | }// End try(). |
167 | 167 | |
168 | 168 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @since 2.0 |
172 | 172 | */ |
173 | - self::$text_configs = apply_filters( 'give_texts', self::$text_configs ); |
|
173 | + self::$text_configs = apply_filters('give_texts', self::$text_configs); |
|
174 | 174 | |
175 | 175 | return $error; |
176 | 176 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - public static function add_label( $args = array() ) { |
|
188 | + public static function add_label($args = array()) { |
|
189 | 189 | // Set text params. |
190 | 190 | $args = wp_parse_args( |
191 | 191 | $args, |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $args['type'] = 'label'; |
200 | 200 | $args['id'] = "{$args['id']}_label"; |
201 | 201 | |
202 | - return self::add_text( $args ); |
|
202 | + return self::add_text($args); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return string |
214 | 214 | */ |
215 | - public static function add_tooltip( $args = array() ) { |
|
215 | + public static function add_tooltip($args = array()) { |
|
216 | 216 | // Set text params. |
217 | 217 | $args = wp_parse_args( |
218 | 218 | $args, |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $args['type'] = 'tooltip'; |
227 | 227 | $args['id'] = "{$args['id']}_tooltip"; |
228 | 228 | |
229 | - return self::add_text( $args ); |
|
229 | + return self::add_text($args); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @return string |
241 | 241 | */ |
242 | - public static function add_translation( $args = array() ) { |
|
242 | + public static function add_translation($args = array()) { |
|
243 | 243 | $args = wp_parse_args( |
244 | 244 | $args, |
245 | 245 | array( |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | ); |
251 | 251 | |
252 | 252 | // Bailout. |
253 | - if ( empty( $args['id'] ) ) { |
|
253 | + if (empty($args['id'])) { |
|
254 | 254 | return; |
255 | 255 | } |
256 | 256 | |
257 | - if ( ! empty( $args['group'] ) ) { |
|
258 | - self::$text_translations[ $args['group'] ][ $args['id'] ] = $args['text']; |
|
257 | + if ( ! empty($args['group'])) { |
|
258 | + self::$text_translations[$args['group']][$args['id']] = $args['text']; |
|
259 | 259 | } else { |
260 | - self::$text_translations[ $args['id'] ] = $args['text']; |
|
260 | + self::$text_translations[$args['id']] = $args['text']; |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return string |
275 | 275 | */ |
276 | - public static function add_label_translation( $id, $group = '', $text = '' ) { |
|
277 | - return self::get_text( array( |
|
276 | + public static function add_label_translation($id, $group = '', $text = '') { |
|
277 | + return self::get_text(array( |
|
278 | 278 | 'id' => "{$id}_label", |
279 | 279 | 'group' => $group, |
280 | 280 | 'text' => $text, |
281 | - ) ); |
|
281 | + )); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return string |
295 | 295 | */ |
296 | - public static function add_tooltip_translation( $id, $group = '', $text = '' ) { |
|
297 | - return self::get_text( array( |
|
296 | + public static function add_tooltip_translation($id, $group = '', $text = '') { |
|
297 | + return self::get_text(array( |
|
298 | 298 | 'id' => "{$id}_label", |
299 | 299 | 'group' => $group, |
300 | 300 | 'text' => $text, |
301 | - ) ); |
|
301 | + )); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -312,12 +312,12 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return string |
314 | 314 | */ |
315 | - public static function get_label( $id, $group = '' ) { |
|
316 | - return self::get_text( array( |
|
315 | + public static function get_label($id, $group = '') { |
|
316 | + return self::get_text(array( |
|
317 | 317 | 'id' => "{$id}_label", |
318 | 318 | 'group' => $group, |
319 | 319 | 'type' => 'label', |
320 | - ) ); |
|
320 | + )); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return string |
333 | 333 | */ |
334 | - public static function get_tooltip( $id, $group = '' ) { |
|
335 | - return self::get_text( array( |
|
334 | + public static function get_tooltip($id, $group = '') { |
|
335 | + return self::get_text(array( |
|
336 | 336 | 'id' => "{$id}_tooltip", |
337 | 337 | 'group' => $group, |
338 | 338 | 'type' => 'tooltip', |
339 | - ) ); |
|
339 | + )); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @return string |
351 | 351 | */ |
352 | - public static function get_text( $args = array() ) { |
|
352 | + public static function get_text($args = array()) { |
|
353 | 353 | $text = ''; |
354 | 354 | |
355 | 355 | // Bailout. |
356 | - if ( empty( $args ) ) { |
|
356 | + if (empty($args)) { |
|
357 | 357 | return $text; |
358 | 358 | } |
359 | 359 | |
@@ -369,40 +369,40 @@ discard block |
||
369 | 369 | |
370 | 370 | // Check if text exist. |
371 | 371 | if ( |
372 | - empty( $args['id'] ) || |
|
373 | - ( empty( $args['group'] ) && ! array_key_exists( $args['id'], self::$text_configs ) ) || |
|
374 | - ( ! empty( $args['group'] ) && ! empty( self::$text_configs[ $args['group'] ] ) && ! array_key_exists( $args['id'], self::$text_configs[ $args['group'] ] ) ) |
|
372 | + empty($args['id']) || |
|
373 | + (empty($args['group']) && ! array_key_exists($args['id'], self::$text_configs)) || |
|
374 | + ( ! empty($args['group']) && ! empty(self::$text_configs[$args['group']]) && ! array_key_exists($args['id'], self::$text_configs[$args['group']])) |
|
375 | 375 | ) { |
376 | 376 | return $text; |
377 | 377 | } |
378 | 378 | |
379 | 379 | // Get text value. |
380 | 380 | if ( |
381 | - ! empty( $args['group'] ) && |
|
382 | - array_key_exists( $args['group'], self::$text_configs ) |
|
381 | + ! empty($args['group']) && |
|
382 | + array_key_exists($args['group'], self::$text_configs) |
|
383 | 383 | ) { |
384 | - $text = self::$text_configs[ $args['group'] ][ $args['id'] ]['text']; |
|
384 | + $text = self::$text_configs[$args['group']][$args['id']]['text']; |
|
385 | 385 | |
386 | 386 | // Get translated text if exist. |
387 | 387 | if ( |
388 | - ! empty( self::$text_translations ) && |
|
389 | - ! empty( self::$text_translations[ $args['group'] ] ) && |
|
390 | - array_key_exists( $args['id'], self::$text_translations[ $args['group'] ] ) |
|
388 | + ! empty(self::$text_translations) && |
|
389 | + ! empty(self::$text_translations[$args['group']]) && |
|
390 | + array_key_exists($args['id'], self::$text_translations[$args['group']]) |
|
391 | 391 | ) { |
392 | - $text = self::$text_translations[ $args['group'] ][ $args['id'] ]; |
|
392 | + $text = self::$text_translations[$args['group']][$args['id']]; |
|
393 | 393 | } |
394 | 394 | } elseif ( |
395 | - empty( $args['group'] ) && |
|
396 | - array_key_exists( $args['id'], self::$text_configs ) |
|
395 | + empty($args['group']) && |
|
396 | + array_key_exists($args['id'], self::$text_configs) |
|
397 | 397 | ) { |
398 | - $text = self::$text_configs[ $args['id'] ]['text']; |
|
398 | + $text = self::$text_configs[$args['id']]['text']; |
|
399 | 399 | |
400 | 400 | // Get translated text if exist. |
401 | 401 | if ( |
402 | - ! empty( self::$text_translations ) && |
|
403 | - array_key_exists( $args['id'], self::$text_translations ) |
|
402 | + ! empty(self::$text_translations) && |
|
403 | + array_key_exists($args['id'], self::$text_translations) |
|
404 | 404 | ) { |
405 | - $text = self::$text_translations[ $args['id'] ]; |
|
405 | + $text = self::$text_translations[$args['id']]; |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @since 2.0 |
413 | 413 | */ |
414 | - $text = apply_filters( 'give_text', $text, $args, self::$text_configs, self::$text_translations ); |
|
414 | + $text = apply_filters('give_text', $text, $args, self::$text_configs, self::$text_translations); |
|
415 | 415 | |
416 | 416 | return $text; |
417 | 417 | } |
@@ -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 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /* @var WPDB $wpdb */ |
36 | 36 | global $wpdb; |
37 | 37 | |
38 | - $this->table_name = $wpdb->prefix . 'give_sequential_ordering'; |
|
38 | + $this->table_name = $wpdb->prefix.'give_sequential_ordering'; |
|
39 | 39 | $this->primary_key = 'id'; |
40 | 40 | $this->version = '1.0'; |
41 | 41 | |
@@ -108,18 +108,18 @@ discard block |
||
108 | 108 | PRIMARY KEY (id) |
109 | 109 | ) {$charset_collate};"; |
110 | 110 | |
111 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
112 | - dbDelta( $sql ); |
|
111 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
112 | + dbDelta($sql); |
|
113 | 113 | |
114 | - if ( ! empty( $payment_ID ) ) { |
|
114 | + if ( ! empty($payment_ID)) { |
|
115 | 115 | $auto_increment = $payment_ID + 1; |
116 | - $wpdb->query( "ALTER TABLE {$this->table_name} AUTO_INCREMENT={$auto_increment};" ); |
|
117 | - give_update_option( 'sequential-ordering_number', $auto_increment ); |
|
116 | + $wpdb->query("ALTER TABLE {$this->table_name} AUTO_INCREMENT={$auto_increment};"); |
|
117 | + give_update_option('sequential-ordering_number', $auto_increment); |
|
118 | 118 | } else { |
119 | - give_update_option( 'sequential-ordering_number', 1 ); |
|
119 | + give_update_option('sequential-ordering_number', 1); |
|
120 | 120 | } |
121 | 121 | |
122 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
122 | + update_option($this->table_name.'_db_version', $this->version); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 |
@@ -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 | |
@@ -62,51 +62,51 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return bool If the gravatar exists or not |
64 | 64 | */ |
65 | - public function validate_gravatar( $id_or_email ) { |
|
65 | + public function validate_gravatar($id_or_email) { |
|
66 | 66 | //id or email code borrowed from wp-includes/pluggable.php |
67 | 67 | $email = ''; |
68 | - if ( is_numeric( $id_or_email ) ) { |
|
68 | + if (is_numeric($id_or_email)) { |
|
69 | 69 | $id = (int) $id_or_email; |
70 | - $user = get_userdata( $id ); |
|
71 | - if ( $user ) { |
|
70 | + $user = get_userdata($id); |
|
71 | + if ($user) { |
|
72 | 72 | $email = $user->user_email; |
73 | 73 | } |
74 | - } elseif ( is_object( $id_or_email ) ) { |
|
74 | + } elseif (is_object($id_or_email)) { |
|
75 | 75 | // No avatar for pingbacks or trackbacks |
76 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
77 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
76 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
77 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
81 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
81 | + if ( ! empty($id_or_email->user_id)) { |
|
82 | 82 | $id = (int) $id_or_email->user_id; |
83 | - $user = get_userdata( $id ); |
|
84 | - if ( $user ) { |
|
83 | + $user = get_userdata($id); |
|
84 | + if ($user) { |
|
85 | 85 | $email = $user->user_email; |
86 | 86 | } |
87 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
87 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
88 | 88 | $email = $id_or_email->comment_author_email; |
89 | 89 | } |
90 | 90 | } else { |
91 | 91 | $email = $id_or_email; |
92 | 92 | } |
93 | 93 | |
94 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
95 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
94 | + $hashkey = md5(strtolower(trim($email))); |
|
95 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
96 | 96 | |
97 | - $data = Give_Cache::get_group( $hashkey ); |
|
97 | + $data = Give_Cache::get_group($hashkey); |
|
98 | 98 | |
99 | - if ( is_null( $data ) ) { |
|
100 | - $response = wp_remote_head( $uri ); |
|
101 | - if ( is_wp_error( $response ) ) { |
|
99 | + if (is_null($data)) { |
|
100 | + $response = wp_remote_head($uri); |
|
101 | + if (is_wp_error($response)) { |
|
102 | 102 | $data = 'not200'; |
103 | 103 | } else { |
104 | 104 | $data = $response['response']['code']; |
105 | 105 | } |
106 | - Give_Cache::set_group( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
106 | + Give_Cache::set_group($hashkey, $data, $group = '', $expire = 60 * 5); |
|
107 | 107 | |
108 | 108 | } |
109 | - if ( $data == '200' ) { |
|
109 | + if ($data == '200') { |
|
110 | 110 | return true; |
111 | 111 | } else { |
112 | 112 | return false; |
@@ -123,15 +123,15 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array IDs if logs, false otherwise |
125 | 125 | */ |
126 | - public function get_log_ids( $form_id = '' ) { |
|
126 | + public function get_log_ids($form_id = '') { |
|
127 | 127 | // get log for this form |
128 | - $logs = Give()->logs->get_logs( $form_id ); |
|
128 | + $logs = Give()->logs->get_logs($form_id); |
|
129 | 129 | |
130 | - if ( $logs ) { |
|
130 | + if ($logs) { |
|
131 | 131 | $log_ids = array(); |
132 | 132 | |
133 | 133 | // make an array with all the donor IDs |
134 | - foreach ( $logs as $log ) { |
|
134 | + foreach ($logs as $log) { |
|
135 | 135 | $log_ids[] = $log->ID; |
136 | 136 | } |
137 | 137 | |
@@ -152,51 +152,51 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return mixed |
154 | 154 | */ |
155 | - public function get_payment_ids( $form_id = '' ) { |
|
155 | + public function get_payment_ids($form_id = '') { |
|
156 | 156 | |
157 | 157 | $give_options = give_get_settings(); |
158 | 158 | |
159 | - $log_ids = $this->get_log_ids( $form_id ); |
|
159 | + $log_ids = $this->get_log_ids($form_id); |
|
160 | 160 | |
161 | - if ( $log_ids ) { |
|
161 | + if ($log_ids) { |
|
162 | 162 | |
163 | 163 | $payment_ids = array(); |
164 | 164 | |
165 | - foreach ( $log_ids as $id ) { |
|
165 | + foreach ($log_ids as $id) { |
|
166 | 166 | // get the payment ID for each corresponding log ID |
167 | - $payment_ids[] = give_get_meta( $id, '_give_log_payment_id', true ); |
|
167 | + $payment_ids[] = give_get_meta($id, '_give_log_payment_id', true); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | // remove donors who have donated more than once so we can have unique avatars |
171 | 171 | $unique_emails = array(); |
172 | 172 | |
173 | - foreach ( $payment_ids as $key => $id ) { |
|
173 | + foreach ($payment_ids as $key => $id) { |
|
174 | 174 | |
175 | - $email = give_get_meta( $id, '_give_payment_donor_email', true ); |
|
175 | + $email = give_get_meta($id, '_give_payment_donor_email', true); |
|
176 | 176 | |
177 | - if ( isset ( $give_options['give_donors_gravatars_has_gravatar_account'] ) ) { |
|
178 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
177 | + if (isset ($give_options['give_donors_gravatars_has_gravatar_account'])) { |
|
178 | + if ( ! $this->validate_gravatar($email)) { |
|
179 | 179 | continue; |
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | - $unique_emails[ $id ] = give_get_meta( $id, '_give_payment_donor_email', true ); |
|
183 | + $unique_emails[$id] = give_get_meta($id, '_give_payment_donor_email', true); |
|
184 | 184 | |
185 | 185 | } |
186 | 186 | |
187 | 187 | $unique_ids = array(); |
188 | 188 | |
189 | 189 | // strip duplicate emails |
190 | - $unique_emails = array_unique( $unique_emails ); |
|
190 | + $unique_emails = array_unique($unique_emails); |
|
191 | 191 | |
192 | 192 | // convert the unique IDs back into simple array |
193 | - foreach ( $unique_emails as $id => $email ) { |
|
193 | + foreach ($unique_emails as $id => $email) { |
|
194 | 194 | $unique_ids[] = $id; |
195 | 195 | } |
196 | 196 | |
197 | 197 | // randomize the payment IDs if enabled |
198 | - if ( isset( $give_options['give_donors_gravatars_random_gravatars'] ) ) { |
|
199 | - shuffle( $unique_ids ); |
|
198 | + if (isset($give_options['give_donors_gravatars_random_gravatars'])) { |
|
199 | + shuffle($unique_ids); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | // return our unique IDs |
@@ -217,22 +217,22 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - public function gravatars( $form_id = false, $title = '' ) { |
|
220 | + public function gravatars($form_id = false, $title = '') { |
|
221 | 221 | |
222 | 222 | // unique $payment_ids |
223 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
223 | + $payment_ids = $this->get_payment_ids($form_id); |
|
224 | 224 | |
225 | 225 | $give_options = give_get_settings(); |
226 | 226 | |
227 | 227 | // return if no ID |
228 | - if ( ! $form_id ) { |
|
228 | + if ( ! $form_id) { |
|
229 | 229 | return; |
230 | 230 | } |
231 | 231 | |
232 | 232 | // minimum amount of donations before showing gravatars |
233 | 233 | // if the number of items in array is not greater or equal to the number specified, then exit |
234 | - if ( isset( $give_options['give_donors_gravatars_min_purchases_required'] ) && '' != $give_options['give_donors_gravatars_min_purchases_required'] ) { |
|
235 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donors_gravatars_min_purchases_required'] ) ) { |
|
234 | + if (isset($give_options['give_donors_gravatars_min_purchases_required']) && '' != $give_options['give_donors_gravatars_min_purchases_required']) { |
|
235 | + if ( ! (count($payment_ids) >= $give_options['give_donors_gravatars_min_purchases_required'])) { |
|
236 | 236 | return; |
237 | 237 | } |
238 | 238 | } |
@@ -243,28 +243,28 @@ discard block |
||
243 | 243 | echo '<div id="give-purchase-gravatars">'; |
244 | 244 | |
245 | 245 | |
246 | - if ( isset ( $title ) ) { |
|
246 | + if (isset ($title)) { |
|
247 | 247 | |
248 | - if ( $title ) { |
|
249 | - echo wp_kses_post( apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ) ); |
|
250 | - } elseif ( isset( $give_options['give_donors_gravatars_heading'] ) ) { |
|
251 | - echo wp_kses_post( apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donors_gravatars_heading'] ) . '</h2>' ) ); |
|
248 | + if ($title) { |
|
249 | + echo wp_kses_post(apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>')); |
|
250 | + } elseif (isset($give_options['give_donors_gravatars_heading'])) { |
|
251 | + echo wp_kses_post(apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donors_gravatars_heading']).'</h2>')); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | } |
255 | 255 | echo '<ul class="give-purchase-gravatars-list">'; |
256 | 256 | $i = 0; |
257 | 257 | |
258 | - if ( $payment_ids ) { |
|
259 | - foreach ( $payment_ids as $id ) { |
|
258 | + if ($payment_ids) { |
|
259 | + foreach ($payment_ids as $id) { |
|
260 | 260 | |
261 | 261 | // Give saves a blank option even when the control is turned off, hence the extra check |
262 | - if ( isset( $give_options['give_donors_gravatars_maximum_number'] ) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number'] ) { |
|
262 | + if (isset($give_options['give_donors_gravatars_maximum_number']) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number']) { |
|
263 | 263 | continue; |
264 | 264 | } |
265 | 265 | |
266 | 266 | // get the payment meta |
267 | - $payment_meta = give_get_meta( $id, '_give_payment_meta', true ); |
|
267 | + $payment_meta = give_get_meta($id, '_give_payment_meta', true); |
|
268 | 268 | |
269 | 269 | $user_info = $payment_meta['user_info']; |
270 | 270 | |
@@ -272,30 +272,30 @@ discard block |
||
272 | 272 | $name = $user_info['first_name']; |
273 | 273 | |
274 | 274 | // get donor's email |
275 | - $email = give_get_meta( $id, '_give_payment_donor_email', true ); |
|
275 | + $email = give_get_meta($id, '_give_payment_donor_email', true); |
|
276 | 276 | |
277 | 277 | // set gravatar size and provide filter |
278 | - $size = isset( $give_options['give_donors_gravatars_gravatar_size'] ) ? apply_filters( 'give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size'] ) : ''; |
|
278 | + $size = isset($give_options['give_donors_gravatars_gravatar_size']) ? apply_filters('give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size']) : ''; |
|
279 | 279 | |
280 | 280 | // default image |
281 | - $default_image = apply_filters( 'give_donors_gravatars_gravatar_default_image', false ); |
|
281 | + $default_image = apply_filters('give_donors_gravatars_gravatar_default_image', false); |
|
282 | 282 | |
283 | 283 | // assemble output |
284 | 284 | $output .= '<li>'; |
285 | 285 | |
286 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
286 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
287 | 287 | $output .= '</li>'; |
288 | 288 | |
289 | - $i ++; |
|
289 | + $i++; |
|
290 | 290 | |
291 | 291 | } // end foreach |
292 | 292 | } |
293 | 293 | |
294 | - echo wp_kses_post( $output ); |
|
294 | + echo wp_kses_post($output); |
|
295 | 295 | echo '</ul>'; |
296 | 296 | echo '</div>'; |
297 | 297 | |
298 | - return apply_filters( 'give_donors_gravatars', ob_get_clean() ); |
|
298 | + return apply_filters('give_donors_gravatars', ob_get_clean()); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @return void |
308 | 308 | */ |
309 | 309 | public function register_widget() { |
310 | - register_widget( 'Give_Donors_Gravatars_Widget' ); |
|
310 | + register_widget('Give_Donors_Gravatars_Widget'); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -321,19 +321,19 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @return string |
323 | 323 | */ |
324 | - public function shortcode( $atts, $content = null ) { |
|
324 | + public function shortcode($atts, $content = null) { |
|
325 | 325 | |
326 | - $atts = shortcode_atts( array( |
|
326 | + $atts = shortcode_atts(array( |
|
327 | 327 | 'id' => '', |
328 | 328 | 'title' => '' |
329 | - ), $atts, 'give_donors_gravatars' ); |
|
329 | + ), $atts, 'give_donors_gravatars'); |
|
330 | 330 | |
331 | 331 | // if no ID is passed on single give_forms pages, get the correct ID |
332 | - if ( is_singular( 'give_forms' ) ) { |
|
332 | + if (is_singular('give_forms')) { |
|
333 | 333 | $id = get_the_ID(); |
334 | 334 | } |
335 | 335 | |
336 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
336 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
337 | 337 | |
338 | 338 | return $content; |
339 | 339 | |
@@ -349,56 +349,56 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @return array Gravatar settings. |
351 | 351 | */ |
352 | - public function settings( $settings ) { |
|
352 | + public function settings($settings) { |
|
353 | 353 | |
354 | 354 | $give_gravatar_settings = array( |
355 | 355 | array( |
356 | - 'name' => esc_html__( 'Donator Gravatars', 'give' ), |
|
356 | + 'name' => esc_html__('Donator Gravatars', 'give'), |
|
357 | 357 | 'desc' => '<hr>', |
358 | 358 | 'id' => 'give_title', |
359 | 359 | 'type' => 'give_title' |
360 | 360 | ), |
361 | 361 | array( |
362 | - 'name' => esc_html__( 'Heading', 'give' ), |
|
363 | - 'desc' => esc_html__( 'The heading to display above the Gravatars.', 'give' ), |
|
362 | + 'name' => esc_html__('Heading', 'give'), |
|
363 | + 'desc' => esc_html__('The heading to display above the Gravatars.', 'give'), |
|
364 | 364 | 'type' => 'text', |
365 | 365 | 'id' => 'give_donors_gravatars_heading' |
366 | 366 | ), |
367 | 367 | array( |
368 | - 'name' => esc_html__( 'Gravatar Size', 'give' ), |
|
369 | - 'desc' => esc_html__( 'The size of each Gravatar in pixels (512px maximum).', 'give' ), |
|
368 | + 'name' => esc_html__('Gravatar Size', 'give'), |
|
369 | + 'desc' => esc_html__('The size of each Gravatar in pixels (512px maximum).', 'give'), |
|
370 | 370 | 'type' => 'text_small', |
371 | 371 | 'id' => 'give_donors_gravatars_gravatar_size', |
372 | 372 | 'default' => '64' |
373 | 373 | ), |
374 | 374 | array( |
375 | - 'name' => esc_html__( 'Minimum Unique Donations Required', 'give' ), |
|
376 | - 'desc' => esc_html__( 'The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), |
|
375 | + 'name' => esc_html__('Minimum Unique Donations Required', 'give'), |
|
376 | + 'desc' => esc_html__('The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), |
|
377 | 377 | 'type' => 'text_small', |
378 | 378 | 'id' => 'give_donors_gravatars_min_purchases_required', |
379 | 379 | ), |
380 | 380 | array( |
381 | - 'name' => esc_html__( 'Maximum Gravatars To Show', 'give' ), |
|
382 | - 'desc' => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
381 | + 'name' => esc_html__('Maximum Gravatars To Show', 'give'), |
|
382 | + 'desc' => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
383 | 383 | 'type' => 'text', |
384 | 384 | 'id' => 'give_donors_gravatars_maximum_number', |
385 | 385 | 'default' => '20', |
386 | 386 | ), |
387 | 387 | array( |
388 | - 'name' => esc_html__( 'Gravatar Visibility', 'give' ), |
|
389 | - 'desc' => esc_html__( 'Show only donors with a Gravatar account.', 'give' ), |
|
388 | + 'name' => esc_html__('Gravatar Visibility', 'give'), |
|
389 | + 'desc' => esc_html__('Show only donors with a Gravatar account.', 'give'), |
|
390 | 390 | 'id' => 'give_donors_gravatars_has_gravatar_account', |
391 | 391 | 'type' => 'checkbox', |
392 | 392 | ), |
393 | 393 | array( |
394 | - 'name' => esc_html__( 'Randomize Gravatars', 'give' ), |
|
395 | - 'desc' => esc_html__( 'Randomize the Gravatars.', 'give' ), |
|
394 | + 'name' => esc_html__('Randomize Gravatars', 'give'), |
|
395 | + 'desc' => esc_html__('Randomize the Gravatars.', 'give'), |
|
396 | 396 | 'id' => 'give_donors_gravatars_random_gravatars', |
397 | 397 | 'type' => 'checkbox', |
398 | 398 | ), |
399 | 399 | ); |
400 | 400 | |
401 | - return array_merge( $settings, $give_gravatar_settings ); |
|
401 | + return array_merge($settings, $give_gravatar_settings); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | } |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | // widget settings |
425 | 425 | $widget_ops = array( |
426 | 426 | 'classname' => 'give-donors-gravatars', |
427 | - 'description' => esc_html__( 'Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give' ), |
|
427 | + 'description' => esc_html__('Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give'), |
|
428 | 428 | ); |
429 | 429 | |
430 | 430 | // widget control settings |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | // create the widget |
438 | 438 | parent::__construct( |
439 | 439 | 'give_donors_gravatars_widget', |
440 | - esc_html__( 'Give Donors Gravatars', 'give' ), |
|
440 | + esc_html__('Give Donors Gravatars', 'give'), |
|
441 | 441 | $widget_ops, |
442 | 442 | $control_ops |
443 | 443 | ); |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * |
458 | 458 | * @return void |
459 | 459 | */ |
460 | - public function widget( $args, $instance ) { |
|
460 | + public function widget($args, $instance) { |
|
461 | 461 | |
462 | 462 | $defaults = array( |
463 | 463 | 'before_widget' => '', |
@@ -466,14 +466,14 @@ discard block |
||
466 | 466 | 'after_title' => '', |
467 | 467 | ); |
468 | 468 | |
469 | - $args = wp_parse_args( $args, $defaults ); |
|
469 | + $args = wp_parse_args($args, $defaults); |
|
470 | 470 | |
471 | - if ( ! is_singular( 'give_forms' ) ) { |
|
471 | + if ( ! is_singular('give_forms')) { |
|
472 | 472 | return; |
473 | 473 | } |
474 | 474 | |
475 | 475 | // Variables from widget settings |
476 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
476 | + $title = apply_filters('widget_title', $instance['title']); |
|
477 | 477 | |
478 | 478 | $output = ''; |
479 | 479 | |
@@ -481,18 +481,18 @@ discard block |
||
481 | 481 | $output .= $args['before_widget']; |
482 | 482 | |
483 | 483 | // Display the widget title |
484 | - if ( $title ) { |
|
485 | - $output .= $args['before_title'] . $title . $args['after_title']; |
|
484 | + if ($title) { |
|
485 | + $output .= $args['before_title'].$title.$args['after_title']; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | $gravatars = new Give_Donors_Gravatars(); |
489 | 489 | |
490 | - $output .= $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
490 | + $output .= $gravatars->gravatars(get_the_ID(), null); // remove title |
|
491 | 491 | |
492 | 492 | // Used by themes. Closes the widget |
493 | 493 | $output .= $args['after_widget']; |
494 | 494 | |
495 | - echo wp_kses_post( $output ); |
|
495 | + echo wp_kses_post($output); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -508,11 +508,11 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return array Updated settings to save. |
510 | 510 | */ |
511 | - public function update( $new_instance, $old_instance ) { |
|
511 | + public function update($new_instance, $old_instance) { |
|
512 | 512 | |
513 | 513 | $instance = $old_instance; |
514 | 514 | |
515 | - $instance['title'] = wp_strip_all_tags( $new_instance['title'] ); |
|
515 | + $instance['title'] = wp_strip_all_tags($new_instance['title']); |
|
516 | 516 | |
517 | 517 | return $instance; |
518 | 518 | |
@@ -530,19 +530,19 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @return void |
532 | 532 | */ |
533 | - public function form( $instance ) { |
|
533 | + public function form($instance) { |
|
534 | 534 | |
535 | 535 | // Set up some default widget settings. |
536 | 536 | $defaults = array( |
537 | 537 | 'title' => '', |
538 | 538 | ); |
539 | 539 | |
540 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
540 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
541 | 541 | |
542 | 542 | <!-- Title --> |
543 | 543 | <p> |
544 | - <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label> |
|
545 | - <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /> |
|
544 | + <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Title:', 'give') ?></label> |
|
545 | + <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>" /> |
|
546 | 546 | </p> |
547 | 547 | |
548 | 548 | <?php |
@@ -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 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return string Donations dropdown. |
37 | 37 | */ |
38 | - public function donations_dropdown( $args = array() ) { |
|
38 | + public function donations_dropdown($args = array()) { |
|
39 | 39 | |
40 | 40 | $defaults = array( |
41 | 41 | 'name' => 'donations', |
@@ -45,32 +45,32 @@ discard block |
||
45 | 45 | 'selected' => 0, |
46 | 46 | 'chosen' => false, |
47 | 47 | 'number' => 30, |
48 | - 'placeholder' => __( 'Select a donation', 'give' ), |
|
48 | + 'placeholder' => __('Select a donation', 'give'), |
|
49 | 49 | ); |
50 | 50 | |
51 | - $args = wp_parse_args( $args, $defaults ); |
|
51 | + $args = wp_parse_args($args, $defaults); |
|
52 | 52 | |
53 | - $payments = new Give_Payments_Query( array( |
|
53 | + $payments = new Give_Payments_Query(array( |
|
54 | 54 | 'number' => $args['number'], |
55 | - ) ); |
|
55 | + )); |
|
56 | 56 | |
57 | 57 | $payments = $payments->get_payments(); |
58 | 58 | |
59 | 59 | $options = array(); |
60 | 60 | |
61 | 61 | // Provide nice human readable options. |
62 | - if ( $payments ) { |
|
62 | + if ($payments) { |
|
63 | 63 | $options[0] = $args['placeholder']; |
64 | - foreach ( $payments as $payment ) { |
|
64 | + foreach ($payments as $payment) { |
|
65 | 65 | |
66 | - $options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
66 | + $options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | } else { |
70 | - $options[0] = __( 'No donations found.', 'give' ); |
|
70 | + $options[0] = __('No donations found.', 'give'); |
|
71 | 71 | } |
72 | 72 | |
73 | - $output = $this->select( array( |
|
73 | + $output = $this->select(array( |
|
74 | 74 | 'name' => $args['name'], |
75 | 75 | 'selected' => $args['selected'], |
76 | 76 | 'id' => $args['id'], |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'select_atts' => $args['select_atts'], |
83 | 83 | 'show_option_all' => false, |
84 | 84 | 'show_option_none' => false, |
85 | - ) ); |
|
85 | + )); |
|
86 | 86 | |
87 | 87 | return $output; |
88 | 88 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return string Give forms dropdown. |
101 | 101 | */ |
102 | - public function forms_dropdown( $args = array() ) { |
|
102 | + public function forms_dropdown($args = array()) { |
|
103 | 103 | |
104 | 104 | $defaults = array( |
105 | 105 | 'name' => 'forms', |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | 'selected' => 0, |
110 | 110 | 'chosen' => false, |
111 | 111 | 'number' => 30, |
112 | - 'placeholder' => esc_attr__( 'All Forms', 'give' ), |
|
112 | + 'placeholder' => esc_attr__('All Forms', 'give'), |
|
113 | 113 | 'data' => array( |
114 | 114 | 'search-type' => 'form', |
115 | 115 | ), |
116 | 116 | ); |
117 | 117 | |
118 | - $args = wp_parse_args( $args, $defaults ); |
|
118 | + $args = wp_parse_args($args, $defaults); |
|
119 | 119 | |
120 | 120 | $form_args = array( |
121 | 121 | 'post_type' => 'give_forms', |
@@ -124,34 +124,34 @@ discard block |
||
124 | 124 | 'posts_per_page' => $args['number'], |
125 | 125 | ); |
126 | 126 | |
127 | - $cache_key = Give_Cache::get_key( 'give_forms', $form_args, false ); |
|
127 | + $cache_key = Give_Cache::get_key('give_forms', $form_args, false); |
|
128 | 128 | |
129 | 129 | // Get forms from cache. |
130 | - $forms = Give_Cache::get_db_query( $cache_key ); |
|
130 | + $forms = Give_Cache::get_db_query($cache_key); |
|
131 | 131 | |
132 | - if ( is_null( $forms ) ) { |
|
133 | - $forms = get_posts( $form_args ); |
|
134 | - Give_Cache::set_db_query( $cache_key, $forms ); |
|
132 | + if (is_null($forms)) { |
|
133 | + $forms = get_posts($form_args); |
|
134 | + Give_Cache::set_db_query($cache_key, $forms); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | $options = array(); |
138 | 138 | |
139 | 139 | // Ensure the selected. |
140 | - if ( false !== $args['selected'] && $args['selected'] !== 0 ) { |
|
141 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
140 | + if (false !== $args['selected'] && $args['selected'] !== 0) { |
|
141 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
142 | 142 | } |
143 | 143 | |
144 | - if ( $forms ) { |
|
144 | + if ($forms) { |
|
145 | 145 | $options[0] = $args['placeholder']; |
146 | - foreach ( $forms as $form ) { |
|
147 | - $form_title = empty( $form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID ) : $form->post_title; |
|
148 | - $options[ absint( $form->ID ) ] = esc_html( $form_title ); |
|
146 | + foreach ($forms as $form) { |
|
147 | + $form_title = empty($form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $form->ID) : $form->post_title; |
|
148 | + $options[absint($form->ID)] = esc_html($form_title); |
|
149 | 149 | } |
150 | 150 | } else { |
151 | - $options[0] = esc_html__( 'No forms found.', 'give' ); |
|
151 | + $options[0] = esc_html__('No forms found.', 'give'); |
|
152 | 152 | } |
153 | 153 | |
154 | - $output = $this->select( array( |
|
154 | + $output = $this->select(array( |
|
155 | 155 | 'name' => $args['name'], |
156 | 156 | 'selected' => $args['selected'], |
157 | 157 | 'id' => $args['id'], |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | 'show_option_all' => false, |
164 | 164 | 'show_option_none' => false, |
165 | 165 | 'data' => $args['data'], |
166 | - ) ); |
|
166 | + )); |
|
167 | 167 | |
168 | 168 | return $output; |
169 | 169 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return string Donors dropdown. |
182 | 182 | */ |
183 | - public function donor_dropdown( $args = array() ) { |
|
183 | + public function donor_dropdown($args = array()) { |
|
184 | 184 | |
185 | 185 | $defaults = array( |
186 | 186 | 'name' => 'donors', |
@@ -189,57 +189,57 @@ discard block |
||
189 | 189 | 'multiple' => false, |
190 | 190 | 'selected' => 0, |
191 | 191 | 'chosen' => true, |
192 | - 'placeholder' => esc_attr__( 'Select a Donor', 'give' ), |
|
192 | + 'placeholder' => esc_attr__('Select a Donor', 'give'), |
|
193 | 193 | 'number' => 30, |
194 | 194 | 'data' => array( |
195 | 195 | 'search-type' => 'donor', |
196 | 196 | ), |
197 | 197 | ); |
198 | 198 | |
199 | - $args = wp_parse_args( $args, $defaults ); |
|
199 | + $args = wp_parse_args($args, $defaults); |
|
200 | 200 | |
201 | - $donors = Give()->donors->get_donors( array( |
|
201 | + $donors = Give()->donors->get_donors(array( |
|
202 | 202 | 'number' => $args['number'] |
203 | - ) ); |
|
203 | + )); |
|
204 | 204 | |
205 | 205 | $options = array(); |
206 | 206 | |
207 | - if ( $donors ) { |
|
208 | - $options[0] = esc_html__( 'No donor attached', 'give' ); |
|
209 | - foreach ( $donors as $donor ) { |
|
210 | - $options[ absint( $donor->id ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
207 | + if ($donors) { |
|
208 | + $options[0] = esc_html__('No donor attached', 'give'); |
|
209 | + foreach ($donors as $donor) { |
|
210 | + $options[absint($donor->id)] = esc_html($donor->name.' ('.$donor->email.')'); |
|
211 | 211 | } |
212 | 212 | } else { |
213 | - $options[0] = esc_html__( 'No donors found.', 'give' ); |
|
213 | + $options[0] = esc_html__('No donors found.', 'give'); |
|
214 | 214 | } |
215 | 215 | |
216 | - if ( ! empty( $args['selected'] ) ) { |
|
216 | + if ( ! empty($args['selected'])) { |
|
217 | 217 | |
218 | 218 | // If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed. |
219 | - if ( ! array_key_exists( $args['selected'], $options ) ) { |
|
219 | + if ( ! array_key_exists($args['selected'], $options)) { |
|
220 | 220 | |
221 | - $donor = new Give_Donor( $args['selected'] ); |
|
221 | + $donor = new Give_Donor($args['selected']); |
|
222 | 222 | |
223 | - if ( $donor ) { |
|
223 | + if ($donor) { |
|
224 | 224 | |
225 | - $options[ absint( $args['selected'] ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
225 | + $options[absint($args['selected'])] = esc_html($donor->name.' ('.$donor->email.')'); |
|
226 | 226 | |
227 | 227 | } |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | - $output = $this->select( array( |
|
231 | + $output = $this->select(array( |
|
232 | 232 | 'name' => $args['name'], |
233 | 233 | 'selected' => $args['selected'], |
234 | 234 | 'id' => $args['id'], |
235 | - 'class' => $args['class'] . ' give-customer-select', |
|
235 | + 'class' => $args['class'].' give-customer-select', |
|
236 | 236 | 'options' => $options, |
237 | 237 | 'multiple' => $args['multiple'], |
238 | 238 | 'chosen' => $args['chosen'], |
239 | 239 | 'show_option_all' => false, |
240 | 240 | 'show_option_none' => false, |
241 | 241 | 'data' => $args['data'], |
242 | - ) ); |
|
242 | + )); |
|
243 | 243 | |
244 | 244 | return $output; |
245 | 245 | } |
@@ -258,22 +258,22 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return string Categories dropdown. |
260 | 260 | */ |
261 | - public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) { |
|
262 | - $categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); |
|
261 | + public function category_dropdown($name = 'give_forms_categories', $selected = 0, $args = array()) { |
|
262 | + $categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array())); |
|
263 | 263 | |
264 | 264 | $options = array(); |
265 | 265 | |
266 | - foreach ( $categories as $category ) { |
|
267 | - $options[ absint( $category->term_id ) ] = esc_html( $category->name ); |
|
266 | + foreach ($categories as $category) { |
|
267 | + $options[absint($category->term_id)] = esc_html($category->name); |
|
268 | 268 | } |
269 | 269 | |
270 | - $output = $this->select( wp_parse_args( $args, array( |
|
270 | + $output = $this->select(wp_parse_args($args, array( |
|
271 | 271 | 'name' => $name, |
272 | 272 | 'selected' => $selected, |
273 | 273 | 'options' => $options, |
274 | - 'show_option_all' => esc_html__( 'All Categories', 'give' ), |
|
274 | + 'show_option_all' => esc_html__('All Categories', 'give'), |
|
275 | 275 | 'show_option_none' => false, |
276 | - ) ) ); |
|
276 | + ))); |
|
277 | 277 | |
278 | 278 | return $output; |
279 | 279 | } |
@@ -292,22 +292,22 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @return string Tags dropdown. |
294 | 294 | */ |
295 | - public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) { |
|
296 | - $tags = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) ); |
|
295 | + public function tags_dropdown($name = 'give_forms_tags', $selected = 0, $args = array()) { |
|
296 | + $tags = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array())); |
|
297 | 297 | |
298 | 298 | $options = array(); |
299 | 299 | |
300 | - foreach ( $tags as $tag ) { |
|
301 | - $options[ absint( $tag->term_id ) ] = esc_html( $tag->name ); |
|
300 | + foreach ($tags as $tag) { |
|
301 | + $options[absint($tag->term_id)] = esc_html($tag->name); |
|
302 | 302 | } |
303 | 303 | |
304 | - $output = $this->select( wp_parse_args( $args, array( |
|
304 | + $output = $this->select(wp_parse_args($args, array( |
|
305 | 305 | 'name' => $name, |
306 | 306 | 'selected' => $selected, |
307 | 307 | 'options' => $options, |
308 | - 'show_option_all' => esc_html__( 'All Tags', 'give' ), |
|
308 | + 'show_option_all' => esc_html__('All Tags', 'give'), |
|
309 | 309 | 'show_option_none' => false, |
310 | - ) ) ); |
|
310 | + ))); |
|
311 | 311 | |
312 | 312 | return $output; |
313 | 313 | } |
@@ -327,25 +327,25 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return string Years dropdown. |
329 | 329 | */ |
330 | - public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
331 | - $current = date( 'Y' ); |
|
332 | - $start_year = $current - absint( $years_before ); |
|
333 | - $end_year = $current + absint( $years_after ); |
|
334 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
330 | + public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
331 | + $current = date('Y'); |
|
332 | + $start_year = $current - absint($years_before); |
|
333 | + $end_year = $current + absint($years_after); |
|
334 | + $selected = empty($selected) ? date('Y') : $selected; |
|
335 | 335 | $options = array(); |
336 | 336 | |
337 | - while ( $start_year <= $end_year ) { |
|
338 | - $options[ absint( $start_year ) ] = $start_year; |
|
339 | - $start_year ++; |
|
337 | + while ($start_year <= $end_year) { |
|
338 | + $options[absint($start_year)] = $start_year; |
|
339 | + $start_year++; |
|
340 | 340 | } |
341 | 341 | |
342 | - $output = $this->select( array( |
|
342 | + $output = $this->select(array( |
|
343 | 343 | 'name' => $name, |
344 | 344 | 'selected' => $selected, |
345 | 345 | 'options' => $options, |
346 | 346 | 'show_option_all' => false, |
347 | 347 | 'show_option_none' => false, |
348 | - ) ); |
|
348 | + )); |
|
349 | 349 | |
350 | 350 | return $output; |
351 | 351 | } |
@@ -363,23 +363,23 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @return string Months dropdown. |
365 | 365 | */ |
366 | - public function month_dropdown( $name = 'month', $selected = 0 ) { |
|
366 | + public function month_dropdown($name = 'month', $selected = 0) { |
|
367 | 367 | $month = 1; |
368 | 368 | $options = array(); |
369 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
369 | + $selected = empty($selected) ? date('n') : $selected; |
|
370 | 370 | |
371 | - while ( $month <= 12 ) { |
|
372 | - $options[ absint( $month ) ] = give_month_num_to_name( $month ); |
|
373 | - $month ++; |
|
371 | + while ($month <= 12) { |
|
372 | + $options[absint($month)] = give_month_num_to_name($month); |
|
373 | + $month++; |
|
374 | 374 | } |
375 | 375 | |
376 | - $output = $this->select( array( |
|
376 | + $output = $this->select(array( |
|
377 | 377 | 'name' => $name, |
378 | 378 | 'selected' => $selected, |
379 | 379 | 'options' => $options, |
380 | 380 | 'show_option_all' => false, |
381 | 381 | 'show_option_none' => false, |
382 | - ) ); |
|
382 | + )); |
|
383 | 383 | |
384 | 384 | return $output; |
385 | 385 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @return string The dropdown. |
398 | 398 | */ |
399 | - public function select( $args = array() ) { |
|
399 | + public function select($args = array()) { |
|
400 | 400 | $defaults = array( |
401 | 401 | 'options' => array(), |
402 | 402 | 'name' => null, |
@@ -407,74 +407,74 @@ discard block |
||
407 | 407 | 'placeholder' => null, |
408 | 408 | 'multiple' => false, |
409 | 409 | 'select_atts' => false, |
410 | - 'show_option_all' => __( 'All', 'give' ), |
|
411 | - 'show_option_none' => __( 'None', 'give' ), |
|
410 | + 'show_option_all' => __('All', 'give'), |
|
411 | + 'show_option_none' => __('None', 'give'), |
|
412 | 412 | 'data' => array(), |
413 | 413 | 'readonly' => false, |
414 | 414 | 'disabled' => false, |
415 | 415 | ); |
416 | 416 | |
417 | - $args = wp_parse_args( $args, $defaults ); |
|
417 | + $args = wp_parse_args($args, $defaults); |
|
418 | 418 | |
419 | 419 | $data_elements = ''; |
420 | - foreach ( $args['data'] as $key => $value ) { |
|
421 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
420 | + foreach ($args['data'] as $key => $value) { |
|
421 | + $data_elements .= ' data-'.esc_attr($key).'="'.esc_attr($value).'"'; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | $multiple = ''; |
425 | - if ( $args['multiple'] ) { |
|
425 | + if ($args['multiple']) { |
|
426 | 426 | $multiple = 'MULTIPLE'; |
427 | 427 | } |
428 | 428 | |
429 | - if ( $args['chosen'] ) { |
|
429 | + if ($args['chosen']) { |
|
430 | 430 | $args['class'] .= ' give-select-chosen'; |
431 | 431 | } |
432 | 432 | |
433 | 433 | $placeholder = ''; |
434 | - if ( $args['placeholder'] ) { |
|
434 | + if ($args['placeholder']) { |
|
435 | 435 | $placeholder = $args['placeholder']; |
436 | 436 | } |
437 | 437 | |
438 | 438 | $output = sprintf( |
439 | 439 | '<select name="%1$s" id="%2$s" class="give-select %3$s" %4$s %5$s placeholder="%6$s" data-placeholder="%6$s" %7$s>', |
440 | - esc_attr( $args['name'] ), |
|
441 | - esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ), |
|
442 | - esc_attr( $args['class'] ), |
|
440 | + esc_attr($args['name']), |
|
441 | + esc_attr(sanitize_key(str_replace('-', '_', $args['id']))), |
|
442 | + esc_attr($args['class']), |
|
443 | 443 | $multiple, |
444 | 444 | $args['select_atts'], |
445 | 445 | $placeholder, |
446 | 446 | $data_elements |
447 | 447 | ); |
448 | 448 | |
449 | - if ( $args['show_option_all'] ) { |
|
450 | - if ( $args['multiple'] ) { |
|
451 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
449 | + if ($args['show_option_all']) { |
|
450 | + if ($args['multiple']) { |
|
451 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
452 | 452 | } else { |
453 | - $selected = selected( $args['selected'], 0, false ); |
|
453 | + $selected = selected($args['selected'], 0, false); |
|
454 | 454 | } |
455 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
455 | + $output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>'; |
|
456 | 456 | } |
457 | 457 | |
458 | - if ( ! empty( $args['options'] ) ) { |
|
458 | + if ( ! empty($args['options'])) { |
|
459 | 459 | |
460 | - if ( $args['show_option_none'] ) { |
|
461 | - if ( $args['multiple'] ) { |
|
462 | - $selected = selected( true, in_array( - 1, $args['selected'] ), false ); |
|
460 | + if ($args['show_option_none']) { |
|
461 | + if ($args['multiple']) { |
|
462 | + $selected = selected(true, in_array( -1, $args['selected'] ), false); |
|
463 | 463 | } else { |
464 | - $selected = selected( $args['selected'], - 1, false ); |
|
464 | + $selected = selected($args['selected'], - 1, false); |
|
465 | 465 | } |
466 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
466 | + $output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>'; |
|
467 | 467 | } |
468 | 468 | |
469 | - foreach ( $args['options'] as $key => $option ) { |
|
469 | + foreach ($args['options'] as $key => $option) { |
|
470 | 470 | |
471 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
472 | - $selected = selected( true, in_array( $key, $args['selected'] ), false ); |
|
471 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
472 | + $selected = selected(true, in_array($key, $args['selected']), false); |
|
473 | 473 | } else { |
474 | - $selected = selected( $args['selected'], $key, false ); |
|
474 | + $selected = selected($args['selected'], $key, false); |
|
475 | 475 | } |
476 | 476 | |
477 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
477 | + $output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>'; |
|
478 | 478 | } |
479 | 479 | } |
480 | 480 | |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * |
496 | 496 | * @return string The checkbox. |
497 | 497 | */ |
498 | - public function checkbox( $args = array() ) { |
|
498 | + public function checkbox($args = array()) { |
|
499 | 499 | $defaults = array( |
500 | 500 | 'name' => null, |
501 | 501 | 'current' => null, |
@@ -506,16 +506,16 @@ discard block |
||
506 | 506 | ), |
507 | 507 | ); |
508 | 508 | |
509 | - $args = wp_parse_args( $args, $defaults ); |
|
509 | + $args = wp_parse_args($args, $defaults); |
|
510 | 510 | |
511 | 511 | $options = ''; |
512 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
512 | + if ( ! empty($args['options']['disabled'])) { |
|
513 | 513 | $options .= ' disabled="disabled"'; |
514 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
514 | + } elseif ( ! empty($args['options']['readonly'])) { |
|
515 | 515 | $options .= ' readonly'; |
516 | 516 | } |
517 | 517 | |
518 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
518 | + $output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />'; |
|
519 | 519 | |
520 | 520 | return $output; |
521 | 521 | } |
@@ -532,22 +532,22 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return string The text field. |
534 | 534 | */ |
535 | - public function text( $args = array() ) { |
|
535 | + public function text($args = array()) { |
|
536 | 536 | // Backwards compatibility. |
537 | - if ( func_num_args() > 1 ) { |
|
537 | + if (func_num_args() > 1) { |
|
538 | 538 | $args = func_get_args(); |
539 | 539 | |
540 | 540 | $name = $args[0]; |
541 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
542 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
543 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
541 | + $value = isset($args[1]) ? $args[1] : ''; |
|
542 | + $label = isset($args[2]) ? $args[2] : ''; |
|
543 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | $defaults = array( |
547 | - 'name' => isset( $name ) ? $name : 'text', |
|
548 | - 'value' => isset( $value ) ? $value : null, |
|
549 | - 'label' => isset( $label ) ? $label : null, |
|
550 | - 'desc' => isset( $desc ) ? $desc : null, |
|
547 | + 'name' => isset($name) ? $name : 'text', |
|
548 | + 'value' => isset($value) ? $value : null, |
|
549 | + 'label' => isset($label) ? $label : null, |
|
550 | + 'desc' => isset($desc) ? $desc : null, |
|
551 | 551 | 'placeholder' => '', |
552 | 552 | 'class' => 'regular-text', |
553 | 553 | 'disabled' => false, |
@@ -555,29 +555,29 @@ discard block |
||
555 | 555 | 'data' => false, |
556 | 556 | ); |
557 | 557 | |
558 | - $args = wp_parse_args( $args, $defaults ); |
|
558 | + $args = wp_parse_args($args, $defaults); |
|
559 | 559 | |
560 | 560 | $disabled = ''; |
561 | - if ( $args['disabled'] ) { |
|
561 | + if ($args['disabled']) { |
|
562 | 562 | $disabled = ' disabled="disabled"'; |
563 | 563 | } |
564 | 564 | |
565 | 565 | $data = ''; |
566 | - if ( ! empty( $args['data'] ) ) { |
|
567 | - foreach ( $args['data'] as $key => $value ) { |
|
568 | - $data .= 'data-' . $key . '="' . $value . '" '; |
|
566 | + if ( ! empty($args['data'])) { |
|
567 | + foreach ($args['data'] as $key => $value) { |
|
568 | + $data .= 'data-'.$key.'="'.$value.'" '; |
|
569 | 569 | } |
570 | 570 | } |
571 | 571 | |
572 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
572 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
573 | 573 | |
574 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
574 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
575 | 575 | |
576 | - if ( ! empty( $args['desc'] ) ) { |
|
577 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
576 | + if ( ! empty($args['desc'])) { |
|
577 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
578 | 578 | } |
579 | 579 | |
580 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; |
|
580 | + $output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>'; |
|
581 | 581 | |
582 | 582 | $output .= '</span>'; |
583 | 583 | |
@@ -596,15 +596,15 @@ discard block |
||
596 | 596 | * |
597 | 597 | * @return string The date picker. |
598 | 598 | */ |
599 | - public function date_field( $args = array() ) { |
|
599 | + public function date_field($args = array()) { |
|
600 | 600 | |
601 | - if ( empty( $args['class'] ) ) { |
|
601 | + if (empty($args['class'])) { |
|
602 | 602 | $args['class'] = 'give_datepicker'; |
603 | - } elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) { |
|
603 | + } elseif ( ! strpos($args['class'], 'give_datepicker')) { |
|
604 | 604 | $args['class'] .= ' give_datepicker'; |
605 | 605 | } |
606 | 606 | |
607 | - return $this->text( $args ); |
|
607 | + return $this->text($args); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * |
620 | 620 | * @return string The textarea. |
621 | 621 | */ |
622 | - public function textarea( $args = array() ) { |
|
622 | + public function textarea($args = array()) { |
|
623 | 623 | $defaults = array( |
624 | 624 | 'name' => 'textarea', |
625 | 625 | 'value' => null, |
@@ -629,21 +629,21 @@ discard block |
||
629 | 629 | 'disabled' => false, |
630 | 630 | ); |
631 | 631 | |
632 | - $args = wp_parse_args( $args, $defaults ); |
|
632 | + $args = wp_parse_args($args, $defaults); |
|
633 | 633 | |
634 | 634 | $disabled = ''; |
635 | - if ( $args['disabled'] ) { |
|
635 | + if ($args['disabled']) { |
|
636 | 636 | $disabled = ' disabled="disabled"'; |
637 | 637 | } |
638 | 638 | |
639 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
639 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
640 | 640 | |
641 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
641 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
642 | 642 | |
643 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
643 | + $output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>'; |
|
644 | 644 | |
645 | - if ( ! empty( $args['desc'] ) ) { |
|
646 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
645 | + if ( ! empty($args['desc'])) { |
|
646 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | $output .= '</span>'; |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | * |
664 | 664 | * @return string The text field with ajax search. |
665 | 665 | */ |
666 | - public function ajax_user_search( $args = array() ) { |
|
666 | + public function ajax_user_search($args = array()) { |
|
667 | 667 | |
668 | 668 | $defaults = array( |
669 | 669 | 'name' => 'users', |
@@ -674,13 +674,13 @@ discard block |
||
674 | 674 | 'chosen' => true, |
675 | 675 | 'number' => 30, |
676 | 676 | 'select_atts' => '', |
677 | - 'placeholder' => __( 'Select a user', 'give' ), |
|
677 | + 'placeholder' => __('Select a user', 'give'), |
|
678 | 678 | 'data' => array( |
679 | 679 | 'search-type' => 'user', |
680 | 680 | ), |
681 | 681 | ); |
682 | 682 | |
683 | - $args = wp_parse_args( $args, $defaults ); |
|
683 | + $args = wp_parse_args($args, $defaults); |
|
684 | 684 | |
685 | 685 | // Set initial args. |
686 | 686 | $get_users_args = array( |
@@ -689,31 +689,31 @@ discard block |
||
689 | 689 | |
690 | 690 | // Ensure selected user is not included in initial query. |
691 | 691 | // This is because sites with many users, it's not a guarantee the selected user will be returned. |
692 | - if ( ! empty( $args['selected'] ) ) { |
|
692 | + if ( ! empty($args['selected'])) { |
|
693 | 693 | $get_users_args['exclude'] = $args['selected']; |
694 | 694 | } |
695 | 695 | |
696 | 696 | // Initial users array. |
697 | - $users = apply_filters( 'give_ajax_user_search_initial_results', get_users( $get_users_args ), $args ); |
|
697 | + $users = apply_filters('give_ajax_user_search_initial_results', get_users($get_users_args), $args); |
|
698 | 698 | |
699 | 699 | // Now add the selected user to the $users array if the arg is present. |
700 | - if ( ! empty( $args['selected'] ) ) { |
|
701 | - $selected_user = apply_filters( 'give_ajax_user_search_selected_results', get_users( "include={$args['selected']}" ), $args );; |
|
702 | - $users = array_merge( $users, $selected_user ); |
|
700 | + if ( ! empty($args['selected'])) { |
|
701 | + $selected_user = apply_filters('give_ajax_user_search_selected_results', get_users("include={$args['selected']}"), $args); ; |
|
702 | + $users = array_merge($users, $selected_user); |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | $options = array(); |
706 | 706 | |
707 | - if ( $users ) { |
|
707 | + if ($users) { |
|
708 | 708 | $options[0] = $args['placeholder']; |
709 | - foreach ( $users as $user ) { |
|
710 | - $options[ absint( $user->ID ) ] = esc_html( $user->user_login . ' (' . $user->user_email . ')' ); |
|
709 | + foreach ($users as $user) { |
|
710 | + $options[absint($user->ID)] = esc_html($user->user_login.' ('.$user->user_email.')'); |
|
711 | 711 | } |
712 | 712 | } else { |
713 | - $options[0] = __( 'No users found.', 'give' ); |
|
713 | + $options[0] = __('No users found.', 'give'); |
|
714 | 714 | } |
715 | 715 | |
716 | - $output = $this->select( array( |
|
716 | + $output = $this->select(array( |
|
717 | 717 | 'name' => $args['name'], |
718 | 718 | 'selected' => $args['selected'], |
719 | 719 | 'id' => $args['id'], |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | 'show_option_all' => false, |
727 | 727 | 'show_option_none' => false, |
728 | 728 | 'data' => $args['data'], |
729 | - ) ); |
|
729 | + )); |
|
730 | 730 | |
731 | 731 | return $output; |
732 | 732 |
@@ -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 | |
@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return void |
30 | 30 | */ |
31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
32 | 32 | |
33 | 33 | // Make sure that payments are only completed once. |
34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Make sure the payment completion is only processed when new status is complete. |
39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - $payment = new Give_Payment( $payment_id ); |
|
43 | + $payment = new Give_Payment($payment_id); |
|
44 | 44 | |
45 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
45 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
46 | 46 | $payment_meta = $payment->payment_meta; |
47 | 47 | $completed_date = $payment->completed_date; |
48 | 48 | $user_info = $payment->user_info; |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param int $payment_id The ID of the payment. |
60 | 60 | */ |
61 | - do_action( 'give_pre_complete_donation', $payment_id ); |
|
61 | + do_action('give_pre_complete_donation', $payment_id); |
|
62 | 62 | |
63 | 63 | // Ensure these actions only run once, ever. |
64 | - if ( empty( $completed_date ) ) { |
|
64 | + if (empty($completed_date)) { |
|
65 | 65 | |
66 | - give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
66 | + give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Fires after logging donation record. |
@@ -74,29 +74,29 @@ discard block |
||
74 | 74 | * @param int $payment_id The ID number of the payment. |
75 | 75 | * @param array $payment_meta The payment meta. |
76 | 76 | */ |
77 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
77 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | 81 | // Increase the earnings for this form ID. |
82 | - give_increase_earnings( $form_id, $amount, $payment_id ); |
|
83 | - give_increase_donation_count( $form_id ); |
|
82 | + give_increase_earnings($form_id, $amount, $payment_id); |
|
83 | + give_increase_donation_count($form_id); |
|
84 | 84 | |
85 | 85 | // @todo: Refresh only range related stat cache |
86 | 86 | give_delete_donation_stats(); |
87 | 87 | |
88 | 88 | // Increase the donor's donation stats. |
89 | - $donor = new Give_Donor( $donor_id ); |
|
89 | + $donor = new Give_Donor($donor_id); |
|
90 | 90 | $donor->increase_purchase_count(); |
91 | - $donor->increase_value( $amount ); |
|
91 | + $donor->increase_value($amount); |
|
92 | 92 | |
93 | - give_increase_total_earnings( $amount ); |
|
93 | + give_increase_total_earnings($amount); |
|
94 | 94 | |
95 | 95 | // Ensure this action only runs once ever. |
96 | - if ( empty( $completed_date ) ) { |
|
96 | + if (empty($completed_date)) { |
|
97 | 97 | |
98 | 98 | // Save the completed date. |
99 | - $payment->completed_date = current_time( 'mysql' ); |
|
99 | + $payment->completed_date = current_time('mysql'); |
|
100 | 100 | $payment->save(); |
101 | 101 | |
102 | 102 | /** |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param int $payment_id The ID of the payment. |
108 | 108 | */ |
109 | - do_action( 'give_complete_donation', $payment_id ); |
|
109 | + do_action('give_complete_donation', $payment_id); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
114 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -125,20 +125,20 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
128 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
129 | 129 | |
130 | 130 | // Get the list of statuses so that status in the payment note can be translated. |
131 | 131 | $stati = give_get_payment_statuses(); |
132 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
133 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
132 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
133 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
134 | 134 | |
135 | 135 | // translators: 1: old status 2: new status. |
136 | - $status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status ); |
|
136 | + $status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status); |
|
137 | 137 | |
138 | - give_insert_payment_note( $payment_id, $status_change ); |
|
138 | + give_insert_payment_note($payment_id, $status_change); |
|
139 | 139 | } |
140 | 140 | |
141 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
141 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
142 | 142 | |
143 | 143 | |
144 | 144 | /** |
@@ -154,25 +154,25 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @return void |
156 | 156 | */ |
157 | -function give_update_old_payments_with_totals( $data ) { |
|
158 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
157 | +function give_update_old_payments_with_totals($data) { |
|
158 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
159 | 159 | return; |
160 | 160 | } |
161 | 161 | |
162 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
162 | + if (get_option('give_payment_totals_upgraded')) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - $payments = give_get_payments( array( |
|
166 | + $payments = give_get_payments(array( |
|
167 | 167 | 'offset' => 0, |
168 | - 'number' => - 1, |
|
168 | + 'number' => -1, |
|
169 | 169 | 'mode' => 'all', |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | |
172 | - if ( $payments ) { |
|
173 | - foreach ( $payments as $payment ) { |
|
172 | + if ($payments) { |
|
173 | + foreach ($payments as $payment) { |
|
174 | 174 | |
175 | - $payment = new Give_Payment( $payment->ID ); |
|
175 | + $payment = new Give_Payment($payment->ID); |
|
176 | 176 | $meta = $payment->get_meta(); |
177 | 177 | |
178 | 178 | $payment->total = $meta['amount']; |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
184 | + add_option('give_payment_totals_upgraded', 1); |
|
185 | 185 | } |
186 | 186 | |
187 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
187 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Mark Abandoned Donations |
@@ -198,17 +198,17 @@ discard block |
||
198 | 198 | function give_mark_abandoned_donations() { |
199 | 199 | $args = array( |
200 | 200 | 'status' => 'pending', |
201 | - 'number' => - 1, |
|
201 | + 'number' => -1, |
|
202 | 202 | 'output' => 'give_payments', |
203 | 203 | ); |
204 | 204 | |
205 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
205 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
206 | 206 | |
207 | - $payments = give_get_payments( $args ); |
|
207 | + $payments = give_get_payments($args); |
|
208 | 208 | |
209 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
209 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
210 | 210 | |
211 | - if ( $payments ) { |
|
211 | + if ($payments) { |
|
212 | 212 | /** |
213 | 213 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
214 | 214 | * |
@@ -216,14 +216,14 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @param array $skip_payment_gateways Array of payment gateways |
218 | 218 | */ |
219 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
219 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
220 | 220 | |
221 | 221 | /* @var Give_Payment $payment */ |
222 | - foreach ( $payments as $payment ) { |
|
223 | - $gateway = give_get_payment_gateway( $payment->ID ); |
|
222 | + foreach ($payments as $payment) { |
|
223 | + $gateway = give_get_payment_gateway($payment->ID); |
|
224 | 224 | |
225 | 225 | // Skip payment gateways. |
226 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
226 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
227 | 227 | continue; |
228 | 228 | } |
229 | 229 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | -Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' ); |
|
236 | +Give_Cron::add_weekly_event('give_mark_abandoned_donations'); |
|
237 | 237 | |
238 | 238 | |
239 | 239 | /** |
@@ -245,15 +245,15 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @return void |
247 | 247 | */ |
248 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
248 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
249 | 249 | // Monthly stats. |
250 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
250 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
251 | 251 | |
252 | 252 | // @todo: Refresh only range related stat cache |
253 | 253 | give_delete_donation_stats(); |
254 | 254 | } |
255 | 255 | |
256 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
256 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
|
257 | 257 | |
258 | 258 | |
259 | 259 | /** |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return array |
271 | 271 | */ |
272 | -function give_bc_v20_get_payment_meta( $check, $object_id, $meta_key, $single ) { |
|
272 | +function give_bc_v20_get_payment_meta($check, $object_id, $meta_key, $single) { |
|
273 | 273 | // Bailout. |
274 | 274 | if ( |
275 | - 'give_payment' !== get_post_type( $object_id ) || |
|
275 | + 'give_payment' !== get_post_type($object_id) || |
|
276 | 276 | '_give_payment_meta' !== $meta_key || |
277 | - ! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) |
|
277 | + ! give_has_upgrade_completed('v20_upgrades_payment_metadata') |
|
278 | 278 | ) { |
279 | 279 | return $check; |
280 | 280 | } |
@@ -282,73 +282,69 @@ discard block |
||
282 | 282 | $cache_key = "_give_payment_meta_{$object_id}"; |
283 | 283 | |
284 | 284 | // Get already calculate payment meta from cache. |
285 | - $payment_meta = Give_Cache::get_db_query( $cache_key ); |
|
285 | + $payment_meta = Give_Cache::get_db_query($cache_key); |
|
286 | 286 | |
287 | - if ( is_null( $payment_meta ) ) { |
|
287 | + if (is_null($payment_meta)) { |
|
288 | 288 | // Remove filter. |
289 | - remove_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999 ); |
|
289 | + remove_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999); |
|
290 | 290 | |
291 | - $donation = new Give_Payment( $object_id ); |
|
291 | + $donation = new Give_Payment($object_id); |
|
292 | 292 | |
293 | 293 | // Get all payment meta. |
294 | - $payment_meta = give_get_meta( $object_id ); |
|
294 | + $payment_meta = give_get_meta($object_id); |
|
295 | 295 | |
296 | 296 | // Set default value to array. |
297 | - if ( empty( $payment_meta ) ) { |
|
297 | + if (empty($payment_meta)) { |
|
298 | 298 | return $check; |
299 | 299 | } |
300 | 300 | |
301 | 301 | // Convert all meta key value to string instead of array |
302 | - array_walk( $payment_meta, function ( &$meta, $key ) { |
|
303 | - $meta = current( $meta ); |
|
302 | + array_walk($payment_meta, function(&$meta, $key) { |
|
303 | + $meta = current($meta); |
|
304 | 304 | } ); |
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Add backward compatibility to old meta keys. |
308 | 308 | */ |
309 | 309 | // Donation key. |
310 | - $payment_meta['key'] = ! empty( $payment_meta['_give_payment_purchase_key'] ) ? $payment_meta['_give_payment_purchase_key'] : ''; |
|
310 | + $payment_meta['key'] = ! empty($payment_meta['_give_payment_purchase_key']) ? $payment_meta['_give_payment_purchase_key'] : ''; |
|
311 | 311 | |
312 | 312 | // Donation form. |
313 | - $payment_meta['form_title'] = ! empty( $payment_meta['_give_payment_form_title'] ) ? $payment_meta['_give_payment_form_title'] : ''; |
|
313 | + $payment_meta['form_title'] = ! empty($payment_meta['_give_payment_form_title']) ? $payment_meta['_give_payment_form_title'] : ''; |
|
314 | 314 | |
315 | 315 | // Donor email. |
316 | - $payment_meta['email'] = ! empty( $payment_meta['_give_payment_donor_email'] ) ? $payment_meta['_give_payment_donor_email'] : ''; |
|
317 | - $payment_meta['email'] = ! empty( $payment_meta['email'] ) ? |
|
318 | - $payment_meta['email'] : |
|
319 | - Give()->donors->get_column( 'email', $donation->donor_id ); |
|
316 | + $payment_meta['email'] = ! empty($payment_meta['_give_payment_donor_email']) ? $payment_meta['_give_payment_donor_email'] : ''; |
|
317 | + $payment_meta['email'] = ! empty($payment_meta['email']) ? |
|
318 | + $payment_meta['email'] : Give()->donors->get_column('email', $donation->donor_id); |
|
320 | 319 | |
321 | 320 | // Form id. |
322 | - $payment_meta['form_id'] = ! empty( $payment_meta['_give_payment_form_id'] ) ? $payment_meta['_give_payment_form_id'] : ''; |
|
321 | + $payment_meta['form_id'] = ! empty($payment_meta['_give_payment_form_id']) ? $payment_meta['_give_payment_form_id'] : ''; |
|
323 | 322 | |
324 | 323 | // Price id. |
325 | - $payment_meta['price_id'] = ! empty( $payment_meta['_give_payment_price_id'] ) ? $payment_meta['_give_payment_price_id'] : ''; |
|
324 | + $payment_meta['price_id'] = ! empty($payment_meta['_give_payment_price_id']) ? $payment_meta['_give_payment_price_id'] : ''; |
|
326 | 325 | |
327 | 326 | // Date. |
328 | - $payment_meta['date'] = ! empty( $payment_meta['_give_payment_date'] ) ? $payment_meta['_give_payment_date'] : ''; |
|
329 | - $payment_meta['date'] = ! empty( $payment_meta['date'] ) ? |
|
330 | - $payment_meta['date'] : |
|
331 | - get_post_field( 'post_date', $object_id ); |
|
327 | + $payment_meta['date'] = ! empty($payment_meta['_give_payment_date']) ? $payment_meta['_give_payment_date'] : ''; |
|
328 | + $payment_meta['date'] = ! empty($payment_meta['date']) ? |
|
329 | + $payment_meta['date'] : get_post_field('post_date', $object_id); |
|
332 | 330 | |
333 | 331 | |
334 | 332 | // Currency. |
335 | - $payment_meta['currency'] = ! empty( $payment_meta['_give_payment_currency'] ) ? $payment_meta['_give_payment_currency'] : ''; |
|
333 | + $payment_meta['currency'] = ! empty($payment_meta['_give_payment_currency']) ? $payment_meta['_give_payment_currency'] : ''; |
|
336 | 334 | |
337 | 335 | // Decode donor data. |
338 | - $donor_id = ! empty( $payment_meta['_give_payment_donor_id'] ) ? $payment_meta['_give_payment_donor_id'] : 0; |
|
339 | - $donor = new Give_Donor( $donor_id ); |
|
336 | + $donor_id = ! empty($payment_meta['_give_payment_donor_id']) ? $payment_meta['_give_payment_donor_id'] : 0; |
|
337 | + $donor = new Give_Donor($donor_id); |
|
340 | 338 | |
341 | 339 | // Donor first name. |
342 | - $donor_data['first_name'] = ! empty( $payment_meta['_give_donor_billing_first_name'] ) ? $payment_meta['_give_donor_billing_first_name'] : ''; |
|
343 | - $donor_data['first_name'] = ! empty( $donor_data['first_name'] ) ? |
|
344 | - $donor_data['first_name'] : |
|
345 | - $donor->get_first_name(); |
|
340 | + $donor_data['first_name'] = ! empty($payment_meta['_give_donor_billing_first_name']) ? $payment_meta['_give_donor_billing_first_name'] : ''; |
|
341 | + $donor_data['first_name'] = ! empty($donor_data['first_name']) ? |
|
342 | + $donor_data['first_name'] : $donor->get_first_name(); |
|
346 | 343 | |
347 | 344 | // Donor last name. |
348 | - $donor_data['last_name'] = ! empty( $payment_meta['_give_donor_billing_last_name'] ) ? $payment_meta['_give_donor_billing_last_name'] : ''; |
|
349 | - $donor_data['last_name'] = ! empty( $donor_data['last_name'] ) ? |
|
350 | - $donor_data['last_name'] : |
|
351 | - $donor->get_last_name(); |
|
345 | + $donor_data['last_name'] = ! empty($payment_meta['_give_donor_billing_last_name']) ? $payment_meta['_give_donor_billing_last_name'] : ''; |
|
346 | + $donor_data['last_name'] = ! empty($donor_data['last_name']) ? |
|
347 | + $donor_data['last_name'] : $donor->get_last_name(); |
|
352 | 348 | |
353 | 349 | // Donor email. |
354 | 350 | $donor_data['email'] = $payment_meta['email']; |
@@ -359,63 +355,63 @@ discard block |
||
359 | 355 | $donor_data['address'] = false; |
360 | 356 | |
361 | 357 | // Address1. |
362 | - $address1 = ! empty( $payment_meta['_give_donor_billing_address1'] ) ? $payment_meta['_give_donor_billing_address1'] : ''; |
|
363 | - if ( $address1 ) { |
|
358 | + $address1 = ! empty($payment_meta['_give_donor_billing_address1']) ? $payment_meta['_give_donor_billing_address1'] : ''; |
|
359 | + if ($address1) { |
|
364 | 360 | $donor_data['address']['line1'] = $address1; |
365 | 361 | } |
366 | 362 | |
367 | 363 | // Address2. |
368 | - $address2 = ! empty( $payment_meta['_give_donor_billing_address2'] ) ? $payment_meta['_give_donor_billing_address2'] : ''; |
|
369 | - if ( $address2 ) { |
|
364 | + $address2 = ! empty($payment_meta['_give_donor_billing_address2']) ? $payment_meta['_give_donor_billing_address2'] : ''; |
|
365 | + if ($address2) { |
|
370 | 366 | $donor_data['address']['line2'] = $address2; |
371 | 367 | } |
372 | 368 | |
373 | 369 | // City. |
374 | - $city = ! empty( $payment_meta['_give_donor_billing_city'] ) ? $payment_meta['_give_donor_billing_city'] : ''; |
|
375 | - if ( $city ) { |
|
370 | + $city = ! empty($payment_meta['_give_donor_billing_city']) ? $payment_meta['_give_donor_billing_city'] : ''; |
|
371 | + if ($city) { |
|
376 | 372 | $donor_data['address']['city'] = $city; |
377 | 373 | } |
378 | 374 | |
379 | 375 | // Zip. |
380 | - $zip = ! empty( $payment_meta['_give_donor_billing_zip'] ) ? $payment_meta['_give_donor_billing_zip'] : ''; |
|
381 | - if ( $zip ) { |
|
376 | + $zip = ! empty($payment_meta['_give_donor_billing_zip']) ? $payment_meta['_give_donor_billing_zip'] : ''; |
|
377 | + if ($zip) { |
|
382 | 378 | $donor_data['address']['zip'] = $zip; |
383 | 379 | } |
384 | 380 | |
385 | 381 | // State. |
386 | - $state = ! empty( $payment_meta['_give_donor_billing_state'] ) ? $payment_meta['_give_donor_billing_state'] : ''; |
|
387 | - if ( $state ) { |
|
382 | + $state = ! empty($payment_meta['_give_donor_billing_state']) ? $payment_meta['_give_donor_billing_state'] : ''; |
|
383 | + if ($state) { |
|
388 | 384 | $donor_data['address']['state'] = $state; |
389 | 385 | } |
390 | 386 | |
391 | 387 | // Country. |
392 | - $country = ! empty( $payment_meta['_give_donor_billing_country'] ) ? $payment_meta['_give_donor_billing_country'] : ''; |
|
393 | - if ( $country ) { |
|
388 | + $country = ! empty($payment_meta['_give_donor_billing_country']) ? $payment_meta['_give_donor_billing_country'] : ''; |
|
389 | + if ($country) { |
|
394 | 390 | $donor_data['address']['country'] = $country; |
395 | 391 | } |
396 | 392 | |
397 | 393 | $payment_meta['user_info'] = $donor_data; |
398 | 394 | |
399 | 395 | // Add filter |
400 | - add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
396 | + add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
401 | 397 | |
402 | 398 | // Set custom meta key into payment meta. |
403 | - if ( ! empty( $payment_meta['_give_payment_meta'] ) ) { |
|
404 | - $payment_meta = array_merge( maybe_unserialize( $payment_meta['_give_payment_meta'] ), $payment_meta ); |
|
399 | + if ( ! empty($payment_meta['_give_payment_meta'])) { |
|
400 | + $payment_meta = array_merge(maybe_unserialize($payment_meta['_give_payment_meta']), $payment_meta); |
|
405 | 401 | } |
406 | 402 | |
407 | 403 | // Set cache. |
408 | - Give_Cache::set_db_query( $cache_key, $payment_meta ); |
|
404 | + Give_Cache::set_db_query($cache_key, $payment_meta); |
|
409 | 405 | } |
410 | 406 | |
411 | - if ( $single ) { |
|
407 | + if ($single) { |
|
412 | 408 | /** |
413 | 409 | * Filter the payment meta |
414 | 410 | * Add custom meta key to payment meta |
415 | 411 | * |
416 | 412 | * @since 2.0 |
417 | 413 | */ |
418 | - $new_payment_meta[0] = apply_filters( 'give_get_payment_meta', $payment_meta, $object_id, $meta_key ); |
|
414 | + $new_payment_meta[0] = apply_filters('give_get_payment_meta', $payment_meta, $object_id, $meta_key); |
|
419 | 415 | |
420 | 416 | $payment_meta = $new_payment_meta; |
421 | 417 | } |
@@ -423,7 +419,7 @@ discard block |
||
423 | 419 | return $payment_meta; |
424 | 420 | } |
425 | 421 | |
426 | -add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
422 | +add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
427 | 423 | |
428 | 424 | /** |
429 | 425 | * Add meta in payment that store page id and page url. |
@@ -435,19 +431,19 @@ discard block |
||
435 | 431 | * |
436 | 432 | * @param int $payment_id Payment id for which the meta value should be updated. |
437 | 433 | */ |
438 | -function give_payment_save_page_data( $payment_id ) { |
|
439 | - $page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false ); |
|
434 | +function give_payment_save_page_data($payment_id) { |
|
435 | + $page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false); |
|
440 | 436 | |
441 | 437 | // Check $page_url is not empty. |
442 | - if ( $page_url ) { |
|
443 | - update_post_meta( $payment_id, '_give_current_url', $page_url ); |
|
444 | - $page_id = url_to_postid( $page_url ); |
|
438 | + if ($page_url) { |
|
439 | + update_post_meta($payment_id, '_give_current_url', $page_url); |
|
440 | + $page_id = url_to_postid($page_url); |
|
445 | 441 | // Check $page_id is not empty. |
446 | - if ( $page_id ) { |
|
447 | - update_post_meta( $payment_id, '_give_current_page_id', $page_id ); |
|
442 | + if ($page_id) { |
|
443 | + update_post_meta($payment_id, '_give_current_page_id', $page_id); |
|
448 | 444 | } |
449 | 445 | } |
450 | 446 | } |
451 | 447 | |
452 | 448 | // Fire when payment is save. |
453 | -add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
454 | 449 | \ No newline at end of file |
450 | +add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
455 | 451 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -30,54 +30,54 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool|array List of all user donations. |
32 | 32 | */ |
33 | -function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
33 | +function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
34 | 34 | |
35 | - if ( empty( $user ) ) { |
|
35 | + if (empty($user)) { |
|
36 | 36 | $user = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | - $status = ( 'complete' === $status ) ? 'publish' : $status; |
|
43 | + $status = ('complete' === $status) ? 'publish' : $status; |
|
44 | 44 | $paged = 1; |
45 | 45 | |
46 | - if ( $pagination ) { |
|
47 | - if ( get_query_var( 'paged' ) ) { |
|
48 | - $paged = get_query_var( 'paged' ); |
|
49 | - } elseif ( get_query_var( 'page' ) ) { |
|
50 | - $paged = get_query_var( 'page' ); |
|
46 | + if ($pagination) { |
|
47 | + if (get_query_var('paged')) { |
|
48 | + $paged = get_query_var('paged'); |
|
49 | + } elseif (get_query_var('page')) { |
|
50 | + $paged = get_query_var('page'); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - $args = apply_filters( 'give_get_users_donations_args', array( |
|
54 | + $args = apply_filters('give_get_users_donations_args', array( |
|
55 | 55 | 'user' => $user, |
56 | 56 | 'number' => $number, |
57 | 57 | 'status' => $status, |
58 | 58 | 'orderby' => 'date', |
59 | - ) ); |
|
59 | + )); |
|
60 | 60 | |
61 | - if ( $pagination ) { |
|
61 | + if ($pagination) { |
|
62 | 62 | $args['page'] = $paged; |
63 | 63 | } else { |
64 | 64 | $args['nopaging'] = true; |
65 | 65 | } |
66 | 66 | |
67 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
68 | - $donor = new Give_Donor( $user, $by_user_id ); |
|
67 | + $by_user_id = is_numeric($user) ? true : false; |
|
68 | + $donor = new Give_Donor($user, $by_user_id); |
|
69 | 69 | |
70 | - if ( ! empty( $donor->payment_ids ) ) { |
|
70 | + if ( ! empty($donor->payment_ids)) { |
|
71 | 71 | |
72 | - unset( $args['user'] ); |
|
73 | - $args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) ); |
|
72 | + unset($args['user']); |
|
73 | + $args['post__in'] = array_map('absint', explode(',', $donor->payment_ids)); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | - $donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
77 | + $donations = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
78 | 78 | |
79 | 79 | // No donations. |
80 | - if ( ! $donations ) { |
|
80 | + if ( ! $donations) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | |
@@ -96,65 +96,65 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return bool|object List of unique forms donated by user |
98 | 98 | */ |
99 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
100 | - if ( empty( $user ) ) { |
|
99 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
100 | + if (empty($user)) { |
|
101 | 101 | $user = get_current_user_id(); |
102 | 102 | } |
103 | 103 | |
104 | - if ( empty( $user ) ) { |
|
104 | + if (empty($user)) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | |
108 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
108 | + $by_user_id = is_numeric($user) ? true : false; |
|
109 | 109 | |
110 | - $donor = new Give_Donor( $user, $by_user_id ); |
|
110 | + $donor = new Give_Donor($user, $by_user_id); |
|
111 | 111 | |
112 | - if ( empty( $donor->payment_ids ) ) { |
|
112 | + if (empty($donor->payment_ids)) { |
|
113 | 113 | return false; |
114 | 114 | } |
115 | 115 | |
116 | 116 | // Get all the items donated. |
117 | - $payment_ids = array_reverse( explode( ',', $donor->payment_ids ) ); |
|
118 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
119 | - if ( ! empty( $limit_payments ) ) { |
|
120 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
117 | + $payment_ids = array_reverse(explode(',', $donor->payment_ids)); |
|
118 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
119 | + if ( ! empty($limit_payments)) { |
|
120 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
121 | 121 | } |
122 | 122 | $donation_data = array(); |
123 | - foreach ( $payment_ids as $payment_id ) { |
|
124 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
123 | + foreach ($payment_ids as $payment_id) { |
|
124 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( empty( $donation_data ) ) { |
|
127 | + if (empty($donation_data)) { |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // Grab only the post ids "form_id" of the forms donated on this order. |
132 | 132 | $completed_donations_ids = array(); |
133 | - foreach ( $donation_data as $donation_meta ) { |
|
134 | - $completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : ''; |
|
133 | + foreach ($donation_data as $donation_meta) { |
|
134 | + $completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : ''; |
|
135 | 135 | } |
136 | 136 | |
137 | - if ( empty( $completed_donations_ids ) ) { |
|
137 | + if (empty($completed_donations_ids)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | // Only include each donation once. |
142 | - $form_ids = array_unique( $completed_donations_ids ); |
|
142 | + $form_ids = array_unique($completed_donations_ids); |
|
143 | 143 | |
144 | 144 | // Make sure we still have some products and a first item. |
145 | - if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
145 | + if (empty($form_ids) || ! isset($form_ids[0])) { |
|
146 | 146 | return false; |
147 | 147 | } |
148 | 148 | |
149 | - $post_type = get_post_type( $form_ids[0] ); |
|
149 | + $post_type = get_post_type($form_ids[0]); |
|
150 | 150 | |
151 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
151 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
152 | 152 | 'include' => $form_ids, |
153 | 153 | 'post_type' => $post_type, |
154 | - 'posts_per_page' => - 1, |
|
155 | - ) ); |
|
154 | + 'posts_per_page' => -1, |
|
155 | + )); |
|
156 | 156 | |
157 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
157 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return bool True if has donated, false other wise. |
172 | 172 | */ |
173 | -function give_has_donations( $user_id = null ) { |
|
174 | - if ( empty( $user_id ) ) { |
|
173 | +function give_has_donations($user_id = null) { |
|
174 | + if (empty($user_id)) { |
|
175 | 175 | $user_id = get_current_user_id(); |
176 | 176 | } |
177 | 177 | |
178 | - if ( give_get_users_donations( $user_id, 1 ) ) { |
|
178 | + if (give_get_users_donations($user_id, 1)) { |
|
179 | 179 | return true; // User has at least one donation. |
180 | 180 | } |
181 | 181 | |
@@ -196,23 +196,23 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return array |
198 | 198 | */ |
199 | -function give_get_donation_stats_by_user( $user = '' ) { |
|
199 | +function give_get_donation_stats_by_user($user = '') { |
|
200 | 200 | |
201 | 201 | $field = ''; |
202 | 202 | |
203 | - if ( is_email( $user ) ) { |
|
203 | + if (is_email($user)) { |
|
204 | 204 | $field = 'email'; |
205 | - } elseif ( is_numeric( $user ) ) { |
|
205 | + } elseif (is_numeric($user)) { |
|
206 | 206 | $field = 'user_id'; |
207 | 207 | } |
208 | 208 | |
209 | - $stats = array(); |
|
210 | - $donor = Give()->donors->get_donor_by( $field, $user ); |
|
209 | + $stats = array(); |
|
210 | + $donor = Give()->donors->get_donor_by($field, $user); |
|
211 | 211 | |
212 | - if ( $donor ) { |
|
213 | - $donor = new Give_Donor( $donor->id ); |
|
214 | - $stats['purchases'] = absint( $donor->purchase_count ); |
|
215 | - $stats['total_spent'] = give_maybe_sanitize_amount( $donor->get_total_donation_amount() ); |
|
212 | + if ($donor) { |
|
213 | + $donor = new Give_Donor($donor->id); |
|
214 | + $stats['purchases'] = absint($donor->purchase_count); |
|
215 | + $stats['total_spent'] = give_maybe_sanitize_amount($donor->get_total_donation_amount()); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @since 1.7 |
222 | 222 | */ |
223 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
223 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
224 | 224 | |
225 | 225 | return $stats; |
226 | 226 | } |
@@ -238,21 +238,21 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return int The total number of donations. |
240 | 240 | */ |
241 | -function give_count_donations_of_donor( $user = null ) { |
|
241 | +function give_count_donations_of_donor($user = null) { |
|
242 | 242 | |
243 | 243 | // Logged in? |
244 | - if ( empty( $user ) ) { |
|
244 | + if (empty($user)) { |
|
245 | 245 | $user = get_current_user_id(); |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Email access? |
249 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
249 | + if (empty($user) && Give()->email_access->token_email) { |
|
250 | 250 | $user = Give()->email_access->token_email; |
251 | 251 | } |
252 | 252 | |
253 | - $stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false; |
|
253 | + $stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false; |
|
254 | 254 | |
255 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
255 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return float The total amount the user has spent |
267 | 267 | */ |
268 | -function give_donation_total_of_user( $user = null ) { |
|
268 | +function give_donation_total_of_user($user = null) { |
|
269 | 269 | |
270 | - $stats = give_get_donation_stats_by_user( $user ); |
|
270 | + $stats = give_get_donation_stats_by_user($user); |
|
271 | 271 | |
272 | 272 | return $stats['total_spent']; |
273 | 273 | } |
@@ -283,40 +283,40 @@ discard block |
||
283 | 283 | * |
284 | 284 | * @return bool |
285 | 285 | */ |
286 | -function give_validate_username( $username, $form_id = 0 ) { |
|
286 | +function give_validate_username($username, $form_id = 0) { |
|
287 | 287 | $valid = true; |
288 | 288 | |
289 | 289 | // Validate username. |
290 | - if ( ! empty( $username ) ) { |
|
290 | + if ( ! empty($username)) { |
|
291 | 291 | |
292 | 292 | // Sanitize username. |
293 | - $sanitized_user_name = sanitize_user( $username, false ); |
|
293 | + $sanitized_user_name = sanitize_user($username, false); |
|
294 | 294 | |
295 | 295 | // We have an user name, check if it already exists. |
296 | - if ( username_exists( $username ) ) { |
|
296 | + if (username_exists($username)) { |
|
297 | 297 | // Username already registered. |
298 | - give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) ); |
|
298 | + give_set_error('username_unavailable', __('Username already taken.', 'give')); |
|
299 | 299 | $valid = false; |
300 | 300 | |
301 | 301 | // Check if it's valid. |
302 | - } elseif ( $sanitized_user_name !== $username ) { |
|
302 | + } elseif ($sanitized_user_name !== $username) { |
|
303 | 303 | // Invalid username. |
304 | - if ( is_multisite() ) { |
|
305 | - give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
304 | + if (is_multisite()) { |
|
305 | + give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
306 | 306 | $valid = false; |
307 | 307 | } else { |
308 | - give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) ); |
|
308 | + give_set_error('username_invalid', __('Invalid username.', 'give')); |
|
309 | 309 | $valid = false; |
310 | 310 | } |
311 | 311 | } |
312 | 312 | } else { |
313 | 313 | // Username is empty. |
314 | - give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) ); |
|
314 | + give_set_error('username_empty', __('Enter a username.', 'give')); |
|
315 | 315 | $valid = false; |
316 | 316 | |
317 | 317 | // Check if guest checkout is disable for form. |
318 | - if ( $form_id && give_logged_in_only( $form_id ) ) { |
|
319 | - give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
318 | + if ($form_id && give_logged_in_only($form_id)) { |
|
319 | + give_set_error('registration_required', __('You must register or login to complete your donation.', 'give')); |
|
320 | 320 | $valid = false; |
321 | 321 | } |
322 | 322 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @since 1.8 |
332 | 332 | */ |
333 | - $valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id ); |
|
333 | + $valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id); |
|
334 | 334 | |
335 | 335 | return $valid; |
336 | 336 | } |
@@ -346,30 +346,30 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @return bool |
348 | 348 | */ |
349 | -function give_validate_user_email( $email, $registering_new_user = false ) { |
|
349 | +function give_validate_user_email($email, $registering_new_user = false) { |
|
350 | 350 | $valid = true; |
351 | 351 | |
352 | - if ( empty( $email ) ) { |
|
352 | + if (empty($email)) { |
|
353 | 353 | // No email. |
354 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
354 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
355 | 355 | $valid = false; |
356 | 356 | |
357 | - } elseif ( email_exists( $email ) ) { |
|
357 | + } elseif (email_exists($email)) { |
|
358 | 358 | // Email already exists. |
359 | - give_set_error( 'email_exists', __( 'Email already exists.', 'give' ) ); |
|
359 | + give_set_error('email_exists', __('Email already exists.', 'give')); |
|
360 | 360 | $valid = false; |
361 | 361 | |
362 | - } elseif ( ! is_email( $email ) ) { |
|
362 | + } elseif ( ! is_email($email)) { |
|
363 | 363 | // Validate email. |
364 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
364 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
365 | 365 | $valid = false; |
366 | 366 | |
367 | - } elseif ( $registering_new_user ) { |
|
367 | + } elseif ($registering_new_user) { |
|
368 | 368 | |
369 | 369 | // If donor email is not primary. |
370 | - if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) { |
|
370 | + if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) { |
|
371 | 371 | // Check if email exists. |
372 | - give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) ); |
|
372 | + give_set_error('email_used', __('The email address provided is already active for another user.', 'give')); |
|
373 | 373 | $valid = false; |
374 | 374 | } |
375 | 375 | } |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * |
384 | 384 | * @since 1.8 |
385 | 385 | */ |
386 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user ); |
|
386 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user); |
|
387 | 387 | |
388 | 388 | return $valid; |
389 | 389 | } |
@@ -399,34 +399,34 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return bool |
401 | 401 | */ |
402 | -function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) { |
|
402 | +function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) { |
|
403 | 403 | $valid = true; |
404 | 404 | |
405 | 405 | // Passwords Validation For New Donors Only. |
406 | - if ( $registering_new_user ) { |
|
406 | + if ($registering_new_user) { |
|
407 | 407 | // Password or confirmation missing. |
408 | - if ( ! $password ) { |
|
408 | + if ( ! $password) { |
|
409 | 409 | // The password is invalid. |
410 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
410 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
411 | 411 | $valid = false; |
412 | - } elseif ( ! $confirm_password ) { |
|
412 | + } elseif ( ! $confirm_password) { |
|
413 | 413 | // Confirmation password is invalid. |
414 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) ); |
|
414 | + give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give')); |
|
415 | 415 | $valid = false; |
416 | 416 | } |
417 | 417 | } |
418 | 418 | // Passwords Validation For New Donors as well as Existing Donors. |
419 | - if ( $password || $confirm_password ) { |
|
420 | - if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) { |
|
419 | + if ($password || $confirm_password) { |
|
420 | + if (strlen($password) < 6 || strlen($confirm_password) < 6) { |
|
421 | 421 | // Seems Weak Password. |
422 | - give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) ); |
|
422 | + give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give')); |
|
423 | 423 | $valid = false; |
424 | 424 | } |
425 | - if ( $password && $confirm_password ) { |
|
425 | + if ($password && $confirm_password) { |
|
426 | 426 | // Verify confirmation matches. |
427 | - if ( $password !== $confirm_password ) { |
|
427 | + if ($password !== $confirm_password) { |
|
428 | 428 | // Passwords do not match. |
429 | - give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) ); |
|
429 | + give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give')); |
|
430 | 430 | $valid = false; |
431 | 431 | } |
432 | 432 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @since 1.8 |
444 | 444 | */ |
445 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user ); |
|
445 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); |
|
446 | 446 | |
447 | 447 | return $valid; |
448 | 448 | } |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | * |
472 | 472 | * @return array The donor's address, if any |
473 | 473 | */ |
474 | -function give_get_donor_address( $donor_id = null, $args = array() ) { |
|
475 | - if ( empty( $donor_id ) ) { |
|
474 | +function give_get_donor_address($donor_id = null, $args = array()) { |
|
475 | + if (empty($donor_id)) { |
|
476 | 476 | $donor_id = get_current_user_id(); |
477 | 477 | } |
478 | 478 | |
@@ -493,34 +493,34 @@ discard block |
||
493 | 493 | ); |
494 | 494 | |
495 | 495 | // Backward compatibility for user id param. |
496 | - $by_user_id = get_user_by( 'id', $donor_id ) ? true : false; |
|
496 | + $by_user_id = get_user_by('id', $donor_id) ? true : false; |
|
497 | 497 | |
498 | 498 | // Backward compatibility. |
499 | - if( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) && $by_user_id ){ |
|
499 | + if ( ! give_has_upgrade_completed('v20_upgrades_user_address') && $by_user_id) { |
|
500 | 500 | return wp_parse_args( |
501 | - (array) get_user_meta( $donor_id, '_give_user_address', true ), |
|
501 | + (array) get_user_meta($donor_id, '_give_user_address', true), |
|
502 | 502 | $default_address |
503 | 503 | ); |
504 | 504 | } |
505 | 505 | |
506 | - $donor = new Give_Donor( $donor_id, $by_user_id ); |
|
506 | + $donor = new Give_Donor($donor_id, $by_user_id); |
|
507 | 507 | |
508 | 508 | |
509 | 509 | if ( |
510 | 510 | ! $donor->id || |
511 | - empty( $donor->address ) || |
|
512 | - ! array_key_exists( $args['address_type'], $donor->address ) |
|
511 | + empty($donor->address) || |
|
512 | + ! array_key_exists($args['address_type'], $donor->address) |
|
513 | 513 | ) { |
514 | 514 | return $default_address; |
515 | 515 | } |
516 | 516 | |
517 | - switch ( true ){ |
|
518 | - case is_string( end( $donor->address[ $args['address_type'] ] ) ) : |
|
519 | - $address = wp_parse_args( $donor->address[ $args['address_type'] ], $default_address ); |
|
517 | + switch (true) { |
|
518 | + case is_string(end($donor->address[$args['address_type']])) : |
|
519 | + $address = wp_parse_args($donor->address[$args['address_type']], $default_address); |
|
520 | 520 | break; |
521 | 521 | |
522 | - case is_array( end( $donor->address[ $args['address_type'] ] ) ) : |
|
523 | - $address = wp_parse_args( array_shift( $donor->address[ $args['address_type'] ] ), $default_address ); |
|
522 | + case is_array(end($donor->address[$args['address_type']])) : |
|
523 | + $address = wp_parse_args(array_shift($donor->address[$args['address_type']]), $default_address); |
|
524 | 524 | break; |
525 | 525 | } |
526 | 526 | |
@@ -540,17 +540,17 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return void |
542 | 542 | */ |
543 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
543 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
544 | 544 | // Bailout. |
545 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
545 | + if (empty($user_id) || empty($user_data)) { |
|
546 | 546 | return; |
547 | 547 | } |
548 | 548 | |
549 | - do_action( 'give_new-donor-register_email_notification', $user_id, $user_data ); |
|
550 | - do_action( 'give_donor-register_email_notification', $user_id, $user_data ); |
|
549 | + do_action('give_new-donor-register_email_notification', $user_id, $user_data); |
|
550 | + do_action('give_donor-register_email_notification', $user_id, $user_data); |
|
551 | 551 | } |
552 | 552 | |
553 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
553 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
554 | 554 | |
555 | 555 | |
556 | 556 | /** |
@@ -566,33 +566,33 @@ discard block |
||
566 | 566 | * |
567 | 567 | * @return string |
568 | 568 | */ |
569 | -function give_get_donor_name_by( $id = 0, $from = 'donation' ) { |
|
569 | +function give_get_donor_name_by($id = 0, $from = 'donation') { |
|
570 | 570 | |
571 | 571 | // ID shouldn't be empty. |
572 | - if ( empty( $id ) ) { |
|
572 | + if (empty($id)) { |
|
573 | 573 | return ''; |
574 | 574 | } |
575 | 575 | |
576 | 576 | $name = ''; |
577 | 577 | |
578 | - switch ( $from ) { |
|
578 | + switch ($from) { |
|
579 | 579 | |
580 | 580 | case 'donation': |
581 | - $first_name = give_get_meta( $id, '_give_donor_billing_first_name', true ); |
|
582 | - $last_name = give_get_meta( $id, '_give_donor_billing_last_name', true ); |
|
581 | + $first_name = give_get_meta($id, '_give_donor_billing_first_name', true); |
|
582 | + $last_name = give_get_meta($id, '_give_donor_billing_last_name', true); |
|
583 | 583 | |
584 | - $name = trim( "{$first_name} {$last_name}" ); |
|
584 | + $name = trim("{$first_name} {$last_name}"); |
|
585 | 585 | |
586 | 586 | break; |
587 | 587 | |
588 | 588 | case 'donor': |
589 | - $name = Give()->donors->get_column( 'name', $id ); |
|
589 | + $name = Give()->donors->get_column('name', $id); |
|
590 | 590 | |
591 | 591 | break; |
592 | 592 | |
593 | 593 | } |
594 | 594 | |
595 | - return trim( $name ); |
|
595 | + return trim($name); |
|
596 | 596 | |
597 | 597 | } |
598 | 598 | |
@@ -605,8 +605,8 @@ discard block |
||
605 | 605 | * |
606 | 606 | * @return boolean The user's ID on success, and false on failure. |
607 | 607 | */ |
608 | -function give_donor_email_exists( $email ) { |
|
609 | - if ( Give()->donors->get_donor_by( 'email', $email ) ) { |
|
608 | +function give_donor_email_exists($email) { |
|
609 | + if (Give()->donors->get_donor_by('email', $email)) { |
|
610 | 610 | return true; |
611 | 611 | } |
612 | 612 | return false; |
@@ -621,14 +621,14 @@ discard block |
||
621 | 621 | * |
622 | 622 | * @return bool |
623 | 623 | */ |
624 | -function give_is_additional_email( $email ) { |
|
624 | +function give_is_additional_email($email) { |
|
625 | 625 | global $wpdb; |
626 | 626 | |
627 | 627 | $meta_table = Give()->donor_meta->table_name; |
628 | 628 | $meta_type = Give()->donor_meta->meta_type; |
629 | - $donor_id = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) ); |
|
629 | + $donor_id = $wpdb->get_var($wpdb->prepare("SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email)); |
|
630 | 630 | |
631 | - if ( empty( $donor_id ) ) { |
|
631 | + if (empty($donor_id)) { |
|
632 | 632 | return false; |
633 | 633 | } |
634 | 634 |