@@ -9,7 +9,6 @@ |
||
| 9 | 9 | use GeoIp2\Exception\InvalidRequestException; |
| 10 | 10 | use GeoIp2\Exception\OutOfQueriesException; |
| 11 | 11 | use GeoIp2\ProviderInterface; |
| 12 | -use MaxMind\Exception\InvalidInputException; |
|
| 13 | 12 | use MaxMind\WebService\Client as WsClient; |
| 14 | 13 | |
| 15 | 14 | /** |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | - exit; |
|
| 3 | + exit; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | if ( !( $user_id = get_current_user_id() ) ) { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | <tbody> |
| 32 | 32 | <?php foreach ( $user_invoices->invoices as $invoice ) { |
| 33 | - ?> |
|
| 33 | + ?> |
|
| 34 | 34 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
| 35 | 35 | <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
| 36 | 36 | <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
@@ -53,31 +53,31 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
| 55 | 55 | <?php |
| 56 | - $actions = array( |
|
| 57 | - 'pay' => array( |
|
| 58 | - 'url' => $invoice->get_checkout_payment_url(), |
|
| 59 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
| 56 | + $actions = array( |
|
| 57 | + 'pay' => array( |
|
| 58 | + 'url' => $invoice->get_checkout_payment_url(), |
|
| 59 | + 'name' => __( 'Pay Now', 'invoicing' ), |
|
| 60 | 60 | 'class' => 'btn-success' |
| 61 | - ), |
|
| 61 | + ), |
|
| 62 | 62 | 'print' => array( |
| 63 | - 'url' => $invoice->get_view_url(), |
|
| 64 | - 'name' => __( 'Print', 'invoicing' ), |
|
| 63 | + 'url' => $invoice->get_view_url(), |
|
| 64 | + 'name' => __( 'Print', 'invoicing' ), |
|
| 65 | 65 | 'class' => 'btn-primary', |
| 66 | 66 | 'attrs' => 'target="_blank"' |
| 67 | - ) |
|
| 68 | - ); |
|
| 67 | + ) |
|
| 68 | + ); |
|
| 69 | 69 | |
| 70 | - if ( ! $invoice->needs_payment() ) { |
|
| 71 | - unset( $actions['pay'] ); |
|
| 72 | - } |
|
| 70 | + if ( ! $invoice->needs_payment() ) { |
|
| 71 | + unset( $actions['pay'] ); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
| 75 | - foreach ( $actions as $key => $action ) { |
|
| 76 | - $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
| 74 | + if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
| 75 | + foreach ( $actions as $key => $action ) { |
|
| 76 | + $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
| 77 | 77 | echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
| 78 | - } |
|
| 79 | - } |
|
| 80 | - ?> |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + ?> |
|
| 81 | 81 | <?php endif; ?> |
| 82 | 82 | </td> |
| 83 | 83 | <?php endforeach; ?> |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | <?php if ( 1 < $user_invoices->max_num_pages ) : ?> |
| 92 | 92 | <div class="invoicing-Pagination"> |
| 93 | 93 | <?php |
| 94 | - $big = 999999; |
|
| 95 | - echo paginate_links( array( |
|
| 96 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 97 | - 'format' => '?paged=%#%', |
|
| 98 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
| 99 | - 'total' => $user_invoices->max_num_pages |
|
| 100 | - ) ); |
|
| 101 | - ?> |
|
| 94 | + $big = 999999; |
|
| 95 | + echo paginate_links( array( |
|
| 96 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 97 | + 'format' => '?paged=%#%', |
|
| 98 | + 'current' => max( 1, get_query_var( 'paged' ) ), |
|
| 99 | + 'total' => $user_invoices->max_num_pages |
|
| 100 | + ) ); |
|
| 101 | + ?> |
|
| 102 | 102 | </div> |
| 103 | 103 | <?php endif; ?> |
| 104 | 104 | |
@@ -348,7 +348,7 @@ |
||
| 348 | 348 | |
| 349 | 349 | $query_args = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true ); |
| 350 | 350 | if ( !empty( $status ) && $status != 'all' ) { |
| 351 | - $query_args['status'] = $status; |
|
| 351 | + $query_args['status'] = $status; |
|
| 352 | 352 | } |
| 353 | 353 | $invoices = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) ); |
| 354 | 354 | |
@@ -30,40 +30,40 @@ 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_send_to_success_page( $args = null ) { |
| 66 | - $redirect = wpinv_get_success_page_uri(); |
|
| 66 | + $redirect = wpinv_get_success_page_uri(); |
|
| 67 | 67 | |
| 68 | 68 | if ( !empty( $args ) ) { |
| 69 | 69 | // Check for backward compatibility |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | function wpinv_send_to_failed_page( $args = null ) { |
| 86 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
| 86 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
| 87 | 87 | |
| 88 | 88 | if ( !empty( $args ) ) { |
| 89 | 89 | // Check for backward compatibility |
@@ -103,72 +103,72 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | function wpinv_get_checkout_uri( $args = array() ) { |
| 106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
| 107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
| 106 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
| 107 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
| 108 | 108 | |
| 109 | - if ( !empty( $args ) ) { |
|
| 110 | - // Check for backward compatibility |
|
| 111 | - if ( is_string( $args ) ) |
|
| 112 | - $args = str_replace( '?', '', $args ); |
|
| 109 | + if ( !empty( $args ) ) { |
|
| 110 | + // Check for backward compatibility |
|
| 111 | + if ( is_string( $args ) ) |
|
| 112 | + $args = str_replace( '?', '', $args ); |
|
| 113 | 113 | |
| 114 | - $args = wp_parse_args( $args ); |
|
| 114 | + $args = wp_parse_args( $args ); |
|
| 115 | 115 | |
| 116 | - $uri = add_query_arg( $args, $uri ); |
|
| 117 | - } |
|
| 116 | + $uri = add_query_arg( $args, $uri ); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 119 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 120 | 120 | |
| 121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 121 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 122 | 122 | |
| 123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
| 124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
| 125 | - } |
|
| 123 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
| 124 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
| 127 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | function wpinv_send_back_to_checkout( $args = array() ) { |
| 131 | - $redirect = wpinv_get_checkout_uri(); |
|
| 131 | + $redirect = wpinv_get_checkout_uri(); |
|
| 132 | 132 | |
| 133 | - if ( ! empty( $args ) ) { |
|
| 134 | - // Check for backward compatibility |
|
| 135 | - if ( is_string( $args ) ) |
|
| 136 | - $args = str_replace( '?', '', $args ); |
|
| 133 | + if ( ! empty( $args ) ) { |
|
| 134 | + // Check for backward compatibility |
|
| 135 | + if ( is_string( $args ) ) |
|
| 136 | + $args = str_replace( '?', '', $args ); |
|
| 137 | 137 | |
| 138 | - $args = wp_parse_args( $args ); |
|
| 138 | + $args = wp_parse_args( $args ); |
|
| 139 | 139 | |
| 140 | - $redirect = add_query_arg( $args, $redirect ); |
|
| 141 | - } |
|
| 140 | + $redirect = add_query_arg( $args, $redirect ); |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
| 144 | - exit; |
|
| 143 | + wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
| 144 | + exit; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | function wpinv_get_success_page_url( $query_string = null ) { |
| 148 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
| 149 | - $success_page = get_permalink( $success_page ); |
|
| 148 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
| 149 | + $success_page = get_permalink( $success_page ); |
|
| 150 | 150 | |
| 151 | - if ( $query_string ) |
|
| 152 | - $success_page .= $query_string; |
|
| 151 | + if ( $query_string ) |
|
| 152 | + $success_page .= $query_string; |
|
| 153 | 153 | |
| 154 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
| 154 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
| 158 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
| 159 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
| 158 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
| 159 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
| 160 | 160 | |
| 161 | - if ( $extras ) |
|
| 162 | - $uri .= $extras; |
|
| 161 | + if ( $extras ) |
|
| 162 | + $uri .= $extras; |
|
| 163 | 163 | |
| 164 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
| 164 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | function wpinv_is_failed_transaction_page() { |
| 168 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
| 169 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
| 168 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
| 169 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
| 170 | 170 | |
| 171 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
| 171 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -977,67 +977,67 @@ |
||
| 977 | 977 | function wpinv_tool_merge_fix_taxes() { |
| 978 | 978 | global $wpdb; |
| 979 | 979 | |
| 980 | - $sql = "SELECT DISTINCT p.ID FROM `" . $wpdb->posts . "` AS p LEFT JOIN " . $wpdb->postmeta . " AS pm ON pm.post_id = p.ID WHERE p.post_type = 'wpi_item' AND pm.meta_key = '_wpinv_type' AND pm.meta_value = 'package'"; |
|
| 981 | - $items = $wpdb->get_results( $sql ); |
|
| 980 | + $sql = "SELECT DISTINCT p.ID FROM `" . $wpdb->posts . "` AS p LEFT JOIN " . $wpdb->postmeta . " AS pm ON pm.post_id = p.ID WHERE p.post_type = 'wpi_item' AND pm.meta_key = '_wpinv_type' AND pm.meta_value = 'package'"; |
|
| 981 | + $items = $wpdb->get_results( $sql ); |
|
| 982 | 982 | |
| 983 | - if ( !empty( $items ) ) { |
|
| 984 | - foreach ( $items as $item ) { |
|
| 985 | - if ( get_post_meta( $item->ID, '_wpinv_vat_class', true ) == '_exempt' ) { |
|
| 986 | - update_post_meta( $item->ID, '_wpinv_vat_class', '_standard' ); |
|
| 987 | - } |
|
| 988 | - } |
|
| 989 | - } |
|
| 983 | + if ( !empty( $items ) ) { |
|
| 984 | + foreach ( $items as $item ) { |
|
| 985 | + if ( get_post_meta( $item->ID, '_wpinv_vat_class', true ) == '_exempt' ) { |
|
| 986 | + update_post_meta( $item->ID, '_wpinv_vat_class', '_standard' ); |
|
| 987 | + } |
|
| 988 | + } |
|
| 989 | + } |
|
| 990 | 990 | |
| 991 | 991 | $sql = "SELECT `p`.`ID`, gdi.id AS gdp_id FROM `" . INVOICE_TABLE . "` AS gdi LEFT JOIN `" . $wpdb->posts . "` AS p ON `p`.`ID` = `gdi`.`invoice_id` AND `p`.`post_type` = 'wpi_invoice' WHERE `p`.`ID` IS NOT NULL AND p.post_status NOT IN( 'publish', 'complete', 'processing', 'renewal' ) ORDER BY `gdi`.`id` ASC"; |
| 992 | 992 | $items = $wpdb->get_results( $sql ); |
| 993 | 993 | |
| 994 | - if ( !empty( $items ) ) { |
|
| 995 | - $success = false; |
|
| 994 | + if ( !empty( $items ) ) { |
|
| 995 | + $success = false; |
|
| 996 | 996 | $message = __( 'Taxes fixed for non-paid merged GD invoices.', 'invoicing' ); |
| 997 | 997 | |
| 998 | - global $wpi_userID, $wpinv_ip_address_country, $wpi_tax_rates; |
|
| 998 | + global $wpi_userID, $wpinv_ip_address_country, $wpi_tax_rates; |
|
| 999 | 999 | |
| 1000 | - foreach ( $items as $item ) { |
|
| 1001 | - $wpi_tax_rates = NULL; |
|
| 1002 | - $data = wpinv_get_invoice($item->ID); |
|
| 1000 | + foreach ( $items as $item ) { |
|
| 1001 | + $wpi_tax_rates = NULL; |
|
| 1002 | + $data = wpinv_get_invoice($item->ID); |
|
| 1003 | 1003 | |
| 1004 | - if ( empty( $data ) ) { |
|
| 1005 | - continue; |
|
| 1006 | - } |
|
| 1004 | + if ( empty( $data ) ) { |
|
| 1005 | + continue; |
|
| 1006 | + } |
|
| 1007 | 1007 | |
| 1008 | - $checkout_session = wpinv_get_checkout_session(); |
|
| 1008 | + $checkout_session = wpinv_get_checkout_session(); |
|
| 1009 | 1009 | |
| 1010 | - $data_session = array(); |
|
| 1011 | - $data_session['invoice_id'] = $data->ID; |
|
| 1012 | - $data_session['cart_discounts'] = $data->get_discounts( true ); |
|
| 1010 | + $data_session = array(); |
|
| 1011 | + $data_session['invoice_id'] = $data->ID; |
|
| 1012 | + $data_session['cart_discounts'] = $data->get_discounts( true ); |
|
| 1013 | 1013 | |
| 1014 | - wpinv_set_checkout_session( $data_session ); |
|
| 1014 | + wpinv_set_checkout_session( $data_session ); |
|
| 1015 | 1015 | |
| 1016 | - $wpi_userID = (int)$data->get_user_id(); |
|
| 1017 | - $_POST['country'] = !empty($data->country) ? $data->country : wpinv_get_default_country(); |
|
| 1016 | + $wpi_userID = (int)$data->get_user_id(); |
|
| 1017 | + $_POST['country'] = !empty($data->country) ? $data->country : wpinv_get_default_country(); |
|
| 1018 | 1018 | |
| 1019 | - $data->country = sanitize_text_field( $_POST['country'] ); |
|
| 1020 | - $data->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 1019 | + $data->country = sanitize_text_field( $_POST['country'] ); |
|
| 1020 | + $data->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 1021 | 1021 | |
| 1022 | - $wpinv_ip_address_country = $data->country; |
|
| 1022 | + $wpinv_ip_address_country = $data->country; |
|
| 1023 | 1023 | |
| 1024 | - $data->recalculate_totals(true); |
|
| 1024 | + $data->recalculate_totals(true); |
|
| 1025 | 1025 | |
| 1026 | - wpinv_set_checkout_session( $checkout_session ); |
|
| 1026 | + wpinv_set_checkout_session( $checkout_session ); |
|
| 1027 | 1027 | |
| 1028 | - $update_data = array(); |
|
| 1029 | - $update_data['tax_amount'] = $data->get_tax(); |
|
| 1030 | - $update_data['paied_amount'] = $data->get_total(); |
|
| 1031 | - $update_data['invoice_id'] = $data->ID; |
|
| 1028 | + $update_data = array(); |
|
| 1029 | + $update_data['tax_amount'] = $data->get_tax(); |
|
| 1030 | + $update_data['paied_amount'] = $data->get_total(); |
|
| 1031 | + $update_data['invoice_id'] = $data->ID; |
|
| 1032 | 1032 | |
| 1033 | - $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $item->gdp_id ) ); |
|
| 1034 | - } |
|
| 1035 | - } else { |
|
| 1033 | + $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $item->gdp_id ) ); |
|
| 1034 | + } |
|
| 1035 | + } else { |
|
| 1036 | 1036 | $success = false; |
| 1037 | 1037 | $message = __( 'No invoices found to fix taxes!', 'invoicing' ); |
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | - $response = array(); |
|
| 1040 | + $response = array(); |
|
| 1041 | 1041 | $response['success'] = $success; |
| 1042 | 1042 | $response['data']['message'] = $message; |
| 1043 | 1043 | wp_send_json( $response ); |
@@ -770,326 +770,326 @@ discard block |
||
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
| 773 | - $pages_options = array(); |
|
| 773 | + $pages_options = array(); |
|
| 774 | 774 | |
| 775 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 776 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 777 | - } |
|
| 775 | + if( $default_label !== NULL && $default_label !== false ) { |
|
| 776 | + $pages_options = array( '' => $default_label ); // Blank option |
|
| 777 | + } |
|
| 778 | 778 | |
| 779 | - $pages = get_pages(); |
|
| 780 | - if ( $pages ) { |
|
| 781 | - foreach ( $pages as $page ) { |
|
| 782 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 779 | + $pages = get_pages(); |
|
| 780 | + if ( $pages ) { |
|
| 781 | + foreach ( $pages as $page ) { |
|
| 782 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 783 | 783 | $pages_options[ $page->ID ] = $title; |
| 784 | - } |
|
| 785 | - } |
|
| 784 | + } |
|
| 785 | + } |
|
| 786 | 786 | |
| 787 | - return $pages_options; |
|
| 787 | + return $pages_options; |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | function wpinv_header_callback( $args ) { |
| 791 | - if ( !empty( $args['desc'] ) ) { |
|
| 791 | + if ( !empty( $args['desc'] ) ) { |
|
| 792 | 792 | echo $args['desc']; |
| 793 | 793 | } |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | function wpinv_hidden_callback( $args ) { |
| 797 | - global $wpinv_options; |
|
| 798 | - |
|
| 799 | - if ( isset( $args['set_value'] ) ) { |
|
| 800 | - $value = $args['set_value']; |
|
| 801 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 802 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 803 | - } else { |
|
| 804 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 805 | - } |
|
| 806 | - |
|
| 807 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 808 | - $args['readonly'] = true; |
|
| 809 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 810 | - $name = ''; |
|
| 811 | - } else { |
|
| 812 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 813 | - } |
|
| 814 | - |
|
| 815 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 797 | + global $wpinv_options; |
|
| 798 | + |
|
| 799 | + if ( isset( $args['set_value'] ) ) { |
|
| 800 | + $value = $args['set_value']; |
|
| 801 | + } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 802 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 803 | + } else { |
|
| 804 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 805 | + } |
|
| 806 | + |
|
| 807 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 808 | + $args['readonly'] = true; |
|
| 809 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 810 | + $name = ''; |
|
| 811 | + } else { |
|
| 812 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 813 | + } |
|
| 814 | + |
|
| 815 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 816 | 816 | |
| 817 | - echo $html; |
|
| 817 | + echo $html; |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | function wpinv_checkbox_callback( $args ) { |
| 821 | - global $wpinv_options; |
|
| 821 | + global $wpinv_options; |
|
| 822 | 822 | |
| 823 | 823 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 824 | 824 | |
| 825 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 826 | - $name = ''; |
|
| 827 | - } else { |
|
| 828 | - $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
| 829 | - } |
|
| 825 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 826 | + $name = ''; |
|
| 827 | + } else { |
|
| 828 | + $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
| 829 | + } |
|
| 830 | 830 | |
| 831 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 832 | - $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
| 833 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 831 | + $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 832 | + $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
| 833 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 834 | 834 | |
| 835 | - echo $html; |
|
| 835 | + echo $html; |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | function wpinv_multicheck_callback( $args ) { |
| 839 | - global $wpinv_options; |
|
| 839 | + global $wpinv_options; |
|
| 840 | 840 | |
| 841 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 841 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 842 | 842 | |
| 843 | - if ( ! empty( $args['options'] ) ) { |
|
| 844 | - foreach( $args['options'] as $key => $option ): |
|
| 845 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 846 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 847 | - $enabled = $sanitize_key; |
|
| 848 | - } else { |
|
| 849 | - $enabled = NULL; |
|
| 850 | - } |
|
| 851 | - echo '<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 ) . '/> '; |
|
| 852 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
| 853 | - endforeach; |
|
| 854 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
| 855 | - } |
|
| 843 | + if ( ! empty( $args['options'] ) ) { |
|
| 844 | + foreach( $args['options'] as $key => $option ): |
|
| 845 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 846 | + if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 847 | + $enabled = $sanitize_key; |
|
| 848 | + } else { |
|
| 849 | + $enabled = NULL; |
|
| 850 | + } |
|
| 851 | + echo '<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 ) . '/> '; |
|
| 852 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
| 853 | + endforeach; |
|
| 854 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
| 855 | + } |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | function wpinv_payment_icons_callback( $args ) { |
| 859 | - global $wpinv_options; |
|
| 859 | + global $wpinv_options; |
|
| 860 | 860 | |
| 861 | 861 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 862 | 862 | |
| 863 | - if ( ! empty( $args['options'] ) ) { |
|
| 864 | - foreach( $args['options'] as $key => $option ) { |
|
| 863 | + if ( ! empty( $args['options'] ) ) { |
|
| 864 | + foreach( $args['options'] as $key => $option ) { |
|
| 865 | 865 | $sanitize_key = wpinv_sanitize_key( $key ); |
| 866 | 866 | |
| 867 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 868 | - $enabled = $option; |
|
| 869 | - } else { |
|
| 870 | - $enabled = NULL; |
|
| 871 | - } |
|
| 872 | - |
|
| 873 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 874 | - |
|
| 875 | - 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 ) . '/> '; |
|
| 876 | - |
|
| 877 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 878 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 879 | - } else { |
|
| 880 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 881 | - |
|
| 882 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 883 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 884 | - } else { |
|
| 885 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 886 | - $content_dir = WP_CONTENT_DIR; |
|
| 887 | - |
|
| 888 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 889 | - // Replaces backslashes with forward slashes for Windows systems |
|
| 890 | - $image = wp_normalize_path( $image ); |
|
| 891 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 892 | - } |
|
| 893 | - |
|
| 894 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 895 | - } |
|
| 896 | - |
|
| 897 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 898 | - } |
|
| 899 | - echo $option . '</label>'; |
|
| 900 | - } |
|
| 901 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 902 | - } |
|
| 867 | + if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 868 | + $enabled = $option; |
|
| 869 | + } else { |
|
| 870 | + $enabled = NULL; |
|
| 871 | + } |
|
| 872 | + |
|
| 873 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 874 | + |
|
| 875 | + 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 ) . '/> '; |
|
| 876 | + |
|
| 877 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
| 878 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 879 | + } else { |
|
| 880 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 881 | + |
|
| 882 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 883 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 884 | + } else { |
|
| 885 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 886 | + $content_dir = WP_CONTENT_DIR; |
|
| 887 | + |
|
| 888 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 889 | + // Replaces backslashes with forward slashes for Windows systems |
|
| 890 | + $image = wp_normalize_path( $image ); |
|
| 891 | + $content_dir = wp_normalize_path( $content_dir ); |
|
| 892 | + } |
|
| 893 | + |
|
| 894 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
| 895 | + } |
|
| 896 | + |
|
| 897 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 898 | + } |
|
| 899 | + echo $option . '</label>'; |
|
| 900 | + } |
|
| 901 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 902 | + } |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | function wpinv_radio_callback( $args ) { |
| 906 | - global $wpinv_options; |
|
| 906 | + global $wpinv_options; |
|
| 907 | 907 | |
| 908 | 908 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 909 | 909 | |
| 910 | 910 | foreach ( $args['options'] as $key => $option ) : |
| 911 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 911 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 912 | 912 | |
| 913 | 913 | $checked = false; |
| 914 | 914 | |
| 915 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 916 | - $checked = true; |
|
| 917 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 918 | - $checked = true; |
|
| 915 | + if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 916 | + $checked = true; |
|
| 917 | + elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 918 | + $checked = true; |
|
| 919 | 919 | |
| 920 | - echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
| 921 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 922 | - endforeach; |
|
| 920 | + echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
| 921 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 922 | + endforeach; |
|
| 923 | 923 | |
| 924 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 924 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | function wpinv_gateways_callback( $args ) { |
| 928 | - global $wpinv_options; |
|
| 928 | + global $wpinv_options; |
|
| 929 | 929 | |
| 930 | 930 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 931 | 931 | |
| 932 | - foreach ( $args['options'] as $key => $option ) : |
|
| 933 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 932 | + foreach ( $args['options'] as $key => $option ) : |
|
| 933 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 934 | 934 | |
| 935 | 935 | if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
| 936 | - $enabled = '1'; |
|
| 937 | - else |
|
| 938 | - $enabled = null; |
|
| 936 | + $enabled = '1'; |
|
| 937 | + else |
|
| 938 | + $enabled = null; |
|
| 939 | 939 | |
| 940 | - 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) . '/> '; |
|
| 941 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 942 | - endforeach; |
|
| 940 | + 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) . '/> '; |
|
| 941 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 942 | + endforeach; |
|
| 943 | 943 | } |
| 944 | 944 | |
| 945 | 945 | function wpinv_gateway_select_callback($args) { |
| 946 | - global $wpinv_options; |
|
| 946 | + global $wpinv_options; |
|
| 947 | 947 | |
| 948 | 948 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 949 | 949 | |
| 950 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
|
| 950 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
|
| 951 | 951 | |
| 952 | - foreach ( $args['options'] as $key => $option ) : |
|
| 953 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 952 | + foreach ( $args['options'] as $key => $option ) : |
|
| 953 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 954 | 954 | $selected = selected( $key, $args['selected'], false ); |
| 955 | 955 | } else { |
| 956 | 956 | $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
| 957 | 957 | } |
| 958 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 959 | - endforeach; |
|
| 958 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 959 | + endforeach; |
|
| 960 | 960 | |
| 961 | - echo '</select>'; |
|
| 962 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 961 | + echo '</select>'; |
|
| 962 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | function wpinv_text_callback( $args ) { |
| 966 | - global $wpinv_options; |
|
| 966 | + global $wpinv_options; |
|
| 967 | 967 | |
| 968 | 968 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 969 | 969 | |
| 970 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 971 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 972 | - } else { |
|
| 973 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 974 | - } |
|
| 975 | - |
|
| 976 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 977 | - $args['readonly'] = true; |
|
| 978 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 979 | - $name = ''; |
|
| 980 | - } else { |
|
| 981 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 982 | - } |
|
| 983 | - |
|
| 984 | - $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
| 985 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 986 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 987 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 988 | - |
|
| 989 | - echo $html; |
|
| 970 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 971 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 972 | + } else { |
|
| 973 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 974 | + } |
|
| 975 | + |
|
| 976 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 977 | + $args['readonly'] = true; |
|
| 978 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 979 | + $name = ''; |
|
| 980 | + } else { |
|
| 981 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 982 | + } |
|
| 983 | + |
|
| 984 | + $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
| 985 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 986 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 987 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 988 | + |
|
| 989 | + echo $html; |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | function wpinv_number_callback( $args ) { |
| 993 | - global $wpinv_options; |
|
| 993 | + global $wpinv_options; |
|
| 994 | 994 | |
| 995 | 995 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 996 | 996 | |
| 997 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 998 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 999 | - } else { |
|
| 1000 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1001 | - } |
|
| 1002 | - |
|
| 1003 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1004 | - $args['readonly'] = true; |
|
| 1005 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1006 | - $name = ''; |
|
| 1007 | - } else { |
|
| 1008 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1009 | - } |
|
| 1010 | - |
|
| 1011 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 1012 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 1013 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 1014 | - |
|
| 1015 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1016 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1017 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1018 | - |
|
| 1019 | - echo $html; |
|
| 997 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 998 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 999 | + } else { |
|
| 1000 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1001 | + } |
|
| 1002 | + |
|
| 1003 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1004 | + $args['readonly'] = true; |
|
| 1005 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1006 | + $name = ''; |
|
| 1007 | + } else { |
|
| 1008 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1009 | + } |
|
| 1010 | + |
|
| 1011 | + $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 1012 | + $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 1013 | + $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 1014 | + |
|
| 1015 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1016 | + $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1017 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1018 | + |
|
| 1019 | + echo $html; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | function wpinv_textarea_callback( $args ) { |
| 1023 | - global $wpinv_options; |
|
| 1023 | + global $wpinv_options; |
|
| 1024 | 1024 | |
| 1025 | 1025 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1026 | 1026 | |
| 1027 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1028 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1029 | - } else { |
|
| 1030 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1031 | - } |
|
| 1027 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1028 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1029 | + } else { |
|
| 1030 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1031 | + } |
|
| 1032 | 1032 | |
| 1033 | 1033 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
| 1034 | 1034 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
| 1035 | 1035 | |
| 1036 | - $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>'; |
|
| 1037 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1036 | + $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>'; |
|
| 1037 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1038 | 1038 | |
| 1039 | - echo $html; |
|
| 1039 | + echo $html; |
|
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | function wpinv_password_callback( $args ) { |
| 1043 | - global $wpinv_options; |
|
| 1043 | + global $wpinv_options; |
|
| 1044 | 1044 | |
| 1045 | 1045 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1046 | 1046 | |
| 1047 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1048 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1049 | - } else { |
|
| 1050 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1051 | - } |
|
| 1047 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1048 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1049 | + } else { |
|
| 1050 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1051 | + } |
|
| 1052 | 1052 | |
| 1053 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1054 | - $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 ) . '"/>'; |
|
| 1055 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1053 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1054 | + $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 ) . '"/>'; |
|
| 1055 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1056 | 1056 | |
| 1057 | - echo $html; |
|
| 1057 | + echo $html; |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | function wpinv_missing_callback($args) { |
| 1061 | - printf( |
|
| 1062 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 1063 | - '<strong>' . $args['id'] . '</strong>' |
|
| 1064 | - ); |
|
| 1061 | + printf( |
|
| 1062 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 1063 | + '<strong>' . $args['id'] . '</strong>' |
|
| 1064 | + ); |
|
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | 1067 | function wpinv_select_callback($args) { |
| 1068 | - global $wpinv_options; |
|
| 1068 | + global $wpinv_options; |
|
| 1069 | 1069 | |
| 1070 | 1070 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1071 | 1071 | |
| 1072 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1073 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1074 | - } else { |
|
| 1075 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1076 | - } |
|
| 1072 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1073 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1074 | + } else { |
|
| 1075 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1076 | + } |
|
| 1077 | 1077 | |
| 1078 | 1078 | if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
| 1079 | 1079 | $value = $args['selected']; |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1083 | - $placeholder = $args['placeholder']; |
|
| 1084 | - } else { |
|
| 1085 | - $placeholder = ''; |
|
| 1086 | - } |
|
| 1087 | - |
|
| 1088 | - if ( isset( $args['chosen'] ) ) { |
|
| 1089 | - $chosen = 'class="wpinv-chosen"'; |
|
| 1090 | - } else { |
|
| 1091 | - $chosen = ''; |
|
| 1092 | - } |
|
| 1082 | + if ( isset( $args['placeholder'] ) ) { |
|
| 1083 | + $placeholder = $args['placeholder']; |
|
| 1084 | + } else { |
|
| 1085 | + $placeholder = ''; |
|
| 1086 | + } |
|
| 1087 | + |
|
| 1088 | + if ( isset( $args['chosen'] ) ) { |
|
| 1089 | + $chosen = 'class="wpinv-chosen"'; |
|
| 1090 | + } else { |
|
| 1091 | + $chosen = ''; |
|
| 1092 | + } |
|
| 1093 | 1093 | |
| 1094 | 1094 | if( !empty( $args['onchange'] ) ) { |
| 1095 | 1095 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
@@ -1097,143 +1097,143 @@ discard block |
||
| 1097 | 1097 | $onchange = ''; |
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 1100 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 1101 | 1101 | |
| 1102 | - foreach ( $args['options'] as $option => $name ) { |
|
| 1103 | - $selected = selected( $option, $value, false ); |
|
| 1104 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1105 | - } |
|
| 1102 | + foreach ( $args['options'] as $option => $name ) { |
|
| 1103 | + $selected = selected( $option, $value, false ); |
|
| 1104 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1105 | + } |
|
| 1106 | 1106 | |
| 1107 | - $html .= '</select>'; |
|
| 1108 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1107 | + $html .= '</select>'; |
|
| 1108 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1109 | 1109 | |
| 1110 | - echo $html; |
|
| 1110 | + echo $html; |
|
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | 1113 | function wpinv_color_select_callback( $args ) { |
| 1114 | - global $wpinv_options; |
|
| 1114 | + global $wpinv_options; |
|
| 1115 | 1115 | |
| 1116 | 1116 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1117 | 1117 | |
| 1118 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1119 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1120 | - } else { |
|
| 1121 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1122 | - } |
|
| 1118 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1119 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1120 | + } else { |
|
| 1121 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1122 | + } |
|
| 1123 | 1123 | |
| 1124 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 1124 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 1125 | 1125 | |
| 1126 | - foreach ( $args['options'] as $option => $color ) { |
|
| 1127 | - $selected = selected( $option, $value, false ); |
|
| 1128 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 1129 | - } |
|
| 1126 | + foreach ( $args['options'] as $option => $color ) { |
|
| 1127 | + $selected = selected( $option, $value, false ); |
|
| 1128 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 1129 | + } |
|
| 1130 | 1130 | |
| 1131 | - $html .= '</select>'; |
|
| 1132 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1131 | + $html .= '</select>'; |
|
| 1132 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1133 | 1133 | |
| 1134 | - echo $html; |
|
| 1134 | + echo $html; |
|
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | 1137 | function wpinv_rich_editor_callback( $args ) { |
| 1138 | - global $wpinv_options, $wp_version; |
|
| 1138 | + global $wpinv_options, $wp_version; |
|
| 1139 | 1139 | |
| 1140 | 1140 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1141 | 1141 | |
| 1142 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1143 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1142 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1143 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1144 | 1144 | |
| 1145 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 1146 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1147 | - } |
|
| 1148 | - } else { |
|
| 1149 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1150 | - } |
|
| 1145 | + if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 1146 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1147 | + } |
|
| 1148 | + } else { |
|
| 1149 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1150 | + } |
|
| 1151 | 1151 | |
| 1152 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 1152 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 1153 | 1153 | |
| 1154 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 1155 | - ob_start(); |
|
| 1156 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
| 1157 | - $html = ob_get_clean(); |
|
| 1158 | - } else { |
|
| 1159 | - $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>'; |
|
| 1160 | - } |
|
| 1154 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 1155 | + ob_start(); |
|
| 1156 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
| 1157 | + $html = ob_get_clean(); |
|
| 1158 | + } else { |
|
| 1159 | + $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>'; |
|
| 1160 | + } |
|
| 1161 | 1161 | |
| 1162 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1162 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1163 | 1163 | |
| 1164 | - echo $html; |
|
| 1164 | + echo $html; |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | function wpinv_upload_callback( $args ) { |
| 1168 | - global $wpinv_options; |
|
| 1168 | + global $wpinv_options; |
|
| 1169 | 1169 | |
| 1170 | 1170 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1171 | 1171 | |
| 1172 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1173 | - $value = $wpinv_options[$args['id']]; |
|
| 1174 | - } else { |
|
| 1175 | - $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1176 | - } |
|
| 1172 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1173 | + $value = $wpinv_options[$args['id']]; |
|
| 1174 | + } else { |
|
| 1175 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1176 | + } |
|
| 1177 | 1177 | |
| 1178 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1179 | - $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 ) ) . '"/>'; |
|
| 1180 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 1181 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1178 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1179 | + $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 ) ) . '"/>'; |
|
| 1180 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 1181 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1182 | 1182 | |
| 1183 | - echo $html; |
|
| 1183 | + echo $html; |
|
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | 1186 | function wpinv_color_callback( $args ) { |
| 1187 | - global $wpinv_options; |
|
| 1187 | + global $wpinv_options; |
|
| 1188 | 1188 | |
| 1189 | 1189 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1190 | 1190 | |
| 1191 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1192 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1193 | - } else { |
|
| 1194 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1195 | - } |
|
| 1191 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1192 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1193 | + } else { |
|
| 1194 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1195 | + } |
|
| 1196 | 1196 | |
| 1197 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1197 | + $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1198 | 1198 | |
| 1199 | - $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 ) . '" />'; |
|
| 1200 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1199 | + $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 ) . '" />'; |
|
| 1200 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1201 | 1201 | |
| 1202 | - echo $html; |
|
| 1202 | + echo $html; |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | function wpinv_country_states_callback($args) { |
| 1206 | - global $wpinv_options; |
|
| 1206 | + global $wpinv_options; |
|
| 1207 | 1207 | |
| 1208 | 1208 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1209 | 1209 | |
| 1210 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1211 | - $placeholder = $args['placeholder']; |
|
| 1212 | - } else { |
|
| 1213 | - $placeholder = ''; |
|
| 1214 | - } |
|
| 1210 | + if ( isset( $args['placeholder'] ) ) { |
|
| 1211 | + $placeholder = $args['placeholder']; |
|
| 1212 | + } else { |
|
| 1213 | + $placeholder = ''; |
|
| 1214 | + } |
|
| 1215 | 1215 | |
| 1216 | - $states = wpinv_get_country_states(); |
|
| 1216 | + $states = wpinv_get_country_states(); |
|
| 1217 | 1217 | |
| 1218 | - $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
| 1219 | - $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1220 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 1218 | + $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
| 1219 | + $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1220 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 1221 | 1221 | |
| 1222 | - foreach ( $states as $option => $name ) { |
|
| 1223 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 1224 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1225 | - } |
|
| 1222 | + foreach ( $states as $option => $name ) { |
|
| 1223 | + $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 1224 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1225 | + } |
|
| 1226 | 1226 | |
| 1227 | - $html .= '</select>'; |
|
| 1228 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1227 | + $html .= '</select>'; |
|
| 1228 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1229 | 1229 | |
| 1230 | - echo $html; |
|
| 1230 | + echo $html; |
|
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | 1233 | function wpinv_tax_rates_callback($args) { |
| 1234 | - global $wpinv_options; |
|
| 1235 | - $rates = wpinv_get_tax_rates(); |
|
| 1236 | - ob_start(); ?> |
|
| 1234 | + global $wpinv_options; |
|
| 1235 | + $rates = wpinv_get_tax_rates(); |
|
| 1236 | + ob_start(); ?> |
|
| 1237 | 1237 | </td><tr> |
| 1238 | 1238 | <td colspan="2" class="wpinv_tax_tdbox"> |
| 1239 | 1239 | <p><?php echo $args['desc']; ?></p> |
@@ -1257,41 +1257,41 @@ discard block |
||
| 1257 | 1257 | <tr> |
| 1258 | 1258 | <td class="wpinv_tax_country"> |
| 1259 | 1259 | <?php |
| 1260 | - echo wpinv_html_select( array( |
|
| 1261 | - 'options' => wpinv_get_country_list( true ), |
|
| 1262 | - 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
| 1260 | + echo wpinv_html_select( array( |
|
| 1261 | + 'options' => wpinv_get_country_list( true ), |
|
| 1262 | + 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
| 1263 | 1263 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1264 | - 'selected' => $rate['country'], |
|
| 1265 | - 'show_option_all' => false, |
|
| 1266 | - 'show_option_none' => false, |
|
| 1267 | - 'class' => 'wpinv-tax-country', |
|
| 1268 | - 'chosen' => false, |
|
| 1269 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1270 | - ) ); |
|
| 1271 | - ?> |
|
| 1264 | + 'selected' => $rate['country'], |
|
| 1265 | + 'show_option_all' => false, |
|
| 1266 | + 'show_option_none' => false, |
|
| 1267 | + 'class' => 'wpinv-tax-country', |
|
| 1268 | + 'chosen' => false, |
|
| 1269 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1270 | + ) ); |
|
| 1271 | + ?> |
|
| 1272 | 1272 | </td> |
| 1273 | 1273 | <td class="wpinv_tax_state"> |
| 1274 | 1274 | <?php |
| 1275 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
| 1276 | - if( !empty( $states ) ) { |
|
| 1277 | - echo wpinv_html_select( array( |
|
| 1278 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1279 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
| 1275 | + $states = wpinv_get_country_states( $rate['country'] ); |
|
| 1276 | + if( !empty( $states ) ) { |
|
| 1277 | + echo wpinv_html_select( array( |
|
| 1278 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1279 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
| 1280 | 1280 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1281 | - 'selected' => $rate['state'], |
|
| 1282 | - 'show_option_all' => false, |
|
| 1283 | - 'show_option_none' => false, |
|
| 1284 | - 'chosen' => false, |
|
| 1285 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 1286 | - ) ); |
|
| 1287 | - } else { |
|
| 1288 | - echo wpinv_html_text( array( |
|
| 1289 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
| 1290 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 1281 | + 'selected' => $rate['state'], |
|
| 1282 | + 'show_option_all' => false, |
|
| 1283 | + 'show_option_none' => false, |
|
| 1284 | + 'chosen' => false, |
|
| 1285 | + 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 1286 | + ) ); |
|
| 1287 | + } else { |
|
| 1288 | + echo wpinv_html_text( array( |
|
| 1289 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
| 1290 | + 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 1291 | 1291 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1292 | - ) ); |
|
| 1293 | - } |
|
| 1294 | - ?> |
|
| 1292 | + ) ); |
|
| 1293 | + } |
|
| 1294 | + ?> |
|
| 1295 | 1295 | </td> |
| 1296 | 1296 | <td class="wpinv_tax_global"> |
| 1297 | 1297 | <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'] ) ); ?>/> |
@@ -1306,20 +1306,20 @@ discard block |
||
| 1306 | 1306 | <tr> |
| 1307 | 1307 | <td class="wpinv_tax_country"> |
| 1308 | 1308 | <?php |
| 1309 | - echo wpinv_html_select( array( |
|
| 1310 | - 'options' => wpinv_get_country_list( true ), |
|
| 1311 | - 'name' => 'tax_rates[0][country]', |
|
| 1312 | - 'show_option_all' => false, |
|
| 1313 | - 'show_option_none' => false, |
|
| 1314 | - 'class' => 'wpinv-tax-country', |
|
| 1315 | - 'chosen' => false, |
|
| 1316 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1317 | - ) ); ?> |
|
| 1309 | + echo wpinv_html_select( array( |
|
| 1310 | + 'options' => wpinv_get_country_list( true ), |
|
| 1311 | + 'name' => 'tax_rates[0][country]', |
|
| 1312 | + 'show_option_all' => false, |
|
| 1313 | + 'show_option_none' => false, |
|
| 1314 | + 'class' => 'wpinv-tax-country', |
|
| 1315 | + 'chosen' => false, |
|
| 1316 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1317 | + ) ); ?> |
|
| 1318 | 1318 | </td> |
| 1319 | 1319 | <td class="wpinv_tax_state"> |
| 1320 | 1320 | <?php echo wpinv_html_text( array( |
| 1321 | - 'name' => 'tax_rates[0][state]' |
|
| 1322 | - ) ); ?> |
|
| 1321 | + 'name' => 'tax_rates[0][state]' |
|
| 1322 | + ) ); ?> |
|
| 1323 | 1323 | </td> |
| 1324 | 1324 | <td class="wpinv_tax_global"> |
| 1325 | 1325 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
@@ -1334,7 +1334,7 @@ discard block |
||
| 1334 | 1334 | <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> |
| 1335 | 1335 | </table> |
| 1336 | 1336 | <?php |
| 1337 | - echo ob_get_clean(); |
|
| 1337 | + echo ob_get_clean(); |
|
| 1338 | 1338 | } |
| 1339 | 1339 | |
| 1340 | 1340 | function wpinv_tools_callback($args) { |
@@ -1362,14 +1362,14 @@ discard block |
||
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | 1364 | function wpinv_descriptive_text_callback( $args ) { |
| 1365 | - echo wp_kses_post( $args['desc'] ); |
|
| 1365 | + echo wp_kses_post( $args['desc'] ); |
|
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | 1368 | function wpinv_hook_callback( $args ) { |
| 1369 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1369 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | 1372 | function wpinv_set_settings_cap() { |
| 1373 | - return 'manage_options'; |
|
| 1373 | + return 'manage_options'; |
|
| 1374 | 1374 | } |
| 1375 | 1375 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
@@ -152,57 +152,57 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | function wpinv_admin_messages() { |
| 155 | - global $wpinv_options; |
|
| 155 | + global $wpinv_options; |
|
| 156 | 156 | |
| 157 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 158 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
| 159 | - } |
|
| 157 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 158 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 162 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 163 | - } |
|
| 161 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 162 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 166 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
| 167 | - } |
|
| 165 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 166 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 170 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
| 171 | - } |
|
| 169 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 170 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 174 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 175 | - } |
|
| 173 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 174 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 178 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
| 179 | - } |
|
| 177 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 178 | + add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 182 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
| 181 | + if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 182 | + add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
| 186 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
| 186 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
| 190 | 190 | add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 194 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
| 195 | - } |
|
| 193 | + if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 194 | + add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 198 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
| 199 | - } |
|
| 197 | + if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 198 | + add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 202 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
| 203 | - } |
|
| 201 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 202 | + add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - settings_errors( 'wpinv-notices' ); |
|
| 205 | + settings_errors( 'wpinv-notices' ); |
|
| 206 | 206 | } |
| 207 | 207 | add_action( 'admin_notices', 'wpinv_admin_messages' ); |
| 208 | 208 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | break; |
| 344 | 344 | case 'id' : |
| 345 | 345 | echo $post->ID; |
| 346 | - echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
| 346 | + echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
| 347 | 347 | <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
| 348 | 348 | if ( $wpinv_euvat->allow_vat_rules() ) { |
| 349 | 349 | echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
@@ -13,9 +13,9 @@ |
||
| 13 | 13 | ) ); |
| 14 | 14 | echo '<div class="' . implode( ' ', $classes ) . '">'; |
| 15 | 15 | // Loop error codes and display errors |
| 16 | - foreach ( $errors as $error_id => $error ) { |
|
| 16 | + foreach ( $errors as $error_id => $error ) { |
|
| 17 | 17 | echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __( 'Error', 'invoicing' ) . '</strong>: ' . $error . '</p>'; |
| 18 | - } |
|
| 18 | + } |
|
| 19 | 19 | echo '</div>'; |
| 20 | 20 | wpinv_clear_errors(); |
| 21 | 21 | } |
@@ -286,26 +286,26 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
| 289 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 289 | + $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 290 | 290 | |
| 291 | 291 | $chosen = false; |
| 292 | 292 | if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
| 293 | 293 | $chosen = $invoice->get_gateway(); |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
| 296 | + $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
| 297 | 297 | |
| 298 | - if ( false !== $chosen ) { |
|
| 299 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
| 300 | - } |
|
| 298 | + if ( false !== $chosen ) { |
|
| 299 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
| 300 | + } |
|
| 301 | 301 | |
| 302 | - if ( ! empty ( $chosen ) ) { |
|
| 303 | - $enabled_gateway = urldecode( $chosen ); |
|
| 304 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
| 305 | - $enabled_gateway = 'manual'; |
|
| 306 | - } else { |
|
| 307 | - $enabled_gateway = wpinv_get_default_gateway(); |
|
| 308 | - } |
|
| 302 | + if ( ! empty ( $chosen ) ) { |
|
| 303 | + $enabled_gateway = urldecode( $chosen ); |
|
| 304 | + } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
| 305 | + $enabled_gateway = 'manual'; |
|
| 306 | + } else { |
|
| 307 | + $enabled_gateway = wpinv_get_default_gateway(); |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | 310 | if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
| 311 | 311 | if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
| 319 | + return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
@@ -324,21 +324,21 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
| 327 | - $ret = 0; |
|
| 328 | - $args = array( |
|
| 329 | - 'meta_key' => '_wpinv_gateway', |
|
| 330 | - 'meta_value' => $gateway_id, |
|
| 331 | - 'nopaging' => true, |
|
| 332 | - 'post_type' => 'wpi_invoice', |
|
| 333 | - 'post_status' => $status, |
|
| 334 | - 'fields' => 'ids' |
|
| 335 | - ); |
|
| 336 | - |
|
| 337 | - $payments = new WP_Query( $args ); |
|
| 338 | - |
|
| 339 | - if( $payments ) |
|
| 340 | - $ret = $payments->post_count; |
|
| 341 | - return $ret; |
|
| 327 | + $ret = 0; |
|
| 328 | + $args = array( |
|
| 329 | + 'meta_key' => '_wpinv_gateway', |
|
| 330 | + 'meta_value' => $gateway_id, |
|
| 331 | + 'nopaging' => true, |
|
| 332 | + 'post_type' => 'wpi_invoice', |
|
| 333 | + 'post_status' => $status, |
|
| 334 | + 'fields' => 'ids' |
|
| 335 | + ); |
|
| 336 | + |
|
| 337 | + $payments = new WP_Query( $args ); |
|
| 338 | + |
|
| 339 | + if( $payments ) |
|
| 340 | + $ret = $payments->post_count; |
|
| 341 | + return $ret; |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | function wpinv_settings_update_gateways( $input ) { |