@@ -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,26 +25,26 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_load_scripts() { |
27 | 27 | |
28 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/'; |
|
29 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
30 | - $scripts_footer = ( give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ) ? true : false; |
|
28 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/frontend/'; |
|
29 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
30 | + $scripts_footer = (give_is_setting_enabled(give_get_option('scripts_footer'))) ? true : false; |
|
31 | 31 | |
32 | 32 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
33 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
33 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
34 | 34 | |
35 | 35 | // Localize / PHP to AJAX vars. |
36 | - $localize_give_vars = apply_filters( 'give_global_script_vars', array( |
|
36 | + $localize_give_vars = apply_filters('give_global_script_vars', array( |
|
37 | 37 | 'ajaxurl' => give_get_ajax_url(), |
38 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
38 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
39 | 39 | 'currency' => give_get_currency(), |
40 | - 'currency_sign' => give_currency_filter( '' ), |
|
40 | + 'currency_sign' => give_currency_filter(''), |
|
41 | 41 | 'currency_pos' => give_get_currency_position(), |
42 | 42 | 'thousands_separator' => give_get_price_thousand_separator(), |
43 | 43 | 'decimal_separator' => give_get_price_decimal_separator(), |
44 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), |
|
45 | - 'bad_minimum' => __( 'The minimum custom donation amount for this form is', 'give' ), |
|
46 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
47 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
44 | + 'no_gateway' => __('Please select a payment method.', 'give'), |
|
45 | + 'bad_minimum' => __('The minimum custom donation amount for this form is', 'give'), |
|
46 | + 'general_loading' => __('Loading...', 'give'), |
|
47 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
48 | 48 | 'number_decimals' => give_get_price_decimals(), |
49 | 49 | 'give_version' => GIVE_VERSION, |
50 | 50 | 'magnific_options' => apply_filters( |
@@ -58,83 +58,83 @@ discard block |
||
58 | 58 | 'give_form_translation_js', |
59 | 59 | array( |
60 | 60 | // Field name Validation message. |
61 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), |
|
62 | - 'give_first' => __( 'Please enter your first name.', 'give' ), |
|
63 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), |
|
64 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), |
|
65 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), |
|
66 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), |
|
67 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), |
|
61 | + 'payment-mode' => __('Please select payment mode.', 'give'), |
|
62 | + 'give_first' => __('Please enter your first name.', 'give'), |
|
63 | + 'give_email' => __('Please enter a valid email address.', 'give'), |
|
64 | + 'give_user_login' => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'), |
|
65 | + 'give_user_pass' => __('Enter a password.', 'give'), |
|
66 | + 'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'), |
|
67 | + 'give_agree_to_terms' => __('You must agree to the terms and conditions.', 'give'), |
|
68 | 68 | ) |
69 | 69 | ), |
70 | - 'confirm_email_sent_message' => __( 'Please check your email and click on the link to access your complete donation history.', 'give' ), |
|
71 | - ) ); |
|
70 | + 'confirm_email_sent_message' => __('Please check your email and click on the link to access your complete donation history.', 'give'), |
|
71 | + )); |
|
72 | 72 | |
73 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
73 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
74 | 74 | 'ajaxurl' => give_get_ajax_url(), |
75 | - 'ajaxNonce' => wp_create_nonce( 'give_ajax_nonce' ), |
|
76 | - 'loading' => __( 'Loading', 'give' ), |
|
75 | + 'ajaxNonce' => wp_create_nonce('give_ajax_nonce'), |
|
76 | + 'loading' => __('Loading', 'give'), |
|
77 | 77 | // General loading message. |
78 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
78 | + 'select_option' => __('Please select an option', 'give'), |
|
79 | 79 | // Variable pricing error with multi-donation option enabled. |
80 | - 'default_gateway' => give_get_default_gateway( null ), |
|
81 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
80 | + 'default_gateway' => give_get_default_gateway(null), |
|
81 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
82 | 82 | 'number_decimals' => give_get_price_decimals(), |
83 | - ) ); |
|
83 | + )); |
|
84 | 84 | |
85 | 85 | // DEBUG is On. |
86 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
86 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
87 | 87 | |
88 | - if ( give_is_cc_verify_enabled() ) { |
|
89 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
90 | - wp_enqueue_script( 'give-cc-validator' ); |
|
88 | + if (give_is_cc_verify_enabled()) { |
|
89 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
90 | + wp_enqueue_script('give-cc-validator'); |
|
91 | 91 | } |
92 | 92 | |
93 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
94 | - wp_enqueue_script( 'give-float-labels' ); |
|
93 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
94 | + wp_enqueue_script('give-float-labels'); |
|
95 | 95 | |
96 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
97 | - wp_enqueue_script( 'give-blockui' ); |
|
96 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
97 | + wp_enqueue_script('give-blockui'); |
|
98 | 98 | |
99 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
100 | - wp_enqueue_script( 'give-qtip' ); |
|
99 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
100 | + wp_enqueue_script('give-qtip'); |
|
101 | 101 | |
102 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
103 | - wp_enqueue_script( 'give-accounting' ); |
|
102 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
103 | + wp_enqueue_script('give-accounting'); |
|
104 | 104 | |
105 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
106 | - wp_enqueue_script( 'give-magnific' ); |
|
105 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
106 | + wp_enqueue_script('give-magnific'); |
|
107 | 107 | |
108 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-donations' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
109 | - wp_enqueue_script( 'give-checkout-global' ); |
|
108 | + wp_register_script('give-checkout-global', $js_dir.'give-donations'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
109 | + wp_enqueue_script('give-checkout-global'); |
|
110 | 110 | |
111 | 111 | // General scripts. |
112 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
113 | - wp_enqueue_script( 'give-scripts' ); |
|
112 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
113 | + wp_enqueue_script('give-scripts'); |
|
114 | 114 | |
115 | 115 | // Load AJAX scripts, if enabled. |
116 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
117 | - wp_enqueue_script( 'give-ajax' ); |
|
116 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
117 | + wp_enqueue_script('give-ajax'); |
|
118 | 118 | |
119 | 119 | // Localize / Pass AJAX vars from PHP, |
120 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars ); |
|
121 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
120 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars); |
|
121 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
122 | 122 | |
123 | 123 | } else { |
124 | 124 | |
125 | 125 | // DEBUG is OFF (one JS file to rule them all!). |
126 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
127 | - wp_enqueue_script( 'give' ); |
|
126 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
127 | + wp_enqueue_script('give'); |
|
128 | 128 | |
129 | 129 | // Localize / Pass AJAX vars from PHP. |
130 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
131 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
130 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
131 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
137 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Register styles. |
@@ -147,16 +147,16 @@ discard block |
||
147 | 147 | */ |
148 | 148 | function give_register_styles() { |
149 | 149 | |
150 | - if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
150 | + if ( ! give_is_setting_enabled(give_get_option('css'))) { |
|
151 | 151 | return; |
152 | 152 | } |
153 | 153 | |
154 | - wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
155 | - wp_enqueue_style( 'give-styles' ); |
|
154 | + wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
155 | + wp_enqueue_style('give-styles'); |
|
156 | 156 | |
157 | 157 | } |
158 | 158 | |
159 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
159 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
160 | 160 | |
161 | 161 | |
162 | 162 | /** |
@@ -169,19 +169,19 @@ discard block |
||
169 | 169 | function give_get_stylesheet_uri() { |
170 | 170 | |
171 | 171 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
172 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
172 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
173 | 173 | |
174 | 174 | // LTR or RTL files. |
175 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
175 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
176 | 176 | |
177 | - $file = 'give' . $direction . $suffix . '.css'; |
|
177 | + $file = 'give'.$direction.$suffix.'.css'; |
|
178 | 178 | $templates_dir = give_get_theme_template_dir_name(); |
179 | 179 | |
180 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
181 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
182 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
183 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
184 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
180 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
181 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css'; |
|
182 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
183 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css'; |
|
184 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
185 | 185 | |
186 | 186 | $uri = false; |
187 | 187 | |
@@ -191,23 +191,23 @@ discard block |
||
191 | 191 | * followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
192 | 192 | * This allows users to copy just give.css to their theme. |
193 | 193 | */ |
194 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
195 | - if ( ! empty( $nonmin ) ) { |
|
196 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
194 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
195 | + if ( ! empty($nonmin)) { |
|
196 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
197 | 197 | } else { |
198 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
198 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
199 | 199 | } |
200 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
201 | - if ( ! empty( $nonmin ) ) { |
|
202 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
200 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
201 | + if ( ! empty($nonmin)) { |
|
202 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
203 | 203 | } else { |
204 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
204 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
205 | 205 | } |
206 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
207 | - $uri = trailingslashit( give_get_templates_url() ) . $file; |
|
206 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
207 | + $uri = trailingslashit(give_get_templates_url()).$file; |
|
208 | 208 | } |
209 | 209 | |
210 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
210 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
211 | 211 | |
212 | 212 | } |
213 | 213 | |
@@ -224,79 +224,79 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return void |
226 | 226 | */ |
227 | -function give_load_admin_scripts( $hook ) { |
|
227 | +function give_load_admin_scripts($hook) { |
|
228 | 228 | |
229 | 229 | global $post, $post_type; |
230 | 230 | |
231 | 231 | $give_options = give_get_settings(); |
232 | 232 | |
233 | 233 | // Directories of assets. |
234 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
235 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
236 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
234 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
235 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
236 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
237 | 237 | |
238 | 238 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
239 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
239 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
240 | 240 | |
241 | 241 | // LTR or RTL files. |
242 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
242 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
243 | 243 | |
244 | 244 | // Global Admin. |
245 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
246 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
245 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
246 | + wp_enqueue_style('give-admin-bar-notification'); |
|
247 | 247 | |
248 | 248 | // Give Admin Only. |
249 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
249 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
250 | 250 | return; |
251 | 251 | } |
252 | 252 | |
253 | 253 | // CSS. |
254 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
255 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
256 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION ); |
|
257 | - wp_enqueue_style( 'give-admin' ); |
|
258 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
259 | - wp_enqueue_style( 'jquery-chosen' ); |
|
260 | - wp_enqueue_style( 'thickbox' ); |
|
261 | - wp_enqueue_style( 'wp-color-picker' ); |
|
254 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
255 | + wp_enqueue_style('jquery-ui-css'); |
|
256 | + wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION); |
|
257 | + wp_enqueue_style('give-admin'); |
|
258 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
259 | + wp_enqueue_style('jquery-chosen'); |
|
260 | + wp_enqueue_style('thickbox'); |
|
261 | + wp_enqueue_style('wp-color-picker'); |
|
262 | 262 | |
263 | 263 | |
264 | 264 | // JS. |
265 | - wp_register_script( 'give-selector-cache', $js_plugins . 'selector-cache' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
266 | - wp_enqueue_script( 'give-selector-cache' ); |
|
265 | + wp_register_script('give-selector-cache', $js_plugins.'selector-cache'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
266 | + wp_enqueue_script('give-selector-cache'); |
|
267 | 267 | |
268 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
269 | - wp_enqueue_script( 'jquery-chosen' ); |
|
268 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
269 | + wp_enqueue_script('jquery-chosen'); |
|
270 | 270 | |
271 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
272 | - wp_enqueue_script( 'give-accounting' ); |
|
271 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
272 | + wp_enqueue_script('give-accounting'); |
|
273 | 273 | |
274 | - wp_enqueue_script( 'wp-color-picker' ); |
|
275 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
276 | - wp_enqueue_script( 'thickbox' ); |
|
274 | + wp_enqueue_script('wp-color-picker'); |
|
275 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
276 | + wp_enqueue_script('thickbox'); |
|
277 | 277 | |
278 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'wp-color-picker', 'jquery-query' ), GIVE_VERSION, false ); |
|
279 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
278 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery', 'jquery-ui-datepicker', 'wp-color-picker', 'jquery-query'), GIVE_VERSION, false); |
|
279 | + wp_enqueue_script('give-admin-scripts'); |
|
280 | 280 | |
281 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
282 | - wp_enqueue_script( 'jquery-flot' ); |
|
281 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
282 | + wp_enqueue_script('jquery-flot'); |
|
283 | 283 | |
284 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
285 | - wp_enqueue_script( 'give-qtip' ); |
|
284 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
285 | + wp_enqueue_script('give-qtip'); |
|
286 | 286 | |
287 | - wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
288 | - wp_enqueue_script( 'give-repeatable-fields' ); |
|
287 | + wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
288 | + wp_enqueue_script('give-repeatable-fields'); |
|
289 | 289 | |
290 | 290 | // Forms CPT Script. |
291 | - if ( $post_type === 'give_forms' ) { |
|
292 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
293 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
291 | + if ($post_type === 'give_forms') { |
|
292 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
293 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | // Settings Scripts. |
297 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) { |
|
298 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
299 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
297 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
298 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
299 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // Price Separators. |
@@ -304,87 +304,87 @@ discard block |
||
304 | 304 | $decimal_separator = give_get_price_decimal_separator(); |
305 | 305 | |
306 | 306 | // Localize strings & variables for JS. |
307 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
308 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
307 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
308 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
309 | 309 | 'give_version' => GIVE_VERSION, |
310 | 310 | 'thousands_separator' => $thousand_separator, |
311 | 311 | 'decimal_separator' => $decimal_separator, |
312 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
313 | - 'delete_payment' => __( 'Are you sure you want to delete this payment?', 'give' ), |
|
314 | - 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ), |
|
315 | - 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ), |
|
316 | - 'regenerate_api_key' => __( 'Are you sure you want to regenerate this API key?', 'give' ), |
|
317 | - 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ), |
|
318 | - 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ), |
|
319 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
320 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
321 | - 'currency_sign' => give_currency_filter( '' ), |
|
322 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
312 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
313 | + 'delete_payment' => __('Are you sure you want to delete this payment?', 'give'), |
|
314 | + 'delete_payment_note' => __('Are you sure you want to delete this note?', 'give'), |
|
315 | + 'revoke_api_key' => __('Are you sure you want to revoke this API key?', 'give'), |
|
316 | + 'regenerate_api_key' => __('Are you sure you want to regenerate this API key?', 'give'), |
|
317 | + 'resend_receipt' => __('Are you sure you want to resend the donation receipt?', 'give'), |
|
318 | + 'disconnect_user' => __('Are you sure you want to disconnect the user from this donor?', 'give'), |
|
319 | + 'one_option' => __('Choose a form', 'give'), |
|
320 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
321 | + 'currency_sign' => give_currency_filter(''), |
|
322 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
323 | 323 | 'currency_decimals' => give_get_price_decimals(), |
324 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
325 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
326 | - 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ), |
|
327 | - 'delete_test_donor' => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ), |
|
328 | - 'delete_import_donor' => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ), |
|
329 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
324 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
325 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
326 | + 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), |
|
327 | + 'delete_test_donor' => __('Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give'), |
|
328 | + 'delete_import_donor' => __('Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give'), |
|
329 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
330 | 330 | /* translators : %s: Donation form options metabox */ |
331 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this level?', 'give' ), |
|
332 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
333 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
334 | - 'search_placeholder' => __( 'Type to search all forms', 'give' ), |
|
335 | - 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ), |
|
336 | - 'search_placeholder_country' => __( 'Type to search all countries', 'give' ), |
|
337 | - 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ), |
|
338 | - 'remove_from_bulk_delete' => __( 'Remove from Bulk Delete', 'give' ), |
|
331 | + 'confirm_before_remove_row_text' => __('Do you want to delete this level?', 'give'), |
|
332 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
333 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
334 | + 'search_placeholder' => __('Type to search all forms', 'give'), |
|
335 | + 'search_placeholder_donor' => __('Type to search all donors', 'give'), |
|
336 | + 'search_placeholder_country' => __('Type to search all countries', 'give'), |
|
337 | + 'search_placeholder_state' => __('Type to search all states/provinces', 'give'), |
|
338 | + 'remove_from_bulk_delete' => __('Remove from Bulk Delete', 'give'), |
|
339 | 339 | 'donors_bulk_action' => array( |
340 | - 'no_donor_selected' => __( 'You must choose at least one or more donors to delete.', 'give' ), |
|
341 | - 'no_action_selected' => __( 'You must select a bulk action to proceed.', 'give' ), |
|
340 | + 'no_donor_selected' => __('You must choose at least one or more donors to delete.', 'give'), |
|
341 | + 'no_action_selected' => __('You must select a bulk action to proceed.', 'give'), |
|
342 | 342 | ), |
343 | 343 | 'donations_bulk_action' => array( |
344 | 344 | 'delete' => array( |
345 | - 'zero' => __( 'You must choose at least one or more donations to delete.', 'give' ), |
|
346 | - 'single' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
347 | - 'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
345 | + 'zero' => __('You must choose at least one or more donations to delete.', 'give'), |
|
346 | + 'single' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
347 | + 'multiple' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
348 | 348 | ), |
349 | 349 | 'resend-receipt' => array( |
350 | - 'zero' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
351 | - 'single' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
352 | - 'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
350 | + 'zero' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
351 | + 'single' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
352 | + 'multiple' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
353 | 353 | ), |
354 | 354 | 'set-to-status' => array( |
355 | - 'zero' => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ), |
|
356 | - 'single' => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ), |
|
357 | - 'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ), |
|
355 | + 'zero' => __('You must choose at least one or more donations to set status to {status}.', 'give'), |
|
356 | + 'single' => __('Are you sure you want to set status of this donation to {status}?', 'give'), |
|
357 | + 'multiple' => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'), |
|
358 | 358 | ), |
359 | 359 | ), |
360 | 360 | 'metabox_fields' => array( |
361 | 361 | 'media' => array( |
362 | - 'button_title' => __( 'Choose Image', 'give' ), |
|
362 | + 'button_title' => __('Choose Image', 'give'), |
|
363 | 363 | ), |
364 | 364 | 'file' => array( |
365 | - 'button_title' => __( 'Choose File', 'give' ), |
|
365 | + 'button_title' => __('Choose File', 'give'), |
|
366 | 366 | ), |
367 | 367 | ), |
368 | 368 | 'chosen' => array( |
369 | - 'no_results_msg' => __( 'No results match {search_term}', 'give' ), |
|
370 | - 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ), |
|
369 | + 'no_results_msg' => __('No results match {search_term}', 'give'), |
|
370 | + 'ajax_search_msg' => __('Searching results for match {search_term}', 'give'), |
|
371 | 371 | ), |
372 | - 'db_update_confirmation_msg_button' => __( 'Run Updates', 'give' ), |
|
373 | - 'db_update_confirmation_msg' => __( 'The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give' ), |
|
374 | - 'error_message' => __( 'Something went wrong kindly try again!', 'give' ), |
|
372 | + 'db_update_confirmation_msg_button' => __('Run Updates', 'give'), |
|
373 | + 'db_update_confirmation_msg' => __('The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give'), |
|
374 | + 'error_message' => __('Something went wrong kindly try again!', 'give'), |
|
375 | 375 | 'give_donation_import' => 'give_donation_import', |
376 | 376 | 'core_settings_import' => 'give_core_settings_import', |
377 | - 'setting_not_save_message' => __( 'Changes you made may not be saved.', 'give' ), |
|
378 | - ) ); |
|
377 | + 'setting_not_save_message' => __('Changes you made may not be saved.', 'give'), |
|
378 | + )); |
|
379 | 379 | |
380 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) { |
|
380 | + if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) { |
|
381 | 381 | // call for new media manager. |
382 | 382 | wp_enqueue_media(); |
383 | 383 | } |
384 | 384 | |
385 | 385 | } |
386 | 386 | |
387 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
387 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
388 | 388 | |
389 | 389 | /** |
390 | 390 | * Admin Give Icon |
@@ -399,13 +399,13 @@ discard block |
||
399 | 399 | ?> |
400 | 400 | <style type="text/css" media="screen"> |
401 | 401 | |
402 | - <?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?> |
|
402 | + <?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?> |
|
403 | 403 | @font-face { |
404 | 404 | font-family: 'give-icomoon'; |
405 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
406 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
407 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
408 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
405 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
406 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
407 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
408 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
409 | 409 | font-weight: normal; |
410 | 410 | font-style: normal; |
411 | 411 | } |
@@ -424,4 +424,4 @@ discard block |
||
424 | 424 | <?php |
425 | 425 | } |
426 | 426 | |
427 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
427 | +add_action('admin_head', 'give_admin_icon'); |
@@ -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 | |
@@ -139,32 +139,32 @@ discard block |
||
139 | 139 | * @param bool $_id_or_email |
140 | 140 | * @param bool $by_user_id |
141 | 141 | */ |
142 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
142 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
143 | 143 | |
144 | 144 | $this->db = Give()->donors; |
145 | 145 | |
146 | 146 | if ( |
147 | 147 | false === $_id_or_email |
148 | - || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) |
|
148 | + || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email)) |
|
149 | 149 | ) { |
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
153 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
153 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
154 | 154 | |
155 | - if ( is_numeric( $_id_or_email ) ) { |
|
155 | + if (is_numeric($_id_or_email)) { |
|
156 | 156 | $field = $by_user_id ? 'user_id' : 'id'; |
157 | 157 | } else { |
158 | 158 | $field = 'email'; |
159 | 159 | } |
160 | 160 | |
161 | - $donor = $this->db->get_donor_by( $field, $_id_or_email ); |
|
161 | + $donor = $this->db->get_donor_by($field, $_id_or_email); |
|
162 | 162 | |
163 | - if ( empty( $donor ) || ! is_object( $donor ) ) { |
|
163 | + if (empty($donor) || ! is_object($donor)) { |
|
164 | 164 | return false; |
165 | 165 | } |
166 | 166 | |
167 | - $this->setup_donor( $donor ); |
|
167 | + $this->setup_donor($donor); |
|
168 | 168 | |
169 | 169 | } |
170 | 170 | |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return bool If the setup was successful or not. |
182 | 182 | */ |
183 | - private function setup_donor( $donor ) { |
|
183 | + private function setup_donor($donor) { |
|
184 | 184 | |
185 | - if ( ! is_object( $donor ) ) { |
|
185 | + if ( ! is_object($donor)) { |
|
186 | 186 | return false; |
187 | 187 | } |
188 | 188 | |
189 | - foreach ( $donor as $key => $value ) { |
|
189 | + foreach ($donor as $key => $value) { |
|
190 | 190 | |
191 | - switch ( $key ) { |
|
191 | + switch ($key) { |
|
192 | 192 | |
193 | 193 | case 'notes': |
194 | 194 | $this->$key = $this->get_notes(); |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | } |
203 | 203 | |
204 | 204 | // Get donor's all email including primary email. |
205 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
206 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
205 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
206 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
207 | 207 | |
208 | 208 | // Donor ID and email are the only things that are necessary, make sure they exist. |
209 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
209 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
210 | 210 | return true; |
211 | 211 | } |
212 | 212 | |
@@ -223,16 +223,16 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return mixed|\WP_Error |
225 | 225 | */ |
226 | - public function __get( $key ) { |
|
226 | + public function __get($key) { |
|
227 | 227 | |
228 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
228 | + if (method_exists($this, 'get_'.$key)) { |
|
229 | 229 | |
230 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
230 | + return call_user_func(array($this, 'get_'.$key)); |
|
231 | 231 | |
232 | 232 | } else { |
233 | 233 | |
234 | 234 | /* translators: %s: property key */ |
235 | - return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
235 | + return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
236 | 236 | |
237 | 237 | } |
238 | 238 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return bool|int False if not a valid creation, donor ID if user is found or valid creation. |
250 | 250 | */ |
251 | - public function create( $data = array() ) { |
|
251 | + public function create($data = array()) { |
|
252 | 252 | |
253 | - if ( $this->id != 0 || empty( $data ) ) { |
|
253 | + if ($this->id != 0 || empty($data)) { |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | 'payment_ids' => '', |
259 | 259 | ); |
260 | 260 | |
261 | - $args = wp_parse_args( $data, $defaults ); |
|
262 | - $args = $this->sanitize_columns( $args ); |
|
261 | + $args = wp_parse_args($data, $defaults); |
|
262 | + $args = $this->sanitize_columns($args); |
|
263 | 263 | |
264 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
264 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
269 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
268 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
269 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -276,18 +276,18 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @param array $args Donor attributes. |
278 | 278 | */ |
279 | - do_action( 'give_donor_pre_create', $args ); |
|
279 | + do_action('give_donor_pre_create', $args); |
|
280 | 280 | |
281 | 281 | $created = false; |
282 | 282 | |
283 | 283 | // The DB class 'add' implies an update if the donor being asked to be created already exists |
284 | - if ( $this->db->add( $data ) ) { |
|
284 | + if ($this->db->add($data)) { |
|
285 | 285 | |
286 | 286 | // We've successfully added/updated the donor, reset the class vars with the new data |
287 | - $donor = $this->db->get_donor_by( 'email', $args['email'] ); |
|
287 | + $donor = $this->db->get_donor_by('email', $args['email']); |
|
288 | 288 | |
289 | 289 | // Setup the donor data with the values from DB |
290 | - $this->setup_donor( $donor ); |
|
290 | + $this->setup_donor($donor); |
|
291 | 291 | |
292 | 292 | $created = $this->id; |
293 | 293 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation. |
301 | 301 | * @param array $args Customer attributes. |
302 | 302 | */ |
303 | - do_action( 'give_donor_post_create', $created, $args ); |
|
303 | + do_action('give_donor_post_create', $created, $args); |
|
304 | 304 | |
305 | 305 | return $created; |
306 | 306 | |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @return bool If the update was successful or not. |
318 | 318 | */ |
319 | - public function update( $data = array() ) { |
|
319 | + public function update($data = array()) { |
|
320 | 320 | |
321 | - if ( empty( $data ) ) { |
|
321 | + if (empty($data)) { |
|
322 | 322 | return false; |
323 | 323 | } |
324 | 324 | |
325 | - $data = $this->sanitize_columns( $data ); |
|
325 | + $data = $this->sanitize_columns($data); |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Fires before updating donors. |
@@ -332,14 +332,14 @@ discard block |
||
332 | 332 | * @param int $donor_id Donor id. |
333 | 333 | * @param array $data Donor attributes. |
334 | 334 | */ |
335 | - do_action( 'give_donor_pre_update', $this->id, $data ); |
|
335 | + do_action('give_donor_pre_update', $this->id, $data); |
|
336 | 336 | |
337 | 337 | $updated = false; |
338 | 338 | |
339 | - if ( $this->db->update( $this->id, $data ) ) { |
|
339 | + if ($this->db->update($this->id, $data)) { |
|
340 | 340 | |
341 | - $donor = $this->db->get_donor_by( 'id', $this->id ); |
|
342 | - $this->setup_donor( $donor ); |
|
341 | + $donor = $this->db->get_donor_by('id', $this->id); |
|
342 | + $this->setup_donor($donor); |
|
343 | 343 | |
344 | 344 | $updated = true; |
345 | 345 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @param int $donor_id Donor id. |
354 | 354 | * @param array $data Donor attributes. |
355 | 355 | */ |
356 | - do_action( 'give_donor_post_update', $updated, $this->id, $data ); |
|
356 | + do_action('give_donor_post_update', $updated, $this->id, $data); |
|
357 | 357 | |
358 | 358 | return $updated; |
359 | 359 | } |
@@ -371,27 +371,27 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return bool If the attachment was successfully. |
373 | 373 | */ |
374 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
374 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
375 | 375 | |
376 | - if ( empty( $payment_id ) ) { |
|
376 | + if (empty($payment_id)) { |
|
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | |
380 | - if ( empty( $this->payment_ids ) ) { |
|
380 | + if (empty($this->payment_ids)) { |
|
381 | 381 | |
382 | 382 | $new_payment_ids = $payment_id; |
383 | 383 | |
384 | 384 | } else { |
385 | 385 | |
386 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
386 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
387 | 387 | |
388 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
388 | + if (in_array($payment_id, $payment_ids)) { |
|
389 | 389 | $update_stats = false; |
390 | 390 | } |
391 | 391 | |
392 | 392 | $payment_ids[] = $payment_id; |
393 | 393 | |
394 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
394 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -403,20 +403,20 @@ discard block |
||
403 | 403 | * @param int $payment_id Payment id. |
404 | 404 | * @param int $donor_id Customer id. |
405 | 405 | */ |
406 | - do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id ); |
|
406 | + do_action('give_donor_pre_attach_payment', $payment_id, $this->id); |
|
407 | 407 | |
408 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
408 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
409 | 409 | |
410 | - if ( $payment_added ) { |
|
410 | + if ($payment_added) { |
|
411 | 411 | |
412 | 412 | $this->payment_ids = $new_payment_ids; |
413 | 413 | |
414 | 414 | // We added this payment successfully, increment the stats |
415 | - if ( $update_stats ) { |
|
416 | - $payment_amount = give_donation_amount( $payment_id ); |
|
415 | + if ($update_stats) { |
|
416 | + $payment_amount = give_donation_amount($payment_id); |
|
417 | 417 | |
418 | - if ( ! empty( $payment_amount ) ) { |
|
419 | - $this->increase_value( $payment_amount ); |
|
418 | + if ( ! empty($payment_amount)) { |
|
419 | + $this->increase_value($payment_amount); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | $this->increase_purchase_count(); |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @param int $payment_id Payment id. |
433 | 433 | * @param int $donor_id Donor id. |
434 | 434 | */ |
435 | - do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
435 | + do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
436 | 436 | |
437 | 437 | return $payment_added; |
438 | 438 | } |
@@ -450,33 +450,33 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @return boolean If the removal was successful. |
452 | 452 | */ |
453 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
453 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
454 | 454 | |
455 | - if ( empty( $payment_id ) ) { |
|
455 | + if (empty($payment_id)) { |
|
456 | 456 | return false; |
457 | 457 | } |
458 | 458 | |
459 | - $payment = new Give_Payment( $payment_id ); |
|
459 | + $payment = new Give_Payment($payment_id); |
|
460 | 460 | |
461 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
461 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
462 | 462 | $update_stats = false; |
463 | 463 | } |
464 | 464 | |
465 | 465 | $new_payment_ids = ''; |
466 | 466 | |
467 | - if ( ! empty( $this->payment_ids ) ) { |
|
467 | + if ( ! empty($this->payment_ids)) { |
|
468 | 468 | |
469 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
469 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
470 | 470 | |
471 | - $pos = array_search( $payment_id, $payment_ids ); |
|
472 | - if ( false === $pos ) { |
|
471 | + $pos = array_search($payment_id, $payment_ids); |
|
472 | + if (false === $pos) { |
|
473 | 473 | return false; |
474 | 474 | } |
475 | 475 | |
476 | - unset( $payment_ids[ $pos ] ); |
|
477 | - $payment_ids = array_filter( $payment_ids ); |
|
476 | + unset($payment_ids[$pos]); |
|
477 | + $payment_ids = array_filter($payment_ids); |
|
478 | 478 | |
479 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
479 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
480 | 480 | |
481 | 481 | } |
482 | 482 | |
@@ -488,20 +488,20 @@ discard block |
||
488 | 488 | * @param int $payment_id Payment id. |
489 | 489 | * @param int $donor_id Customer id. |
490 | 490 | */ |
491 | - do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id ); |
|
491 | + do_action('give_donor_pre_remove_payment', $payment_id, $this->id); |
|
492 | 492 | |
493 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
493 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
494 | 494 | |
495 | - if ( $payment_removed ) { |
|
495 | + if ($payment_removed) { |
|
496 | 496 | |
497 | 497 | $this->payment_ids = $new_payment_ids; |
498 | 498 | |
499 | - if ( $update_stats ) { |
|
499 | + if ($update_stats) { |
|
500 | 500 | // We removed this payment successfully, decrement the stats |
501 | - $payment_amount = give_donation_amount( $payment_id ); |
|
501 | + $payment_amount = give_donation_amount($payment_id); |
|
502 | 502 | |
503 | - if ( ! empty( $payment_amount ) ) { |
|
504 | - $this->decrease_value( $payment_amount ); |
|
503 | + if ( ! empty($payment_amount)) { |
|
504 | + $this->decrease_value($payment_amount); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | $this->decrease_donation_count(); |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * @param int $payment_id Payment id. |
518 | 518 | * @param int $donor_id Donor id. |
519 | 519 | */ |
520 | - do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
520 | + do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
521 | 521 | |
522 | 522 | return $payment_removed; |
523 | 523 | |
@@ -533,10 +533,10 @@ discard block |
||
533 | 533 | * |
534 | 534 | * @return int The donation count. |
535 | 535 | */ |
536 | - public function increase_purchase_count( $count = 1 ) { |
|
536 | + public function increase_purchase_count($count = 1) { |
|
537 | 537 | |
538 | 538 | // Make sure it's numeric and not negative. |
539 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
539 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
540 | 540 | return false; |
541 | 541 | } |
542 | 542 | |
@@ -550,9 +550,9 @@ discard block |
||
550 | 550 | * @param int $count The number to increase by. |
551 | 551 | * @param int $donor_id Donor id. |
552 | 552 | */ |
553 | - do_action( 'give_donor_pre_increase_donation_count', $count, $this->id ); |
|
553 | + do_action('give_donor_pre_increase_donation_count', $count, $this->id); |
|
554 | 554 | |
555 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
555 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
556 | 556 | $this->purchase_count = $new_total; |
557 | 557 | } |
558 | 558 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * @param int $count The number increased by. |
566 | 566 | * @param int $donor_id Donor id. |
567 | 567 | */ |
568 | - do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id ); |
|
568 | + do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id); |
|
569 | 569 | |
570 | 570 | return $this->purchase_count; |
571 | 571 | } |
@@ -580,16 +580,16 @@ discard block |
||
580 | 580 | * |
581 | 581 | * @return mixed If successful, the new count, otherwise false. |
582 | 582 | */ |
583 | - public function decrease_donation_count( $count = 1 ) { |
|
583 | + public function decrease_donation_count($count = 1) { |
|
584 | 584 | |
585 | 585 | // Make sure it's numeric and not negative |
586 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
586 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
587 | 587 | return false; |
588 | 588 | } |
589 | 589 | |
590 | 590 | $new_total = (int) $this->purchase_count - (int) $count; |
591 | 591 | |
592 | - if ( $new_total < 0 ) { |
|
592 | + if ($new_total < 0) { |
|
593 | 593 | $new_total = 0; |
594 | 594 | } |
595 | 595 | |
@@ -601,9 +601,9 @@ discard block |
||
601 | 601 | * @param int $count The number to decrease by. |
602 | 602 | * @param int $donor_id Customer id. |
603 | 603 | */ |
604 | - do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id ); |
|
604 | + do_action('give_donor_pre_decrease_donation_count', $count, $this->id); |
|
605 | 605 | |
606 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
606 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
607 | 607 | $this->purchase_count = $new_total; |
608 | 608 | } |
609 | 609 | |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | * @param int $count The number decreased by. |
617 | 617 | * @param int $donor_id Donor id. |
618 | 618 | */ |
619 | - do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id ); |
|
619 | + do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id); |
|
620 | 620 | |
621 | 621 | return $this->purchase_count; |
622 | 622 | } |
@@ -631,9 +631,9 @@ discard block |
||
631 | 631 | * |
632 | 632 | * @return mixed If successful, the new value, otherwise false. |
633 | 633 | */ |
634 | - public function increase_value( $value = 0.00 ) { |
|
634 | + public function increase_value($value = 0.00) { |
|
635 | 635 | |
636 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
636 | + $new_value = floatval($this->purchase_value) + $value; |
|
637 | 637 | |
638 | 638 | /** |
639 | 639 | * Fires before increasing donor lifetime value. |
@@ -643,9 +643,9 @@ discard block |
||
643 | 643 | * @param float $value The value to increase by. |
644 | 644 | * @param int $donor_id Customer id. |
645 | 645 | */ |
646 | - do_action( 'give_donor_pre_increase_value', $value, $this->id ); |
|
646 | + do_action('give_donor_pre_increase_value', $value, $this->id); |
|
647 | 647 | |
648 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
648 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
649 | 649 | $this->purchase_value = $new_value; |
650 | 650 | } |
651 | 651 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | * @param float $value The value increased by. |
659 | 659 | * @param int $donor_id Donor id. |
660 | 660 | */ |
661 | - do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
661 | + do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id); |
|
662 | 662 | |
663 | 663 | return $this->purchase_value; |
664 | 664 | } |
@@ -673,11 +673,11 @@ discard block |
||
673 | 673 | * |
674 | 674 | * @return mixed If successful, the new value, otherwise false. |
675 | 675 | */ |
676 | - public function decrease_value( $value = 0.00 ) { |
|
676 | + public function decrease_value($value = 0.00) { |
|
677 | 677 | |
678 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
678 | + $new_value = floatval($this->purchase_value) - $value; |
|
679 | 679 | |
680 | - if ( $new_value < 0 ) { |
|
680 | + if ($new_value < 0) { |
|
681 | 681 | $new_value = 0.00; |
682 | 682 | } |
683 | 683 | |
@@ -689,9 +689,9 @@ discard block |
||
689 | 689 | * @param float $value The value to decrease by. |
690 | 690 | * @param int $donor_id Donor id. |
691 | 691 | */ |
692 | - do_action( 'give_donor_pre_decrease_value', $value, $this->id ); |
|
692 | + do_action('give_donor_pre_decrease_value', $value, $this->id); |
|
693 | 693 | |
694 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
694 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
695 | 695 | $this->purchase_value = $new_value; |
696 | 696 | } |
697 | 697 | |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | * @param float $value The value decreased by. |
705 | 705 | * @param int $donor_id Donor id. |
706 | 706 | */ |
707 | - do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
707 | + do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
708 | 708 | |
709 | 709 | return $this->purchase_value; |
710 | 710 | } |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | * |
724 | 724 | * @return mixed If successful, the new donation stat value, otherwise false. |
725 | 725 | */ |
726 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
726 | + public function update_donation_value($curr_amount, $new_amount) { |
|
727 | 727 | /** |
728 | 728 | * Payment total difference value can be: |
729 | 729 | * zero (in case amount not change) |
@@ -733,15 +733,15 @@ discard block |
||
733 | 733 | $payment_total_diff = $new_amount - $curr_amount; |
734 | 734 | |
735 | 735 | // We do not need to update donation stat if donation did not change. |
736 | - if ( ! $payment_total_diff ) { |
|
736 | + if ( ! $payment_total_diff) { |
|
737 | 737 | return false; |
738 | 738 | } |
739 | 739 | |
740 | - if ( $payment_total_diff > 0 ) { |
|
741 | - $this->increase_value( $payment_total_diff ); |
|
740 | + if ($payment_total_diff > 0) { |
|
741 | + $this->increase_value($payment_total_diff); |
|
742 | 742 | } else { |
743 | 743 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
744 | - $this->decrease_value( - $payment_total_diff ); |
|
744 | + $this->decrease_value( -$payment_total_diff ); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | return $this->purchase_value; |
@@ -758,15 +758,15 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @return array The notes requested. |
760 | 760 | */ |
761 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
761 | + public function get_notes($length = 20, $paged = 1) { |
|
762 | 762 | |
763 | - $length = is_numeric( $length ) ? $length : 20; |
|
764 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
763 | + $length = is_numeric($length) ? $length : 20; |
|
764 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
765 | 765 | |
766 | 766 | $all_notes = $this->get_raw_notes(); |
767 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
767 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
768 | 768 | |
769 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
769 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
770 | 770 | |
771 | 771 | return $desired_notes; |
772 | 772 | |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | public function get_notes_count() { |
784 | 784 | |
785 | 785 | $all_notes = $this->get_raw_notes(); |
786 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
786 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
787 | 787 | |
788 | - return count( $notes_array ); |
|
788 | + return count($notes_array); |
|
789 | 789 | |
790 | 790 | } |
791 | 791 | |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | * |
799 | 799 | * @return string|float |
800 | 800 | */ |
801 | - public function get_total_donation_amount( $args = array() ) { |
|
801 | + public function get_total_donation_amount($args = array()) { |
|
802 | 802 | |
803 | 803 | /** |
804 | 804 | * Filter total donation amount. |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | * @param integer $donor_id Donor ID. |
810 | 810 | * @param array $args Pass additional data. |
811 | 811 | */ |
812 | - return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args ); |
|
812 | + return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args); |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | /** |
@@ -822,22 +822,22 @@ discard block |
||
822 | 822 | * |
823 | 823 | * @return string|boolean The new note if added successfully, false otherwise. |
824 | 824 | */ |
825 | - public function add_note( $note = '' ) { |
|
825 | + public function add_note($note = '') { |
|
826 | 826 | |
827 | - $note = trim( $note ); |
|
828 | - if ( empty( $note ) ) { |
|
827 | + $note = trim($note); |
|
828 | + if (empty($note)) { |
|
829 | 829 | return false; |
830 | 830 | } |
831 | 831 | |
832 | 832 | $notes = $this->get_raw_notes(); |
833 | 833 | |
834 | - if ( empty( $notes ) ) { |
|
834 | + if (empty($notes)) { |
|
835 | 835 | $notes = ''; |
836 | 836 | } |
837 | 837 | |
838 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
839 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
840 | - $notes .= "\n\n" . $new_note; |
|
838 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
839 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
840 | + $notes .= "\n\n".$new_note; |
|
841 | 841 | |
842 | 842 | /** |
843 | 843 | * Fires before donor note is added. |
@@ -847,11 +847,11 @@ discard block |
||
847 | 847 | * @param string $new_note New note to add. |
848 | 848 | * @param int $donor_id Donor id. |
849 | 849 | */ |
850 | - do_action( 'give_donor_pre_add_note', $new_note, $this->id ); |
|
850 | + do_action('give_donor_pre_add_note', $new_note, $this->id); |
|
851 | 851 | |
852 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
852 | + $updated = $this->update(array('notes' => $notes)); |
|
853 | 853 | |
854 | - if ( $updated ) { |
|
854 | + if ($updated) { |
|
855 | 855 | $this->notes = $this->get_notes(); |
856 | 856 | } |
857 | 857 | |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | * @param string $new_note New note added. |
865 | 865 | * @param int $donor_id Donor id. |
866 | 866 | */ |
867 | - do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id ); |
|
867 | + do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id); |
|
868 | 868 | |
869 | 869 | // Return the formatted note, so we can test, as well as update any displays |
870 | 870 | return $new_note; |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | */ |
882 | 882 | private function get_raw_notes() { |
883 | 883 | |
884 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
884 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
885 | 885 | |
886 | 886 | return $all_notes; |
887 | 887 | |
@@ -898,8 +898,8 @@ discard block |
||
898 | 898 | * |
899 | 899 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
900 | 900 | */ |
901 | - public function get_meta( $meta_key = '', $single = true ) { |
|
902 | - return Give()->donor_meta->get_meta( $this->id, $meta_key, $single ); |
|
901 | + public function get_meta($meta_key = '', $single = true) { |
|
902 | + return Give()->donor_meta->get_meta($this->id, $meta_key, $single); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | /** |
@@ -914,8 +914,8 @@ discard block |
||
914 | 914 | * |
915 | 915 | * @return bool False for failure. True for success. |
916 | 916 | */ |
917 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
918 | - return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
917 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
918 | + return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | /** |
@@ -930,8 +930,8 @@ discard block |
||
930 | 930 | * |
931 | 931 | * @return bool False on failure, true if success. |
932 | 932 | */ |
933 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
934 | - return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
933 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
934 | + return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | /** |
@@ -945,8 +945,8 @@ discard block |
||
945 | 945 | * |
946 | 946 | * @return bool False for failure. True for success. |
947 | 947 | */ |
948 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
949 | - return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
948 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
949 | + return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | /** |
@@ -959,51 +959,51 @@ discard block |
||
959 | 959 | * |
960 | 960 | * @return array The sanitized data, based off column defaults. |
961 | 961 | */ |
962 | - private function sanitize_columns( $data ) { |
|
962 | + private function sanitize_columns($data) { |
|
963 | 963 | |
964 | 964 | $columns = $this->db->get_columns(); |
965 | 965 | $default_values = $this->db->get_column_defaults(); |
966 | 966 | |
967 | - foreach ( $columns as $key => $type ) { |
|
967 | + foreach ($columns as $key => $type) { |
|
968 | 968 | |
969 | 969 | // Only sanitize data that we were provided |
970 | - if ( ! array_key_exists( $key, $data ) ) { |
|
970 | + if ( ! array_key_exists($key, $data)) { |
|
971 | 971 | continue; |
972 | 972 | } |
973 | 973 | |
974 | - switch ( $type ) { |
|
974 | + switch ($type) { |
|
975 | 975 | |
976 | 976 | case '%s': |
977 | - if ( 'email' == $key ) { |
|
978 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
979 | - } elseif ( 'notes' == $key ) { |
|
980 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
977 | + if ('email' == $key) { |
|
978 | + $data[$key] = sanitize_email($data[$key]); |
|
979 | + } elseif ('notes' == $key) { |
|
980 | + $data[$key] = strip_tags($data[$key]); |
|
981 | 981 | } else { |
982 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
982 | + $data[$key] = sanitize_text_field($data[$key]); |
|
983 | 983 | } |
984 | 984 | break; |
985 | 985 | |
986 | 986 | case '%d': |
987 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
988 | - $data[ $key ] = $default_values[ $key ]; |
|
987 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
988 | + $data[$key] = $default_values[$key]; |
|
989 | 989 | } else { |
990 | - $data[ $key ] = absint( $data[ $key ] ); |
|
990 | + $data[$key] = absint($data[$key]); |
|
991 | 991 | } |
992 | 992 | break; |
993 | 993 | |
994 | 994 | case '%f': |
995 | 995 | // Convert what was given to a float |
996 | - $value = floatval( $data[ $key ] ); |
|
996 | + $value = floatval($data[$key]); |
|
997 | 997 | |
998 | - if ( ! is_float( $value ) ) { |
|
999 | - $data[ $key ] = $default_values[ $key ]; |
|
998 | + if ( ! is_float($value)) { |
|
999 | + $data[$key] = $default_values[$key]; |
|
1000 | 1000 | } else { |
1001 | - $data[ $key ] = $value; |
|
1001 | + $data[$key] = $value; |
|
1002 | 1002 | } |
1003 | 1003 | break; |
1004 | 1004 | |
1005 | 1005 | default: |
1006 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
1006 | + $data[$key] = sanitize_text_field($data[$key]); |
|
1007 | 1007 | break; |
1008 | 1008 | |
1009 | 1009 | } |
@@ -1023,33 +1023,33 @@ discard block |
||
1023 | 1023 | * |
1024 | 1024 | * @return bool If the email was added successfully |
1025 | 1025 | */ |
1026 | - public function add_email( $email = '', $primary = false ) { |
|
1027 | - if ( ! is_email( $email ) ) { |
|
1026 | + public function add_email($email = '', $primary = false) { |
|
1027 | + if ( ! is_email($email)) { |
|
1028 | 1028 | return false; |
1029 | 1029 | } |
1030 | - $existing = new Give_Donor( $email ); |
|
1030 | + $existing = new Give_Donor($email); |
|
1031 | 1031 | |
1032 | - if ( $existing->id > 0 ) { |
|
1032 | + if ($existing->id > 0) { |
|
1033 | 1033 | // Email address already belongs to another donor |
1034 | 1034 | return false; |
1035 | 1035 | } |
1036 | 1036 | |
1037 | - if ( email_exists( $email ) ) { |
|
1038 | - $user = get_user_by( 'email', $email ); |
|
1039 | - if ( $user->ID != $this->user_id ) { |
|
1037 | + if (email_exists($email)) { |
|
1038 | + $user = get_user_by('email', $email); |
|
1039 | + if ($user->ID != $this->user_id) { |
|
1040 | 1040 | return false; |
1041 | 1041 | } |
1042 | 1042 | } |
1043 | 1043 | |
1044 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
1044 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
1045 | 1045 | |
1046 | 1046 | // Add is used to ensure duplicate emails are not added |
1047 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
1047 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
1048 | 1048 | |
1049 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
1049 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
1050 | 1050 | |
1051 | - if ( $ret && true === $primary ) { |
|
1052 | - $this->set_primary_email( $email ); |
|
1051 | + if ($ret && true === $primary) { |
|
1052 | + $this->set_primary_email($email); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | return $ret; |
@@ -1065,16 +1065,16 @@ discard block |
||
1065 | 1065 | * |
1066 | 1066 | * @return bool If the email was removed successfully. |
1067 | 1067 | */ |
1068 | - public function remove_email( $email = '' ) { |
|
1069 | - if ( ! is_email( $email ) ) { |
|
1068 | + public function remove_email($email = '') { |
|
1069 | + if ( ! is_email($email)) { |
|
1070 | 1070 | return false; |
1071 | 1071 | } |
1072 | 1072 | |
1073 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
1073 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
1074 | 1074 | |
1075 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
1075 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
1076 | 1076 | |
1077 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
1077 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
1078 | 1078 | |
1079 | 1079 | return $ret; |
1080 | 1080 | } |
@@ -1091,16 +1091,16 @@ discard block |
||
1091 | 1091 | * |
1092 | 1092 | * @return bool If the email was set as primary successfully. |
1093 | 1093 | */ |
1094 | - public function set_primary_email( $new_primary_email = '' ) { |
|
1095 | - if ( ! is_email( $new_primary_email ) ) { |
|
1094 | + public function set_primary_email($new_primary_email = '') { |
|
1095 | + if ( ! is_email($new_primary_email)) { |
|
1096 | 1096 | return false; |
1097 | 1097 | } |
1098 | 1098 | |
1099 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1099 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
1100 | 1100 | |
1101 | - $existing = new Give_Donor( $new_primary_email ); |
|
1101 | + $existing = new Give_Donor($new_primary_email); |
|
1102 | 1102 | |
1103 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
1103 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
1104 | 1104 | // This email belongs to another donor. |
1105 | 1105 | return false; |
1106 | 1106 | } |
@@ -1108,21 +1108,21 @@ discard block |
||
1108 | 1108 | $old_email = $this->email; |
1109 | 1109 | |
1110 | 1110 | // Update donor record with new email. |
1111 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
1111 | + $update = $this->update(array('email' => $new_primary_email)); |
|
1112 | 1112 | |
1113 | 1113 | // Remove new primary from list of additional emails. |
1114 | - $remove = $this->remove_email( $new_primary_email ); |
|
1114 | + $remove = $this->remove_email($new_primary_email); |
|
1115 | 1115 | |
1116 | 1116 | // Add old email to additional emails list. |
1117 | - $add = $this->add_email( $old_email ); |
|
1117 | + $add = $this->add_email($old_email); |
|
1118 | 1118 | |
1119 | 1119 | $ret = $update && $remove && $add; |
1120 | 1120 | |
1121 | - if ( $ret ) { |
|
1121 | + if ($ret) { |
|
1122 | 1122 | $this->email = $new_primary_email; |
1123 | 1123 | } |
1124 | 1124 | |
1125 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1125 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
1126 | 1126 | |
1127 | 1127 | return $ret; |
1128 | 1128 | } |
@@ -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,29 +90,29 @@ 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 | - if ( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
|
107 | - foreach ( $donations as $donation ) { |
|
108 | - give_update_meta( $donation, '_give_payment_user_id', $user_id ); |
|
106 | + if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) { |
|
107 | + foreach ($donations as $donation) { |
|
108 | + give_update_meta($donation, '_give_payment_user_id', $user_id); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
115 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
116 | 116 | |
117 | 117 | |
118 | 118 | /** |
@@ -126,45 +126,45 @@ discard block |
||
126 | 126 | */ |
127 | 127 | function give_validate_license_when_site_migrated() { |
128 | 128 | // Store current site address if not already stored. |
129 | - $home_url_parts = parse_url( home_url() ); |
|
130 | - $home_url = isset( $home_url_parts['host'] ) ? $home_url_parts['host'] : false; |
|
131 | - $home_url .= isset( $home_url_parts['path'] ) ? $home_url_parts['path'] : ''; |
|
132 | - $site_address_before_migrate = get_option( 'give_site_address_before_migrate' ); |
|
129 | + $home_url_parts = parse_url(home_url()); |
|
130 | + $home_url = isset($home_url_parts['host']) ? $home_url_parts['host'] : false; |
|
131 | + $home_url .= isset($home_url_parts['path']) ? $home_url_parts['path'] : ''; |
|
132 | + $site_address_before_migrate = get_option('give_site_address_before_migrate'); |
|
133 | 133 | |
134 | 134 | // Need $home_url to proceed. |
135 | - if ( ! $home_url ) { |
|
135 | + if ( ! $home_url) { |
|
136 | 136 | return; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Save site address. |
140 | - if ( ! $site_address_before_migrate ) { |
|
140 | + if ( ! $site_address_before_migrate) { |
|
141 | 141 | // Update site address. |
142 | - update_option( 'give_site_address_before_migrate', $home_url ); |
|
142 | + update_option('give_site_address_before_migrate', $home_url); |
|
143 | 143 | |
144 | 144 | return; |
145 | 145 | } |
146 | 146 | |
147 | 147 | // Backwards compat. for before when we were storing URL scheme. |
148 | - if ( strpos( $site_address_before_migrate, 'http' ) ) { |
|
149 | - $site_address_before_migrate = parse_url( $site_address_before_migrate ); |
|
150 | - $site_address_before_migrate = isset( $site_address_before_migrate['host'] ) ? $site_address_before_migrate['host'] : false; |
|
148 | + if (strpos($site_address_before_migrate, 'http')) { |
|
149 | + $site_address_before_migrate = parse_url($site_address_before_migrate); |
|
150 | + $site_address_before_migrate = isset($site_address_before_migrate['host']) ? $site_address_before_migrate['host'] : false; |
|
151 | 151 | |
152 | 152 | // Add path for multisite installs. |
153 | - $site_address_before_migrate .= isset( $site_address_before_migrate['path'] ) ? $site_address_before_migrate['path'] : ''; |
|
153 | + $site_address_before_migrate .= isset($site_address_before_migrate['path']) ? $site_address_before_migrate['path'] : ''; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | // If the two URLs don't match run CRON. |
157 | - if ( $home_url !== $site_address_before_migrate ) { |
|
157 | + if ($home_url !== $site_address_before_migrate) { |
|
158 | 158 | // Immediately run cron. |
159 | - wp_schedule_single_event( time(), 'give_validate_license_when_site_migrated' ); |
|
159 | + wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated'); |
|
160 | 160 | |
161 | 161 | // Update site address. |
162 | - update_option( 'give_site_address_before_migrate', $home_url ); |
|
162 | + update_option('give_site_address_before_migrate', $home_url); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | } |
166 | 166 | |
167 | -add_action( 'admin_init', 'give_validate_license_when_site_migrated' ); |
|
167 | +add_action('admin_init', 'give_validate_license_when_site_migrated'); |
|
168 | 168 | |
169 | 169 | |
170 | 170 | /** |
@@ -174,19 +174,19 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @param $data |
176 | 176 | */ |
177 | -function give_donor_batch_export_complete( $data ) { |
|
177 | +function give_donor_batch_export_complete($data) { |
|
178 | 178 | // Remove donor ids cache. |
179 | 179 | if ( |
180 | - isset( $data['class'] ) |
|
180 | + isset($data['class']) |
|
181 | 181 | && 'Give_Batch_Donors_Export' === $data['class'] |
182 | - && ! empty( $data['forms'] ) |
|
183 | - && isset( $data['give_export_option']['query_id'] ) |
|
182 | + && ! empty($data['forms']) |
|
183 | + && isset($data['give_export_option']['query_id']) |
|
184 | 184 | ) { |
185 | - Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) ); |
|
185 | + Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id'])); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | -add_action( 'give_file_export_complete', 'give_donor_batch_export_complete' ); |
|
189 | +add_action('give_file_export_complete', 'give_donor_batch_export_complete'); |
|
190 | 190 | |
191 | 191 | /** |
192 | 192 | * Print css for wordpress setting pages. |
@@ -197,12 +197,12 @@ discard block |
||
197 | 197 | /* @var WP_Screen $screen */ |
198 | 198 | $screen = get_current_screen(); |
199 | 199 | |
200 | - if ( ! ( $screen instanceof WP_Screen ) ) { |
|
200 | + if ( ! ($screen instanceof WP_Screen)) { |
|
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | |
204 | - switch ( true ) { |
|
205 | - case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ): |
|
204 | + switch (true) { |
|
205 | + case ('plugins' === $screen->base || 'plugins-network' === $screen->base): |
|
206 | 206 | ?> |
207 | 207 | <style> |
208 | 208 | tr.active.update + tr.give-addon-notice-tr td { |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
242 | -add_action( 'admin_head', 'give_admin_quick_css' ); |
|
242 | +add_action('admin_head', 'give_admin_quick_css'); |
|
243 | 243 | |
244 | 244 | |
245 | 245 | /** |
@@ -251,28 +251,28 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return void |
253 | 253 | */ |
254 | -function give_set_donation_levels_max_min_amount( $form_id ) { |
|
254 | +function give_set_donation_levels_max_min_amount($form_id) { |
|
255 | 255 | if ( |
256 | - ( 'set' === $_POST['_give_price_option'] ) || |
|
257 | - ( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) || |
|
258 | - ! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) ) |
|
256 | + ('set' === $_POST['_give_price_option']) || |
|
257 | + (in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) || |
|
258 | + ! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount')) |
|
259 | 259 | ) { |
260 | 260 | // Delete old meta. |
261 | - give_delete_meta( $form_id, '_give_levels_minimum_amount' ); |
|
262 | - give_delete_meta( $form_id, '_give_levels_maximum_amount' ); |
|
261 | + give_delete_meta($form_id, '_give_levels_minimum_amount'); |
|
262 | + give_delete_meta($form_id, '_give_levels_maximum_amount'); |
|
263 | 263 | |
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Sanitize donation level amounts. |
268 | - $donation_levels_amounts = array_map( 'give_maybe_sanitize_amount', $donation_levels_amounts ); |
|
268 | + $donation_levels_amounts = array_map('give_maybe_sanitize_amount', $donation_levels_amounts); |
|
269 | 269 | |
270 | - $min_amount = min( $donation_levels_amounts ); |
|
271 | - $max_amount = max( $donation_levels_amounts ); |
|
270 | + $min_amount = min($donation_levels_amounts); |
|
271 | + $max_amount = max($donation_levels_amounts); |
|
272 | 272 | |
273 | 273 | // Set Minimum and Maximum amount for Multi Level Donation Forms. |
274 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 ); |
|
275 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db( $max_amount ) : 0 ); |
|
274 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0); |
|
275 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0); |
|
276 | 276 | } |
277 | 277 | |
278 | -add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 ); |
|
279 | 278 | \ No newline at end of file |
279 | +add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30); |
|
280 | 280 | \ 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 | 43 | $status = $status === 'complete' ? '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 | * @param string $username |
331 | 331 | * @param bool $form_id |
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,25 +346,25 @@ 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 ( ! is_email( $email ) ) { |
|
357 | + } elseif ( ! is_email($email)) { |
|
358 | 358 | // Validate email. |
359 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
359 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
360 | 360 | $valid = false; |
361 | 361 | |
362 | - } elseif ( $registering_new_user ) { |
|
362 | + } elseif ($registering_new_user) { |
|
363 | 363 | |
364 | 364 | // If donor email is not primary |
365 | - if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) { |
|
365 | + if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) { |
|
366 | 366 | // Check if email exists. |
367 | - give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) ); |
|
367 | + give_set_error('email_used', __('The email address provided is already active for another user.', 'give')); |
|
368 | 368 | $valid = false; |
369 | 369 | } |
370 | 370 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @param string $email |
379 | 379 | * @param bool $registering_new_user |
380 | 380 | */ |
381 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user ); |
|
381 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user); |
|
382 | 382 | |
383 | 383 | return $valid; |
384 | 384 | } |
@@ -394,34 +394,34 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @return bool |
396 | 396 | */ |
397 | -function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) { |
|
397 | +function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) { |
|
398 | 398 | $valid = true; |
399 | 399 | |
400 | 400 | // Passwords Validation For New Donors Only |
401 | - if ( $registering_new_user ) { |
|
401 | + if ($registering_new_user) { |
|
402 | 402 | // Password or confirmation missing. |
403 | - if ( ! $password ) { |
|
403 | + if ( ! $password) { |
|
404 | 404 | // The password is invalid. |
405 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
405 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
406 | 406 | $valid = false; |
407 | - } elseif ( ! $confirm_password ) { |
|
407 | + } elseif ( ! $confirm_password) { |
|
408 | 408 | // Confirmation password is invalid. |
409 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) ); |
|
409 | + give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give')); |
|
410 | 410 | $valid = false; |
411 | 411 | } |
412 | 412 | } |
413 | 413 | // Passwords Validation For New Donors as well as Existing Donors |
414 | - if ( $password || $confirm_password ) { |
|
415 | - if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) { |
|
414 | + if ($password || $confirm_password) { |
|
415 | + if (strlen($password) < 6 || strlen($confirm_password) < 6) { |
|
416 | 416 | // Seems Weak Password |
417 | - give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) ); |
|
417 | + give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give')); |
|
418 | 418 | $valid = false; |
419 | 419 | } |
420 | - if ( $password && $confirm_password ) { |
|
420 | + if ($password && $confirm_password) { |
|
421 | 421 | // Verify confirmation matches. |
422 | - if ( $password != $confirm_password ) { |
|
422 | + if ($password != $confirm_password) { |
|
423 | 423 | // Passwords do not match |
424 | - give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) ); |
|
424 | + give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give')); |
|
425 | 425 | $valid = false; |
426 | 426 | } |
427 | 427 | } |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * @param string $confirm_password |
438 | 438 | * @param bool $registering_new_user |
439 | 439 | */ |
440 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user ); |
|
440 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); |
|
441 | 441 | |
442 | 442 | return $valid; |
443 | 443 | } |
@@ -455,20 +455,20 @@ discard block |
||
455 | 455 | * |
456 | 456 | * @return void |
457 | 457 | */ |
458 | -function give_add_past_donations_to_new_user( $user_id ) { |
|
458 | +function give_add_past_donations_to_new_user($user_id) { |
|
459 | 459 | |
460 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
460 | + $email = get_the_author_meta('user_email', $user_id); |
|
461 | 461 | |
462 | - $payments = give_get_payments( array( |
|
462 | + $payments = give_get_payments(array( |
|
463 | 463 | 'output' => 'payments', |
464 | 464 | 's' => $email, |
465 | - ) ); |
|
465 | + )); |
|
466 | 466 | |
467 | - if ( $payments ) { |
|
468 | - foreach ( $payments as $payment ) { |
|
467 | + if ($payments) { |
|
468 | + foreach ($payments as $payment) { |
|
469 | 469 | /* @var $payment \Give_Payment */ |
470 | 470 | |
471 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
471 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
472 | 472 | continue; |
473 | 473 | } |
474 | 474 | |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | |
481 | 481 | } |
482 | 482 | |
483 | -add_action( 'user_register', 'give_add_past_donations_to_new_user' ); |
|
483 | +add_action('user_register', 'give_add_past_donations_to_new_user'); |
|
484 | 484 | |
485 | 485 | |
486 | 486 | /** |
@@ -506,34 +506,34 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return array The donor's address, if any |
508 | 508 | */ |
509 | -function give_get_donor_address( $user_id = 0 ) { |
|
510 | - if ( empty( $user_id ) ) { |
|
509 | +function give_get_donor_address($user_id = 0) { |
|
510 | + if (empty($user_id)) { |
|
511 | 511 | $user_id = get_current_user_id(); |
512 | 512 | } |
513 | 513 | |
514 | - $address = (array) get_user_meta( $user_id, '_give_user_address', true ); |
|
514 | + $address = (array) get_user_meta($user_id, '_give_user_address', true); |
|
515 | 515 | |
516 | - if ( ! isset( $address['line1'] ) ) { |
|
516 | + if ( ! isset($address['line1'])) { |
|
517 | 517 | $address['line1'] = ''; |
518 | 518 | } |
519 | 519 | |
520 | - if ( ! isset( $address['line2'] ) ) { |
|
520 | + if ( ! isset($address['line2'])) { |
|
521 | 521 | $address['line2'] = ''; |
522 | 522 | } |
523 | 523 | |
524 | - if ( ! isset( $address['city'] ) ) { |
|
524 | + if ( ! isset($address['city'])) { |
|
525 | 525 | $address['city'] = ''; |
526 | 526 | } |
527 | 527 | |
528 | - if ( ! isset( $address['zip'] ) ) { |
|
528 | + if ( ! isset($address['zip'])) { |
|
529 | 529 | $address['zip'] = ''; |
530 | 530 | } |
531 | 531 | |
532 | - if ( ! isset( $address['country'] ) ) { |
|
532 | + if ( ! isset($address['country'])) { |
|
533 | 533 | $address['country'] = ''; |
534 | 534 | } |
535 | 535 | |
536 | - if ( ! isset( $address['state'] ) ) { |
|
536 | + if ( ! isset($address['state'])) { |
|
537 | 537 | $address['state'] = ''; |
538 | 538 | } |
539 | 539 | |
@@ -553,53 +553,53 @@ discard block |
||
553 | 553 | * |
554 | 554 | * @return void |
555 | 555 | */ |
556 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
556 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
557 | 557 | |
558 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
558 | + if (empty($user_id) || empty($user_data)) { |
|
559 | 559 | return; |
560 | 560 | } |
561 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
561 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
562 | 562 | |
563 | 563 | // New User Registration: Email sends to the site admin. |
564 | 564 | $emails = Give()->emails; |
565 | - $emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) ); |
|
565 | + $emails->__set('heading', esc_html__('New User Registration', 'give')); |
|
566 | 566 | |
567 | 567 | /* translators: %s: site name */ |
568 | - $message = sprintf( esc_attr__( 'A new user has registered on %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
568 | + $message = sprintf(esc_attr__('A new user has registered on %s:', 'give'), $blogname)."\r\n\r\n"; |
|
569 | 569 | /* translators: %s: user login */ |
570 | - $message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n"; |
|
570 | + $message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n"; |
|
571 | 571 | /* translators: %s: user email */ |
572 | - $message .= '<strong>' . esc_attr__( 'E-mail:', 'give' ) . '</strong> ' . $user_data['user_email'] . "\r\n\r\n"; |
|
572 | + $message .= '<strong>'.esc_attr__('E-mail:', 'give').'</strong> '.$user_data['user_email']."\r\n\r\n"; |
|
573 | 573 | |
574 | - $message .= '<a href="' . admin_url( 'user-edit.php?user_id=' . $user_id ) . '" target="_blank"> ' . esc_attr__( 'Click here to view »', 'give' ) . '</a>' . "\r\n"; |
|
574 | + $message .= '<a href="'.admin_url('user-edit.php?user_id='.$user_id).'" target="_blank"> '.esc_attr__('Click here to view »', 'give').'</a>'."\r\n"; |
|
575 | 575 | |
576 | 576 | $emails->send( |
577 | - get_option( 'admin_email' ), |
|
577 | + get_option('admin_email'), |
|
578 | 578 | sprintf( |
579 | 579 | /* translators: %s: site name */ |
580 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
580 | + esc_attr__('[%s] New User Registration', 'give'), |
|
581 | 581 | $blogname |
582 | 582 | ), |
583 | 583 | $message |
584 | 584 | ); |
585 | 585 | |
586 | 586 | // Account Information: Email sends to donor who registered. |
587 | - $emails->__set( 'heading', esc_html__( 'Account Information', 'give' ) ); |
|
587 | + $emails->__set('heading', esc_html__('Account Information', 'give')); |
|
588 | 588 | |
589 | - $message = sprintf( esc_attr__( 'The following email contains your account information for %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
589 | + $message = sprintf(esc_attr__('The following email contains your account information for %s:', 'give'), $blogname)."\r\n\r\n"; |
|
590 | 590 | |
591 | 591 | /* translators: %s: user login */ |
592 | - $message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n"; |
|
592 | + $message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n"; |
|
593 | 593 | /* translators: %s: password */ |
594 | - $message .= '<strong>' . esc_attr__( 'Password:', 'give' ) . '</strong> ' . esc_attr__( '[Password entered during donation]', 'give' ) . "\r\n\r\n"; |
|
594 | + $message .= '<strong>'.esc_attr__('Password:', 'give').'</strong> '.esc_attr__('[Password entered during donation]', 'give')."\r\n\r\n"; |
|
595 | 595 | |
596 | - $message .= '<a href="' . wp_login_url() . '" target="_blank"> ' . esc_attr__( 'Click here to login »', 'give' ) . '</a>' . "\r\n"; |
|
596 | + $message .= '<a href="'.wp_login_url().'" target="_blank"> '.esc_attr__('Click here to login »', 'give').'</a>'."\r\n"; |
|
597 | 597 | |
598 | 598 | $emails->send( |
599 | 599 | $user_data['user_email'], |
600 | 600 | sprintf( |
601 | 601 | /* translators: %s: site name */ |
602 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
602 | + esc_attr__('[%s] Your username and password', 'give'), |
|
603 | 603 | $blogname |
604 | 604 | ), |
605 | 605 | $message |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | |
608 | 608 | } |
609 | 609 | |
610 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
610 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
611 | 611 | |
612 | 612 | |
613 | 613 | /** |
@@ -623,34 +623,34 @@ discard block |
||
623 | 623 | * |
624 | 624 | * @return string |
625 | 625 | */ |
626 | -function give_get_donor_name_by( $id = 0, $from = 'donation' ) { |
|
626 | +function give_get_donor_name_by($id = 0, $from = 'donation') { |
|
627 | 627 | |
628 | 628 | // ID shouldn't be empty |
629 | - if ( empty( $id ) ) { |
|
629 | + if (empty($id)) { |
|
630 | 630 | return; |
631 | 631 | } |
632 | 632 | |
633 | 633 | $name = ''; |
634 | 634 | |
635 | - switch ( $from ) { |
|
635 | + switch ($from) { |
|
636 | 636 | |
637 | 637 | case 'donation': |
638 | 638 | |
639 | - $user_info = give_get_payment_meta_user_info( $id ); |
|
640 | - $name = trim( "{$user_info['first_name']} {$user_info['last_name']}" ); |
|
639 | + $user_info = give_get_payment_meta_user_info($id); |
|
640 | + $name = trim("{$user_info['first_name']} {$user_info['last_name']}"); |
|
641 | 641 | |
642 | 642 | break; |
643 | 643 | |
644 | 644 | case 'donor': |
645 | 645 | |
646 | - $donor = new Give_Donor( $id ); |
|
646 | + $donor = new Give_Donor($id); |
|
647 | 647 | $name = $donor->name; |
648 | 648 | |
649 | 649 | break; |
650 | 650 | |
651 | 651 | } |
652 | 652 | |
653 | - return trim( $name ); |
|
653 | + return trim($name); |
|
654 | 654 | |
655 | 655 | } |
656 | 656 | |
@@ -662,8 +662,8 @@ discard block |
||
662 | 662 | * @param string $email Donor Email. |
663 | 663 | * @return boolean The user's ID on success, and false on failure. |
664 | 664 | */ |
665 | -function give_donor_email_exists( $email ) { |
|
666 | - if ( Give()->donors->get_donor_by( 'email', $email ) ) { |
|
665 | +function give_donor_email_exists($email) { |
|
666 | + if (Give()->donors->get_donor_by('email', $email)) { |
|
667 | 667 | return true; |
668 | 668 | } |
669 | 669 | return false; |
@@ -678,12 +678,12 @@ discard block |
||
678 | 678 | * |
679 | 679 | * @return bool |
680 | 680 | */ |
681 | -function give_is_additional_email( $email ) { |
|
681 | +function give_is_additional_email($email) { |
|
682 | 682 | global $wpdb; |
683 | - $meta_table = Give()->donor_meta->table_name; |
|
684 | - $donor_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) ); |
|
683 | + $meta_table = Give()->donor_meta->table_name; |
|
684 | + $donor_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email)); |
|
685 | 685 | |
686 | - if ( empty( $donor_id ) ) { |
|
686 | + if (empty($donor_id)) { |
|
687 | 687 | return false; |
688 | 688 | } |
689 | 689 | return true; |
@@ -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 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
67 | 67 | */ |
68 | - public function __construct( $args = array() ) { |
|
68 | + public function __construct($args = array()) { |
|
69 | 69 | $defaults = array( |
70 | 70 | 'output' => 'payments', |
71 | - 'post_type' => array( 'give_payment' ), |
|
71 | + 'post_type' => array('give_payment'), |
|
72 | 72 | 'start_date' => false, |
73 | 73 | 'end_date' => false, |
74 | 74 | 'number' => 20, |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | 'give_forms' => null, |
91 | 91 | ); |
92 | 92 | |
93 | - $this->args = $this->_args = wp_parse_args( $args, $defaults ); |
|
93 | + $this->args = $this->_args = wp_parse_args($args, $defaults); |
|
94 | 94 | |
95 | 95 | $this->init(); |
96 | 96 | } |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | * @param $query_var |
105 | 105 | * @param $value |
106 | 106 | */ |
107 | - public function __set( $query_var, $value ) { |
|
108 | - if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) { |
|
109 | - $this->args[ $query_var ][] = $value; |
|
107 | + public function __set($query_var, $value) { |
|
108 | + if (in_array($query_var, array('meta_query', 'tax_query'))) { |
|
109 | + $this->args[$query_var][] = $value; |
|
110 | 110 | } else { |
111 | - $this->args[ $query_var ] = $value; |
|
111 | + $this->args[$query_var] = $value; |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @param $query_var |
122 | 122 | */ |
123 | - public function __unset( $query_var ) { |
|
124 | - unset( $this->args[ $query_var ] ); |
|
123 | + public function __unset($query_var) { |
|
124 | + unset($this->args[$query_var]); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $this->give_forms(); |
162 | 162 | $this->gateway_filter(); |
163 | 163 | |
164 | - add_filter( 'posts_orderby', array( $this, 'custom_orderby' ), 10, 2 ); |
|
164 | + add_filter('posts_orderby', array($this, 'custom_orderby'), 10, 2); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | private function unset_filters() { |
174 | 174 | $this->date_filter_post(); |
175 | - remove_filter( 'posts_orderby', array( $this, 'custom_orderby' ) ); |
|
175 | + remove_filter('posts_orderby', array($this, 'custom_orderby')); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @param Give_Payments_Query $this Payments query object. |
201 | 201 | */ |
202 | - do_action( 'give_pre_get_payments', $this ); |
|
202 | + do_action('give_pre_get_payments', $this); |
|
203 | 203 | |
204 | - $query = new WP_Query( $this->args ); |
|
204 | + $query = new WP_Query($this->args); |
|
205 | 205 | $this->payments = array(); |
206 | 206 | |
207 | 207 | $custom_output = array( |
@@ -209,18 +209,18 @@ discard block |
||
209 | 209 | 'give_payments', |
210 | 210 | ); |
211 | 211 | |
212 | - if ( ! in_array( $this->args['output'], $custom_output ) ) { |
|
212 | + if ( ! in_array($this->args['output'], $custom_output)) { |
|
213 | 213 | return $query->posts; |
214 | 214 | } |
215 | 215 | |
216 | - if ( $query->have_posts() ) { |
|
217 | - while ( $query->have_posts() ) { |
|
216 | + if ($query->have_posts()) { |
|
217 | + while ($query->have_posts()) { |
|
218 | 218 | $query->the_post(); |
219 | 219 | |
220 | 220 | $payment_id = get_post()->ID; |
221 | - $payment = new Give_Payment( $payment_id ); |
|
221 | + $payment = new Give_Payment($payment_id); |
|
222 | 222 | |
223 | - $this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this ); |
|
223 | + $this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | wp_reset_postdata(); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @param Give_Payments_Query $this Payments query object. |
238 | 238 | */ |
239 | - do_action( 'give_post_get_payments', $this ); |
|
239 | + do_action('give_post_get_payments', $this); |
|
240 | 240 | |
241 | 241 | return $this->payments; |
242 | 242 | } |
@@ -250,13 +250,13 @@ discard block |
||
250 | 250 | * @return void |
251 | 251 | */ |
252 | 252 | public function date_filter_pre() { |
253 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
253 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
254 | 254 | return; |
255 | 255 | } |
256 | 256 | |
257 | - $this->setup_dates( $this->args['start_date'], $this->args['end_date'] ); |
|
257 | + $this->setup_dates($this->args['start_date'], $this->args['end_date']); |
|
258 | 258 | |
259 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
259 | + add_filter('posts_where', array($this, 'payments_where')); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | * @return void |
270 | 270 | */ |
271 | 271 | public function date_filter_post() { |
272 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
272 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
276 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -285,12 +285,12 @@ discard block |
||
285 | 285 | * @return void |
286 | 286 | */ |
287 | 287 | public function status() { |
288 | - if ( ! isset( $this->args['status'] ) ) { |
|
288 | + if ( ! isset($this->args['status'])) { |
|
289 | 289 | return; |
290 | 290 | } |
291 | 291 | |
292 | - $this->__set( 'post_status', $this->args['status'] ); |
|
293 | - $this->__unset( 'status' ); |
|
292 | + $this->__set('post_status', $this->args['status']); |
|
293 | + $this->__unset('status'); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -302,12 +302,12 @@ discard block |
||
302 | 302 | * @return void |
303 | 303 | */ |
304 | 304 | public function page() { |
305 | - if ( ! isset( $this->args['page'] ) ) { |
|
305 | + if ( ! isset($this->args['page'])) { |
|
306 | 306 | return; |
307 | 307 | } |
308 | 308 | |
309 | - $this->__set( 'paged', $this->args['page'] ); |
|
310 | - $this->__unset( 'page' ); |
|
309 | + $this->__set('paged', $this->args['page']); |
|
310 | + $this->__unset('page'); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -320,17 +320,17 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function per_page() { |
322 | 322 | |
323 | - if ( ! isset( $this->args['number'] ) ) { |
|
323 | + if ( ! isset($this->args['number'])) { |
|
324 | 324 | return; |
325 | 325 | } |
326 | 326 | |
327 | - if ( $this->args['number'] == - 1 ) { |
|
328 | - $this->__set( 'nopaging', true ); |
|
327 | + if ($this->args['number'] == - 1) { |
|
328 | + $this->__set('nopaging', true); |
|
329 | 329 | } else { |
330 | - $this->__set( 'posts_per_page', $this->args['number'] ); |
|
330 | + $this->__set('posts_per_page', $this->args['number']); |
|
331 | 331 | } |
332 | 332 | |
333 | - $this->__unset( 'number' ); |
|
333 | + $this->__unset('number'); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | * @return void |
343 | 343 | */ |
344 | 344 | public function month() { |
345 | - if ( ! isset( $this->args['month'] ) ) { |
|
345 | + if ( ! isset($this->args['month'])) { |
|
346 | 346 | return; |
347 | 347 | } |
348 | 348 | |
349 | - $this->__set( 'monthnum', $this->args['month'] ); |
|
350 | - $this->__unset( 'month' ); |
|
349 | + $this->__set('monthnum', $this->args['month']); |
|
350 | + $this->__unset('month'); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -359,23 +359,23 @@ discard block |
||
359 | 359 | * @return void |
360 | 360 | */ |
361 | 361 | public function orderby() { |
362 | - switch ( $this->args['orderby'] ) { |
|
362 | + switch ($this->args['orderby']) { |
|
363 | 363 | case 'amount': |
364 | - $this->__set( 'orderby', 'meta_value_num' ); |
|
365 | - $this->__set( 'meta_key', '_give_payment_total' ); |
|
364 | + $this->__set('orderby', 'meta_value_num'); |
|
365 | + $this->__set('meta_key', '_give_payment_total'); |
|
366 | 366 | break; |
367 | 367 | |
368 | 368 | case 'status': |
369 | - $this->__set( 'orderby', 'post_status' ); |
|
369 | + $this->__set('orderby', 'post_status'); |
|
370 | 370 | break; |
371 | 371 | |
372 | 372 | case 'donation_form': |
373 | - $this->__set( 'orderby', 'meta_value' ); |
|
374 | - $this->__set( 'meta_key', '_give_payment_form_title' ); |
|
373 | + $this->__set('orderby', 'meta_value'); |
|
374 | + $this->__set('meta_key', '_give_payment_form_title'); |
|
375 | 375 | break; |
376 | 376 | |
377 | 377 | default: |
378 | - $this->__set( 'orderby', $this->args['orderby'] ); |
|
378 | + $this->__set('orderby', $this->args['orderby']); |
|
379 | 379 | break; |
380 | 380 | } |
381 | 381 | } |
@@ -392,19 +392,19 @@ discard block |
||
392 | 392 | * |
393 | 393 | * @return mixed |
394 | 394 | */ |
395 | - public function custom_orderby( $order, $query ) { |
|
395 | + public function custom_orderby($order, $query) { |
|
396 | 396 | |
397 | - if ( ! empty( $query->query['post_type'] ) ) { |
|
398 | - $post_types = is_array( $query->query['post_type'] ) ? $query->query['post_type'] : array( $query->query['post_type'] ); |
|
397 | + if ( ! empty($query->query['post_type'])) { |
|
398 | + $post_types = is_array($query->query['post_type']) ? $query->query['post_type'] : array($query->query['post_type']); |
|
399 | 399 | |
400 | - if ( ! in_array( 'give_payment', $post_types ) || is_array( $query->query['orderby'] ) ) { |
|
400 | + if ( ! in_array('give_payment', $post_types) || is_array($query->query['orderby'])) { |
|
401 | 401 | return $order; |
402 | 402 | } |
403 | 403 | |
404 | 404 | global $wpdb; |
405 | - switch ( $query->query['orderby'] ) { |
|
405 | + switch ($query->query['orderby']) { |
|
406 | 406 | case 'post_status': |
407 | - $order = $wpdb->posts . '.post_status ' . strtoupper( $query->query['order'] ); |
|
407 | + $order = $wpdb->posts.'.post_status '.strtoupper($query->query['order']); |
|
408 | 408 | break; |
409 | 409 | } |
410 | 410 | } |
@@ -421,11 +421,11 @@ discard block |
||
421 | 421 | * @return void |
422 | 422 | */ |
423 | 423 | public function user() { |
424 | - if ( is_null( $this->args['user'] ) ) { |
|
424 | + if (is_null($this->args['user'])) { |
|
425 | 425 | return; |
426 | 426 | } |
427 | 427 | |
428 | - if ( is_numeric( $this->args['user'] ) ) { |
|
428 | + if (is_numeric($this->args['user'])) { |
|
429 | 429 | $user_key = '_give_payment_user_id'; |
430 | 430 | } else { |
431 | 431 | $user_key = '_give_payment_user_email'; |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * @return void |
448 | 448 | */ |
449 | 449 | public function donor() { |
450 | - if ( is_null( $this->args['donor'] ) || ! is_numeric( $this->args['donor'] ) ) { |
|
450 | + if (is_null($this->args['donor']) || ! is_numeric($this->args['donor'])) { |
|
451 | 451 | return; |
452 | 452 | } |
453 | 453 | |
@@ -469,33 +469,33 @@ discard block |
||
469 | 469 | */ |
470 | 470 | public function search() { |
471 | 471 | |
472 | - if ( ! isset( $this->args['s'] ) ) { |
|
472 | + if ( ! isset($this->args['s'])) { |
|
473 | 473 | return; |
474 | 474 | } |
475 | 475 | |
476 | - $search = trim( $this->args['s'] ); |
|
476 | + $search = trim($this->args['s']); |
|
477 | 477 | |
478 | - if ( empty( $search ) ) { |
|
478 | + if (empty($search)) { |
|
479 | 479 | return; |
480 | 480 | } |
481 | 481 | |
482 | - $is_email = is_email( $search ) || strpos( $search, '@' ) !== false; |
|
483 | - $is_user = strpos( $search, strtolower( 'user:' ) ) !== false; |
|
482 | + $is_email = is_email($search) || strpos($search, '@') !== false; |
|
483 | + $is_user = strpos($search, strtolower('user:')) !== false; |
|
484 | 484 | |
485 | - if ( ! empty( $this->args['search_in_notes'] ) ) { |
|
485 | + if ( ! empty($this->args['search_in_notes'])) { |
|
486 | 486 | |
487 | - $notes = give_get_payment_notes( 0, $search ); |
|
487 | + $notes = give_get_payment_notes(0, $search); |
|
488 | 488 | |
489 | - if ( ! empty( $notes ) ) { |
|
489 | + if ( ! empty($notes)) { |
|
490 | 490 | |
491 | - $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' ); |
|
491 | + $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); |
|
492 | 492 | |
493 | - $this->__set( 'post__in', $payment_ids ); |
|
493 | + $this->__set('post__in', $payment_ids); |
|
494 | 494 | } |
495 | 495 | |
496 | - $this->__unset( 's' ); |
|
496 | + $this->__unset('s'); |
|
497 | 497 | |
498 | - } elseif ( $is_email || strlen( $search ) == 32 ) { |
|
498 | + } elseif ($is_email || strlen($search) == 32) { |
|
499 | 499 | |
500 | 500 | $key = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key'; |
501 | 501 | $search_meta = array( |
@@ -504,19 +504,19 @@ discard block |
||
504 | 504 | 'compare' => 'LIKE', |
505 | 505 | ); |
506 | 506 | |
507 | - $this->__set( 'meta_query', $search_meta ); |
|
508 | - $this->__unset( 's' ); |
|
507 | + $this->__set('meta_query', $search_meta); |
|
508 | + $this->__unset('s'); |
|
509 | 509 | |
510 | - } elseif ( $is_user ) { |
|
510 | + } elseif ($is_user) { |
|
511 | 511 | |
512 | 512 | $search_meta = array( |
513 | 513 | 'key' => '_give_payment_user_id', |
514 | - 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ), |
|
514 | + 'value' => trim(str_replace('user:', '', strtolower($search))), |
|
515 | 515 | ); |
516 | 516 | |
517 | - $this->__set( 'meta_query', $search_meta ); |
|
517 | + $this->__set('meta_query', $search_meta); |
|
518 | 518 | |
519 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
519 | + if (give_get_option('enable_sequential')) { |
|
520 | 520 | |
521 | 521 | $search_meta = array( |
522 | 522 | 'key' => '_give_payment_number', |
@@ -524,19 +524,19 @@ discard block |
||
524 | 524 | 'compare' => 'LIKE', |
525 | 525 | ); |
526 | 526 | |
527 | - $this->__set( 'meta_query', $search_meta ); |
|
527 | + $this->__set('meta_query', $search_meta); |
|
528 | 528 | |
529 | 529 | $this->args['meta_query']['relation'] = 'OR'; |
530 | 530 | |
531 | 531 | } |
532 | 532 | |
533 | - $this->__unset( 's' ); |
|
533 | + $this->__unset('s'); |
|
534 | 534 | |
535 | 535 | } elseif ( |
536 | - give_get_option( 'enable_sequential' ) && |
|
536 | + give_get_option('enable_sequential') && |
|
537 | 537 | ( |
538 | - false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) || |
|
539 | - false !== strpos( $search, give_get_option( 'sequential_postfix' ) ) |
|
538 | + false !== strpos($search, give_get_option('sequential_prefix')) || |
|
539 | + false !== strpos($search, give_get_option('sequential_postfix')) |
|
540 | 540 | ) |
541 | 541 | ) { |
542 | 542 | |
@@ -546,29 +546,29 @@ discard block |
||
546 | 546 | 'compare' => 'LIKE', |
547 | 547 | ); |
548 | 548 | |
549 | - $this->__set( 'meta_query', $search_meta ); |
|
550 | - $this->__unset( 's' ); |
|
549 | + $this->__set('meta_query', $search_meta); |
|
550 | + $this->__unset('s'); |
|
551 | 551 | |
552 | - } elseif ( is_numeric( $search ) ) { |
|
552 | + } elseif (is_numeric($search)) { |
|
553 | 553 | |
554 | - $post = get_post( $search ); |
|
554 | + $post = get_post($search); |
|
555 | 555 | |
556 | - if ( is_object( $post ) && $post->post_type == 'give_payment' ) { |
|
556 | + if (is_object($post) && $post->post_type == 'give_payment') { |
|
557 | 557 | |
558 | 558 | $arr = array(); |
559 | 559 | $arr[] = $search; |
560 | - $this->__set( 'post__in', $arr ); |
|
561 | - $this->__unset( 's' ); |
|
560 | + $this->__set('post__in', $arr); |
|
561 | + $this->__unset('s'); |
|
562 | 562 | } |
563 | - } elseif ( '#' == substr( $search, 0, 1 ) ) { |
|
563 | + } elseif ('#' == substr($search, 0, 1)) { |
|
564 | 564 | |
565 | - $search = str_replace( '#:', '', $search ); |
|
566 | - $search = str_replace( '#', '', $search ); |
|
567 | - $this->__set( 'give_forms', $search ); |
|
568 | - $this->__unset( 's' ); |
|
565 | + $search = str_replace('#:', '', $search); |
|
566 | + $search = str_replace('#', '', $search); |
|
567 | + $this->__set('give_forms', $search); |
|
568 | + $this->__unset('s'); |
|
569 | 569 | |
570 | 570 | } else { |
571 | - $this->__set( 's', $search ); |
|
571 | + $this->__set('s', $search); |
|
572 | 572 | |
573 | 573 | } |
574 | 574 | |
@@ -583,8 +583,8 @@ discard block |
||
583 | 583 | * @return void |
584 | 584 | */ |
585 | 585 | public function mode() { |
586 | - if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) { |
|
587 | - $this->__unset( 'mode' ); |
|
586 | + if (empty($this->args['mode']) || $this->args['mode'] == 'all') { |
|
587 | + $this->__unset('mode'); |
|
588 | 588 | |
589 | 589 | return; |
590 | 590 | } |
@@ -606,10 +606,10 @@ discard block |
||
606 | 606 | * @return void |
607 | 607 | */ |
608 | 608 | public function children() { |
609 | - if ( empty( $this->args['children'] ) ) { |
|
610 | - $this->__set( 'post_parent', 0 ); |
|
609 | + if (empty($this->args['children'])) { |
|
610 | + $this->__set('post_parent', 0); |
|
611 | 611 | } |
612 | - $this->__unset( 'children' ); |
|
612 | + $this->__unset('children'); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | */ |
623 | 623 | public function give_forms() { |
624 | 624 | |
625 | - if ( empty( $this->args['give_forms'] ) ) { |
|
625 | + if (empty($this->args['give_forms'])) { |
|
626 | 626 | return; |
627 | 627 | } |
628 | 628 | |
629 | 629 | $compare = '='; |
630 | 630 | |
631 | - if ( is_array( $this->args['give_forms'] ) ) { |
|
631 | + if (is_array($this->args['give_forms'])) { |
|
632 | 632 | $compare = 'IN'; |
633 | 633 | } |
634 | 634 | |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | ) |
643 | 643 | ); |
644 | 644 | |
645 | - $this->__unset( 'give_forms' ); |
|
645 | + $this->__unset('give_forms'); |
|
646 | 646 | |
647 | 647 | } |
648 | 648 | |
@@ -656,13 +656,13 @@ discard block |
||
656 | 656 | */ |
657 | 657 | public function gateway_filter() { |
658 | 658 | |
659 | - if ( empty( $this->args['gateway'] ) ) { |
|
659 | + if (empty($this->args['gateway'])) { |
|
660 | 660 | return; |
661 | 661 | } |
662 | 662 | |
663 | 663 | $compare = '='; |
664 | 664 | |
665 | - if ( is_array( $this->args['gateway'] ) ) { |
|
665 | + if (is_array($this->args['gateway'])) { |
|
666 | 666 | $compare = 'IN'; |
667 | 667 | } |
668 | 668 | |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | ) |
677 | 677 | ); |
678 | 678 | |
679 | - $this->__unset( 'gateway' ); |
|
679 | + $this->__unset('gateway'); |
|
680 | 680 | |
681 | 681 | } |
682 | 682 |
@@ -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 | |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return float|int Total amount of donations based on the passed arguments. |
40 | 40 | */ |
41 | - public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
|
41 | + public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') { |
|
42 | 42 | |
43 | - $this->setup_dates( $start_date, $end_date ); |
|
43 | + $this->setup_dates($start_date, $end_date); |
|
44 | 44 | |
45 | 45 | // Make sure start date is valid |
46 | - if ( is_wp_error( $this->start_date ) ) { |
|
46 | + if (is_wp_error($this->start_date)) { |
|
47 | 47 | return $this->start_date; |
48 | 48 | } |
49 | 49 | |
50 | 50 | // Make sure end date is valid |
51 | - if ( is_wp_error( $this->end_date ) ) { |
|
51 | + if (is_wp_error($this->end_date)) { |
|
52 | 52 | return $this->end_date; |
53 | 53 | } |
54 | 54 | |
@@ -57,18 +57,18 @@ discard block |
||
57 | 57 | 'start_date' => $this->start_date, |
58 | 58 | 'end_date' => $this->end_date, |
59 | 59 | 'fields' => 'ids', |
60 | - 'number' => - 1, |
|
60 | + 'number' => -1, |
|
61 | 61 | ); |
62 | 62 | |
63 | - if ( ! empty( $form_id ) ) { |
|
63 | + if ( ! empty($form_id)) { |
|
64 | 64 | $args['give_forms'] = $form_id; |
65 | 65 | } |
66 | 66 | |
67 | 67 | /* @var Give_Payments_Query $payments */ |
68 | - $payments = new Give_Payments_Query( $args ); |
|
68 | + $payments = new Give_Payments_Query($args); |
|
69 | 69 | $payments = $payments->get_payments(); |
70 | 70 | |
71 | - return count( $payments ); |
|
71 | + return count($payments); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -85,16 +85,16 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return float|int Total amount of donations based on the passed arguments. |
87 | 87 | */ |
88 | - public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
89 | - $this->setup_dates( $start_date, $end_date ); |
|
88 | + public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
89 | + $this->setup_dates($start_date, $end_date); |
|
90 | 90 | |
91 | 91 | // Make sure start date is valid |
92 | - if ( is_wp_error( $this->start_date ) ) { |
|
92 | + if (is_wp_error($this->start_date)) { |
|
93 | 93 | return $this->start_date; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Make sure end date is valid |
97 | - if ( is_wp_error( $this->end_date ) ) { |
|
97 | + if (is_wp_error($this->end_date)) { |
|
98 | 98 | return $this->end_date; |
99 | 99 | } |
100 | 100 | |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | 'start_date' => $this->start_date, |
105 | 105 | 'end_date' => $this->end_date, |
106 | 106 | 'fields' => 'ids', |
107 | - 'number' => - 1, |
|
107 | + 'number' => -1, |
|
108 | 108 | ); |
109 | 109 | |
110 | 110 | |
111 | 111 | // Filter by Gateway ID meta_key |
112 | - if ( $gateway_id ) { |
|
112 | + if ($gateway_id) { |
|
113 | 113 | $args['meta_query'][] = array( |
114 | 114 | 'key' => '_give_payment_gateway', |
115 | 115 | 'value' => $gateway_id, |
@@ -117,39 +117,39 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | // Filter by Gateway ID meta_key |
120 | - if ( $form_id ) { |
|
120 | + if ($form_id) { |
|
121 | 121 | $args['meta_query'][] = array( |
122 | 122 | 'key' => '_give_payment_form_id', |
123 | 123 | 'value' => $form_id, |
124 | 124 | ); |
125 | 125 | } |
126 | 126 | |
127 | - if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) { |
|
127 | + if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) { |
|
128 | 128 | $args['meta_query']['relation'] = 'AND'; |
129 | 129 | } |
130 | 130 | |
131 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
132 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
131 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
132 | + $key = Give_Cache::get_key('give_stats', $args); |
|
133 | 133 | |
134 | 134 | // Set transient for faster stats. |
135 | - $earnings = Give_Cache::get( $key ); |
|
135 | + $earnings = Give_Cache::get($key); |
|
136 | 136 | |
137 | - if ( false === $earnings ) { |
|
137 | + if (false === $earnings) { |
|
138 | 138 | |
139 | 139 | $this->timestamp = false; |
140 | - $payments = new Give_Payments_Query( $args ); |
|
140 | + $payments = new Give_Payments_Query($args); |
|
141 | 141 | $payments = $payments->get_payments(); |
142 | 142 | $earnings = 0; |
143 | 143 | |
144 | - if ( ! empty( $payments ) ) { |
|
145 | - foreach ( $payments as $payment ) { |
|
146 | - $earnings += give_donation_amount( $payment->ID ); |
|
144 | + if ( ! empty($payments)) { |
|
145 | + foreach ($payments as $payment) { |
|
146 | + $earnings += give_donation_amount($payment->ID); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Cache the results for one hour. |
152 | - Give_Cache::set( $key, give_sanitize_amount_for_db( $earnings ), 60 * 60 ); |
|
152 | + Give_Cache::set($key, give_sanitize_amount_for_db($earnings), 60 * 60); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | * @param string|bool $end_date Earning end date. |
164 | 164 | * @param string|bool $gateway_id Payment gateway id. |
165 | 165 | */ |
166 | - $earnings = apply_filters( 'give_get_earnings', $earnings, $form_id, $start_date, $end_date, $gateway_id ); |
|
166 | + $earnings = apply_filters('give_get_earnings', $earnings, $form_id, $start_date, $end_date, $gateway_id); |
|
167 | 167 | |
168 | 168 | //return earnings |
169 | - return round( $earnings, give_get_price_decimals( $form_id ) ); |
|
169 | + return round($earnings, give_get_price_decimals($form_id)); |
|
170 | 170 | |
171 | 171 | } |
172 | 172 | |
@@ -183,17 +183,17 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return float|int Total amount of donations based on the passed arguments. |
185 | 185 | */ |
186 | - public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
186 | + public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
187 | 187 | |
188 | - $this->setup_dates( $start_date, $end_date ); |
|
188 | + $this->setup_dates($start_date, $end_date); |
|
189 | 189 | |
190 | 190 | // Make sure start date is valid |
191 | - if ( is_wp_error( $this->start_date ) ) { |
|
191 | + if (is_wp_error($this->start_date)) { |
|
192 | 192 | return $this->start_date; |
193 | 193 | } |
194 | 194 | |
195 | 195 | // Make sure end date is valid |
196 | - if ( is_wp_error( $this->end_date ) ) { |
|
196 | + if (is_wp_error($this->end_date)) { |
|
197 | 197 | return $this->end_date; |
198 | 198 | } |
199 | 199 | |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | 'start_date' => $this->start_date, |
204 | 204 | 'end_date' => $this->end_date, |
205 | 205 | 'fields' => 'ids', |
206 | - 'number' => - 1, |
|
206 | + 'number' => -1, |
|
207 | 207 | ); |
208 | 208 | |
209 | 209 | |
210 | 210 | // Filter by Gateway ID meta_key |
211 | - if ( $gateway_id ) { |
|
211 | + if ($gateway_id) { |
|
212 | 212 | $args['meta_query'][] = array( |
213 | 213 | 'key' => '_give_payment_gateway', |
214 | 214 | 'value' => $gateway_id, |
@@ -216,19 +216,19 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | // Filter by Gateway ID meta_key |
219 | - if ( $form_id ) { |
|
219 | + if ($form_id) { |
|
220 | 220 | $args['meta_query'][] = array( |
221 | 221 | 'key' => '_give_payment_form_id', |
222 | 222 | 'value' => $form_id, |
223 | 223 | ); |
224 | 224 | } |
225 | 225 | |
226 | - if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) { |
|
226 | + if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) { |
|
227 | 227 | $args['meta_query']['relation'] = 'AND'; |
228 | 228 | } |
229 | 229 | |
230 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
231 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
230 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
231 | + $key = Give_Cache::get_key('give_stats', $args); |
|
232 | 232 | |
233 | 233 | //return earnings |
234 | 234 | return $key; |
@@ -245,16 +245,16 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @return array Best selling forms |
247 | 247 | */ |
248 | - public function get_best_selling( $number = 10 ) { |
|
248 | + public function get_best_selling($number = 10) { |
|
249 | 249 | |
250 | 250 | global $wpdb; |
251 | 251 | |
252 | - $give_forms = $wpdb->get_results( $wpdb->prepare( |
|
252 | + $give_forms = $wpdb->get_results($wpdb->prepare( |
|
253 | 253 | "SELECT post_id as form_id, max(meta_value) as sales |
254 | 254 | FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0 |
255 | 255 | GROUP BY meta_value+0 |
256 | 256 | DESC LIMIT %d;", $number |
257 | - ) ); |
|
257 | + )); |
|
258 | 258 | |
259 | 259 | return $give_forms; |
260 | 260 | } |
@@ -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 | |
@@ -53,21 +53,21 @@ discard block |
||
53 | 53 | * @since 1.8.9 |
54 | 54 | */ |
55 | 55 | public function __construct() { |
56 | - add_action( 'admin_notices', array( $this, 'render_admin_notices' ), 999 ); |
|
57 | - add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) ); |
|
56 | + add_action('admin_notices', array($this, 'render_admin_notices'), 999); |
|
57 | + add_action('give_dismiss_notices', array($this, 'dismiss_notices')); |
|
58 | 58 | |
59 | - add_action( 'give_frontend_notices', array( $this, 'render_frontend_notices' ), 999 ); |
|
60 | - add_action( 'give_donation_form_before_personal_info', array( $this, 'render_frontend_notices' ) ); |
|
61 | - add_action( 'give_ajax_donation_errors', array( $this, 'render_frontend_notices' ) ); |
|
59 | + add_action('give_frontend_notices', array($this, 'render_frontend_notices'), 999); |
|
60 | + add_action('give_donation_form_before_personal_info', array($this, 'render_frontend_notices')); |
|
61 | + add_action('give_ajax_donation_errors', array($this, 'render_frontend_notices')); |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Backward compatibility for deprecated params. |
65 | 65 | * |
66 | 66 | * @since 1.8.14 |
67 | 67 | */ |
68 | - add_filter( 'give_register_notice_args', array( $this, 'bc_deprecated_params' ) ); |
|
69 | - add_filter( 'give_frontend_errors_args', array( $this, 'bc_deprecated_params' ) ); |
|
70 | - add_filter( 'give_frontend_notice_args', array( $this, 'bc_deprecated_params' ) ); |
|
68 | + add_filter('give_register_notice_args', array($this, 'bc_deprecated_params')); |
|
69 | + add_filter('give_frontend_errors_args', array($this, 'bc_deprecated_params')); |
|
70 | + add_filter('give_frontend_notice_args', array($this, 'bc_deprecated_params')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return array |
82 | 82 | */ |
83 | - public function bc_deprecated_params( $args ) { |
|
83 | + public function bc_deprecated_params($args) { |
|
84 | 84 | /** |
85 | 85 | * Param: auto_dismissible |
86 | 86 | * deprecated in 1.8.14 |
87 | 87 | * |
88 | 88 | * Check if auto_dismissible is set and it true then unset and change dismissible parameter value to auto |
89 | 89 | */ |
90 | - if ( isset( $args['auto_dismissible'] ) ) { |
|
91 | - if ( ! empty( $args['auto_dismissible'] ) ) { |
|
90 | + if (isset($args['auto_dismissible'])) { |
|
91 | + if ( ! empty($args['auto_dismissible'])) { |
|
92 | 92 | $args['dismissible'] = 'auto'; |
93 | 93 | } |
94 | 94 | // unset auto_dismissible as it has been deprecated. |
95 | - unset( $args['auto_dismissible'] ); |
|
95 | + unset($args['auto_dismissible']); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | return $args; |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return bool |
110 | 110 | */ |
111 | - public function register_notice( $notice_args ) { |
|
111 | + public function register_notice($notice_args) { |
|
112 | 112 | // Bailout. |
113 | - if ( empty( $notice_args['id'] ) || array_key_exists( $notice_args['id'], self::$notices ) ) { |
|
113 | + if (empty($notice_args['id']) || array_key_exists($notice_args['id'], self::$notices)) { |
|
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | |
@@ -159,39 +159,39 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @since 1.8.14 |
161 | 161 | */ |
162 | - $notice_args = apply_filters( 'give_register_notice_args', $notice_args ); |
|
162 | + $notice_args = apply_filters('give_register_notice_args', $notice_args); |
|
163 | 163 | |
164 | 164 | // Set extra dismiss links if any. |
165 | - if ( false !== strpos( $notice_args['description'], 'data-dismiss-interval' ) ) { |
|
165 | + if (false !== strpos($notice_args['description'], 'data-dismiss-interval')) { |
|
166 | 166 | |
167 | - preg_match_all( "/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link ); |
|
167 | + preg_match_all("/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link); |
|
168 | 168 | |
169 | - if ( ! empty( $extra_notice_dismiss_link ) ) { |
|
170 | - $extra_notice_dismiss_links = array_chunk( current( $extra_notice_dismiss_link ), 3 ); |
|
171 | - foreach ( $extra_notice_dismiss_links as $extra_notice_dismiss_link ) { |
|
169 | + if ( ! empty($extra_notice_dismiss_link)) { |
|
170 | + $extra_notice_dismiss_links = array_chunk(current($extra_notice_dismiss_link), 3); |
|
171 | + foreach ($extra_notice_dismiss_links as $extra_notice_dismiss_link) { |
|
172 | 172 | // Create array og key ==> value by parsing query string created after renaming data attributes. |
173 | - $data_attribute_query_str = str_replace( array( 'data-', '-', '"' ), array( |
|
173 | + $data_attribute_query_str = str_replace(array('data-', '-', '"'), array( |
|
174 | 174 | '', |
175 | 175 | '_', |
176 | 176 | '', |
177 | - ), implode( '&', $extra_notice_dismiss_link ) ); |
|
177 | + ), implode('&', $extra_notice_dismiss_link)); |
|
178 | 178 | |
179 | - $notice_args['extra_links'][] = wp_parse_args( $data_attribute_query_str ); |
|
179 | + $notice_args['extra_links'][] = wp_parse_args($data_attribute_query_str); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | 184 | |
185 | - self::$notices[ $notice_args['id'] ] = $notice_args; |
|
185 | + self::$notices[$notice_args['id']] = $notice_args; |
|
186 | 186 | |
187 | 187 | // Auto set show param if not already set. |
188 | - if ( ! isset( self::$notices[ $notice_args['id'] ]['show'] ) ) { |
|
189 | - self::$notices[ $notice_args['id'] ]['show'] = $this->is_notice_dismissed( $notice_args ) ? false : true; |
|
188 | + if ( ! isset(self::$notices[$notice_args['id']]['show'])) { |
|
189 | + self::$notices[$notice_args['id']]['show'] = $this->is_notice_dismissed($notice_args) ? false : true; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | // Auto set time interval for shortly. |
193 | - if ( 'shortly' === self::$notices[ $notice_args['id'] ]['dismiss_interval'] ) { |
|
194 | - self::$notices[ $notice_args['id'] ]['dismiss_interval_time'] = DAY_IN_SECONDS; |
|
193 | + if ('shortly' === self::$notices[$notice_args['id']]['dismiss_interval']) { |
|
194 | + self::$notices[$notice_args['id']]['dismiss_interval_time'] = DAY_IN_SECONDS; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | return true; |
@@ -205,51 +205,51 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function render_admin_notices() { |
207 | 207 | // Bailout. |
208 | - if ( empty( self::$notices ) ) { |
|
208 | + if (empty(self::$notices)) { |
|
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
212 | 212 | $output = ''; |
213 | 213 | |
214 | - foreach ( self::$notices as $notice_id => $notice ) { |
|
214 | + foreach (self::$notices as $notice_id => $notice) { |
|
215 | 215 | // Check flag set to true to show notice. |
216 | - if ( ! $notice['show'] ) { |
|
216 | + if ( ! $notice['show']) { |
|
217 | 217 | continue; |
218 | 218 | } |
219 | 219 | |
220 | 220 | |
221 | 221 | // Render custom html. |
222 | - if( ! empty( $notice['description_html'] ) ) { |
|
222 | + if ( ! empty($notice['description_html'])) { |
|
223 | 223 | $output .= "{$notice['description_html']} \n"; |
224 | 224 | continue; |
225 | 225 | } |
226 | 226 | |
227 | 227 | // Check if notice dismissible or not. |
228 | - if ( ! self::$has_auto_dismissible_notice ) { |
|
229 | - self::$has_auto_dismissible_notice = ( 'auto' === $notice['dismissible'] ); |
|
228 | + if ( ! self::$has_auto_dismissible_notice) { |
|
229 | + self::$has_auto_dismissible_notice = ('auto' === $notice['dismissible']); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | // Check if notice dismissible or not. |
233 | - if ( ! self::$has_dismiss_interval_notice ) { |
|
233 | + if ( ! self::$has_dismiss_interval_notice) { |
|
234 | 234 | self::$has_dismiss_interval_notice = $notice['dismiss_interval']; |
235 | 235 | } |
236 | 236 | |
237 | - $css_id = ( false === strpos( $notice['id'], 'give' ) ? "give-{$notice['id']}" : $notice['id'] ); |
|
237 | + $css_id = (false === strpos($notice['id'], 'give') ? "give-{$notice['id']}" : $notice['id']); |
|
238 | 238 | |
239 | - $css_class = 'give-notice notice ' . ( empty( $notice['dismissible'] ) ? 'non' : 'is' ) . "-dismissible {$notice['type']} notice-{$notice['type']}"; |
|
240 | - $output .= sprintf( |
|
241 | - '<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">' . " \n", |
|
239 | + $css_class = 'give-notice notice '.(empty($notice['dismissible']) ? 'non' : 'is')."-dismissible {$notice['type']} notice-{$notice['type']}"; |
|
240 | + $output .= sprintf( |
|
241 | + '<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">'." \n", |
|
242 | 242 | $css_id, |
243 | 243 | $css_class, |
244 | - give_clean( $notice['dismissible'] ), |
|
244 | + give_clean($notice['dismissible']), |
|
245 | 245 | $notice['dismissible_type'], |
246 | 246 | $notice['dismiss_interval'], |
247 | 247 | $notice['id'], |
248 | - empty( $notice['dismissible_type'] ) ? '' : wp_create_nonce( "give_edit_{$notice_id}_notice" ), |
|
248 | + empty($notice['dismissible_type']) ? '' : wp_create_nonce("give_edit_{$notice_id}_notice"), |
|
249 | 249 | $notice['dismiss_interval_time'] |
250 | 250 | ); |
251 | 251 | |
252 | - $output .= ( 0 === strpos( $notice['description'], '<div' ) || 0 === strpos( $notice['description'], '<p' ) ? $notice['description'] : "<p>{$notice['description']}</p>" ); |
|
252 | + $output .= (0 === strpos($notice['description'], '<div') || 0 === strpos($notice['description'], '<p') ? $notice['description'] : "<p>{$notice['description']}</p>"); |
|
253 | 253 | $output .= "</div> \n"; |
254 | 254 | } |
255 | 255 | |
@@ -267,18 +267,18 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @param int $form_id |
269 | 269 | */ |
270 | - public function render_frontend_notices( $form_id = 0 ) { |
|
270 | + public function render_frontend_notices($form_id = 0) { |
|
271 | 271 | $errors = give_get_errors(); |
272 | 272 | |
273 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? absint( $_REQUEST['form-id'] ) : 0; |
|
273 | + $request_form_id = isset($_REQUEST['form-id']) ? absint($_REQUEST['form-id']) : 0; |
|
274 | 274 | |
275 | 275 | // Sanity checks first: Ensure that gateway returned errors display on the appropriate form. |
276 | - if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) { |
|
276 | + if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) { |
|
277 | 277 | return; |
278 | 278 | } |
279 | 279 | |
280 | - if ( $errors ) { |
|
281 | - self::print_frontend_errors( $errors ); |
|
280 | + if ($errors) { |
|
281 | + self::print_frontend_errors($errors); |
|
282 | 282 | |
283 | 283 | give_clear_errors(); |
284 | 284 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @access private |
292 | 292 | */ |
293 | 293 | private function print_js() { |
294 | - if ( self::$has_auto_dismissible_notice ) : |
|
294 | + if (self::$has_auto_dismissible_notice) : |
|
295 | 295 | ?> |
296 | 296 | <script> |
297 | 297 | jQuery(document).ready(function () { |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | <?php |
308 | 308 | endif; |
309 | 309 | |
310 | - if ( self::$has_dismiss_interval_notice ) : |
|
310 | + if (self::$has_dismiss_interval_notice) : |
|
311 | 311 | ?> |
312 | 312 | <script> |
313 | 313 | jQuery(document).ready(function () { |
@@ -386,29 +386,29 @@ discard block |
||
386 | 386 | * @access public |
387 | 387 | */ |
388 | 388 | public function dismiss_notices() { |
389 | - $_post = give_clean( $_POST ); |
|
390 | - $notice_id = esc_attr( $_post['notice_id'] ); |
|
389 | + $_post = give_clean($_POST); |
|
390 | + $notice_id = esc_attr($_post['notice_id']); |
|
391 | 391 | |
392 | 392 | // Bailout. |
393 | 393 | if ( |
394 | - empty( $notice_id ) || |
|
395 | - empty( $_post['dismissible_type'] ) || |
|
396 | - empty( $_post['dismiss_interval'] ) || |
|
397 | - ! check_ajax_referer( "give_edit_{$notice_id}_notice", '_wpnonce' ) |
|
394 | + empty($notice_id) || |
|
395 | + empty($_post['dismissible_type']) || |
|
396 | + empty($_post['dismiss_interval']) || |
|
397 | + ! check_ajax_referer("give_edit_{$notice_id}_notice", '_wpnonce') |
|
398 | 398 | ) { |
399 | 399 | wp_send_json_error(); |
400 | 400 | } |
401 | 401 | |
402 | - $notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'] ); |
|
403 | - if ( 'user' === $_post['dismissible_type'] ) { |
|
402 | + $notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval']); |
|
403 | + if ('user' === $_post['dismissible_type']) { |
|
404 | 404 | $current_user = wp_get_current_user(); |
405 | - $notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'], $current_user->ID ); |
|
405 | + $notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval'], $current_user->ID); |
|
406 | 406 | } |
407 | 407 | |
408 | - $notice_dismiss_time = ! empty( $_post['dismiss_interval_time'] ) ? $_post['dismiss_interval_time'] : null; |
|
408 | + $notice_dismiss_time = ! empty($_post['dismiss_interval_time']) ? $_post['dismiss_interval_time'] : null; |
|
409 | 409 | |
410 | 410 | // Save option to hide notice. |
411 | - Give_Cache::set( $notice_key, true, $notice_dismiss_time, true ); |
|
411 | + Give_Cache::set($notice_key, true, $notice_dismiss_time, true); |
|
412 | 412 | |
413 | 413 | wp_send_json_success(); |
414 | 414 | } |
@@ -426,18 +426,18 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @return string |
428 | 428 | */ |
429 | - public function get_notice_key( $notice_id, $dismiss_interval = null, $user_id = 0 ) { |
|
429 | + public function get_notice_key($notice_id, $dismiss_interval = null, $user_id = 0) { |
|
430 | 430 | $notice_key = "_give_notice_{$notice_id}"; |
431 | 431 | |
432 | - if ( ! empty( $dismiss_interval ) ) { |
|
432 | + if ( ! empty($dismiss_interval)) { |
|
433 | 433 | $notice_key .= "_{$dismiss_interval}"; |
434 | 434 | } |
435 | 435 | |
436 | - if ( $user_id ) { |
|
436 | + if ($user_id) { |
|
437 | 437 | $notice_key .= "_{$user_id}"; |
438 | 438 | } |
439 | 439 | |
440 | - $notice_key = sanitize_key( $notice_key ); |
|
440 | + $notice_key = sanitize_key($notice_key); |
|
441 | 441 | |
442 | 442 | return $notice_key; |
443 | 443 | } |
@@ -450,11 +450,11 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @return string |
452 | 452 | */ |
453 | - public function get_dismiss_link( $notice_args ) { |
|
453 | + public function get_dismiss_link($notice_args) { |
|
454 | 454 | $notice_args = wp_parse_args( |
455 | 455 | $notice_args, |
456 | 456 | array( |
457 | - 'title' => __( 'Click here', 'give' ), |
|
457 | + 'title' => __('Click here', 'give'), |
|
458 | 458 | 'dismissible_type' => '', |
459 | 459 | 'dismiss_interval' => '', |
460 | 460 | 'dismiss_interval_time' => null, |
@@ -481,31 +481,31 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @return bool|null |
483 | 483 | */ |
484 | - public function is_notice_dismissed( $notice ) { |
|
485 | - $notice_key = $this->get_notice_key( $notice['id'], $notice['dismiss_interval'] ); |
|
484 | + public function is_notice_dismissed($notice) { |
|
485 | + $notice_key = $this->get_notice_key($notice['id'], $notice['dismiss_interval']); |
|
486 | 486 | $is_notice_dismissed = false; |
487 | 487 | |
488 | - if ( 'user' === $notice['dismissible_type'] ) { |
|
488 | + if ('user' === $notice['dismissible_type']) { |
|
489 | 489 | $current_user = wp_get_current_user(); |
490 | - $notice_key = Give()->notices->get_notice_key( $notice['id'], $notice['dismiss_interval'], $current_user->ID ); |
|
490 | + $notice_key = Give()->notices->get_notice_key($notice['id'], $notice['dismiss_interval'], $current_user->ID); |
|
491 | 491 | } |
492 | 492 | |
493 | - $notice_data = Give_Cache::get( $notice_key, true ); |
|
493 | + $notice_data = Give_Cache::get($notice_key, true); |
|
494 | 494 | |
495 | 495 | // Find notice dismiss link status if notice has extra dismissible links. |
496 | - if ( ( empty( $notice_data ) || is_wp_error( $notice_data ) ) && ! empty( $notice['extra_links'] ) ) { |
|
496 | + if ((empty($notice_data) || is_wp_error($notice_data)) && ! empty($notice['extra_links'])) { |
|
497 | 497 | |
498 | - foreach ( $notice['extra_links'] as $extra_link ) { |
|
499 | - $new_notice_data = wp_parse_args( $extra_link, $notice ); |
|
500 | - unset( $new_notice_data['extra_links'] ); |
|
498 | + foreach ($notice['extra_links'] as $extra_link) { |
|
499 | + $new_notice_data = wp_parse_args($extra_link, $notice); |
|
500 | + unset($new_notice_data['extra_links']); |
|
501 | 501 | |
502 | - if ( $is_notice_dismissed = $this->is_notice_dismissed( $new_notice_data ) ) { |
|
502 | + if ($is_notice_dismissed = $this->is_notice_dismissed($new_notice_data)) { |
|
503 | 503 | return $is_notice_dismissed; |
504 | 504 | } |
505 | 505 | } |
506 | 506 | } |
507 | 507 | |
508 | - $is_notice_dismissed = ! empty( $notice_data ) && ! is_wp_error( $notice_data ); |
|
508 | + $is_notice_dismissed = ! empty($notice_data) && ! is_wp_error($notice_data); |
|
509 | 509 | |
510 | 510 | return $is_notice_dismissed; |
511 | 511 | } |
@@ -519,9 +519,9 @@ discard block |
||
519 | 519 | * |
520 | 520 | * @param array $errors |
521 | 521 | */ |
522 | - public static function print_frontend_errors( $errors ) { |
|
522 | + public static function print_frontend_errors($errors) { |
|
523 | 523 | // Bailout. |
524 | - if ( ! $errors ) { |
|
524 | + if ( ! $errors) { |
|
525 | 525 | return; |
526 | 526 | } |
527 | 527 | |
@@ -536,37 +536,37 @@ discard block |
||
536 | 536 | ); |
537 | 537 | |
538 | 538 | // Note: we will remove give_errors class in future. |
539 | - $classes = apply_filters( 'give_error_class', array( 'give_notices', 'give_errors' ) ); |
|
539 | + $classes = apply_filters('give_error_class', array('give_notices', 'give_errors')); |
|
540 | 540 | |
541 | - echo sprintf( '<div class="%s">', implode( ' ', $classes ) ); |
|
541 | + echo sprintf('<div class="%s">', implode(' ', $classes)); |
|
542 | 542 | |
543 | 543 | // Loop error codes and display errors. |
544 | - foreach ( $errors as $error_id => $error ) { |
|
544 | + foreach ($errors as $error_id => $error) { |
|
545 | 545 | // Backward compatibility v<1.8.11 |
546 | - if ( is_string( $error ) ) { |
|
546 | + if (is_string($error)) { |
|
547 | 547 | $error = array( |
548 | 548 | 'message' => $error, |
549 | 549 | 'notice_args' => array(), |
550 | 550 | ); |
551 | 551 | } |
552 | 552 | |
553 | - $notice_args = wp_parse_args( $error['notice_args'], $default_notice_args ); |
|
553 | + $notice_args = wp_parse_args($error['notice_args'], $default_notice_args); |
|
554 | 554 | |
555 | 555 | /** |
556 | 556 | * Filter to modify Frontend Errors args before errors is display. |
557 | 557 | * |
558 | 558 | * @since 1.8.14 |
559 | 559 | */ |
560 | - $notice_args = apply_filters( 'give_frontend_errors_args', $notice_args ); |
|
560 | + $notice_args = apply_filters('give_frontend_errors_args', $notice_args); |
|
561 | 561 | |
562 | 562 | echo sprintf( |
563 | 563 | '<div class="give_error give_notice" id="give_error_%1$s" data-dismissible="%2$s" data-dismiss-interval="%3$d"> |
564 | 564 | <p><strong>%4$s</strong>: %5$s</p> |
565 | 565 | </div>', |
566 | 566 | $error_id, |
567 | - give_clean( $notice_args['dismissible'] ), |
|
568 | - absint( $notice_args['dismiss_interval'] ), |
|
569 | - esc_html__( 'Error', 'give' ), |
|
567 | + give_clean($notice_args['dismissible']), |
|
568 | + absint($notice_args['dismiss_interval']), |
|
569 | + esc_html__('Error', 'give'), |
|
570 | 570 | $error['message'] |
571 | 571 | ); |
572 | 572 | } |
@@ -588,8 +588,8 @@ discard block |
||
588 | 588 | * |
589 | 589 | * @return string |
590 | 590 | */ |
591 | - public static function print_frontend_notice( $message, $echo = true, $notice_type = 'warning', $notice_args = array() ) { |
|
592 | - if ( empty( $message ) ) { |
|
591 | + public static function print_frontend_notice($message, $echo = true, $notice_type = 'warning', $notice_args = array()) { |
|
592 | + if (empty($message)) { |
|
593 | 593 | return ''; |
594 | 594 | } |
595 | 595 | |
@@ -603,14 +603,14 @@ discard block |
||
603 | 603 | 'dismiss_interval' => 5000, |
604 | 604 | ); |
605 | 605 | |
606 | - $notice_args = wp_parse_args( $notice_args, $default_notice_args ); |
|
606 | + $notice_args = wp_parse_args($notice_args, $default_notice_args); |
|
607 | 607 | |
608 | 608 | /** |
609 | 609 | * Filter to modify Frontend notice args before notices is display. |
610 | 610 | * |
611 | 611 | * @since 1.8.14 |
612 | 612 | */ |
613 | - $notice_args = apply_filters( 'give_frontend_notice_args', $notice_args ); |
|
613 | + $notice_args = apply_filters('give_frontend_notice_args', $notice_args); |
|
614 | 614 | |
615 | 615 | // Note: we will remove give_errors class in future. |
616 | 616 | $error = sprintf( |
@@ -620,12 +620,12 @@ discard block |
||
620 | 620 | </p> |
621 | 621 | </div>', |
622 | 622 | $notice_type, |
623 | - give_clean( $notice_args['dismissible'] ), |
|
624 | - absint( $notice_args['dismiss_interval'] ), |
|
623 | + give_clean($notice_args['dismissible']), |
|
624 | + absint($notice_args['dismiss_interval']), |
|
625 | 625 | $message |
626 | 626 | ); |
627 | 627 | |
628 | - if ( ! $echo ) { |
|
628 | + if ( ! $echo) { |
|
629 | 629 | return $error; |
630 | 630 | } |
631 | 631 | |
@@ -645,24 +645,24 @@ discard block |
||
645 | 645 | * |
646 | 646 | * @return string |
647 | 647 | */ |
648 | - public function print_admin_notices( $notice_args = array() ) { |
|
648 | + public function print_admin_notices($notice_args = array()) { |
|
649 | 649 | // Bailout. |
650 | - if ( empty( $notice_args['description'] ) ) { |
|
650 | + if (empty($notice_args['description'])) { |
|
651 | 651 | return ''; |
652 | 652 | } |
653 | 653 | |
654 | - $defaults = array( |
|
654 | + $defaults = array( |
|
655 | 655 | 'id' => '', |
656 | 656 | 'echo' => true, |
657 | 657 | 'notice_type' => 'warning', |
658 | 658 | 'dismissible' => true, |
659 | 659 | ); |
660 | - $notice_args = wp_parse_args( $notice_args, $defaults ); |
|
660 | + $notice_args = wp_parse_args($notice_args, $defaults); |
|
661 | 661 | |
662 | 662 | $output = ''; |
663 | - $css_id = ! empty( $notice_args['id'] ) ? $notice_args['id'] : uniqid( 'give-inline-notice-' ); |
|
663 | + $css_id = ! empty($notice_args['id']) ? $notice_args['id'] : uniqid('give-inline-notice-'); |
|
664 | 664 | $css_class = "notice-{$notice_args['notice_type']} give-notice notice inline"; |
665 | - $css_class .= ( $notice_args['dismissible'] ) ? ' is-dismissible' : ''; |
|
665 | + $css_class .= ($notice_args['dismissible']) ? ' is-dismissible' : ''; |
|
666 | 666 | $output .= sprintf( |
667 | 667 | '<div id="%1$s" class="%2$s"><p>%3$s</p></div>', |
668 | 668 | $css_id, |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | $notice_args['description'] |
671 | 671 | ); |
672 | 672 | |
673 | - if ( ! $notice_args['echo'] ) { |
|
673 | + if ( ! $notice_args['echo']) { |
|
674 | 674 | return $output; |
675 | 675 | } |
676 | 676 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,40 +23,40 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string|bool |
25 | 25 | */ |
26 | -function give_donation_history( $atts ) { |
|
26 | +function give_donation_history($atts) { |
|
27 | 27 | |
28 | - $donation_history_args = shortcode_atts( array( |
|
28 | + $donation_history_args = shortcode_atts(array( |
|
29 | 29 | 'id' => true, |
30 | 30 | 'date' => true, |
31 | 31 | 'donor' => false, |
32 | 32 | 'amount' => true, |
33 | 33 | 'status' => false, |
34 | 34 | 'payment_method' => false, |
35 | - ), $atts, 'donation_history' ); |
|
35 | + ), $atts, 'donation_history'); |
|
36 | 36 | |
37 | 37 | // Always show receipt link. |
38 | 38 | $donation_history_args['details'] = true; |
39 | 39 | |
40 | 40 | // Set Donation History Shortcode Arguments in session variable. |
41 | - Give()->session->set( 'give_donation_history_args', $donation_history_args ); |
|
41 | + Give()->session->set('give_donation_history_args', $donation_history_args); |
|
42 | 42 | |
43 | 43 | // If payment_key query arg exists, return receipt instead of donation history. |
44 | - if ( isset( $_GET['payment_key'] ) ) { |
|
44 | + if (isset($_GET['payment_key'])) { |
|
45 | 45 | ob_start(); |
46 | - echo give_receipt_shortcode( array() ); |
|
46 | + echo give_receipt_shortcode(array()); |
|
47 | 47 | |
48 | 48 | // Display donation history link only if it is not accessed via Receipt Access Link. |
49 | - if ( give_get_receipt_session() ) { |
|
49 | + if (give_get_receipt_session()) { |
|
50 | 50 | echo sprintf( |
51 | 51 | '<a href="%s">%s</a>', |
52 | - esc_url( give_get_history_page_uri() ), |
|
53 | - __( '« Return to All Donations', 'give' ) |
|
52 | + esc_url(give_get_history_page_uri()), |
|
53 | + __('« Return to All Donations', 'give') |
|
54 | 54 | ); |
55 | 55 | } |
56 | 56 | return ob_get_clean(); |
57 | 57 | } |
58 | 58 | |
59 | - $email_access = give_get_option( 'email_access' ); |
|
59 | + $email_access = give_get_option('email_access'); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Determine access |
@@ -67,31 +67,31 @@ discard block |
||
67 | 67 | if ( |
68 | 68 | is_user_logged_in() || |
69 | 69 | false !== Give()->session->get_session_expiration() || |
70 | - ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) || |
|
70 | + (give_is_setting_enabled($email_access) && Give()->email_access->token_exists) || |
|
71 | 71 | true === give_get_history_session() |
72 | 72 | ) { |
73 | 73 | ob_start(); |
74 | - give_get_template_part( 'history', 'donations' ); |
|
74 | + give_get_template_part('history', 'donations'); |
|
75 | 75 | |
76 | 76 | return ob_get_clean(); |
77 | 77 | |
78 | - } elseif ( give_is_setting_enabled( $email_access ) ) { |
|
78 | + } elseif (give_is_setting_enabled($email_access)) { |
|
79 | 79 | // Is Email-based access enabled? |
80 | 80 | ob_start(); |
81 | - give_get_template_part( 'email', 'login-form' ); |
|
81 | + give_get_template_part('email', 'login-form'); |
|
82 | 82 | |
83 | 83 | return ob_get_clean(); |
84 | 84 | |
85 | 85 | } else { |
86 | 86 | |
87 | - $output = apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) ); |
|
88 | - $output .= do_shortcode( '[give_login]' ); |
|
87 | + $output = apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false)); |
|
88 | + $output .= do_shortcode('[give_login]'); |
|
89 | 89 | |
90 | 90 | return $output; |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
94 | +add_shortcode('donation_history', 'give_donation_history'); |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Donation Form Shortcode |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return string |
106 | 106 | */ |
107 | -function give_form_shortcode( $atts ) { |
|
108 | - $atts = shortcode_atts( array( |
|
107 | +function give_form_shortcode($atts) { |
|
108 | + $atts = shortcode_atts(array( |
|
109 | 109 | 'id' => '', |
110 | 110 | 'show_title' => true, |
111 | 111 | 'show_goal' => true, |
@@ -113,21 +113,21 @@ discard block |
||
113 | 113 | 'float_labels' => '', |
114 | 114 | 'display_style' => '', |
115 | 115 | 'continue_button_title' => '', |
116 | - ), $atts, 'give_form' ); |
|
116 | + ), $atts, 'give_form'); |
|
117 | 117 | |
118 | 118 | // Convert string to bool. |
119 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
120 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
119 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
120 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
121 | 121 | |
122 | 122 | //get the Give Form |
123 | 123 | ob_start(); |
124 | - give_get_donation_form( $atts ); |
|
124 | + give_get_donation_form($atts); |
|
125 | 125 | $final_output = ob_get_clean(); |
126 | 126 | |
127 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
127 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
128 | 128 | } |
129 | 129 | |
130 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
130 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
131 | 131 | |
132 | 132 | /** |
133 | 133 | * Donation Form Goal Shortcode. |
@@ -140,37 +140,37 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return string |
142 | 142 | */ |
143 | -function give_goal_shortcode( $atts ) { |
|
144 | - $atts = shortcode_atts( array( |
|
143 | +function give_goal_shortcode($atts) { |
|
144 | + $atts = shortcode_atts(array( |
|
145 | 145 | 'id' => '', |
146 | 146 | 'show_text' => true, |
147 | 147 | 'show_bar' => true, |
148 | - ), $atts, 'give_goal' ); |
|
148 | + ), $atts, 'give_goal'); |
|
149 | 149 | |
150 | 150 | |
151 | 151 | //get the Give Form. |
152 | 152 | ob_start(); |
153 | 153 | |
154 | 154 | //Sanity check 1: ensure there is an ID Provided. |
155 | - if ( empty( $atts['id'] ) ) { |
|
156 | - Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
155 | + if (empty($atts['id'])) { |
|
156 | + Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | //Sanity check 2: Check the form even has Goals enabled. |
160 | - if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
160 | + if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) { |
|
161 | 161 | |
162 | - Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true ); |
|
162 | + Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true); |
|
163 | 163 | } else { |
164 | 164 | //Passed all sanity checks: output Goal. |
165 | - give_show_goal_progress( $atts['id'], $atts ); |
|
165 | + give_show_goal_progress($atts['id'], $atts); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | $final_output = ob_get_clean(); |
169 | 169 | |
170 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
170 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
171 | 171 | } |
172 | 172 | |
173 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
173 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
174 | 174 | |
175 | 175 | |
176 | 176 | /** |
@@ -187,22 +187,22 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return string |
189 | 189 | */ |
190 | -function give_login_form_shortcode( $atts ) { |
|
191 | - $atts = shortcode_atts( array( |
|
190 | +function give_login_form_shortcode($atts) { |
|
191 | + $atts = shortcode_atts(array( |
|
192 | 192 | // Add backward compatibility for redirect attribute. |
193 | 193 | 'redirect' => '', |
194 | 194 | |
195 | 195 | 'login-redirect' => '', |
196 | 196 | 'logout-redirect' => '', |
197 | - ), $atts, 'give_login' ); |
|
197 | + ), $atts, 'give_login'); |
|
198 | 198 | |
199 | 199 | // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
200 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
200 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
201 | 201 | |
202 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
202 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
203 | 203 | } |
204 | 204 | |
205 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
205 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Register Shortcode. |
@@ -217,15 +217,15 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return string |
219 | 219 | */ |
220 | -function give_register_form_shortcode( $atts ) { |
|
221 | - $atts = shortcode_atts( array( |
|
220 | +function give_register_form_shortcode($atts) { |
|
221 | + $atts = shortcode_atts(array( |
|
222 | 222 | 'redirect' => '', |
223 | - ), $atts, 'give_register' ); |
|
223 | + ), $atts, 'give_register'); |
|
224 | 224 | |
225 | - return give_register_form( $atts['redirect'] ); |
|
225 | + return give_register_form($atts['redirect']); |
|
226 | 226 | } |
227 | 227 | |
228 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
228 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
229 | 229 | |
230 | 230 | /** |
231 | 231 | * Receipt Shortcode. |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return string |
240 | 240 | */ |
241 | -function give_receipt_shortcode( $atts ) { |
|
241 | +function give_receipt_shortcode($atts) { |
|
242 | 242 | |
243 | 243 | global $give_receipt_args; |
244 | 244 | |
245 | - $give_receipt_args = shortcode_atts( array( |
|
246 | - 'error' => __( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
245 | + $give_receipt_args = shortcode_atts(array( |
|
246 | + 'error' => __('You are missing the payment key to view this donation receipt.', 'give'), |
|
247 | 247 | 'price' => true, |
248 | 248 | 'donor' => true, |
249 | 249 | 'date' => true, |
@@ -252,49 +252,49 @@ discard block |
||
252 | 252 | 'payment_id' => true, |
253 | 253 | 'payment_status' => false, |
254 | 254 | 'status_notice' => true, |
255 | - ), $atts, 'give_receipt' ); |
|
255 | + ), $atts, 'give_receipt'); |
|
256 | 256 | |
257 | 257 | //set $session var |
258 | 258 | $session = give_get_purchase_session(); |
259 | 259 | |
260 | 260 | //set payment key var |
261 | - if ( isset( $_GET['payment_key'] ) ) { |
|
262 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
263 | - } elseif ( $session ) { |
|
261 | + if (isset($_GET['payment_key'])) { |
|
262 | + $payment_key = urldecode($_GET['payment_key']); |
|
263 | + } elseif ($session) { |
|
264 | 264 | $payment_key = $session['purchase_key']; |
265 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
265 | + } elseif ($give_receipt_args['payment_key']) { |
|
266 | 266 | $payment_key = $give_receipt_args['payment_key']; |
267 | 267 | } |
268 | 268 | |
269 | - $email_access = give_get_option( 'email_access' ); |
|
269 | + $email_access = give_get_option('email_access'); |
|
270 | 270 | |
271 | 271 | // No payment_key found & Email Access is Turned on: |
272 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
272 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
273 | 273 | |
274 | 274 | ob_start(); |
275 | 275 | |
276 | - give_get_template_part( 'email-login-form' ); |
|
276 | + give_get_template_part('email-login-form'); |
|
277 | 277 | |
278 | 278 | return ob_get_clean(); |
279 | 279 | |
280 | - } elseif ( ! isset( $payment_key ) ) { |
|
280 | + } elseif ( ! isset($payment_key)) { |
|
281 | 281 | |
282 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
282 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
283 | 283 | |
284 | 284 | } |
285 | 285 | |
286 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
286 | + $user_can_view = give_can_view_receipt($payment_key); |
|
287 | 287 | |
288 | 288 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
289 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
289 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
290 | 290 | |
291 | 291 | ob_start(); |
292 | 292 | |
293 | - give_get_template_part( 'email-login-form' ); |
|
293 | + give_get_template_part('email-login-form'); |
|
294 | 294 | |
295 | 295 | return ob_get_clean(); |
296 | 296 | |
297 | - } elseif ( ! $user_can_view ) { |
|
297 | + } elseif ( ! $user_can_view) { |
|
298 | 298 | |
299 | 299 | global $give_login_redirect; |
300 | 300 | |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | |
303 | 303 | ob_start(); |
304 | 304 | |
305 | - Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
305 | + Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give'))); |
|
306 | 306 | |
307 | - give_get_template_part( 'shortcode', 'login' ); |
|
307 | + give_get_template_part('shortcode', 'login'); |
|
308 | 308 | |
309 | 309 | $login_form = ob_get_clean(); |
310 | 310 | |
@@ -318,20 +318,20 @@ discard block |
||
318 | 318 | * or if user is logged out and donation was made as a guest, the donation session is checked for |
319 | 319 | * or if user is logged in and the user can view sensitive shop data. |
320 | 320 | */ |
321 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
322 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
321 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
322 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | ob_start(); |
326 | 326 | |
327 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
327 | + give_get_template_part('shortcode', 'receipt'); |
|
328 | 328 | |
329 | 329 | $display = ob_get_clean(); |
330 | 330 | |
331 | 331 | return $display; |
332 | 332 | } |
333 | 333 | |
334 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
334 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
335 | 335 | |
336 | 336 | /** |
337 | 337 | * Profile Editor Shortcode. |
@@ -350,25 +350,25 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @return string Output generated from the profile editor |
352 | 352 | */ |
353 | -function give_profile_editor_shortcode( $atts ) { |
|
353 | +function give_profile_editor_shortcode($atts) { |
|
354 | 354 | |
355 | 355 | ob_start(); |
356 | 356 | |
357 | 357 | // Restrict access to donor profile, if donor and user are disconnected. |
358 | - $is_donor_disconnected = get_user_meta( get_current_user_id(), '_give_is_donor_disconnected', true ); |
|
359 | - if( is_user_logged_in() && $is_donor_disconnected ) { |
|
360 | - Give()->notices->print_frontend_notice( __( 'Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give' ), true, 'error' ); |
|
358 | + $is_donor_disconnected = get_user_meta(get_current_user_id(), '_give_is_donor_disconnected', true); |
|
359 | + if (is_user_logged_in() && $is_donor_disconnected) { |
|
360 | + Give()->notices->print_frontend_notice(__('Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give'), true, 'error'); |
|
361 | 361 | return false; |
362 | 362 | } |
363 | 363 | |
364 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
364 | + give_get_template_part('shortcode', 'profile-editor'); |
|
365 | 365 | |
366 | 366 | $display = ob_get_clean(); |
367 | 367 | |
368 | 368 | return $display; |
369 | 369 | } |
370 | 370 | |
371 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
371 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Process Profile Updater Form. |
@@ -381,32 +381,32 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @return bool |
383 | 383 | */ |
384 | -function give_process_profile_editor_updates( $data ) { |
|
384 | +function give_process_profile_editor_updates($data) { |
|
385 | 385 | // Profile field change request |
386 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
386 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
387 | 387 | return false; |
388 | 388 | } |
389 | 389 | |
390 | 390 | // Nonce security |
391 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
391 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
392 | 392 | return false; |
393 | 393 | } |
394 | 394 | |
395 | 395 | $user_id = get_current_user_id(); |
396 | - $old_user_data = get_userdata( $user_id ); |
|
397 | - |
|
398 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
399 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
400 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
401 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
402 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
403 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
404 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
405 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
406 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
407 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
408 | - $password = ! empty( $data['give_new_user_pass1'] ) ? $data['give_new_user_pass1'] : ''; |
|
409 | - $confirm_password = ! empty( $data['give_new_user_pass2'] ) ? $data['give_new_user_pass2'] : ''; |
|
396 | + $old_user_data = get_userdata($user_id); |
|
397 | + |
|
398 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
399 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
400 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
401 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
402 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
403 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
404 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
405 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
406 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
407 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
408 | + $password = ! empty($data['give_new_user_pass1']) ? $data['give_new_user_pass1'] : ''; |
|
409 | + $confirm_password = ! empty($data['give_new_user_pass2']) ? $data['give_new_user_pass2'] : ''; |
|
410 | 410 | |
411 | 411 | $userdata = array( |
412 | 412 | 'ID' => $user_id, |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | 'user_pass' => $password, |
418 | 418 | ); |
419 | 419 | |
420 | - if( empty( $line1 ) || empty( $city ) || empty( $state ) || empty( $zip ) || empty( $country ) ) { |
|
421 | - give_set_error( 'give-empty-address-fields', __( 'Please fill in the required address fields.', 'give' ) ); |
|
420 | + if (empty($line1) || empty($city) || empty($state) || empty($zip) || empty($country)) { |
|
421 | + give_set_error('give-empty-address-fields', __('Please fill in the required address fields.', 'give')); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | $address = array( |
@@ -438,48 +438,48 @@ discard block |
||
438 | 438 | * @param int $user_id The ID of the user. |
439 | 439 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
440 | 440 | */ |
441 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
441 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
442 | 442 | |
443 | 443 | // Validate First Name. |
444 | - if( empty( $first_name ) ) { |
|
445 | - give_set_error( 'give-empty-first-name', __( 'Please enter first name.', 'give' ) ); |
|
444 | + if (empty($first_name)) { |
|
445 | + give_set_error('give-empty-first-name', __('Please enter first name.', 'give')); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | // Make sure to validate passwords for existing Donors. |
449 | - give_validate_user_password( $password, $confirm_password ); |
|
449 | + give_validate_user_password($password, $confirm_password); |
|
450 | 450 | |
451 | - if ( empty( $email ) ) { |
|
451 | + if (empty($email)) { |
|
452 | 452 | // Make sure email should not be empty. |
453 | - give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) ); |
|
453 | + give_set_error('email_empty', __('The email you entered is empty.', 'give')); |
|
454 | 454 | |
455 | - } else if ( ! is_email( $email ) ) { |
|
455 | + } else if ( ! is_email($email)) { |
|
456 | 456 | // Make sure email should be valid. |
457 | - give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
457 | + give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give')); |
|
458 | 458 | |
459 | - } else if ( $email != $old_user_data->user_email ) { |
|
459 | + } else if ($email != $old_user_data->user_email) { |
|
460 | 460 | // Make sure the new email doesn't belong to another user |
461 | - if ( email_exists( $email ) ) { |
|
462 | - give_set_error( 'user_email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
463 | - } elseif ( Give()->donors->get_donor_by( 'email', $email ) ){ |
|
461 | + if (email_exists($email)) { |
|
462 | + give_set_error('user_email_exists', __('The email you entered belongs to another user. Please use another.', 'give')); |
|
463 | + } elseif (Give()->donors->get_donor_by('email', $email)) { |
|
464 | 464 | // Make sure the new email doesn't belong to another user |
465 | - give_set_error( 'donor_email_exists', __( 'The email you entered belongs to another donor. Please use another.', 'give' ) ); |
|
465 | + give_set_error('donor_email_exists', __('The email you entered belongs to another donor. Please use another.', 'give')); |
|
466 | 466 | } |
467 | 467 | } |
468 | 468 | |
469 | 469 | // Check for errors |
470 | 470 | $errors = give_get_errors(); |
471 | 471 | |
472 | - if ( $errors ) { |
|
472 | + if ($errors) { |
|
473 | 473 | // Send back to the profile editor if there are errors |
474 | - wp_redirect( $data['give_redirect'] ); |
|
474 | + wp_redirect($data['give_redirect']); |
|
475 | 475 | give_die(); |
476 | 476 | } |
477 | 477 | |
478 | 478 | // Update the user |
479 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
480 | - $updated = wp_update_user( $userdata ); |
|
479 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
480 | + $updated = wp_update_user($userdata); |
|
481 | 481 | |
482 | - if ( $updated ) { |
|
482 | + if ($updated) { |
|
483 | 483 | |
484 | 484 | /** |
485 | 485 | * Fires after updating user profile. |
@@ -489,12 +489,12 @@ discard block |
||
489 | 489 | * @param int $user_id The ID of the user. |
490 | 490 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
491 | 491 | */ |
492 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
493 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
492 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
493 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
494 | 494 | give_die(); |
495 | 495 | } |
496 | 496 | |
497 | 497 | return false; |
498 | 498 | } |
499 | 499 | |
500 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
500 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
@@ -20,19 +20,19 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return string The currency code |
22 | 22 | */ |
23 | -function give_get_currency( $donation_or_form_id = null, $args = array() ) { |
|
23 | +function give_get_currency($donation_or_form_id = null, $args = array()) { |
|
24 | 24 | |
25 | 25 | // Get currency from donation |
26 | - if ( is_numeric( $donation_or_form_id ) && 'give_payment' === get_post_type( $donation_or_form_id ) ) { |
|
27 | - $donation_meta = give_get_meta( $donation_or_form_id, '_give_payment_meta', true ); |
|
26 | + if (is_numeric($donation_or_form_id) && 'give_payment' === get_post_type($donation_or_form_id)) { |
|
27 | + $donation_meta = give_get_meta($donation_or_form_id, '_give_payment_meta', true); |
|
28 | 28 | |
29 | - if ( ! empty( $donation_meta['currency'] ) ) { |
|
29 | + if ( ! empty($donation_meta['currency'])) { |
|
30 | 30 | $currency = $donation_meta['currency']; |
31 | 31 | } else { |
32 | - $currency = give_get_option( 'currency', 'USD' ); |
|
32 | + $currency = give_get_option('currency', 'USD'); |
|
33 | 33 | } |
34 | 34 | } else { |
35 | - $currency = give_get_option( 'currency', 'USD' ); |
|
35 | + $currency = give_get_option('currency', 'USD'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @since 1.0 |
42 | 42 | */ |
43 | - return apply_filters( 'give_currency', $currency, $donation_or_form_id, $args ); |
|
43 | + return apply_filters('give_currency', $currency, $donation_or_form_id, $args); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | */ |
53 | 53 | function give_get_currency_position() { |
54 | 54 | |
55 | - $currency_pos = give_get_option( 'currency_position', 'before' ); |
|
55 | + $currency_pos = give_get_option('currency_position', 'before'); |
|
56 | 56 | |
57 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
57 | + return apply_filters('give_currency_position', $currency_pos); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | function give_get_currencies_list() { |
68 | 68 | $currencies = array( |
69 | 69 | 'USD' => array( |
70 | - 'admin_label' => __( 'US Dollars ($)', 'give' ), |
|
70 | + 'admin_label' => __('US Dollars ($)', 'give'), |
|
71 | 71 | 'symbol' => '$', |
72 | 72 | 'setting' => array( |
73 | 73 | 'currency_position' => 'before', |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | ), |
78 | 78 | ), |
79 | 79 | 'EUR' => array( |
80 | - 'admin_label' => __( 'Euros (€)', 'give' ), |
|
80 | + 'admin_label' => __('Euros (€)', 'give'), |
|
81 | 81 | 'symbol' => '€', |
82 | 82 | 'setting' => array( |
83 | 83 | 'currency_position' => 'before', |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | ), |
88 | 88 | ), |
89 | 89 | 'GBP' => array( |
90 | - 'admin_label' => __( 'Pounds Sterling (£)', 'give' ), |
|
90 | + 'admin_label' => __('Pounds Sterling (£)', 'give'), |
|
91 | 91 | 'symbol' => '£', |
92 | 92 | 'setting' => array( |
93 | 93 | 'currency_position' => 'before', |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | ), |
98 | 98 | ), |
99 | 99 | 'AUD' => array( |
100 | - 'admin_label' => __( 'Australian Dollars ($)', 'give' ), |
|
100 | + 'admin_label' => __('Australian Dollars ($)', 'give'), |
|
101 | 101 | 'symbol' => '$', |
102 | 102 | 'setting' => array( |
103 | 103 | 'currency_position' => 'before', |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | ), |
108 | 108 | ), |
109 | 109 | 'BRL' => array( |
110 | - 'admin_label' => __( 'Brazilian Real (R$)', 'give' ), |
|
110 | + 'admin_label' => __('Brazilian Real (R$)', 'give'), |
|
111 | 111 | 'symbol' => 'R$', |
112 | 112 | 'setting' => array( |
113 | 113 | 'currency_position' => 'before', |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | ), |
118 | 118 | ), |
119 | 119 | 'CAD' => array( |
120 | - 'admin_label' => __( 'Canadian Dollars ($)', 'give' ), |
|
120 | + 'admin_label' => __('Canadian Dollars ($)', 'give'), |
|
121 | 121 | 'symbol' => '$', |
122 | 122 | 'setting' => array( |
123 | 123 | 'currency_position' => 'before', |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | ), |
128 | 128 | ), |
129 | 129 | 'CZK' => array( |
130 | - 'admin_label' => __( 'Czech Koruna (Kč)', 'give' ), |
|
130 | + 'admin_label' => __('Czech Koruna (Kč)', 'give'), |
|
131 | 131 | 'symbol' => 'Kč', |
132 | 132 | 'setting' => array( |
133 | 133 | 'currency_position' => 'after', |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | ), |
138 | 138 | ), |
139 | 139 | 'DKK' => array( |
140 | - 'admin_label' => __( 'Danish Krone (kr.)', 'give' ), |
|
140 | + 'admin_label' => __('Danish Krone (kr.)', 'give'), |
|
141 | 141 | 'symbol' => ' kr. ', |
142 | 142 | 'setting' => array( |
143 | 143 | 'currency_position' => 'before', |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | ), |
148 | 148 | ), |
149 | 149 | 'HKD' => array( |
150 | - 'admin_label' => __( 'Hong Kong Dollar ($)', 'give' ), |
|
150 | + 'admin_label' => __('Hong Kong Dollar ($)', 'give'), |
|
151 | 151 | 'symbol' => '$', |
152 | 152 | 'setting' => array( |
153 | 153 | 'currency_position' => 'before', |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | ), |
158 | 158 | ), |
159 | 159 | 'HUF' => array( |
160 | - 'admin_label' => __( 'Hungarian Forint (Ft)', 'give' ), |
|
160 | + 'admin_label' => __('Hungarian Forint (Ft)', 'give'), |
|
161 | 161 | 'symbol' => 'Ft', |
162 | 162 | 'setting' => array( |
163 | 163 | 'currency_position' => 'after', |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | ), |
168 | 168 | ), |
169 | 169 | 'ILS' => array( |
170 | - 'admin_label' => __( 'Israeli Shekel (₪)', 'give' ), |
|
170 | + 'admin_label' => __('Israeli Shekel (₪)', 'give'), |
|
171 | 171 | 'symbol' => '₪', |
172 | 172 | 'setting' => array( |
173 | 173 | 'currency_position' => 'after', |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | ), |
178 | 178 | ), |
179 | 179 | 'JPY' => array( |
180 | - 'admin_label' => __( 'Japanese Yen (¥)', 'give' ), |
|
180 | + 'admin_label' => __('Japanese Yen (¥)', 'give'), |
|
181 | 181 | 'symbol' => '¥', |
182 | 182 | 'setting' => array( |
183 | 183 | 'currency_position' => 'before', |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | ), |
188 | 188 | ), |
189 | 189 | 'MYR' => array( |
190 | - 'admin_label' => __( 'Malaysian Ringgits (RM)', 'give' ), |
|
190 | + 'admin_label' => __('Malaysian Ringgits (RM)', 'give'), |
|
191 | 191 | 'symbol' => 'RM', |
192 | 192 | 'setting' => array( |
193 | 193 | 'currency_position' => 'before', |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | ), |
198 | 198 | ), |
199 | 199 | 'MXN' => array( |
200 | - 'admin_label' => __( 'Mexican Peso ($)', 'give' ), |
|
200 | + 'admin_label' => __('Mexican Peso ($)', 'give'), |
|
201 | 201 | 'symbol' => '$', |
202 | 202 | 'setting' => array( |
203 | 203 | 'currency_position' => 'before', |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | ), |
208 | 208 | ), |
209 | 209 | 'MAD' => array( |
210 | - 'admin_label' => __( 'Moroccan Dirham (.د.م)', 'give' ), |
|
210 | + 'admin_label' => __('Moroccan Dirham (.د.م)', 'give'), |
|
211 | 211 | 'symbol' => '.د.م', |
212 | 212 | 'setting' => array( |
213 | 213 | 'currency_position' => 'before', |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | ), |
218 | 218 | ), |
219 | 219 | 'NZD' => array( |
220 | - 'admin_label' => __( 'New Zealand Dollar ($)', 'give' ), |
|
220 | + 'admin_label' => __('New Zealand Dollar ($)', 'give'), |
|
221 | 221 | 'symbol' => '$', |
222 | 222 | 'setting' => array( |
223 | 223 | 'currency_position' => 'before', |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | ), |
228 | 228 | ), |
229 | 229 | 'NOK' => array( |
230 | - 'admin_label' => __( 'Norwegian Krone (Kr.)', 'give' ), |
|
230 | + 'admin_label' => __('Norwegian Krone (Kr.)', 'give'), |
|
231 | 231 | 'symbol' => 'kr.', |
232 | 232 | 'setting' => array( |
233 | 233 | 'currency_position' => 'before', |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | ), |
238 | 238 | ), |
239 | 239 | 'PHP' => array( |
240 | - 'admin_label' => __( 'Philippine Pesos (₱)', 'give' ), |
|
240 | + 'admin_label' => __('Philippine Pesos (₱)', 'give'), |
|
241 | 241 | 'symbol' => '₱', |
242 | 242 | 'setting' => array( |
243 | 243 | 'currency_position' => 'before', |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | ), |
248 | 248 | ), |
249 | 249 | 'PLN' => array( |
250 | - 'admin_label' => __( 'Polish Zloty (zł)', 'give' ), |
|
250 | + 'admin_label' => __('Polish Zloty (zł)', 'give'), |
|
251 | 251 | 'symbol' => 'zł', |
252 | 252 | 'setting' => array( |
253 | 253 | 'currency_position' => 'after', |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | ), |
258 | 258 | ), |
259 | 259 | 'SGD' => array( |
260 | - 'admin_label' => __( 'Singapore Dollar ($)', 'give' ), |
|
260 | + 'admin_label' => __('Singapore Dollar ($)', 'give'), |
|
261 | 261 | 'symbol' => '$', |
262 | 262 | 'setting' => array( |
263 | 263 | 'currency_position' => 'before', |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | ), |
268 | 268 | ), |
269 | 269 | 'KRW' => array( |
270 | - 'admin_label' => __( 'South Korean Won (₩)', 'give' ), |
|
270 | + 'admin_label' => __('South Korean Won (₩)', 'give'), |
|
271 | 271 | 'symbol' => '₩', |
272 | 272 | 'setting' => array( |
273 | 273 | 'currency_position' => 'before', |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | ), |
278 | 278 | ), |
279 | 279 | 'ZAR' => array( |
280 | - 'admin_label' => __( 'South African Rand (R)', 'give' ), |
|
280 | + 'admin_label' => __('South African Rand (R)', 'give'), |
|
281 | 281 | 'symbol' => 'R', |
282 | 282 | 'setting' => array( |
283 | 283 | 'currency_position' => 'before', |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | ), |
288 | 288 | ), |
289 | 289 | 'SEK' => array( |
290 | - 'admin_label' => __( 'Swedish Krona (kr)', 'give' ), |
|
290 | + 'admin_label' => __('Swedish Krona (kr)', 'give'), |
|
291 | 291 | 'symbol' => ' kr. ', |
292 | 292 | 'setting' => array( |
293 | 293 | 'currency_position' => 'before', |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | ), |
298 | 298 | ), |
299 | 299 | 'CHF' => array( |
300 | - 'admin_label' => __( 'Swiss Franc (Fr)', 'give' ), |
|
300 | + 'admin_label' => __('Swiss Franc (Fr)', 'give'), |
|
301 | 301 | 'symbol' => 'Fr', |
302 | 302 | 'setting' => array( |
303 | 303 | 'currency_position' => 'before', |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | ), |
308 | 308 | ), |
309 | 309 | 'TWD' => array( |
310 | - 'admin_label' => __( 'Taiwan New Dollars (NT$)', 'give' ), |
|
310 | + 'admin_label' => __('Taiwan New Dollars (NT$)', 'give'), |
|
311 | 311 | 'symbol' => 'NT$', |
312 | 312 | 'setting' => array( |
313 | 313 | 'currency_position' => 'before', |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | ), |
318 | 318 | ), |
319 | 319 | 'THB' => array( |
320 | - 'admin_label' => __( 'Thai Baht (฿)', 'give' ), |
|
320 | + 'admin_label' => __('Thai Baht (฿)', 'give'), |
|
321 | 321 | 'symbol' => '฿', |
322 | 322 | 'setting' => array( |
323 | 323 | 'currency_position' => 'before', |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | ), |
328 | 328 | ), |
329 | 329 | 'INR' => array( |
330 | - 'admin_label' => __( 'Indian Rupee (₹)', 'give' ), |
|
330 | + 'admin_label' => __('Indian Rupee (₹)', 'give'), |
|
331 | 331 | 'symbol' => '₹', |
332 | 332 | 'setting' => array( |
333 | 333 | 'currency_position' => 'before', |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | ), |
338 | 338 | ), |
339 | 339 | 'TRY' => array( |
340 | - 'admin_label' => __( 'Turkish Lira (₺)', 'give' ), |
|
340 | + 'admin_label' => __('Turkish Lira (₺)', 'give'), |
|
341 | 341 | 'symbol' => '₺', |
342 | 342 | 'setting' => array( |
343 | 343 | 'currency_position' => 'after', |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | ), |
348 | 348 | ), |
349 | 349 | 'IRR' => array( |
350 | - 'admin_label' => __( 'Iranian Rial (﷼)', 'give' ), |
|
350 | + 'admin_label' => __('Iranian Rial (﷼)', 'give'), |
|
351 | 351 | 'symbol' => '﷼', |
352 | 352 | 'setting' => array( |
353 | 353 | 'currency_position' => 'after', |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | ), |
358 | 358 | ), |
359 | 359 | 'RUB' => array( |
360 | - 'admin_label' => __( 'Russian Rubles (руб)', 'give' ), |
|
360 | + 'admin_label' => __('Russian Rubles (руб)', 'give'), |
|
361 | 361 | 'symbol' => '₽', |
362 | 362 | 'setting' => array( |
363 | 363 | 'currency_position' => 'before', |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | ), |
368 | 368 | ), |
369 | 369 | 'AED' => array( |
370 | - 'admin_label' => __( 'United Arab Emirates dirham (د.إ)', 'give' ), |
|
370 | + 'admin_label' => __('United Arab Emirates dirham (د.إ)', 'give'), |
|
371 | 371 | 'symbol' => 'د.إ', |
372 | 372 | 'setting' => array( |
373 | 373 | 'currency_position' => 'before', |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | ), |
378 | 378 | ), |
379 | 379 | 'AMD' => array( |
380 | - 'admin_label' => __( 'Armenian dram (AMD)', 'give' ), |
|
380 | + 'admin_label' => __('Armenian dram (AMD)', 'give'), |
|
381 | 381 | 'symbol' => 'AMD', // Add backward compatibility. Using AMD in place of ֏ |
382 | 382 | 'setting' => array( |
383 | 383 | 'currency_position' => 'before', |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | ), |
388 | 388 | ), |
389 | 389 | 'ANG' => array( |
390 | - 'admin_label' => __( 'Netherlands Antillean guilder (ƒ)', 'give' ), |
|
390 | + 'admin_label' => __('Netherlands Antillean guilder (ƒ)', 'give'), |
|
391 | 391 | 'symbol' => 'ƒ', |
392 | 392 | 'setting' => array( |
393 | 393 | 'currency_position' => 'before', |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | ), |
398 | 398 | ), |
399 | 399 | 'ARS' => array( |
400 | - 'admin_label' => __( 'Argentine peso ($)', 'give' ), |
|
400 | + 'admin_label' => __('Argentine peso ($)', 'give'), |
|
401 | 401 | 'symbol' => '$', |
402 | 402 | 'setting' => array( |
403 | 403 | 'currency_position' => 'before', |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | ), |
408 | 408 | ), |
409 | 409 | 'AWG' => array( |
410 | - 'admin_label' => __( 'Aruban florin (ƒ)', 'give' ), |
|
410 | + 'admin_label' => __('Aruban florin (ƒ)', 'give'), |
|
411 | 411 | 'symbol' => 'ƒ', |
412 | 412 | 'setting' => array( |
413 | 413 | 'currency_position' => 'before', |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | ), |
418 | 418 | ), |
419 | 419 | 'BAM' => array( |
420 | - 'admin_label' => __( 'Bosnia and Herzegovina convertible mark (KM)', 'give' ), |
|
420 | + 'admin_label' => __('Bosnia and Herzegovina convertible mark (KM)', 'give'), |
|
421 | 421 | 'symbol' => 'KM', |
422 | 422 | 'setting' => array( |
423 | 423 | 'currency_position' => 'before', |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | ), |
428 | 428 | ), |
429 | 429 | 'BDT' => array( |
430 | - 'admin_label' => __( 'Bangladeshi taka (৳)', 'give' ), |
|
430 | + 'admin_label' => __('Bangladeshi taka (৳)', 'give'), |
|
431 | 431 | 'symbol' => '৳', |
432 | 432 | 'setting' => array( |
433 | 433 | 'currency_position' => 'before', |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | ), |
438 | 438 | ), |
439 | 439 | 'BHD' => array( |
440 | - 'admin_label' => __( 'Bahraini dinar (.د.ب)', 'give' ), |
|
440 | + 'admin_label' => __('Bahraini dinar (.د.ب)', 'give'), |
|
441 | 441 | 'symbol' => '.د.ب', |
442 | 442 | 'setting' => array( |
443 | 443 | 'currency_position' => 'before', |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | ), |
448 | 448 | ), |
449 | 449 | 'BMD' => array( |
450 | - 'admin_label' => __( 'Bermudian dollar (BD$)', 'give' ), |
|
450 | + 'admin_label' => __('Bermudian dollar (BD$)', 'give'), |
|
451 | 451 | 'symbol' => 'BD$', |
452 | 452 | 'setting' => array( |
453 | 453 | 'currency_position' => 'before', |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | ), |
458 | 458 | ), |
459 | 459 | 'BND' => array( |
460 | - 'admin_label' => __( 'Brunei dollar (B$)', 'give' ), |
|
460 | + 'admin_label' => __('Brunei dollar (B$)', 'give'), |
|
461 | 461 | 'symbol' => 'B$', |
462 | 462 | 'setting' => array( |
463 | 463 | 'currency_position' => 'before', |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | ), |
468 | 468 | ), |
469 | 469 | 'BOB' => array( |
470 | - 'admin_label' => __( 'Bolivian boliviano (Bs.)', 'give' ), |
|
470 | + 'admin_label' => __('Bolivian boliviano (Bs.)', 'give'), |
|
471 | 471 | 'symbol' => 'Bs.', |
472 | 472 | 'setting' => array( |
473 | 473 | 'currency_position' => 'before', |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | ), |
478 | 478 | ), |
479 | 479 | 'BSD' => array( |
480 | - 'admin_label' => __( 'Bahamian dollar (B$)', 'give' ), |
|
480 | + 'admin_label' => __('Bahamian dollar (B$)', 'give'), |
|
481 | 481 | 'symbol' => 'B$', |
482 | 482 | 'setting' => array( |
483 | 483 | 'currency_position' => 'before', |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | ), |
488 | 488 | ), |
489 | 489 | 'BWP' => array( |
490 | - 'admin_label' => __( 'Botswana pula (P)', 'give' ), |
|
490 | + 'admin_label' => __('Botswana pula (P)', 'give'), |
|
491 | 491 | 'symbol' => 'P', |
492 | 492 | 'setting' => array( |
493 | 493 | 'currency_position' => 'before', |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | ), |
498 | 498 | ), |
499 | 499 | 'BZD' => array( |
500 | - 'admin_label' => __( 'Belizean dollar (BZ$)', 'give' ), |
|
500 | + 'admin_label' => __('Belizean dollar (BZ$)', 'give'), |
|
501 | 501 | 'symbol' => 'BZ$', |
502 | 502 | 'setting' => array( |
503 | 503 | 'currency_position' => 'before', |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | ), |
508 | 508 | ), |
509 | 509 | 'CLP' => array( |
510 | - 'admin_label' => __( 'Chilean peso ($)', 'give' ), |
|
510 | + 'admin_label' => __('Chilean peso ($)', 'give'), |
|
511 | 511 | 'symbol' => '$', |
512 | 512 | 'setting' => array( |
513 | 513 | 'currency_position' => 'before', |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | ), |
518 | 518 | ), |
519 | 519 | 'CNY' => array( |
520 | - 'admin_label' => __( 'Chinese yuan (¥)', 'give' ), |
|
520 | + 'admin_label' => __('Chinese yuan (¥)', 'give'), |
|
521 | 521 | 'symbol' => '¥', |
522 | 522 | 'setting' => array( |
523 | 523 | 'currency_position' => 'before', |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | ), |
528 | 528 | ), |
529 | 529 | 'COP' => array( |
530 | - 'admin_label' => __( 'Colombian peso ($)', 'give' ), |
|
530 | + 'admin_label' => __('Colombian peso ($)', 'give'), |
|
531 | 531 | 'symbol' => '$', |
532 | 532 | 'setting' => array( |
533 | 533 | 'currency_position' => 'before', |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | ), |
538 | 538 | ), |
539 | 539 | 'CRC' => array( |
540 | - 'admin_label' => __( 'Costa Rican colón (₡)', 'give' ), |
|
540 | + 'admin_label' => __('Costa Rican colón (₡)', 'give'), |
|
541 | 541 | 'symbol' => '₡', |
542 | 542 | 'setting' => array( |
543 | 543 | 'currency_position' => 'before', |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | ), |
548 | 548 | ), |
549 | 549 | 'CUC' => array( |
550 | - 'admin_label' => __( 'Cuban convertible peso (₱)', 'give' ), |
|
550 | + 'admin_label' => __('Cuban convertible peso (₱)', 'give'), |
|
551 | 551 | 'symbol' => '₱', |
552 | 552 | 'setting' => array( |
553 | 553 | 'currency_position' => 'before', |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | ), |
558 | 558 | ), |
559 | 559 | 'CUP' => array( |
560 | - 'admin_label' => __( 'Cuban convertible peso (₱)', 'give' ), |
|
560 | + 'admin_label' => __('Cuban convertible peso (₱)', 'give'), |
|
561 | 561 | 'symbol' => '₱', |
562 | 562 | 'setting' => array( |
563 | 563 | 'currency_position' => 'before', |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | ), |
568 | 568 | ), |
569 | 569 | 'DOP' => array( |
570 | - 'admin_label' => __( 'Dominican peso (RD$)', 'give' ), |
|
570 | + 'admin_label' => __('Dominican peso (RD$)', 'give'), |
|
571 | 571 | 'symbol' => 'RD$', |
572 | 572 | 'setting' => array( |
573 | 573 | 'currency_position' => 'before', |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | ), |
578 | 578 | ), |
579 | 579 | 'EGP' => array( |
580 | - 'admin_label' => __( 'Egyptian pound (E£)', 'give' ), |
|
580 | + 'admin_label' => __('Egyptian pound (E£)', 'give'), |
|
581 | 581 | 'symbol' => 'E£', |
582 | 582 | 'setting' => array( |
583 | 583 | 'currency_position' => 'before', |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | ), |
588 | 588 | ), |
589 | 589 | 'GIP' => array( |
590 | - 'admin_label' => __( 'Gibraltar pound (£)', 'give' ), |
|
590 | + 'admin_label' => __('Gibraltar pound (£)', 'give'), |
|
591 | 591 | 'symbol' => '£', |
592 | 592 | 'setting' => array( |
593 | 593 | 'currency_position' => 'before', |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | ), |
598 | 598 | ), |
599 | 599 | 'GTQ' => array( |
600 | - 'admin_label' => __( 'Guatemalan quetzal (Q)', 'give' ), |
|
600 | + 'admin_label' => __('Guatemalan quetzal (Q)', 'give'), |
|
601 | 601 | 'symbol' => 'Q', |
602 | 602 | 'setting' => array( |
603 | 603 | 'currency_position' => 'before', |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | ), |
608 | 608 | ), |
609 | 609 | 'HNL' => array( |
610 | - 'admin_label' => __( 'Honduran lempira (L)', 'give' ), |
|
610 | + 'admin_label' => __('Honduran lempira (L)', 'give'), |
|
611 | 611 | 'symbol' => 'L', |
612 | 612 | 'setting' => array( |
613 | 613 | 'currency_position' => 'before', |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | ), |
618 | 618 | ), |
619 | 619 | 'HRK' => array( |
620 | - 'admin_label' => __( 'Croatian kuna (kn)', 'give' ), |
|
620 | + 'admin_label' => __('Croatian kuna (kn)', 'give'), |
|
621 | 621 | 'symbol' => 'kn', |
622 | 622 | 'setting' => array( |
623 | 623 | 'currency_position' => 'after', |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | ), |
628 | 628 | ), |
629 | 629 | 'IDR' => array( |
630 | - 'admin_label' => __( 'Indonesian rupiah (Rp)', 'give' ), |
|
630 | + 'admin_label' => __('Indonesian rupiah (Rp)', 'give'), |
|
631 | 631 | 'symbol' => 'Rp', |
632 | 632 | 'setting' => array( |
633 | 633 | 'currency_position' => 'before', |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | ), |
638 | 638 | ), |
639 | 639 | 'ISK' => array( |
640 | - 'admin_label' => __( 'Icelandic króna (kr)', 'give' ), |
|
640 | + 'admin_label' => __('Icelandic króna (kr)', 'give'), |
|
641 | 641 | 'symbol' => 'kr', |
642 | 642 | 'setting' => array( |
643 | 643 | 'currency_position' => 'after', |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | ), |
648 | 648 | ), |
649 | 649 | 'JMD' => array( |
650 | - 'admin_label' => __( 'Jamaican dollar (J$)', 'give' ), |
|
650 | + 'admin_label' => __('Jamaican dollar (J$)', 'give'), |
|
651 | 651 | 'symbol' => 'j$', |
652 | 652 | 'setting' => array( |
653 | 653 | 'currency_position' => 'before', |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | ), |
658 | 658 | ), |
659 | 659 | 'JOD' => array( |
660 | - 'admin_label' => __( 'Jordanian dinar (د.ا)', 'give' ), |
|
660 | + 'admin_label' => __('Jordanian dinar (د.ا)', 'give'), |
|
661 | 661 | 'symbol' => 'د.ا', |
662 | 662 | 'setting' => array( |
663 | 663 | 'currency_position' => 'before', |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | ), |
668 | 668 | ), |
669 | 669 | 'KES' => array( |
670 | - 'admin_label' => __( 'Kenyan shilling (KSh)', 'give' ), |
|
670 | + 'admin_label' => __('Kenyan shilling (KSh)', 'give'), |
|
671 | 671 | 'symbol' => 'KSh', |
672 | 672 | 'setting' => array( |
673 | 673 | 'currency_position' => 'before', |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | ), |
678 | 678 | ), |
679 | 679 | 'KWD' => array( |
680 | - 'admin_label' => __( 'Kuwaiti dinar (د.ك)', 'give' ), |
|
680 | + 'admin_label' => __('Kuwaiti dinar (د.ك)', 'give'), |
|
681 | 681 | 'symbol' => 'د.ك', |
682 | 682 | 'setting' => array( |
683 | 683 | 'currency_position' => 'before', |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | ), |
688 | 688 | ), |
689 | 689 | 'KYD' => array( |
690 | - 'admin_label' => __( 'Cayman Islands dollar (KY$)', 'give' ), |
|
690 | + 'admin_label' => __('Cayman Islands dollar (KY$)', 'give'), |
|
691 | 691 | 'symbol' => 'KY$', |
692 | 692 | 'setting' => array( |
693 | 693 | 'currency_position' => 'before', |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | ), |
698 | 698 | ), |
699 | 699 | 'MKD' => array( |
700 | - 'admin_label' => __( 'Macedonian denar (ден)', 'give' ), |
|
700 | + 'admin_label' => __('Macedonian denar (ден)', 'give'), |
|
701 | 701 | 'symbol' => 'ден', |
702 | 702 | 'setting' => array( |
703 | 703 | 'currency_position' => 'before', |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | ), |
708 | 708 | ), |
709 | 709 | 'NPR' => array( |
710 | - 'admin_label' => __( 'Nepalese rupee (NɌs)', 'give' ), |
|
710 | + 'admin_label' => __('Nepalese rupee (NɌs)', 'give'), |
|
711 | 711 | 'symbol' => '₨', |
712 | 712 | 'setting' => array( |
713 | 713 | 'currency_position' => 'before', |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | ), |
718 | 718 | ), |
719 | 719 | 'OMR' => array( |
720 | - 'admin_label' => __( 'Omani rial (ر.ع.)', 'give' ), |
|
720 | + 'admin_label' => __('Omani rial (ر.ع.)', 'give'), |
|
721 | 721 | 'symbol' => 'ر.ع.', |
722 | 722 | 'setting' => array( |
723 | 723 | 'currency_position' => 'before', |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | ), |
728 | 728 | ), |
729 | 729 | 'PEN' => array( |
730 | - 'admin_label' => __( 'Peruvian nuevo sol (S/.)', 'give' ), |
|
730 | + 'admin_label' => __('Peruvian nuevo sol (S/.)', 'give'), |
|
731 | 731 | 'symbol' => 'S/.', |
732 | 732 | 'setting' => array( |
733 | 733 | 'currency_position' => 'before', |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | ), |
738 | 738 | ), |
739 | 739 | 'PKR' => array( |
740 | - 'admin_label' => __( 'Pakistani rupee (Ɍs)', 'give' ), |
|
740 | + 'admin_label' => __('Pakistani rupee (Ɍs)', 'give'), |
|
741 | 741 | 'symbol' => '₨', |
742 | 742 | 'setting' => array( |
743 | 743 | 'currency_position' => 'before', |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | ), |
748 | 748 | ), |
749 | 749 | 'RON' => array( |
750 | - 'admin_label' => __( 'Romanian leu (L)', 'give' ), |
|
750 | + 'admin_label' => __('Romanian leu (L)', 'give'), |
|
751 | 751 | 'symbol' => 'L', |
752 | 752 | 'setting' => array( |
753 | 753 | 'currency_position' => 'after', |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | ), |
758 | 758 | ), |
759 | 759 | 'SAR' => array( |
760 | - 'admin_label' => __( 'Saudi riyal (ر.س)', 'give' ), |
|
760 | + 'admin_label' => __('Saudi riyal (ر.س)', 'give'), |
|
761 | 761 | 'symbol' => 'ر.س', |
762 | 762 | 'setting' => array( |
763 | 763 | 'currency_position' => 'before', |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | ), |
768 | 768 | ), |
769 | 769 | 'SZL' => array( |
770 | - 'admin_label' => __( 'Swazi lilangeni (L)', 'give' ), |
|
770 | + 'admin_label' => __('Swazi lilangeni (L)', 'give'), |
|
771 | 771 | 'symbol' => 'L', |
772 | 772 | 'setting' => array( |
773 | 773 | 'currency_position' => 'before', |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | ), |
778 | 778 | ), |
779 | 779 | 'TOP' => array( |
780 | - 'admin_label' => __( 'Tongan paʻanga (T$)', 'give' ), |
|
780 | + 'admin_label' => __('Tongan paʻanga (T$)', 'give'), |
|
781 | 781 | 'symbol' => 'T$', |
782 | 782 | 'setting' => array( |
783 | 783 | 'currency_position' => 'before', |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | ), |
788 | 788 | ), |
789 | 789 | 'TZS' => array( |
790 | - 'admin_label' => __( 'Tanzanian shilling (TSh)', 'give' ), |
|
790 | + 'admin_label' => __('Tanzanian shilling (TSh)', 'give'), |
|
791 | 791 | 'symbol' => 'TSh', |
792 | 792 | 'setting' => array( |
793 | 793 | 'currency_position' => 'before', |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | ), |
798 | 798 | ), |
799 | 799 | 'UAH' => array( |
800 | - 'admin_label' => __( 'Ukrainian hryvnia (₴)', 'give' ), |
|
800 | + 'admin_label' => __('Ukrainian hryvnia (₴)', 'give'), |
|
801 | 801 | 'symbol' => '₴', |
802 | 802 | 'setting' => array( |
803 | 803 | 'currency_position' => 'before', |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | ), |
808 | 808 | ), |
809 | 809 | 'UYU' => array( |
810 | - 'admin_label' => __( 'Uruguayan peso ($U)', 'give' ), |
|
810 | + 'admin_label' => __('Uruguayan peso ($U)', 'give'), |
|
811 | 811 | 'symbol' => '$U', |
812 | 812 | 'setting' => array( |
813 | 813 | 'currency_position' => 'before', |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | ), |
818 | 818 | ), |
819 | 819 | 'VEF' => array( |
820 | - 'admin_label' => __( 'Venezuelan bolívar (Bs)', 'give' ), |
|
820 | + 'admin_label' => __('Venezuelan bolívar (Bs)', 'give'), |
|
821 | 821 | 'symbol' => 'Bs', |
822 | 822 | 'setting' => array( |
823 | 823 | 'currency_position' => 'before', |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | ), |
828 | 828 | ), |
829 | 829 | 'XCD' => array( |
830 | - 'admin_label' => __( 'East Caribbean dollar (EC$)', 'give' ), |
|
830 | + 'admin_label' => __('East Caribbean dollar (EC$)', 'give'), |
|
831 | 831 | 'symbol' => 'EC$', |
832 | 832 | 'setting' => array( |
833 | 833 | 'currency_position' => 'before', |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | * |
853 | 853 | * @param array $currencies |
854 | 854 | */ |
855 | - return (array) apply_filters( 'give_currencies', $currencies ); |
|
855 | + return (array) apply_filters('give_currencies', $currencies); |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | /** |
@@ -864,22 +864,22 @@ discard block |
||
864 | 864 | * |
865 | 865 | * @return array $currencies A list of the available currencies |
866 | 866 | */ |
867 | -function give_get_currencies( $info = 'admin_label' ) { |
|
867 | +function give_get_currencies($info = 'admin_label') { |
|
868 | 868 | |
869 | 869 | $currencies = give_get_currencies_list(); |
870 | 870 | |
871 | 871 | // Backward compatibility: handle old way of currency registration. |
872 | 872 | // Backward compatibility: Return desired result. |
873 | - if ( ! empty( $currencies ) ) { |
|
874 | - foreach ( $currencies as $currency_code => $currency_setting ) { |
|
875 | - if ( is_string( $currency_setting ) ) { |
|
876 | - $currencies[ $currency_code ] = array( |
|
873 | + if ( ! empty($currencies)) { |
|
874 | + foreach ($currencies as $currency_code => $currency_setting) { |
|
875 | + if (is_string($currency_setting)) { |
|
876 | + $currencies[$currency_code] = array( |
|
877 | 877 | 'admin_label' => $currency_setting, |
878 | 878 | ); |
879 | 879 | } |
880 | 880 | |
881 | - $currencies[ $currency_code ] = wp_parse_args( |
|
882 | - $currencies[ $currency_code ], |
|
881 | + $currencies[$currency_code] = wp_parse_args( |
|
882 | + $currencies[$currency_code], |
|
883 | 883 | array( |
884 | 884 | 'admin_label' => '', |
885 | 885 | 'symbol' => $currency_code, |
@@ -888,8 +888,8 @@ discard block |
||
888 | 888 | ); |
889 | 889 | } |
890 | 890 | |
891 | - if ( ! empty( $info ) && is_string( $info ) && 'all' !== $info ) { |
|
892 | - $currencies = wp_list_pluck( $currencies, $info ); |
|
891 | + if ( ! empty($info) && is_string($info) && 'all' !== $info) { |
|
892 | + $currencies = wp_list_pluck($currencies, $info); |
|
893 | 893 | } |
894 | 894 | } |
895 | 895 | |
@@ -906,12 +906,12 @@ discard block |
||
906 | 906 | * |
907 | 907 | * @return array |
908 | 908 | */ |
909 | -function give_currency_symbols( $decode_currencies = false ) { |
|
910 | - $currencies = give_get_currencies( 'symbol' ); |
|
909 | +function give_currency_symbols($decode_currencies = false) { |
|
910 | + $currencies = give_get_currencies('symbol'); |
|
911 | 911 | |
912 | - if ( $decode_currencies ) { |
|
913 | - array_walk( $currencies, function ( &$currency_symbol ) { |
|
914 | - $currency_symbol = html_entity_decode( $currency_symbol, ENT_COMPAT, 'UTF-8' ); |
|
912 | + if ($decode_currencies) { |
|
913 | + array_walk($currencies, function(&$currency_symbol) { |
|
914 | + $currency_symbol = html_entity_decode($currency_symbol, ENT_COMPAT, 'UTF-8'); |
|
915 | 915 | } ); |
916 | 916 | } |
917 | 917 | |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | * |
923 | 923 | * @param array $currencies |
924 | 924 | */ |
925 | - return apply_filters( 'give_currency_symbols', $currencies ); |
|
925 | + return apply_filters('give_currency_symbols', $currencies); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | |
@@ -939,14 +939,14 @@ discard block |
||
939 | 939 | * |
940 | 940 | * @return string The symbol to use for the currency |
941 | 941 | */ |
942 | -function give_currency_symbol( $currency = '', $decode_currency = false ) { |
|
942 | +function give_currency_symbol($currency = '', $decode_currency = false) { |
|
943 | 943 | |
944 | - if ( empty( $currency ) ) { |
|
944 | + if (empty($currency)) { |
|
945 | 945 | $currency = give_get_currency(); |
946 | 946 | } |
947 | 947 | |
948 | - $currencies = give_currency_symbols( $decode_currency ); |
|
949 | - $symbol = array_key_exists( $currency, $currencies ) ? $currencies[ $currency ] : $currency; |
|
948 | + $currencies = give_currency_symbols($decode_currency); |
|
949 | + $symbol = array_key_exists($currency, $currencies) ? $currencies[$currency] : $currency; |
|
950 | 950 | |
951 | 951 | /** |
952 | 952 | * Filter the currency symbol |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | * @param string $symbol |
957 | 957 | * @param string $currency |
958 | 958 | */ |
959 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
959 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
960 | 960 | } |
961 | 961 | |
962 | 962 | |
@@ -969,13 +969,13 @@ discard block |
||
969 | 969 | * |
970 | 970 | * @return string |
971 | 971 | */ |
972 | -function give_get_currency_name( $currency_code ) { |
|
972 | +function give_get_currency_name($currency_code) { |
|
973 | 973 | $currency_name = ''; |
974 | 974 | $currency_names = give_get_currencies(); |
975 | 975 | |
976 | - if ( $currency_code && array_key_exists( $currency_code, $currency_names ) ) { |
|
977 | - $currency_name = explode( '(', $currency_names[ $currency_code ] ); |
|
978 | - $currency_name = trim( current( $currency_name ) ); |
|
976 | + if ($currency_code && array_key_exists($currency_code, $currency_names)) { |
|
977 | + $currency_name = explode('(', $currency_names[$currency_code]); |
|
978 | + $currency_name = trim(current($currency_name)); |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | /** |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | * @param string $currency_name |
987 | 987 | * @param string $currency_code |
988 | 988 | */ |
989 | - return apply_filters( 'give_currency_name', $currency_name, $currency_code ); |
|
989 | + return apply_filters('give_currency_name', $currency_name, $currency_code); |
|
990 | 990 | } |
991 | 991 | |
992 | 992 | /** |
@@ -999,17 +999,17 @@ discard block |
||
999 | 999 | * |
1000 | 1000 | * @return mixed|string |
1001 | 1001 | */ |
1002 | -function give_currency_filter( $price = '', $args = array() ) { |
|
1002 | +function give_currency_filter($price = '', $args = array()) { |
|
1003 | 1003 | |
1004 | 1004 | // Get functions arguments. |
1005 | 1005 | $func_args = func_get_args(); |
1006 | 1006 | |
1007 | 1007 | // Backward compatibility: modify second param to array |
1008 | - if ( isset( $func_args[1] ) && is_string( $func_args[1] ) ) { |
|
1008 | + if (isset($func_args[1]) && is_string($func_args[1])) { |
|
1009 | 1009 | $args = array( |
1010 | - 'currency_code' => isset( $func_args[1] ) ? $func_args[1] : '', |
|
1011 | - 'decode_currency' => isset( $func_args[2] ) ? $func_args[2] : false, |
|
1012 | - 'form_id' => isset( $func_args[3] ) ? $func_args[3] : '', |
|
1010 | + 'currency_code' => isset($func_args[1]) ? $func_args[1] : '', |
|
1011 | + 'decode_currency' => isset($func_args[2]) ? $func_args[2] : false, |
|
1012 | + 'form_id' => isset($func_args[3]) ? $func_args[3] : '', |
|
1013 | 1013 | ); |
1014 | 1014 | } |
1015 | 1015 | |
@@ -1023,22 +1023,22 @@ discard block |
||
1023 | 1023 | ) |
1024 | 1024 | ); |
1025 | 1025 | |
1026 | - if ( empty( $args['currency_code'] ) || ! array_key_exists( (string) $args['currency_code'], give_get_currencies() ) ) { |
|
1027 | - $args['currency_code'] = give_get_currency( $args['form_id'] ); |
|
1026 | + if (empty($args['currency_code']) || ! array_key_exists((string) $args['currency_code'], give_get_currencies())) { |
|
1027 | + $args['currency_code'] = give_get_currency($args['form_id']); |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | - $args['position'] = give_get_option( 'currency_position', 'before' ); |
|
1030 | + $args['position'] = give_get_option('currency_position', 'before'); |
|
1031 | 1031 | |
1032 | 1032 | $negative = $price < 0; |
1033 | 1033 | |
1034 | - if ( $negative ) { |
|
1034 | + if ($negative) { |
|
1035 | 1035 | // Remove proceeding "-". |
1036 | - $price = substr( $price, 1 ); |
|
1036 | + $price = substr($price, 1); |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | - $args['symbol'] = give_currency_symbol( $args['currency_code'], $args['decode_currency'] ); |
|
1039 | + $args['symbol'] = give_currency_symbol($args['currency_code'], $args['decode_currency']); |
|
1040 | 1040 | |
1041 | - switch ( $args['currency_code'] ) : |
|
1041 | + switch ($args['currency_code']) : |
|
1042 | 1042 | case 'GBP' : |
1043 | 1043 | case 'BRL' : |
1044 | 1044 | case 'EUR' : |
@@ -1068,13 +1068,13 @@ discard block |
||
1068 | 1068 | case 'MAD' : |
1069 | 1069 | case 'KRW' : |
1070 | 1070 | case 'ZAR' : |
1071 | - $formatted = ( 'before' === $args['position'] ? $args['symbol'] . $price : $price . $args['symbol'] ); |
|
1071 | + $formatted = ('before' === $args['position'] ? $args['symbol'].$price : $price.$args['symbol']); |
|
1072 | 1072 | break; |
1073 | 1073 | case 'NOK': |
1074 | - $formatted = ( 'before' === $args['position'] ? $args['symbol'] . ' ' . $price : $price . ' ' . $args['symbol'] ); |
|
1074 | + $formatted = ('before' === $args['position'] ? $args['symbol'].' '.$price : $price.' '.$args['symbol']); |
|
1075 | 1075 | break; |
1076 | 1076 | default: |
1077 | - $formatted = ( 'before' === $args['position'] ? $args['symbol'] . ' ' . $price : $price . ' ' . $args['symbol'] ); |
|
1077 | + $formatted = ('before' === $args['position'] ? $args['symbol'].' '.$price : $price.' '.$args['symbol']); |
|
1078 | 1078 | break; |
1079 | 1079 | endswitch; |
1080 | 1080 | |
@@ -1083,7 +1083,7 @@ discard block |
||
1083 | 1083 | * |
1084 | 1084 | * @since 1.8.17 |
1085 | 1085 | */ |
1086 | - $formatted = apply_filters( 'give_currency_filter', $formatted, $args, $price ); |
|
1086 | + $formatted = apply_filters('give_currency_filter', $formatted, $args, $price); |
|
1087 | 1087 | |
1088 | 1088 | /** |
1089 | 1089 | * Filter formatted amount with currency |
@@ -1097,16 +1097,16 @@ discard block |
||
1097 | 1097 | * filter name will be give_usd_currency_filter_after |
1098 | 1098 | */ |
1099 | 1099 | $formatted = apply_filters( |
1100 | - 'give_' . strtolower( $args['currency_code'] ) . "_currency_filter_{$args['position']}", |
|
1100 | + 'give_'.strtolower($args['currency_code'])."_currency_filter_{$args['position']}", |
|
1101 | 1101 | $formatted, |
1102 | 1102 | $args['currency_code'], |
1103 | 1103 | $price, |
1104 | 1104 | $args |
1105 | 1105 | ); |
1106 | 1106 | |
1107 | - if ( $negative ) { |
|
1107 | + if ($negative) { |
|
1108 | 1108 | // Prepend the minus sign before the currency sign. |
1109 | - $formatted = '-' . $formatted; |
|
1109 | + $formatted = '-'.$formatted; |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | 1112 | return $formatted; |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | * |
1124 | 1124 | * @return bool |
1125 | 1125 | */ |
1126 | -function give_is_zero_based_currency( $currency = '' ) { |
|
1126 | +function give_is_zero_based_currency($currency = '') { |
|
1127 | 1127 | $zero_based_currency = array( |
1128 | 1128 | 'PYG', // Paraguayan Guarani. |
1129 | 1129 | 'GNF', // Guinean Franc. |
@@ -1143,12 +1143,12 @@ discard block |
||
1143 | 1143 | ); |
1144 | 1144 | |
1145 | 1145 | // Set default currency. |
1146 | - if ( empty( $currency ) ) { |
|
1146 | + if (empty($currency)) { |
|
1147 | 1147 | $currency = give_get_currency(); |
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | // Check for Zero Based Currency. |
1151 | - if ( in_array( $currency, $zero_based_currency ) ) { |
|
1151 | + if (in_array($currency, $zero_based_currency)) { |
|
1152 | 1152 | return true; |
1153 | 1153 | } |
1154 | 1154 | |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | * |
1164 | 1164 | * @return bool |
1165 | 1165 | */ |
1166 | -function give_is_right_to_left_supported_currency( $currency = '' ) { |
|
1166 | +function give_is_right_to_left_supported_currency($currency = '') { |
|
1167 | 1167 | $zero_based_currency = apply_filters( |
1168 | 1168 | 'give_right_to_left_supported_currency', |
1169 | 1169 | array( |
@@ -1179,12 +1179,12 @@ discard block |
||
1179 | 1179 | ); |
1180 | 1180 | |
1181 | 1181 | // Set default currency. |
1182 | - if ( empty( $currency ) ) { |
|
1182 | + if (empty($currency)) { |
|
1183 | 1183 | $currency = give_get_currency(); |
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | // Check for Zero Based Currency. |
1187 | - if ( in_array( $currency, $zero_based_currency ) ) { |
|
1187 | + if (in_array($currency, $zero_based_currency)) { |
|
1188 | 1188 | return true; |
1189 | 1189 | } |
1190 | 1190 |