@@ -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,81 +58,81 @@ 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 | - ) ); |
|
70 | + )); |
|
71 | 71 | |
72 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
72 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
73 | 73 | 'ajaxurl' => give_get_ajax_url(), |
74 | - 'loading' => __( 'Loading', 'give' ), |
|
74 | + 'loading' => __('Loading', 'give'), |
|
75 | 75 | // General loading message. |
76 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
76 | + 'select_option' => __('Please select an option', 'give'), |
|
77 | 77 | // Variable pricing error with multi-donation option enabled. |
78 | - 'default_gateway' => give_get_default_gateway( null ), |
|
79 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
78 | + 'default_gateway' => give_get_default_gateway(null), |
|
79 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
80 | 80 | 'number_decimals' => give_get_price_decimals(), |
81 | - ) ); |
|
81 | + )); |
|
82 | 82 | |
83 | 83 | // DEBUG is On. |
84 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
84 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
85 | 85 | |
86 | - if ( give_is_cc_verify_enabled() ) { |
|
87 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
88 | - wp_enqueue_script( 'give-cc-validator' ); |
|
86 | + if (give_is_cc_verify_enabled()) { |
|
87 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
88 | + wp_enqueue_script('give-cc-validator'); |
|
89 | 89 | } |
90 | 90 | |
91 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
92 | - wp_enqueue_script( 'give-float-labels' ); |
|
91 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
92 | + wp_enqueue_script('give-float-labels'); |
|
93 | 93 | |
94 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
95 | - wp_enqueue_script( 'give-blockui' ); |
|
94 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
95 | + wp_enqueue_script('give-blockui'); |
|
96 | 96 | |
97 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
98 | - wp_enqueue_script( 'give-qtip' ); |
|
97 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
98 | + wp_enqueue_script('give-qtip'); |
|
99 | 99 | |
100 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
101 | - wp_enqueue_script( 'give-accounting' ); |
|
100 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
101 | + wp_enqueue_script('give-accounting'); |
|
102 | 102 | |
103 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
104 | - wp_enqueue_script( 'give-magnific' ); |
|
103 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
104 | + wp_enqueue_script('give-magnific'); |
|
105 | 105 | |
106 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
107 | - wp_enqueue_script( 'give-checkout-global' ); |
|
106 | + wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
107 | + wp_enqueue_script('give-checkout-global'); |
|
108 | 108 | |
109 | 109 | // General scripts. |
110 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
111 | - wp_enqueue_script( 'give-scripts' ); |
|
110 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
111 | + wp_enqueue_script('give-scripts'); |
|
112 | 112 | |
113 | 113 | // Load AJAX scripts, if enabled. |
114 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
115 | - wp_enqueue_script( 'give-ajax' ); |
|
114 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
115 | + wp_enqueue_script('give-ajax'); |
|
116 | 116 | |
117 | 117 | // Localize / Pass AJAX vars from PHP, |
118 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars ); |
|
119 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
118 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars); |
|
119 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
120 | 120 | |
121 | 121 | } else { |
122 | 122 | |
123 | 123 | // DEBUG is OFF (one JS file to rule them all!). |
124 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
125 | - wp_enqueue_script( 'give' ); |
|
124 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
125 | + wp_enqueue_script('give'); |
|
126 | 126 | |
127 | 127 | // Localize / Pass AJAX vars from PHP. |
128 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
129 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
128 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
129 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
130 | 130 | |
131 | 131 | } |
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
135 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
136 | 136 | |
137 | 137 | /** |
138 | 138 | * Register styles. |
@@ -145,16 +145,16 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function give_register_styles() { |
147 | 147 | |
148 | - if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
148 | + if ( ! give_is_setting_enabled(give_get_option('css'))) { |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
152 | - wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
153 | - wp_enqueue_style( 'give-styles' ); |
|
152 | + wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
153 | + wp_enqueue_style('give-styles'); |
|
154 | 154 | |
155 | 155 | } |
156 | 156 | |
157 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
157 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
158 | 158 | |
159 | 159 | |
160 | 160 | /** |
@@ -167,19 +167,19 @@ discard block |
||
167 | 167 | function give_get_stylesheet_uri() { |
168 | 168 | |
169 | 169 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
170 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
170 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
171 | 171 | |
172 | 172 | // LTR or RTL files. |
173 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
173 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
174 | 174 | |
175 | - $file = 'give' . $direction . $suffix . '.css'; |
|
175 | + $file = 'give'.$direction.$suffix.'.css'; |
|
176 | 176 | $templates_dir = give_get_theme_template_dir_name(); |
177 | 177 | |
178 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
179 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
180 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
181 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
182 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
178 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
179 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css'; |
|
180 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
181 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css'; |
|
182 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
183 | 183 | |
184 | 184 | $uri = false; |
185 | 185 | |
@@ -189,23 +189,23 @@ discard block |
||
189 | 189 | * followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
190 | 190 | * This allows users to copy just give.css to their theme. |
191 | 191 | */ |
192 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
193 | - if ( ! empty( $nonmin ) ) { |
|
194 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
192 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
193 | + if ( ! empty($nonmin)) { |
|
194 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
195 | 195 | } else { |
196 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
196 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
197 | 197 | } |
198 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
199 | - if ( ! empty( $nonmin ) ) { |
|
200 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
198 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
199 | + if ( ! empty($nonmin)) { |
|
200 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
201 | 201 | } else { |
202 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
202 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
203 | 203 | } |
204 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
205 | - $uri = trailingslashit( give_get_templates_url() ) . $file; |
|
204 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
205 | + $uri = trailingslashit(give_get_templates_url()).$file; |
|
206 | 206 | } |
207 | 207 | |
208 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
208 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
209 | 209 | |
210 | 210 | } |
211 | 211 | |
@@ -222,79 +222,79 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return void |
224 | 224 | */ |
225 | -function give_load_admin_scripts( $hook ) { |
|
225 | +function give_load_admin_scripts($hook) { |
|
226 | 226 | |
227 | 227 | global $post, $post_type; |
228 | 228 | |
229 | 229 | $give_options = give_get_settings(); |
230 | 230 | |
231 | 231 | // Directories of assets. |
232 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
233 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
234 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
232 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
233 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
234 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
235 | 235 | |
236 | 236 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
237 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
237 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
238 | 238 | |
239 | 239 | // LTR or RTL files. |
240 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
240 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
241 | 241 | |
242 | 242 | // Global Admin. |
243 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
244 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
243 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
244 | + wp_enqueue_style('give-admin-bar-notification'); |
|
245 | 245 | |
246 | 246 | // Give Admin Only. |
247 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
247 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
248 | 248 | return; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // CSS. |
252 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
253 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
254 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION ); |
|
255 | - wp_enqueue_style( 'give-admin' ); |
|
256 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
257 | - wp_enqueue_style( 'jquery-chosen' ); |
|
258 | - wp_enqueue_style( 'thickbox' ); |
|
259 | - wp_enqueue_style( 'wp-color-picker' ); |
|
252 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
253 | + wp_enqueue_style('jquery-ui-css'); |
|
254 | + wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION); |
|
255 | + wp_enqueue_style('give-admin'); |
|
256 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
257 | + wp_enqueue_style('jquery-chosen'); |
|
258 | + wp_enqueue_style('thickbox'); |
|
259 | + wp_enqueue_style('wp-color-picker'); |
|
260 | 260 | |
261 | 261 | |
262 | 262 | // JS. |
263 | - wp_register_script( 'give-selector-cache', $js_plugins . 'selector-cache' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
264 | - wp_enqueue_script( 'give-selector-cache' ); |
|
263 | + wp_register_script('give-selector-cache', $js_plugins.'selector-cache'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
264 | + wp_enqueue_script('give-selector-cache'); |
|
265 | 265 | |
266 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
267 | - wp_enqueue_script( 'jquery-chosen' ); |
|
266 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
267 | + wp_enqueue_script('jquery-chosen'); |
|
268 | 268 | |
269 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
270 | - wp_enqueue_script( 'give-accounting' ); |
|
269 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
270 | + wp_enqueue_script('give-accounting'); |
|
271 | 271 | |
272 | - wp_enqueue_script( 'wp-color-picker' ); |
|
273 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
274 | - wp_enqueue_script( 'thickbox' ); |
|
272 | + wp_enqueue_script('wp-color-picker'); |
|
273 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
274 | + wp_enqueue_script('thickbox'); |
|
275 | 275 | |
276 | - 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 ); |
|
277 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
276 | + 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); |
|
277 | + wp_enqueue_script('give-admin-scripts'); |
|
278 | 278 | |
279 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
280 | - wp_enqueue_script( 'jquery-flot' ); |
|
279 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
280 | + wp_enqueue_script('jquery-flot'); |
|
281 | 281 | |
282 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
283 | - wp_enqueue_script( 'give-qtip' ); |
|
282 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
283 | + wp_enqueue_script('give-qtip'); |
|
284 | 284 | |
285 | - wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
286 | - wp_enqueue_script( 'give-repeatable-fields' ); |
|
285 | + wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
286 | + wp_enqueue_script('give-repeatable-fields'); |
|
287 | 287 | |
288 | 288 | // Forms CPT Script. |
289 | - if ( $post_type === 'give_forms' ) { |
|
290 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
291 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
289 | + if ($post_type === 'give_forms') { |
|
290 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
291 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | // Settings Scripts. |
295 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) { |
|
296 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
297 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
295 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
296 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
297 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | // Price Separators. |
@@ -302,81 +302,81 @@ discard block |
||
302 | 302 | $decimal_separator = give_get_price_decimal_separator(); |
303 | 303 | |
304 | 304 | // Localize strings & variables for JS. |
305 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
306 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
305 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
306 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
307 | 307 | 'give_version' => GIVE_VERSION, |
308 | 308 | 'thousands_separator' => $thousand_separator, |
309 | 309 | 'decimal_separator' => $decimal_separator, |
310 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
311 | - 'delete_payment' => __( 'Are you sure you want to delete this payment?', 'give' ), |
|
312 | - 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ), |
|
313 | - 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ), |
|
314 | - 'regenerate_api_key' => __( 'Are you sure you want to regenerate this API key?', 'give' ), |
|
315 | - 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ), |
|
316 | - 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ), |
|
317 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
318 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
319 | - 'currency_sign' => give_currency_filter( '' ), |
|
320 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
321 | - 'currency_decimals' => give_currency_decimal_filter( give_get_price_decimals() ), |
|
322 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
323 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
324 | - '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' ), |
|
325 | - 'delete_test_donor' => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ), |
|
326 | - 'delete_import_donor' => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ), |
|
327 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
310 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
311 | + 'delete_payment' => __('Are you sure you want to delete this payment?', 'give'), |
|
312 | + 'delete_payment_note' => __('Are you sure you want to delete this note?', 'give'), |
|
313 | + 'revoke_api_key' => __('Are you sure you want to revoke this API key?', 'give'), |
|
314 | + 'regenerate_api_key' => __('Are you sure you want to regenerate this API key?', 'give'), |
|
315 | + 'resend_receipt' => __('Are you sure you want to resend the donation receipt?', 'give'), |
|
316 | + 'disconnect_user' => __('Are you sure you want to disconnect the user from this donor?', 'give'), |
|
317 | + 'one_option' => __('Choose a form', 'give'), |
|
318 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
319 | + 'currency_sign' => give_currency_filter(''), |
|
320 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
321 | + 'currency_decimals' => give_currency_decimal_filter(give_get_price_decimals()), |
|
322 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
323 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
324 | + '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'), |
|
325 | + 'delete_test_donor' => __('Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give'), |
|
326 | + 'delete_import_donor' => __('Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give'), |
|
327 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
328 | 328 | /* translators : %s: Donation form options metabox */ |
329 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this level?', 'give' ), |
|
330 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
331 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
332 | - 'search_placeholder' => __( 'Type to search all forms', 'give' ), |
|
333 | - 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ), |
|
334 | - 'search_placeholder_country' => __( 'Type to search all countries', 'give' ), |
|
335 | - 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ), |
|
329 | + 'confirm_before_remove_row_text' => __('Do you want to delete this level?', 'give'), |
|
330 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
331 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
332 | + 'search_placeholder' => __('Type to search all forms', 'give'), |
|
333 | + 'search_placeholder_donor' => __('Type to search all donors', 'give'), |
|
334 | + 'search_placeholder_country' => __('Type to search all countries', 'give'), |
|
335 | + 'search_placeholder_state' => __('Type to search all states/provinces', 'give'), |
|
336 | 336 | 'bulk_action' => array( |
337 | 337 | 'delete' => array( |
338 | - 'zero' => __( 'You must choose at least one or more payments to delete.', 'give' ), |
|
339 | - 'single' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
340 | - 'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
338 | + 'zero' => __('You must choose at least one or more payments to delete.', 'give'), |
|
339 | + 'single' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
340 | + 'multiple' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
341 | 341 | ), |
342 | 342 | 'resend-receipt' => array( |
343 | - 'zero' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
344 | - 'single' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
345 | - 'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
343 | + 'zero' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
344 | + 'single' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
345 | + 'multiple' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
346 | 346 | ), |
347 | 347 | 'set-to-status' => array( |
348 | - 'zero' => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ), |
|
349 | - 'single' => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ), |
|
350 | - 'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ), |
|
348 | + 'zero' => __('You must choose at least one or more donations to set status to {status}.', 'give'), |
|
349 | + 'single' => __('Are you sure you want to set status of this donation to {status}?', 'give'), |
|
350 | + 'multiple' => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'), |
|
351 | 351 | ), |
352 | 352 | ), |
353 | 353 | 'metabox_fields' => array( |
354 | 354 | 'media' => array( |
355 | - 'button_title' => __( 'Choose Image', 'give' ), |
|
355 | + 'button_title' => __('Choose Image', 'give'), |
|
356 | 356 | ), |
357 | 357 | 'file' => array( |
358 | - 'button_title' => __( 'Choose File', 'give' ), |
|
358 | + 'button_title' => __('Choose File', 'give'), |
|
359 | 359 | ), |
360 | 360 | ), |
361 | 361 | 'chosen' => array( |
362 | - 'no_results_msg' => __( 'No results match {search_term}', 'give' ), |
|
363 | - 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ), |
|
362 | + 'no_results_msg' => __('No results match {search_term}', 'give'), |
|
363 | + 'ajax_search_msg' => __('Searching results for match {search_term}', 'give'), |
|
364 | 364 | ), |
365 | - 'db_update_confirmation_msg_button' => __( 'Run Updates', 'give' ), |
|
366 | - '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' ), |
|
367 | - 'error_message' => __( 'Something went wrong kindly try again!', 'give' ), |
|
365 | + 'db_update_confirmation_msg_button' => __('Run Updates', 'give'), |
|
366 | + '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'), |
|
367 | + 'error_message' => __('Something went wrong kindly try again!', 'give'), |
|
368 | 368 | 'give_donation_import' => 'give_donation_import', |
369 | - 'setting_not_save_message' => __( 'Changes you made may not be saved.', 'give' ), |
|
370 | - ) ); |
|
369 | + 'setting_not_save_message' => __('Changes you made may not be saved.', 'give'), |
|
370 | + )); |
|
371 | 371 | |
372 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) { |
|
372 | + if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) { |
|
373 | 373 | // call for new media manager. |
374 | 374 | wp_enqueue_media(); |
375 | 375 | } |
376 | 376 | |
377 | 377 | } |
378 | 378 | |
379 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
379 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
380 | 380 | |
381 | 381 | /** |
382 | 382 | * Admin Give Icon |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | ?> |
392 | 392 | <style type="text/css" media="screen"> |
393 | 393 | |
394 | - <?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?> |
|
394 | + <?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?> |
|
395 | 395 | @font-face { |
396 | 396 | font-family: 'give-icomoon'; |
397 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
398 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
399 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
400 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
397 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
398 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
399 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
400 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
401 | 401 | font-weight: normal; |
402 | 402 | font-style: normal; |
403 | 403 | } |
@@ -416,4 +416,4 @@ discard block |
||
416 | 416 | <?php |
417 | 417 | } |
418 | 418 | |
419 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
419 | +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 | |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return bool true if has variable prices, false otherwise |
25 | 25 | */ |
26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
26 | +function give_has_variable_prices($form_id = 0) { |
|
27 | 27 | |
28 | - if ( empty( $form_id ) ) { |
|
28 | + if (empty($form_id)) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - $form = new Give_Donate_Form( $form_id ); |
|
32 | + $form = new Give_Donate_Form($form_id); |
|
33 | 33 | |
34 | 34 | return $form->has_variable_prices(); |
35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array|bool Variable prices |
46 | 46 | */ |
47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
47 | +function give_get_variable_prices($form_id = 0) { |
|
48 | 48 | |
49 | - if ( empty( $form_id ) ) { |
|
49 | + if (empty($form_id)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - $form = new Give_Donate_Form( $form_id ); |
|
53 | + $form = new Give_Donate_Form($form_id); |
|
54 | 54 | |
55 | 55 | return $form->prices; |
56 | 56 | |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return array Variable prices |
67 | 67 | */ |
68 | -function give_get_variable_price_ids( $form_id = 0 ) { |
|
69 | - if( ! ( $prices = give_get_variable_prices( $form_id ) ) ) { |
|
68 | +function give_get_variable_price_ids($form_id = 0) { |
|
69 | + if ( ! ($prices = give_get_variable_prices($form_id))) { |
|
70 | 70 | return array(); |
71 | 71 | } |
72 | 72 | |
73 | 73 | $price_ids = array(); |
74 | - foreach ( $prices as $price ){ |
|
74 | + foreach ($prices as $price) { |
|
75 | 75 | $price_ids[] = $price['_give_id']['level_id']; |
76 | 76 | } |
77 | 77 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return string $default_price |
91 | 91 | */ |
92 | -function give_get_default_multilevel_amount( $form_id ) { |
|
92 | +function give_get_default_multilevel_amount($form_id) { |
|
93 | 93 | $default_price = '1.00'; |
94 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
94 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
95 | 95 | |
96 | - foreach ( $prices as $price ) { |
|
96 | + foreach ($prices as $price) { |
|
97 | 97 | |
98 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
98 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
99 | 99 | $default_price = $price['_give_amount']; |
100 | 100 | } |
101 | 101 | |
@@ -116,19 +116,19 @@ discard block |
||
116 | 116 | * @return string $default_price |
117 | 117 | * @since 1.0 |
118 | 118 | */ |
119 | -function give_get_default_form_amount( $form_id ) { |
|
119 | +function give_get_default_form_amount($form_id) { |
|
120 | 120 | |
121 | - if ( give_has_variable_prices( $form_id ) ) { |
|
121 | + if (give_has_variable_prices($form_id)) { |
|
122 | 122 | |
123 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
123 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
124 | 124 | |
125 | 125 | } else { |
126 | 126 | |
127 | - $default_amount = give_get_meta( $form_id, '_give_set_price', true ); |
|
127 | + $default_amount = give_get_meta($form_id, '_give_set_price', true); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
131 | - return apply_filters( 'give_default_form_amount', $default_amount, $form_id ); |
|
131 | + return apply_filters('give_default_form_amount', $default_amount, $form_id); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
149 | +function give_is_custom_price_mode($form_id = 0) { |
|
150 | 150 | |
151 | - if ( empty( $form_id ) ) { |
|
151 | + if (empty($form_id)) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | - $form = new Give_Donate_Form( $form_id ); |
|
155 | + $form = new Give_Donate_Form($form_id); |
|
156 | 156 | |
157 | 157 | return $form->is_custom_price_mode(); |
158 | 158 | } |
159 | 159 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,34 +26,34 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_set_settings_with_disable_prefix( $old_settings, $settings ) { |
|
29 | +function give_set_settings_with_disable_prefix($old_settings, $settings) { |
|
30 | 30 | // Bailout. |
31 | - if ( ! function_exists( 'give_v18_renamed_core_settings' ) ) { |
|
31 | + if ( ! function_exists('give_v18_renamed_core_settings')) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // Get old setting names. |
36 | - $old_settings = array_flip( give_v18_renamed_core_settings() ); |
|
36 | + $old_settings = array_flip(give_v18_renamed_core_settings()); |
|
37 | 37 | $update_setting = false; |
38 | 38 | |
39 | - foreach ( $settings as $key => $value ) { |
|
39 | + foreach ($settings as $key => $value) { |
|
40 | 40 | |
41 | 41 | // Check 1. Check if new option is really updated or not. |
42 | 42 | // Check 2. Continue if key is not renamed. |
43 | - if ( ! isset( $old_settings[ $key ] ) ) { |
|
43 | + if ( ! isset($old_settings[$key])) { |
|
44 | 44 | continue; |
45 | 45 | } |
46 | 46 | |
47 | 47 | // Set old setting. |
48 | - $settings[ $old_settings[ $key ] ] = 'on'; |
|
48 | + $settings[$old_settings[$key]] = 'on'; |
|
49 | 49 | |
50 | 50 | // Do not need to set old setting if new setting is not set. |
51 | 51 | if ( |
52 | - ( give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'disable_' ) ) ) |
|
53 | - || ( ! give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'enable_' ) ) ) |
|
52 | + (give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'disable_'))) |
|
53 | + || ( ! give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'enable_'))) |
|
54 | 54 | |
55 | 55 | ) { |
56 | - unset( $settings[ $old_settings[ $key ] ] ); |
|
56 | + unset($settings[$old_settings[$key]]); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Tell bot to update setting. |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // Update setting if any old setting set. |
64 | - if ( $update_setting ) { |
|
65 | - update_option( 'give_settings', $settings ); |
|
64 | + if ($update_setting) { |
|
65 | + update_option('give_settings', $settings); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -add_action( 'update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 ); |
|
69 | +add_action('update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Check spam through Akismet. |
@@ -80,45 +80,45 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return bool|mixed |
82 | 82 | */ |
83 | -function give_akismet( $spam ) { |
|
83 | +function give_akismet($spam) { |
|
84 | 84 | |
85 | 85 | // Bail out, If spam. |
86 | - if ( $spam ) { |
|
86 | + if ($spam) { |
|
87 | 87 | return $spam; |
88 | 88 | } |
89 | 89 | |
90 | 90 | // Bail out, if Akismet key not exist. |
91 | - if ( ! give_check_akismet_key() ) { |
|
91 | + if ( ! give_check_akismet_key()) { |
|
92 | 92 | return false; |
93 | 93 | } |
94 | 94 | |
95 | 95 | // Build args array. |
96 | 96 | $args = array(); |
97 | 97 | |
98 | - $args['comment_author'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
99 | - $args['comment_author_email'] = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
100 | - $args['blog'] = get_option( 'home' ); |
|
98 | + $args['comment_author'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
99 | + $args['comment_author_email'] = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
100 | + $args['blog'] = get_option('home'); |
|
101 | 101 | $args['blog_lang'] = get_locale(); |
102 | - $args['blog_charset'] = get_option( 'blog_charset' ); |
|
102 | + $args['blog_charset'] = get_option('blog_charset'); |
|
103 | 103 | $args['user_ip'] = $_SERVER['REMOTE_ADDR']; |
104 | 104 | $args['user_agent'] = $_SERVER['HTTP_USER_AGENT']; |
105 | 105 | $args['referrer'] = $_SERVER['HTTP_REFERER']; |
106 | 106 | $args['comment_type'] = 'contact-form'; |
107 | 107 | |
108 | - $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ); |
|
108 | + $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'); |
|
109 | 109 | |
110 | - foreach ( $_SERVER as $key => $value ) { |
|
111 | - if ( ! in_array( $key, (array) $ignore ) ) { |
|
110 | + foreach ($_SERVER as $key => $value) { |
|
111 | + if ( ! in_array($key, (array) $ignore)) { |
|
112 | 112 | $args["$key"] = $value; |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | 116 | // It will return Akismet spam detect API response. |
117 | - return give_akismet_spam_check( $args ); |
|
117 | + return give_akismet_spam_check($args); |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | |
121 | -add_filter( 'give_spam', 'give_akismet' ); |
|
121 | +add_filter('give_spam', 'give_akismet'); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Check Akismet API Key. |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | * @return bool |
129 | 129 | */ |
130 | 130 | function give_check_akismet_key() { |
131 | - if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) { // Akismet v3.0+ |
|
131 | + if (is_callable(array('Akismet', 'get_api_key'))) { // Akismet v3.0+ |
|
132 | 132 | return (bool) Akismet::get_api_key(); |
133 | 133 | } |
134 | 134 | |
135 | - if ( function_exists( 'akismet_get_key' ) ) { |
|
135 | + if (function_exists('akismet_get_key')) { |
|
136 | 136 | return (bool) akismet_get_key(); |
137 | 137 | } |
138 | 138 | |
@@ -148,24 +148,24 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return bool|mixed |
150 | 150 | */ |
151 | -function give_akismet_spam_check( $args ) { |
|
151 | +function give_akismet_spam_check($args) { |
|
152 | 152 | global $akismet_api_host, $akismet_api_port; |
153 | 153 | |
154 | 154 | $spam = false; |
155 | - $query_string = http_build_query( $args ); |
|
155 | + $query_string = http_build_query($args); |
|
156 | 156 | |
157 | - if ( is_callable( array( 'Akismet', 'http_post' ) ) ) { // Akismet v3.0+ |
|
158 | - $response = Akismet::http_post( $query_string, 'comment-check' ); |
|
157 | + if (is_callable(array('Akismet', 'http_post'))) { // Akismet v3.0+ |
|
158 | + $response = Akismet::http_post($query_string, 'comment-check'); |
|
159 | 159 | } else { |
160 | - $response = akismet_http_post( $query_string, $akismet_api_host, |
|
161 | - '/1.1/comment-check', $akismet_api_port ); |
|
160 | + $response = akismet_http_post($query_string, $akismet_api_host, |
|
161 | + '/1.1/comment-check', $akismet_api_port); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // It's spam if response status is true. |
165 | - if ( 'true' === $response[1] ) { |
|
165 | + if ('true' === $response[1]) { |
|
166 | 166 | $spam = true; |
167 | 167 | } |
168 | 168 | |
169 | 169 | // Allow developer to modified Akismet spam detection response. |
170 | - return apply_filters( 'give_akismet_spam_check', $spam, $args ); |
|
170 | + return apply_filters('give_akismet_spam_check', $spam, $args); |
|
171 | 171 | } |
172 | 172 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | /* @var WPDB $wpdb */ |
44 | 44 | global $wpdb; |
45 | 45 | |
46 | - $wpdb->customermeta = $this->table_name = $wpdb->prefix . 'give_customermeta'; |
|
46 | + $wpdb->customermeta = $this->table_name = $wpdb->prefix.'give_customermeta'; |
|
47 | 47 | $this->primary_key = 'meta_id'; |
48 | 48 | $this->version = '1.0'; |
49 | 49 | |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
83 | 83 | */ |
84 | - public function get_meta( $donor_id = 0, $meta_key = '', $single = false ) { |
|
85 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
86 | - if ( false === $donor_id ) { |
|
84 | + public function get_meta($donor_id = 0, $meta_key = '', $single = false) { |
|
85 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
86 | + if (false === $donor_id) { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | |
90 | - return get_metadata( 'customer', $donor_id, $meta_key, $single ); |
|
90 | + return get_metadata('customer', $donor_id, $meta_key, $single); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return bool False for failure. True for success. |
107 | 107 | */ |
108 | - public function add_meta( $donor_id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
109 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
110 | - if ( false === $donor_id ) { |
|
108 | + public function add_meta($donor_id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
109 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
110 | + if (false === $donor_id) { |
|
111 | 111 | return false; |
112 | 112 | } |
113 | 113 | |
114 | - return add_metadata( 'customer', $donor_id, $meta_key, $meta_value, $unique ); |
|
114 | + return add_metadata('customer', $donor_id, $meta_key, $meta_value, $unique); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return bool False on failure, true if success. |
136 | 136 | */ |
137 | - public function update_meta( $donor_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
138 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
139 | - if ( false === $donor_id ) { |
|
137 | + public function update_meta($donor_id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
138 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
139 | + if (false === $donor_id) { |
|
140 | 140 | return false; |
141 | 141 | } |
142 | 142 | |
143 | - return update_metadata( 'customer', $donor_id, $meta_key, $meta_value, $prev_value ); |
|
143 | + return update_metadata('customer', $donor_id, $meta_key, $meta_value, $prev_value); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return bool False for failure. True for success. |
163 | 163 | */ |
164 | - public function delete_meta( $donor_id = 0, $meta_key = '', $meta_value = '' ) { |
|
165 | - return delete_metadata( 'customer', $donor_id, $meta_key, $meta_value ); |
|
164 | + public function delete_meta($donor_id = 0, $meta_key = '', $meta_value = '') { |
|
165 | + return delete_metadata('customer', $donor_id, $meta_key, $meta_value); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return bool False for failure. True for success. |
177 | 177 | */ |
178 | - public function delete_all_meta( $donor_id = 0 ) { |
|
178 | + public function delete_all_meta($donor_id = 0) { |
|
179 | 179 | global $wpdb; |
180 | - $wpdb->delete( $this->table_name, array( 'customer_id' => $donor_id ), array( '%d' ) ); |
|
180 | + $wpdb->delete($this->table_name, array('customer_id' => $donor_id), array('%d')); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function create_table() { |
192 | 192 | |
193 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
193 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
194 | 194 | |
195 | 195 | $sql = "CREATE TABLE {$this->table_name} ( |
196 | 196 | meta_id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | KEY meta_key (meta_key) |
203 | 203 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
204 | 204 | |
205 | - dbDelta( $sql ); |
|
205 | + dbDelta($sql); |
|
206 | 206 | |
207 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
207 | + update_option($this->table_name.'_db_version', $this->version); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -217,23 +217,23 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return int|bool The normalized donor ID or false if it's found to not be valid. |
219 | 219 | */ |
220 | - private function sanitize_donor_id( $donor_id ) { |
|
221 | - if ( ! is_numeric( $donor_id ) ) { |
|
220 | + private function sanitize_donor_id($donor_id) { |
|
221 | + if ( ! is_numeric($donor_id)) { |
|
222 | 222 | return false; |
223 | 223 | } |
224 | 224 | |
225 | 225 | $donor_id = (int) $donor_id; |
226 | 226 | |
227 | 227 | // We were given a non positive number. |
228 | - if ( absint( $donor_id ) !== $donor_id ) { |
|
228 | + if (absint($donor_id) !== $donor_id) { |
|
229 | 229 | return false; |
230 | 230 | } |
231 | 231 | |
232 | - if ( empty( $donor_id ) ) { |
|
232 | + if (empty($donor_id)) { |
|
233 | 233 | return false; |
234 | 234 | } |
235 | 235 | |
236 | - return absint( $donor_id ); |
|
236 | + return absint($donor_id); |
|
237 | 237 | |
238 | 238 | } |
239 | 239 |
@@ -288,8 +288,8 @@ |
||
288 | 288 | |
289 | 289 | // Check spam detect. |
290 | 290 | if ( isset( $_POST['action'] ) |
291 | - && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
292 | - && give_is_spam_donation() |
|
291 | + && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
292 | + && give_is_spam_donation() |
|
293 | 293 | ) { |
294 | 294 | give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); |
295 | 295 | } |
@@ -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 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.0 |
32 | 32 | */ |
33 | - do_action( 'give_pre_process_donation' ); |
|
33 | + do_action('give_pre_process_donation'); |
|
34 | 34 | |
35 | 35 | // Validate the form $_POST data |
36 | 36 | $valid_data = give_donation_form_validate_fields(); |
@@ -45,26 +45,26 @@ discard block |
||
45 | 45 | * @param bool|array $valid_data Validate fields. |
46 | 46 | * @param array $_POST Array of variables passed via the HTTP POST. |
47 | 47 | */ |
48 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
48 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
49 | 49 | |
50 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
50 | + $is_ajax = isset($_POST['give_ajax']); |
|
51 | 51 | |
52 | 52 | // Process the login form |
53 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
53 | + if (isset($_POST['give_login_submit'])) { |
|
54 | 54 | give_process_form_login(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Validate the user |
58 | - $user = give_get_donation_form_user( $valid_data ); |
|
58 | + $user = give_get_donation_form_user($valid_data); |
|
59 | 59 | |
60 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
61 | - if ( $is_ajax ) { |
|
60 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
61 | + if ($is_ajax) { |
|
62 | 62 | /** |
63 | 63 | * Fires when AJAX sends back errors from the donation form. |
64 | 64 | * |
65 | 65 | * @since 1.0 |
66 | 66 | */ |
67 | - do_action( 'give_ajax_donation_errors' ); |
|
67 | + do_action('give_ajax_donation_errors'); |
|
68 | 68 | give_die(); |
69 | 69 | } else { |
70 | 70 | return false; |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | // If AJAX send back success to proceed with form submission |
75 | - if ( $is_ajax ) { |
|
75 | + if ($is_ajax) { |
|
76 | 76 | echo 'success'; |
77 | 77 | give_die(); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // After AJAX: Setup session if not using php_sessions |
81 | - if ( ! Give()->session->use_php_sessions() ) { |
|
81 | + if ( ! Give()->session->use_php_sessions()) { |
|
82 | 82 | // Double-check that set_cookie is publicly accessible; |
83 | 83 | // we're using a slightly modified class-wp-sessions.php |
84 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
85 | - if ( $session_reflection->isPublic() ) { |
|
84 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
85 | + if ($session_reflection->isPublic()) { |
|
86 | 86 | // Manually set the cookie. |
87 | 87 | Give()->session->init()->set_cookie(); |
88 | 88 | } |
@@ -97,20 +97,19 @@ discard block |
||
97 | 97 | 'address' => $user['address'], |
98 | 98 | ); |
99 | 99 | |
100 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
100 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
101 | 101 | |
102 | - $price = isset( $_POST['give-amount'] ) ? |
|
103 | - (float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) : |
|
104 | - '0.00'; |
|
105 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
102 | + $price = isset($_POST['give-amount']) ? |
|
103 | + (float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00'; |
|
104 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
106 | 105 | |
107 | 106 | // Setup donation information |
108 | 107 | $donation_data = array( |
109 | 108 | 'price' => $price, |
110 | 109 | 'purchase_key' => $purchase_key, |
111 | 110 | 'user_email' => $user['user_email'], |
112 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
113 | - 'user_info' => stripslashes_deep( $user_info ), |
|
111 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
112 | + 'user_info' => stripslashes_deep($user_info), |
|
114 | 113 | 'post_data' => $_POST, |
115 | 114 | 'gateway' => $valid_data['gateway'], |
116 | 115 | 'card_info' => $valid_data['cc_info'], |
@@ -130,10 +129,10 @@ discard block |
||
130 | 129 | * @param array $user_info Array containing basic user information. |
131 | 130 | * @param bool|array $valid_data Validate fields. |
132 | 131 | */ |
133 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
132 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
134 | 133 | |
135 | 134 | // Sanity check for price |
136 | - if ( ! $donation_data['price'] ) { |
|
135 | + if ( ! $donation_data['price']) { |
|
137 | 136 | // Revert to manual |
138 | 137 | $donation_data['gateway'] = 'manual'; |
139 | 138 | $_POST['give-gateway'] = 'manual'; |
@@ -144,27 +143,27 @@ discard block |
||
144 | 143 | * |
145 | 144 | * @since 1.7 |
146 | 145 | */ |
147 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
146 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
148 | 147 | |
149 | 148 | // Setup the data we're storing in the donation session |
150 | 149 | $session_data = $donation_data; |
151 | 150 | |
152 | 151 | // Make sure credit card numbers are never stored in sessions |
153 | - unset( $session_data['card_info']['card_number'] ); |
|
154 | - unset( $session_data['post_data']['card_number'] ); |
|
152 | + unset($session_data['card_info']['card_number']); |
|
153 | + unset($session_data['post_data']['card_number']); |
|
155 | 154 | |
156 | 155 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
157 | - give_set_purchase_session( $session_data ); |
|
156 | + give_set_purchase_session($session_data); |
|
158 | 157 | |
159 | 158 | // Send info to the gateway for payment processing |
160 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
159 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
161 | 160 | give_die(); |
162 | 161 | |
163 | 162 | } |
164 | 163 | |
165 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
166 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
167 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
164 | +add_action('give_purchase', 'give_process_donation_form'); |
|
165 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
166 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
168 | 167 | |
169 | 168 | |
170 | 169 | /** |
@@ -177,29 +176,29 @@ discard block |
||
177 | 176 | * |
178 | 177 | * @return void |
179 | 178 | */ |
180 | -function give_check_logged_in_user_for_existing_email( $valid_data, $post ) { |
|
179 | +function give_check_logged_in_user_for_existing_email($valid_data, $post) { |
|
181 | 180 | |
182 | 181 | // Verify that the email address belongs to this customer. |
183 | - if ( is_user_logged_in() ) { |
|
182 | + if (is_user_logged_in()) { |
|
184 | 183 | |
185 | 184 | $submitted_email = $valid_data['logged_in_user']['user_email']; |
186 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
185 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
187 | 186 | |
188 | 187 | // If this email address is not registered with this customer, see if it belongs to any other customer |
189 | 188 | if ( |
190 | 189 | $submitted_email !== $donor->email |
191 | - && ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails ) ) |
|
190 | + && (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails)) |
|
192 | 191 | ) { |
193 | - $found_donor = new Give_Donor( $submitted_email ); |
|
192 | + $found_donor = new Give_Donor($submitted_email); |
|
194 | 193 | |
195 | - if ( $found_donor->id > 0 ) { |
|
196 | - give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), $donor->email, $submitted_email ) ); |
|
194 | + if ($found_donor->id > 0) { |
|
195 | + give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $donor->email, $submitted_email)); |
|
197 | 196 | } |
198 | 197 | } |
199 | 198 | } |
200 | 199 | } |
201 | 200 | |
202 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 ); |
|
201 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2); |
|
203 | 202 | |
204 | 203 | /** |
205 | 204 | * Process the checkout login form |
@@ -209,49 +208,49 @@ discard block |
||
209 | 208 | * @return void |
210 | 209 | */ |
211 | 210 | function give_process_form_login() { |
212 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
211 | + $is_ajax = isset($_POST['give_ajax']); |
|
213 | 212 | |
214 | 213 | $user_data = give_donation_form_validate_user_login(); |
215 | 214 | |
216 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
217 | - if ( $is_ajax ) { |
|
215 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
216 | + if ($is_ajax) { |
|
218 | 217 | /** |
219 | 218 | * Fires when AJAX sends back errors from the donation form. |
220 | 219 | * |
221 | 220 | * @since 1.0 |
222 | 221 | */ |
223 | 222 | ob_start(); |
224 | - do_action( 'give_ajax_donation_errors' ); |
|
223 | + do_action('give_ajax_donation_errors'); |
|
225 | 224 | $message = ob_get_contents(); |
226 | 225 | ob_end_clean(); |
227 | - wp_send_json_error( $message ); |
|
226 | + wp_send_json_error($message); |
|
228 | 227 | } else { |
229 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
228 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
230 | 229 | exit; |
231 | 230 | } |
232 | 231 | } |
233 | 232 | |
234 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
233 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
235 | 234 | |
236 | - if ( $is_ajax ) { |
|
235 | + if ($is_ajax) { |
|
237 | 236 | $message = Give()->notices->print_frontend_notice( |
238 | 237 | sprintf( |
239 | 238 | /* translators: %s: user first name */ |
240 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
241 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
239 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
240 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
242 | 241 | ), |
243 | 242 | false, |
244 | 243 | 'success' |
245 | 244 | ); |
246 | 245 | |
247 | - wp_send_json_success( $message ); |
|
246 | + wp_send_json_success($message); |
|
248 | 247 | } else { |
249 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
248 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
250 | 249 | } |
251 | 250 | } |
252 | 251 | |
253 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
254 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
252 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
253 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
255 | 254 | |
256 | 255 | /** |
257 | 256 | * Donation Form Validate Fields. |
@@ -263,63 +262,63 @@ discard block |
||
263 | 262 | function give_donation_form_validate_fields() { |
264 | 263 | |
265 | 264 | // Check if there is $_POST |
266 | - if ( empty( $_POST ) ) { |
|
265 | + if (empty($_POST)) { |
|
267 | 266 | return false; |
268 | 267 | } |
269 | 268 | |
270 | - $form_id = ! empty( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
269 | + $form_id = ! empty($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
271 | 270 | |
272 | 271 | // Start an array to collect valid data |
273 | 272 | $valid_data = array( |
274 | 273 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here) |
275 | - 'need_new_user' => false, // New user flag |
|
276 | - 'need_user_login' => false, // Login user flag |
|
277 | - 'logged_user_data' => array(), // Logged user collected data |
|
278 | - 'new_user_data' => array(), // New user collected data |
|
279 | - 'login_user_data' => array(), // Login user collected data |
|
280 | - 'guest_user_data' => array(), // Guest user collected data |
|
281 | - 'cc_info' => give_donation_form_validate_cc(),// Credit card info |
|
274 | + 'need_new_user' => false, // New user flag |
|
275 | + 'need_user_login' => false, // Login user flag |
|
276 | + 'logged_user_data' => array(), // Logged user collected data |
|
277 | + 'new_user_data' => array(), // New user collected data |
|
278 | + 'login_user_data' => array(), // Login user collected data |
|
279 | + 'guest_user_data' => array(), // Guest user collected data |
|
280 | + 'cc_info' => give_donation_form_validate_cc(), // Credit card info |
|
282 | 281 | ); |
283 | 282 | |
284 | 283 | // Validate Honeypot First |
285 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
286 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
284 | + if ( ! empty($_POST['give-honeypot'])) { |
|
285 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
287 | 286 | } |
288 | 287 | |
289 | 288 | // Check spam detect. |
290 | - if ( isset( $_POST['action'] ) |
|
291 | - && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
289 | + if (isset($_POST['action']) |
|
290 | + && give_is_setting_enabled(give_get_option('akismet_spam_protection')) |
|
292 | 291 | && give_is_spam_donation() |
293 | 292 | ) { |
294 | - give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); |
|
293 | + give_set_error('invalid_donation', __('This donation has been flagged as spam. Please try again.', 'give')); |
|
295 | 294 | } |
296 | 295 | |
297 | 296 | // Validate agree to terms |
298 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
297 | + if (give_is_terms_enabled($form_id)) { |
|
299 | 298 | give_donation_form_validate_agree_to_terms(); |
300 | 299 | } |
301 | 300 | |
302 | 301 | // Stop processing donor registration, if donor registration is optional and donor can do guest checkout. |
303 | 302 | // If registration form username field is empty that means donor do not want to registration instead want guest checkout. |
304 | 303 | if ( |
305 | - ! give_logged_in_only( $form_id ) |
|
306 | - && isset( $_POST['give-purchase-var'] ) |
|
304 | + ! give_logged_in_only($form_id) |
|
305 | + && isset($_POST['give-purchase-var']) |
|
307 | 306 | && $_POST['give-purchase-var'] == 'needs-to-register' |
308 | - && empty( $_POST['give_user_login'] ) |
|
307 | + && empty($_POST['give_user_login']) |
|
309 | 308 | ) { |
310 | - unset( $_POST['give-purchase-var'] ); |
|
309 | + unset($_POST['give-purchase-var']); |
|
311 | 310 | } |
312 | 311 | |
313 | - if ( is_user_logged_in() ) { |
|
312 | + if (is_user_logged_in()) { |
|
314 | 313 | // Collect logged in user data. |
315 | 314 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
316 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
315 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
317 | 316 | // Set new user registration as required. |
318 | 317 | $valid_data['need_new_user'] = true; |
319 | 318 | // Validate new user data. |
320 | 319 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
321 | 320 | // Check if login validation is needed. |
322 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
321 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
323 | 322 | // Set user login as required. |
324 | 323 | $valid_data['need_user_login'] = true; |
325 | 324 | // Validate users login info. |
@@ -343,14 +342,14 @@ discard block |
||
343 | 342 | function give_is_spam_donation() { |
344 | 343 | $spam = false; |
345 | 344 | |
346 | - $user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
345 | + $user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
347 | 346 | |
348 | - if ( strlen( $user_agent ) < 2 ) { |
|
347 | + if (strlen($user_agent) < 2) { |
|
349 | 348 | $spam = true; |
350 | 349 | } |
351 | 350 | |
352 | 351 | // Allow developer to customized Akismet spam detect API call and it's response. |
353 | - return apply_filters( 'give_spam', $spam ); |
|
352 | + return apply_filters('give_spam', $spam); |
|
354 | 353 | } |
355 | 354 | |
356 | 355 | /** |
@@ -364,41 +363,41 @@ discard block |
||
364 | 363 | */ |
365 | 364 | function give_donation_form_validate_gateway() { |
366 | 365 | |
367 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
368 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
369 | - $gateway = give_get_default_gateway( $form_id ); |
|
366 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
367 | + $amount = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
368 | + $gateway = give_get_default_gateway($form_id); |
|
370 | 369 | |
371 | 370 | // Check if a gateway value is present. |
372 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
371 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
373 | 372 | |
374 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
373 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
375 | 374 | |
376 | 375 | // Is amount being donated in LIVE mode 0.00? If so, error: |
377 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
376 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
378 | 377 | |
379 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
378 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
380 | 379 | |
381 | 380 | } // End if(). |
382 | - elseif ( ! give_verify_minimum_price() ) { |
|
381 | + elseif ( ! give_verify_minimum_price()) { |
|
383 | 382 | // translators: %s: minimum donation amount. |
384 | 383 | give_set_error( |
385 | 384 | 'invalid_donation_minimum', |
386 | 385 | sprintf( |
387 | 386 | /* translators: %s: minimum donation amount */ |
388 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
389 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) ) |
|
387 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
388 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false))) |
|
390 | 389 | ) |
391 | 390 | ); |
392 | 391 | |
393 | 392 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
394 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
393 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
395 | 394 | |
396 | 395 | $gateway = 'manual'; |
397 | 396 | |
398 | 397 | } //Check if this gateway is active. |
399 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
398 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
400 | 399 | |
401 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
400 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
402 | 401 | |
403 | 402 | } |
404 | 403 | } |
@@ -416,21 +415,21 @@ discard block |
||
416 | 415 | */ |
417 | 416 | function give_verify_minimum_price() { |
418 | 417 | |
419 | - $amount = give_maybe_sanitize_amount( $_REQUEST['give-amount'] ); |
|
420 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
421 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null; |
|
422 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
418 | + $amount = give_maybe_sanitize_amount($_REQUEST['give-amount']); |
|
419 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
420 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null; |
|
421 | + $variable_prices = give_has_variable_prices($form_id); |
|
423 | 422 | |
424 | - if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) { |
|
423 | + if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) { |
|
425 | 424 | |
426 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
425 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
427 | 426 | |
428 | - if ( $price_level_amount == $amount ) { |
|
427 | + if ($price_level_amount == $amount) { |
|
429 | 428 | return true; |
430 | 429 | } |
431 | 430 | } |
432 | 431 | |
433 | - if ( give_get_form_minimum_price( $form_id ) > $amount ) { |
|
432 | + if (give_get_form_minimum_price($form_id) > $amount) { |
|
434 | 433 | return false; |
435 | 434 | } |
436 | 435 | |
@@ -446,9 +445,9 @@ discard block |
||
446 | 445 | */ |
447 | 446 | function give_donation_form_validate_agree_to_terms() { |
448 | 447 | // Validate agree to terms. |
449 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
448 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
450 | 449 | // User did not agree. |
451 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
450 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
452 | 451 | } |
453 | 452 | } |
454 | 453 | |
@@ -462,59 +461,59 @@ discard block |
||
462 | 461 | * |
463 | 462 | * @return array |
464 | 463 | */ |
465 | -function give_get_required_fields( $form_id ) { |
|
464 | +function give_get_required_fields($form_id) { |
|
466 | 465 | |
467 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
466 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
468 | 467 | |
469 | 468 | $required_fields = array( |
470 | 469 | 'give_email' => array( |
471 | 470 | 'error_id' => 'invalid_email', |
472 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
471 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
473 | 472 | ), |
474 | 473 | 'give_first' => array( |
475 | 474 | 'error_id' => 'invalid_first_name', |
476 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
475 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
477 | 476 | ), |
478 | 477 | ); |
479 | 478 | |
480 | - $require_address = give_require_billing_address( $payment_mode ); |
|
479 | + $require_address = give_require_billing_address($payment_mode); |
|
481 | 480 | |
482 | - if ( $require_address ) { |
|
483 | - $required_fields['card_address'] = array( |
|
481 | + if ($require_address) { |
|
482 | + $required_fields['card_address'] = array( |
|
484 | 483 | 'error_id' => 'invalid_card_address', |
485 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
484 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
486 | 485 | ); |
487 | - $required_fields['card_zip'] = array( |
|
486 | + $required_fields['card_zip'] = array( |
|
488 | 487 | 'error_id' => 'invalid_zip_code', |
489 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
488 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
490 | 489 | ); |
491 | - $required_fields['card_city'] = array( |
|
490 | + $required_fields['card_city'] = array( |
|
492 | 491 | 'error_id' => 'invalid_city', |
493 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
492 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
494 | 493 | ); |
495 | 494 | $required_fields['billing_country'] = array( |
496 | 495 | 'error_id' => 'invalid_country', |
497 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
496 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
498 | 497 | ); |
499 | 498 | |
500 | 499 | |
501 | 500 | $required_fields['card_state'] = array( |
502 | 501 | 'error_id' => 'invalid_state', |
503 | - 'error_message' => __( 'Please enter billing state / province / County.', 'give' ), |
|
502 | + 'error_message' => __('Please enter billing state / province / County.', 'give'), |
|
504 | 503 | ); |
505 | 504 | |
506 | 505 | // Check if billing country alredy exists. |
507 | - if ( ! empty( $_POST['billing_country'] ) ) { |
|
506 | + if ( ! empty($_POST['billing_country'])) { |
|
508 | 507 | // Get the value from $_POST. |
509 | - $country = sanitize_text_field( $_POST['billing_country'] ); |
|
508 | + $country = sanitize_text_field($_POST['billing_country']); |
|
510 | 509 | |
511 | 510 | // Get the country list that does not required any states init. |
512 | 511 | $states_country = give_states_not_required_country_list(); |
513 | 512 | |
514 | 513 | // Check if states is empty or not. |
515 | - if ( array_key_exists( $country, $states_country ) ) { |
|
514 | + if (array_key_exists($country, $states_country)) { |
|
516 | 515 | // If states is empty remove the required feilds of state in billing cart. |
517 | - unset( $required_fields['card_state'] ); |
|
516 | + unset($required_fields['card_state']); |
|
518 | 517 | } |
519 | 518 | } |
520 | 519 | } |
@@ -524,7 +523,7 @@ discard block |
||
524 | 523 | * |
525 | 524 | * @since 1.7 |
526 | 525 | */ |
527 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
526 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
528 | 527 | |
529 | 528 | return $required_fields; |
530 | 529 | |
@@ -539,16 +538,16 @@ discard block |
||
539 | 538 | * |
540 | 539 | * @return bool |
541 | 540 | */ |
542 | -function give_require_billing_address( $payment_mode ) { |
|
541 | +function give_require_billing_address($payment_mode) { |
|
543 | 542 | |
544 | 543 | $return = false; |
545 | 544 | |
546 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
545 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
547 | 546 | $return = true; |
548 | 547 | } |
549 | 548 | |
550 | 549 | // Let payment gateways and other extensions determine if address fields should be required. |
551 | - return apply_filters( 'give_require_billing_address', $return ); |
|
550 | + return apply_filters('give_require_billing_address', $return); |
|
552 | 551 | |
553 | 552 | } |
554 | 553 | |
@@ -562,42 +561,42 @@ discard block |
||
562 | 561 | function give_donation_form_validate_logged_in_user() { |
563 | 562 | global $user_ID; |
564 | 563 | |
565 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
564 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
566 | 565 | |
567 | 566 | // Start empty array to collect valid user data. |
568 | 567 | $valid_user_data = array( |
569 | 568 | // Assume there will be errors. |
570 | - 'user_id' => - 1, |
|
569 | + 'user_id' => -1, |
|
571 | 570 | ); |
572 | 571 | |
573 | 572 | // Verify there is a user_ID. |
574 | - if ( $user_ID > 0 ) { |
|
573 | + if ($user_ID > 0) { |
|
575 | 574 | // Get the logged in user data. |
576 | - $user_data = get_userdata( $user_ID ); |
|
575 | + $user_data = get_userdata($user_ID); |
|
577 | 576 | |
578 | 577 | // Loop through required fields and show error messages. |
579 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
580 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
581 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
578 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
579 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
580 | + give_set_error($value['error_id'], $value['error_message']); |
|
582 | 581 | } |
583 | 582 | } |
584 | 583 | |
585 | 584 | // Verify data. |
586 | - if ( $user_data ) { |
|
585 | + if ($user_data) { |
|
587 | 586 | // Collected logged in user data. |
588 | 587 | $valid_user_data = array( |
589 | 588 | 'user_id' => $user_ID, |
590 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
591 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
592 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
589 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
590 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
591 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
593 | 592 | ); |
594 | 593 | |
595 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
596 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
594 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
595 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
597 | 596 | } |
598 | 597 | } else { |
599 | 598 | // Set invalid user error. |
600 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
599 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
601 | 600 | } |
602 | 601 | } |
603 | 602 | |
@@ -616,7 +615,7 @@ discard block |
||
616 | 615 | // Default user data. |
617 | 616 | $default_user_data = array( |
618 | 617 | 'give-form-id' => '', |
619 | - 'user_id' => - 1, // Assume there will be errors. |
|
618 | + 'user_id' => -1, // Assume there will be errors. |
|
620 | 619 | 'user_first' => '', |
621 | 620 | 'user_last' => '', |
622 | 621 | 'give_user_login' => false, |
@@ -626,14 +625,14 @@ discard block |
||
626 | 625 | ); |
627 | 626 | |
628 | 627 | // Get user data. |
629 | - $user_data = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data ); |
|
628 | + $user_data = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data); |
|
630 | 629 | $registering_new_user = false; |
631 | - $form_id = absint( $user_data['give-form-id'] ); |
|
630 | + $form_id = absint($user_data['give-form-id']); |
|
632 | 631 | |
633 | 632 | // Start an empty array to collect valid user data. |
634 | 633 | $valid_user_data = array( |
635 | 634 | // Assume there will be errors. |
636 | - 'user_id' => - 1, |
|
635 | + 'user_id' => -1, |
|
637 | 636 | |
638 | 637 | // Get first name. |
639 | 638 | 'user_first' => $user_data['give_first'], |
@@ -643,25 +642,25 @@ discard block |
||
643 | 642 | ); |
644 | 643 | |
645 | 644 | // Loop through required fields and show error messages. |
646 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
647 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
648 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
645 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
646 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
647 | + give_set_error($value['error_id'], $value['error_message']); |
|
649 | 648 | } |
650 | 649 | } |
651 | 650 | |
652 | 651 | // Check if we have an username to register. |
653 | - if ( give_validate_username( $user_data['give_user_login'] ) ) { |
|
652 | + if (give_validate_username($user_data['give_user_login'])) { |
|
654 | 653 | $registering_new_user = true; |
655 | 654 | $valid_user_data['user_login'] = $user_data['give_user_login']; |
656 | 655 | } |
657 | 656 | |
658 | 657 | // Check if we have an email to verify. |
659 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
658 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
660 | 659 | $valid_user_data['user_email'] = $user_data['give_email']; |
661 | 660 | } |
662 | 661 | |
663 | 662 | // Check password. |
664 | - if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) { |
|
663 | + if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { |
|
665 | 664 | // All is good to go. |
666 | 665 | $valid_user_data['user_pass'] = $user_data['give_user_pass']; |
667 | 666 | } |
@@ -681,36 +680,36 @@ discard block |
||
681 | 680 | // Start an array to collect valid user data. |
682 | 681 | $valid_user_data = array( |
683 | 682 | // Assume there will be errors. |
684 | - 'user_id' => - 1, |
|
683 | + 'user_id' => -1, |
|
685 | 684 | ); |
686 | 685 | |
687 | 686 | // Username. |
688 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
689 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
687 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
688 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
690 | 689 | |
691 | 690 | return $valid_user_data; |
692 | 691 | } |
693 | 692 | |
694 | 693 | // Get the user by login. |
695 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
694 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
696 | 695 | |
697 | 696 | // Check if user exists. |
698 | - if ( $user_data ) { |
|
697 | + if ($user_data) { |
|
699 | 698 | // Get password. |
700 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
699 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
701 | 700 | |
702 | 701 | // Check user_pass. |
703 | - if ( $user_pass ) { |
|
702 | + if ($user_pass) { |
|
704 | 703 | // Check if password is valid. |
705 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
704 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
706 | 705 | // Incorrect password. |
707 | 706 | give_set_error( |
708 | 707 | 'password_incorrect', |
709 | 708 | sprintf( |
710 | 709 | '%1$s <a href="%2$s">%3$s</a>', |
711 | - __( 'The password you entered is incorrect.', 'give' ), |
|
712 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
713 | - __( 'Reset Password', 'give' ) |
|
710 | + __('The password you entered is incorrect.', 'give'), |
|
711 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
712 | + __('Reset Password', 'give') |
|
714 | 713 | ) |
715 | 714 | ); |
716 | 715 | // All is correct. |
@@ -728,11 +727,11 @@ discard block |
||
728 | 727 | } |
729 | 728 | } else { |
730 | 729 | // Empty password. |
731 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
730 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
732 | 731 | } |
733 | 732 | } else { |
734 | 733 | // No username. |
735 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
734 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
736 | 735 | }// End if(). |
737 | 736 | |
738 | 737 | return $valid_user_data; |
@@ -747,7 +746,7 @@ discard block |
||
747 | 746 | */ |
748 | 747 | function give_donation_form_validate_guest_user() { |
749 | 748 | |
750 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
749 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
751 | 750 | |
752 | 751 | // Start an array to collect valid user data. |
753 | 752 | $valid_user_data = array( |
@@ -756,38 +755,38 @@ discard block |
||
756 | 755 | ); |
757 | 756 | |
758 | 757 | // Show error message if user must be logged in. |
759 | - if ( give_logged_in_only( $form_id ) ) { |
|
760 | - give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) ); |
|
758 | + if (give_logged_in_only($form_id)) { |
|
759 | + give_set_error('logged_in_only', __('You must be logged in to donate.', 'give')); |
|
761 | 760 | } |
762 | 761 | |
763 | 762 | // Get the guest email. |
764 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
763 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
765 | 764 | |
766 | 765 | // Check email. |
767 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
766 | + if ($guest_email && strlen($guest_email) > 0) { |
|
768 | 767 | // Validate email. |
769 | - if ( ! is_email( $guest_email ) ) { |
|
768 | + if ( ! is_email($guest_email)) { |
|
770 | 769 | // Invalid email. |
771 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
770 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
772 | 771 | } else { |
773 | 772 | // All is good to go. |
774 | 773 | $valid_user_data['user_email'] = $guest_email; |
775 | 774 | |
776 | 775 | // Get user_id from donor if exist. |
777 | - $donor = new Give_Donor( $guest_email ); |
|
778 | - if ( $donor->id && $donor->user_id ) { |
|
776 | + $donor = new Give_Donor($guest_email); |
|
777 | + if ($donor->id && $donor->user_id) { |
|
779 | 778 | $valid_user_data['user_id'] = $donor->user_id; |
780 | 779 | } |
781 | 780 | } |
782 | 781 | } else { |
783 | 782 | // No email. |
784 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
783 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
785 | 784 | } |
786 | 785 | |
787 | 786 | // Loop through required fields and show error messages. |
788 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
789 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
790 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
787 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
788 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
789 | + give_set_error($value['error_id'], $value['error_message']); |
|
791 | 790 | } |
792 | 791 | } |
793 | 792 | |
@@ -803,36 +802,36 @@ discard block |
||
803 | 802 | * @since 1.0 |
804 | 803 | * @return integer |
805 | 804 | */ |
806 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
805 | +function give_register_and_login_new_user($user_data = array()) { |
|
807 | 806 | // Verify the array. |
808 | - if ( empty( $user_data ) ) { |
|
809 | - return - 1; |
|
807 | + if (empty($user_data)) { |
|
808 | + return -1; |
|
810 | 809 | } |
811 | 810 | |
812 | - if ( give_get_errors() ) { |
|
813 | - return - 1; |
|
811 | + if (give_get_errors()) { |
|
812 | + return -1; |
|
814 | 813 | } |
815 | 814 | |
816 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
817 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
818 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
819 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
820 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
821 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
822 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
823 | - 'role' => give_get_option( 'donor_default_user_role', 'give_donor' ), |
|
824 | - ), $user_data ); |
|
815 | + $user_args = apply_filters('give_insert_user_args', array( |
|
816 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
817 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
818 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
819 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
820 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
821 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
822 | + 'role' => give_get_option('donor_default_user_role', 'give_donor'), |
|
823 | + ), $user_data); |
|
825 | 824 | |
826 | 825 | // Insert new user. |
827 | - $user_id = wp_insert_user( $user_args ); |
|
826 | + $user_id = wp_insert_user($user_args); |
|
828 | 827 | |
829 | 828 | // Validate inserted user. |
830 | - if ( is_wp_error( $user_id ) ) { |
|
831 | - return - 1; |
|
829 | + if (is_wp_error($user_id)) { |
|
830 | + return -1; |
|
832 | 831 | } |
833 | 832 | |
834 | 833 | // Allow themes and plugins to filter the user data. |
835 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
834 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
836 | 835 | |
837 | 836 | /** |
838 | 837 | * Fires after inserting user. |
@@ -842,7 +841,7 @@ discard block |
||
842 | 841 | * @param int $user_id User id. |
843 | 842 | * @param array $user_data Array containing user data. |
844 | 843 | */ |
845 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
844 | + do_action('give_insert_user', $user_id, $user_data); |
|
846 | 845 | |
847 | 846 | /** |
848 | 847 | * Filter allow user to alter if user when to login or not when user is register for the first time. |
@@ -851,9 +850,9 @@ discard block |
||
851 | 850 | * |
852 | 851 | * return bool True if login with registration and False if only want to register. |
853 | 852 | */ |
854 | - if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) { |
|
853 | + if (true === (bool) apply_filters('give_log_user_in_on_register', true)) { |
|
855 | 854 | // Login new user. |
856 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
855 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
857 | 856 | } |
858 | 857 | |
859 | 858 | // Return user id. |
@@ -869,27 +868,27 @@ discard block |
||
869 | 868 | * @since 1.0 |
870 | 869 | * @return array|bool |
871 | 870 | */ |
872 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
871 | +function give_get_donation_form_user($valid_data = array()) { |
|
873 | 872 | |
874 | 873 | // Initialize user. |
875 | 874 | $user = false; |
876 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
875 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
877 | 876 | |
878 | - if ( $is_ajax ) { |
|
877 | + if ($is_ajax) { |
|
879 | 878 | // Do not create or login the user during the ajax submission (check for errors only). |
880 | 879 | return true; |
881 | - } elseif ( is_user_logged_in() ) { |
|
880 | + } elseif (is_user_logged_in()) { |
|
882 | 881 | // Set the valid user as the logged in collected data. |
883 | 882 | $user = $valid_data['logged_in_user']; |
884 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
883 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
885 | 884 | // New user registration. |
886 | - if ( $valid_data['need_new_user'] === true ) { |
|
885 | + if ($valid_data['need_new_user'] === true) { |
|
887 | 886 | // Set user. |
888 | 887 | $user = $valid_data['new_user_data']; |
889 | 888 | // Register and login new user. |
890 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
889 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
891 | 890 | // User login |
892 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
891 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
893 | 892 | |
894 | 893 | /** |
895 | 894 | * The login form is now processed in the give_process_donation_login() function. |
@@ -901,48 +900,48 @@ discard block |
||
901 | 900 | // Set user. |
902 | 901 | $user = $valid_data['login_user_data']; |
903 | 902 | // Login user. |
904 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
903 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
905 | 904 | } |
906 | 905 | } |
907 | 906 | |
908 | 907 | // Check guest checkout. |
909 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
908 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
910 | 909 | // Set user |
911 | 910 | $user = $valid_data['guest_user_data']; |
912 | 911 | } |
913 | 912 | |
914 | 913 | // Verify we have an user. |
915 | - if ( false === $user || empty( $user ) ) { |
|
914 | + if (false === $user || empty($user)) { |
|
916 | 915 | // Return false. |
917 | 916 | return false; |
918 | 917 | } |
919 | 918 | |
920 | 919 | // Get user first name. |
921 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
922 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
920 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
921 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
923 | 922 | } |
924 | 923 | |
925 | 924 | // Get user last name. |
926 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
927 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
925 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
926 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
928 | 927 | } |
929 | 928 | |
930 | 929 | // Get the user's billing address details. |
931 | 930 | $user['address'] = array(); |
932 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? give_clean( $_POST['card_address'] ) : false; |
|
933 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? give_clean( $_POST['card_address_2'] ) : false; |
|
934 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? give_clean( $_POST['card_city'] ) : false; |
|
935 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? give_clean( $_POST['card_state'] ) : false; |
|
936 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? give_clean( $_POST['card_zip'] ) : false; |
|
937 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : false; |
|
938 | - |
|
939 | - if ( empty( $user['address']['country'] ) ) { |
|
931 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? give_clean($_POST['card_address']) : false; |
|
932 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? give_clean($_POST['card_address_2']) : false; |
|
933 | + $user['address']['city'] = ! empty($_POST['card_city']) ? give_clean($_POST['card_city']) : false; |
|
934 | + $user['address']['state'] = ! empty($_POST['card_state']) ? give_clean($_POST['card_state']) : false; |
|
935 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? give_clean($_POST['card_zip']) : false; |
|
936 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : false; |
|
937 | + |
|
938 | + if (empty($user['address']['country'])) { |
|
940 | 939 | $user['address'] = false; |
941 | 940 | } // End if(). |
942 | 941 | |
943 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
942 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
944 | 943 | // Store the address in the user's meta so the donation form can be pre-populated with it on return donation. |
945 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
944 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
946 | 945 | } |
947 | 946 | |
948 | 947 | // Return valid user. |
@@ -961,16 +960,16 @@ discard block |
||
961 | 960 | $card_data = give_get_donation_cc_info(); |
962 | 961 | |
963 | 962 | // Validate the card zip. |
964 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
965 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
966 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
963 | + if ( ! empty($card_data['card_zip'])) { |
|
964 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
965 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
967 | 966 | } |
968 | 967 | } |
969 | 968 | |
970 | 969 | // Ensure no spaces. |
971 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
972 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
973 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
970 | + if ( ! empty($card_data['card_number'])) { |
|
971 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
972 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
974 | 973 | } |
975 | 974 | |
976 | 975 | // This should validate card numbers at some point too. |
@@ -987,17 +986,17 @@ discard block |
||
987 | 986 | function give_get_donation_cc_info() { |
988 | 987 | |
989 | 988 | $cc_info = array(); |
990 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
991 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
992 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
993 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
994 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
995 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
996 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
997 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
998 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
999 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
1000 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
989 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
990 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
991 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
992 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
993 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
994 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
995 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
996 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
997 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
998 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
999 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
1001 | 1000 | |
1002 | 1001 | // Return cc info. |
1003 | 1002 | return $cc_info; |
@@ -1013,14 +1012,14 @@ discard block |
||
1013 | 1012 | * |
1014 | 1013 | * @return bool|mixed |
1015 | 1014 | */ |
1016 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
1015 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
1017 | 1016 | $ret = false; |
1018 | 1017 | |
1019 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
1018 | + if (empty($zip) || empty($country_code)) { |
|
1020 | 1019 | return $ret; |
1021 | 1020 | } |
1022 | 1021 | |
1023 | - $country_code = strtoupper( $country_code ); |
|
1022 | + $country_code = strtoupper($country_code); |
|
1024 | 1023 | |
1025 | 1024 | $zip_regex = array( |
1026 | 1025 | 'AD' => 'AD\d{3}', |
@@ -1180,11 +1179,11 @@ discard block |
||
1180 | 1179 | 'ZM' => '\d{5}', |
1181 | 1180 | ); |
1182 | 1181 | |
1183 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1182 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1184 | 1183 | $ret = true; |
1185 | 1184 | } |
1186 | 1185 | |
1187 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1186 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1188 | 1187 | } |
1189 | 1188 | |
1190 | 1189 | |
@@ -1198,33 +1197,33 @@ discard block |
||
1198 | 1197 | * |
1199 | 1198 | * @return bool |
1200 | 1199 | */ |
1201 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1200 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1202 | 1201 | /* @var Give_Donate_Form $form */ |
1203 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1202 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1204 | 1203 | |
1205 | 1204 | $donation_level_matched = false; |
1206 | 1205 | |
1207 | - if ( $form->is_multi_type_donation_form() ) { |
|
1206 | + if ($form->is_multi_type_donation_form()) { |
|
1208 | 1207 | |
1209 | 1208 | // Bailout. |
1210 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1209 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1211 | 1210 | return false; |
1212 | 1211 | } |
1213 | 1212 | |
1214 | 1213 | // Sanitize donation amount. |
1215 | - $data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] ); |
|
1214 | + $data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']); |
|
1216 | 1215 | |
1217 | - if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) { |
|
1216 | + if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) { |
|
1218 | 1217 | return true; |
1219 | 1218 | } |
1220 | 1219 | |
1221 | 1220 | // Find correct donation level from all donation levels. |
1222 | - foreach ( $variable_prices as $variable_price ) { |
|
1221 | + foreach ($variable_prices as $variable_price) { |
|
1223 | 1222 | // Sanitize level amount. |
1224 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); |
|
1223 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); |
|
1225 | 1224 | |
1226 | 1225 | // Set first match donation level ID. |
1227 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1226 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1228 | 1227 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1229 | 1228 | $donation_level_matched = true; |
1230 | 1229 | break; |
@@ -1235,19 +1234,19 @@ discard block |
||
1235 | 1234 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1236 | 1235 | if ( |
1237 | 1236 | ! $donation_level_matched |
1238 | - && ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) ) |
|
1237 | + && (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true))) |
|
1239 | 1238 | ) { |
1240 | 1239 | // Sanitize custom minimum amount. |
1241 | - $custom_minimum_amount = give_maybe_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ) ); |
|
1240 | + $custom_minimum_amount = give_maybe_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true)); |
|
1242 | 1241 | |
1243 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1242 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1244 | 1243 | $_POST['give-price-id'] = 'custom'; |
1245 | 1244 | $donation_level_matched = true; |
1246 | 1245 | } |
1247 | 1246 | } |
1248 | 1247 | }// End if(). |
1249 | 1248 | |
1250 | - return ( $donation_level_matched ? true : false ); |
|
1249 | + return ($donation_level_matched ? true : false); |
|
1251 | 1250 | } |
1252 | 1251 | |
1253 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1252 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * @global $wpdb |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_install( $network_wide = false ) { |
|
29 | +function give_install($network_wide = false) { |
|
30 | 30 | |
31 | 31 | global $wpdb; |
32 | 32 | |
33 | - if ( is_multisite() && $network_wide ) { |
|
33 | + if (is_multisite() && $network_wide) { |
|
34 | 34 | |
35 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
35 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
36 | 36 | |
37 | - switch_to_blog( $blog_id ); |
|
37 | + switch_to_blog($blog_id); |
|
38 | 38 | give_run_install(); |
39 | 39 | restore_current_blog(); |
40 | 40 | |
@@ -61,31 +61,31 @@ discard block |
||
61 | 61 | give_setup_post_types(); |
62 | 62 | |
63 | 63 | // Add Upgraded From Option. |
64 | - $current_version = get_option( 'give_version' ); |
|
65 | - if ( $current_version ) { |
|
66 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
64 | + $current_version = get_option('give_version'); |
|
65 | + if ($current_version) { |
|
66 | + update_option('give_version_upgraded_from', $current_version); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Setup some default options. |
70 | 70 | $options = array(); |
71 | 71 | |
72 | 72 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
73 | - if ( empty( $current_version ) ) { |
|
74 | - $options = array_merge( $options, give_get_default_settings() ); |
|
73 | + if (empty($current_version)) { |
|
74 | + $options = array_merge($options, give_get_default_settings()); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // Populate the default values. |
78 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
78 | + update_option('give_settings', array_merge($give_options, $options)); |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Run plugin upgrades. |
82 | 82 | * |
83 | 83 | * @since 1.8 |
84 | 84 | */ |
85 | - do_action( 'give_upgrades' ); |
|
85 | + do_action('give_upgrades'); |
|
86 | 86 | |
87 | - if ( GIVE_VERSION !== get_option( 'give_version' ) ) { |
|
88 | - update_option( 'give_version', GIVE_VERSION ); |
|
87 | + if (GIVE_VERSION !== get_option('give_version')) { |
|
88 | + update_option('give_version', GIVE_VERSION); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Create Give roles. |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | // Set api version, end point and refresh permalink. |
97 | 97 | $api = new Give_API(); |
98 | 98 | $api->add_endpoint(); |
99 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
99 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
100 | 100 | |
101 | 101 | flush_rewrite_rules(); |
102 | 102 | |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | $give_sessions->use_php_sessions(); |
106 | 106 | |
107 | 107 | // Add a temporary option to note that Give pages have been created. |
108 | - Give_Cache::set( '_give_installed', $options, 30, true ); |
|
108 | + Give_Cache::set('_give_installed', $options, 30, true); |
|
109 | 109 | |
110 | - if ( ! $current_version ) { |
|
110 | + if ( ! $current_version) { |
|
111 | 111 | |
112 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
112 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
113 | 113 | |
114 | 114 | // When new upgrade routines are added, mark them as complete on fresh install. |
115 | 115 | $upgrade_routines = array( |
@@ -125,18 +125,18 @@ discard block |
||
125 | 125 | 'v1813_update_donor_user_roles' |
126 | 126 | ); |
127 | 127 | |
128 | - foreach ( $upgrade_routines as $upgrade ) { |
|
129 | - give_set_upgrade_complete( $upgrade ); |
|
128 | + foreach ($upgrade_routines as $upgrade) { |
|
129 | + give_set_upgrade_complete($upgrade); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | 133 | // Bail if activating from network, or bulk. |
134 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
134 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
135 | 135 | return; |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Add the transient to redirect. |
139 | - Give_Cache::set( '_give_activation_redirect', true, 30, true ); |
|
139 | + Give_Cache::set('_give_activation_redirect', true, 30, true); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | * @param int $site_id The Site ID. |
154 | 154 | * @param array $meta Blog Meta. |
155 | 155 | */ |
156 | -function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
156 | +function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
157 | 157 | |
158 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
158 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
159 | 159 | |
160 | - switch_to_blog( $blog_id ); |
|
160 | + switch_to_blog($blog_id); |
|
161 | 161 | give_install(); |
162 | 162 | restore_current_blog(); |
163 | 163 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | } |
167 | 167 | |
168 | -add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 ); |
|
168 | +add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6); |
|
169 | 169 | |
170 | 170 | |
171 | 171 | /** |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return array The tables to drop. |
180 | 180 | */ |
181 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
181 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
182 | 182 | |
183 | - switch_to_blog( $blog_id ); |
|
183 | + switch_to_blog($blog_id); |
|
184 | 184 | $donors_db = new Give_DB_Donors(); |
185 | 185 | $donor_meta_db = new Give_DB_Donor_Meta(); |
186 | 186 | |
187 | - if ( $donors_db->installed() ) { |
|
187 | + if ($donors_db->installed()) { |
|
188 | 188 | $tables[] = $donors_db->table_name; |
189 | 189 | $tables[] = $donor_meta_db->table_name; |
190 | 190 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | } |
196 | 196 | |
197 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
197 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Post-installation |
@@ -206,16 +206,16 @@ discard block |
||
206 | 206 | */ |
207 | 207 | function give_after_install() { |
208 | 208 | |
209 | - if ( ! is_admin() ) { |
|
209 | + if ( ! is_admin()) { |
|
210 | 210 | return; |
211 | 211 | } |
212 | 212 | |
213 | - $give_options = Give_Cache::get( '_give_installed', true ); |
|
214 | - $give_table_check = get_option( '_give_table_check', false ); |
|
213 | + $give_options = Give_Cache::get('_give_installed', true); |
|
214 | + $give_table_check = get_option('_give_table_check', false); |
|
215 | 215 | |
216 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
216 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
217 | 217 | |
218 | - if ( ! @Give()->donor_meta->installed() ) { |
|
218 | + if ( ! @Give()->donor_meta->installed()) { |
|
219 | 219 | |
220 | 220 | // Create the donor meta database. |
221 | 221 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | - if ( ! @Give()->donors->installed() ) { |
|
226 | + if ( ! @Give()->donors->installed()) { |
|
227 | 227 | // Create the donor database. |
228 | 228 | // (this ensures it creates it on multisite instances where it is network activated). |
229 | 229 | @Give()->donors->create_table(); |
@@ -235,22 +235,22 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @param array $give_options Give plugin options. |
237 | 237 | */ |
238 | - do_action( 'give_after_install', $give_options ); |
|
238 | + do_action('give_after_install', $give_options); |
|
239 | 239 | } |
240 | 240 | |
241 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
241 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
242 | 242 | |
243 | 243 | } |
244 | 244 | |
245 | 245 | // Delete the transient |
246 | - if ( false !== $give_options ) { |
|
247 | - Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) ); |
|
246 | + if (false !== $give_options) { |
|
247 | + Give_Cache::delete(Give_Cache::get_key('_give_installed')); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
251 | 251 | } |
252 | 252 | |
253 | -add_action( 'admin_init', 'give_after_install' ); |
|
253 | +add_action('admin_init', 'give_after_install'); |
|
254 | 254 | |
255 | 255 | |
256 | 256 | /** |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | |
266 | 266 | global $wp_roles; |
267 | 267 | |
268 | - if ( ! is_object( $wp_roles ) ) { |
|
268 | + if ( ! is_object($wp_roles)) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | |
272 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
272 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
273 | 273 | |
274 | 274 | // Create Give plugin roles |
275 | 275 | $roles = new Give_Roles(); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | |
281 | 281 | } |
282 | 282 | |
283 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
283 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
284 | 284 | |
285 | 285 | /** |
286 | 286 | * Default core setting values. |
@@ -318,14 +318,14 @@ discard block |
||
318 | 318 | 'uninstall_on_delete' => 'disabled', |
319 | 319 | 'the_content_filter' => 'enabled', |
320 | 320 | 'scripts_footer' => 'disabled', |
321 | - 'agree_to_terms_label' => __( 'Agree to Terms?', 'give' ), |
|
321 | + 'agree_to_terms_label' => __('Agree to Terms?', 'give'), |
|
322 | 322 | 'agreement_text' => give_get_default_agreement_text(), |
323 | 323 | |
324 | 324 | // Paypal IPN verification. |
325 | 325 | 'paypal_verification' => 'enabled', |
326 | 326 | |
327 | 327 | // Default is manual gateway. |
328 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), |
|
328 | + 'gateways' => array('manual' => 1, 'offline' => 1), |
|
329 | 329 | 'default_gateway' => 'manual', |
330 | 330 | |
331 | 331 | // Offline gateway setup. |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | */ |
354 | 354 | function give_get_default_agreement_text() { |
355 | 355 | |
356 | - $org_name = get_bloginfo( 'name' ); |
|
356 | + $org_name = get_bloginfo('name'); |
|
357 | 357 | |
358 | 358 | $agreement = sprintf( |
359 | 359 | '<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the %1$s.</p> |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | $org_name |
368 | 368 | ); |
369 | 369 | |
370 | - return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name ); |
|
370 | + return apply_filters('give_get_default_agreement_text', $agreement, $org_name); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
@@ -376,22 +376,22 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @since 1.8.11 |
378 | 378 | */ |
379 | -function give_create_pages(){ |
|
379 | +function give_create_pages() { |
|
380 | 380 | |
381 | 381 | // Bailout if pages already created. |
382 | - if( get_option( 'give_install_pages_created') ) { |
|
382 | + if (get_option('give_install_pages_created')) { |
|
383 | 383 | return false; |
384 | 384 | } |
385 | 385 | |
386 | 386 | $options = array(); |
387 | 387 | |
388 | 388 | // Checks if the Success Page option exists AND that the page exists. |
389 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
389 | + if ( ! get_post(give_get_option('success_page'))) { |
|
390 | 390 | |
391 | 391 | // Donation Confirmation (Success) Page |
392 | 392 | $success = wp_insert_post( |
393 | 393 | array( |
394 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
394 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
395 | 395 | 'post_content' => '[give_receipt]', |
396 | 396 | 'post_status' => 'publish', |
397 | 397 | 'post_author' => 1, |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | // Checks if the Failure Page option exists AND that the page exists. |
408 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
408 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
409 | 409 | |
410 | 410 | // Failed Donation Page |
411 | 411 | $failed = wp_insert_post( |
412 | 412 | array( |
413 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
414 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
413 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
414 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
415 | 415 | 'post_status' => 'publish', |
416 | 416 | 'post_author' => 1, |
417 | 417 | 'post_type' => 'page', |
@@ -423,11 +423,11 @@ discard block |
||
423 | 423 | } |
424 | 424 | |
425 | 425 | // Checks if the History Page option exists AND that the page exists. |
426 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
426 | + if ( ! get_post(give_get_option('history_page'))) { |
|
427 | 427 | // Donation History Page |
428 | 428 | $history = wp_insert_post( |
429 | 429 | array( |
430 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
430 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
431 | 431 | 'post_content' => '[donation_history]', |
432 | 432 | 'post_status' => 'publish', |
433 | 433 | 'post_author' => 1, |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | $options['history_page'] = $history; |
440 | 440 | } |
441 | 441 | |
442 | - if( ! empty( $options ) ) { |
|
443 | - update_option( 'give_settings', array_merge( give_get_settings(), $options ) ); |
|
442 | + if ( ! empty($options)) { |
|
443 | + update_option('give_settings', array_merge(give_get_settings(), $options)); |
|
444 | 444 | } |
445 | 445 | |
446 | - add_option( 'give_install_pages_created', 1, '', 'no' ); |
|
446 | + add_option('give_install_pages_created', 1, '', 'no'); |
|
447 | 447 | } |
448 | -add_action( 'admin_init', 'give_create_pages', -1 ); |
|
448 | +add_action('admin_init', 'give_create_pages', -1); |