@@ -45,22 +45,22 @@ discard block |
||
45 | 45 | * @param string $default_path Default path. Default is empty. |
46 | 46 | */ |
47 | 47 | function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | - extract( $args ); |
|
50 | - } |
|
48 | + if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | + extract( $args ); |
|
50 | + } |
|
51 | 51 | |
52 | - $template_names = array( $template_name . '.php' ); |
|
52 | + $template_names = array( $template_name . '.php' ); |
|
53 | 53 | |
54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
54 | + $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
55 | 55 | |
56 | - if ( ! file_exists( $located ) ) { |
|
56 | + if ( ! file_exists( $located ) ) { |
|
57 | 57 | /* translators: %s: the template */ |
58 | - give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
59 | - return; |
|
60 | - } |
|
58 | + give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
59 | + return; |
|
60 | + } |
|
61 | 61 | |
62 | - // Allow 3rd party plugin filter template file from their plugin. |
|
63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
62 | + // Allow 3rd party plugin filter template file from their plugin. |
|
63 | + $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
75 | 75 | * @param array $args Passed arguments. |
76 | 76 | */ |
77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
77 | + do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
78 | 78 | |
79 | - include( $located ); |
|
79 | + include( $located ); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
91 | 91 | * @param array $args Passed arguments. |
92 | 92 | */ |
93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
93 | + do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -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 | /** |
@@ -44,23 +44,23 @@ discard block |
||
44 | 44 | * @param string $template_path Template file path. Default is empty. |
45 | 45 | * @param string $default_path Default path. Default is empty. |
46 | 46 | */ |
47 | -function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | - extract( $args ); |
|
47 | +function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
48 | + if ( ! empty($args) && is_array($args)) { |
|
49 | + extract($args); |
|
50 | 50 | } |
51 | 51 | |
52 | - $template_names = array( $template_name . '.php' ); |
|
52 | + $template_names = array($template_name.'.php'); |
|
53 | 53 | |
54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
54 | + $located = give_locate_template($template_names, $template_path, $default_path); |
|
55 | 55 | |
56 | - if ( ! file_exists( $located ) ) { |
|
56 | + if ( ! file_exists($located)) { |
|
57 | 57 | /* translators: %s: the template */ |
58 | - give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
58 | + give_output_error(sprintf(__('The %s template was not found.', 'give'), $located), true); |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Allow 3rd party plugin filter template file from their plugin. |
63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
63 | + $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
75 | 75 | * @param array $args Passed arguments. |
76 | 76 | */ |
77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
77 | + do_action('give_before_template_part', $template_name, $template_path, $located, $args); |
|
78 | 78 | |
79 | - include( $located ); |
|
79 | + include($located); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
91 | 91 | * @param array $args Passed arguments. |
92 | 92 | */ |
93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
93 | + do_action('give_after_template_part', $template_name, $template_path, $located, $args); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return string |
108 | 108 | */ |
109 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
109 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Fires in give template part, before the template part is retrieved. |
@@ -118,20 +118,20 @@ discard block |
||
118 | 118 | * @param string $slug Template part file slug {slug}.php. |
119 | 119 | * @param string $name Template part file name {slug}-{name}.php. |
120 | 120 | */ |
121 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
121 | + do_action('get_template_part_'.$slug, $slug, $name); |
|
122 | 122 | |
123 | 123 | // Setup possible parts |
124 | 124 | $templates = array(); |
125 | - if ( isset( $name ) ) { |
|
126 | - $templates[] = $slug . '-' . $name . '.php'; |
|
125 | + if (isset($name)) { |
|
126 | + $templates[] = $slug.'-'.$name.'.php'; |
|
127 | 127 | } |
128 | - $templates[] = $slug . '.php'; |
|
128 | + $templates[] = $slug.'.php'; |
|
129 | 129 | |
130 | 130 | // Allow template parts to be filtered |
131 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
131 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
132 | 132 | |
133 | 133 | // Return the part that is found |
134 | - return give_locate_template( $templates, $load, false ); |
|
134 | + return give_locate_template($templates, $load, false); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -152,37 +152,37 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return string The template filename if one is located. |
154 | 154 | */ |
155 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
155 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
156 | 156 | // No file found yet |
157 | 157 | $located = false; |
158 | 158 | |
159 | 159 | // Try to find a template file |
160 | - foreach ( (array) $template_names as $template_name ) { |
|
160 | + foreach ((array) $template_names as $template_name) { |
|
161 | 161 | |
162 | 162 | // Continue if template is empty |
163 | - if ( empty( $template_name ) ) { |
|
163 | + if (empty($template_name)) { |
|
164 | 164 | continue; |
165 | 165 | } |
166 | 166 | |
167 | 167 | // Trim off any slashes from the template name |
168 | - $template_name = ltrim( $template_name, '/' ); |
|
168 | + $template_name = ltrim($template_name, '/'); |
|
169 | 169 | |
170 | 170 | // try locating this template file by looping through the template paths |
171 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
171 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
172 | 172 | |
173 | - if ( file_exists( $template_path . $template_name ) ) { |
|
174 | - $located = $template_path . $template_name; |
|
173 | + if (file_exists($template_path.$template_name)) { |
|
174 | + $located = $template_path.$template_name; |
|
175 | 175 | break; |
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | - if ( $located ) { |
|
179 | + if ($located) { |
|
180 | 180 | break; |
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
185 | - load_template( $located, $require_once ); |
|
184 | + if ((true == $load) && ! empty($located)) { |
|
185 | + load_template($located, $require_once); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | return $located; |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | $template_dir = give_get_theme_template_dir_name(); |
200 | 200 | |
201 | 201 | $file_paths = array( |
202 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
203 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
202 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
203 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
204 | 204 | 100 => give_get_templates_dir() |
205 | 205 | ); |
206 | 206 | |
207 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
207 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
208 | 208 | |
209 | 209 | // sort the file paths based on priority |
210 | - ksort( $file_paths, SORT_NUMERIC ); |
|
210 | + ksort($file_paths, SORT_NUMERIC); |
|
211 | 211 | |
212 | - return array_map( 'trailingslashit', $file_paths ); |
|
212 | + return array_map('trailingslashit', $file_paths); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @return string |
222 | 222 | */ |
223 | 223 | function give_get_theme_template_dir_name() { |
224 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
224 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | * @return void |
232 | 232 | */ |
233 | 233 | function give_version_in_header() { |
234 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
234 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
235 | 235 | } |
236 | 236 | |
237 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
237 | +add_action('wp_head', 'give_version_in_header'); |
|
238 | 238 | |
239 | 239 | /** |
240 | 240 | * Determines if we're currently on the Donations History page. |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | */ |
245 | 245 | function give_is_donation_history_page() { |
246 | 246 | |
247 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
247 | + $ret = is_page(give_get_option('history_page')); |
|
248 | 248 | |
249 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
249 | + return apply_filters('give_is_donation_history_page', $ret); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -258,25 +258,25 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array Modified array of classes |
260 | 260 | */ |
261 | -function give_add_body_classes( $class ) { |
|
261 | +function give_add_body_classes($class) { |
|
262 | 262 | $classes = (array) $class; |
263 | 263 | |
264 | - if ( give_is_success_page() ) { |
|
264 | + if (give_is_success_page()) { |
|
265 | 265 | $classes[] = 'give-success'; |
266 | 266 | $classes[] = 'give-page'; |
267 | 267 | } |
268 | 268 | |
269 | - if ( give_is_failed_transaction_page() ) { |
|
269 | + if (give_is_failed_transaction_page()) { |
|
270 | 270 | $classes[] = 'give-failed-transaction'; |
271 | 271 | $classes[] = 'give-page'; |
272 | 272 | } |
273 | 273 | |
274 | - if ( give_is_donation_history_page() ) { |
|
274 | + if (give_is_donation_history_page()) { |
|
275 | 275 | $classes[] = 'give-donation-history'; |
276 | 276 | $classes[] = 'give-page'; |
277 | 277 | } |
278 | 278 | |
279 | - if ( give_is_test_mode() ) { |
|
279 | + if (give_is_test_mode()) { |
|
280 | 280 | $classes[] = 'give-test-mode'; |
281 | 281 | $classes[] = 'give-page'; |
282 | 282 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | //Theme-specific Classes used to prevent conflicts via CSS |
285 | 285 | $current_theme = wp_get_theme(); |
286 | 286 | |
287 | - switch ( $current_theme->template ) { |
|
287 | + switch ($current_theme->template) { |
|
288 | 288 | |
289 | 289 | case 'Divi': |
290 | 290 | $classes[] = 'give-divi'; |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | |
299 | 299 | } |
300 | 300 | |
301 | - return array_unique( $classes ); |
|
301 | + return array_unique($classes); |
|
302 | 302 | } |
303 | 303 | |
304 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
304 | +add_filter('body_class', 'give_add_body_classes'); |
|
305 | 305 | |
306 | 306 | |
307 | 307 | /** |
@@ -317,22 +317,22 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return array |
319 | 319 | */ |
320 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
321 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
320 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
321 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
322 | 322 | return $classes; |
323 | 323 | } |
324 | 324 | |
325 | 325 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
326 | 326 | |
327 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
328 | - unset( $classes[ $key ] ); |
|
327 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
328 | + unset($classes[$key]); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | return $classes; |
332 | 332 | } |
333 | 333 | |
334 | 334 | |
335 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
335 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * Get the placeholder image URL for forms etc |
@@ -342,85 +342,85 @@ discard block |
||
342 | 342 | */ |
343 | 343 | function give_get_placeholder_img_src() { |
344 | 344 | |
345 | - $placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
345 | + $placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
346 | 346 | |
347 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
347 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Global |
353 | 353 | */ |
354 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
354 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Output the start of the page wrapper. |
358 | 358 | */ |
359 | 359 | function give_output_content_wrapper() { |
360 | - give_get_template_part( 'global/wrapper-start' ); |
|
360 | + give_get_template_part('global/wrapper-start'); |
|
361 | 361 | } |
362 | 362 | } |
363 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
363 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * Output the end of the page wrapper. |
367 | 367 | */ |
368 | 368 | function give_output_content_wrapper_end() { |
369 | - give_get_template_part( 'global/wrapper-end' ); |
|
369 | + give_get_template_part('global/wrapper-end'); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Single Give Form |
375 | 375 | */ |
376 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
376 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
377 | 377 | function give_left_sidebar_pre_wrap() { |
378 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
378 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
382 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
382 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
383 | 383 | function give_left_sidebar_post_wrap() { |
384 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
384 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
388 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
388 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
389 | 389 | function give_get_forms_sidebar() { |
390 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
390 | + give_get_template_part('single-give-form/sidebar'); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
394 | +if ( ! function_exists('give_show_form_images')) { |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Output the product image before the single product summary. |
398 | 398 | */ |
399 | 399 | function give_show_form_images() { |
400 | - $featured_image_option = give_get_option( 'disable_form_featured_img' ); |
|
401 | - if ( $featured_image_option !== 'on' ) { |
|
402 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
400 | + $featured_image_option = give_get_option('disable_form_featured_img'); |
|
401 | + if ($featured_image_option !== 'on') { |
|
402 | + give_get_template_part('single-give-form/featured-image'); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
407 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
407 | +if ( ! function_exists('give_template_single_title')) { |
|
408 | 408 | |
409 | 409 | /** |
410 | 410 | * Output the product title. |
411 | 411 | */ |
412 | 412 | function give_template_single_title() { |
413 | - give_get_template_part( 'single-give-form/title' ); |
|
413 | + give_get_template_part('single-give-form/title'); |
|
414 | 414 | } |
415 | 415 | } |
416 | 416 | |
417 | -if ( ! function_exists( 'give_show_avatars' ) ) { |
|
417 | +if ( ! function_exists('give_show_avatars')) { |
|
418 | 418 | |
419 | 419 | /** |
420 | 420 | * Output the product title. |
421 | 421 | */ |
422 | 422 | function give_show_avatars() { |
423 | - echo do_shortcode( '[give_donators_gravatars]' ); |
|
423 | + echo do_shortcode('[give_donators_gravatars]'); |
|
424 | 424 | } |
425 | 425 | } |
426 | 426 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * Conditional Functions |
429 | 429 | */ |
430 | 430 | |
431 | -if ( ! function_exists( 'is_give_form' ) ) { |
|
431 | +if ( ! function_exists('is_give_form')) { |
|
432 | 432 | |
433 | 433 | /** |
434 | 434 | * is_give_form |
@@ -440,11 +440,11 @@ discard block |
||
440 | 440 | * @return bool |
441 | 441 | */ |
442 | 442 | function is_give_form() { |
443 | - return is_singular( array( 'give_form' ) ); |
|
443 | + return is_singular(array('give_form')); |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | -if ( ! function_exists( 'is_give_category' ) ) { |
|
447 | +if ( ! function_exists('is_give_category')) { |
|
448 | 448 | |
449 | 449 | /** |
450 | 450 | * is_give_category |
@@ -459,12 +459,12 @@ discard block |
||
459 | 459 | * |
460 | 460 | * @return bool |
461 | 461 | */ |
462 | - function is_give_category( $term = '' ) { |
|
463 | - return is_tax( 'give_forms_category', $term ); |
|
462 | + function is_give_category($term = '') { |
|
463 | + return is_tax('give_forms_category', $term); |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | -if ( ! function_exists( 'is_give_tag' ) ) { |
|
467 | +if ( ! function_exists('is_give_tag')) { |
|
468 | 468 | |
469 | 469 | /** |
470 | 470 | * is_give_tag |
@@ -479,12 +479,12 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return bool |
481 | 481 | */ |
482 | - function is_give_tag( $term = '' ) { |
|
483 | - return is_tax( 'give_forms_tag', $term ); |
|
482 | + function is_give_tag($term = '') { |
|
483 | + return is_tax('give_forms_tag', $term); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
487 | -if ( ! function_exists( 'is_give_taxonomy' ) ) { |
|
487 | +if ( ! function_exists('is_give_taxonomy')) { |
|
488 | 488 | |
489 | 489 | /** |
490 | 490 | * is_give_taxonomy |
@@ -496,6 +496,6 @@ discard block |
||
496 | 496 | * @return bool |
497 | 497 | */ |
498 | 498 | function is_give_taxonomy() { |
499 | - return is_tax( get_object_taxonomies( 'give_form' ) ); |
|
499 | + return is_tax(get_object_taxonomies('give_form')); |
|
500 | 500 | } |
501 | 501 | } |
@@ -33,20 +33,20 @@ discard block |
||
33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $logout_redirect ) ) { |
|
37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
38 | - } |
|
36 | + if ( empty( $logout_redirect ) ) { |
|
37 | + $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - // Add user_logout action to logout url. |
|
42 | - $logout_redirect = add_query_arg( |
|
43 | - array( |
|
44 | - 'give_action' => 'user_logout', |
|
45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
47 | - ), |
|
48 | - home_url('/') |
|
49 | - ); |
|
41 | + // Add user_logout action to logout url. |
|
42 | + $logout_redirect = add_query_arg( |
|
43 | + array( |
|
44 | + 'give_action' => 'user_logout', |
|
45 | + 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
46 | + 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
47 | + ), |
|
48 | + home_url('/') |
|
49 | + ); |
|
50 | 50 | |
51 | 51 | $give_login_redirect = $login_redirect; |
52 | 52 | $give_logout_redirect = $logout_redirect; |
@@ -136,31 +136,31 @@ discard block |
||
136 | 136 | * @return void |
137 | 137 | */ |
138 | 138 | function give_process_user_logout( $data ) { |
139 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
139 | + if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
140 | 140 | |
141 | - // Prevent occurring of any custom action on wp_logout. |
|
142 | - remove_all_actions( 'wp_logout' ); |
|
141 | + // Prevent occurring of any custom action on wp_logout. |
|
142 | + remove_all_actions( 'wp_logout' ); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Fires before processing user logout. |
146 | 146 | * |
147 | 147 | * @since 1.0 |
148 | 148 | */ |
149 | - do_action( 'give_before_user_logout' ); |
|
149 | + do_action( 'give_before_user_logout' ); |
|
150 | 150 | |
151 | - // Logout user. |
|
152 | - wp_logout(); |
|
151 | + // Logout user. |
|
152 | + wp_logout(); |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Fires after processing user logout. |
156 | 156 | * |
157 | 157 | * @since 1.0 |
158 | 158 | */ |
159 | - do_action( 'give_after_user_logout' ); |
|
159 | + do_action( 'give_after_user_logout' ); |
|
160 | 160 | |
161 | - wp_redirect( $data['give_logout_redirect'] ); |
|
162 | - give_die(); |
|
163 | - } |
|
161 | + wp_redirect( $data['give_logout_redirect'] ); |
|
162 | + give_die(); |
|
163 | + } |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | add_action( 'give_user_logout', 'give_process_user_logout' ); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return string Login form |
28 | 28 | */ |
29 | -function give_login_form( $login_redirect = '', $logout_redirect = '' ) { |
|
30 | - global $give_login_redirect, $give_logout_redirect;; |
|
29 | +function give_login_form($login_redirect = '', $logout_redirect = '') { |
|
30 | + global $give_login_redirect, $give_logout_redirect; ; |
|
31 | 31 | |
32 | - if ( empty( $login_redirect ) ) { |
|
32 | + if (empty($login_redirect)) { |
|
33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $logout_redirect ) ) { |
|
37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
36 | + if (empty($logout_redirect)) { |
|
37 | + $logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | $logout_redirect = add_query_arg( |
43 | 43 | array( |
44 | 44 | 'give_action' => 'user_logout', |
45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
45 | + 'give_logout_nonce' => wp_create_nonce('give-logout-nonce'), |
|
46 | + 'give_logout_redirect' => urlencode($logout_redirect) |
|
47 | 47 | ), |
48 | 48 | home_url('/') |
49 | 49 | ); |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | |
54 | 54 | ob_start(); |
55 | 55 | |
56 | - give_get_template_part( 'shortcode', 'login' ); |
|
56 | + give_get_template_part('shortcode', 'login'); |
|
57 | 57 | |
58 | - return apply_filters( 'give_login_form', ob_get_clean() ); |
|
58 | + return apply_filters('give_login_form', ob_get_clean()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return string Register form |
71 | 71 | */ |
72 | -function give_register_form( $redirect = '' ) { |
|
72 | +function give_register_form($redirect = '') { |
|
73 | 73 | global $give_options, $give_register_redirect; |
74 | 74 | |
75 | - if ( empty( $redirect ) ) { |
|
75 | + if (empty($redirect)) { |
|
76 | 76 | $redirect = give_get_current_page_url(); |
77 | 77 | } |
78 | 78 | |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | |
81 | 81 | ob_start(); |
82 | 82 | |
83 | - if ( ! is_user_logged_in() ) { |
|
84 | - give_get_template_part( 'shortcode', 'register' ); |
|
83 | + if ( ! is_user_logged_in()) { |
|
84 | + give_get_template_part('shortcode', 'register'); |
|
85 | 85 | } |
86 | 86 | |
87 | - return apply_filters( 'give_register_form', ob_get_clean() ); |
|
87 | + return apply_filters('give_register_form', ob_get_clean()); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -96,34 +96,34 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return void |
98 | 98 | */ |
99 | -function give_process_login_form( $data ) { |
|
100 | - if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) { |
|
101 | - $user_data = get_user_by( 'login', $data['give_user_login'] ); |
|
102 | - if ( ! $user_data ) { |
|
103 | - $user_data = get_user_by( 'email', $data['give_user_login'] ); |
|
99 | +function give_process_login_form($data) { |
|
100 | + if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) { |
|
101 | + $user_data = get_user_by('login', $data['give_user_login']); |
|
102 | + if ( ! $user_data) { |
|
103 | + $user_data = get_user_by('email', $data['give_user_login']); |
|
104 | 104 | } |
105 | - if ( $user_data ) { |
|
105 | + if ($user_data) { |
|
106 | 106 | $user_ID = $user_data->ID; |
107 | 107 | $user_email = $user_data->user_email; |
108 | - if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_data->ID ) ) { |
|
109 | - give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] ); |
|
108 | + if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_data->ID)) { |
|
109 | + give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']); |
|
110 | 110 | } else { |
111 | - give_set_error( 'password_incorrect', esc_html__( 'The password you entered is incorrect.', 'give' ) ); |
|
111 | + give_set_error('password_incorrect', esc_html__('The password you entered is incorrect.', 'give')); |
|
112 | 112 | } |
113 | 113 | } else { |
114 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
114 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
115 | 115 | } |
116 | 116 | // Check for errors and redirect if none present |
117 | 117 | $errors = give_get_errors(); |
118 | - if ( ! $errors ) { |
|
119 | - $redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID ); |
|
120 | - wp_redirect( $redirect ); |
|
118 | + if ( ! $errors) { |
|
119 | + $redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID); |
|
120 | + wp_redirect($redirect); |
|
121 | 121 | give_die(); |
122 | 122 | } |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | -add_action( 'give_user_login', 'give_process_login_form' ); |
|
126 | +add_action('give_user_login', 'give_process_login_form'); |
|
127 | 127 | |
128 | 128 | |
129 | 129 | /** |
@@ -135,18 +135,18 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_process_user_logout( $data ) { |
|
139 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
138 | +function give_process_user_logout($data) { |
|
139 | + if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) { |
|
140 | 140 | |
141 | 141 | // Prevent occurring of any custom action on wp_logout. |
142 | - remove_all_actions( 'wp_logout' ); |
|
142 | + remove_all_actions('wp_logout'); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Fires before processing user logout. |
146 | 146 | * |
147 | 147 | * @since 1.0 |
148 | 148 | */ |
149 | - do_action( 'give_before_user_logout' ); |
|
149 | + do_action('give_before_user_logout'); |
|
150 | 150 | |
151 | 151 | // Logout user. |
152 | 152 | wp_logout(); |
@@ -156,14 +156,14 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @since 1.0 |
158 | 158 | */ |
159 | - do_action( 'give_after_user_logout' ); |
|
159 | + do_action('give_after_user_logout'); |
|
160 | 160 | |
161 | - wp_redirect( $data['give_logout_redirect'] ); |
|
161 | + wp_redirect($data['give_logout_redirect']); |
|
162 | 162 | give_die(); |
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | -add_action( 'give_user_logout', 'give_process_user_logout' ); |
|
166 | +add_action('give_user_logout', 'give_process_user_logout'); |
|
167 | 167 | |
168 | 168 | /** |
169 | 169 | * Log User In |
@@ -176,13 +176,13 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return void |
178 | 178 | */ |
179 | -function give_log_user_in( $user_id, $user_login, $user_pass ) { |
|
180 | - if ( $user_id < 1 ) { |
|
179 | +function give_log_user_in($user_id, $user_login, $user_pass) { |
|
180 | + if ($user_id < 1) { |
|
181 | 181 | return; |
182 | 182 | } |
183 | 183 | |
184 | - wp_set_auth_cookie( $user_id ); |
|
185 | - wp_set_current_user( $user_id, $user_login ); |
|
184 | + wp_set_auth_cookie($user_id); |
|
185 | + wp_set_current_user($user_id, $user_login); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Fires after the user has successfully logged in. |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param string $user_login Username. |
193 | 193 | * @param WP_User $$user WP_User object of the logged-in user. |
194 | 194 | */ |
195 | - do_action( 'wp_login', $user_login, get_userdata( $user_id ) ); |
|
195 | + do_action('wp_login', $user_login, get_userdata($user_id)); |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Fires after give user has successfully logged in. |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param string $user_login Username. |
204 | 204 | * @param string $user_pass User password. |
205 | 205 | */ |
206 | - do_action( 'give_log_user_in', $user_id, $user_login, $user_pass ); |
|
206 | + do_action('give_log_user_in', $user_id, $user_login, $user_pass); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return void |
218 | 218 | */ |
219 | -function give_process_register_form( $data ) { |
|
219 | +function give_process_register_form($data) { |
|
220 | 220 | |
221 | - if ( is_user_logged_in() ) { |
|
221 | + if (is_user_logged_in()) { |
|
222 | 222 | return; |
223 | 223 | } |
224 | 224 | |
225 | - if ( empty( $_POST['give_register_submit'] ) ) { |
|
225 | + if (empty($_POST['give_register_submit'])) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
@@ -231,38 +231,38 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @since 1.0 |
233 | 233 | */ |
234 | - do_action( 'give_pre_process_register_form' ); |
|
234 | + do_action('give_pre_process_register_form'); |
|
235 | 235 | |
236 | - if ( empty( $data['give_user_login'] ) ) { |
|
237 | - give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) ); |
|
236 | + if (empty($data['give_user_login'])) { |
|
237 | + give_set_error('empty_username', esc_html__('Invalid username.', 'give')); |
|
238 | 238 | } |
239 | 239 | |
240 | - if ( username_exists( $data['give_user_login'] ) ) { |
|
241 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
240 | + if (username_exists($data['give_user_login'])) { |
|
241 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
242 | 242 | } |
243 | 243 | |
244 | - if ( ! validate_username( $data['give_user_login'] ) ) { |
|
245 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
244 | + if ( ! validate_username($data['give_user_login'])) { |
|
245 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( email_exists( $data['give_user_email'] ) ) { |
|
249 | - give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) ); |
|
248 | + if (email_exists($data['give_user_email'])) { |
|
249 | + give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give')); |
|
250 | 250 | } |
251 | 251 | |
252 | - if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) { |
|
253 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
252 | + if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) { |
|
253 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
254 | 254 | } |
255 | 255 | |
256 | - if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) { |
|
257 | - give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) ); |
|
256 | + if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) { |
|
257 | + give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give')); |
|
258 | 258 | } |
259 | 259 | |
260 | - if ( empty( $_POST['give_user_pass'] ) ) { |
|
261 | - give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) ); |
|
260 | + if (empty($_POST['give_user_pass'])) { |
|
261 | + give_set_error('empty_password', esc_html__('Please enter a password.', 'give')); |
|
262 | 262 | } |
263 | 263 | |
264 | - if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) { |
|
265 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
264 | + if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) { |
|
265 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -270,26 +270,26 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @since 1.0 |
272 | 272 | */ |
273 | - do_action( 'give_process_register_form' ); |
|
273 | + do_action('give_process_register_form'); |
|
274 | 274 | |
275 | 275 | // Check for errors and redirect if none present |
276 | 276 | $errors = give_get_errors(); |
277 | 277 | |
278 | - if ( empty( $errors ) ) { |
|
278 | + if (empty($errors)) { |
|
279 | 279 | |
280 | - $redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] ); |
|
280 | + $redirect = apply_filters('give_register_redirect', $data['give_redirect']); |
|
281 | 281 | |
282 | - give_register_and_login_new_user( array( |
|
282 | + give_register_and_login_new_user(array( |
|
283 | 283 | 'user_login' => $data['give_user_login'], |
284 | 284 | 'user_pass' => $data['give_user_pass'], |
285 | 285 | 'user_email' => $data['give_user_email'], |
286 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
287 | - 'role' => get_option( 'default_role' ) |
|
288 | - ) ); |
|
286 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
287 | + 'role' => get_option('default_role') |
|
288 | + )); |
|
289 | 289 | |
290 | - wp_redirect( $redirect ); |
|
290 | + wp_redirect($redirect); |
|
291 | 291 | give_die(); |
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
295 | -add_action( 'give_user_register', 'give_process_register_form' ); |
|
296 | 295 | \ No newline at end of file |
296 | +add_action('give_user_register', 'give_process_register_form'); |
|
297 | 297 | \ No newline at end of file |
@@ -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: 1: Paypal parent transaction ID 2. Paypal reason code */ |
600 | - esc_html__( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), |
|
600 | + esc_html__('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), |
|
601 | 601 | $data['parent_txn_id'], |
602 | 602 | $data['reason_code'] |
603 | 603 | ) |
@@ -606,11 +606,11 @@ discard block |
||
606 | 606 | $payment_id, |
607 | 607 | sprintf( |
608 | 608 | /* translators: %s: Paypal transaction ID */ |
609 | - esc_html__( 'PayPal Refund Transaction ID: %s', 'give' ), |
|
609 | + esc_html__('PayPal Refund Transaction ID: %s', 'give'), |
|
610 | 610 | $data['txn_id'] |
611 | 611 | ) |
612 | 612 | ); |
613 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
613 | + give_update_payment_status($payment_id, 'refunded'); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | /** |
@@ -622,24 +622,24 @@ discard block |
||
622 | 622 | * |
623 | 623 | * @return string |
624 | 624 | */ |
625 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
625 | +function give_get_paypal_redirect($ssl_check = false) { |
|
626 | 626 | |
627 | - if ( is_ssl() || ! $ssl_check ) { |
|
627 | + if (is_ssl() || ! $ssl_check) { |
|
628 | 628 | $protocal = 'https://'; |
629 | 629 | } else { |
630 | 630 | $protocal = 'http://'; |
631 | 631 | } |
632 | 632 | |
633 | 633 | // Check the current payment mode |
634 | - if ( give_is_test_mode() ) { |
|
634 | + if (give_is_test_mode()) { |
|
635 | 635 | // Test mode |
636 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
636 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
637 | 637 | } else { |
638 | 638 | // Live mode |
639 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
639 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
640 | 640 | } |
641 | 641 | |
642 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
642 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
@@ -649,8 +649,8 @@ discard block |
||
649 | 649 | * @return string |
650 | 650 | */ |
651 | 651 | function give_get_paypal_page_style() { |
652 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
653 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
652 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
653 | + return apply_filters('give_paypal_page_style', $page_style); |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | /** |
@@ -665,27 +665,27 @@ discard block |
||
665 | 665 | * @return string |
666 | 666 | * |
667 | 667 | */ |
668 | -function give_paypal_success_page_content( $content ) { |
|
668 | +function give_paypal_success_page_content($content) { |
|
669 | 669 | |
670 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
670 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
671 | 671 | return $content; |
672 | 672 | } |
673 | 673 | |
674 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
674 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
675 | 675 | |
676 | - if ( ! $payment_id ) { |
|
676 | + if ( ! $payment_id) { |
|
677 | 677 | $session = give_get_purchase_session(); |
678 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
678 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
679 | 679 | } |
680 | 680 | |
681 | - $payment = get_post( $payment_id ); |
|
681 | + $payment = get_post($payment_id); |
|
682 | 682 | |
683 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
683 | + if ($payment && 'pending' == $payment->post_status) { |
|
684 | 684 | |
685 | 685 | // Payment is still pending so show processing indicator to fix the Race Condition |
686 | 686 | ob_start(); |
687 | 687 | |
688 | - give_get_template_part( 'payment', 'processing' ); |
|
688 | + give_get_template_part('payment', 'processing'); |
|
689 | 689 | |
690 | 690 | $content = ob_get_clean(); |
691 | 691 | |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | |
696 | 696 | } |
697 | 697 | |
698 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
698 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
699 | 699 | |
700 | 700 | /** |
701 | 701 | * Given a Payment ID, extract the transaction ID |
@@ -706,22 +706,22 @@ discard block |
||
706 | 706 | * |
707 | 707 | * @return string Transaction ID |
708 | 708 | */ |
709 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
709 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
710 | 710 | |
711 | 711 | $transaction_id = ''; |
712 | - $notes = give_get_payment_notes( $payment_id ); |
|
712 | + $notes = give_get_payment_notes($payment_id); |
|
713 | 713 | |
714 | - foreach ( $notes as $note ) { |
|
715 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
714 | + foreach ($notes as $note) { |
|
715 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
716 | 716 | $transaction_id = $match[1]; |
717 | 717 | continue; |
718 | 718 | } |
719 | 719 | } |
720 | 720 | |
721 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
721 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
722 | 722 | } |
723 | 723 | |
724 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
724 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
725 | 725 | |
726 | 726 | /** |
727 | 727 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -733,13 +733,13 @@ discard block |
||
733 | 733 | * |
734 | 734 | * @return string A link to the PayPal transaction details |
735 | 735 | */ |
736 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
736 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
737 | 737 | |
738 | 738 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
739 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
739 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
740 | 740 | |
741 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
741 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
742 | 742 | |
743 | 743 | } |
744 | 744 | |
745 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
745 | +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 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.0 |
21 | 21 | * @return void |
22 | 22 | */ |
23 | -add_action( 'give_manual_cc_form', '__return_false' ); |
|
23 | +add_action('give_manual_cc_form', '__return_false'); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Processes the purchase data and uses the Manual Payment gateway to record |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_manual_payment( $purchase_data ) { |
|
35 | +function give_manual_payment($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 | 41 | //Create payment_data array |
42 | 42 | $payment_data = array( |
43 | 43 | 'price' => $purchase_data['price'], |
44 | 44 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
45 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
45 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
46 | 46 | 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
47 | 47 | 'date' => $purchase_data['date'], |
48 | 48 | 'user_email' => $purchase_data['user_email'], |
@@ -52,24 +52,24 @@ discard block |
||
52 | 52 | 'status' => 'pending' |
53 | 53 | ); |
54 | 54 | // Record the pending payment |
55 | - $payment = give_insert_payment( $payment_data ); |
|
55 | + $payment = give_insert_payment($payment_data); |
|
56 | 56 | |
57 | - if ( $payment ) { |
|
58 | - give_update_payment_status( $payment, 'publish' ); |
|
57 | + if ($payment) { |
|
58 | + give_update_payment_status($payment, 'publish'); |
|
59 | 59 | give_send_to_success_page(); |
60 | 60 | } else { |
61 | 61 | give_record_gateway_error( |
62 | - esc_html__( 'Payment Error', 'give' ), |
|
62 | + esc_html__('Payment Error', 'give'), |
|
63 | 63 | sprintf( |
64 | 64 | /* translators: %s: payment data */ |
65 | - esc_html__( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ), |
|
66 | - json_encode( $payment_data ) |
|
65 | + esc_html__('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'), |
|
66 | + json_encode($payment_data) |
|
67 | 67 | ), |
68 | 68 | $payment |
69 | 69 | ); |
70 | 70 | // If errors are present, send the user back to the purchase page so they can be corrected |
71 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
71 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | -add_action( 'give_gateway_manual', 'give_manual_payment' ); |
|
75 | +add_action('give_gateway_manual', 'give_manual_payment'); |
@@ -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_attr__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ) |
|
24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_attr__('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_attr__( '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_attr__('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,52 +204,52 @@ 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_attr__( 'New Pending Donation', 'give' ), $payment_id ); |
|
224 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', esc_attr__('New Pending Donation', 'give'), $payment_id); |
|
225 | 225 | |
226 | - $admin_message = esc_attr__( 'Dear Admin,', 'give' ) . "\n\n"; |
|
227 | - $admin_message .= esc_attr__( 'An offline donation has been made on your website:', 'give' ) . ' ' . get_bloginfo( 'name' ) . ' '; |
|
228 | - $admin_message .= esc_attr__( '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_attr__('Dear Admin,', 'give')."\n\n"; |
|
227 | + $admin_message .= esc_attr__('An offline donation has been made on your website:', 'give').' '.get_bloginfo('name').' '; |
|
228 | + $admin_message .= esc_attr__('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_attr__( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
232 | - $admin_message .= '<strong>' . esc_attr__( 'Amount:', 'give' ) . '</strong> {price}' . "\n\n"; |
|
231 | + $admin_message .= '<strong>'.esc_attr__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
232 | + $admin_message .= '<strong>'.esc_attr__('Amount:', 'give').'</strong> {price}'."\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 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
240 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
241 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
242 | 242 | |
243 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
244 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
243 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
244 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
245 | 245 | |
246 | 246 | //Send Email |
247 | 247 | $emails = Give()->emails; |
248 | - if ( ! empty( $admin_headers ) ) { |
|
249 | - $emails->__set( 'headers', $admin_headers ); |
|
248 | + if ( ! empty($admin_headers)) { |
|
249 | + $emails->__set('headers', $admin_headers); |
|
250 | 250 | } |
251 | 251 | |
252 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
252 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
253 | 253 | |
254 | 254 | } |
255 | 255 | |
@@ -260,15 +260,15 @@ discard block |
||
260 | 260 | * @since 1.0 |
261 | 261 | * @return array |
262 | 262 | */ |
263 | -function give_offline_add_settings( $settings ) { |
|
263 | +function give_offline_add_settings($settings) { |
|
264 | 264 | |
265 | 265 | //Vars |
266 | 266 | $prefix = '_give_'; |
267 | 267 | |
268 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
268 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
269 | 269 | |
270 | 270 | //this gateway isn't active |
271 | - if ( ! $is_gateway_active ) { |
|
271 | + if ( ! $is_gateway_active) { |
|
272 | 272 | //return settings and bounce |
273 | 273 | return $settings; |
274 | 274 | } |
@@ -277,27 +277,27 @@ discard block |
||
277 | 277 | $check_settings = array( |
278 | 278 | |
279 | 279 | array( |
280 | - 'name' => esc_attr__( 'Customize Offline Donations', 'give' ), |
|
281 | - 'desc' => esc_attr__( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ), |
|
282 | - 'id' => $prefix . 'customize_offline_donations', |
|
280 | + 'name' => esc_attr__('Customize Offline Donations', 'give'), |
|
281 | + 'desc' => esc_attr__('If you would like to customize the donation instructions for this specific forms check this option.', 'give'), |
|
282 | + 'id' => $prefix.'customize_offline_donations', |
|
283 | 283 | 'type' => 'radio_inline', |
284 | 284 | 'default' => 'no', |
285 | 285 | 'options' => array( |
286 | - 'yes' => esc_attr__( 'Yes', 'give' ), |
|
287 | - 'no' => esc_attr__( 'No', 'give' ), |
|
286 | + 'yes' => esc_attr__('Yes', 'give'), |
|
287 | + 'no' => esc_attr__('No', 'give'), |
|
288 | 288 | ), |
289 | 289 | ), |
290 | 290 | array( |
291 | - 'name' => esc_attr__( 'Request Billing Information', 'give' ), |
|
292 | - 'desc' => esc_attr__( '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' ), |
|
293 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
291 | + 'name' => esc_attr__('Request Billing Information', 'give'), |
|
292 | + 'desc' => esc_attr__('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'), |
|
293 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
294 | 294 | 'row_classes' => 'give-subfield', |
295 | 295 | 'type' => 'checkbox' |
296 | 296 | ), |
297 | 297 | array( |
298 | - 'id' => $prefix . 'offline_checkout_notes', |
|
299 | - 'name' => esc_attr__( 'Offline Donation Instructions', 'give' ), |
|
300 | - 'desc' => esc_attr__( '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' ), |
|
298 | + 'id' => $prefix.'offline_checkout_notes', |
|
299 | + 'name' => esc_attr__('Offline Donation Instructions', 'give'), |
|
300 | + 'desc' => esc_attr__('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'), |
|
301 | 301 | 'default' => give_get_default_offline_donation_content(), |
302 | 302 | 'type' => 'wysiwyg', |
303 | 303 | 'row_classes' => 'give-subfield', |
@@ -306,17 +306,17 @@ discard block |
||
306 | 306 | ) |
307 | 307 | ), |
308 | 308 | array( |
309 | - 'id' => $prefix . 'offline_donation_subject', |
|
310 | - 'name' => esc_attr__( 'Offline Donation Email Instructions Subject', 'give' ), |
|
311 | - 'desc' => esc_attr__( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
312 | - 'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ), |
|
309 | + 'id' => $prefix.'offline_donation_subject', |
|
310 | + 'name' => esc_attr__('Offline Donation Email Instructions Subject', 'give'), |
|
311 | + 'desc' => esc_attr__('Enter the subject line for the donation receipt email.', 'give'), |
|
312 | + 'default' => esc_attr__('{donation} - Offline Donation Instructions', 'give'), |
|
313 | 313 | 'row_classes' => 'give-subfield', |
314 | 314 | 'type' => 'text' |
315 | 315 | ), |
316 | 316 | array( |
317 | - 'id' => $prefix . 'offline_donation_email', |
|
318 | - 'name' => esc_attr__( 'Offline Donation Email Instructions', 'give' ), |
|
319 | - 'desc' => esc_attr__( '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' ), |
|
317 | + 'id' => $prefix.'offline_donation_email', |
|
318 | + 'name' => esc_attr__('Offline Donation Email Instructions', 'give'), |
|
319 | + 'desc' => esc_attr__('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'), |
|
320 | 320 | 'default' => give_get_default_offline_donation_email_content(), |
321 | 321 | 'type' => 'wysiwyg', |
322 | 322 | 'row_classes' => 'give-subfield', |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | ) |
327 | 327 | ); |
328 | 328 | |
329 | - return array_merge( $settings, $check_settings ); |
|
329 | + return array_merge($settings, $check_settings); |
|
330 | 330 | } |
331 | 331 | |
332 | -add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' ); |
|
332 | +add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings'); |
|
333 | 333 | |
334 | 334 | |
335 | 335 | /** |
@@ -341,32 +341,32 @@ discard block |
||
341 | 341 | */ |
342 | 342 | function give_get_default_offline_donation_content() { |
343 | 343 | |
344 | - $sitename = get_bloginfo( 'sitename' ); |
|
344 | + $sitename = get_bloginfo('sitename'); |
|
345 | 345 | |
346 | - $default_text = '<p>' . esc_attr__( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
346 | + $default_text = '<p>'.esc_attr__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
347 | 347 | $default_text .= '<ol>'; |
348 | 348 | $default_text .= '<li>'; |
349 | 349 | $default_text .= sprintf( |
350 | 350 | /* translators: %s: site name */ |
351 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
351 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
352 | 352 | $sitename |
353 | 353 | ); |
354 | 354 | $default_text .= '</li>'; |
355 | 355 | $default_text .= '<li>'; |
356 | 356 | $default_text .= sprintf( |
357 | 357 | /* translators: %s: site name */ |
358 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
358 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
359 | 359 | $sitename |
360 | 360 | ); |
361 | 361 | $default_text .= '</li>'; |
362 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
362 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
363 | 363 | $default_text .= '</ol>'; |
364 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
364 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
365 | 365 | $default_text .= ' <em>123 G Street </em><br>'; |
366 | 366 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
367 | - $default_text .= '<p>' . esc_attr__( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
367 | + $default_text .= '<p>'.esc_attr__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
368 | 368 | |
369 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
369 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
370 | 370 | |
371 | 371 | } |
372 | 372 | |
@@ -379,33 +379,33 @@ discard block |
||
379 | 379 | */ |
380 | 380 | function give_get_default_offline_donation_email_content() { |
381 | 381 | |
382 | - $sitename = get_bloginfo( 'sitename' ); |
|
383 | - $default_text = '<p>' . esc_html__( 'Dear {name},', 'give' ) . '</p>'; |
|
384 | - $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>'; |
|
382 | + $sitename = get_bloginfo('sitename'); |
|
383 | + $default_text = '<p>'.esc_html__('Dear {name},', 'give').'</p>'; |
|
384 | + $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>'; |
|
385 | 385 | $default_text .= '<ol>'; |
386 | 386 | $default_text .= '<li>'; |
387 | 387 | $default_text .= sprintf( |
388 | 388 | /* translators: %s: site name */ |
389 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
389 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
390 | 390 | $sitename |
391 | 391 | ); |
392 | 392 | $default_text .= '</li>'; |
393 | 393 | $default_text .= '<li>'; |
394 | 394 | $default_text .= sprintf( |
395 | 395 | /* translators: %s: site name */ |
396 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
396 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
397 | 397 | $sitename |
398 | 398 | ); |
399 | 399 | $default_text .= '</li>'; |
400 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
400 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
401 | 401 | $default_text .= '</ol>'; |
402 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
402 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
403 | 403 | $default_text .= ' <em>123 G Street </em><br>'; |
404 | 404 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
405 | - $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>'; |
|
406 | - $default_text .= '<p>' . esc_html__( 'Sincerely,', 'give' ) . '</p>'; |
|
407 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
405 | + $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>'; |
|
406 | + $default_text .= '<p>'.esc_html__('Sincerely,', 'give').'</p>'; |
|
407 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
408 | 408 | |
409 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
409 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
410 | 410 | |
411 | 411 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,94 +26,94 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function give_load_scripts() { |
28 | 28 | |
29 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/'; |
|
30 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
31 | - $scripts_footer = ( give_get_option( 'scripts_footer' ) == 'on' ) ? true : false; |
|
29 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/frontend/'; |
|
30 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
31 | + $scripts_footer = (give_get_option('scripts_footer') == 'on') ? true : false; |
|
32 | 32 | |
33 | 33 | // Use minified libraries if SCRIPT_DEBUG is turned off |
34 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
34 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
35 | 35 | |
36 | 36 | //Localize / PHP to AJAX vars |
37 | - $localize_give_checkout = apply_filters( 'give_global_script_vars', array( |
|
37 | + $localize_give_checkout = apply_filters('give_global_script_vars', array( |
|
38 | 38 | 'ajaxurl' => give_get_ajax_url(), |
39 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
40 | - 'currency_sign' => give_currency_filter( '' ), |
|
39 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
40 | + 'currency_sign' => give_currency_filter(''), |
|
41 | 41 | 'currency_pos' => give_get_currency_position(), |
42 | 42 | 'thousands_separator' => give_get_price_thousand_separator(), |
43 | 43 | 'decimal_separator' => give_get_price_decimal_separator(), |
44 | - 'no_gateway' => esc_html__( 'Please select a payment method.', 'give' ), |
|
45 | - 'bad_minimum' => esc_html__( 'The minimum donation amount for this form is', 'give' ), |
|
46 | - 'general_loading' => esc_html__( 'Loading...', 'give' ), |
|
47 | - 'purchase_loading' => esc_html__( 'Please Wait...', 'give' ), |
|
44 | + 'no_gateway' => esc_html__('Please select a payment method.', 'give'), |
|
45 | + 'bad_minimum' => esc_html__('The minimum donation amount for this form is', 'give'), |
|
46 | + 'general_loading' => esc_html__('Loading...', 'give'), |
|
47 | + 'purchase_loading' => esc_html__('Please Wait...', 'give'), |
|
48 | 48 | 'number_decimals' => give_get_price_decimals(), |
49 | 49 | 'give_version' => GIVE_VERSION |
50 | - ) ); |
|
51 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
50 | + )); |
|
51 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
52 | 52 | 'ajaxurl' => give_get_ajax_url(), |
53 | - 'loading' => esc_html__( 'Loading', 'give' ), |
|
53 | + 'loading' => esc_html__('Loading', 'give'), |
|
54 | 54 | // General loading message |
55 | - 'select_option' => esc_html__( 'Please select an option', 'give' ), |
|
55 | + 'select_option' => esc_html__('Please select an option', 'give'), |
|
56 | 56 | // Variable pricing error with multi-purchase option enabled |
57 | - 'default_gateway' => give_get_default_gateway( null ), |
|
58 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
57 | + 'default_gateway' => give_get_default_gateway(null), |
|
58 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
59 | 59 | 'number_decimals' => give_get_price_decimals() |
60 | - ) ); |
|
60 | + )); |
|
61 | 61 | |
62 | 62 | //DEBUG is On |
63 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
63 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
64 | 64 | |
65 | - if ( give_is_cc_verify_enabled() ) { |
|
66 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
67 | - wp_enqueue_script( 'give-cc-validator' ); |
|
65 | + if (give_is_cc_verify_enabled()) { |
|
66 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
67 | + wp_enqueue_script('give-cc-validator'); |
|
68 | 68 | } |
69 | 69 | |
70 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
71 | - wp_enqueue_script( 'give-float-labels' ); |
|
70 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
71 | + wp_enqueue_script('give-float-labels'); |
|
72 | 72 | |
73 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
74 | - wp_enqueue_script( 'give-blockui' ); |
|
73 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
74 | + wp_enqueue_script('give-blockui'); |
|
75 | 75 | |
76 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
77 | - wp_enqueue_script( 'give-qtip' ); |
|
76 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
77 | + wp_enqueue_script('give-qtip'); |
|
78 | 78 | |
79 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
80 | - wp_enqueue_script( 'give-accounting' ); |
|
79 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
80 | + wp_enqueue_script('give-accounting'); |
|
81 | 81 | |
82 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
83 | - wp_enqueue_script( 'give-magnific' ); |
|
82 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
83 | + wp_enqueue_script('give-magnific'); |
|
84 | 84 | |
85 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
86 | - wp_enqueue_script( 'give-checkout-global' ); |
|
85 | + wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
86 | + wp_enqueue_script('give-checkout-global'); |
|
87 | 87 | |
88 | 88 | //General scripts |
89 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
90 | - wp_enqueue_script( 'give-scripts' ); |
|
89 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
90 | + wp_enqueue_script('give-scripts'); |
|
91 | 91 | |
92 | 92 | // Load AJAX scripts, if enabled |
93 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
94 | - wp_enqueue_script( 'give-ajax' ); |
|
93 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
94 | + wp_enqueue_script('give-ajax'); |
|
95 | 95 | |
96 | 96 | //Localize / Pass AJAX vars from PHP |
97 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_checkout ); |
|
98 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
97 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_checkout); |
|
98 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
99 | 99 | |
100 | 100 | |
101 | 101 | } else { |
102 | 102 | |
103 | 103 | //DEBUG is OFF (one JS file to rule them all!) |
104 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
105 | - wp_enqueue_script( 'give' ); |
|
104 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
105 | + wp_enqueue_script('give'); |
|
106 | 106 | |
107 | 107 | //Localize / Pass AJAX vars from PHP |
108 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_checkout ); |
|
109 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
108 | + wp_localize_script('give', 'give_global_vars', $localize_give_checkout); |
|
109 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
110 | 110 | |
111 | 111 | } |
112 | 112 | |
113 | 113 | |
114 | 114 | } |
115 | 115 | |
116 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
116 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Register styles. |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function give_register_styles() { |
127 | 127 | |
128 | - if ( give_get_option( 'disable_css', false ) ) { |
|
128 | + if (give_get_option('disable_css', false)) { |
|
129 | 129 | return; |
130 | 130 | } |
131 | 131 | |
132 | - wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
133 | - wp_enqueue_style( 'give-styles' ); |
|
132 | + wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
133 | + wp_enqueue_style('give-styles'); |
|
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
137 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
138 | 138 | |
139 | 139 | |
140 | 140 | /** |
@@ -146,39 +146,39 @@ discard block |
||
146 | 146 | function give_get_stylesheet_uri() { |
147 | 147 | |
148 | 148 | // Use minified libraries if SCRIPT_DEBUG is turned off |
149 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
149 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
150 | 150 | |
151 | - $file = 'give' . $suffix . '.css'; |
|
151 | + $file = 'give'.$suffix.'.css'; |
|
152 | 152 | $templates_dir = give_get_theme_template_dir_name(); |
153 | 153 | |
154 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
155 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give.css'; |
|
156 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
157 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give.css'; |
|
158 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
154 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
155 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give.css'; |
|
156 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
157 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give.css'; |
|
158 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
159 | 159 | |
160 | 160 | $uri = false; |
161 | 161 | |
162 | 162 | // Look in the child theme directory first, followed by the parent theme, followed by the Give core templates directory |
163 | 163 | // Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
164 | 164 | // This allows users to copy just give.css to their theme |
165 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
166 | - if ( ! empty( $nonmin ) ) { |
|
167 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give.css'; |
|
165 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
166 | + if ( ! empty($nonmin)) { |
|
167 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give.css'; |
|
168 | 168 | } else { |
169 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
169 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
170 | 170 | } |
171 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
172 | - if ( ! empty( $nonmin ) ) { |
|
173 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give.css'; |
|
171 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
172 | + if ( ! empty($nonmin)) { |
|
173 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give.css'; |
|
174 | 174 | } else { |
175 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
175 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
176 | 176 | } |
177 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
178 | - $uri = trailingslashit( give_get_templates_url() ) . $file; |
|
177 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
178 | + $uri = trailingslashit(give_get_templates_url()).$file; |
|
179 | 179 | } |
180 | 180 | |
181 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
181 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
182 | 182 | |
183 | 183 | } |
184 | 184 | |
@@ -196,65 +196,65 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return void |
198 | 198 | */ |
199 | -function give_load_admin_scripts( $hook ) { |
|
199 | +function give_load_admin_scripts($hook) { |
|
200 | 200 | |
201 | 201 | global $wp_version, $post, $post_type, $give_options; |
202 | 202 | |
203 | 203 | //Directories of assets |
204 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
205 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
206 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
204 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
205 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
206 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
207 | 207 | |
208 | 208 | // Use minified libraries if SCRIPT_DEBUG is turned off |
209 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
209 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
210 | 210 | |
211 | 211 | //Global Admin: |
212 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
213 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
212 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
213 | + wp_enqueue_style('give-admin-bar-notification'); |
|
214 | 214 | |
215 | 215 | //Give Admin Only: |
216 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
216 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
220 | 220 | //CSS |
221 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
222 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
223 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $suffix . '.css', GIVE_VERSION ); |
|
224 | - wp_enqueue_style( 'give-admin' ); |
|
225 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
226 | - wp_enqueue_style( 'jquery-chosen' ); |
|
227 | - wp_enqueue_style( 'thickbox' ); |
|
221 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
222 | + wp_enqueue_style('jquery-ui-css'); |
|
223 | + wp_register_style('give-admin', $css_dir.'give-admin'.$suffix.'.css', GIVE_VERSION); |
|
224 | + wp_enqueue_style('give-admin'); |
|
225 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
226 | + wp_enqueue_style('jquery-chosen'); |
|
227 | + wp_enqueue_style('thickbox'); |
|
228 | 228 | |
229 | 229 | //JS |
230 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
231 | - wp_enqueue_script( 'jquery-chosen' ); |
|
230 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
231 | + wp_enqueue_script('jquery-chosen'); |
|
232 | 232 | |
233 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
234 | - wp_enqueue_script( 'give-accounting' ); |
|
233 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
234 | + wp_enqueue_script('give-accounting'); |
|
235 | 235 | |
236 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
237 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
236 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
237 | + wp_enqueue_script('give-admin-scripts'); |
|
238 | 238 | |
239 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
240 | - wp_enqueue_script( 'jquery-flot' ); |
|
239 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
240 | + wp_enqueue_script('jquery-flot'); |
|
241 | 241 | |
242 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
243 | - wp_enqueue_script( 'give-qtip' ); |
|
242 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
243 | + wp_enqueue_script('give-qtip'); |
|
244 | 244 | |
245 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
246 | - wp_enqueue_script( 'thickbox' ); |
|
245 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
246 | + wp_enqueue_script('thickbox'); |
|
247 | 247 | |
248 | 248 | // Forms CPT Script. |
249 | - if ( $post_type === 'give_forms' ) { |
|
250 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
251 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
249 | + if ($post_type === 'give_forms') { |
|
250 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
251 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | //Settings Scripts |
255 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) { |
|
256 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
257 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
255 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
256 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
257 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | // Price Separators. |
@@ -262,50 +262,50 @@ discard block |
||
262 | 262 | $decimal_separator = give_get_price_decimal_separator(); |
263 | 263 | |
264 | 264 | //Localize strings & variables for JS |
265 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
266 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
265 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
266 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
267 | 267 | 'give_version' => GIVE_VERSION, |
268 | 268 | 'thousands_separator' => $thousand_separator, |
269 | 269 | 'decimal_separator' => $decimal_separator, |
270 | - 'quick_edit_warning' => esc_html__( 'Not available for variable priced forms.', 'give' ), |
|
271 | - 'delete_payment' => esc_html__( 'Are you sure you wish to delete this payment?', 'give' ), |
|
272 | - 'delete_payment_note' => esc_html__( 'Are you sure you wish to delete this note?', 'give' ), |
|
273 | - 'revoke_api_key' => esc_html__( 'Are you sure you wish to revoke this API key?', 'give' ), |
|
274 | - 'regenerate_api_key' => esc_html__( 'Are you sure you wish to regenerate this API key?', 'give' ), |
|
275 | - 'resend_receipt' => esc_html__( 'Are you sure you wish to resend the donation receipt?', 'give' ), |
|
276 | - 'copy_download_link_text' => esc_html__( 'Copy these links to your clipboard and give them to your donor.', 'give' ), |
|
270 | + 'quick_edit_warning' => esc_html__('Not available for variable priced forms.', 'give'), |
|
271 | + 'delete_payment' => esc_html__('Are you sure you wish to delete this payment?', 'give'), |
|
272 | + 'delete_payment_note' => esc_html__('Are you sure you wish to delete this note?', 'give'), |
|
273 | + 'revoke_api_key' => esc_html__('Are you sure you wish to revoke this API key?', 'give'), |
|
274 | + 'regenerate_api_key' => esc_html__('Are you sure you wish to regenerate this API key?', 'give'), |
|
275 | + 'resend_receipt' => esc_html__('Are you sure you wish to resend the donation receipt?', 'give'), |
|
276 | + 'copy_download_link_text' => esc_html__('Copy these links to your clipboard and give them to your donor.', 'give'), |
|
277 | 277 | /* translators: %s: form singular label */ |
278 | - 'delete_payment_download' => sprintf( esc_html__( 'Are you sure you wish to delete this %s?', 'give' ), give_get_forms_label_singular() ), |
|
279 | - 'one_price_min' => esc_html__( 'You must have at least one price.', 'give' ), |
|
280 | - 'one_file_min' => esc_html__( 'You must have at least one file.', 'give' ), |
|
281 | - 'one_field_min' => esc_html__( 'You must have at least one field.', 'give' ), |
|
278 | + 'delete_payment_download' => sprintf(esc_html__('Are you sure you wish to delete this %s?', 'give'), give_get_forms_label_singular()), |
|
279 | + 'one_price_min' => esc_html__('You must have at least one price.', 'give'), |
|
280 | + 'one_file_min' => esc_html__('You must have at least one file.', 'give'), |
|
281 | + 'one_field_min' => esc_html__('You must have at least one field.', 'give'), |
|
282 | 282 | /* translators: %s: form singular label */ |
283 | - 'one_option' => sprintf( esc_html__( 'Choose a %s', 'give' ), give_get_forms_label_singular() ), |
|
283 | + 'one_option' => sprintf(esc_html__('Choose a %s', 'give'), give_get_forms_label_singular()), |
|
284 | 284 | /* translators: %s: form plural label */ |
285 | - 'one_or_more_option' => sprintf( esc_html__( 'Choose one or more %s', 'give' ), give_get_forms_label_plural() ), |
|
286 | - 'numeric_item_price' => esc_html__( 'Item price must be numeric.', 'give' ), |
|
287 | - 'numeric_quantity' => esc_html__( 'Quantity must be numeric.', 'give' ), |
|
288 | - 'currency_sign' => give_currency_filter( '' ), |
|
289 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
290 | - 'currency_decimals' => give_currency_decimal_filter( give_get_price_decimals() ), |
|
291 | - 'new_media_ui' => apply_filters( 'give_use_35_media_ui', 1 ), |
|
292 | - 'remove_text' => esc_html__( 'Remove', 'give' ), |
|
285 | + 'one_or_more_option' => sprintf(esc_html__('Choose one or more %s', 'give'), give_get_forms_label_plural()), |
|
286 | + 'numeric_item_price' => esc_html__('Item price must be numeric.', 'give'), |
|
287 | + 'numeric_quantity' => esc_html__('Quantity must be numeric.', 'give'), |
|
288 | + 'currency_sign' => give_currency_filter(''), |
|
289 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
290 | + 'currency_decimals' => give_currency_decimal_filter(give_get_price_decimals()), |
|
291 | + 'new_media_ui' => apply_filters('give_use_35_media_ui', 1), |
|
292 | + 'remove_text' => esc_html__('Remove', 'give'), |
|
293 | 293 | /* translators: %s: form plural label */ |
294 | - 'type_to_search' => sprintf( esc_html__( 'Type to search %s', 'give' ), give_get_forms_label_plural() ), |
|
295 | - 'batch_export_no_class' => esc_html__( 'You must choose a method.', 'give' ), |
|
296 | - 'batch_export_no_reqs' => esc_html__( 'Required fields not completed.', 'give' ), |
|
297 | - 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ), |
|
298 | - 'price_format_guide' => sprintf( esc_html__( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ) |
|
299 | - ) ); |
|
300 | - |
|
301 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( $wp_version, '3.5', '>=' ) ) { |
|
294 | + 'type_to_search' => sprintf(esc_html__('Type to search %s', 'give'), give_get_forms_label_plural()), |
|
295 | + 'batch_export_no_class' => esc_html__('You must choose a method.', 'give'), |
|
296 | + 'batch_export_no_reqs' => esc_html__('Required fields not completed.', 'give'), |
|
297 | + 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), |
|
298 | + 'price_format_guide' => sprintf(esc_html__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator) |
|
299 | + )); |
|
300 | + |
|
301 | + if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) { |
|
302 | 302 | //call for new media manager |
303 | 303 | wp_enqueue_media(); |
304 | 304 | } |
305 | 305 | |
306 | 306 | } |
307 | 307 | |
308 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
308 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
309 | 309 | |
310 | 310 | /** |
311 | 311 | * Admin Give Icon |
@@ -322,14 +322,14 @@ discard block |
||
322 | 322 | ?> |
323 | 323 | <style type="text/css" media="screen"> |
324 | 324 | |
325 | - <?php if( version_compare( $wp_version, '3.8-RC', '>=' ) || version_compare( $wp_version, '3.8', '>=' ) ) { ?> |
|
325 | + <?php if (version_compare($wp_version, '3.8-RC', '>=') || version_compare($wp_version, '3.8', '>=')) { ?> |
|
326 | 326 | @font-face { |
327 | 327 | font-family: 'give-icomoon'; |
328 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
329 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
330 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
331 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'), |
|
332 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
328 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
329 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
330 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
331 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'), |
|
332 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
333 | 333 | font-weight: normal; |
334 | 334 | font-style: normal; |
335 | 335 | } |
@@ -348,4 +348,4 @@ discard block |
||
348 | 348 | <?php |
349 | 349 | } |
350 | 350 | |
351 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
351 | +add_action('admin_head', 'give_admin_icon'); |
@@ -10,14 +10,14 @@ 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 |
17 | 17 | * |
18 | 18 | * @since 1.0 |
19 | 19 | */ |
20 | -class Give_Forms_Widget extends WP_Widget{ |
|
20 | +class Give_Forms_Widget extends WP_Widget { |
|
21 | 21 | /** |
22 | 22 | * The widget class name |
23 | 23 | * |
@@ -28,19 +28,19 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * Instantiate the class |
30 | 30 | */ |
31 | - public function __construct(){ |
|
32 | - $this->self = get_class( $this ); |
|
31 | + public function __construct() { |
|
32 | + $this->self = get_class($this); |
|
33 | 33 | |
34 | 34 | parent::__construct( |
35 | - strtolower( $this->self ), |
|
36 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
35 | + strtolower($this->self), |
|
36 | + esc_html__('Give - Donation Form', 'give'), |
|
37 | 37 | array( |
38 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
38 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
39 | 39 | ) |
40 | 40 | ); |
41 | 41 | |
42 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
43 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
42 | + add_action('widgets_init', array($this, 'widget_init')); |
|
43 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -50,23 +50,23 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return void |
52 | 52 | */ |
53 | - public function admin_widget_scripts( $hook ){ |
|
53 | + public function admin_widget_scripts($hook) { |
|
54 | 54 | // Directories of assets |
55 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
56 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
57 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
55 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
56 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
57 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
58 | 58 | |
59 | 59 | // Use minified libraries if SCRIPT_DEBUG is turned off |
60 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
60 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
61 | 61 | |
62 | 62 | // Widget Script |
63 | - if ( $hook == 'widgets.php' ) { |
|
63 | + if ($hook == 'widgets.php') { |
|
64 | 64 | |
65 | - wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' ); |
|
65 | + wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css'); |
|
66 | 66 | |
67 | - wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
67 | + wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
68 | 68 | |
69 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
69 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | * before_widget, and after_widget. |
78 | 78 | * @param array $instance The settings for the particular instance of the widget. |
79 | 79 | */ |
80 | - public function widget( $args, $instance ){ |
|
81 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
82 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
80 | + public function widget($args, $instance) { |
|
81 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
82 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
83 | 83 | |
84 | 84 | echo $args['before_widget']; |
85 | 85 | |
86 | - do_action( 'give_before_forms_widget' ); |
|
86 | + do_action('give_before_forms_widget'); |
|
87 | 87 | |
88 | - echo $title ? $args['before_title'] . $title . $args['after_title'] : ''; |
|
88 | + echo $title ? $args['before_title'].$title.$args['after_title'] : ''; |
|
89 | 89 | |
90 | - give_get_donation_form( $instance ); |
|
90 | + give_get_donation_form($instance); |
|
91 | 91 | |
92 | 92 | echo $args['after_widget']; |
93 | 93 | |
94 | - do_action( 'give_after_forms_widget' ); |
|
94 | + do_action('give_after_forms_widget'); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,61 +101,61 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string |
103 | 103 | */ |
104 | - public function form( $instance ){ |
|
104 | + public function form($instance) { |
|
105 | 105 | $defaults = array( |
106 | 106 | 'title' => '', |
107 | 107 | 'id' => '', |
108 | 108 | 'float_labels' => '', |
109 | 109 | ); |
110 | 110 | |
111 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
111 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
112 | 112 | |
113 | 113 | // Query Give Forms |
114 | 114 | $args = array( |
115 | 115 | 'post_type' => 'give_forms', |
116 | - 'posts_per_page' => - 1, |
|
116 | + 'posts_per_page' => -1, |
|
117 | 117 | 'post_status' => 'publish', |
118 | 118 | ); |
119 | 119 | |
120 | - $give_forms = get_posts( $args ); |
|
120 | + $give_forms = get_posts($args); |
|
121 | 121 | |
122 | 122 | // Widget: Title |
123 | 123 | |
124 | 124 | ?><p> |
125 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
126 | - <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( $instance['title'] ); ?>" /><br> |
|
127 | - <small><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
125 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
126 | + <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($instance['title']); ?>" /><br> |
|
127 | + <small><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
128 | 128 | </p><?php |
129 | 129 | |
130 | 130 | // Widget: Give Form |
131 | 131 | |
132 | 132 | ?><p> |
133 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php |
|
133 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php |
|
134 | 134 | printf( |
135 | 135 | /* translators: %s: form singular label */ |
136 | - esc_html__( 'Give %s:', 'give' ), |
|
136 | + esc_html__('Give %s:', 'give'), |
|
137 | 137 | give_get_forms_label_singular() |
138 | 138 | ); |
139 | 139 | ?></label> |
140 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
141 | - <option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
142 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
143 | - <option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $give_form->post_title; ?></option> |
|
140 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
141 | + <option value="current"><?php esc_html_e('- Select -', 'give'); ?></option> |
|
142 | + <?php foreach ($give_forms as $give_form) { ?> |
|
143 | + <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $give_form->post_title; ?></option> |
|
144 | 144 | <?php } ?> |
145 | 145 | </select><br> |
146 | - <small><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
146 | + <small><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
147 | 147 | </p><?php |
148 | 148 | |
149 | 149 | // Widget: Floating Labels |
150 | 150 | |
151 | 151 | ?><p> |
152 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels:', 'give' ); ?></label> |
|
153 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'float_labels' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"> |
|
154 | - <option value="" <?php selected( esc_attr( $instance['float_labels'] ), '' ) ?>><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
155 | - <option value="enabled" <?php selected( esc_attr( $instance['float_labels'] ), 'enabled' ) ?>><?php esc_html_e( 'Enabled', 'give' ); ?></option> |
|
156 | - <option value="disabled" <?php selected( esc_attr( $instance['float_labels'] ), 'disabled' ) ?>><?php esc_html_e( 'Disabled', 'give' ); ?></option> |
|
152 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels:', 'give'); ?></label> |
|
153 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('float_labels')); ?>" id="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"> |
|
154 | + <option value="" <?php selected(esc_attr($instance['float_labels']), '') ?>><?php esc_html_e('- Select -', 'give'); ?></option> |
|
155 | + <option value="enabled" <?php selected(esc_attr($instance['float_labels']), 'enabled') ?>><?php esc_html_e('Enabled', 'give'); ?></option> |
|
156 | + <option value="disabled" <?php selected(esc_attr($instance['float_labels']), 'disabled') ?>><?php esc_html_e('Disabled', 'give'); ?></option> |
|
157 | 157 | </select><br> |
158 | - <small><?php esc_html_e( 'Override the default floating labels setting for this form.', 'give' ); ?></small> |
|
158 | + <small><?php esc_html_e('Override the default floating labels setting for this form.', 'give'); ?></small> |
|
159 | 159 | </p><?php |
160 | 160 | } |
161 | 161 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return void |
166 | 166 | */ |
167 | - function widget_init(){ |
|
168 | - register_widget( $this->self ); |
|
167 | + function widget_init() { |
|
168 | + register_widget($this->self); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return array |
178 | 178 | */ |
179 | - public function update( $new_instance, $old_instance ){ |
|
179 | + public function update($new_instance, $old_instance) { |
|
180 | 180 | $this->flush_widget_cache(); |
181 | 181 | |
182 | 182 | return $new_instance; |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return void |
189 | 189 | */ |
190 | - public function flush_widget_cache(){ |
|
191 | - wp_cache_delete( $this->self, 'widget' ); |
|
190 | + public function flush_widget_cache() { |
|
191 | + wp_cache_delete($this->self, 'widget'); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 |