@@ -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,24 +44,24 @@ 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 | 52 | $template_names = "{$template_name}.php"; |
| 53 | 53 | |
| 54 | - $located = give_get_locate_template( $template_names, $template_path, $default_path ); |
|
| 54 | + $located = give_get_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()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
| 58 | + Give()->notices->print_frontend_notice(sprintf(__('The %s template was not found.', 'give'), $located), true); |
|
| 59 | 59 | |
| 60 | 60 | return; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Allow 3rd party plugin filter template file from their plugin. |
| 64 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 64 | + $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Fires in give template, before the file is included. |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | * @param string $located Template file filter by 3rd party plugin. |
| 76 | 76 | * @param array $args Passed arguments. |
| 77 | 77 | */ |
| 78 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 78 | + do_action('give_before_template_part', $template_name, $template_path, $located, $args); |
|
| 79 | 79 | |
| 80 | - include( $located ); |
|
| 80 | + include($located); |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Fires in give template, after the file is included. |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $located Template file filter by 3rd party plugin. |
| 92 | 92 | * @param array $args Passed arguments. |
| 93 | 93 | */ |
| 94 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 94 | + do_action('give_after_template_part', $template_name, $template_path, $located, $args); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return string |
| 109 | 109 | */ |
| 110 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
| 110 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * Fires in give template part, before the template part is retrieved. |
@@ -119,20 +119,20 @@ discard block |
||
| 119 | 119 | * @param string $slug Template part file slug {slug}.php. |
| 120 | 120 | * @param string $name Template part file name {slug}-{name}.php. |
| 121 | 121 | */ |
| 122 | - do_action( "get_template_part_{$slug}", $slug, $name ); |
|
| 122 | + do_action("get_template_part_{$slug}", $slug, $name); |
|
| 123 | 123 | |
| 124 | 124 | // Setup possible parts |
| 125 | 125 | $templates = array(); |
| 126 | - if ( isset( $name ) ) { |
|
| 127 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 126 | + if (isset($name)) { |
|
| 127 | + $templates[] = $slug.'-'.$name.'.php'; |
|
| 128 | 128 | } |
| 129 | - $templates[] = $slug . '.php'; |
|
| 129 | + $templates[] = $slug.'.php'; |
|
| 130 | 130 | |
| 131 | 131 | // Allow template parts to be filtered |
| 132 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
| 132 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
| 133 | 133 | |
| 134 | 134 | // Return the part that is found |
| 135 | - return give_locate_template( $templates, $load, false ); |
|
| 135 | + return give_locate_template($templates, $load, false); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -153,37 +153,37 @@ discard block |
||
| 153 | 153 | * |
| 154 | 154 | * @return string The template filename if one is located. |
| 155 | 155 | */ |
| 156 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
| 156 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
| 157 | 157 | // No file found yet |
| 158 | 158 | $located = false; |
| 159 | 159 | |
| 160 | 160 | // Try to find a template file |
| 161 | - foreach ( (array) $template_names as $template_name ) { |
|
| 161 | + foreach ((array) $template_names as $template_name) { |
|
| 162 | 162 | |
| 163 | 163 | // Continue if template is empty |
| 164 | - if ( empty( $template_name ) ) { |
|
| 164 | + if (empty($template_name)) { |
|
| 165 | 165 | continue; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // Trim off any slashes from the template name |
| 169 | - $template_name = ltrim( $template_name, '/' ); |
|
| 169 | + $template_name = ltrim($template_name, '/'); |
|
| 170 | 170 | |
| 171 | 171 | // try locating this template file by looping through the template paths |
| 172 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
| 172 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
| 173 | 173 | |
| 174 | - if ( file_exists( $template_path . $template_name ) ) { |
|
| 175 | - $located = $template_path . $template_name; |
|
| 174 | + if (file_exists($template_path.$template_name)) { |
|
| 175 | + $located = $template_path.$template_name; |
|
| 176 | 176 | break; |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if ( $located ) { |
|
| 180 | + if ($located) { |
|
| 181 | 181 | break; |
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 186 | - load_template( $located, $require_once ); |
|
| 185 | + if ((true == $load) && ! empty($located)) { |
|
| 186 | + load_template($located, $require_once); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | return $located; |
@@ -207,26 +207,26 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return string |
| 209 | 209 | */ |
| 210 | -function give_get_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 211 | - if ( ! $template_path ) { |
|
| 212 | - $template_path = give_get_theme_template_dir_name() . '/'; |
|
| 210 | +function give_get_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 211 | + if ( ! $template_path) { |
|
| 212 | + $template_path = give_get_theme_template_dir_name().'/'; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if ( ! $default_path ) { |
|
| 216 | - $default_path = GIVE_PLUGIN_DIR . 'templates/'; |
|
| 215 | + if ( ! $default_path) { |
|
| 216 | + $default_path = GIVE_PLUGIN_DIR.'templates/'; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // Look within passed path within the theme - this is priority. |
| 220 | 220 | $template = locate_template( |
| 221 | 221 | array( |
| 222 | - trailingslashit( $template_path ) . $template_name, |
|
| 222 | + trailingslashit($template_path).$template_name, |
|
| 223 | 223 | $template_name, |
| 224 | 224 | ) |
| 225 | 225 | ); |
| 226 | 226 | |
| 227 | 227 | // Get default template/ |
| 228 | - if ( ! $template ) { |
|
| 229 | - $template = $default_path . $template_name; |
|
| 228 | + if ( ! $template) { |
|
| 229 | + $template = $default_path.$template_name; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * |
| 235 | 235 | * @since 2.0.3 |
| 236 | 236 | */ |
| 237 | - return apply_filters( 'give_get_locate_template', $template, $template_name, $template_path ); |
|
| 237 | + return apply_filters('give_get_locate_template', $template, $template_name, $template_path); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -248,17 +248,17 @@ discard block |
||
| 248 | 248 | $template_dir = give_get_theme_template_dir_name(); |
| 249 | 249 | |
| 250 | 250 | $file_paths = array( |
| 251 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 252 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 251 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
| 252 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
| 253 | 253 | 100 => give_get_templates_dir(), |
| 254 | 254 | ); |
| 255 | 255 | |
| 256 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
| 256 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
| 257 | 257 | |
| 258 | 258 | // sort the file paths based on priority |
| 259 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 259 | + ksort($file_paths, SORT_NUMERIC); |
|
| 260 | 260 | |
| 261 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 261 | + return array_map('trailingslashit', $file_paths); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @return string |
| 271 | 271 | */ |
| 272 | 272 | function give_get_theme_template_dir_name() { |
| 273 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
| 273 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -280,10 +280,10 @@ discard block |
||
| 280 | 280 | * @return void |
| 281 | 281 | */ |
| 282 | 282 | function give_version_in_header() { |
| 283 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
| 283 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
| 286 | +add_action('wp_head', 'give_version_in_header'); |
|
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | 289 | * Determines if we're currently on the Donations History page. |
@@ -293,9 +293,9 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | function give_is_donation_history_page() { |
| 295 | 295 | |
| 296 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
| 296 | + $ret = is_page(give_get_option('history_page')); |
|
| 297 | 297 | |
| 298 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
| 298 | + return apply_filters('give_is_donation_history_page', $ret); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -307,25 +307,25 @@ discard block |
||
| 307 | 307 | * |
| 308 | 308 | * @return array Modified array of classes |
| 309 | 309 | */ |
| 310 | -function give_add_body_classes( $class ) { |
|
| 310 | +function give_add_body_classes($class) { |
|
| 311 | 311 | $classes = (array) $class; |
| 312 | 312 | |
| 313 | - if ( give_is_success_page() ) { |
|
| 313 | + if (give_is_success_page()) { |
|
| 314 | 314 | $classes[] = 'give-success'; |
| 315 | 315 | $classes[] = 'give-page'; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if ( give_is_failed_transaction_page() ) { |
|
| 318 | + if (give_is_failed_transaction_page()) { |
|
| 319 | 319 | $classes[] = 'give-failed-transaction'; |
| 320 | 320 | $classes[] = 'give-page'; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if ( give_is_donation_history_page() ) { |
|
| 323 | + if (give_is_donation_history_page()) { |
|
| 324 | 324 | $classes[] = 'give-donation-history'; |
| 325 | 325 | $classes[] = 'give-page'; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if ( give_is_test_mode() ) { |
|
| 328 | + if (give_is_test_mode()) { |
|
| 329 | 329 | $classes[] = 'give-test-mode'; |
| 330 | 330 | $classes[] = 'give-page'; |
| 331 | 331 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | /* @var WP_Theme $current_theme */ |
| 335 | 335 | $current_theme = wp_get_theme(); |
| 336 | 336 | |
| 337 | - switch ( $current_theme->get_template() ) { |
|
| 337 | + switch ($current_theme->get_template()) { |
|
| 338 | 338 | |
| 339 | 339 | case 'Divi': |
| 340 | 340 | $classes[] = 'give-divi'; |
@@ -351,10 +351,10 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - return array_unique( $classes ); |
|
| 354 | + return array_unique($classes); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
| 357 | +add_filter('body_class', 'give_add_body_classes'); |
|
| 358 | 358 | |
| 359 | 359 | |
| 360 | 360 | /** |
@@ -370,22 +370,22 @@ discard block |
||
| 370 | 370 | * |
| 371 | 371 | * @return array |
| 372 | 372 | */ |
| 373 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
| 374 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
| 373 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
| 374 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
| 375 | 375 | return $classes; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
| 379 | 379 | |
| 380 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
| 381 | - unset( $classes[ $key ] ); |
|
| 380 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
| 381 | + unset($classes[$key]); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | return $classes; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | |
| 388 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
| 388 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
| 389 | 389 | |
| 390 | 390 | /** |
| 391 | 391 | * Get the placeholder image URL for forms etc |
@@ -395,74 +395,74 @@ discard block |
||
| 395 | 395 | */ |
| 396 | 396 | function give_get_placeholder_img_src() { |
| 397 | 397 | |
| 398 | - $placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
| 398 | + $placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
| 399 | 399 | |
| 400 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
| 400 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | |
| 404 | 404 | /** |
| 405 | 405 | * Global |
| 406 | 406 | */ |
| 407 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
| 407 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
| 408 | 408 | |
| 409 | 409 | /** |
| 410 | 410 | * Output the start of the page wrapper. |
| 411 | 411 | */ |
| 412 | 412 | function give_output_content_wrapper() { |
| 413 | - give_get_template_part( 'global/wrapper-start' ); |
|
| 413 | + give_get_template_part('global/wrapper-start'); |
|
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
| 416 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
| 417 | 417 | |
| 418 | 418 | /** |
| 419 | 419 | * Output the end of the page wrapper. |
| 420 | 420 | */ |
| 421 | 421 | function give_output_content_wrapper_end() { |
| 422 | - give_get_template_part( 'global/wrapper-end' ); |
|
| 422 | + give_get_template_part('global/wrapper-end'); |
|
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
| 427 | 427 | * Single Give Form |
| 428 | 428 | */ |
| 429 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
| 429 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
| 430 | 430 | function give_left_sidebar_pre_wrap() { |
| 431 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
| 431 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
| 435 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
| 436 | 436 | function give_left_sidebar_post_wrap() { |
| 437 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
| 437 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
| 441 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
| 442 | 442 | function give_get_forms_sidebar() { |
| 443 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
| 443 | + give_get_template_part('single-give-form/sidebar'); |
|
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
| 447 | +if ( ! function_exists('give_show_form_images')) { |
|
| 448 | 448 | |
| 449 | 449 | /** |
| 450 | 450 | * Output the donation form featured image. |
| 451 | 451 | */ |
| 452 | 452 | function give_show_form_images() { |
| 453 | - if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
| 454 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
| 453 | + if (give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
| 454 | + give_get_template_part('single-give-form/featured-image'); |
|
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
| 459 | +if ( ! function_exists('give_template_single_title')) { |
|
| 460 | 460 | |
| 461 | 461 | /** |
| 462 | 462 | * Output the form title. |
| 463 | 463 | */ |
| 464 | 464 | function give_template_single_title() { |
| 465 | - give_get_template_part( 'single-give-form/title' ); |
|
| 465 | + give_get_template_part('single-give-form/title'); |
|
| 466 | 466 | } |
| 467 | 467 | } |
| 468 | 468 | |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | * Conditional Functions |
| 471 | 471 | */ |
| 472 | 472 | |
| 473 | -if ( ! function_exists( 'is_give_form' ) ) { |
|
| 473 | +if ( ! function_exists('is_give_form')) { |
|
| 474 | 474 | |
| 475 | 475 | /** |
| 476 | 476 | * is_give_form |
@@ -482,11 +482,11 @@ discard block |
||
| 482 | 482 | * @return bool |
| 483 | 483 | */ |
| 484 | 484 | function is_give_form() { |
| 485 | - return is_singular( array( 'give_form' ) ); |
|
| 485 | + return is_singular(array('give_form')); |
|
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | -if ( ! function_exists( 'is_give_category' ) ) { |
|
| 489 | +if ( ! function_exists('is_give_category')) { |
|
| 490 | 490 | |
| 491 | 491 | /** |
| 492 | 492 | * is_give_category |
@@ -501,12 +501,12 @@ discard block |
||
| 501 | 501 | * |
| 502 | 502 | * @return bool |
| 503 | 503 | */ |
| 504 | - function is_give_category( $term = '' ) { |
|
| 505 | - return is_tax( 'give_forms_category', $term ); |
|
| 504 | + function is_give_category($term = '') { |
|
| 505 | + return is_tax('give_forms_category', $term); |
|
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | -if ( ! function_exists( 'is_give_tag' ) ) { |
|
| 509 | +if ( ! function_exists('is_give_tag')) { |
|
| 510 | 510 | |
| 511 | 511 | /** |
| 512 | 512 | * is_give_tag |
@@ -521,12 +521,12 @@ discard block |
||
| 521 | 521 | * |
| 522 | 522 | * @return bool |
| 523 | 523 | */ |
| 524 | - function is_give_tag( $term = '' ) { |
|
| 525 | - return is_tax( 'give_forms_tag', $term ); |
|
| 524 | + function is_give_tag($term = '') { |
|
| 525 | + return is_tax('give_forms_tag', $term); |
|
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | -if ( ! function_exists( 'is_give_taxonomy' ) ) { |
|
| 529 | +if ( ! function_exists('is_give_taxonomy')) { |
|
| 530 | 530 | |
| 531 | 531 | /** |
| 532 | 532 | * is_give_taxonomy |
@@ -538,6 +538,6 @@ discard block |
||
| 538 | 538 | * @return bool |
| 539 | 539 | */ |
| 540 | 540 | function is_give_taxonomy() { |
| 541 | - return is_tax( get_object_taxonomies( 'give_form' ) ); |
|
| 541 | + return is_tax(get_object_taxonomies('give_form')); |
|
| 542 | 542 | } |
| 543 | 543 | } |
@@ -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,24 +26,24 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return string Login form |
| 28 | 28 | */ |
| 29 | -function give_login_form( $login_redirect = '', $logout_redirect = '' ) { |
|
| 29 | +function give_login_form($login_redirect = '', $logout_redirect = '') { |
|
| 30 | 30 | |
| 31 | - if ( empty( $login_redirect ) ) { |
|
| 32 | - $login_redirect = add_query_arg( 'give-login-success', 'true', give_get_history_page_uri() ); |
|
| 31 | + if (empty($login_redirect)) { |
|
| 32 | + $login_redirect = add_query_arg('give-login-success', 'true', give_get_history_page_uri()); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if ( empty( $logout_redirect ) ) { |
|
| 36 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
| 35 | + if (empty($logout_redirect)) { |
|
| 36 | + $logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url()); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Add user_logout action to logout url. |
| 40 | 40 | $logout_redirect = add_query_arg( |
| 41 | 41 | array( |
| 42 | 42 | 'give_action' => 'user_logout', |
| 43 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
| 44 | - 'give_logout_redirect' => urlencode( $logout_redirect ), |
|
| 43 | + 'give_logout_nonce' => wp_create_nonce('give-logout-nonce'), |
|
| 44 | + 'give_logout_redirect' => urlencode($logout_redirect), |
|
| 45 | 45 | ), |
| 46 | - home_url( '/' ) |
|
| 46 | + home_url('/') |
|
| 47 | 47 | ); |
| 48 | 48 | |
| 49 | 49 | ob_start(); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | ) |
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | - return apply_filters( 'give_login_form', ob_get_clean() ); |
|
| 59 | + return apply_filters('give_login_form', ob_get_clean()); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return string Register form |
| 71 | 71 | */ |
| 72 | -function give_register_form( $redirect = '' ) { |
|
| 73 | - if ( empty( $redirect ) ) { |
|
| 72 | +function give_register_form($redirect = '') { |
|
| 73 | + if (empty($redirect)) { |
|
| 74 | 74 | $redirect = give_get_current_page_url(); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | ob_start(); |
| 78 | 78 | |
| 79 | - if ( ! is_user_logged_in() ) { |
|
| 79 | + if ( ! is_user_logged_in()) { |
|
| 80 | 80 | give_get_template( |
| 81 | 81 | 'shortcode-register', |
| 82 | 82 | array( |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - return apply_filters( 'give_register_form', ob_get_clean() ); |
|
| 88 | + return apply_filters('give_register_form', ob_get_clean()); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -97,40 +97,40 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return void |
| 99 | 99 | */ |
| 100 | -function give_process_login_form( $data ) { |
|
| 101 | - if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) { |
|
| 100 | +function give_process_login_form($data) { |
|
| 101 | + if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) { |
|
| 102 | 102 | |
| 103 | 103 | // Set Receipt Access Session. |
| 104 | - if ( ! empty( $_GET['payment_key'] ) ) { |
|
| 105 | - Give()->session->set( 'receipt_access', true ); |
|
| 104 | + if ( ! empty($_GET['payment_key'])) { |
|
| 105 | + Give()->session->set('receipt_access', true); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - $user_data = get_user_by( 'login', $data['give_user_login'] ); |
|
| 109 | - if ( ! $user_data ) { |
|
| 110 | - $user_data = get_user_by( 'email', $data['give_user_login'] ); |
|
| 108 | + $user_data = get_user_by('login', $data['give_user_login']); |
|
| 109 | + if ( ! $user_data) { |
|
| 110 | + $user_data = get_user_by('email', $data['give_user_login']); |
|
| 111 | 111 | } |
| 112 | - if ( $user_data ) { |
|
| 112 | + if ($user_data) { |
|
| 113 | 113 | $user_ID = $user_data->ID; |
| 114 | 114 | $user_email = $user_data->user_email; |
| 115 | - if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_ID ) ) { |
|
| 116 | - give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] ); |
|
| 115 | + if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_ID)) { |
|
| 116 | + give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']); |
|
| 117 | 117 | } else { |
| 118 | - give_set_error( 'password_incorrect', __( 'The password you entered is incorrect.', 'give' ) ); |
|
| 118 | + give_set_error('password_incorrect', __('The password you entered is incorrect.', 'give')); |
|
| 119 | 119 | } |
| 120 | 120 | } else { |
| 121 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
| 121 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
| 122 | 122 | } |
| 123 | 123 | // Check for errors and redirect if none present |
| 124 | 124 | $errors = give_get_errors(); |
| 125 | - if ( ! $errors ) { |
|
| 126 | - $redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID ); |
|
| 127 | - wp_redirect( $redirect ); |
|
| 125 | + if ( ! $errors) { |
|
| 126 | + $redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID); |
|
| 127 | + wp_redirect($redirect); |
|
| 128 | 128 | give_die(); |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | -add_action( 'give_user_login', 'give_process_login_form' ); |
|
| 133 | +add_action('give_user_login', 'give_process_login_form'); |
|
| 134 | 134 | |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -142,18 +142,18 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * @return void |
| 144 | 144 | */ |
| 145 | -function give_process_user_logout( $data ) { |
|
| 146 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
| 145 | +function give_process_user_logout($data) { |
|
| 146 | + if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) { |
|
| 147 | 147 | |
| 148 | 148 | // Prevent occurring of any custom action on wp_logout. |
| 149 | - remove_all_actions( 'wp_logout' ); |
|
| 149 | + remove_all_actions('wp_logout'); |
|
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * Fires before processing user logout. |
| 153 | 153 | * |
| 154 | 154 | * @since 1.0 |
| 155 | 155 | */ |
| 156 | - do_action( 'give_before_user_logout' ); |
|
| 156 | + do_action('give_before_user_logout'); |
|
| 157 | 157 | |
| 158 | 158 | // Logout user. |
| 159 | 159 | wp_logout(); |
@@ -163,14 +163,14 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @since 1.0 |
| 165 | 165 | */ |
| 166 | - do_action( 'give_after_user_logout' ); |
|
| 166 | + do_action('give_after_user_logout'); |
|
| 167 | 167 | |
| 168 | - wp_redirect( $data['give_logout_redirect'] ); |
|
| 168 | + wp_redirect($data['give_logout_redirect']); |
|
| 169 | 169 | give_die(); |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | -add_action( 'give_user_logout', 'give_process_user_logout' ); |
|
| 173 | +add_action('give_user_logout', 'give_process_user_logout'); |
|
| 174 | 174 | |
| 175 | 175 | /** |
| 176 | 176 | * Log User In |
@@ -183,14 +183,14 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @return bool |
| 185 | 185 | */ |
| 186 | -function give_log_user_in( $user_id, $user_login, $user_pass ) { |
|
| 186 | +function give_log_user_in($user_id, $user_login, $user_pass) { |
|
| 187 | 187 | |
| 188 | - if ( $user_id < 1 ) { |
|
| 188 | + if ($user_id < 1) { |
|
| 189 | 189 | return false; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - wp_set_auth_cookie( $user_id ); |
|
| 193 | - wp_set_current_user( $user_id, $user_login ); |
|
| 192 | + wp_set_auth_cookie($user_id); |
|
| 193 | + wp_set_current_user($user_id, $user_login); |
|
| 194 | 194 | |
| 195 | 195 | /** |
| 196 | 196 | * Fires after the user has successfully logged in. |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @param string $user_login Username. |
| 201 | 201 | * @param WP_User $$user WP_User object of the logged-in user. |
| 202 | 202 | */ |
| 203 | - do_action( 'wp_login', $user_login, get_userdata( $user_id ) ); |
|
| 203 | + do_action('wp_login', $user_login, get_userdata($user_id)); |
|
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | 206 | * Fires after give user has successfully logged in. |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * @param string $user_login Username. |
| 212 | 212 | * @param string $user_pass User password. |
| 213 | 213 | */ |
| 214 | - do_action( 'give_log_user_in', $user_id, $user_login, $user_pass ); |
|
| 214 | + do_action('give_log_user_in', $user_id, $user_login, $user_pass); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
@@ -224,13 +224,13 @@ discard block |
||
| 224 | 224 | * |
| 225 | 225 | * @return bool |
| 226 | 226 | */ |
| 227 | -function give_process_register_form( $data ) { |
|
| 227 | +function give_process_register_form($data) { |
|
| 228 | 228 | |
| 229 | - if ( is_user_logged_in() ) { |
|
| 229 | + if (is_user_logged_in()) { |
|
| 230 | 230 | return false; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - if ( empty( $_POST['give_register_submit'] ) ) { |
|
| 233 | + if (empty($_POST['give_register_submit'])) { |
|
| 234 | 234 | return false; |
| 235 | 235 | } |
| 236 | 236 | |
@@ -239,38 +239,38 @@ discard block |
||
| 239 | 239 | * |
| 240 | 240 | * @since 1.0 |
| 241 | 241 | */ |
| 242 | - do_action( 'give_pre_process_register_form' ); |
|
| 242 | + do_action('give_pre_process_register_form'); |
|
| 243 | 243 | |
| 244 | - if ( empty( $data['give_user_login'] ) ) { |
|
| 245 | - give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) ); |
|
| 244 | + if (empty($data['give_user_login'])) { |
|
| 245 | + give_set_error('empty_username', esc_html__('Invalid username.', 'give')); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - if ( username_exists( $data['give_user_login'] ) ) { |
|
| 249 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
| 248 | + if (username_exists($data['give_user_login'])) { |
|
| 249 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - if ( ! validate_username( $data['give_user_login'] ) ) { |
|
| 253 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
| 252 | + if ( ! validate_username($data['give_user_login'])) { |
|
| 253 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if ( email_exists( $data['give_user_email'] ) ) { |
|
| 257 | - give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) ); |
|
| 256 | + if (email_exists($data['give_user_email'])) { |
|
| 257 | + give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give')); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) { |
|
| 261 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
| 260 | + if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) { |
|
| 261 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) { |
|
| 265 | - give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) ); |
|
| 264 | + if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) { |
|
| 265 | + give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give')); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if ( empty( $_POST['give_user_pass'] ) ) { |
|
| 269 | - give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) ); |
|
| 268 | + if (empty($_POST['give_user_pass'])) { |
|
| 269 | + give_set_error('empty_password', esc_html__('Please enter a password.', 'give')); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) { |
|
| 273 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
| 272 | + if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) { |
|
| 273 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -278,29 +278,29 @@ discard block |
||
| 278 | 278 | * |
| 279 | 279 | * @since 1.0 |
| 280 | 280 | */ |
| 281 | - do_action( 'give_process_register_form' ); |
|
| 281 | + do_action('give_process_register_form'); |
|
| 282 | 282 | |
| 283 | 283 | // Check for errors and redirect if none present |
| 284 | 284 | $errors = give_get_errors(); |
| 285 | 285 | |
| 286 | - if ( empty( $errors ) ) { |
|
| 286 | + if (empty($errors)) { |
|
| 287 | 287 | |
| 288 | - $redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] ); |
|
| 288 | + $redirect = apply_filters('give_register_redirect', $data['give_redirect']); |
|
| 289 | 289 | |
| 290 | - give_register_and_login_new_user( array( |
|
| 290 | + give_register_and_login_new_user(array( |
|
| 291 | 291 | 'user_login' => $data['give_user_login'], |
| 292 | 292 | 'user_pass' => $data['give_user_pass'], |
| 293 | 293 | 'user_email' => $data['give_user_email'], |
| 294 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 295 | - 'role' => get_option( 'default_role' ), |
|
| 296 | - ) ); |
|
| 294 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 295 | + 'role' => get_option('default_role'), |
|
| 296 | + )); |
|
| 297 | 297 | |
| 298 | - wp_redirect( $redirect ); |
|
| 298 | + wp_redirect($redirect); |
|
| 299 | 299 | give_die(); |
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | -add_action( 'give_user_register', 'give_process_register_form' ); |
|
| 303 | +add_action('give_user_register', 'give_process_register_form'); |
|
| 304 | 304 | |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -313,24 +313,24 @@ discard block |
||
| 313 | 313 | function give_email_access_login() { |
| 314 | 314 | |
| 315 | 315 | // Verify nonce. |
| 316 | - if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'give' ) ) { |
|
| 316 | + if ( ! isset($_POST['_wpnonce']) || ! wp_verify_nonce($_POST['_wpnonce'], 'give')) { |
|
| 317 | 317 | return false; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // Need email to proceed. |
| 321 | - $email = isset( $_POST['give_email'] ) ? give_clean( $_POST['give_email'] ) : ''; |
|
| 322 | - if ( empty( $email ) ) { |
|
| 323 | - give_set_error( 'give_empty_email', __( 'Please enter the email address you used for your donation.', 'give' ) ); |
|
| 321 | + $email = isset($_POST['give_email']) ? give_clean($_POST['give_email']) : ''; |
|
| 322 | + if (empty($email)) { |
|
| 323 | + give_set_error('give_empty_email', __('Please enter the email address you used for your donation.', 'give')); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - $recaptcha_key = give_get_option( 'recaptcha_key' ); |
|
| 327 | - $recaptcha_secret = give_get_option( 'recaptcha_secret' ); |
|
| 326 | + $recaptcha_key = give_get_option('recaptcha_key'); |
|
| 327 | + $recaptcha_secret = give_get_option('recaptcha_secret'); |
|
| 328 | 328 | |
| 329 | - $enable_recaptcha = ( give_is_setting_enabled( give_get_option( 'enable_recaptcha' ) ) ) && ! empty( $recaptcha_key ) && ! empty( $recaptcha_secret ) ? true : false; |
|
| 330 | - $access_token = ! empty( $_GET['payment_key'] ) ? $_GET['payment_key'] : ''; |
|
| 329 | + $enable_recaptcha = (give_is_setting_enabled(give_get_option('enable_recaptcha'))) && ! empty($recaptcha_key) && ! empty($recaptcha_secret) ? true : false; |
|
| 330 | + $access_token = ! empty($_GET['payment_key']) ? $_GET['payment_key'] : ''; |
|
| 331 | 331 | |
| 332 | 332 | // Use reCAPTCHA. |
| 333 | - if ( $enable_recaptcha ) { |
|
| 333 | + if ($enable_recaptcha) { |
|
| 334 | 334 | |
| 335 | 335 | $args = array( |
| 336 | 336 | 'secret' => $recaptcha_secret, |
@@ -338,43 +338,43 @@ discard block |
||
| 338 | 338 | 'remoteip' => $_POST['give_ip'], |
| 339 | 339 | ); |
| 340 | 340 | |
| 341 | - if ( ! empty( $args['response'] ) ) { |
|
| 342 | - $request = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array( |
|
| 341 | + if ( ! empty($args['response'])) { |
|
| 342 | + $request = wp_remote_post('https://www.google.com/recaptcha/api/siteverify', array( |
|
| 343 | 343 | 'body' => $args, |
| 344 | - ) ); |
|
| 345 | - if ( ! is_wp_error( $request ) || 200 == wp_remote_retrieve_response_code( $request ) ) { |
|
| 344 | + )); |
|
| 345 | + if ( ! is_wp_error($request) || 200 == wp_remote_retrieve_response_code($request)) { |
|
| 346 | 346 | |
| 347 | - $response = json_decode( $request['body'], true ); |
|
| 347 | + $response = json_decode($request['body'], true); |
|
| 348 | 348 | |
| 349 | 349 | // reCAPTCHA fail. |
| 350 | - if ( ! $response['success'] ) { |
|
| 351 | - give_set_error( 'give_recaptcha_test_failed', apply_filters( 'give_recaptcha_test_failed_message', __( 'reCAPTCHA test failed.', 'give' ) ) ); |
|
| 350 | + if ( ! $response['success']) { |
|
| 351 | + give_set_error('give_recaptcha_test_failed', apply_filters('give_recaptcha_test_failed_message', __('reCAPTCHA test failed.', 'give'))); |
|
| 352 | 352 | } |
| 353 | 353 | } else { |
| 354 | 354 | |
| 355 | 355 | // Connection issue. |
| 356 | - give_set_error( 'give_recaptcha_connection_issue', apply_filters( 'give_recaptcha_connection_issue_message', __( 'Unable to connect to reCAPTCHA server.', 'give' ) ) ); |
|
| 356 | + give_set_error('give_recaptcha_connection_issue', apply_filters('give_recaptcha_connection_issue_message', __('Unable to connect to reCAPTCHA server.', 'give'))); |
|
| 357 | 357 | |
| 358 | 358 | } // End if(). |
| 359 | 359 | } else { |
| 360 | 360 | |
| 361 | - give_set_error( 'give_recaptcha_failed', apply_filters( 'give_recaptcha_failed_message', __( 'It looks like the reCAPTCHA test has failed.', 'give' ) ) ); |
|
| 361 | + give_set_error('give_recaptcha_failed', apply_filters('give_recaptcha_failed_message', __('It looks like the reCAPTCHA test has failed.', 'give'))); |
|
| 362 | 362 | |
| 363 | 363 | } // End if(). |
| 364 | 364 | } // End if(). |
| 365 | 365 | |
| 366 | 366 | // If no errors or only expired token key error - then send email. |
| 367 | - if ( ! give_get_errors() ) { |
|
| 367 | + if ( ! give_get_errors()) { |
|
| 368 | 368 | |
| 369 | - $donor = Give()->donors->get_donor_by( 'email', $email ); |
|
| 369 | + $donor = Give()->donors->get_donor_by('email', $email); |
|
| 370 | 370 | |
| 371 | 371 | Give()->email_access->init(); |
| 372 | 372 | |
| 373 | 373 | // Verify that donor object is present and donor is connected with its user profile or not. |
| 374 | - if ( is_object( $donor ) ) { |
|
| 374 | + if (is_object($donor)) { |
|
| 375 | 375 | |
| 376 | 376 | // Verify that email can be sent. |
| 377 | - if ( ! Give()->email_access->can_send_email( $donor->id ) ) { |
|
| 377 | + if ( ! Give()->email_access->can_send_email($donor->id)) { |
|
| 378 | 378 | |
| 379 | 379 | $_POST['email-access-exhausted'] = true; |
| 380 | 380 | |
@@ -382,10 +382,10 @@ discard block |
||
| 382 | 382 | |
| 383 | 383 | } else { |
| 384 | 384 | // Send the email. Requests not |
| 385 | - $email_sent = Give()->email_access->send_email( $donor->id, $donor->email ); |
|
| 385 | + $email_sent = Give()->email_access->send_email($donor->id, $donor->email); |
|
| 386 | 386 | |
| 387 | - if ( ! $email_sent ) { |
|
| 388 | - give_set_error( 'give_email_access_send_issue', __( 'Unable to send email. Please try again.', 'give' ) ); |
|
| 387 | + if ( ! $email_sent) { |
|
| 388 | + give_set_error('give_email_access_send_issue', __('Unable to send email. Please try again.', 'give')); |
|
| 389 | 389 | return false; |
| 390 | 390 | } |
| 391 | 391 | |
@@ -395,11 +395,11 @@ discard block |
||
| 395 | 395 | } |
| 396 | 396 | } else { |
| 397 | 397 | |
| 398 | - give_set_error( 'give-no-donations', __( 'We were unable to find any donations associated with the email address provided. Please try again using another email.', 'give' ) ); |
|
| 398 | + give_set_error('give-no-donations', __('We were unable to find any donations associated with the email address provided. Please try again using another email.', 'give')); |
|
| 399 | 399 | |
| 400 | 400 | } |
| 401 | 401 | } // End if(). |
| 402 | 402 | |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | -add_action( 'give_email_access_form_login', 'give_email_access_login' ); |
|
| 405 | +add_action('give_email_access_form_login', 'give_email_access_login'); |
|
@@ -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 | |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | * @access public |
| 73 | 73 | */ |
| 74 | 74 | public function __construct() { |
| 75 | - if( is_multisite() ) { |
|
| 76 | - add_action( 'switch_blog', array( $this, 'handle_switch_blog' ), 10, 2 ); |
|
| 75 | + if (is_multisite()) { |
|
| 76 | + add_action('switch_blog', array($this, 'handle_switch_blog'), 10, 2); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
@@ -111,16 +111,16 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @return object |
| 113 | 113 | */ |
| 114 | - public function get( $row_id ) { |
|
| 114 | + public function get($row_id) { |
|
| 115 | 115 | /* @var WPDB $wpdb */ |
| 116 | 116 | global $wpdb; |
| 117 | 117 | |
| 118 | 118 | // Bailout. |
| 119 | - if ( empty( $row_id ) ) { |
|
| 119 | + if (empty($row_id)) { |
|
| 120 | 120 | return null; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
| 123 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -134,18 +134,18 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * @return object |
| 136 | 136 | */ |
| 137 | - public function get_by( $column, $row_id ) { |
|
| 137 | + public function get_by($column, $row_id) { |
|
| 138 | 138 | /* @var WPDB $wpdb */ |
| 139 | 139 | global $wpdb; |
| 140 | 140 | |
| 141 | 141 | // Bailout. |
| 142 | - if ( empty( $column ) || empty( $row_id ) ) { |
|
| 142 | + if (empty($column) || empty($row_id)) { |
|
| 143 | 143 | return null; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $column = esc_sql( $column ); |
|
| 146 | + $column = esc_sql($column); |
|
| 147 | 147 | |
| 148 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
| 148 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -159,18 +159,18 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @return string Column value. |
| 161 | 161 | */ |
| 162 | - public function get_column( $column, $row_id ) { |
|
| 162 | + public function get_column($column, $row_id) { |
|
| 163 | 163 | /* @var WPDB $wpdb */ |
| 164 | 164 | global $wpdb; |
| 165 | 165 | |
| 166 | 166 | // Bailout. |
| 167 | - if ( empty( $column ) || empty( $row_id ) ) { |
|
| 167 | + if (empty($column) || empty($row_id)) { |
|
| 168 | 168 | return null; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $column = esc_sql( $column ); |
|
| 171 | + $column = esc_sql($column); |
|
| 172 | 172 | |
| 173 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
| 173 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -185,19 +185,19 @@ discard block |
||
| 185 | 185 | * |
| 186 | 186 | * @return string |
| 187 | 187 | */ |
| 188 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
| 188 | + public function get_column_by($column, $column_where, $column_value) { |
|
| 189 | 189 | /* @var WPDB $wpdb */ |
| 190 | 190 | global $wpdb; |
| 191 | 191 | |
| 192 | 192 | // Bailout. |
| 193 | - if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) { |
|
| 193 | + if (empty($column) || empty($column_where) || empty($column_value)) { |
|
| 194 | 194 | return null; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - $column_where = esc_sql( $column_where ); |
|
| 198 | - $column = esc_sql( $column ); |
|
| 197 | + $column_where = esc_sql($column_where); |
|
| 198 | + $column = esc_sql($column); |
|
| 199 | 199 | |
| 200 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
| 200 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -211,12 +211,12 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @return int |
| 213 | 213 | */ |
| 214 | - public function insert( $data, $type = '' ) { |
|
| 214 | + public function insert($data, $type = '') { |
|
| 215 | 215 | /* @var WPDB $wpdb */ |
| 216 | 216 | global $wpdb; |
| 217 | 217 | |
| 218 | 218 | // Set default values. |
| 219 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
| 219 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
| 220 | 220 | |
| 221 | 221 | /** |
| 222 | 222 | * Fires before inserting data to the database. |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @param array $data |
| 227 | 227 | */ |
| 228 | - do_action( "give_pre_insert_{$type}", $data ); |
|
| 228 | + do_action("give_pre_insert_{$type}", $data); |
|
| 229 | 229 | |
| 230 | 230 | // Initialise column format array |
| 231 | 231 | $column_formats = $this->get_columns(); |
@@ -234,13 +234,13 @@ discard block |
||
| 234 | 234 | // $data = array_change_key_case( $data ); |
| 235 | 235 | |
| 236 | 236 | // White list columns |
| 237 | - $data = array_intersect_key( $data, $column_formats ); |
|
| 237 | + $data = array_intersect_key($data, $column_formats); |
|
| 238 | 238 | |
| 239 | 239 | // Reorder $column_formats to match the order of columns given in $data |
| 240 | - $data_keys = array_keys( $data ); |
|
| 241 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
| 240 | + $data_keys = array_keys($data); |
|
| 241 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
| 242 | 242 | |
| 243 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
| 243 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
| 244 | 244 | |
| 245 | 245 | /** |
| 246 | 246 | * Fires after inserting data to the database. |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * @param int $insert_id |
| 251 | 251 | * @param array $data |
| 252 | 252 | */ |
| 253 | - do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data ); |
|
| 253 | + do_action("give_post_insert_{$type}", $wpdb->insert_id, $data); |
|
| 254 | 254 | |
| 255 | 255 | return $wpdb->insert_id; |
| 256 | 256 | } |
@@ -267,18 +267,18 @@ discard block |
||
| 267 | 267 | * |
| 268 | 268 | * @return bool |
| 269 | 269 | */ |
| 270 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
| 270 | + public function update($row_id, $data = array(), $where = '') { |
|
| 271 | 271 | /* @var WPDB $wpdb */ |
| 272 | 272 | global $wpdb; |
| 273 | 273 | |
| 274 | 274 | // Row ID must be positive integer |
| 275 | - $row_id = absint( $row_id ); |
|
| 275 | + $row_id = absint($row_id); |
|
| 276 | 276 | |
| 277 | - if ( empty( $row_id ) ) { |
|
| 277 | + if (empty($row_id)) { |
|
| 278 | 278 | return false; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - if ( empty( $where ) ) { |
|
| 281 | + if (empty($where)) { |
|
| 282 | 282 | $where = $this->primary_key; |
| 283 | 283 | } |
| 284 | 284 | |
@@ -286,16 +286,16 @@ discard block |
||
| 286 | 286 | $column_formats = $this->get_columns(); |
| 287 | 287 | |
| 288 | 288 | // Force fields to lower case |
| 289 | - $data = array_change_key_case( $data ); |
|
| 289 | + $data = array_change_key_case($data); |
|
| 290 | 290 | |
| 291 | 291 | // White list columns |
| 292 | - $data = array_intersect_key( $data, $column_formats ); |
|
| 292 | + $data = array_intersect_key($data, $column_formats); |
|
| 293 | 293 | |
| 294 | 294 | // Reorder $column_formats to match the order of columns given in $data |
| 295 | - $data_keys = array_keys( $data ); |
|
| 296 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
| 295 | + $data_keys = array_keys($data); |
|
| 296 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
| 297 | 297 | |
| 298 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
| 298 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
| 299 | 299 | return false; |
| 300 | 300 | } |
| 301 | 301 | |
@@ -312,18 +312,18 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @return bool |
| 314 | 314 | */ |
| 315 | - public function delete( $row_id = 0 ) { |
|
| 315 | + public function delete($row_id = 0) { |
|
| 316 | 316 | /* @var WPDB $wpdb */ |
| 317 | 317 | global $wpdb; |
| 318 | 318 | |
| 319 | 319 | // Row ID must be positive integer |
| 320 | - $row_id = absint( $row_id ); |
|
| 320 | + $row_id = absint($row_id); |
|
| 321 | 321 | |
| 322 | - if ( empty( $row_id ) ) { |
|
| 322 | + if (empty($row_id)) { |
|
| 323 | 323 | return false; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
| 326 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
| 327 | 327 | return false; |
| 328 | 328 | } |
| 329 | 329 | |
@@ -340,13 +340,13 @@ discard block |
||
| 340 | 340 | * |
| 341 | 341 | * @return bool If the table name exists. |
| 342 | 342 | */ |
| 343 | - public function table_exists( $table ) { |
|
| 343 | + public function table_exists($table) { |
|
| 344 | 344 | /* @var WPDB $wpdb */ |
| 345 | 345 | global $wpdb; |
| 346 | 346 | |
| 347 | - $table = sanitize_text_field( $table ); |
|
| 347 | + $table = sanitize_text_field($table); |
|
| 348 | 348 | |
| 349 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
| 349 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
@@ -360,16 +360,16 @@ discard block |
||
| 360 | 360 | * |
| 361 | 361 | * @return bool |
| 362 | 362 | */ |
| 363 | - public function does_column_exist( $column_name ) { |
|
| 363 | + public function does_column_exist($column_name) { |
|
| 364 | 364 | |
| 365 | 365 | global $wpdb; |
| 366 | 366 | |
| 367 | - $column = $wpdb->get_results( $wpdb->prepare( |
|
| 367 | + $column = $wpdb->get_results($wpdb->prepare( |
|
| 368 | 368 | "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s AND COLUMN_NAME = %s ", |
| 369 | 369 | DB_NAME, $this->table_name, $column_name |
| 370 | - ) ); |
|
| 370 | + )); |
|
| 371 | 371 | |
| 372 | - if ( ! empty( $column ) ) { |
|
| 372 | + if ( ! empty($column)) { |
|
| 373 | 373 | return true; |
| 374 | 374 | } |
| 375 | 375 | |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | * @return bool Returns if the customers table was installed and upgrade routine run. |
| 386 | 386 | */ |
| 387 | 387 | public function installed() { |
| 388 | - return $this->table_exists( $this->table_name ); |
|
| 388 | + return $this->table_exists($this->table_name); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | /** |
@@ -395,8 +395,8 @@ discard block |
||
| 395 | 395 | * @access public |
| 396 | 396 | */ |
| 397 | 397 | public function register_table() { |
| 398 | - $current_version = get_option( $this->table_name . '_db_version' ); |
|
| 399 | - if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) { |
|
| 398 | + $current_version = get_option($this->table_name.'_db_version'); |
|
| 399 | + if ( ! $current_version || version_compare($current_version, $this->version, '<')) { |
|
| 400 | 400 | $this->create_table(); |
| 401 | 401 | } |
| 402 | 402 | } |
@@ -421,23 +421,23 @@ discard block |
||
| 421 | 421 | * |
| 422 | 422 | * @return int|bool The normalized log ID or false if it's found to not be valid. |
| 423 | 423 | */ |
| 424 | - public function sanitize_id( $id ) { |
|
| 425 | - if ( ! is_numeric( $id ) ) { |
|
| 424 | + public function sanitize_id($id) { |
|
| 425 | + if ( ! is_numeric($id)) { |
|
| 426 | 426 | return false; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | $id = (int) $id; |
| 430 | 430 | |
| 431 | 431 | // We were given a non positive number. |
| 432 | - if ( absint( $id ) !== $id ) { |
|
| 432 | + if (absint($id) !== $id) { |
|
| 433 | 433 | return false; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - if ( empty( $id ) ) { |
|
| 436 | + if (empty($id)) { |
|
| 437 | 437 | return false; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - return absint( $id ); |
|
| 440 | + return absint($id); |
|
| 441 | 441 | |
| 442 | 442 | } |
| 443 | 443 | |
@@ -451,23 +451,23 @@ discard block |
||
| 451 | 451 | * @param $new_blog_id |
| 452 | 452 | * @param $prev_blog_id |
| 453 | 453 | */ |
| 454 | - public function handle_switch_blog( $new_blog_id, $prev_blog_id ) { |
|
| 454 | + public function handle_switch_blog($new_blog_id, $prev_blog_id) { |
|
| 455 | 455 | global $wpdb; |
| 456 | 456 | |
| 457 | 457 | // Bailout. |
| 458 | - if ( $new_blog_id === $prev_blog_id ) { |
|
| 458 | + if ($new_blog_id === $prev_blog_id) { |
|
| 459 | 459 | return; |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | |
| 463 | 463 | $this->table_name = str_replace( |
| 464 | - 1 != $prev_blog_id ? $wpdb->get_blog_prefix( $prev_blog_id ) : $wpdb->base_prefix, |
|
| 465 | - 1 != $new_blog_id ? $wpdb->get_blog_prefix( $new_blog_id ) : $wpdb->base_prefix, |
|
| 464 | + 1 != $prev_blog_id ? $wpdb->get_blog_prefix($prev_blog_id) : $wpdb->base_prefix, |
|
| 465 | + 1 != $new_blog_id ? $wpdb->get_blog_prefix($new_blog_id) : $wpdb->base_prefix, |
|
| 466 | 466 | $this->table_name |
| 467 | 467 | ); |
| 468 | 468 | |
| 469 | - if ( $this instanceof Give_DB_Meta ) { |
|
| 470 | - $wpdb->{$this->get_meta_type() . 'meta'} = $this->table_name; |
|
| 469 | + if ($this instanceof Give_DB_Meta) { |
|
| 470 | + $wpdb->{$this->get_meta_type().'meta'} = $this->table_name; |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | } |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if access directly. |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if ( ! defined('ABSPATH')) { |
|
| 4 | 4 | exit; |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * Blocks |
| 9 | 9 | */ |
| 10 | -require_once GIVE_PLUGIN_DIR . 'blocks/donation-form/class-give-donation-form-block.php'; |
|
| 11 | -require_once GIVE_PLUGIN_DIR . 'blocks/donation-form-grid/class-give-donation-form-grid-block.php'; |
|
| 10 | +require_once GIVE_PLUGIN_DIR.'blocks/donation-form/class-give-donation-form-block.php'; |
|
| 11 | +require_once GIVE_PLUGIN_DIR.'blocks/donation-form-grid/class-give-donation-form-grid-block.php'; |
|
@@ -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 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @return Give_Donation_Form_Block |
| 50 | 50 | */ |
| 51 | 51 | public static function get_instance() { |
| 52 | - if ( null === static::$instance ) { |
|
| 52 | + if (null === static::$instance) { |
|
| 53 | 53 | self::$instance = new static(); |
| 54 | 54 | |
| 55 | 55 | self::$instance->init(); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @access private |
| 68 | 68 | */ |
| 69 | 69 | private function init() { |
| 70 | - add_action( 'init', array( $this, 'register_block' ), 999 ); |
|
| 70 | + add_action('init', array($this, 'register_block'), 999); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function register_block() { |
| 82 | 82 | // Bailout. |
| 83 | - if( ! function_exists('register_block_type' ) ) { |
|
| 83 | + if ( ! function_exists('register_block_type')) { |
|
| 84 | 84 | return; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // Register block. |
| 88 | - register_block_type( 'give/donation-form', array( |
|
| 89 | - 'render_callback' => array( $this, 'render_donation_form' ), |
|
| 88 | + register_block_type('give/donation-form', array( |
|
| 89 | + 'render_callback' => array($this, 'render_donation_form'), |
|
| 90 | 90 | 'attributes' => array( |
| 91 | 91 | 'id' => array( |
| 92 | 92 | 'type' => 'number', |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | 'default' => 'none', |
| 111 | 111 | ), |
| 112 | 112 | ), |
| 113 | - ) ); |
|
| 113 | + )); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | * @access public |
| 122 | 122 | * @return string; |
| 123 | 123 | */ |
| 124 | - public function render_donation_form( $attributes ) { |
|
| 124 | + public function render_donation_form($attributes) { |
|
| 125 | 125 | // Bailout. |
| 126 | - if ( empty( $attributes['id'] ) ) { |
|
| 126 | + if (empty($attributes['id'])) { |
|
| 127 | 127 | return ''; |
| 128 | 128 | } |
| 129 | 129 | |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | $parameters['show_goal'] = $attributes['showGoal']; |
| 135 | 135 | $parameters['show_content'] = $attributes['showContent']; |
| 136 | 136 | $parameters['display_style'] = $attributes['displayStyle']; |
| 137 | - $parameters['continue_button_title'] = trim( $attributes['continueButtonTitle'] ); |
|
| 137 | + $parameters['continue_button_title'] = trim($attributes['continueButtonTitle']); |
|
| 138 | 138 | |
| 139 | - return give_form_shortcode( $parameters ); |
|
| 139 | + return give_form_shortcode($parameters); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
@@ -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 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @return Give_Donation_form_Grid_Block |
| 50 | 50 | */ |
| 51 | 51 | public static function get_instance() { |
| 52 | - if ( null === static::$instance ) { |
|
| 52 | + if (null === static::$instance) { |
|
| 53 | 53 | self::$instance = new static(); |
| 54 | 54 | |
| 55 | 55 | self::$instance->init(); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @access private |
| 68 | 68 | */ |
| 69 | 69 | private function init() { |
| 70 | - add_action( 'init', array( $this, 'register_block' ), 999 ); |
|
| 70 | + add_action('init', array($this, 'register_block'), 999); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -78,13 +78,13 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function register_block() { |
| 80 | 80 | // Bailout. |
| 81 | - if( ! function_exists('register_block_type' ) ) { |
|
| 81 | + if ( ! function_exists('register_block_type')) { |
|
| 82 | 82 | return; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // Register block. |
| 86 | - register_block_type( 'give/donation-form-grid', array( |
|
| 87 | - 'render_callback' => array( $this, 'render_block' ), |
|
| 86 | + register_block_type('give/donation-form-grid', array( |
|
| 87 | + 'render_callback' => array($this, 'render_block'), |
|
| 88 | 88 | 'attributes' => array( |
| 89 | 89 | 'columns' => array( |
| 90 | 90 | 'type' => 'string', |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | 'default' => 'redirect', |
| 108 | 108 | ), |
| 109 | 109 | ), |
| 110 | - ) ); |
|
| 110 | + )); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -118,16 +118,16 @@ discard block |
||
| 118 | 118 | * @access public |
| 119 | 119 | * @return string; |
| 120 | 120 | */ |
| 121 | - public function render_block( $attributes ) { |
|
| 121 | + public function render_block($attributes) { |
|
| 122 | 122 | $parameters = array( |
| 123 | - 'columns' => absint( $attributes['columns'] ), |
|
| 123 | + 'columns' => absint($attributes['columns']), |
|
| 124 | 124 | 'show_goal' => $attributes['showGoal'], |
| 125 | 125 | 'show_excerpt' => $attributes['showExcerpt'], |
| 126 | 126 | 'show_featured_image' => $attributes['showFeaturedImage'], |
| 127 | 127 | 'display_type' => $attributes['displayType'], |
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | - return give_form_grid_shortcode( $parameters ); |
|
| 130 | + return give_form_grid_shortcode($parameters); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
@@ -4,26 +4,26 @@ discard block |
||
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | // Bail out if total goal is empty. |
| 7 | -if ( empty( $total_goal ) ) { |
|
| 7 | +if (empty($total_goal)) { |
|
| 8 | 8 | return false; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | // Set Give total progress bar color. |
| 12 | -$color = apply_filters( 'give_totals_progress_color', '#2bc253' ); |
|
| 12 | +$color = apply_filters('give_totals_progress_color', '#2bc253'); |
|
| 13 | 13 | |
| 14 | 14 | // Give total. |
| 15 | -$total = ! empty( $total ) ? $total : 0; |
|
| 15 | +$total = ! empty($total) ? $total : 0; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Filter the goal progress output |
| 19 | 19 | * |
| 20 | 20 | * @since 2.1 |
| 21 | 21 | */ |
| 22 | -$progress = round( ( $total / $total_goal ) * 100, 2 ); |
|
| 22 | +$progress = round(($total / $total_goal) * 100, 2); |
|
| 23 | 23 | |
| 24 | 24 | // Set progress to 100 percentage if total > total_goal |
| 25 | 25 | $progress = $total >= $total_goal ? 100 : $progress; |
| 26 | -$progress = apply_filters( 'give_goal_totals_funded_percentage_output', $progress, $total, $total_goal ); |
|
| 26 | +$progress = apply_filters('give_goal_totals_funded_percentage_output', $progress, $total, $total_goal); |
|
| 27 | 27 | |
| 28 | 28 | ?> |
| 29 | 29 | <div class="give-goal-progress"> |
@@ -31,16 +31,16 @@ discard block |
||
| 31 | 31 | <?php |
| 32 | 32 | echo sprintf( |
| 33 | 33 | /* translators: %s: percentage of the amount raised compared to the goal target */ |
| 34 | - __( '<span class="give-percentage">%s%%</span> funded', 'give' ), |
|
| 35 | - round( $progress ) |
|
| 34 | + __('<span class="give-percentage">%s%%</span> funded', 'give'), |
|
| 35 | + round($progress) |
|
| 36 | 36 | ); |
| 37 | 37 | ?> |
| 38 | 38 | </div> |
| 39 | 39 | |
| 40 | 40 | <div class="give-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" |
| 41 | - aria-valuenow="<?php echo esc_attr( $progress ); ?>"> |
|
| 42 | - <span style="width: <?php echo esc_attr( $progress ); ?>%;<?php if ( ! empty( $color ) ) { |
|
| 43 | - echo 'background-color:' . $color; |
|
| 41 | + aria-valuenow="<?php echo esc_attr($progress); ?>"> |
|
| 42 | + <span style="width: <?php echo esc_attr($progress); ?>%;<?php if ( ! empty($color)) { |
|
| 43 | + echo 'background-color:'.$color; |
|
| 44 | 44 | } ?>"></span> |
| 45 | 45 | </div><!-- /.give-progress-bar --> |
| 46 | 46 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | // Exit if accessed directly. |
| 7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 7 | +if ( ! defined('ABSPATH')) { |
|
| 8 | 8 | exit; |
| 9 | 9 | } |
| 10 | 10 | |
@@ -19,16 +19,16 @@ discard block |
||
| 19 | 19 | <div class="give-grid__item"> |
| 20 | 20 | <?php |
| 21 | 21 | // Print the opening anchor tag based on display style. |
| 22 | - if ( 'redirect' === $atts['display_style'] ) { |
|
| 22 | + if ('redirect' === $atts['display_style']) { |
|
| 23 | 23 | printf( |
| 24 | 24 | '<a id="give-card-%1$s" class="give-card" href="%2$s">', |
| 25 | - esc_attr( $form_id ), |
|
| 26 | - esc_attr( get_the_permalink() ) |
|
| 25 | + esc_attr($form_id), |
|
| 26 | + esc_attr(get_the_permalink()) |
|
| 27 | 27 | ); |
| 28 | - } elseif ( 'modal_reveal' === $atts['display_style'] ) { |
|
| 28 | + } elseif ('modal_reveal' === $atts['display_style']) { |
|
| 29 | 29 | printf( |
| 30 | 30 | '<a id="give-card-%1$s" class="give-card js-give-grid-modal-launcher" data-effect="mfp-zoom-out" href="#give-modal-form-%1$s">', |
| 31 | - esc_attr( $form_id ) |
|
| 31 | + esc_attr($form_id) |
|
| 32 | 32 | ); |
| 33 | 33 | } |
| 34 | 34 | ?> |
@@ -36,46 +36,46 @@ discard block |
||
| 36 | 36 | <div class="give-card__body"> |
| 37 | 37 | <?php |
| 38 | 38 | // Maybe display the form title. |
| 39 | - if ( true === $atts['show_title'] ) { |
|
| 40 | - the_title( '<h3 class="give-card__title">', '</h3>' ); |
|
| 39 | + if (true === $atts['show_title']) { |
|
| 40 | + the_title('<h3 class="give-card__title">', '</h3>'); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Maybe display the form excerpt. |
| 44 | - if ( true === $atts['show_excerpt'] ) { |
|
| 45 | - if ( has_excerpt( $form_id ) ) { |
|
| 44 | + if (true === $atts['show_excerpt']) { |
|
| 45 | + if (has_excerpt($form_id)) { |
|
| 46 | 46 | // Get excerpt from the form post's excerpt field. |
| 47 | - $raw_content = get_the_excerpt( $form_id ); |
|
| 47 | + $raw_content = get_the_excerpt($form_id); |
|
| 48 | 48 | $stripped_content = wp_strip_all_tags( |
| 49 | - strip_shortcodes( $raw_content ) |
|
| 49 | + strip_shortcodes($raw_content) |
|
| 50 | 50 | ); |
| 51 | 51 | } else { |
| 52 | 52 | // Get content from the form post's content field. |
| 53 | - $raw_content = give_get_meta( $form_id, '_give_form_content', true ); |
|
| 53 | + $raw_content = give_get_meta($form_id, '_give_form_content', true); |
|
| 54 | 54 | |
| 55 | - if ( ! empty( $raw_content ) ) { |
|
| 55 | + if ( ! empty($raw_content)) { |
|
| 56 | 56 | $stripped_content = wp_strip_all_tags( |
| 57 | - strip_shortcodes( $raw_content ) |
|
| 57 | + strip_shortcodes($raw_content) |
|
| 58 | 58 | ); |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // Maybe truncate excerpt. |
| 63 | - if ( 0 < $atts['excerpt_length'] ) { |
|
| 64 | - $excerpt = wp_trim_words( $stripped_content, $atts['excerpt_length'] ); |
|
| 63 | + if (0 < $atts['excerpt_length']) { |
|
| 64 | + $excerpt = wp_trim_words($stripped_content, $atts['excerpt_length']); |
|
| 65 | 65 | } else { |
| 66 | 66 | $excerpt = $stripped_content; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - printf( '<p class="give-card__text">%s</p>', $excerpt ); |
|
| 69 | + printf('<p class="give-card__text">%s</p>', $excerpt); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Maybe display the goal progess bar. |
| 73 | 73 | if ( |
| 74 | - give_is_setting_enabled( get_post_meta( $form_id, '_give_goal_option', true ) ) |
|
| 74 | + give_is_setting_enabled(get_post_meta($form_id, '_give_goal_option', true)) |
|
| 75 | 75 | && true === $atts['show_goal'] |
| 76 | 76 | ) { |
| 77 | 77 | echo '<div class="give-card__progress">'; |
| 78 | - give_show_goal_progress( $form_id ); |
|
| 78 | + give_show_goal_progress($form_id); |
|
| 79 | 79 | echo '</div>'; |
| 80 | 80 | } |
| 81 | 81 | ?> |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | <?php |
| 85 | 85 | // Maybe display the featured image. |
| 86 | 86 | if ( |
| 87 | - give_is_setting_enabled( $give_settings['form_featured_img'] ) |
|
| 87 | + give_is_setting_enabled($give_settings['form_featured_img']) |
|
| 88 | 88 | && has_post_thumbnail() |
| 89 | 89 | && true === $atts['show_featured_image'] |
| 90 | 90 | ) { |
@@ -94,28 +94,28 @@ discard block |
||
| 94 | 94 | * @param string The image size. |
| 95 | 95 | * @param array Form grid attributes. |
| 96 | 96 | */ |
| 97 | - $image_size = apply_filters( 'give_form_grid_image_size', $atts['image_size'], $atts ); |
|
| 97 | + $image_size = apply_filters('give_form_grid_image_size', $atts['image_size'], $atts); |
|
| 98 | 98 | $image_attr = ''; |
| 99 | 99 | |
| 100 | 100 | echo '<div class="give-card__media">'; |
| 101 | - if ( 'auto' !== $atts['image_height'] ) { |
|
| 101 | + if ('auto' !== $atts['image_height']) { |
|
| 102 | 102 | $image_attr = array( |
| 103 | - 'style' => 'height: ' . $atts['image_height'], |
|
| 103 | + 'style' => 'height: '.$atts['image_height'], |
|
| 104 | 104 | ); |
| 105 | 105 | } |
| 106 | - the_post_thumbnail( $image_size, $image_attr ); |
|
| 106 | + the_post_thumbnail($image_size, $image_attr); |
|
| 107 | 107 | echo '</div>'; |
| 108 | 108 | } |
| 109 | 109 | ?> |
| 110 | 110 | </a> |
| 111 | 111 | <?php |
| 112 | 112 | // If modal, print form in hidden container until it is time to be revealed. |
| 113 | - if ( 'modal_reveal' === $atts['display_style'] ) { |
|
| 113 | + if ('modal_reveal' === $atts['display_style']) { |
|
| 114 | 114 | printf( |
| 115 | 115 | '<div id="give-modal-form-%1$s" class="give-donation-grid-item-form give-modal--slide mfp-hide">', |
| 116 | 116 | $form_id |
| 117 | 117 | ); |
| 118 | - give_get_donation_form( $form_id ); |
|
| 118 | + give_get_donation_form($form_id); |
|
| 119 | 119 | echo '</div>'; |
| 120 | 120 | } |
| 121 | 121 | ?> |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @return string |
| 26 | 26 | */ |
| 27 | -function give_admin_rate_us( $footer_text ) { |
|
| 27 | +function give_admin_rate_us($footer_text) { |
|
| 28 | 28 | global $typenow; |
| 29 | 29 | |
| 30 | - if ( 'give_forms' === $typenow ) { |
|
| 30 | + if ('give_forms' === $typenow) { |
|
| 31 | 31 | $rate_text = sprintf( |
| 32 | 32 | /* translators: %s: Link to 5 star rating */ |
| 33 | - __( 'If you like <strong>Give</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'give' ), |
|
| 34 | - '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" style="text-decoration:none;" data-rated="' . esc_attr__( 'Thanks :)', 'give' ) . '">★★★★★</a>' |
|
| 33 | + __('If you like <strong>Give</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'give'), |
|
| 34 | + '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" style="text-decoration:none;" data-rated="'.esc_attr__('Thanks :)', 'give').'">★★★★★</a>' |
|
| 35 | 35 | ); |
| 36 | 36 | |
| 37 | 37 | return $rate_text; |
@@ -40,4 +40,4 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -add_filter( 'admin_footer_text', 'give_admin_rate_us' ); |
|
| 43 | +add_filter('admin_footer_text', 'give_admin_rate_us'); |
|