@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,35 +23,35 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return string Donation form. |
| 25 | 25 | */ |
| 26 | -function give_get_donation_form( $args = array() ) { |
|
| 26 | +function give_get_donation_form($args = array()) { |
|
| 27 | 27 | |
| 28 | 28 | global $post; |
| 29 | 29 | static $count = 1; |
| 30 | 30 | |
| 31 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
| 31 | + $form_id = is_object($post) ? $post->ID : 0; |
|
| 32 | 32 | |
| 33 | - if ( isset( $args['id'] ) ) { |
|
| 33 | + if (isset($args['id'])) { |
|
| 34 | 34 | $form_id = $args['id']; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
| 37 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
| 38 | 38 | 'form_id' => $form_id, |
| 39 | - ) ); |
|
| 39 | + )); |
|
| 40 | 40 | |
| 41 | - $args = wp_parse_args( $args, $defaults ); |
|
| 41 | + $args = wp_parse_args($args, $defaults); |
|
| 42 | 42 | |
| 43 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
| 43 | + $form = new Give_Donate_Form($args['form_id']); |
|
| 44 | 44 | |
| 45 | 45 | // Bail out, if no form ID. |
| 46 | - if ( empty( $form->ID ) ) { |
|
| 46 | + if (empty($form->ID)) { |
|
| 47 | 47 | return false; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | $args['id_prefix'] = "{$form_id}-{$count}"; |
| 51 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
| 51 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
| 52 | 52 | |
| 53 | 53 | $form_action = add_query_arg( |
| 54 | - apply_filters( 'give_form_action_args', array( |
|
| 54 | + apply_filters('give_form_action_args', array( |
|
| 55 | 55 | 'payment-mode' => $payment_mode, |
| 56 | 56 | ) |
| 57 | 57 | ), |
@@ -60,17 +60,17 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | // Sanity Check: Donation form not published or user doesn't have permission to view drafts. |
| 62 | 62 | if ( |
| 63 | - ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) |
|
| 64 | - || ( 'trash' === $form->post_status ) |
|
| 63 | + ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) |
|
| 64 | + || ('trash' === $form->post_status) |
|
| 65 | 65 | ) { |
| 66 | 66 | return false; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // Get the form wrap CSS classes. |
| 70 | - $form_wrap_classes = $form->get_form_wrap_classes( $args ); |
|
| 70 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
| 71 | 71 | |
| 72 | 72 | // Get the <form> tag wrap CSS classes. |
| 73 | - $form_classes = $form->get_form_classes( $args ); |
|
| 73 | + $form_classes = $form->get_form_classes($args); |
|
| 74 | 74 | |
| 75 | 75 | ob_start(); |
| 76 | 76 | |
@@ -82,21 +82,21 @@ discard block |
||
| 82 | 82 | * @param int $form_id The form ID. |
| 83 | 83 | * @param array $args An array of form arguments. |
| 84 | 84 | */ |
| 85 | - do_action( 'give_pre_form_output', $form->ID, $args, $form ); |
|
| 85 | + do_action('give_pre_form_output', $form->ID, $args, $form); |
|
| 86 | 86 | |
| 87 | 87 | ?> |
| 88 | 88 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
| 89 | 89 | <?php |
| 90 | - if ( $form->is_close_donation_form() ) { |
|
| 90 | + if ($form->is_close_donation_form()) { |
|
| 91 | 91 | |
| 92 | - $form_title = ! is_singular( 'give_forms' ) ? apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ) : ''; |
|
| 92 | + $form_title = ! is_singular('give_forms') ? apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>') : ''; |
|
| 93 | 93 | |
| 94 | 94 | // Get Goal thank you message. |
| 95 | - $goal_achieved_message = get_post_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
| 96 | - $goal_achieved_message = ! empty( $goal_achieved_message ) ? $form_title . apply_filters( 'the_content', $goal_achieved_message ) : ''; |
|
| 95 | + $goal_achieved_message = get_post_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
| 96 | + $goal_achieved_message = ! empty($goal_achieved_message) ? $form_title.apply_filters('the_content', $goal_achieved_message) : ''; |
|
| 97 | 97 | |
| 98 | 98 | // Print thank you message. |
| 99 | - echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID, $form ); |
|
| 99 | + echo apply_filters('give_goal_closed_output', $goal_achieved_message, $form->ID, $form); |
|
| 100 | 100 | |
| 101 | 101 | } else { |
| 102 | 102 | /** |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | * 1. if show_title params set to true |
| 105 | 105 | * 2. if admin set form display_style to button |
| 106 | 106 | */ |
| 107 | - $form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
| 107 | + $form_title = apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
| 108 | 108 | if ( |
| 109 | 109 | ( |
| 110 | - ( isset( $args['show_title'] ) && $args['show_title'] == true ) |
|
| 111 | - || ( 'button' === get_post_meta( $form_id, '_give_payment_display', true ) ) |
|
| 110 | + (isset($args['show_title']) && $args['show_title'] == true) |
|
| 111 | + || ('button' === get_post_meta($form_id, '_give_payment_display', true)) |
|
| 112 | 112 | ) |
| 113 | - && ! doing_action( 'give_single_form_summary' ) |
|
| 113 | + && ! doing_action('give_single_form_summary') |
|
| 114 | 114 | ) { |
| 115 | 115 | echo $form_title; |
| 116 | 116 | } |
@@ -124,13 +124,13 @@ discard block |
||
| 124 | 124 | * @param array $args An array of form arguments. |
| 125 | 125 | * @param Give_Donate_Form $form Form object. |
| 126 | 126 | */ |
| 127 | - do_action( 'give_pre_form', $form->ID, $args, $form ); |
|
| 127 | + do_action('give_pre_form', $form->ID, $args, $form); |
|
| 128 | 128 | |
| 129 | 129 | // Set form html tags. |
| 130 | 130 | $form_html_tags = array( |
| 131 | 131 | 'id' => "give-form-{$args['id_prefix']}", |
| 132 | 132 | 'class' => $form_classes, |
| 133 | - 'action' => esc_url_raw( $form_action ), |
|
| 133 | + 'action' => esc_url_raw($form_action), |
|
| 134 | 134 | 'data-id' => $args['id_prefix'], |
| 135 | 135 | ); |
| 136 | 136 | |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | * @param array $form_html_tags Array of form html tags. |
| 143 | 143 | * @param Give_Donate_Form $form Form object. |
| 144 | 144 | */ |
| 145 | - $form_html_tags = apply_filters( 'give_form_html_tags', (array) $form_html_tags, $form ); |
|
| 145 | + $form_html_tags = apply_filters('give_form_html_tags', (array) $form_html_tags, $form); |
|
| 146 | 146 | ?> |
| 147 | - <form <?php echo give_get_attribute_str( $form_html_tags ); ?> method="post"> |
|
| 147 | + <form <?php echo give_get_attribute_str($form_html_tags); ?> method="post"> |
|
| 148 | 148 | <!-- The following field is for robots only, invisible to humans: --> |
| 149 | 149 | <span class="give-hidden" style="display: none !important;"> |
| 150 | 150 | <label for="give-form-honeypot-<?php echo $form_id; ?>"></label> |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @param array $args An array of form arguments. |
| 163 | 163 | * @param Give_Donate_Form $form Form object. |
| 164 | 164 | */ |
| 165 | - do_action( 'give_donation_form_top', $form->ID, $args, $form ); |
|
| 165 | + do_action('give_donation_form_top', $form->ID, $args, $form); |
|
| 166 | 166 | |
| 167 | 167 | /** |
| 168 | 168 | * Fires while outputting donation form, for payment gateway fields. |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @param array $args An array of form arguments. |
| 174 | 174 | * @param Give_Donate_Form $form Form object. |
| 175 | 175 | */ |
| 176 | - do_action( 'give_payment_mode_select', $form->ID, $args, $form ); |
|
| 176 | + do_action('give_payment_mode_select', $form->ID, $args, $form); |
|
| 177 | 177 | |
| 178 | 178 | /** |
| 179 | 179 | * Fires while outputting donation form, after all other fields. |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * @param array $args An array of form arguments. |
| 185 | 185 | * @param Give_Donate_Form $form Form object. |
| 186 | 186 | */ |
| 187 | - do_action( 'give_donation_form_bottom', $form->ID, $args, $form ); |
|
| 187 | + do_action('give_donation_form_bottom', $form->ID, $args, $form); |
|
| 188 | 188 | |
| 189 | 189 | ?> |
| 190 | 190 | </form> |
@@ -199,12 +199,12 @@ discard block |
||
| 199 | 199 | * @param array $args An array of form arguments. |
| 200 | 200 | * @param Give_Donate_Form $form Form object. |
| 201 | 201 | */ |
| 202 | - do_action( 'give_post_form', $form->ID, $args, $form ); |
|
| 202 | + do_action('give_post_form', $form->ID, $args, $form); |
|
| 203 | 203 | |
| 204 | 204 | } |
| 205 | 205 | ?> |
| 206 | 206 | |
| 207 | - </div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
|
| 207 | + </div><!--end #give-form-<?php echo absint($form->ID); ?>--> |
|
| 208 | 208 | <?php |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -215,12 +215,12 @@ discard block |
||
| 215 | 215 | * @param int $form_id The form ID. |
| 216 | 216 | * @param array $args An array of form arguments. |
| 217 | 217 | */ |
| 218 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
| 218 | + do_action('give_post_form_output', $form->ID, $args); |
|
| 219 | 219 | |
| 220 | 220 | $final_output = ob_get_clean(); |
| 221 | - $count ++; |
|
| 221 | + $count++; |
|
| 222 | 222 | |
| 223 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
| 223 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -237,11 +237,11 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @return string |
| 239 | 239 | */ |
| 240 | -function give_show_purchase_form( $form_id, $args ) { |
|
| 240 | +function give_show_purchase_form($form_id, $args) { |
|
| 241 | 241 | |
| 242 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
| 242 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
| 243 | 243 | |
| 244 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
| 244 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
| 245 | 245 | $form_id = $_POST['give_form_id']; |
| 246 | 246 | } |
| 247 | 247 | |
@@ -250,33 +250,33 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @since 1.7 |
| 252 | 252 | */ |
| 253 | - do_action( 'give_payment_fields_top', $form_id ); |
|
| 253 | + do_action('give_payment_fields_top', $form_id); |
|
| 254 | 254 | |
| 255 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
| 255 | + if (give_can_checkout() && isset($form_id)) { |
|
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | 258 | * Fires while displaying donation form, before registration login. |
| 259 | 259 | * |
| 260 | 260 | * @since 1.7 |
| 261 | 261 | */ |
| 262 | - do_action( 'give_donation_form_before_register_login', $form_id, $args ); |
|
| 262 | + do_action('give_donation_form_before_register_login', $form_id, $args); |
|
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | 265 | * Fire when register/login form fields render. |
| 266 | 266 | * |
| 267 | 267 | * @since 1.7 |
| 268 | 268 | */ |
| 269 | - do_action( 'give_donation_form_register_login_fields', $form_id, $args ); |
|
| 269 | + do_action('give_donation_form_register_login_fields', $form_id, $args); |
|
| 270 | 270 | |
| 271 | 271 | /** |
| 272 | 272 | * Fire when credit card form fields render. |
| 273 | 273 | * |
| 274 | 274 | * @since 1.7 |
| 275 | 275 | */ |
| 276 | - do_action( 'give_donation_form_before_cc_form', $form_id, $args ); |
|
| 276 | + do_action('give_donation_form_before_cc_form', $form_id, $args); |
|
| 277 | 277 | |
| 278 | 278 | // Load the credit card form and allow gateways to load their own if they wish. |
| 279 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
| 279 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
| 280 | 280 | /** |
| 281 | 281 | * Fires while displaying donation form, credit card form fields for a given gateway. |
| 282 | 282 | * |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * |
| 285 | 285 | * @param int $form_id The form ID. |
| 286 | 286 | */ |
| 287 | - do_action( "give_{$payment_mode}_cc_form", $form_id, $args ); |
|
| 287 | + do_action("give_{$payment_mode}_cc_form", $form_id, $args); |
|
| 288 | 288 | } else { |
| 289 | 289 | /** |
| 290 | 290 | * Fires while displaying donation form, credit card form fields. |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @param int $form_id The form ID. |
| 295 | 295 | */ |
| 296 | - do_action( 'give_cc_form', $form_id, $args ); |
|
| 296 | + do_action('give_cc_form', $form_id, $args); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | /** |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * |
| 302 | 302 | * @since 1.7 |
| 303 | 303 | */ |
| 304 | - do_action( 'give_donation_form_after_cc_form', $form_id, $args ); |
|
| 304 | + do_action('give_donation_form_after_cc_form', $form_id, $args); |
|
| 305 | 305 | |
| 306 | 306 | } else { |
| 307 | 307 | /** |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * |
| 310 | 310 | * @since 1.7 |
| 311 | 311 | */ |
| 312 | - do_action( 'give_donation_form_no_access', $form_id ); |
|
| 312 | + do_action('give_donation_form_no_access', $form_id); |
|
| 313 | 313 | |
| 314 | 314 | } |
| 315 | 315 | |
@@ -318,10 +318,10 @@ discard block |
||
| 318 | 318 | * |
| 319 | 319 | * @since 1.7 |
| 320 | 320 | */ |
| 321 | - do_action( 'give_payment_fields_bottom', $form_id, $args ); |
|
| 321 | + do_action('give_payment_fields_bottom', $form_id, $args); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | -add_action( 'give_donation_form', 'give_show_purchase_form', 10, 2 ); |
|
| 324 | +add_action('give_donation_form', 'give_show_purchase_form', 10, 2); |
|
| 325 | 325 | |
| 326 | 326 | /** |
| 327 | 327 | * Give Show Login/Register Form Fields. |
@@ -332,11 +332,11 @@ discard block |
||
| 332 | 332 | * |
| 333 | 333 | * @return void |
| 334 | 334 | */ |
| 335 | -function give_show_register_login_fields( $form_id ) { |
|
| 335 | +function give_show_register_login_fields($form_id) { |
|
| 336 | 336 | |
| 337 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 337 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 338 | 338 | |
| 339 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 339 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : |
|
| 340 | 340 | ?> |
| 341 | 341 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
| 342 | 342 | <?php |
@@ -345,11 +345,11 @@ discard block |
||
| 345 | 345 | * |
| 346 | 346 | * @since 1.7 |
| 347 | 347 | */ |
| 348 | - do_action( 'give_donation_form_register_fields', $form_id ); |
|
| 348 | + do_action('give_donation_form_register_fields', $form_id); |
|
| 349 | 349 | ?> |
| 350 | 350 | </div> |
| 351 | 351 | <?php |
| 352 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 352 | + elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : |
|
| 353 | 353 | ?> |
| 354 | 354 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
| 355 | 355 | <?php |
@@ -358,23 +358,23 @@ discard block |
||
| 358 | 358 | * |
| 359 | 359 | * @since 1.7 |
| 360 | 360 | */ |
| 361 | - do_action( 'give_donation_form_login_fields', $form_id ); |
|
| 361 | + do_action('give_donation_form_login_fields', $form_id); |
|
| 362 | 362 | ?> |
| 363 | 363 | </div> |
| 364 | 364 | <?php |
| 365 | 365 | endif; |
| 366 | 366 | |
| 367 | - if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
| 367 | + if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
| 368 | 368 | /** |
| 369 | 369 | * Fire when user info render. |
| 370 | 370 | * |
| 371 | 371 | * @since 1.7 |
| 372 | 372 | */ |
| 373 | - do_action( 'give_donation_form_after_user_info', $form_id ); |
|
| 373 | + do_action('give_donation_form_after_user_info', $form_id); |
|
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | -add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
|
| 377 | +add_action('give_donation_form_register_login_fields', 'give_show_register_login_fields'); |
|
| 378 | 378 | |
| 379 | 379 | /** |
| 380 | 380 | * Donation Amount Field. |
@@ -389,16 +389,16 @@ discard block |
||
| 389 | 389 | * |
| 390 | 390 | * @return void |
| 391 | 391 | */ |
| 392 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
| 392 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
| 393 | 393 | |
| 394 | 394 | $give_options = give_get_settings(); |
| 395 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
| 396 | - $allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
| 397 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
| 398 | - $symbol = give_currency_symbol( give_get_currency( $form_id, $args ) ); |
|
| 399 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
| 400 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ), array( 'sanitize' => false, 'currency' => give_get_currency( $form_id ) ) ); |
|
| 401 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 395 | + $variable_pricing = give_has_variable_prices($form_id); |
|
| 396 | + $allow_custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
| 397 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
| 398 | + $symbol = give_currency_symbol(give_get_currency($form_id, $args)); |
|
| 399 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
| 400 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id), array('sanitize' => false, 'currency' => give_get_currency($form_id))); |
|
| 401 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
| 402 | 402 | |
| 403 | 403 | /** |
| 404 | 404 | * Fires while displaying donation form, before donation level fields. |
@@ -408,20 +408,20 @@ discard block |
||
| 408 | 408 | * @param int $form_id The form ID. |
| 409 | 409 | * @param array $args An array of form arguments. |
| 410 | 410 | */ |
| 411 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
| 411 | + do_action('give_before_donation_levels', $form_id, $args); |
|
| 412 | 412 | |
| 413 | 413 | //Set Price, No Custom Amount Allowed means hidden price field |
| 414 | - if ( ! give_is_setting_enabled( $allow_custom_amount ) ) { |
|
| 414 | + if ( ! give_is_setting_enabled($allow_custom_amount)) { |
|
| 415 | 415 | ?> |
| 416 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
| 416 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
| 417 | 417 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
| 418 | 418 | value="<?php echo $default_amount; ?>" required aria-required="true"/> |
| 419 | 419 | <div class="set-price give-donation-amount form-row-wide"> |
| 420 | - <?php if ( $currency_position == 'before' ) { |
|
| 420 | + <?php if ($currency_position == 'before') { |
|
| 421 | 421 | echo $currency_output; |
| 422 | 422 | } ?> |
| 423 | 423 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
| 424 | - <?php if ( $currency_position == 'after' ) { |
|
| 424 | + <?php if ($currency_position == 'after') { |
|
| 425 | 425 | echo $currency_output; |
| 426 | 426 | } ?> |
| 427 | 427 | </div> |
@@ -431,13 +431,13 @@ discard block |
||
| 431 | 431 | ?> |
| 432 | 432 | <div class="give-total-wrap"> |
| 433 | 433 | <div class="give-donation-amount form-row-wide"> |
| 434 | - <?php if ( $currency_position == 'before' ) { |
|
| 434 | + <?php if ($currency_position == 'before') { |
|
| 435 | 435 | echo $currency_output; |
| 436 | 436 | } ?> |
| 437 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
| 437 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
| 438 | 438 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" |
| 439 | 439 | placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
| 440 | - <?php if ( $currency_position == 'after' ) { |
|
| 440 | + <?php if ($currency_position == 'after') { |
|
| 441 | 441 | echo $currency_output; |
| 442 | 442 | } ?> |
| 443 | 443 | </div> |
@@ -452,16 +452,16 @@ discard block |
||
| 452 | 452 | * @param int $form_id The form ID. |
| 453 | 453 | * @param array $args An array of form arguments. |
| 454 | 454 | */ |
| 455 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
| 455 | + do_action('give_after_donation_amount', $form_id, $args); |
|
| 456 | 456 | |
| 457 | 457 | //Custom Amount Text |
| 458 | - if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) { ?> |
|
| 458 | + if ( ! $variable_pricing && give_is_setting_enabled($allow_custom_amount) && ! empty($custom_amount_text)) { ?> |
|
| 459 | 459 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
| 460 | 460 | <?php } |
| 461 | 461 | |
| 462 | 462 | //Output Variable Pricing Levels. |
| 463 | - if ( $variable_pricing ) { |
|
| 464 | - give_output_levels( $form_id ); |
|
| 463 | + if ($variable_pricing) { |
|
| 464 | + give_output_levels($form_id); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | /** |
@@ -472,10 +472,10 @@ discard block |
||
| 472 | 472 | * @param int $form_id The form ID. |
| 473 | 473 | * @param array $args An array of form arguments. |
| 474 | 474 | */ |
| 475 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
| 475 | + do_action('give_after_donation_levels', $form_id, $args); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | -add_action( 'give_donation_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
| 478 | +add_action('give_donation_form_top', 'give_output_donation_amount_top', 10, 2); |
|
| 479 | 479 | |
| 480 | 480 | /** |
| 481 | 481 | * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
@@ -486,48 +486,48 @@ discard block |
||
| 486 | 486 | * |
| 487 | 487 | * @return string Donation levels. |
| 488 | 488 | */ |
| 489 | -function give_output_levels( $form_id ) { |
|
| 489 | +function give_output_levels($form_id) { |
|
| 490 | 490 | |
| 491 | 491 | //Get variable pricing. |
| 492 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 493 | - $display_style = give_get_meta( $form_id, '_give_display_style', true ); |
|
| 494 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
| 495 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 492 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 493 | + $display_style = give_get_meta($form_id, '_give_display_style', true); |
|
| 494 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
| 495 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
| 496 | 496 | |
| 497 | - if ( empty( $custom_amount_text ) ) { |
|
| 498 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
| 497 | + if (empty($custom_amount_text)) { |
|
| 498 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | $output = ''; |
| 502 | 502 | |
| 503 | - switch ( $display_style ) { |
|
| 503 | + switch ($display_style) { |
|
| 504 | 504 | case 'buttons': |
| 505 | 505 | |
| 506 | 506 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
| 507 | 507 | |
| 508 | - foreach ( $prices as $price ) { |
|
| 509 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ), array( 'currency_code' => give_get_currency( $form_id ) ) ), $form_id, $price ); |
|
| 510 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
| 508 | + foreach ($prices as $price) { |
|
| 509 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false)), array('currency_code' => give_get_currency($form_id))), $form_id, $price); |
|
| 510 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$price['_give_id']['level_id'].' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
| 511 | 511 | |
| 512 | - $formatted_amount = give_format_amount( $price['_give_amount'], array( |
|
| 512 | + $formatted_amount = give_format_amount($price['_give_amount'], array( |
|
| 513 | 513 | 'sanitize' => false, |
| 514 | - 'currency' => give_get_currency( $form_id ), |
|
| 515 | - ) ); |
|
| 514 | + 'currency' => give_get_currency($form_id), |
|
| 515 | + )); |
|
| 516 | 516 | |
| 517 | 517 | $output .= sprintf( |
| 518 | 518 | '<li><button type="button" data-price-id="%1$s" class="%2$s" value="%3$s" data-default="%4$s">%5$s</button></li>', |
| 519 | 519 | $price['_give_id']['level_id'], |
| 520 | 520 | $level_classes, |
| 521 | 521 | $formatted_amount, |
| 522 | - array_key_exists( '_give_default', $price ) ? 1 : 0, |
|
| 522 | + array_key_exists('_give_default', $price) ? 1 : 0, |
|
| 523 | 523 | $level_text |
| 524 | 524 | ); |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | //Custom Amount. |
| 528 | 528 | if ( |
| 529 | - give_is_setting_enabled( $custom_amount ) |
|
| 530 | - && ! empty( $custom_amount_text ) |
|
| 529 | + give_is_setting_enabled($custom_amount) |
|
| 530 | + && ! empty($custom_amount_text) |
|
| 531 | 531 | ) { |
| 532 | 532 | |
| 533 | 533 | $output .= sprintf( |
@@ -544,30 +544,30 @@ discard block |
||
| 544 | 544 | |
| 545 | 545 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
| 546 | 546 | |
| 547 | - foreach ( $prices as $price ) { |
|
| 548 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ), array( 'currency_code' => give_get_currency( $form_id ) ) ), $form_id, $price ); |
|
| 549 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
| 547 | + foreach ($prices as $price) { |
|
| 548 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false)), array('currency_code' => give_get_currency($form_id))), $form_id, $price); |
|
| 549 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
| 550 | 550 | |
| 551 | - $formatted_amount = give_format_amount( $price['_give_amount'], array( |
|
| 551 | + $formatted_amount = give_format_amount($price['_give_amount'], array( |
|
| 552 | 552 | 'sanitize' => false, |
| 553 | - 'currency' => give_get_currency( $form_id ), |
|
| 554 | - ) ); |
|
| 553 | + 'currency' => give_get_currency($form_id), |
|
| 554 | + )); |
|
| 555 | 555 | |
| 556 | 556 | $output .= sprintf( |
| 557 | 557 | '<li><input type="radio" data-price-id="%1$s" class="%2$s" value="%3$s" name="give-radio-donation-level" id="give-radio-level-%1$s" %4$s data-default="%5$s"><label for="give-radio-level-%1$s">%6$s</label></li>', |
| 558 | 558 | $price['_give_id']['level_id'], |
| 559 | 559 | $level_classes, |
| 560 | 560 | $formatted_amount, |
| 561 | - ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ), |
|
| 562 | - array_key_exists( '_give_default', $price ) ? 1 : 0, |
|
| 561 | + ((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : ''), |
|
| 562 | + array_key_exists('_give_default', $price) ? 1 : 0, |
|
| 563 | 563 | $level_text |
| 564 | 564 | ); |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | //Custom Amount. |
| 568 | 568 | if ( |
| 569 | - give_is_setting_enabled( $custom_amount ) |
|
| 570 | - && ! empty( $custom_amount_text ) |
|
| 569 | + give_is_setting_enabled($custom_amount) |
|
| 570 | + && ! empty($custom_amount_text) |
|
| 571 | 571 | ) { |
| 572 | 572 | $output .= sprintf( |
| 573 | 573 | '<li><input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom"><label for="give-radio-level-custom">%1$s</label></li>', |
@@ -581,32 +581,32 @@ discard block |
||
| 581 | 581 | |
| 582 | 582 | case 'dropdown': |
| 583 | 583 | |
| 584 | - $output .= '<label for="give-donation-level-select-' . $form_id . '" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
| 585 | - $output .= '<select id="give-donation-level-select-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
| 584 | + $output .= '<label for="give-donation-level-select-'.$form_id.'" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
| 585 | + $output .= '<select id="give-donation-level-select-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
| 586 | 586 | |
| 587 | 587 | //first loop through prices. |
| 588 | - foreach ( $prices as $price ) { |
|
| 589 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ), array( 'currency_code' => give_get_currency( $form_id ) ) ), $form_id, $price ); |
|
| 590 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
| 588 | + foreach ($prices as $price) { |
|
| 589 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false)), array('currency_code' => give_get_currency($form_id))), $form_id, $price); |
|
| 590 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
| 591 | 591 | |
| 592 | - $formatted_amount = give_format_amount( $price['_give_amount'], array( |
|
| 592 | + $formatted_amount = give_format_amount($price['_give_amount'], array( |
|
| 593 | 593 | 'sanitize' => false, |
| 594 | - 'currency' => give_get_currency( $form_id ), |
|
| 595 | - ) ); |
|
| 594 | + 'currency' => give_get_currency($form_id), |
|
| 595 | + )); |
|
| 596 | 596 | |
| 597 | 597 | $output .= sprintf( |
| 598 | 598 | '<option data-price-id="%1$s" class="%2$s" value="%3$s" %4$s data-default="%5$s">%6$s</option>', |
| 599 | 599 | $price['_give_id']['level_id'], |
| 600 | 600 | $level_classes, |
| 601 | 601 | $formatted_amount, |
| 602 | - ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ), |
|
| 603 | - array_key_exists( '_give_default', $price ) ? 1 : 0, |
|
| 602 | + ((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : ''), |
|
| 603 | + array_key_exists('_give_default', $price) ? 1 : 0, |
|
| 604 | 604 | $level_text |
| 605 | 605 | ); |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | //Custom Amount. |
| 609 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
| 609 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
| 610 | 610 | $output .= sprintf( |
| 611 | 611 | '<option data-price-id="custom" class="give-donation-level-custom" value="custom">%1$s</option>', |
| 612 | 612 | $custom_amount_text |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | break; |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
| 621 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | /** |
@@ -633,27 +633,27 @@ discard block |
||
| 633 | 633 | * |
| 634 | 634 | * @return string Checkout button. |
| 635 | 635 | */ |
| 636 | -function give_display_checkout_button( $form_id, $args ) { |
|
| 636 | +function give_display_checkout_button($form_id, $args) { |
|
| 637 | 637 | |
| 638 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
| 638 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
| 639 | 639 | ? $args['display_style'] |
| 640 | - : give_get_meta( $form_id, '_give_payment_display', true ); |
|
| 640 | + : give_get_meta($form_id, '_give_payment_display', true); |
|
| 641 | 641 | |
| 642 | - if ( 'button' === $display_option ) { |
|
| 642 | + if ('button' === $display_option) { |
|
| 643 | 643 | $display_option = 'modal'; |
| 644 | - } elseif ( $display_option === 'onpage' ) { |
|
| 644 | + } elseif ($display_option === 'onpage') { |
|
| 645 | 645 | return ''; |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | - $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true ); |
|
| 649 | - $display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
| 648 | + $display_label_field = give_get_meta($form_id, '_give_reveal_label', true); |
|
| 649 | + $display_label = ! empty($args['continue_button_title']) ? $args['continue_button_title'] : ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
| 650 | 650 | |
| 651 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
| 651 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
| 652 | 652 | |
| 653 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
| 653 | + echo apply_filters('give_display_checkout_button', $output); |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
| 656 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
| 657 | 657 | |
| 658 | 658 | /** |
| 659 | 659 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -666,79 +666,79 @@ discard block |
||
| 666 | 666 | * |
| 667 | 667 | * @return void |
| 668 | 668 | */ |
| 669 | -function give_user_info_fields( $form_id ) { |
|
| 669 | +function give_user_info_fields($form_id) { |
|
| 670 | 670 | // Get user info. |
| 671 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
| 671 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
| 672 | 672 | |
| 673 | 673 | /** |
| 674 | 674 | * Fire before user personal information fields |
| 675 | 675 | * |
| 676 | 676 | * @since 1.7 |
| 677 | 677 | */ |
| 678 | - do_action( 'give_donation_form_before_personal_info', $form_id ); |
|
| 678 | + do_action('give_donation_form_before_personal_info', $form_id); |
|
| 679 | 679 | ?> |
| 680 | 680 | <fieldset id="give_checkout_user_info"> |
| 681 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', __( 'Personal Info', 'give' ) ); ?></legend> |
|
| 681 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', __('Personal Info', 'give')); ?></legend> |
|
| 682 | 682 | <p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive"> |
| 683 | 683 | <label class="give-label" for="give-first"> |
| 684 | - <?php _e( 'First Name', 'give' ); ?> |
|
| 685 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
|
| 684 | + <?php _e('First Name', 'give'); ?> |
|
| 685 | + <?php if (give_field_is_required('give_first', $form_id)) : ?> |
|
| 686 | 686 | <span class="give-required-indicator">*</span> |
| 687 | 687 | <?php endif ?> |
| 688 | - <?php echo Give()->tooltips->render_help( __( 'We will use this to personalize your account experience.', 'give' ) ); ?> |
|
| 688 | + <?php echo Give()->tooltips->render_help(__('We will use this to personalize your account experience.', 'give')); ?> |
|
| 689 | 689 | </label> |
| 690 | 690 | <input |
| 691 | 691 | class="give-input required" |
| 692 | 692 | type="text" |
| 693 | 693 | name="give_first" |
| 694 | 694 | autocomplete="given-name" |
| 695 | - placeholder="<?php _e( 'First Name', 'give' ); ?>" |
|
| 695 | + placeholder="<?php _e('First Name', 'give'); ?>" |
|
| 696 | 696 | id="give-first" |
| 697 | - value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
| 698 | - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 697 | + value="<?php echo isset($give_user_info['give_first']) ? $give_user_info['give_first'] : ''; ?>" |
|
| 698 | + <?php echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 699 | 699 | /> |
| 700 | 700 | </p> |
| 701 | 701 | |
| 702 | 702 | <p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive"> |
| 703 | 703 | <label class="give-label" for="give-last"> |
| 704 | - <?php _e( 'Last Name', 'give' ); ?> |
|
| 705 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
|
| 704 | + <?php _e('Last Name', 'give'); ?> |
|
| 705 | + <?php if (give_field_is_required('give_last', $form_id)) : ?> |
|
| 706 | 706 | <span class="give-required-indicator">*</span> |
| 707 | 707 | <?php endif ?> |
| 708 | - <?php echo Give()->tooltips->render_help( __( 'We will use this as well to personalize your account experience.', 'give' ) ); ?> |
|
| 708 | + <?php echo Give()->tooltips->render_help(__('We will use this as well to personalize your account experience.', 'give')); ?> |
|
| 709 | 709 | </label> |
| 710 | 710 | |
| 711 | 711 | <input |
| 712 | - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
| 712 | + class="give-input<?php echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>" |
|
| 713 | 713 | type="text" |
| 714 | 714 | name="give_last" |
| 715 | 715 | autocomplete="family-name" |
| 716 | 716 | id="give-last" |
| 717 | - placeholder="<?php _e( 'Last Name', 'give' ); ?>" |
|
| 718 | - value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
| 719 | - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 717 | + placeholder="<?php _e('Last Name', 'give'); ?>" |
|
| 718 | + value="<?php echo isset($give_user_info['give_last']) ? $give_user_info['give_last'] : ''; ?>" |
|
| 719 | + <?php echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 720 | 720 | /> |
| 721 | 721 | </p> |
| 722 | 722 | |
| 723 | - <?php if ( give_is_company_field_enabled( $form_id ) ) : ?> |
|
| 724 | - <?php $give_company = give_field_is_required( 'give_company_name', $form_id ); ?> |
|
| 723 | + <?php if (give_is_company_field_enabled($form_id)) : ?> |
|
| 724 | + <?php $give_company = give_field_is_required('give_company_name', $form_id); ?> |
|
| 725 | 725 | <p id="give-company-wrap" class="form-row form-row-wide"> |
| 726 | 726 | <label class="give-label" for="give-company"> |
| 727 | - <?php _e( 'Company Name', 'give' ); ?> |
|
| 728 | - <?php if ( $give_company ) : ?> |
|
| 727 | + <?php _e('Company Name', 'give'); ?> |
|
| 728 | + <?php if ($give_company) : ?> |
|
| 729 | 729 | <span class="give-required-indicator">*</span> |
| 730 | 730 | <?php endif; ?> |
| 731 | - <?php echo Give()->tooltips->render_help( __( 'Donate on behalf of Company', 'give' ) ); ?> |
|
| 731 | + <?php echo Give()->tooltips->render_help(__('Donate on behalf of Company', 'give')); ?> |
|
| 732 | 732 | </label> |
| 733 | 733 | |
| 734 | 734 | <input |
| 735 | - class="give-input<?php echo( $give_company ? ' required' : '' ); ?>" |
|
| 735 | + class="give-input<?php echo($give_company ? ' required' : ''); ?>" |
|
| 736 | 736 | type="text" |
| 737 | 737 | name="give_company_name" |
| 738 | - placeholder="<?php _e( 'Company Name', 'give' ); ?>" |
|
| 738 | + placeholder="<?php _e('Company Name', 'give'); ?>" |
|
| 739 | 739 | id="give-company" |
| 740 | - value="<?php echo isset( $give_user_info['company_name'] ) ? $give_user_info['company_name'] : ''; ?>" |
|
| 741 | - <?php echo( $give_company ? ' required aria-required="true" ' : '' ); ?> |
|
| 740 | + value="<?php echo isset($give_user_info['company_name']) ? $give_user_info['company_name'] : ''; ?>" |
|
| 741 | + <?php echo($give_company ? ' required aria-required="true" ' : ''); ?> |
|
| 742 | 742 | /> |
| 743 | 743 | |
| 744 | 744 | </p> |
@@ -750,15 +750,15 @@ discard block |
||
| 750 | 750 | * |
| 751 | 751 | * @since 1.7 |
| 752 | 752 | */ |
| 753 | - do_action( 'give_donation_form_before_email', $form_id ); |
|
| 753 | + do_action('give_donation_form_before_email', $form_id); |
|
| 754 | 754 | ?> |
| 755 | 755 | <p id="give-email-wrap" class="form-row form-row-wide"> |
| 756 | 756 | <label class="give-label" for="give-email"> |
| 757 | - <?php _e( 'Email Address', 'give' ); ?> |
|
| 758 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
| 757 | + <?php _e('Email Address', 'give'); ?> |
|
| 758 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
| 759 | 759 | <span class="give-required-indicator">*</span> |
| 760 | 760 | <?php } ?> |
| 761 | - <?php echo Give()->tooltips->render_help( __( 'We will send the donation receipt to this address.', 'give' ) ); ?> |
|
| 761 | + <?php echo Give()->tooltips->render_help(__('We will send the donation receipt to this address.', 'give')); ?> |
|
| 762 | 762 | </label> |
| 763 | 763 | |
| 764 | 764 | <input |
@@ -766,10 +766,10 @@ discard block |
||
| 766 | 766 | type="email" |
| 767 | 767 | name="give_email" |
| 768 | 768 | autocomplete="email" |
| 769 | - placeholder="<?php _e( 'Email Address', 'give' ); ?>" |
|
| 769 | + placeholder="<?php _e('Email Address', 'give'); ?>" |
|
| 770 | 770 | id="give-email" |
| 771 | - value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
| 772 | - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 771 | + value="<?php echo isset($give_user_info['give_email']) ? $give_user_info['give_email'] : ''; ?>" |
|
| 772 | + <?php echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 773 | 773 | /> |
| 774 | 774 | |
| 775 | 775 | </p> |
@@ -779,14 +779,14 @@ discard block |
||
| 779 | 779 | * |
| 780 | 780 | * @since 1.7 |
| 781 | 781 | */ |
| 782 | - do_action( 'give_donation_form_after_email', $form_id ); |
|
| 782 | + do_action('give_donation_form_after_email', $form_id); |
|
| 783 | 783 | |
| 784 | 784 | /** |
| 785 | 785 | * Fire after personal email field |
| 786 | 786 | * |
| 787 | 787 | * @since 1.7 |
| 788 | 788 | */ |
| 789 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
| 789 | + do_action('give_donation_form_user_info', $form_id); |
|
| 790 | 790 | ?> |
| 791 | 791 | </fieldset> |
| 792 | 792 | <?php |
@@ -795,11 +795,11 @@ discard block |
||
| 795 | 795 | * |
| 796 | 796 | * @since 1.7 |
| 797 | 797 | */ |
| 798 | - do_action( 'give_donation_form_after_personal_info', $form_id ); |
|
| 798 | + do_action('give_donation_form_after_personal_info', $form_id); |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | -add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
|
| 802 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
| 801 | +add_action('give_donation_form_after_user_info', 'give_user_info_fields'); |
|
| 802 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
| 803 | 803 | |
| 804 | 804 | /** |
| 805 | 805 | * Renders the credit card info form. |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | * |
| 811 | 811 | * @return void |
| 812 | 812 | */ |
| 813 | -function give_get_cc_form( $form_id ) { |
|
| 813 | +function give_get_cc_form($form_id) { |
|
| 814 | 814 | |
| 815 | 815 | ob_start(); |
| 816 | 816 | |
@@ -821,50 +821,50 @@ discard block |
||
| 821 | 821 | * |
| 822 | 822 | * @param int $form_id The form ID. |
| 823 | 823 | */ |
| 824 | - do_action( 'give_before_cc_fields', $form_id ); |
|
| 824 | + do_action('give_before_cc_fields', $form_id); |
|
| 825 | 825 | ?> |
| 826 | 826 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
| 827 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
| 828 | - <?php if ( is_ssl() ) : ?> |
|
| 827 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
| 828 | + <?php if (is_ssl()) : ?> |
|
| 829 | 829 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
| 830 | 830 | <span class="give-icon padlock"></span> |
| 831 | - <span><?php _e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
| 831 | + <span><?php _e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
| 832 | 832 | </div> |
| 833 | 833 | <?php endif; ?> |
| 834 | 834 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
| 835 | 835 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
| 836 | - <?php _e( 'Card Number', 'give' ); ?> |
|
| 836 | + <?php _e('Card Number', 'give'); ?> |
|
| 837 | 837 | <span class="give-required-indicator">*</span> |
| 838 | - <?php echo Give()->tooltips->render_help( __( 'The (typically) 16 digits on the front of your credit card.', 'give' ) ); ?> |
|
| 838 | + <?php echo Give()->tooltips->render_help(__('The (typically) 16 digits on the front of your credit card.', 'give')); ?> |
|
| 839 | 839 | <span class="card-type"></span> |
| 840 | 840 | </label> |
| 841 | 841 | |
| 842 | 842 | <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" |
| 843 | - class="card-number give-input required" placeholder="<?php _e( 'Card number', 'give' ); ?>" |
|
| 843 | + class="card-number give-input required" placeholder="<?php _e('Card number', 'give'); ?>" |
|
| 844 | 844 | required aria-required="true"/> |
| 845 | 845 | </p> |
| 846 | 846 | |
| 847 | 847 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third form-row-responsive"> |
| 848 | 848 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
| 849 | - <?php _e( 'CVC', 'give' ); ?> |
|
| 849 | + <?php _e('CVC', 'give'); ?> |
|
| 850 | 850 | <span class="give-required-indicator">*</span> |
| 851 | - <?php echo Give()->tooltips->render_help( __( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ) ); ?> |
|
| 851 | + <?php echo Give()->tooltips->render_help(__('The 3 digit (back) or 4 digit (front) value on your card.', 'give')); ?> |
|
| 852 | 852 | </label> |
| 853 | 853 | |
| 854 | 854 | <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" |
| 855 | - class="card-cvc give-input required" placeholder="<?php _e( 'Security code', 'give' ); ?>" |
|
| 855 | + class="card-cvc give-input required" placeholder="<?php _e('Security code', 'give'); ?>" |
|
| 856 | 856 | required aria-required="true"/> |
| 857 | 857 | </p> |
| 858 | 858 | |
| 859 | 859 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
| 860 | 860 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
| 861 | - <?php _e( 'Name on the Card', 'give' ); ?> |
|
| 861 | + <?php _e('Name on the Card', 'give'); ?> |
|
| 862 | 862 | <span class="give-required-indicator">*</span> |
| 863 | - <?php echo Give()->tooltips->render_help( __( 'The name printed on the front of your credit card.', 'give' ) ); ?> |
|
| 863 | + <?php echo Give()->tooltips->render_help(__('The name printed on the front of your credit card.', 'give')); ?> |
|
| 864 | 864 | </label> |
| 865 | 865 | |
| 866 | 866 | <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" |
| 867 | - class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" |
|
| 867 | + class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" |
|
| 868 | 868 | required aria-required="true"/> |
| 869 | 869 | </p> |
| 870 | 870 | <?php |
@@ -875,19 +875,19 @@ discard block |
||
| 875 | 875 | * |
| 876 | 876 | * @param int $form_id The form ID. |
| 877 | 877 | */ |
| 878 | - do_action( 'give_before_cc_expiration' ); |
|
| 878 | + do_action('give_before_cc_expiration'); |
|
| 879 | 879 | ?> |
| 880 | 880 | <p class="card-expiration form-row form-row-one-third form-row-responsive"> |
| 881 | 881 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
| 882 | - <?php _e( 'Expiration', 'give' ); ?> |
|
| 882 | + <?php _e('Expiration', 'give'); ?> |
|
| 883 | 883 | <span class="give-required-indicator">*</span> |
| 884 | - <?php echo Give()->tooltips->render_help( __( 'The date your credit card expires, typically on the front of the card.', 'give' ) ); ?> |
|
| 884 | + <?php echo Give()->tooltips->render_help(__('The date your credit card expires, typically on the front of the card.', 'give')); ?> |
|
| 885 | 885 | </label> |
| 886 | 886 | |
| 887 | 887 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" class="card-expiry-month"/> |
| 888 | 888 | <input type="hidden" id="card_exp_year-<?php echo $form_id ?>" name="card_exp_year" class="card-expiry-year"/> |
| 889 | 889 | |
| 890 | - <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" required aria-required="true"/> |
|
| 890 | + <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" required aria-required="true"/> |
|
| 891 | 891 | </p> |
| 892 | 892 | <?php |
| 893 | 893 | /** |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | * |
| 898 | 898 | * @param int $form_id The form ID. |
| 899 | 899 | */ |
| 900 | - do_action( 'give_after_cc_expiration', $form_id ); |
|
| 900 | + do_action('give_after_cc_expiration', $form_id); |
|
| 901 | 901 | ?> |
| 902 | 902 | </fieldset> |
| 903 | 903 | <?php |
@@ -908,12 +908,12 @@ discard block |
||
| 908 | 908 | * |
| 909 | 909 | * @param int $form_id The form ID. |
| 910 | 910 | */ |
| 911 | - do_action( 'give_after_cc_fields', $form_id ); |
|
| 911 | + do_action('give_after_cc_fields', $form_id); |
|
| 912 | 912 | |
| 913 | 913 | echo ob_get_clean(); |
| 914 | 914 | } |
| 915 | 915 | |
| 916 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
| 916 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
| 917 | 917 | |
| 918 | 918 | /** |
| 919 | 919 | * Outputs the default credit card address fields. |
@@ -924,20 +924,20 @@ discard block |
||
| 924 | 924 | * |
| 925 | 925 | * @return void |
| 926 | 926 | */ |
| 927 | -function give_default_cc_address_fields( $form_id ) { |
|
| 927 | +function give_default_cc_address_fields($form_id) { |
|
| 928 | 928 | // Get user info. |
| 929 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
| 929 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
| 930 | 930 | |
| 931 | 931 | $logged_in = is_user_logged_in(); |
| 932 | 932 | |
| 933 | - if ( $logged_in ) { |
|
| 934 | - $user_address = give_get_donor_address( get_current_user_id() ); |
|
| 933 | + if ($logged_in) { |
|
| 934 | + $user_address = give_get_donor_address(get_current_user_id()); |
|
| 935 | 935 | } |
| 936 | 936 | |
| 937 | 937 | ob_start(); |
| 938 | 938 | ?> |
| 939 | 939 | <fieldset id="give_cc_address" class="cc-address"> |
| 940 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
| 940 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
| 941 | 941 | <?php |
| 942 | 942 | /** |
| 943 | 943 | * Fires while rendering credit card billing form, before address fields. |
@@ -946,36 +946,36 @@ discard block |
||
| 946 | 946 | * |
| 947 | 947 | * @param int $form_id The form ID. |
| 948 | 948 | */ |
| 949 | - do_action( 'give_cc_billing_top' ); |
|
| 949 | + do_action('give_cc_billing_top'); |
|
| 950 | 950 | |
| 951 | 951 | // For Country. |
| 952 | 952 | $selected_country = give_get_country(); |
| 953 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
| 953 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
| 954 | 954 | $selected_country = $give_user_info['billing_country']; |
| 955 | 955 | } |
| 956 | 956 | $countries = give_get_country_list(); |
| 957 | 957 | |
| 958 | 958 | // For state |
| 959 | 959 | $selected_state = ''; |
| 960 | - if ( $selected_country === give_get_country() ) { |
|
| 960 | + if ($selected_country === give_get_country()) { |
|
| 961 | 961 | // Get defalut selected state by admin. |
| 962 | 962 | $selected_state = give_get_state(); |
| 963 | 963 | } |
| 964 | 964 | // Get the last payment made by user states. |
| 965 | - if ( ! empty( $give_user_info['card_state'] ) && '*' !== $give_user_info['card_state'] ) { |
|
| 965 | + if ( ! empty($give_user_info['card_state']) && '*' !== $give_user_info['card_state']) { |
|
| 966 | 966 | $selected_state = $give_user_info['card_state']; |
| 967 | 967 | } |
| 968 | 968 | // Get the country code |
| 969 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
| 969 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
| 970 | 970 | $selected_country = $give_user_info['billing_country']; |
| 971 | 971 | } |
| 972 | - $label = __( 'State', 'give' ); |
|
| 972 | + $label = __('State', 'give'); |
|
| 973 | 973 | $states_label = give_get_states_label(); |
| 974 | 974 | // Check if $country code exists in the array key for states label. |
| 975 | - if ( array_key_exists( $selected_country, $states_label ) ) { |
|
| 976 | - $label = $states_label[ $selected_country ]; |
|
| 975 | + if (array_key_exists($selected_country, $states_label)) { |
|
| 976 | + $label = $states_label[$selected_country]; |
|
| 977 | 977 | } |
| 978 | - $states = give_get_states( $selected_country ); |
|
| 978 | + $states = give_get_states($selected_country); |
|
| 979 | 979 | // Get the country list that do not have any states init. |
| 980 | 980 | $no_states_country = give_no_states_country_list(); |
| 981 | 981 | // Get the country list that does not require states. |
@@ -983,24 +983,24 @@ discard block |
||
| 983 | 983 | ?> |
| 984 | 984 | <p id="give-card-country-wrap" class="form-row form-row-wide"> |
| 985 | 985 | <label for="billing_country" class="give-label"> |
| 986 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
| 987 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
|
| 986 | + <?php esc_html_e('Country', 'give'); ?> |
|
| 987 | + <?php if (give_field_is_required('billing_country', $form_id)) : ?> |
|
| 988 | 988 | <span class="give-required-indicator">*</span> |
| 989 | 989 | <?php endif; ?> |
| 990 | 990 | <span class="give-tooltip give-icon give-icon-question" |
| 991 | - data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
| 991 | + data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
| 992 | 992 | </label> |
| 993 | 993 | |
| 994 | 994 | <select |
| 995 | 995 | name="billing_country" |
| 996 | 996 | autocomplete="country-name" |
| 997 | 997 | id="billing_country" |
| 998 | - class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
| 999 | - <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 998 | + class="billing-country billing_country give-select<?php echo(give_field_is_required('billing_country', $form_id) ? ' required' : ''); ?>" |
|
| 999 | + <?php echo(give_field_is_required('billing_country', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 1000 | 1000 | > |
| 1001 | 1001 | <?php |
| 1002 | - foreach ( $countries as $country_code => $country ) { |
|
| 1003 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
| 1002 | + foreach ($countries as $country_code => $country) { |
|
| 1003 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
| 1004 | 1004 | } |
| 1005 | 1005 | ?> |
| 1006 | 1006 | </select> |
@@ -1008,12 +1008,12 @@ discard block |
||
| 1008 | 1008 | |
| 1009 | 1009 | <p id="give-card-address-wrap" class="form-row form-row-wide"> |
| 1010 | 1010 | <label for="card_address" class="give-label"> |
| 1011 | - <?php _e( 'Address 1', 'give' ); ?> |
|
| 1011 | + <?php _e('Address 1', 'give'); ?> |
|
| 1012 | 1012 | <?php |
| 1013 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
| 1013 | + if (give_field_is_required('card_address', $form_id)) : ?> |
|
| 1014 | 1014 | <span class="give-required-indicator">*</span> |
| 1015 | 1015 | <?php endif; ?> |
| 1016 | - <?php echo Give()->tooltips->render_help( __( 'The primary billing address for your credit card.', 'give' ) ); ?> |
|
| 1016 | + <?php echo Give()->tooltips->render_help(__('The primary billing address for your credit card.', 'give')); ?> |
|
| 1017 | 1017 | </label> |
| 1018 | 1018 | |
| 1019 | 1019 | <input |
@@ -1021,20 +1021,20 @@ discard block |
||
| 1021 | 1021 | id="card_address" |
| 1022 | 1022 | name="card_address" |
| 1023 | 1023 | autocomplete="address-line1" |
| 1024 | - class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
| 1025 | - placeholder="<?php _e( 'Address line 1', 'give' ); ?>" |
|
| 1026 | - value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
| 1027 | - <?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 1024 | + class="card-address give-input<?php echo(give_field_is_required('card_address', $form_id) ? ' required' : ''); ?>" |
|
| 1025 | + placeholder="<?php _e('Address line 1', 'give'); ?>" |
|
| 1026 | + value="<?php echo isset($give_user_info['card_address']) ? $give_user_info['card_address'] : ''; ?>" |
|
| 1027 | + <?php echo(give_field_is_required('card_address', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 1028 | 1028 | /> |
| 1029 | 1029 | </p> |
| 1030 | 1030 | |
| 1031 | 1031 | <p id="give-card-address-2-wrap" class="form-row form-row-wide"> |
| 1032 | 1032 | <label for="card_address_2" class="give-label"> |
| 1033 | - <?php _e( 'Address 2', 'give' ); ?> |
|
| 1034 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
|
| 1033 | + <?php _e('Address 2', 'give'); ?> |
|
| 1034 | + <?php if (give_field_is_required('card_address_2', $form_id)) : ?> |
|
| 1035 | 1035 | <span class="give-required-indicator">*</span> |
| 1036 | 1036 | <?php endif; ?> |
| 1037 | - <?php echo Give()->tooltips->render_help( __( '(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give' ) ); ?> |
|
| 1037 | + <?php echo Give()->tooltips->render_help(__('(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give')); ?> |
|
| 1038 | 1038 | </label> |
| 1039 | 1039 | |
| 1040 | 1040 | <input |
@@ -1042,56 +1042,56 @@ discard block |
||
| 1042 | 1042 | id="card_address_2" |
| 1043 | 1043 | name="card_address_2" |
| 1044 | 1044 | autocomplete="address-line2" |
| 1045 | - class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
| 1046 | - placeholder="<?php _e( 'Address line 2', 'give' ); ?>" |
|
| 1047 | - value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
| 1048 | - <?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 1045 | + class="card-address-2 give-input<?php echo(give_field_is_required('card_address_2', $form_id) ? ' required' : ''); ?>" |
|
| 1046 | + placeholder="<?php _e('Address line 2', 'give'); ?>" |
|
| 1047 | + value="<?php echo isset($give_user_info['card_address_2']) ? $give_user_info['card_address_2'] : ''; ?>" |
|
| 1048 | + <?php echo(give_field_is_required('card_address_2', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 1049 | 1049 | /> |
| 1050 | 1050 | </p> |
| 1051 | 1051 | |
| 1052 | 1052 | <p id="give-card-city-wrap" class="form-row form-row-wide"> |
| 1053 | 1053 | <label for="card_city" class="give-label"> |
| 1054 | - <?php _e( 'City', 'give' ); ?> |
|
| 1055 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
|
| 1054 | + <?php _e('City', 'give'); ?> |
|
| 1055 | + <?php if (give_field_is_required('card_city', $form_id)) : ?> |
|
| 1056 | 1056 | <span class="give-required-indicator">*</span> |
| 1057 | 1057 | <?php endif; ?> |
| 1058 | - <?php echo Give()->tooltips->render_help( __( 'The city for your billing address.', 'give' ) ); ?> |
|
| 1058 | + <?php echo Give()->tooltips->render_help(__('The city for your billing address.', 'give')); ?> |
|
| 1059 | 1059 | </label> |
| 1060 | 1060 | <input |
| 1061 | 1061 | type="text" |
| 1062 | 1062 | id="card_city" |
| 1063 | 1063 | name="card_city" |
| 1064 | 1064 | autocomplete="address-level3" |
| 1065 | - class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
| 1066 | - placeholder="<?php _e( 'City', 'give' ); ?>" |
|
| 1067 | - value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
| 1068 | - <?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 1065 | + class="card-city give-input<?php echo(give_field_is_required('card_city', $form_id) ? ' required' : ''); ?>" |
|
| 1066 | + placeholder="<?php _e('City', 'give'); ?>" |
|
| 1067 | + value="<?php echo isset($give_user_info['card_city']) ? $give_user_info['card_city'] : ''; ?>" |
|
| 1068 | + <?php echo(give_field_is_required('card_city', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 1069 | 1069 | /> |
| 1070 | 1070 | </p> |
| 1071 | 1071 | |
| 1072 | 1072 | <p id="give-card-state-wrap" |
| 1073 | - class="form-row form-row-first form-row-responsive <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'give-hidden' : ''; ?> "> |
|
| 1073 | + class="form-row form-row-first form-row-responsive <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country)) ? 'give-hidden' : ''; ?> "> |
|
| 1074 | 1074 | <label for="card_state" class="give-label"> |
| 1075 | 1075 | <span class="state-label-text"><?php echo $label; ?></span> |
| 1076 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
|
| 1076 | + <?php if (give_field_is_required('card_state', $form_id)) : |
|
| 1077 | 1077 | ?> |
| 1078 | - <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
|
| 1078 | + <span class="give-required-indicator <?php echo(array_key_exists($selected_country, $states_not_required_country_list) ? 'give-hidden' : '') ?> ">*</span> |
|
| 1079 | 1079 | <?php endif; ?> |
| 1080 | 1080 | <span class="give-tooltip give-icon give-icon-question" |
| 1081 | - data-tooltip="<?php esc_attr_e( 'The state, province, or county for your billing address.', 'give' ); ?>"></span> |
|
| 1081 | + data-tooltip="<?php esc_attr_e('The state, province, or county for your billing address.', 'give'); ?>"></span> |
|
| 1082 | 1082 | </label> |
| 1083 | 1083 | <?php |
| 1084 | 1084 | |
| 1085 | - if ( ! empty( $states ) ) : ?> |
|
| 1085 | + if ( ! empty($states)) : ?> |
|
| 1086 | 1086 | <select |
| 1087 | 1087 | name="card_state" |
| 1088 | 1088 | autocomplete="address-level4" |
| 1089 | 1089 | id="card_state" |
| 1090 | - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
| 1091 | - <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
|
| 1090 | + class="card_state give-select<?php echo(give_field_is_required('card_state', $form_id) ? ' required' : ''); ?>" |
|
| 1091 | + <?php echo(give_field_is_required('card_state', $form_id) ? ' required aria-required="true" ' : ''); ?>> |
|
| 1092 | 1092 | <?php |
| 1093 | - foreach ( $states as $state_code => $state ) { |
|
| 1094 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
| 1093 | + foreach ($states as $state_code => $state) { |
|
| 1094 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
| 1095 | 1095 | } |
| 1096 | 1096 | ?> |
| 1097 | 1097 | </select> |
@@ -1103,11 +1103,11 @@ discard block |
||
| 1103 | 1103 | |
| 1104 | 1104 | <p id="give-card-zip-wrap" class="form-row form-row-last form-row-responsive"> |
| 1105 | 1105 | <label for="card_zip" class="give-label"> |
| 1106 | - <?php _e( 'Zip / Postal Code', 'give' ); ?> |
|
| 1107 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
|
| 1106 | + <?php _e('Zip / Postal Code', 'give'); ?> |
|
| 1107 | + <?php if (give_field_is_required('card_zip', $form_id)) : ?> |
|
| 1108 | 1108 | <span class="give-required-indicator">*</span> |
| 1109 | 1109 | <?php endif; ?> |
| 1110 | - <?php echo Give()->tooltips->render_help( __( 'The ZIP Code or postal code for your billing address.', 'give' ) ); ?> |
|
| 1110 | + <?php echo Give()->tooltips->render_help(__('The ZIP Code or postal code for your billing address.', 'give')); ?> |
|
| 1111 | 1111 | </label> |
| 1112 | 1112 | |
| 1113 | 1113 | <input |
@@ -1116,10 +1116,10 @@ discard block |
||
| 1116 | 1116 | id="card_zip" |
| 1117 | 1117 | name="card_zip" |
| 1118 | 1118 | autocomplete="postal-code" |
| 1119 | - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
| 1120 | - placeholder="<?php _e( 'Zip / Postal Code', 'give' ); ?>" |
|
| 1121 | - value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
| 1122 | - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 1119 | + class="card-zip give-input<?php echo(give_field_is_required('card_zip', $form_id) ? ' required' : ''); ?>" |
|
| 1120 | + placeholder="<?php _e('Zip / Postal Code', 'give'); ?>" |
|
| 1121 | + value="<?php echo isset($give_user_info['card_zip']) ? $give_user_info['card_zip'] : ''; ?>" |
|
| 1122 | + <?php echo(give_field_is_required('card_zip', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 1123 | 1123 | /> |
| 1124 | 1124 | </p> |
| 1125 | 1125 | <?php |
@@ -1130,14 +1130,14 @@ discard block |
||
| 1130 | 1130 | * |
| 1131 | 1131 | * @param int $form_id The form ID. |
| 1132 | 1132 | */ |
| 1133 | - do_action( 'give_cc_billing_bottom' ); |
|
| 1133 | + do_action('give_cc_billing_bottom'); |
|
| 1134 | 1134 | ?> |
| 1135 | 1135 | </fieldset> |
| 1136 | 1136 | <?php |
| 1137 | 1137 | echo ob_get_clean(); |
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
| 1140 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
| 1141 | 1141 | |
| 1142 | 1142 | |
| 1143 | 1143 | /** |
@@ -1150,15 +1150,15 @@ discard block |
||
| 1150 | 1150 | * |
| 1151 | 1151 | * @return string |
| 1152 | 1152 | */ |
| 1153 | -function give_get_register_fields( $form_id ) { |
|
| 1153 | +function give_get_register_fields($form_id) { |
|
| 1154 | 1154 | |
| 1155 | 1155 | global $user_ID; |
| 1156 | 1156 | |
| 1157 | - if ( is_user_logged_in() ) { |
|
| 1158 | - $user_data = get_userdata( $user_ID ); |
|
| 1157 | + if (is_user_logged_in()) { |
|
| 1158 | + $user_data = get_userdata($user_ID); |
|
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 1161 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 1162 | 1162 | |
| 1163 | 1163 | ob_start(); ?> |
| 1164 | 1164 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
@@ -1171,7 +1171,7 @@ discard block |
||
| 1171 | 1171 | * |
| 1172 | 1172 | * @param int $form_id The form ID. |
| 1173 | 1173 | */ |
| 1174 | - do_action( 'give_register_fields_before', $form_id ); |
|
| 1174 | + do_action('give_register_fields_before', $form_id); |
|
| 1175 | 1175 | ?> |
| 1176 | 1176 | |
| 1177 | 1177 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
@@ -1183,24 +1183,24 @@ discard block |
||
| 1183 | 1183 | * |
| 1184 | 1184 | * @param int $form_id The form ID. |
| 1185 | 1185 | */ |
| 1186 | - do_action( 'give_register_account_fields_before', $form_id ); |
|
| 1186 | + do_action('give_register_account_fields_before', $form_id); |
|
| 1187 | 1187 | |
| 1188 | - $class = ( 'registration' === $show_register_form) ? 'form-row-wide' : 'form-row-first'; |
|
| 1188 | + $class = ('registration' === $show_register_form) ? 'form-row-wide' : 'form-row-first'; |
|
| 1189 | 1189 | ?> |
| 1190 | - <div id="give-create-account-wrap-<?php echo $form_id; ?>" class="form-row <?php echo esc_attr( $class ); ?> form-row-responsive"> |
|
| 1190 | + <div id="give-create-account-wrap-<?php echo $form_id; ?>" class="form-row <?php echo esc_attr($class); ?> form-row-responsive"> |
|
| 1191 | 1191 | <label for="give-create-account-<?php echo $form_id; ?>"> |
| 1192 | 1192 | <?php |
| 1193 | 1193 | // Add attributes to checkbox, if Guest Checkout is disabled. |
| 1194 | - $is_guest_checkout = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
| 1195 | - $id = 'give-create-account-' . $form_id; |
|
| 1196 | - if ( ! give_is_setting_enabled( $is_guest_checkout ) ) { |
|
| 1194 | + $is_guest_checkout = give_get_meta($form_id, '_give_logged_in_only', true); |
|
| 1195 | + $id = 'give-create-account-'.$form_id; |
|
| 1196 | + if ( ! give_is_setting_enabled($is_guest_checkout)) { |
|
| 1197 | 1197 | echo Give()->tooltips->render( |
| 1198 | 1198 | array( |
| 1199 | 1199 | 'tag_content' => sprintf( |
| 1200 | 1200 | '<input type="checkbox" name="give_create_account" value="on" id="%s" class="give-input give-disabled" checked />', |
| 1201 | 1201 | $id |
| 1202 | 1202 | ), |
| 1203 | - 'label' => __( 'Registration is required to donate.', 'give' ), |
|
| 1203 | + 'label' => __('Registration is required to donate.', 'give'), |
|
| 1204 | 1204 | ) ); |
| 1205 | 1205 | } else { |
| 1206 | 1206 | ?> |
@@ -1208,17 +1208,17 @@ discard block |
||
| 1208 | 1208 | <?php |
| 1209 | 1209 | } |
| 1210 | 1210 | ?> |
| 1211 | - <?php _e( 'Create an account', 'give' ); ?> |
|
| 1212 | - <?php echo Give()->tooltips->render_help( __( 'Create an account on the site to see and manage donation history.', 'give' ) ); ?> |
|
| 1213 | - <?php wp_nonce_field( 'give_form_create_user_nonce', 'give-form-user-register-hash', false, true );?> |
|
| 1211 | + <?php _e('Create an account', 'give'); ?> |
|
| 1212 | + <?php echo Give()->tooltips->render_help(__('Create an account on the site to see and manage donation history.', 'give')); ?> |
|
| 1213 | + <?php wp_nonce_field('give_form_create_user_nonce', 'give-form-user-register-hash', false, true); ?> |
|
| 1214 | 1214 | </label> |
| 1215 | 1215 | </div> |
| 1216 | 1216 | |
| 1217 | - <?php if ( 'both' === $show_register_form ) { ?> |
|
| 1217 | + <?php if ('both' === $show_register_form) { ?> |
|
| 1218 | 1218 | <div class="give-login-account-wrap form-row form-row-last form-row-responsive"> |
| 1219 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
| 1220 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" |
|
| 1221 | - data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
| 1219 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
| 1220 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" |
|
| 1221 | + data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
| 1222 | 1222 | </p> |
| 1223 | 1223 | <p class="give-loading-text"> |
| 1224 | 1224 | <span class="give-loading-animation"></span> |
@@ -1234,7 +1234,7 @@ discard block |
||
| 1234 | 1234 | * |
| 1235 | 1235 | * @param int $form_id The form ID. |
| 1236 | 1236 | */ |
| 1237 | - do_action( 'give_register_account_fields_after', $form_id ); |
|
| 1237 | + do_action('give_register_account_fields_after', $form_id); |
|
| 1238 | 1238 | ?> |
| 1239 | 1239 | </fieldset> |
| 1240 | 1240 | |
@@ -1246,7 +1246,7 @@ discard block |
||
| 1246 | 1246 | * |
| 1247 | 1247 | * @param int $form_id The form ID. |
| 1248 | 1248 | */ |
| 1249 | - do_action( 'give_register_fields_after', $form_id ); |
|
| 1249 | + do_action('give_register_fields_after', $form_id); |
|
| 1250 | 1250 | ?> |
| 1251 | 1251 | |
| 1252 | 1252 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
@@ -1257,7 +1257,7 @@ discard block |
||
| 1257 | 1257 | * |
| 1258 | 1258 | * @since 1.7 |
| 1259 | 1259 | */ |
| 1260 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
| 1260 | + do_action('give_donation_form_user_info', $form_id); |
|
| 1261 | 1261 | ?> |
| 1262 | 1262 | |
| 1263 | 1263 | </fieldset> |
@@ -1265,7 +1265,7 @@ discard block |
||
| 1265 | 1265 | echo ob_get_clean(); |
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | -add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
|
| 1268 | +add_action('give_donation_form_register_fields', 'give_get_register_fields'); |
|
| 1269 | 1269 | |
| 1270 | 1270 | /** |
| 1271 | 1271 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -1278,28 +1278,28 @@ discard block |
||
| 1278 | 1278 | * |
| 1279 | 1279 | * @return string |
| 1280 | 1280 | */ |
| 1281 | -function give_get_login_fields( $form_id ) { |
|
| 1281 | +function give_get_login_fields($form_id) { |
|
| 1282 | 1282 | |
| 1283 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
| 1284 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 1283 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
| 1284 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 1285 | 1285 | |
| 1286 | 1286 | ob_start(); |
| 1287 | 1287 | ?> |
| 1288 | 1288 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
| 1289 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', __( 'Login to Your Account', 'give' ) ); |
|
| 1290 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1291 | - echo ' <span class="sub-text">' . __( '(optional)', 'give' ) . '</span>'; |
|
| 1289 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', __('Login to Your Account', 'give')); |
|
| 1290 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1291 | + echo ' <span class="sub-text">'.__('(optional)', 'give').'</span>'; |
|
| 1292 | 1292 | } ?> |
| 1293 | 1293 | </legend> |
| 1294 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
| 1294 | + <?php if ($show_register_form == 'both') { ?> |
|
| 1295 | 1295 | <p class="give-new-account-link"> |
| 1296 | - <?php _e( 'Don\'t have an account?', 'give' ); ?> |
|
| 1297 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
|
| 1296 | + <?php _e('Don\'t have an account?', 'give'); ?> |
|
| 1297 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" |
|
| 1298 | 1298 | data-action="give_checkout_register"> |
| 1299 | - <?php if ( give_logged_in_only( $form_id ) ) { |
|
| 1300 | - _e( 'Register as a part of your donation »', 'give' ); |
|
| 1299 | + <?php if (give_logged_in_only($form_id)) { |
|
| 1300 | + _e('Register as a part of your donation »', 'give'); |
|
| 1301 | 1301 | } else { |
| 1302 | - _e( 'Register or donate as a guest »', 'give' ); |
|
| 1302 | + _e('Register or donate as a guest »', 'give'); |
|
| 1303 | 1303 | } ?> |
| 1304 | 1304 | </a> |
| 1305 | 1305 | </p> |
@@ -1315,49 +1315,49 @@ discard block |
||
| 1315 | 1315 | * |
| 1316 | 1316 | * @param int $form_id The form ID. |
| 1317 | 1317 | */ |
| 1318 | - do_action( 'give_checkout_login_fields_before', $form_id ); |
|
| 1318 | + do_action('give_checkout_login_fields_before', $form_id); |
|
| 1319 | 1319 | ?> |
| 1320 | 1320 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
| 1321 | 1321 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
| 1322 | - <?php _e( 'Username', 'give' ); ?> |
|
| 1323 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1322 | + <?php _e('Username', 'give'); ?> |
|
| 1323 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1324 | 1324 | <span class="give-required-indicator">*</span> |
| 1325 | 1325 | <?php } ?> |
| 1326 | 1326 | </label> |
| 1327 | 1327 | |
| 1328 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" |
|
| 1328 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="text" |
|
| 1329 | 1329 | name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" |
| 1330 | - placeholder="<?php _e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1330 | + placeholder="<?php _e('Your username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1331 | 1331 | </div> |
| 1332 | 1332 | |
| 1333 | 1333 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
| 1334 | 1334 | class="give_login_password form-row form-row-last form-row-responsive"> |
| 1335 | 1335 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
| 1336 | - <?php _e( 'Password', 'give' ); ?> |
|
| 1337 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1336 | + <?php _e('Password', 'give'); ?> |
|
| 1337 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1338 | 1338 | <span class="give-required-indicator">*</span> |
| 1339 | 1339 | <?php } ?> |
| 1340 | 1340 | </label> |
| 1341 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" |
|
| 1341 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" |
|
| 1342 | 1342 | type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" |
| 1343 | - placeholder="<?php _e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1343 | + placeholder="<?php _e('Your password', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1344 | 1344 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
| 1345 | 1345 | </div> |
| 1346 | 1346 | |
| 1347 | 1347 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
| 1348 | 1348 | <span class="give-forgot-password "> |
| 1349 | 1349 | <a href="<?php echo wp_lostpassword_url() ?>" |
| 1350 | - target="_blank"><?php _e( 'Reset Password', 'give' ) ?></a> |
|
| 1350 | + target="_blank"><?php _e('Reset Password', 'give') ?></a> |
|
| 1351 | 1351 | </span> |
| 1352 | 1352 | </div> |
| 1353 | 1353 | |
| 1354 | 1354 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
| 1355 | 1355 | <input type="submit" class="give-submit give-btn button" name="give_login_submit" |
| 1356 | - value="<?php _e( 'Login', 'give' ); ?>"/> |
|
| 1357 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
| 1356 | + value="<?php _e('Login', 'give'); ?>"/> |
|
| 1357 | + <?php if ($show_register_form !== 'login') { ?> |
|
| 1358 | 1358 | <input type="button" data-action="give_cancel_login" |
| 1359 | 1359 | class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" |
| 1360 | - value="<?php _e( 'Cancel', 'give' ); ?>"/> |
|
| 1360 | + value="<?php _e('Cancel', 'give'); ?>"/> |
|
| 1361 | 1361 | <?php } ?> |
| 1362 | 1362 | <span class="give-loading-animation"></span> |
| 1363 | 1363 | </div> |
@@ -1369,14 +1369,14 @@ discard block |
||
| 1369 | 1369 | * |
| 1370 | 1370 | * @param int $form_id The form ID. |
| 1371 | 1371 | */ |
| 1372 | - do_action( 'give_checkout_login_fields_after', $form_id ); |
|
| 1372 | + do_action('give_checkout_login_fields_after', $form_id); |
|
| 1373 | 1373 | ?> |
| 1374 | 1374 | </fieldset><!--end #give-login-fields--> |
| 1375 | 1375 | <?php |
| 1376 | 1376 | echo ob_get_clean(); |
| 1377 | 1377 | } |
| 1378 | 1378 | |
| 1379 | -add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
| 1379 | +add_action('give_donation_form_login_fields', 'give_get_login_fields', 10, 1); |
|
| 1380 | 1380 | |
| 1381 | 1381 | /** |
| 1382 | 1382 | * Payment Mode Select. |
@@ -1392,10 +1392,10 @@ discard block |
||
| 1392 | 1392 | * |
| 1393 | 1393 | * @return void |
| 1394 | 1394 | */ |
| 1395 | -function give_payment_mode_select( $form_id, $args ) { |
|
| 1395 | +function give_payment_mode_select($form_id, $args) { |
|
| 1396 | 1396 | |
| 1397 | - $gateways = give_get_enabled_payment_gateways( $form_id ); |
|
| 1398 | - $id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : ''; |
|
| 1397 | + $gateways = give_get_enabled_payment_gateways($form_id); |
|
| 1398 | + $id_prefix = ! empty($args['id_prefix']) ? $args['id_prefix'] : ''; |
|
| 1399 | 1399 | |
| 1400 | 1400 | /** |
| 1401 | 1401 | * Fires while selecting payment gateways, before the fields. |
@@ -1404,10 +1404,10 @@ discard block |
||
| 1404 | 1404 | * |
| 1405 | 1405 | * @param int $form_id The form ID. |
| 1406 | 1406 | */ |
| 1407 | - do_action( 'give_payment_mode_top', $form_id ); |
|
| 1407 | + do_action('give_payment_mode_top', $form_id); |
|
| 1408 | 1408 | ?> |
| 1409 | 1409 | |
| 1410 | - <fieldset id="give-payment-mode-select" <?php if ( count( $gateways ) <= 1 ) { |
|
| 1410 | + <fieldset id="give-payment-mode-select" <?php if (count($gateways) <= 1) { |
|
| 1411 | 1411 | echo 'style="display: none;"'; |
| 1412 | 1412 | } ?>> |
| 1413 | 1413 | <?php |
@@ -1418,10 +1418,10 @@ discard block |
||
| 1418 | 1418 | * |
| 1419 | 1419 | * @param int $form_id The form ID. |
| 1420 | 1420 | */ |
| 1421 | - do_action( 'give_payment_mode_before_gateways_wrap' ); |
|
| 1421 | + do_action('give_payment_mode_before_gateways_wrap'); |
|
| 1422 | 1422 | ?> |
| 1423 | 1423 | <legend |
| 1424 | - class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?> |
|
| 1424 | + class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?> |
|
| 1425 | 1425 | <span class="give-loading-text"><span |
| 1426 | 1426 | class="give-loading-animation"></span> |
| 1427 | 1427 | </span> |
@@ -1434,37 +1434,36 @@ discard block |
||
| 1434 | 1434 | * |
| 1435 | 1435 | * @since 1.7 |
| 1436 | 1436 | */ |
| 1437 | - do_action( 'give_payment_mode_before_gateways' ) |
|
| 1437 | + do_action('give_payment_mode_before_gateways') |
|
| 1438 | 1438 | ?> |
| 1439 | 1439 | <ul id="give-gateway-radio-list"> |
| 1440 | 1440 | <?php |
| 1441 | 1441 | /** |
| 1442 | 1442 | * Loop through the active payment gateways. |
| 1443 | 1443 | */ |
| 1444 | - $selected_gateway = give_get_chosen_gateway( $form_id ); |
|
| 1444 | + $selected_gateway = give_get_chosen_gateway($form_id); |
|
| 1445 | 1445 | $give_settings = give_get_settings(); |
| 1446 | - $gateways_label = array_key_exists( 'gateways_label', $give_settings ) ? |
|
| 1447 | - $give_settings['gateways_label'] : |
|
| 1448 | - array(); |
|
| 1446 | + $gateways_label = array_key_exists('gateways_label', $give_settings) ? |
|
| 1447 | + $give_settings['gateways_label'] : array(); |
|
| 1449 | 1448 | |
| 1450 | - foreach ( $gateways as $gateway_id => $gateway ) : |
|
| 1449 | + foreach ($gateways as $gateway_id => $gateway) : |
|
| 1451 | 1450 | //Determine the default gateway. |
| 1452 | - $checked = checked( $gateway_id, $selected_gateway, false ); |
|
| 1451 | + $checked = checked($gateway_id, $selected_gateway, false); |
|
| 1453 | 1452 | $checked_class = $checked ? ' class="give-gateway-option-selected"' : ''; ?> |
| 1454 | 1453 | <li<?php echo $checked_class ?>> |
| 1455 | 1454 | <input type="radio" name="payment-mode" class="give-gateway" |
| 1456 | - id="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>" |
|
| 1457 | - value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
| 1455 | + id="give-gateway-<?php echo esc_attr($gateway_id.'-'.$id_prefix); ?>" |
|
| 1456 | + value="<?php echo esc_attr($gateway_id); ?>"<?php echo $checked; ?>> |
|
| 1458 | 1457 | |
| 1459 | 1458 | <?php |
| 1460 | 1459 | $label = $gateway['checkout_label']; |
| 1461 | - if ( ! empty( $gateways_label[ $gateway_id ] ) ) { |
|
| 1462 | - $label = $gateways_label[ $gateway_id ]; |
|
| 1460 | + if ( ! empty($gateways_label[$gateway_id])) { |
|
| 1461 | + $label = $gateways_label[$gateway_id]; |
|
| 1463 | 1462 | } |
| 1464 | 1463 | ?> |
| 1465 | - <label for="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>" |
|
| 1464 | + <label for="give-gateway-<?php echo esc_attr($gateway_id.'-'.$id_prefix); ?>" |
|
| 1466 | 1465 | class="give-gateway-option" |
| 1467 | - id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $label ); ?></label> |
|
| 1466 | + id="give-gateway-option-<?php echo esc_attr($gateway_id); ?>"> <?php echo esc_html($label); ?></label> |
|
| 1468 | 1467 | </li> |
| 1469 | 1468 | <?php |
| 1470 | 1469 | endforeach; |
@@ -1476,7 +1475,7 @@ discard block |
||
| 1476 | 1475 | * |
| 1477 | 1476 | * @since 1.7 |
| 1478 | 1477 | */ |
| 1479 | - do_action( 'give_payment_mode_after_gateways' ); |
|
| 1478 | + do_action('give_payment_mode_after_gateways'); |
|
| 1480 | 1479 | ?> |
| 1481 | 1480 | </div> |
| 1482 | 1481 | <?php |
@@ -1487,7 +1486,7 @@ discard block |
||
| 1487 | 1486 | * |
| 1488 | 1487 | * @param int $form_id The form ID. |
| 1489 | 1488 | */ |
| 1490 | - do_action( 'give_payment_mode_after_gateways_wrap' ); |
|
| 1489 | + do_action('give_payment_mode_after_gateways_wrap'); |
|
| 1491 | 1490 | ?> |
| 1492 | 1491 | </fieldset> |
| 1493 | 1492 | |
@@ -1499,7 +1498,7 @@ discard block |
||
| 1499 | 1498 | * |
| 1500 | 1499 | * @param int $form_id The form ID. |
| 1501 | 1500 | */ |
| 1502 | - do_action( 'give_payment_mode_bottom', $form_id ); |
|
| 1501 | + do_action('give_payment_mode_bottom', $form_id); |
|
| 1503 | 1502 | ?> |
| 1504 | 1503 | |
| 1505 | 1504 | <div id="give_purchase_form_wrap"> |
@@ -1510,7 +1509,7 @@ discard block |
||
| 1510 | 1509 | * |
| 1511 | 1510 | * @since 1.7 |
| 1512 | 1511 | */ |
| 1513 | - do_action( 'give_donation_form', $form_id, $args ); |
|
| 1512 | + do_action('give_donation_form', $form_id, $args); |
|
| 1514 | 1513 | ?> |
| 1515 | 1514 | |
| 1516 | 1515 | </div> |
@@ -1521,10 +1520,10 @@ discard block |
||
| 1521 | 1520 | * |
| 1522 | 1521 | * @since 1.7 |
| 1523 | 1522 | */ |
| 1524 | - do_action( 'give_donation_form_wrap_bottom', $form_id ); |
|
| 1523 | + do_action('give_donation_form_wrap_bottom', $form_id); |
|
| 1525 | 1524 | } |
| 1526 | 1525 | |
| 1527 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select', 10, 2 ); |
|
| 1526 | +add_action('give_payment_mode_select', 'give_payment_mode_select', 10, 2); |
|
| 1528 | 1527 | |
| 1529 | 1528 | /** |
| 1530 | 1529 | * Renders the Checkout Agree to Terms, this displays a checkbox for users to |
@@ -1537,22 +1536,22 @@ discard block |
||
| 1537 | 1536 | * |
| 1538 | 1537 | * @return bool |
| 1539 | 1538 | */ |
| 1540 | -function give_terms_agreement( $form_id ) { |
|
| 1541 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
| 1539 | +function give_terms_agreement($form_id) { |
|
| 1540 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
| 1542 | 1541 | |
| 1543 | 1542 | // Bailout if per form and global term and conditions is not setup. |
| 1544 | 1543 | if ( |
| 1545 | - give_is_setting_enabled( $form_option, 'global' ) |
|
| 1546 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
| 1544 | + give_is_setting_enabled($form_option, 'global') |
|
| 1545 | + && give_is_setting_enabled(give_get_option('terms')) |
|
| 1547 | 1546 | ) { |
| 1548 | - $label = give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
|
| 1549 | - $terms = $terms = give_get_option( 'agreement_text', '' ); |
|
| 1550 | - $edit_term_url = admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions' ); |
|
| 1547 | + $label = give_get_option('agree_to_terms_label', esc_html__('Agree to Terms?', 'give')); |
|
| 1548 | + $terms = $terms = give_get_option('agreement_text', ''); |
|
| 1549 | + $edit_term_url = admin_url('edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions'); |
|
| 1551 | 1550 | |
| 1552 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
| 1553 | - $label = ( $label = give_get_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' ); |
|
| 1554 | - $terms = give_get_meta( $form_id, '_give_agree_text', true ); |
|
| 1555 | - $edit_term_url = admin_url( 'post.php?post=' . $form_id . '&action=edit#form_terms_options' ); |
|
| 1551 | + } elseif (give_is_setting_enabled($form_option)) { |
|
| 1552 | + $label = ($label = give_get_meta($form_id, '_give_agree_label', true)) ? stripslashes($label) : esc_html__('Agree to Terms?', 'give'); |
|
| 1553 | + $terms = give_get_meta($form_id, '_give_agree_text', true); |
|
| 1554 | + $edit_term_url = admin_url('post.php?post='.$form_id.'&action=edit#form_terms_options'); |
|
| 1556 | 1555 | |
| 1557 | 1556 | } else { |
| 1558 | 1557 | return false; |
@@ -1560,9 +1559,9 @@ discard block |
||
| 1560 | 1559 | |
| 1561 | 1560 | |
| 1562 | 1561 | // Bailout: Check if term and conditions text is empty or not. |
| 1563 | - if ( empty( $terms ) ) { |
|
| 1564 | - if ( is_user_logged_in() && current_user_can( 'edit_give_forms' ) ) { |
|
| 1565 | - echo sprintf( __( 'Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), $edit_term_url ); |
|
| 1562 | + if (empty($terms)) { |
|
| 1563 | + if (is_user_logged_in() && current_user_can('edit_give_forms')) { |
|
| 1564 | + echo sprintf(__('Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give'), $edit_term_url); |
|
| 1566 | 1565 | } |
| 1567 | 1566 | |
| 1568 | 1567 | return false; |
@@ -1573,11 +1572,11 @@ discard block |
||
| 1573 | 1572 | * |
| 1574 | 1573 | * @since 2.1.5 |
| 1575 | 1574 | */ |
| 1576 | - $terms = apply_filters( 'give_the_term_content', wpautop( do_shortcode( $terms ) ), $terms, $form_id ); |
|
| 1575 | + $terms = apply_filters('give_the_term_content', wpautop(do_shortcode($terms)), $terms, $form_id); |
|
| 1577 | 1576 | |
| 1578 | 1577 | ?> |
| 1579 | 1578 | <fieldset id="give_terms_agreement"> |
| 1580 | - <legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
| 1579 | + <legend><?php echo apply_filters('give_terms_agreement_text', esc_html__('Terms', 'give')); ?></legend> |
|
| 1581 | 1580 | <div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
| 1582 | 1581 | <?php |
| 1583 | 1582 | /** |
@@ -1585,7 +1584,7 @@ discard block |
||
| 1585 | 1584 | * |
| 1586 | 1585 | * @since 1.0 |
| 1587 | 1586 | */ |
| 1588 | - do_action( 'give_before_terms' ); |
|
| 1587 | + do_action('give_before_terms'); |
|
| 1589 | 1588 | |
| 1590 | 1589 | echo $terms; |
| 1591 | 1590 | /** |
@@ -1593,14 +1592,14 @@ discard block |
||
| 1593 | 1592 | * |
| 1594 | 1593 | * @since 1.0 |
| 1595 | 1594 | */ |
| 1596 | - do_action( 'give_after_terms' ); |
|
| 1595 | + do_action('give_after_terms'); |
|
| 1597 | 1596 | ?> |
| 1598 | 1597 | </div> |
| 1599 | 1598 | <div id="give_show_terms"> |
| 1600 | 1599 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
| 1601 | - aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
| 1600 | + aria-controls="give_terms"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
| 1602 | 1601 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
| 1603 | - aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
| 1602 | + aria-controls="give_terms" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
| 1604 | 1603 | </div> |
| 1605 | 1604 | |
| 1606 | 1605 | <input name="give_agree_to_terms" class="required" type="checkbox" |
@@ -1611,7 +1610,7 @@ discard block |
||
| 1611 | 1610 | <?php |
| 1612 | 1611 | } |
| 1613 | 1612 | |
| 1614 | -add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
|
| 1613 | +add_action('give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1); |
|
| 1615 | 1614 | |
| 1616 | 1615 | /** |
| 1617 | 1616 | * Checkout Final Total. |
@@ -1624,15 +1623,14 @@ discard block |
||
| 1624 | 1623 | * |
| 1625 | 1624 | * @return void |
| 1626 | 1625 | */ |
| 1627 | -function give_checkout_final_total( $form_id ) { |
|
| 1626 | +function give_checkout_final_total($form_id) { |
|
| 1628 | 1627 | |
| 1629 | - $total = isset( $_POST['give_total'] ) ? |
|
| 1630 | - apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give_total'] ) ) : |
|
| 1631 | - give_get_default_form_amount( $form_id ); |
|
| 1628 | + $total = isset($_POST['give_total']) ? |
|
| 1629 | + apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give_total'])) : give_get_default_form_amount($form_id); |
|
| 1632 | 1630 | |
| 1633 | 1631 | |
| 1634 | 1632 | // Only proceed if give_total available. |
| 1635 | - if ( empty( $total ) ) { |
|
| 1633 | + if (empty($total)) { |
|
| 1636 | 1634 | return; |
| 1637 | 1635 | } |
| 1638 | 1636 | ?> |
@@ -1643,19 +1641,19 @@ discard block |
||
| 1643 | 1641 | * |
| 1644 | 1642 | * @since 2.0.5 |
| 1645 | 1643 | */ |
| 1646 | - do_action( 'give_donation_final_total_label_before', $form_id ); |
|
| 1644 | + do_action('give_donation_final_total_label_before', $form_id); |
|
| 1647 | 1645 | ?> |
| 1648 | 1646 | <span class="give-donation-total-label"> |
| 1649 | - <?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?> |
|
| 1647 | + <?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?> |
|
| 1650 | 1648 | </span> |
| 1651 | 1649 | <span class="give-final-total-amount" |
| 1652 | - data-total="<?php echo give_format_amount( $total, array( 'sanitize' => false ) ); ?>"> |
|
| 1650 | + data-total="<?php echo give_format_amount($total, array('sanitize' => false)); ?>"> |
|
| 1653 | 1651 | <?php |
| 1654 | 1652 | |
| 1655 | - echo give_currency_filter( give_format_amount( $total, array( |
|
| 1653 | + echo give_currency_filter(give_format_amount($total, array( |
|
| 1656 | 1654 | 'sanitize' => false, |
| 1657 | - 'currency' => give_get_currency( $form_id ), |
|
| 1658 | - ) ), array( 'currency_code' => give_get_currency( $form_id ) ) ); ?> |
|
| 1655 | + 'currency' => give_get_currency($form_id), |
|
| 1656 | + )), array('currency_code' => give_get_currency($form_id))); ?> |
|
| 1659 | 1657 | </span> |
| 1660 | 1658 | <?php |
| 1661 | 1659 | /** |
@@ -1663,13 +1661,13 @@ discard block |
||
| 1663 | 1661 | * |
| 1664 | 1662 | * @since 2.0.5 |
| 1665 | 1663 | */ |
| 1666 | - do_action( 'give_donation_final_total_label_after', $form_id ); |
|
| 1664 | + do_action('give_donation_final_total_label_after', $form_id); |
|
| 1667 | 1665 | ?> |
| 1668 | 1666 | </p> |
| 1669 | 1667 | <?php |
| 1670 | 1668 | } |
| 1671 | 1669 | |
| 1672 | -add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
|
| 1670 | +add_action('give_donation_form_before_submit', 'give_checkout_final_total', 999); |
|
| 1673 | 1671 | |
| 1674 | 1672 | /** |
| 1675 | 1673 | * Renders the Checkout Submit section. |
@@ -1681,7 +1679,7 @@ discard block |
||
| 1681 | 1679 | * |
| 1682 | 1680 | * @return void |
| 1683 | 1681 | */ |
| 1684 | -function give_checkout_submit( $form_id, $args ) { |
|
| 1682 | +function give_checkout_submit($form_id, $args) { |
|
| 1685 | 1683 | ?> |
| 1686 | 1684 | <fieldset id="give_purchase_submit" class="give-donation-submit"> |
| 1687 | 1685 | <?php |
@@ -1690,24 +1688,24 @@ discard block |
||
| 1690 | 1688 | * |
| 1691 | 1689 | * @since 1.7 |
| 1692 | 1690 | */ |
| 1693 | - do_action( 'give_donation_form_before_submit', $form_id, $args ); |
|
| 1691 | + do_action('give_donation_form_before_submit', $form_id, $args); |
|
| 1694 | 1692 | |
| 1695 | - give_checkout_hidden_fields( $form_id ); |
|
| 1693 | + give_checkout_hidden_fields($form_id); |
|
| 1696 | 1694 | |
| 1697 | - echo give_get_donation_form_submit_button( $form_id ); |
|
| 1695 | + echo give_get_donation_form_submit_button($form_id); |
|
| 1698 | 1696 | |
| 1699 | 1697 | /** |
| 1700 | 1698 | * Fire after donation form submit. |
| 1701 | 1699 | * |
| 1702 | 1700 | * @since 1.7 |
| 1703 | 1701 | */ |
| 1704 | - do_action( 'give_donation_form_after_submit', $form_id, $args ); |
|
| 1702 | + do_action('give_donation_form_after_submit', $form_id, $args); |
|
| 1705 | 1703 | ?> |
| 1706 | 1704 | </fieldset> |
| 1707 | 1705 | <?php |
| 1708 | 1706 | } |
| 1709 | 1707 | |
| 1710 | -add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999, 2 ); |
|
| 1708 | +add_action('give_donation_form_after_cc_form', 'give_checkout_submit', 9999, 2); |
|
| 1711 | 1709 | |
| 1712 | 1710 | /** |
| 1713 | 1711 | * Give Donation form submit button. |
@@ -1718,10 +1716,10 @@ discard block |
||
| 1718 | 1716 | * |
| 1719 | 1717 | * @return string |
| 1720 | 1718 | */ |
| 1721 | -function give_get_donation_form_submit_button( $form_id ) { |
|
| 1719 | +function give_get_donation_form_submit_button($form_id) { |
|
| 1722 | 1720 | |
| 1723 | - $display_label_field = give_get_meta( $form_id, '_give_checkout_label', true ); |
|
| 1724 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
| 1721 | + $display_label_field = give_get_meta($form_id, '_give_checkout_label', true); |
|
| 1722 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
| 1725 | 1723 | ob_start(); |
| 1726 | 1724 | ?> |
| 1727 | 1725 | <div class="give-submit-button-wrap give-clearfix"> |
@@ -1730,7 +1728,7 @@ discard block |
||
| 1730 | 1728 | <span class="give-loading-animation"></span> |
| 1731 | 1729 | </div> |
| 1732 | 1730 | <?php |
| 1733 | - return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id ); |
|
| 1731 | + return apply_filters('give_donation_form_submit_button', ob_get_clean(), $form_id); |
|
| 1734 | 1732 | } |
| 1735 | 1733 | |
| 1736 | 1734 | /** |
@@ -1745,22 +1743,22 @@ discard block |
||
| 1745 | 1743 | * |
| 1746 | 1744 | * @return mixed |
| 1747 | 1745 | */ |
| 1748 | -function give_show_goal_progress( $form_id, $args = array() ) { |
|
| 1746 | +function give_show_goal_progress($form_id, $args = array()) { |
|
| 1749 | 1747 | |
| 1750 | 1748 | ob_start(); |
| 1751 | - give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
|
| 1749 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
| 1752 | 1750 | |
| 1753 | 1751 | /** |
| 1754 | 1752 | * Filter progress bar output |
| 1755 | 1753 | * |
| 1756 | 1754 | * @since 2.0 |
| 1757 | 1755 | */ |
| 1758 | - echo apply_filters( 'give_goal_output', ob_get_clean(), $form_id, $args ); |
|
| 1756 | + echo apply_filters('give_goal_output', ob_get_clean(), $form_id, $args); |
|
| 1759 | 1757 | |
| 1760 | 1758 | return true; |
| 1761 | 1759 | } |
| 1762 | 1760 | |
| 1763 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
| 1761 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
| 1764 | 1762 | |
| 1765 | 1763 | /** |
| 1766 | 1764 | * Show Give Totals Progress. |
@@ -1772,22 +1770,22 @@ discard block |
||
| 1772 | 1770 | * |
| 1773 | 1771 | * @return mixed |
| 1774 | 1772 | */ |
| 1775 | -function give_show_goal_totals_progress( $total, $total_goal ) { |
|
| 1773 | +function give_show_goal_totals_progress($total, $total_goal) { |
|
| 1776 | 1774 | |
| 1777 | 1775 | // Bail out if total goal is set as an array. |
| 1778 | - if ( isset( $total_goal ) && is_array( $total_goal ) ) { |
|
| 1776 | + if (isset($total_goal) && is_array($total_goal)) { |
|
| 1779 | 1777 | return false; |
| 1780 | 1778 | } |
| 1781 | 1779 | |
| 1782 | 1780 | ob_start(); |
| 1783 | - give_get_template( 'shortcode-totals-progress', array( 'total' => $total, 'total_goal' => $total_goal ) ); |
|
| 1781 | + give_get_template('shortcode-totals-progress', array('total' => $total, 'total_goal' => $total_goal)); |
|
| 1784 | 1782 | |
| 1785 | - echo apply_filters( 'give_total_progress_output', ob_get_clean() ); |
|
| 1783 | + echo apply_filters('give_total_progress_output', ob_get_clean()); |
|
| 1786 | 1784 | |
| 1787 | 1785 | return true; |
| 1788 | 1786 | } |
| 1789 | 1787 | |
| 1790 | -add_action( 'give_pre_form', 'give_show_goal_totals_progress', 10, 2 ); |
|
| 1788 | +add_action('give_pre_form', 'give_show_goal_totals_progress', 10, 2); |
|
| 1791 | 1789 | |
| 1792 | 1790 | /** |
| 1793 | 1791 | * Get form content position. |
@@ -1799,10 +1797,10 @@ discard block |
||
| 1799 | 1797 | * |
| 1800 | 1798 | * @return mixed|string |
| 1801 | 1799 | */ |
| 1802 | -function give_get_form_content_placement( $form_id, $args ) { |
|
| 1800 | +function give_get_form_content_placement($form_id, $args) { |
|
| 1803 | 1801 | $show_content = ''; |
| 1804 | 1802 | |
| 1805 | - if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) { |
|
| 1803 | + if (isset($args['show_content']) && ! empty($args['show_content'])) { |
|
| 1806 | 1804 | // Content positions. |
| 1807 | 1805 | $content_placement = array( |
| 1808 | 1806 | 'above' => 'give_pre_form', |
@@ -1810,18 +1808,18 @@ discard block |
||
| 1810 | 1808 | ); |
| 1811 | 1809 | |
| 1812 | 1810 | // Check if content position already decoded. |
| 1813 | - if ( in_array( $args['show_content'], $content_placement ) ) { |
|
| 1811 | + if (in_array($args['show_content'], $content_placement)) { |
|
| 1814 | 1812 | return $args['show_content']; |
| 1815 | 1813 | } |
| 1816 | 1814 | |
| 1817 | - $show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' ); |
|
| 1815 | + $show_content = ('none' !== $args['show_content'] ? $content_placement[$args['show_content']] : ''); |
|
| 1818 | 1816 | |
| 1819 | - } elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) { |
|
| 1820 | - $show_content = give_get_meta( $form_id, '_give_content_placement', true ); |
|
| 1817 | + } elseif (give_is_setting_enabled(give_get_meta($form_id, '_give_display_content', true))) { |
|
| 1818 | + $show_content = give_get_meta($form_id, '_give_content_placement', true); |
|
| 1821 | 1819 | |
| 1822 | - } elseif ( 'none' !== give_get_meta( $form_id, '_give_content_option', true ) ) { |
|
| 1820 | + } elseif ('none' !== give_get_meta($form_id, '_give_content_option', true)) { |
|
| 1823 | 1821 | // Backward compatibility for _give_content_option for v18. |
| 1824 | - $show_content = give_get_meta( $form_id, '_give_content_option', true ); |
|
| 1822 | + $show_content = give_get_meta($form_id, '_give_content_option', true); |
|
| 1825 | 1823 | } |
| 1826 | 1824 | |
| 1827 | 1825 | return $show_content; |
@@ -1837,20 +1835,20 @@ discard block |
||
| 1837 | 1835 | * |
| 1838 | 1836 | * @return void|bool |
| 1839 | 1837 | */ |
| 1840 | -function give_form_content( $form_id, $args ) { |
|
| 1838 | +function give_form_content($form_id, $args) { |
|
| 1841 | 1839 | |
| 1842 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
| 1840 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
| 1843 | 1841 | |
| 1844 | 1842 | // Bailout. |
| 1845 | - if ( empty( $show_content ) ) { |
|
| 1843 | + if (empty($show_content)) { |
|
| 1846 | 1844 | return false; |
| 1847 | 1845 | } |
| 1848 | 1846 | |
| 1849 | 1847 | // Add action according to value. |
| 1850 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
| 1848 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
| 1851 | 1849 | } |
| 1852 | 1850 | |
| 1853 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
| 1851 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
| 1854 | 1852 | |
| 1855 | 1853 | /** |
| 1856 | 1854 | * Renders Post Form Content. |
@@ -1864,14 +1862,14 @@ discard block |
||
| 1864 | 1862 | * |
| 1865 | 1863 | * @return void |
| 1866 | 1864 | */ |
| 1867 | -function give_form_display_content( $form_id, $args ) { |
|
| 1868 | - $content = give_get_meta( $form_id, '_give_form_content', true ); |
|
| 1869 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
| 1870 | - |
|
| 1871 | - if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) { |
|
| 1872 | - $content = apply_filters( 'the_content', $content ); |
|
| 1873 | - } else{ |
|
| 1874 | - $content = wpautop( do_shortcode( $content ) ); |
|
| 1865 | +function give_form_display_content($form_id, $args) { |
|
| 1866 | + $content = give_get_meta($form_id, '_give_form_content', true); |
|
| 1867 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
| 1868 | + |
|
| 1869 | + if (give_is_setting_enabled(give_get_option('the_content_filter'))) { |
|
| 1870 | + $content = apply_filters('the_content', $content); |
|
| 1871 | + } else { |
|
| 1872 | + $content = wpautop(do_shortcode($content)); |
|
| 1875 | 1873 | } |
| 1876 | 1874 | |
| 1877 | 1875 | $output = sprintf( |
@@ -1890,11 +1888,11 @@ discard block |
||
| 1890 | 1888 | * @param int $form_id |
| 1891 | 1889 | * @param array $args |
| 1892 | 1890 | */ |
| 1893 | - echo apply_filters( 'give_form_content_output', $output, $form_id, $args ); |
|
| 1891 | + echo apply_filters('give_form_content_output', $output, $form_id, $args); |
|
| 1894 | 1892 | |
| 1895 | 1893 | // remove action to prevent content output on addition forms on page. |
| 1896 | 1894 | // @see: https://github.com/WordImpress/Give/issues/634. |
| 1897 | - remove_action( $show_content, 'give_form_display_content' ); |
|
| 1895 | + remove_action($show_content, 'give_form_display_content'); |
|
| 1898 | 1896 | } |
| 1899 | 1897 | |
| 1900 | 1898 | /** |
@@ -1906,7 +1904,7 @@ discard block |
||
| 1906 | 1904 | * |
| 1907 | 1905 | * @return void |
| 1908 | 1906 | */ |
| 1909 | -function give_checkout_hidden_fields( $form_id ) { |
|
| 1907 | +function give_checkout_hidden_fields($form_id) { |
|
| 1910 | 1908 | |
| 1911 | 1909 | /** |
| 1912 | 1910 | * Fires while rendering hidden checkout fields, before the fields. |
@@ -1915,13 +1913,13 @@ discard block |
||
| 1915 | 1913 | * |
| 1916 | 1914 | * @param int $form_id The form ID. |
| 1917 | 1915 | */ |
| 1918 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
| 1916 | + do_action('give_hidden_fields_before', $form_id); |
|
| 1919 | 1917 | |
| 1920 | - if ( is_user_logged_in() ) { ?> |
|
| 1918 | + if (is_user_logged_in()) { ?> |
|
| 1921 | 1919 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
| 1922 | 1920 | <?php } ?> |
| 1923 | 1921 | <input type="hidden" name="give_action" value="purchase"/> |
| 1924 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
| 1922 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
| 1925 | 1923 | <?php |
| 1926 | 1924 | /** |
| 1927 | 1925 | * Fires while rendering hidden checkout fields, after the fields. |
@@ -1930,7 +1928,7 @@ discard block |
||
| 1930 | 1928 | * |
| 1931 | 1929 | * @param int $form_id The form ID. |
| 1932 | 1930 | */ |
| 1933 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
| 1931 | + do_action('give_hidden_fields_after', $form_id); |
|
| 1934 | 1932 | |
| 1935 | 1933 | } |
| 1936 | 1934 | |
@@ -1945,20 +1943,20 @@ discard block |
||
| 1945 | 1943 | * |
| 1946 | 1944 | * @return string $content Filtered content. |
| 1947 | 1945 | */ |
| 1948 | -function give_filter_success_page_content( $content ) { |
|
| 1946 | +function give_filter_success_page_content($content) { |
|
| 1949 | 1947 | |
| 1950 | 1948 | $give_options = give_get_settings(); |
| 1951 | 1949 | |
| 1952 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
| 1953 | - if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
| 1954 | - $content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
| 1950 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
| 1951 | + if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) { |
|
| 1952 | + $content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content); |
|
| 1955 | 1953 | } |
| 1956 | 1954 | } |
| 1957 | 1955 | |
| 1958 | 1956 | return $content; |
| 1959 | 1957 | } |
| 1960 | 1958 | |
| 1961 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
| 1959 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
| 1962 | 1960 | |
| 1963 | 1961 | /** |
| 1964 | 1962 | * Test Mode Frontend Warning. |
@@ -1969,12 +1967,12 @@ discard block |
||
| 1969 | 1967 | */ |
| 1970 | 1968 | function give_test_mode_frontend_warning() { |
| 1971 | 1969 | |
| 1972 | - if ( give_is_test_mode() ) { |
|
| 1973 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>'; |
|
| 1970 | + if (give_is_test_mode()) { |
|
| 1971 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice:', 'give').'</strong> '.esc_html__('Test mode is enabled. While in test mode no live donations are processed.', 'give').'</p></div>'; |
|
| 1974 | 1972 | } |
| 1975 | 1973 | } |
| 1976 | 1974 | |
| 1977 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
| 1975 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
| 1978 | 1976 | |
| 1979 | 1977 | /** |
| 1980 | 1978 | * Members-only Form. |
@@ -1988,21 +1986,21 @@ discard block |
||
| 1988 | 1986 | * |
| 1989 | 1987 | * @return string |
| 1990 | 1988 | */ |
| 1991 | -function give_members_only_form( $final_output, $args ) { |
|
| 1989 | +function give_members_only_form($final_output, $args) { |
|
| 1992 | 1990 | |
| 1993 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
| 1991 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
| 1994 | 1992 | |
| 1995 | 1993 | //Sanity Check: Must have form_id & not be logged in. |
| 1996 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
| 1994 | + if (empty($form_id) || is_user_logged_in()) { |
|
| 1997 | 1995 | return $final_output; |
| 1998 | 1996 | } |
| 1999 | 1997 | |
| 2000 | 1998 | //Logged in only and Register / Login set to none. |
| 2001 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
| 1999 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
| 2002 | 2000 | |
| 2003 | - $final_output = Give()->notices->print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
| 2001 | + $final_output = Give()->notices->print_frontend_notice(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
| 2004 | 2002 | |
| 2005 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
| 2003 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
| 2006 | 2004 | |
| 2007 | 2005 | } |
| 2008 | 2006 | |
@@ -2010,7 +2008,7 @@ discard block |
||
| 2010 | 2008 | |
| 2011 | 2009 | } |
| 2012 | 2010 | |
| 2013 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
| 2011 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
|
| 2014 | 2012 | |
| 2015 | 2013 | |
| 2016 | 2014 | /** |
@@ -2022,45 +2020,45 @@ discard block |
||
| 2022 | 2020 | * @param array $args |
| 2023 | 2021 | * @param Give_Donate_Form $form |
| 2024 | 2022 | */ |
| 2025 | -function __give_form_add_donation_hidden_field( $form_id, $args, $form ) { |
|
| 2026 | - $id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : ''; |
|
| 2023 | +function __give_form_add_donation_hidden_field($form_id, $args, $form) { |
|
| 2024 | + $id_prefix = ! empty($args['id_prefix']) ? $args['id_prefix'] : ''; |
|
| 2027 | 2025 | ?> |
| 2028 | 2026 | <input type="hidden" name="give-form-id-prefix" value="<?php echo $id_prefix; ?>"/> |
| 2029 | - <input type="hidden" name="give-form-id" value="<?php echo intval( $form_id ); ?>"/> |
|
| 2030 | - <input type="hidden" name="give-form-title" value="<?php echo esc_html( $form->post_title ); ?>"/> |
|
| 2031 | - <input type="hidden" name="give-current-url" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/> |
|
| 2032 | - <input type="hidden" name="give-form-url" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/> |
|
| 2027 | + <input type="hidden" name="give-form-id" value="<?php echo intval($form_id); ?>"/> |
|
| 2028 | + <input type="hidden" name="give-form-title" value="<?php echo esc_html($form->post_title); ?>"/> |
|
| 2029 | + <input type="hidden" name="give-current-url" value="<?php echo esc_url(give_get_current_page_url()); ?>"/> |
|
| 2030 | + <input type="hidden" name="give-form-url" value="<?php echo esc_url(give_get_current_page_url()); ?>"/> |
|
| 2033 | 2031 | <?php |
| 2034 | 2032 | // Get the custom option amount. |
| 2035 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
| 2033 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
| 2036 | 2034 | |
| 2037 | 2035 | // If custom amount enabled. |
| 2038 | - if ( give_is_setting_enabled( $custom_amount ) ) { |
|
| 2036 | + if (give_is_setting_enabled($custom_amount)) { |
|
| 2039 | 2037 | ?> |
| 2040 | 2038 | <input type="hidden" name="give-form-minimum" |
| 2041 | - value="<?php echo give_maybe_sanitize_amount( give_get_form_minimum_price( $form_id ) ); ?>"/> |
|
| 2039 | + value="<?php echo give_maybe_sanitize_amount(give_get_form_minimum_price($form_id)); ?>"/> |
|
| 2042 | 2040 | <input type="hidden" name="give-form-maximum" |
| 2043 | - value="<?php echo give_maybe_sanitize_amount( give_get_form_maximum_price( $form_id ) ); ?>"/> |
|
| 2041 | + value="<?php echo give_maybe_sanitize_amount(give_get_form_maximum_price($form_id)); ?>"/> |
|
| 2044 | 2042 | <?php |
| 2045 | 2043 | } |
| 2046 | 2044 | |
| 2047 | 2045 | // WP nonce field. |
| 2048 | 2046 | echo str_replace( |
| 2049 | 2047 | '/>', |
| 2050 | - 'data-time="' . time() . '" data-nonce-life="' . give_get_nonce_life() . '"/>', |
|
| 2051 | - give_get_nonce_field( "give_donation_form_nonce_{$form_id}", 'give-form-hash', false ) |
|
| 2048 | + 'data-time="'.time().'" data-nonce-life="'.give_get_nonce_life().'"/>', |
|
| 2049 | + give_get_nonce_field("give_donation_form_nonce_{$form_id}", 'give-form-hash', false) |
|
| 2052 | 2050 | ); |
| 2053 | 2051 | |
| 2054 | 2052 | // Price ID hidden field for variable (multi-level) donation forms. |
| 2055 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 2053 | + if (give_has_variable_prices($form_id)) { |
|
| 2056 | 2054 | |
| 2057 | 2055 | // Get default selected price ID. |
| 2058 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 2056 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 2059 | 2057 | $price_id = 0; |
| 2060 | 2058 | |
| 2061 | 2059 | // Loop through prices. |
| 2062 | - foreach ( $prices as $price ) { |
|
| 2063 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
| 2060 | + foreach ($prices as $price) { |
|
| 2061 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
| 2064 | 2062 | $price_id = $price['_give_id']['level_id']; |
| 2065 | 2063 | }; |
| 2066 | 2064 | } |
@@ -2073,7 +2071,7 @@ discard block |
||
| 2073 | 2071 | } |
| 2074 | 2072 | } |
| 2075 | 2073 | |
| 2076 | -add_action( 'give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3 ); |
|
| 2074 | +add_action('give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3); |
|
| 2077 | 2075 | |
| 2078 | 2076 | /** |
| 2079 | 2077 | * Add currency settings on donation form. |
@@ -2085,20 +2083,20 @@ discard block |
||
| 2085 | 2083 | * |
| 2086 | 2084 | * @return array |
| 2087 | 2085 | */ |
| 2088 | -function __give_form_add_currency_settings( $form_html_tags, $form ) { |
|
| 2089 | - $form_currency = give_get_currency( $form->ID ); |
|
| 2090 | - $currency_settings = give_get_currency_formatting_settings( $form_currency ); |
|
| 2086 | +function __give_form_add_currency_settings($form_html_tags, $form) { |
|
| 2087 | + $form_currency = give_get_currency($form->ID); |
|
| 2088 | + $currency_settings = give_get_currency_formatting_settings($form_currency); |
|
| 2091 | 2089 | |
| 2092 | 2090 | // Check if currency exist. |
| 2093 | - if ( empty( $currency_settings ) ) { |
|
| 2091 | + if (empty($currency_settings)) { |
|
| 2094 | 2092 | return $form_html_tags; |
| 2095 | 2093 | } |
| 2096 | 2094 | |
| 2097 | - $form_html_tags['data-currency_symbol'] = give_currency_symbol( $form_currency ); |
|
| 2095 | + $form_html_tags['data-currency_symbol'] = give_currency_symbol($form_currency); |
|
| 2098 | 2096 | $form_html_tags['data-currency_code'] = $form_currency; |
| 2099 | 2097 | |
| 2100 | - if ( ! empty( $currency_settings ) ) { |
|
| 2101 | - foreach ( $currency_settings as $key => $value ) { |
|
| 2098 | + if ( ! empty($currency_settings)) { |
|
| 2099 | + foreach ($currency_settings as $key => $value) { |
|
| 2102 | 2100 | $form_html_tags["data-{$key}"] = $value; |
| 2103 | 2101 | } |
| 2104 | 2102 | } |
@@ -2106,7 +2104,7 @@ discard block |
||
| 2106 | 2104 | return $form_html_tags; |
| 2107 | 2105 | } |
| 2108 | 2106 | |
| 2109 | -add_filter( 'give_form_html_tags', '__give_form_add_currency_settings', 0, 2 ); |
|
| 2107 | +add_filter('give_form_html_tags', '__give_form_add_currency_settings', 0, 2); |
|
| 2110 | 2108 | |
| 2111 | 2109 | /** |
| 2112 | 2110 | * Adds classes to progress bar container. |
@@ -2117,7 +2115,7 @@ discard block |
||
| 2117 | 2115 | * |
| 2118 | 2116 | * @return string |
| 2119 | 2117 | */ |
| 2120 | -function add_give_goal_progress_class( $class_goal ) { |
|
| 2118 | +function add_give_goal_progress_class($class_goal) { |
|
| 2121 | 2119 | $class_goal = 'progress progress-striped active'; |
| 2122 | 2120 | |
| 2123 | 2121 | return $class_goal; |
@@ -2132,7 +2130,7 @@ discard block |
||
| 2132 | 2130 | * |
| 2133 | 2131 | * @return string |
| 2134 | 2132 | */ |
| 2135 | -function add_give_goal_progress_bar_class( $class_bar ) { |
|
| 2133 | +function add_give_goal_progress_bar_class($class_bar) { |
|
| 2136 | 2134 | $class_bar = 'bar'; |
| 2137 | 2135 | |
| 2138 | 2136 | return $class_bar; |
@@ -2149,12 +2147,12 @@ discard block |
||
| 2149 | 2147 | * |
| 2150 | 2148 | * @return array |
| 2151 | 2149 | */ |
| 2152 | -function add_class_for_form_grid( $class, $id, $args ) { |
|
| 2150 | +function add_class_for_form_grid($class, $id, $args) { |
|
| 2153 | 2151 | $class[] = 'give-form-grid-wrap'; |
| 2154 | 2152 | |
| 2155 | - foreach ( $class as $index => $item ) { |
|
| 2156 | - if( false !== strpos( $item, 'give-display-' ) ) { |
|
| 2157 | - unset( $class[$index] ); |
|
| 2153 | + foreach ($class as $index => $item) { |
|
| 2154 | + if (false !== strpos($item, 'give-display-')) { |
|
| 2155 | + unset($class[$index]); |
|
| 2158 | 2156 | } |
| 2159 | 2157 | } |
| 2160 | 2158 | |
@@ -2170,7 +2168,7 @@ discard block |
||
| 2170 | 2168 | * |
| 2171 | 2169 | * @since 2.1 |
| 2172 | 2170 | */ |
| 2173 | -function give_is_form_grid_page_hidden_field( $id, $args, $form ) { |
|
| 2171 | +function give_is_form_grid_page_hidden_field($id, $args, $form) { |
|
| 2174 | 2172 | echo '<input type="hidden" name="is-form-grid" value="true" />'; |
| 2175 | 2173 | } |
| 2176 | 2174 | |
@@ -2185,28 +2183,28 @@ discard block |
||
| 2185 | 2183 | * @since 2.1 |
| 2186 | 2184 | * @return string |
| 2187 | 2185 | */ |
| 2188 | -function give_redirect_and_popup_form( $redirect, $args ) { |
|
| 2186 | +function give_redirect_and_popup_form($redirect, $args) { |
|
| 2189 | 2187 | |
| 2190 | 2188 | // Check the page has Form Grid. |
| 2191 | - $is_form_grid = isset( $_POST['is-form-grid'] ) ? give_clean( $_POST['is-form-grid'] ) : ''; |
|
| 2189 | + $is_form_grid = isset($_POST['is-form-grid']) ? give_clean($_POST['is-form-grid']) : ''; |
|
| 2192 | 2190 | |
| 2193 | - if ( 'true' === $is_form_grid ) { |
|
| 2191 | + if ('true' === $is_form_grid) { |
|
| 2194 | 2192 | |
| 2195 | - $payment_mode = give_clean( $_POST['payment-mode'] ); |
|
| 2193 | + $payment_mode = give_clean($_POST['payment-mode']); |
|
| 2196 | 2194 | $form_id = $args['form-id']; |
| 2197 | 2195 | |
| 2198 | 2196 | // Get the URL without Query parameters. |
| 2199 | - $redirect = strtok( $redirect, '?' ); |
|
| 2197 | + $redirect = strtok($redirect, '?'); |
|
| 2200 | 2198 | |
| 2201 | 2199 | // Add query parameters 'form-id' and 'payment-mode'. |
| 2202 | - $redirect = add_query_arg( array( |
|
| 2200 | + $redirect = add_query_arg(array( |
|
| 2203 | 2201 | 'form-id' => $form_id, |
| 2204 | 2202 | 'payment-mode' => $payment_mode, |
| 2205 | - ), $redirect ); |
|
| 2203 | + ), $redirect); |
|
| 2206 | 2204 | } |
| 2207 | 2205 | |
| 2208 | 2206 | // Return the modified URL. |
| 2209 | 2207 | return $redirect; |
| 2210 | 2208 | } |
| 2211 | 2209 | |
| 2212 | -add_filter( 'give_send_back_to_checkout', 'give_redirect_and_popup_form', 10, 2 ); |
|
| 2210 | +add_filter('give_send_back_to_checkout', 'give_redirect_and_popup_form', 10, 2); |
|
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -18,34 +18,34 @@ discard block |
||
| 18 | 18 | ?> |
| 19 | 19 | <div class="wrap" id="poststuff"> |
| 20 | 20 | <div id="give-updates"> |
| 21 | - <h1 id="give-updates-h1"><?php esc_html_e( 'Give - Updates', 'give' ); ?></h1> |
|
| 21 | + <h1 id="give-updates-h1"><?php esc_html_e('Give - Updates', 'give'); ?></h1> |
|
| 22 | 22 | <hr class="wp-header-end"> |
| 23 | 23 | |
| 24 | 24 | <?php $db_updates = $give_updates->get_pending_db_update_count(); ?> |
| 25 | - <?php if ( ! empty( $db_updates ) ) : ?> |
|
| 25 | + <?php if ( ! empty($db_updates)) : ?> |
|
| 26 | 26 | <?php |
| 27 | 27 | $is_doing_updates = $give_updates->is_doing_updates(); |
| 28 | - $db_update_url = add_query_arg( array( 'type' => 'database', ) ); |
|
| 29 | - $resume_updates = get_option( 'give_doing_upgrade' ); |
|
| 30 | - $width = ! empty( $resume_updates ) ? $resume_updates['percentage'] : 0; |
|
| 28 | + $db_update_url = add_query_arg(array('type' => 'database',)); |
|
| 29 | + $resume_updates = get_option('give_doing_upgrade'); |
|
| 30 | + $width = ! empty($resume_updates) ? $resume_updates['percentage'] : 0; |
|
| 31 | 31 | ?> |
| 32 | 32 | <div class="give-update-panel-content"> |
| 33 | - <p><?php printf( __( 'Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons. Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give' ), 'https://givewp.com/my-account/' ); ?></p> |
|
| 33 | + <p><?php printf(__('Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons. Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give'), 'https://givewp.com/my-account/'); ?></p> |
|
| 34 | 34 | </div> |
| 35 | 35 | |
| 36 | - <div id="give-db-updates" data-resume-update="<?php echo absint( $give_updates->is_doing_updates() ); ?>"> |
|
| 36 | + <div id="give-db-updates" data-resume-update="<?php echo absint($give_updates->is_doing_updates()); ?>"> |
|
| 37 | 37 | <div class="postbox-container"> |
| 38 | 38 | <div class="postbox"> |
| 39 | - <h2 class="hndle"><?php _e( 'Database Updates', 'give' ); ?></h2> |
|
| 39 | + <h2 class="hndle"><?php _e('Database Updates', 'give'); ?></h2> |
|
| 40 | 40 | <div class="inside"> |
| 41 | 41 | <div class="panel-content"> |
| 42 | 42 | <?php |
| 43 | - if ( ! give_test_ajax_works() ) : |
|
| 43 | + if ( ! give_test_ajax_works()) : |
|
| 44 | 44 | echo sprintf( |
| 45 | 45 | '%1$s <a href="%2$s" target="_blank">%3$s</a>', |
| 46 | - __( 'Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give' ), |
|
| 47 | - esc_url( 'http://docs.givewp.com/troubleshooting-db-updates' ), |
|
| 48 | - __( 'Read More', 'give' ) . ' »' |
|
| 46 | + __('Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give'), |
|
| 47 | + esc_url('http://docs.givewp.com/troubleshooting-db-updates'), |
|
| 48 | + __('Read More', 'give').' »' |
|
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | 51 | else: |
@@ -54,32 +54,31 @@ discard block |
||
| 54 | 54 | <span class="give-doing-update-text-p" <?php echo Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
| 55 | 55 | <?php |
| 56 | 56 | echo sprintf( |
| 57 | - __( '%1$s <a href="%2$s" class="give-update-now %3$s">%4$s</a>', 'give' ), |
|
| 57 | + __('%1$s <a href="%2$s" class="give-update-now %3$s">%4$s</a>', 'give'), |
|
| 58 | 58 | $is_doing_updates ? |
| 59 | - __( 'Give is currently updating the database in the background.', 'give' ) : |
|
| 60 | - __( 'Give needs to update the database.', 'give' ), |
|
| 59 | + __('Give is currently updating the database in the background.', 'give') : __('Give needs to update the database.', 'give'), |
|
| 61 | 60 | $db_update_url, |
| 62 | - ( $is_doing_updates ? 'give-hidden' : '' ), |
|
| 63 | - __( 'Update now', 'give' ) |
|
| 61 | + ($is_doing_updates ? 'give-hidden' : ''), |
|
| 62 | + __('Update now', 'give') |
|
| 64 | 63 | ); |
| 65 | 64 | ?> |
| 66 | 65 | </span> |
| 67 | 66 | <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
| 68 | - <?php if ( get_option( 'give_upgrade_error' ) ) : ?> |
|
| 69 | - <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
|
| 67 | + <?php if (get_option('give_upgrade_error')) : ?> |
|
| 68 | + <?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?> |
|
| 70 | 69 | <?php else : ?> |
| 71 | - <?php _e( 'The updates have been paused.', 'give' ); ?> |
|
| 70 | + <?php _e('The updates have been paused.', 'give'); ?> |
|
| 72 | 71 | |
| 73 | 72 | <?php endif; ?> |
| 74 | 73 | </span> |
| 75 | 74 | |
| 76 | - <?php if ( Give_Updates::$background_updater->is_paused_process() ) : ?> |
|
| 77 | - <?php $is_disabled = isset( $_GET['give-restart-db-upgrades'] ) ? ' disabled' : ''; ?> |
|
| 78 | - <button id="give-restart-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url( admin_url( '/edit.php?post_type=give_forms&page=give-updates&give-restart-db-upgrades=1' ) ); ?>"<?php echo $is_disabled; ?>><?php _e( 'Restart Upgrades', 'give' ); ?></button> |
|
| 79 | - <?php elseif ( $give_updates->is_doing_updates() ): ?> |
|
| 80 | - <?php $is_disabled = isset( $_GET['give-pause-db-upgrades'] ) ? ' disabled' : ''; ?> |
|
| 81 | - <button id="give-pause-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url( admin_url( '/edit.php?post_type=give_forms&page=give-updates&give-pause-db-upgrades=1' ) ); ?>"<?php echo $is_disabled; ?>> |
|
| 82 | - <?php _e( 'Pause Upgrades', 'give' ); ?> |
|
| 75 | + <?php if (Give_Updates::$background_updater->is_paused_process()) : ?> |
|
| 76 | + <?php $is_disabled = isset($_GET['give-restart-db-upgrades']) ? ' disabled' : ''; ?> |
|
| 77 | + <button id="give-restart-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url(admin_url('/edit.php?post_type=give_forms&page=give-updates&give-restart-db-upgrades=1')); ?>"<?php echo $is_disabled; ?>><?php _e('Restart Upgrades', 'give'); ?></button> |
|
| 78 | + <?php elseif ($give_updates->is_doing_updates()): ?> |
|
| 79 | + <?php $is_disabled = isset($_GET['give-pause-db-upgrades']) ? ' disabled' : ''; ?> |
|
| 80 | + <button id="give-pause-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url(admin_url('/edit.php?post_type=give_forms&page=give-updates&give-pause-db-upgrades=1')); ?>"<?php echo $is_disabled; ?>> |
|
| 81 | + <?php _e('Pause Upgrades', 'give'); ?> |
|
| 83 | 82 | </button> |
| 84 | 83 | <?php endif; ?> |
| 85 | 84 | </p> |
@@ -89,7 +88,7 @@ discard block |
||
| 89 | 88 | <strong> |
| 90 | 89 | <?php |
| 91 | 90 | echo sprintf( |
| 92 | - __( 'Update %s of %s', 'give' ), |
|
| 91 | + __('Update %s of %s', 'give'), |
|
| 93 | 92 | $give_updates->get_running_db_update(), |
| 94 | 93 | $give_updates->get_total_new_db_update_count() |
| 95 | 94 | ); |
@@ -97,10 +96,10 @@ discard block |
||
| 97 | 96 | </strong> |
| 98 | 97 | </p> |
| 99 | 98 | <div class="progress-content"> |
| 100 | - <?php if ( $is_doing_updates ) : ?> |
|
| 99 | + <?php if ($is_doing_updates) : ?> |
|
| 101 | 100 | <div class="notice-wrap give-clearfix"> |
| 102 | 101 | |
| 103 | - <?php if ( ! Give_Updates::$background_updater->is_paused_process() ) : ?> |
|
| 102 | + <?php if ( ! Give_Updates::$background_updater->is_paused_process()) : ?> |
|
| 104 | 103 | <span class="spinner is-active"></span> |
| 105 | 104 | <?php endif; ?> |
| 106 | 105 | |
@@ -111,7 +110,7 @@ discard block |
||
| 111 | 110 | <?php endif; ?> |
| 112 | 111 | </div> |
| 113 | 112 | </div> |
| 114 | - <?php if ( ! $is_doing_updates ) : ?> |
|
| 113 | + <?php if ( ! $is_doing_updates) : ?> |
|
| 115 | 114 | <div class="give-run-database-update"></div> |
| 116 | 115 | <?php endif; ?> |
| 117 | 116 | <?php endif; ?> |
@@ -120,18 +119,18 @@ discard block |
||
| 120 | 119 | </div><!-- .postbox --> |
| 121 | 120 | </div> <!-- .post-container --> |
| 122 | 121 | </div> |
| 123 | - <?php else: include GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/db-upgrades-complete-metabox.php'; ?> |
|
| 122 | + <?php else: include GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/db-upgrades-complete-metabox.php'; ?> |
|
| 124 | 123 | <?php endif; ?> |
| 125 | 124 | |
| 126 | 125 | <?php $plugin_updates = $give_updates->get_total_plugin_update_count(); ?> |
| 127 | - <?php if ( ! empty( $plugin_updates ) ) : ?> |
|
| 128 | - <?php $plugin_update_url = add_query_arg( array( |
|
| 126 | + <?php if ( ! empty($plugin_updates)) : ?> |
|
| 127 | + <?php $plugin_update_url = add_query_arg(array( |
|
| 129 | 128 | 'plugin_status' => 'give', |
| 130 | - ), admin_url( '/plugins.php' ) ); ?> |
|
| 129 | + ), admin_url('/plugins.php')); ?> |
|
| 131 | 130 | <div id="give-plugin-updates"> |
| 132 | 131 | <div class="postbox-container"> |
| 133 | 132 | <div class="postbox"> |
| 134 | - <h2 class="hndle"><?php _e( 'Add-on Updates', 'give' ); ?></h2> |
|
| 133 | + <h2 class="hndle"><?php _e('Add-on Updates', 'give'); ?></h2> |
|
| 135 | 134 | <div class="inside"> |
| 136 | 135 | <div class="panel-content"> |
| 137 | 136 | <p> |
@@ -48,10 +48,13 @@ discard block |
||
| 48 | 48 | __( 'Read More', 'give' ) . ' »' |
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | - else: |
|
| 51 | + else { |
|
| 52 | + : |
|
| 52 | 53 | ?> |
| 53 | 54 | <p class="give-update-button"> |
| 54 | - <span class="give-doing-update-text-p" <?php echo Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
| 55 | + <span class="give-doing-update-text-p" <?php echo Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; |
|
| 56 | + } |
|
| 57 | + ?>> |
|
| 55 | 58 | <?php |
| 56 | 59 | echo sprintf( |
| 57 | 60 | __( '%1$s <a href="%2$s" class="give-update-now %3$s">%4$s</a>', 'give' ), |
@@ -67,8 +70,11 @@ discard block |
||
| 67 | 70 | <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
| 68 | 71 | <?php if ( get_option( 'give_upgrade_error' ) ) : ?> |
| 69 | 72 | <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
| 70 | - <?php else : ?> |
|
| 71 | - <?php _e( 'The updates have been paused.', 'give' ); ?> |
|
| 73 | + <?php else { |
|
| 74 | + : ?> |
|
| 75 | + <?php _e( 'The updates have been paused.', 'give' ); |
|
| 76 | +} |
|
| 77 | +?> |
|
| 72 | 78 | |
| 73 | 79 | <?php endif; ?> |
| 74 | 80 | </span> |
@@ -120,7 +126,10 @@ discard block |
||
| 120 | 126 | </div><!-- .postbox --> |
| 121 | 127 | </div> <!-- .post-container --> |
| 122 | 128 | </div> |
| 123 | - <?php else: include GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/db-upgrades-complete-metabox.php'; ?> |
|
| 129 | + <?php else { |
|
| 130 | + : include GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/db-upgrades-complete-metabox.php'; |
|
| 131 | +} |
|
| 132 | +?> |
|
| 124 | 133 | <?php endif; ?> |
| 125 | 134 | |
| 126 | 135 | <?php $plugin_updates = $give_updates->get_total_plugin_update_count(); ?> |
@@ -80,34 +80,34 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @param array $args |
| 82 | 82 | */ |
| 83 | - public function register( $args ) { |
|
| 83 | + public function register($args) { |
|
| 84 | 84 | $args_default = array( |
| 85 | 85 | 'id' => '', |
| 86 | 86 | 'version' => '', |
| 87 | 87 | 'callback' => '', |
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | - $args = wp_parse_args( $args, $args_default ); |
|
| 90 | + $args = wp_parse_args($args, $args_default); |
|
| 91 | 91 | |
| 92 | 92 | // You can only register database upgrade. |
| 93 | 93 | $args['type'] = 'database'; |
| 94 | 94 | |
| 95 | 95 | // Bailout. |
| 96 | 96 | if ( |
| 97 | - empty( $args['id'] ) || |
|
| 98 | - empty( $args['version'] ) || |
|
| 99 | - empty( $args['callback'] ) || |
|
| 100 | - ! is_callable( $args['callback'] ) |
|
| 97 | + empty($args['id']) || |
|
| 98 | + empty($args['version']) || |
|
| 99 | + empty($args['callback']) || |
|
| 100 | + ! is_callable($args['callback']) |
|
| 101 | 101 | ) { |
| 102 | 102 | return; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // Change depend param to array. |
| 106 | - if ( isset( $args['depend'] ) && is_string( $args['depend'] ) ) { |
|
| 107 | - $args['depend'] = array( $args['depend'] ); |
|
| 106 | + if (isset($args['depend']) && is_string($args['depend'])) { |
|
| 107 | + $args['depend'] = array($args['depend']); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $this->updates[ $args['type'] ][] = $args; |
|
| 110 | + $this->updates[$args['type']][] = $args; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * @return static |
| 119 | 119 | */ |
| 120 | 120 | static function get_instance() { |
| 121 | - if ( is_null( self::$instance ) ) { |
|
| 121 | + if (is_null(self::$instance)) { |
|
| 122 | 122 | self::$instance = new self(); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -136,27 +136,27 @@ discard block |
||
| 136 | 136 | /** |
| 137 | 137 | * Load file |
| 138 | 138 | */ |
| 139 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-background-updater.php'; |
|
| 140 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
| 139 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-background-updater.php'; |
|
| 140 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
| 141 | 141 | |
| 142 | 142 | self::$background_updater = new Give_Background_Updater(); |
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Setup hooks. |
| 146 | 146 | */ |
| 147 | - add_action( 'init', array( $this, '__register_upgrade' ), 9999 ); |
|
| 148 | - add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 ); |
|
| 149 | - add_action( 'wp_ajax_give_db_updates_info', array( $this, '__give_db_updates_info' ) ); |
|
| 150 | - add_action( 'wp_ajax_give_run_db_updates', array( $this, '__give_start_updating' ) ); |
|
| 151 | - add_action( 'admin_init', array( $this, '__redirect_admin' ) ); |
|
| 152 | - add_action( 'admin_init', array( $this, '__pause_db_update' ), - 1 ); |
|
| 153 | - add_action( 'admin_init', array( $this, '__restart_db_update' ), - 1 ); |
|
| 154 | - add_action( 'admin_notices', array( $this, '__show_notice' ) ); |
|
| 155 | - add_action( 'give_restart_db_upgrade', array( $this, '__health_background_update' ) ); |
|
| 156 | - |
|
| 157 | - if ( is_admin() ) { |
|
| 158 | - add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 ); |
|
| 159 | - add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 ); |
|
| 147 | + add_action('init', array($this, '__register_upgrade'), 9999); |
|
| 148 | + add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999); |
|
| 149 | + add_action('wp_ajax_give_db_updates_info', array($this, '__give_db_updates_info')); |
|
| 150 | + add_action('wp_ajax_give_run_db_updates', array($this, '__give_start_updating')); |
|
| 151 | + add_action('admin_init', array($this, '__redirect_admin')); |
|
| 152 | + add_action('admin_init', array($this, '__pause_db_update'), - 1); |
|
| 153 | + add_action('admin_init', array($this, '__restart_db_update'), - 1); |
|
| 154 | + add_action('admin_notices', array($this, '__show_notice')); |
|
| 155 | + add_action('give_restart_db_upgrade', array($this, '__health_background_update')); |
|
| 156 | + |
|
| 157 | + if (is_admin()) { |
|
| 158 | + add_action('admin_init', array($this, '__change_donations_label'), 9999); |
|
| 159 | + add_action('admin_menu', array($this, '__register_menu'), 9999); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
@@ -170,12 +170,12 @@ discard block |
||
| 170 | 170 | $addons = give_get_plugins(); |
| 171 | 171 | $plugin_updates = get_plugin_updates(); |
| 172 | 172 | |
| 173 | - foreach ( $addons as $key => $info ) { |
|
| 174 | - if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) { |
|
| 173 | + foreach ($addons as $key => $info) { |
|
| 174 | + if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) { |
|
| 175 | 175 | continue; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - $this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] ); |
|
| 178 | + $this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * @access public |
| 188 | 188 | */ |
| 189 | 189 | public function __register_upgrade() { |
| 190 | - if ( ! is_admin() ) { |
|
| 190 | + if ( ! is_admin()) { |
|
| 191 | 191 | return; |
| 192 | 192 | } |
| 193 | 193 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * |
| 197 | 197 | * @since 1.8.12 |
| 198 | 198 | */ |
| 199 | - do_action( 'give_register_updates', $this ); |
|
| 199 | + do_action('give_register_updates', $this); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -209,23 +209,22 @@ discard block |
||
| 209 | 209 | global $menu; |
| 210 | 210 | |
| 211 | 211 | // Bailout. |
| 212 | - if ( empty( $menu ) || ! $this->get_total_update_count() ) { |
|
| 212 | + if (empty($menu) || ! $this->get_total_update_count()) { |
|
| 213 | 213 | return; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
| 216 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
| 217 | 217 | |
| 218 | - foreach ( $menu as $index => $menu_item ) { |
|
| 219 | - if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) { |
|
| 218 | + foreach ($menu as $index => $menu_item) { |
|
| 219 | + if ('edit.php?post_type=give_forms' !== $menu_item[2]) { |
|
| 220 | 220 | continue; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - $menu[ $index ][0] = sprintf( |
|
| 223 | + $menu[$index][0] = sprintf( |
|
| 224 | 224 | '%1$s <span class="update-plugins"><span class="plugin-count give-update-progress-count">%2$s%3$s</span></span>', |
| 225 | - __( 'Donations', 'give' ), |
|
| 225 | + __('Donations', 'give'), |
|
| 226 | 226 | $is_update ? |
| 227 | - $this->get_db_update_processing_percentage() : |
|
| 228 | - $this->get_total_update_count(), |
|
| 227 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
| 229 | 228 | $is_update ? '%' : '' |
| 230 | 229 | ); |
| 231 | 230 | |
@@ -244,41 +243,40 @@ discard block |
||
| 244 | 243 | $this->__register_plugin_addon_updates(); |
| 245 | 244 | |
| 246 | 245 | // Bailout. |
| 247 | - if ( ! $this->get_total_update_count() ) { |
|
| 246 | + if ( ! $this->get_total_update_count()) { |
|
| 248 | 247 | // Show complete update message if still on update setting page. |
| 249 | - if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) { |
|
| 248 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
| 250 | 249 | // Upgrades |
| 251 | 250 | add_submenu_page( |
| 252 | 251 | 'edit.php?post_type=give_forms', |
| 253 | - esc_html__( 'Give Updates Complete', 'give' ), |
|
| 254 | - __( 'Updates', 'give' ), |
|
| 252 | + esc_html__('Give Updates Complete', 'give'), |
|
| 253 | + __('Updates', 'give'), |
|
| 255 | 254 | 'manage_give_settings', |
| 256 | 255 | 'give-updates', |
| 257 | - array( $this, 'render_complete_page' ) |
|
| 256 | + array($this, 'render_complete_page') |
|
| 258 | 257 | ); |
| 259 | 258 | } |
| 260 | 259 | |
| 261 | 260 | return; |
| 262 | 261 | } |
| 263 | 262 | |
| 264 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
| 263 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
| 265 | 264 | |
| 266 | 265 | // Upgrades |
| 267 | 266 | add_submenu_page( |
| 268 | 267 | 'edit.php?post_type=give_forms', |
| 269 | - esc_html__( 'Give Updates', 'give' ), |
|
| 268 | + esc_html__('Give Updates', 'give'), |
|
| 270 | 269 | sprintf( |
| 271 | 270 | '%1$s <span class="update-plugins"%2$s><span class="plugin-count give-update-progress-count">%3$s%4$s</span></span>', |
| 272 | - __( 'Updates', 'give' ), |
|
| 273 | - isset( $_GET['give-pause-db-upgrades'] ) ? ' style="display:none;"' : '', |
|
| 271 | + __('Updates', 'give'), |
|
| 272 | + isset($_GET['give-pause-db-upgrades']) ? ' style="display:none;"' : '', |
|
| 274 | 273 | $is_update ? |
| 275 | - $this->get_db_update_processing_percentage() : |
|
| 276 | - $this->get_total_update_count(), |
|
| 274 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
| 277 | 275 | $is_update ? '%' : '' |
| 278 | 276 | ), |
| 279 | 277 | 'manage_give_settings', |
| 280 | 278 | 'give-updates', |
| 281 | - array( $this, 'render_page' ) |
|
| 279 | + array($this, 'render_page') |
|
| 282 | 280 | ); |
| 283 | 281 | } |
| 284 | 282 | |
@@ -293,13 +291,13 @@ discard block |
||
| 293 | 291 | // Show db upgrade completed notice. |
| 294 | 292 | if ( |
| 295 | 293 | ! wp_doing_ajax() && |
| 296 | - current_user_can( 'manage_give_settings' ) && |
|
| 297 | - get_option( 'give_show_db_upgrade_complete_notice' ) && |
|
| 298 | - ! isset( $_GET['give-db-update-completed'] ) |
|
| 294 | + current_user_can('manage_give_settings') && |
|
| 295 | + get_option('give_show_db_upgrade_complete_notice') && |
|
| 296 | + ! isset($_GET['give-db-update-completed']) |
|
| 299 | 297 | ) { |
| 300 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
| 298 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
| 301 | 299 | |
| 302 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-updates&give-db-update-completed=give_db_upgrade_completed' ) ); |
|
| 300 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-updates&give-db-update-completed=give_db_upgrade_completed')); |
|
| 303 | 301 | exit(); |
| 304 | 302 | } |
| 305 | 303 | } |
@@ -315,15 +313,15 @@ discard block |
||
| 315 | 313 | * |
| 316 | 314 | * @return bool |
| 317 | 315 | */ |
| 318 | - public function __pause_db_update( $force = false ) { |
|
| 316 | + public function __pause_db_update($force = false) { |
|
| 319 | 317 | // Bailout. |
| 320 | 318 | if ( |
| 321 | 319 | ! $force && |
| 322 | 320 | ( |
| 323 | 321 | wp_doing_ajax() || |
| 324 | - ! isset( $_GET['page'] ) || |
|
| 322 | + ! isset($_GET['page']) || |
|
| 325 | 323 | 'give-updates' !== $_GET['page'] || |
| 326 | - ! isset( $_GET['give-pause-db-upgrades'] ) || |
|
| 324 | + ! isset($_GET['give-pause-db-upgrades']) || |
|
| 327 | 325 | self::$background_updater->is_paused_process() |
| 328 | 326 | ) |
| 329 | 327 | |
@@ -331,13 +329,13 @@ discard block |
||
| 331 | 329 | return false; |
| 332 | 330 | } |
| 333 | 331 | |
| 334 | - delete_option( 'give_upgrade_error' ); |
|
| 332 | + delete_option('give_upgrade_error'); |
|
| 335 | 333 | |
| 336 | - $this->__health_background_update( $this ); |
|
| 334 | + $this->__health_background_update($this); |
|
| 337 | 335 | $batch = self::$background_updater->get_all_batch(); |
| 338 | 336 | |
| 339 | 337 | // Bailout: if batch is empty |
| 340 | - if ( empty( $batch->data ) ) { |
|
| 338 | + if (empty($batch->data)) { |
|
| 341 | 339 | return false; |
| 342 | 340 | } |
| 343 | 341 | |
@@ -346,25 +344,25 @@ discard block |
||
| 346 | 344 | |
| 347 | 345 | // Do not stop background process immediately if task running. |
| 348 | 346 | // @see Give_Background_Updater::lock_process |
| 349 | - if ( ! $force && self::$background_updater->is_process_running() ) { |
|
| 350 | - update_option( 'give_pause_upgrade', 1 ); |
|
| 347 | + if ( ! $force && self::$background_updater->is_process_running()) { |
|
| 348 | + update_option('give_pause_upgrade', 1); |
|
| 351 | 349 | |
| 352 | 350 | return true; |
| 353 | 351 | } |
| 354 | 352 | |
| 355 | - update_option( 'give_paused_batches', $batch, 'no' ); |
|
| 356 | - delete_option( $batch->key ); |
|
| 357 | - delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' ); |
|
| 358 | - wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() ); |
|
| 353 | + update_option('give_paused_batches', $batch, 'no'); |
|
| 354 | + delete_option($batch->key); |
|
| 355 | + delete_site_transient(self::$background_updater->get_identifier().'_process_lock'); |
|
| 356 | + wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier()); |
|
| 359 | 357 | |
| 360 | - Give()->logs->add( 'Update Pause', print_r( $batch, true ), 0, 'update' ); |
|
| 358 | + Give()->logs->add('Update Pause', print_r($batch, true), 0, 'update'); |
|
| 361 | 359 | |
| 362 | 360 | /** |
| 363 | 361 | * Fire action when pause db updates |
| 364 | 362 | * |
| 365 | 363 | * @since 2.0.1 |
| 366 | 364 | */ |
| 367 | - do_action( 'give_pause_db_upgrade', $this ); |
|
| 365 | + do_action('give_pause_db_upgrade', $this); |
|
| 368 | 366 | |
| 369 | 367 | return true; |
| 370 | 368 | } |
@@ -381,31 +379,31 @@ discard block |
||
| 381 | 379 | // Bailout. |
| 382 | 380 | if ( |
| 383 | 381 | wp_doing_ajax() || |
| 384 | - ! isset( $_GET['page'] ) || |
|
| 382 | + ! isset($_GET['page']) || |
|
| 385 | 383 | 'give-updates' !== $_GET['page'] || |
| 386 | - ! isset( $_GET['give-restart-db-upgrades'] ) || |
|
| 384 | + ! isset($_GET['give-restart-db-upgrades']) || |
|
| 387 | 385 | ! self::$background_updater->is_paused_process() |
| 388 | 386 | ) { |
| 389 | 387 | return false; |
| 390 | 388 | } |
| 391 | 389 | |
| 392 | 390 | Give_Background_Updater::flush_cache(); |
| 393 | - $batch = get_option( 'give_paused_batches' ); |
|
| 391 | + $batch = get_option('give_paused_batches'); |
|
| 394 | 392 | |
| 395 | - if ( ! empty( $batch ) ) { |
|
| 396 | - wp_cache_delete( $batch->key, 'options' ); |
|
| 397 | - update_option( $batch->key, $batch->data ); |
|
| 393 | + if ( ! empty($batch)) { |
|
| 394 | + wp_cache_delete($batch->key, 'options'); |
|
| 395 | + update_option($batch->key, $batch->data); |
|
| 398 | 396 | |
| 399 | - delete_option( 'give_paused_batches' ); |
|
| 397 | + delete_option('give_paused_batches'); |
|
| 400 | 398 | |
| 401 | - Give()->logs->add( 'Update Restart', print_r( $batch, true ), 0, 'update' ); |
|
| 399 | + Give()->logs->add('Update Restart', print_r($batch, true), 0, 'update'); |
|
| 402 | 400 | |
| 403 | 401 | |
| 404 | 402 | /** Fire action when restart db updates |
| 405 | 403 | * |
| 406 | 404 | * @since 2.0.1 |
| 407 | 405 | */ |
| 408 | - do_action( 'give_restart_db_upgrade', $this ); |
|
| 406 | + do_action('give_restart_db_upgrade', $this); |
|
| 409 | 407 | |
| 410 | 408 | self::$background_updater->dispatch(); |
| 411 | 409 | } |
@@ -421,53 +419,53 @@ discard block |
||
| 421 | 419 | * |
| 422 | 420 | * @param Give_Updates $give_updates |
| 423 | 421 | */ |
| 424 | - public function __health_background_update( $give_updates ) { |
|
| 425 | - if ( ! $this->is_doing_updates() ) { |
|
| 422 | + public function __health_background_update($give_updates) { |
|
| 423 | + if ( ! $this->is_doing_updates()) { |
|
| 426 | 424 | return; |
| 427 | 425 | } |
| 428 | 426 | |
| 429 | 427 | Give_Background_Updater::flush_cache(); |
| 430 | 428 | |
| 431 | 429 | $batch = Give_Updates::$background_updater->get_all_batch(); |
| 432 | - $batch_data_count = count( $batch->data ); |
|
| 433 | - $all_updates = $give_updates->get_updates( 'database', 'all' ); |
|
| 434 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
| 435 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
| 430 | + $batch_data_count = count($batch->data); |
|
| 431 | + $all_updates = $give_updates->get_updates('database', 'all'); |
|
| 432 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
| 433 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
| 436 | 434 | $log_data = ''; |
| 437 | - $doing_upgrade_args = get_option( 'give_doing_upgrade' ); |
|
| 435 | + $doing_upgrade_args = get_option('give_doing_upgrade'); |
|
| 438 | 436 | |
| 439 | - if ( ! empty( $doing_upgrade_args ) ) { |
|
| 440 | - $log_data .= 'Doing update:' . "\n"; |
|
| 441 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
| 437 | + if ( ! empty($doing_upgrade_args)) { |
|
| 438 | + $log_data .= 'Doing update:'."\n"; |
|
| 439 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
| 442 | 440 | } |
| 443 | 441 | |
| 444 | 442 | /** |
| 445 | 443 | * Add remove upgrade from batch |
| 446 | 444 | */ |
| 447 | - if ( ! empty( $batch->data ) ) { |
|
| 445 | + if ( ! empty($batch->data)) { |
|
| 448 | 446 | |
| 449 | - foreach ( $batch->data as $index => $update ) { |
|
| 450 | - $log_data = print_r( $update, true ) . "\n"; |
|
| 447 | + foreach ($batch->data as $index => $update) { |
|
| 448 | + $log_data = print_r($update, true)."\n"; |
|
| 451 | 449 | |
| 452 | - if ( ! is_callable( $update['callback'] ) ) { |
|
| 453 | - $log_data .= 'Removing missing callback update: ' . "{$update['id']}\n"; |
|
| 454 | - unset( $batch->data[ $index ] ); |
|
| 455 | - } elseif ( give_has_upgrade_completed( $update['id'] ) ) { |
|
| 456 | - $log_data .= 'Removing already completed update: ' . "{$update['id']}\n"; |
|
| 457 | - unset( $batch->data[ $index ] ); |
|
| 450 | + if ( ! is_callable($update['callback'])) { |
|
| 451 | + $log_data .= 'Removing missing callback update: '."{$update['id']}\n"; |
|
| 452 | + unset($batch->data[$index]); |
|
| 453 | + } elseif (give_has_upgrade_completed($update['id'])) { |
|
| 454 | + $log_data .= 'Removing already completed update: '."{$update['id']}\n"; |
|
| 455 | + unset($batch->data[$index]); |
|
| 458 | 456 | } |
| 459 | 457 | |
| 460 | - if ( ! empty( $update['depend'] ) ) { |
|
| 458 | + if ( ! empty($update['depend'])) { |
|
| 461 | 459 | |
| 462 | - foreach ( $update['depend'] as $depend ) { |
|
| 463 | - if ( give_has_upgrade_completed( $depend ) ) { |
|
| 464 | - $log_data .= 'Completed update: ' . "{$depend}\n"; |
|
| 460 | + foreach ($update['depend'] as $depend) { |
|
| 461 | + if (give_has_upgrade_completed($depend)) { |
|
| 462 | + $log_data .= 'Completed update: '."{$depend}\n"; |
|
| 465 | 463 | continue; |
| 466 | 464 | } |
| 467 | 465 | |
| 468 | - if ( in_array( $depend, $all_update_ids ) && ! in_array( $depend, $all_batch_update_ids ) ) { |
|
| 469 | - $log_data .= 'Adding missing update: ' . "{$depend}\n"; |
|
| 470 | - array_unshift( $batch->data, $all_updates[ array_search( $depend, $all_update_ids ) ] ); |
|
| 466 | + if (in_array($depend, $all_update_ids) && ! in_array($depend, $all_batch_update_ids)) { |
|
| 467 | + $log_data .= 'Adding missing update: '."{$depend}\n"; |
|
| 468 | + array_unshift($batch->data, $all_updates[array_search($depend, $all_update_ids)]); |
|
| 471 | 469 | } |
| 472 | 470 | } |
| 473 | 471 | } |
@@ -477,52 +475,52 @@ discard block |
||
| 477 | 475 | /** |
| 478 | 476 | * Add new upgrade to batch |
| 479 | 477 | */ |
| 480 | - if ( $new_updates = $this->get_updates( 'database', 'new' ) ) { |
|
| 481 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
| 478 | + if ($new_updates = $this->get_updates('database', 'new')) { |
|
| 479 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
| 482 | 480 | |
| 483 | - foreach ( $new_updates as $index => $new_update ) { |
|
| 484 | - if ( give_has_upgrade_completed( $new_update['id'] ) || in_array( $new_update['id'], $all_batch_update_ids ) ) { |
|
| 485 | - unset( $new_updates[ $index ] ); |
|
| 481 | + foreach ($new_updates as $index => $new_update) { |
|
| 482 | + if (give_has_upgrade_completed($new_update['id']) || in_array($new_update['id'], $all_batch_update_ids)) { |
|
| 483 | + unset($new_updates[$index]); |
|
| 486 | 484 | } |
| 487 | 485 | } |
| 488 | 486 | |
| 489 | - if ( ! empty( $new_updates ) ) { |
|
| 490 | - $log_data .= 'Adding new update: ' . "\n"; |
|
| 491 | - $log_data .= print_r( $new_updates, true ) . "\n"; |
|
| 487 | + if ( ! empty($new_updates)) { |
|
| 488 | + $log_data .= 'Adding new update: '."\n"; |
|
| 489 | + $log_data .= print_r($new_updates, true)."\n"; |
|
| 492 | 490 | |
| 493 | - $batch->data = array_merge( (array) $batch->data, $new_updates ); |
|
| 494 | - update_option( 'give_db_update_count', ( absint( get_option( 'give_db_update_count' ) ) + count( $new_updates ) ) ); |
|
| 491 | + $batch->data = array_merge((array) $batch->data, $new_updates); |
|
| 492 | + update_option('give_db_update_count', (absint(get_option('give_db_update_count')) + count($new_updates))); |
|
| 495 | 493 | } |
| 496 | 494 | } |
| 497 | 495 | |
| 498 | 496 | /** |
| 499 | 497 | * Fix batch |
| 500 | 498 | */ |
| 501 | - if ( empty( $batch->data ) ) { |
|
| 499 | + if (empty($batch->data)) { |
|
| 502 | 500 | // Complete batch if do not have any data to process. |
| 503 | - self::$background_updater->delete( $batch->key ); |
|
| 501 | + self::$background_updater->delete($batch->key); |
|
| 504 | 502 | |
| 505 | - if ( self::$background_updater->has_queue() ) { |
|
| 506 | - $this->__health_background_update( $this ); |
|
| 503 | + if (self::$background_updater->has_queue()) { |
|
| 504 | + $this->__health_background_update($this); |
|
| 507 | 505 | } else { |
| 508 | - delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' ); |
|
| 509 | - wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() ); |
|
| 506 | + delete_site_transient(self::$background_updater->get_identifier().'_process_lock'); |
|
| 507 | + wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier()); |
|
| 510 | 508 | |
| 511 | 509 | self::$background_updater->complete(); |
| 512 | 510 | } |
| 513 | 511 | |
| 514 | - } elseif ( $batch_data_count !== count( $batch->data ) ) { |
|
| 512 | + } elseif ($batch_data_count !== count($batch->data)) { |
|
| 515 | 513 | |
| 516 | - $log_data .= 'Updating batch' . "\n"; |
|
| 517 | - $log_data .= print_r( $batch, true ); |
|
| 514 | + $log_data .= 'Updating batch'."\n"; |
|
| 515 | + $log_data .= print_r($batch, true); |
|
| 518 | 516 | |
| 519 | - if ( ! empty( $batch->key ) ) { |
|
| 520 | - wp_cache_delete( $batch->key, 'options' ); |
|
| 521 | - update_option( $batch->key, $batch->data ); |
|
| 517 | + if ( ! empty($batch->key)) { |
|
| 518 | + wp_cache_delete($batch->key, 'options'); |
|
| 519 | + update_option($batch->key, $batch->data); |
|
| 522 | 520 | } else { |
| 523 | 521 | |
| 524 | - foreach ( $batch->data as $data ) { |
|
| 525 | - Give_Updates::$background_updater->push_to_queue( $data ); |
|
| 522 | + foreach ($batch->data as $data) { |
|
| 523 | + Give_Updates::$background_updater->push_to_queue($data); |
|
| 526 | 524 | } |
| 527 | 525 | |
| 528 | 526 | Give_Updates::$background_updater->save(); |
@@ -533,31 +531,31 @@ discard block |
||
| 533 | 531 | /** |
| 534 | 532 | * Fix give_doing_upgrade option |
| 535 | 533 | */ |
| 536 | - if( $fresh_new_db_count = $this->get_total_new_db_update_count( true ) ) { |
|
| 537 | - update_option( 'give_db_update_count', $fresh_new_db_count ); |
|
| 534 | + if ($fresh_new_db_count = $this->get_total_new_db_update_count(true)) { |
|
| 535 | + update_option('give_db_update_count', $fresh_new_db_count); |
|
| 538 | 536 | } |
| 539 | 537 | |
| 540 | 538 | $doing_upgrade_args['update'] = 1; |
| 541 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, $fresh_new_db_count ); |
|
| 542 | - $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage( true ); |
|
| 539 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', 1, $fresh_new_db_count); |
|
| 540 | + $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage(true); |
|
| 543 | 541 | |
| 544 | 542 | // Remove already completed update from info. |
| 545 | 543 | if ( |
| 546 | - empty( $doing_upgrade_args['update_info'] ) |
|
| 547 | - || give_has_upgrade_completed( $doing_upgrade_args['update_info']['id'] ) |
|
| 544 | + empty($doing_upgrade_args['update_info']) |
|
| 545 | + || give_has_upgrade_completed($doing_upgrade_args['update_info']['id']) |
|
| 548 | 546 | ) { |
| 549 | - $doing_upgrade_args['update_info'] = current( array_values( $batch->data ) ); |
|
| 547 | + $doing_upgrade_args['update_info'] = current(array_values($batch->data)); |
|
| 550 | 548 | $doing_upgrade_args['step'] = 1; |
| 551 | 549 | } |
| 552 | 550 | |
| 553 | 551 | // Check if dependency completed or not. |
| 554 | - if ( isset( $doing_upgrade_args['update_info']['depend'] ) ) { |
|
| 555 | - foreach ( $doing_upgrade_args['update_info']['depend'] as $depend ) { |
|
| 556 | - if ( give_has_upgrade_completed( $depend ) ) { |
|
| 552 | + if (isset($doing_upgrade_args['update_info']['depend'])) { |
|
| 553 | + foreach ($doing_upgrade_args['update_info']['depend'] as $depend) { |
|
| 554 | + if (give_has_upgrade_completed($depend)) { |
|
| 557 | 555 | continue; |
| 558 | 556 | } |
| 559 | 557 | |
| 560 | - $doing_upgrade_args['update_info'] = $all_updates[ array_search( $depend, $all_update_ids ) ]; |
|
| 558 | + $doing_upgrade_args['update_info'] = $all_updates[array_search($depend, $all_update_ids)]; |
|
| 561 | 559 | $doing_upgrade_args['step'] = 1; |
| 562 | 560 | $doing_upgrade_args['percentage'] = 0; |
| 563 | 561 | $doing_upgrade_args['total_percentage'] = 0; |
@@ -566,14 +564,14 @@ discard block |
||
| 566 | 564 | } |
| 567 | 565 | } |
| 568 | 566 | |
| 569 | - if( ! empty( $doing_upgrade_args['update_info'] ) ) { |
|
| 570 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
| 567 | + if ( ! empty($doing_upgrade_args['update_info'])) { |
|
| 568 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
| 571 | 569 | |
| 572 | - $log_data .= 'Updated doing update:' . "\n"; |
|
| 573 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
| 570 | + $log_data .= 'Updated doing update:'."\n"; |
|
| 571 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
| 574 | 572 | } |
| 575 | 573 | |
| 576 | - Give()->logs->add( 'Update Health Check', $log_data, 0, 'update' ); |
|
| 574 | + Give()->logs->add('Update Health Check', $log_data, 0, 'update'); |
|
| 577 | 575 | } |
| 578 | 576 | |
| 579 | 577 | |
@@ -587,33 +585,33 @@ discard block |
||
| 587 | 585 | $current_screen = get_current_screen(); |
| 588 | 586 | |
| 589 | 587 | // Bailout. |
| 590 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 588 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 591 | 589 | return; |
| 592 | 590 | } |
| 593 | 591 | |
| 594 | 592 | // Run DB updates. |
| 595 | - if ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
| 593 | + if ( ! empty($_GET['give-run-db-update'])) { |
|
| 596 | 594 | $this->run_db_update(); |
| 597 | 595 | } |
| 598 | 596 | |
| 599 | 597 | |
| 600 | 598 | // Bailout. |
| 601 | - if ( in_array( $current_screen->base, array( 'give_forms_page_give-updates', 'update-core' ) ) ) { |
|
| 599 | + if (in_array($current_screen->base, array('give_forms_page_give-updates', 'update-core'))) { |
|
| 602 | 600 | return; |
| 603 | 601 | } |
| 604 | 602 | |
| 605 | 603 | |
| 606 | 604 | // Show notice if ajax is not working. |
| 607 | - if ( ! give_test_ajax_works() ) { |
|
| 605 | + if ( ! give_test_ajax_works()) { |
|
| 608 | 606 | Give()->notices->register_notice( |
| 609 | 607 | array( |
| 610 | 608 | 'id' => 'give_db_upgrade_ajax_inaccessible', |
| 611 | 609 | 'type' => 'error', |
| 612 | 610 | 'description' => sprintf( |
| 613 | 611 | '%1$s <a href="%2$s" target="_blank">%3$s</a>', |
| 614 | - __( 'Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give' ), |
|
| 615 | - esc_url( 'http://docs.givewp.com/troubleshooting-db-updates' ), |
|
| 616 | - __( 'Read More', 'give' ) . ' »' |
|
| 612 | + __('Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give'), |
|
| 613 | + esc_url('http://docs.givewp.com/troubleshooting-db-updates'), |
|
| 614 | + __('Read More', 'give').' »' |
|
| 617 | 615 | ), |
| 618 | 616 | 'show' => true, |
| 619 | 617 | ) |
@@ -623,74 +621,74 @@ discard block |
||
| 623 | 621 | } |
| 624 | 622 | |
| 625 | 623 | // Show notice if upgrade paused. |
| 626 | - if ( self::$background_updater->is_paused_process() ) { |
|
| 624 | + if (self::$background_updater->is_paused_process()) { |
|
| 627 | 625 | ob_start(); |
| 628 | 626 | |
| 629 | - $upgrade_error = get_option( 'give_upgrade_error' ); |
|
| 630 | - if ( ! $upgrade_error ) : ?> |
|
| 631 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
| 632 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give' ); ?> |
|
| 627 | + $upgrade_error = get_option('give_upgrade_error'); |
|
| 628 | + if ( ! $upgrade_error) : ?> |
|
| 629 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
| 630 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give'); ?> |
|
| 633 | 631 | <br> |
| 634 | 632 | <br> |
| 635 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-restart-db-upgrades' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-restart-updater-btn"> |
|
| 636 | - <?php _e( 'Restart the updater', 'give' ); ?> |
|
| 633 | + <a href="<?php echo esc_url(add_query_arg(array('give-restart-db-upgrades' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-restart-updater-btn"> |
|
| 634 | + <?php _e('Restart the updater', 'give'); ?> |
|
| 637 | 635 | </a> |
| 638 | 636 | <?php else: ?> |
| 639 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
| 640 | - – <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
|
| 641 | - <a href="<?php echo esc_url('http://docs.givewp.com/troubleshooting-db-updates')?>" target="_blank"><?php _e( 'Read More', 'give' ); ?> »</a> |
|
| 637 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
| 638 | + – <?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?> |
|
| 639 | + <a href="<?php echo esc_url('http://docs.givewp.com/troubleshooting-db-updates')?>" target="_blank"><?php _e('Read More', 'give'); ?> »</a> |
|
| 642 | 640 | <?php |
| 643 | 641 | endif; |
| 644 | 642 | $desc_html = ob_get_clean(); |
| 645 | 643 | |
| 646 | - Give()->notices->register_notice( array( |
|
| 644 | + Give()->notices->register_notice(array( |
|
| 647 | 645 | 'id' => 'give_upgrade_db', |
| 648 | 646 | 'type' => 'error', |
| 649 | 647 | 'dismissible' => false, |
| 650 | 648 | 'description' => $desc_html, |
| 651 | - ) ); |
|
| 649 | + )); |
|
| 652 | 650 | } |
| 653 | 651 | |
| 654 | 652 | // Bailout if doing upgrades. |
| 655 | - if ( $this->is_doing_updates() ) { |
|
| 653 | + if ($this->is_doing_updates()) { |
|
| 656 | 654 | return; |
| 657 | 655 | } |
| 658 | 656 | |
| 659 | 657 | // Show db upgrade completed notice. |
| 660 | - if ( ! empty( $_GET['give-db-update-completed'] ) ) { |
|
| 661 | - Give()->notices->register_notice( array( |
|
| 658 | + if ( ! empty($_GET['give-db-update-completed'])) { |
|
| 659 | + Give()->notices->register_notice(array( |
|
| 662 | 660 | 'id' => 'give_db_upgrade_completed', |
| 663 | 661 | 'type' => 'updated', |
| 664 | - 'description' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
| 662 | + 'description' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
| 665 | 663 | 'show' => true, |
| 666 | - ) ); |
|
| 664 | + )); |
|
| 667 | 665 | |
| 668 | 666 | // Start update. |
| 669 | - } elseif ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
| 667 | + } elseif ( ! empty($_GET['give-run-db-update'])) { |
|
| 670 | 668 | $this->run_db_update(); |
| 671 | 669 | |
| 672 | 670 | // Show run the update notice. |
| 673 | - } elseif ( $this->get_total_new_db_update_count() ) { |
|
| 671 | + } elseif ($this->get_total_new_db_update_count()) { |
|
| 674 | 672 | ob_start(); |
| 675 | 673 | ?> |
| 676 | 674 | <p> |
| 677 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
| 678 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give' ); ?> |
|
| 675 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
| 676 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give'); ?> |
|
| 679 | 677 | </p> |
| 680 | 678 | <p class="submit"> |
| 681 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-run-db-update' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-run-update-now"> |
|
| 682 | - <?php _e( 'Run the updater', 'give' ); ?> |
|
| 679 | + <a href="<?php echo esc_url(add_query_arg(array('give-run-db-update' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-run-update-now"> |
|
| 680 | + <?php _e('Run the updater', 'give'); ?> |
|
| 683 | 681 | </a> |
| 684 | 682 | </p> |
| 685 | 683 | <?php |
| 686 | 684 | $desc_html = ob_get_clean(); |
| 687 | 685 | |
| 688 | - Give()->notices->register_notice( array( |
|
| 686 | + Give()->notices->register_notice(array( |
|
| 689 | 687 | 'id' => 'give_upgrade_db', |
| 690 | 688 | 'type' => 'updated', |
| 691 | 689 | 'dismissible' => false, |
| 692 | 690 | 'description' => $desc_html, |
| 693 | - ) ); |
|
| 691 | + )); |
|
| 694 | 692 | } |
| 695 | 693 | } |
| 696 | 694 | |
@@ -701,7 +699,7 @@ discard block |
||
| 701 | 699 | * @access public |
| 702 | 700 | */ |
| 703 | 701 | public function render_complete_page() { |
| 704 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php'; |
|
| 702 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php'; |
|
| 705 | 703 | } |
| 706 | 704 | |
| 707 | 705 | /** |
@@ -711,7 +709,7 @@ discard block |
||
| 711 | 709 | * @access public |
| 712 | 710 | */ |
| 713 | 711 | public function render_page() { |
| 714 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php'; |
|
| 712 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php'; |
|
| 715 | 713 | } |
| 716 | 714 | |
| 717 | 715 | /** |
@@ -722,26 +720,26 @@ discard block |
||
| 722 | 720 | */ |
| 723 | 721 | private function run_db_update() { |
| 724 | 722 | // Bailout. |
| 725 | - if ( $this->is_doing_updates() || ! $this->get_total_new_db_update_count() ) { |
|
| 723 | + if ($this->is_doing_updates() || ! $this->get_total_new_db_update_count()) { |
|
| 726 | 724 | return; |
| 727 | 725 | } |
| 728 | 726 | |
| 729 | - $updates = $this->get_updates( 'database', 'new' ); |
|
| 727 | + $updates = $this->get_updates('database', 'new'); |
|
| 730 | 728 | |
| 731 | - foreach ( $updates as $update ) { |
|
| 732 | - self::$background_updater->push_to_queue( $update ); |
|
| 729 | + foreach ($updates as $update) { |
|
| 730 | + self::$background_updater->push_to_queue($update); |
|
| 733 | 731 | } |
| 734 | 732 | |
| 735 | - add_option( 'give_db_update_count', count( $updates ), '', 'no' ); |
|
| 733 | + add_option('give_db_update_count', count($updates), '', 'no'); |
|
| 736 | 734 | |
| 737 | - add_option( 'give_doing_upgrade', array( |
|
| 735 | + add_option('give_doing_upgrade', array( |
|
| 738 | 736 | 'update_info' => $updates[0], |
| 739 | 737 | 'step' => 1, |
| 740 | 738 | 'update' => 1, |
| 741 | - 'heading' => sprintf( 'Update %s of %s', 1, count( $updates ) ), |
|
| 739 | + 'heading' => sprintf('Update %s of %s', 1, count($updates)), |
|
| 742 | 740 | 'percentage' => 0, |
| 743 | 741 | 'total_percentage' => 0, |
| 744 | - ), '', 'no' ); |
|
| 742 | + ), '', 'no'); |
|
| 745 | 743 | |
| 746 | 744 | self::$background_updater->save()->dispatch(); |
| 747 | 745 | } |
@@ -755,14 +753,13 @@ discard block |
||
| 755 | 753 | */ |
| 756 | 754 | public function __flush_resume_updates() { |
| 757 | 755 | //delete_option( 'give_doing_upgrade' ); |
| 758 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
| 756 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
| 759 | 757 | |
| 760 | 758 | // Reset counter. |
| 761 | 759 | $this->step = $this->percentage = 0; |
| 762 | 760 | |
| 763 | - $this->update = ( $this->get_total_db_update_count() > $this->update ) ? |
|
| 764 | - ( $this->update + 1 ) : |
|
| 765 | - $this->update; |
|
| 761 | + $this->update = ($this->get_total_db_update_count() > $this->update) ? |
|
| 762 | + ($this->update + 1) : $this->update; |
|
| 766 | 763 | } |
| 767 | 764 | |
| 768 | 765 | |
@@ -777,7 +774,7 @@ discard block |
||
| 777 | 774 | public function __give_start_updating() { |
| 778 | 775 | // Check permission. |
| 779 | 776 | if ( |
| 780 | - ! current_user_can( 'manage_give_settings' ) || |
|
| 777 | + ! current_user_can('manage_give_settings') || |
|
| 781 | 778 | $this->is_doing_updates() |
| 782 | 779 | ) { |
| 783 | 780 | wp_send_json_error(); |
@@ -785,7 +782,7 @@ discard block |
||
| 785 | 782 | |
| 786 | 783 | // @todo: validate nonce |
| 787 | 784 | // @todo: set http method to post |
| 788 | - if ( empty( $_POST['run_db_update'] ) ) { |
|
| 785 | + if (empty($_POST['run_db_update'])) { |
|
| 789 | 786 | wp_send_json_error(); |
| 790 | 787 | } |
| 791 | 788 | |
@@ -804,34 +801,34 @@ discard block |
||
| 804 | 801 | * @return string |
| 805 | 802 | */ |
| 806 | 803 | public function __give_db_updates_info() { |
| 807 | - $update_info = get_option( 'give_doing_upgrade' ); |
|
| 804 | + $update_info = get_option('give_doing_upgrade'); |
|
| 808 | 805 | $response_type = ''; |
| 809 | 806 | |
| 810 | - if ( self::$background_updater->is_paused_process() ) { |
|
| 807 | + if (self::$background_updater->is_paused_process()) { |
|
| 811 | 808 | $update_info = array( |
| 812 | - 'message' => __( 'The updates have been paused.', 'give' ), |
|
| 809 | + 'message' => __('The updates have been paused.', 'give'), |
|
| 813 | 810 | 'heading' => '', |
| 814 | 811 | 'percentage' => 0, |
| 815 | 812 | ); |
| 816 | 813 | |
| 817 | - if ( get_option( 'give_upgrade_error' ) ) { |
|
| 818 | - $update_info['message'] = __( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); |
|
| 814 | + if (get_option('give_upgrade_error')) { |
|
| 815 | + $update_info['message'] = __('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); |
|
| 819 | 816 | } |
| 820 | 817 | |
| 821 | 818 | $response_type = 'error'; |
| 822 | 819 | |
| 823 | - } elseif ( empty( $update_info ) || ! $this->get_total_new_db_update_count( true ) ) { |
|
| 820 | + } elseif (empty($update_info) || ! $this->get_total_new_db_update_count(true)) { |
|
| 824 | 821 | $update_info = array( |
| 825 | - 'message' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
| 826 | - 'heading' => __( 'Updates Completed.', 'give' ), |
|
| 822 | + 'message' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
| 823 | + 'heading' => __('Updates Completed.', 'give'), |
|
| 827 | 824 | 'percentage' => 0, |
| 828 | 825 | ); |
| 829 | 826 | $response_type = 'success'; |
| 830 | 827 | |
| 831 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
| 828 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
| 832 | 829 | } |
| 833 | 830 | |
| 834 | - $this->send_ajax_response( $update_info, $response_type ); |
|
| 831 | + $this->send_ajax_response($update_info, $response_type); |
|
| 835 | 832 | } |
| 836 | 833 | |
| 837 | 834 | /** |
@@ -843,7 +840,7 @@ discard block |
||
| 843 | 840 | * @param $data |
| 844 | 841 | * @param string $type |
| 845 | 842 | */ |
| 846 | - public function send_ajax_response( $data, $type = '' ) { |
|
| 843 | + public function send_ajax_response($data, $type = '') { |
|
| 847 | 844 | $default = array( |
| 848 | 845 | 'message' => '', |
| 849 | 846 | 'heading' => '', |
@@ -853,24 +850,24 @@ discard block |
||
| 853 | 850 | ); |
| 854 | 851 | |
| 855 | 852 | // Set data. |
| 856 | - $data = wp_parse_args( $data, $default ); |
|
| 853 | + $data = wp_parse_args($data, $default); |
|
| 857 | 854 | |
| 858 | 855 | // Enable cache. |
| 859 | 856 | Give_Cache::enable(); |
| 860 | 857 | |
| 861 | - switch ( $type ) { |
|
| 858 | + switch ($type) { |
|
| 862 | 859 | case 'success': |
| 863 | - wp_send_json_success( $data ); |
|
| 860 | + wp_send_json_success($data); |
|
| 864 | 861 | break; |
| 865 | 862 | |
| 866 | 863 | case 'error': |
| 867 | - wp_send_json_error( $data ); |
|
| 864 | + wp_send_json_error($data); |
|
| 868 | 865 | break; |
| 869 | 866 | |
| 870 | 867 | default: |
| 871 | - wp_send_json( array( |
|
| 868 | + wp_send_json(array( |
|
| 872 | 869 | 'data' => $data, |
| 873 | - ) ); |
|
| 870 | + )); |
|
| 874 | 871 | break; |
| 875 | 872 | } |
| 876 | 873 | } |
@@ -884,12 +881,12 @@ discard block |
||
| 884 | 881 | * @param $total |
| 885 | 882 | * @param $current_total |
| 886 | 883 | */ |
| 887 | - public function set_percentage( $total, $current_total ) { |
|
| 884 | + public function set_percentage($total, $current_total) { |
|
| 888 | 885 | // Set percentage. |
| 889 | - $this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0; |
|
| 886 | + $this->percentage = $total ? (($current_total) / $total) * 100 : 0; |
|
| 890 | 887 | |
| 891 | 888 | // Verify percentage. |
| 892 | - $this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage; |
|
| 889 | + $this->percentage = (100 < $this->percentage) ? 100 : $this->percentage; |
|
| 893 | 890 | } |
| 894 | 891 | |
| 895 | 892 | /** |
@@ -902,22 +899,22 @@ discard block |
||
| 902 | 899 | * |
| 903 | 900 | * @return bool|null |
| 904 | 901 | */ |
| 905 | - public function is_parent_updates_completed( $update ) { |
|
| 902 | + public function is_parent_updates_completed($update) { |
|
| 906 | 903 | // Bailout. |
| 907 | - if ( empty( $update['depend'] ) ) { |
|
| 904 | + if (empty($update['depend'])) { |
|
| 908 | 905 | return true; |
| 909 | 906 | } |
| 910 | 907 | |
| 911 | 908 | // Check if dependency is valid or not. |
| 912 | - if ( ! $this->has_valid_dependency( $update ) ) { |
|
| 909 | + if ( ! $this->has_valid_dependency($update)) { |
|
| 913 | 910 | return null; |
| 914 | 911 | } |
| 915 | 912 | |
| 916 | 913 | $is_dependency_completed = true; |
| 917 | 914 | |
| 918 | - foreach ( $update['depend'] as $depend ) { |
|
| 915 | + foreach ($update['depend'] as $depend) { |
|
| 919 | 916 | |
| 920 | - if ( ! give_has_upgrade_completed( $depend ) ) { |
|
| 917 | + if ( ! give_has_upgrade_completed($depend)) { |
|
| 921 | 918 | $is_dependency_completed = false; |
| 922 | 919 | break; |
| 923 | 920 | } |
@@ -934,7 +931,7 @@ discard block |
||
| 934 | 931 | * @return bool |
| 935 | 932 | */ |
| 936 | 933 | public function is_doing_updates() { |
| 937 | - return (bool) get_option( 'give_doing_upgrade' ); |
|
| 934 | + return (bool) get_option('give_doing_upgrade'); |
|
| 938 | 935 | } |
| 939 | 936 | |
| 940 | 937 | |
@@ -948,7 +945,7 @@ discard block |
||
| 948 | 945 | * |
| 949 | 946 | * @return bool |
| 950 | 947 | */ |
| 951 | - public function has_valid_dependency( $update ) { |
|
| 948 | + public function has_valid_dependency($update) { |
|
| 952 | 949 | $is_valid_dependency = true; |
| 953 | 950 | // $update_ids = wp_list_pluck( $this->get_updates( 'database', 'all' ), 'id' ); |
| 954 | 951 | // |
@@ -974,33 +971,33 @@ discard block |
||
| 974 | 971 | * |
| 975 | 972 | * @return array |
| 976 | 973 | */ |
| 977 | - public function get_updates( $update_type = '', $status = 'all' ) { |
|
| 974 | + public function get_updates($update_type = '', $status = 'all') { |
|
| 978 | 975 | // return all updates. |
| 979 | - if ( empty( $update_type ) ) { |
|
| 976 | + if (empty($update_type)) { |
|
| 980 | 977 | return $this->updates; |
| 981 | 978 | } |
| 982 | 979 | |
| 983 | 980 | // Get specific update. |
| 984 | - $updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array(); |
|
| 981 | + $updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array(); |
|
| 985 | 982 | |
| 986 | 983 | // Bailout. |
| 987 | - if ( empty( $updates ) ) { |
|
| 984 | + if (empty($updates)) { |
|
| 988 | 985 | return $updates; |
| 989 | 986 | } |
| 990 | 987 | |
| 991 | - switch ( $status ) { |
|
| 988 | + switch ($status) { |
|
| 992 | 989 | case 'new': |
| 993 | 990 | // Remove already completed updates. |
| 994 | - wp_cache_delete( 'give_completed_upgrades', 'options' ); |
|
| 991 | + wp_cache_delete('give_completed_upgrades', 'options'); |
|
| 995 | 992 | $completed_updates = give_get_completed_upgrades(); |
| 996 | 993 | |
| 997 | - if ( ! empty( $completed_updates ) ) { |
|
| 998 | - foreach ( $updates as $index => $update ) { |
|
| 999 | - if ( in_array( $update['id'], $completed_updates ) ) { |
|
| 1000 | - unset( $updates[ $index ] ); |
|
| 994 | + if ( ! empty($completed_updates)) { |
|
| 995 | + foreach ($updates as $index => $update) { |
|
| 996 | + if (in_array($update['id'], $completed_updates)) { |
|
| 997 | + unset($updates[$index]); |
|
| 1001 | 998 | } |
| 1002 | 999 | } |
| 1003 | - $updates = array_values( $updates ); |
|
| 1000 | + $updates = array_values($updates); |
|
| 1004 | 1001 | } |
| 1005 | 1002 | |
| 1006 | 1003 | break; |
@@ -1017,7 +1014,7 @@ discard block |
||
| 1017 | 1014 | * @return int |
| 1018 | 1015 | */ |
| 1019 | 1016 | public function get_total_plugin_update_count() { |
| 1020 | - return count( $this->get_updates( 'plugin' ) ); |
|
| 1017 | + return count($this->get_updates('plugin')); |
|
| 1021 | 1018 | } |
| 1022 | 1019 | |
| 1023 | 1020 | /** |
@@ -1032,7 +1029,7 @@ discard block |
||
| 1032 | 1029 | $db_update_count = $this->get_pending_db_update_count(); |
| 1033 | 1030 | $plugin_update_count = $this->get_total_plugin_update_count(); |
| 1034 | 1031 | |
| 1035 | - return ( $db_update_count + $plugin_update_count ); |
|
| 1032 | + return ($db_update_count + $plugin_update_count); |
|
| 1036 | 1033 | } |
| 1037 | 1034 | |
| 1038 | 1035 | /** |
@@ -1044,7 +1041,7 @@ discard block |
||
| 1044 | 1041 | * @return int |
| 1045 | 1042 | */ |
| 1046 | 1043 | public function get_pending_db_update_count() { |
| 1047 | - return count( $this->get_updates( 'database', 'new' ) ); |
|
| 1044 | + return count($this->get_updates('database', 'new')); |
|
| 1048 | 1045 | } |
| 1049 | 1046 | |
| 1050 | 1047 | /** |
@@ -1056,7 +1053,7 @@ discard block |
||
| 1056 | 1053 | * @return int |
| 1057 | 1054 | */ |
| 1058 | 1055 | public function get_total_db_update_count() { |
| 1059 | - return count( $this->get_updates( 'database', 'all' ) ); |
|
| 1056 | + return count($this->get_updates('database', 'all')); |
|
| 1060 | 1057 | } |
| 1061 | 1058 | |
| 1062 | 1059 | /** |
@@ -1069,10 +1066,9 @@ discard block |
||
| 1069 | 1066 | * |
| 1070 | 1067 | * @return int |
| 1071 | 1068 | */ |
| 1072 | - public function get_total_new_db_update_count( $refresh = false ) { |
|
| 1069 | + public function get_total_new_db_update_count($refresh = false) { |
|
| 1073 | 1070 | $update_count = $this->is_doing_updates() && ! $refresh ? |
| 1074 | - get_option( 'give_db_update_count' ) : |
|
| 1075 | - $this->get_pending_db_update_count(); |
|
| 1071 | + get_option('give_db_update_count') : $this->get_pending_db_update_count(); |
|
| 1076 | 1072 | |
| 1077 | 1073 | return $update_count; |
| 1078 | 1074 | } |
@@ -1087,11 +1083,11 @@ discard block |
||
| 1087 | 1083 | * |
| 1088 | 1084 | * @return int |
| 1089 | 1085 | */ |
| 1090 | - public function get_running_db_update( $refresh = false ) { |
|
| 1086 | + public function get_running_db_update($refresh = false) { |
|
| 1091 | 1087 | $current_update = 1; |
| 1092 | 1088 | |
| 1093 | - if ( $this->is_doing_updates() && ! $refresh ) { |
|
| 1094 | - $current_update = get_option( 'give_doing_upgrade' ); |
|
| 1089 | + if ($this->is_doing_updates() && ! $refresh) { |
|
| 1090 | + $current_update = get_option('give_doing_upgrade'); |
|
| 1095 | 1091 | $current_update = $current_update['update']; |
| 1096 | 1092 | } |
| 1097 | 1093 | |
@@ -1108,25 +1104,23 @@ discard block |
||
| 1108 | 1104 | * |
| 1109 | 1105 | * @return float|int |
| 1110 | 1106 | */ |
| 1111 | - public function get_db_update_processing_percentage( $refresh = false ) { |
|
| 1107 | + public function get_db_update_processing_percentage($refresh = false) { |
|
| 1112 | 1108 | // Bailout. |
| 1113 | - if ( ! $this->get_total_new_db_update_count( $refresh ) ) { |
|
| 1109 | + if ( ! $this->get_total_new_db_update_count($refresh)) { |
|
| 1114 | 1110 | return 0; |
| 1115 | 1111 | } |
| 1116 | 1112 | |
| 1117 | - $resume_update = get_option( 'give_doing_upgrade' ); |
|
| 1118 | - $update_count_percentages = ( ( $this->get_running_db_update( $refresh ) - 1 ) / $this->get_total_new_db_update_count( $refresh ) ) * 100; |
|
| 1119 | - $update_percentage_share = ( 1 / $this->get_total_new_db_update_count() ) * 100; |
|
| 1120 | - $upgrade_percentage = ( ( $resume_update['percentage'] * $update_percentage_share ) / 100 ); |
|
| 1113 | + $resume_update = get_option('give_doing_upgrade'); |
|
| 1114 | + $update_count_percentages = (($this->get_running_db_update($refresh) - 1) / $this->get_total_new_db_update_count($refresh)) * 100; |
|
| 1115 | + $update_percentage_share = (1 / $this->get_total_new_db_update_count()) * 100; |
|
| 1116 | + $upgrade_percentage = (($resume_update['percentage'] * $update_percentage_share) / 100); |
|
| 1121 | 1117 | |
| 1122 | 1118 | $final_percentage = $update_count_percentages + $upgrade_percentage; |
| 1123 | 1119 | |
| 1124 | 1120 | return $this->is_doing_updates() ? |
| 1125 | - ( absint( $final_percentage ) ? |
|
| 1126 | - absint( $final_percentage ) : |
|
| 1127 | - round( $final_percentage, 2 ) |
|
| 1128 | - ) : |
|
| 1129 | - 0; |
|
| 1121 | + (absint($final_percentage) ? |
|
| 1122 | + absint($final_percentage) : round($final_percentage, 2) |
|
| 1123 | + ) : 0; |
|
| 1130 | 1124 | } |
| 1131 | 1125 | |
| 1132 | 1126 | |
@@ -1138,8 +1132,8 @@ discard block |
||
| 1138 | 1132 | * @return array |
| 1139 | 1133 | */ |
| 1140 | 1134 | public function get_update_ids() { |
| 1141 | - $all_updates = $this->get_updates( 'database', 'all' ); |
|
| 1142 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
| 1135 | + $all_updates = $this->get_updates('database', 'all'); |
|
| 1136 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
| 1143 | 1137 | |
| 1144 | 1138 | return $all_update_ids; |
| 1145 | 1139 | } |
@@ -1154,10 +1148,9 @@ discard block |
||
| 1154 | 1148 | * |
| 1155 | 1149 | * @return float|int |
| 1156 | 1150 | */ |
| 1157 | - public function get_offset( $process_item_count ) { |
|
| 1158 | - return ( 1 === $this->step ) ? |
|
| 1159 | - 0 : |
|
| 1160 | - ( $this->step - 1 ) * $process_item_count; |
|
| 1151 | + public function get_offset($process_item_count) { |
|
| 1152 | + return (1 === $this->step) ? |
|
| 1153 | + 0 : ($this->step - 1) * $process_item_count; |
|
| 1161 | 1154 | } |
| 1162 | 1155 | } |
| 1163 | 1156 | |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | * @since 2.1.0 |
| 38 | 38 | */ |
| 39 | 39 | public function __construct() { |
| 40 | - $this->direction = ( is_rtl() || isset( $_GET['d'] ) && 'rtl' === $_GET['d'] ) ? '.rtl' : ''; |
|
| 41 | - $this->scripts_footer = give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ? true : false; |
|
| 40 | + $this->direction = (is_rtl() || isset($_GET['d']) && 'rtl' === $_GET['d']) ? '.rtl' : ''; |
|
| 41 | + $this->scripts_footer = give_is_setting_enabled(give_get_option('scripts_footer')) ? true : false; |
|
| 42 | 42 | $this->init(); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -49,20 +49,20 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function init() { |
| 51 | 51 | |
| 52 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_styles' ) ); |
|
| 53 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
| 54 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) ); |
|
| 55 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
| 52 | + add_action('admin_enqueue_scripts', array($this, 'register_styles')); |
|
| 53 | + add_action('admin_enqueue_scripts', array($this, 'register_scripts')); |
|
| 54 | + add_action('wp_enqueue_scripts', array($this, 'register_styles')); |
|
| 55 | + add_action('wp_enqueue_scripts', array($this, 'register_scripts')); |
|
| 56 | 56 | |
| 57 | - if ( is_admin() ) { |
|
| 58 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
|
| 59 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_styles' ) ); |
|
| 60 | - add_action( 'enqueue_block_editor_assets', array( $this, 'gutenberg_admin_scripts' ) ); |
|
| 61 | - add_action( 'admin_head', array( $this, 'global_admin_head' ) ); |
|
| 57 | + if (is_admin()) { |
|
| 58 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
| 59 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_styles')); |
|
| 60 | + add_action('enqueue_block_editor_assets', array($this, 'gutenberg_admin_scripts')); |
|
| 61 | + add_action('admin_head', array($this, 'global_admin_head')); |
|
| 62 | 62 | |
| 63 | 63 | } else { |
| 64 | - add_action( 'wp_enqueue_scripts', array( $this, 'public_enqueue_styles' ) ); |
|
| 65 | - add_action( 'wp_enqueue_scripts', array( $this, 'public_enqueue_scripts' ) ); |
|
| 64 | + add_action('wp_enqueue_scripts', array($this, 'public_enqueue_styles')); |
|
| 65 | + add_action('wp_enqueue_scripts', array($this, 'public_enqueue_scripts')); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | public function register_styles() { |
| 75 | 75 | |
| 76 | 76 | // WP-admin. |
| 77 | - wp_register_style( 'give-admin-styles', GIVE_PLUGIN_URL . 'assets/dist/css/admin' . $this->direction . '.css', array(), GIVE_VERSION ); |
|
| 77 | + wp_register_style('give-admin-styles', GIVE_PLUGIN_URL.'assets/dist/css/admin'.$this->direction.'.css', array(), GIVE_VERSION); |
|
| 78 | 78 | |
| 79 | 79 | // Frontend. |
| 80 | - if ( give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
| 81 | - wp_register_style( 'give-styles', $this->get_frontend_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
| 80 | + if (give_is_setting_enabled(give_get_option('css'))) { |
|
| 81 | + wp_register_style('give-styles', $this->get_frontend_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
@@ -90,15 +90,15 @@ discard block |
||
| 90 | 90 | public function register_scripts() { |
| 91 | 91 | |
| 92 | 92 | // WP-Admin. |
| 93 | - wp_register_script( 'give-admin-scripts', GIVE_PLUGIN_URL . 'assets/dist/js/admin.js', array( |
|
| 93 | + wp_register_script('give-admin-scripts', GIVE_PLUGIN_URL.'assets/dist/js/admin.js', array( |
|
| 94 | 94 | 'jquery', |
| 95 | 95 | 'jquery-ui-datepicker', |
| 96 | 96 | 'wp-color-picker', |
| 97 | 97 | 'jquery-query', |
| 98 | - ), GIVE_VERSION ); |
|
| 98 | + ), GIVE_VERSION); |
|
| 99 | 99 | |
| 100 | 100 | // Frontend. |
| 101 | - wp_register_script( 'give', GIVE_PLUGIN_URL . 'assets/dist/js/give.js', array( 'jquery' ), GIVE_VERSION, $this->scripts_footer ); |
|
| 101 | + wp_register_script('give', GIVE_PLUGIN_URL.'assets/dist/js/give.js', array('jquery'), GIVE_VERSION, $this->scripts_footer); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -108,20 +108,20 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param string $hook Page hook. |
| 110 | 110 | */ |
| 111 | - public function admin_enqueue_styles( $hook ) { |
|
| 111 | + public function admin_enqueue_styles($hook) { |
|
| 112 | 112 | |
| 113 | 113 | // Give Admin Only. |
| 114 | - if ( ! apply_filters( 'give_load_admin_styles', give_is_admin_page(), $hook ) ) { |
|
| 114 | + if ( ! apply_filters('give_load_admin_styles', give_is_admin_page(), $hook)) { |
|
| 115 | 115 | return; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Give enqueues. |
| 119 | - wp_enqueue_style( 'give-admin-styles' ); |
|
| 120 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
| 119 | + wp_enqueue_style('give-admin-styles'); |
|
| 120 | + wp_enqueue_style('give-admin-bar-notification'); |
|
| 121 | 121 | |
| 122 | 122 | // WP Core enqueues. |
| 123 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 124 | - wp_enqueue_style( 'thickbox' ); // @TODO remove once we have modal API. |
|
| 123 | + wp_enqueue_style('wp-color-picker'); |
|
| 124 | + wp_enqueue_style('thickbox'); // @TODO remove once we have modal API. |
|
| 125 | 125 | |
| 126 | 126 | } |
| 127 | 127 | |
@@ -132,21 +132,21 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @param string $hook Page hook. |
| 134 | 134 | */ |
| 135 | - public function admin_enqueue_scripts( $hook ) { |
|
| 135 | + public function admin_enqueue_scripts($hook) { |
|
| 136 | 136 | |
| 137 | 137 | // Give Admin Only. |
| 138 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
| 138 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
| 139 | 139 | return; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | // WP Scripts. |
| 143 | - wp_enqueue_script( 'wp-color-picker' ); |
|
| 144 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 145 | - wp_enqueue_script( 'thickbox' ); |
|
| 143 | + wp_enqueue_script('wp-color-picker'); |
|
| 144 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 145 | + wp_enqueue_script('thickbox'); |
|
| 146 | 146 | wp_enqueue_media(); |
| 147 | 147 | |
| 148 | 148 | // Give admin scripts. |
| 149 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
| 149 | + wp_enqueue_script('give-admin-scripts'); |
|
| 150 | 150 | |
| 151 | 151 | // Localize admin scripts |
| 152 | 152 | $this->admin_localize_scripts(); |
@@ -166,112 +166,112 @@ discard block |
||
| 166 | 166 | $decimal_separator = give_get_price_decimal_separator(); |
| 167 | 167 | |
| 168 | 168 | // Localize strings & variables for JS. |
| 169 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
| 170 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
| 169 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
| 170 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
| 171 | 171 | 'give_version' => GIVE_VERSION, |
| 172 | 172 | 'thousands_separator' => $thousand_separator, |
| 173 | 173 | 'decimal_separator' => $decimal_separator, |
| 174 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
| 175 | - 'delete_payment' => __( 'Are you sure you want to <strong>permanently</strong> delete this donation?', 'give' ), |
|
| 176 | - 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ), |
|
| 177 | - 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ), |
|
| 178 | - 'regenerate_api_key' => __( 'Are you sure you want to regenerate this API key?', 'give' ), |
|
| 179 | - 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ), |
|
| 180 | - 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ), |
|
| 181 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
| 182 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
| 183 | - 'currency_sign' => give_currency_filter( '' ), |
|
| 184 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
| 174 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
| 175 | + 'delete_payment' => __('Are you sure you want to <strong>permanently</strong> delete this donation?', 'give'), |
|
| 176 | + 'delete_payment_note' => __('Are you sure you want to delete this note?', 'give'), |
|
| 177 | + 'revoke_api_key' => __('Are you sure you want to revoke this API key?', 'give'), |
|
| 178 | + 'regenerate_api_key' => __('Are you sure you want to regenerate this API key?', 'give'), |
|
| 179 | + 'resend_receipt' => __('Are you sure you want to resend the donation receipt?', 'give'), |
|
| 180 | + 'disconnect_user' => __('Are you sure you want to disconnect the user from this donor?', 'give'), |
|
| 181 | + 'one_option' => __('Choose a form', 'give'), |
|
| 182 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
| 183 | + 'currency_sign' => give_currency_filter(''), |
|
| 184 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
| 185 | 185 | 'currency_decimals' => give_get_price_decimals(), |
| 186 | - 'ok' => __( 'Ok', 'give' ), |
|
| 187 | - 'cancel' => __( 'Cancel', 'give' ), |
|
| 188 | - 'close' => __( 'Close', 'give' ), |
|
| 189 | - 'confirm' => __( 'Confirm', 'give' ), |
|
| 190 | - 'confirm_action' => __( 'Confirm Action', 'give' ), |
|
| 191 | - 'confirm_deletion' => __( 'Confirm Deletion', 'give' ), |
|
| 192 | - 'confirm_delete_donation' => __( 'Confirm Delete Donation', 'give' ), |
|
| 193 | - 'confirm_resend' => __( 'Confirm re-send', 'give' ), |
|
| 194 | - 'confirm_bulk_action' => __( 'Confirm bulk action', 'give' ), |
|
| 195 | - 'restart_upgrade' => __( 'Do you want to restart the update process?', 'give' ), |
|
| 196 | - 'restart_update' => __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ), |
|
| 197 | - 'stop_upgrade' => __( 'Do you want to stop the update process now?', 'give' ), |
|
| 198 | - 'import_failed' => __( 'Import failed', 'give' ), |
|
| 199 | - 'flush_success' => __( 'Flush success', 'give' ), |
|
| 200 | - 'flush_error' => __( 'Flush error', 'give' ), |
|
| 201 | - 'no_form_selected' => __( 'No form selected', 'give' ), |
|
| 202 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
| 203 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
| 204 | - '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' ), |
|
| 205 | - 'delete_test_donor' => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ), |
|
| 206 | - 'delete_import_donor' => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ), |
|
| 207 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
| 186 | + 'ok' => __('Ok', 'give'), |
|
| 187 | + 'cancel' => __('Cancel', 'give'), |
|
| 188 | + 'close' => __('Close', 'give'), |
|
| 189 | + 'confirm' => __('Confirm', 'give'), |
|
| 190 | + 'confirm_action' => __('Confirm Action', 'give'), |
|
| 191 | + 'confirm_deletion' => __('Confirm Deletion', 'give'), |
|
| 192 | + 'confirm_delete_donation' => __('Confirm Delete Donation', 'give'), |
|
| 193 | + 'confirm_resend' => __('Confirm re-send', 'give'), |
|
| 194 | + 'confirm_bulk_action' => __('Confirm bulk action', 'give'), |
|
| 195 | + 'restart_upgrade' => __('Do you want to restart the update process?', 'give'), |
|
| 196 | + 'restart_update' => __('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give'), |
|
| 197 | + 'stop_upgrade' => __('Do you want to stop the update process now?', 'give'), |
|
| 198 | + 'import_failed' => __('Import failed', 'give'), |
|
| 199 | + 'flush_success' => __('Flush success', 'give'), |
|
| 200 | + 'flush_error' => __('Flush error', 'give'), |
|
| 201 | + 'no_form_selected' => __('No form selected', 'give'), |
|
| 202 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
| 203 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
| 204 | + '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'), |
|
| 205 | + 'delete_test_donor' => __('Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give'), |
|
| 206 | + 'delete_import_donor' => __('Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give'), |
|
| 207 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
| 208 | 208 | /* translators : %s: Donation form options metabox */ |
| 209 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this item?', 'give' ), |
|
| 210 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
| 211 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
| 212 | - 'search_placeholder' => __( 'Type to search all forms', 'give' ), |
|
| 213 | - 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ), |
|
| 214 | - 'search_placeholder_country' => __( 'Type to search all countries', 'give' ), |
|
| 215 | - 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ), |
|
| 216 | - 'unlock_donor_fields_title' => __( 'Action forbidden', 'give' ), |
|
| 217 | - 'unlock_donor_fields_message' => __( 'To edit first name and last name, please go to user profile of the donor.', 'give' ), |
|
| 218 | - 'remove_from_bulk_delete' => __( 'Remove from Bulk Delete', 'give' ), |
|
| 209 | + 'confirm_before_remove_row_text' => __('Do you want to delete this item?', 'give'), |
|
| 210 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
| 211 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
| 212 | + 'search_placeholder' => __('Type to search all forms', 'give'), |
|
| 213 | + 'search_placeholder_donor' => __('Type to search all donors', 'give'), |
|
| 214 | + 'search_placeholder_country' => __('Type to search all countries', 'give'), |
|
| 215 | + 'search_placeholder_state' => __('Type to search all states/provinces', 'give'), |
|
| 216 | + 'unlock_donor_fields_title' => __('Action forbidden', 'give'), |
|
| 217 | + 'unlock_donor_fields_message' => __('To edit first name and last name, please go to user profile of the donor.', 'give'), |
|
| 218 | + 'remove_from_bulk_delete' => __('Remove from Bulk Delete', 'give'), |
|
| 219 | 219 | 'donors_bulk_action' => array( |
| 220 | 220 | 'no_donor_selected' => array( |
| 221 | - 'title' => __( 'No donors selected', 'give' ), |
|
| 222 | - 'desc' => __( 'You must choose at least one or more donors to delete.', 'give' ) |
|
| 221 | + 'title' => __('No donors selected', 'give'), |
|
| 222 | + 'desc' => __('You must choose at least one or more donors to delete.', 'give') |
|
| 223 | 223 | ), |
| 224 | 224 | 'no_action_selected' => array( |
| 225 | - 'title' => __( 'No action selected', 'give' ), |
|
| 226 | - 'desc' => __( 'You must select a bulk action to proceed.', 'give' ), |
|
| 225 | + 'title' => __('No action selected', 'give'), |
|
| 226 | + 'desc' => __('You must select a bulk action to proceed.', 'give'), |
|
| 227 | 227 | ), |
| 228 | 228 | ), |
| 229 | 229 | 'donations_bulk_action' => array( |
| 230 | 230 | 'titles' => array( |
| 231 | - 'zero' => __( 'No payments selected', 'give' ), |
|
| 231 | + 'zero' => __('No payments selected', 'give'), |
|
| 232 | 232 | ), |
| 233 | 233 | 'delete' => array( |
| 234 | - 'zero' => __( 'You must choose at least one or more donations to delete.', 'give' ), |
|
| 235 | - 'single' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
| 236 | - 'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
| 234 | + 'zero' => __('You must choose at least one or more donations to delete.', 'give'), |
|
| 235 | + 'single' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
| 236 | + 'multiple' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
| 237 | 237 | ), |
| 238 | 238 | 'resend-receipt' => array( |
| 239 | - 'zero' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
| 240 | - 'single' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
| 241 | - 'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
| 239 | + 'zero' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
| 240 | + 'single' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
| 241 | + 'multiple' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
| 242 | 242 | ), |
| 243 | 243 | 'set-to-status' => array( |
| 244 | - 'zero' => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ), |
|
| 245 | - 'single' => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ), |
|
| 246 | - 'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ), |
|
| 244 | + 'zero' => __('You must choose at least one or more donations to set status to {status}.', 'give'), |
|
| 245 | + 'single' => __('Are you sure you want to set status of this donation to {status}?', 'give'), |
|
| 246 | + 'multiple' => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'), |
|
| 247 | 247 | ), |
| 248 | 248 | ), |
| 249 | 249 | 'updates' => array( |
| 250 | - 'ajax_error' => __( 'Please reload this page and try again', 'give' ), |
|
| 250 | + 'ajax_error' => __('Please reload this page and try again', 'give'), |
|
| 251 | 251 | ), |
| 252 | 252 | 'metabox_fields' => array( |
| 253 | 253 | 'media' => array( |
| 254 | - 'button_title' => __( 'Choose Image', 'give' ), |
|
| 254 | + 'button_title' => __('Choose Image', 'give'), |
|
| 255 | 255 | ), |
| 256 | 256 | 'file' => array( |
| 257 | - 'button_title' => __( 'Choose File', 'give' ), |
|
| 257 | + 'button_title' => __('Choose File', 'give'), |
|
| 258 | 258 | ), |
| 259 | 259 | ), |
| 260 | 260 | 'chosen' => array( |
| 261 | - 'no_results_msg' => __( 'No results match {search_term}', 'give' ), |
|
| 262 | - 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ), |
|
| 261 | + 'no_results_msg' => __('No results match {search_term}', 'give'), |
|
| 262 | + 'ajax_search_msg' => __('Searching results for match {search_term}', 'give'), |
|
| 263 | 263 | ), |
| 264 | - 'db_update_confirmation_msg_button' => __( 'Run Updates', 'give' ), |
|
| 265 | - 'db_update_confirmation_msg' => __( 'The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give' ), |
|
| 266 | - 'error_message' => __( 'Something went wrong kindly try again!', 'give' ), |
|
| 264 | + 'db_update_confirmation_msg_button' => __('Run Updates', 'give'), |
|
| 265 | + 'db_update_confirmation_msg' => __('The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give'), |
|
| 266 | + 'error_message' => __('Something went wrong kindly try again!', 'give'), |
|
| 267 | 267 | 'give_donation_import' => 'give_donation_import', |
| 268 | 268 | 'core_settings_import' => 'give_core_settings_import', |
| 269 | - 'setting_not_save_message' => __( 'Changes you made may not be saved.', 'give' ), |
|
| 269 | + 'setting_not_save_message' => __('Changes you made may not be saved.', 'give'), |
|
| 270 | 270 | 'give_donation_amounts' => array( |
| 271 | - 'minimum' => apply_filters( 'give_donation_minimum_limit', 1 ), |
|
| 272 | - 'maximum' => apply_filters( 'give_donation_maximum_limit', 999999.99 ), |
|
| 271 | + 'minimum' => apply_filters('give_donation_minimum_limit', 1), |
|
| 272 | + 'maximum' => apply_filters('give_donation_maximum_limit', 999999.99), |
|
| 273 | 273 | ), |
| 274 | - ) ); |
|
| 274 | + )); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -282,10 +282,10 @@ discard block |
||
| 282 | 282 | <style type="text/css" media="screen"> |
| 283 | 283 | @font-face { |
| 284 | 284 | font-family: 'give-icomoon'; |
| 285 | - src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?ngjl88'; ?>'); |
|
| 286 | - src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
| 287 | - url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
| 288 | - url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
| 285 | + src: url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.eot?ngjl88'; ?>'); |
|
| 286 | + src: url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
| 287 | + url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
| 288 | + url('<?php echo GIVE_PLUGIN_URL.'assets/dist/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
| 289 | 289 | font-weight: normal; |
| 290 | 290 | font-style: normal; |
| 291 | 291 | } |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | * @since 2.1.0 |
| 309 | 309 | */ |
| 310 | 310 | public function public_enqueue_styles() { |
| 311 | - wp_enqueue_style( 'give-styles' ); |
|
| 311 | + wp_enqueue_style('give-styles'); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | |
@@ -320,17 +320,17 @@ discard block |
||
| 320 | 320 | public function public_enqueue_scripts() { |
| 321 | 321 | |
| 322 | 322 | // Call Babel Polyfill with common handle so that it is compatible with plugins and themes. |
| 323 | - if ( ! wp_script_is( 'babel-polyfill', 'enqueued' ) ) { |
|
| 323 | + if ( ! wp_script_is('babel-polyfill', 'enqueued')) { |
|
| 324 | 324 | wp_enqueue_script( |
| 325 | 325 | 'babel-polyfill', |
| 326 | - GIVE_PLUGIN_URL . 'assets/dist/js/babel-polyfill.js', |
|
| 327 | - array( 'jquery' ), |
|
| 326 | + GIVE_PLUGIN_URL.'assets/dist/js/babel-polyfill.js', |
|
| 327 | + array('jquery'), |
|
| 328 | 328 | GIVE_VERSION, |
| 329 | 329 | false |
| 330 | 330 | ); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - wp_enqueue_script( 'give' ); |
|
| 333 | + wp_enqueue_script('give'); |
|
| 334 | 334 | |
| 335 | 335 | $this->public_localize_scripts(); |
| 336 | 336 | } |
@@ -349,22 +349,22 @@ discard block |
||
| 349 | 349 | * |
| 350 | 350 | * @return string $message Send notice message for email access. |
| 351 | 351 | */ |
| 352 | - $message = (string) apply_filters( 'give_email_access_mail_send_notice', __( 'Please check your email and click on the link to access your complete donation history.', 'give' ) ); |
|
| 352 | + $message = (string) apply_filters('give_email_access_mail_send_notice', __('Please check your email and click on the link to access your complete donation history.', 'give')); |
|
| 353 | 353 | |
| 354 | - $localize_give_vars = apply_filters( 'give_global_script_vars', array( |
|
| 354 | + $localize_give_vars = apply_filters('give_global_script_vars', array( |
|
| 355 | 355 | 'ajaxurl' => give_get_ajax_url(), |
| 356 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
| 356 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
| 357 | 357 | // Do not use this nonce. Its deprecated. |
| 358 | 358 | 'currency' => give_get_currency(), |
| 359 | - 'currency_sign' => give_currency_filter( '' ), |
|
| 359 | + 'currency_sign' => give_currency_filter(''), |
|
| 360 | 360 | 'currency_pos' => give_get_currency_position(), |
| 361 | 361 | 'thousands_separator' => give_get_price_thousand_separator(), |
| 362 | 362 | 'decimal_separator' => give_get_price_decimal_separator(), |
| 363 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), |
|
| 364 | - 'bad_minimum' => __( 'The minimum custom donation amount for this form is', 'give' ), |
|
| 365 | - 'bad_maximum' => __( 'The maximum custom donation amount for this form is', 'give' ), |
|
| 366 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
| 367 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
| 363 | + 'no_gateway' => __('Please select a payment method.', 'give'), |
|
| 364 | + 'bad_minimum' => __('The minimum custom donation amount for this form is', 'give'), |
|
| 365 | + 'bad_maximum' => __('The maximum custom donation amount for this form is', 'give'), |
|
| 366 | + 'general_loading' => __('Loading...', 'give'), |
|
| 367 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
| 368 | 368 | 'number_decimals' => give_get_price_decimals(), |
| 369 | 369 | 'give_version' => GIVE_VERSION, |
| 370 | 370 | 'magnific_options' => apply_filters( |
@@ -378,30 +378,30 @@ discard block |
||
| 378 | 378 | 'give_form_translation_js', |
| 379 | 379 | array( |
| 380 | 380 | // Field name Validation message. |
| 381 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), |
|
| 382 | - 'give_first' => __( 'Please enter your first name.', 'give' ), |
|
| 383 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), |
|
| 384 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), |
|
| 385 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), |
|
| 386 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), |
|
| 387 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), |
|
| 381 | + 'payment-mode' => __('Please select payment mode.', 'give'), |
|
| 382 | + 'give_first' => __('Please enter your first name.', 'give'), |
|
| 383 | + 'give_email' => __('Please enter a valid email address.', 'give'), |
|
| 384 | + 'give_user_login' => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'), |
|
| 385 | + 'give_user_pass' => __('Enter a password.', 'give'), |
|
| 386 | + 'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'), |
|
| 387 | + 'give_agree_to_terms' => __('You must agree to the terms and conditions.', 'give'), |
|
| 388 | 388 | ) |
| 389 | 389 | ), |
| 390 | 390 | 'confirm_email_sent_message' => $message, |
| 391 | - 'ajax_vars' => apply_filters( 'give_global_ajax_vars', array( |
|
| 391 | + 'ajax_vars' => apply_filters('give_global_ajax_vars', array( |
|
| 392 | 392 | 'ajaxurl' => give_get_ajax_url(), |
| 393 | - 'ajaxNonce' => wp_create_nonce( 'give_ajax_nonce' ), |
|
| 394 | - 'loading' => __( 'Loading', 'give' ), |
|
| 393 | + 'ajaxNonce' => wp_create_nonce('give_ajax_nonce'), |
|
| 394 | + 'loading' => __('Loading', 'give'), |
|
| 395 | 395 | // General loading message. |
| 396 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
| 396 | + 'select_option' => __('Please select an option', 'give'), |
|
| 397 | 397 | // Variable pricing error with multi-donation option enabled. |
| 398 | - 'default_gateway' => give_get_default_gateway( null ), |
|
| 399 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
| 398 | + 'default_gateway' => give_get_default_gateway(null), |
|
| 399 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
| 400 | 400 | 'number_decimals' => give_get_price_decimals(), |
| 401 | - ) ), |
|
| 402 | - ) ); |
|
| 401 | + )), |
|
| 402 | + )); |
|
| 403 | 403 | |
| 404 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
| 404 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
| 405 | 405 | |
| 406 | 406 | } |
| 407 | 407 | |
@@ -415,15 +415,15 @@ discard block |
||
| 415 | 415 | */ |
| 416 | 416 | public function get_frontend_stylesheet_uri() { |
| 417 | 417 | |
| 418 | - $file = 'give' . $this->direction . '.css'; |
|
| 418 | + $file = 'give'.$this->direction.'.css'; |
|
| 419 | 419 | $templates_dir = give_get_theme_template_dir_name(); |
| 420 | 420 | |
| 421 | 421 | // Directory paths to CSS files to support checking via file_exists(). |
| 422 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
| 423 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $this->direction . '.css'; |
|
| 424 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
| 425 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $this->direction . '.css'; |
|
| 426 | - $give_plugin_style_sheet = trailingslashit( GIVE_PLUGIN_DIR ) . 'assets/dist/css/' . $file; |
|
| 422 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
| 423 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$this->direction.'.css'; |
|
| 424 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
| 425 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$this->direction.'.css'; |
|
| 426 | + $give_plugin_style_sheet = trailingslashit(GIVE_PLUGIN_DIR).'assets/dist/css/'.$file; |
|
| 427 | 427 | $uri = false; |
| 428 | 428 | |
| 429 | 429 | /** |
@@ -434,23 +434,23 @@ discard block |
||
| 434 | 434 | * c. followed by non minified version, even if SCRIPT_DEBUG is not enabled. This allows users to copy just give.css to their theme. |
| 435 | 435 | * d. Finally, fallback to the standard Give version. This is the default styles included within the plugin. |
| 436 | 436 | */ |
| 437 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
| 438 | - if ( ! empty( $nonmin ) ) { |
|
| 439 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css'; |
|
| 437 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
| 438 | + if ( ! empty($nonmin)) { |
|
| 439 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$this->direction.'.css'; |
|
| 440 | 440 | } else { |
| 441 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
| 441 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
| 442 | 442 | } |
| 443 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
| 444 | - if ( ! empty( $nonmin ) ) { |
|
| 445 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css'; |
|
| 443 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
| 444 | + if ( ! empty($nonmin)) { |
|
| 445 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$this->direction.'.css'; |
|
| 446 | 446 | } else { |
| 447 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
| 447 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
| 448 | 448 | } |
| 449 | - } elseif ( file_exists( $give_plugin_style_sheet ) ) { |
|
| 450 | - $uri = trailingslashit( GIVE_PLUGIN_URL ) . 'assets/dist/css/' . $file; |
|
| 449 | + } elseif (file_exists($give_plugin_style_sheet)) { |
|
| 450 | + $uri = trailingslashit(GIVE_PLUGIN_URL).'assets/dist/css/'.$file; |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
| 453 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
| 454 | 454 | |
| 455 | 455 | } |
| 456 | 456 | |
@@ -462,19 +462,19 @@ discard block |
||
| 462 | 462 | // Enqueue the bundled block JS file |
| 463 | 463 | wp_enqueue_script( |
| 464 | 464 | 'give-blocks-js', |
| 465 | - GIVE_PLUGIN_URL . 'assets/dist/js/gutenberg.js', |
|
| 466 | - array( 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-api' ), |
|
| 465 | + GIVE_PLUGIN_URL.'assets/dist/js/gutenberg.js', |
|
| 466 | + array('wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-api'), |
|
| 467 | 467 | GIVE_VERSION |
| 468 | 468 | ); |
| 469 | 469 | |
| 470 | 470 | // Enqueue public styles |
| 471 | - wp_enqueue_style( 'give-styles' ); |
|
| 471 | + wp_enqueue_style('give-styles'); |
|
| 472 | 472 | |
| 473 | 473 | // Enqueue the bundled block css file |
| 474 | 474 | wp_enqueue_style( |
| 475 | 475 | 'give-blocks-css', |
| 476 | - GIVE_PLUGIN_URL . 'assets/dist/css/gutenberg.css', |
|
| 477 | - array( 'wp-blocks' ), |
|
| 476 | + GIVE_PLUGIN_URL.'assets/dist/css/gutenberg.css', |
|
| 477 | + array('wp-blocks'), |
|
| 478 | 478 | GIVE_VERSION |
| 479 | 479 | ); |
| 480 | 480 | |
@@ -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 | |
@@ -28,18 +28,18 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | function give_process_donation_form() { |
| 30 | 30 | |
| 31 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, CSRF ok. |
|
| 32 | - $is_ajax = isset( $post_data['give_ajax'] ); |
|
| 31 | + $post_data = give_clean($_POST); // WPCS: input var ok, CSRF ok. |
|
| 32 | + $is_ajax = isset($post_data['give_ajax']); |
|
| 33 | 33 | |
| 34 | 34 | // Verify donation form nonce. |
| 35 | - if ( ! give_verify_donation_form_nonce( $post_data['give-form-hash'], $post_data['give-form-id'] ) ) { |
|
| 36 | - if ( $is_ajax ) { |
|
| 35 | + if ( ! give_verify_donation_form_nonce($post_data['give-form-hash'], $post_data['give-form-id'])) { |
|
| 36 | + if ($is_ajax) { |
|
| 37 | 37 | /** |
| 38 | 38 | * Fires when AJAX sends back errors from the donation form. |
| 39 | 39 | * |
| 40 | 40 | * @since 1.0 |
| 41 | 41 | */ |
| 42 | - do_action( 'give_ajax_donation_errors' ); |
|
| 42 | + do_action('give_ajax_donation_errors'); |
|
| 43 | 43 | give_die(); |
| 44 | 44 | } else { |
| 45 | 45 | give_send_back_to_checkout(); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @since 1.0 |
| 53 | 53 | */ |
| 54 | - do_action( 'give_pre_process_donation' ); |
|
| 54 | + do_action('give_pre_process_donation'); |
|
| 55 | 55 | |
| 56 | 56 | // Validate the form $_POST data. |
| 57 | 57 | $valid_data = give_donation_form_validate_fields(); |
@@ -67,24 +67,24 @@ discard block |
||
| 67 | 67 | * @param array $deprecated Deprecated Since 2.0.2. Use $_POST instead. |
| 68 | 68 | */ |
| 69 | 69 | $deprecated = $post_data; |
| 70 | - do_action( 'give_checkout_error_checks', $valid_data, $deprecated ); |
|
| 70 | + do_action('give_checkout_error_checks', $valid_data, $deprecated); |
|
| 71 | 71 | |
| 72 | 72 | // Process the login form. |
| 73 | - if ( isset( $post_data['give_login_submit'] ) ) { |
|
| 73 | + if (isset($post_data['give_login_submit'])) { |
|
| 74 | 74 | give_process_form_login(); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // Validate the user. |
| 78 | - $user = give_get_donation_form_user( $valid_data ); |
|
| 78 | + $user = give_get_donation_form_user($valid_data); |
|
| 79 | 79 | |
| 80 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
| 81 | - if ( $is_ajax ) { |
|
| 80 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
| 81 | + if ($is_ajax) { |
|
| 82 | 82 | /** |
| 83 | 83 | * Fires when AJAX sends back errors from the donation form. |
| 84 | 84 | * |
| 85 | 85 | * @since 1.0 |
| 86 | 86 | */ |
| 87 | - do_action( 'give_ajax_donation_errors' ); |
|
| 87 | + do_action('give_ajax_donation_errors'); |
|
| 88 | 88 | give_die(); |
| 89 | 89 | } else { |
| 90 | 90 | return false; |
@@ -92,17 +92,17 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | // If AJAX send back success to proceed with form submission. |
| 95 | - if ( $is_ajax ) { |
|
| 95 | + if ($is_ajax) { |
|
| 96 | 96 | echo 'success'; |
| 97 | 97 | give_die(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // After AJAX: Setup session if not using php_sessions. |
| 101 | - if ( ! Give()->session->use_php_sessions() ) { |
|
| 101 | + if ( ! Give()->session->use_php_sessions()) { |
|
| 102 | 102 | // Double-check that set_cookie is publicly accessible. |
| 103 | 103 | // we're using a slightly modified class-wp-sessions.php. |
| 104 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
| 105 | - if ( $session_reflection->isPublic() ) { |
|
| 104 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
| 105 | + if ($session_reflection->isPublic()) { |
|
| 106 | 106 | // Manually set the cookie. |
| 107 | 107 | Give()->session->init()->set_cookie(); |
| 108 | 108 | } |
@@ -117,23 +117,22 @@ discard block |
||
| 117 | 117 | 'address' => $user['address'], |
| 118 | 118 | ); |
| 119 | 119 | |
| 120 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 120 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 121 | 121 | |
| 122 | 122 | // Donation form ID. |
| 123 | - $form_id = isset( $post_data['give-form-id'] ) ? absint( $post_data['give-form-id'] ) : 0; |
|
| 123 | + $form_id = isset($post_data['give-form-id']) ? absint($post_data['give-form-id']) : 0; |
|
| 124 | 124 | |
| 125 | - $price = isset( $post_data['give-amount'] ) ? |
|
| 126 | - (float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => give_get_currency( $form_id ) ) ) ) : |
|
| 127 | - '0.00'; |
|
| 128 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
| 125 | + $price = isset($post_data['give-amount']) ? |
|
| 126 | + (float) apply_filters('give_donation_total', give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => give_get_currency($form_id)))) : '0.00'; |
|
| 127 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
| 129 | 128 | |
| 130 | 129 | // Setup donation information. |
| 131 | 130 | $donation_data = array( |
| 132 | 131 | 'price' => $price, |
| 133 | 132 | 'purchase_key' => $purchase_key, |
| 134 | 133 | 'user_email' => $user['user_email'], |
| 135 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
| 136 | - 'user_info' => stripslashes_deep( $user_info ), |
|
| 134 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
| 135 | + 'user_info' => stripslashes_deep($user_info), |
|
| 137 | 136 | 'post_data' => $post_data, |
| 138 | 137 | 'gateway' => $valid_data['gateway'], |
| 139 | 138 | 'card_info' => $valid_data['cc_info'], |
@@ -153,10 +152,10 @@ discard block |
||
| 153 | 152 | * @param array $user_info Array containing basic user information. |
| 154 | 153 | * @param bool|array $valid_data Validate fields. |
| 155 | 154 | */ |
| 156 | - do_action( 'give_checkout_before_gateway', $post_data, $user_info, $valid_data ); |
|
| 155 | + do_action('give_checkout_before_gateway', $post_data, $user_info, $valid_data); |
|
| 157 | 156 | |
| 158 | 157 | // Sanity check for price. |
| 159 | - if ( ! $donation_data['price'] ) { |
|
| 158 | + if ( ! $donation_data['price']) { |
|
| 160 | 159 | // Revert to manual. |
| 161 | 160 | $donation_data['gateway'] = 'manual'; |
| 162 | 161 | $_POST['give-gateway'] = 'manual'; |
@@ -167,26 +166,26 @@ discard block |
||
| 167 | 166 | * |
| 168 | 167 | * @since 1.7 |
| 169 | 168 | */ |
| 170 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
| 169 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
| 171 | 170 | |
| 172 | 171 | // Setup the data we're storing in the donation session. |
| 173 | 172 | $session_data = $donation_data; |
| 174 | 173 | |
| 175 | 174 | // Make sure credit card numbers are never stored in sessions. |
| 176 | - unset( $session_data['card_info']['card_number'] ); |
|
| 177 | - unset( $session_data['post_data']['card_number'] ); |
|
| 175 | + unset($session_data['card_info']['card_number']); |
|
| 176 | + unset($session_data['post_data']['card_number']); |
|
| 178 | 177 | |
| 179 | 178 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
| 180 | - give_set_purchase_session( $session_data ); |
|
| 179 | + give_set_purchase_session($session_data); |
|
| 181 | 180 | |
| 182 | 181 | // Send info to the gateway for payment processing. |
| 183 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
| 182 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
| 184 | 183 | give_die(); |
| 185 | 184 | } |
| 186 | 185 | |
| 187 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
| 188 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
| 189 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
| 186 | +add_action('give_purchase', 'give_process_donation_form'); |
|
| 187 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
| 188 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
| 190 | 189 | |
| 191 | 190 | /** |
| 192 | 191 | * Verify that when a logged in user makes a donation that the email address used doesn't belong to a different customer. |
@@ -197,27 +196,27 @@ discard block |
||
| 197 | 196 | * |
| 198 | 197 | * @return void |
| 199 | 198 | */ |
| 200 | -function give_check_logged_in_user_for_existing_email( $valid_data ) { |
|
| 199 | +function give_check_logged_in_user_for_existing_email($valid_data) { |
|
| 201 | 200 | |
| 202 | 201 | // Verify that the email address belongs to this customer. |
| 203 | - if ( is_user_logged_in() ) { |
|
| 202 | + if (is_user_logged_in()) { |
|
| 204 | 203 | |
| 205 | 204 | $submitted_email = $valid_data['logged_in_user']['user_email']; |
| 206 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
| 205 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
| 207 | 206 | |
| 208 | 207 | // If this email address is not registered with this customer, see if it belongs to any other customer. |
| 209 | 208 | if ( |
| 210 | 209 | $submitted_email !== $donor->email |
| 211 | - && ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails, true ) ) |
|
| 210 | + && (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails, true)) |
|
| 212 | 211 | ) { |
| 213 | - $found_donor = new Give_Donor( $submitted_email ); |
|
| 212 | + $found_donor = new Give_Donor($submitted_email); |
|
| 214 | 213 | |
| 215 | - if ( $found_donor->id > 0 ) { |
|
| 214 | + if ($found_donor->id > 0) { |
|
| 216 | 215 | give_set_error( |
| 217 | 216 | 'give-customer-email-exists', |
| 218 | 217 | sprintf( |
| 219 | 218 | /* translators: 1. Donor Email, 2. Submitted Email */ |
| 220 | - __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), |
|
| 219 | + __('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), |
|
| 221 | 220 | $donor->email, |
| 222 | 221 | $submitted_email |
| 223 | 222 | ) |
@@ -227,7 +226,7 @@ discard block |
||
| 227 | 226 | } |
| 228 | 227 | } |
| 229 | 228 | |
| 230 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1 ); |
|
| 229 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1); |
|
| 231 | 230 | |
| 232 | 231 | /** |
| 233 | 232 | * Process the checkout login form |
@@ -239,49 +238,49 @@ discard block |
||
| 239 | 238 | */ |
| 240 | 239 | function give_process_form_login() { |
| 241 | 240 | |
| 242 | - $is_ajax = ! empty( $_POST['give_ajax'] ) ? give_clean( $_POST['give_ajax'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 241 | + $is_ajax = ! empty($_POST['give_ajax']) ? give_clean($_POST['give_ajax']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 243 | 242 | $referrer = wp_get_referer(); |
| 244 | 243 | $user_data = give_donation_form_validate_user_login(); |
| 245 | 244 | |
| 246 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
| 247 | - if ( $is_ajax ) { |
|
| 245 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
| 246 | + if ($is_ajax) { |
|
| 248 | 247 | /** |
| 249 | 248 | * Fires when AJAX sends back errors from the donation form. |
| 250 | 249 | * |
| 251 | 250 | * @since 1.0 |
| 252 | 251 | */ |
| 253 | 252 | ob_start(); |
| 254 | - do_action( 'give_ajax_donation_errors' ); |
|
| 253 | + do_action('give_ajax_donation_errors'); |
|
| 255 | 254 | $message = ob_get_contents(); |
| 256 | 255 | ob_end_clean(); |
| 257 | - wp_send_json_error( $message ); |
|
| 256 | + wp_send_json_error($message); |
|
| 258 | 257 | } else { |
| 259 | - wp_safe_redirect( $referrer ); |
|
| 258 | + wp_safe_redirect($referrer); |
|
| 260 | 259 | exit; |
| 261 | 260 | } |
| 262 | 261 | } |
| 263 | 262 | |
| 264 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
| 263 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
| 265 | 264 | |
| 266 | - if ( $is_ajax ) { |
|
| 265 | + if ($is_ajax) { |
|
| 267 | 266 | $message = Give()->notices->print_frontend_notice( |
| 268 | 267 | sprintf( |
| 269 | 268 | /* translators: %s: user first name */ |
| 270 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
| 271 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
| 269 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
| 270 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
| 272 | 271 | ), |
| 273 | 272 | false, |
| 274 | 273 | 'success' |
| 275 | 274 | ); |
| 276 | 275 | |
| 277 | - wp_send_json_success( $message ); |
|
| 276 | + wp_send_json_success($message); |
|
| 278 | 277 | } else { |
| 279 | - wp_safe_redirect( $referrer ); |
|
| 278 | + wp_safe_redirect($referrer); |
|
| 280 | 279 | } |
| 281 | 280 | } |
| 282 | 281 | |
| 283 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
| 284 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
| 282 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
| 283 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
| 285 | 284 | |
| 286 | 285 | /** |
| 287 | 286 | * Donation Form Validate Fields. |
@@ -293,49 +292,49 @@ discard block |
||
| 293 | 292 | */ |
| 294 | 293 | function give_donation_form_validate_fields() { |
| 295 | 294 | |
| 296 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 295 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 297 | 296 | |
| 298 | 297 | // Validate Honeypot First. |
| 299 | - if ( ! empty( $post_data['give-honeypot'] ) ) { |
|
| 300 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
| 298 | + if ( ! empty($post_data['give-honeypot'])) { |
|
| 299 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
| 301 | 300 | } |
| 302 | 301 | |
| 303 | 302 | // Check spam detect. |
| 304 | 303 | if ( |
| 305 | - isset( $post_data['action'] ) && |
|
| 306 | - give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) && |
|
| 304 | + isset($post_data['action']) && |
|
| 305 | + give_is_setting_enabled(give_get_option('akismet_spam_protection')) && |
|
| 307 | 306 | give_is_spam_donation() |
| 308 | 307 | ) { |
| 309 | - give_set_error( 'spam_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); |
|
| 308 | + give_set_error('spam_donation', __('This donation has been flagged as spam. Please try again.', 'give')); |
|
| 310 | 309 | } |
| 311 | 310 | |
| 312 | 311 | // Start an array to collect valid data. |
| 313 | 312 | $valid_data = array( |
| 314 | 313 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here). |
| 315 | - 'need_new_user' => false, // New user flag. |
|
| 316 | - 'need_user_login' => false, // Login user flag. |
|
| 317 | - 'logged_user_data' => array(), // Logged user collected data. |
|
| 318 | - 'new_user_data' => array(), // New user collected data. |
|
| 319 | - 'login_user_data' => array(), // Login user collected data. |
|
| 320 | - 'guest_user_data' => array(), // Guest user collected data. |
|
| 314 | + 'need_new_user' => false, // New user flag. |
|
| 315 | + 'need_user_login' => false, // Login user flag. |
|
| 316 | + 'logged_user_data' => array(), // Logged user collected data. |
|
| 317 | + 'new_user_data' => array(), // New user collected data. |
|
| 318 | + 'login_user_data' => array(), // Login user collected data. |
|
| 319 | + 'guest_user_data' => array(), // Guest user collected data. |
|
| 321 | 320 | 'cc_info' => give_donation_form_validate_cc(), // Credit card info. |
| 322 | 321 | ); |
| 323 | 322 | |
| 324 | - $form_id = intval( $post_data['give-form-id'] ); |
|
| 323 | + $form_id = intval($post_data['give-form-id']); |
|
| 325 | 324 | |
| 326 | 325 | // Validate agree to terms. |
| 327 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
| 326 | + if (give_is_terms_enabled($form_id)) { |
|
| 328 | 327 | give_donation_form_validate_agree_to_terms(); |
| 329 | 328 | } |
| 330 | 329 | |
| 331 | - if ( is_user_logged_in() ) { |
|
| 330 | + if (is_user_logged_in()) { |
|
| 332 | 331 | |
| 333 | 332 | // Collect logged in user data. |
| 334 | 333 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
| 335 | 334 | } elseif ( |
| 336 | - isset( $post_data['give-purchase-var'] ) && |
|
| 335 | + isset($post_data['give-purchase-var']) && |
|
| 337 | 336 | 'needs-to-register' === $post_data['give-purchase-var'] && |
| 338 | - ! empty( $post_data['give_create_account'] ) |
|
| 337 | + ! empty($post_data['give_create_account']) |
|
| 339 | 338 | ) { |
| 340 | 339 | |
| 341 | 340 | // Set new user registration as required. |
@@ -344,7 +343,7 @@ discard block |
||
| 344 | 343 | // Validate new user data. |
| 345 | 344 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
| 346 | 345 | } elseif ( |
| 347 | - isset( $post_data['give-purchase-var'] ) && |
|
| 346 | + isset($post_data['give-purchase-var']) && |
|
| 348 | 347 | 'needs-to-login' === $post_data['give-purchase-var'] |
| 349 | 348 | ) { |
| 350 | 349 | |
@@ -373,14 +372,14 @@ discard block |
||
| 373 | 372 | function give_is_spam_donation() { |
| 374 | 373 | $spam = false; |
| 375 | 374 | |
| 376 | - $user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
| 375 | + $user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
| 377 | 376 | |
| 378 | - if ( strlen( $user_agent ) < 2 ) { |
|
| 377 | + if (strlen($user_agent) < 2) { |
|
| 379 | 378 | $spam = true; |
| 380 | 379 | } |
| 381 | 380 | |
| 382 | 381 | // Allow developer to customized Akismet spam detect API call and it's response. |
| 383 | - return apply_filters( 'give_spam', $spam ); |
|
| 382 | + return apply_filters('give_spam', $spam); |
|
| 384 | 383 | } |
| 385 | 384 | |
| 386 | 385 | /** |
@@ -395,33 +394,33 @@ discard block |
||
| 395 | 394 | */ |
| 396 | 395 | function give_donation_form_validate_gateway() { |
| 397 | 396 | |
| 398 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 399 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; |
|
| 400 | - $amount = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'] ) : 0; |
|
| 401 | - $gateway = ! empty( $post_data['give-gateway'] ) ? $post_data['give-gateway'] : 0; |
|
| 397 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 398 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; |
|
| 399 | + $amount = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount']) : 0; |
|
| 400 | + $gateway = ! empty($post_data['give-gateway']) ? $post_data['give-gateway'] : 0; |
|
| 402 | 401 | |
| 403 | 402 | // Bailout, if payment gateway is not submitted with donation form data. |
| 404 | - if ( empty( $gateway ) ) { |
|
| 403 | + if (empty($gateway)) { |
|
| 405 | 404 | |
| 406 | - give_set_error( 'empty_gateway', __( 'The donation form will process with a valid payment gateway.', 'give' ) ); |
|
| 405 | + give_set_error('empty_gateway', __('The donation form will process with a valid payment gateway.', 'give')); |
|
| 407 | 406 | |
| 408 | - } elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
| 407 | + } elseif ( ! give_is_gateway_active($gateway)) { |
|
| 409 | 408 | |
| 410 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
| 409 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
| 411 | 410 | |
| 412 | - } elseif ( empty( $amount ) ) { |
|
| 411 | + } elseif (empty($amount)) { |
|
| 413 | 412 | |
| 414 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
| 413 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
| 415 | 414 | |
| 416 | - } elseif ( ! give_verify_minimum_price( 'minimum' ) ) { |
|
| 415 | + } elseif ( ! give_verify_minimum_price('minimum')) { |
|
| 417 | 416 | |
| 418 | 417 | give_set_error( |
| 419 | 418 | 'invalid_donation_minimum', |
| 420 | 419 | sprintf( |
| 421 | 420 | /* translators: %s: minimum donation amount */ |
| 422 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
| 421 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
| 423 | 422 | give_currency_filter( |
| 424 | - give_format_amount( give_get_form_minimum_price( $form_id ), |
|
| 423 | + give_format_amount(give_get_form_minimum_price($form_id), |
|
| 425 | 424 | array( |
| 426 | 425 | 'sanitize' => false, |
| 427 | 426 | ) |
@@ -429,15 +428,15 @@ discard block |
||
| 429 | 428 | ) |
| 430 | 429 | ) |
| 431 | 430 | ); |
| 432 | - } elseif ( ! give_verify_minimum_price( 'maximum' ) ) { |
|
| 431 | + } elseif ( ! give_verify_minimum_price('maximum')) { |
|
| 433 | 432 | |
| 434 | 433 | give_set_error( |
| 435 | 434 | 'invalid_donation_maximum', |
| 436 | 435 | sprintf( |
| 437 | 436 | /* translators: %s: Maximum donation amount */ |
| 438 | - __( 'This form has a maximum donation amount of %s.', 'give' ), |
|
| 437 | + __('This form has a maximum donation amount of %s.', 'give'), |
|
| 439 | 438 | give_currency_filter( |
| 440 | - give_format_amount( give_get_form_maximum_price( $form_id ), |
|
| 439 | + give_format_amount(give_get_form_maximum_price($form_id), |
|
| 441 | 440 | array( |
| 442 | 441 | 'sanitize' => false, |
| 443 | 442 | ) |
@@ -463,33 +462,33 @@ discard block |
||
| 463 | 462 | * |
| 464 | 463 | * @return bool |
| 465 | 464 | */ |
| 466 | -function give_verify_minimum_price( $amount_range = 'minimum' ) { |
|
| 465 | +function give_verify_minimum_price($amount_range = 'minimum') { |
|
| 467 | 466 | |
| 468 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 469 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; |
|
| 470 | - $amount = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => give_get_currency( $form_id ) ) ) : 0; |
|
| 471 | - $price_id = isset( $post_data['give-price-id'] ) ? absint( $post_data['give-price-id'] ) : ''; |
|
| 467 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 468 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; |
|
| 469 | + $amount = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => give_get_currency($form_id))) : 0; |
|
| 470 | + $price_id = isset($post_data['give-price-id']) ? absint($post_data['give-price-id']) : ''; |
|
| 472 | 471 | |
| 473 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
| 474 | - $price_ids = array_map( 'absint', give_get_variable_price_ids( $form_id ) ); |
|
| 472 | + $variable_prices = give_has_variable_prices($form_id); |
|
| 473 | + $price_ids = array_map('absint', give_get_variable_price_ids($form_id)); |
|
| 475 | 474 | $verified_stat = false; |
| 476 | 475 | |
| 477 | - if ( $variable_prices && in_array( $price_id, $price_ids, true ) ) { |
|
| 476 | + if ($variable_prices && in_array($price_id, $price_ids, true)) { |
|
| 478 | 477 | |
| 479 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
| 478 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
| 480 | 479 | |
| 481 | - if ( $price_level_amount == $amount ) { |
|
| 480 | + if ($price_level_amount == $amount) { |
|
| 482 | 481 | $verified_stat = true; |
| 483 | 482 | } |
| 484 | 483 | } |
| 485 | 484 | |
| 486 | - if ( ! $verified_stat ) { |
|
| 487 | - switch ( $amount_range ) { |
|
| 485 | + if ( ! $verified_stat) { |
|
| 486 | + switch ($amount_range) { |
|
| 488 | 487 | case 'minimum' : |
| 489 | - $verified_stat = ( give_get_form_minimum_price( $form_id ) > $amount ) ? false : true; |
|
| 488 | + $verified_stat = (give_get_form_minimum_price($form_id) > $amount) ? false : true; |
|
| 490 | 489 | break; |
| 491 | 490 | case 'maximum' : |
| 492 | - $verified_stat = ( give_get_form_maximum_price( $form_id ) < $amount ) ? false : true; |
|
| 491 | + $verified_stat = (give_get_form_maximum_price($form_id) < $amount) ? false : true; |
|
| 493 | 492 | break; |
| 494 | 493 | } |
| 495 | 494 | } |
@@ -503,7 +502,7 @@ discard block |
||
| 503 | 502 | * @param string $amount_range Type of the amount. |
| 504 | 503 | * @param integer $form_id Give Donation Form ID. |
| 505 | 504 | */ |
| 506 | - return apply_filters( 'give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id ); |
|
| 505 | + return apply_filters('give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id); |
|
| 507 | 506 | } |
| 508 | 507 | |
| 509 | 508 | /** |
@@ -516,13 +515,13 @@ discard block |
||
| 516 | 515 | */ |
| 517 | 516 | function give_donation_form_validate_agree_to_terms() { |
| 518 | 517 | |
| 519 | - $agree_to_terms = ! empty( $_POST['give_agree_to_terms'] ) ? give_clean( $_POST['give_agree_to_terms'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 518 | + $agree_to_terms = ! empty($_POST['give_agree_to_terms']) ? give_clean($_POST['give_agree_to_terms']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 520 | 519 | |
| 521 | 520 | // Proceed only, if donor agreed to terms. |
| 522 | - if ( ! $agree_to_terms ) { |
|
| 521 | + if ( ! $agree_to_terms) { |
|
| 523 | 522 | |
| 524 | 523 | // User did not agree. |
| 525 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
| 524 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
| 526 | 525 | } |
| 527 | 526 | } |
| 528 | 527 | |
@@ -536,84 +535,84 @@ discard block |
||
| 536 | 535 | * |
| 537 | 536 | * @return array |
| 538 | 537 | */ |
| 539 | -function give_get_required_fields( $form_id ) { |
|
| 538 | +function give_get_required_fields($form_id) { |
|
| 540 | 539 | |
| 541 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
| 540 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
| 542 | 541 | |
| 543 | 542 | $required_fields = array( |
| 544 | 543 | 'give_email' => array( |
| 545 | 544 | 'error_id' => 'invalid_email', |
| 546 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
| 545 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
| 547 | 546 | ), |
| 548 | 547 | 'give_first' => array( |
| 549 | 548 | 'error_id' => 'invalid_first_name', |
| 550 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
| 549 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
| 551 | 550 | ), |
| 552 | 551 | ); |
| 553 | 552 | |
| 554 | - $require_address = give_require_billing_address( $payment_mode ); |
|
| 553 | + $require_address = give_require_billing_address($payment_mode); |
|
| 555 | 554 | |
| 556 | - if ( $require_address ) { |
|
| 557 | - $required_fields['card_address'] = array( |
|
| 555 | + if ($require_address) { |
|
| 556 | + $required_fields['card_address'] = array( |
|
| 558 | 557 | 'error_id' => 'invalid_card_address', |
| 559 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
| 558 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
| 560 | 559 | ); |
| 561 | - $required_fields['card_zip'] = array( |
|
| 560 | + $required_fields['card_zip'] = array( |
|
| 562 | 561 | 'error_id' => 'invalid_zip_code', |
| 563 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
| 562 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
| 564 | 563 | ); |
| 565 | - $required_fields['card_city'] = array( |
|
| 564 | + $required_fields['card_city'] = array( |
|
| 566 | 565 | 'error_id' => 'invalid_city', |
| 567 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
| 566 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
| 568 | 567 | ); |
| 569 | 568 | $required_fields['billing_country'] = array( |
| 570 | 569 | 'error_id' => 'invalid_country', |
| 571 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
| 570 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
| 572 | 571 | ); |
| 573 | 572 | |
| 574 | 573 | |
| 575 | 574 | $required_fields['card_state'] = array( |
| 576 | 575 | 'error_id' => 'invalid_state', |
| 577 | - 'error_message' => __( 'Please enter billing state / province / County.', 'give' ), |
|
| 576 | + 'error_message' => __('Please enter billing state / province / County.', 'give'), |
|
| 578 | 577 | ); |
| 579 | 578 | |
| 580 | - $country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 579 | + $country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 581 | 580 | |
| 582 | 581 | // Check if billing country already exists. |
| 583 | - if ( $country ) { |
|
| 582 | + if ($country) { |
|
| 584 | 583 | |
| 585 | 584 | // Get the country list that does not required any states init. |
| 586 | 585 | $states_country = give_states_not_required_country_list(); |
| 587 | 586 | |
| 588 | 587 | // Check if states is empty or not. |
| 589 | - if ( array_key_exists( $country, $states_country ) ) { |
|
| 588 | + if (array_key_exists($country, $states_country)) { |
|
| 590 | 589 | // If states is empty remove the required fields of state in billing cart. |
| 591 | - unset( $required_fields['card_state'] ); |
|
| 590 | + unset($required_fields['card_state']); |
|
| 592 | 591 | } |
| 593 | 592 | } |
| 594 | 593 | } // End if(). |
| 595 | 594 | |
| 596 | - if ( give_is_company_field_enabled( $form_id ) ) { |
|
| 597 | - $form_option = give_get_meta( $form_id, '_give_company_field', true ); |
|
| 598 | - $global_setting = give_get_option( 'company_field' ); |
|
| 595 | + if (give_is_company_field_enabled($form_id)) { |
|
| 596 | + $form_option = give_get_meta($form_id, '_give_company_field', true); |
|
| 597 | + $global_setting = give_get_option('company_field'); |
|
| 599 | 598 | |
| 600 | 599 | $is_company_field_required = false; |
| 601 | 600 | |
| 602 | - if ( ! empty( $form_option ) && give_is_setting_enabled( $form_option, array( 'required' ) ) ) { |
|
| 601 | + if ( ! empty($form_option) && give_is_setting_enabled($form_option, array('required'))) { |
|
| 603 | 602 | $is_company_field_required = true; |
| 604 | 603 | |
| 605 | - } elseif ( 'global' === $form_option && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) { |
|
| 604 | + } elseif ('global' === $form_option && give_is_setting_enabled($global_setting, array('required'))) { |
|
| 606 | 605 | $is_company_field_required = true; |
| 607 | 606 | |
| 608 | - } elseif ( empty( $form_option ) && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) { |
|
| 607 | + } elseif (empty($form_option) && give_is_setting_enabled($global_setting, array('required'))) { |
|
| 609 | 608 | $is_company_field_required = true; |
| 610 | 609 | |
| 611 | 610 | } |
| 612 | 611 | |
| 613 | - if ( $is_company_field_required ) { |
|
| 612 | + if ($is_company_field_required) { |
|
| 614 | 613 | $required_fields['give_company_name'] = array( |
| 615 | 614 | 'error_id' => 'invalid_company', |
| 616 | - 'error_message' => __( 'Please enter Company Name.', 'give' ), |
|
| 615 | + 'error_message' => __('Please enter Company Name.', 'give'), |
|
| 617 | 616 | ); |
| 618 | 617 | } |
| 619 | 618 | } |
@@ -623,7 +622,7 @@ discard block |
||
| 623 | 622 | * |
| 624 | 623 | * @since 1.7 |
| 625 | 624 | */ |
| 626 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
| 625 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
| 627 | 626 | |
| 628 | 627 | return $required_fields; |
| 629 | 628 | |
@@ -638,17 +637,17 @@ discard block |
||
| 638 | 637 | * |
| 639 | 638 | * @return bool |
| 640 | 639 | */ |
| 641 | -function give_require_billing_address( $payment_mode ) { |
|
| 640 | +function give_require_billing_address($payment_mode) { |
|
| 642 | 641 | |
| 643 | 642 | $return = false; |
| 644 | - $billing_country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 643 | + $billing_country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 645 | 644 | |
| 646 | - if ( $billing_country || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
| 645 | + if ($billing_country || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
| 647 | 646 | $return = true; |
| 648 | 647 | } |
| 649 | 648 | |
| 650 | 649 | // Let payment gateways and other extensions determine if address fields should be required. |
| 651 | - return apply_filters( 'give_require_billing_address', $return ); |
|
| 650 | + return apply_filters('give_require_billing_address', $return); |
|
| 652 | 651 | |
| 653 | 652 | } |
| 654 | 653 | |
@@ -662,47 +661,47 @@ discard block |
||
| 662 | 661 | */ |
| 663 | 662 | function give_donation_form_validate_logged_in_user() { |
| 664 | 663 | |
| 665 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 664 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 666 | 665 | $user_id = get_current_user_id(); |
| 667 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; |
|
| 666 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; |
|
| 668 | 667 | |
| 669 | 668 | // Start empty array to collect valid user data. |
| 670 | 669 | $valid_user_data = array( |
| 671 | 670 | |
| 672 | 671 | // Assume there will be errors. |
| 673 | - 'user_id' => - 1, |
|
| 672 | + 'user_id' => -1, |
|
| 674 | 673 | ); |
| 675 | 674 | |
| 676 | 675 | // Proceed on;y, if valid $user_id found. |
| 677 | - if ( $user_id > 0 ) { |
|
| 676 | + if ($user_id > 0) { |
|
| 678 | 677 | |
| 679 | 678 | // Get the logged in user data. |
| 680 | - $user_data = get_userdata( $user_id ); |
|
| 679 | + $user_data = get_userdata($user_id); |
|
| 681 | 680 | |
| 682 | 681 | // Validate Required Form Fields. |
| 683 | - give_validate_required_form_fields( $form_id ); |
|
| 682 | + give_validate_required_form_fields($form_id); |
|
| 684 | 683 | |
| 685 | 684 | // Verify data. |
| 686 | - if ( is_object( $user_data ) && $user_data->ID > 0 ) { |
|
| 685 | + if (is_object($user_data) && $user_data->ID > 0) { |
|
| 687 | 686 | |
| 688 | 687 | // Collected logged in user data. |
| 689 | 688 | $valid_user_data = array( |
| 690 | 689 | 'user_id' => $user_id, |
| 691 | - 'user_email' => ! empty( $post_data['give_email'] ) ? sanitize_email( $post_data['give_email'] ) : $user_data->user_email, |
|
| 692 | - 'user_first' => ! empty( $post_data['give_first'] ) ? $post_data['give_first'] : $user_data->first_name, |
|
| 693 | - 'user_last' => ! empty( $post_data['give_last'] ) ? $post_data['give_last'] : $user_data->last_name, |
|
| 690 | + 'user_email' => ! empty($post_data['give_email']) ? sanitize_email($post_data['give_email']) : $user_data->user_email, |
|
| 691 | + 'user_first' => ! empty($post_data['give_first']) ? $post_data['give_first'] : $user_data->first_name, |
|
| 692 | + 'user_last' => ! empty($post_data['give_last']) ? $post_data['give_last'] : $user_data->last_name, |
|
| 694 | 693 | ); |
| 695 | 694 | |
| 696 | 695 | // Validate essential form fields. |
| 697 | - give_donation_form_validate_name_fields( $post_data ); |
|
| 696 | + give_donation_form_validate_name_fields($post_data); |
|
| 698 | 697 | |
| 699 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
| 700 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
| 698 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
| 699 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
| 701 | 700 | } |
| 702 | 701 | } else { |
| 703 | 702 | |
| 704 | 703 | // Set invalid user information error. |
| 705 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
| 704 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
| 706 | 705 | } |
| 707 | 706 | } |
| 708 | 707 | |
@@ -720,12 +719,12 @@ discard block |
||
| 720 | 719 | */ |
| 721 | 720 | function give_donation_form_validate_new_user() { |
| 722 | 721 | |
| 723 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 724 | - $nonce = ! empty( $post_data['give-form-user-register-hash'] ) ? $post_data['give-form-user-register-hash'] : ''; |
|
| 722 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 723 | + $nonce = ! empty($post_data['give-form-user-register-hash']) ? $post_data['give-form-user-register-hash'] : ''; |
|
| 725 | 724 | |
| 726 | 725 | // Validate user creation nonce. |
| 727 | - if ( ! wp_verify_nonce( $nonce, 'give_form_create_user_nonce' ) ) { |
|
| 728 | - give_set_error( 'invalid_nonce', __( 'Nonce verification has failed.', 'give' ) ); |
|
| 726 | + if ( ! wp_verify_nonce($nonce, 'give_form_create_user_nonce')) { |
|
| 727 | + give_set_error('invalid_nonce', __('Nonce verification has failed.', 'give')); |
|
| 729 | 728 | } |
| 730 | 729 | |
| 731 | 730 | $auto_generated_password = wp_generate_password(); |
@@ -733,7 +732,7 @@ discard block |
||
| 733 | 732 | // Default user data. |
| 734 | 733 | $default_user_data = array( |
| 735 | 734 | 'give-form-id' => '', |
| 736 | - 'user_id' => - 1, // Assume there will be errors. |
|
| 735 | + 'user_id' => -1, // Assume there will be errors. |
|
| 737 | 736 | 'user_first' => '', |
| 738 | 737 | 'user_last' => '', |
| 739 | 738 | 'give_user_login' => false, |
@@ -743,17 +742,17 @@ discard block |
||
| 743 | 742 | ); |
| 744 | 743 | |
| 745 | 744 | // Get user data. |
| 746 | - $user_data = wp_parse_args( $post_data, $default_user_data ); |
|
| 745 | + $user_data = wp_parse_args($post_data, $default_user_data); |
|
| 747 | 746 | $registering_new_user = false; |
| 748 | - $form_id = absint( $user_data['give-form-id'] ); |
|
| 747 | + $form_id = absint($user_data['give-form-id']); |
|
| 749 | 748 | |
| 750 | - give_donation_form_validate_name_fields( $user_data ); |
|
| 749 | + give_donation_form_validate_name_fields($user_data); |
|
| 751 | 750 | |
| 752 | 751 | // Start an empty array to collect valid user data. |
| 753 | 752 | $valid_user_data = array( |
| 754 | 753 | |
| 755 | 754 | // Assume there will be errors. |
| 756 | - 'user_id' => - 1, |
|
| 755 | + 'user_id' => -1, |
|
| 757 | 756 | |
| 758 | 757 | // Get first name. |
| 759 | 758 | 'user_first' => $user_data['give_first'], |
@@ -766,13 +765,13 @@ discard block |
||
| 766 | 765 | ); |
| 767 | 766 | |
| 768 | 767 | // Validate Required Form Fields. |
| 769 | - give_validate_required_form_fields( $form_id ); |
|
| 768 | + give_validate_required_form_fields($form_id); |
|
| 770 | 769 | |
| 771 | 770 | // Set Email as Username. |
| 772 | 771 | $valid_user_data['user_login'] = $user_data['give_email']; |
| 773 | 772 | |
| 774 | 773 | // Check if we have an email to verify. |
| 775 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
| 774 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
| 776 | 775 | $valid_user_data['user_email'] = $user_data['give_email']; |
| 777 | 776 | } |
| 778 | 777 | |
@@ -789,47 +788,47 @@ discard block |
||
| 789 | 788 | */ |
| 790 | 789 | function give_donation_form_validate_user_login() { |
| 791 | 790 | |
| 792 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 791 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 793 | 792 | |
| 794 | 793 | // Start an array to collect valid user data. |
| 795 | 794 | $valid_user_data = array( |
| 796 | 795 | |
| 797 | 796 | // Assume there will be errors. |
| 798 | - 'user_id' => - 1, |
|
| 797 | + 'user_id' => -1, |
|
| 799 | 798 | ); |
| 800 | 799 | |
| 801 | 800 | // Bailout, if Username is empty. |
| 802 | - if ( empty( $post_data['give_user_login'] ) ) { |
|
| 803 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
| 801 | + if (empty($post_data['give_user_login'])) { |
|
| 802 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
| 804 | 803 | |
| 805 | 804 | return $valid_user_data; |
| 806 | 805 | } |
| 807 | 806 | |
| 808 | 807 | // Get the user by login. |
| 809 | - $user_data = get_user_by( 'login', strip_tags( $post_data['give_user_login'] ) ); |
|
| 808 | + $user_data = get_user_by('login', strip_tags($post_data['give_user_login'])); |
|
| 810 | 809 | |
| 811 | 810 | // Check if user exists. |
| 812 | - if ( $user_data ) { |
|
| 811 | + if ($user_data) { |
|
| 813 | 812 | |
| 814 | 813 | // Get password. |
| 815 | - $user_pass = ! empty( $post_data['give_user_pass'] ) ? $post_data['give_user_pass'] : false; |
|
| 814 | + $user_pass = ! empty($post_data['give_user_pass']) ? $post_data['give_user_pass'] : false; |
|
| 816 | 815 | |
| 817 | 816 | // Check user_pass. |
| 818 | - if ( $user_pass ) { |
|
| 817 | + if ($user_pass) { |
|
| 819 | 818 | |
| 820 | 819 | // Check if password is valid. |
| 821 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
| 820 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
| 822 | 821 | |
| 823 | - $current_page_url = site_url() . '/' . get_page_uri(); |
|
| 822 | + $current_page_url = site_url().'/'.get_page_uri(); |
|
| 824 | 823 | |
| 825 | 824 | // Incorrect password. |
| 826 | 825 | give_set_error( |
| 827 | 826 | 'password_incorrect', |
| 828 | 827 | sprintf( |
| 829 | 828 | '%1$s <a href="%2$s">%3$s</a>', |
| 830 | - __( 'The password you entered is incorrect.', 'give' ), |
|
| 831 | - wp_lostpassword_url( $current_page_url ), |
|
| 832 | - __( 'Reset Password', 'give' ) |
|
| 829 | + __('The password you entered is incorrect.', 'give'), |
|
| 830 | + wp_lostpassword_url($current_page_url), |
|
| 831 | + __('Reset Password', 'give') |
|
| 833 | 832 | ) |
| 834 | 833 | ); |
| 835 | 834 | |
@@ -847,11 +846,11 @@ discard block |
||
| 847 | 846 | } |
| 848 | 847 | } else { |
| 849 | 848 | // Empty password. |
| 850 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
| 849 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
| 851 | 850 | } |
| 852 | 851 | } else { |
| 853 | 852 | // No username. |
| 854 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
| 853 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
| 855 | 854 | } // End if(). |
| 856 | 855 | |
| 857 | 856 | return $valid_user_data; |
@@ -867,8 +866,8 @@ discard block |
||
| 867 | 866 | */ |
| 868 | 867 | function give_donation_form_validate_guest_user() { |
| 869 | 868 | |
| 870 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 871 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; |
|
| 869 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 870 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; |
|
| 872 | 871 | |
| 873 | 872 | // Start an array to collect valid user data. |
| 874 | 873 | $valid_user_data = array( |
@@ -877,22 +876,22 @@ discard block |
||
| 877 | 876 | ); |
| 878 | 877 | |
| 879 | 878 | // Validate name fields. |
| 880 | - give_donation_form_validate_name_fields( $post_data ); |
|
| 879 | + give_donation_form_validate_name_fields($post_data); |
|
| 881 | 880 | |
| 882 | 881 | // Validate Required Form Fields. |
| 883 | - give_validate_required_form_fields( $form_id ); |
|
| 882 | + give_validate_required_form_fields($form_id); |
|
| 884 | 883 | |
| 885 | 884 | // Get the guest email. |
| 886 | - $guest_email = ! empty( $post_data['give_email'] ) ? $post_data['give_email'] : false; |
|
| 885 | + $guest_email = ! empty($post_data['give_email']) ? $post_data['give_email'] : false; |
|
| 887 | 886 | |
| 888 | 887 | // Check email. |
| 889 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
| 888 | + if ($guest_email && strlen($guest_email) > 0) { |
|
| 890 | 889 | |
| 891 | 890 | // Validate email. |
| 892 | - if ( ! is_email( $guest_email ) ) { |
|
| 891 | + if ( ! is_email($guest_email)) { |
|
| 893 | 892 | |
| 894 | 893 | // Invalid email. |
| 895 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
| 894 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
| 896 | 895 | |
| 897 | 896 | } else { |
| 898 | 897 | |
@@ -900,15 +899,15 @@ discard block |
||
| 900 | 899 | $valid_user_data['user_email'] = $guest_email; |
| 901 | 900 | |
| 902 | 901 | // Get user_id from donor if exist. |
| 903 | - $donor = new Give_Donor( $guest_email ); |
|
| 902 | + $donor = new Give_Donor($guest_email); |
|
| 904 | 903 | |
| 905 | - if ( $donor->id && $donor->user_id ) { |
|
| 904 | + if ($donor->id && $donor->user_id) { |
|
| 906 | 905 | $valid_user_data['user_id'] = $donor->user_id; |
| 907 | 906 | } |
| 908 | 907 | } |
| 909 | 908 | } else { |
| 910 | 909 | // No email. |
| 911 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
| 910 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
| 912 | 911 | } |
| 913 | 912 | |
| 914 | 913 | return $valid_user_data; |
@@ -924,36 +923,36 @@ discard block |
||
| 924 | 923 | * |
| 925 | 924 | * @return integer |
| 926 | 925 | */ |
| 927 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
| 926 | +function give_register_and_login_new_user($user_data = array()) { |
|
| 928 | 927 | // Verify the array. |
| 929 | - if ( empty( $user_data ) ) { |
|
| 930 | - return - 1; |
|
| 928 | + if (empty($user_data)) { |
|
| 929 | + return -1; |
|
| 931 | 930 | } |
| 932 | 931 | |
| 933 | - if ( give_get_errors() ) { |
|
| 934 | - return - 1; |
|
| 932 | + if (give_get_errors()) { |
|
| 933 | + return -1; |
|
| 935 | 934 | } |
| 936 | 935 | |
| 937 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
| 938 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
| 939 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
| 940 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
| 941 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
| 942 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
| 943 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 944 | - 'role' => give_get_option( 'donor_default_user_role', 'give_donor' ), |
|
| 945 | - ), $user_data ); |
|
| 936 | + $user_args = apply_filters('give_insert_user_args', array( |
|
| 937 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
| 938 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
| 939 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
| 940 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
| 941 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
| 942 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 943 | + 'role' => give_get_option('donor_default_user_role', 'give_donor'), |
|
| 944 | + ), $user_data); |
|
| 946 | 945 | |
| 947 | 946 | // Insert new user. |
| 948 | - $user_id = wp_insert_user( $user_args ); |
|
| 947 | + $user_id = wp_insert_user($user_args); |
|
| 949 | 948 | |
| 950 | 949 | // Validate inserted user. |
| 951 | - if ( is_wp_error( $user_id ) ) { |
|
| 952 | - return - 1; |
|
| 950 | + if (is_wp_error($user_id)) { |
|
| 951 | + return -1; |
|
| 953 | 952 | } |
| 954 | 953 | |
| 955 | 954 | // Allow themes and plugins to filter the user data. |
| 956 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
| 955 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
| 957 | 956 | |
| 958 | 957 | /** |
| 959 | 958 | * Fires after inserting user. |
@@ -963,7 +962,7 @@ discard block |
||
| 963 | 962 | * @param int $user_id User id. |
| 964 | 963 | * @param array $user_data Array containing user data. |
| 965 | 964 | */ |
| 966 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
| 965 | + do_action('give_insert_user', $user_id, $user_data); |
|
| 967 | 966 | |
| 968 | 967 | /** |
| 969 | 968 | * Filter allow user to alter if user when to login or not when user is register for the first time. |
@@ -972,9 +971,9 @@ discard block |
||
| 972 | 971 | * |
| 973 | 972 | * return bool True if login with registration and False if only want to register. |
| 974 | 973 | */ |
| 975 | - if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) { |
|
| 974 | + if (true === (bool) apply_filters('give_log_user_in_on_register', true)) { |
|
| 976 | 975 | // Login new user. |
| 977 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
| 976 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
| 978 | 977 | } |
| 979 | 978 | |
| 980 | 979 | // Return user id. |
@@ -991,33 +990,33 @@ discard block |
||
| 991 | 990 | * |
| 992 | 991 | * @return array|bool |
| 993 | 992 | */ |
| 994 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
| 993 | +function give_get_donation_form_user($valid_data = array()) { |
|
| 995 | 994 | |
| 996 | 995 | // Initialize user. |
| 997 | 996 | $user = false; |
| 998 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
| 999 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 997 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
| 998 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 1000 | 999 | |
| 1001 | - if ( $is_ajax ) { |
|
| 1000 | + if ($is_ajax) { |
|
| 1002 | 1001 | |
| 1003 | 1002 | // Do not create or login the user during the ajax submission (check for errors only). |
| 1004 | 1003 | return true; |
| 1005 | - } elseif ( is_user_logged_in() ) { |
|
| 1004 | + } elseif (is_user_logged_in()) { |
|
| 1006 | 1005 | |
| 1007 | 1006 | // Set the valid user as the logged in collected data. |
| 1008 | 1007 | $user = $valid_data['logged_in_user']; |
| 1009 | - } elseif ( true === $valid_data['need_new_user'] || true === $valid_data['need_user_login'] ) { |
|
| 1008 | + } elseif (true === $valid_data['need_new_user'] || true === $valid_data['need_user_login']) { |
|
| 1010 | 1009 | |
| 1011 | 1010 | // New user registration. |
| 1012 | - if ( true === $valid_data['need_new_user'] ) { |
|
| 1011 | + if (true === $valid_data['need_new_user']) { |
|
| 1013 | 1012 | |
| 1014 | 1013 | // Set user. |
| 1015 | 1014 | $user = $valid_data['new_user_data']; |
| 1016 | 1015 | |
| 1017 | 1016 | // Register and login new user. |
| 1018 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
| 1017 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
| 1019 | 1018 | |
| 1020 | - } elseif ( true === $valid_data['need_user_login'] && ! $is_ajax ) { |
|
| 1019 | + } elseif (true === $valid_data['need_user_login'] && ! $is_ajax) { |
|
| 1021 | 1020 | |
| 1022 | 1021 | /** |
| 1023 | 1022 | * The login form is now processed in the give_process_donation_login() function. |
@@ -1029,42 +1028,42 @@ discard block |
||
| 1029 | 1028 | $user = $valid_data['login_user_data']; |
| 1030 | 1029 | |
| 1031 | 1030 | // Login user. |
| 1032 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
| 1031 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
| 1033 | 1032 | } |
| 1034 | 1033 | } // End if(). |
| 1035 | 1034 | |
| 1036 | 1035 | // Check guest checkout. |
| 1037 | - if ( false === $user && false === give_logged_in_only( $post_data['give-form-id'] ) ) { |
|
| 1036 | + if (false === $user && false === give_logged_in_only($post_data['give-form-id'])) { |
|
| 1038 | 1037 | |
| 1039 | 1038 | // Set user. |
| 1040 | 1039 | $user = $valid_data['guest_user_data']; |
| 1041 | 1040 | } |
| 1042 | 1041 | |
| 1043 | 1042 | // Verify we have an user. |
| 1044 | - if ( false === $user || empty( $user ) ) { |
|
| 1043 | + if (false === $user || empty($user)) { |
|
| 1045 | 1044 | return false; |
| 1046 | 1045 | } |
| 1047 | 1046 | |
| 1048 | 1047 | // Get user first name. |
| 1049 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
| 1050 | - $user['user_first'] = isset( $post_data['give_first'] ) ? strip_tags( trim( $post_data['give_first'] ) ) : ''; |
|
| 1048 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
| 1049 | + $user['user_first'] = isset($post_data['give_first']) ? strip_tags(trim($post_data['give_first'])) : ''; |
|
| 1051 | 1050 | } |
| 1052 | 1051 | |
| 1053 | 1052 | // Get user last name. |
| 1054 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
| 1055 | - $user['user_last'] = isset( $post_data['give_last'] ) ? strip_tags( trim( $post_data['give_last'] ) ) : ''; |
|
| 1053 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
| 1054 | + $user['user_last'] = isset($post_data['give_last']) ? strip_tags(trim($post_data['give_last'])) : ''; |
|
| 1056 | 1055 | } |
| 1057 | 1056 | |
| 1058 | 1057 | // Get the user's billing address details. |
| 1059 | 1058 | $user['address'] = array(); |
| 1060 | - $user['address']['line1'] = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : false; |
|
| 1061 | - $user['address']['line2'] = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : false; |
|
| 1062 | - $user['address']['city'] = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : false; |
|
| 1063 | - $user['address']['state'] = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : false; |
|
| 1064 | - $user['address']['zip'] = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : false; |
|
| 1065 | - $user['address']['country'] = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : false; |
|
| 1066 | - |
|
| 1067 | - if ( empty( $user['address']['country'] ) ) { |
|
| 1059 | + $user['address']['line1'] = ! empty($post_data['card_address']) ? $post_data['card_address'] : false; |
|
| 1060 | + $user['address']['line2'] = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : false; |
|
| 1061 | + $user['address']['city'] = ! empty($post_data['card_city']) ? $post_data['card_city'] : false; |
|
| 1062 | + $user['address']['state'] = ! empty($post_data['card_state']) ? $post_data['card_state'] : false; |
|
| 1063 | + $user['address']['zip'] = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : false; |
|
| 1064 | + $user['address']['country'] = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : false; |
|
| 1065 | + |
|
| 1066 | + if (empty($user['address']['country'])) { |
|
| 1068 | 1067 | $user['address'] = false; |
| 1069 | 1068 | } // End if(). |
| 1070 | 1069 | |
@@ -1085,16 +1084,16 @@ discard block |
||
| 1085 | 1084 | $card_data = give_get_donation_cc_info(); |
| 1086 | 1085 | |
| 1087 | 1086 | // Validate the card zip. |
| 1088 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
| 1089 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
| 1090 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
| 1087 | + if ( ! empty($card_data['card_zip'])) { |
|
| 1088 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
| 1089 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
| 1091 | 1090 | } |
| 1092 | 1091 | } |
| 1093 | 1092 | |
| 1094 | 1093 | // Ensure no spaces. |
| 1095 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
| 1096 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs. |
|
| 1097 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces. |
|
| 1094 | + if ( ! empty($card_data['card_number'])) { |
|
| 1095 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs. |
|
| 1096 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces. |
|
| 1098 | 1097 | } |
| 1099 | 1098 | |
| 1100 | 1099 | // This should validate card numbers at some point too. |
@@ -1112,20 +1111,20 @@ discard block |
||
| 1112 | 1111 | function give_get_donation_cc_info() { |
| 1113 | 1112 | |
| 1114 | 1113 | // Sanitize the values submitted with donation form. |
| 1115 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 1114 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 1116 | 1115 | |
| 1117 | 1116 | $cc_info = array(); |
| 1118 | - $cc_info['card_name'] = ! empty( $post_data['card_name'] ) ? $post_data['card_name'] : ''; |
|
| 1119 | - $cc_info['card_number'] = ! empty( $post_data['card_number'] ) ? $post_data['card_number'] : ''; |
|
| 1120 | - $cc_info['card_cvc'] = ! empty( $post_data['card_cvc'] ) ? $post_data['card_cvc'] : ''; |
|
| 1121 | - $cc_info['card_exp_month'] = ! empty( $post_data['card_exp_month'] ) ? $post_data['card_exp_month'] : ''; |
|
| 1122 | - $cc_info['card_exp_year'] = ! empty( $post_data['card_exp_year'] ) ? $post_data['card_exp_year'] : ''; |
|
| 1123 | - $cc_info['card_address'] = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : ''; |
|
| 1124 | - $cc_info['card_address_2'] = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : ''; |
|
| 1125 | - $cc_info['card_city'] = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : ''; |
|
| 1126 | - $cc_info['card_state'] = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : ''; |
|
| 1127 | - $cc_info['card_country'] = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : ''; |
|
| 1128 | - $cc_info['card_zip'] = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : ''; |
|
| 1117 | + $cc_info['card_name'] = ! empty($post_data['card_name']) ? $post_data['card_name'] : ''; |
|
| 1118 | + $cc_info['card_number'] = ! empty($post_data['card_number']) ? $post_data['card_number'] : ''; |
|
| 1119 | + $cc_info['card_cvc'] = ! empty($post_data['card_cvc']) ? $post_data['card_cvc'] : ''; |
|
| 1120 | + $cc_info['card_exp_month'] = ! empty($post_data['card_exp_month']) ? $post_data['card_exp_month'] : ''; |
|
| 1121 | + $cc_info['card_exp_year'] = ! empty($post_data['card_exp_year']) ? $post_data['card_exp_year'] : ''; |
|
| 1122 | + $cc_info['card_address'] = ! empty($post_data['card_address']) ? $post_data['card_address'] : ''; |
|
| 1123 | + $cc_info['card_address_2'] = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : ''; |
|
| 1124 | + $cc_info['card_city'] = ! empty($post_data['card_city']) ? $post_data['card_city'] : ''; |
|
| 1125 | + $cc_info['card_state'] = ! empty($post_data['card_state']) ? $post_data['card_state'] : ''; |
|
| 1126 | + $cc_info['card_country'] = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : ''; |
|
| 1127 | + $cc_info['card_zip'] = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : ''; |
|
| 1129 | 1128 | |
| 1130 | 1129 | // Return cc info. |
| 1131 | 1130 | return $cc_info; |
@@ -1141,14 +1140,14 @@ discard block |
||
| 1141 | 1140 | * |
| 1142 | 1141 | * @return bool|mixed |
| 1143 | 1142 | */ |
| 1144 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
| 1143 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
| 1145 | 1144 | $ret = false; |
| 1146 | 1145 | |
| 1147 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
| 1146 | + if (empty($zip) || empty($country_code)) { |
|
| 1148 | 1147 | return $ret; |
| 1149 | 1148 | } |
| 1150 | 1149 | |
| 1151 | - $country_code = strtoupper( $country_code ); |
|
| 1150 | + $country_code = strtoupper($country_code); |
|
| 1152 | 1151 | |
| 1153 | 1152 | $zip_regex = array( |
| 1154 | 1153 | 'AD' => 'AD\d{3}', |
@@ -1308,11 +1307,11 @@ discard block |
||
| 1308 | 1307 | 'ZM' => '\d{5}', |
| 1309 | 1308 | ); |
| 1310 | 1309 | |
| 1311 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
| 1310 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
| 1312 | 1311 | $ret = true; |
| 1313 | 1312 | } |
| 1314 | 1313 | |
| 1315 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
| 1314 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
| 1316 | 1315 | } |
| 1317 | 1316 | |
| 1318 | 1317 | /** |
@@ -1324,60 +1323,60 @@ discard block |
||
| 1324 | 1323 | * |
| 1325 | 1324 | * @return bool |
| 1326 | 1325 | */ |
| 1327 | -function give_validate_donation_amount( $valid_data ) { |
|
| 1326 | +function give_validate_donation_amount($valid_data) { |
|
| 1328 | 1327 | |
| 1329 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 1328 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 1330 | 1329 | |
| 1331 | 1330 | /* @var Give_Donate_Form $form */ |
| 1332 | - $form = new Give_Donate_Form( $post_data['give-form-id'] ); |
|
| 1331 | + $form = new Give_Donate_Form($post_data['give-form-id']); |
|
| 1333 | 1332 | |
| 1334 | 1333 | // Get the form currency. |
| 1335 | - $form_currency = give_get_currency( $post_data['give-form-id'] ); |
|
| 1334 | + $form_currency = give_get_currency($post_data['give-form-id']); |
|
| 1336 | 1335 | |
| 1337 | 1336 | $donation_level_matched = false; |
| 1338 | 1337 | |
| 1339 | - if ( $form->is_set_type_donation_form() ) { |
|
| 1338 | + if ($form->is_set_type_donation_form()) { |
|
| 1340 | 1339 | |
| 1341 | 1340 | // Sanitize donation amount. |
| 1342 | - $post_data['give-amount'] = give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => $form_currency ) ); |
|
| 1341 | + $post_data['give-amount'] = give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => $form_currency)); |
|
| 1343 | 1342 | |
| 1344 | 1343 | // Backward compatibility. |
| 1345 | - if ( $form->is_custom_price( $post_data['give-amount'] ) ) { |
|
| 1344 | + if ($form->is_custom_price($post_data['give-amount'])) { |
|
| 1346 | 1345 | $post_data['give-price-id'] = 'custom'; |
| 1347 | 1346 | } |
| 1348 | 1347 | |
| 1349 | 1348 | $donation_level_matched = true; |
| 1350 | 1349 | |
| 1351 | - } elseif ( $form->is_multi_type_donation_form() ) { |
|
| 1350 | + } elseif ($form->is_multi_type_donation_form()) { |
|
| 1352 | 1351 | |
| 1353 | 1352 | $variable_prices = $form->get_prices(); |
| 1354 | 1353 | |
| 1355 | 1354 | // Bailout. |
| 1356 | - if ( ! $variable_prices ) { |
|
| 1355 | + if ( ! $variable_prices) { |
|
| 1357 | 1356 | return false; |
| 1358 | 1357 | } |
| 1359 | 1358 | |
| 1360 | 1359 | // Sanitize donation amount. |
| 1361 | - $post_data['give-amount'] = give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => $form_currency ) ); |
|
| 1362 | - $variable_price_option_amount = give_maybe_sanitize_amount( give_get_price_option_amount( $post_data['give-form-id'], $post_data['give-price-id'] ), array( 'currency' => $form_currency ) ); |
|
| 1360 | + $post_data['give-amount'] = give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => $form_currency)); |
|
| 1361 | + $variable_price_option_amount = give_maybe_sanitize_amount(give_get_price_option_amount($post_data['give-form-id'], $post_data['give-price-id']), array('currency' => $form_currency)); |
|
| 1363 | 1362 | $new_price_id = ''; |
| 1364 | 1363 | |
| 1365 | - if ( $post_data['give-amount'] === $variable_price_option_amount ) { |
|
| 1364 | + if ($post_data['give-amount'] === $variable_price_option_amount) { |
|
| 1366 | 1365 | return true; |
| 1367 | 1366 | } |
| 1368 | 1367 | |
| 1369 | - if ( $form->is_custom_price( $post_data['give-amount'] ) ) { |
|
| 1368 | + if ($form->is_custom_price($post_data['give-amount'])) { |
|
| 1370 | 1369 | $new_price_id = 'custom'; |
| 1371 | 1370 | } else { |
| 1372 | 1371 | |
| 1373 | 1372 | // Find correct donation level from all donation levels. |
| 1374 | - foreach ( $variable_prices as $variable_price ) { |
|
| 1373 | + foreach ($variable_prices as $variable_price) { |
|
| 1375 | 1374 | |
| 1376 | 1375 | // Sanitize level amount. |
| 1377 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); |
|
| 1376 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); |
|
| 1378 | 1377 | |
| 1379 | 1378 | // Set first match donation level ID. |
| 1380 | - if ( $post_data['give-amount'] === $variable_price['_give_amount'] ) { |
|
| 1379 | + if ($post_data['give-amount'] === $variable_price['_give_amount']) { |
|
| 1381 | 1380 | $new_price_id = $variable_price['_give_id']['level_id']; |
| 1382 | 1381 | break; |
| 1383 | 1382 | } |
@@ -1386,26 +1385,26 @@ discard block |
||
| 1386 | 1385 | |
| 1387 | 1386 | // If donation amount is not find in donation levels then check if form has custom donation feature enable or not. |
| 1388 | 1387 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
| 1389 | - if ( $post_data['give-price-id'] === $new_price_id ) { |
|
| 1388 | + if ($post_data['give-price-id'] === $new_price_id) { |
|
| 1390 | 1389 | $donation_level_matched = true; |
| 1391 | 1390 | } |
| 1392 | 1391 | } // End if(). |
| 1393 | 1392 | |
| 1394 | - if ( ! $donation_level_matched ) { |
|
| 1393 | + if ( ! $donation_level_matched) { |
|
| 1395 | 1394 | give_set_error( |
| 1396 | 1395 | 'invalid_donation_amount', |
| 1397 | 1396 | sprintf( |
| 1398 | 1397 | /* translators: %s: invalid donation amount */ |
| 1399 | - __( 'Donation amount %s is invalid.', 'give' ), |
|
| 1398 | + __('Donation amount %s is invalid.', 'give'), |
|
| 1400 | 1399 | give_currency_filter( |
| 1401 | - give_format_amount( $post_data['give-amount'], array( 'sanitize' => false, ) ) |
|
| 1400 | + give_format_amount($post_data['give-amount'], array('sanitize' => false,)) |
|
| 1402 | 1401 | ) |
| 1403 | 1402 | ) |
| 1404 | 1403 | ); |
| 1405 | 1404 | } |
| 1406 | 1405 | } |
| 1407 | 1406 | |
| 1408 | -add_action( 'give_checkout_error_checks', 'give_validate_donation_amount', 10, 1 ); |
|
| 1407 | +add_action('give_checkout_error_checks', 'give_validate_donation_amount', 10, 1); |
|
| 1409 | 1408 | |
| 1410 | 1409 | /** |
| 1411 | 1410 | * Validate Required Form Fields. |
@@ -1414,20 +1413,20 @@ discard block |
||
| 1414 | 1413 | * |
| 1415 | 1414 | * @since 2.0 |
| 1416 | 1415 | */ |
| 1417 | -function give_validate_required_form_fields( $form_id ) { |
|
| 1416 | +function give_validate_required_form_fields($form_id) { |
|
| 1418 | 1417 | |
| 1419 | 1418 | // Sanitize values submitted with donation form. |
| 1420 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 1419 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 1421 | 1420 | |
| 1422 | 1421 | // Loop through required fields and show error messages. |
| 1423 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
| 1422 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
| 1424 | 1423 | |
| 1425 | 1424 | // Clean Up Data of the input fields. |
| 1426 | - $field_value = $post_data[ $field_name ]; |
|
| 1425 | + $field_value = $post_data[$field_name]; |
|
| 1427 | 1426 | |
| 1428 | 1427 | // Check whether the required field is empty, then show the error message. |
| 1429 | - if ( in_array( $value, give_get_required_fields( $form_id ), true ) && empty( $field_value ) ) { |
|
| 1430 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 1428 | + if (in_array($value, give_get_required_fields($form_id), true) && empty($field_value)) { |
|
| 1429 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 1431 | 1430 | } |
| 1432 | 1431 | } |
| 1433 | 1432 | } |
@@ -1441,12 +1440,12 @@ discard block |
||
| 1441 | 1440 | * |
| 1442 | 1441 | * @return void |
| 1443 | 1442 | */ |
| 1444 | -function give_donation_form_validate_name_fields( $post_data ) { |
|
| 1443 | +function give_donation_form_validate_name_fields($post_data) { |
|
| 1445 | 1444 | |
| 1446 | - $is_alpha_first_name = ( ! is_email( $post_data['give_first'] ) && ! preg_match( '~[0-9]~', $post_data['give_first'] ) ); |
|
| 1447 | - $is_alpha_last_name = ( ! is_email( $post_data['give_last'] ) && ! preg_match( '~[0-9]~', $post_data['give_last'] ) ); |
|
| 1445 | + $is_alpha_first_name = ( ! is_email($post_data['give_first']) && ! preg_match('~[0-9]~', $post_data['give_first'])); |
|
| 1446 | + $is_alpha_last_name = ( ! is_email($post_data['give_last']) && ! preg_match('~[0-9]~', $post_data['give_last'])); |
|
| 1448 | 1447 | |
| 1449 | - if ( ! $is_alpha_first_name || ( ! empty( $post_data['give_last'] ) && ! $is_alpha_last_name ) ) { |
|
| 1450 | - give_set_error( 'invalid_name', esc_html__( 'The First Name and Last Name fields cannot contain an email address or numbers.', 'give' ) ); |
|
| 1448 | + if ( ! $is_alpha_first_name || ( ! empty($post_data['give_last']) && ! $is_alpha_last_name)) { |
|
| 1449 | + give_set_error('invalid_name', esc_html__('The First Name and Last Name fields cannot contain an email address or numbers.', 'give')); |
|
| 1451 | 1450 | } |
| 1452 | 1451 | } |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | |
| 41 | 41 | // Exit if accessed directly. |
| 42 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 42 | +if ( ! defined('ABSPATH')) { |
|
| 43 | 43 | exit; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | -if ( ! class_exists( 'Give' ) ) : |
|
| 46 | +if ( ! class_exists('Give')) : |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Main Give Class |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @return Give |
| 262 | 262 | */ |
| 263 | 263 | public static function instance() { |
| 264 | - if ( is_null( self::$_instance ) ) { |
|
| 264 | + if (is_null(self::$_instance)) { |
|
| 265 | 265 | self::$_instance = new self(); |
| 266 | 266 | } |
| 267 | 267 | |
@@ -273,13 +273,13 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | public function __construct() { |
| 275 | 275 | // PHP version |
| 276 | - if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) { |
|
| 277 | - define( 'GIVE_REQUIRED_PHP_VERSION', '5.3' ); |
|
| 276 | + if ( ! defined('GIVE_REQUIRED_PHP_VERSION')) { |
|
| 277 | + define('GIVE_REQUIRED_PHP_VERSION', '5.3'); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // Bailout: Need minimum php version to load plugin. |
| 281 | - if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) { |
|
| 282 | - add_action( 'admin_notices', array( $this, 'minimum_phpversion_notice' ) ); |
|
| 281 | + if (function_exists('phpversion') && version_compare(GIVE_REQUIRED_PHP_VERSION, phpversion(), '>')) { |
|
| 282 | + add_action('admin_notices', array($this, 'minimum_phpversion_notice')); |
|
| 283 | 283 | |
| 284 | 284 | return; |
| 285 | 285 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | $this->includes(); |
| 289 | 289 | $this->init_hooks(); |
| 290 | 290 | |
| 291 | - do_action( 'give_loaded' ); |
|
| 291 | + do_action('give_loaded'); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -297,11 +297,11 @@ discard block |
||
| 297 | 297 | * @since 1.8.9 |
| 298 | 298 | */ |
| 299 | 299 | private function init_hooks() { |
| 300 | - register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
| 301 | - add_action( 'plugins_loaded', array( $this, 'init' ), 0 ); |
|
| 300 | + register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
| 301 | + add_action('plugins_loaded', array($this, 'init'), 0); |
|
| 302 | 302 | |
| 303 | 303 | // Set up localization on init Hook. |
| 304 | - add_action( 'init', array( $this, 'load_textdomain' ), 0 ); |
|
| 304 | + add_action('init', array($this, 'load_textdomain'), 0); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * |
| 318 | 318 | * @since 1.8.9 |
| 319 | 319 | */ |
| 320 | - do_action( 'before_give_init' ); |
|
| 320 | + do_action('before_give_init'); |
|
| 321 | 321 | |
| 322 | 322 | // Set up localization. |
| 323 | 323 | $this->load_textdomain(); |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * |
| 351 | 351 | * @since 1.8.7 |
| 352 | 352 | */ |
| 353 | - do_action( 'give_init', $this ); |
|
| 353 | + do_action('give_init', $this); |
|
| 354 | 354 | |
| 355 | 355 | } |
| 356 | 356 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | */ |
| 368 | 368 | public function __clone() { |
| 369 | 369 | // Cloning instances of the class is forbidden. |
| 370 | - give_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
| 370 | + give_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | */ |
| 381 | 381 | public function __wakeup() { |
| 382 | 382 | // Unserializing instances of the class is forbidden. |
| 383 | - give_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
| 383 | + give_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -394,33 +394,33 @@ discard block |
||
| 394 | 394 | private function setup_constants() { |
| 395 | 395 | |
| 396 | 396 | // Plugin version |
| 397 | - if ( ! defined( 'GIVE_VERSION' ) ) { |
|
| 398 | - define( 'GIVE_VERSION', '2.1.7' ); |
|
| 397 | + if ( ! defined('GIVE_VERSION')) { |
|
| 398 | + define('GIVE_VERSION', '2.1.7'); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | // Plugin Root File |
| 402 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) { |
|
| 403 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); |
|
| 402 | + if ( ! defined('GIVE_PLUGIN_FILE')) { |
|
| 403 | + define('GIVE_PLUGIN_FILE', __FILE__); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | // Plugin Folder Path |
| 407 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) { |
|
| 408 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( GIVE_PLUGIN_FILE ) ); |
|
| 407 | + if ( ! defined('GIVE_PLUGIN_DIR')) { |
|
| 408 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(GIVE_PLUGIN_FILE)); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | // Plugin Folder URL |
| 412 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) { |
|
| 413 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( GIVE_PLUGIN_FILE ) ); |
|
| 412 | + if ( ! defined('GIVE_PLUGIN_URL')) { |
|
| 413 | + define('GIVE_PLUGIN_URL', plugin_dir_url(GIVE_PLUGIN_FILE)); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | // Plugin Basename aka: "give/give.php" |
| 417 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) { |
|
| 418 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( GIVE_PLUGIN_FILE ) ); |
|
| 417 | + if ( ! defined('GIVE_PLUGIN_BASENAME')) { |
|
| 418 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(GIVE_PLUGIN_FILE)); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | // Make sure CAL_GREGORIAN is defined |
| 422 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
| 423 | - define( 'CAL_GREGORIAN', 1 ); |
|
| 422 | + if ( ! defined('CAL_GREGORIAN')) { |
|
| 423 | + define('CAL_GREGORIAN', 1); |
|
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
@@ -438,161 +438,161 @@ discard block |
||
| 438 | 438 | /** |
| 439 | 439 | * Load libraries. |
| 440 | 440 | */ |
| 441 | - if ( ! class_exists( 'WP_Async_Request' ) ) { |
|
| 442 | - include_once( GIVE_PLUGIN_DIR . 'includes/libraries/wp-async-request.php' ); |
|
| 441 | + if ( ! class_exists('WP_Async_Request')) { |
|
| 442 | + include_once(GIVE_PLUGIN_DIR.'includes/libraries/wp-async-request.php'); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if ( ! class_exists( 'WP_Background_Process' ) ) { |
|
| 446 | - include_once( GIVE_PLUGIN_DIR . 'includes/libraries/wp-background-process.php' ); |
|
| 445 | + if ( ! class_exists('WP_Background_Process')) { |
|
| 446 | + include_once(GIVE_PLUGIN_DIR.'includes/libraries/wp-background-process.php'); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /** |
| 450 | 450 | * Load plugin files |
| 451 | 451 | */ |
| 452 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php'; |
|
| 453 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; |
|
| 452 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php'; |
|
| 453 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php'; |
|
| 454 | 454 | $give_options = give_get_settings(); |
| 455 | 455 | |
| 456 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; |
|
| 457 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-async-process.php'; |
|
| 458 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php'; |
|
| 459 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php'; |
|
| 460 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; |
|
| 461 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; |
|
| 462 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; |
|
| 463 | - require_once GIVE_PLUGIN_DIR . 'includes/filters.php'; |
|
| 464 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; |
|
| 465 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-v2.php'; |
|
| 466 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-tooltips.php'; |
|
| 467 | - require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php'; |
|
| 468 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-translation.php'; |
|
| 469 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-readme-parser.php'; |
|
| 470 | - |
|
| 471 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-scripts.php'; |
|
| 472 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; |
|
| 473 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; |
|
| 474 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; |
|
| 475 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; |
|
| 476 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-meta.php'; |
|
| 477 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donors.php'; |
|
| 478 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donor-meta.php'; |
|
| 479 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php'; |
|
| 480 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; |
|
| 481 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; |
|
| 482 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; |
|
| 483 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; |
|
| 484 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; |
|
| 485 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; |
|
| 486 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-payment-meta.php'; |
|
| 487 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-form-meta.php'; |
|
| 488 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-sequential-ordering.php'; |
|
| 489 | - |
|
| 490 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; |
|
| 491 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; |
|
| 492 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; |
|
| 493 | - require_once GIVE_PLUGIN_DIR . 'includes/import-functions.php'; |
|
| 494 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; |
|
| 495 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; |
|
| 496 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; |
|
| 497 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; |
|
| 498 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; |
|
| 499 | - require_once GIVE_PLUGIN_DIR . 'includes/currency-functions.php'; |
|
| 500 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; |
|
| 501 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; |
|
| 502 | - require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php'; |
|
| 503 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; |
|
| 504 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; |
|
| 505 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; |
|
| 506 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php'; |
|
| 507 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php'; |
|
| 508 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php'; |
|
| 509 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php'; |
|
| 510 | - |
|
| 511 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/backward-compatibility.php'; |
|
| 512 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; |
|
| 513 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; |
|
| 514 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; |
|
| 515 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; |
|
| 516 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; |
|
| 517 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-sequential-donation-number.php'; |
|
| 518 | - |
|
| 519 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; |
|
| 520 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; |
|
| 521 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; |
|
| 522 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; |
|
| 523 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; |
|
| 524 | - |
|
| 525 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; |
|
| 526 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; |
|
| 527 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-notifications.php'; |
|
| 528 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; |
|
| 529 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
|
| 530 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
|
| 531 | - |
|
| 532 | - require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donors-query.php'; |
|
| 533 | - require_once GIVE_PLUGIN_DIR . 'includes/donors/backward-compatibility.php'; |
|
| 534 | - |
|
| 535 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/class-give-updates.php'; |
|
| 536 | - |
|
| 537 | - require_once GIVE_PLUGIN_DIR . 'blocks/load.php'; |
|
| 538 | - |
|
| 539 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 540 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
| 456 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php'; |
|
| 457 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-async-process.php'; |
|
| 458 | + require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php'; |
|
| 459 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cache.php'; |
|
| 460 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php'; |
|
| 461 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php'; |
|
| 462 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php'; |
|
| 463 | + require_once GIVE_PLUGIN_DIR.'includes/filters.php'; |
|
| 464 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php'; |
|
| 465 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-v2.php'; |
|
| 466 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-tooltips.php'; |
|
| 467 | + require_once GIVE_PLUGIN_DIR.'includes/class-notices.php'; |
|
| 468 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-translation.php'; |
|
| 469 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-readme-parser.php'; |
|
| 470 | + |
|
| 471 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-scripts.php'; |
|
| 472 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php'; |
|
| 473 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php'; |
|
| 474 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php'; |
|
| 475 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php'; |
|
| 476 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-meta.php'; |
|
| 477 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donors.php'; |
|
| 478 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donor-meta.php'; |
|
| 479 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donor.php'; |
|
| 480 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php'; |
|
| 481 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php'; |
|
| 482 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php'; |
|
| 483 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php'; |
|
| 484 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php'; |
|
| 485 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php'; |
|
| 486 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-payment-meta.php'; |
|
| 487 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-form-meta.php'; |
|
| 488 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-sequential-ordering.php'; |
|
| 489 | + |
|
| 490 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php'; |
|
| 491 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php'; |
|
| 492 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php'; |
|
| 493 | + require_once GIVE_PLUGIN_DIR.'includes/import-functions.php'; |
|
| 494 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php'; |
|
| 495 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php'; |
|
| 496 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php'; |
|
| 497 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php'; |
|
| 498 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php'; |
|
| 499 | + require_once GIVE_PLUGIN_DIR.'includes/currency-functions.php'; |
|
| 500 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php'; |
|
| 501 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php'; |
|
| 502 | + require_once GIVE_PLUGIN_DIR.'includes/process-donation.php'; |
|
| 503 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php'; |
|
| 504 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php'; |
|
| 505 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php'; |
|
| 506 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-classes.php'; |
|
| 507 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php'; |
|
| 508 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php'; |
|
| 509 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php'; |
|
| 510 | + |
|
| 511 | + require_once GIVE_PLUGIN_DIR.'includes/payments/backward-compatibility.php'; |
|
| 512 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php'; |
|
| 513 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php'; |
|
| 514 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php'; |
|
| 515 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php'; |
|
| 516 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php'; |
|
| 517 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-sequential-donation-number.php'; |
|
| 518 | + |
|
| 519 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php'; |
|
| 520 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php'; |
|
| 521 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php'; |
|
| 522 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php'; |
|
| 523 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php'; |
|
| 524 | + |
|
| 525 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php'; |
|
| 526 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php'; |
|
| 527 | + require_once GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-notifications.php'; |
|
| 528 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php'; |
|
| 529 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php'; |
|
| 530 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php'; |
|
| 531 | + |
|
| 532 | + require_once GIVE_PLUGIN_DIR.'includes/donors/class-give-donors-query.php'; |
|
| 533 | + require_once GIVE_PLUGIN_DIR.'includes/donors/backward-compatibility.php'; |
|
| 534 | + |
|
| 535 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/class-give-updates.php'; |
|
| 536 | + |
|
| 537 | + require_once GIVE_PLUGIN_DIR.'blocks/load.php'; |
|
| 538 | + |
|
| 539 | + if (defined('WP_CLI') && WP_CLI) { |
|
| 540 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php'; |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 544 | - |
|
| 545 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; |
|
| 546 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; |
|
| 547 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
|
| 548 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
| 549 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php'; |
|
| 550 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; |
|
| 551 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php'; |
|
| 552 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
| 553 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
| 554 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
| 555 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-blank-slate.php'; |
|
| 556 | - |
|
| 557 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
| 558 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
| 559 | - |
|
| 560 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donors.php'; |
|
| 561 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-functions.php'; |
|
| 562 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-actions.php'; |
|
| 563 | - |
|
| 564 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
| 565 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php'; |
|
| 566 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
| 567 | - |
|
| 568 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php'; |
|
| 569 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php'; |
|
| 570 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php'; |
|
| 571 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php'; |
|
| 572 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/give-export-donations-functions.php'; |
|
| 573 | - |
|
| 574 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/reports.php'; |
|
| 575 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/class-give-graph.php'; |
|
| 576 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/graphing.php'; |
|
| 577 | - |
|
| 578 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php'; |
|
| 579 | - |
|
| 580 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php'; |
|
| 581 | - |
|
| 582 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
| 583 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
| 584 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
| 585 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
| 586 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
| 587 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
| 588 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
| 589 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-grid.php'; |
|
| 590 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
| 591 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
| 592 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-totals.php'; |
|
| 543 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
| 544 | + |
|
| 545 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php'; |
|
| 546 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php'; |
|
| 547 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php'; |
|
| 548 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
| 549 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php'; |
|
| 550 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php'; |
|
| 551 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php'; |
|
| 552 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
| 553 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
| 554 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
| 555 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-blank-slate.php'; |
|
| 556 | + |
|
| 557 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
| 558 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
| 559 | + |
|
| 560 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donors.php'; |
|
| 561 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-functions.php'; |
|
| 562 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-actions.php'; |
|
| 563 | + |
|
| 564 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
| 565 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php'; |
|
| 566 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
| 567 | + |
|
| 568 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-functions.php'; |
|
| 569 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export.php'; |
|
| 570 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-actions.php'; |
|
| 571 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/pdf-reports.php'; |
|
| 572 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/give-export-donations-functions.php'; |
|
| 573 | + |
|
| 574 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reports/reports.php'; |
|
| 575 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reports/class-give-graph.php'; |
|
| 576 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reports/graphing.php'; |
|
| 577 | + |
|
| 578 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php'; |
|
| 579 | + |
|
| 580 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/tools-actions.php'; |
|
| 581 | + |
|
| 582 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
| 583 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
| 584 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
| 585 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
| 586 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
| 587 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
| 588 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
| 589 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-grid.php'; |
|
| 590 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
| 591 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
| 592 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-totals.php'; |
|
| 593 | 593 | }// End if(). |
| 594 | 594 | |
| 595 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
| 595 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
| 596 | 596 | |
| 597 | 597 | } |
| 598 | 598 | |
@@ -607,16 +607,16 @@ discard block |
||
| 607 | 607 | public function load_textdomain() { |
| 608 | 608 | |
| 609 | 609 | // Set filter for Give's languages directory |
| 610 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
| 611 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
| 610 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
| 611 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir); |
|
| 612 | 612 | |
| 613 | 613 | // Traditional WordPress plugin locale filter. |
| 614 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
| 615 | - $locale = apply_filters( 'plugin_locale', $locale, 'give' ); |
|
| 614 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
| 615 | + $locale = apply_filters('plugin_locale', $locale, 'give'); |
|
| 616 | 616 | |
| 617 | - unload_textdomain( 'give' ); |
|
| 618 | - load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' ); |
|
| 619 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
| 617 | + unload_textdomain('give'); |
|
| 618 | + load_textdomain('give', WP_LANG_DIR.'/give/give-'.$locale.'.mo'); |
|
| 619 | + load_plugin_textdomain('give', false, $give_lang_dir); |
|
| 620 | 620 | |
| 621 | 621 | } |
| 622 | 622 | |
@@ -629,21 +629,21 @@ discard block |
||
| 629 | 629 | */ |
| 630 | 630 | public function minimum_phpversion_notice() { |
| 631 | 631 | // Bailout. |
| 632 | - if ( ! is_admin() ) { |
|
| 632 | + if ( ! is_admin()) { |
|
| 633 | 633 | return; |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - $notice_desc = '<p><strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'give' ) . '</strong></p>'; |
|
| 637 | - $notice_desc .= '<p>' . __( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give' ) . '</p>'; |
|
| 638 | - $notice_desc .= '<p>' . __( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give' ) . '</p>'; |
|
| 639 | - $notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>'; |
|
| 640 | - $notice_desc .= '<p>' . __( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give' ) . '</p>'; |
|
| 641 | - $notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>'; |
|
| 642 | - $notice_desc .= '<p>' . sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give' ), sprintf( '<a href="%1$s" target="_blank">', esc_url( 'https://wordpress.org/hosting/' ) ), '</a>' ) . '</p>'; |
|
| 636 | + $notice_desc = '<p><strong>'.__('Your site could be faster and more secure with a newer PHP version.', 'give').'</strong></p>'; |
|
| 637 | + $notice_desc .= '<p>'.__('Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give').'</p>'; |
|
| 638 | + $notice_desc .= '<p>'.__('Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give').'</p>'; |
|
| 639 | + $notice_desc .= '<p><strong>'.__('To which version should I update?', 'give').'</strong></p>'; |
|
| 640 | + $notice_desc .= '<p>'.__('You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give').'</p>'; |
|
| 641 | + $notice_desc .= '<p><strong>'.__('Can\'t update? Ask your host!', 'give').'</strong></p>'; |
|
| 642 | + $notice_desc .= '<p>'.sprintf(__('If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give'), sprintf('<a href="%1$s" target="_blank">', esc_url('https://wordpress.org/hosting/')), '</a>').'</p>'; |
|
| 643 | 643 | |
| 644 | 644 | echo sprintf( |
| 645 | 645 | '<div class="notice notice-error">%1$s</div>', |
| 646 | - wp_kses_post( $notice_desc ) |
|
| 646 | + wp_kses_post($notice_desc) |
|
| 647 | 647 | ); |
| 648 | 648 | } |
| 649 | 649 | |