@@ -30,36 +30,36 @@ discard block |
||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | function wpinv_can_checkout() { |
| 33 | - $can_checkout = true; // Always true for now |
|
| 33 | + $can_checkout = true; // Always true for now |
|
| 34 | 34 | |
| 35 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
| 35 | + return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | function wpinv_get_success_page_uri() { |
| 39 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
| 40 | - $page_id = absint( $page_id ); |
|
| 39 | + $page_id = wpinv_get_option( 'success_page', 0 ); |
|
| 40 | + $page_id = absint( $page_id ); |
|
| 41 | 41 | |
| 42 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
| 42 | + return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function wpinv_get_history_page_uri() { |
| 46 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
| 47 | - $page_id = absint( $page_id ); |
|
| 46 | + $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
| 47 | + $page_id = absint( $page_id ); |
|
| 48 | 48 | |
| 49 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
| 49 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | function wpinv_is_success_page() { |
| 53 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
| 54 | - $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
| 53 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
| 54 | + $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
| 55 | 55 | |
| 56 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
| 56 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | function wpinv_is_invoice_history_page() { |
| 60 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
| 61 | - $ret = $ret ? is_page( $ret ) : false; |
|
| 62 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
| 60 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
| 61 | + $ret = $ret ? is_page( $ret ) : false; |
|
| 62 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | function wpinv_is_subscriptions_history_page() { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | function wpinv_send_to_success_page( $args = null ) { |
| 72 | - $redirect = wpinv_get_success_page_uri(); |
|
| 72 | + $redirect = wpinv_get_success_page_uri(); |
|
| 73 | 73 | |
| 74 | 74 | if ( !empty( $args ) ) { |
| 75 | 75 | // Check for backward compatibility |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | function wpinv_send_to_failed_page( $args = null ) { |
| 92 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
| 92 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
| 93 | 93 | |
| 94 | 94 | if ( !empty( $args ) ) { |
| 95 | 95 | // Check for backward compatibility |
@@ -109,72 +109,72 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | function wpinv_get_checkout_uri( $args = array() ) { |
| 112 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
| 113 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
| 112 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
| 113 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
| 114 | 114 | |
| 115 | - if ( !empty( $args ) ) { |
|
| 116 | - // Check for backward compatibility |
|
| 117 | - if ( is_string( $args ) ) |
|
| 118 | - $args = str_replace( '?', '', $args ); |
|
| 115 | + if ( !empty( $args ) ) { |
|
| 116 | + // Check for backward compatibility |
|
| 117 | + if ( is_string( $args ) ) |
|
| 118 | + $args = str_replace( '?', '', $args ); |
|
| 119 | 119 | |
| 120 | - $args = wp_parse_args( $args ); |
|
| 120 | + $args = wp_parse_args( $args ); |
|
| 121 | 121 | |
| 122 | - $uri = add_query_arg( $args, $uri ); |
|
| 123 | - } |
|
| 122 | + $uri = add_query_arg( $args, $uri ); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 125 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 126 | 126 | |
| 127 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 127 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 128 | 128 | |
| 129 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
| 130 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
| 131 | - } |
|
| 129 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
| 130 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
| 133 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | function wpinv_send_back_to_checkout( $args = array() ) { |
| 137 | - $redirect = wpinv_get_checkout_uri(); |
|
| 137 | + $redirect = wpinv_get_checkout_uri(); |
|
| 138 | 138 | |
| 139 | - if ( ! empty( $args ) ) { |
|
| 140 | - // Check for backward compatibility |
|
| 141 | - if ( is_string( $args ) ) |
|
| 142 | - $args = str_replace( '?', '', $args ); |
|
| 139 | + if ( ! empty( $args ) ) { |
|
| 140 | + // Check for backward compatibility |
|
| 141 | + if ( is_string( $args ) ) |
|
| 142 | + $args = str_replace( '?', '', $args ); |
|
| 143 | 143 | |
| 144 | - $args = wp_parse_args( $args ); |
|
| 144 | + $args = wp_parse_args( $args ); |
|
| 145 | 145 | |
| 146 | - $redirect = add_query_arg( $args, $redirect ); |
|
| 147 | - } |
|
| 146 | + $redirect = add_query_arg( $args, $redirect ); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
| 150 | - exit; |
|
| 149 | + wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
| 150 | + exit; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | function wpinv_get_success_page_url( $query_string = null ) { |
| 154 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
| 155 | - $success_page = get_permalink( $success_page ); |
|
| 154 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
| 155 | + $success_page = get_permalink( $success_page ); |
|
| 156 | 156 | |
| 157 | - if ( $query_string ) |
|
| 158 | - $success_page .= $query_string; |
|
| 157 | + if ( $query_string ) |
|
| 158 | + $success_page .= $query_string; |
|
| 159 | 159 | |
| 160 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
| 160 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
| 164 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
| 165 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
| 164 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
| 165 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
| 166 | 166 | |
| 167 | - if ( $extras ) |
|
| 168 | - $uri .= $extras; |
|
| 167 | + if ( $extras ) |
|
| 168 | + $uri .= $extras; |
|
| 169 | 169 | |
| 170 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
| 170 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | function wpinv_is_failed_transaction_page() { |
| 174 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
| 175 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
| 174 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
| 175 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
| 176 | 176 | |
| 177 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
| 177 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -368,69 +368,69 @@ discard block |
||
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
| 371 | - $pages_options = array(); |
|
| 371 | + $pages_options = array(); |
|
| 372 | 372 | |
| 373 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 374 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 375 | - } |
|
| 373 | + if( $default_label !== NULL && $default_label !== false ) { |
|
| 374 | + $pages_options = array( '' => $default_label ); // Blank option |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | - $pages = get_pages(); |
|
| 378 | - if ( $pages ) { |
|
| 379 | - foreach ( $pages as $page ) { |
|
| 380 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 377 | + $pages = get_pages(); |
|
| 378 | + if ( $pages ) { |
|
| 379 | + foreach ( $pages as $page ) { |
|
| 380 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 381 | 381 | $pages_options[ $page->ID ] = $title; |
| 382 | - } |
|
| 383 | - } |
|
| 382 | + } |
|
| 383 | + } |
|
| 384 | 384 | |
| 385 | - return $pages_options; |
|
| 385 | + return $pages_options; |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | function wpinv_header_callback( $args ) { |
| 389 | - if ( !empty( $args['desc'] ) ) { |
|
| 389 | + if ( !empty( $args['desc'] ) ) { |
|
| 390 | 390 | echo $args['desc']; |
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | function wpinv_hidden_callback( $args ) { |
| 395 | - global $wpinv_options; |
|
| 396 | - |
|
| 397 | - if ( isset( $args['set_value'] ) ) { |
|
| 398 | - $value = $args['set_value']; |
|
| 399 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 400 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 401 | - } else { |
|
| 402 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 406 | - $args['readonly'] = true; |
|
| 407 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 408 | - $name = ''; |
|
| 409 | - } else { |
|
| 410 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 395 | + global $wpinv_options; |
|
| 396 | + |
|
| 397 | + if ( isset( $args['set_value'] ) ) { |
|
| 398 | + $value = $args['set_value']; |
|
| 399 | + } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 400 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 401 | + } else { |
|
| 402 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 406 | + $args['readonly'] = true; |
|
| 407 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 408 | + $name = ''; |
|
| 409 | + } else { |
|
| 410 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 414 | 414 | |
| 415 | - echo $html; |
|
| 415 | + echo $html; |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | function wpinv_checkbox_callback( $args ) { |
| 419 | - global $wpinv_options; |
|
| 419 | + global $wpinv_options; |
|
| 420 | 420 | |
| 421 | 421 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 422 | 422 | |
| 423 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 424 | - $name = ''; |
|
| 425 | - } else { |
|
| 426 | - $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
| 427 | - } |
|
| 423 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 424 | + $name = ''; |
|
| 425 | + } else { |
|
| 426 | + $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 430 | - $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
| 431 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 429 | + $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 430 | + $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
| 431 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 432 | 432 | |
| 433 | - echo $html; |
|
| 433 | + echo $html; |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | function wpinv_checkout_fields_callback( $args ) { |
@@ -438,260 +438,260 @@ discard block |
||
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | function wpinv_multicheck_callback( $args ) { |
| 441 | - global $wpinv_options; |
|
| 441 | + global $wpinv_options; |
|
| 442 | 442 | |
| 443 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 444 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 443 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 444 | + $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 445 | 445 | |
| 446 | - if ( ! empty( $args['options'] ) ) { |
|
| 447 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
| 446 | + if ( ! empty( $args['options'] ) ) { |
|
| 447 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
| 448 | 448 | foreach( $args['options'] as $key => $option ): |
| 449 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 450 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 451 | - $enabled = $sanitize_key; |
|
| 452 | - } else { |
|
| 453 | - $enabled = NULL; |
|
| 454 | - } |
|
| 455 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 456 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
| 457 | - endforeach; |
|
| 458 | - echo '</div>'; |
|
| 459 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
| 460 | - } |
|
| 449 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 450 | + if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 451 | + $enabled = $sanitize_key; |
|
| 452 | + } else { |
|
| 453 | + $enabled = NULL; |
|
| 454 | + } |
|
| 455 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 456 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
| 457 | + endforeach; |
|
| 458 | + echo '</div>'; |
|
| 459 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
| 460 | + } |
|
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | function wpinv_payment_icons_callback( $args ) { |
| 464 | - global $wpinv_options; |
|
| 464 | + global $wpinv_options; |
|
| 465 | 465 | |
| 466 | 466 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 467 | 467 | |
| 468 | - if ( ! empty( $args['options'] ) ) { |
|
| 469 | - foreach( $args['options'] as $key => $option ) { |
|
| 468 | + if ( ! empty( $args['options'] ) ) { |
|
| 469 | + foreach( $args['options'] as $key => $option ) { |
|
| 470 | 470 | $sanitize_key = wpinv_sanitize_key( $key ); |
| 471 | 471 | |
| 472 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 473 | - $enabled = $option; |
|
| 474 | - } else { |
|
| 475 | - $enabled = NULL; |
|
| 476 | - } |
|
| 477 | - |
|
| 478 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 479 | - |
|
| 480 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 481 | - |
|
| 482 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 483 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 484 | - } else { |
|
| 485 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 486 | - |
|
| 487 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 488 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 489 | - } else { |
|
| 490 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 491 | - $content_dir = WP_CONTENT_DIR; |
|
| 492 | - |
|
| 493 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 494 | - // Replaces backslashes with forward slashes for Windows systems |
|
| 495 | - $image = wp_normalize_path( $image ); |
|
| 496 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 503 | - } |
|
| 504 | - echo $option . '</label>'; |
|
| 505 | - } |
|
| 506 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 507 | - } |
|
| 472 | + if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 473 | + $enabled = $option; |
|
| 474 | + } else { |
|
| 475 | + $enabled = NULL; |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 479 | + |
|
| 480 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 481 | + |
|
| 482 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
| 483 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 484 | + } else { |
|
| 485 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 486 | + |
|
| 487 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 488 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 489 | + } else { |
|
| 490 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 491 | + $content_dir = WP_CONTENT_DIR; |
|
| 492 | + |
|
| 493 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 494 | + // Replaces backslashes with forward slashes for Windows systems |
|
| 495 | + $image = wp_normalize_path( $image ); |
|
| 496 | + $content_dir = wp_normalize_path( $content_dir ); |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 503 | + } |
|
| 504 | + echo $option . '</label>'; |
|
| 505 | + } |
|
| 506 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 507 | + } |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | function wpinv_radio_callback( $args ) { |
| 511 | - global $wpinv_options; |
|
| 511 | + global $wpinv_options; |
|
| 512 | 512 | |
| 513 | 513 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 514 | 514 | |
| 515 | 515 | foreach ( $args['options'] as $key => $option ) : |
| 516 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 516 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 517 | 517 | |
| 518 | 518 | $checked = false; |
| 519 | 519 | |
| 520 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 521 | - $checked = true; |
|
| 522 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 523 | - $checked = true; |
|
| 520 | + if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 521 | + $checked = true; |
|
| 522 | + elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 523 | + $checked = true; |
|
| 524 | 524 | |
| 525 | - echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
| 526 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 527 | - endforeach; |
|
| 525 | + echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
| 526 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 527 | + endforeach; |
|
| 528 | 528 | |
| 529 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 529 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | function wpinv_gateways_callback( $args ) { |
| 533 | - global $wpinv_options; |
|
| 533 | + global $wpinv_options; |
|
| 534 | 534 | |
| 535 | 535 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 536 | 536 | |
| 537 | - foreach ( $args['options'] as $key => $option ) : |
|
| 538 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 537 | + foreach ( $args['options'] as $key => $option ) : |
|
| 538 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 539 | 539 | |
| 540 | 540 | if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
| 541 | - $enabled = '1'; |
|
| 542 | - else |
|
| 543 | - $enabled = null; |
|
| 541 | + $enabled = '1'; |
|
| 542 | + else |
|
| 543 | + $enabled = null; |
|
| 544 | 544 | |
| 545 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 546 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 547 | - endforeach; |
|
| 545 | + echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 546 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 547 | + endforeach; |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | function wpinv_gateway_select_callback($args) { |
| 551 | - global $wpinv_options; |
|
| 551 | + global $wpinv_options; |
|
| 552 | 552 | |
| 553 | 553 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 554 | 554 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
| 555 | 555 | |
| 556 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
| 556 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
| 557 | 557 | |
| 558 | - foreach ( $args['options'] as $key => $option ) : |
|
| 559 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 558 | + foreach ( $args['options'] as $key => $option ) : |
|
| 559 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 560 | 560 | $selected = selected( $key, $args['selected'], false ); |
| 561 | 561 | } else { |
| 562 | 562 | $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
| 563 | 563 | } |
| 564 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 565 | - endforeach; |
|
| 564 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 565 | + endforeach; |
|
| 566 | 566 | |
| 567 | - echo '</select>'; |
|
| 568 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 567 | + echo '</select>'; |
|
| 568 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | function wpinv_text_callback( $args ) { |
| 572 | - global $wpinv_options; |
|
| 572 | + global $wpinv_options; |
|
| 573 | 573 | |
| 574 | 574 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 575 | 575 | |
| 576 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 577 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 578 | - } else { |
|
| 579 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 583 | - $args['readonly'] = true; |
|
| 584 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 585 | - $name = ''; |
|
| 586 | - } else { |
|
| 587 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 588 | - } |
|
| 589 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 590 | - |
|
| 591 | - $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
| 592 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 593 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 594 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 595 | - |
|
| 596 | - echo $html; |
|
| 576 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 577 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 578 | + } else { |
|
| 579 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 583 | + $args['readonly'] = true; |
|
| 584 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 585 | + $name = ''; |
|
| 586 | + } else { |
|
| 587 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 588 | + } |
|
| 589 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 590 | + |
|
| 591 | + $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
| 592 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 593 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 594 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 595 | + |
|
| 596 | + echo $html; |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | function wpinv_number_callback( $args ) { |
| 600 | - global $wpinv_options; |
|
| 600 | + global $wpinv_options; |
|
| 601 | 601 | |
| 602 | 602 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 603 | 603 | |
| 604 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 605 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 606 | - } else { |
|
| 607 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 611 | - $args['readonly'] = true; |
|
| 612 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 613 | - $name = ''; |
|
| 614 | - } else { |
|
| 615 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 616 | - } |
|
| 617 | - |
|
| 618 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 619 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 620 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 621 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 622 | - |
|
| 623 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 624 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 625 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 626 | - |
|
| 627 | - echo $html; |
|
| 604 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 605 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 606 | + } else { |
|
| 607 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 611 | + $args['readonly'] = true; |
|
| 612 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 613 | + $name = ''; |
|
| 614 | + } else { |
|
| 615 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 616 | + } |
|
| 617 | + |
|
| 618 | + $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 619 | + $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 620 | + $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 621 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 622 | + |
|
| 623 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 624 | + $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 625 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 626 | + |
|
| 627 | + echo $html; |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | function wpinv_textarea_callback( $args ) { |
| 631 | - global $wpinv_options; |
|
| 631 | + global $wpinv_options; |
|
| 632 | 632 | |
| 633 | 633 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 634 | 634 | |
| 635 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 636 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 637 | - } else { |
|
| 638 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 639 | - } |
|
| 635 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 636 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 637 | + } else { |
|
| 638 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 639 | + } |
|
| 640 | 640 | |
| 641 | 641 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
| 642 | 642 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
| 643 | 643 | |
| 644 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 645 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 644 | + $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 645 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 646 | 646 | |
| 647 | - echo $html; |
|
| 647 | + echo $html; |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | function wpinv_password_callback( $args ) { |
| 651 | - global $wpinv_options; |
|
| 651 | + global $wpinv_options; |
|
| 652 | 652 | |
| 653 | 653 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 654 | 654 | |
| 655 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 656 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 657 | - } else { |
|
| 658 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 659 | - } |
|
| 655 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 656 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 657 | + } else { |
|
| 658 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 659 | + } |
|
| 660 | 660 | |
| 661 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 662 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 663 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 661 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 662 | + $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 663 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 664 | 664 | |
| 665 | - echo $html; |
|
| 665 | + echo $html; |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | function wpinv_missing_callback($args) { |
| 669 | - printf( |
|
| 670 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 671 | - '<strong>' . $args['id'] . '</strong>' |
|
| 672 | - ); |
|
| 669 | + printf( |
|
| 670 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 671 | + '<strong>' . $args['id'] . '</strong>' |
|
| 672 | + ); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | function wpinv_select_callback($args) { |
| 676 | - global $wpinv_options; |
|
| 676 | + global $wpinv_options; |
|
| 677 | 677 | |
| 678 | 678 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 679 | 679 | |
| 680 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 681 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 682 | - } else { |
|
| 683 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 684 | - } |
|
| 680 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 681 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 682 | + } else { |
|
| 683 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 684 | + } |
|
| 685 | 685 | |
| 686 | 686 | if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
| 687 | 687 | $value = $args['selected']; |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | - if ( isset( $args['placeholder'] ) ) { |
|
| 691 | - $placeholder = $args['placeholder']; |
|
| 692 | - } else { |
|
| 693 | - $placeholder = ''; |
|
| 694 | - } |
|
| 690 | + if ( isset( $args['placeholder'] ) ) { |
|
| 691 | + $placeholder = $args['placeholder']; |
|
| 692 | + } else { |
|
| 693 | + $placeholder = ''; |
|
| 694 | + } |
|
| 695 | 695 | |
| 696 | 696 | if( !empty( $args['onchange'] ) ) { |
| 697 | 697 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
@@ -701,142 +701,142 @@ discard block |
||
| 701 | 701 | |
| 702 | 702 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
| 703 | 703 | |
| 704 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 704 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 705 | 705 | |
| 706 | - foreach ( $args['options'] as $option => $name ) { |
|
| 707 | - $selected = selected( $option, $value, false ); |
|
| 708 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 709 | - } |
|
| 706 | + foreach ( $args['options'] as $option => $name ) { |
|
| 707 | + $selected = selected( $option, $value, false ); |
|
| 708 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 709 | + } |
|
| 710 | 710 | |
| 711 | - $html .= '</select>'; |
|
| 712 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 711 | + $html .= '</select>'; |
|
| 712 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 713 | 713 | |
| 714 | - echo $html; |
|
| 714 | + echo $html; |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | function wpinv_color_select_callback( $args ) { |
| 718 | - global $wpinv_options; |
|
| 718 | + global $wpinv_options; |
|
| 719 | 719 | |
| 720 | 720 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 721 | 721 | |
| 722 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 723 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 724 | - } else { |
|
| 725 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 726 | - } |
|
| 722 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 723 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 724 | + } else { |
|
| 725 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 726 | + } |
|
| 727 | 727 | |
| 728 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 728 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 729 | 729 | |
| 730 | - foreach ( $args['options'] as $option => $color ) { |
|
| 731 | - $selected = selected( $option, $value, false ); |
|
| 732 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 733 | - } |
|
| 730 | + foreach ( $args['options'] as $option => $color ) { |
|
| 731 | + $selected = selected( $option, $value, false ); |
|
| 732 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 733 | + } |
|
| 734 | 734 | |
| 735 | - $html .= '</select>'; |
|
| 736 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 735 | + $html .= '</select>'; |
|
| 736 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 737 | 737 | |
| 738 | - echo $html; |
|
| 738 | + echo $html; |
|
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | function wpinv_rich_editor_callback( $args ) { |
| 742 | - global $wpinv_options, $wp_version; |
|
| 742 | + global $wpinv_options, $wp_version; |
|
| 743 | 743 | |
| 744 | 744 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 745 | 745 | |
| 746 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 747 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 746 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 747 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 748 | 748 | |
| 749 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 750 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 751 | - } |
|
| 752 | - } else { |
|
| 753 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 754 | - } |
|
| 749 | + if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 750 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 751 | + } |
|
| 752 | + } else { |
|
| 753 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 754 | + } |
|
| 755 | 755 | |
| 756 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 756 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 757 | 757 | |
| 758 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 759 | - ob_start(); |
|
| 760 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
| 761 | - $html = ob_get_clean(); |
|
| 762 | - } else { |
|
| 763 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 764 | - } |
|
| 758 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 759 | + ob_start(); |
|
| 760 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
| 761 | + $html = ob_get_clean(); |
|
| 762 | + } else { |
|
| 763 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 764 | + } |
|
| 765 | 765 | |
| 766 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 766 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 767 | 767 | |
| 768 | - echo $html; |
|
| 768 | + echo $html; |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | function wpinv_upload_callback( $args ) { |
| 772 | - global $wpinv_options; |
|
| 772 | + global $wpinv_options; |
|
| 773 | 773 | |
| 774 | 774 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 775 | 775 | |
| 776 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 777 | - $value = $wpinv_options[$args['id']]; |
|
| 778 | - } else { |
|
| 779 | - $value = isset($args['std']) ? $args['std'] : ''; |
|
| 780 | - } |
|
| 776 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 777 | + $value = $wpinv_options[$args['id']]; |
|
| 778 | + } else { |
|
| 779 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 780 | + } |
|
| 781 | 781 | |
| 782 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 783 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 784 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 785 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 782 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 783 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 784 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 785 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 786 | 786 | |
| 787 | - echo $html; |
|
| 787 | + echo $html; |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | function wpinv_color_callback( $args ) { |
| 791 | - global $wpinv_options; |
|
| 791 | + global $wpinv_options; |
|
| 792 | 792 | |
| 793 | 793 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 794 | 794 | |
| 795 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 796 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 797 | - } else { |
|
| 798 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 799 | - } |
|
| 795 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 796 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 797 | + } else { |
|
| 798 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 799 | + } |
|
| 800 | 800 | |
| 801 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 801 | + $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 802 | 802 | |
| 803 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
| 804 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 803 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
| 804 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 805 | 805 | |
| 806 | - echo $html; |
|
| 806 | + echo $html; |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | function wpinv_country_states_callback($args) { |
| 810 | - global $wpinv_options; |
|
| 810 | + global $wpinv_options; |
|
| 811 | 811 | |
| 812 | 812 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 813 | 813 | |
| 814 | - if ( isset( $args['placeholder'] ) ) { |
|
| 815 | - $placeholder = $args['placeholder']; |
|
| 816 | - } else { |
|
| 817 | - $placeholder = ''; |
|
| 818 | - } |
|
| 814 | + if ( isset( $args['placeholder'] ) ) { |
|
| 815 | + $placeholder = $args['placeholder']; |
|
| 816 | + } else { |
|
| 817 | + $placeholder = ''; |
|
| 818 | + } |
|
| 819 | 819 | |
| 820 | - $states = wpinv_get_country_states(); |
|
| 820 | + $states = wpinv_get_country_states(); |
|
| 821 | 821 | |
| 822 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 823 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 822 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 823 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 824 | 824 | |
| 825 | - foreach ( $states as $option => $name ) { |
|
| 826 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 827 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 828 | - } |
|
| 825 | + foreach ( $states as $option => $name ) { |
|
| 826 | + $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 827 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 828 | + } |
|
| 829 | 829 | |
| 830 | - $html .= '</select>'; |
|
| 831 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 830 | + $html .= '</select>'; |
|
| 831 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 832 | 832 | |
| 833 | - echo $html; |
|
| 833 | + echo $html; |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | function wpinv_tax_rates_callback($args) { |
| 837 | - global $wpinv_options; |
|
| 838 | - $rates = wpinv_get_tax_rates(); |
|
| 839 | - ob_start(); ?> |
|
| 837 | + global $wpinv_options; |
|
| 838 | + $rates = wpinv_get_tax_rates(); |
|
| 839 | + ob_start(); ?> |
|
| 840 | 840 | </td><tr> |
| 841 | 841 | <td colspan="2" class="wpinv_tax_tdbox"> |
| 842 | 842 | <p><?php echo $args['desc']; ?></p> |
@@ -860,40 +860,40 @@ discard block |
||
| 860 | 860 | <tr> |
| 861 | 861 | <td class="wpinv_tax_country"> |
| 862 | 862 | <?php |
| 863 | - echo wpinv_html_select( array( |
|
| 864 | - 'options' => wpinv_get_country_list( true ), |
|
| 865 | - 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
| 863 | + echo wpinv_html_select( array( |
|
| 864 | + 'options' => wpinv_get_country_list( true ), |
|
| 865 | + 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
| 866 | 866 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
| 867 | - 'selected' => $rate['country'], |
|
| 868 | - 'show_option_all' => false, |
|
| 869 | - 'show_option_none' => false, |
|
| 870 | - 'class' => 'wpinv-tax-country wpi_select2', |
|
| 871 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 872 | - ) ); |
|
| 873 | - ?> |
|
| 867 | + 'selected' => $rate['country'], |
|
| 868 | + 'show_option_all' => false, |
|
| 869 | + 'show_option_none' => false, |
|
| 870 | + 'class' => 'wpinv-tax-country wpi_select2', |
|
| 871 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 872 | + ) ); |
|
| 873 | + ?> |
|
| 874 | 874 | </td> |
| 875 | 875 | <td class="wpinv_tax_state"> |
| 876 | 876 | <?php |
| 877 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
| 878 | - if( !empty( $states ) ) { |
|
| 879 | - echo wpinv_html_select( array( |
|
| 880 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 881 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
| 877 | + $states = wpinv_get_country_states( $rate['country'] ); |
|
| 878 | + if( !empty( $states ) ) { |
|
| 879 | + echo wpinv_html_select( array( |
|
| 880 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
| 881 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
| 882 | 882 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 883 | - 'selected' => $rate['state'], |
|
| 884 | - 'show_option_all' => false, |
|
| 885 | - 'show_option_none' => false, |
|
| 883 | + 'selected' => $rate['state'], |
|
| 884 | + 'show_option_all' => false, |
|
| 885 | + 'show_option_none' => false, |
|
| 886 | 886 | 'class' => 'wpi_select2', |
| 887 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 888 | - ) ); |
|
| 889 | - } else { |
|
| 890 | - echo wpinv_html_text( array( |
|
| 891 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
| 892 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 887 | + 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 888 | + ) ); |
|
| 889 | + } else { |
|
| 890 | + echo wpinv_html_text( array( |
|
| 891 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
| 892 | + 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 893 | 893 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 894 | - ) ); |
|
| 895 | - } |
|
| 896 | - ?> |
|
| 894 | + ) ); |
|
| 895 | + } |
|
| 896 | + ?> |
|
| 897 | 897 | </td> |
| 898 | 898 | <td class="wpinv_tax_global"> |
| 899 | 899 | <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
@@ -908,19 +908,19 @@ discard block |
||
| 908 | 908 | <tr> |
| 909 | 909 | <td class="wpinv_tax_country"> |
| 910 | 910 | <?php |
| 911 | - echo wpinv_html_select( array( |
|
| 912 | - 'options' => wpinv_get_country_list( true ), |
|
| 913 | - 'name' => 'tax_rates[0][country]', |
|
| 914 | - 'show_option_all' => false, |
|
| 915 | - 'show_option_none' => false, |
|
| 916 | - 'class' => 'wpinv-tax-country wpi_select2', |
|
| 917 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 918 | - ) ); ?> |
|
| 911 | + echo wpinv_html_select( array( |
|
| 912 | + 'options' => wpinv_get_country_list( true ), |
|
| 913 | + 'name' => 'tax_rates[0][country]', |
|
| 914 | + 'show_option_all' => false, |
|
| 915 | + 'show_option_none' => false, |
|
| 916 | + 'class' => 'wpinv-tax-country wpi_select2', |
|
| 917 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 918 | + ) ); ?> |
|
| 919 | 919 | </td> |
| 920 | 920 | <td class="wpinv_tax_state"> |
| 921 | 921 | <?php echo wpinv_html_text( array( |
| 922 | - 'name' => 'tax_rates[0][state]' |
|
| 923 | - ) ); ?> |
|
| 922 | + 'name' => 'tax_rates[0][state]' |
|
| 923 | + ) ); ?> |
|
| 924 | 924 | </td> |
| 925 | 925 | <td class="wpinv_tax_global"> |
| 926 | 926 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
| 936 | 936 | </table> |
| 937 | 937 | <?php |
| 938 | - echo ob_get_clean(); |
|
| 938 | + echo ob_get_clean(); |
|
| 939 | 939 | } |
| 940 | 940 | |
| 941 | 941 | function wpinv_tools_callback($args) { |
@@ -963,15 +963,15 @@ discard block |
||
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | function wpinv_descriptive_text_callback( $args ) { |
| 966 | - echo wp_kses_post( $args['desc'] ); |
|
| 966 | + echo wp_kses_post( $args['desc'] ); |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | function wpinv_hook_callback( $args ) { |
| 970 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 970 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
| 971 | 971 | } |
| 972 | 972 | |
| 973 | 973 | function wpinv_set_settings_cap() { |
| 974 | - return wpinv_get_capability(); |
|
| 974 | + return wpinv_get_capability(); |
|
| 975 | 975 | } |
| 976 | 976 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
| 977 | 977 | |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | if( isset( $_GET['page'] ) && 'wpinv-settings' == $_GET['page'] ) { |
| 503 | 503 | |
| 504 | 504 | // Sweetalert https://sweetalert2.github.io/. |
| 505 | - wp_register_script( 'promise-polyfill', WPINV_PLUGIN_URL . 'assets/vendor/sweetalert/promise-polyfill.min.js', array(), '8.1.3', true ); |
|
| 505 | + wp_register_script( 'promise-polyfill', WPINV_PLUGIN_URL . 'assets/vendor/sweetalert/promise-polyfill.min.js', array(), '8.1.3', true ); |
|
| 506 | 506 | wp_register_script( 'sweetalert2', WPINV_PLUGIN_URL . 'assets/vendor/sweetalert/sweetalert2.all.min.js', array( 'promise-polyfill' ), '9.6.0', true ); |
| 507 | 507 | |
| 508 | 508 | // Vue js. |
@@ -527,9 +527,9 @@ discard block |
||
| 527 | 527 | ); |
| 528 | 528 | |
| 529 | 529 | // localize and enqueue the script with all of the variable inserted. |
| 530 | - wp_localize_script( 'wpinv-field-editor', 'wpinvFieldEditor', $params ); |
|
| 530 | + wp_localize_script( 'wpinv-field-editor', 'wpinvFieldEditor', $params ); |
|
| 531 | 531 | |
| 532 | - wp_enqueue_script( 'wpinv-field-editor' ); |
|
| 532 | + wp_enqueue_script( 'wpinv-field-editor' ); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | } |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | function wpinv_get_payment_key( $invoice_id = 0 ) { |
| 703 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 703 | + $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 704 | 704 | return $invoice->get_key(); |
| 705 | 705 | } |
| 706 | 706 | |
@@ -950,7 +950,7 @@ discard block |
||
| 950 | 950 | return false; |
| 951 | 951 | } |
| 952 | 952 | $invoice = wpinv_get_invoice_cart(); |
| 953 | - if ( empty( $invoice ) ) { |
|
| 953 | + if ( empty( $invoice ) ) { |
|
| 954 | 954 | return false; |
| 955 | 955 | } |
| 956 | 956 | |
@@ -1247,20 +1247,20 @@ discard block |
||
| 1247 | 1247 | } |
| 1248 | 1248 | |
| 1249 | 1249 | function wpinv_checkout_get_cc_info() { |
| 1250 | - $cc_info = array(); |
|
| 1251 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 1252 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 1253 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 1254 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 1255 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 1256 | - $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
| 1257 | - $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
| 1258 | - $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
| 1259 | - $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
| 1260 | - $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
| 1261 | - |
|
| 1262 | - // Return cc info |
|
| 1263 | - return $cc_info; |
|
| 1250 | + $cc_info = array(); |
|
| 1251 | + $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 1252 | + $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 1253 | + $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 1254 | + $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 1255 | + $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 1256 | + $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
| 1257 | + $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
| 1258 | + $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
| 1259 | + $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
| 1260 | + $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
| 1261 | + |
|
| 1262 | + // Return cc info |
|
| 1263 | + return $cc_info; |
|
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) { |
@@ -1467,7 +1467,7 @@ discard block |
||
| 1467 | 1467 | $required_fields = wpinv_checkout_required_fields(); |
| 1468 | 1468 | |
| 1469 | 1469 | // Loop through required fields and show error messages |
| 1470 | - if ( !empty( $required_fields ) ) { |
|
| 1470 | + if ( !empty( $required_fields ) ) { |
|
| 1471 | 1471 | foreach ( $required_fields as $field_name => $value ) { |
| 1472 | 1472 | if ( empty( $_POST[ $field_name ] ) ) { |
| 1473 | 1473 | wpinv_set_error( $value['error_id'], $value['error_message'] ); |
@@ -1589,7 +1589,7 @@ discard block |
||
| 1589 | 1589 | } |
| 1590 | 1590 | |
| 1591 | 1591 | function wpinv_get_checkout_session() { |
| 1592 | - global $wpi_session; |
|
| 1592 | + global $wpi_session; |
|
| 1593 | 1593 | |
| 1594 | 1594 | return $wpi_session->get( 'wpinv_checkout' ); |
| 1595 | 1595 | } |
@@ -1697,7 +1697,7 @@ discard block |
||
| 1697 | 1697 | $response['data']['taxf'] = $invoice->get_tax( true ); |
| 1698 | 1698 | $response['data']['total'] = $invoice->get_total(); |
| 1699 | 1699 | $response['data']['totalf'] = $invoice->get_total( true ); |
| 1700 | - $response['data']['free'] = $invoice->is_free() && ( ! ( (float) $response['data']['total'] > 0 ) || $invoice->is_free_trial() ) ? true : false; |
|
| 1700 | + $response['data']['free'] = $invoice->is_free() && ( ! ( (float) $response['data']['total'] > 0 ) || $invoice->is_free_trial() ) ? true : false; |
|
| 1701 | 1701 | |
| 1702 | 1702 | wp_send_json( $response ); |
| 1703 | 1703 | } |
@@ -1986,57 +1986,57 @@ discard block |
||
| 1986 | 1986 | } |
| 1987 | 1987 | |
| 1988 | 1988 | function wpinv_get_invoice_id_by_key( $key ) { |
| 1989 | - global $wpdb; |
|
| 1989 | + global $wpdb; |
|
| 1990 | 1990 | |
| 1991 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1991 | + $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1992 | 1992 | |
| 1993 | - if ( $invoice_id != NULL ) |
|
| 1994 | - return $invoice_id; |
|
| 1993 | + if ( $invoice_id != NULL ) |
|
| 1994 | + return $invoice_id; |
|
| 1995 | 1995 | |
| 1996 | - return 0; |
|
| 1996 | + return 0; |
|
| 1997 | 1997 | } |
| 1998 | 1998 | |
| 1999 | 1999 | function wpinv_can_view_receipt( $invoice_key = '' ) { |
| 2000 | - $return = false; |
|
| 2000 | + $return = false; |
|
| 2001 | 2001 | |
| 2002 | - if ( empty( $invoice_key ) ) { |
|
| 2003 | - return $return; |
|
| 2004 | - } |
|
| 2002 | + if ( empty( $invoice_key ) ) { |
|
| 2003 | + return $return; |
|
| 2004 | + } |
|
| 2005 | 2005 | |
| 2006 | - global $wpinv_receipt_args; |
|
| 2006 | + global $wpinv_receipt_args; |
|
| 2007 | 2007 | |
| 2008 | - $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 2009 | - if ( isset( $_GET['invoice-id'] ) ) { |
|
| 2010 | - $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
| 2011 | - } |
|
| 2008 | + $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 2009 | + if ( isset( $_GET['invoice-id'] ) ) { |
|
| 2010 | + $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
| 2011 | + } |
|
| 2012 | 2012 | |
| 2013 | - if ( empty( $wpinv_receipt_args['id'] ) ) { |
|
| 2014 | - return $return; |
|
| 2015 | - } |
|
| 2013 | + if ( empty( $wpinv_receipt_args['id'] ) ) { |
|
| 2014 | + return $return; |
|
| 2015 | + } |
|
| 2016 | 2016 | |
| 2017 | - $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] ); |
|
| 2018 | - if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) { |
|
| 2019 | - return $return; |
|
| 2020 | - } |
|
| 2017 | + $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] ); |
|
| 2018 | + if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) { |
|
| 2019 | + return $return; |
|
| 2020 | + } |
|
| 2021 | 2021 | |
| 2022 | - if ( is_user_logged_in() ) { |
|
| 2023 | - if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) { |
|
| 2024 | - $return = true; |
|
| 2025 | - } |
|
| 2026 | - } |
|
| 2022 | + if ( is_user_logged_in() ) { |
|
| 2023 | + if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) { |
|
| 2024 | + $return = true; |
|
| 2025 | + } |
|
| 2026 | + } |
|
| 2027 | 2027 | |
| 2028 | - $session = wpinv_get_checkout_session(); |
|
| 2029 | - if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) { |
|
| 2030 | - $check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key']; |
|
| 2028 | + $session = wpinv_get_checkout_session(); |
|
| 2029 | + if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) { |
|
| 2030 | + $check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key']; |
|
| 2031 | 2031 | |
| 2032 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 2033 | - $return = $return && $check_key === $invoice_key; |
|
| 2034 | - } else { |
|
| 2035 | - $return = $check_key === $invoice_key; |
|
| 2036 | - } |
|
| 2037 | - } |
|
| 2032 | + if ( wpinv_require_login_to_checkout() ) { |
|
| 2033 | + $return = $return && $check_key === $invoice_key; |
|
| 2034 | + } else { |
|
| 2035 | + $return = $check_key === $invoice_key; |
|
| 2036 | + } |
|
| 2037 | + } |
|
| 2038 | 2038 | |
| 2039 | - return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
| 2039 | + return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
| 2040 | 2040 | } |
| 2041 | 2041 | |
| 2042 | 2042 | function wpinv_pay_for_invoice() { |
@@ -2346,14 +2346,14 @@ discard block |
||
| 2346 | 2346 | |
| 2347 | 2347 | if ( isset( $_GET['invoice_key'] ) || is_singular( 'wpi_invoice' ) || is_singular( 'wpi_quote' ) ) { |
| 2348 | 2348 | $invoice_key = isset( $_GET['invoice_key'] ) ? urldecode($_GET['invoice_key']) : ''; |
| 2349 | - global $post; |
|
| 2349 | + global $post; |
|
| 2350 | 2350 | |
| 2351 | 2351 | if(!empty($invoice_key)){ |
| 2352 | - $invoice_id = wpinv_get_invoice_id_by_key($invoice_key); |
|
| 2352 | + $invoice_id = wpinv_get_invoice_id_by_key($invoice_key); |
|
| 2353 | 2353 | } else if(!empty( $post ) && ($post->post_type == 'wpi_invoice' || $post->post_type == 'wpi_quote')) { |
| 2354 | - $invoice_id = $post->ID; |
|
| 2354 | + $invoice_id = $post->ID; |
|
| 2355 | 2355 | } else { |
| 2356 | - return; |
|
| 2356 | + return; |
|
| 2357 | 2357 | } |
| 2358 | 2358 | |
| 2359 | 2359 | $invoice = new WPInv_Invoice($invoice_id); |
@@ -2362,17 +2362,17 @@ discard block |
||
| 2362 | 2362 | return; |
| 2363 | 2363 | } |
| 2364 | 2364 | |
| 2365 | - if ( is_user_logged_in() ) { |
|
| 2366 | - if ( (int)$invoice->get_user_id() === get_current_user_id() ) { |
|
| 2367 | - update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2368 | - } else if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2369 | - update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2370 | - } |
|
| 2371 | - } else { |
|
| 2372 | - if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2373 | - update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2374 | - } |
|
| 2375 | - } |
|
| 2365 | + if ( is_user_logged_in() ) { |
|
| 2366 | + if ( (int)$invoice->get_user_id() === get_current_user_id() ) { |
|
| 2367 | + update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2368 | + } else if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2369 | + update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2370 | + } |
|
| 2371 | + } else { |
|
| 2372 | + if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2373 | + update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2374 | + } |
|
| 2375 | + } |
|
| 2376 | 2376 | } |
| 2377 | 2377 | |
| 2378 | 2378 | } |