@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -26,16 +26,16 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return array $links |
28 | 28 | */ |
29 | -function give_plugin_action_links( $links, $file ) { |
|
30 | - $settings_link = '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-settings' ) . '">' . esc_html__( 'Settings', 'give' ) . '</a>'; |
|
31 | - if ( $file == 'give/give.php' ) { |
|
32 | - array_unshift( $links, $settings_link ); |
|
29 | +function give_plugin_action_links($links, $file) { |
|
30 | + $settings_link = '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-settings').'">'.esc_html__('Settings', 'give').'</a>'; |
|
31 | + if ($file == 'give/give.php') { |
|
32 | + array_unshift($links, $settings_link); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | return $links; |
36 | 36 | } |
37 | 37 | |
38 | -add_filter( 'plugin_action_links', 'give_plugin_action_links', 10, 2 ); |
|
38 | +add_filter('plugin_action_links', 'give_plugin_action_links', 10, 2); |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -48,33 +48,33 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return array $input |
50 | 50 | */ |
51 | -function give_plugin_row_meta( $input, $file ) { |
|
52 | - if ( $file != 'give/give.php' ) { |
|
51 | +function give_plugin_row_meta($input, $file) { |
|
52 | + if ($file != 'give/give.php') { |
|
53 | 53 | return $input; |
54 | 54 | } |
55 | 55 | |
56 | - $give_addons_link = esc_url( add_query_arg( array( |
|
56 | + $give_addons_link = esc_url(add_query_arg(array( |
|
57 | 57 | 'utm_source' => 'plugins-page', |
58 | 58 | 'utm_medium' => 'plugin-row', |
59 | 59 | 'utm_campaign' => 'admin', |
60 | - ), 'https://givewp.com/addons/' ) |
|
60 | + ), 'https://givewp.com/addons/') |
|
61 | 61 | ); |
62 | 62 | |
63 | - $give_docs_link = esc_url( add_query_arg( array( |
|
63 | + $give_docs_link = esc_url(add_query_arg(array( |
|
64 | 64 | 'utm_source' => 'plugins-page', |
65 | 65 | 'utm_medium' => 'plugin-row', |
66 | 66 | 'utm_campaign' => 'admin', |
67 | - ), 'https://givewp.com/documentation/' ) |
|
67 | + ), 'https://givewp.com/documentation/') |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | $links = array( |
71 | - '<a href="' . $give_docs_link . '" target="_blank">' . esc_html__( 'Documentation', 'give' ) . '</a>', |
|
72 | - '<a href="' . $give_addons_link . '" target="_blank">' . esc_html__( 'Add-ons', 'give' ) . '</a>', |
|
71 | + '<a href="'.$give_docs_link.'" target="_blank">'.esc_html__('Documentation', 'give').'</a>', |
|
72 | + '<a href="'.$give_addons_link.'" target="_blank">'.esc_html__('Add-ons', 'give').'</a>', |
|
73 | 73 | ); |
74 | 74 | |
75 | - $input = array_merge( $input, $links ); |
|
75 | + $input = array_merge($input, $links); |
|
76 | 76 | |
77 | 77 | return $input; |
78 | 78 | } |
79 | 79 | |
80 | -add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 ); |
|
80 | +add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @return string |
22 | 22 | */ |
23 | 23 | function give_get_templates_dir() { |
24 | - return GIVE_PLUGIN_DIR . 'templates'; |
|
24 | + return GIVE_PLUGIN_DIR.'templates'; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | function give_get_templates_url() { |
34 | - return GIVE_PLUGIN_URL . 'templates'; |
|
34 | + return GIVE_PLUGIN_URL.'templates'; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -51,23 +51,23 @@ discard block |
||
51 | 51 | * @uses load_template() |
52 | 52 | * @uses get_template_part() |
53 | 53 | */ |
54 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
54 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
55 | 55 | |
56 | 56 | // Execute code for this part |
57 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
57 | + do_action('get_template_part_'.$slug, $slug, $name); |
|
58 | 58 | |
59 | 59 | // Setup possible parts |
60 | 60 | $templates = array(); |
61 | - if ( isset( $name ) ) { |
|
62 | - $templates[] = $slug . '-' . $name . '.php'; |
|
61 | + if (isset($name)) { |
|
62 | + $templates[] = $slug.'-'.$name.'.php'; |
|
63 | 63 | } |
64 | - $templates[] = $slug . '.php'; |
|
64 | + $templates[] = $slug.'.php'; |
|
65 | 65 | |
66 | 66 | // Allow template parts to be filtered |
67 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
67 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
68 | 68 | |
69 | 69 | // Return the part that is found |
70 | - return give_locate_template( $templates, $load, false ); |
|
70 | + return give_locate_template($templates, $load, false); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -88,37 +88,37 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string The template filename if one is located. |
90 | 90 | */ |
91 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
91 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
92 | 92 | // No file found yet |
93 | 93 | $located = false; |
94 | 94 | |
95 | 95 | // Try to find a template file |
96 | - foreach ( (array) $template_names as $template_name ) { |
|
96 | + foreach ((array) $template_names as $template_name) { |
|
97 | 97 | |
98 | 98 | // Continue if template is empty |
99 | - if ( empty( $template_name ) ) { |
|
99 | + if (empty($template_name)) { |
|
100 | 100 | continue; |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Trim off any slashes from the template name |
104 | - $template_name = ltrim( $template_name, '/' ); |
|
104 | + $template_name = ltrim($template_name, '/'); |
|
105 | 105 | |
106 | 106 | // try locating this template file by looping through the template paths |
107 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
107 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
108 | 108 | |
109 | - if ( file_exists( $template_path . $template_name ) ) { |
|
110 | - $located = $template_path . $template_name; |
|
109 | + if (file_exists($template_path.$template_name)) { |
|
110 | + $located = $template_path.$template_name; |
|
111 | 111 | break; |
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - if ( $located ) { |
|
115 | + if ($located) { |
|
116 | 116 | break; |
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
121 | - load_template( $located, $require_once ); |
|
120 | + if ((true == $load) && ! empty($located)) { |
|
121 | + load_template($located, $require_once); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | return $located; |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | $template_dir = give_get_theme_template_dir_name(); |
136 | 136 | |
137 | 137 | $file_paths = array( |
138 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
139 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
138 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
139 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
140 | 140 | 100 => give_get_templates_dir() |
141 | 141 | ); |
142 | 142 | |
143 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
143 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
144 | 144 | |
145 | 145 | // sort the file paths based on priority |
146 | - ksort( $file_paths, SORT_NUMERIC ); |
|
146 | + ksort($file_paths, SORT_NUMERIC); |
|
147 | 147 | |
148 | - return array_map( 'trailingslashit', $file_paths ); |
|
148 | + return array_map('trailingslashit', $file_paths); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return string |
158 | 158 | */ |
159 | 159 | function give_get_theme_template_dir_name() { |
160 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
160 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | * @return void |
168 | 168 | */ |
169 | 169 | function give_version_in_header() { |
170 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
170 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
171 | 171 | } |
172 | 172 | |
173 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
173 | +add_action('wp_head', 'give_version_in_header'); |
|
174 | 174 | |
175 | 175 | /** |
176 | 176 | * Determines if we're currently on the Donations History page. |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | */ |
181 | 181 | function give_is_donation_history_page() { |
182 | 182 | |
183 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
183 | + $ret = is_page(give_get_option('history_page')); |
|
184 | 184 | |
185 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
185 | + return apply_filters('give_is_donation_history_page', $ret); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -194,25 +194,25 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @return array Modified array of classes |
196 | 196 | */ |
197 | -function give_add_body_classes( $class ) { |
|
197 | +function give_add_body_classes($class) { |
|
198 | 198 | $classes = (array) $class; |
199 | 199 | |
200 | - if ( give_is_success_page() ) { |
|
200 | + if (give_is_success_page()) { |
|
201 | 201 | $classes[] = 'give-success'; |
202 | 202 | $classes[] = 'give-page'; |
203 | 203 | } |
204 | 204 | |
205 | - if ( give_is_failed_transaction_page() ) { |
|
205 | + if (give_is_failed_transaction_page()) { |
|
206 | 206 | $classes[] = 'give-failed-transaction'; |
207 | 207 | $classes[] = 'give-page'; |
208 | 208 | } |
209 | 209 | |
210 | - if ( give_is_donation_history_page() ) { |
|
210 | + if (give_is_donation_history_page()) { |
|
211 | 211 | $classes[] = 'give-donation-history'; |
212 | 212 | $classes[] = 'give-page'; |
213 | 213 | } |
214 | 214 | |
215 | - if ( give_is_test_mode() ) { |
|
215 | + if (give_is_test_mode()) { |
|
216 | 216 | $classes[] = 'give-test-mode'; |
217 | 217 | $classes[] = 'give-page'; |
218 | 218 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | //Theme-specific Classes used to prevent conflicts via CSS |
221 | 221 | $current_theme = wp_get_theme(); |
222 | 222 | |
223 | - switch ( $current_theme->template ) { |
|
223 | + switch ($current_theme->template) { |
|
224 | 224 | |
225 | 225 | case 'Divi': |
226 | 226 | $classes[] = 'give-divi'; |
@@ -234,10 +234,10 @@ discard block |
||
234 | 234 | |
235 | 235 | } |
236 | 236 | |
237 | - return array_unique( $classes ); |
|
237 | + return array_unique($classes); |
|
238 | 238 | } |
239 | 239 | |
240 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
240 | +add_filter('body_class', 'give_add_body_classes'); |
|
241 | 241 | |
242 | 242 | |
243 | 243 | /** |
@@ -253,22 +253,22 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return array |
255 | 255 | */ |
256 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
257 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
256 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
257 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
258 | 258 | return $classes; |
259 | 259 | } |
260 | 260 | |
261 | 261 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
262 | 262 | |
263 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
264 | - unset( $classes[ $key ] ); |
|
263 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
264 | + unset($classes[$key]); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | return $classes; |
268 | 268 | } |
269 | 269 | |
270 | 270 | |
271 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
271 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
272 | 272 | |
273 | 273 | /** |
274 | 274 | * Get the placeholder image URL for forms etc |
@@ -278,84 +278,84 @@ discard block |
||
278 | 278 | */ |
279 | 279 | function give_get_placeholder_img_src() { |
280 | 280 | |
281 | - $placeholder_url = 'http://placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
281 | + $placeholder_url = 'http://placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
282 | 282 | |
283 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
283 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | |
287 | 287 | /** |
288 | 288 | * Global |
289 | 289 | */ |
290 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
290 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
291 | 291 | |
292 | 292 | /** |
293 | 293 | * Output the start of the page wrapper. |
294 | 294 | */ |
295 | 295 | function give_output_content_wrapper() { |
296 | - give_get_template_part( 'global/wrapper-start' ); |
|
296 | + give_get_template_part('global/wrapper-start'); |
|
297 | 297 | } |
298 | 298 | } |
299 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
299 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
300 | 300 | |
301 | 301 | /** |
302 | 302 | * Output the end of the page wrapper. |
303 | 303 | */ |
304 | 304 | function give_output_content_wrapper_end() { |
305 | - give_get_template_part( 'global/wrapper-end' ); |
|
305 | + give_get_template_part('global/wrapper-end'); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
310 | 310 | * Single Give Form |
311 | 311 | */ |
312 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
312 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
313 | 313 | function give_left_sidebar_pre_wrap() { |
314 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
314 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
318 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
318 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
319 | 319 | function give_left_sidebar_post_wrap() { |
320 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
320 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
324 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
324 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
325 | 325 | function give_get_forms_sidebar() { |
326 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
326 | + give_get_template_part('single-give-form/sidebar'); |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
330 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
330 | +if ( ! function_exists('give_show_form_images')) { |
|
331 | 331 | |
332 | 332 | /** |
333 | 333 | * Output the product image before the single product summary. |
334 | 334 | */ |
335 | 335 | function give_show_form_images() { |
336 | - $featured_image_option = give_get_option( 'disable_form_featured_img' ); |
|
337 | - if ( $featured_image_option !== 'on' ) { |
|
338 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
336 | + $featured_image_option = give_get_option('disable_form_featured_img'); |
|
337 | + if ($featured_image_option !== 'on') { |
|
338 | + give_get_template_part('single-give-form/featured-image'); |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
343 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
343 | +if ( ! function_exists('give_template_single_title')) { |
|
344 | 344 | |
345 | 345 | /** |
346 | 346 | * Output the product title. |
347 | 347 | */ |
348 | 348 | function give_template_single_title() { |
349 | - give_get_template_part( 'single-give-form/title' ); |
|
349 | + give_get_template_part('single-give-form/title'); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
353 | -if ( ! function_exists( 'give_show_avatars' ) ) { |
|
353 | +if ( ! function_exists('give_show_avatars')) { |
|
354 | 354 | |
355 | 355 | /** |
356 | 356 | * Output the product title. |
357 | 357 | */ |
358 | 358 | function give_show_avatars() { |
359 | - echo do_shortcode( '[give_donators_gravatars]' ); |
|
359 | + echo do_shortcode('[give_donators_gravatars]'); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -defined( 'ABSPATH' ) or exit; |
|
13 | +defined('ABSPATH') or exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Give Form widget |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct() |
33 | 33 | { |
34 | - $this->self = get_class( $this ); |
|
34 | + $this->self = get_class($this); |
|
35 | 35 | |
36 | 36 | parent::__construct( |
37 | - strtolower( $this->self ), |
|
38 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
37 | + strtolower($this->self), |
|
38 | + esc_html__('Give - Donation Form', 'give'), |
|
39 | 39 | array( |
40 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
40 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
41 | 41 | ) |
42 | 42 | ); |
43 | 43 | |
44 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
45 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
44 | + add_action('widgets_init', array($this, 'widget_init')); |
|
45 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -52,24 +52,24 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function admin_widget_scripts( $hook ) |
|
55 | + public function admin_widget_scripts($hook) |
|
56 | 56 | { |
57 | 57 | // Directories of assets |
58 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
59 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
60 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
58 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
59 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
60 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
61 | 61 | |
62 | 62 | // Use minified libraries if SCRIPT_DEBUG is turned off |
63 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
63 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
64 | 64 | |
65 | 65 | // Widget Script |
66 | - if ( $hook == 'widgets.php' ) { |
|
66 | + if ($hook == 'widgets.php') { |
|
67 | 67 | |
68 | - wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' ); |
|
68 | + wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css'); |
|
69 | 69 | |
70 | - wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
70 | + wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
71 | 71 | |
72 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
72 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -80,24 +80,24 @@ discard block |
||
80 | 80 | * before_widget, and after_widget. |
81 | 81 | * @param array $instance The settings for the particular instance of the widget. |
82 | 82 | */ |
83 | - public function widget( $args, $instance ) |
|
83 | + public function widget($args, $instance) |
|
84 | 84 | { |
85 | - extract( $args ); |
|
85 | + extract($args); |
|
86 | 86 | |
87 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
88 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
87 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
88 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
89 | 89 | |
90 | 90 | echo $before_widget; |
91 | 91 | |
92 | - do_action( 'give_before_forms_widget' ); |
|
92 | + do_action('give_before_forms_widget'); |
|
93 | 93 | |
94 | - echo $title ? $before_title . $title . $after_title : ''; |
|
94 | + echo $title ? $before_title.$title.$after_title : ''; |
|
95 | 95 | |
96 | - give_get_donation_form( $instance ); |
|
96 | + give_get_donation_form($instance); |
|
97 | 97 | |
98 | 98 | echo $after_widget; |
99 | 99 | |
100 | - do_action( 'give_after_forms_widget' ); |
|
100 | + do_action('give_after_forms_widget'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return string |
109 | 109 | */ |
110 | - public function form( $instance ) |
|
110 | + public function form($instance) |
|
111 | 111 | { |
112 | 112 | $defaults = array( |
113 | 113 | 'title' => '', |
@@ -115,61 +115,61 @@ discard block |
||
115 | 115 | 'float_labels' => '', |
116 | 116 | ); |
117 | 117 | |
118 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
118 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
119 | 119 | |
120 | - extract( $instance ); |
|
120 | + extract($instance); |
|
121 | 121 | |
122 | 122 | // Query Give Forms |
123 | 123 | |
124 | 124 | $args = array( |
125 | 125 | 'post_type' => 'give_forms', |
126 | - 'posts_per_page' => - 1, |
|
126 | + 'posts_per_page' => -1, |
|
127 | 127 | 'post_status' => 'publish', |
128 | 128 | ); |
129 | 129 | |
130 | - $give_forms = get_posts( $args ); |
|
130 | + $give_forms = get_posts($args); |
|
131 | 131 | |
132 | 132 | // Widget: Title |
133 | 133 | |
134 | 134 | ?><p> |
135 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
136 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $title ); ?>" /><br> |
|
137 | - <small><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
135 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
136 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($title); ?>" /><br> |
|
137 | + <small><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
138 | 138 | </p><?php |
139 | 139 | |
140 | 140 | // Widget: Give Form |
141 | 141 | |
142 | 142 | ?><p> |
143 | - <label for="<?php esc_attr_e( $this->get_field_id( 'id' ) ); ?>"><?php |
|
143 | + <label for="<?php esc_attr_e($this->get_field_id('id')); ?>"><?php |
|
144 | 144 | printf( |
145 | 145 | /* translators: %s: form singular label */ |
146 | - esc_html__( 'Give %s:', 'give' ), |
|
146 | + esc_html__('Give %s:', 'give'), |
|
147 | 147 | give_get_forms_label_singular() |
148 | 148 | ); |
149 | 149 | ?></label> |
150 | - <select class="widefat" name="<?php esc_attr_e( $this->get_field_name( 'id' ) ); ?>" id="<?php esc_attr_e( $this->get_field_id( 'id' ) ); ?>"> |
|
151 | - <option value="current"><?php esc_html_e( '— Select —', 'give' ); ?></option> |
|
152 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
153 | - <option <?php selected( absint( $id ), $give_form->ID ); ?> value="<?php esc_attr_e( $give_form->ID ); ?>"><?php echo $give_form->post_title; ?></option> |
|
150 | + <select class="widefat" name="<?php esc_attr_e($this->get_field_name('id')); ?>" id="<?php esc_attr_e($this->get_field_id('id')); ?>"> |
|
151 | + <option value="current"><?php esc_html_e('— Select —', 'give'); ?></option> |
|
152 | + <?php foreach ($give_forms as $give_form) { ?> |
|
153 | + <option <?php selected(absint($id), $give_form->ID); ?> value="<?php esc_attr_e($give_form->ID); ?>"><?php echo $give_form->post_title; ?></option> |
|
154 | 154 | <?php } ?> |
155 | 155 | </select><br> |
156 | - <small><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
156 | + <small><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
157 | 157 | </p><?php |
158 | 158 | |
159 | 159 | // Widget: Floating Labels |
160 | 160 | |
161 | 161 | ?><p> |
162 | - <label for="<?php esc_attr_e( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label> |
|
163 | - <select class="widefat" name="<?php esc_attr_e( $this->get_field_name( 'float_labels' ) ); ?>" id="<?php esc_attr_e( $this->get_field_id( 'float_labels' ) ); ?>"> |
|
164 | - <option value="" <?php selected( esc_attr__( $float_labels ), '' ) ?>><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
165 | - <option value="enabled" <?php selected( esc_attr__( $float_labels ), 'enabled' ) ?>><?php esc_html_e( 'Enabled', 'give' ); ?></option> |
|
166 | - <option value="disabled" <?php selected( esc_attr__( $float_labels ), 'disabled' ) ?>><?php esc_html_e( 'Disabled', 'give' ); ?></option> |
|
162 | + <label for="<?php esc_attr_e($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label> |
|
163 | + <select class="widefat" name="<?php esc_attr_e($this->get_field_name('float_labels')); ?>" id="<?php esc_attr_e($this->get_field_id('float_labels')); ?>"> |
|
164 | + <option value="" <?php selected(esc_attr__($float_labels), '') ?>><?php esc_html_e('- Select -', 'give'); ?></option> |
|
165 | + <option value="enabled" <?php selected(esc_attr__($float_labels), 'enabled') ?>><?php esc_html_e('Enabled', 'give'); ?></option> |
|
166 | + <option value="disabled" <?php selected(esc_attr__($float_labels), 'disabled') ?>><?php esc_html_e('Disabled', 'give'); ?></option> |
|
167 | 167 | </select><br> |
168 | 168 | <small><?php |
169 | 169 | printf( |
170 | 170 | /* translators: %s: http://bradfrost.com/blog/post/float-label-pattern/ */ |
171 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
172 | - esc_url( 'http://bradfrost.com/blog/post/float-label-pattern/' ) |
|
171 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
172 | + esc_url('http://bradfrost.com/blog/post/float-label-pattern/') |
|
173 | 173 | ); |
174 | 174 | ?></small> |
175 | 175 | </p><?php |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | function widget_init() |
184 | 184 | { |
185 | - register_widget( $this->self ); |
|
185 | + register_widget($this->self); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @return array |
195 | 195 | */ |
196 | - public function update( $new_instance, $old_instance ) |
|
196 | + public function update($new_instance, $old_instance) |
|
197 | 197 | { |
198 | 198 | $this->flush_widget_cache(); |
199 | 199 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function flush_widget_cache() |
209 | 209 | { |
210 | - wp_cache_delete( $this->self, 'widget' ); |
|
210 | + wp_cache_delete($this->self, 'widget'); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,64 +23,64 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string $purchase_form |
25 | 25 | */ |
26 | -function give_get_donation_form( $args = array() ) { |
|
26 | +function give_get_donation_form($args = array()) { |
|
27 | 27 | |
28 | 28 | global $post; |
29 | 29 | |
30 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
30 | + $form_id = is_object($post) ? $post->ID : 0; |
|
31 | 31 | |
32 | - if ( isset( $args['id'] ) ) { |
|
32 | + if (isset($args['id'])) { |
|
33 | 33 | $form_id = $args['id']; |
34 | 34 | } |
35 | 35 | |
36 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
36 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
37 | 37 | 'form_id' => $form_id |
38 | - ) ); |
|
38 | + )); |
|
39 | 39 | |
40 | - $args = wp_parse_args( $args, $defaults ); |
|
40 | + $args = wp_parse_args($args, $defaults); |
|
41 | 41 | |
42 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
42 | + $form = new Give_Donate_Form($args['form_id']); |
|
43 | 43 | |
44 | 44 | //bail if no form ID |
45 | - if ( empty( $form->ID ) ) { |
|
45 | + if (empty($form->ID)) { |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
49 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
50 | 50 | |
51 | - $form_action = esc_url( add_query_arg( apply_filters( 'give_form_action_args', array( |
|
51 | + $form_action = esc_url(add_query_arg(apply_filters('give_form_action_args', array( |
|
52 | 52 | 'payment-mode' => $payment_mode, |
53 | - ) ), |
|
53 | + )), |
|
54 | 54 | give_get_current_page_url() |
55 | - ) ); |
|
55 | + )); |
|
56 | 56 | |
57 | 57 | //Sanity Check: Donation form not published or user doesn't have permission to view drafts |
58 | - if ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) { |
|
58 | + if ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) { |
|
59 | 59 | return false; |
60 | 60 | } |
61 | 61 | |
62 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
62 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
63 | 63 | ? $args['display_style'] |
64 | - : get_post_meta( $form->ID, '_give_payment_display', true ); |
|
64 | + : get_post_meta($form->ID, '_give_payment_display', true); |
|
65 | 65 | |
66 | - $float_labels_option = give_is_float_labels_enabled( $args ) |
|
66 | + $float_labels_option = give_is_float_labels_enabled($args) |
|
67 | 67 | ? ' float-labels-enabled' |
68 | 68 | : ''; |
69 | 69 | |
70 | 70 | //Form Wrap Classes |
71 | - $form_wrap_classes_array = apply_filters( 'give_form_wrap_classes', array( |
|
71 | + $form_wrap_classes_array = apply_filters('give_form_wrap_classes', array( |
|
72 | 72 | 'give-form-wrap', |
73 | - 'give-display-' . $display_option |
|
74 | - ), $form->ID, $args ); |
|
75 | - $form_wrap_classes = implode( ' ', $form_wrap_classes_array ); |
|
73 | + 'give-display-'.$display_option |
|
74 | + ), $form->ID, $args); |
|
75 | + $form_wrap_classes = implode(' ', $form_wrap_classes_array); |
|
76 | 76 | |
77 | 77 | //Form Classes |
78 | - $form_classes_array = apply_filters( 'give_form_classes', array( |
|
78 | + $form_classes_array = apply_filters('give_form_classes', array( |
|
79 | 79 | 'give-form', |
80 | - 'give-form-' . $form->ID, |
|
80 | + 'give-form-'.$form->ID, |
|
81 | 81 | $float_labels_option |
82 | - ), $form->ID, $args ); |
|
83 | - $form_classes = implode( ' ', $form_classes_array ); |
|
82 | + ), $form->ID, $args); |
|
83 | + $form_classes = implode(' ', $form_classes_array); |
|
84 | 84 | |
85 | 85 | |
86 | 86 | ob_start(); |
@@ -93,35 +93,35 @@ discard block |
||
93 | 93 | * @param int $form ->ID The current form ID |
94 | 94 | * @param array $args An array of form args |
95 | 95 | */ |
96 | - do_action( 'give_pre_form_output', $form->ID, $args ); ?> |
|
96 | + do_action('give_pre_form_output', $form->ID, $args); ?> |
|
97 | 97 | |
98 | 98 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
99 | 99 | |
100 | - <?php if ( $form->is_close_donation_form() ) { |
|
100 | + <?php if ($form->is_close_donation_form()) { |
|
101 | 101 | |
102 | 102 | //Get Goal thank you message. |
103 | - $display_thankyou_message = get_post_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
104 | - $display_thankyou_message = ! empty( $display_thankyou_message ) ? $display_thankyou_message : esc_html__( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ); |
|
103 | + $display_thankyou_message = get_post_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
104 | + $display_thankyou_message = ! empty($display_thankyou_message) ? $display_thankyou_message : esc_html__('Thank you to all our donors, we have met our fundraising goal.', 'give'); |
|
105 | 105 | |
106 | 106 | //Print thank you message. |
107 | - apply_filters( 'give_goal_closed_output', give_output_error( $display_thankyou_message, true, 'success' ) ); |
|
107 | + apply_filters('give_goal_closed_output', give_output_error($display_thankyou_message, true, 'success')); |
|
108 | 108 | |
109 | 109 | } else { |
110 | 110 | |
111 | - if ( isset( $args['show_title'] ) && $args['show_title'] == true ) { |
|
111 | + if (isset($args['show_title']) && $args['show_title'] == true) { |
|
112 | 112 | |
113 | - echo apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
113 | + echo apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | - do_action( 'give_pre_form', $form->ID, $args ); ?> |
|
117 | + do_action('give_pre_form', $form->ID, $args); ?> |
|
118 | 118 | |
119 | 119 | <form id="give-form-<?php echo $form_id; ?>" class="<?php echo $form_classes; ?>" action="<?php echo $form_action; ?>" method="post"> |
120 | 120 | <input type="hidden" name="give-form-id" value="<?php echo $form->ID; ?>"/> |
121 | - <input type="hidden" name="give-form-title" value="<?php echo htmlentities( $form->post_title ); ?>"/> |
|
122 | - <input type="hidden" name="give-current-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
123 | - <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
124 | - <input type="hidden" name="give-form-minimum" value="<?php echo give_format_amount( give_get_form_minimum_price( $form->ID ) ); ?>"/> |
|
121 | + <input type="hidden" name="give-form-title" value="<?php echo htmlentities($form->post_title); ?>"/> |
|
122 | + <input type="hidden" name="give-current-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
123 | + <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
124 | + <input type="hidden" name="give-form-minimum" value="<?php echo give_format_amount(give_get_form_minimum_price($form->ID)); ?>"/> |
|
125 | 125 | |
126 | 126 | <!-- The following field is for robots only, invisible to humans: --> |
127 | 127 | <span class="give-hidden" style="display: none !important;"> |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | <?php |
133 | 133 | |
134 | 134 | //Price ID hidden field for variable (mult-level) donation forms |
135 | - if ( give_has_variable_prices( $form_id ) ) { |
|
135 | + if (give_has_variable_prices($form_id)) { |
|
136 | 136 | //get default selected price ID |
137 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
137 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
138 | 138 | $price_id = 0; |
139 | 139 | //loop through prices |
140 | - foreach ( $prices as $price ) { |
|
141 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
140 | + foreach ($prices as $price) { |
|
141 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
142 | 142 | $price_id = $price['_give_id']['level_id']; |
143 | 143 | }; |
144 | 144 | } |
@@ -146,20 +146,20 @@ discard block |
||
146 | 146 | <input type="hidden" name="give-price-id" value="<?php echo $price_id; ?>"/> |
147 | 147 | <?php } |
148 | 148 | |
149 | - do_action( 'give_checkout_form_top', $form->ID, $args ); |
|
149 | + do_action('give_checkout_form_top', $form->ID, $args); |
|
150 | 150 | |
151 | - do_action( 'give_payment_mode_select', $form->ID, $args ); |
|
151 | + do_action('give_payment_mode_select', $form->ID, $args); |
|
152 | 152 | |
153 | - do_action( 'give_checkout_form_bottom', $form->ID, $args ); |
|
153 | + do_action('give_checkout_form_bottom', $form->ID, $args); |
|
154 | 154 | |
155 | 155 | ?> |
156 | 156 | </form> |
157 | 157 | |
158 | - <?php do_action( 'give_post_form', $form->ID, $args ); ?> |
|
158 | + <?php do_action('give_post_form', $form->ID, $args); ?> |
|
159 | 159 | |
160 | 160 | <?php } ?> |
161 | 161 | |
162 | - <!--end #give-form-<?php echo absint( $form->ID ); ?>--></div> |
|
162 | + <!--end #give-form-<?php echo absint($form->ID); ?>--></div> |
|
163 | 163 | <?php |
164 | 164 | |
165 | 165 | /** |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | * @param int $form ->ID The current form ID |
171 | 171 | * @param array $args An array of form args |
172 | 172 | */ |
173 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
173 | + do_action('give_post_form_output', $form->ID, $args); |
|
174 | 174 | |
175 | 175 | $final_output = ob_get_clean(); |
176 | 176 | |
177 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
177 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -194,43 +194,43 @@ discard block |
||
194 | 194 | * @global $give_options Array of all the Give options |
195 | 195 | * @return string |
196 | 196 | */ |
197 | -function give_show_purchase_form( $form_id ) { |
|
197 | +function give_show_purchase_form($form_id) { |
|
198 | 198 | |
199 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
199 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
200 | 200 | |
201 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
201 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
202 | 202 | $form_id = $_POST['give_form_id']; |
203 | 203 | } |
204 | 204 | |
205 | - do_action( 'give_purchase_form_top', $form_id ); |
|
205 | + do_action('give_purchase_form_top', $form_id); |
|
206 | 206 | |
207 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
207 | + if (give_can_checkout() && isset($form_id)) { |
|
208 | 208 | |
209 | - do_action( 'give_purchase_form_before_register_login', $form_id ); |
|
209 | + do_action('give_purchase_form_before_register_login', $form_id); |
|
210 | 210 | |
211 | - do_action( 'give_purchase_form_register_login_fields', $form_id ); |
|
211 | + do_action('give_purchase_form_register_login_fields', $form_id); |
|
212 | 212 | |
213 | - do_action( 'give_purchase_form_before_cc_form', $form_id ); |
|
213 | + do_action('give_purchase_form_before_cc_form', $form_id); |
|
214 | 214 | |
215 | 215 | // Load the credit card form and allow gateways to load their own if they wish |
216 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
217 | - do_action( 'give_' . $payment_mode . '_cc_form', $form_id ); |
|
216 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
217 | + do_action('give_'.$payment_mode.'_cc_form', $form_id); |
|
218 | 218 | } else { |
219 | - do_action( 'give_cc_form', $form_id ); |
|
219 | + do_action('give_cc_form', $form_id); |
|
220 | 220 | } |
221 | 221 | |
222 | - do_action( 'give_purchase_form_after_cc_form', $form_id ); |
|
222 | + do_action('give_purchase_form_after_cc_form', $form_id); |
|
223 | 223 | |
224 | 224 | } else { |
225 | 225 | // Can't checkout |
226 | - do_action( 'give_purchase_form_no_access', $form_id ); |
|
226 | + do_action('give_purchase_form_no_access', $form_id); |
|
227 | 227 | |
228 | 228 | } |
229 | 229 | |
230 | - do_action( 'give_purchase_form_bottom', $form_id ); |
|
230 | + do_action('give_purchase_form_bottom', $form_id); |
|
231 | 231 | } |
232 | 232 | |
233 | -add_action( 'give_purchase_form', 'give_show_purchase_form' ); |
|
233 | +add_action('give_purchase_form', 'give_show_purchase_form'); |
|
234 | 234 | |
235 | 235 | /** |
236 | 236 | * |
@@ -242,26 +242,26 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return void |
244 | 244 | */ |
245 | -function give_show_register_login_fields( $form_id ) { |
|
245 | +function give_show_register_login_fields($form_id) { |
|
246 | 246 | |
247 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
247 | + $show_register_form = give_show_login_register_option($form_id); |
|
248 | 248 | |
249 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?> |
|
249 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : ?> |
|
250 | 250 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
251 | - <?php do_action( 'give_purchase_form_register_fields', $form_id ); ?> |
|
251 | + <?php do_action('give_purchase_form_register_fields', $form_id); ?> |
|
252 | 252 | </div> |
253 | - <?php elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?> |
|
253 | + <?php elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : ?> |
|
254 | 254 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
255 | - <?php do_action( 'give_purchase_form_login_fields', $form_id ); ?> |
|
255 | + <?php do_action('give_purchase_form_login_fields', $form_id); ?> |
|
256 | 256 | </div> |
257 | 257 | <?php endif; ?> |
258 | 258 | |
259 | - <?php if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
260 | - do_action( 'give_purchase_form_after_user_info', $form_id ); |
|
259 | + <?php if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
260 | + do_action('give_purchase_form_after_user_info', $form_id); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | -add_action( 'give_purchase_form_register_login_fields', 'give_show_register_login_fields' ); |
|
264 | +add_action('give_purchase_form_register_login_fields', 'give_show_register_login_fields'); |
|
265 | 265 | |
266 | 266 | /** |
267 | 267 | * Donation Amount Field |
@@ -275,33 +275,33 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return void |
277 | 277 | */ |
278 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
278 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
279 | 279 | |
280 | 280 | global $give_options; |
281 | 281 | |
282 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
283 | - $allow_custom_amount = get_post_meta( $form_id, '_give_custom_amount', true ); |
|
284 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
285 | - $symbol = give_currency_symbol( give_get_currency() ); |
|
286 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
287 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ) ); |
|
288 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
282 | + $variable_pricing = give_has_variable_prices($form_id); |
|
283 | + $allow_custom_amount = get_post_meta($form_id, '_give_custom_amount', true); |
|
284 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
285 | + $symbol = give_currency_symbol(give_get_currency()); |
|
286 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
287 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id)); |
|
288 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
289 | 289 | |
290 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
290 | + do_action('give_before_donation_levels', $form_id, $args); |
|
291 | 291 | |
292 | 292 | //Set Price, No Custom Amount Allowed means hidden price field |
293 | - if ( $allow_custom_amount == 'no' ) { |
|
293 | + if ($allow_custom_amount == 'no') { |
|
294 | 294 | ?> |
295 | 295 | |
296 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
296 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
297 | 297 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
298 | 298 | value="<?php echo $default_amount; ?>" required> |
299 | 299 | <div class="set-price give-donation-amount form-row-wide"> |
300 | - <?php if ( $currency_position == 'before' ) { |
|
300 | + <?php if ($currency_position == 'before') { |
|
301 | 301 | echo $currency_output; |
302 | 302 | } ?> |
303 | 303 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
304 | - <?php if ( $currency_position == 'after' ) { |
|
304 | + <?php if ($currency_position == 'after') { |
|
305 | 305 | echo $currency_output; |
306 | 306 | } ?> |
307 | 307 | </div> |
@@ -311,34 +311,34 @@ discard block |
||
311 | 311 | ?> |
312 | 312 | <div class="give-total-wrap"> |
313 | 313 | <div class="give-donation-amount form-row-wide"> |
314 | - <?php if ( $currency_position == 'before' ) { |
|
314 | + <?php if ($currency_position == 'before') { |
|
315 | 315 | echo $currency_output; |
316 | 316 | } ?> |
317 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
317 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
318 | 318 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
319 | - <?php if ( $currency_position == 'after' ) { |
|
319 | + <?php if ($currency_position == 'after') { |
|
320 | 320 | echo $currency_output; |
321 | 321 | } ?> |
322 | 322 | </div> |
323 | 323 | </div> |
324 | 324 | <?php } |
325 | 325 | |
326 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
326 | + do_action('give_after_donation_amount', $form_id, $args); |
|
327 | 327 | |
328 | 328 | //Custom Amount Text |
329 | - if ( ! $variable_pricing && $allow_custom_amount == 'yes' && ! empty( $custom_amount_text ) ) { ?> |
|
329 | + if ( ! $variable_pricing && $allow_custom_amount == 'yes' && ! empty($custom_amount_text)) { ?> |
|
330 | 330 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
331 | 331 | <?php } |
332 | 332 | |
333 | 333 | //Output Variable Pricing Levels |
334 | - if ( $variable_pricing ) { |
|
335 | - give_output_levels( $form_id ); |
|
334 | + if ($variable_pricing) { |
|
335 | + give_output_levels($form_id); |
|
336 | 336 | } |
337 | 337 | |
338 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
338 | + do_action('give_after_donation_levels', $form_id, $args); |
|
339 | 339 | } |
340 | 340 | |
341 | -add_action( 'give_checkout_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
341 | +add_action('give_checkout_form_top', 'give_output_donation_amount_top', 10, 2); |
|
342 | 342 | |
343 | 343 | |
344 | 344 | /** |
@@ -350,32 +350,32 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @return string |
352 | 352 | */ |
353 | -function give_output_levels( $form_id ) { |
|
353 | +function give_output_levels($form_id) { |
|
354 | 354 | |
355 | 355 | //Get variable pricing |
356 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
357 | - $display_style = get_post_meta( $form_id, '_give_display_style', true ); |
|
358 | - $custom_amount = get_post_meta( $form_id, '_give_custom_amount', true ); |
|
359 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
360 | - if ( empty( $custom_amount_text ) ) { |
|
361 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
356 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
357 | + $display_style = get_post_meta($form_id, '_give_display_style', true); |
|
358 | + $custom_amount = get_post_meta($form_id, '_give_custom_amount', true); |
|
359 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
360 | + if (empty($custom_amount_text)) { |
|
361 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | $output = ''; |
365 | 365 | $counter = 0; |
366 | 366 | |
367 | - switch ( $display_style ) { |
|
367 | + switch ($display_style) { |
|
368 | 368 | case 'buttons': |
369 | 369 | |
370 | 370 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
371 | 371 | |
372 | - foreach ( $prices as $price ) { |
|
373 | - $counter ++; |
|
374 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
375 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $counter . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
372 | + foreach ($prices as $price) { |
|
373 | + $counter++; |
|
374 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
375 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$counter.' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
376 | 376 | |
377 | 377 | $output .= '<li>'; |
378 | - $output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class=" ' . $level_classes . '" value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
378 | + $output .= '<button type="button" data-price-id="'.$price['_give_id']['level_id'].'" class=" '.$level_classes.'" value="'.give_format_amount($price['_give_amount']).'">'; |
|
379 | 379 | $output .= $level_text; |
380 | 380 | $output .= '</button>'; |
381 | 381 | $output .= '</li>'; |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | } |
384 | 384 | |
385 | 385 | //Custom Amount |
386 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
386 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
387 | 387 | $output .= '<li>'; |
388 | 388 | $output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">'; |
389 | 389 | $output .= $custom_amount_text; |
@@ -399,23 +399,23 @@ discard block |
||
399 | 399 | |
400 | 400 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
401 | 401 | |
402 | - foreach ( $prices as $price ) { |
|
403 | - $counter ++; |
|
404 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
405 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $counter . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
402 | + foreach ($prices as $price) { |
|
403 | + $counter++; |
|
404 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
405 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$counter.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
406 | 406 | |
407 | 407 | $output .= '<li>'; |
408 | - $output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" name="give-radio-donation-level" id="give-radio-level-' . $counter . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
409 | - $output .= '<label for="give-radio-level-' . $counter . '">' . $level_text . '</label>'; |
|
408 | + $output .= '<input type="radio" data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" name="give-radio-donation-level" id="give-radio-level-'.$counter.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : '').' value="'.give_format_amount($price['_give_amount']).'">'; |
|
409 | + $output .= '<label for="give-radio-level-'.$counter.'">'.$level_text.'</label>'; |
|
410 | 410 | $output .= '</li>'; |
411 | 411 | |
412 | 412 | } |
413 | 413 | |
414 | 414 | //Custom Amount |
415 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
415 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
416 | 416 | $output .= '<li>'; |
417 | 417 | $output .= '<input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom">'; |
418 | - $output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>'; |
|
418 | + $output .= '<label for="give-radio-level-custom">'.$custom_amount_text.'</label>'; |
|
419 | 419 | $output .= '</li>'; |
420 | 420 | } |
421 | 421 | |
@@ -425,23 +425,23 @@ discard block |
||
425 | 425 | |
426 | 426 | case 'dropdown': |
427 | 427 | |
428 | - $output .= '<label for="give-donation-level" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
429 | - $output .= '<select id="give-donation-level-' . $form_id . '" class="give-select give-select-level">'; |
|
428 | + $output .= '<label for="give-donation-level" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
429 | + $output .= '<select id="give-donation-level-'.$form_id.'" class="give-select give-select-level">'; |
|
430 | 430 | |
431 | 431 | //first loop through prices |
432 | - foreach ( $prices as $price ) { |
|
433 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
434 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $form_id . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
432 | + foreach ($prices as $price) { |
|
433 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
434 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$form_id.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
435 | 435 | |
436 | - $output .= '<option data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
436 | + $output .= '<option data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : '').' value="'.give_format_amount($price['_give_amount']).'">'; |
|
437 | 437 | $output .= $level_text; |
438 | 438 | $output .= '</option>'; |
439 | 439 | |
440 | 440 | } |
441 | 441 | |
442 | 442 | //Custom Amount |
443 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
444 | - $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>'; |
|
443 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
444 | + $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">'.$custom_amount_text.'</option>'; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | $output .= '</select>'; |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | break; |
450 | 450 | } |
451 | 451 | |
452 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
452 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -461,26 +461,26 @@ discard block |
||
461 | 461 | * @param array $args |
462 | 462 | * |
463 | 463 | */ |
464 | -function give_display_checkout_button( $form_id, $args ) { |
|
464 | +function give_display_checkout_button($form_id, $args) { |
|
465 | 465 | |
466 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
466 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
467 | 467 | ? $args['display_style'] |
468 | - : get_post_meta( $form_id, '_give_payment_display', true ); |
|
468 | + : get_post_meta($form_id, '_give_payment_display', true); |
|
469 | 469 | |
470 | 470 | //no btn for onpage |
471 | - if ( $display_option === 'onpage' ) { |
|
471 | + if ($display_option === 'onpage') { |
|
472 | 472 | return; |
473 | 473 | } |
474 | 474 | |
475 | - $display_label_field = get_post_meta( $form_id, '_give_reveal_label', true ); |
|
476 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
475 | + $display_label_field = get_post_meta($form_id, '_give_reveal_label', true); |
|
476 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
477 | 477 | |
478 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
478 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
479 | 479 | |
480 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
480 | + echo apply_filters('give_display_checkout_button', $output); |
|
481 | 481 | } |
482 | 482 | |
483 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
483 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
484 | 484 | |
485 | 485 | /** |
486 | 486 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -491,71 +491,71 @@ discard block |
||
491 | 491 | * |
492 | 492 | * @return void |
493 | 493 | */ |
494 | -function give_user_info_fields( $form_id ) { |
|
494 | +function give_user_info_fields($form_id) { |
|
495 | 495 | |
496 | - if ( is_user_logged_in() ) : |
|
497 | - $user_data = get_userdata( get_current_user_id() ); |
|
496 | + if (is_user_logged_in()) : |
|
497 | + $user_data = get_userdata(get_current_user_id()); |
|
498 | 498 | endif; |
499 | 499 | |
500 | - do_action( 'give_purchase_form_before_personal_info', $form_id ); |
|
500 | + do_action('give_purchase_form_before_personal_info', $form_id); |
|
501 | 501 | ?> |
502 | 502 | <fieldset id="give_checkout_user_info"> |
503 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', esc_html__( 'Personal Info', 'give' ) ); ?></legend> |
|
503 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', esc_html__('Personal Info', 'give')); ?></legend> |
|
504 | 504 | <p id="give-first-name-wrap" class="form-row form-row-first"> |
505 | 505 | <label class="give-label" for="give-first"> |
506 | - <?php esc_html_e( 'First Name', 'give' ); ?> |
|
507 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) { ?> |
|
506 | + <?php esc_html_e('First Name', 'give'); ?> |
|
507 | + <?php if (give_field_is_required('give_first', $form_id)) { ?> |
|
508 | 508 | <span class="give-required-indicator">*</span> |
509 | 509 | <?php } ?> |
510 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'We will use this to personalize your account experience.', 'give' ); ?>"></span> |
|
510 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('We will use this to personalize your account experience.', 'give'); ?>"></span> |
|
511 | 511 | </label> |
512 | - <input class="give-input required" type="text" name="give_first" placeholder="<?php esc_attr_e( 'First name', 'give' ); ?>" id="give-first" value="<?php echo is_user_logged_in() ? $user_data->first_name : ''; ?>"<?php if ( give_field_is_required( 'give_first', $form_id ) ) { |
|
512 | + <input class="give-input required" type="text" name="give_first" placeholder="<?php esc_attr_e('First name', 'give'); ?>" id="give-first" value="<?php echo is_user_logged_in() ? $user_data->first_name : ''; ?>"<?php if (give_field_is_required('give_first', $form_id)) { |
|
513 | 513 | echo ' required '; |
514 | 514 | } ?>/> |
515 | 515 | </p> |
516 | 516 | |
517 | 517 | <p id="give-last-name-wrap" class="form-row form-row-last"> |
518 | 518 | <label class="give-label" for="give-last"> |
519 | - <?php esc_html_e( 'Last Name', 'give' ); ?> |
|
520 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) { ?> |
|
519 | + <?php esc_html_e('Last Name', 'give'); ?> |
|
520 | + <?php if (give_field_is_required('give_last', $form_id)) { ?> |
|
521 | 521 | <span class="give-required-indicator">*</span> |
522 | 522 | <?php } ?> |
523 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'We will use this as well to personalize your account experience.', 'give' ); ?>"></span> |
|
523 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('We will use this as well to personalize your account experience.', 'give'); ?>"></span> |
|
524 | 524 | </label> |
525 | 525 | |
526 | - <input class="give-input<?php if ( give_field_is_required( 'give_last', $form_id ) ) { |
|
526 | + <input class="give-input<?php if (give_field_is_required('give_last', $form_id)) { |
|
527 | 527 | echo ' required'; |
528 | - } ?>" type="text" name="give_last" id="give-last" placeholder="<?php esc_attr_e( 'Last name', 'give' ); ?>" value="<?php echo is_user_logged_in() ? $user_data->last_name : ''; ?>"<?php if ( give_field_is_required( 'give_last', $form_id ) ) { |
|
528 | + } ?>" type="text" name="give_last" id="give-last" placeholder="<?php esc_attr_e('Last name', 'give'); ?>" value="<?php echo is_user_logged_in() ? $user_data->last_name : ''; ?>"<?php if (give_field_is_required('give_last', $form_id)) { |
|
529 | 529 | echo ' required '; |
530 | 530 | } ?> /> |
531 | 531 | </p> |
532 | 532 | |
533 | - <?php do_action( 'give_purchase_form_before_email', $form_id ); ?> |
|
533 | + <?php do_action('give_purchase_form_before_email', $form_id); ?> |
|
534 | 534 | <p id="give-email-wrap" class="form-row form-row-wide"> |
535 | 535 | <label class="give-label" for="give-email"> |
536 | - <?php esc_html_e( 'Email Address', 'give' ); ?> |
|
537 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
536 | + <?php esc_html_e('Email Address', 'give'); ?> |
|
537 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
538 | 538 | <span class="give-required-indicator">*</span> |
539 | 539 | <?php } ?> |
540 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'We will send the purchase receipt to this address.', 'give' ); ?>"></span> |
|
540 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('We will send the purchase receipt to this address.', 'give'); ?>"></span> |
|
541 | 541 | </label> |
542 | 542 | |
543 | - <input class="give-input required" type="email" name="give_email" placeholder="<?php esc_attr_e( 'Email address', 'give' ); ?>" id="give-email" value="<?php echo is_user_logged_in() ? $user_data->user_email : ''; ?>"<?php if ( give_field_is_required( 'give_email', $form_id ) ) { |
|
543 | + <input class="give-input required" type="email" name="give_email" placeholder="<?php esc_attr_e('Email address', 'give'); ?>" id="give-email" value="<?php echo is_user_logged_in() ? $user_data->user_email : ''; ?>"<?php if (give_field_is_required('give_email', $form_id)) { |
|
544 | 544 | echo ' required '; |
545 | 545 | } ?>/> |
546 | 546 | |
547 | 547 | </p> |
548 | - <?php do_action( 'give_purchase_form_after_email', $form_id ); ?> |
|
548 | + <?php do_action('give_purchase_form_after_email', $form_id); ?> |
|
549 | 549 | |
550 | - <?php do_action( 'give_purchase_form_user_info', $form_id ); ?> |
|
550 | + <?php do_action('give_purchase_form_user_info', $form_id); ?> |
|
551 | 551 | </fieldset> |
552 | 552 | <?php |
553 | - do_action( 'give_purchase_form_after_personal_info', $form_id ); |
|
553 | + do_action('give_purchase_form_after_personal_info', $form_id); |
|
554 | 554 | |
555 | 555 | } |
556 | 556 | |
557 | -add_action( 'give_purchase_form_after_user_info', 'give_user_info_fields' ); |
|
558 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
557 | +add_action('give_purchase_form_after_user_info', 'give_user_info_fields'); |
|
558 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
559 | 559 | |
560 | 560 | /** |
561 | 561 | * Renders the credit card info form. |
@@ -566,73 +566,73 @@ discard block |
||
566 | 566 | * |
567 | 567 | * @return void |
568 | 568 | */ |
569 | -function give_get_cc_form( $form_id ) { |
|
569 | +function give_get_cc_form($form_id) { |
|
570 | 570 | |
571 | 571 | ob_start(); |
572 | 572 | |
573 | - do_action( 'give_before_cc_fields', $form_id ); ?> |
|
573 | + do_action('give_before_cc_fields', $form_id); ?> |
|
574 | 574 | |
575 | 575 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
576 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
577 | - <?php if ( is_ssl() ) : ?> |
|
576 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
577 | + <?php if (is_ssl()) : ?> |
|
578 | 578 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
579 | 579 | <span class="give-icon padlock"></span> |
580 | - <span><?php esc_html_e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
580 | + <span><?php esc_html_e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
581 | 581 | </div> |
582 | 582 | <?php endif; ?> |
583 | 583 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds"> |
584 | 584 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
585 | - <?php esc_html_e( 'Card Number', 'give' ); ?> |
|
585 | + <?php esc_html_e('Card Number', 'give'); ?> |
|
586 | 586 | <span class="give-required-indicator">*</span> |
587 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The (typically) 16 digits on the front of your credit card.', 'give' ); ?>"></span> |
|
587 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The (typically) 16 digits on the front of your credit card.', 'give'); ?>"></span> |
|
588 | 588 | <span class="card-type"></span> |
589 | 589 | </label> |
590 | 590 | |
591 | - <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" class="card-number give-input required" placeholder="<?php esc_attr_e( 'Card number', 'give' ); ?>" required/> |
|
591 | + <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" class="card-number give-input required" placeholder="<?php esc_attr_e('Card number', 'give'); ?>" required/> |
|
592 | 592 | </p> |
593 | 593 | |
594 | 594 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third"> |
595 | 595 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
596 | - <?php esc_html_e( 'CVC', 'give' ); ?> |
|
596 | + <?php esc_html_e('CVC', 'give'); ?> |
|
597 | 597 | <span class="give-required-indicator">*</span> |
598 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ); ?>"></span> |
|
598 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The 3 digit (back) or 4 digit (front) value on your card.', 'give'); ?>"></span> |
|
599 | 599 | </label> |
600 | 600 | |
601 | - <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" class="card-cvc give-input required" placeholder="<?php esc_attr_e( 'Security code', 'give' ); ?>" required/> |
|
601 | + <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" class="card-cvc give-input required" placeholder="<?php esc_attr_e('Security code', 'give'); ?>" required/> |
|
602 | 602 | </p> |
603 | 603 | |
604 | 604 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds"> |
605 | 605 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
606 | - <?php esc_html_e( 'Name on the Card', 'give' ); ?> |
|
606 | + <?php esc_html_e('Name on the Card', 'give'); ?> |
|
607 | 607 | <span class="give-required-indicator">*</span> |
608 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The name printed on the front of your credit card.', 'give' ); ?>"></span> |
|
608 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The name printed on the front of your credit card.', 'give'); ?>"></span> |
|
609 | 609 | </label> |
610 | 610 | |
611 | - <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" required/> |
|
611 | + <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" required/> |
|
612 | 612 | </p> |
613 | - <?php do_action( 'give_before_cc_expiration' ); ?> |
|
613 | + <?php do_action('give_before_cc_expiration'); ?> |
|
614 | 614 | <p class="card-expiration form-row form-row-one-third"> |
615 | 615 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
616 | - <?php esc_html_e( 'Expiration', 'give' ); ?> |
|
616 | + <?php esc_html_e('Expiration', 'give'); ?> |
|
617 | 617 | <span class="give-required-indicator">*</span> |
618 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The date your credit card expires, typically on the front of the card.', 'give' ); ?>"></span> |
|
618 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The date your credit card expires, typically on the front of the card.', 'give'); ?>"></span> |
|
619 | 619 | </label> |
620 | 620 | |
621 | 621 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" class="card-expiry-month"/> |
622 | 622 | <input type="hidden" id="card_exp_year-<?php echo $form_id ?>" name="card_exp_year" class="card-expiry-year"/> |
623 | 623 | |
624 | - <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" required/> |
|
624 | + <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" required/> |
|
625 | 625 | </p> |
626 | - <?php do_action( 'give_after_cc_expiration', $form_id ); ?> |
|
626 | + <?php do_action('give_after_cc_expiration', $form_id); ?> |
|
627 | 627 | |
628 | 628 | </fieldset> |
629 | 629 | <?php |
630 | - do_action( 'give_after_cc_fields', $form_id ); |
|
630 | + do_action('give_after_cc_fields', $form_id); |
|
631 | 631 | |
632 | 632 | echo ob_get_clean(); |
633 | 633 | } |
634 | 634 | |
635 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
635 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
636 | 636 | |
637 | 637 | /** |
638 | 638 | * Outputs the default credit card address fields |
@@ -643,110 +643,110 @@ discard block |
||
643 | 643 | * |
644 | 644 | * @return void |
645 | 645 | */ |
646 | -function give_default_cc_address_fields( $form_id ) { |
|
646 | +function give_default_cc_address_fields($form_id) { |
|
647 | 647 | |
648 | 648 | $logged_in = is_user_logged_in(); |
649 | 649 | |
650 | - if ( $logged_in ) { |
|
651 | - $user_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
650 | + if ($logged_in) { |
|
651 | + $user_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
652 | 652 | } |
653 | - $line1 = $logged_in && ! empty( $user_address['line1'] ) ? $user_address['line1'] : ''; |
|
654 | - $line2 = $logged_in && ! empty( $user_address['line2'] ) ? $user_address['line2'] : ''; |
|
655 | - $city = $logged_in && ! empty( $user_address['city'] ) ? $user_address['city'] : ''; |
|
656 | - $zip = $logged_in && ! empty( $user_address['zip'] ) ? $user_address['zip'] : ''; |
|
653 | + $line1 = $logged_in && ! empty($user_address['line1']) ? $user_address['line1'] : ''; |
|
654 | + $line2 = $logged_in && ! empty($user_address['line2']) ? $user_address['line2'] : ''; |
|
655 | + $city = $logged_in && ! empty($user_address['city']) ? $user_address['city'] : ''; |
|
656 | + $zip = $logged_in && ! empty($user_address['zip']) ? $user_address['zip'] : ''; |
|
657 | 657 | ob_start(); ?> |
658 | 658 | <fieldset id="give_cc_address" class="cc-address"> |
659 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
660 | - <?php do_action( 'give_cc_billing_top' ); ?> |
|
659 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
660 | + <?php do_action('give_cc_billing_top'); ?> |
|
661 | 661 | <p id="give-card-address-wrap" class="form-row form-row-two-thirds"> |
662 | 662 | <label for="card_address" class="give-label"> |
663 | - <?php esc_html_e( 'Address', 'give' ); ?> |
|
663 | + <?php esc_html_e('Address', 'give'); ?> |
|
664 | 664 | <?php |
665 | - if ( give_field_is_required( 'card_address', $form_id ) ) { ?> |
|
665 | + if (give_field_is_required('card_address', $form_id)) { ?> |
|
666 | 666 | <span class="give-required-indicator">*</span> |
667 | 667 | <?php } ?> |
668 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The primary billing address for your credit card.', 'give' ); ?>"></span> |
|
668 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The primary billing address for your credit card.', 'give'); ?>"></span> |
|
669 | 669 | </label> |
670 | 670 | |
671 | - <input type="text" id="card_address" name="card_address" class="card-address give-input<?php if ( give_field_is_required( 'card_address', $form_id ) ) { |
|
671 | + <input type="text" id="card_address" name="card_address" class="card-address give-input<?php if (give_field_is_required('card_address', $form_id)) { |
|
672 | 672 | echo ' required'; |
673 | - } ?>" placeholder="<?php esc_attr_e( 'Address line 1', 'give' ); ?>" value="<?php echo $line1; ?>"<?php if ( give_field_is_required( 'card_address', $form_id ) ) { |
|
673 | + } ?>" placeholder="<?php esc_attr_e('Address line 1', 'give'); ?>" value="<?php echo $line1; ?>"<?php if (give_field_is_required('card_address', $form_id)) { |
|
674 | 674 | echo ' required '; |
675 | 675 | } ?>/> |
676 | 676 | </p> |
677 | 677 | |
678 | 678 | <p id="give-card-address-2-wrap" class="form-row form-row-one-third"> |
679 | 679 | <label for="card_address_2" class="give-label"> |
680 | - <?php esc_html_e( 'Address Line 2', 'give' ); ?> |
|
681 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) { ?> |
|
680 | + <?php esc_html_e('Address Line 2', 'give'); ?> |
|
681 | + <?php if (give_field_is_required('card_address_2', $form_id)) { ?> |
|
682 | 682 | <span class="give-required-indicator">*</span> |
683 | 683 | <?php } ?> |
684 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( '(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give' ); ?>"></span> |
|
684 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give'); ?>"></span> |
|
685 | 685 | </label> |
686 | 686 | |
687 | - <input type="text" id="card_address_2" name="card_address_2" class="card-address-2 give-input<?php if ( give_field_is_required( 'card_address_2', $form_id ) ) { |
|
687 | + <input type="text" id="card_address_2" name="card_address_2" class="card-address-2 give-input<?php if (give_field_is_required('card_address_2', $form_id)) { |
|
688 | 688 | echo ' required'; |
689 | - } ?>" placeholder="<?php esc_attr_e( 'Address line 2', 'give' ); ?>" value="<?php echo $line2; ?>"<?php if ( give_field_is_required( 'card_address_2', $form_id ) ) { |
|
689 | + } ?>" placeholder="<?php esc_attr_e('Address line 2', 'give'); ?>" value="<?php echo $line2; ?>"<?php if (give_field_is_required('card_address_2', $form_id)) { |
|
690 | 690 | echo ' required '; |
691 | 691 | } ?>/> |
692 | 692 | </p> |
693 | 693 | |
694 | 694 | <p id="give-card-city-wrap" class="form-row form-row-two-thirds"> |
695 | 695 | <label for="card_city" class="give-label"> |
696 | - <?php esc_html_e( 'City', 'give' ); ?> |
|
697 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) { ?> |
|
696 | + <?php esc_html_e('City', 'give'); ?> |
|
697 | + <?php if (give_field_is_required('card_city', $form_id)) { ?> |
|
698 | 698 | <span class="give-required-indicator">*</span> |
699 | 699 | <?php } ?> |
700 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The city for your billing address.', 'give' ); ?>"></span> |
|
700 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The city for your billing address.', 'give'); ?>"></span> |
|
701 | 701 | </label> |
702 | - <input type="text" id="card_city" name="card_city" class="card-city give-input<?php if ( give_field_is_required( 'card_city', $form_id ) ) { |
|
702 | + <input type="text" id="card_city" name="card_city" class="card-city give-input<?php if (give_field_is_required('card_city', $form_id)) { |
|
703 | 703 | echo ' required'; |
704 | - } ?>" placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" value="<?php echo $city; ?>"<?php if ( give_field_is_required( 'card_city', $form_id ) ) { |
|
704 | + } ?>" placeholder="<?php esc_attr_e('City', 'give'); ?>" value="<?php echo $city; ?>"<?php if (give_field_is_required('card_city', $form_id)) { |
|
705 | 705 | echo ' required '; |
706 | 706 | } ?>/> |
707 | 707 | </p> |
708 | 708 | |
709 | 709 | <p id="give-card-zip-wrap" class="form-row form-row-one-third"> |
710 | 710 | <label for="card_zip" class="give-label"> |
711 | - <?php esc_html_e( 'Zip / Postal Code', 'give' ); ?> |
|
712 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) { ?> |
|
711 | + <?php esc_html_e('Zip / Postal Code', 'give'); ?> |
|
712 | + <?php if (give_field_is_required('card_zip', $form_id)) { ?> |
|
713 | 713 | <span class="give-required-indicator">*</span> |
714 | 714 | <?php } ?> |
715 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The zip or postal code for your billing address.', 'give' ); ?>"></span> |
|
715 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The zip or postal code for your billing address.', 'give'); ?>"></span> |
|
716 | 716 | </label> |
717 | 717 | |
718 | - <input type="text" size="4" id="card_zip" name="card_zip" class="card-zip give-input<?php if ( give_field_is_required( 'card_zip', $form_id ) ) { |
|
718 | + <input type="text" size="4" id="card_zip" name="card_zip" class="card-zip give-input<?php if (give_field_is_required('card_zip', $form_id)) { |
|
719 | 719 | echo ' required'; |
720 | - } ?>" placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $zip; ?>" <?php if ( give_field_is_required( 'card_zip', $form_id ) ) { |
|
720 | + } ?>" placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" value="<?php echo $zip; ?>" <?php if (give_field_is_required('card_zip', $form_id)) { |
|
721 | 721 | echo ' required '; |
722 | 722 | } ?>/> |
723 | 723 | </p> |
724 | 724 | |
725 | 725 | <p id="give-card-country-wrap" class="form-row form-row-first"> |
726 | 726 | <label for="billing_country" class="give-label"> |
727 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
728 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) { ?> |
|
727 | + <?php esc_html_e('Country', 'give'); ?> |
|
728 | + <?php if (give_field_is_required('billing_country', $form_id)) { ?> |
|
729 | 729 | <span class="give-required-indicator">*</span> |
730 | 730 | <?php } ?> |
731 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
731 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
732 | 732 | </label> |
733 | 733 | |
734 | - <select name="billing_country" id="billing_country" class="billing-country billing_country give-select<?php if ( give_field_is_required( 'billing_country', $form_id ) ) { |
|
734 | + <select name="billing_country" id="billing_country" class="billing-country billing_country give-select<?php if (give_field_is_required('billing_country', $form_id)) { |
|
735 | 735 | echo ' required'; |
736 | - } ?>"<?php if ( give_field_is_required( 'billing_country', $form_id ) ) { |
|
736 | + } ?>"<?php if (give_field_is_required('billing_country', $form_id)) { |
|
737 | 737 | echo ' required '; |
738 | 738 | } ?>> |
739 | 739 | <?php |
740 | 740 | |
741 | 741 | $selected_country = give_get_country(); |
742 | 742 | |
743 | - if ( $logged_in && ! empty( $user_address['country'] ) && '*' !== $user_address['country'] ) { |
|
743 | + if ($logged_in && ! empty($user_address['country']) && '*' !== $user_address['country']) { |
|
744 | 744 | $selected_country = $user_address['country']; |
745 | 745 | } |
746 | 746 | |
747 | 747 | $countries = give_get_country_list(); |
748 | - foreach ( $countries as $country_code => $country ) { |
|
749 | - echo '<option value="' . esc_attr__( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
748 | + foreach ($countries as $country_code => $country) { |
|
749 | + echo '<option value="'.esc_attr__($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
750 | 750 | } |
751 | 751 | ?> |
752 | 752 | </select> |
@@ -754,44 +754,44 @@ discard block |
||
754 | 754 | |
755 | 755 | <p id="give-card-state-wrap" class="form-row form-row-last"> |
756 | 756 | <label for="card_state" class="give-label"> |
757 | - <?php esc_html_e( 'State / Province', 'give' ); ?> |
|
758 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) { ?> |
|
757 | + <?php esc_html_e('State / Province', 'give'); ?> |
|
758 | + <?php if (give_field_is_required('card_state', $form_id)) { ?> |
|
759 | 759 | <span class="give-required-indicator">*</span> |
760 | 760 | <?php } ?> |
761 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The state or province for your billing address.', 'give' ); ?>"></span> |
|
761 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The state or province for your billing address.', 'give'); ?>"></span> |
|
762 | 762 | </label> |
763 | 763 | |
764 | 764 | <?php |
765 | 765 | $selected_state = give_get_state(); |
766 | - $states = give_get_states( $selected_country ); |
|
766 | + $states = give_get_states($selected_country); |
|
767 | 767 | |
768 | - if ( $logged_in && ! empty( $user_address['state'] ) ) { |
|
768 | + if ($logged_in && ! empty($user_address['state'])) { |
|
769 | 769 | $selected_state = $user_address['state']; |
770 | 770 | } |
771 | 771 | |
772 | - if ( ! empty( $states ) ) : ?> |
|
773 | - <select name="card_state" id="card_state" class="card_state give-select<?php if ( give_field_is_required( 'card_state', $form_id ) ) { |
|
772 | + if ( ! empty($states)) : ?> |
|
773 | + <select name="card_state" id="card_state" class="card_state give-select<?php if (give_field_is_required('card_state', $form_id)) { |
|
774 | 774 | echo ' required'; |
775 | - } ?>"<?php if ( give_field_is_required( 'card_state', $form_id ) ) { |
|
775 | + } ?>"<?php if (give_field_is_required('card_state', $form_id)) { |
|
776 | 776 | echo ' required '; |
777 | 777 | } ?>> |
778 | 778 | <?php |
779 | - foreach ( $states as $state_code => $state ) { |
|
780 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
779 | + foreach ($states as $state_code => $state) { |
|
780 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
781 | 781 | } |
782 | 782 | ?> |
783 | 783 | </select> |
784 | 784 | <?php else : ?> |
785 | - <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>"/> |
|
785 | + <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_attr_e('State / Province', 'give'); ?>"/> |
|
786 | 786 | <?php endif; ?> |
787 | 787 | </p> |
788 | - <?php do_action( 'give_cc_billing_bottom' ); ?> |
|
788 | + <?php do_action('give_cc_billing_bottom'); ?> |
|
789 | 789 | </fieldset> |
790 | 790 | <?php |
791 | 791 | echo ob_get_clean(); |
792 | 792 | } |
793 | 793 | |
794 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
794 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
795 | 795 | |
796 | 796 | |
797 | 797 | /** |
@@ -803,93 +803,93 @@ discard block |
||
803 | 803 | * |
804 | 804 | * @return string |
805 | 805 | */ |
806 | -function give_get_register_fields( $form_id ) { |
|
806 | +function give_get_register_fields($form_id) { |
|
807 | 807 | |
808 | 808 | global $user_ID; |
809 | 809 | |
810 | - if ( is_user_logged_in() ) { |
|
811 | - $user_data = get_userdata( $user_ID ); |
|
810 | + if (is_user_logged_in()) { |
|
811 | + $user_data = get_userdata($user_ID); |
|
812 | 812 | } |
813 | 813 | |
814 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
814 | + $show_register_form = give_show_login_register_option($form_id); |
|
815 | 815 | |
816 | 816 | ob_start(); ?> |
817 | 817 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
818 | 818 | |
819 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
819 | + <?php if ($show_register_form == 'both') { ?> |
|
820 | 820 | <div class="give-login-account-wrap"> |
821 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
822 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
821 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
822 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
823 | 823 | </p> |
824 | 824 | <p class="give-loading-text"> |
825 | - <span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?></p> |
|
825 | + <span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?></p> |
|
826 | 826 | </div> |
827 | 827 | <?php } ?> |
828 | 828 | |
829 | - <?php do_action( 'give_register_fields_before', $form_id ); ?> |
|
829 | + <?php do_action('give_register_fields_before', $form_id); ?> |
|
830 | 830 | |
831 | 831 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
832 | - <legend><?php echo apply_filters( 'give_create_account_fieldset_heading', esc_html__( 'Create an account', 'give' ) ); |
|
833 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
834 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
832 | + <legend><?php echo apply_filters('give_create_account_fieldset_heading', esc_html__('Create an account', 'give')); |
|
833 | + if ( ! give_logged_in_only($form_id)) { |
|
834 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
835 | 835 | } ?></legend> |
836 | - <?php do_action( 'give_register_account_fields_before', $form_id ); ?> |
|
836 | + <?php do_action('give_register_account_fields_before', $form_id); ?> |
|
837 | 837 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third form-row-first"> |
838 | 838 | <label for="give-user-login-<?php echo $form_id; ?>"> |
839 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
840 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
839 | + <?php esc_html_e('Username', 'give'); ?> |
|
840 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
841 | 841 | <span class="give-required-indicator">*</span> |
842 | 842 | <?php } ?> |
843 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The username you will use to log into your account.', 'give' ); ?>"></span> |
|
843 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The username you will use to log into your account.', 'give'); ?>"></span> |
|
844 | 844 | </label> |
845 | 845 | |
846 | - <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
846 | + <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="<?php if (give_logged_in_only($form_id)) { |
|
847 | 847 | echo 'required '; |
848 | - } ?>give-input" type="text" placeholder="<?php esc_attr_e( 'Username', 'give' ); ?>" title="<?php esc_attr_e( 'Username', 'give' ); ?>"/> |
|
848 | + } ?>give-input" type="text" placeholder="<?php esc_attr_e('Username', 'give'); ?>" title="<?php esc_attr_e('Username', 'give'); ?>"/> |
|
849 | 849 | </div> |
850 | 850 | |
851 | 851 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third"> |
852 | 852 | <label for="give-user-pass-<?php echo $form_id; ?>"> |
853 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
854 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
853 | + <?php esc_html_e('Password', 'give'); ?> |
|
854 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
855 | 855 | <span class="give-required-indicator">*</span> |
856 | 856 | <?php } ?> |
857 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The password used to access your account.', 'give' ); ?>"></span> |
|
857 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The password used to access your account.', 'give'); ?>"></span> |
|
858 | 858 | </label> |
859 | 859 | |
860 | - <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
860 | + <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="<?php if (give_logged_in_only($form_id)) { |
|
861 | 861 | echo 'required '; |
862 | - } ?>give-input" placeholder="<?php esc_attr_e( 'Password', 'give' ); ?>" type="password"/> |
|
862 | + } ?>give-input" placeholder="<?php esc_attr_e('Password', 'give'); ?>" type="password"/> |
|
863 | 863 | </div> |
864 | 864 | |
865 | 865 | <div id="give-user-pass-confirm-wrap-<?php echo $form_id; ?>" class="give-register-password form-row form-row-one-third"> |
866 | 866 | <label for="give-user-pass-confirm-<?php echo $form_id; ?>"> |
867 | - <?php esc_html_e( 'Confirm PW', 'give' ); ?> |
|
868 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
867 | + <?php esc_html_e('Confirm PW', 'give'); ?> |
|
868 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
869 | 869 | <span class="give-required-indicator">*</span> |
870 | 870 | <?php } ?> |
871 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'Please retype your password to confirm.', 'give' ); ?>"></span> |
|
871 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('Please retype your password to confirm.', 'give'); ?>"></span> |
|
872 | 872 | </label> |
873 | 873 | |
874 | - <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
874 | + <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" class="<?php if (give_logged_in_only($form_id)) { |
|
875 | 875 | echo 'required '; |
876 | - } ?>give-input" placeholder="<?php esc_attr_e( 'Confirm password', 'give' ); ?>" type="password"/> |
|
876 | + } ?>give-input" placeholder="<?php esc_attr_e('Confirm password', 'give'); ?>" type="password"/> |
|
877 | 877 | </div> |
878 | - <?php do_action( 'give_register_account_fields_after', $form_id ); ?> |
|
878 | + <?php do_action('give_register_account_fields_after', $form_id); ?> |
|
879 | 879 | </fieldset> |
880 | 880 | |
881 | - <?php do_action( 'give_register_fields_after', $form_id ); ?> |
|
881 | + <?php do_action('give_register_fields_after', $form_id); ?> |
|
882 | 882 | |
883 | 883 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
884 | 884 | |
885 | - <?php do_action( 'give_purchase_form_user_info', $form_id ); ?> |
|
885 | + <?php do_action('give_purchase_form_user_info', $form_id); ?> |
|
886 | 886 | |
887 | 887 | </fieldset> |
888 | 888 | <?php |
889 | 889 | echo ob_get_clean(); |
890 | 890 | } |
891 | 891 | |
892 | -add_action( 'give_purchase_form_register_fields', 'give_get_register_fields' ); |
|
892 | +add_action('give_purchase_form_register_fields', 'give_get_register_fields'); |
|
893 | 893 | |
894 | 894 | /** |
895 | 895 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -902,79 +902,79 @@ discard block |
||
902 | 902 | * |
903 | 903 | * @return string |
904 | 904 | */ |
905 | -function give_get_login_fields( $form_id ) { |
|
905 | +function give_get_login_fields($form_id) { |
|
906 | 906 | |
907 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
908 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
907 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
908 | + $show_register_form = give_show_login_register_option($form_id); |
|
909 | 909 | |
910 | 910 | ob_start(); |
911 | 911 | ?> |
912 | 912 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
913 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', esc_html__( 'Login to Your Account', 'give' ) ); |
|
914 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
915 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
913 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', esc_html__('Login to Your Account', 'give')); |
|
914 | + if ( ! give_logged_in_only($form_id)) { |
|
915 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
916 | 916 | } ?> |
917 | 917 | </legend> |
918 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
918 | + <?php if ($show_register_form == 'both') { ?> |
|
919 | 919 | <p class="give-new-account-link"> |
920 | - <?php esc_html_e( 'Need to create an account?', 'give' ); ?> |
|
921 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" data-action="give_checkout_register"> |
|
922 | - <?php esc_html_e( 'Register', 'give' ); |
|
923 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
924 | - echo ' ' . esc_html__( 'or checkout as a guest.', 'give' ); |
|
920 | + <?php esc_html_e('Need to create an account?', 'give'); ?> |
|
921 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" data-action="give_checkout_register"> |
|
922 | + <?php esc_html_e('Register', 'give'); |
|
923 | + if ( ! give_logged_in_only($form_id)) { |
|
924 | + echo ' '.esc_html__('or checkout as a guest.', 'give'); |
|
925 | 925 | } ?> |
926 | 926 | </a> |
927 | 927 | </p> |
928 | 928 | <p class="give-loading-text"> |
929 | - <span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?> </p> |
|
929 | + <span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?> </p> |
|
930 | 930 | <?php } ?> |
931 | - <?php do_action( 'give_checkout_login_fields_before', $form_id ); ?> |
|
931 | + <?php do_action('give_checkout_login_fields_before', $form_id); ?> |
|
932 | 932 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first"> |
933 | 933 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
934 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
935 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
934 | + <?php esc_html_e('Username', 'give'); ?> |
|
935 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
936 | 936 | <span class="give-required-indicator">*</span> |
937 | 937 | <?php } ?> |
938 | 938 | </label> |
939 | 939 | |
940 | - <input class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
940 | + <input class="<?php if (give_logged_in_only($form_id)) { |
|
941 | 941 | echo 'required '; |
942 | - } ?>give-input" type="text" name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" placeholder="<?php esc_attr_e( 'Your username', 'give' ); ?>"/> |
|
942 | + } ?>give-input" type="text" name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" placeholder="<?php esc_attr_e('Your username', 'give'); ?>"/> |
|
943 | 943 | </div> |
944 | 944 | |
945 | 945 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="give_login_password form-row form-row-last"> |
946 | 946 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
947 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
948 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
947 | + <?php esc_html_e('Password', 'give'); ?> |
|
948 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
949 | 949 | <span class="give-required-indicator">*</span> |
950 | 950 | <?php } ?> |
951 | 951 | </label> |
952 | - <input class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
952 | + <input class="<?php if (give_logged_in_only($form_id)) { |
|
953 | 953 | echo 'required '; |
954 | - } ?>give-input" type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" placeholder="<?php esc_attr_e( 'Your password', 'give' ); ?>"/> |
|
954 | + } ?>give-input" type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" placeholder="<?php esc_attr_e('Your password', 'give'); ?>"/> |
|
955 | 955 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
956 | 956 | </div> |
957 | 957 | |
958 | 958 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
959 | 959 | <span class="give-forgot-password "> |
960 | - <a href="<?php echo wp_lostpassword_url( $redirect )?>"> <?php esc_html_e( 'Forgot password?' ) ?> </a> |
|
960 | + <a href="<?php echo wp_lostpassword_url($redirect)?>"> <?php esc_html_e('Forgot password?') ?> </a> |
|
961 | 961 | </span> |
962 | 962 | </div> |
963 | 963 | |
964 | 964 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
965 | - <input type="submit" class="give-submit give-btn button" name="give_login_submit" value="<?php esc_attr_e( 'Login', 'give' ); ?>"/> |
|
966 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
967 | - <input type="button" data-action="give_cancel_login" class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" value="<?php esc_attr_e( 'Cancel', 'give' ); ?>"/> |
|
965 | + <input type="submit" class="give-submit give-btn button" name="give_login_submit" value="<?php esc_attr_e('Login', 'give'); ?>"/> |
|
966 | + <?php if ($show_register_form !== 'login') { ?> |
|
967 | + <input type="button" data-action="give_cancel_login" class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" value="<?php esc_attr_e('Cancel', 'give'); ?>"/> |
|
968 | 968 | <?php } ?> |
969 | 969 | <span class="give-loading-animation"></span> |
970 | 970 | </div> |
971 | - <?php do_action( 'give_checkout_login_fields_after', $form_id ); ?> |
|
971 | + <?php do_action('give_checkout_login_fields_after', $form_id); ?> |
|
972 | 972 | </fieldset><!--end #give-login-fields--> |
973 | 973 | <?php |
974 | 974 | echo ob_get_clean(); |
975 | 975 | } |
976 | 976 | |
977 | -add_action( 'give_purchase_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
977 | +add_action('give_purchase_form_login_fields', 'give_get_login_fields', 10, 1); |
|
978 | 978 | |
979 | 979 | /** |
980 | 980 | * Payment Mode Select |
@@ -990,49 +990,49 @@ discard block |
||
990 | 990 | * |
991 | 991 | * @return void |
992 | 992 | */ |
993 | -function give_payment_mode_select( $form_id ) { |
|
993 | +function give_payment_mode_select($form_id) { |
|
994 | 994 | |
995 | 995 | $gateways = give_get_enabled_payment_gateways(); |
996 | 996 | |
997 | - do_action( 'give_payment_mode_top', $form_id ); ?> |
|
997 | + do_action('give_payment_mode_top', $form_id); ?> |
|
998 | 998 | |
999 | 999 | <fieldset id="give-payment-mode-select"> |
1000 | - <?php do_action( 'give_payment_mode_before_gateways_wrap' ); ?> |
|
1000 | + <?php do_action('give_payment_mode_before_gateways_wrap'); ?> |
|
1001 | 1001 | <div id="give-payment-mode-wrap"> |
1002 | - <legend class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?> |
|
1003 | - <span class="give-loading-text"><span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?></span> |
|
1002 | + <legend class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?> |
|
1003 | + <span class="give-loading-text"><span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?></span> |
|
1004 | 1004 | </legend> |
1005 | 1005 | <?php |
1006 | 1006 | |
1007 | - do_action( 'give_payment_mode_before_gateways' ) ?> |
|
1007 | + do_action('give_payment_mode_before_gateways') ?> |
|
1008 | 1008 | |
1009 | 1009 | <ul id="give-gateway-radio-list"> |
1010 | - <?php foreach ( $gateways as $gateway_id => $gateway ) : |
|
1011 | - $checked = checked( $gateway_id, give_get_default_gateway( $form_id ), false ); |
|
1010 | + <?php foreach ($gateways as $gateway_id => $gateway) : |
|
1011 | + $checked = checked($gateway_id, give_get_default_gateway($form_id), false); |
|
1012 | 1012 | $checked_class = $checked ? ' give-gateway-option-selected' : ''; |
1013 | - echo '<li><label for="give-gateway-' . esc_attr__( $gateway_id ) . '-' . $form_id . '" class="give-gateway-option' . $checked_class . '" id="give-gateway-option-' . esc_attr__( $gateway_id ) . '">'; |
|
1014 | - echo '<input type="radio" name="payment-mode" class="give-gateway" id="give-gateway-' . esc_attr__( $gateway_id ) . '-' . $form_id . '" value="' . esc_attr__( $gateway_id ) . '"' . $checked . '>' . esc_html__( $gateway['checkout_label'] ); |
|
1013 | + echo '<li><label for="give-gateway-'.esc_attr__($gateway_id).'-'.$form_id.'" class="give-gateway-option'.$checked_class.'" id="give-gateway-option-'.esc_attr__($gateway_id).'">'; |
|
1014 | + echo '<input type="radio" name="payment-mode" class="give-gateway" id="give-gateway-'.esc_attr__($gateway_id).'-'.$form_id.'" value="'.esc_attr__($gateway_id).'"'.$checked.'>'.esc_html__($gateway['checkout_label']); |
|
1015 | 1015 | echo '</label></li>'; |
1016 | 1016 | endforeach; ?> |
1017 | 1017 | </ul> |
1018 | - <?php do_action( 'give_payment_mode_after_gateways' ); ?> |
|
1018 | + <?php do_action('give_payment_mode_after_gateways'); ?> |
|
1019 | 1019 | </div> |
1020 | - <?php do_action( 'give_payment_mode_after_gateways_wrap' ); ?> |
|
1020 | + <?php do_action('give_payment_mode_after_gateways_wrap'); ?> |
|
1021 | 1021 | </fieldset> |
1022 | 1022 | |
1023 | - <?php do_action( 'give_payment_mode_bottom', $form_id ); ?> |
|
1023 | + <?php do_action('give_payment_mode_bottom', $form_id); ?> |
|
1024 | 1024 | |
1025 | 1025 | <div id="give_purchase_form_wrap"> |
1026 | 1026 | |
1027 | - <?php do_action( 'give_purchase_form', $form_id ); ?> |
|
1027 | + <?php do_action('give_purchase_form', $form_id); ?> |
|
1028 | 1028 | |
1029 | 1029 | </div><!-- the checkout fields are loaded into this--> |
1030 | 1030 | |
1031 | - <?php do_action( 'give_purchase_form_wrap_bottom', $form_id ); |
|
1031 | + <?php do_action('give_purchase_form_wrap_bottom', $form_id); |
|
1032 | 1032 | |
1033 | 1033 | } |
1034 | 1034 | |
1035 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select' ); |
|
1035 | +add_action('give_payment_mode_select', 'give_payment_mode_select'); |
|
1036 | 1036 | |
1037 | 1037 | |
1038 | 1038 | /** |
@@ -1047,36 +1047,36 @@ discard block |
||
1047 | 1047 | * |
1048 | 1048 | * @return void |
1049 | 1049 | */ |
1050 | -function give_terms_agreement( $form_id ) { |
|
1050 | +function give_terms_agreement($form_id) { |
|
1051 | 1051 | |
1052 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
1053 | - $label = get_post_meta( $form_id, '_give_agree_label', true ); |
|
1054 | - $terms = get_post_meta( $form_id, '_give_agree_text', true ); |
|
1052 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
1053 | + $label = get_post_meta($form_id, '_give_agree_label', true); |
|
1054 | + $terms = get_post_meta($form_id, '_give_agree_text', true); |
|
1055 | 1055 | |
1056 | - if ( $form_option === 'yes' && ! empty( $terms ) ) { ?> |
|
1056 | + if ($form_option === 'yes' && ! empty($terms)) { ?> |
|
1057 | 1057 | <fieldset id="give_terms_agreement"> |
1058 | - <div id="give_terms" class= "give_terms-<?php echo $form_id;?>" style="display:none;"> |
|
1058 | + <div id="give_terms" class= "give_terms-<?php echo $form_id; ?>" style="display:none;"> |
|
1059 | 1059 | <?php |
1060 | - do_action( 'give_before_terms' ); |
|
1061 | - echo wpautop( stripslashes( $terms ) ); |
|
1062 | - do_action( 'give_after_terms' ); |
|
1060 | + do_action('give_before_terms'); |
|
1061 | + echo wpautop(stripslashes($terms)); |
|
1062 | + do_action('give_after_terms'); |
|
1063 | 1063 | ?> |
1064 | 1064 | </div> |
1065 | 1065 | <div id="give_show_terms"> |
1066 | - <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id;?>"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
1067 | - <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id;?>" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
1066 | + <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
1067 | + <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
1068 | 1068 | </div> |
1069 | 1069 | |
1070 | 1070 | <input name="give_agree_to_terms" class="required" type="checkbox" id="give_agree_to_terms" value="1"/> |
1071 | 1071 | <label |
1072 | - for="give_agree_to_terms"><?php echo ! empty( $label ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' ); ?></label> |
|
1072 | + for="give_agree_to_terms"><?php echo ! empty($label) ? stripslashes($label) : esc_html__('Agree to Terms?', 'give'); ?></label> |
|
1073 | 1073 | |
1074 | 1074 | </fieldset> |
1075 | 1075 | <?php |
1076 | 1076 | } |
1077 | 1077 | } |
1078 | 1078 | |
1079 | -add_action( 'give_purchase_form_before_submit', 'give_terms_agreement', 10, 1 ); |
|
1079 | +add_action('give_purchase_form_before_submit', 'give_terms_agreement', 10, 1); |
|
1080 | 1080 | |
1081 | 1081 | /** |
1082 | 1082 | * Checkout Final Total |
@@ -1088,27 +1088,27 @@ discard block |
||
1088 | 1088 | * @since 1.0 |
1089 | 1089 | * @return void |
1090 | 1090 | */ |
1091 | -function give_checkout_final_total( $form_id ) { |
|
1091 | +function give_checkout_final_total($form_id) { |
|
1092 | 1092 | |
1093 | - if ( isset( $_POST['give_total'] ) ) { |
|
1094 | - $total = apply_filters( 'give_donation_total', $_POST['give_total'] ); |
|
1093 | + if (isset($_POST['give_total'])) { |
|
1094 | + $total = apply_filters('give_donation_total', $_POST['give_total']); |
|
1095 | 1095 | } else { |
1096 | 1096 | //default total |
1097 | - $total = give_get_default_form_amount( $form_id ); |
|
1097 | + $total = give_get_default_form_amount($form_id); |
|
1098 | 1098 | } |
1099 | 1099 | //Only proceed if give_total available |
1100 | - if ( empty( $total ) ) { |
|
1100 | + if (empty($total)) { |
|
1101 | 1101 | return; |
1102 | 1102 | } |
1103 | 1103 | ?> |
1104 | 1104 | <p id="give-final-total-wrap" class="form-wrap "> |
1105 | - <span class="give-donation-total-label"><?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?></span> |
|
1106 | - <span class="give-final-total-amount" data-total="<?php echo give_format_amount( $total ); ?>"><?php echo give_currency_filter( give_format_amount( $total ) ); ?></span> |
|
1105 | + <span class="give-donation-total-label"><?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?></span> |
|
1106 | + <span class="give-final-total-amount" data-total="<?php echo give_format_amount($total); ?>"><?php echo give_currency_filter(give_format_amount($total)); ?></span> |
|
1107 | 1107 | </p> |
1108 | 1108 | <?php |
1109 | 1109 | } |
1110 | 1110 | |
1111 | -add_action( 'give_purchase_form_before_submit', 'give_checkout_final_total', 999 ); |
|
1111 | +add_action('give_purchase_form_before_submit', 'give_checkout_final_total', 999); |
|
1112 | 1112 | |
1113 | 1113 | |
1114 | 1114 | /** |
@@ -1120,22 +1120,22 @@ discard block |
||
1120 | 1120 | * |
1121 | 1121 | * @return void |
1122 | 1122 | */ |
1123 | -function give_checkout_submit( $form_id ) { |
|
1123 | +function give_checkout_submit($form_id) { |
|
1124 | 1124 | ?> |
1125 | 1125 | <fieldset id="give_purchase_submit"> |
1126 | - <?php do_action( 'give_purchase_form_before_submit', $form_id ); ?> |
|
1126 | + <?php do_action('give_purchase_form_before_submit', $form_id); ?> |
|
1127 | 1127 | |
1128 | - <?php give_checkout_hidden_fields( $form_id ); ?> |
|
1128 | + <?php give_checkout_hidden_fields($form_id); ?> |
|
1129 | 1129 | |
1130 | - <?php echo give_checkout_button_purchase( $form_id ); ?> |
|
1130 | + <?php echo give_checkout_button_purchase($form_id); ?> |
|
1131 | 1131 | |
1132 | - <?php do_action( 'give_purchase_form_after_submit', $form_id ); ?> |
|
1132 | + <?php do_action('give_purchase_form_after_submit', $form_id); ?> |
|
1133 | 1133 | |
1134 | 1134 | </fieldset> |
1135 | 1135 | <?php |
1136 | 1136 | } |
1137 | 1137 | |
1138 | -add_action( 'give_purchase_form_after_cc_form', 'give_checkout_submit', 9999 ); |
|
1138 | +add_action('give_purchase_form_after_cc_form', 'give_checkout_submit', 9999); |
|
1139 | 1139 | |
1140 | 1140 | |
1141 | 1141 | /** |
@@ -1148,17 +1148,17 @@ discard block |
||
1148 | 1148 | * |
1149 | 1149 | * @return string |
1150 | 1150 | */ |
1151 | -function give_checkout_button_purchase( $form_id ) { |
|
1151 | +function give_checkout_button_purchase($form_id) { |
|
1152 | 1152 | |
1153 | - $display_label_field = get_post_meta( $form_id, '_give_checkout_label', true ); |
|
1154 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
1153 | + $display_label_field = get_post_meta($form_id, '_give_checkout_label', true); |
|
1154 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
1155 | 1155 | ob_start(); ?> |
1156 | 1156 | <div class="give-submit-button-wrap give-clearfix"> |
1157 | 1157 | <input type="submit" class="give-submit give-btn" id="give-purchase-button" name="give-purchase" value="<?php echo $display_label; ?>"/> |
1158 | 1158 | <span class="give-loading-animation"></span> |
1159 | 1159 | </div> |
1160 | 1160 | <?php |
1161 | - return apply_filters( 'give_checkout_button_purchase', ob_get_clean(), $form_id ); |
|
1161 | + return apply_filters('give_checkout_button_purchase', ob_get_clean(), $form_id); |
|
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | /** |
@@ -1171,18 +1171,18 @@ discard block |
||
1171 | 1171 | * |
1172 | 1172 | * @return void |
1173 | 1173 | */ |
1174 | -function give_agree_to_terms_js( $form_id ) { |
|
1174 | +function give_agree_to_terms_js($form_id) { |
|
1175 | 1175 | |
1176 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
1176 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
1177 | 1177 | |
1178 | - if ( $form_option === 'yes' ) { |
|
1178 | + if ($form_option === 'yes') { |
|
1179 | 1179 | ?> |
1180 | 1180 | <script type="text/javascript"> |
1181 | 1181 | jQuery(document).ready(function ($) { |
1182 | - $('body').on('click', '.give_terms_links-<?php echo $form_id;?>', function (e) { |
|
1182 | + $('body').on('click', '.give_terms_links-<?php echo $form_id; ?>', function (e) { |
|
1183 | 1183 | e.preventDefault(); |
1184 | - $('.give_terms-<?php echo $form_id;?>').slideToggle(); |
|
1185 | - $('.give_terms_links-<?php echo $form_id;?>').toggle(); |
|
1184 | + $('.give_terms-<?php echo $form_id; ?>').slideToggle(); |
|
1185 | + $('.give_terms_links-<?php echo $form_id; ?>').toggle(); |
|
1186 | 1186 | return false; |
1187 | 1187 | }); |
1188 | 1188 | }); |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | } |
1192 | 1192 | } |
1193 | 1193 | |
1194 | -add_action( 'give_checkout_form_top', 'give_agree_to_terms_js', 10, 2 ); |
|
1194 | +add_action('give_checkout_form_top', 'give_agree_to_terms_js', 10, 2); |
|
1195 | 1195 | |
1196 | 1196 | /** |
1197 | 1197 | * Show Give Goals |
@@ -1204,25 +1204,25 @@ discard block |
||
1204 | 1204 | * @return mixed |
1205 | 1205 | */ |
1206 | 1206 | |
1207 | -function give_show_goal_progress( $form_id, $args ) { |
|
1207 | +function give_show_goal_progress($form_id, $args) { |
|
1208 | 1208 | |
1209 | - $goal_option = get_post_meta( $form_id, '_give_goal_option', true ); |
|
1210 | - $form = new Give_Donate_Form( $form_id ); |
|
1209 | + $goal_option = get_post_meta($form_id, '_give_goal_option', true); |
|
1210 | + $form = new Give_Donate_Form($form_id); |
|
1211 | 1211 | $goal = $form->goal; |
1212 | - $goal_format = get_post_meta( $form_id, '_give_goal_format', true ); |
|
1212 | + $goal_format = get_post_meta($form_id, '_give_goal_format', true); |
|
1213 | 1213 | $income = $form->get_earnings(); |
1214 | - $color = get_post_meta( $form_id, '_give_goal_color', true ); |
|
1215 | - $show_text = (bool) isset( $args['show_text'] ) ? filter_var( $args['show_text'], FILTER_VALIDATE_BOOLEAN ) : true; |
|
1216 | - $show_bar = (bool) isset( $args['show_bar'] ) ? filter_var( $args['show_bar'], FILTER_VALIDATE_BOOLEAN ) : true; |
|
1214 | + $color = get_post_meta($form_id, '_give_goal_color', true); |
|
1215 | + $show_text = (bool) isset($args['show_text']) ? filter_var($args['show_text'], FILTER_VALIDATE_BOOLEAN) : true; |
|
1216 | + $show_bar = (bool) isset($args['show_bar']) ? filter_var($args['show_bar'], FILTER_VALIDATE_BOOLEAN) : true; |
|
1217 | 1217 | |
1218 | 1218 | //Sanity check - respect shortcode args |
1219 | - if ( isset( $args['show_goal'] ) && $args['show_goal'] === false ) { |
|
1219 | + if (isset($args['show_goal']) && $args['show_goal'] === false) { |
|
1220 | 1220 | return false; |
1221 | 1221 | } |
1222 | 1222 | |
1223 | 1223 | //Sanity check - ensure form has goal set to output |
1224 | - if ( empty( $form->ID ) |
|
1225 | - || ( is_singular( 'give_forms' ) && $goal_option !== 'yes' ) |
|
1224 | + if (empty($form->ID) |
|
1225 | + || (is_singular('give_forms') && $goal_option !== 'yes') |
|
1226 | 1226 | || $goal_option !== 'yes' |
1227 | 1227 | || $goal == 0 |
1228 | 1228 | ) { |
@@ -1230,34 +1230,34 @@ discard block |
||
1230 | 1230 | return false; |
1231 | 1231 | } |
1232 | 1232 | |
1233 | - $progress = round( ( $income / $goal ) * 100, 2 ); |
|
1233 | + $progress = round(($income / $goal) * 100, 2); |
|
1234 | 1234 | |
1235 | - if ( $income >= $goal ) { |
|
1235 | + if ($income >= $goal) { |
|
1236 | 1236 | $progress = 100; |
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | $output = '<div class="give-goal-progress">'; |
1240 | 1240 | |
1241 | 1241 | //Goal Progress Text |
1242 | - if ( ! empty( $show_text ) ) { |
|
1242 | + if ( ! empty($show_text)) { |
|
1243 | 1243 | |
1244 | 1244 | $output .= '<div class="raised">'; |
1245 | 1245 | |
1246 | - if ( $goal_format !== 'percentage' ) { |
|
1246 | + if ($goal_format !== 'percentage') { |
|
1247 | 1247 | |
1248 | 1248 | $output .= sprintf( |
1249 | 1249 | /* translators: 1: amount of income raised 2: goal target ammount */ |
1250 | - esc_html__( '%1$s of %2$s raised', 'give' ), |
|
1251 | - '<span class="income">' . apply_filters( 'give_goal_amount_raised_output', give_currency_filter( give_format_amount( $income ) ) ) . '</span>', |
|
1252 | - '<span class="goal-text">' . apply_filters( 'give_goal_amount_target_output', give_currency_filter( give_format_amount( $goal ) ) ) . '</span>' |
|
1250 | + esc_html__('%1$s of %2$s raised', 'give'), |
|
1251 | + '<span class="income">'.apply_filters('give_goal_amount_raised_output', give_currency_filter(give_format_amount($income))).'</span>', |
|
1252 | + '<span class="goal-text">'.apply_filters('give_goal_amount_target_output', give_currency_filter(give_format_amount($goal))).'</span>' |
|
1253 | 1253 | ); |
1254 | 1254 | |
1255 | - } elseif ( $goal_format == 'percentage' ) { |
|
1255 | + } elseif ($goal_format == 'percentage') { |
|
1256 | 1256 | |
1257 | 1257 | $output .= sprintf( |
1258 | 1258 | /* translators: %s: percentage of the amount raised compared to the goal target */ |
1259 | - esc_html__( '%s%% funded', 'give' ), |
|
1260 | - '<span class="give-percentage">' . apply_filters( 'give_goal_amount_funded_percentage_output', round( $progress ) ) . '</span>' |
|
1259 | + esc_html__('%s%% funded', 'give'), |
|
1260 | + '<span class="give-percentage">'.apply_filters('give_goal_amount_funded_percentage_output', round($progress)).'</span>' |
|
1261 | 1261 | ); |
1262 | 1262 | |
1263 | 1263 | } |
@@ -1267,11 +1267,11 @@ discard block |
||
1267 | 1267 | } |
1268 | 1268 | |
1269 | 1269 | //Goal Progress Bar |
1270 | - if ( ! empty( $show_bar ) ) { |
|
1270 | + if ( ! empty($show_bar)) { |
|
1271 | 1271 | $output .= '<div class="give-progress-bar">'; |
1272 | - $output .= '<span style="width: ' . esc_attr__( $progress ) . '%;'; |
|
1273 | - if ( ! empty( $color ) ) { |
|
1274 | - $output .= 'background-color:' . $color; |
|
1272 | + $output .= '<span style="width: '.esc_attr__($progress).'%;'; |
|
1273 | + if ( ! empty($color)) { |
|
1274 | + $output .= 'background-color:'.$color; |
|
1275 | 1275 | } |
1276 | 1276 | $output .= '"></span>'; |
1277 | 1277 | $output .= '</div><!-- /.give-progress-bar -->'; |
@@ -1279,13 +1279,13 @@ discard block |
||
1279 | 1279 | |
1280 | 1280 | $output .= '</div><!-- /.goal-progress -->'; |
1281 | 1281 | |
1282 | - echo apply_filters( 'give_goal_output', $output ); |
|
1282 | + echo apply_filters('give_goal_output', $output); |
|
1283 | 1283 | |
1284 | 1284 | return false; |
1285 | 1285 | |
1286 | 1286 | } |
1287 | 1287 | |
1288 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
1288 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
1289 | 1289 | |
1290 | 1290 | /** |
1291 | 1291 | * Adds Actions to Render Form Content |
@@ -1297,19 +1297,19 @@ discard block |
||
1297 | 1297 | * |
1298 | 1298 | * @return void |
1299 | 1299 | */ |
1300 | -function give_form_content( $form_id, $args ) { |
|
1300 | +function give_form_content($form_id, $args) { |
|
1301 | 1301 | |
1302 | - $show_content = ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) |
|
1302 | + $show_content = (isset($args['show_content']) && ! empty($args['show_content'])) |
|
1303 | 1303 | ? $args['show_content'] |
1304 | - : get_post_meta( $form_id, '_give_content_option', true ); |
|
1304 | + : get_post_meta($form_id, '_give_content_option', true); |
|
1305 | 1305 | |
1306 | - if ( $show_content !== 'none' ) { |
|
1306 | + if ($show_content !== 'none') { |
|
1307 | 1307 | //add action according to value |
1308 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
1308 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
1309 | 1309 | } |
1310 | 1310 | } |
1311 | 1311 | |
1312 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
1312 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
1313 | 1313 | |
1314 | 1314 | /** |
1315 | 1315 | * Renders Post Form Content |
@@ -1321,24 +1321,24 @@ discard block |
||
1321 | 1321 | * @return void |
1322 | 1322 | * @since 1.0 |
1323 | 1323 | */ |
1324 | -function give_form_display_content( $form_id, $args ) { |
|
1324 | +function give_form_display_content($form_id, $args) { |
|
1325 | 1325 | |
1326 | - $content = wpautop( get_post_meta( $form_id, '_give_form_content', true ) ); |
|
1327 | - $show_content = ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) |
|
1326 | + $content = wpautop(get_post_meta($form_id, '_give_form_content', true)); |
|
1327 | + $show_content = (isset($args['show_content']) && ! empty($args['show_content'])) |
|
1328 | 1328 | ? $args['show_content'] |
1329 | - : get_post_meta( $form_id, '_give_content_option', true ); |
|
1329 | + : get_post_meta($form_id, '_give_content_option', true); |
|
1330 | 1330 | |
1331 | - if ( give_get_option( 'disable_the_content_filter' ) !== 'on' ) { |
|
1332 | - $content = apply_filters( 'the_content', $content ); |
|
1331 | + if (give_get_option('disable_the_content_filter') !== 'on') { |
|
1332 | + $content = apply_filters('the_content', $content); |
|
1333 | 1333 | } |
1334 | 1334 | |
1335 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap" >' . $content . '</div>'; |
|
1335 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap" >'.$content.'</div>'; |
|
1336 | 1336 | |
1337 | - echo apply_filters( 'give_form_content_output', $output ); |
|
1337 | + echo apply_filters('give_form_content_output', $output); |
|
1338 | 1338 | |
1339 | 1339 | //remove action to prevent content output on addition forms on page |
1340 | 1340 | //@see: https://github.com/WordImpress/Give/issues/634 |
1341 | - remove_action( $show_content, 'give_form_display_content' ); |
|
1341 | + remove_action($show_content, 'give_form_display_content'); |
|
1342 | 1342 | } |
1343 | 1343 | |
1344 | 1344 | |
@@ -1351,16 +1351,16 @@ discard block |
||
1351 | 1351 | * |
1352 | 1352 | * @return void |
1353 | 1353 | */ |
1354 | -function give_checkout_hidden_fields( $form_id ) { |
|
1354 | +function give_checkout_hidden_fields($form_id) { |
|
1355 | 1355 | |
1356 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
1357 | - if ( is_user_logged_in() ) { ?> |
|
1356 | + do_action('give_hidden_fields_before', $form_id); |
|
1357 | + if (is_user_logged_in()) { ?> |
|
1358 | 1358 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
1359 | 1359 | <?php } ?> |
1360 | 1360 | <input type="hidden" name="give_action" value="purchase"/> |
1361 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
1361 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
1362 | 1362 | <?php |
1363 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
1363 | + do_action('give_hidden_fields_after', $form_id); |
|
1364 | 1364 | |
1365 | 1365 | } |
1366 | 1366 | |
@@ -1375,20 +1375,20 @@ discard block |
||
1375 | 1375 | * |
1376 | 1376 | * @return string $content Filtered content |
1377 | 1377 | */ |
1378 | -function give_filter_success_page_content( $content ) { |
|
1378 | +function give_filter_success_page_content($content) { |
|
1379 | 1379 | |
1380 | 1380 | global $give_options; |
1381 | 1381 | |
1382 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
1383 | - if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
1384 | - $content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
1382 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
1383 | + if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) { |
|
1384 | + $content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content); |
|
1385 | 1385 | } |
1386 | 1386 | } |
1387 | 1387 | |
1388 | 1388 | return $content; |
1389 | 1389 | } |
1390 | 1390 | |
1391 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
1391 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
1392 | 1392 | |
1393 | 1393 | |
1394 | 1394 | /** |
@@ -1400,14 +1400,14 @@ discard block |
||
1400 | 1400 | |
1401 | 1401 | function give_test_mode_frontend_warning() { |
1402 | 1402 | |
1403 | - $test_mode = give_get_option( 'test_mode' ); |
|
1403 | + $test_mode = give_get_option('test_mode'); |
|
1404 | 1404 | |
1405 | - if ( $test_mode == 'on' ) { |
|
1406 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice', 'give' ) . '</strong>: ' . esc_html__( 'Test mode is enabled. While in test mode no live transactions are processed.', 'give' ) . '</p></div>'; |
|
1405 | + if ($test_mode == 'on') { |
|
1406 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice', 'give').'</strong>: '.esc_html__('Test mode is enabled. While in test mode no live transactions are processed.', 'give').'</p></div>'; |
|
1407 | 1407 | } |
1408 | 1408 | } |
1409 | 1409 | |
1410 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
1410 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
1411 | 1411 | |
1412 | 1412 | |
1413 | 1413 | /** |
@@ -1417,21 +1417,21 @@ discard block |
||
1417 | 1417 | * @since 1.4.1 |
1418 | 1418 | */ |
1419 | 1419 | |
1420 | -function give_members_only_form( $final_output, $args ) { |
|
1420 | +function give_members_only_form($final_output, $args) { |
|
1421 | 1421 | |
1422 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
1422 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
1423 | 1423 | |
1424 | 1424 | //Sanity Check: Must have form_id & not be logged in |
1425 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
1425 | + if (empty($form_id) || is_user_logged_in()) { |
|
1426 | 1426 | return $final_output; |
1427 | 1427 | } |
1428 | 1428 | |
1429 | 1429 | //Logged in only and Register / Login set to none |
1430 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
1430 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
1431 | 1431 | |
1432 | - $final_output = give_output_error( esc_html__( 'Please login in order to complete your donation.', 'give' ), false ); |
|
1432 | + $final_output = give_output_error(esc_html__('Please login in order to complete your donation.', 'give'), false); |
|
1433 | 1433 | |
1434 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
1434 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
1435 | 1435 | |
1436 | 1436 | } |
1437 | 1437 | |
@@ -1439,4 +1439,4 @@ discard block |
||
1439 | 1439 | |
1440 | 1440 | } |
1441 | 1441 | |
1442 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
1442 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function __construct() { |
32 | 32 | // Create the log post type |
33 | - add_action( 'init', array( $this, 'register_post_type' ), 1 ); |
|
33 | + add_action('init', array($this, 'register_post_type'), 1); |
|
34 | 34 | |
35 | 35 | // Create types taxonomy and default types |
36 | - add_action( 'init', array( $this, 'register_taxonomy' ), 1 ); |
|
36 | + add_action('init', array($this, 'register_taxonomy'), 1); |
|
37 | 37 | |
38 | 38 | } |
39 | 39 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function register_post_type() { |
48 | 48 | /* Logs post type */ |
49 | 49 | $log_args = array( |
50 | - 'labels' => array( 'name' => esc_html__( 'Logs', 'give' ) ), |
|
50 | + 'labels' => array('name' => esc_html__('Logs', 'give')), |
|
51 | 51 | 'public' => false, |
52 | 52 | 'exclude_from_search' => true, |
53 | 53 | 'publicly_queryable' => false, |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | 'query_var' => false, |
56 | 56 | 'rewrite' => false, |
57 | 57 | 'capability_type' => 'post', |
58 | - 'supports' => array( 'title', 'editor' ), |
|
58 | + 'supports' => array('title', 'editor'), |
|
59 | 59 | 'can_export' => true |
60 | 60 | ); |
61 | 61 | |
62 | - register_post_type( 'give_log', $log_args ); |
|
62 | + register_post_type('give_log', $log_args); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @return void |
73 | 73 | */ |
74 | 74 | public function register_taxonomy() { |
75 | - register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) ); |
|
75 | + register_taxonomy('give_log_type', 'give_log', array('public' => false)); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | 'api_request' |
92 | 92 | ); |
93 | 93 | |
94 | - return apply_filters( 'give_log_types', $terms ); |
|
94 | + return apply_filters('give_log_types', $terms); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return bool Whether log type is valid |
109 | 109 | */ |
110 | - function valid_type( $type ) { |
|
111 | - return in_array( $type, $this->log_types() ); |
|
110 | + function valid_type($type) { |
|
111 | + return in_array($type, $this->log_types()); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return int Log ID |
130 | 130 | */ |
131 | - public function add( $title = '', $message = '', $parent = 0, $type = null ) { |
|
131 | + public function add($title = '', $message = '', $parent = 0, $type = null) { |
|
132 | 132 | $log_data = array( |
133 | 133 | 'post_title' => $title, |
134 | 134 | 'post_content' => $message, |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | 'log_type' => $type |
137 | 137 | ); |
138 | 138 | |
139 | - return $this->insert_log( $log_data ); |
|
139 | + return $this->insert_log($log_data); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return array Array of the connected logs |
154 | 154 | */ |
155 | - public function get_logs( $object_id = 0, $type = null, $paged = null ) { |
|
156 | - return $this->get_connected_logs( array( |
|
155 | + public function get_logs($object_id = 0, $type = null, $paged = null) { |
|
156 | + return $this->get_connected_logs(array( |
|
157 | 157 | 'post_parent' => $object_id, |
158 | 158 | 'paged' => $paged, |
159 | 159 | 'log_type' => $type |
160 | - ) ); |
|
160 | + )); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return int The ID of the newly created log item |
174 | 174 | */ |
175 | - function insert_log( $log_data = array(), $log_meta = array() ) { |
|
175 | + function insert_log($log_data = array(), $log_meta = array()) { |
|
176 | 176 | $defaults = array( |
177 | 177 | 'post_type' => 'give_log', |
178 | 178 | 'post_status' => 'publish', |
@@ -181,26 +181,26 @@ discard block |
||
181 | 181 | 'log_type' => false |
182 | 182 | ); |
183 | 183 | |
184 | - $args = wp_parse_args( $log_data, $defaults ); |
|
184 | + $args = wp_parse_args($log_data, $defaults); |
|
185 | 185 | |
186 | - do_action( 'give_pre_insert_log', $log_data, $log_meta ); |
|
186 | + do_action('give_pre_insert_log', $log_data, $log_meta); |
|
187 | 187 | |
188 | 188 | // Store the log entry |
189 | - $log_id = wp_insert_post( $args ); |
|
189 | + $log_id = wp_insert_post($args); |
|
190 | 190 | |
191 | 191 | // Set the log type, if any |
192 | - if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) { |
|
193 | - wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false ); |
|
192 | + if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) { |
|
193 | + wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | // Set log meta, if any |
197 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
198 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
199 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
197 | + if ($log_id && ! empty($log_meta)) { |
|
198 | + foreach ((array) $log_meta as $key => $meta) { |
|
199 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | - do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta ); |
|
203 | + do_action('give_post_insert_log', $log_id, $log_data, $log_meta); |
|
204 | 204 | |
205 | 205 | return $log_id; |
206 | 206 | } |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return bool True if successful, false otherwise |
218 | 218 | */ |
219 | - public function update_log( $log_data = array(), $log_meta = array() ) { |
|
219 | + public function update_log($log_data = array(), $log_meta = array()) { |
|
220 | 220 | |
221 | - do_action( 'give_pre_update_log', $log_data, $log_meta ); |
|
221 | + do_action('give_pre_update_log', $log_data, $log_meta); |
|
222 | 222 | |
223 | 223 | $defaults = array( |
224 | 224 | 'post_type' => 'give_log', |
@@ -226,20 +226,20 @@ discard block |
||
226 | 226 | 'post_parent' => 0 |
227 | 227 | ); |
228 | 228 | |
229 | - $args = wp_parse_args( $log_data, $defaults ); |
|
229 | + $args = wp_parse_args($log_data, $defaults); |
|
230 | 230 | |
231 | 231 | // Store the log entry |
232 | - $log_id = wp_update_post( $args ); |
|
232 | + $log_id = wp_update_post($args); |
|
233 | 233 | |
234 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
235 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
236 | - if ( ! empty( $meta ) ) { |
|
237 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
234 | + if ($log_id && ! empty($log_meta)) { |
|
235 | + foreach ((array) $log_meta as $key => $meta) { |
|
236 | + if ( ! empty($meta)) { |
|
237 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
242 | - do_action( 'give_post_update_log', $log_id, $log_data, $log_meta ); |
|
242 | + do_action('give_post_update_log', $log_id, $log_data, $log_meta); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -254,19 +254,19 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return mixed array if logs were found, false otherwise |
256 | 256 | */ |
257 | - public function get_connected_logs( $args = array() ) { |
|
257 | + public function get_connected_logs($args = array()) { |
|
258 | 258 | |
259 | 259 | $defaults = array( |
260 | 260 | 'post_type' => 'give_log', |
261 | 261 | 'posts_per_page' => 20, |
262 | 262 | 'post_status' => 'publish', |
263 | - 'paged' => get_query_var( 'paged' ), |
|
263 | + 'paged' => get_query_var('paged'), |
|
264 | 264 | 'log_type' => false |
265 | 265 | ); |
266 | 266 | |
267 | - $query_args = wp_parse_args( $args, $defaults ); |
|
267 | + $query_args = wp_parse_args($args, $defaults); |
|
268 | 268 | |
269 | - if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) { |
|
269 | + if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) { |
|
270 | 270 | $query_args['tax_query'] = array( |
271 | 271 | array( |
272 | 272 | 'taxonomy' => 'give_log_type', |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | ); |
277 | 277 | } |
278 | 278 | |
279 | - $logs = get_posts( $query_args ); |
|
279 | + $logs = get_posts($query_args); |
|
280 | 280 | |
281 | - if ( $logs ) { |
|
281 | + if ($logs) { |
|
282 | 282 | return $logs; |
283 | 283 | } |
284 | 284 | |
@@ -299,17 +299,17 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @return int Log count |
301 | 301 | */ |
302 | - public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) { |
|
302 | + public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) { |
|
303 | 303 | |
304 | 304 | $query_args = array( |
305 | 305 | 'post_parent' => $object_id, |
306 | 306 | 'post_type' => 'give_log', |
307 | - 'posts_per_page' => - 1, |
|
307 | + 'posts_per_page' => -1, |
|
308 | 308 | 'post_status' => 'publish', |
309 | 309 | 'fields' => 'ids', |
310 | 310 | ); |
311 | 311 | |
312 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
312 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
313 | 313 | $query_args['tax_query'] = array( |
314 | 314 | array( |
315 | 315 | 'taxonomy' => 'give_log_type', |
@@ -319,15 +319,15 @@ discard block |
||
319 | 319 | ); |
320 | 320 | } |
321 | 321 | |
322 | - if ( ! empty( $meta_query ) ) { |
|
322 | + if ( ! empty($meta_query)) { |
|
323 | 323 | $query_args['meta_query'] = $meta_query; |
324 | 324 | } |
325 | 325 | |
326 | - if ( ! empty( $date_query ) ) { |
|
326 | + if ( ! empty($date_query)) { |
|
327 | 327 | $query_args['date_query'] = $date_query; |
328 | 328 | } |
329 | 329 | |
330 | - $logs = new WP_Query( $query_args ); |
|
330 | + $logs = new WP_Query($query_args); |
|
331 | 331 | |
332 | 332 | return (int) $logs->post_count; |
333 | 333 | } |
@@ -345,16 +345,16 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return void |
347 | 347 | */ |
348 | - public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) { |
|
348 | + public function delete_logs($object_id = 0, $type = null, $meta_query = null) { |
|
349 | 349 | $query_args = array( |
350 | 350 | 'post_parent' => $object_id, |
351 | 351 | 'post_type' => 'give_log', |
352 | - 'posts_per_page' => - 1, |
|
352 | + 'posts_per_page' => -1, |
|
353 | 353 | 'post_status' => 'publish', |
354 | 354 | 'fields' => 'ids' |
355 | 355 | ); |
356 | 356 | |
357 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
357 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
358 | 358 | $query_args['tax_query'] = array( |
359 | 359 | array( |
360 | 360 | 'taxonomy' => 'give_log_type', |
@@ -364,15 +364,15 @@ discard block |
||
364 | 364 | ); |
365 | 365 | } |
366 | 366 | |
367 | - if ( ! empty( $meta_query ) ) { |
|
367 | + if ( ! empty($meta_query)) { |
|
368 | 368 | $query_args['meta_query'] = $meta_query; |
369 | 369 | } |
370 | 370 | |
371 | - $logs = get_posts( $query_args ); |
|
371 | + $logs = get_posts($query_args); |
|
372 | 372 | |
373 | - if ( $logs ) { |
|
374 | - foreach ( $logs as $log ) { |
|
375 | - wp_delete_post( $log, true ); |
|
373 | + if ($logs) { |
|
374 | + foreach ($logs as $log) { |
|
375 | + wp_delete_post($log, true); |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | } |
@@ -400,9 +400,9 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return mixed ID of the new log entry |
402 | 402 | */ |
403 | -function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
|
403 | +function give_record_log($title = '', $message = '', $parent = 0, $type = null) { |
|
404 | 404 | global $give_logs; |
405 | - $log = $give_logs->add( $title, $message, $parent, $type ); |
|
405 | + $log = $give_logs->add($title, $message, $parent, $type); |
|
406 | 406 | |
407 | 407 | return $log; |
408 | 408 | } |
409 | 409 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,17 +24,17 @@ discard block |
||
24 | 24 | // Default, built-in gateways |
25 | 25 | $gateways = array( |
26 | 26 | 'paypal' => array( |
27 | - 'admin_label' => esc_html__( 'PayPal Standard', 'give' ), |
|
28 | - 'checkout_label' => esc_html__( 'PayPal', 'give' ), |
|
29 | - 'supports' => array( 'buy_now' ) |
|
27 | + 'admin_label' => esc_html__('PayPal Standard', 'give'), |
|
28 | + 'checkout_label' => esc_html__('PayPal', 'give'), |
|
29 | + 'supports' => array('buy_now') |
|
30 | 30 | ), |
31 | 31 | 'manual' => array( |
32 | - 'admin_label' => esc_html__( 'Test Payment', 'give' ), |
|
33 | - 'checkout_label' => esc_html__( 'Test Payment', 'give' ) |
|
32 | + 'admin_label' => esc_html__('Test Payment', 'give'), |
|
33 | + 'checkout_label' => esc_html__('Test Payment', 'give') |
|
34 | 34 | ), |
35 | 35 | ); |
36 | 36 | |
37 | - return apply_filters( 'give_payment_gateways', $gateways ); |
|
37 | + return apply_filters('give_payment_gateways', $gateways); |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
@@ -48,20 +48,20 @@ discard block |
||
48 | 48 | |
49 | 49 | $gateways = give_get_payment_gateways(); |
50 | 50 | |
51 | - $enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
51 | + $enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
52 | 52 | |
53 | 53 | $gateway_list = array(); |
54 | 54 | |
55 | - foreach ( $gateways as $key => $gateway ) { |
|
56 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
57 | - $gateway_list[ $key ] = $gateway; |
|
55 | + foreach ($gateways as $key => $gateway) { |
|
56 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
57 | + $gateway_list[$key] = $gateway; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | 61 | // Set order of payment gateway in list. |
62 | - $gateway_list = give_get_ordered_payment_gateways( $gateway_list ); |
|
62 | + $gateway_list = give_get_ordered_payment_gateways($gateway_list); |
|
63 | 63 | |
64 | - return apply_filters( 'give_enabled_payment_gateways', $gateway_list ); |
|
64 | + return apply_filters('give_enabled_payment_gateways', $gateway_list); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return boolean true if enabled, false otherwise |
75 | 75 | */ |
76 | -function give_is_gateway_active( $gateway ) { |
|
76 | +function give_is_gateway_active($gateway) { |
|
77 | 77 | $gateways = give_get_enabled_payment_gateways(); |
78 | 78 | |
79 | - $ret = array_key_exists( $gateway, $gateways ); |
|
79 | + $ret = array_key_exists($gateway, $gateways); |
|
80 | 80 | |
81 | - return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways ); |
|
81 | + return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -91,24 +91,24 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return string Gateway ID |
93 | 93 | */ |
94 | -function give_get_default_gateway( $form_id ) { |
|
94 | +function give_get_default_gateway($form_id) { |
|
95 | 95 | |
96 | 96 | global $give_options; |
97 | 97 | |
98 | - $default = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal'; |
|
99 | - $form_default = get_post_meta( $form_id, '_give_default_gateway', true ); |
|
98 | + $default = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal'; |
|
99 | + $form_default = get_post_meta($form_id, '_give_default_gateway', true); |
|
100 | 100 | |
101 | 101 | //Single Form settings varies compared to the Global default settings |
102 | - if ( ! empty( $form_default ) && |
|
102 | + if ( ! empty($form_default) && |
|
103 | 103 | $form_id !== null && |
104 | 104 | $default !== $form_default && |
105 | 105 | $form_default !== 'global' && |
106 | - give_is_gateway_active( $form_default ) |
|
106 | + give_is_gateway_active($form_default) |
|
107 | 107 | ) { |
108 | 108 | $default = $form_default; |
109 | 109 | } |
110 | 110 | |
111 | - return apply_filters( 'give_default_gateway', $default ); |
|
111 | + return apply_filters('give_default_gateway', $default); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,18 +120,18 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string Gateway admin label |
122 | 122 | */ |
123 | -function give_get_gateway_admin_label( $gateway ) { |
|
123 | +function give_get_gateway_admin_label($gateway) { |
|
124 | 124 | $gateways = give_get_enabled_payment_gateways(); |
125 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
126 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
125 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
126 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
127 | 127 | |
128 | - if ( $gateway == 'manual' && $payment ) { |
|
129 | - if ( give_get_payment_amount( $payment ) == 0 ) { |
|
130 | - $label = esc_html__( 'Test Donation', 'give' ); |
|
128 | + if ($gateway == 'manual' && $payment) { |
|
129 | + if (give_get_payment_amount($payment) == 0) { |
|
130 | + $label = esc_html__('Test Donation', 'give'); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( 'give_gateway_admin_label', $label, $gateway ); |
|
134 | + return apply_filters('give_gateway_admin_label', $label, $gateway); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return string Checkout label for the gateway |
145 | 145 | */ |
146 | -function give_get_gateway_checkout_label( $gateway ) { |
|
146 | +function give_get_gateway_checkout_label($gateway) { |
|
147 | 147 | $gateways = give_get_enabled_payment_gateways(); |
148 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
148 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
149 | 149 | |
150 | - if ( $gateway == 'manual' ) { |
|
151 | - $label = esc_html__( 'Test Donation', 'give' ); |
|
150 | + if ($gateway == 'manual') { |
|
151 | + $label = esc_html__('Test Donation', 'give'); |
|
152 | 152 | } |
153 | 153 | |
154 | - return apply_filters( 'give_gateway_checkout_label', $label, $gateway ); |
|
154 | + return apply_filters('give_gateway_checkout_label', $label, $gateway); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array Options the gateway supports |
165 | 165 | */ |
166 | -function give_get_gateway_supports( $gateway ) { |
|
166 | +function give_get_gateway_supports($gateway) { |
|
167 | 167 | $gateways = give_get_enabled_payment_gateways(); |
168 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
168 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
169 | 169 | |
170 | - return apply_filters( 'give_gateway_supports', $supports, $gateway ); |
|
170 | + return apply_filters('give_gateway_supports', $supports, $gateway); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return bool |
181 | 181 | */ |
182 | -function give_gateway_supports_buy_now( $gateway ) { |
|
183 | - $supports = give_get_gateway_supports( $gateway ); |
|
184 | - $ret = in_array( 'buy_now', $supports ); |
|
182 | +function give_gateway_supports_buy_now($gateway) { |
|
183 | + $supports = give_get_gateway_supports($gateway); |
|
184 | + $ret = in_array('buy_now', $supports); |
|
185 | 185 | |
186 | - return apply_filters( 'give_gateway_supports_buy_now', $ret, $gateway ); |
|
186 | + return apply_filters('give_gateway_supports_buy_now', $ret, $gateway); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -196,16 +196,16 @@ discard block |
||
196 | 196 | $gateways = give_get_enabled_payment_gateways(); |
197 | 197 | $ret = false; |
198 | 198 | |
199 | - if ( $gateways ) { |
|
200 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
201 | - if ( give_gateway_supports_buy_now( $gateway_id ) ) { |
|
199 | + if ($gateways) { |
|
200 | + foreach ($gateways as $gateway_id => $gateway) { |
|
201 | + if (give_gateway_supports_buy_now($gateway_id)) { |
|
202 | 202 | $ret = true; |
203 | 203 | break; |
204 | 204 | } |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | - return apply_filters( 'give_give_supports_buy_now', $ret ); |
|
208 | + return apply_filters('give_give_supports_buy_now', $ret); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return void |
220 | 220 | */ |
221 | -function give_send_to_gateway( $gateway, $payment_data ) { |
|
221 | +function give_send_to_gateway($gateway, $payment_data) { |
|
222 | 222 | |
223 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' ); |
|
223 | + $payment_data['gateway_nonce'] = wp_create_nonce('give-gateway'); |
|
224 | 224 | |
225 | 225 | // $gateway must match the ID used when registering the gateway |
226 | - do_action( 'give_gateway_' . $gateway, $payment_data ); |
|
226 | + do_action('give_gateway_'.$gateway, $payment_data); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
@@ -240,32 +240,32 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return string $enabled_gateway The slug of the gateway |
242 | 242 | */ |
243 | -function give_get_chosen_gateway( $form_id ) { |
|
243 | +function give_get_chosen_gateway($form_id) { |
|
244 | 244 | $gateways = give_get_enabled_payment_gateways(); |
245 | - $request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0; |
|
246 | - if ( empty( $request_form_id ) ) { |
|
247 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0; |
|
245 | + $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0; |
|
246 | + if (empty($request_form_id)) { |
|
247 | + $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0; |
|
248 | 248 | } |
249 | - $chosen = give_get_default_gateway( $form_id ); |
|
249 | + $chosen = give_get_default_gateway($form_id); |
|
250 | 250 | $enabled_gateway = ''; |
251 | 251 | |
252 | 252 | //Take into account request Form ID args |
253 | - if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) { |
|
253 | + if ( ! empty($request_form_id) && $form_id == $request_form_id) { |
|
254 | 254 | $chosen = $_REQUEST['payment-mode']; |
255 | 255 | } |
256 | 256 | |
257 | - if ( $chosen ) { |
|
258 | - $enabled_gateway = urldecode( $chosen ); |
|
259 | - } else if ( count( $gateways ) >= 1 && ! $chosen ) { |
|
260 | - foreach ( $gateways as $gateway_id => $gateway ): |
|
257 | + if ($chosen) { |
|
258 | + $enabled_gateway = urldecode($chosen); |
|
259 | + } else if (count($gateways) >= 1 && ! $chosen) { |
|
260 | + foreach ($gateways as $gateway_id => $gateway): |
|
261 | 261 | $enabled_gateway = $gateway_id; |
262 | 262 | endforeach; |
263 | 263 | } else { |
264 | - $enabled_gateway = give_get_default_gateway( $form_id ); |
|
264 | + $enabled_gateway = give_get_default_gateway($form_id); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
268 | - return apply_filters( 'give_chosen_gateway', $enabled_gateway ); |
|
268 | + return apply_filters('give_chosen_gateway', $enabled_gateway); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return int ID of the new log entry |
284 | 284 | */ |
285 | -function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
286 | - return give_record_log( $title, $message, $parent, 'gateway_error' ); |
|
285 | +function give_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
286 | + return give_record_log($title, $message, $parent, 'gateway_error'); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return int |
298 | 298 | */ |
299 | -function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
299 | +function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
300 | 300 | |
301 | 301 | $ret = 0; |
302 | 302 | $args = array( |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | 'fields' => 'ids' |
309 | 309 | ); |
310 | 310 | |
311 | - $payments = new WP_Query( $args ); |
|
311 | + $payments = new WP_Query($args); |
|
312 | 312 | |
313 | - if ( $payments ) { |
|
313 | + if ($payments) { |
|
314 | 314 | $ret = $payments->post_count; |
315 | 315 | } |
316 | 316 | |
@@ -327,27 +327,27 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return array $gateways All the available gateways |
329 | 329 | */ |
330 | -function give_get_ordered_payment_gateways( $gateways ) { |
|
330 | +function give_get_ordered_payment_gateways($gateways) { |
|
331 | 331 | |
332 | 332 | // Get gateways setting. |
333 | - $gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
333 | + $gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
334 | 334 | |
335 | 335 | // Return from here if we do not have gateways setting. |
336 | - if ( empty( $gateways_setting ) ) { |
|
336 | + if (empty($gateways_setting)) { |
|
337 | 337 | return $gateways; |
338 | 338 | } |
339 | 339 | |
340 | 340 | // Reverse array to order payment gateways. |
341 | - $gateways_setting = array_reverse( $gateways_setting ); |
|
341 | + $gateways_setting = array_reverse($gateways_setting); |
|
342 | 342 | |
343 | 343 | // Reorder gateways array |
344 | - foreach ( $gateways_setting as $gateway_key => $value ) { |
|
344 | + foreach ($gateways_setting as $gateway_key => $value) { |
|
345 | 345 | |
346 | - $new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : ''; |
|
347 | - unset( $gateways[ $gateway_key ] ); |
|
346 | + $new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : ''; |
|
347 | + unset($gateways[$gateway_key]); |
|
348 | 348 | |
349 | - if(!empty($new_gateway_value)) { |
|
350 | - $gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways ); |
|
349 | + if ( ! empty($new_gateway_value)) { |
|
350 | + $gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways); |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
@@ -358,5 +358,5 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @param array $gateways All the available gateways |
360 | 360 | */ |
361 | - return apply_filters( 'give_payment_gateways_order', $gateways ); |
|
361 | + return apply_filters('give_payment_gateways_order', $gateways); |
|
362 | 362 | } |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | - 'admin_label' => esc_html__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_html__( 'Offline Donation', 'give' ) |
|
24 | + 'admin_label' => esc_html__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_html__('Offline Donation', 'give') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,56 +40,56 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | -function give_offline_payment_cc_form( $form_id ) { |
|
43 | +function give_offline_payment_cc_form($form_id) { |
|
44 | 44 | |
45 | - $post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
46 | - $post_offline_instructions = get_post_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
47 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
45 | + $post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
46 | + $post_offline_instructions = get_post_meta($form_id, '_give_offline_checkout_notes', true); |
|
47 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
48 | 48 | $offline_instructions = $global_offline_instruction; |
49 | 49 | |
50 | - if ( $post_offline_customization_option == 'yes' ) { |
|
50 | + if ($post_offline_customization_option == 'yes') { |
|
51 | 51 | $offline_instructions = $post_offline_instructions; |
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | ob_start(); ?> |
56 | - <?php do_action( 'give_before_offline_info_fields', $form_id ); ?> |
|
56 | + <?php do_action('give_before_offline_info_fields', $form_id); ?> |
|
57 | 57 | <fieldset id="give_offline_payment_info"> |
58 | 58 | <?php |
59 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
59 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
60 | 60 | /* translators: %s: form settings url */ |
61 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( esc_html__( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
62 | - echo wpautop( stripslashes( $offline_instructions ) ); |
|
61 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(esc_html__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
62 | + echo wpautop(stripslashes($offline_instructions)); |
|
63 | 63 | ?> |
64 | 64 | </fieldset> |
65 | - <?php do_action( 'give_after_offline_info_fields', $form_id ); ?> |
|
65 | + <?php do_action('give_after_offline_info_fields', $form_id); ?> |
|
66 | 66 | <?php |
67 | 67 | echo ob_get_clean(); |
68 | 68 | } |
69 | 69 | |
70 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
70 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Give Offline Billing Field |
74 | 74 | * |
75 | 75 | * @param $form_id |
76 | 76 | */ |
77 | -function give_offline_billing_fields( $form_id ) { |
|
77 | +function give_offline_billing_fields($form_id) { |
|
78 | 78 | //Enable Default CC fields (billing info) |
79 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
80 | - $post_offline_customize_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
79 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
80 | + $post_offline_customize_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
81 | 81 | |
82 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
82 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
83 | 83 | |
84 | 84 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
85 | - if ( $global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes' ) { |
|
86 | - give_default_cc_address_fields( $form_id ); |
|
87 | - } elseif($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
88 | - give_default_cc_address_fields( $form_id ); |
|
85 | + if ($global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes') { |
|
86 | + give_default_cc_address_fields($form_id); |
|
87 | + } elseif ($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
88 | + give_default_cc_address_fields($form_id); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
92 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Process the payment |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return void |
102 | 102 | */ |
103 | -function give_offline_process_payment( $purchase_data ) { |
|
103 | +function give_offline_process_payment($purchase_data) { |
|
104 | 104 | |
105 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
105 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
106 | 106 | |
107 | 107 | // setup the payment details |
108 | 108 | $payment_data = array( |
109 | 109 | 'price' => $purchase_data['price'], |
110 | 110 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
111 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
112 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
111 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
112 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
113 | 113 | 'date' => $purchase_data['date'], |
114 | 114 | 'user_email' => $purchase_data['user_email'], |
115 | 115 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -121,20 +121,20 @@ discard block |
||
121 | 121 | |
122 | 122 | |
123 | 123 | // record the pending payment |
124 | - $payment = give_insert_payment( $payment_data ); |
|
124 | + $payment = give_insert_payment($payment_data); |
|
125 | 125 | |
126 | - if ( $payment ) { |
|
127 | - give_offline_send_admin_notice( $payment ); |
|
128 | - give_offline_send_donor_instructions( $payment ); |
|
126 | + if ($payment) { |
|
127 | + give_offline_send_admin_notice($payment); |
|
128 | + give_offline_send_donor_instructions($payment); |
|
129 | 129 | give_send_to_success_page(); |
130 | 130 | } else { |
131 | 131 | // if errors are present, send the user back to the donation form so they can be corrected |
132 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
132 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
137 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
138 | 138 | |
139 | 139 | |
140 | 140 | /** |
@@ -147,47 +147,47 @@ discard block |
||
147 | 147 | * @since 1.0 |
148 | 148 | * @return void |
149 | 149 | */ |
150 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
150 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
151 | 151 | |
152 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
153 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
152 | + $payment_data = give_get_payment_meta($payment_id); |
|
153 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
154 | 154 | |
155 | 155 | //Customize email content depending on whether the single form has been customized |
156 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
156 | + $email_content = give_get_option('global_offline_donation_email'); |
|
157 | 157 | |
158 | - if ( $post_offline_customization_option === 'yes' ) { |
|
159 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
158 | + if ($post_offline_customization_option === 'yes') { |
|
159 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
160 | 160 | } |
161 | 161 | |
162 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
163 | - $from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data ); |
|
162 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
163 | + $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data); |
|
164 | 164 | |
165 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
166 | - $from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data ); |
|
165 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
166 | + $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data); |
|
167 | 167 | |
168 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
168 | + $to_email = give_get_payment_user_email($payment_id); |
|
169 | 169 | |
170 | - $subject = give_get_option( 'offline_donation_subject', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
171 | - if ( $post_offline_customization_option === 'yes' ) { |
|
172 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
170 | + $subject = give_get_option('offline_donation_subject', esc_html__('Offline Donation Instructions', 'give')); |
|
171 | + if ($post_offline_customization_option === 'yes') { |
|
172 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
173 | 173 | } |
174 | 174 | |
175 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
176 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
175 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
176 | + $subject = give_do_email_tags($subject, $payment_id); |
|
177 | 177 | |
178 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
179 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
178 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
179 | + $message = give_do_email_tags($email_content, $payment_id); |
|
180 | 180 | |
181 | 181 | $emails = Give()->emails; |
182 | 182 | |
183 | - $emails->__set( 'from_name', $from_name ); |
|
184 | - $emails->__set( 'from_email', $from_email ); |
|
185 | - $emails->__set( 'heading', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
183 | + $emails->__set('from_name', $from_name); |
|
184 | + $emails->__set('from_email', $from_email); |
|
185 | + $emails->__set('heading', esc_html__('Offline Donation Instructions', 'give')); |
|
186 | 186 | |
187 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
188 | - $emails->__set( 'headers', $headers ); |
|
187 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
188 | + $emails->__set('headers', $headers); |
|
189 | 189 | |
190 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
190 | + $emails->send($to_email, $subject, $message, $attachments); |
|
191 | 191 | |
192 | 192 | } |
193 | 193 | |
@@ -204,50 +204,50 @@ discard block |
||
204 | 204 | * @return void |
205 | 205 | * |
206 | 206 | */ |
207 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
207 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
208 | 208 | |
209 | 209 | /* Send an email notification to the admin */ |
210 | 210 | $admin_email = give_get_admin_notice_emails(); |
211 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
211 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
212 | 212 | |
213 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
214 | - $user_data = get_userdata( $user_info['id'] ); |
|
213 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
214 | + $user_data = get_userdata($user_info['id']); |
|
215 | 215 | $name = $user_data->display_name; |
216 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
217 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
216 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
217 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
218 | 218 | } else { |
219 | 219 | $name = $user_info['email']; |
220 | 220 | } |
221 | 221 | |
222 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
222 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
223 | 223 | |
224 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', esc_html__( 'New Pending Donation', 'give' ), $payment_id ); |
|
224 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', esc_html__('New Pending Donation', 'give'), $payment_id); |
|
225 | 225 | |
226 | - $admin_message = esc_html__( 'Dear Admin,', 'give' ) . "\n\n"; |
|
227 | - $admin_message .= esc_html__( 'An offline donation has been made on your website: ', 'give' ) . get_bloginfo( 'name' ) . ' '; |
|
228 | - $admin_message .= esc_html__( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
226 | + $admin_message = esc_html__('Dear Admin,', 'give')."\n\n"; |
|
227 | + $admin_message .= esc_html__('An offline donation has been made on your website: ', 'give').get_bloginfo('name').' '; |
|
228 | + $admin_message .= esc_html__('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
229 | 229 | |
230 | 230 | |
231 | - $admin_message .= '<strong>' . esc_html__( 'Donor: ', 'give' ) . '</strong>' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
232 | - $admin_message .= '<strong>' . esc_html__( 'Amount: ', 'give' ) . '</strong>' . html_entity_decode( $amount, ENT_COMPAT, 'UTF-8' ) . "\n\n"; |
|
231 | + $admin_message .= '<strong>'.esc_html__('Donor: ', 'give').'</strong>'.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n"; |
|
232 | + $admin_message .= '<strong>'.esc_html__('Amount: ', 'give').'</strong>'.html_entity_decode($amount, ENT_COMPAT, 'UTF-8')."\n\n"; |
|
233 | 233 | |
234 | 234 | $admin_message .= sprintf( |
235 | 235 | '<a href="%1$s">%2$s</a>', |
236 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
237 | - esc_html__( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
238 | - ) . "\n\n"; |
|
236 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id), |
|
237 | + esc_html__('Click Here to View and/or Update Donation Details', 'give') |
|
238 | + )."\n\n"; |
|
239 | 239 | |
240 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
241 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
242 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
240 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
241 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
242 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
243 | 243 | |
244 | 244 | //Send Email |
245 | 245 | $emails = Give()->emails; |
246 | - if ( ! empty( $admin_headers ) ) { |
|
247 | - $emails->__set( 'headers', $admin_headers ); |
|
246 | + if ( ! empty($admin_headers)) { |
|
247 | + $emails->__set('headers', $admin_headers); |
|
248 | 248 | } |
249 | 249 | |
250 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
250 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
251 | 251 | |
252 | 252 | } |
253 | 253 | |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | * @since 1.0 |
259 | 259 | * @return array |
260 | 260 | */ |
261 | -function give_offline_add_settings( $settings ) { |
|
261 | +function give_offline_add_settings($settings) { |
|
262 | 262 | |
263 | 263 | //Vars |
264 | 264 | $prefix = '_give_'; |
265 | 265 | |
266 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
266 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
267 | 267 | |
268 | 268 | //this gateway isn't active |
269 | - if ( ! $is_gateway_active ) { |
|
269 | + if ( ! $is_gateway_active) { |
|
270 | 270 | //return settings and bounce |
271 | 271 | return $settings; |
272 | 272 | } |
@@ -275,27 +275,27 @@ discard block |
||
275 | 275 | $check_settings = array( |
276 | 276 | |
277 | 277 | array( |
278 | - 'name' => esc_html__( 'Customize Offline Donations', 'give' ), |
|
279 | - 'desc' => esc_html__( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ), |
|
280 | - 'id' => $prefix . 'customize_offline_donations', |
|
278 | + 'name' => esc_html__('Customize Offline Donations', 'give'), |
|
279 | + 'desc' => esc_html__('If you would like to customize the donation instructions for this specific forms check this option.', 'give'), |
|
280 | + 'id' => $prefix.'customize_offline_donations', |
|
281 | 281 | 'type' => 'radio_inline', |
282 | 282 | 'default' => 'no', |
283 | 283 | 'options' => array( |
284 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
285 | - 'no' => esc_html__( 'No', 'give' ), |
|
284 | + 'yes' => esc_html__('Yes', 'give'), |
|
285 | + 'no' => esc_html__('No', 'give'), |
|
286 | 286 | ), |
287 | 287 | ), |
288 | 288 | array( |
289 | - 'name' => esc_html__( 'Request Billing Information', 'give' ), |
|
290 | - 'desc' => esc_html__( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
291 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
289 | + 'name' => esc_html__('Request Billing Information', 'give'), |
|
290 | + 'desc' => esc_html__('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
291 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
292 | 292 | 'row_classes' => 'give-subfield', |
293 | 293 | 'type' => 'checkbox' |
294 | 294 | ), |
295 | 295 | array( |
296 | - 'id' => $prefix . 'offline_checkout_notes', |
|
297 | - 'name' => esc_html__( 'Offline Donation Instructions', 'give' ), |
|
298 | - 'desc' => esc_html__( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
296 | + 'id' => $prefix.'offline_checkout_notes', |
|
297 | + 'name' => esc_html__('Offline Donation Instructions', 'give'), |
|
298 | + 'desc' => esc_html__('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
299 | 299 | 'default' => give_get_default_offline_donation_content(), |
300 | 300 | 'type' => 'wysiwyg', |
301 | 301 | 'row_classes' => 'give-subfield', |
@@ -304,17 +304,17 @@ discard block |
||
304 | 304 | ) |
305 | 305 | ), |
306 | 306 | array( |
307 | - 'id' => $prefix . 'offline_donation_subject', |
|
308 | - 'name' => esc_html__( 'Offline Donation Email Instructions Subject', 'give' ), |
|
309 | - 'desc' => esc_html__( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
310 | - 'default' => esc_html__( '{donation} - Offline Donation Instructions', 'give' ), |
|
307 | + 'id' => $prefix.'offline_donation_subject', |
|
308 | + 'name' => esc_html__('Offline Donation Email Instructions Subject', 'give'), |
|
309 | + 'desc' => esc_html__('Enter the subject line for the donation receipt email.', 'give'), |
|
310 | + 'default' => esc_html__('{donation} - Offline Donation Instructions', 'give'), |
|
311 | 311 | 'row_classes' => 'give-subfield', |
312 | 312 | 'type' => 'text' |
313 | 313 | ), |
314 | 314 | array( |
315 | - 'id' => $prefix . 'offline_donation_email', |
|
316 | - 'name' => esc_html__( 'Offline Donation Email Instructions', 'give' ), |
|
317 | - 'desc' => esc_html__( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
315 | + 'id' => $prefix.'offline_donation_email', |
|
316 | + 'name' => esc_html__('Offline Donation Email Instructions', 'give'), |
|
317 | + 'desc' => esc_html__('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
318 | 318 | 'default' => give_get_default_offline_donation_email_content(), |
319 | 319 | 'type' => 'wysiwyg', |
320 | 320 | 'row_classes' => 'give-subfield', |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | ) |
325 | 325 | ); |
326 | 326 | |
327 | - return array_merge( $settings, $check_settings ); |
|
327 | + return array_merge($settings, $check_settings); |
|
328 | 328 | } |
329 | 329 | |
330 | -add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' ); |
|
330 | +add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings'); |
|
331 | 331 | |
332 | 332 | |
333 | 333 | /** |
@@ -339,32 +339,32 @@ discard block |
||
339 | 339 | */ |
340 | 340 | function give_get_default_offline_donation_content() { |
341 | 341 | |
342 | - $sitename = get_bloginfo( 'sitename' ); |
|
342 | + $sitename = get_bloginfo('sitename'); |
|
343 | 343 | |
344 | - $default_text = '<p>' . esc_html__( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
344 | + $default_text = '<p>'.esc_html__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
345 | 345 | $default_text .= '<ol>'; |
346 | 346 | $default_text .= '<li>'; |
347 | 347 | $default_text .= sprintf( |
348 | 348 | /* translators: %s: site name */ |
349 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
349 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
350 | 350 | $sitename |
351 | 351 | ); |
352 | 352 | $default_text .= '</li>'; |
353 | 353 | $default_text .= '<li>'; |
354 | 354 | $default_text .= sprintf( |
355 | 355 | /* translators: %s: site name */ |
356 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
356 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
357 | 357 | $sitename |
358 | 358 | ); |
359 | 359 | $default_text .= '</li>'; |
360 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
360 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
361 | 361 | $default_text .= '</ol>'; |
362 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
362 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
363 | 363 | $default_text .= ' <em>123 G Street </em><br>'; |
364 | 364 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
365 | - $default_text .= '<p>' . esc_html__( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
365 | + $default_text .= '<p>'.esc_html__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
366 | 366 | |
367 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
367 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
368 | 368 | |
369 | 369 | } |
370 | 370 | |
@@ -377,33 +377,33 @@ discard block |
||
377 | 377 | */ |
378 | 378 | function give_get_default_offline_donation_email_content() { |
379 | 379 | |
380 | - $sitename = get_bloginfo( 'sitename' ); |
|
381 | - $default_text = '<p>' . esc_html__( 'Dear {name},', 'give' ) . '</p>'; |
|
382 | - $default_text .= '<p>' . esc_html__( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
380 | + $sitename = get_bloginfo('sitename'); |
|
381 | + $default_text = '<p>'.esc_html__('Dear {name},', 'give').'</p>'; |
|
382 | + $default_text .= '<p>'.esc_html__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
383 | 383 | $default_text .= '<ol>'; |
384 | 384 | $default_text .= '<li>'; |
385 | 385 | $default_text .= sprintf( |
386 | 386 | /* translators: %s: site name */ |
387 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
387 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
388 | 388 | $sitename |
389 | 389 | ); |
390 | 390 | $default_text .= '</li>'; |
391 | 391 | $default_text .= '<li>'; |
392 | 392 | $default_text .= sprintf( |
393 | 393 | /* translators: %s: site name */ |
394 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
394 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
395 | 395 | $sitename |
396 | 396 | ); |
397 | 397 | $default_text .= '</li>'; |
398 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
398 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
399 | 399 | $default_text .= '</ol>'; |
400 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
400 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
401 | 401 | $default_text .= ' <em>123 G Street </em><br>'; |
402 | 402 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
403 | - $default_text .= '<p>' . esc_html__( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
404 | - $default_text .= '<p>' . esc_html__( 'Sincerely,', 'give' ) . '</p>'; |
|
405 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
403 | + $default_text .= '<p>'.esc_html__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
404 | + $default_text .= '<p>'.esc_html__('Sincerely,', 'give').'</p>'; |
|
405 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
406 | 406 | |
407 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
407 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
408 | 408 | |
409 | 409 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @access private |
22 | 22 | * @since 1.0 |
23 | 23 | */ |
24 | -add_action( 'give_paypal_cc_form', '__return_false' ); |
|
24 | +add_action('give_paypal_cc_form', '__return_false'); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Process PayPal Purchase |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_process_paypal_purchase( $purchase_data ) { |
|
35 | +function give_process_paypal_purchase($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( esc_html__( 'Nonce verification has failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(esc_html__('Nonce verification has failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | - $form_id = intval( $purchase_data['post_data']['give-form-id'] ); |
|
41 | + $form_id = intval($purchase_data['post_data']['give-form-id']); |
|
42 | 42 | $price_id = isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : ''; |
43 | 43 | |
44 | 44 | // Collect payment data |
@@ -57,67 +57,67 @@ discard block |
||
57 | 57 | ); |
58 | 58 | |
59 | 59 | // Record the pending payment |
60 | - $payment = give_insert_payment( $payment_data ); |
|
60 | + $payment = give_insert_payment($payment_data); |
|
61 | 61 | |
62 | 62 | // Check payment |
63 | - if ( ! $payment ) { |
|
63 | + if ( ! $payment) { |
|
64 | 64 | // Record the error |
65 | 65 | give_record_gateway_error( |
66 | - esc_html__( 'Payment Error', 'give' ), |
|
66 | + esc_html__('Payment Error', 'give'), |
|
67 | 67 | sprintf( |
68 | 68 | /* translators: %s: payment data */ |
69 | - esc_html__( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give' ), |
|
70 | - json_encode( $payment_data ) |
|
69 | + esc_html__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'), |
|
70 | + json_encode($payment_data) |
|
71 | 71 | ), |
72 | 72 | $payment |
73 | 73 | ); |
74 | 74 | // Problems? send back |
75 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
75 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
76 | 76 | } else { |
77 | 77 | // Only send to PayPal if the pending payment is created successfully |
78 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
78 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
79 | 79 | |
80 | 80 | // Get the success url |
81 | - $return_url = add_query_arg( array( |
|
81 | + $return_url = add_query_arg(array( |
|
82 | 82 | 'payment-confirmation' => 'paypal', |
83 | 83 | 'payment-id' => $payment |
84 | 84 | |
85 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
85 | + ), get_permalink(give_get_option('success_page'))); |
|
86 | 86 | |
87 | 87 | // Get the PayPal redirect uri |
88 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
88 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
89 | 89 | |
90 | 90 | //Item name - pass level name if variable priced |
91 | 91 | $item_name = $purchase_data['post_data']['give-form-title']; |
92 | 92 | |
93 | 93 | //Verify has variable prices |
94 | - if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) { |
|
94 | + if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) { |
|
95 | 95 | |
96 | - $item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
96 | + $item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']); |
|
97 | 97 | |
98 | - $price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
98 | + $price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']); |
|
99 | 99 | |
100 | 100 | //Donation given doesn't match selected level (must be a custom amount) |
101 | - if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) { |
|
102 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
101 | + if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) { |
|
102 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
103 | 103 | //user custom amount text if any, fallback to default if not |
104 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
104 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
105 | 105 | |
106 | 106 | } //Is there any donation level text? |
107 | - elseif ( ! empty( $item_price_level_text ) ) { |
|
108 | - $item_name .= ' - ' . $item_price_level_text; |
|
107 | + elseif ( ! empty($item_price_level_text)) { |
|
108 | + $item_name .= ' - '.$item_price_level_text; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | } //Single donation: Custom Amount |
112 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) { |
|
113 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
112 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) { |
|
113 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
114 | 114 | //user custom amount text if any, fallback to default if not |
115 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
115 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | // Setup PayPal arguments |
119 | 119 | $paypal_args = array( |
120 | - 'business' => give_get_option( 'paypal_email', false ), |
|
120 | + 'business' => give_get_option('paypal_email', false), |
|
121 | 121 | 'email' => $purchase_data['user_email'], |
122 | 122 | 'invoice' => $purchase_data['purchase_key'], |
123 | 123 | 'amount' => $purchase_data['price'], |
@@ -128,25 +128,25 @@ discard block |
||
128 | 128 | 'shipping' => '0', |
129 | 129 | 'no_note' => '1', |
130 | 130 | 'currency_code' => give_get_currency(), |
131 | - 'charset' => get_bloginfo( 'charset' ), |
|
131 | + 'charset' => get_bloginfo('charset'), |
|
132 | 132 | 'custom' => $payment, |
133 | 133 | 'rm' => '2', |
134 | 134 | 'return' => $return_url, |
135 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment ), |
|
135 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment), |
|
136 | 136 | 'notify_url' => $listener_url, |
137 | 137 | 'page_style' => give_get_paypal_page_style(), |
138 | - 'cbt' => get_bloginfo( 'name' ), |
|
138 | + 'cbt' => get_bloginfo('name'), |
|
139 | 139 | 'bn' => 'givewp_SP' |
140 | 140 | ); |
141 | 141 | |
142 | - if ( ! empty( $purchase_data['user_info']['address'] ) ) { |
|
142 | + if ( ! empty($purchase_data['user_info']['address'])) { |
|
143 | 143 | $paypal_args['address1'] = $purchase_data['user_info']['address']['line1']; |
144 | 144 | $paypal_args['address2'] = $purchase_data['user_info']['address']['line2']; |
145 | 145 | $paypal_args['city'] = $purchase_data['user_info']['address']['city']; |
146 | 146 | $paypal_args['country'] = $purchase_data['user_info']['address']['country']; |
147 | 147 | } |
148 | 148 | |
149 | - if ( give_get_option( 'paypal_button_type' ) === 'standard' ) { |
|
149 | + if (give_get_option('paypal_button_type') === 'standard') { |
|
150 | 150 | $paypal_extra_args = array( |
151 | 151 | 'cmd' => '_xclick', |
152 | 152 | ); |
@@ -156,23 +156,23 @@ discard block |
||
156 | 156 | ); |
157 | 157 | } |
158 | 158 | |
159 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
160 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data ); |
|
159 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
160 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data); |
|
161 | 161 | |
162 | 162 | // Build query |
163 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
163 | + $paypal_redirect .= http_build_query($paypal_args); |
|
164 | 164 | |
165 | 165 | // Fix for some sites that encode the entities |
166 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
166 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
167 | 167 | |
168 | 168 | // Redirect to PayPal |
169 | - wp_redirect( $paypal_redirect ); |
|
169 | + wp_redirect($paypal_redirect); |
|
170 | 170 | exit; |
171 | 171 | } |
172 | 172 | |
173 | 173 | } |
174 | 174 | |
175 | -add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' ); |
|
175 | +add_action('give_gateway_paypal', 'give_process_paypal_purchase'); |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Listens for a PayPal IPN requests and then sends to the processing function |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | */ |
183 | 183 | function give_listen_for_paypal_ipn() { |
184 | 184 | // Regular PayPal IPN |
185 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
186 | - do_action( 'give_verify_paypal_ipn' ); |
|
185 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
186 | + do_action('give_verify_paypal_ipn'); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
190 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
191 | 191 | |
192 | 192 | /** |
193 | 193 | * Process PayPal IPN |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | function give_process_paypal_ipn() { |
199 | 199 | |
200 | 200 | // Check the request method is POST |
201 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
201 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | $post_data = ''; |
207 | 207 | |
208 | 208 | // Fallback just in case post_max_size is lower than needed |
209 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
210 | - $post_data = file_get_contents( 'php://input' ); |
|
209 | + if (ini_get('allow_url_fopen')) { |
|
210 | + $post_data = file_get_contents('php://input'); |
|
211 | 211 | } else { |
212 | 212 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
213 | - ini_set( 'post_max_size', '12M' ); |
|
213 | + ini_set('post_max_size', '12M'); |
|
214 | 214 | } |
215 | 215 | // Start the encoded data collection with notification command |
216 | 216 | $encoded_data = 'cmd=_notify-validate'; |
@@ -219,40 +219,40 @@ discard block |
||
219 | 219 | $arg_separator = give_get_php_arg_separator_output(); |
220 | 220 | |
221 | 221 | // Verify there is a post_data |
222 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
222 | + if ($post_data || strlen($post_data) > 0) { |
|
223 | 223 | // Append the data |
224 | - $encoded_data .= $arg_separator . $post_data; |
|
224 | + $encoded_data .= $arg_separator.$post_data; |
|
225 | 225 | } else { |
226 | 226 | // Check if POST is empty |
227 | - if ( empty( $_POST ) ) { |
|
227 | + if (empty($_POST)) { |
|
228 | 228 | // Nothing to do |
229 | 229 | return; |
230 | 230 | } else { |
231 | 231 | // Loop through each POST |
232 | - foreach ( $_POST as $key => $value ) { |
|
232 | + foreach ($_POST as $key => $value) { |
|
233 | 233 | // Encode the value and append the data |
234 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
234 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | 239 | // Convert collected post data to an array |
240 | - parse_str( $encoded_data, $encoded_data_array ); |
|
240 | + parse_str($encoded_data, $encoded_data_array); |
|
241 | 241 | |
242 | - foreach ( $encoded_data_array as $key => $value ) { |
|
242 | + foreach ($encoded_data_array as $key => $value) { |
|
243 | 243 | |
244 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
245 | - $new_key = str_replace( '&', '&', $key ); |
|
246 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
244 | + if (false !== strpos($key, 'amp;')) { |
|
245 | + $new_key = str_replace('&', '&', $key); |
|
246 | + $new_key = str_replace('amp;', '&', $new_key); |
|
247 | 247 | |
248 | - unset( $encoded_data_array[ $key ] ); |
|
249 | - $encoded_data_array[ $new_key ] = $value; |
|
248 | + unset($encoded_data_array[$key]); |
|
249 | + $encoded_data_array[$new_key] = $value; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | } |
253 | 253 | |
254 | 254 | //Validate IPN request w/ PayPal if user hasn't disabled this security measure |
255 | - if ( ! give_get_option( 'disable_paypal_verification' ) ) { |
|
255 | + if ( ! give_get_option('disable_paypal_verification')) { |
|
256 | 256 | |
257 | 257 | $remote_post_vars = array( |
258 | 258 | 'method' => 'POST', |
@@ -272,27 +272,27 @@ discard block |
||
272 | 272 | ); |
273 | 273 | |
274 | 274 | // Validate the IPN |
275 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
275 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
276 | 276 | |
277 | - if ( is_wp_error( $api_response ) ) { |
|
277 | + if (is_wp_error($api_response)) { |
|
278 | 278 | give_record_gateway_error( |
279 | - esc_html__( 'IPN Error', 'give' ), |
|
279 | + esc_html__('IPN Error', 'give'), |
|
280 | 280 | sprintf( |
281 | 281 | /* translators: %s: Paypal IPN response */ |
282 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
283 | - json_encode( $api_response ) |
|
282 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
283 | + json_encode($api_response) |
|
284 | 284 | ) |
285 | 285 | ); |
286 | 286 | return; // Something went wrong |
287 | 287 | } |
288 | 288 | |
289 | - if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) { |
|
289 | + if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) { |
|
290 | 290 | give_record_gateway_error( |
291 | - esc_html__( 'IPN Error', 'give' ), |
|
291 | + esc_html__('IPN Error', 'give'), |
|
292 | 292 | sprintf( |
293 | 293 | /* translators: %s: Paypal IPN response */ |
294 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
295 | - json_encode( $api_response ) |
|
294 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
295 | + json_encode($api_response) |
|
296 | 296 | ) |
297 | 297 | ); |
298 | 298 | return; // Response not okay |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | } |
302 | 302 | |
303 | 303 | // Check if $post_data_array has been populated |
304 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
304 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
305 | 305 | return; |
306 | 306 | } |
307 | 307 | |
@@ -310,21 +310,21 @@ discard block |
||
310 | 310 | 'payment_status' => '' |
311 | 311 | ); |
312 | 312 | |
313 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
313 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
314 | 314 | |
315 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
315 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
316 | 316 | |
317 | - if ( has_action( 'give_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
317 | + if (has_action('give_paypal_'.$encoded_data_array['txn_type'])) { |
|
318 | 318 | // Allow PayPal IPN types to be processed separately |
319 | - do_action( 'give_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $payment_id ); |
|
319 | + do_action('give_paypal_'.$encoded_data_array['txn_type'], $encoded_data_array, $payment_id); |
|
320 | 320 | } else { |
321 | 321 | // Fallback to web accept just in case the txn_type isn't present |
322 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
322 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
323 | 323 | } |
324 | 324 | exit; |
325 | 325 | } |
326 | 326 | |
327 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
327 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
328 | 328 | |
329 | 329 | /** |
330 | 330 | * Process web accept (one time) payment IPNs |
@@ -335,224 +335,224 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return void |
337 | 337 | */ |
338 | -function give_process_paypal_web_accept_and_cart( $data, $payment_id ) { |
|
338 | +function give_process_paypal_web_accept_and_cart($data, $payment_id) { |
|
339 | 339 | |
340 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
340 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') { |
|
341 | 341 | return; |
342 | 342 | } |
343 | 343 | |
344 | - if ( empty( $payment_id ) ) { |
|
344 | + if (empty($payment_id)) { |
|
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | 348 | // Collect payment details |
349 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
349 | + $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number']; |
|
350 | 350 | $paypal_amount = $data['mc_gross']; |
351 | - $payment_status = strtolower( $data['payment_status'] ); |
|
352 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
353 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
354 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
351 | + $payment_status = strtolower($data['payment_status']); |
|
352 | + $currency_code = strtolower($data['mc_currency']); |
|
353 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
354 | + $payment_meta = give_get_payment_meta($payment_id); |
|
355 | 355 | |
356 | 356 | |
357 | - if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) { |
|
357 | + if (give_get_payment_gateway($payment_id) != 'paypal') { |
|
358 | 358 | return; // this isn't a PayPal standard IPN |
359 | 359 | } |
360 | 360 | |
361 | 361 | // Verify payment recipient |
362 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) { |
|
362 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) { |
|
363 | 363 | |
364 | 364 | give_record_gateway_error( |
365 | - esc_html__( 'IPN Error', 'give' ), |
|
365 | + esc_html__('IPN Error', 'give'), |
|
366 | 366 | sprintf( |
367 | 367 | /* translators: %s: Paypal IPN response */ |
368 | - esc_html__( 'Invalid business email in IPN response. IPN data: %s', 'give' ), |
|
369 | - json_encode( $data ) |
|
368 | + esc_html__('Invalid business email in IPN response. IPN data: %s', 'give'), |
|
369 | + json_encode($data) |
|
370 | 370 | ), |
371 | 371 | $payment_id |
372 | 372 | ); |
373 | - give_update_payment_status( $payment_id, 'failed' ); |
|
374 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
373 | + give_update_payment_status($payment_id, 'failed'); |
|
374 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid PayPal business email.', 'give')); |
|
375 | 375 | |
376 | 376 | return; |
377 | 377 | } |
378 | 378 | |
379 | 379 | // Verify payment currency |
380 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
380 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
381 | 381 | |
382 | 382 | give_record_gateway_error( |
383 | - esc_html__( 'IPN Error', 'give' ), |
|
383 | + esc_html__('IPN Error', 'give'), |
|
384 | 384 | sprintf( |
385 | 385 | /* translators: %s: Paypal IPN response */ |
386 | - esc_html__( 'Invalid currency in IPN response. IPN data: %s', 'give' ), |
|
387 | - json_encode( $data ) |
|
386 | + esc_html__('Invalid currency in IPN response. IPN data: %s', 'give'), |
|
387 | + json_encode($data) |
|
388 | 388 | ), |
389 | 389 | $payment_id |
390 | 390 | ); |
391 | - give_update_payment_status( $payment_id, 'failed' ); |
|
392 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
391 | + give_update_payment_status($payment_id, 'failed'); |
|
392 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
393 | 393 | |
394 | 394 | return; |
395 | 395 | } |
396 | 396 | |
397 | - if ( ! give_get_payment_user_email( $payment_id ) ) { |
|
397 | + if ( ! give_get_payment_user_email($payment_id)) { |
|
398 | 398 | |
399 | 399 | // No email associated with purchase, so store from PayPal |
400 | - give_update_payment_meta( $payment_id, '_give_payment_user_email', $data['payer_email'] ); |
|
400 | + give_update_payment_meta($payment_id, '_give_payment_user_email', $data['payer_email']); |
|
401 | 401 | |
402 | 402 | // Setup and store the donors's details |
403 | 403 | $address = array(); |
404 | - $address['line1'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
405 | - $address['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
406 | - $address['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
407 | - $address['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
408 | - $address['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
404 | + $address['line1'] = ! empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false; |
|
405 | + $address['city'] = ! empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false; |
|
406 | + $address['state'] = ! empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false; |
|
407 | + $address['country'] = ! empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false; |
|
408 | + $address['zip'] = ! empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false; |
|
409 | 409 | |
410 | 410 | $user_info = array( |
411 | 411 | 'id' => '-1', |
412 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
413 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
414 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
412 | + 'email' => sanitize_text_field($data['payer_email']), |
|
413 | + 'first_name' => sanitize_text_field($data['first_name']), |
|
414 | + 'last_name' => sanitize_text_field($data['last_name']), |
|
415 | 415 | 'discount' => '', |
416 | 416 | 'address' => $address |
417 | 417 | ); |
418 | 418 | |
419 | 419 | $payment_meta['user_info'] = $user_info; |
420 | - give_update_payment_meta( $payment_id, '_give_payment_meta', $payment_meta ); |
|
420 | + give_update_payment_meta($payment_id, '_give_payment_meta', $payment_meta); |
|
421 | 421 | } |
422 | 422 | |
423 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
423 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
424 | 424 | |
425 | 425 | // Process a refund |
426 | - give_process_paypal_refund( $data, $payment_id ); |
|
426 | + give_process_paypal_refund($data, $payment_id); |
|
427 | 427 | |
428 | 428 | } else { |
429 | 429 | |
430 | - if ( get_post_status( $payment_id ) == 'publish' ) { |
|
430 | + if (get_post_status($payment_id) == 'publish') { |
|
431 | 431 | return; // Only complete payments once |
432 | 432 | } |
433 | 433 | |
434 | 434 | // Retrieve the total purchase amount (before PayPal) |
435 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
435 | + $payment_amount = give_get_payment_amount($payment_id); |
|
436 | 436 | |
437 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
437 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
438 | 438 | // The prices don't match |
439 | 439 | give_record_gateway_error( |
440 | - esc_html__( 'IPN Error', 'give' ), |
|
440 | + esc_html__('IPN Error', 'give'), |
|
441 | 441 | sprintf( |
442 | 442 | /* translators: %s: Paypal IPN response */ |
443 | - esc_html__( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), |
|
444 | - json_encode( $data ) |
|
443 | + esc_html__('Invalid payment amount in IPN response. IPN data: %s', 'give'), |
|
444 | + json_encode($data) |
|
445 | 445 | ), |
446 | 446 | $payment_id |
447 | 447 | ); |
448 | - give_update_payment_status( $payment_id, 'failed' ); |
|
449 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
448 | + give_update_payment_status($payment_id, 'failed'); |
|
449 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
450 | 450 | |
451 | 451 | return; |
452 | 452 | } |
453 | - if ( $purchase_key != give_get_payment_key( $payment_id ) ) { |
|
453 | + if ($purchase_key != give_get_payment_key($payment_id)) { |
|
454 | 454 | // Purchase keys don't match |
455 | 455 | give_record_gateway_error( |
456 | - esc_html__( 'IPN Error', 'give' ), |
|
456 | + esc_html__('IPN Error', 'give'), |
|
457 | 457 | sprintf( |
458 | 458 | /* translators: %s: Paypal IPN response */ |
459 | - esc_html__( 'Invalid purchase key in IPN response. IPN data: %s', 'give' ), |
|
460 | - json_encode( $data ) |
|
459 | + esc_html__('Invalid purchase key in IPN response. IPN data: %s', 'give'), |
|
460 | + json_encode($data) |
|
461 | 461 | ), |
462 | 462 | $payment_id |
463 | 463 | ); |
464 | - give_update_payment_status( $payment_id, 'failed' ); |
|
465 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid purchase key in PayPal IPN.', 'give' ) ); |
|
464 | + give_update_payment_status($payment_id, 'failed'); |
|
465 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid purchase key in PayPal IPN.', 'give')); |
|
466 | 466 | |
467 | 467 | return; |
468 | 468 | } |
469 | 469 | |
470 | - if ( $payment_status == 'completed' || give_is_test_mode() ) { |
|
470 | + if ($payment_status == 'completed' || give_is_test_mode()) { |
|
471 | 471 | give_insert_payment_note( |
472 | 472 | $payment_id, |
473 | 473 | sprintf( |
474 | 474 | /* translators: %s: Paypal transaction ID */ |
475 | - esc_html__( 'PayPal Transaction ID: %s', 'give' ), |
|
475 | + esc_html__('PayPal Transaction ID: %s', 'give'), |
|
476 | 476 | $data['txn_id'] |
477 | 477 | ) |
478 | 478 | ); |
479 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
480 | - give_update_payment_status( $payment_id, 'publish' ); |
|
481 | - } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
479 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
480 | + give_update_payment_status($payment_id, 'publish'); |
|
481 | + } else if ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
482 | 482 | |
483 | 483 | // Look for possible pending reasons, such as an echeck |
484 | 484 | |
485 | 485 | $note = ''; |
486 | 486 | |
487 | - switch ( strtolower( $data['pending_reason'] ) ) { |
|
487 | + switch (strtolower($data['pending_reason'])) { |
|
488 | 488 | |
489 | 489 | case 'echeck' : |
490 | 490 | |
491 | - $note = esc_html__( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
491 | + $note = esc_html__('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
492 | 492 | |
493 | 493 | break; |
494 | 494 | |
495 | 495 | case 'address' : |
496 | 496 | |
497 | - $note = esc_html__( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
497 | + $note = esc_html__('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
498 | 498 | |
499 | 499 | break; |
500 | 500 | |
501 | 501 | case 'intl' : |
502 | 502 | |
503 | - $note = esc_html__( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
503 | + $note = esc_html__('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
504 | 504 | |
505 | 505 | break; |
506 | 506 | |
507 | 507 | case 'multi-currency' : |
508 | 508 | |
509 | - $note = esc_html__( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
509 | + $note = esc_html__('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
510 | 510 | |
511 | 511 | break; |
512 | 512 | |
513 | 513 | case 'paymentreview' : |
514 | 514 | case 'regulatory_review' : |
515 | 515 | |
516 | - $note = esc_html__( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
516 | + $note = esc_html__('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
517 | 517 | |
518 | 518 | break; |
519 | 519 | |
520 | 520 | case 'unilateral' : |
521 | 521 | |
522 | - $note = esc_html__( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
522 | + $note = esc_html__('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
523 | 523 | |
524 | 524 | break; |
525 | 525 | |
526 | 526 | case 'upgrade' : |
527 | 527 | |
528 | - $note = esc_html__( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
528 | + $note = esc_html__('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
529 | 529 | |
530 | 530 | break; |
531 | 531 | |
532 | 532 | case 'verify' : |
533 | 533 | |
534 | - $note = esc_html__( 'PayPal account is not verified. Verify account in order to accept this payment.', 'give' ); |
|
534 | + $note = esc_html__('PayPal account is not verified. Verify account in order to accept this payment.', 'give'); |
|
535 | 535 | |
536 | 536 | break; |
537 | 537 | |
538 | 538 | case 'other' : |
539 | 539 | |
540 | - $note = esc_html__( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
540 | + $note = esc_html__('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
541 | 541 | |
542 | 542 | break; |
543 | 543 | |
544 | 544 | } |
545 | 545 | |
546 | - if ( ! empty( $note ) ) { |
|
546 | + if ( ! empty($note)) { |
|
547 | 547 | |
548 | - give_insert_payment_note( $payment_id, $note ); |
|
548 | + give_insert_payment_note($payment_id, $note); |
|
549 | 549 | |
550 | 550 | } |
551 | 551 | } |
552 | 552 | } |
553 | 553 | } |
554 | 554 | |
555 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 ); |
|
555 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2); |
|
556 | 556 | |
557 | 557 | /** |
558 | 558 | * Process PayPal IPN Refunds |
@@ -563,28 +563,28 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @return void |
565 | 565 | */ |
566 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
566 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
567 | 567 | |
568 | 568 | // Collect payment details |
569 | 569 | |
570 | - if ( empty( $payment_id ) ) { |
|
570 | + if (empty($payment_id)) { |
|
571 | 571 | return; |
572 | 572 | } |
573 | 573 | |
574 | - if ( get_post_status( $payment_id ) == 'refunded' ) { |
|
574 | + if (get_post_status($payment_id) == 'refunded') { |
|
575 | 575 | return; // Only refund payments once |
576 | 576 | } |
577 | 577 | |
578 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
578 | + $payment_amount = give_get_payment_amount($payment_id); |
|
579 | 579 | $refund_amount = $data['payment_gross'] * - 1; |
580 | 580 | |
581 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
581 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
582 | 582 | |
583 | 583 | give_insert_payment_note( |
584 | 584 | $payment_id, |
585 | 585 | sprintf( |
586 | 586 | /* translators: %s: Paypal parent transaction ID */ |
587 | - esc_html__( 'Partial PayPal refund processed: %s', 'give' ), |
|
587 | + esc_html__('Partial PayPal refund processed: %s', 'give'), |
|
588 | 588 | $data['parent_txn_id'] |
589 | 589 | ) |
590 | 590 | ); |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | $payment_id, |
598 | 598 | sprintf( |
599 | 599 | /* translators: %s: Paypal parent transaction ID */ |
600 | - esc_html__( 'PayPal Payment #%s Refunded for reason: %s', 'give' ), |
|
600 | + esc_html__('PayPal Payment #%s Refunded for reason: %s', 'give'), |
|
601 | 601 | $data['parent_txn_id'], $data['reason_code'] |
602 | 602 | ) |
603 | 603 | ); |
@@ -605,11 +605,11 @@ discard block |
||
605 | 605 | $payment_id, |
606 | 606 | sprintf( |
607 | 607 | /* translators: %s: Paypal transaction ID */ |
608 | - esc_html__( 'PayPal Refund Transaction ID: %s', 'give' ), |
|
608 | + esc_html__('PayPal Refund Transaction ID: %s', 'give'), |
|
609 | 609 | $data['txn_id'] |
610 | 610 | ) |
611 | 611 | ); |
612 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
612 | + give_update_payment_status($payment_id, 'refunded'); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
@@ -621,24 +621,24 @@ discard block |
||
621 | 621 | * |
622 | 622 | * @return string |
623 | 623 | */ |
624 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
624 | +function give_get_paypal_redirect($ssl_check = false) { |
|
625 | 625 | |
626 | - if ( is_ssl() || ! $ssl_check ) { |
|
626 | + if (is_ssl() || ! $ssl_check) { |
|
627 | 627 | $protocal = 'https://'; |
628 | 628 | } else { |
629 | 629 | $protocal = 'http://'; |
630 | 630 | } |
631 | 631 | |
632 | 632 | // Check the current payment mode |
633 | - if ( give_is_test_mode() ) { |
|
633 | + if (give_is_test_mode()) { |
|
634 | 634 | // Test mode |
635 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
635 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
636 | 636 | } else { |
637 | 637 | // Live mode |
638 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
638 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
639 | 639 | } |
640 | 640 | |
641 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
641 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
@@ -648,8 +648,8 @@ discard block |
||
648 | 648 | * @return string |
649 | 649 | */ |
650 | 650 | function give_get_paypal_page_style() { |
651 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
652 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
651 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
652 | + return apply_filters('give_paypal_page_style', $page_style); |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | /** |
@@ -664,27 +664,27 @@ discard block |
||
664 | 664 | * @return string |
665 | 665 | * |
666 | 666 | */ |
667 | -function give_paypal_success_page_content( $content ) { |
|
667 | +function give_paypal_success_page_content($content) { |
|
668 | 668 | |
669 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
669 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
670 | 670 | return $content; |
671 | 671 | } |
672 | 672 | |
673 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
673 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
674 | 674 | |
675 | - if ( ! $payment_id ) { |
|
675 | + if ( ! $payment_id) { |
|
676 | 676 | $session = give_get_purchase_session(); |
677 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
677 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
678 | 678 | } |
679 | 679 | |
680 | - $payment = get_post( $payment_id ); |
|
680 | + $payment = get_post($payment_id); |
|
681 | 681 | |
682 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
682 | + if ($payment && 'pending' == $payment->post_status) { |
|
683 | 683 | |
684 | 684 | // Payment is still pending so show processing indicator to fix the Race Condition |
685 | 685 | ob_start(); |
686 | 686 | |
687 | - give_get_template_part( 'payment', 'processing' ); |
|
687 | + give_get_template_part('payment', 'processing'); |
|
688 | 688 | |
689 | 689 | $content = ob_get_clean(); |
690 | 690 | |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | |
695 | 695 | } |
696 | 696 | |
697 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
697 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
698 | 698 | |
699 | 699 | /** |
700 | 700 | * Given a Payment ID, extract the transaction ID |
@@ -705,22 +705,22 @@ discard block |
||
705 | 705 | * |
706 | 706 | * @return string Transaction ID |
707 | 707 | */ |
708 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
708 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
709 | 709 | |
710 | 710 | $transaction_id = ''; |
711 | - $notes = give_get_payment_notes( $payment_id ); |
|
711 | + $notes = give_get_payment_notes($payment_id); |
|
712 | 712 | |
713 | - foreach ( $notes as $note ) { |
|
714 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
713 | + foreach ($notes as $note) { |
|
714 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
715 | 715 | $transaction_id = $match[1]; |
716 | 716 | continue; |
717 | 717 | } |
718 | 718 | } |
719 | 719 | |
720 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
720 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
721 | 721 | } |
722 | 722 | |
723 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
723 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
724 | 724 | |
725 | 725 | /** |
726 | 726 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -732,13 +732,13 @@ discard block |
||
732 | 732 | * |
733 | 733 | * @return string A link to the PayPal transaction details |
734 | 734 | */ |
735 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
735 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
736 | 736 | |
737 | 737 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
738 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
738 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
739 | 739 | |
740 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
740 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
741 | 741 | |
742 | 742 | } |
743 | 743 | |
744 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
744 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param $data |
23 | 23 | */ |
24 | -function give_process_gateway_select( $data ) { |
|
25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
24 | +function give_process_gateway_select($data) { |
|
25 | + if (isset($_POST['gateway_submit'])) { |
|
26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Loads a payment gateway via AJAX |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | * @return void |
38 | 38 | */ |
39 | 39 | function give_load_ajax_gateway() { |
40 | - if ( isset( $_POST['give_payment_mode'] ) ) { |
|
41 | - do_action( 'give_purchase_form', $_POST['give_form_id'] ); |
|
40 | + if (isset($_POST['give_payment_mode'])) { |
|
41 | + do_action('give_purchase_form', $_POST['give_form_id']); |
|
42 | 42 | exit(); |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
47 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
46 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
47 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Sets an error on checkout if no gateways are enabled |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | function give_no_gateway_error() { |
56 | 56 | $gateways = give_get_enabled_payment_gateways(); |
57 | 57 | |
58 | - if ( empty( $gateways ) ) { |
|
59 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
58 | + if (empty($gateways)) { |
|
59 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
60 | 60 | } else { |
61 | - give_unset_error( 'no_gateways' ); |
|
61 | + give_unset_error('no_gateways'); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | -add_action( 'init', 'give_no_gateway_error' ); |
|
66 | 65 | \ No newline at end of file |
66 | +add_action('init', 'give_no_gateway_error'); |
|
67 | 67 | \ No newline at end of file |