@@ -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,25 +25,25 @@ 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' ), |
|
39 | - 'currency_sign' => give_currency_filter( '' ), |
|
38 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
39 | + 'currency_sign' => give_currency_filter(''), |
|
40 | 40 | 'currency_pos' => give_get_currency_position(), |
41 | 41 | 'thousands_separator' => give_get_price_thousand_separator(), |
42 | 42 | 'decimal_separator' => give_get_price_decimal_separator(), |
43 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), |
|
44 | - 'bad_minimum' => __( 'The minimum donation amount for this form is', 'give' ), |
|
45 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
46 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
43 | + 'no_gateway' => __('Please select a payment method.', 'give'), |
|
44 | + 'bad_minimum' => __('The minimum donation amount for this form is', 'give'), |
|
45 | + 'general_loading' => __('Loading...', 'give'), |
|
46 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
47 | 47 | 'number_decimals' => give_get_price_decimals(), |
48 | 48 | 'give_version' => GIVE_VERSION, |
49 | 49 | 'magnific_options' => apply_filters( |
@@ -57,81 +57,81 @@ discard block |
||
57 | 57 | 'give_form_translation_js', |
58 | 58 | array( |
59 | 59 | // Field name Validation message. |
60 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), |
|
61 | - 'give_first' => __( 'Please enter your first name.', 'give' ), |
|
62 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), |
|
63 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), |
|
64 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), |
|
65 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), |
|
66 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), |
|
60 | + 'payment-mode' => __('Please select payment mode.', 'give'), |
|
61 | + 'give_first' => __('Please enter your first name.', 'give'), |
|
62 | + 'give_email' => __('Please enter a valid email address.', 'give'), |
|
63 | + 'give_user_login' => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'), |
|
64 | + 'give_user_pass' => __('Enter a password.', 'give'), |
|
65 | + 'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'), |
|
66 | + 'give_agree_to_terms' => __('You must agree to the terms and conditions.', 'give'), |
|
67 | 67 | ) |
68 | 68 | ), |
69 | - ) ); |
|
69 | + )); |
|
70 | 70 | |
71 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
71 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
72 | 72 | 'ajaxurl' => give_get_ajax_url(), |
73 | - 'loading' => __( 'Loading', 'give' ), |
|
73 | + 'loading' => __('Loading', 'give'), |
|
74 | 74 | // General loading message. |
75 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
75 | + 'select_option' => __('Please select an option', 'give'), |
|
76 | 76 | // Variable pricing error with multi-donation option enabled. |
77 | - 'default_gateway' => give_get_default_gateway( null ), |
|
78 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
77 | + 'default_gateway' => give_get_default_gateway(null), |
|
78 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
79 | 79 | 'number_decimals' => give_get_price_decimals(), |
80 | - ) ); |
|
80 | + )); |
|
81 | 81 | |
82 | 82 | // DEBUG is On. |
83 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
83 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
84 | 84 | |
85 | - if ( give_is_cc_verify_enabled() ) { |
|
86 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
87 | - wp_enqueue_script( 'give-cc-validator' ); |
|
85 | + if (give_is_cc_verify_enabled()) { |
|
86 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
87 | + wp_enqueue_script('give-cc-validator'); |
|
88 | 88 | } |
89 | 89 | |
90 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
91 | - wp_enqueue_script( 'give-float-labels' ); |
|
90 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
91 | + wp_enqueue_script('give-float-labels'); |
|
92 | 92 | |
93 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
94 | - wp_enqueue_script( 'give-blockui' ); |
|
93 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
94 | + wp_enqueue_script('give-blockui'); |
|
95 | 95 | |
96 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
97 | - wp_enqueue_script( 'give-qtip' ); |
|
96 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
97 | + wp_enqueue_script('give-qtip'); |
|
98 | 98 | |
99 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
100 | - wp_enqueue_script( 'give-accounting' ); |
|
99 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
100 | + wp_enqueue_script('give-accounting'); |
|
101 | 101 | |
102 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
103 | - wp_enqueue_script( 'give-magnific' ); |
|
102 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
103 | + wp_enqueue_script('give-magnific'); |
|
104 | 104 | |
105 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
106 | - wp_enqueue_script( 'give-checkout-global' ); |
|
105 | + wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
106 | + wp_enqueue_script('give-checkout-global'); |
|
107 | 107 | |
108 | 108 | // General scripts. |
109 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
110 | - wp_enqueue_script( 'give-scripts' ); |
|
109 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
110 | + wp_enqueue_script('give-scripts'); |
|
111 | 111 | |
112 | 112 | // Load AJAX scripts, if enabled. |
113 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
114 | - wp_enqueue_script( 'give-ajax' ); |
|
113 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
114 | + wp_enqueue_script('give-ajax'); |
|
115 | 115 | |
116 | 116 | // Localize / Pass AJAX vars from PHP, |
117 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars ); |
|
118 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
117 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars); |
|
118 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
119 | 119 | |
120 | 120 | } else { |
121 | 121 | |
122 | 122 | // DEBUG is OFF (one JS file to rule them all!). |
123 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
124 | - wp_enqueue_script( 'give' ); |
|
123 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
124 | + wp_enqueue_script('give'); |
|
125 | 125 | |
126 | 126 | // Localize / Pass AJAX vars from PHP. |
127 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
128 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
127 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
128 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
129 | 129 | |
130 | 130 | } |
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
134 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Register styles. |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | */ |
145 | 145 | function give_register_styles() { |
146 | 146 | |
147 | - if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
147 | + if ( ! give_is_setting_enabled(give_get_option('css'))) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
151 | - wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
152 | - wp_enqueue_style( 'give-styles' ); |
|
151 | + wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
152 | + wp_enqueue_style('give-styles'); |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
156 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
156 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
157 | 157 | |
158 | 158 | |
159 | 159 | /** |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | function give_get_stylesheet_uri() { |
167 | 167 | |
168 | 168 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
169 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
169 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
170 | 170 | |
171 | 171 | // LTR or RTL files. |
172 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
172 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
173 | 173 | |
174 | - $file = 'give' . $direction . $suffix . '.css'; |
|
174 | + $file = 'give'.$direction.$suffix.'.css'; |
|
175 | 175 | $templates_dir = give_get_theme_template_dir_name(); |
176 | 176 | |
177 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
178 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
179 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
180 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
181 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
177 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
178 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css'; |
|
179 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
180 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css'; |
|
181 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
182 | 182 | |
183 | 183 | $uri = false; |
184 | 184 | |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | * followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
189 | 189 | * This allows users to copy just give.css to their theme. |
190 | 190 | */ |
191 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
192 | - if ( ! empty( $nonmin ) ) { |
|
193 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
191 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
192 | + if ( ! empty($nonmin)) { |
|
193 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
194 | 194 | } else { |
195 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
195 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
196 | 196 | } |
197 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
198 | - if ( ! empty( $nonmin ) ) { |
|
199 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
197 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
198 | + if ( ! empty($nonmin)) { |
|
199 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
200 | 200 | } else { |
201 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
201 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
202 | 202 | } |
203 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
204 | - $uri = trailingslashit( give_get_templates_url() ) . $file; |
|
203 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
204 | + $uri = trailingslashit(give_get_templates_url()).$file; |
|
205 | 205 | } |
206 | 206 | |
207 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
207 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,73 +221,73 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return void |
223 | 223 | */ |
224 | -function give_load_admin_scripts( $hook ) { |
|
224 | +function give_load_admin_scripts($hook) { |
|
225 | 225 | |
226 | 226 | global $post, $post_type; |
227 | 227 | |
228 | 228 | $give_options = give_get_settings(); |
229 | 229 | |
230 | 230 | // Directories of assets. |
231 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
232 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
233 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
231 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
232 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
233 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
234 | 234 | |
235 | 235 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
236 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
236 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
237 | 237 | |
238 | 238 | // LTR or RTL files. |
239 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
239 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
240 | 240 | |
241 | 241 | // Global Admin. |
242 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
243 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
242 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
243 | + wp_enqueue_style('give-admin-bar-notification'); |
|
244 | 244 | |
245 | 245 | // Give Admin Only. |
246 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
246 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | |
250 | 250 | // CSS. |
251 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
252 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
253 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION ); |
|
254 | - wp_enqueue_style( 'give-admin' ); |
|
255 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
256 | - wp_enqueue_style( 'jquery-chosen' ); |
|
257 | - wp_enqueue_style( 'thickbox' ); |
|
251 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
252 | + wp_enqueue_style('jquery-ui-css'); |
|
253 | + wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION); |
|
254 | + wp_enqueue_style('give-admin'); |
|
255 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
256 | + wp_enqueue_style('jquery-chosen'); |
|
257 | + wp_enqueue_style('thickbox'); |
|
258 | 258 | |
259 | 259 | // JS. |
260 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
261 | - wp_enqueue_script( 'jquery-chosen' ); |
|
260 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
261 | + wp_enqueue_script('jquery-chosen'); |
|
262 | 262 | |
263 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
264 | - wp_enqueue_script( 'give-accounting' ); |
|
263 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
264 | + wp_enqueue_script('give-accounting'); |
|
265 | 265 | |
266 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
267 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
266 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
267 | + wp_enqueue_script('give-admin-scripts'); |
|
268 | 268 | |
269 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
270 | - wp_enqueue_script( 'jquery-flot' ); |
|
269 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
270 | + wp_enqueue_script('jquery-flot'); |
|
271 | 271 | |
272 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
273 | - wp_enqueue_script( 'give-qtip' ); |
|
272 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
273 | + wp_enqueue_script('give-qtip'); |
|
274 | 274 | |
275 | - wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
276 | - wp_enqueue_script( 'give-repeatable-fields' ); |
|
275 | + wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
276 | + wp_enqueue_script('give-repeatable-fields'); |
|
277 | 277 | |
278 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
279 | - wp_enqueue_script( 'thickbox' ); |
|
278 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
279 | + wp_enqueue_script('thickbox'); |
|
280 | 280 | |
281 | 281 | // Forms CPT Script. |
282 | - if ( $post_type === 'give_forms' ) { |
|
283 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
284 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
282 | + if ($post_type === 'give_forms') { |
|
283 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
284 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // Settings Scripts. |
288 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) { |
|
289 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
290 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
288 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
289 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
290 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | // Price Separators. |
@@ -295,60 +295,60 @@ discard block |
||
295 | 295 | $decimal_separator = give_get_price_decimal_separator(); |
296 | 296 | |
297 | 297 | // Localize strings & variables for JS. |
298 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
299 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
298 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
299 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
300 | 300 | 'give_version' => GIVE_VERSION, |
301 | 301 | 'thousands_separator' => $thousand_separator, |
302 | 302 | 'decimal_separator' => $decimal_separator, |
303 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
304 | - 'delete_payment' => __( 'Are you sure you wish to delete this payment?', 'give' ), |
|
305 | - 'delete_payment_note' => __( 'Are you sure you wish to delete this note?', 'give' ), |
|
306 | - 'revoke_api_key' => __( 'Are you sure you wish to revoke this API key?', 'give' ), |
|
307 | - 'regenerate_api_key' => __( 'Are you sure you wish to regenerate this API key?', 'give' ), |
|
308 | - 'resend_receipt' => __( 'Are you sure you wish to resend the donation receipt?', 'give' ), |
|
309 | - 'logo' => __( 'Logo', 'give' ), |
|
310 | - 'use_this_image' => __( 'Use this image', 'give' ), |
|
311 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
312 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
313 | - 'currency_sign' => give_currency_filter( '' ), |
|
314 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
315 | - 'currency_decimals' => give_currency_decimal_filter( give_get_price_decimals() ), |
|
316 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
317 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
318 | - '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' ), |
|
319 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
303 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
304 | + 'delete_payment' => __('Are you sure you wish to delete this payment?', 'give'), |
|
305 | + 'delete_payment_note' => __('Are you sure you wish to delete this note?', 'give'), |
|
306 | + 'revoke_api_key' => __('Are you sure you wish to revoke this API key?', 'give'), |
|
307 | + 'regenerate_api_key' => __('Are you sure you wish to regenerate this API key?', 'give'), |
|
308 | + 'resend_receipt' => __('Are you sure you wish to resend the donation receipt?', 'give'), |
|
309 | + 'logo' => __('Logo', 'give'), |
|
310 | + 'use_this_image' => __('Use this image', 'give'), |
|
311 | + 'one_option' => __('Choose a form', 'give'), |
|
312 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
313 | + 'currency_sign' => give_currency_filter(''), |
|
314 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
315 | + 'currency_decimals' => give_currency_decimal_filter(give_get_price_decimals()), |
|
316 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
317 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
318 | + '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'), |
|
319 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
320 | 320 | /* translators : %s: Donation form options metabox */ |
321 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this level?', 'give' ), |
|
322 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
323 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
321 | + 'confirm_before_remove_row_text' => __('Do you want to delete this level?', 'give'), |
|
322 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
323 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
324 | 324 | 'bulk_action' => array( |
325 | 325 | 'delete' => array( |
326 | - 'zero_payment_selected' => __( 'You must choose at least one or more payments to delete.', 'give' ), |
|
327 | - 'delete_payment' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
328 | - 'delete_payments' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
326 | + 'zero_payment_selected' => __('You must choose at least one or more payments to delete.', 'give'), |
|
327 | + 'delete_payment' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
328 | + 'delete_payments' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
329 | 329 | ), |
330 | 330 | 'resend_receipt' => array( |
331 | - 'zero_recipient_selected' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
332 | - 'resend_receipt' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
333 | - 'resend_receipts' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
331 | + 'zero_recipient_selected' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
332 | + 'resend_receipt' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
333 | + 'resend_receipts' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
334 | 334 | ), |
335 | 335 | ), |
336 | - 'upgrade_confirmation' => __( 'Please make sure to create a database backup before initiating the upgrade.', 'give' ), |
|
336 | + 'upgrade_confirmation' => __('Please make sure to create a database backup before initiating the upgrade.', 'give'), |
|
337 | 337 | 'metabox_fields' => array( |
338 | 338 | 'media' => array( |
339 | - 'button_title' => esc_html__( 'Choose Attachment', 'give' ), |
|
339 | + 'button_title' => esc_html__('Choose Attachment', 'give'), |
|
340 | 340 | ) |
341 | 341 | ) |
342 | - ) ); |
|
342 | + )); |
|
343 | 343 | |
344 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) { |
|
344 | + if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) { |
|
345 | 345 | // call for new media manager. |
346 | 346 | wp_enqueue_media(); |
347 | 347 | } |
348 | 348 | |
349 | 349 | } |
350 | 350 | |
351 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
351 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
352 | 352 | |
353 | 353 | /** |
354 | 354 | * Admin Give Icon |
@@ -363,13 +363,13 @@ discard block |
||
363 | 363 | ?> |
364 | 364 | <style type="text/css" media="screen"> |
365 | 365 | |
366 | - <?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?> |
|
366 | + <?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?> |
|
367 | 367 | @font-face { |
368 | 368 | font-family: 'give-icomoon'; |
369 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
370 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
371 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
372 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
369 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
370 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
371 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
372 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
373 | 373 | font-weight: normal; |
374 | 374 | font-style: normal; |
375 | 375 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | <?php |
389 | 389 | } |
390 | 390 | |
391 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
391 | +add_action('admin_head', 'give_admin_icon'); |
|
392 | 392 | |
393 | 393 | /** |
394 | 394 | * Admin js code |
@@ -418,4 +418,4 @@ discard block |
||
418 | 418 | <?php |
419 | 419 | } |
420 | 420 | |
421 | -add_action( 'admin_head', 'give_admin_hide_notice_shortly_js' ); |
|
421 | +add_action('admin_head', 'give_admin_hide_notice_shortly_js'); |
@@ -673,7 +673,7 @@ |
||
673 | 673 | |
674 | 674 | <div id="<?php echo $setting['id']; ?>" |
675 | 675 | class="panel give_options_panel<?php echo( $show_first_tab_content ? '' : ' give-hidden' ); |
676 | - $show_first_tab_content = false; ?>"> |
|
676 | + $show_first_tab_content = false; ?>"> |
|
677 | 677 | <?php if ( ! empty( $setting['fields'] ) ) : ?> |
678 | 678 | <?php foreach ( $setting['fields'] as $field ) : ?> |
679 | 679 | <?php give_render_field( $field ); ?> |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function __construct() { |
48 | 48 | $this->metabox_id = 'give-metabox-form-data'; |
49 | - $this->metabox_label = esc_html__( 'Donation Form Options', 'give' ); |
|
49 | + $this->metabox_label = esc_html__('Donation Form Options', 'give'); |
|
50 | 50 | |
51 | 51 | // Setup. |
52 | - add_action( 'admin_init', array( $this, 'setup' ) ); |
|
52 | + add_action('admin_init', array($this, 'setup')); |
|
53 | 53 | |
54 | 54 | // Add metabox. |
55 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ), 30 ); |
|
55 | + add_action('add_meta_boxes', array($this, 'add_meta_box'), 30); |
|
56 | 56 | |
57 | 57 | // Load required scripts. |
58 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_script' ) ); |
|
58 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_script')); |
|
59 | 59 | |
60 | 60 | // Save form meta. |
61 | - add_action( 'save_post_give_forms', array( $this, 'save' ), 10, 2 ); |
|
61 | + add_action('save_post_give_forms', array($this, 'save'), 10, 2); |
|
62 | 62 | |
63 | 63 | // cmb2 old setting loaders. |
64 | 64 | // add_filter( 'give_metabox_form_data_settings', array( $this, 'cmb2_metabox_settings' ) ); |
65 | 65 | // Add offline donations options. |
66 | - add_filter( 'give_metabox_form_data_settings', array( $this, 'add_offline_donations_setting_tab' ), 0, 1 ); |
|
66 | + add_filter('give_metabox_form_data_settings', array($this, 'add_offline_donations_setting_tab'), 0, 1); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -86,18 +86,18 @@ discard block |
||
86 | 86 | */ |
87 | 87 | function get_settings() { |
88 | 88 | $post_id = give_get_admin_post_id(); |
89 | - $price = give_get_form_price( $post_id ); |
|
90 | - $custom_amount_minimum = give_get_form_minimum_price( $post_id ); |
|
91 | - $goal = give_get_form_goal( $post_id ); |
|
89 | + $price = give_get_form_price($post_id); |
|
90 | + $custom_amount_minimum = give_get_form_minimum_price($post_id); |
|
91 | + $goal = give_get_form_goal($post_id); |
|
92 | 92 | |
93 | 93 | // No empty prices - min. 1.00 for new forms |
94 | - if ( empty( $price ) && is_null( $post_id ) ) { |
|
95 | - $price = esc_attr( give_format_decimal( '1.00' ) ); |
|
94 | + if (empty($price) && is_null($post_id)) { |
|
95 | + $price = esc_attr(give_format_decimal('1.00')); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // Min. $1.00 for new forms |
99 | - if ( empty( $custom_amount_minimum ) ) { |
|
100 | - $custom_amount_minimum = esc_attr( give_format_decimal( '1.00' ) ); |
|
99 | + if (empty($custom_amount_minimum)) { |
|
100 | + $custom_amount_minimum = esc_attr(give_format_decimal('1.00')); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // Start with an underscore to hide fields from custom fields list |
@@ -107,215 +107,215 @@ discard block |
||
107 | 107 | /** |
108 | 108 | * Repeatable Field Groups |
109 | 109 | */ |
110 | - 'form_field_options' => apply_filters( 'give_forms_field_options', array( |
|
110 | + 'form_field_options' => apply_filters('give_forms_field_options', array( |
|
111 | 111 | 'id' => 'form_field_options', |
112 | - 'title' => esc_html__( 'Donation Options', 'give' ), |
|
112 | + 'title' => esc_html__('Donation Options', 'give'), |
|
113 | 113 | 'icon-html' => '<span class="give-icon give-icon-heart"></span>', |
114 | - 'fields' => apply_filters( 'give_forms_donation_form_metabox_fields', array( |
|
114 | + 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array( |
|
115 | 115 | // Donation Option |
116 | 116 | array( |
117 | - 'name' => esc_html__( 'Donation Option', 'give' ), |
|
118 | - 'description' => esc_html__( 'Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ), |
|
119 | - 'id' => $prefix . 'price_option', |
|
117 | + 'name' => esc_html__('Donation Option', 'give'), |
|
118 | + 'description' => esc_html__('Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'), |
|
119 | + 'id' => $prefix.'price_option', |
|
120 | 120 | 'type' => 'radio_inline', |
121 | 121 | 'default' => 'set', |
122 | - 'options' => apply_filters( 'give_forms_price_options', array( |
|
123 | - 'set' => esc_html__( 'Set Donation', 'give' ), |
|
124 | - 'multi' => esc_html__( 'Multi-level Donation', 'give' ), |
|
125 | - ) ), |
|
122 | + 'options' => apply_filters('give_forms_price_options', array( |
|
123 | + 'set' => esc_html__('Set Donation', 'give'), |
|
124 | + 'multi' => esc_html__('Multi-level Donation', 'give'), |
|
125 | + )), |
|
126 | 126 | ), |
127 | 127 | array( |
128 | - 'name' => esc_html__( 'Set Donation', 'give' ), |
|
129 | - 'description' => esc_html__( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ), |
|
130 | - 'id' => $prefix . 'set_price', |
|
128 | + 'name' => esc_html__('Set Donation', 'give'), |
|
129 | + 'description' => esc_html__('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'), |
|
130 | + 'id' => $prefix.'set_price', |
|
131 | 131 | 'type' => 'text_small', |
132 | 132 | 'data_type' => 'price', |
133 | 133 | 'attributes' => array( |
134 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
135 | - 'value' => give_format_decimal( $price ), |
|
134 | + 'placeholder' => give_format_decimal('1.00'), |
|
135 | + 'value' => give_format_decimal($price), |
|
136 | 136 | 'class' => 'give-money-field', |
137 | 137 | ), |
138 | 138 | ), |
139 | 139 | // Display Style |
140 | 140 | array( |
141 | - 'name' => esc_html__( 'Display Style', 'give' ), |
|
142 | - 'description' => esc_html__( 'Set how the donations levels will display on the form.', 'give' ), |
|
143 | - 'id' => $prefix . 'display_style', |
|
141 | + 'name' => esc_html__('Display Style', 'give'), |
|
142 | + 'description' => esc_html__('Set how the donations levels will display on the form.', 'give'), |
|
143 | + 'id' => $prefix.'display_style', |
|
144 | 144 | 'type' => 'radio_inline', |
145 | 145 | 'default' => 'buttons', |
146 | 146 | 'options' => array( |
147 | - 'buttons' => esc_html__( 'Buttons', 'give' ), |
|
148 | - 'radios' => esc_html__( 'Radios', 'give' ), |
|
149 | - 'dropdown' => esc_html__( 'Dropdown', 'give' ), |
|
147 | + 'buttons' => esc_html__('Buttons', 'give'), |
|
148 | + 'radios' => esc_html__('Radios', 'give'), |
|
149 | + 'dropdown' => esc_html__('Dropdown', 'give'), |
|
150 | 150 | ), |
151 | 151 | ), |
152 | 152 | // Custom Amount |
153 | 153 | array( |
154 | - 'name' => esc_html__( 'Custom Amount', 'give' ), |
|
155 | - 'description' => esc_html__( 'Do you want the user to be able to input their own donation amount?', 'give' ), |
|
156 | - 'id' => $prefix . 'custom_amount', |
|
154 | + 'name' => esc_html__('Custom Amount', 'give'), |
|
155 | + 'description' => esc_html__('Do you want the user to be able to input their own donation amount?', 'give'), |
|
156 | + 'id' => $prefix.'custom_amount', |
|
157 | 157 | 'type' => 'radio_inline', |
158 | 158 | 'default' => 'disabled', |
159 | 159 | 'options' => array( |
160 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
161 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
160 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
161 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
162 | 162 | ), |
163 | 163 | ), |
164 | 164 | array( |
165 | - 'name' => esc_html__( 'Minimum Amount', 'give' ), |
|
166 | - 'description' => esc_html__( 'Enter the minimum custom donation amount.', 'give' ), |
|
167 | - 'id' => $prefix . 'custom_amount_minimum', |
|
165 | + 'name' => esc_html__('Minimum Amount', 'give'), |
|
166 | + 'description' => esc_html__('Enter the minimum custom donation amount.', 'give'), |
|
167 | + 'id' => $prefix.'custom_amount_minimum', |
|
168 | 168 | 'type' => 'text_small', |
169 | 169 | 'data_type' => 'price', |
170 | 170 | 'attributes' => array( |
171 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
172 | - 'value' => give_format_decimal( $custom_amount_minimum ), |
|
171 | + 'placeholder' => give_format_decimal('1.00'), |
|
172 | + 'value' => give_format_decimal($custom_amount_minimum), |
|
173 | 173 | 'class' => 'give-money-field', |
174 | 174 | ), |
175 | 175 | ), |
176 | 176 | array( |
177 | - 'name' => esc_html__( 'Custom Amount Text', 'give' ), |
|
178 | - 'description' => esc_html__( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ), |
|
179 | - 'id' => $prefix . 'custom_amount_text', |
|
177 | + 'name' => esc_html__('Custom Amount Text', 'give'), |
|
178 | + 'description' => esc_html__('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'), |
|
179 | + 'id' => $prefix.'custom_amount_text', |
|
180 | 180 | 'type' => 'text_medium', |
181 | 181 | 'attributes' => array( |
182 | 182 | 'rows' => 3, |
183 | - 'placeholder' => esc_attr__( 'Give a Custom Amount', 'give' ), |
|
183 | + 'placeholder' => esc_attr__('Give a Custom Amount', 'give'), |
|
184 | 184 | ), |
185 | 185 | ), |
186 | 186 | // Donation Levels: Repeatable CMB2 Group |
187 | 187 | array( |
188 | - 'id' => $prefix . 'donation_levels', |
|
188 | + 'id' => $prefix.'donation_levels', |
|
189 | 189 | 'type' => 'group', |
190 | 190 | 'options' => array( |
191 | - 'add_button' => esc_html__( 'Add Level', 'give' ), |
|
192 | - 'header_title' => esc_html__( 'Donation Level', 'give' ), |
|
191 | + 'add_button' => esc_html__('Add Level', 'give'), |
|
192 | + 'header_title' => esc_html__('Donation Level', 'give'), |
|
193 | 193 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
194 | 194 | ), |
195 | 195 | // Fields array works the same, except id's only need to be unique for this group. |
196 | 196 | // Prefix is not needed. |
197 | - 'fields' => apply_filters( 'give_donation_levels_table_row', array( |
|
197 | + 'fields' => apply_filters('give_donation_levels_table_row', array( |
|
198 | 198 | array( |
199 | - 'name' => esc_html__( 'ID', 'give' ), |
|
200 | - 'id' => $prefix . 'id', |
|
199 | + 'name' => esc_html__('ID', 'give'), |
|
200 | + 'id' => $prefix.'id', |
|
201 | 201 | 'type' => 'levels_id', |
202 | 202 | ), |
203 | 203 | array( |
204 | - 'name' => esc_html__( 'Amount', 'give' ), |
|
205 | - 'id' => $prefix . 'amount', |
|
204 | + 'name' => esc_html__('Amount', 'give'), |
|
205 | + 'id' => $prefix.'amount', |
|
206 | 206 | 'type' => 'text_small', |
207 | 207 | 'data_type' => 'price', |
208 | 208 | 'attributes' => array( |
209 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
209 | + 'placeholder' => give_format_decimal('1.00'), |
|
210 | 210 | 'class' => 'give-money-field', |
211 | 211 | ), |
212 | 212 | ), |
213 | 213 | array( |
214 | - 'name' => esc_html__( 'Text', 'give' ), |
|
215 | - 'id' => $prefix . 'text', |
|
214 | + 'name' => esc_html__('Text', 'give'), |
|
215 | + 'id' => $prefix.'text', |
|
216 | 216 | 'type' => 'text', |
217 | 217 | 'attributes' => array( |
218 | - 'placeholder' => esc_html__( 'Donation Level', 'give' ), |
|
218 | + 'placeholder' => esc_html__('Donation Level', 'give'), |
|
219 | 219 | 'class' => 'give-multilevel-text-field', |
220 | 220 | ), |
221 | 221 | ), |
222 | 222 | array( |
223 | - 'name' => esc_html__( 'Default', 'give' ), |
|
224 | - 'id' => $prefix . 'default', |
|
223 | + 'name' => esc_html__('Default', 'give'), |
|
224 | + 'id' => $prefix.'default', |
|
225 | 225 | 'type' => 'give_default_radio_inline', |
226 | 226 | ), |
227 | - ) ), |
|
227 | + )), |
|
228 | 228 | ), |
229 | 229 | array( |
230 | 230 | 'name' => 'donation_options_docs', |
231 | 231 | 'type' => 'docs_link', |
232 | 232 | 'url' => 'http://docs.givewp.com/form-donation-options', |
233 | - 'title' => esc_html__( 'Donation Options', 'give' ), |
|
233 | + 'title' => esc_html__('Donation Options', 'give'), |
|
234 | 234 | ), |
235 | 235 | ), |
236 | 236 | $post_id |
237 | 237 | ), |
238 | - ) ), |
|
238 | + )), |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Display Options |
242 | 242 | */ |
243 | - 'form_display_options' => apply_filters( 'give_form_display_options', array( |
|
243 | + 'form_display_options' => apply_filters('give_form_display_options', array( |
|
244 | 244 | 'id' => 'form_display_options', |
245 | - 'title' => esc_html__( 'Form Display', 'give' ), |
|
245 | + 'title' => esc_html__('Form Display', 'give'), |
|
246 | 246 | 'icon-html' => '<span class="give-icon give-icon-display"></span>', |
247 | - 'fields' => apply_filters( 'give_forms_display_options_metabox_fields', array( |
|
247 | + 'fields' => apply_filters('give_forms_display_options_metabox_fields', array( |
|
248 | 248 | array( |
249 | - 'name' => esc_html__( 'Display Options', 'give' ), |
|
250 | - 'desc' => sprintf( __( 'How would you like to display donation information for this form?', 'give' ), '#' ), |
|
251 | - 'id' => $prefix . 'payment_display', |
|
249 | + 'name' => esc_html__('Display Options', 'give'), |
|
250 | + 'desc' => sprintf(__('How would you like to display donation information for this form?', 'give'), '#'), |
|
251 | + 'id' => $prefix.'payment_display', |
|
252 | 252 | 'type' => 'radio_inline', |
253 | 253 | 'options' => array( |
254 | - 'onpage' => esc_html__( 'All Fields', 'give' ), |
|
255 | - 'modal' => esc_html__( 'Modal', 'give' ), |
|
256 | - 'reveal' => esc_html__( 'Reveal', 'give' ), |
|
257 | - 'button' => esc_html__( 'Button', 'give' ), |
|
254 | + 'onpage' => esc_html__('All Fields', 'give'), |
|
255 | + 'modal' => esc_html__('Modal', 'give'), |
|
256 | + 'reveal' => esc_html__('Reveal', 'give'), |
|
257 | + 'button' => esc_html__('Button', 'give'), |
|
258 | 258 | ), |
259 | 259 | 'default' => 'onpage', |
260 | 260 | ), |
261 | 261 | array( |
262 | - 'id' => $prefix . 'reveal_label', |
|
263 | - 'name' => esc_html__( 'Continue Button', 'give' ), |
|
264 | - 'desc' => esc_html__( 'The button label for displaying the additional payment fields.', 'give' ), |
|
262 | + 'id' => $prefix.'reveal_label', |
|
263 | + 'name' => esc_html__('Continue Button', 'give'), |
|
264 | + 'desc' => esc_html__('The button label for displaying the additional payment fields.', 'give'), |
|
265 | 265 | 'type' => 'text_small', |
266 | 266 | 'attributes' => array( |
267 | - 'placeholder' => esc_attr__( 'Donate Now', 'give' ), |
|
267 | + 'placeholder' => esc_attr__('Donate Now', 'give'), |
|
268 | 268 | ), |
269 | 269 | ), |
270 | 270 | array( |
271 | - 'id' => $prefix . 'checkout_label', |
|
272 | - 'name' => esc_html__( 'Submit Button', 'give' ), |
|
273 | - 'desc' => esc_html__( 'The button label for completing a donation.', 'give' ), |
|
271 | + 'id' => $prefix.'checkout_label', |
|
272 | + 'name' => esc_html__('Submit Button', 'give'), |
|
273 | + 'desc' => esc_html__('The button label for completing a donation.', 'give'), |
|
274 | 274 | 'type' => 'text_small', |
275 | 275 | 'attributes' => array( |
276 | - 'placeholder' => esc_html__( 'Donate Now', 'give' ), |
|
276 | + 'placeholder' => esc_html__('Donate Now', 'give'), |
|
277 | 277 | ), |
278 | 278 | ), |
279 | 279 | array( |
280 | - 'name' => esc_html__( 'Default Gateway', 'give' ), |
|
281 | - 'desc' => esc_html__( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ), |
|
282 | - 'id' => $prefix . 'default_gateway', |
|
280 | + 'name' => esc_html__('Default Gateway', 'give'), |
|
281 | + 'desc' => esc_html__('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'), |
|
282 | + 'id' => $prefix.'default_gateway', |
|
283 | 283 | 'type' => 'default_gateway', |
284 | 284 | ), |
285 | 285 | array( |
286 | - 'name' => esc_html__( 'Guest Donations', 'give' ), |
|
287 | - 'desc' => esc_html__( 'Do you want to allow non-logged-in users to make donations?', 'give' ), |
|
288 | - 'id' => $prefix . 'logged_in_only', |
|
286 | + 'name' => esc_html__('Guest Donations', 'give'), |
|
287 | + 'desc' => esc_html__('Do you want to allow non-logged-in users to make donations?', 'give'), |
|
288 | + 'id' => $prefix.'logged_in_only', |
|
289 | 289 | 'type' => 'radio_inline', |
290 | 290 | 'default' => 'enabled', |
291 | 291 | 'options' => array( |
292 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
293 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
292 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
293 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
294 | 294 | ), |
295 | 295 | ), |
296 | 296 | array( |
297 | - 'name' => esc_html__( 'Registration', 'give' ), |
|
298 | - 'desc' => esc_html__( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ), |
|
299 | - 'id' => $prefix . 'show_register_form', |
|
297 | + 'name' => esc_html__('Registration', 'give'), |
|
298 | + 'desc' => esc_html__('Display the registration and login forms in the payment section for non-logged-in users.', 'give'), |
|
299 | + 'id' => $prefix.'show_register_form', |
|
300 | 300 | 'type' => 'radio', |
301 | 301 | 'options' => array( |
302 | - 'none' => esc_html__( 'None', 'give' ), |
|
303 | - 'registration' => esc_html__( 'Registration', 'give' ), |
|
304 | - 'login' => esc_html__( 'Login', 'give' ), |
|
305 | - 'both' => esc_html__( 'Registration + Login', 'give' ), |
|
302 | + 'none' => esc_html__('None', 'give'), |
|
303 | + 'registration' => esc_html__('Registration', 'give'), |
|
304 | + 'login' => esc_html__('Login', 'give'), |
|
305 | + 'both' => esc_html__('Registration + Login', 'give'), |
|
306 | 306 | ), |
307 | 307 | 'default' => 'none', |
308 | 308 | ), |
309 | 309 | array( |
310 | - 'name' => esc_html__( 'Floating Labels', 'give' ), |
|
310 | + 'name' => esc_html__('Floating Labels', 'give'), |
|
311 | 311 | /* translators: %s: forms http://docs.givewp.com/form-floating-labels */ |
312 | - 'desc' => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ), |
|
313 | - 'id' => $prefix . 'form_floating_labels', |
|
312 | + 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('http://docs.givewp.com/form-floating-labels')), |
|
313 | + 'id' => $prefix.'form_floating_labels', |
|
314 | 314 | 'type' => 'radio_inline', |
315 | 315 | 'options' => array( |
316 | - 'global' => esc_html__( 'Global Option', 'give' ), |
|
317 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
318 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
316 | + 'global' => esc_html__('Global Option', 'give'), |
|
317 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
318 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
319 | 319 | ), |
320 | 320 | 'default' => 'global', |
321 | 321 | ), |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | 'name' => 'form_display_docs', |
324 | 324 | 'type' => 'docs_link', |
325 | 325 | 'url' => 'http://docs.givewp.com/form-display-options', |
326 | - 'title' => esc_html__( 'Form Display', 'give' ), |
|
326 | + 'title' => esc_html__('Form Display', 'give'), |
|
327 | 327 | ), |
328 | 328 | ), |
329 | 329 | $post_id |
@@ -334,193 +334,193 @@ discard block |
||
334 | 334 | /** |
335 | 335 | * Donation Goals |
336 | 336 | */ |
337 | - 'donation_goal_options' => apply_filters( 'give_donation_goal_options', array( |
|
337 | + 'donation_goal_options' => apply_filters('give_donation_goal_options', array( |
|
338 | 338 | 'id' => 'donation_goal_options', |
339 | - 'title' => esc_html__( 'Donation Goal', 'give' ), |
|
339 | + 'title' => esc_html__('Donation Goal', 'give'), |
|
340 | 340 | 'icon-html' => '<span class="give-icon give-icon-target"></span>', |
341 | - 'fields' => apply_filters( 'give_forms_donation_goal_metabox_fields', array( |
|
341 | + 'fields' => apply_filters('give_forms_donation_goal_metabox_fields', array( |
|
342 | 342 | // Goals |
343 | 343 | array( |
344 | - 'name' => esc_html__( 'Donation Goal', 'give' ), |
|
345 | - 'description' => esc_html__( 'Do you want to set a donation goal for this form?', 'give' ), |
|
346 | - 'id' => $prefix . 'goal_option', |
|
344 | + 'name' => esc_html__('Donation Goal', 'give'), |
|
345 | + 'description' => esc_html__('Do you want to set a donation goal for this form?', 'give'), |
|
346 | + 'id' => $prefix.'goal_option', |
|
347 | 347 | 'type' => 'radio_inline', |
348 | 348 | 'default' => 'disabled', |
349 | 349 | 'options' => array( |
350 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
351 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
350 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
351 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
352 | 352 | ), |
353 | 353 | ), |
354 | 354 | array( |
355 | - 'name' => esc_html__( 'Goal Amount', 'give' ), |
|
356 | - 'description' => esc_html__( 'This is the monetary goal amount you want to reach for this form.', 'give' ), |
|
357 | - 'id' => $prefix . 'set_goal', |
|
355 | + 'name' => esc_html__('Goal Amount', 'give'), |
|
356 | + 'description' => esc_html__('This is the monetary goal amount you want to reach for this form.', 'give'), |
|
357 | + 'id' => $prefix.'set_goal', |
|
358 | 358 | 'type' => 'text_small', |
359 | 359 | 'data_type' => 'price', |
360 | 360 | 'attributes' => array( |
361 | - 'placeholder' => give_format_decimal( '0.00' ), |
|
362 | - 'value' => give_format_decimal( $goal ), |
|
361 | + 'placeholder' => give_format_decimal('0.00'), |
|
362 | + 'value' => give_format_decimal($goal), |
|
363 | 363 | 'class' => 'give-money-field', |
364 | 364 | ), |
365 | 365 | ), |
366 | 366 | |
367 | 367 | array( |
368 | - 'name' => esc_html__( 'Goal Format', 'give' ), |
|
369 | - 'description' => esc_html__( 'Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give' ), |
|
370 | - 'id' => $prefix . 'goal_format', |
|
368 | + 'name' => esc_html__('Goal Format', 'give'), |
|
369 | + 'description' => esc_html__('Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give'), |
|
370 | + 'id' => $prefix.'goal_format', |
|
371 | 371 | 'type' => 'radio_inline', |
372 | 372 | 'default' => 'amount', |
373 | 373 | 'options' => array( |
374 | - 'amount' => esc_html__( 'Amount', 'give' ), |
|
375 | - 'percentage' => esc_html__( 'Percentage', 'give' ), |
|
374 | + 'amount' => esc_html__('Amount', 'give'), |
|
375 | + 'percentage' => esc_html__('Percentage', 'give'), |
|
376 | 376 | ), |
377 | 377 | ), |
378 | 378 | array( |
379 | - 'name' => esc_html__( 'Progress Bar Color', 'give' ), |
|
380 | - 'desc' => esc_html__( 'Customize the color of the goal progress bar.', 'give' ), |
|
381 | - 'id' => $prefix . 'goal_color', |
|
379 | + 'name' => esc_html__('Progress Bar Color', 'give'), |
|
380 | + 'desc' => esc_html__('Customize the color of the goal progress bar.', 'give'), |
|
381 | + 'id' => $prefix.'goal_color', |
|
382 | 382 | 'type' => 'colorpicker', |
383 | 383 | 'default' => '#2bc253', |
384 | 384 | ), |
385 | 385 | |
386 | 386 | array( |
387 | - 'name' => esc_html__( 'Close Form', 'give' ), |
|
388 | - 'desc' => esc_html__( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ), |
|
389 | - 'id' => $prefix . 'close_form_when_goal_achieved', |
|
387 | + 'name' => esc_html__('Close Form', 'give'), |
|
388 | + 'desc' => esc_html__('Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give'), |
|
389 | + 'id' => $prefix.'close_form_when_goal_achieved', |
|
390 | 390 | 'type' => 'radio_inline', |
391 | 391 | 'default' => 'disabled', |
392 | 392 | 'options' => array( |
393 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
394 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
393 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
394 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
395 | 395 | ), |
396 | 396 | ), |
397 | 397 | array( |
398 | - 'name' => esc_html__( 'Goal Achieved Message', 'give' ), |
|
399 | - 'desc' => esc_html__( 'Do you want to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give' ), |
|
400 | - 'id' => $prefix . 'form_goal_achieved_message', |
|
398 | + 'name' => esc_html__('Goal Achieved Message', 'give'), |
|
399 | + 'desc' => esc_html__('Do you want to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give'), |
|
400 | + 'id' => $prefix.'form_goal_achieved_message', |
|
401 | 401 | 'type' => 'textarea', |
402 | 402 | 'attributes' => array( |
403 | - 'placeholder' => esc_attr__( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ), |
|
403 | + 'placeholder' => esc_attr__('Thank you to all our donors, we have met our fundraising goal.', 'give'), |
|
404 | 404 | ), |
405 | 405 | ), |
406 | 406 | array( |
407 | 407 | 'name' => 'donation_goal_docs', |
408 | 408 | 'type' => 'docs_link', |
409 | 409 | 'url' => 'http://docs.givewp.com/form-donation-goal', |
410 | - 'title' => esc_html__( 'Donation Goal', 'give' ), |
|
410 | + 'title' => esc_html__('Donation Goal', 'give'), |
|
411 | 411 | ), |
412 | 412 | ), |
413 | 413 | $post_id |
414 | 414 | ), |
415 | - ) ), |
|
415 | + )), |
|
416 | 416 | |
417 | 417 | /** |
418 | 418 | * Content Field |
419 | 419 | */ |
420 | - 'form_content_options' => apply_filters( 'give_forms_content_options', array( |
|
420 | + 'form_content_options' => apply_filters('give_forms_content_options', array( |
|
421 | 421 | 'id' => 'form_content_options', |
422 | - 'title' => esc_html__( 'Form Content', 'give' ), |
|
422 | + 'title' => esc_html__('Form Content', 'give'), |
|
423 | 423 | 'icon-html' => '<span class="give-icon give-icon-edit"></span>', |
424 | - 'fields' => apply_filters( 'give_forms_content_options_metabox_fields', array( |
|
424 | + 'fields' => apply_filters('give_forms_content_options_metabox_fields', array( |
|
425 | 425 | |
426 | 426 | // Donation content. |
427 | 427 | array( |
428 | - 'name' => esc_html__( 'Display Content', 'give' ), |
|
429 | - 'description' => esc_html__( 'Do you want to add custom content to this form?', 'give' ), |
|
430 | - 'id' => $prefix . 'display_content', |
|
428 | + 'name' => esc_html__('Display Content', 'give'), |
|
429 | + 'description' => esc_html__('Do you want to add custom content to this form?', 'give'), |
|
430 | + 'id' => $prefix.'display_content', |
|
431 | 431 | 'type' => 'radio_inline', |
432 | 432 | 'options' => array( |
433 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
434 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
433 | + 'enabled' => esc_html__('Enabled', 'give'), |
|
434 | + 'disabled' => esc_html__('Disabled', 'give'), |
|
435 | 435 | ), |
436 | 436 | 'default' => 'disabled', |
437 | 437 | ), |
438 | 438 | |
439 | 439 | // Content placement. |
440 | 440 | array( |
441 | - 'name' => esc_html__( 'Content Placement', 'give' ), |
|
442 | - 'description' => esc_html__( 'This option controls where the content appears within the donation form.', 'give' ), |
|
443 | - 'id' => $prefix . 'content_placement', |
|
441 | + 'name' => esc_html__('Content Placement', 'give'), |
|
442 | + 'description' => esc_html__('This option controls where the content appears within the donation form.', 'give'), |
|
443 | + 'id' => $prefix.'content_placement', |
|
444 | 444 | 'type' => 'radio_inline', |
445 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
446 | - 'give_pre_form' => esc_html__( 'Above fields', 'give' ), |
|
447 | - 'give_post_form' => esc_html__( 'Below fields', 'give' ), |
|
445 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
446 | + 'give_pre_form' => esc_html__('Above fields', 'give'), |
|
447 | + 'give_post_form' => esc_html__('Below fields', 'give'), |
|
448 | 448 | ) |
449 | 449 | ), |
450 | 450 | 'default' => 'give_pre_form', |
451 | 451 | ), |
452 | 452 | array( |
453 | - 'name' => esc_html__( 'Content', 'give' ), |
|
454 | - 'description' => esc_html__( 'This content will display on the single give form page.', 'give' ), |
|
455 | - 'id' => $prefix . 'form_content', |
|
453 | + 'name' => esc_html__('Content', 'give'), |
|
454 | + 'description' => esc_html__('This content will display on the single give form page.', 'give'), |
|
455 | + 'id' => $prefix.'form_content', |
|
456 | 456 | 'type' => 'wysiwyg', |
457 | 457 | ), |
458 | 458 | array( |
459 | 459 | 'name' => 'form_content_docs', |
460 | 460 | 'type' => 'docs_link', |
461 | 461 | 'url' => 'http://docs.givewp.com/form-content', |
462 | - 'title' => esc_html__( 'Form Content', 'give' ), |
|
462 | + 'title' => esc_html__('Form Content', 'give'), |
|
463 | 463 | ), |
464 | 464 | ), |
465 | 465 | $post_id |
466 | 466 | ), |
467 | - ) ), |
|
467 | + )), |
|
468 | 468 | |
469 | 469 | /** |
470 | 470 | * Terms & Conditions |
471 | 471 | */ |
472 | - 'form_terms_options' => apply_filters( 'give_forms_terms_options', array( |
|
472 | + 'form_terms_options' => apply_filters('give_forms_terms_options', array( |
|
473 | 473 | 'id' => 'form_terms_options', |
474 | - 'title' => esc_html__( 'Terms & Conditions', 'give' ), |
|
474 | + 'title' => esc_html__('Terms & Conditions', 'give'), |
|
475 | 475 | 'icon-html' => '<span class="give-icon give-icon-checklist"></span>', |
476 | - 'fields' => apply_filters( 'give_forms_terms_options_metabox_fields', array( |
|
476 | + 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array( |
|
477 | 477 | // Donation Option |
478 | 478 | array( |
479 | - 'name' => esc_html__( 'Terms & Conditions', 'give' ), |
|
480 | - 'description' => esc_html__( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ), |
|
481 | - 'id' => $prefix . 'terms_option', |
|
479 | + 'name' => esc_html__('Terms & Conditions', 'give'), |
|
480 | + 'description' => esc_html__('Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give'), |
|
481 | + 'id' => $prefix.'terms_option', |
|
482 | 482 | 'type' => 'radio_inline', |
483 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
484 | - 'global' => esc_html__( 'Global Option', 'give' ), |
|
485 | - 'enabled' => esc_html__( 'Customize', 'give' ), |
|
486 | - 'disabled' => esc_html__( 'Disable', 'give' ), |
|
483 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
484 | + 'global' => esc_html__('Global Option', 'give'), |
|
485 | + 'enabled' => esc_html__('Customize', 'give'), |
|
486 | + 'disabled' => esc_html__('Disable', 'give'), |
|
487 | 487 | ) |
488 | 488 | ), |
489 | 489 | 'default' => 'global', |
490 | 490 | ), |
491 | 491 | array( |
492 | - 'id' => $prefix . 'agree_label', |
|
493 | - 'name' => esc_html__( 'Agreement Label', 'give' ), |
|
494 | - 'desc' => esc_html__( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ), |
|
492 | + 'id' => $prefix.'agree_label', |
|
493 | + 'name' => esc_html__('Agreement Label', 'give'), |
|
494 | + 'desc' => esc_html__('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'), |
|
495 | 495 | 'type' => 'text', |
496 | 496 | 'size' => 'regular', |
497 | 497 | 'attributes' => array( |
498 | - 'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ), |
|
498 | + 'placeholder' => esc_attr__('Agree to Terms?', 'give'), |
|
499 | 499 | ), |
500 | 500 | ), |
501 | 501 | array( |
502 | - 'id' => $prefix . 'agree_text', |
|
503 | - 'name' => esc_html__( 'Agreement Text', 'give' ), |
|
504 | - 'desc' => esc_html__( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ), |
|
502 | + 'id' => $prefix.'agree_text', |
|
503 | + 'name' => esc_html__('Agreement Text', 'give'), |
|
504 | + 'desc' => esc_html__('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), |
|
505 | 505 | 'type' => 'wysiwyg', |
506 | 506 | ), |
507 | 507 | array( |
508 | 508 | 'name' => 'terms_docs', |
509 | 509 | 'type' => 'docs_link', |
510 | 510 | 'url' => 'http://docs.givewp.com/form-terms', |
511 | - 'title' => esc_html__( 'Terms & Conditions', 'give' ), |
|
511 | + 'title' => esc_html__('Terms & Conditions', 'give'), |
|
512 | 512 | ), |
513 | 513 | ), |
514 | 514 | $post_id |
515 | 515 | ), |
516 | - ) ), |
|
516 | + )), |
|
517 | 517 | ); |
518 | 518 | |
519 | 519 | |
520 | 520 | /** |
521 | 521 | * Filter the metabox tabbed panel settings. |
522 | 522 | */ |
523 | - $settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id ); |
|
523 | + $settings = apply_filters('give_metabox_form_data_settings', $settings, $post_id); |
|
524 | 524 | |
525 | 525 | // Output. |
526 | 526 | return $settings; |
@@ -536,8 +536,8 @@ discard block |
||
536 | 536 | add_meta_box( |
537 | 537 | $this->get_metabox_ID(), |
538 | 538 | $this->get_metabox_label(), |
539 | - array( $this, 'output' ), |
|
540 | - array( 'give_forms' ), |
|
539 | + array($this, 'output'), |
|
540 | + array('give_forms'), |
|
541 | 541 | 'normal', |
542 | 542 | 'high' |
543 | 543 | ); |
@@ -553,9 +553,9 @@ discard block |
||
553 | 553 | function enqueue_script() { |
554 | 554 | global $post; |
555 | 555 | |
556 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
557 | - wp_enqueue_style( 'wp-color-picker' ); |
|
558 | - wp_enqueue_script( 'wp-color-picker' ); |
|
556 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
557 | + wp_enqueue_style('wp-color-picker'); |
|
558 | + wp_enqueue_script('wp-color-picker'); |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | |
@@ -589,32 +589,32 @@ discard block |
||
589 | 589 | public function get_tabs() { |
590 | 590 | $tabs = array(); |
591 | 591 | |
592 | - if ( ! empty( $this->settings ) ) { |
|
593 | - foreach ( $this->settings as $setting ) { |
|
594 | - if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) { |
|
592 | + if ( ! empty($this->settings)) { |
|
593 | + foreach ($this->settings as $setting) { |
|
594 | + if ( ! isset($setting['id']) || ! isset($setting['title'])) { |
|
595 | 595 | continue; |
596 | 596 | } |
597 | 597 | $tab = array( |
598 | 598 | 'id' => $setting['id'], |
599 | 599 | 'label' => $setting['title'], |
600 | - 'icon-html' => ( ! empty( $setting['icon-html'] ) ? $setting['icon-html'] : '' ), |
|
600 | + 'icon-html' => ( ! empty($setting['icon-html']) ? $setting['icon-html'] : ''), |
|
601 | 601 | ); |
602 | 602 | |
603 | - if ( $this->has_sub_tab( $setting ) ) { |
|
604 | - if ( empty( $setting['sub-fields'] ) ) { |
|
603 | + if ($this->has_sub_tab($setting)) { |
|
604 | + if (empty($setting['sub-fields'])) { |
|
605 | 605 | $tab = array(); |
606 | 606 | } else { |
607 | - foreach ( $setting['sub-fields'] as $sub_fields ) { |
|
607 | + foreach ($setting['sub-fields'] as $sub_fields) { |
|
608 | 608 | $tab['sub-fields'][] = array( |
609 | 609 | 'id' => $sub_fields['id'], |
610 | 610 | 'label' => $sub_fields['title'], |
611 | - 'icon-html' => ( ! empty( $sub_fields['icon-html'] ) ? $sub_fields['icon-html'] : '' ), |
|
611 | + 'icon-html' => ( ! empty($sub_fields['icon-html']) ? $sub_fields['icon-html'] : ''), |
|
612 | 612 | ); |
613 | 613 | } |
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | - if ( ! empty( $tab ) ) { |
|
617 | + if ( ! empty($tab)) { |
|
618 | 618 | $tabs[] = $tab; |
619 | 619 | } |
620 | 620 | } |
@@ -631,27 +631,27 @@ discard block |
||
631 | 631 | */ |
632 | 632 | public function output() { |
633 | 633 | // Bailout. |
634 | - if ( $form_data_tabs = $this->get_tabs() ) { |
|
635 | - wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' ); |
|
634 | + if ($form_data_tabs = $this->get_tabs()) { |
|
635 | + wp_nonce_field('give_save_form_meta', 'give_form_meta_nonce'); |
|
636 | 636 | ?> |
637 | 637 | <div class="give-metabox-panel-wrap"> |
638 | 638 | <ul class="give-form-data-tabs give-metabox-tabs"> |
639 | - <?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?> |
|
640 | - <li class="<?php echo "{$form_data_tab['id']}_tab" . ( ! $index ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>"> |
|
639 | + <?php foreach ($form_data_tabs as $index => $form_data_tab) : ?> |
|
640 | + <li class="<?php echo "{$form_data_tab['id']}_tab".( ! $index ? ' active' : '').($this->has_sub_tab($form_data_tab) ? ' has-sub-fields' : ''); ?>"> |
|
641 | 641 | <a href="#<?php echo $form_data_tab['id']; ?>"> |
642 | - <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
|
642 | + <?php if ( ! empty($form_data_tab['icon-html'])) : ?> |
|
643 | 643 | <?php echo $form_data_tab['icon-html']; ?> |
644 | 644 | <?php else : ?> |
645 | 645 | <span class="give-icon give-icon-default"></span> |
646 | 646 | <?php endif; ?> |
647 | 647 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
648 | 648 | </a> |
649 | - <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
|
649 | + <?php if ($this->has_sub_tab($form_data_tab)) : ?> |
|
650 | 650 | <ul class="give-metabox-sub-tabs give-hidden"> |
651 | - <?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?> |
|
651 | + <?php foreach ($form_data_tab['sub-fields'] as $sub_tab) : ?> |
|
652 | 652 | <li class="<?php echo "{$sub_tab['id']}_tab"; ?>"> |
653 | 653 | <a href="#<?php echo $sub_tab['id']; ?>"> |
654 | - <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
|
654 | + <?php if ( ! empty($sub_tab['icon-html'])) : ?> |
|
655 | 655 | <?php echo $sub_tab['icon-html']; ?> |
656 | 656 | <?php else : ?> |
657 | 657 | <span class="give-icon give-icon-default"></span> |
@@ -667,30 +667,30 @@ discard block |
||
667 | 667 | </ul> |
668 | 668 | |
669 | 669 | <?php $show_first_tab_content = true; ?> |
670 | - <?php foreach ( $this->settings as $setting ) : ?> |
|
671 | - <?php if ( ! $this->has_sub_tab( $setting ) ) : ?> |
|
672 | - <?php do_action( "give_before_{$setting['id']}_settings" ); ?> |
|
670 | + <?php foreach ($this->settings as $setting) : ?> |
|
671 | + <?php if ( ! $this->has_sub_tab($setting)) : ?> |
|
672 | + <?php do_action("give_before_{$setting['id']}_settings"); ?> |
|
673 | 673 | |
674 | 674 | <div id="<?php echo $setting['id']; ?>" |
675 | - class="panel give_options_panel<?php echo( $show_first_tab_content ? '' : ' give-hidden' ); |
|
675 | + class="panel give_options_panel<?php echo($show_first_tab_content ? '' : ' give-hidden'); |
|
676 | 676 | $show_first_tab_content = false; ?>"> |
677 | - <?php if ( ! empty( $setting['fields'] ) ) : ?> |
|
678 | - <?php foreach ( $setting['fields'] as $field ) : ?> |
|
679 | - <?php give_render_field( $field ); ?> |
|
677 | + <?php if ( ! empty($setting['fields'])) : ?> |
|
678 | + <?php foreach ($setting['fields'] as $field) : ?> |
|
679 | + <?php give_render_field($field); ?> |
|
680 | 680 | <?php endforeach; ?> |
681 | 681 | <?php endif; ?> |
682 | 682 | </div> |
683 | 683 | |
684 | - <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
|
684 | + <?php do_action("give_after_{$setting['id']}_settings"); ?> |
|
685 | 685 | <?php else: ?> |
686 | - <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
|
687 | - <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
|
688 | - <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
|
686 | + <?php if ($this->has_sub_tab($setting)) : ?> |
|
687 | + <?php if ( ! empty($setting['sub-fields'])) : ?> |
|
688 | + <?php foreach ($setting['sub-fields'] as $index => $sub_fields) : ?> |
|
689 | 689 | <div id="<?php echo $sub_fields['id']; ?>" |
690 | 690 | class="panel give_options_panel give-hidden"> |
691 | - <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
|
692 | - <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
|
693 | - <?php give_render_field( $sub_field ); ?> |
|
691 | + <?php if ( ! empty($sub_fields['fields'])) : ?> |
|
692 | + <?php foreach ($sub_fields['fields'] as $sub_field) : ?> |
|
693 | + <?php give_render_field($sub_field); ?> |
|
694 | 694 | <?php endforeach; ?> |
695 | 695 | <?php endif; ?> |
696 | 696 | </div> |
@@ -714,9 +714,9 @@ discard block |
||
714 | 714 | * |
715 | 715 | * @return bool |
716 | 716 | */ |
717 | - private function has_sub_tab( $field_setting ) { |
|
717 | + private function has_sub_tab($field_setting) { |
|
718 | 718 | $has_sub_tab = false; |
719 | - if ( array_key_exists( 'sub-fields', $field_setting ) ) { |
|
719 | + if (array_key_exists('sub-fields', $field_setting)) { |
|
720 | 720 | $has_sub_tab = true; |
721 | 721 | } |
722 | 722 | |
@@ -730,13 +730,13 @@ discard block |
||
730 | 730 | * @return array |
731 | 731 | */ |
732 | 732 | function cmb2_metabox_settings() { |
733 | - $all_cmb2_settings = apply_filters( 'cmb2_meta_boxes', array() ); |
|
733 | + $all_cmb2_settings = apply_filters('cmb2_meta_boxes', array()); |
|
734 | 734 | $give_forms_settings = $all_cmb2_settings; |
735 | 735 | |
736 | 736 | // Filter settings: Use only give forms related settings. |
737 | - foreach ( $all_cmb2_settings as $index => $setting ) { |
|
738 | - if ( ! in_array( 'give_forms', $setting['object_types'] ) ) { |
|
739 | - unset( $give_forms_settings[ $index ] ); |
|
737 | + foreach ($all_cmb2_settings as $index => $setting) { |
|
738 | + if ( ! in_array('give_forms', $setting['object_types'])) { |
|
739 | + unset($give_forms_settings[$index]); |
|
740 | 740 | } |
741 | 741 | } |
742 | 742 | |
@@ -754,114 +754,114 @@ discard block |
||
754 | 754 | * |
755 | 755 | * @return void |
756 | 756 | */ |
757 | - public function save( $post_id, $post ) { |
|
757 | + public function save($post_id, $post) { |
|
758 | 758 | |
759 | 759 | // $post_id and $post are required. |
760 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
760 | + if (empty($post_id) || empty($post)) { |
|
761 | 761 | return; |
762 | 762 | } |
763 | 763 | |
764 | 764 | // Don't save meta boxes for revisions or autosaves. |
765 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
765 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
766 | 766 | return; |
767 | 767 | } |
768 | 768 | |
769 | 769 | // Check the nonce. |
770 | - if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) { |
|
770 | + if (empty($_POST['give_form_meta_nonce']) || ! wp_verify_nonce($_POST['give_form_meta_nonce'], 'give_save_form_meta')) { |
|
771 | 771 | return; |
772 | 772 | } |
773 | 773 | |
774 | 774 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
775 | - if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
|
775 | + if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) { |
|
776 | 776 | return; |
777 | 777 | } |
778 | 778 | |
779 | 779 | // Check user has permission to edit. |
780 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
780 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
781 | 781 | return; |
782 | 782 | } |
783 | 783 | |
784 | 784 | // Fire action before saving form meta. |
785 | - do_action( 'give_pre_process_give_forms_meta', $post_id, $post ); |
|
785 | + do_action('give_pre_process_give_forms_meta', $post_id, $post); |
|
786 | 786 | |
787 | 787 | /** |
788 | 788 | * Filter the meta key to save. |
789 | 789 | * Third party addon developer can remove there meta keys from this array to handle saving data on there own. |
790 | 790 | */ |
791 | - $form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() ); |
|
791 | + $form_meta_keys = apply_filters('give_process_form_meta_keys', $this->get_meta_keys_from_settings()); |
|
792 | 792 | |
793 | 793 | // Save form meta data. |
794 | - if ( ! empty( $form_meta_keys ) ) { |
|
795 | - foreach ( $form_meta_keys as $form_meta_key ) { |
|
794 | + if ( ! empty($form_meta_keys)) { |
|
795 | + foreach ($form_meta_keys as $form_meta_key) { |
|
796 | 796 | |
797 | 797 | // Set default value for checkbox fields. |
798 | 798 | if ( |
799 | - ! isset( $_POST[ $form_meta_key ] ) |
|
800 | - && ( 'checkbox' === $this->get_field_type( $form_meta_key ) ) |
|
799 | + ! isset($_POST[$form_meta_key]) |
|
800 | + && ('checkbox' === $this->get_field_type($form_meta_key)) |
|
801 | 801 | ) { |
802 | - $_POST[ $form_meta_key ] = ''; |
|
802 | + $_POST[$form_meta_key] = ''; |
|
803 | 803 | } |
804 | 804 | |
805 | - if ( isset( $_POST[ $form_meta_key ] ) ) { |
|
806 | - if ( $field_type = $this->get_field_type( $form_meta_key ) ) { |
|
807 | - switch ( $field_type ) { |
|
805 | + if (isset($_POST[$form_meta_key])) { |
|
806 | + if ($field_type = $this->get_field_type($form_meta_key)) { |
|
807 | + switch ($field_type) { |
|
808 | 808 | case 'textarea': |
809 | 809 | case 'wysiwyg': |
810 | - $form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] ); |
|
811 | - update_post_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
810 | + $form_meta_value = wp_kses_post($_POST[$form_meta_key]); |
|
811 | + update_post_meta($post_id, $form_meta_key, $form_meta_value); |
|
812 | 812 | break; |
813 | 813 | |
814 | 814 | case 'group': |
815 | 815 | $form_meta_value = array(); |
816 | 816 | |
817 | - foreach ( $_POST[ $form_meta_key ] as $index => $group ) { |
|
817 | + foreach ($_POST[$form_meta_key] as $index => $group) { |
|
818 | 818 | |
819 | 819 | // Do not save template input field values. |
820 | - if ( '{{row-count-placeholder}}' === $index ) { |
|
820 | + if ('{{row-count-placeholder}}' === $index) { |
|
821 | 821 | continue; |
822 | 822 | } |
823 | 823 | |
824 | 824 | $group_meta_value = array(); |
825 | - foreach ( $group as $field_id => $field_value ) { |
|
826 | - switch ( $this->get_field_type( $field_id, $form_meta_key ) ) { |
|
825 | + foreach ($group as $field_id => $field_value) { |
|
826 | + switch ($this->get_field_type($field_id, $form_meta_key)) { |
|
827 | 827 | case 'wysiwyg': |
828 | - $group_meta_value[ $field_id ] = wp_kses_post( $field_value ); |
|
828 | + $group_meta_value[$field_id] = wp_kses_post($field_value); |
|
829 | 829 | break; |
830 | 830 | |
831 | 831 | default: |
832 | - $group_meta_value[ $field_id ] = give_clean( $field_value ); |
|
832 | + $group_meta_value[$field_id] = give_clean($field_value); |
|
833 | 833 | } |
834 | 834 | } |
835 | 835 | |
836 | - if ( ! empty( $group_meta_value ) ) { |
|
837 | - $form_meta_value[ $index ] = $group_meta_value; |
|
836 | + if ( ! empty($group_meta_value)) { |
|
837 | + $form_meta_value[$index] = $group_meta_value; |
|
838 | 838 | } |
839 | 839 | } |
840 | 840 | |
841 | 841 | |
842 | 842 | // Arrange repeater field keys in order. |
843 | - $form_meta_value = array_values( $form_meta_value ); |
|
843 | + $form_meta_value = array_values($form_meta_value); |
|
844 | 844 | |
845 | 845 | // Save data. |
846 | - update_post_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
846 | + update_post_meta($post_id, $form_meta_key, $form_meta_value); |
|
847 | 847 | break; |
848 | 848 | |
849 | 849 | default: |
850 | - $form_meta_value = give_clean( $_POST[ $form_meta_key ] ); |
|
850 | + $form_meta_value = give_clean($_POST[$form_meta_key]); |
|
851 | 851 | |
852 | 852 | // Save data. |
853 | - update_post_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
853 | + update_post_meta($post_id, $form_meta_key, $form_meta_value); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | // Fire after saving form meta key. |
857 | - do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post ); |
|
857 | + do_action("give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post); |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | } |
861 | 861 | } |
862 | 862 | |
863 | 863 | // Fire action after saving form meta. |
864 | - do_action( 'give_post_process_give_forms_meta', $post_id, $post ); |
|
864 | + do_action('give_post_process_give_forms_meta', $post_id, $post); |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | |
@@ -874,10 +874,10 @@ discard block |
||
874 | 874 | * |
875 | 875 | * @return string |
876 | 876 | */ |
877 | - private function get_field_id( $field ) { |
|
877 | + private function get_field_id($field) { |
|
878 | 878 | $field_id = ''; |
879 | 879 | |
880 | - if ( array_key_exists( 'id', $field ) ) { |
|
880 | + if (array_key_exists('id', $field)) { |
|
881 | 881 | $field_id = $field['id']; |
882 | 882 | |
883 | 883 | } |
@@ -894,12 +894,12 @@ discard block |
||
894 | 894 | * |
895 | 895 | * @return array |
896 | 896 | */ |
897 | - private function get_fields_id( $setting ) { |
|
897 | + private function get_fields_id($setting) { |
|
898 | 898 | $meta_keys = array(); |
899 | 899 | |
900 | - if ( ! empty( $setting ) ) { |
|
901 | - foreach ( $setting['fields'] as $field ) { |
|
902 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
900 | + if ( ! empty($setting)) { |
|
901 | + foreach ($setting['fields'] as $field) { |
|
902 | + if ($field_id = $this->get_field_id($field)) { |
|
903 | 903 | $meta_keys[] = $field_id; |
904 | 904 | } |
905 | 905 | } |
@@ -917,14 +917,14 @@ discard block |
||
917 | 917 | * |
918 | 918 | * @return array |
919 | 919 | */ |
920 | - private function get_sub_fields_id( $setting ) { |
|
920 | + private function get_sub_fields_id($setting) { |
|
921 | 921 | $meta_keys = array(); |
922 | 922 | |
923 | - if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) { |
|
924 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
925 | - if ( ! empty( $fields['fields'] ) ) { |
|
926 | - foreach ( $fields['fields'] as $field ) { |
|
927 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
923 | + if ($this->has_sub_tab($setting) && ! empty($setting['sub-fields'])) { |
|
924 | + foreach ($setting['sub-fields'] as $fields) { |
|
925 | + if ( ! empty($fields['fields'])) { |
|
926 | + foreach ($fields['fields'] as $field) { |
|
927 | + if ($field_id = $this->get_field_id($field)) { |
|
928 | 928 | $meta_keys[] = $field_id; |
929 | 929 | } |
930 | 930 | } |
@@ -945,14 +945,14 @@ discard block |
||
945 | 945 | private function get_meta_keys_from_settings() { |
946 | 946 | $meta_keys = array(); |
947 | 947 | |
948 | - foreach ( $this->settings as $setting ) { |
|
949 | - if ( $this->has_sub_tab( $setting ) ) { |
|
950 | - $meta_key = $this->get_sub_fields_id( $setting ); |
|
948 | + foreach ($this->settings as $setting) { |
|
949 | + if ($this->has_sub_tab($setting)) { |
|
950 | + $meta_key = $this->get_sub_fields_id($setting); |
|
951 | 951 | } else { |
952 | - $meta_key = $this->get_fields_id( $setting ); |
|
952 | + $meta_key = $this->get_fields_id($setting); |
|
953 | 953 | } |
954 | 954 | |
955 | - $meta_keys = array_merge( $meta_keys, $meta_key ); |
|
955 | + $meta_keys = array_merge($meta_keys, $meta_key); |
|
956 | 956 | } |
957 | 957 | |
958 | 958 | return $meta_keys; |
@@ -969,10 +969,10 @@ discard block |
||
969 | 969 | * |
970 | 970 | * @return string |
971 | 971 | */ |
972 | - function get_field_type( $field_id, $group_id = '' ) { |
|
973 | - $field = $this->get_setting_field( $field_id, $group_id ); |
|
972 | + function get_field_type($field_id, $group_id = '') { |
|
973 | + $field = $this->get_setting_field($field_id, $group_id); |
|
974 | 974 | |
975 | - $type = array_key_exists( 'type', $field ) |
|
975 | + $type = array_key_exists('type', $field) |
|
976 | 976 | ? $field['type'] |
977 | 977 | : ''; |
978 | 978 | |
@@ -990,12 +990,12 @@ discard block |
||
990 | 990 | * |
991 | 991 | * @return array |
992 | 992 | */ |
993 | - private function get_field( $setting, $field_id ) { |
|
993 | + private function get_field($setting, $field_id) { |
|
994 | 994 | $setting_field = array(); |
995 | 995 | |
996 | - if ( ! empty( $setting['fields'] ) ) { |
|
997 | - foreach ( $setting['fields'] as $field ) { |
|
998 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) { |
|
996 | + if ( ! empty($setting['fields'])) { |
|
997 | + foreach ($setting['fields'] as $field) { |
|
998 | + if (array_key_exists('id', $field) && $field['id'] === $field_id) { |
|
999 | 999 | $setting_field = $field; |
1000 | 1000 | break; |
1001 | 1001 | } |
@@ -1015,12 +1015,12 @@ discard block |
||
1015 | 1015 | * |
1016 | 1016 | * @return array |
1017 | 1017 | */ |
1018 | - private function get_sub_field( $setting, $field_id ) { |
|
1018 | + private function get_sub_field($setting, $field_id) { |
|
1019 | 1019 | $setting_field = array(); |
1020 | 1020 | |
1021 | - if ( ! empty( $setting['sub-fields'] ) ) { |
|
1022 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
1023 | - if ( $field = $this->get_field( $fields, $field_id ) ) { |
|
1021 | + if ( ! empty($setting['sub-fields'])) { |
|
1022 | + foreach ($setting['sub-fields'] as $fields) { |
|
1023 | + if ($field = $this->get_field($fields, $field_id)) { |
|
1024 | 1024 | $setting_field = $field; |
1025 | 1025 | break; |
1026 | 1026 | } |
@@ -1040,17 +1040,17 @@ discard block |
||
1040 | 1040 | * |
1041 | 1041 | * @return array |
1042 | 1042 | */ |
1043 | - function get_setting_field( $field_id, $group_id = '' ) { |
|
1043 | + function get_setting_field($field_id, $group_id = '') { |
|
1044 | 1044 | $setting_field = array(); |
1045 | 1045 | |
1046 | 1046 | $_field_id = $field_id; |
1047 | - $field_id = empty( $group_id ) ? $field_id : $group_id; |
|
1047 | + $field_id = empty($group_id) ? $field_id : $group_id; |
|
1048 | 1048 | |
1049 | - if ( ! empty( $this->settings ) ) { |
|
1050 | - foreach ( $this->settings as $setting ) { |
|
1049 | + if ( ! empty($this->settings)) { |
|
1050 | + foreach ($this->settings as $setting) { |
|
1051 | 1051 | if ( |
1052 | - ( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) ) |
|
1053 | - || ( $setting_field = $this->get_field( $setting, $field_id ) ) |
|
1052 | + ($this->has_sub_tab($setting) && ($setting_field = $this->get_sub_field($setting, $field_id))) |
|
1053 | + || ($setting_field = $this->get_field($setting, $field_id)) |
|
1054 | 1054 | ) { |
1055 | 1055 | break; |
1056 | 1056 | } |
@@ -1059,9 +1059,9 @@ discard block |
||
1059 | 1059 | |
1060 | 1060 | |
1061 | 1061 | // Get field from group. |
1062 | - if ( ! empty( $group_id ) ) { |
|
1063 | - foreach ( $setting_field['fields'] as $field ) { |
|
1064 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) { |
|
1062 | + if ( ! empty($group_id)) { |
|
1063 | + foreach ($setting_field['fields'] as $field) { |
|
1064 | + if (array_key_exists('id', $field) && $field['id'] === $_field_id) { |
|
1065 | 1065 | $setting_field = $field; |
1066 | 1066 | } |
1067 | 1067 | } |
@@ -1080,14 +1080,14 @@ discard block |
||
1080 | 1080 | * |
1081 | 1081 | * @return mixed |
1082 | 1082 | */ |
1083 | - function add_offline_donations_setting_tab( $settings ) { |
|
1084 | - if ( give_is_gateway_active( 'offline' ) ) { |
|
1085 | - $settings['offline_donations_options'] = apply_filters( 'give_forms_offline_donations_options', array( |
|
1083 | + function add_offline_donations_setting_tab($settings) { |
|
1084 | + if (give_is_gateway_active('offline')) { |
|
1085 | + $settings['offline_donations_options'] = apply_filters('give_forms_offline_donations_options', array( |
|
1086 | 1086 | 'id' => 'offline_donations_options', |
1087 | - 'title' => esc_html__( 'Offline Donations', 'give' ), |
|
1087 | + 'title' => esc_html__('Offline Donations', 'give'), |
|
1088 | 1088 | 'icon-html' => '<span class="give-icon give-icon-purse"></span>', |
1089 | - 'fields' => apply_filters( 'give_forms_offline_donations_metabox_fields', array() ), |
|
1090 | - ) ); |
|
1089 | + 'fields' => apply_filters('give_forms_offline_donations_metabox_fields', array()), |
|
1090 | + )); |
|
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | return $settings; |
@@ -641,9 +641,12 @@ discard block |
||
641 | 641 | <a href="#<?php echo $form_data_tab['id']; ?>"> |
642 | 642 | <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
643 | 643 | <?php echo $form_data_tab['icon-html']; ?> |
644 | - <?php else : ?> |
|
644 | + <?php else { |
|
645 | + : ?> |
|
645 | 646 | <span class="give-icon give-icon-default"></span> |
646 | - <?php endif; ?> |
|
647 | + <?php endif; |
|
648 | +} |
|
649 | +?> |
|
647 | 650 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
648 | 651 | </a> |
649 | 652 | <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
@@ -653,9 +656,12 @@ discard block |
||
653 | 656 | <a href="#<?php echo $sub_tab['id']; ?>"> |
654 | 657 | <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
655 | 658 | <?php echo $sub_tab['icon-html']; ?> |
656 | - <?php else : ?> |
|
659 | + <?php else { |
|
660 | + : ?> |
|
657 | 661 | <span class="give-icon give-icon-default"></span> |
658 | - <?php endif; ?> |
|
662 | + <?php endif; |
|
663 | +} |
|
664 | +?> |
|
659 | 665 | <span class="give-label"><?php echo $sub_tab['label']; ?></span> |
660 | 666 | </a> |
661 | 667 | </li> |
@@ -682,11 +688,14 @@ discard block |
||
682 | 688 | </div> |
683 | 689 | |
684 | 690 | <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
685 | - <?php else: ?> |
|
691 | + <?php else { |
|
692 | + : ?> |
|
686 | 693 | <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
687 | 694 | <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
688 | 695 | <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
689 | - <div id="<?php echo $sub_fields['id']; ?>" |
|
696 | + <div id="<?php echo $sub_fields['id']; |
|
697 | +} |
|
698 | +?>" |
|
690 | 699 | class="panel give_options_panel give-hidden"> |
691 | 700 | <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
692 | 701 | <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
@@ -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,38 +26,38 @@ discard block |
||
26 | 26 | function give_donation_history() { |
27 | 27 | |
28 | 28 | // If payment_key query arg exists, return receipt instead of donation history. |
29 | - if ( isset( $_GET['payment_key'] ) ) { |
|
29 | + if (isset($_GET['payment_key'])) { |
|
30 | 30 | ob_start(); |
31 | - echo give_receipt_shortcode( array() ); |
|
32 | - echo '<a href="' . esc_url( give_get_history_page_uri() ) . '">« ' . esc_html__( 'Return to All Donations', 'give' ) . '</a>'; |
|
31 | + echo give_receipt_shortcode(array()); |
|
32 | + echo '<a href="'.esc_url(give_get_history_page_uri()).'">« '.esc_html__('Return to All Donations', 'give').'</a>'; |
|
33 | 33 | |
34 | 34 | return ob_get_clean(); |
35 | 35 | } |
36 | 36 | |
37 | - $email_access = give_get_option( 'email_access' ); |
|
37 | + $email_access = give_get_option('email_access'); |
|
38 | 38 | |
39 | 39 | //Is user logged in? Does a session exist? Does an email-access token exist? |
40 | - if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) { |
|
40 | + if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) { |
|
41 | 41 | ob_start(); |
42 | - give_get_template_part( 'history', 'donations' ); |
|
42 | + give_get_template_part('history', 'donations'); |
|
43 | 43 | |
44 | 44 | return ob_get_clean(); |
45 | 45 | } //Is Email-based access enabled? |
46 | - elseif ( give_is_setting_enabled( $email_access ) ) { |
|
46 | + elseif (give_is_setting_enabled($email_access)) { |
|
47 | 47 | |
48 | 48 | ob_start(); |
49 | - give_get_template_part( 'email', 'login-form' ); |
|
49 | + give_get_template_part('email', 'login-form'); |
|
50 | 50 | |
51 | 51 | return ob_get_clean(); |
52 | 52 | } else { |
53 | - $message = esc_html__( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ); |
|
54 | - echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message ); |
|
55 | - echo do_shortcode( '[give_login]' ); |
|
53 | + $message = esc_html__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'); |
|
54 | + echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message); |
|
55 | + echo do_shortcode('[give_login]'); |
|
56 | 56 | |
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
60 | +add_shortcode('donation_history', 'give_donation_history'); |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Donation Form Shortcode |
@@ -70,29 +70,29 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return string |
72 | 72 | */ |
73 | -function give_form_shortcode( $atts ) { |
|
74 | - $atts = shortcode_atts( array( |
|
73 | +function give_form_shortcode($atts) { |
|
74 | + $atts = shortcode_atts(array( |
|
75 | 75 | 'id' => '', |
76 | 76 | 'show_title' => true, |
77 | 77 | 'show_goal' => true, |
78 | 78 | 'show_content' => '', |
79 | 79 | 'float_labels' => '', |
80 | 80 | 'display_style' => '', |
81 | - ), $atts, 'give_form' ); |
|
81 | + ), $atts, 'give_form'); |
|
82 | 82 | |
83 | 83 | // Convert string to bool. |
84 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
85 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
84 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
85 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
86 | 86 | |
87 | 87 | //get the Give Form |
88 | 88 | ob_start(); |
89 | - give_get_donation_form( $atts ); |
|
89 | + give_get_donation_form($atts); |
|
90 | 90 | $final_output = ob_get_clean(); |
91 | 91 | |
92 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
92 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
93 | 93 | } |
94 | 94 | |
95 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
95 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * Donation Form Goal Shortcode. |
@@ -105,37 +105,37 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return string |
107 | 107 | */ |
108 | -function give_goal_shortcode( $atts ) { |
|
109 | - $atts = shortcode_atts( array( |
|
108 | +function give_goal_shortcode($atts) { |
|
109 | + $atts = shortcode_atts(array( |
|
110 | 110 | 'id' => '', |
111 | 111 | 'show_text' => true, |
112 | 112 | 'show_bar' => true, |
113 | - ), $atts, 'give_goal' ); |
|
113 | + ), $atts, 'give_goal'); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | //get the Give Form. |
117 | 117 | ob_start(); |
118 | 118 | |
119 | 119 | //Sanity check 1: ensure there is an ID Provided. |
120 | - if ( empty( $atts['id'] ) ) { |
|
121 | - give_output_error( esc_html__( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
120 | + if (empty($atts['id'])) { |
|
121 | + give_output_error(esc_html__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | //Sanity check 2: Check the form even has Goals enabled. |
125 | - if ( ! give_is_setting_enabled( get_post_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
125 | + if ( ! give_is_setting_enabled(get_post_meta($atts['id'], '_give_goal_option', true))) { |
|
126 | 126 | |
127 | - give_output_error( esc_html__( 'The form does not have Goals enabled.', 'give' ), true ); |
|
127 | + give_output_error(esc_html__('The form does not have Goals enabled.', 'give'), true); |
|
128 | 128 | } else { |
129 | 129 | //Passed all sanity checks: output Goal. |
130 | - give_show_goal_progress( $atts['id'], $atts ); |
|
130 | + give_show_goal_progress($atts['id'], $atts); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | $final_output = ob_get_clean(); |
134 | 134 | |
135 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
135 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
136 | 136 | } |
137 | 137 | |
138 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
138 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
139 | 139 | |
140 | 140 | |
141 | 141 | /** |
@@ -152,22 +152,22 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return string |
154 | 154 | */ |
155 | -function give_login_form_shortcode( $atts ) { |
|
156 | - $atts = shortcode_atts( array( |
|
155 | +function give_login_form_shortcode($atts) { |
|
156 | + $atts = shortcode_atts(array( |
|
157 | 157 | // Add backward compatibility for redirect attribute. |
158 | 158 | 'redirect' => '', |
159 | 159 | |
160 | 160 | 'login-redirect' => '', |
161 | 161 | 'logout-redirect' => '', |
162 | - ), $atts, 'give_login' ); |
|
162 | + ), $atts, 'give_login'); |
|
163 | 163 | |
164 | 164 | // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
165 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
165 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
166 | 166 | |
167 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
167 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
168 | 168 | } |
169 | 169 | |
170 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
170 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Register Shortcode. |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return string |
184 | 184 | */ |
185 | -function give_register_form_shortcode( $atts ) { |
|
186 | - $atts = shortcode_atts( array( |
|
185 | +function give_register_form_shortcode($atts) { |
|
186 | + $atts = shortcode_atts(array( |
|
187 | 187 | 'redirect' => '', |
188 | - ), $atts, 'give_register' ); |
|
188 | + ), $atts, 'give_register'); |
|
189 | 189 | |
190 | - return give_register_form( $atts['redirect'] ); |
|
190 | + return give_register_form($atts['redirect']); |
|
191 | 191 | } |
192 | 192 | |
193 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
193 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
194 | 194 | |
195 | 195 | /** |
196 | 196 | * Receipt Shortcode. |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @return string |
205 | 205 | */ |
206 | -function give_receipt_shortcode( $atts ) { |
|
206 | +function give_receipt_shortcode($atts) { |
|
207 | 207 | |
208 | 208 | global $give_receipt_args, $payment; |
209 | 209 | |
210 | - $give_receipt_args = shortcode_atts( array( |
|
211 | - 'error' => esc_html__( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
210 | + $give_receipt_args = shortcode_atts(array( |
|
211 | + 'error' => esc_html__('You are missing the payment key to view this donation receipt.', 'give'), |
|
212 | 212 | 'price' => true, |
213 | 213 | 'donor' => true, |
214 | 214 | 'date' => true, |
@@ -217,50 +217,50 @@ discard block |
||
217 | 217 | 'payment_id' => true, |
218 | 218 | 'payment_status' => false, |
219 | 219 | 'status_notice' => true, |
220 | - ), $atts, 'give_receipt' ); |
|
220 | + ), $atts, 'give_receipt'); |
|
221 | 221 | |
222 | 222 | //set $session var |
223 | 223 | $session = give_get_purchase_session(); |
224 | 224 | |
225 | 225 | //set payment key var |
226 | - if ( isset( $_GET['payment_key'] ) ) { |
|
227 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
228 | - } elseif ( $session ) { |
|
226 | + if (isset($_GET['payment_key'])) { |
|
227 | + $payment_key = urldecode($_GET['payment_key']); |
|
228 | + } elseif ($session) { |
|
229 | 229 | $payment_key = $session['purchase_key']; |
230 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
230 | + } elseif ($give_receipt_args['payment_key']) { |
|
231 | 231 | $payment_key = $give_receipt_args['payment_key']; |
232 | 232 | } |
233 | 233 | |
234 | - $email_access = give_get_option( 'email_access' ); |
|
234 | + $email_access = give_get_option('email_access'); |
|
235 | 235 | |
236 | 236 | // No payment_key found & Email Access is Turned on: |
237 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
237 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
238 | 238 | |
239 | 239 | ob_start(); |
240 | 240 | |
241 | - give_get_template_part( 'email-login-form' ); |
|
241 | + give_get_template_part('email-login-form'); |
|
242 | 242 | |
243 | 243 | return ob_get_clean(); |
244 | 244 | |
245 | - } elseif ( ! isset( $payment_key ) ) { |
|
245 | + } elseif ( ! isset($payment_key)) { |
|
246 | 246 | |
247 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
247 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
248 | 248 | |
249 | 249 | } |
250 | 250 | |
251 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
252 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
251 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
252 | + $user_can_view = give_can_view_receipt($payment_key); |
|
253 | 253 | |
254 | 254 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
255 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
255 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
256 | 256 | |
257 | 257 | ob_start(); |
258 | 258 | |
259 | - give_get_template_part( 'email-login-form' ); |
|
259 | + give_get_template_part('email-login-form'); |
|
260 | 260 | |
261 | 261 | return ob_get_clean(); |
262 | 262 | |
263 | - } elseif ( ! $user_can_view ) { |
|
263 | + } elseif ( ! $user_can_view) { |
|
264 | 264 | |
265 | 265 | global $give_login_redirect; |
266 | 266 | |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | |
269 | 269 | ob_start(); |
270 | 270 | |
271 | - give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
271 | + give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation receipt.', 'give'))); |
|
272 | 272 | |
273 | - give_get_template_part( 'shortcode', 'login' ); |
|
273 | + give_get_template_part('shortcode', 'login'); |
|
274 | 274 | |
275 | 275 | $login_form = ob_get_clean(); |
276 | 276 | |
@@ -285,20 +285,20 @@ discard block |
||
285 | 285 | * or if user is logged in and the user can view sensitive shop data. |
286 | 286 | * |
287 | 287 | */ |
288 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
289 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
288 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
289 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | ob_start(); |
293 | 293 | |
294 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
294 | + give_get_template_part('shortcode', 'receipt'); |
|
295 | 295 | |
296 | 296 | $display = ob_get_clean(); |
297 | 297 | |
298 | 298 | return $display; |
299 | 299 | } |
300 | 300 | |
301 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
301 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
302 | 302 | |
303 | 303 | /** |
304 | 304 | * Profile Editor Shortcode. |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return string Output generated from the profile editor |
319 | 319 | */ |
320 | -function give_profile_editor_shortcode( $atts ) { |
|
320 | +function give_profile_editor_shortcode($atts) { |
|
321 | 321 | |
322 | 322 | ob_start(); |
323 | 323 | |
324 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
324 | + give_get_template_part('shortcode', 'profile-editor'); |
|
325 | 325 | |
326 | 326 | $display = ob_get_clean(); |
327 | 327 | |
328 | 328 | return $display; |
329 | 329 | } |
330 | 330 | |
331 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
331 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
332 | 332 | |
333 | 333 | /** |
334 | 334 | * Process Profile Updater Form. |
@@ -341,30 +341,30 @@ discard block |
||
341 | 341 | * |
342 | 342 | * @return bool |
343 | 343 | */ |
344 | -function give_process_profile_editor_updates( $data ) { |
|
344 | +function give_process_profile_editor_updates($data) { |
|
345 | 345 | // Profile field change request |
346 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
346 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
347 | 347 | return false; |
348 | 348 | } |
349 | 349 | |
350 | 350 | // Nonce security |
351 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
351 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
352 | 352 | return false; |
353 | 353 | } |
354 | 354 | |
355 | 355 | $user_id = get_current_user_id(); |
356 | - $old_user_data = get_userdata( $user_id ); |
|
357 | - |
|
358 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
359 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
360 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
361 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
362 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
363 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
364 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
365 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
366 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
367 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
356 | + $old_user_data = get_userdata($user_id); |
|
357 | + |
|
358 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
359 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
360 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
361 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
362 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
363 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
364 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
365 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
366 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
367 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
368 | 368 | |
369 | 369 | $userdata = array( |
370 | 370 | 'ID' => $user_id, |
@@ -392,46 +392,46 @@ discard block |
||
392 | 392 | * @param int $user_id The ID of the user. |
393 | 393 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
394 | 394 | */ |
395 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
395 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
396 | 396 | |
397 | 397 | // New password |
398 | - if ( ! empty( $data['give_new_user_pass1'] ) ) { |
|
399 | - if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) { |
|
400 | - give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) ); |
|
398 | + if ( ! empty($data['give_new_user_pass1'])) { |
|
399 | + if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) { |
|
400 | + give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give')); |
|
401 | 401 | } else { |
402 | 402 | $userdata['user_pass'] = $data['give_new_user_pass1']; |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | - if ( empty( $email ) ) { |
|
406 | + if (empty($email)) { |
|
407 | 407 | // Make sure email should not be empty. |
408 | - give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) ); |
|
408 | + give_set_error('email_empty', esc_html__('The email you entered is empty.', 'give')); |
|
409 | 409 | |
410 | - } else if ( ! is_email( $email ) ) { |
|
410 | + } else if ( ! is_email($email)) { |
|
411 | 411 | // Make sure email should be valid. |
412 | - give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
412 | + give_set_error('email_not_valid', esc_html__('The email you entered is not valid. Please use another', 'give')); |
|
413 | 413 | |
414 | - } else if ( $email != $old_user_data->user_email ) { |
|
414 | + } else if ($email != $old_user_data->user_email) { |
|
415 | 415 | // Make sure the new email doesn't belong to another user |
416 | - if ( email_exists( $email ) ) { |
|
417 | - give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
416 | + if (email_exists($email)) { |
|
417 | + give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give')); |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 | |
421 | 421 | // Check for errors |
422 | 422 | $errors = give_get_errors(); |
423 | 423 | |
424 | - if ( $errors ) { |
|
424 | + if ($errors) { |
|
425 | 425 | // Send back to the profile editor if there are errors |
426 | - wp_redirect( $data['give_redirect'] ); |
|
426 | + wp_redirect($data['give_redirect']); |
|
427 | 427 | give_die(); |
428 | 428 | } |
429 | 429 | |
430 | 430 | // Update the user |
431 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
432 | - $updated = wp_update_user( $userdata ); |
|
431 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
432 | + $updated = wp_update_user($userdata); |
|
433 | 433 | |
434 | - if ( $updated ) { |
|
434 | + if ($updated) { |
|
435 | 435 | |
436 | 436 | /** |
437 | 437 | * Fires after updating user profile. |
@@ -441,12 +441,12 @@ discard block |
||
441 | 441 | * @param int $user_id The ID of the user. |
442 | 442 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
443 | 443 | */ |
444 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
445 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
444 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
445 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
446 | 446 | give_die(); |
447 | 447 | } |
448 | 448 | |
449 | 449 | return false; |
450 | 450 | } |
451 | 451 | |
452 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
452 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function __construct() { |
89 | 89 | |
90 | - if ( 'none' === $this->get_template() ) { |
|
90 | + if ('none' === $this->get_template()) { |
|
91 | 91 | $this->html = false; |
92 | 92 | } |
93 | 93 | |
94 | - add_action( 'give_email_send_before', array( $this, 'send_before' ) ); |
|
95 | - add_action( 'give_email_send_after', array( $this, 'send_after' ) ); |
|
94 | + add_action('give_email_send_before', array($this, 'send_before')); |
|
95 | + add_action('give_email_send_after', array($this, 'send_after')); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param $key |
105 | 105 | * @param $value |
106 | 106 | */ |
107 | - public function __set( $key, $value ) { |
|
107 | + public function __set($key, $value) { |
|
108 | 108 | $this->$key = $value; |
109 | 109 | } |
110 | 110 | |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | * @since 1.0 |
115 | 115 | */ |
116 | 116 | public function get_from_name() { |
117 | - if ( ! $this->from_name ) { |
|
118 | - $this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) ); |
|
117 | + if ( ! $this->from_name) { |
|
118 | + $this->from_name = give_get_option('from_name', get_bloginfo('name')); |
|
119 | 119 | } |
120 | 120 | |
121 | - return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this ); |
|
121 | + return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | * @since 1.0 |
128 | 128 | */ |
129 | 129 | public function get_from_address() { |
130 | - if ( ! $this->from_address ) { |
|
131 | - $this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) ); |
|
130 | + if ( ! $this->from_address) { |
|
131 | + $this->from_address = give_get_option('from_email', get_option('admin_email')); |
|
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( 'give_email_from_address', $this->from_address, $this ); |
|
134 | + return apply_filters('give_email_from_address', $this->from_address, $this); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | * @since 1.0 |
141 | 141 | */ |
142 | 142 | public function get_content_type() { |
143 | - if ( ! $this->content_type && $this->html ) { |
|
144 | - $this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this ); |
|
145 | - } else if ( ! $this->html ) { |
|
143 | + if ( ! $this->content_type && $this->html) { |
|
144 | + $this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this); |
|
145 | + } else if ( ! $this->html) { |
|
146 | 146 | $this->content_type = 'text/plain'; |
147 | 147 | } |
148 | 148 | |
149 | - return apply_filters( 'give_email_content_type', $this->content_type, $this ); |
|
149 | + return apply_filters('give_email_content_type', $this->content_type, $this); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * @since 1.0 |
156 | 156 | */ |
157 | 157 | public function get_headers() { |
158 | - if ( ! $this->headers ) { |
|
158 | + if ( ! $this->headers) { |
|
159 | 159 | $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n"; |
160 | 160 | $this->headers .= "Reply-To: {$this->get_from_address()}\r\n"; |
161 | 161 | $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n"; |
162 | 162 | } |
163 | 163 | |
164 | - return apply_filters( 'give_email_headers', $this->headers, $this ); |
|
164 | + return apply_filters('give_email_headers', $this->headers, $this); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function get_templates() { |
173 | 173 | $templates = array( |
174 | - 'default' => esc_html__( 'Default Template', 'give' ), |
|
175 | - 'none' => esc_html__( 'No template, plain text only', 'give' ) |
|
174 | + 'default' => esc_html__('Default Template', 'give'), |
|
175 | + 'none' => esc_html__('No template, plain text only', 'give') |
|
176 | 176 | ); |
177 | 177 | |
178 | - return apply_filters( 'give_email_templates', $templates ); |
|
178 | + return apply_filters('give_email_templates', $templates); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | * @since 1.0 |
185 | 185 | */ |
186 | 186 | public function get_template() { |
187 | - if ( ! $this->template ) { |
|
188 | - $this->template = give_get_option( 'email_template', 'default' ); |
|
187 | + if ( ! $this->template) { |
|
188 | + $this->template = give_get_option('email_template', 'default'); |
|
189 | 189 | } |
190 | 190 | |
191 | - return apply_filters( 'give_email_template', $this->template ); |
|
191 | + return apply_filters('give_email_template', $this->template); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @since 1.0 |
198 | 198 | */ |
199 | 199 | public function get_heading() { |
200 | - return apply_filters( 'give_email_heading', $this->heading ); |
|
200 | + return apply_filters('give_email_heading', $this->heading); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return mixed |
209 | 209 | */ |
210 | - public function parse_tags( $content ) { |
|
210 | + public function parse_tags($content) { |
|
211 | 211 | return $content; |
212 | 212 | } |
213 | 213 | |
@@ -220,19 +220,19 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - public function build_email( $message ) { |
|
223 | + public function build_email($message) { |
|
224 | 224 | |
225 | - if ( false === $this->html ) { |
|
226 | - return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this ); |
|
225 | + if (false === $this->html) { |
|
226 | + return apply_filters('give_email_message', wp_strip_all_tags($message), $this); |
|
227 | 227 | } |
228 | 228 | |
229 | - $message = $this->text_to_html( $message ); |
|
229 | + $message = $this->text_to_html($message); |
|
230 | 230 | |
231 | 231 | $template = $this->get_template(); |
232 | 232 | |
233 | 233 | ob_start(); |
234 | 234 | |
235 | - give_get_template_part( 'emails/header', $template, true ); |
|
235 | + give_get_template_part('emails/header', $template, true); |
|
236 | 236 | |
237 | 237 | /** |
238 | 238 | * Fires in the email head. |
@@ -241,17 +241,17 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @param Give_Emails $this The email object. |
243 | 243 | */ |
244 | - do_action( 'give_email_header', $this ); |
|
244 | + do_action('give_email_header', $this); |
|
245 | 245 | |
246 | - if ( has_action( 'give_email_template_' . $template ) ) { |
|
246 | + if (has_action('give_email_template_'.$template)) { |
|
247 | 247 | /** |
248 | 248 | * Fires in a specific email template. |
249 | 249 | * |
250 | 250 | * @since 1.0 |
251 | 251 | */ |
252 | - do_action( "give_email_template_{$template}" ); |
|
252 | + do_action("give_email_template_{$template}"); |
|
253 | 253 | } else { |
254 | - give_get_template_part( 'emails/body', $template, true ); |
|
254 | + give_get_template_part('emails/body', $template, true); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @param Give_Emails $this The email object. |
263 | 263 | */ |
264 | - do_action( 'give_email_body', $this ); |
|
264 | + do_action('give_email_body', $this); |
|
265 | 265 | |
266 | - give_get_template_part( 'emails/footer', $template, true ); |
|
266 | + give_get_template_part('emails/footer', $template, true); |
|
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Fires in the email footer. |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @param Give_Emails $this The email object. |
274 | 274 | */ |
275 | - do_action( 'give_email_footer', $this ); |
|
275 | + do_action('give_email_footer', $this); |
|
276 | 276 | |
277 | 277 | $body = ob_get_clean(); |
278 | - $message = str_replace( '{email}', $message, $body ); |
|
278 | + $message = str_replace('{email}', $message, $body); |
|
279 | 279 | |
280 | - return apply_filters( 'give_email_message', $message, $this ); |
|
280 | + return apply_filters('give_email_message', $message, $this); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @return bool |
292 | 292 | */ |
293 | - public function send( $to, $subject, $message, $attachments = '' ) { |
|
293 | + public function send($to, $subject, $message, $attachments = '') { |
|
294 | 294 | |
295 | - if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) { |
|
296 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null ); |
|
295 | + if ( ! did_action('init') && ! did_action('admin_init')) { |
|
296 | + _doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null); |
|
297 | 297 | |
298 | 298 | return false; |
299 | 299 | } |
@@ -305,16 +305,16 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @param Give_Emails $this The email object. |
307 | 307 | */ |
308 | - do_action( 'give_email_send_before', $this ); |
|
308 | + do_action('give_email_send_before', $this); |
|
309 | 309 | |
310 | - $subject = $this->parse_tags( $subject ); |
|
311 | - $message = $this->parse_tags( $message ); |
|
310 | + $subject = $this->parse_tags($subject); |
|
311 | + $message = $this->parse_tags($message); |
|
312 | 312 | |
313 | - $message = $this->build_email( $message ); |
|
313 | + $message = $this->build_email($message); |
|
314 | 314 | |
315 | - $attachments = apply_filters( 'give_email_attachments', $attachments, $this ); |
|
315 | + $attachments = apply_filters('give_email_attachments', $attachments, $this); |
|
316 | 316 | |
317 | - $sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments ); |
|
317 | + $sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments); |
|
318 | 318 | |
319 | 319 | /** |
320 | 320 | * Fires after sending an email. |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @param Give_Emails $this The email object. |
325 | 325 | */ |
326 | - do_action( 'give_email_send_after', $this ); |
|
326 | + do_action('give_email_send_after', $this); |
|
327 | 327 | |
328 | 328 | return $sent; |
329 | 329 | |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | * @since 1.0 |
336 | 336 | */ |
337 | 337 | public function send_before() { |
338 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
339 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
340 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
338 | + add_filter('wp_mail_from', array($this, 'get_from_address')); |
|
339 | + add_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
340 | + add_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -346,9 +346,9 @@ discard block |
||
346 | 346 | * @since 1.0 |
347 | 347 | */ |
348 | 348 | public function send_after() { |
349 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
350 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
351 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
349 | + remove_filter('wp_mail_from', array($this, 'get_from_address')); |
|
350 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
351 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
352 | 352 | |
353 | 353 | // Reset heading to an empty string |
354 | 354 | $this->heading = ''; |
@@ -359,10 +359,10 @@ discard block |
||
359 | 359 | * |
360 | 360 | * @since 1.0 |
361 | 361 | */ |
362 | - public function text_to_html( $message ) { |
|
362 | + public function text_to_html($message) { |
|
363 | 363 | |
364 | - if ( 'text/html' == $this->content_type || true === $this->html ) { |
|
365 | - $message = wpautop( $message ); |
|
364 | + if ('text/html' == $this->content_type || true === $this->html) { |
|
365 | + $message = wpautop($message); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | return $message; |
@@ -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_purchase_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_purchase_form_user( $valid_data ); |
|
58 | + $user = give_get_purchase_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,18 +97,18 @@ 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'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00'; |
|
103 | - $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']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'; |
|
103 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
104 | 104 | |
105 | 105 | // Setup donation information |
106 | 106 | $purchase_data = array( |
107 | 107 | 'price' => $price, |
108 | 108 | 'purchase_key' => $purchase_key, |
109 | 109 | 'user_email' => $user['user_email'], |
110 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
111 | - 'user_info' => stripslashes_deep( $user_info ), |
|
110 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
111 | + 'user_info' => stripslashes_deep($user_info), |
|
112 | 112 | 'post_data' => $_POST, |
113 | 113 | 'gateway' => $valid_data['gateway'], |
114 | 114 | 'card_info' => $valid_data['cc_info'], |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | * @param array $user_info Array containing basic user information. |
129 | 129 | * @param bool|array $valid_data Validate fields. |
130 | 130 | */ |
131 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
131 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
132 | 132 | |
133 | 133 | // Sanity check for price |
134 | - if ( ! $purchase_data['price'] ) { |
|
134 | + if ( ! $purchase_data['price']) { |
|
135 | 135 | // Revert to manual |
136 | 136 | $purchase_data['gateway'] = 'manual'; |
137 | 137 | $_POST['give-gateway'] = 'manual'; |
@@ -142,27 +142,27 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @since 1.7 |
144 | 144 | */ |
145 | - $purchase_data = apply_filters( 'give_donation_data_before_gateway', $purchase_data, $valid_data ); |
|
145 | + $purchase_data = apply_filters('give_donation_data_before_gateway', $purchase_data, $valid_data); |
|
146 | 146 | |
147 | 147 | // Setup the data we're storing in the donation session |
148 | 148 | $session_data = $purchase_data; |
149 | 149 | |
150 | 150 | // Make sure credit card numbers are never stored in sessions |
151 | - unset( $session_data['card_info']['card_number'] ); |
|
152 | - unset( $session_data['post_data']['card_number'] ); |
|
151 | + unset($session_data['card_info']['card_number']); |
|
152 | + unset($session_data['post_data']['card_number']); |
|
153 | 153 | |
154 | 154 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
155 | - give_set_purchase_session( $session_data ); |
|
155 | + give_set_purchase_session($session_data); |
|
156 | 156 | |
157 | 157 | // Send info to the gateway for payment processing |
158 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data ); |
|
158 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data); |
|
159 | 159 | give_die(); |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
164 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
165 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
163 | +add_action('give_purchase', 'give_process_donation_form'); |
|
164 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
165 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | /** |
@@ -175,26 +175,26 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return void |
177 | 177 | */ |
178 | -function give_checkout_check_existing_email( $valid_data, $post ) { |
|
178 | +function give_checkout_check_existing_email($valid_data, $post) { |
|
179 | 179 | |
180 | 180 | // Verify that the email address belongs to this customer. |
181 | - if ( is_user_logged_in() ) { |
|
181 | + if (is_user_logged_in()) { |
|
182 | 182 | |
183 | 183 | $email = $valid_data['logged_in_user']['user_email']; |
184 | - $customer = new Give_Customer( get_current_user_id(), true ); |
|
184 | + $customer = new Give_Customer(get_current_user_id(), true); |
|
185 | 185 | |
186 | 186 | // If this email address is not registered with this customer, see if it belongs to any other customer |
187 | - if ( $email !== $customer->email && ( is_array( $customer->emails ) && ! in_array( $email, $customer->emails ) ) ) { |
|
188 | - $found_customer = new Give_Customer( $email ); |
|
187 | + if ($email !== $customer->email && (is_array($customer->emails) && ! in_array($email, $customer->emails))) { |
|
188 | + $found_customer = new Give_Customer($email); |
|
189 | 189 | |
190 | - if ( $found_customer->id > 0 ) { |
|
191 | - give_set_error( 'give-customer-email-exists', sprintf( esc_html__( 'The email address %s is already in use.', 'give' ), $email ) ); |
|
190 | + if ($found_customer->id > 0) { |
|
191 | + give_set_error('give-customer-email-exists', sprintf(esc_html__('The email address %s is already in use.', 'give'), $email)); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | -add_action( 'give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2 ); |
|
197 | +add_action('give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Process the checkout login form |
@@ -205,37 +205,37 @@ discard block |
||
205 | 205 | */ |
206 | 206 | function give_process_form_login() { |
207 | 207 | |
208 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
208 | + $is_ajax = isset($_POST['give_ajax']); |
|
209 | 209 | |
210 | 210 | $user_data = give_purchase_form_validate_user_login(); |
211 | 211 | |
212 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
213 | - if ( $is_ajax ) { |
|
212 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
213 | + if ($is_ajax) { |
|
214 | 214 | /** |
215 | 215 | * Fires when AJAX sends back errors from the donation form. |
216 | 216 | * |
217 | 217 | * @since 1.0 |
218 | 218 | */ |
219 | - do_action( 'give_ajax_donation_errors' ); |
|
219 | + do_action('give_ajax_donation_errors'); |
|
220 | 220 | give_die(); |
221 | 221 | } else { |
222 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
222 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
223 | 223 | exit; |
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
227 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
228 | 228 | |
229 | - if ( $is_ajax ) { |
|
229 | + if ($is_ajax) { |
|
230 | 230 | echo 'success'; |
231 | 231 | give_die(); |
232 | 232 | } else { |
233 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
233 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
238 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
237 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
238 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Donation Form Validate Fields |
@@ -247,44 +247,44 @@ discard block |
||
247 | 247 | function give_purchase_form_validate_fields() { |
248 | 248 | |
249 | 249 | // Check if there is $_POST |
250 | - if ( empty( $_POST ) ) { |
|
250 | + if (empty($_POST)) { |
|
251 | 251 | return false; |
252 | 252 | } |
253 | 253 | |
254 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
254 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
255 | 255 | |
256 | 256 | // Start an array to collect valid data |
257 | 257 | $valid_data = array( |
258 | 258 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here) |
259 | - 'need_new_user' => false, // New user flag |
|
260 | - 'need_user_login' => false, // Login user flag |
|
261 | - 'logged_user_data' => array(), // Logged user collected data |
|
262 | - 'new_user_data' => array(), // New user collected data |
|
263 | - 'login_user_data' => array(), // Login user collected data |
|
264 | - 'guest_user_data' => array(), // Guest user collected data |
|
265 | - 'cc_info' => give_purchase_form_validate_cc(),// Credit card info |
|
259 | + 'need_new_user' => false, // New user flag |
|
260 | + 'need_user_login' => false, // Login user flag |
|
261 | + 'logged_user_data' => array(), // Logged user collected data |
|
262 | + 'new_user_data' => array(), // New user collected data |
|
263 | + 'login_user_data' => array(), // Login user collected data |
|
264 | + 'guest_user_data' => array(), // Guest user collected data |
|
265 | + 'cc_info' => give_purchase_form_validate_cc(), // Credit card info |
|
266 | 266 | ); |
267 | 267 | |
268 | 268 | // Validate Honeypot First |
269 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
270 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
269 | + if ( ! empty($_POST['give-honeypot'])) { |
|
270 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // Validate agree to terms |
274 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
274 | + if (give_is_terms_enabled($form_id)) { |
|
275 | 275 | give_purchase_form_validate_agree_to_terms(); |
276 | 276 | } |
277 | 277 | |
278 | - if ( is_user_logged_in() ) { |
|
278 | + if (is_user_logged_in()) { |
|
279 | 279 | // Collect logged in user data |
280 | 280 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user(); |
281 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
281 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
282 | 282 | // Set new user registration as required |
283 | 283 | $valid_data['need_new_user'] = true; |
284 | 284 | // Validate new user data |
285 | 285 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user(); |
286 | 286 | // Check if login validation is needed |
287 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
287 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
288 | 288 | // Set user login as required |
289 | 289 | $valid_data['need_user_login'] = true; |
290 | 290 | // Validate users login info |
@@ -309,41 +309,41 @@ discard block |
||
309 | 309 | */ |
310 | 310 | function give_purchase_form_validate_gateway() { |
311 | 311 | |
312 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
313 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
314 | - $gateway = give_get_default_gateway( $form_id ); |
|
312 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
313 | + $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
314 | + $gateway = give_get_default_gateway($form_id); |
|
315 | 315 | |
316 | 316 | // Check if a gateway value is present |
317 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
317 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
318 | 318 | |
319 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
319 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
320 | 320 | |
321 | 321 | // Is amount being donated in LIVE mode 0.00? If so, error: |
322 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
322 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
323 | 323 | |
324 | - give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) ); |
|
324 | + give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give')); |
|
325 | 325 | |
326 | 326 | } //Check for a minimum custom amount |
327 | - elseif ( ! give_verify_minimum_price() ) { |
|
327 | + elseif ( ! give_verify_minimum_price()) { |
|
328 | 328 | // translators: %s: minimum donation amount. |
329 | 329 | give_set_error( |
330 | 330 | 'invalid_donation_minimum', |
331 | 331 | sprintf( |
332 | 332 | /* translators: %s: minimum donation amount */ |
333 | - esc_html__( 'This form has a minimum donation amount of %s.', 'give' ), |
|
334 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) ) |
|
333 | + esc_html__('This form has a minimum donation amount of %s.', 'give'), |
|
334 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id))) |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | |
338 | 338 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
339 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
339 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
340 | 340 | |
341 | 341 | $gateway = 'manual'; |
342 | 342 | |
343 | 343 | } //Check if this gateway is active. |
344 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
344 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
345 | 345 | |
346 | - give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
346 | + give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give')); |
|
347 | 347 | |
348 | 348 | } |
349 | 349 | } |
@@ -361,23 +361,23 @@ discard block |
||
361 | 361 | */ |
362 | 362 | function give_verify_minimum_price() { |
363 | 363 | |
364 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] ); |
|
365 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
366 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0; |
|
367 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
364 | + $amount = give_sanitize_amount($_REQUEST['give-amount']); |
|
365 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
366 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0; |
|
367 | + $variable_prices = give_has_variable_prices($form_id); |
|
368 | 368 | |
369 | - if ( $variable_prices && ! empty( $price_id ) ) { |
|
369 | + if ($variable_prices && ! empty($price_id)) { |
|
370 | 370 | |
371 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
371 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
372 | 372 | |
373 | - if ( $price_level_amount == $amount ) { |
|
373 | + if ($price_level_amount == $amount) { |
|
374 | 374 | return true; |
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
378 | - $minimum = give_get_form_minimum_price( $form_id ); |
|
378 | + $minimum = give_get_form_minimum_price($form_id); |
|
379 | 379 | |
380 | - if ( $minimum > $amount ) { |
|
380 | + if ($minimum > $amount) { |
|
381 | 381 | return false; |
382 | 382 | } |
383 | 383 | |
@@ -393,9 +393,9 @@ discard block |
||
393 | 393 | */ |
394 | 394 | function give_purchase_form_validate_agree_to_terms() { |
395 | 395 | // Validate agree to terms. |
396 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
396 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
397 | 397 | // User did not agree. |
398 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
398 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms and conditions.', 'give'))); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -409,43 +409,43 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @return array |
411 | 411 | */ |
412 | -function give_get_required_fields( $form_id ) { |
|
412 | +function give_get_required_fields($form_id) { |
|
413 | 413 | |
414 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
414 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
415 | 415 | |
416 | 416 | $required_fields = array( |
417 | 417 | 'give_email' => array( |
418 | 418 | 'error_id' => 'invalid_email', |
419 | - 'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ), |
|
419 | + 'error_message' => esc_html__('Please enter a valid email address.', 'give'), |
|
420 | 420 | ), |
421 | 421 | 'give_first' => array( |
422 | 422 | 'error_id' => 'invalid_first_name', |
423 | - 'error_message' => esc_html__( 'Please enter your first name.', 'give' ), |
|
423 | + 'error_message' => esc_html__('Please enter your first name.', 'give'), |
|
424 | 424 | ), |
425 | 425 | ); |
426 | 426 | |
427 | - $require_address = give_require_billing_address( $payment_mode ); |
|
427 | + $require_address = give_require_billing_address($payment_mode); |
|
428 | 428 | |
429 | - if ( $require_address ) { |
|
430 | - $required_fields['card_address'] = array( |
|
429 | + if ($require_address) { |
|
430 | + $required_fields['card_address'] = array( |
|
431 | 431 | 'error_id' => 'invalid_card_address', |
432 | - 'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ), |
|
432 | + 'error_message' => esc_html__('Please enter your primary billing address.', 'give'), |
|
433 | 433 | ); |
434 | - $required_fields['card_zip'] = array( |
|
434 | + $required_fields['card_zip'] = array( |
|
435 | 435 | 'error_id' => 'invalid_zip_code', |
436 | - 'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ), |
|
436 | + 'error_message' => esc_html__('Please enter your zip / postal code.', 'give'), |
|
437 | 437 | ); |
438 | - $required_fields['card_city'] = array( |
|
438 | + $required_fields['card_city'] = array( |
|
439 | 439 | 'error_id' => 'invalid_city', |
440 | - 'error_message' => esc_html__( 'Please enter your billing city.', 'give' ), |
|
440 | + 'error_message' => esc_html__('Please enter your billing city.', 'give'), |
|
441 | 441 | ); |
442 | 442 | $required_fields['billing_country'] = array( |
443 | 443 | 'error_id' => 'invalid_country', |
444 | - 'error_message' => esc_html__( 'Please select your billing country.', 'give' ), |
|
444 | + 'error_message' => esc_html__('Please select your billing country.', 'give'), |
|
445 | 445 | ); |
446 | - $required_fields['card_state'] = array( |
|
446 | + $required_fields['card_state'] = array( |
|
447 | 447 | 'error_id' => 'invalid_state', |
448 | - 'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ), |
|
448 | + 'error_message' => esc_html__('Please enter billing state / province.', 'give'), |
|
449 | 449 | ); |
450 | 450 | } |
451 | 451 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @since 1.7 |
456 | 456 | */ |
457 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
457 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
458 | 458 | |
459 | 459 | return $required_fields; |
460 | 460 | |
@@ -469,16 +469,16 @@ discard block |
||
469 | 469 | * |
470 | 470 | * @return mixed|void |
471 | 471 | */ |
472 | -function give_require_billing_address( $payment_mode ) { |
|
472 | +function give_require_billing_address($payment_mode) { |
|
473 | 473 | |
474 | 474 | $return = false; |
475 | 475 | |
476 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
476 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
477 | 477 | $return = true; |
478 | 478 | } |
479 | 479 | |
480 | 480 | // Let payment gateways and other extensions determine if address fields should be required. |
481 | - return apply_filters( 'give_require_billing_address', $return ); |
|
481 | + return apply_filters('give_require_billing_address', $return); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | |
@@ -492,42 +492,42 @@ discard block |
||
492 | 492 | function give_purchase_form_validate_logged_in_user() { |
493 | 493 | global $user_ID; |
494 | 494 | |
495 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
495 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
496 | 496 | |
497 | 497 | // Start empty array to collect valid user data. |
498 | 498 | $valid_user_data = array( |
499 | 499 | // Assume there will be errors. |
500 | - 'user_id' => - 1, |
|
500 | + 'user_id' => -1, |
|
501 | 501 | ); |
502 | 502 | |
503 | 503 | // Verify there is a user_ID. |
504 | - if ( $user_ID > 0 ) { |
|
504 | + if ($user_ID > 0) { |
|
505 | 505 | // Get the logged in user data. |
506 | - $user_data = get_userdata( $user_ID ); |
|
506 | + $user_data = get_userdata($user_ID); |
|
507 | 507 | |
508 | 508 | // Loop through required fields and show error messages. |
509 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
510 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
511 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
509 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
510 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
511 | + give_set_error($value['error_id'], $value['error_message']); |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | 515 | // Verify data. |
516 | - if ( $user_data ) { |
|
516 | + if ($user_data) { |
|
517 | 517 | // Collected logged in user data. |
518 | 518 | $valid_user_data = array( |
519 | 519 | 'user_id' => $user_ID, |
520 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
521 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
522 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
520 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
521 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
522 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
523 | 523 | ); |
524 | 524 | |
525 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
526 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
525 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
526 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
527 | 527 | } |
528 | 528 | } else { |
529 | 529 | // Set invalid user error. |
530 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
530 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | // Default user data. |
547 | 547 | $default_user_data = array( |
548 | 548 | 'give-form-id' => '', |
549 | - 'user_id' => - 1, // Assume there will be errors. |
|
549 | + 'user_id' => -1, // Assume there will be errors. |
|
550 | 550 | 'user_first' => '', |
551 | 551 | 'user_last' => '', |
552 | 552 | 'give_user_login' => false, |
@@ -556,14 +556,14 @@ discard block |
||
556 | 556 | ); |
557 | 557 | |
558 | 558 | // Get user data. |
559 | - $user_data = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data ); |
|
559 | + $user_data = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data); |
|
560 | 560 | $registering_new_user = false; |
561 | - $form_id = absint( $user_data['give-form-id'] ); |
|
561 | + $form_id = absint($user_data['give-form-id']); |
|
562 | 562 | |
563 | 563 | // Start an empty array to collect valid user data. |
564 | 564 | $valid_user_data = array( |
565 | 565 | // Assume there will be errors. |
566 | - 'user_id' => - 1, |
|
566 | + 'user_id' => -1, |
|
567 | 567 | |
568 | 568 | // Get first name. |
569 | 569 | 'user_first' => $user_data['give_first'], |
@@ -573,25 +573,25 @@ discard block |
||
573 | 573 | ); |
574 | 574 | |
575 | 575 | // Loop through required fields and show error messages. |
576 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
577 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
578 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
576 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
577 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
578 | + give_set_error($value['error_id'], $value['error_message']); |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 | |
582 | 582 | // Check if we have an username to register. |
583 | - if( give_validate_username( $user_data['give_user_login'] ) ) { |
|
583 | + if (give_validate_username($user_data['give_user_login'])) { |
|
584 | 584 | $registering_new_user = true; |
585 | 585 | $valid_user_data['user_login'] = $user_data['give_user_login']; |
586 | 586 | } |
587 | 587 | |
588 | 588 | // Check if we have an email to verify. |
589 | - if( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
589 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
590 | 590 | $valid_user_data['user_email'] = $user_data['give_email']; |
591 | 591 | } |
592 | 592 | |
593 | 593 | // Check password. |
594 | - if( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)){ |
|
594 | + if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { |
|
595 | 595 | // All is good to go. |
596 | 596 | $valid_user_data['user_pass'] = $user_data['give_user_pass']; |
597 | 597 | } |
@@ -611,36 +611,36 @@ discard block |
||
611 | 611 | // Start an array to collect valid user data. |
612 | 612 | $valid_user_data = array( |
613 | 613 | // Assume there will be errors |
614 | - 'user_id' => - 1, |
|
614 | + 'user_id' => -1, |
|
615 | 615 | ); |
616 | 616 | |
617 | 617 | // Username. |
618 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
619 | - give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
618 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
619 | + give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give')); |
|
620 | 620 | |
621 | 621 | return $valid_user_data; |
622 | 622 | } |
623 | 623 | |
624 | 624 | // Get the user by login. |
625 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
625 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
626 | 626 | |
627 | 627 | // Check if user exists. |
628 | - if ( $user_data ) { |
|
628 | + if ($user_data) { |
|
629 | 629 | // Get password. |
630 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
630 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
631 | 631 | |
632 | 632 | // Check user_pass. |
633 | - if ( $user_pass ) { |
|
633 | + if ($user_pass) { |
|
634 | 634 | // Check if password is valid. |
635 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
635 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
636 | 636 | // Incorrect password. |
637 | 637 | give_set_error( |
638 | 638 | 'password_incorrect', |
639 | 639 | sprintf( |
640 | 640 | '%1$s <a href="%2$s">%3$s</a>', |
641 | - esc_html__( 'The password you entered is incorrect.', 'give' ), |
|
642 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
643 | - esc_html__( 'Reset Password', 'give' ) |
|
641 | + esc_html__('The password you entered is incorrect.', 'give'), |
|
642 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
643 | + esc_html__('Reset Password', 'give') |
|
644 | 644 | ) |
645 | 645 | ); |
646 | 646 | // All is correct. |
@@ -657,11 +657,11 @@ discard block |
||
657 | 657 | } |
658 | 658 | } else { |
659 | 659 | // Empty password. |
660 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
660 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
661 | 661 | } |
662 | 662 | } else { |
663 | 663 | // No username. |
664 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
664 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | return $valid_user_data; |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | */ |
677 | 677 | function give_purchase_form_validate_guest_user() { |
678 | 678 | |
679 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
679 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
680 | 680 | |
681 | 681 | // Start an array to collect valid user data. |
682 | 682 | $valid_user_data = array( |
@@ -685,38 +685,38 @@ discard block |
||
685 | 685 | ); |
686 | 686 | |
687 | 687 | // Show error message if user must be logged in. |
688 | - if ( give_logged_in_only( $form_id ) ) { |
|
689 | - give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) ); |
|
688 | + if (give_logged_in_only($form_id)) { |
|
689 | + give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give')); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | // Get the guest email. |
693 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
693 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
694 | 694 | |
695 | 695 | // Check email. |
696 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
696 | + if ($guest_email && strlen($guest_email) > 0) { |
|
697 | 697 | // Validate email. |
698 | - if ( ! is_email( $guest_email ) ) { |
|
698 | + if ( ! is_email($guest_email)) { |
|
699 | 699 | // Invalid email. |
700 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
700 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
701 | 701 | } else { |
702 | 702 | // All is good to go. |
703 | 703 | $valid_user_data['user_email'] = $guest_email; |
704 | 704 | |
705 | 705 | // Get user_id from donor if exist. |
706 | - $donor = new Give_Customer( $guest_email ); |
|
707 | - if ( $donor->id && $donor->user_id ) { |
|
706 | + $donor = new Give_Customer($guest_email); |
|
707 | + if ($donor->id && $donor->user_id) { |
|
708 | 708 | $valid_user_data['user_id'] = $donor->user_id; |
709 | 709 | } |
710 | 710 | } |
711 | 711 | } else { |
712 | 712 | // No email. |
713 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
713 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | // Loop through required fields and show error messages. |
717 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
718 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
719 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
717 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
718 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
719 | + give_set_error($value['error_id'], $value['error_message']); |
|
720 | 720 | } |
721 | 721 | } |
722 | 722 | |
@@ -732,36 +732,36 @@ discard block |
||
732 | 732 | * @since 1.0 |
733 | 733 | * @return integer |
734 | 734 | */ |
735 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
735 | +function give_register_and_login_new_user($user_data = array()) { |
|
736 | 736 | // Verify the array. |
737 | - if ( empty( $user_data ) ) { |
|
738 | - return - 1; |
|
737 | + if (empty($user_data)) { |
|
738 | + return -1; |
|
739 | 739 | } |
740 | 740 | |
741 | - if ( give_get_errors() ) { |
|
742 | - return - 1; |
|
741 | + if (give_get_errors()) { |
|
742 | + return -1; |
|
743 | 743 | } |
744 | 744 | |
745 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
746 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
747 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
748 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
749 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
750 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
751 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
752 | - 'role' => get_option( 'default_role' ), |
|
753 | - ), $user_data ); |
|
745 | + $user_args = apply_filters('give_insert_user_args', array( |
|
746 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
747 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
748 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
749 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
750 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
751 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
752 | + 'role' => get_option('default_role'), |
|
753 | + ), $user_data); |
|
754 | 754 | |
755 | 755 | // Insert new user. |
756 | - $user_id = wp_insert_user( $user_args ); |
|
756 | + $user_id = wp_insert_user($user_args); |
|
757 | 757 | |
758 | 758 | // Validate inserted user. |
759 | - if ( is_wp_error( $user_id ) ) { |
|
760 | - return - 1; |
|
759 | + if (is_wp_error($user_id)) { |
|
760 | + return -1; |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | // Allow themes and plugins to filter the user data. |
764 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
764 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
765 | 765 | |
766 | 766 | /** |
767 | 767 | * Fires after inserting user. |
@@ -771,10 +771,10 @@ discard block |
||
771 | 771 | * @param int $user_id User id. |
772 | 772 | * @param array $user_data Array containing user data. |
773 | 773 | */ |
774 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
774 | + do_action('give_insert_user', $user_id, $user_data); |
|
775 | 775 | |
776 | 776 | // Login new user. |
777 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
777 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
778 | 778 | |
779 | 779 | // Return user id. |
780 | 780 | return $user_id; |
@@ -789,27 +789,27 @@ discard block |
||
789 | 789 | * @since 1.0 |
790 | 790 | * @return array |
791 | 791 | */ |
792 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
792 | +function give_get_purchase_form_user($valid_data = array()) { |
|
793 | 793 | |
794 | 794 | // Initialize user. |
795 | 795 | $user = false; |
796 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
796 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
797 | 797 | |
798 | - if ( $is_ajax ) { |
|
798 | + if ($is_ajax) { |
|
799 | 799 | // Do not create or login the user during the ajax submission (check for errors only). |
800 | 800 | return true; |
801 | - } elseif ( is_user_logged_in() ) { |
|
801 | + } elseif (is_user_logged_in()) { |
|
802 | 802 | // Set the valid user as the logged in collected data. |
803 | 803 | $user = $valid_data['logged_in_user']; |
804 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
804 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
805 | 805 | // New user registration. |
806 | - if ( $valid_data['need_new_user'] === true ) { |
|
806 | + if ($valid_data['need_new_user'] === true) { |
|
807 | 807 | // Set user. |
808 | 808 | $user = $valid_data['new_user_data']; |
809 | 809 | // Register and login new user. |
810 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
810 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
811 | 811 | // User login |
812 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
812 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
813 | 813 | |
814 | 814 | /* |
815 | 815 | * The login form is now processed in the give_process_purchase_login() function. |
@@ -822,48 +822,48 @@ discard block |
||
822 | 822 | // Set user. |
823 | 823 | $user = $valid_data['login_user_data']; |
824 | 824 | // Login user. |
825 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
825 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
826 | 826 | } |
827 | 827 | } |
828 | 828 | |
829 | 829 | // Check guest checkout. |
830 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
830 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
831 | 831 | // Set user |
832 | 832 | $user = $valid_data['guest_user_data']; |
833 | 833 | } |
834 | 834 | |
835 | 835 | // Verify we have an user. |
836 | - if ( false === $user || empty( $user ) ) { |
|
836 | + if (false === $user || empty($user)) { |
|
837 | 837 | // Return false. |
838 | 838 | return false; |
839 | 839 | } |
840 | 840 | |
841 | 841 | // Get user first name. |
842 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
843 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
842 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
843 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | // Get user last name. |
847 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
848 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
847 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
848 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | // Get the user's billing address details. |
852 | 852 | $user['address'] = array(); |
853 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
854 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
855 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
856 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
857 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
858 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
859 | - |
|
860 | - if ( empty( $user['address']['country'] ) ) { |
|
853 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
854 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
855 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
856 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
857 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
858 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
859 | + |
|
860 | + if (empty($user['address']['country'])) { |
|
861 | 861 | $user['address'] = false; |
862 | 862 | } // Country will always be set if address fields are present. |
863 | 863 | |
864 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
864 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
865 | 865 | // Store the address in the user's meta so the donation form can be pre-populated with it on return purchases. |
866 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
866 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
867 | 867 | } |
868 | 868 | |
869 | 869 | // Return valid user. |
@@ -882,16 +882,16 @@ discard block |
||
882 | 882 | $card_data = give_get_purchase_cc_info(); |
883 | 883 | |
884 | 884 | // Validate the card zip. |
885 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
886 | - if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
887 | - give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
885 | + if ( ! empty($card_data['card_zip'])) { |
|
886 | + if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
887 | + give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
888 | 888 | } |
889 | 889 | } |
890 | 890 | |
891 | 891 | // Ensure no spaces. |
892 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
893 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
894 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
892 | + if ( ! empty($card_data['card_number'])) { |
|
893 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
894 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | // This should validate card numbers at some point too. |
@@ -907,17 +907,17 @@ discard block |
||
907 | 907 | */ |
908 | 908 | function give_get_purchase_cc_info() { |
909 | 909 | $cc_info = array(); |
910 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
911 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
912 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
913 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
914 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
915 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
916 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
917 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
918 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
919 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
920 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
910 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
911 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
912 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
913 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
914 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
915 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
916 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
917 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
918 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
919 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
920 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
921 | 921 | |
922 | 922 | // Return cc info |
923 | 923 | return $cc_info; |
@@ -933,14 +933,14 @@ discard block |
||
933 | 933 | * |
934 | 934 | * @return bool|mixed|void |
935 | 935 | */ |
936 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
936 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
937 | 937 | $ret = false; |
938 | 938 | |
939 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
939 | + if (empty($zip) || empty($country_code)) { |
|
940 | 940 | return $ret; |
941 | 941 | } |
942 | 942 | |
943 | - $country_code = strtoupper( $country_code ); |
|
943 | + $country_code = strtoupper($country_code); |
|
944 | 944 | |
945 | 945 | $zip_regex = array( |
946 | 946 | 'AD' => 'AD\d{3}', |
@@ -1100,11 +1100,11 @@ discard block |
||
1100 | 1100 | 'ZM' => '\d{5}', |
1101 | 1101 | ); |
1102 | 1102 | |
1103 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1103 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1104 | 1104 | $ret = true; |
1105 | 1105 | } |
1106 | 1106 | |
1107 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1107 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | |
@@ -1118,36 +1118,36 @@ discard block |
||
1118 | 1118 | * |
1119 | 1119 | * @return bool |
1120 | 1120 | */ |
1121 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1121 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1122 | 1122 | /* @var Give_Donate_Form $form */ |
1123 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1123 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1124 | 1124 | |
1125 | 1125 | $donation_level_matched = false; |
1126 | 1126 | |
1127 | - if ( $form->is_multi_type_donation_form() ) { |
|
1127 | + if ($form->is_multi_type_donation_form()) { |
|
1128 | 1128 | |
1129 | 1129 | // Bailout. |
1130 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1130 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1131 | 1131 | return false; |
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | // Sanitize donation amount. |
1135 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1135 | + $data['give-amount'] = give_sanitize_amount($data['give-amount']); |
|
1136 | 1136 | |
1137 | 1137 | // Get number of decimals. |
1138 | 1138 | $default_decimals = give_get_price_decimals(); |
1139 | 1139 | |
1140 | - if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) { |
|
1140 | + if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) { |
|
1141 | 1141 | return true; |
1142 | 1142 | } |
1143 | 1143 | |
1144 | 1144 | // Find correct donation level from all donation levels. |
1145 | - foreach ( $variable_prices as $variable_price ) { |
|
1145 | + foreach ($variable_prices as $variable_price) { |
|
1146 | 1146 | // Sanitize level amount. |
1147 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1147 | + $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals); |
|
1148 | 1148 | |
1149 | 1149 | // Set first match donation level ID. |
1150 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1150 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1151 | 1151 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1152 | 1152 | $donation_level_matched = true; |
1153 | 1153 | break; |
@@ -1158,19 +1158,19 @@ discard block |
||
1158 | 1158 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1159 | 1159 | if ( |
1160 | 1160 | ! $donation_level_matched |
1161 | - && ( give_is_setting_enabled( get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) ) |
|
1161 | + && (give_is_setting_enabled(get_post_meta($data['give-form-id'], '_give_custom_amount', true))) |
|
1162 | 1162 | ) { |
1163 | 1163 | // Sanitize custom minimum amount. |
1164 | - $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1164 | + $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals); |
|
1165 | 1165 | |
1166 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1166 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1167 | 1167 | $_POST['give-price-id'] = 'custom'; |
1168 | 1168 | $donation_level_matched = true; |
1169 | 1169 | } |
1170 | 1170 | } |
1171 | 1171 | } |
1172 | 1172 | |
1173 | - return ( $donation_level_matched ? true : false ); |
|
1173 | + return ($donation_level_matched ? true : false); |
|
1174 | 1174 | } |
1175 | 1175 | |
1176 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1176 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |