@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function wpinv_subscriptions_page() { |
| 10 | 10 | |
| 11 | - if ( ! empty( $_GET['id'] ) ) { |
|
| 11 | + if (!empty($_GET['id'])) { |
|
| 12 | 12 | |
| 13 | 13 | wpinv_recurring_subscription_details(); |
| 14 | 14 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | <div class="wrap"> |
| 20 | 20 | |
| 21 | 21 | <h1> |
| 22 | - <?php _e( 'Subscriptions', 'invoicing' ); ?> |
|
| 22 | + <?php _e('Subscriptions', 'invoicing'); ?> |
|
| 23 | 23 | </h1> |
| 24 | 24 | <?php |
| 25 | 25 | $subscribers_table = new WPInv_Subscription_Reports_Table(); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | <input type="hidden" name="post_type" value="download" /> |
| 32 | 32 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
| 33 | 33 | <?php $subscribers_table->views(); ?> |
| 34 | - <?php $subscribers_table->search_box( __( 'Search', 'wpinvoicing' ), 'subscriptions' ); ?> |
|
| 34 | + <?php $subscribers_table->search_box(__('Search', 'wpinvoicing'), 'subscriptions'); ?> |
|
| 35 | 35 | <?php $subscribers_table->display(); ?> |
| 36 | 36 | |
| 37 | 37 | </form> |
@@ -49,34 +49,34 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $render = true; |
| 51 | 51 | |
| 52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
| 53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
| 52 | + if (!current_user_can('manage_invoicing')) { |
|
| 53 | + die(__('You are not permitted to view this data.', 'invoicing')); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
| 57 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
| 56 | + if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { |
|
| 57 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $sub_id = (int) $_GET['id']; |
|
| 61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
| 60 | + $sub_id = (int)$_GET['id']; |
|
| 61 | + $sub = new WPInv_Subscription($sub_id); |
|
| 62 | 62 | |
| 63 | - if ( empty( $sub ) ) { |
|
| 64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
| 63 | + if (empty($sub)) { |
|
| 64 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | ?> |
| 68 | 68 | <div class="wrap"> |
| 69 | - <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
| 69 | + <h2><?php _e('Subscription Details', 'invoicing'); ?></h2> |
|
| 70 | 70 | |
| 71 | - <?php if ( $sub ) : ?> |
|
| 71 | + <?php if ($sub) : ?> |
|
| 72 | 72 | |
| 73 | 73 | <div id="wpinv-item-card-wrapper"> |
| 74 | 74 | |
| 75 | - <?php do_action( 'wpinv_subscription_card_top', $sub ); ?> |
|
| 75 | + <?php do_action('wpinv_subscription_card_top', $sub); ?> |
|
| 76 | 76 | |
| 77 | 77 | <div class="info-wrapper item-section"> |
| 78 | 78 | |
| 79 | - <form id="edit-item-info" method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $sub->id ); ?>"> |
|
| 79 | + <form id="edit-item-info" method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . $sub->id); ?>"> |
|
| 80 | 80 | |
| 81 | 81 | <div class="item-info"> |
| 82 | 82 | |
@@ -84,124 +84,124 @@ discard block |
||
| 84 | 84 | <tbody> |
| 85 | 85 | <tr> |
| 86 | 86 | <td class="row-title"> |
| 87 | - <label for="tablecell"><?php _e( 'Billing Cycle:', 'invoicing' ); ?></label> |
|
| 87 | + <label for="tablecell"><?php _e('Billing Cycle:', 'invoicing'); ?></label> |
|
| 88 | 88 | </td> |
| 89 | 89 | <td> |
| 90 | 90 | <?php |
| 91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
| 92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
| 93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
| 94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
| 91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($sub->period, $sub->frequency); |
|
| 92 | + $billing = wpinv_price(wpinv_format_amount($sub->recurring_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)) . ' / ' . $frequency; |
|
| 93 | + $initial = wpinv_price(wpinv_format_amount($sub->initial_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)); |
|
| 94 | + printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); |
|
| 95 | 95 | ?> |
| 96 | 96 | </td> |
| 97 | 97 | </tr> |
| 98 | 98 | <tr> |
| 99 | 99 | <td class="row-title"> |
| 100 | - <label for="tablecell"><?php _e( 'Times Billed:', 'invoicing' ); ?></label> |
|
| 100 | + <label for="tablecell"><?php _e('Times Billed:', 'invoicing'); ?></label> |
|
| 101 | 101 | </td> |
| 102 | - <td><?php echo $sub->get_times_billed() . ' / ' . ( ( $sub->bill_times == 0 ) ? 'Until Cancelled' : $sub->bill_times ); ?></td> |
|
| 102 | + <td><?php echo $sub->get_times_billed() . ' / ' . (($sub->bill_times == 0) ? 'Until Cancelled' : $sub->bill_times); ?></td> |
|
| 103 | 103 | </tr> |
| 104 | 104 | <tr> |
| 105 | 105 | <td class="row-title"> |
| 106 | - <label for="tablecell"><?php _e( 'Customer:', 'invoicing' ); ?></label> |
|
| 106 | + <label for="tablecell"><?php _e('Customer:', 'invoicing'); ?></label> |
|
| 107 | 107 | </td> |
| 108 | 108 | <td> |
| 109 | - <?php $subscriber = get_userdata( $sub->customer_id ); ?> |
|
| 110 | - <a href="<?php echo esc_url( get_edit_user_link( $sub->customer_id ) ); ?>" target="_blank"><?php echo ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
| 109 | + <?php $subscriber = get_userdata($sub->customer_id); ?> |
|
| 110 | + <a href="<?php echo esc_url(get_edit_user_link($sub->customer_id)); ?>" target="_blank"><?php echo !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
| 111 | 111 | </td> |
| 112 | 112 | </tr> |
| 113 | 113 | <tr> |
| 114 | 114 | <td class="row-title"> |
| 115 | - <label for="tablecell"><?php _e( 'Initial Invoice:', 'invoicing' ); ?></label> |
|
| 115 | + <label for="tablecell"><?php _e('Initial Invoice:', 'invoicing'); ?></label> |
|
| 116 | 116 | </td> |
| 117 | 117 | <td> |
| 118 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $sub->parent_payment_id ) ); ?>"><?php echo wpinv_get_invoice_number( $sub->parent_payment_id ); ?></a> <?php echo wp_sprintf( __( '( ID: %s )', 'invoicing' ), '<a title="' . esc_attr( __( 'View invoice details', 'invoicing' ) ) . '" href="' . get_edit_post_link( $sub->parent_payment_id ) . '" target="_blank">' . $sub->parent_payment_id . '</a>' ); ?></td> |
|
| 118 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($sub->parent_payment_id)); ?>"><?php echo wpinv_get_invoice_number($sub->parent_payment_id); ?></a> <?php echo wp_sprintf(__('( ID: %s )', 'invoicing'), '<a title="' . esc_attr(__('View invoice details', 'invoicing')) . '" href="' . get_edit_post_link($sub->parent_payment_id) . '" target="_blank">' . $sub->parent_payment_id . '</a>'); ?></td> |
|
| 119 | 119 | </tr> |
| 120 | 120 | <tr> |
| 121 | 121 | <td class="row-title"> |
| 122 | - <label for="tablecell"><?php _e( 'Item:', 'invoicing' ); ?></label> |
|
| 122 | + <label for="tablecell"><?php _e('Item:', 'invoicing'); ?></label> |
|
| 123 | 123 | </td> |
| 124 | 124 | <td> |
| 125 | 125 | <?php |
| 126 | - echo wpinv_item_dropdown( array( |
|
| 126 | + echo wpinv_item_dropdown(array( |
|
| 127 | 127 | 'name' => 'product_id', |
| 128 | 128 | 'id' => 'wpinv_invoice_item', |
| 129 | 129 | 'with_packages' => false, |
| 130 | 130 | 'show_recurring' => true, |
| 131 | 131 | 'selected' => $sub->product_id, |
| 132 | 132 | 'class' => 'wpinv-sub-product-id wpi_select2', |
| 133 | - ) ); |
|
| 133 | + )); |
|
| 134 | 134 | |
| 135 | 135 | ?> |
| 136 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 136 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 137 | 137 | 'post' => $sub->product_id, |
| 138 | 138 | 'action' => 'edit' |
| 139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
| 139 | + ), admin_url('post.php'))); ?>" target="_blank"><?php _e('View Item', 'invoicing'); ?></a> |
|
| 140 | 140 | </td> |
| 141 | 141 | </tr> |
| 142 | 142 | <tr> |
| 143 | 143 | <td class="row-title"> |
| 144 | - <label for="tablecell"><?php _e( 'Payment Method:', 'invoicing' ); ?></label> |
|
| 144 | + <label for="tablecell"><?php _e('Payment Method:', 'invoicing'); ?></label> |
|
| 145 | 145 | </td> |
| 146 | - <td><?php echo wpinv_get_gateway_admin_label( wpinv_get_payment_gateway( $sub->parent_payment_id ) ); ?></td> |
|
| 146 | + <td><?php echo wpinv_get_gateway_admin_label(wpinv_get_payment_gateway($sub->parent_payment_id)); ?></td> |
|
| 147 | 147 | </tr> |
| 148 | 148 | <tr> |
| 149 | 149 | <td class="row-title"> |
| 150 | - <label for="tablecell"><?php _e( 'Profile ID:', 'invoicing' ); ?></label> |
|
| 150 | + <label for="tablecell"><?php _e('Profile ID:', 'invoicing'); ?></label> |
|
| 151 | 151 | </td> |
| 152 | 152 | <td> |
| 153 | 153 | <span class="wpinv-sub-profile-id"> |
| 154 | - <?php echo apply_filters( 'wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub ); ?> |
|
| 154 | + <?php echo apply_filters('wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub); ?> |
|
| 155 | 155 | </span> |
| 156 | - <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr( $sub->profile_id ); ?>" /> |
|
| 156 | + <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr($sub->profile_id); ?>" /> |
|
| 157 | 157 | <span> – </span> |
| 158 | - <a href="#" class="wpinv-edit-sub-profile-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
| 158 | + <a href="#" class="wpinv-edit-sub-profile-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
| 159 | 159 | </td> |
| 160 | 160 | </tr> |
| 161 | 161 | <tr> |
| 162 | 162 | <td class="row-title"> |
| 163 | - <label for="tablecell"><?php _e( 'Transaction ID:', 'invoicing' ); ?></label> |
|
| 163 | + <label for="tablecell"><?php _e('Transaction ID:', 'invoicing'); ?></label> |
|
| 164 | 164 | </td> |
| 165 | 165 | <td> |
| 166 | - <span class="wpinv-sub-transaction-id"><?php echo apply_filters( 'wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub ); ?></span> |
|
| 167 | - <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr( $sub->get_transaction_id() ); ?>" /> |
|
| 166 | + <span class="wpinv-sub-transaction-id"><?php echo apply_filters('wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub); ?></span> |
|
| 167 | + <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr($sub->get_transaction_id()); ?>" /> |
|
| 168 | 168 | <span> – </span> |
| 169 | - <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
| 169 | + <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
| 170 | 170 | </td> |
| 171 | 171 | </tr> |
| 172 | 172 | <tr> |
| 173 | 173 | <td class="row-title"> |
| 174 | - <label for="tablecell"><?php _e( 'Date Created:', 'invoicing' ); ?></label> |
|
| 174 | + <label for="tablecell"><?php _e('Date Created:', 'invoicing'); ?></label> |
|
| 175 | 175 | </td> |
| 176 | - <td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->created, current_time( 'timestamp' ) ) ); ?></td> |
|
| 176 | + <td><?php echo date_i18n(get_option('date_format'), strtotime($sub->created, current_time('timestamp'))); ?></td> |
|
| 177 | 177 | </tr> |
| 178 | 178 | <tr> |
| 179 | 179 | <td class="row-title"> |
| 180 | 180 | <label for="tablecell"> |
| 181 | - <?php if( 'trialling' == $sub->status ) : ?> |
|
| 182 | - <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
|
| 181 | + <?php if ('trialling' == $sub->status) : ?> |
|
| 182 | + <?php _e('Trialling Until:', 'invoicing'); ?> |
|
| 183 | 183 | <?php else: ?> |
| 184 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
| 184 | + <?php _e('Expiration Date:', 'invoicing'); ?> |
|
| 185 | 185 | <?php endif; ?> |
| 186 | 186 | </label> |
| 187 | 187 | </td> |
| 188 | 188 | <td> |
| 189 | - <span class="wpinv-sub-expiration"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->expiration, current_time( 'timestamp' ) ) ); ?></span> |
|
| 189 | + <span class="wpinv-sub-expiration"><?php echo date_i18n(get_option('date_format'), strtotime($sub->expiration, current_time('timestamp'))); ?></span> |
|
| 190 | 190 | </td> |
| 191 | 191 | </tr> |
| 192 | 192 | <tr> |
| 193 | 193 | <td class="row-title"> |
| 194 | - <label for="tablecell"><?php _e( 'Subscription Status:', 'invoicing' ); ?></label> |
|
| 194 | + <label for="tablecell"><?php _e('Subscription Status:', 'invoicing'); ?></label> |
|
| 195 | 195 | </td> |
| 196 | 196 | <td> |
| 197 | 197 | <select name="status" class="wpi_select2"> |
| 198 | - <option value="pending"<?php selected( 'pending', $sub->status ); ?>><?php _e( 'Pending', 'invoicing' ); ?></option> |
|
| 199 | - <option value="active"<?php selected( 'active', $sub->status ); ?>><?php _e( 'Active', 'invoicing' ); ?></option> |
|
| 200 | - <option value="cancelled"<?php selected( 'cancelled', $sub->status ); ?>><?php _e( 'Cancelled', 'invoicing' ); ?></option> |
|
| 201 | - <option value="expired"<?php selected( 'expired', $sub->status ); ?>><?php _e( 'Expired', 'invoicing' ); ?></option> |
|
| 202 | - <option value="trialling"<?php selected( 'trialling', $sub->status ); ?>><?php _e( 'Trialling', 'invoicing' ); ?></option> |
|
| 203 | - <option value="failing"<?php selected( 'failing', $sub->status ); ?>><?php _e( 'Failing', 'invoicing' ); ?></option> |
|
| 204 | - <option value="completed"<?php selected( 'completed', $sub->status ); ?>><?php _e( 'Completed', 'invoicing' ); ?></option> |
|
| 198 | + <option value="pending"<?php selected('pending', $sub->status); ?>><?php _e('Pending', 'invoicing'); ?></option> |
|
| 199 | + <option value="active"<?php selected('active', $sub->status); ?>><?php _e('Active', 'invoicing'); ?></option> |
|
| 200 | + <option value="cancelled"<?php selected('cancelled', $sub->status); ?>><?php _e('Cancelled', 'invoicing'); ?></option> |
|
| 201 | + <option value="expired"<?php selected('expired', $sub->status); ?>><?php _e('Expired', 'invoicing'); ?></option> |
|
| 202 | + <option value="trialling"<?php selected('trialling', $sub->status); ?>><?php _e('Trialling', 'invoicing'); ?></option> |
|
| 203 | + <option value="failing"<?php selected('failing', $sub->status); ?>><?php _e('Failing', 'invoicing'); ?></option> |
|
| 204 | + <option value="completed"<?php selected('completed', $sub->status); ?>><?php _e('Completed', 'invoicing'); ?></option> |
|
| 205 | 205 | </select> |
| 206 | 206 | </td> |
| 207 | 207 | </tr> |
@@ -209,79 +209,79 @@ discard block |
||
| 209 | 209 | </table> |
| 210 | 210 | </div> |
| 211 | 211 | <div id="wpinv-sub-notices"> |
| 212 | - <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e( 'Changing the product assigned will not automatically adjust any pricing.', 'invoicing' ); ?></p></div> |
|
| 213 | - <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e( 'Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing' ); ?></p></div> |
|
| 212 | + <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e('Changing the product assigned will not automatically adjust any pricing.', 'invoicing'); ?></p></div> |
|
| 213 | + <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e('Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing'); ?></p></div> |
|
| 214 | 214 | </div> |
| 215 | 215 | <div id="item-edit-actions" class="edit-item" style="float:right; margin: 10px 0 0; display: block;"> |
| 216 | - <?php wp_nonce_field( 'wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true ); ?> |
|
| 217 | - <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e( 'Update Subscription', 'invoicing' ); ?>"/> |
|
| 218 | - <input type="hidden" name="sub_id" value="<?php echo absint( $sub->id ); ?>" /> |
|
| 219 | - <?php if( $sub->can_cancel() ) : ?> |
|
| 220 | - <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e( 'Cancel Subscription', 'invoicing' ); ?></a> |
|
| 216 | + <?php wp_nonce_field('wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true); ?> |
|
| 217 | + <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e('Update Subscription', 'invoicing'); ?>"/> |
|
| 218 | + <input type="hidden" name="sub_id" value="<?php echo absint($sub->id); ?>" /> |
|
| 219 | + <?php if ($sub->can_cancel()) : ?> |
|
| 220 | + <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e('Cancel Subscription', 'invoicing'); ?></a> |
|
| 221 | 221 | <?php endif; ?> |
| 222 | - <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e( 'Delete Subscription', 'invoicing' ); ?>"/> |
|
| 222 | + <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e('Delete Subscription', 'invoicing'); ?>"/> |
|
| 223 | 223 | </div> |
| 224 | 224 | |
| 225 | 225 | </form> |
| 226 | 226 | </div> |
| 227 | 227 | |
| 228 | - <?php do_action( 'wpinv_subscription_before_stats', $sub ); ?> |
|
| 228 | + <?php do_action('wpinv_subscription_before_stats', $sub); ?> |
|
| 229 | 229 | |
| 230 | - <?php do_action( 'wpinv_subscription_before_tables_wrapper', $sub ); ?> |
|
| 230 | + <?php do_action('wpinv_subscription_before_tables_wrapper', $sub); ?> |
|
| 231 | 231 | |
| 232 | 232 | <div id="item-tables-wrapper" class="item-section"> |
| 233 | 233 | |
| 234 | - <?php do_action( 'wpinv_subscription_before_tables', $sub ); ?> |
|
| 234 | + <?php do_action('wpinv_subscription_before_tables', $sub); ?> |
|
| 235 | 235 | |
| 236 | - <h3><?php _e( 'Renewal Payments:', 'invoicing' ); ?></h3> |
|
| 236 | + <h3><?php _e('Renewal Payments:', 'invoicing'); ?></h3> |
|
| 237 | 237 | <?php $payments = $sub->get_child_payments(); ?> |
| 238 | - <?php if ( 'manual' == $sub->gateway ) : ?> |
|
| 239 | - <p><strong><?php _e( 'Note:', 'invoicing' ); ?></strong> <?php _e( 'Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing' ); ?></p> |
|
| 238 | + <?php if ('manual' == $sub->gateway) : ?> |
|
| 239 | + <p><strong><?php _e('Note:', 'invoicing'); ?></strong> <?php _e('Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing'); ?></p> |
|
| 240 | 240 | <?php endif; ?> |
| 241 | 241 | <table class="wp-list-table widefat striped payments"> |
| 242 | 242 | <thead> |
| 243 | 243 | <tr> |
| 244 | - <th><?php _e( 'ID', 'invoicing' ); ?></th> |
|
| 245 | - <th><?php _e( 'Amount', 'invoicing' ); ?></th> |
|
| 246 | - <th><?php _e( 'Date', 'invoicing' ); ?></th> |
|
| 247 | - <th><?php _e( 'Status', 'invoicing' ); ?></th> |
|
| 248 | - <th><?php _e( 'Invoice', 'invoicing' ); ?></th> |
|
| 249 | - <th class="column-wpi_actions"><?php _e( 'Actions', 'invoicing' ); ?></th> |
|
| 244 | + <th><?php _e('ID', 'invoicing'); ?></th> |
|
| 245 | + <th><?php _e('Amount', 'invoicing'); ?></th> |
|
| 246 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
| 247 | + <th><?php _e('Status', 'invoicing'); ?></th> |
|
| 248 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
| 249 | + <th class="column-wpi_actions"><?php _e('Actions', 'invoicing'); ?></th> |
|
| 250 | 250 | </tr> |
| 251 | 251 | </thead> |
| 252 | 252 | <tbody> |
| 253 | - <?php if ( ! empty( $payments ) ) : ?> |
|
| 254 | - <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?> |
|
| 253 | + <?php if (!empty($payments)) : ?> |
|
| 254 | + <?php foreach ($payments as $payment) : $invoice = wpinv_get_invoice($payment->ID); if (empty($invoice->ID)) continue; ?> |
|
| 255 | 255 | <tr> |
| 256 | 256 | <td><?php echo $payment->ID; ?></td> |
| 257 | - <td><?php echo $invoice->get_total( true ); ?></td> |
|
| 257 | + <td><?php echo $invoice->get_total(true); ?></td> |
|
| 258 | 258 | <td><?php echo $invoice->get_invoice_date(); ?></td> |
| 259 | - <td><?php echo $invoice->get_status( true ); ?></td> |
|
| 259 | + <td><?php echo $invoice->get_status(true); ?></td> |
|
| 260 | 260 | <td> |
| 261 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $payment->ID ) ); ?>"><?php echo $invoice->get_number(); ?></a> |
|
| 262 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
| 261 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($payment->ID)); ?>"><?php echo $invoice->get_number(); ?></a> |
|
| 262 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
| 263 | 263 | </td> |
| 264 | 264 | <td class="column-wpi_actions"> |
| 265 | - <a title="<?php echo esc_attr( wp_sprintf( __( 'View details for invoice: %s', 'invoicing' ), $invoice->get_number() ) ); ?>" href="<?php echo get_edit_post_link( $payment->ID ); ?>"><?php _e( 'View Details', 'invoicing' ); ?> |
|
| 265 | + <a title="<?php echo esc_attr(wp_sprintf(__('View details for invoice: %s', 'invoicing'), $invoice->get_number())); ?>" href="<?php echo get_edit_post_link($payment->ID); ?>"><?php _e('View Details', 'invoicing'); ?> |
|
| 266 | 266 | </a> |
| 267 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
| 267 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
| 268 | 268 | </td> |
| 269 | 269 | </tr> |
| 270 | 270 | <?php endforeach; ?> |
| 271 | 271 | <?php else: ?> |
| 272 | 272 | <tr> |
| 273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
| 273 | + <td colspan="5"><?php _e('No Invoices Found.', 'invoicing'); ?></td> |
|
| 274 | 274 | </tr> |
| 275 | 275 | <?php endif; ?> |
| 276 | 276 | </tbody> |
| 277 | 277 | <tfoot></tfoot> |
| 278 | 278 | </table> |
| 279 | 279 | |
| 280 | - <?php do_action( 'wpinv_subscription_after_tables', $sub ); ?> |
|
| 280 | + <?php do_action('wpinv_subscription_after_tables', $sub); ?> |
|
| 281 | 281 | |
| 282 | 282 | </div> |
| 283 | 283 | |
| 284 | - <?php do_action( 'wpinv_subscription_card_bottom', $sub ); ?> |
|
| 284 | + <?php do_action('wpinv_subscription_card_bottom', $sub); ?> |
|
| 285 | 285 | </div> |
| 286 | 286 | |
| 287 | 287 | <?php endif; ?> |
@@ -299,36 +299,36 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | function wpinv_recurring_process_subscription_update() { |
| 301 | 301 | |
| 302 | - if( empty( $_POST['sub_id'] ) ) { |
|
| 302 | + if (empty($_POST['sub_id'])) { |
|
| 303 | 303 | return; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
| 306 | + if (empty($_POST['wpinv_update_subscription'])) { |
|
| 307 | 307 | return; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
| 310 | + if (!current_user_can('manage_invoicing')) { |
|
| 311 | 311 | return; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 314 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
| 315 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
| 319 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
| 320 | - $product_id = absint( $_POST['product_id'] ); |
|
| 321 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 322 | - $subscription->update( array( |
|
| 323 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
| 318 | + $profile_id = sanitize_text_field($_POST['profile_id']); |
|
| 319 | + $transaction_id = sanitize_text_field($_POST['transaction_id']); |
|
| 320 | + $product_id = absint($_POST['product_id']); |
|
| 321 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
| 322 | + $subscription->update(array( |
|
| 323 | + 'status' => sanitize_text_field($_POST['status']), |
|
| 324 | 324 | 'profile_id' => $profile_id, |
| 325 | 325 | 'product_id' => $product_id, |
| 326 | 326 | 'transaction_id' => $transaction_id, |
| 327 | - ) ); |
|
| 327 | + )); |
|
| 328 | 328 | |
| 329 | - $status = sanitize_text_field( $_POST['status'] ); |
|
| 329 | + $status = sanitize_text_field($_POST['status']); |
|
| 330 | 330 | |
| 331 | - switch( $status ) { |
|
| 331 | + switch ($status) { |
|
| 332 | 332 | |
| 333 | 333 | case 'cancelled' : |
| 334 | 334 | |
@@ -347,11 +347,11 @@ discard block |
||
| 347 | 347 | |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
| 350 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id)); |
|
| 351 | 351 | exit; |
| 352 | 352 | |
| 353 | 353 | } |
| 354 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
|
| 354 | +add_action('admin_init', 'wpinv_recurring_process_subscription_update', 1); |
|
| 355 | 355 | |
| 356 | 356 | /** |
| 357 | 357 | * Handles subscription deletion |
@@ -362,30 +362,30 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | function wpinv_recurring_process_subscription_deletion() { |
| 364 | 364 | |
| 365 | - if( empty( $_POST['sub_id'] ) ) { |
|
| 365 | + if (empty($_POST['sub_id'])) { |
|
| 366 | 366 | return; |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
| 369 | + if (empty($_POST['wpinv_delete_subscription'])) { |
|
| 370 | 370 | return; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
| 373 | + if (!current_user_can('manage_invoicing')) { |
|
| 374 | 374 | return; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 378 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 377 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
| 378 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 381 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
| 382 | 382 | |
| 383 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
| 383 | + delete_post_meta($subscription->parent_payment_id, '_wpinv_subscription_payment'); |
|
| 384 | 384 | |
| 385 | 385 | $subscription->delete(); |
| 386 | 386 | |
| 387 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
| 387 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=deleted')); |
|
| 388 | 388 | exit; |
| 389 | 389 | |
| 390 | 390 | } |
| 391 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
|
| 391 | +add_action('admin_init', 'wpinv_recurring_process_subscription_deletion', 2); |
|
@@ -7,91 +7,91 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -if ( !is_admin() ) { |
|
| 15 | - add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 16 | - add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' ); |
|
| 17 | - add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' ); |
|
| 18 | - add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' ); |
|
| 14 | +if (!is_admin()) { |
|
| 15 | + add_filter('template_include', 'wpinv_template', 10, 1); |
|
| 16 | + add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar'); |
|
| 17 | + add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions'); |
|
| 18 | + add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions'); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | function wpinv_template_path() { |
| 22 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
| 22 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -function wpinv_display_invoice_top_bar( $invoice ) { |
|
| 26 | - if ( empty( $invoice ) ) { |
|
| 25 | +function wpinv_display_invoice_top_bar($invoice) { |
|
| 26 | + if (empty($invoice)) { |
|
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | ?> |
| 30 | 30 | <div class="row wpinv-top-bar no-print"> |
| 31 | 31 | <div class="container"> |
| 32 | 32 | <div class="col-xs-6"> |
| 33 | - <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?> |
|
| 33 | + <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?> |
|
| 34 | 34 | </div> |
| 35 | 35 | <div class="col-xs-6 text-right"> |
| 36 | - <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?> |
|
| 36 | + <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?> |
|
| 37 | 37 | </div> |
| 38 | 38 | </div> |
| 39 | 39 | </div> |
| 40 | 40 | <?php |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -function wpinv_invoice_display_left_actions( $invoice ) { |
|
| 44 | - if ( empty( $invoice ) ) { |
|
| 43 | +function wpinv_invoice_display_left_actions($invoice) { |
|
| 44 | + if (empty($invoice)) { |
|
| 45 | 45 | return; // Exit if invoice is not set. |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if ( $invoice->post_type == 'wpi_invoice' ) { |
|
| 49 | - if ( $invoice->needs_payment() ) { |
|
| 50 | - ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php |
|
| 48 | + if ($invoice->post_type == 'wpi_invoice') { |
|
| 49 | + if ($invoice->needs_payment()) { |
|
| 50 | + ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | do_action('wpinv_invoice_display_left_actions', $invoice); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
| 57 | - if ( empty( $invoice ) ) { |
|
| 56 | +function wpinv_invoice_display_right_actions($invoice) { |
|
| 57 | + if (empty($invoice)) { |
|
| 58 | 58 | return; // Exit if invoice is not set. |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if ( $invoice->post_type == 'wpi_invoice' ) { ?> |
|
| 62 | - <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
| 63 | - <?php if ( is_user_logged_in() ) { ?> |
|
| 64 | - <a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
| 61 | + if ($invoice->post_type == 'wpi_invoice') { ?> |
|
| 62 | + <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
| 63 | + <?php if (is_user_logged_in()) { ?> |
|
| 64 | + <a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
| 65 | 65 | <?php } |
| 66 | 66 | } |
| 67 | 67 | do_action('wpinv_invoice_display_right_actions', $invoice); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | -function wpinv_before_invoice_content( $content ) { |
|
| 70 | +function wpinv_before_invoice_content($content) { |
|
| 71 | 71 | global $post; |
| 72 | 72 | |
| 73 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
| 73 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
| 74 | 74 | ob_start(); |
| 75 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
| 75 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
| 76 | 76 | $content = ob_get_clean() . $content; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | return $content; |
| 80 | 80 | } |
| 81 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
| 81 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
| 82 | 82 | |
| 83 | -function wpinv_after_invoice_content( $content ) { |
|
| 83 | +function wpinv_after_invoice_content($content) { |
|
| 84 | 84 | global $post; |
| 85 | 85 | |
| 86 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
| 86 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
| 87 | 87 | ob_start(); |
| 88 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
| 88 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
| 89 | 89 | $content .= ob_get_clean(); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $content; |
| 93 | 93 | } |
| 94 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
| 94 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
| 95 | 95 | |
| 96 | 96 | function wpinv_get_templates_dir() { |
| 97 | 97 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -101,105 +101,105 @@ discard block |
||
| 101 | 101 | return WPINV_PLUGIN_URL . 'templates'; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 105 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
| 106 | - extract( $args ); |
|
| 104 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 105 | + if (!empty($args) && is_array($args)) { |
|
| 106 | + extract($args); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 109 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
| 110 | 110 | // Allow 3rd party plugin filter template file from their plugin. |
| 111 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 111 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
| 112 | 112 | |
| 113 | - if ( ! file_exists( $located ) ) { |
|
| 114 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
| 113 | + if (!file_exists($located)) { |
|
| 114 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
| 115 | 115 | return; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 118 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
| 119 | 119 | |
| 120 | - include( $located ); |
|
| 120 | + include($located); |
|
| 121 | 121 | |
| 122 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 122 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 125 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 126 | 126 | ob_start(); |
| 127 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 127 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
| 128 | 128 | return ob_get_clean(); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 132 | - if ( ! $template_path ) { |
|
| 131 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 132 | + if (!$template_path) { |
|
| 133 | 133 | $template_path = wpinv_template_path(); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if ( ! $default_path ) { |
|
| 136 | + if (!$default_path) { |
|
| 137 | 137 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Look within passed path within the theme - this is priority. |
| 141 | 141 | $template = locate_template( |
| 142 | 142 | array( |
| 143 | - trailingslashit( $template_path ) . $template_name, |
|
| 143 | + trailingslashit($template_path) . $template_name, |
|
| 144 | 144 | $template_name |
| 145 | 145 | ) |
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | 148 | // Get default templates/ |
| 149 | - if ( !$template && $default_path ) { |
|
| 150 | - $template = trailingslashit( $default_path ) . $template_name; |
|
| 149 | + if (!$template && $default_path) { |
|
| 150 | + $template = trailingslashit($default_path) . $template_name; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Return what we found. |
| 154 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
| 154 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
| 158 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 157 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
| 158 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
| 159 | 159 | |
| 160 | 160 | // Setup possible parts |
| 161 | 161 | $templates = array(); |
| 162 | - if ( isset( $name ) ) |
|
| 162 | + if (isset($name)) |
|
| 163 | 163 | $templates[] = $slug . '-' . $name . '.php'; |
| 164 | 164 | $templates[] = $slug . '.php'; |
| 165 | 165 | |
| 166 | 166 | // Allow template parts to be filtered |
| 167 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 167 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
| 168 | 168 | |
| 169 | 169 | // Return the part that is found |
| 170 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 170 | + return wpinv_locate_tmpl($templates, $load, false); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
| 173 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
| 174 | 174 | // No file found yet |
| 175 | 175 | $located = false; |
| 176 | 176 | |
| 177 | 177 | // Try to find a template file |
| 178 | - foreach ( (array)$template_names as $template_name ) { |
|
| 178 | + foreach ((array)$template_names as $template_name) { |
|
| 179 | 179 | |
| 180 | 180 | // Continue if template is empty |
| 181 | - if ( empty( $template_name ) ) |
|
| 181 | + if (empty($template_name)) |
|
| 182 | 182 | continue; |
| 183 | 183 | |
| 184 | 184 | // Trim off any slashes from the template name |
| 185 | - $template_name = ltrim( $template_name, '/' ); |
|
| 185 | + $template_name = ltrim($template_name, '/'); |
|
| 186 | 186 | |
| 187 | 187 | // try locating this template file by looping through the template paths |
| 188 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 188 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
| 189 | 189 | |
| 190 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 190 | + if (file_exists($template_path . $template_name)) { |
|
| 191 | 191 | $located = $template_path . $template_name; |
| 192 | 192 | break; |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - if( !empty( $located ) ) { |
|
| 196 | + if (!empty($located)) { |
|
| 197 | 197 | break; |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 202 | - load_template( $located, $require_once ); |
|
| 201 | + if ((true == $load) && !empty($located)) |
|
| 202 | + load_template($located, $require_once); |
|
| 203 | 203 | |
| 204 | 204 | return $located; |
| 205 | 205 | } |
@@ -208,149 +208,149 @@ discard block |
||
| 208 | 208 | $template_dir = wpinv_get_theme_template_dir_name(); |
| 209 | 209 | |
| 210 | 210 | $file_paths = array( |
| 211 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 212 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 211 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
| 212 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
| 213 | 213 | 100 => wpinv_get_templates_dir() |
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 216 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
| 217 | 217 | |
| 218 | 218 | // sort the file paths based on priority |
| 219 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 219 | + ksort($file_paths, SORT_NUMERIC); |
|
| 220 | 220 | |
| 221 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 221 | + return array_map('trailingslashit', $file_paths); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | function wpinv_get_theme_template_dir_name() { |
| 225 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 225 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | function wpinv_checkout_meta_tags() { |
| 229 | 229 | |
| 230 | 230 | $pages = array(); |
| 231 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 232 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 233 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 234 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 231 | + $pages[] = wpinv_get_option('success_page'); |
|
| 232 | + $pages[] = wpinv_get_option('failure_page'); |
|
| 233 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
| 234 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
| 235 | 235 | |
| 236 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 236 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
| 241 | 241 | } |
| 242 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
| 242 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
| 243 | 243 | |
| 244 | -function wpinv_add_body_classes( $class ) { |
|
| 244 | +function wpinv_add_body_classes($class) { |
|
| 245 | 245 | $classes = (array)$class; |
| 246 | 246 | |
| 247 | - if( wpinv_is_checkout() ) { |
|
| 247 | + if (wpinv_is_checkout()) { |
|
| 248 | 248 | $classes[] = 'wpinv-checkout'; |
| 249 | 249 | $classes[] = 'wpinv-page'; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - if( wpinv_is_success_page() ) { |
|
| 252 | + if (wpinv_is_success_page()) { |
|
| 253 | 253 | $classes[] = 'wpinv-success'; |
| 254 | 254 | $classes[] = 'wpinv-page'; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 257 | + if (wpinv_is_failed_transaction_page()) { |
|
| 258 | 258 | $classes[] = 'wpinv-failed-transaction'; |
| 259 | 259 | $classes[] = 'wpinv-page'; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - if( wpinv_is_invoice_history_page() ) { |
|
| 262 | + if (wpinv_is_invoice_history_page()) { |
|
| 263 | 263 | $classes[] = 'wpinv-history'; |
| 264 | 264 | $classes[] = 'wpinv-page'; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if( wpinv_is_subscriptions_history_page() ) { |
|
| 267 | + if (wpinv_is_subscriptions_history_page()) { |
|
| 268 | 268 | $classes[] = 'wpinv-subscription'; |
| 269 | 269 | $classes[] = 'wpinv-page'; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if( wpinv_is_test_mode() ) { |
|
| 272 | + if (wpinv_is_test_mode()) { |
|
| 273 | 273 | $classes[] = 'wpinv-test-mode'; |
| 274 | 274 | $classes[] = 'wpinv-page'; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - return array_unique( $classes ); |
|
| 277 | + return array_unique($classes); |
|
| 278 | 278 | } |
| 279 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
| 279 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
| 280 | 280 | |
| 281 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
| 282 | - $args = array( 'nopaging' => true ); |
|
| 281 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
| 282 | + $args = array('nopaging' => true); |
|
| 283 | 283 | |
| 284 | - if ( ! empty( $status ) ) |
|
| 284 | + if (!empty($status)) |
|
| 285 | 285 | $args['post_status'] = $status; |
| 286 | 286 | |
| 287 | - $discounts = wpinv_get_discounts( $args ); |
|
| 287 | + $discounts = wpinv_get_discounts($args); |
|
| 288 | 288 | $options = array(); |
| 289 | 289 | |
| 290 | - if ( $discounts ) { |
|
| 291 | - foreach ( $discounts as $discount ) { |
|
| 292 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
| 290 | + if ($discounts) { |
|
| 291 | + foreach ($discounts as $discount) { |
|
| 292 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
| 293 | 293 | } |
| 294 | 294 | } else { |
| 295 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
| 295 | + $options[0] = __('No discounts found', 'invoicing'); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - $output = wpinv_html_select( array( |
|
| 298 | + $output = wpinv_html_select(array( |
|
| 299 | 299 | 'name' => $name, |
| 300 | 300 | 'selected' => $selected, |
| 301 | 301 | 'options' => $options, |
| 302 | 302 | 'show_option_all' => false, |
| 303 | 303 | 'show_option_none' => false, |
| 304 | - ) ); |
|
| 304 | + )); |
|
| 305 | 305 | |
| 306 | 306 | return $output; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
| 310 | - $current = date( 'Y' ); |
|
| 311 | - $start_year = $current - absint( $years_before ); |
|
| 312 | - $end_year = $current + absint( $years_after ); |
|
| 313 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
| 309 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
| 310 | + $current = date('Y'); |
|
| 311 | + $start_year = $current - absint($years_before); |
|
| 312 | + $end_year = $current + absint($years_after); |
|
| 313 | + $selected = empty($selected) ? date('Y') : $selected; |
|
| 314 | 314 | $options = array(); |
| 315 | 315 | |
| 316 | - while ( $start_year <= $end_year ) { |
|
| 317 | - $options[ absint( $start_year ) ] = $start_year; |
|
| 316 | + while ($start_year <= $end_year) { |
|
| 317 | + $options[absint($start_year)] = $start_year; |
|
| 318 | 318 | $start_year++; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - $output = wpinv_html_select( array( |
|
| 321 | + $output = wpinv_html_select(array( |
|
| 322 | 322 | 'name' => $name, |
| 323 | 323 | 'selected' => $selected, |
| 324 | 324 | 'options' => $options, |
| 325 | 325 | 'show_option_all' => false, |
| 326 | 326 | 'show_option_none' => false |
| 327 | - ) ); |
|
| 327 | + )); |
|
| 328 | 328 | |
| 329 | 329 | return $output; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
| 332 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
| 333 | 333 | $month = 1; |
| 334 | 334 | $options = array(); |
| 335 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
| 335 | + $selected = empty($selected) ? date('n') : $selected; |
|
| 336 | 336 | |
| 337 | - while ( $month <= 12 ) { |
|
| 338 | - $options[ absint( $month ) ] = wpinv_month_num_to_name( $month ); |
|
| 337 | + while ($month <= 12) { |
|
| 338 | + $options[absint($month)] = wpinv_month_num_to_name($month); |
|
| 339 | 339 | $month++; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $output = wpinv_html_select( array( |
|
| 342 | + $output = wpinv_html_select(array( |
|
| 343 | 343 | 'name' => $name, |
| 344 | 344 | 'selected' => $selected, |
| 345 | 345 | 'options' => $options, |
| 346 | 346 | 'show_option_all' => false, |
| 347 | 347 | 'show_option_none' => false |
| 348 | - ) ); |
|
| 348 | + )); |
|
| 349 | 349 | |
| 350 | 350 | return $output; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | -function wpinv_html_select( $args = array() ) { |
|
| 353 | +function wpinv_html_select($args = array()) { |
|
| 354 | 354 | $defaults = array( |
| 355 | 355 | 'options' => array(), |
| 356 | 356 | 'name' => null, |
@@ -359,8 +359,8 @@ discard block |
||
| 359 | 359 | 'selected' => 0, |
| 360 | 360 | 'placeholder' => null, |
| 361 | 361 | 'multiple' => false, |
| 362 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
| 363 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
| 362 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
| 363 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
| 364 | 364 | 'data' => array(), |
| 365 | 365 | 'onchange' => null, |
| 366 | 366 | 'required' => false, |
@@ -368,74 +368,74 @@ discard block |
||
| 368 | 368 | 'readonly' => false, |
| 369 | 369 | ); |
| 370 | 370 | |
| 371 | - $args = wp_parse_args( $args, $defaults ); |
|
| 371 | + $args = wp_parse_args($args, $defaults); |
|
| 372 | 372 | |
| 373 | 373 | $data_elements = ''; |
| 374 | - foreach ( $args['data'] as $key => $value ) { |
|
| 375 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
| 374 | + foreach ($args['data'] as $key => $value) { |
|
| 375 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if( $args['multiple'] ) { |
|
| 378 | + if ($args['multiple']) { |
|
| 379 | 379 | $multiple = ' MULTIPLE'; |
| 380 | 380 | } else { |
| 381 | 381 | $multiple = ''; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - if( $args['placeholder'] ) { |
|
| 384 | + if ($args['placeholder']) { |
|
| 385 | 385 | $placeholder = $args['placeholder']; |
| 386 | 386 | } else { |
| 387 | 387 | $placeholder = ''; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | $options = ''; |
| 391 | - if( !empty( $args['onchange'] ) ) { |
|
| 392 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 391 | + if (!empty($args['onchange'])) { |
|
| 392 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - if( !empty( $args['required'] ) ) { |
|
| 395 | + if (!empty($args['required'])) { |
|
| 396 | 396 | $options .= ' required="required"'; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - if( !empty( $args['disabled'] ) ) { |
|
| 399 | + if (!empty($args['disabled'])) { |
|
| 400 | 400 | $options .= ' disabled'; |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - if( !empty( $args['readonly'] ) ) { |
|
| 403 | + if (!empty($args['readonly'])) { |
|
| 404 | 404 | $options .= ' readonly'; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 408 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
| 407 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 408 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
| 409 | 409 | |
| 410 | - if ( $args['show_option_all'] ) { |
|
| 411 | - if( $args['multiple'] ) { |
|
| 412 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
| 410 | + if ($args['show_option_all']) { |
|
| 411 | + if ($args['multiple']) { |
|
| 412 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
| 413 | 413 | } else { |
| 414 | - $selected = selected( $args['selected'], 0, false ); |
|
| 414 | + $selected = selected($args['selected'], 0, false); |
|
| 415 | 415 | } |
| 416 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
| 416 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - if ( !empty( $args['options'] ) ) { |
|
| 419 | + if (!empty($args['options'])) { |
|
| 420 | 420 | |
| 421 | - if ( $args['show_option_none'] ) { |
|
| 422 | - if( $args['multiple'] ) { |
|
| 423 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
| 421 | + if ($args['show_option_none']) { |
|
| 422 | + if ($args['multiple']) { |
|
| 423 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
| 424 | 424 | } else { |
| 425 | - $selected = selected( $args['selected'] === "", true, false ); |
|
| 425 | + $selected = selected($args['selected'] === "", true, false); |
|
| 426 | 426 | } |
| 427 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 427 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - foreach( $args['options'] as $key => $option ) { |
|
| 430 | + foreach ($args['options'] as $key => $option) { |
|
| 431 | 431 | |
| 432 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 433 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
| 432 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
| 433 | + $selected = selected(true, (bool)in_array($key, $args['selected']), false); |
|
| 434 | 434 | } else { |
| 435 | - $selected = selected( $args['selected'], $key, false ); |
|
| 435 | + $selected = selected($args['selected'], $key, false); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
| 438 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
| 439 | 439 | } |
| 440 | 440 | } |
| 441 | 441 | |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | return $output; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | -function wpinv_item_dropdown( $args = array() ) { |
|
| 447 | +function wpinv_item_dropdown($args = array()) { |
|
| 448 | 448 | $defaults = array( |
| 449 | 449 | 'name' => 'wpi_item', |
| 450 | 450 | 'id' => 'wpi_item', |
@@ -452,14 +452,14 @@ discard block |
||
| 452 | 452 | 'multiple' => false, |
| 453 | 453 | 'selected' => 0, |
| 454 | 454 | 'number' => 100, |
| 455 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
| 456 | - 'data' => array( 'search-type' => 'item' ), |
|
| 455 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
| 456 | + 'data' => array('search-type' => 'item'), |
|
| 457 | 457 | 'show_option_all' => false, |
| 458 | 458 | 'show_option_none' => false, |
| 459 | 459 | 'show_recurring' => false, |
| 460 | 460 | ); |
| 461 | 461 | |
| 462 | - $args = wp_parse_args( $args, $defaults ); |
|
| 462 | + $args = wp_parse_args($args, $defaults); |
|
| 463 | 463 | |
| 464 | 464 | $item_args = array( |
| 465 | 465 | 'post_type' => 'wpi_item', |
@@ -468,44 +468,44 @@ discard block |
||
| 468 | 468 | 'posts_per_page' => $args['number'] |
| 469 | 469 | ); |
| 470 | 470 | |
| 471 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
| 471 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
| 472 | 472 | |
| 473 | - $items = get_posts( $item_args ); |
|
| 473 | + $items = get_posts($item_args); |
|
| 474 | 474 | $options = array(); |
| 475 | - if ( $items ) { |
|
| 476 | - foreach ( $items as $item ) { |
|
| 477 | - $title = esc_html( $item->post_title ); |
|
| 475 | + if ($items) { |
|
| 476 | + foreach ($items as $item) { |
|
| 477 | + $title = esc_html($item->post_title); |
|
| 478 | 478 | |
| 479 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 480 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
| 479 | + if (!empty($args['show_recurring'])) { |
|
| 480 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - $options[ absint( $item->ID ) ] = $title; |
|
| 483 | + $options[absint($item->ID)] = $title; |
|
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | // This ensures that any selected items are included in the drop down |
| 488 | - if( is_array( $args['selected'] ) ) { |
|
| 489 | - foreach( $args['selected'] as $item ) { |
|
| 490 | - if( ! in_array( $item, $options ) ) { |
|
| 491 | - $title = get_the_title( $item ); |
|
| 492 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 493 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
| 488 | + if (is_array($args['selected'])) { |
|
| 489 | + foreach ($args['selected'] as $item) { |
|
| 490 | + if (!in_array($item, $options)) { |
|
| 491 | + $title = get_the_title($item); |
|
| 492 | + if (!empty($args['show_recurring'])) { |
|
| 493 | + $title .= wpinv_get_item_suffix($item, false); |
|
| 494 | 494 | } |
| 495 | 495 | $options[$item] = $title; |
| 496 | 496 | } |
| 497 | 497 | } |
| 498 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
| 499 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
| 500 | - $title = get_the_title( $args['selected'] ); |
|
| 501 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 502 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
| 498 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
| 499 | + if (!in_array($args['selected'], $options)) { |
|
| 500 | + $title = get_the_title($args['selected']); |
|
| 501 | + if (!empty($args['show_recurring'])) { |
|
| 502 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
| 503 | 503 | } |
| 504 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
| 504 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - $output = wpinv_html_select( array( |
|
| 508 | + $output = wpinv_html_select(array( |
|
| 509 | 509 | 'name' => $args['name'], |
| 510 | 510 | 'selected' => $args['selected'], |
| 511 | 511 | 'id' => $args['id'], |
@@ -516,12 +516,12 @@ discard block |
||
| 516 | 516 | 'show_option_all' => $args['show_option_all'], |
| 517 | 517 | 'show_option_none' => $args['show_option_none'], |
| 518 | 518 | 'data' => $args['data'], |
| 519 | - ) ); |
|
| 519 | + )); |
|
| 520 | 520 | |
| 521 | 521 | return $output; |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | -function wpinv_html_checkbox( $args = array() ) { |
|
| 524 | +function wpinv_html_checkbox($args = array()) { |
|
| 525 | 525 | $defaults = array( |
| 526 | 526 | 'name' => null, |
| 527 | 527 | 'current' => null, |
@@ -532,38 +532,38 @@ discard block |
||
| 532 | 532 | ) |
| 533 | 533 | ); |
| 534 | 534 | |
| 535 | - $args = wp_parse_args( $args, $defaults ); |
|
| 535 | + $args = wp_parse_args($args, $defaults); |
|
| 536 | 536 | |
| 537 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 537 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 538 | 538 | $options = ''; |
| 539 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 539 | + if (!empty($args['options']['disabled'])) { |
|
| 540 | 540 | $options .= ' disabled="disabled"'; |
| 541 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 541 | + } elseif (!empty($args['options']['readonly'])) { |
|
| 542 | 542 | $options .= ' readonly'; |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
| 545 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
| 546 | 546 | |
| 547 | 547 | return $output; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | -function wpinv_html_text( $args = array() ) { |
|
| 550 | +function wpinv_html_text($args = array()) { |
|
| 551 | 551 | // Backwards compatibility |
| 552 | - if ( func_num_args() > 1 ) { |
|
| 552 | + if (func_num_args() > 1) { |
|
| 553 | 553 | $args = func_get_args(); |
| 554 | 554 | |
| 555 | 555 | $name = $args[0]; |
| 556 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 557 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 558 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 556 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 557 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 558 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | $defaults = array( |
| 562 | 562 | 'id' => '', |
| 563 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 564 | - 'value' => isset( $value ) ? $value : null, |
|
| 565 | - 'label' => isset( $label ) ? $label : null, |
|
| 566 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 563 | + 'name' => isset($name) ? $name : 'text', |
|
| 564 | + 'value' => isset($value) ? $value : null, |
|
| 565 | + 'label' => isset($label) ? $label : null, |
|
| 566 | + 'desc' => isset($desc) ? $desc : null, |
|
| 567 | 567 | 'placeholder' => '', |
| 568 | 568 | 'class' => 'regular-text', |
| 569 | 569 | 'disabled' => false, |
@@ -573,51 +573,51 @@ discard block |
||
| 573 | 573 | 'data' => false |
| 574 | 574 | ); |
| 575 | 575 | |
| 576 | - $args = wp_parse_args( $args, $defaults ); |
|
| 576 | + $args = wp_parse_args($args, $defaults); |
|
| 577 | 577 | |
| 578 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 578 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 579 | 579 | $options = ''; |
| 580 | - if( $args['required'] ) { |
|
| 580 | + if ($args['required']) { |
|
| 581 | 581 | $options .= ' required="required"'; |
| 582 | 582 | } |
| 583 | - if( $args['readonly'] ) { |
|
| 583 | + if ($args['readonly']) { |
|
| 584 | 584 | $options .= ' readonly'; |
| 585 | 585 | } |
| 586 | - if( $args['readonly'] ) { |
|
| 586 | + if ($args['readonly']) { |
|
| 587 | 587 | $options .= ' readonly'; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | $data = ''; |
| 591 | - if ( !empty( $args['data'] ) ) { |
|
| 592 | - foreach ( $args['data'] as $key => $value ) { |
|
| 593 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 591 | + if (!empty($args['data'])) { |
|
| 592 | + foreach ($args['data'] as $key => $value) { |
|
| 593 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
| 594 | 594 | } |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 598 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 599 | - if ( ! empty( $args['desc'] ) ) { |
|
| 600 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 597 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 598 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 599 | + if (!empty($args['desc'])) { |
|
| 600 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
| 603 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
| 604 | 604 | |
| 605 | 605 | $output .= '</span>'; |
| 606 | 606 | |
| 607 | 607 | return $output; |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | -function wpinv_html_date_field( $args = array() ) { |
|
| 611 | - if( empty( $args['class'] ) ) { |
|
| 610 | +function wpinv_html_date_field($args = array()) { |
|
| 611 | + if (empty($args['class'])) { |
|
| 612 | 612 | $args['class'] = 'wpiDatepicker'; |
| 613 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
| 613 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
| 614 | 614 | $args['class'] .= ' wpiDatepicker'; |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - return wpinv_html_text( $args ); |
|
| 617 | + return wpinv_html_text($args); |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | -function wpinv_html_textarea( $args = array() ) { |
|
| 620 | +function wpinv_html_textarea($args = array()) { |
|
| 621 | 621 | $defaults = array( |
| 622 | 622 | 'name' => 'textarea', |
| 623 | 623 | 'value' => null, |
@@ -627,31 +627,31 @@ discard block |
||
| 627 | 627 | 'disabled' => false |
| 628 | 628 | ); |
| 629 | 629 | |
| 630 | - $args = wp_parse_args( $args, $defaults ); |
|
| 630 | + $args = wp_parse_args($args, $defaults); |
|
| 631 | 631 | |
| 632 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 632 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 633 | 633 | $disabled = ''; |
| 634 | - if( $args['disabled'] ) { |
|
| 634 | + if ($args['disabled']) { |
|
| 635 | 635 | $disabled = ' disabled="disabled"'; |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 639 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 640 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
| 638 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 639 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 640 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
| 641 | 641 | |
| 642 | - if ( ! empty( $args['desc'] ) ) { |
|
| 643 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 642 | + if (!empty($args['desc'])) { |
|
| 643 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 644 | 644 | } |
| 645 | 645 | $output .= '</span>'; |
| 646 | 646 | |
| 647 | 647 | return $output; |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
| 650 | +function wpinv_html_ajax_user_search($args = array()) { |
|
| 651 | 651 | $defaults = array( |
| 652 | 652 | 'name' => 'user_id', |
| 653 | 653 | 'value' => null, |
| 654 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
| 654 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
| 655 | 655 | 'label' => null, |
| 656 | 656 | 'desc' => null, |
| 657 | 657 | 'class' => '', |
@@ -660,13 +660,13 @@ discard block |
||
| 660 | 660 | 'data' => false |
| 661 | 661 | ); |
| 662 | 662 | |
| 663 | - $args = wp_parse_args( $args, $defaults ); |
|
| 663 | + $args = wp_parse_args($args, $defaults); |
|
| 664 | 664 | |
| 665 | 665 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
| 666 | 666 | |
| 667 | 667 | $output = '<span class="wpinv_user_search_wrap">'; |
| 668 | - $output .= wpinv_html_text( $args ); |
|
| 669 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
| 668 | + $output .= wpinv_html_text($args); |
|
| 669 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
| 670 | 670 | $output .= '</span>'; |
| 671 | 671 | |
| 672 | 672 | return $output; |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | function wpinv_ip_geolocation() { |
| 676 | 676 | global $wpinv_euvat; |
| 677 | 677 | |
| 678 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
| 678 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
| 679 | 679 | $content = ''; |
| 680 | 680 | $iso = ''; |
| 681 | 681 | $country = ''; |
@@ -686,69 +686,69 @@ discard block |
||
| 686 | 686 | $credit = ''; |
| 687 | 687 | $address = ''; |
| 688 | 688 | |
| 689 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
| 689 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
| 690 | 690 | try { |
| 691 | 691 | $iso = $geoip2_city->country->isoCode; |
| 692 | 692 | $country = $geoip2_city->country->name; |
| 693 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 693 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 694 | 694 | $city = $geoip2_city->city->name; |
| 695 | 695 | $longitude = $geoip2_city->location->longitude; |
| 696 | 696 | $latitude = $geoip2_city->location->latitude; |
| 697 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
| 698 | - } catch( Exception $e ) { } |
|
| 697 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
| 698 | + } catch (Exception $e) { } |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
| 701 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
| 702 | 702 | try { |
| 703 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
| 703 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
| 704 | 704 | |
| 705 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
| 705 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
| 706 | 706 | $iso = $load_xml->geoplugin_countryCode; |
| 707 | 707 | $country = $load_xml->geoplugin_countryName; |
| 708 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
| 709 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
| 708 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
| 709 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
| 710 | 710 | $longitude = $load_xml->geoplugin_longitude; |
| 711 | 711 | $latitude = $load_xml->geoplugin_latitude; |
| 712 | 712 | $credit = $load_xml->geoplugin_credit; |
| 713 | - $credit = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit; |
|
| 713 | + $credit = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit; |
|
| 714 | 714 | } |
| 715 | - } catch( Exception $e ) { } |
|
| 715 | + } catch (Exception $e) { } |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | - if ( $iso && $longitude && $latitude ) { |
|
| 719 | - if ( $city ) { |
|
| 718 | + if ($iso && $longitude && $latitude) { |
|
| 719 | + if ($city) { |
|
| 720 | 720 | $address .= $city . ', '; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - if ( $region ) { |
|
| 723 | + if ($region) { |
|
| 724 | 724 | $address .= $region . ', '; |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | $address .= $country . ' (' . $iso . ')'; |
| 728 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
| 729 | - $content .= '<p>'. $credit . '</p>'; |
|
| 728 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
| 729 | + $content .= '<p>' . $credit . '</p>'; |
|
| 730 | 730 | } else { |
| 731 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
| 731 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
| 732 | 732 | } |
| 733 | 733 | ?> |
| 734 | 734 | <!DOCTYPE html> |
| 735 | -<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
| 735 | +<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
| 736 | 736 | <body> |
| 737 | - <?php if ( $latitude && $latitude ) { ?> |
|
| 737 | + <?php if ($latitude && $latitude) { ?> |
|
| 738 | 738 | <div id="map"></div> |
| 739 | 739 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
| 740 | 740 | <script type="text/javascript"> |
| 741 | 741 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
| 742 | 742 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
| 743 | 743 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
| 744 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
| 744 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
| 745 | 745 | |
| 746 | 746 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
| 747 | 747 | |
| 748 | 748 | var marker = new L.Marker(latlng); |
| 749 | 749 | map.addLayer(marker); |
| 750 | 750 | |
| 751 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
| 751 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
| 752 | 752 | </script> |
| 753 | 753 | <?php } ?> |
| 754 | 754 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -756,18 +756,18 @@ discard block |
||
| 756 | 756 | <?php |
| 757 | 757 | exit; |
| 758 | 758 | } |
| 759 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
| 760 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
| 759 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
| 760 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
| 761 | 761 | |
| 762 | 762 | // Set up the template for the invoice. |
| 763 | -function wpinv_template( $template ) { |
|
| 763 | +function wpinv_template($template) { |
|
| 764 | 764 | global $post, $wp_query; |
| 765 | 765 | |
| 766 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) { |
|
| 767 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
| 768 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
| 766 | + if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) { |
|
| 767 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
| 768 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
| 769 | 769 | } else { |
| 770 | - $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
| 770 | + $template = wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
| 771 | 771 | } |
| 772 | 772 | } |
| 773 | 773 | |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | |
| 777 | 777 | function wpinv_get_business_address() { |
| 778 | 778 | $business_address = wpinv_store_address(); |
| 779 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
| 779 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
| 780 | 780 | |
| 781 | 781 | /* |
| 782 | 782 | $default_country = wpinv_get_default_country(); |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | |
| 801 | 801 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
| 802 | 802 | |
| 803 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
| 803 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | function wpinv_display_from_address() { |
@@ -810,192 +810,192 @@ discard block |
||
| 810 | 810 | if (empty($from_name)) { |
| 811 | 811 | $from_name = wpinv_get_business_name(); |
| 812 | 812 | } |
| 813 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
| 813 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
| 814 | 814 | <div class="wrapper col-xs-10"> |
| 815 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
| 816 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
| 817 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
| 815 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
| 816 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
| 817 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
| 818 | 818 | <?php } ?> |
| 819 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
| 820 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div> |
|
| 819 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
| 820 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div> |
|
| 821 | 821 | <?php } ?> |
| 822 | 822 | </div> |
| 823 | 823 | <?php |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | -function wpinv_watermark( $id = 0 ) { |
|
| 827 | - $output = wpinv_get_watermark( $id ); |
|
| 826 | +function wpinv_watermark($id = 0) { |
|
| 827 | + $output = wpinv_get_watermark($id); |
|
| 828 | 828 | |
| 829 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
| 829 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
| 830 | 830 | } |
| 831 | 831 | |
| 832 | -function wpinv_get_watermark( $id ) { |
|
| 833 | - if ( !$id > 0 ) { |
|
| 832 | +function wpinv_get_watermark($id) { |
|
| 833 | + if (!$id > 0) { |
|
| 834 | 834 | return NULL; |
| 835 | 835 | } |
| 836 | - $invoice = wpinv_get_invoice( $id ); |
|
| 836 | + $invoice = wpinv_get_invoice($id); |
|
| 837 | 837 | |
| 838 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
| 839 | - if ( $invoice->is_paid() ) { |
|
| 840 | - return __( 'Paid', 'invoicing' ); |
|
| 838 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
| 839 | + if ($invoice->is_paid()) { |
|
| 840 | + return __('Paid', 'invoicing'); |
|
| 841 | 841 | } |
| 842 | - if ( $invoice->is_refunded() ) { |
|
| 843 | - return __( 'Refunded', 'invoicing' ); |
|
| 842 | + if ($invoice->is_refunded()) { |
|
| 843 | + return __('Refunded', 'invoicing'); |
|
| 844 | 844 | } |
| 845 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
| 846 | - return __( 'Cancelled', 'invoicing' ); |
|
| 845 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
| 846 | + return __('Cancelled', 'invoicing'); |
|
| 847 | 847 | } |
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | return NULL; |
| 851 | 851 | } |
| 852 | 852 | |
| 853 | -function wpinv_display_invoice_details( $invoice ) { |
|
| 853 | +function wpinv_display_invoice_details($invoice) { |
|
| 854 | 854 | global $wpinv_euvat; |
| 855 | 855 | |
| 856 | 856 | $invoice_id = $invoice->ID; |
| 857 | 857 | $vat_name = $wpinv_euvat->get_vat_name(); |
| 858 | 858 | $use_taxes = wpinv_use_taxes(); |
| 859 | 859 | |
| 860 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
| 860 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
| 861 | 861 | ?> |
| 862 | 862 | <table class="table table-bordered table-sm"> |
| 863 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
| 863 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
| 864 | 864 | <tr class="wpi-row-number"> |
| 865 | - <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th> |
|
| 866 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
| 865 | + <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th> |
|
| 866 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
| 867 | 867 | </tr> |
| 868 | 868 | <?php } ?> |
| 869 | 869 | <tr class="wpi-row-status"> |
| 870 | - <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th> |
|
| 871 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
| 870 | + <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th> |
|
| 871 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
| 872 | 872 | </tr> |
| 873 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
| 873 | + <?php if ($invoice->is_renewal()) { ?> |
|
| 874 | 874 | <tr class="wpi-row-parent"> |
| 875 | - <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th> |
|
| 876 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
| 875 | + <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th> |
|
| 876 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
| 877 | 877 | </tr> |
| 878 | 878 | <?php } ?> |
| 879 | - <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
| 879 | + <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
| 880 | 880 | <tr class="wpi-row-gateway"> |
| 881 | - <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th> |
|
| 881 | + <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th> |
|
| 882 | 882 | <td><?php echo $gateway_name; ?></td> |
| 883 | 883 | </tr> |
| 884 | 884 | <?php } ?> |
| 885 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
| 885 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
| 886 | 886 | <tr class="wpi-row-date"> |
| 887 | - <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th> |
|
| 887 | + <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th> |
|
| 888 | 888 | <td><?php echo $invoice_date; ?></td> |
| 889 | 889 | </tr> |
| 890 | 890 | <?php } ?> |
| 891 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
| 891 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
| 892 | 892 | <tr class="wpi-row-date"> |
| 893 | - <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th> |
|
| 893 | + <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th> |
|
| 894 | 894 | <td><?php echo $due_date; ?></td> |
| 895 | 895 | </tr> |
| 896 | 896 | <?php } ?> |
| 897 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
| 898 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
| 897 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
| 898 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
| 899 | 899 | <tr class="wpi-row-ovatno"> |
| 900 | - <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
| 900 | + <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
| 901 | 901 | <td><?php echo $owner_vat_number; ?></td> |
| 902 | 902 | </tr> |
| 903 | 903 | <?php } ?> |
| 904 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
| 905 | - <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?> |
|
| 904 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
| 905 | + <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?> |
|
| 906 | 906 | <tr class="wpi-row-uvatno"> |
| 907 | - <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
| 907 | + <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
| 908 | 908 | <td><?php echo $user_vat_number; ?></td> |
| 909 | 909 | </tr> |
| 910 | 910 | <?php } ?> |
| 911 | 911 | <tr class="table-active tr-total wpi-row-total"> |
| 912 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
| 913 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
| 912 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
| 913 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
| 914 | 914 | </tr> |
| 915 | 915 | </table> |
| 916 | 916 | <?php |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
| 920 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 919 | +function wpinv_display_to_address($invoice_id = 0) { |
|
| 920 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 921 | 921 | |
| 922 | - if ( empty( $invoice ) ) { |
|
| 922 | + if (empty($invoice)) { |
|
| 923 | 923 | return NULL; |
| 924 | 924 | } |
| 925 | 925 | |
| 926 | 926 | $billing_details = $invoice->get_user_info(); |
| 927 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
| 927 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
| 928 | 928 | $output .= '<div class="wrapper col-xs-10">'; |
| 929 | 929 | |
| 930 | 930 | ob_start(); |
| 931 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
| 931 | + do_action('wpinv_display_to_address_top', $invoice); |
|
| 932 | 932 | $output .= ob_get_clean(); |
| 933 | 933 | |
| 934 | - $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>'; |
|
| 935 | - if ( $company = $billing_details['company'] ) { |
|
| 936 | - $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>'; |
|
| 934 | + $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>'; |
|
| 935 | + if ($company = $billing_details['company']) { |
|
| 936 | + $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>'; |
|
| 937 | 937 | } |
| 938 | 938 | $address_row = ''; |
| 939 | - if ( $address = $billing_details['address'] ) { |
|
| 940 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
| 939 | + if ($address = $billing_details['address']) { |
|
| 940 | + $address_row .= wpautop(wp_kses_post($address)); |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | $address_fields = array(); |
| 944 | - if ( !empty( $billing_details['city'] ) ) { |
|
| 944 | + if (!empty($billing_details['city'])) { |
|
| 945 | 945 | $address_fields[] = $billing_details['city']; |
| 946 | 946 | } |
| 947 | 947 | |
| 948 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
| 949 | - if ( !empty( $billing_details['state'] ) ) { |
|
| 950 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
| 948 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
| 949 | + if (!empty($billing_details['state'])) { |
|
| 950 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - if ( !empty( $billing_country ) ) { |
|
| 954 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
| 953 | + if (!empty($billing_country)) { |
|
| 954 | + $address_fields[] = wpinv_country_name($billing_country); |
|
| 955 | 955 | } |
| 956 | 956 | |
| 957 | - if ( !empty( $address_fields ) ) { |
|
| 958 | - $address_fields = implode( ", ", $address_fields ); |
|
| 957 | + if (!empty($address_fields)) { |
|
| 958 | + $address_fields = implode(", ", $address_fields); |
|
| 959 | 959 | |
| 960 | - if ( !empty( $billing_details['zip'] ) ) { |
|
| 960 | + if (!empty($billing_details['zip'])) { |
|
| 961 | 961 | $address_fields .= ' ' . $billing_details['zip']; |
| 962 | 962 | } |
| 963 | 963 | |
| 964 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
| 964 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
| 965 | 965 | } |
| 966 | 966 | |
| 967 | - if ( $address_row ) { |
|
| 967 | + if ($address_row) { |
|
| 968 | 968 | $output .= '<div class="address">' . $address_row . '</div>'; |
| 969 | 969 | } |
| 970 | 970 | |
| 971 | - if ( $phone = $invoice->get_phone() ) { |
|
| 972 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>'; |
|
| 971 | + if ($phone = $invoice->get_phone()) { |
|
| 972 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>'; |
|
| 973 | 973 | } |
| 974 | - if ( $email = $invoice->get_email() ) { |
|
| 975 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>'; |
|
| 974 | + if ($email = $invoice->get_email()) { |
|
| 975 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>'; |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | ob_start(); |
| 979 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
| 979 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
| 980 | 980 | $output .= ob_get_clean(); |
| 981 | 981 | |
| 982 | 982 | $output .= '</div>'; |
| 983 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
| 983 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
| 984 | 984 | |
| 985 | 985 | echo $output; |
| 986 | 986 | } |
| 987 | 987 | |
| 988 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
| 988 | +function wpinv_display_line_items($invoice_id = 0) { |
|
| 989 | 989 | global $wpinv_euvat, $ajax_cart_details; |
| 990 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 990 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 991 | 991 | $quantities_enabled = wpinv_item_quantities_enabled(); |
| 992 | 992 | $use_taxes = wpinv_use_taxes(); |
| 993 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
| 993 | + if (!$use_taxes && (float)$invoice->get_tax() > 0) { |
|
| 994 | 994 | $use_taxes = true; |
| 995 | 995 | } |
| 996 | 996 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
| 997 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
| 998 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
| 997 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
| 998 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
| 999 | 999 | |
| 1000 | 1000 | $cart_details = $invoice->get_cart_details(); |
| 1001 | 1001 | $ajax_cart_details = $cart_details; |
@@ -1004,66 +1004,66 @@ discard block |
||
| 1004 | 1004 | <table class="table table-sm table-bordered table-responsive"> |
| 1005 | 1005 | <thead> |
| 1006 | 1006 | <tr> |
| 1007 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
| 1008 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
| 1007 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
| 1008 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
| 1009 | 1009 | <?php if ($quantities_enabled) { ?> |
| 1010 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
| 1010 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
| 1011 | 1011 | <?php } ?> |
| 1012 | 1012 | <?php if ($use_taxes && !$zero_tax) { ?> |
| 1013 | 1013 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
| 1014 | 1014 | <?php } ?> |
| 1015 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
| 1015 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
| 1016 | 1016 | </tr> |
| 1017 | 1017 | </thead> |
| 1018 | 1018 | <tbody> |
| 1019 | 1019 | <?php |
| 1020 | - if ( !empty( $cart_details ) ) { |
|
| 1021 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
| 1020 | + if (!empty($cart_details)) { |
|
| 1021 | + do_action('wpinv_display_line_items_start', $invoice); |
|
| 1022 | 1022 | |
| 1023 | 1023 | $count = 0; |
| 1024 | 1024 | $cols = 3; |
| 1025 | - foreach ( $cart_details as $key => $cart_item ) { |
|
| 1026 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
| 1027 | - $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0; |
|
| 1028 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0; |
|
| 1029 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
| 1025 | + foreach ($cart_details as $key => $cart_item) { |
|
| 1026 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
| 1027 | + $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0; |
|
| 1028 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0; |
|
| 1029 | + $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
| 1030 | 1030 | |
| 1031 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
| 1031 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
| 1032 | 1032 | $summary = ''; |
| 1033 | 1033 | $cols = 3; |
| 1034 | - if ( !empty($item) ) { |
|
| 1034 | + if (!empty($item)) { |
|
| 1035 | 1035 | $item_name = $item->get_name(); |
| 1036 | 1036 | $summary = $item->get_summary(); |
| 1037 | 1037 | } |
| 1038 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
| 1038 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
| 1039 | 1039 | |
| 1040 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
| 1040 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
| 1041 | 1041 | |
| 1042 | 1042 | $item_tax = ''; |
| 1043 | 1043 | $tax_rate = ''; |
| 1044 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
| 1045 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
| 1046 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
| 1047 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
| 1044 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
| 1045 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
| 1046 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
| 1047 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
| 1048 | 1048 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | $line_item_tax = $item_tax . $tax_rate; |
| 1052 | 1052 | |
| 1053 | - if ( $line_item_tax === '' ) { |
|
| 1053 | + if ($line_item_tax === '') { |
|
| 1054 | 1054 | $line_item_tax = 0; // Zero tax |
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | - $action = apply_filters( 'wpinv_display_line_item_action', '', $cart_item, $invoice, $cols ); |
|
| 1057 | + $action = apply_filters('wpinv_display_line_item_action', '', $cart_item, $invoice, $cols); |
|
| 1058 | 1058 | |
| 1059 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
| 1060 | - $line_item .= '<td class="name">' . $action. esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
| 1061 | - if ( $summary !== '' ) { |
|
| 1062 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
| 1059 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
| 1060 | + $line_item .= '<td class="name">' . $action . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
| 1061 | + if ($summary !== '') { |
|
| 1062 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
| 1063 | 1063 | } |
| 1064 | 1064 | $line_item .= '</td>'; |
| 1065 | 1065 | |
| 1066 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>'; |
|
| 1066 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>'; |
|
| 1067 | 1067 | if ($quantities_enabled) { |
| 1068 | 1068 | $cols++; |
| 1069 | 1069 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1072,55 +1072,55 @@ discard block |
||
| 1072 | 1072 | $cols++; |
| 1073 | 1073 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
| 1074 | 1074 | } |
| 1075 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>'; |
|
| 1075 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>'; |
|
| 1076 | 1076 | $line_item .= '</tr>'; |
| 1077 | 1077 | |
| 1078 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
| 1078 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
| 1079 | 1079 | |
| 1080 | 1080 | $count++; |
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
| 1083 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
| 1084 | 1084 | ?> |
| 1085 | 1085 | <tr class="row-sub-total row_odd"> |
| 1086 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
| 1087 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
| 1086 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
| 1087 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
| 1088 | 1088 | </tr> |
| 1089 | 1089 | <?php |
| 1090 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
| 1090 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
| 1091 | 1091 | |
| 1092 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
| 1093 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
| 1092 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
| 1093 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
| 1094 | 1094 | ?> |
| 1095 | 1095 | <tr class="row-discount"> |
| 1096 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
| 1097 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
| 1096 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
| 1097 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
| 1098 | 1098 | </tr> |
| 1099 | 1099 | <?php |
| 1100 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
| 1100 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | - if ( $use_taxes ) { |
|
| 1104 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
| 1103 | + if ($use_taxes) { |
|
| 1104 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
| 1105 | 1105 | ?> |
| 1106 | 1106 | <tr class="row-tax"> |
| 1107 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
| 1108 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
| 1107 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
| 1108 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
| 1109 | 1109 | </tr> |
| 1110 | 1110 | <?php |
| 1111 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
| 1111 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
| 1114 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
| 1115 | 1115 | ?> |
| 1116 | 1116 | <tr class="table-active row-total"> |
| 1117 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
| 1118 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
| 1117 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
| 1118 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
| 1119 | 1119 | </tr> |
| 1120 | 1120 | <?php |
| 1121 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
| 1121 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
| 1122 | 1122 | |
| 1123 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
| 1123 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
| 1124 | 1124 | } |
| 1125 | 1125 | ?> |
| 1126 | 1126 | </tbody> |
@@ -1129,35 +1129,35 @@ discard block |
||
| 1129 | 1129 | echo ob_get_clean(); |
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
| 1132 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
| 1133 | 1133 | $use_taxes = wpinv_use_taxes(); |
| 1134 | 1134 | |
| 1135 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
| 1135 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
| 1136 | 1136 | ?> |
| 1137 | 1137 | <table class="table table-sm table-bordered table-responsive"> |
| 1138 | 1138 | <tbody> |
| 1139 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
| 1139 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
| 1140 | 1140 | <tr class="row-sub-total"> |
| 1141 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
| 1142 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
| 1141 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
| 1142 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
| 1143 | 1143 | </tr> |
| 1144 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
| 1145 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
| 1144 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
| 1145 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
| 1146 | 1146 | <tr class="row-discount"> |
| 1147 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
| 1148 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
| 1147 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
| 1148 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
| 1149 | 1149 | </tr> |
| 1150 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
| 1150 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
| 1151 | 1151 | <?php } ?> |
| 1152 | - <?php if ( $use_taxes ) { ?> |
|
| 1152 | + <?php if ($use_taxes) { ?> |
|
| 1153 | 1153 | <tr class="row-tax"> |
| 1154 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
| 1155 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
| 1154 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
| 1155 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
| 1156 | 1156 | </tr> |
| 1157 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
| 1157 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
| 1158 | 1158 | <?php } ?> |
| 1159 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
| 1160 | - <?php foreach ( $fees as $fee ) { ?> |
|
| 1159 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
| 1160 | + <?php foreach ($fees as $fee) { ?> |
|
| 1161 | 1161 | <tr class="row-fee"> |
| 1162 | 1162 | <td class="rate"><?php echo $fee['label']; ?></td> |
| 1163 | 1163 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1165,82 +1165,82 @@ discard block |
||
| 1165 | 1165 | <?php } ?> |
| 1166 | 1166 | <?php } ?> |
| 1167 | 1167 | <tr class="table-active row-total"> |
| 1168 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
| 1169 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
| 1168 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
| 1169 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
| 1170 | 1170 | </tr> |
| 1171 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
| 1171 | + <?php do_action('wpinv_after_totals'); ?> |
|
| 1172 | 1172 | </tbody> |
| 1173 | 1173 | |
| 1174 | 1174 | </table> |
| 1175 | 1175 | |
| 1176 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
| 1176 | + <?php do_action('wpinv_after_totals_table'); |
|
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
| 1180 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1179 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
| 1180 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1181 | 1181 | |
| 1182 | 1182 | ob_start(); |
| 1183 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
| 1184 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 1183 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
| 1184 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 1185 | 1185 | ?> |
| 1186 | 1186 | <div class="wpi-payment-info"> |
| 1187 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
| 1188 | - <?php if ( $gateway_title ) { ?> |
|
| 1189 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
| 1187 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
| 1188 | + <?php if ($gateway_title) { ?> |
|
| 1189 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
| 1190 | 1190 | <?php } ?> |
| 1191 | 1191 | </div> |
| 1192 | 1192 | <?php |
| 1193 | 1193 | } |
| 1194 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
| 1194 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
| 1195 | 1195 | $outout = ob_get_clean(); |
| 1196 | 1196 | |
| 1197 | - if ( $echo ) { |
|
| 1197 | + if ($echo) { |
|
| 1198 | 1198 | echo $outout; |
| 1199 | 1199 | } else { |
| 1200 | 1200 | return $outout; |
| 1201 | 1201 | } |
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | -function wpinv_display_style( $invoice ) { |
|
| 1205 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
| 1204 | +function wpinv_display_style($invoice) { |
|
| 1205 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
| 1206 | 1206 | |
| 1207 | - wp_print_styles( 'open-sans' ); |
|
| 1208 | - wp_print_styles( 'wpinv-single-style' ); |
|
| 1207 | + wp_print_styles('open-sans'); |
|
| 1208 | + wp_print_styles('wpinv-single-style'); |
|
| 1209 | 1209 | |
| 1210 | 1210 | $custom_css = wpinv_get_option('template_custom_css'); |
| 1211 | - if(isset($custom_css) && !empty($custom_css)){ |
|
| 1212 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
| 1213 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
| 1211 | + if (isset($custom_css) && !empty($custom_css)) { |
|
| 1212 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
| 1213 | + $custom_css = str_replace('>', '>', $custom_css); |
|
| 1214 | 1214 | echo '<style type="text/css">'; |
| 1215 | 1215 | echo $custom_css; |
| 1216 | 1216 | echo '</style>'; |
| 1217 | 1217 | } |
| 1218 | 1218 | } |
| 1219 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
| 1220 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
| 1219 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
| 1220 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
| 1221 | 1221 | |
| 1222 | 1222 | function wpinv_checkout_billing_details() { |
| 1223 | 1223 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
| 1224 | 1224 | if (empty($invoice_id)) { |
| 1225 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
| 1225 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
| 1226 | 1226 | return null; |
| 1227 | 1227 | } |
| 1228 | 1228 | |
| 1229 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
| 1229 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
| 1230 | 1230 | if (empty($invoice)) { |
| 1231 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
| 1231 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
| 1232 | 1232 | return null; |
| 1233 | 1233 | } |
| 1234 | 1234 | $user_id = $invoice->get_user_id(); |
| 1235 | 1235 | $user_info = $invoice->get_user_info(); |
| 1236 | - $address_info = wpinv_get_user_address( $user_id ); |
|
| 1236 | + $address_info = wpinv_get_user_address($user_id); |
|
| 1237 | 1237 | |
| 1238 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
| 1238 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
| 1239 | 1239 | $user_info['first_name'] = $user_info['first_name']; |
| 1240 | 1240 | $user_info['last_name'] = $user_info['last_name']; |
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
| 1243 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
| 1244 | 1244 | $user_info['country'] = $address_info['country']; |
| 1245 | 1245 | $user_info['state'] = $address_info['state']; |
| 1246 | 1246 | $user_info['city'] = $address_info['city']; |
@@ -1256,98 +1256,98 @@ discard block |
||
| 1256 | 1256 | 'address' |
| 1257 | 1257 | ); |
| 1258 | 1258 | |
| 1259 | - foreach ( $address_fields as $field ) { |
|
| 1260 | - if ( empty( $user_info[$field] ) ) { |
|
| 1259 | + foreach ($address_fields as $field) { |
|
| 1260 | + if (empty($user_info[$field])) { |
|
| 1261 | 1261 | $user_info[$field] = $address_info[$field]; |
| 1262 | 1262 | } |
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
| 1265 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | function wpinv_admin_get_line_items($invoice = array()) { |
| 1269 | 1269 | $item_quantities = wpinv_item_quantities_enabled(); |
| 1270 | 1270 | $use_taxes = wpinv_use_taxes(); |
| 1271 | 1271 | |
| 1272 | - if ( empty( $invoice ) ) { |
|
| 1272 | + if (empty($invoice)) { |
|
| 1273 | 1273 | return NULL; |
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | 1276 | $cart_items = $invoice->get_cart_details(); |
| 1277 | - if ( empty( $cart_items ) ) { |
|
| 1277 | + if (empty($cart_items)) { |
|
| 1278 | 1278 | return NULL; |
| 1279 | 1279 | } |
| 1280 | 1280 | ob_start(); |
| 1281 | 1281 | |
| 1282 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
| 1282 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
| 1283 | 1283 | |
| 1284 | 1284 | $count = 0; |
| 1285 | - foreach ( $cart_items as $key => $cart_item ) { |
|
| 1285 | + foreach ($cart_items as $key => $cart_item) { |
|
| 1286 | 1286 | $item_id = $cart_item['id']; |
| 1287 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
| 1287 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
| 1288 | 1288 | |
| 1289 | 1289 | if (empty($wpi_item)) { |
| 1290 | 1290 | continue; |
| 1291 | 1291 | } |
| 1292 | 1292 | |
| 1293 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() ); |
|
| 1294 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
| 1295 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() ); |
|
| 1293 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency()); |
|
| 1294 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
| 1295 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency()); |
|
| 1296 | 1296 | $can_remove = true; |
| 1297 | 1297 | |
| 1298 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice ); |
|
| 1298 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice); |
|
| 1299 | 1299 | |
| 1300 | 1300 | $item_tax = ''; |
| 1301 | 1301 | $tax_rate = ''; |
| 1302 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
| 1303 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
| 1304 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
| 1305 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
| 1302 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
| 1303 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
| 1304 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
| 1305 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
| 1306 | 1306 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
| 1307 | 1307 | } |
| 1308 | 1308 | $line_item_tax = $item_tax . $tax_rate; |
| 1309 | 1309 | |
| 1310 | - if ( $line_item_tax === '' ) { |
|
| 1310 | + if ($line_item_tax === '') { |
|
| 1311 | 1311 | $line_item_tax = 0; // Zero tax |
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
| 1314 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
| 1315 | 1315 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
| 1316 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item ); |
|
| 1317 | - if ( $summary !== '' ) { |
|
| 1318 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
| 1316 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item); |
|
| 1317 | + if ($summary !== '') { |
|
| 1318 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
| 1319 | 1319 | } |
| 1320 | 1320 | $line_item .= '</td>'; |
| 1321 | 1321 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
| 1322 | 1322 | |
| 1323 | - if ( $item_quantities ) { |
|
| 1324 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
| 1323 | + if ($item_quantities) { |
|
| 1324 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
| 1325 | 1325 | $can_remove = false; |
| 1326 | 1326 | } |
| 1327 | 1327 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
| 1328 | 1328 | } else { |
| 1329 | - if ( count( $cart_items ) == 1 ) { |
|
| 1329 | + if (count($cart_items) == 1) { |
|
| 1330 | 1330 | $can_remove = false; |
| 1331 | 1331 | } |
| 1332 | 1332 | } |
| 1333 | 1333 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
| 1334 | 1334 | |
| 1335 | - if ( $use_taxes ) { |
|
| 1335 | + if ($use_taxes) { |
|
| 1336 | 1336 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
| 1337 | 1337 | } |
| 1338 | 1338 | $line_item .= '<td class="action">'; |
| 1339 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() && $can_remove ) { |
|
| 1339 | + if (!$invoice->is_paid() && !$invoice->is_refunded() && $can_remove) { |
|
| 1340 | 1340 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
| 1341 | 1341 | } |
| 1342 | 1342 | $line_item .= '</td>'; |
| 1343 | 1343 | $line_item .= '</tr>'; |
| 1344 | 1344 | |
| 1345 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
| 1345 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
| 1346 | 1346 | |
| 1347 | 1347 | $count++; |
| 1348 | 1348 | } |
| 1349 | 1349 | |
| 1350 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
| 1350 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
| 1351 | 1351 | |
| 1352 | 1352 | return ob_get_clean(); |
| 1353 | 1353 | } |
@@ -1358,35 +1358,35 @@ discard block |
||
| 1358 | 1358 | // Set current invoice id. |
| 1359 | 1359 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
| 1360 | 1360 | |
| 1361 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
| 1361 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
| 1362 | 1362 | |
| 1363 | 1363 | ob_start(); |
| 1364 | 1364 | echo '<div id="wpinv_checkout_wrap">'; |
| 1365 | 1365 | |
| 1366 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
| 1366 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
| 1367 | 1367 | ?> |
| 1368 | 1368 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
| 1369 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
| 1369 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
| 1370 | 1370 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
| 1371 | 1371 | <?php |
| 1372 | - do_action( 'wpinv_checkout_form_top' ); |
|
| 1373 | - do_action( 'wpinv_checkout_billing_info' ); |
|
| 1374 | - do_action( 'wpinv_checkout_cart' ); |
|
| 1375 | - do_action( 'wpinv_payment_mode_select' ); |
|
| 1376 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
| 1372 | + do_action('wpinv_checkout_form_top'); |
|
| 1373 | + do_action('wpinv_checkout_billing_info'); |
|
| 1374 | + do_action('wpinv_checkout_cart'); |
|
| 1375 | + do_action('wpinv_payment_mode_select'); |
|
| 1376 | + do_action('wpinv_checkout_form_bottom') |
|
| 1377 | 1377 | ?> |
| 1378 | 1378 | </form> |
| 1379 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
| 1379 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
| 1380 | 1380 | </div><!--end #wpinv_checkout_form_wrap--> |
| 1381 | 1381 | <?php |
| 1382 | 1382 | } else { |
| 1383 | - do_action( 'wpinv_cart_empty' ); |
|
| 1383 | + do_action('wpinv_cart_empty'); |
|
| 1384 | 1384 | } |
| 1385 | 1385 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
| 1386 | 1386 | return ob_get_clean(); |
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
| 1389 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
| 1390 | 1390 | global $ajax_cart_details; |
| 1391 | 1391 | $ajax_cart_details = $cart_details; |
| 1392 | 1392 | /* |
@@ -1401,25 +1401,25 @@ discard block |
||
| 1401 | 1401 | } |
| 1402 | 1402 | */ |
| 1403 | 1403 | ob_start(); |
| 1404 | - do_action( 'wpinv_before_checkout_cart' ); |
|
| 1404 | + do_action('wpinv_before_checkout_cart'); |
|
| 1405 | 1405 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
| 1406 | 1406 | echo '<div id="wpinv_checkout_cart_wrap">'; |
| 1407 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
| 1407 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
| 1408 | 1408 | echo '</div>'; |
| 1409 | 1409 | echo '</div>'; |
| 1410 | - do_action( 'wpinv_after_checkout_cart' ); |
|
| 1410 | + do_action('wpinv_after_checkout_cart'); |
|
| 1411 | 1411 | $content = ob_get_clean(); |
| 1412 | 1412 | |
| 1413 | - if ( $echo ) { |
|
| 1413 | + if ($echo) { |
|
| 1414 | 1414 | echo $content; |
| 1415 | 1415 | } else { |
| 1416 | 1416 | return $content; |
| 1417 | 1417 | } |
| 1418 | 1418 | } |
| 1419 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
| 1419 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
| 1420 | 1420 | |
| 1421 | 1421 | function wpinv_empty_cart_message() { |
| 1422 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1422 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | 1425 | /** |
@@ -1431,91 +1431,91 @@ discard block |
||
| 1431 | 1431 | function wpinv_empty_checkout_cart() { |
| 1432 | 1432 | echo wpinv_empty_cart_message(); |
| 1433 | 1433 | } |
| 1434 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
| 1434 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
| 1435 | 1435 | |
| 1436 | 1436 | function wpinv_save_cart_button() { |
| 1437 | - if ( wpinv_is_cart_saving_disabled() ) |
|
| 1437 | + if (wpinv_is_cart_saving_disabled()) |
|
| 1438 | 1438 | return; |
| 1439 | 1439 | ?> |
| 1440 | - <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a> |
|
| 1440 | + <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url(add_query_arg('wpi_action', 'save_cart')); ?>"><?php _e('Save Cart', 'invoicing'); ?></a> |
|
| 1441 | 1441 | <?php |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | function wpinv_update_cart_button() { |
| 1445 | - if ( !wpinv_item_quantities_enabled() ) |
|
| 1445 | + if (!wpinv_item_quantities_enabled()) |
|
| 1446 | 1446 | return; |
| 1447 | 1447 | ?> |
| 1448 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
| 1448 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
| 1449 | 1449 | <input type="hidden" name="wpi_action" value="update_cart"/> |
| 1450 | 1450 | <?php |
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | function wpinv_checkout_cart_columns() { |
| 1454 | 1454 | $default = 3; |
| 1455 | - if ( wpinv_item_quantities_enabled() ) { |
|
| 1455 | + if (wpinv_item_quantities_enabled()) { |
|
| 1456 | 1456 | $default++; |
| 1457 | 1457 | } |
| 1458 | 1458 | |
| 1459 | - if ( wpinv_use_taxes() ) { |
|
| 1459 | + if (wpinv_use_taxes()) { |
|
| 1460 | 1460 | $default++; |
| 1461 | 1461 | } |
| 1462 | 1462 | |
| 1463 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
| 1463 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | 1466 | function wpinv_display_cart_messages() { |
| 1467 | 1467 | global $wpi_session; |
| 1468 | 1468 | |
| 1469 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
| 1469 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
| 1470 | 1470 | |
| 1471 | - if ( $messages ) { |
|
| 1472 | - foreach ( $messages as $message_id => $message ) { |
|
| 1471 | + if ($messages) { |
|
| 1472 | + foreach ($messages as $message_id => $message) { |
|
| 1473 | 1473 | // Try and detect what type of message this is |
| 1474 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
| 1474 | + if (strpos(strtolower($message), 'error')) { |
|
| 1475 | 1475 | $type = 'error'; |
| 1476 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
| 1476 | + } elseif (strpos(strtolower($message), 'success')) { |
|
| 1477 | 1477 | $type = 'success'; |
| 1478 | 1478 | } else { |
| 1479 | 1479 | $type = 'info'; |
| 1480 | 1480 | } |
| 1481 | 1481 | |
| 1482 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
| 1482 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
| 1483 | 1483 | |
| 1484 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
| 1484 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
| 1485 | 1485 | // Loop message codes and display messages |
| 1486 | 1486 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
| 1487 | 1487 | echo '</div>'; |
| 1488 | 1488 | } |
| 1489 | 1489 | |
| 1490 | 1490 | // Remove all of the cart saving messages |
| 1491 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
| 1491 | + $wpi_session->set('wpinv_cart_messages', null); |
|
| 1492 | 1492 | } |
| 1493 | 1493 | } |
| 1494 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
| 1494 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
| 1495 | 1495 | |
| 1496 | 1496 | function wpinv_discount_field() { |
| 1497 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
| 1497 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
| 1498 | 1498 | return; // Only show before a payment method has been selected if ajax is disabled |
| 1499 | 1499 | } |
| 1500 | 1500 | |
| 1501 | - if ( !wpinv_is_checkout() ) { |
|
| 1501 | + if (!wpinv_is_checkout()) { |
|
| 1502 | 1502 | return; |
| 1503 | 1503 | } |
| 1504 | 1504 | |
| 1505 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
| 1505 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
| 1506 | 1506 | ?> |
| 1507 | 1507 | <div id="wpinv-discount-field" class="panel panel-default"> |
| 1508 | 1508 | <div class="panel-body"> |
| 1509 | 1509 | <p> |
| 1510 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
| 1511 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
| 1510 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
| 1511 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
| 1512 | 1512 | </p> |
| 1513 | 1513 | <div class="form-group row"> |
| 1514 | 1514 | <div class="col-sm-4"> |
| 1515 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
| 1515 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
| 1516 | 1516 | </div> |
| 1517 | 1517 | <div class="col-sm-3"> |
| 1518 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
| 1518 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
| 1519 | 1519 | </div> |
| 1520 | 1520 | <div style="clear:both"></div> |
| 1521 | 1521 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1528,10 +1528,10 @@ discard block |
||
| 1528 | 1528 | <?php |
| 1529 | 1529 | } |
| 1530 | 1530 | } |
| 1531 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
| 1531 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
| 1532 | 1532 | |
| 1533 | 1533 | function wpinv_agree_to_terms_js() { |
| 1534 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
| 1534 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
| 1535 | 1535 | ?> |
| 1536 | 1536 | <script type="text/javascript"> |
| 1537 | 1537 | jQuery(document).ready(function($){ |
@@ -1546,126 +1546,126 @@ discard block |
||
| 1546 | 1546 | <?php |
| 1547 | 1547 | } |
| 1548 | 1548 | } |
| 1549 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
| 1549 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
| 1550 | 1550 | |
| 1551 | 1551 | function wpinv_payment_mode_select() { |
| 1552 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
| 1553 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
| 1552 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
| 1553 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
| 1554 | 1554 | $page_URL = wpinv_get_current_page_url(); |
| 1555 | - $invoice = wpinv_get_invoice( 0, true ); |
|
| 1555 | + $invoice = wpinv_get_invoice(0, true); |
|
| 1556 | 1556 | |
| 1557 | 1557 | do_action('wpinv_payment_mode_top'); |
| 1558 | 1558 | $invoice_id = (int)$invoice->ID; |
| 1559 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
| 1559 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
| 1560 | 1560 | ?> |
| 1561 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;" data-free="1"' : '' ); ?>> |
|
| 1562 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
| 1561 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;" data-free="1"' : ''); ?>> |
|
| 1562 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
| 1563 | 1563 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
| 1564 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
| 1564 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
| 1565 | 1565 | <div class="panel-body list-group wpi-payment_methods"> |
| 1566 | 1566 | <?php |
| 1567 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
| 1567 | + do_action('wpinv_payment_mode_before_gateways'); |
|
| 1568 | 1568 | |
| 1569 | - if ( !empty( $gateways ) ) { |
|
| 1570 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1571 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1572 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1573 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1569 | + if (!empty($gateways)) { |
|
| 1570 | + foreach ($gateways as $gateway_id => $gateway) { |
|
| 1571 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
| 1572 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
| 1573 | + $description = wpinv_get_gateway_description($gateway_id); |
|
| 1574 | 1574 | ?> |
| 1575 | 1575 | <div class="list-group-item"> |
| 1576 | 1576 | <div class="radio"> |
| 1577 | - <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
| 1577 | + <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway['checkout_label']); ?></label> |
|
| 1578 | 1578 | </div> |
| 1579 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
| 1580 | - <?php if ( !empty( $description ) ) { ?> |
|
| 1581 | - <div class="wpi-gateway-desc alert alert-info"><?php _e( $description, 'invoicing' ); ?></div> |
|
| 1579 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
| 1580 | + <?php if (!empty($description)) { ?> |
|
| 1581 | + <div class="wpi-gateway-desc alert alert-info"><?php _e($description, 'invoicing'); ?></div> |
|
| 1582 | 1582 | <?php } ?> |
| 1583 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
| 1583 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
| 1584 | 1584 | </div> |
| 1585 | 1585 | </div> |
| 1586 | 1586 | <?php |
| 1587 | 1587 | } |
| 1588 | 1588 | } else { |
| 1589 | - echo '<div class="alert alert-warning">'. __( 'No payment gateway active', 'invoicing' ) .'</div>'; |
|
| 1589 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
| 1590 | 1590 | } |
| 1591 | 1591 | |
| 1592 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
| 1592 | + do_action('wpinv_payment_mode_after_gateways'); |
|
| 1593 | 1593 | ?> |
| 1594 | 1594 | </div> |
| 1595 | 1595 | </div> |
| 1596 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
| 1596 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
| 1597 | 1597 | </div> |
| 1598 | 1598 | <?php |
| 1599 | 1599 | do_action('wpinv_payment_mode_bottom'); |
| 1600 | 1600 | } |
| 1601 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
| 1601 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
| 1602 | 1602 | |
| 1603 | 1603 | function wpinv_checkout_billing_info() { |
| 1604 | - if ( wpinv_is_checkout() ) { |
|
| 1604 | + if (wpinv_is_checkout()) { |
|
| 1605 | 1605 | $logged_in = is_user_logged_in(); |
| 1606 | 1606 | $billing_details = wpinv_checkout_billing_details(); |
| 1607 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
| 1607 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
| 1608 | 1608 | ?> |
| 1609 | 1609 | <div id="wpinv-fields" class="clearfix"> |
| 1610 | 1610 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
| 1611 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
| 1611 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
| 1612 | 1612 | <div id="wpinv-fields-box" class="panel-body"> |
| 1613 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
| 1613 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
| 1614 | 1614 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1615 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1615 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1616 | 1616 | <?php |
| 1617 | - echo wpinv_html_text( array( |
|
| 1617 | + echo wpinv_html_text(array( |
|
| 1618 | 1618 | 'id' => 'wpinv_first_name', |
| 1619 | 1619 | 'name' => 'wpinv_first_name', |
| 1620 | 1620 | 'value' => $billing_details['first_name'], |
| 1621 | 1621 | 'class' => 'wpi-input form-control', |
| 1622 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
| 1623 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
| 1624 | - ) ); |
|
| 1622 | + 'placeholder' => __('First name', 'invoicing'), |
|
| 1623 | + 'required' => (bool)wpinv_get_option('fname_mandatory'), |
|
| 1624 | + )); |
|
| 1625 | 1625 | ?> |
| 1626 | 1626 | </p> |
| 1627 | 1627 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1628 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1628 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1629 | 1629 | <?php |
| 1630 | - echo wpinv_html_text( array( |
|
| 1630 | + echo wpinv_html_text(array( |
|
| 1631 | 1631 | 'id' => 'wpinv_last_name', |
| 1632 | 1632 | 'name' => 'wpinv_last_name', |
| 1633 | 1633 | 'value' => $billing_details['last_name'], |
| 1634 | 1634 | 'class' => 'wpi-input form-control', |
| 1635 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
| 1636 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
| 1637 | - ) ); |
|
| 1635 | + 'placeholder' => __('Last name', 'invoicing'), |
|
| 1636 | + 'required' => (bool)wpinv_get_option('lname_mandatory'), |
|
| 1637 | + )); |
|
| 1638 | 1638 | ?> |
| 1639 | 1639 | </p> |
| 1640 | 1640 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1641 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1641 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1642 | 1642 | <?php |
| 1643 | - echo wpinv_html_text( array( |
|
| 1643 | + echo wpinv_html_text(array( |
|
| 1644 | 1644 | 'id' => 'wpinv_address', |
| 1645 | 1645 | 'name' => 'wpinv_address', |
| 1646 | 1646 | 'value' => $billing_details['address'], |
| 1647 | 1647 | 'class' => 'wpi-input form-control', |
| 1648 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
| 1649 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
| 1650 | - ) ); |
|
| 1648 | + 'placeholder' => __('Address', 'invoicing'), |
|
| 1649 | + 'required' => (bool)wpinv_get_option('address_mandatory'), |
|
| 1650 | + )); |
|
| 1651 | 1651 | ?> |
| 1652 | 1652 | </p> |
| 1653 | 1653 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1654 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1654 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1655 | 1655 | <?php |
| 1656 | - echo wpinv_html_text( array( |
|
| 1656 | + echo wpinv_html_text(array( |
|
| 1657 | 1657 | 'id' => 'wpinv_city', |
| 1658 | 1658 | 'name' => 'wpinv_city', |
| 1659 | 1659 | 'value' => $billing_details['city'], |
| 1660 | 1660 | 'class' => 'wpi-input form-control', |
| 1661 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
| 1662 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
| 1663 | - ) ); |
|
| 1661 | + 'placeholder' => __('City', 'invoicing'), |
|
| 1662 | + 'required' => (bool)wpinv_get_option('city_mandatory'), |
|
| 1663 | + )); |
|
| 1664 | 1664 | ?> |
| 1665 | 1665 | </p> |
| 1666 | 1666 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1667 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1668 | - <?php echo wpinv_html_select( array( |
|
| 1667 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1668 | + <?php echo wpinv_html_select(array( |
|
| 1669 | 1669 | 'options' => wpinv_get_country_list(), |
| 1670 | 1670 | 'name' => 'wpinv_country', |
| 1671 | 1671 | 'id' => 'wpinv_country', |
@@ -1673,16 +1673,16 @@ discard block |
||
| 1673 | 1673 | 'show_option_all' => false, |
| 1674 | 1674 | 'show_option_none' => false, |
| 1675 | 1675 | 'class' => 'wpi-input form-control wpi_select2', |
| 1676 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 1677 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
| 1678 | - ) ); ?> |
|
| 1676 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
| 1677 | + 'required' => (bool)wpinv_get_option('country_mandatory'), |
|
| 1678 | + )); ?> |
|
| 1679 | 1679 | </p> |
| 1680 | 1680 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1681 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1681 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1682 | 1682 | <?php |
| 1683 | - $states = wpinv_get_country_states( $selected_country ); |
|
| 1684 | - if( !empty( $states ) ) { |
|
| 1685 | - echo wpinv_html_select( array( |
|
| 1683 | + $states = wpinv_get_country_states($selected_country); |
|
| 1684 | + if (!empty($states)) { |
|
| 1685 | + echo wpinv_html_select(array( |
|
| 1686 | 1686 | 'options' => $states, |
| 1687 | 1687 | 'name' => 'wpinv_state', |
| 1688 | 1688 | 'id' => 'wpinv_state', |
@@ -1690,61 +1690,61 @@ discard block |
||
| 1690 | 1690 | 'show_option_all' => false, |
| 1691 | 1691 | 'show_option_none' => false, |
| 1692 | 1692 | 'class' => 'wpi-input form-control wpi_select2', |
| 1693 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 1694 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
| 1695 | - ) ); |
|
| 1693 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 1694 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
| 1695 | + )); |
|
| 1696 | 1696 | } else { |
| 1697 | - echo wpinv_html_text( array( |
|
| 1697 | + echo wpinv_html_text(array( |
|
| 1698 | 1698 | 'name' => 'wpinv_state', |
| 1699 | 1699 | 'value' => $billing_details['state'], |
| 1700 | 1700 | 'id' => 'wpinv_state', |
| 1701 | 1701 | 'class' => 'wpi-input form-control', |
| 1702 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
| 1703 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
| 1704 | - ) ); |
|
| 1702 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
| 1703 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
| 1704 | + )); |
|
| 1705 | 1705 | } |
| 1706 | 1706 | ?> |
| 1707 | 1707 | </p> |
| 1708 | 1708 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1709 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1709 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1710 | 1710 | <?php |
| 1711 | - echo wpinv_html_text( array( |
|
| 1711 | + echo wpinv_html_text(array( |
|
| 1712 | 1712 | 'name' => 'wpinv_zip', |
| 1713 | 1713 | 'value' => $billing_details['zip'], |
| 1714 | 1714 | 'id' => 'wpinv_zip', |
| 1715 | 1715 | 'class' => 'wpi-input form-control', |
| 1716 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
| 1717 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
| 1718 | - ) ); |
|
| 1716 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
| 1717 | + 'required' => (bool)wpinv_get_option('zip_mandatory'), |
|
| 1718 | + )); |
|
| 1719 | 1719 | ?> |
| 1720 | 1720 | </p> |
| 1721 | 1721 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1722 | - <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1722 | + <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1723 | 1723 | <?php |
| 1724 | - echo wpinv_html_text( array( |
|
| 1724 | + echo wpinv_html_text(array( |
|
| 1725 | 1725 | 'id' => 'wpinv_phone', |
| 1726 | 1726 | 'name' => 'wpinv_phone', |
| 1727 | 1727 | 'value' => $billing_details['phone'], |
| 1728 | 1728 | 'class' => 'wpi-input form-control', |
| 1729 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
| 1730 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
| 1731 | - ) ); |
|
| 1729 | + 'placeholder' => __('Phone', 'invoicing'), |
|
| 1730 | + 'required' => (bool)wpinv_get_option('phone_mandatory'), |
|
| 1731 | + )); |
|
| 1732 | 1732 | ?> |
| 1733 | 1733 | </p> |
| 1734 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
| 1734 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
| 1735 | 1735 | <div class="clearfix"></div> |
| 1736 | 1736 | </div> |
| 1737 | 1737 | </div> |
| 1738 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
| 1738 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
| 1739 | 1739 | </div> |
| 1740 | 1740 | <?php |
| 1741 | 1741 | } |
| 1742 | 1742 | } |
| 1743 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
| 1743 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
| 1744 | 1744 | |
| 1745 | 1745 | function wpinv_checkout_hidden_fields() { |
| 1746 | 1746 | ?> |
| 1747 | - <?php if ( is_user_logged_in() ) { ?> |
|
| 1747 | + <?php if (is_user_logged_in()) { ?> |
|
| 1748 | 1748 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
| 1749 | 1749 | <?php } ?> |
| 1750 | 1750 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1754,9 +1754,9 @@ discard block |
||
| 1754 | 1754 | function wpinv_checkout_button_purchase() { |
| 1755 | 1755 | ob_start(); |
| 1756 | 1756 | ?> |
| 1757 | - <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/> |
|
| 1757 | + <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/> |
|
| 1758 | 1758 | <?php |
| 1759 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
| 1759 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
| 1760 | 1760 | } |
| 1761 | 1761 | |
| 1762 | 1762 | function wpinv_checkout_total() { |
@@ -1765,116 +1765,116 @@ discard block |
||
| 1765 | 1765 | <div id="wpinv_checkout_total" class="panel panel-info"> |
| 1766 | 1766 | <div class="panel-body"> |
| 1767 | 1767 | <?php |
| 1768 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
| 1768 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
| 1769 | 1769 | ?> |
| 1770 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
| 1770 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
| 1771 | 1771 | <?php |
| 1772 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
| 1772 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
| 1773 | 1773 | ?> |
| 1774 | 1774 | </div> |
| 1775 | 1775 | </div> |
| 1776 | 1776 | <?php |
| 1777 | 1777 | } |
| 1778 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
| 1778 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
| 1779 | 1779 | |
| 1780 | 1780 | function wpinv_checkout_accept_tandc() { |
| 1781 | - $page = wpinv_get_option( 'tandc_page' ); |
|
| 1781 | + $page = wpinv_get_option('tandc_page'); |
|
| 1782 | 1782 | ?> |
| 1783 | 1783 | <div id="wpinv_checkout_tandc" class="panel panel-success"> |
| 1784 | 1784 | <div class="panel-body"> |
| 1785 | 1785 | <?php echo wpinv_get_policy_text(); ?> |
| 1786 | 1786 | <?php |
| 1787 | - if(isset($page) && (int)$page > 0 && apply_filters( 'wpinv_checkout_show_terms', true )){ |
|
| 1788 | - $terms_link = esc_url( get_permalink( $page ) ); |
|
| 1787 | + if (isset($page) && (int)$page > 0 && apply_filters('wpinv_checkout_show_terms', true)) { |
|
| 1788 | + $terms_link = esc_url(get_permalink($page)); |
|
| 1789 | 1789 | ?> |
| 1790 | 1790 | <label class=""> |
| 1791 | - <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked( apply_filters( 'wpinv_terms_is_checked_default', isset( $_POST['wpi_terms'] ) ), true ); ?>> <span><?php printf( __( 'I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing' ), $terms_link ); ?></span> <span class="wpi-required">*</span> |
|
| 1791 | + <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked(apply_filters('wpinv_terms_is_checked_default', isset($_POST['wpi_terms'])), true); ?>> <span><?php printf(__('I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing'), $terms_link); ?></span> <span class="wpi-required">*</span> |
|
| 1792 | 1792 | </label> |
| 1793 | 1793 | <?php } ?> |
| 1794 | 1794 | </div> |
| 1795 | 1795 | </div> |
| 1796 | 1796 | <?php |
| 1797 | 1797 | } |
| 1798 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995 ); |
|
| 1798 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995); |
|
| 1799 | 1799 | |
| 1800 | 1800 | function wpinv_checkout_submit() { |
| 1801 | 1801 | ?> |
| 1802 | 1802 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
| 1803 | 1803 | <div class="panel-body text-center"> |
| 1804 | 1804 | <?php |
| 1805 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
| 1805 | + do_action('wpinv_purchase_form_before_submit'); |
|
| 1806 | 1806 | wpinv_checkout_hidden_fields(); |
| 1807 | 1807 | echo wpinv_checkout_button_purchase(); |
| 1808 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
| 1808 | + do_action('wpinv_purchase_form_after_submit'); |
|
| 1809 | 1809 | ?> |
| 1810 | 1810 | </div> |
| 1811 | 1811 | </div> |
| 1812 | 1812 | <?php |
| 1813 | 1813 | } |
| 1814 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
| 1814 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
| 1815 | 1815 | |
| 1816 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
| 1817 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1816 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
| 1817 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1818 | 1818 | |
| 1819 | - if ( empty( $invoice ) ) { |
|
| 1819 | + if (empty($invoice)) { |
|
| 1820 | 1820 | return NULL; |
| 1821 | 1821 | } |
| 1822 | 1822 | |
| 1823 | 1823 | $billing_details = $invoice->get_user_info(); |
| 1824 | 1824 | $address_row = ''; |
| 1825 | - if ( $address = $billing_details['address'] ) { |
|
| 1826 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
| 1825 | + if ($address = $billing_details['address']) { |
|
| 1826 | + $address_row .= wpautop(wp_kses_post($address)); |
|
| 1827 | 1827 | } |
| 1828 | 1828 | |
| 1829 | 1829 | $address_fields = array(); |
| 1830 | - if ( !empty( $billing_details['city'] ) ) { |
|
| 1830 | + if (!empty($billing_details['city'])) { |
|
| 1831 | 1831 | $address_fields[] = $billing_details['city']; |
| 1832 | 1832 | } |
| 1833 | 1833 | |
| 1834 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
| 1835 | - if ( !empty( $billing_details['state'] ) ) { |
|
| 1836 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
| 1834 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
| 1835 | + if (!empty($billing_details['state'])) { |
|
| 1836 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
| 1837 | 1837 | } |
| 1838 | 1838 | |
| 1839 | - if ( !empty( $billing_country ) ) { |
|
| 1840 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
| 1839 | + if (!empty($billing_country)) { |
|
| 1840 | + $address_fields[] = wpinv_country_name($billing_country); |
|
| 1841 | 1841 | } |
| 1842 | 1842 | |
| 1843 | - if ( !empty( $address_fields ) ) { |
|
| 1844 | - $address_fields = implode( ", ", $address_fields ); |
|
| 1843 | + if (!empty($address_fields)) { |
|
| 1844 | + $address_fields = implode(", ", $address_fields); |
|
| 1845 | 1845 | |
| 1846 | - if ( !empty( $billing_details['zip'] ) ) { |
|
| 1846 | + if (!empty($billing_details['zip'])) { |
|
| 1847 | 1847 | $address_fields .= ' ' . $billing_details['zip']; |
| 1848 | 1848 | } |
| 1849 | 1849 | |
| 1850 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
| 1850 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
| 1851 | 1851 | } |
| 1852 | 1852 | ob_start(); |
| 1853 | 1853 | ?> |
| 1854 | 1854 | <table class="table table-bordered table-sm wpi-billing-details"> |
| 1855 | 1855 | <tbody> |
| 1856 | 1856 | <tr class="wpi-receipt-name"> |
| 1857 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
| 1858 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
| 1857 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
| 1858 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
| 1859 | 1859 | </tr> |
| 1860 | 1860 | <tr class="wpi-receipt-email"> |
| 1861 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
| 1862 | - <td><?php echo $billing_details['email'] ;?></td> |
|
| 1861 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
| 1862 | + <td><?php echo $billing_details['email']; ?></td> |
|
| 1863 | 1863 | </tr> |
| 1864 | - <?php if ( $billing_details['company'] ) { ?> |
|
| 1864 | + <?php if ($billing_details['company']) { ?> |
|
| 1865 | 1865 | <tr class="wpi-receipt-company"> |
| 1866 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
| 1867 | - <td><?php echo esc_html( $billing_details['company'] ) ;?></td> |
|
| 1866 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
| 1867 | + <td><?php echo esc_html($billing_details['company']); ?></td> |
|
| 1868 | 1868 | </tr> |
| 1869 | 1869 | <?php } ?> |
| 1870 | 1870 | <tr class="wpi-receipt-address"> |
| 1871 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
| 1872 | - <td><?php echo $address_row ;?></td> |
|
| 1871 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
| 1872 | + <td><?php echo $address_row; ?></td> |
|
| 1873 | 1873 | </tr> |
| 1874 | - <?php if ( $billing_details['phone'] ) { ?> |
|
| 1874 | + <?php if ($billing_details['phone']) { ?> |
|
| 1875 | 1875 | <tr class="wpi-receipt-phone"> |
| 1876 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
| 1877 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
| 1876 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
| 1877 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
| 1878 | 1878 | </tr> |
| 1879 | 1879 | <?php } ?> |
| 1880 | 1880 | </tbody> |
@@ -1882,74 +1882,74 @@ discard block |
||
| 1882 | 1882 | <?php |
| 1883 | 1883 | $output = ob_get_clean(); |
| 1884 | 1884 | |
| 1885 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
| 1885 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
| 1886 | 1886 | |
| 1887 | 1887 | echo $output; |
| 1888 | 1888 | } |
| 1889 | 1889 | |
| 1890 | -function wpinv_filter_success_page_content( $content ) { |
|
| 1891 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
| 1892 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
| 1893 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
| 1890 | +function wpinv_filter_success_page_content($content) { |
|
| 1891 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
| 1892 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
| 1893 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
| 1894 | 1894 | } |
| 1895 | 1895 | } |
| 1896 | 1896 | |
| 1897 | 1897 | return $content; |
| 1898 | 1898 | } |
| 1899 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
| 1899 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
| 1900 | 1900 | |
| 1901 | -function wpinv_receipt_actions( $invoice ) { |
|
| 1902 | - if ( !empty( $invoice ) ) { |
|
| 1901 | +function wpinv_receipt_actions($invoice) { |
|
| 1902 | + if (!empty($invoice)) { |
|
| 1903 | 1903 | $actions = array(); |
| 1904 | 1904 | |
| 1905 | - if ( wpinv_user_can_view_invoice( $invoice->ID ) ) { |
|
| 1906 | - $actions['print'] = array( |
|
| 1907 | - 'url' => $invoice->get_view_url( true ), |
|
| 1908 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
| 1905 | + if (wpinv_user_can_view_invoice($invoice->ID)) { |
|
| 1906 | + $actions['print'] = array( |
|
| 1907 | + 'url' => $invoice->get_view_url(true), |
|
| 1908 | + 'name' => __('Print Invoice', 'invoicing'), |
|
| 1909 | 1909 | 'class' => 'btn-primary', |
| 1910 | 1910 | ); |
| 1911 | 1911 | } |
| 1912 | 1912 | |
| 1913 | - if ( is_user_logged_in() ) { |
|
| 1913 | + if (is_user_logged_in()) { |
|
| 1914 | 1914 | $actions['history'] = array( |
| 1915 | 1915 | 'url' => wpinv_get_history_page_uri(), |
| 1916 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
| 1916 | + 'name' => __('Invoice History', 'invoicing'), |
|
| 1917 | 1917 | 'class' => 'btn-warning', |
| 1918 | 1918 | ); |
| 1919 | 1919 | } |
| 1920 | 1920 | |
| 1921 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
| 1921 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
| 1922 | 1922 | |
| 1923 | - if ( !empty( $actions ) ) { |
|
| 1923 | + if (!empty($actions)) { |
|
| 1924 | 1924 | ?> |
| 1925 | 1925 | <div class="wpinv-receipt-actions text-right"> |
| 1926 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
| 1927 | - <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a> |
|
| 1926 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
| 1927 | + <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a> |
|
| 1928 | 1928 | <?php } ?> |
| 1929 | 1929 | </div> |
| 1930 | 1930 | <?php |
| 1931 | 1931 | } |
| 1932 | 1932 | } |
| 1933 | 1933 | } |
| 1934 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
| 1934 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
| 1935 | 1935 | |
| 1936 | -function wpinv_invoice_link( $invoice_id ) { |
|
| 1937 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1936 | +function wpinv_invoice_link($invoice_id) { |
|
| 1937 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1938 | 1938 | |
| 1939 | - if ( empty( $invoice ) ) { |
|
| 1939 | + if (empty($invoice)) { |
|
| 1940 | 1940 | return NULL; |
| 1941 | 1941 | } |
| 1942 | 1942 | |
| 1943 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
| 1943 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
| 1944 | 1944 | |
| 1945 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
| 1945 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
| 1946 | 1946 | } |
| 1947 | 1947 | |
| 1948 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
| 1949 | - if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) { |
|
| 1950 | - $subscription = wpinv_get_subscription( $invoice, true ); |
|
| 1948 | +function wpinv_invoice_subscription_details($invoice) { |
|
| 1949 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
| 1950 | + $subscription = wpinv_get_subscription($invoice, true); |
|
| 1951 | 1951 | |
| 1952 | - if ( empty( $subscription ) ) { |
|
| 1952 | + if (empty($subscription)) { |
|
| 1953 | 1953 | return; |
| 1954 | 1954 | } |
| 1955 | 1955 | |
@@ -1960,15 +1960,15 @@ discard block |
||
| 1960 | 1960 | $payments = $subscription->get_child_payments(); |
| 1961 | 1961 | ?> |
| 1962 | 1962 | <div class="wpinv-subscriptions-details"> |
| 1963 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
| 1963 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
| 1964 | 1964 | <table class="table"> |
| 1965 | 1965 | <thead> |
| 1966 | 1966 | <tr> |
| 1967 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
| 1968 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
| 1969 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
| 1970 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
| 1971 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
| 1967 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
| 1968 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
| 1969 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
| 1970 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
| 1971 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
| 1972 | 1972 | </tr> |
| 1973 | 1973 | </thead> |
| 1974 | 1974 | <tbody> |
@@ -1982,29 +1982,29 @@ discard block |
||
| 1982 | 1982 | </tbody> |
| 1983 | 1983 | </table> |
| 1984 | 1984 | </div> |
| 1985 | - <?php if ( !empty( $payments ) ) { ?> |
|
| 1985 | + <?php if (!empty($payments)) { ?> |
|
| 1986 | 1986 | <div class="wpinv-renewal-payments"> |
| 1987 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
| 1987 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
| 1988 | 1988 | <table class="table"> |
| 1989 | 1989 | <thead> |
| 1990 | 1990 | <tr> |
| 1991 | 1991 | <th>#</th> |
| 1992 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
| 1993 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
| 1994 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
| 1992 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
| 1993 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
| 1994 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
| 1995 | 1995 | </tr> |
| 1996 | 1996 | </thead> |
| 1997 | 1997 | <tbody> |
| 1998 | 1998 | <?php |
| 1999 | 1999 | $i = 1; |
| 2000 | - foreach ( $payments as $payment ) { |
|
| 2000 | + foreach ($payments as $payment) { |
|
| 2001 | 2001 | $invoice_id = $payment->ID; |
| 2002 | 2002 | ?> |
| 2003 | 2003 | <tr> |
| 2004 | - <th scope="row"><?php echo $i;?></th> |
|
| 2005 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
| 2006 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
| 2007 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
| 2004 | + <th scope="row"><?php echo $i; ?></th> |
|
| 2005 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
| 2006 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
| 2007 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
| 2008 | 2008 | </tr> |
| 2009 | 2009 | <?php $i++; } ?> |
| 2010 | 2010 | </tbody> |
@@ -2015,52 +2015,52 @@ discard block |
||
| 2015 | 2015 | } |
| 2016 | 2016 | } |
| 2017 | 2017 | |
| 2018 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
| 2019 | - if ( empty( $invoice ) ) { |
|
| 2018 | +function wpinv_cart_total_label($label, $invoice) { |
|
| 2019 | + if (empty($invoice)) { |
|
| 2020 | 2020 | return $label; |
| 2021 | 2021 | } |
| 2022 | 2022 | |
| 2023 | 2023 | $prefix_label = ''; |
| 2024 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
| 2025 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
| 2026 | - } else if ( $invoice->is_renewal() ) { |
|
| 2027 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
| 2024 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
| 2025 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
| 2026 | + } else if ($invoice->is_renewal()) { |
|
| 2027 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
| 2028 | 2028 | } |
| 2029 | 2029 | |
| 2030 | - if ( $prefix_label != '' ) { |
|
| 2031 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 2030 | + if ($prefix_label != '') { |
|
| 2031 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 2032 | 2032 | } |
| 2033 | 2033 | |
| 2034 | 2034 | return $label; |
| 2035 | 2035 | } |
| 2036 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2037 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2038 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2036 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2037 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2038 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2039 | 2039 | |
| 2040 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
| 2040 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
| 2041 | 2041 | |
| 2042 | -function wpinv_invoice_print_description( $invoice ) { |
|
| 2043 | - if ( empty( $invoice ) ) { |
|
| 2042 | +function wpinv_invoice_print_description($invoice) { |
|
| 2043 | + if (empty($invoice)) { |
|
| 2044 | 2044 | return NULL; |
| 2045 | 2045 | } |
| 2046 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
| 2046 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
| 2047 | 2047 | ?> |
| 2048 | 2048 | <div class="row wpinv-lower"> |
| 2049 | 2049 | <div class="col-sm-12 wpinv-description"> |
| 2050 | - <?php echo wpautop( $description ); ?> |
|
| 2050 | + <?php echo wpautop($description); ?> |
|
| 2051 | 2051 | </div> |
| 2052 | 2052 | </div> |
| 2053 | 2053 | <?php |
| 2054 | 2054 | } |
| 2055 | 2055 | } |
| 2056 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
| 2056 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
| 2057 | 2057 | |
| 2058 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
| 2059 | - if ( empty( $invoice ) ) { |
|
| 2058 | +function wpinv_invoice_print_payment_info($invoice) { |
|
| 2059 | + if (empty($invoice)) { |
|
| 2060 | 2060 | return NULL; |
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
| 2063 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
| 2064 | 2064 | ?> |
| 2065 | 2065 | <div class="row wpinv-payments"> |
| 2066 | 2066 | <div class="col-sm-12"> |
@@ -2072,43 +2072,43 @@ discard block |
||
| 2072 | 2072 | } |
| 2073 | 2073 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
| 2074 | 2074 | |
| 2075 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
| 2076 | - if ( empty( $note ) ) { |
|
| 2075 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
| 2076 | + if (empty($note)) { |
|
| 2077 | 2077 | return NULL; |
| 2078 | 2078 | } |
| 2079 | 2079 | |
| 2080 | - if ( is_int( $note ) ) { |
|
| 2081 | - $note = get_comment( $note ); |
|
| 2080 | + if (is_int($note)) { |
|
| 2081 | + $note = get_comment($note); |
|
| 2082 | 2082 | } |
| 2083 | 2083 | |
| 2084 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
| 2084 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
| 2085 | 2085 | return NULL; |
| 2086 | 2086 | } |
| 2087 | 2087 | |
| 2088 | - $note_classes = array( 'note' ); |
|
| 2089 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
| 2088 | + $note_classes = array('note'); |
|
| 2089 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
| 2090 | 2090 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
| 2091 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
| 2092 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
| 2091 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
| 2092 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
| 2093 | 2093 | |
| 2094 | 2094 | ob_start(); |
| 2095 | 2095 | ?> |
| 2096 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
| 2096 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
| 2097 | 2097 | <div class="note_content"> |
| 2098 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
| 2098 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
| 2099 | 2099 | </div> |
| 2100 | 2100 | <p class="meta"> |
| 2101 | - <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr> |
|
| 2102 | - <?php if ( $note->comment_author !== 'System' || current_user_can( 'manage_options' ) ) { ?> |
|
| 2103 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
| 2101 | + <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr> |
|
| 2102 | + <?php if ($note->comment_author !== 'System' || current_user_can('manage_options')) { ?> |
|
| 2103 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
| 2104 | 2104 | <?php } ?> |
| 2105 | 2105 | </p> |
| 2106 | 2106 | </li> |
| 2107 | 2107 | <?php |
| 2108 | 2108 | $note_content = ob_get_clean(); |
| 2109 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
| 2109 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
| 2110 | 2110 | |
| 2111 | - if ( $echo ) { |
|
| 2111 | + if ($echo) { |
|
| 2112 | 2112 | echo $note_content; |
| 2113 | 2113 | } else { |
| 2114 | 2114 | return $note_content; |
@@ -2118,43 +2118,43 @@ discard block |
||
| 2118 | 2118 | function wpinv_invalid_invoice_content() { |
| 2119 | 2119 | global $post; |
| 2120 | 2120 | |
| 2121 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
| 2121 | + $invoice = wpinv_get_invoice($post->ID); |
|
| 2122 | 2122 | |
| 2123 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing' ); |
|
| 2124 | - if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
| 2125 | - if ( is_user_logged_in() ) { |
|
| 2126 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 2127 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2128 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
| 2123 | + $error = __('This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing'); |
|
| 2124 | + if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
| 2125 | + if (is_user_logged_in()) { |
|
| 2126 | + if (wpinv_require_login_to_checkout()) { |
|
| 2127 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 2128 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
| 2129 | 2129 | } |
| 2130 | 2130 | } |
| 2131 | 2131 | } else { |
| 2132 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 2133 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2134 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
| 2132 | + if (wpinv_require_login_to_checkout()) { |
|
| 2133 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 2134 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
| 2135 | 2135 | } |
| 2136 | 2136 | } |
| 2137 | 2137 | } |
| 2138 | 2138 | } else { |
| 2139 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
| 2139 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
| 2140 | 2140 | } |
| 2141 | 2141 | ?> |
| 2142 | 2142 | <div class="row wpinv-row-invalid"> |
| 2143 | 2143 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
| 2144 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
| 2144 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
| 2145 | 2145 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
| 2146 | 2146 | </div> |
| 2147 | 2147 | </div> |
| 2148 | 2148 | <?php |
| 2149 | 2149 | } |
| 2150 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
| 2150 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
| 2151 | 2151 | |
| 2152 | -add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
| 2153 | -function wpinv_force_company_name_field(){ |
|
| 2152 | +add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
| 2153 | +function wpinv_force_company_name_field() { |
|
| 2154 | 2154 | $invoice = wpinv_get_invoice_cart(); |
| 2155 | - $user_id = wpinv_get_user_id( $invoice->ID ); |
|
| 2156 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
| 2157 | - if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) { |
|
| 2155 | + $user_id = wpinv_get_user_id($invoice->ID); |
|
| 2156 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
| 2157 | + if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) { |
|
| 2158 | 2158 | ?> |
| 2159 | 2159 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 2160 | 2160 | <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label> |
@@ -2179,21 +2179,21 @@ discard block |
||
| 2179 | 2179 | * @return string |
| 2180 | 2180 | */ |
| 2181 | 2181 | function wpinv_get_policy_text() { |
| 2182 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
| 2182 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
| 2183 | 2183 | |
| 2184 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
| 2184 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
| 2185 | 2185 | |
| 2186 | - if(!$privacy_page_id){ |
|
| 2187 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
| 2186 | + if (!$privacy_page_id) { |
|
| 2187 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
| 2188 | 2188 | } |
| 2189 | 2189 | |
| 2190 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
| 2190 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
| 2191 | 2191 | |
| 2192 | 2192 | $find_replace = array( |
| 2193 | 2193 | '[wpinv_privacy_policy]' => $privacy_link, |
| 2194 | 2194 | ); |
| 2195 | 2195 | |
| 2196 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
| 2196 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
| 2197 | 2197 | |
| 2198 | 2198 | return wp_kses_post(wpautop($privacy_text)); |
| 2199 | 2199 | } |
| 2200 | 2200 | \ No newline at end of file |
@@ -7,67 +7,67 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | function wpinv_get_default_country() { |
| 16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
| 16 | + $country = wpinv_get_option('default_country', 'UK'); |
|
| 17 | 17 | |
| 18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
| 18 | + return apply_filters('wpinv_default_country', $country); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -function wpinv_is_base_country( $country ) { |
|
| 21 | +function wpinv_is_base_country($country) { |
|
| 22 | 22 | $base_country = wpinv_get_default_country(); |
| 23 | 23 | |
| 24 | - if ( $base_country === 'UK' ) { |
|
| 24 | + if ($base_country === 'UK') { |
|
| 25 | 25 | $base_country = 'GB'; |
| 26 | 26 | } |
| 27 | - if ( $country == 'UK' ) { |
|
| 27 | + if ($country == 'UK') { |
|
| 28 | 28 | $country = 'GB'; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - return ( $country && $country === $base_country ) ? true : false; |
|
| 31 | + return ($country && $country === $base_country) ? true : false; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -function wpinv_country_name( $country_code = '' ) { |
|
| 34 | +function wpinv_country_name($country_code = '') { |
|
| 35 | 35 | $countries = wpinv_get_country_list(); |
| 36 | 36 | $country_code = $country_code == 'UK' ? 'GB' : $country_code; |
| 37 | - $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code; |
|
| 37 | + $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code; |
|
| 38 | 38 | |
| 39 | - return apply_filters( 'wpinv_country_name', $country, $country_code ); |
|
| 39 | + return apply_filters('wpinv_country_name', $country, $country_code); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | function wpinv_get_default_state() { |
| 43 | - $state = wpinv_get_option( 'default_state', false ); |
|
| 43 | + $state = wpinv_get_option('default_state', false); |
|
| 44 | 44 | |
| 45 | - return apply_filters( 'wpinv_default_state', $state ); |
|
| 45 | + return apply_filters('wpinv_default_state', $state); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | -function wpinv_state_name( $state_code = '', $country_code = '' ) { |
|
| 48 | +function wpinv_state_name($state_code = '', $country_code = '') { |
|
| 49 | 49 | $state = $state_code; |
| 50 | 50 | |
| 51 | - if ( !empty( $country_code ) ) { |
|
| 52 | - $states = wpinv_get_country_states( $country_code ); |
|
| 51 | + if (!empty($country_code)) { |
|
| 52 | + $states = wpinv_get_country_states($country_code); |
|
| 53 | 53 | |
| 54 | - $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state; |
|
| 54 | + $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code ); |
|
| 57 | + return apply_filters('wpinv_state_name', $state, $state_code, $country_code); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | function wpinv_store_address() { |
| 61 | - $address = wpinv_get_option( 'store_address', '' ); |
|
| 61 | + $address = wpinv_get_option('store_address', ''); |
|
| 62 | 62 | |
| 63 | - return apply_filters( 'wpinv_store_address', $address ); |
|
| 63 | + return apply_filters('wpinv_store_address', $address); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | -function wpinv_get_user_address( $user_id = 0, $with_default = true ) { |
|
| 66 | +function wpinv_get_user_address($user_id = 0, $with_default = true) { |
|
| 67 | 67 | global $wpi_userID; |
| 68 | 68 | |
| 69 | - if( empty( $user_id ) ) { |
|
| 70 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : get_current_user_id(); |
|
| 69 | + if (empty($user_id)) { |
|
| 70 | + $user_id = !empty($wpi_userID) ? $wpi_userID : get_current_user_id(); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $address_fields = array( |
@@ -85,36 +85,36 @@ discard block |
||
| 85 | 85 | 'zip', |
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | - $user_info = get_userdata( $user_id ); |
|
| 88 | + $user_info = get_userdata($user_id); |
|
| 89 | 89 | |
| 90 | 90 | $address = array(); |
| 91 | 91 | $address['user_id'] = $user_id; |
| 92 | - $address['email'] = !empty( $user_info ) ? $user_info->user_email : ''; |
|
| 93 | - foreach ( $address_fields as $field ) { |
|
| 94 | - $address[$field] = get_user_meta( $user_id, '_wpinv_' . $field, true ); |
|
| 92 | + $address['email'] = !empty($user_info) ? $user_info->user_email : ''; |
|
| 93 | + foreach ($address_fields as $field) { |
|
| 94 | + $address[$field] = get_user_meta($user_id, '_wpinv_' . $field, true); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if ( !empty( $user_info ) ) { |
|
| 98 | - if( empty( $address['first_name'] ) ) |
|
| 97 | + if (!empty($user_info)) { |
|
| 98 | + if (empty($address['first_name'])) |
|
| 99 | 99 | $address['first_name'] = $user_info->first_name; |
| 100 | 100 | |
| 101 | - if( empty( $address['last_name'] ) ) |
|
| 101 | + if (empty($address['last_name'])) |
|
| 102 | 102 | $address['last_name'] = $user_info->last_name; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - $address['name'] = trim( trim( $address['first_name'] . ' ' . $address['last_name'] ), "," ); |
|
| 105 | + $address['name'] = trim(trim($address['first_name'] . ' ' . $address['last_name']), ","); |
|
| 106 | 106 | |
| 107 | - if( empty( $address['state'] ) && $with_default ) |
|
| 107 | + if (empty($address['state']) && $with_default) |
|
| 108 | 108 | $address['state'] = wpinv_get_default_state(); |
| 109 | 109 | |
| 110 | - if( empty( $address['country'] ) && $with_default ) |
|
| 110 | + if (empty($address['country']) && $with_default) |
|
| 111 | 111 | $address['country'] = wpinv_get_default_country(); |
| 112 | 112 | |
| 113 | 113 | |
| 114 | 114 | return $address; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | -function wpinv_get_country_list( $first_empty = false ) { |
|
| 117 | +function wpinv_get_country_list($first_empty = false) { |
|
| 118 | 118 | $countries = array( |
| 119 | 119 | 'US' => __('United States', 'invoicing'), |
| 120 | 120 | 'CA' => __('Canada', 'invoicing'), |
@@ -370,23 +370,23 @@ discard block |
||
| 370 | 370 | 'ZW' => __('Zimbabwe', 'invoicing'), |
| 371 | 371 | ); |
| 372 | 372 | |
| 373 | - if ( $first_empty ) { |
|
| 374 | - $countries = array_merge( array( '' => '' ), $countries ); |
|
| 373 | + if ($first_empty) { |
|
| 374 | + $countries = array_merge(array('' => ''), $countries); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - $countries = apply_filters( 'wpinv_countries', $countries ); |
|
| 377 | + $countries = apply_filters('wpinv_countries', $countries); |
|
| 378 | 378 | |
| 379 | 379 | asort($countries); |
| 380 | 380 | |
| 381 | 381 | return $countries; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | -function wpinv_get_country_states( $country = null, $first_empty = false ) { |
|
| 385 | - if ( empty( $country ) ) { |
|
| 384 | +function wpinv_get_country_states($country = null, $first_empty = false) { |
|
| 385 | + if (empty($country)) { |
|
| 386 | 386 | $country = wpinv_get_default_country(); |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - switch( $country ) { |
|
| 389 | + switch ($country) { |
|
| 390 | 390 | case 'US' : |
| 391 | 391 | $states = wpinv_get_us_states_list(); |
| 392 | 392 | break; |
@@ -461,11 +461,11 @@ discard block |
||
| 461 | 461 | break; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - if ( !empty( $states ) && $first_empty ) { |
|
| 465 | - $states = array_merge( array( '' => '' ), $states ); |
|
| 464 | + if (!empty($states) && $first_empty) { |
|
| 465 | + $states = array_merge(array('' => ''), $states); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - $states = apply_filters( 'wpinv_country_states', $states, $country ); |
|
| 468 | + $states = apply_filters('wpinv_country_states', $states, $country); |
|
| 469 | 469 | |
| 470 | 470 | asort($states); |
| 471 | 471 | |
@@ -474,1087 +474,1087 @@ discard block |
||
| 474 | 474 | |
| 475 | 475 | function wpinv_get_us_states_list() { |
| 476 | 476 | $states = array( |
| 477 | - 'AL' => __( 'Alabama', 'invoicing' ), |
|
| 478 | - 'AK' => __( 'Alaska', 'invoicing' ), |
|
| 479 | - 'AZ' => __( 'Arizona', 'invoicing' ), |
|
| 480 | - 'AR' => __( 'Arkansas', 'invoicing' ), |
|
| 481 | - 'CA' => __( 'California', 'invoicing' ), |
|
| 482 | - 'CO' => __( 'Colorado', 'invoicing' ), |
|
| 483 | - 'CT' => __( 'Connecticut', 'invoicing' ), |
|
| 484 | - 'DE' => __( 'Delaware', 'invoicing' ), |
|
| 485 | - 'DC' => __( 'District of Columbia', 'invoicing' ), |
|
| 486 | - 'FL' => __( 'Florida', 'invoicing' ), |
|
| 487 | - 'GA' => __( 'Georgia', 'invoicing' ), |
|
| 488 | - 'HI' => __( 'Hawaii', 'invoicing' ), |
|
| 489 | - 'ID' => __( 'Idaho', 'invoicing' ), |
|
| 490 | - 'IL' => __( 'Illinois', 'invoicing' ), |
|
| 491 | - 'IN' => __( 'Indiana', 'invoicing' ), |
|
| 492 | - 'IA' => __( 'Iowa', 'invoicing' ), |
|
| 493 | - 'KS' => __( 'Kansas', 'invoicing' ), |
|
| 494 | - 'KY' => __( 'Kentucky', 'invoicing' ), |
|
| 495 | - 'LA' => __( 'Louisiana', 'invoicing' ), |
|
| 496 | - 'ME' => __( 'Maine', 'invoicing' ), |
|
| 497 | - 'MD' => __( 'Maryland', 'invoicing' ), |
|
| 498 | - 'MA' => __( 'Massachusetts', 'invoicing' ), |
|
| 499 | - 'MI' => __( 'Michigan', 'invoicing' ), |
|
| 500 | - 'MN' => __( 'Minnesota', 'invoicing' ), |
|
| 501 | - 'MS' => __( 'Mississippi', 'invoicing' ), |
|
| 502 | - 'MO' => __( 'Missouri', 'invoicing' ), |
|
| 503 | - 'MT' => __( 'Montana', 'invoicing' ), |
|
| 504 | - 'NE' => __( 'Nebraska', 'invoicing' ), |
|
| 505 | - 'NV' => __( 'Nevada', 'invoicing' ), |
|
| 506 | - 'NH' => __( 'New Hampshire', 'invoicing' ), |
|
| 507 | - 'NJ' => __( 'New Jersey', 'invoicing' ), |
|
| 508 | - 'NM' => __( 'New Mexico', 'invoicing' ), |
|
| 509 | - 'NY' => __( 'New York', 'invoicing' ), |
|
| 510 | - 'NC' => __( 'North Carolina', 'invoicing' ), |
|
| 511 | - 'ND' => __( 'North Dakota', 'invoicing' ), |
|
| 512 | - 'OH' => __( 'Ohio', 'invoicing' ), |
|
| 513 | - 'OK' => __( 'Oklahoma', 'invoicing' ), |
|
| 514 | - 'OR' => __( 'Oregon', 'invoicing' ), |
|
| 515 | - 'PA' => __( 'Pennsylvania', 'invoicing' ), |
|
| 516 | - 'RI' => __( 'Rhode Island', 'invoicing' ), |
|
| 517 | - 'SC' => __( 'South Carolina', 'invoicing' ), |
|
| 518 | - 'SD' => __( 'South Dakota', 'invoicing' ), |
|
| 519 | - 'TN' => __( 'Tennessee', 'invoicing' ), |
|
| 520 | - 'TX' => __( 'Texas', 'invoicing' ), |
|
| 521 | - 'UT' => __( 'Utah', 'invoicing' ), |
|
| 522 | - 'VT' => __( 'Vermont', 'invoicing' ), |
|
| 523 | - 'VA' => __( 'Virginia', 'invoicing' ), |
|
| 524 | - 'WA' => __( 'Washington', 'invoicing' ), |
|
| 525 | - 'WV' => __( 'West Virginia', 'invoicing' ), |
|
| 526 | - 'WI' => __( 'Wisconsin', 'invoicing' ), |
|
| 527 | - 'WY' => __( 'Wyoming', 'invoicing' ), |
|
| 528 | - 'AS' => __( 'American Samoa', 'invoicing' ), |
|
| 529 | - 'CZ' => __( 'Canal Zone', 'invoicing' ), |
|
| 530 | - 'CM' => __( 'Commonwealth of the Northern Mariana Islands', 'invoicing' ), |
|
| 531 | - 'FM' => __( 'Federated States of Micronesia', 'invoicing' ), |
|
| 532 | - 'GU' => __( 'Guam', 'invoicing' ), |
|
| 533 | - 'MH' => __( 'Marshall Islands', 'invoicing' ), |
|
| 534 | - 'MP' => __( 'Northern Mariana Islands', 'invoicing' ), |
|
| 535 | - 'PW' => __( 'Palau', 'invoicing' ), |
|
| 536 | - 'PI' => __( 'Philippine Islands', 'invoicing' ), |
|
| 537 | - 'PR' => __( 'Puerto Rico', 'invoicing' ), |
|
| 538 | - 'TT' => __( 'Trust Territory of the Pacific Islands', 'invoicing' ), |
|
| 539 | - 'VI' => __( 'Virgin Islands', 'invoicing' ), |
|
| 540 | - 'AA' => __( 'Armed Forces - Americas', 'invoicing' ), |
|
| 541 | - 'AE' => __( 'Armed Forces - Europe, Canada, Middle East, Africa', 'invoicing' ), |
|
| 542 | - 'AP' => __( 'Armed Forces - Pacific', 'invoicing' ) |
|
| 477 | + 'AL' => __('Alabama', 'invoicing'), |
|
| 478 | + 'AK' => __('Alaska', 'invoicing'), |
|
| 479 | + 'AZ' => __('Arizona', 'invoicing'), |
|
| 480 | + 'AR' => __('Arkansas', 'invoicing'), |
|
| 481 | + 'CA' => __('California', 'invoicing'), |
|
| 482 | + 'CO' => __('Colorado', 'invoicing'), |
|
| 483 | + 'CT' => __('Connecticut', 'invoicing'), |
|
| 484 | + 'DE' => __('Delaware', 'invoicing'), |
|
| 485 | + 'DC' => __('District of Columbia', 'invoicing'), |
|
| 486 | + 'FL' => __('Florida', 'invoicing'), |
|
| 487 | + 'GA' => __('Georgia', 'invoicing'), |
|
| 488 | + 'HI' => __('Hawaii', 'invoicing'), |
|
| 489 | + 'ID' => __('Idaho', 'invoicing'), |
|
| 490 | + 'IL' => __('Illinois', 'invoicing'), |
|
| 491 | + 'IN' => __('Indiana', 'invoicing'), |
|
| 492 | + 'IA' => __('Iowa', 'invoicing'), |
|
| 493 | + 'KS' => __('Kansas', 'invoicing'), |
|
| 494 | + 'KY' => __('Kentucky', 'invoicing'), |
|
| 495 | + 'LA' => __('Louisiana', 'invoicing'), |
|
| 496 | + 'ME' => __('Maine', 'invoicing'), |
|
| 497 | + 'MD' => __('Maryland', 'invoicing'), |
|
| 498 | + 'MA' => __('Massachusetts', 'invoicing'), |
|
| 499 | + 'MI' => __('Michigan', 'invoicing'), |
|
| 500 | + 'MN' => __('Minnesota', 'invoicing'), |
|
| 501 | + 'MS' => __('Mississippi', 'invoicing'), |
|
| 502 | + 'MO' => __('Missouri', 'invoicing'), |
|
| 503 | + 'MT' => __('Montana', 'invoicing'), |
|
| 504 | + 'NE' => __('Nebraska', 'invoicing'), |
|
| 505 | + 'NV' => __('Nevada', 'invoicing'), |
|
| 506 | + 'NH' => __('New Hampshire', 'invoicing'), |
|
| 507 | + 'NJ' => __('New Jersey', 'invoicing'), |
|
| 508 | + 'NM' => __('New Mexico', 'invoicing'), |
|
| 509 | + 'NY' => __('New York', 'invoicing'), |
|
| 510 | + 'NC' => __('North Carolina', 'invoicing'), |
|
| 511 | + 'ND' => __('North Dakota', 'invoicing'), |
|
| 512 | + 'OH' => __('Ohio', 'invoicing'), |
|
| 513 | + 'OK' => __('Oklahoma', 'invoicing'), |
|
| 514 | + 'OR' => __('Oregon', 'invoicing'), |
|
| 515 | + 'PA' => __('Pennsylvania', 'invoicing'), |
|
| 516 | + 'RI' => __('Rhode Island', 'invoicing'), |
|
| 517 | + 'SC' => __('South Carolina', 'invoicing'), |
|
| 518 | + 'SD' => __('South Dakota', 'invoicing'), |
|
| 519 | + 'TN' => __('Tennessee', 'invoicing'), |
|
| 520 | + 'TX' => __('Texas', 'invoicing'), |
|
| 521 | + 'UT' => __('Utah', 'invoicing'), |
|
| 522 | + 'VT' => __('Vermont', 'invoicing'), |
|
| 523 | + 'VA' => __('Virginia', 'invoicing'), |
|
| 524 | + 'WA' => __('Washington', 'invoicing'), |
|
| 525 | + 'WV' => __('West Virginia', 'invoicing'), |
|
| 526 | + 'WI' => __('Wisconsin', 'invoicing'), |
|
| 527 | + 'WY' => __('Wyoming', 'invoicing'), |
|
| 528 | + 'AS' => __('American Samoa', 'invoicing'), |
|
| 529 | + 'CZ' => __('Canal Zone', 'invoicing'), |
|
| 530 | + 'CM' => __('Commonwealth of the Northern Mariana Islands', 'invoicing'), |
|
| 531 | + 'FM' => __('Federated States of Micronesia', 'invoicing'), |
|
| 532 | + 'GU' => __('Guam', 'invoicing'), |
|
| 533 | + 'MH' => __('Marshall Islands', 'invoicing'), |
|
| 534 | + 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
| 535 | + 'PW' => __('Palau', 'invoicing'), |
|
| 536 | + 'PI' => __('Philippine Islands', 'invoicing'), |
|
| 537 | + 'PR' => __('Puerto Rico', 'invoicing'), |
|
| 538 | + 'TT' => __('Trust Territory of the Pacific Islands', 'invoicing'), |
|
| 539 | + 'VI' => __('Virgin Islands', 'invoicing'), |
|
| 540 | + 'AA' => __('Armed Forces - Americas', 'invoicing'), |
|
| 541 | + 'AE' => __('Armed Forces - Europe, Canada, Middle East, Africa', 'invoicing'), |
|
| 542 | + 'AP' => __('Armed Forces - Pacific', 'invoicing') |
|
| 543 | 543 | ); |
| 544 | 544 | |
| 545 | - return apply_filters( 'wpinv_us_states', $states ); |
|
| 545 | + return apply_filters('wpinv_us_states', $states); |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | function wpinv_get_canada_states_list() { |
| 549 | 549 | $states = array( |
| 550 | - 'AB' => __( 'Alberta', 'invoicing' ), |
|
| 551 | - 'BC' => __( 'British Columbia', 'invoicing' ), |
|
| 552 | - 'MB' => __( 'Manitoba', 'invoicing' ), |
|
| 553 | - 'NB' => __( 'New Brunswick', 'invoicing' ), |
|
| 554 | - 'NL' => __( 'Newfoundland and Labrador', 'invoicing' ), |
|
| 555 | - 'NS' => __( 'Nova Scotia', 'invoicing' ), |
|
| 556 | - 'NT' => __( 'Northwest Territories', 'invoicing' ), |
|
| 557 | - 'NU' => __( 'Nunavut', 'invoicing' ), |
|
| 558 | - 'ON' => __( 'Ontario', 'invoicing' ), |
|
| 559 | - 'PE' => __( 'Prince Edward Island', 'invoicing' ), |
|
| 560 | - 'QC' => __( 'Quebec', 'invoicing' ), |
|
| 561 | - 'SK' => __( 'Saskatchewan', 'invoicing' ), |
|
| 562 | - 'YT' => __( 'Yukon', 'invoicing' ) |
|
| 550 | + 'AB' => __('Alberta', 'invoicing'), |
|
| 551 | + 'BC' => __('British Columbia', 'invoicing'), |
|
| 552 | + 'MB' => __('Manitoba', 'invoicing'), |
|
| 553 | + 'NB' => __('New Brunswick', 'invoicing'), |
|
| 554 | + 'NL' => __('Newfoundland and Labrador', 'invoicing'), |
|
| 555 | + 'NS' => __('Nova Scotia', 'invoicing'), |
|
| 556 | + 'NT' => __('Northwest Territories', 'invoicing'), |
|
| 557 | + 'NU' => __('Nunavut', 'invoicing'), |
|
| 558 | + 'ON' => __('Ontario', 'invoicing'), |
|
| 559 | + 'PE' => __('Prince Edward Island', 'invoicing'), |
|
| 560 | + 'QC' => __('Quebec', 'invoicing'), |
|
| 561 | + 'SK' => __('Saskatchewan', 'invoicing'), |
|
| 562 | + 'YT' => __('Yukon', 'invoicing') |
|
| 563 | 563 | ); |
| 564 | 564 | |
| 565 | - return apply_filters( 'wpinv_canada_provinces', $states ); |
|
| 565 | + return apply_filters('wpinv_canada_provinces', $states); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | function wpinv_get_australia_states_list() { |
| 569 | 569 | $states = array( |
| 570 | - 'ACT' => __( 'Australian Capital Territory', 'invoicing' ), |
|
| 571 | - 'NSW' => __( 'New South Wales', 'invoicing' ), |
|
| 572 | - 'NT' => __( 'Northern Territory', 'invoicing' ), |
|
| 573 | - 'QLD' => __( 'Queensland', 'invoicing' ), |
|
| 574 | - 'SA' => __( 'South Australia', 'invoicing' ), |
|
| 575 | - 'TAS' => __( 'Tasmania', 'invoicing' ), |
|
| 576 | - 'VIC' => __( 'Victoria', 'invoicing' ), |
|
| 577 | - 'WA' => __( 'Western Australia', 'invoicing' ) |
|
| 570 | + 'ACT' => __('Australian Capital Territory', 'invoicing'), |
|
| 571 | + 'NSW' => __('New South Wales', 'invoicing'), |
|
| 572 | + 'NT' => __('Northern Territory', 'invoicing'), |
|
| 573 | + 'QLD' => __('Queensland', 'invoicing'), |
|
| 574 | + 'SA' => __('South Australia', 'invoicing'), |
|
| 575 | + 'TAS' => __('Tasmania', 'invoicing'), |
|
| 576 | + 'VIC' => __('Victoria', 'invoicing'), |
|
| 577 | + 'WA' => __('Western Australia', 'invoicing') |
|
| 578 | 578 | ); |
| 579 | 579 | |
| 580 | - return apply_filters( 'wpinv_australia_states', $states ); |
|
| 580 | + return apply_filters('wpinv_australia_states', $states); |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | function wpinv_get_bangladesh_states_list() { |
| 584 | 584 | $states = array( |
| 585 | - 'BAG' => __( 'Bagerhat', 'invoicing' ), |
|
| 586 | - 'BAN' => __( 'Bandarban', 'invoicing' ), |
|
| 587 | - 'BAR' => __( 'Barguna', 'invoicing' ), |
|
| 588 | - 'BARI'=> __( 'Barisal', 'invoicing' ), |
|
| 589 | - 'BHO' => __( 'Bhola', 'invoicing' ), |
|
| 590 | - 'BOG' => __( 'Bogra', 'invoicing' ), |
|
| 591 | - 'BRA' => __( 'Brahmanbaria', 'invoicing' ), |
|
| 592 | - 'CHA' => __( 'Chandpur', 'invoicing' ), |
|
| 593 | - 'CHI' => __( 'Chittagong', 'invoicing' ), |
|
| 594 | - 'CHU' => __( 'Chuadanga', 'invoicing' ), |
|
| 595 | - 'COM' => __( 'Comilla', 'invoicing' ), |
|
| 596 | - 'COX' => __( 'Cox\'s Bazar', 'invoicing' ), |
|
| 597 | - 'DHA' => __( 'Dhaka', 'invoicing' ), |
|
| 598 | - 'DIN' => __( 'Dinajpur', 'invoicing' ), |
|
| 599 | - 'FAR' => __( 'Faridpur', 'invoicing' ), |
|
| 600 | - 'FEN' => __( 'Feni', 'invoicing' ), |
|
| 601 | - 'GAI' => __( 'Gaibandha', 'invoicing' ), |
|
| 602 | - 'GAZI'=> __( 'Gazipur', 'invoicing' ), |
|
| 603 | - 'GOP' => __( 'Gopalganj', 'invoicing' ), |
|
| 604 | - 'HAB' => __( 'Habiganj', 'invoicing' ), |
|
| 605 | - 'JAM' => __( 'Jamalpur', 'invoicing' ), |
|
| 606 | - 'JES' => __( 'Jessore', 'invoicing' ), |
|
| 607 | - 'JHA' => __( 'Jhalokati', 'invoicing' ), |
|
| 608 | - 'JHE' => __( 'Jhenaidah', 'invoicing' ), |
|
| 609 | - 'JOY' => __( 'Joypurhat', 'invoicing' ), |
|
| 610 | - 'KHA' => __( 'Khagrachhari', 'invoicing' ), |
|
| 611 | - 'KHU' => __( 'Khulna', 'invoicing' ), |
|
| 612 | - 'KIS' => __( 'Kishoreganj', 'invoicing' ), |
|
| 613 | - 'KUR' => __( 'Kurigram', 'invoicing' ), |
|
| 614 | - 'KUS' => __( 'Kushtia', 'invoicing' ), |
|
| 615 | - 'LAK' => __( 'Lakshmipur', 'invoicing' ), |
|
| 616 | - 'LAL' => __( 'Lalmonirhat', 'invoicing' ), |
|
| 617 | - 'MAD' => __( 'Madaripur', 'invoicing' ), |
|
| 618 | - 'MAG' => __( 'Magura', 'invoicing' ), |
|
| 619 | - 'MAN' => __( 'Manikganj', 'invoicing' ), |
|
| 620 | - 'MEH' => __( 'Meherpur', 'invoicing' ), |
|
| 621 | - 'MOU' => __( 'Moulvibazar', 'invoicing' ), |
|
| 622 | - 'MUN' => __( 'Munshiganj', 'invoicing' ), |
|
| 623 | - 'MYM' => __( 'Mymensingh', 'invoicing' ), |
|
| 624 | - 'NAO' => __( 'Naogaon', 'invoicing' ), |
|
| 625 | - 'NAR' => __( 'Narail', 'invoicing' ), |
|
| 626 | - 'NARG'=> __( 'Narayanganj', 'invoicing' ), |
|
| 627 | - 'NARD'=> __( 'Narsingdi', 'invoicing' ), |
|
| 628 | - 'NAT' => __( 'Natore', 'invoicing' ), |
|
| 629 | - 'NAW' => __( 'Nawabganj', 'invoicing' ), |
|
| 630 | - 'NET' => __( 'Netrakona', 'invoicing' ), |
|
| 631 | - 'NIL' => __( 'Nilphamari', 'invoicing' ), |
|
| 632 | - 'NOA' => __( 'Noakhali', 'invoicing' ), |
|
| 633 | - 'PAB' => __( 'Pabna', 'invoicing' ), |
|
| 634 | - 'PAN' => __( 'Panchagarh', 'invoicing' ), |
|
| 635 | - 'PAT' => __( 'Patuakhali', 'invoicing' ), |
|
| 636 | - 'PIR' => __( 'Pirojpur', 'invoicing' ), |
|
| 637 | - 'RAJB'=> __( 'Rajbari', 'invoicing' ), |
|
| 638 | - 'RAJ' => __( 'Rajshahi', 'invoicing' ), |
|
| 639 | - 'RAN' => __( 'Rangamati', 'invoicing' ), |
|
| 640 | - 'RANP'=> __( 'Rangpur', 'invoicing' ), |
|
| 641 | - 'SAT' => __( 'Satkhira', 'invoicing' ), |
|
| 642 | - 'SHA' => __( 'Shariatpur', 'invoicing' ), |
|
| 643 | - 'SHE' => __( 'Sherpur', 'invoicing' ), |
|
| 644 | - 'SIR' => __( 'Sirajganj', 'invoicing' ), |
|
| 645 | - 'SUN' => __( 'Sunamganj', 'invoicing' ), |
|
| 646 | - 'SYL' => __( 'Sylhet', 'invoicing' ), |
|
| 647 | - 'TAN' => __( 'Tangail', 'invoicing' ), |
|
| 648 | - 'THA' => __( 'Thakurgaon', 'invoicing' ) |
|
| 585 | + 'BAG' => __('Bagerhat', 'invoicing'), |
|
| 586 | + 'BAN' => __('Bandarban', 'invoicing'), |
|
| 587 | + 'BAR' => __('Barguna', 'invoicing'), |
|
| 588 | + 'BARI'=> __('Barisal', 'invoicing'), |
|
| 589 | + 'BHO' => __('Bhola', 'invoicing'), |
|
| 590 | + 'BOG' => __('Bogra', 'invoicing'), |
|
| 591 | + 'BRA' => __('Brahmanbaria', 'invoicing'), |
|
| 592 | + 'CHA' => __('Chandpur', 'invoicing'), |
|
| 593 | + 'CHI' => __('Chittagong', 'invoicing'), |
|
| 594 | + 'CHU' => __('Chuadanga', 'invoicing'), |
|
| 595 | + 'COM' => __('Comilla', 'invoicing'), |
|
| 596 | + 'COX' => __('Cox\'s Bazar', 'invoicing'), |
|
| 597 | + 'DHA' => __('Dhaka', 'invoicing'), |
|
| 598 | + 'DIN' => __('Dinajpur', 'invoicing'), |
|
| 599 | + 'FAR' => __('Faridpur', 'invoicing'), |
|
| 600 | + 'FEN' => __('Feni', 'invoicing'), |
|
| 601 | + 'GAI' => __('Gaibandha', 'invoicing'), |
|
| 602 | + 'GAZI'=> __('Gazipur', 'invoicing'), |
|
| 603 | + 'GOP' => __('Gopalganj', 'invoicing'), |
|
| 604 | + 'HAB' => __('Habiganj', 'invoicing'), |
|
| 605 | + 'JAM' => __('Jamalpur', 'invoicing'), |
|
| 606 | + 'JES' => __('Jessore', 'invoicing'), |
|
| 607 | + 'JHA' => __('Jhalokati', 'invoicing'), |
|
| 608 | + 'JHE' => __('Jhenaidah', 'invoicing'), |
|
| 609 | + 'JOY' => __('Joypurhat', 'invoicing'), |
|
| 610 | + 'KHA' => __('Khagrachhari', 'invoicing'), |
|
| 611 | + 'KHU' => __('Khulna', 'invoicing'), |
|
| 612 | + 'KIS' => __('Kishoreganj', 'invoicing'), |
|
| 613 | + 'KUR' => __('Kurigram', 'invoicing'), |
|
| 614 | + 'KUS' => __('Kushtia', 'invoicing'), |
|
| 615 | + 'LAK' => __('Lakshmipur', 'invoicing'), |
|
| 616 | + 'LAL' => __('Lalmonirhat', 'invoicing'), |
|
| 617 | + 'MAD' => __('Madaripur', 'invoicing'), |
|
| 618 | + 'MAG' => __('Magura', 'invoicing'), |
|
| 619 | + 'MAN' => __('Manikganj', 'invoicing'), |
|
| 620 | + 'MEH' => __('Meherpur', 'invoicing'), |
|
| 621 | + 'MOU' => __('Moulvibazar', 'invoicing'), |
|
| 622 | + 'MUN' => __('Munshiganj', 'invoicing'), |
|
| 623 | + 'MYM' => __('Mymensingh', 'invoicing'), |
|
| 624 | + 'NAO' => __('Naogaon', 'invoicing'), |
|
| 625 | + 'NAR' => __('Narail', 'invoicing'), |
|
| 626 | + 'NARG'=> __('Narayanganj', 'invoicing'), |
|
| 627 | + 'NARD'=> __('Narsingdi', 'invoicing'), |
|
| 628 | + 'NAT' => __('Natore', 'invoicing'), |
|
| 629 | + 'NAW' => __('Nawabganj', 'invoicing'), |
|
| 630 | + 'NET' => __('Netrakona', 'invoicing'), |
|
| 631 | + 'NIL' => __('Nilphamari', 'invoicing'), |
|
| 632 | + 'NOA' => __('Noakhali', 'invoicing'), |
|
| 633 | + 'PAB' => __('Pabna', 'invoicing'), |
|
| 634 | + 'PAN' => __('Panchagarh', 'invoicing'), |
|
| 635 | + 'PAT' => __('Patuakhali', 'invoicing'), |
|
| 636 | + 'PIR' => __('Pirojpur', 'invoicing'), |
|
| 637 | + 'RAJB'=> __('Rajbari', 'invoicing'), |
|
| 638 | + 'RAJ' => __('Rajshahi', 'invoicing'), |
|
| 639 | + 'RAN' => __('Rangamati', 'invoicing'), |
|
| 640 | + 'RANP'=> __('Rangpur', 'invoicing'), |
|
| 641 | + 'SAT' => __('Satkhira', 'invoicing'), |
|
| 642 | + 'SHA' => __('Shariatpur', 'invoicing'), |
|
| 643 | + 'SHE' => __('Sherpur', 'invoicing'), |
|
| 644 | + 'SIR' => __('Sirajganj', 'invoicing'), |
|
| 645 | + 'SUN' => __('Sunamganj', 'invoicing'), |
|
| 646 | + 'SYL' => __('Sylhet', 'invoicing'), |
|
| 647 | + 'TAN' => __('Tangail', 'invoicing'), |
|
| 648 | + 'THA' => __('Thakurgaon', 'invoicing') |
|
| 649 | 649 | ); |
| 650 | 650 | |
| 651 | - return apply_filters( 'wpinv_bangladesh_states', $states ); |
|
| 651 | + return apply_filters('wpinv_bangladesh_states', $states); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | function wpinv_get_brazil_states_list() { |
| 655 | 655 | $states = array( |
| 656 | - 'AC' => __( 'Acre', 'invoicing' ), |
|
| 657 | - 'AL' => __( 'Alagoas', 'invoicing' ), |
|
| 658 | - 'AP' => __( 'Amapá', 'invoicing' ), |
|
| 659 | - 'AM' => __( 'Amazonas', 'invoicing' ), |
|
| 660 | - 'BA' => __( 'Bahia', 'invoicing' ), |
|
| 661 | - 'CE' => __( 'Ceará', 'invoicing' ), |
|
| 662 | - 'DF' => __( 'Distrito Federal', 'invoicing' ), |
|
| 663 | - 'ES' => __( 'Espírito Santo', 'invoicing' ), |
|
| 664 | - 'GO' => __( 'Goiás', 'invoicing' ), |
|
| 665 | - 'MA' => __( 'Maranhão', 'invoicing' ), |
|
| 666 | - 'MT' => __( 'Mato Grosso', 'invoicing' ), |
|
| 667 | - 'MS' => __( 'Mato Grosso do Sul', 'invoicing' ), |
|
| 668 | - 'MG' => __( 'Minas Gerais', 'invoicing' ), |
|
| 669 | - 'PA' => __( 'Pará', 'invoicing' ), |
|
| 670 | - 'PB' => __( 'Paraíba', 'invoicing' ), |
|
| 671 | - 'PR' => __( 'Paraná', 'invoicing' ), |
|
| 672 | - 'PE' => __( 'Pernambuco', 'invoicing' ), |
|
| 673 | - 'PI' => __( 'Piauí', 'invoicing' ), |
|
| 674 | - 'RJ' => __( 'Rio de Janeiro', 'invoicing' ), |
|
| 675 | - 'RN' => __( 'Rio Grande do Norte', 'invoicing' ), |
|
| 676 | - 'RS' => __( 'Rio Grande do Sul', 'invoicing' ), |
|
| 677 | - 'RO' => __( 'Rondônia', 'invoicing' ), |
|
| 678 | - 'RR' => __( 'Roraima', 'invoicing' ), |
|
| 679 | - 'SC' => __( 'Santa Catarina', 'invoicing' ), |
|
| 680 | - 'SP' => __( 'São Paulo', 'invoicing' ), |
|
| 681 | - 'SE' => __( 'Sergipe', 'invoicing' ), |
|
| 682 | - 'TO' => __( 'Tocantins', 'invoicing' ) |
|
| 656 | + 'AC' => __('Acre', 'invoicing'), |
|
| 657 | + 'AL' => __('Alagoas', 'invoicing'), |
|
| 658 | + 'AP' => __('Amapá', 'invoicing'), |
|
| 659 | + 'AM' => __('Amazonas', 'invoicing'), |
|
| 660 | + 'BA' => __('Bahia', 'invoicing'), |
|
| 661 | + 'CE' => __('Ceará', 'invoicing'), |
|
| 662 | + 'DF' => __('Distrito Federal', 'invoicing'), |
|
| 663 | + 'ES' => __('Espírito Santo', 'invoicing'), |
|
| 664 | + 'GO' => __('Goiás', 'invoicing'), |
|
| 665 | + 'MA' => __('Maranhão', 'invoicing'), |
|
| 666 | + 'MT' => __('Mato Grosso', 'invoicing'), |
|
| 667 | + 'MS' => __('Mato Grosso do Sul', 'invoicing'), |
|
| 668 | + 'MG' => __('Minas Gerais', 'invoicing'), |
|
| 669 | + 'PA' => __('Pará', 'invoicing'), |
|
| 670 | + 'PB' => __('Paraíba', 'invoicing'), |
|
| 671 | + 'PR' => __('Paraná', 'invoicing'), |
|
| 672 | + 'PE' => __('Pernambuco', 'invoicing'), |
|
| 673 | + 'PI' => __('Piauí', 'invoicing'), |
|
| 674 | + 'RJ' => __('Rio de Janeiro', 'invoicing'), |
|
| 675 | + 'RN' => __('Rio Grande do Norte', 'invoicing'), |
|
| 676 | + 'RS' => __('Rio Grande do Sul', 'invoicing'), |
|
| 677 | + 'RO' => __('Rondônia', 'invoicing'), |
|
| 678 | + 'RR' => __('Roraima', 'invoicing'), |
|
| 679 | + 'SC' => __('Santa Catarina', 'invoicing'), |
|
| 680 | + 'SP' => __('São Paulo', 'invoicing'), |
|
| 681 | + 'SE' => __('Sergipe', 'invoicing'), |
|
| 682 | + 'TO' => __('Tocantins', 'invoicing') |
|
| 683 | 683 | ); |
| 684 | 684 | |
| 685 | - return apply_filters( 'wpinv_brazil_states', $states ); |
|
| 685 | + return apply_filters('wpinv_brazil_states', $states); |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | function wpinv_get_bulgaria_states_list() { |
| 689 | 689 | $states = array( |
| 690 | - 'BG-01' => __( 'Blagoevgrad', 'invoicing' ), |
|
| 691 | - 'BG-02' => __( 'Burgas', 'invoicing' ), |
|
| 692 | - 'BG-08' => __( 'Dobrich', 'invoicing' ), |
|
| 693 | - 'BG-07' => __( 'Gabrovo', 'invoicing' ), |
|
| 694 | - 'BG-26' => __( 'Haskovo', 'invoicing' ), |
|
| 695 | - 'BG-09' => __( 'Kardzhali', 'invoicing' ), |
|
| 696 | - 'BG-10' => __( 'Kyustendil', 'invoicing' ), |
|
| 697 | - 'BG-11' => __( 'Lovech', 'invoicing' ), |
|
| 698 | - 'BG-12' => __( 'Montana', 'invoicing' ), |
|
| 699 | - 'BG-13' => __( 'Pazardzhik', 'invoicing' ), |
|
| 700 | - 'BG-14' => __( 'Pernik', 'invoicing' ), |
|
| 701 | - 'BG-15' => __( 'Pleven', 'invoicing' ), |
|
| 702 | - 'BG-16' => __( 'Plovdiv', 'invoicing' ), |
|
| 703 | - 'BG-17' => __( 'Razgrad', 'invoicing' ), |
|
| 704 | - 'BG-18' => __( 'Ruse', 'invoicing' ), |
|
| 705 | - 'BG-27' => __( 'Shumen', 'invoicing' ), |
|
| 706 | - 'BG-19' => __( 'Silistra', 'invoicing' ), |
|
| 707 | - 'BG-20' => __( 'Sliven', 'invoicing' ), |
|
| 708 | - 'BG-21' => __( 'Smolyan', 'invoicing' ), |
|
| 709 | - 'BG-23' => __( 'Sofia', 'invoicing' ), |
|
| 710 | - 'BG-22' => __( 'Sofia-Grad', 'invoicing' ), |
|
| 711 | - 'BG-24' => __( 'Stara Zagora', 'invoicing' ), |
|
| 712 | - 'BG-25' => __( 'Targovishte', 'invoicing' ), |
|
| 713 | - 'BG-03' => __( 'Varna', 'invoicing' ), |
|
| 714 | - 'BG-04' => __( 'Veliko Tarnovo', 'invoicing' ), |
|
| 715 | - 'BG-05' => __( 'Vidin', 'invoicing' ), |
|
| 716 | - 'BG-06' => __( 'Vratsa', 'invoicing' ), |
|
| 717 | - 'BG-28' => __( 'Yambol', 'invoicing' ) |
|
| 690 | + 'BG-01' => __('Blagoevgrad', 'invoicing'), |
|
| 691 | + 'BG-02' => __('Burgas', 'invoicing'), |
|
| 692 | + 'BG-08' => __('Dobrich', 'invoicing'), |
|
| 693 | + 'BG-07' => __('Gabrovo', 'invoicing'), |
|
| 694 | + 'BG-26' => __('Haskovo', 'invoicing'), |
|
| 695 | + 'BG-09' => __('Kardzhali', 'invoicing'), |
|
| 696 | + 'BG-10' => __('Kyustendil', 'invoicing'), |
|
| 697 | + 'BG-11' => __('Lovech', 'invoicing'), |
|
| 698 | + 'BG-12' => __('Montana', 'invoicing'), |
|
| 699 | + 'BG-13' => __('Pazardzhik', 'invoicing'), |
|
| 700 | + 'BG-14' => __('Pernik', 'invoicing'), |
|
| 701 | + 'BG-15' => __('Pleven', 'invoicing'), |
|
| 702 | + 'BG-16' => __('Plovdiv', 'invoicing'), |
|
| 703 | + 'BG-17' => __('Razgrad', 'invoicing'), |
|
| 704 | + 'BG-18' => __('Ruse', 'invoicing'), |
|
| 705 | + 'BG-27' => __('Shumen', 'invoicing'), |
|
| 706 | + 'BG-19' => __('Silistra', 'invoicing'), |
|
| 707 | + 'BG-20' => __('Sliven', 'invoicing'), |
|
| 708 | + 'BG-21' => __('Smolyan', 'invoicing'), |
|
| 709 | + 'BG-23' => __('Sofia', 'invoicing'), |
|
| 710 | + 'BG-22' => __('Sofia-Grad', 'invoicing'), |
|
| 711 | + 'BG-24' => __('Stara Zagora', 'invoicing'), |
|
| 712 | + 'BG-25' => __('Targovishte', 'invoicing'), |
|
| 713 | + 'BG-03' => __('Varna', 'invoicing'), |
|
| 714 | + 'BG-04' => __('Veliko Tarnovo', 'invoicing'), |
|
| 715 | + 'BG-05' => __('Vidin', 'invoicing'), |
|
| 716 | + 'BG-06' => __('Vratsa', 'invoicing'), |
|
| 717 | + 'BG-28' => __('Yambol', 'invoicing') |
|
| 718 | 718 | ); |
| 719 | 719 | |
| 720 | - return apply_filters( 'wpinv_bulgaria_states', $states ); |
|
| 720 | + return apply_filters('wpinv_bulgaria_states', $states); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | function wpinv_get_hong_kong_states_list() { |
| 724 | 724 | $states = array( |
| 725 | - 'HONG KONG' => __( 'Hong Kong Island', 'invoicing' ), |
|
| 726 | - 'KOWLOON' => __( 'Kowloon', 'invoicing' ), |
|
| 727 | - 'NEW TERRITORIES' => __( 'New Territories', 'invoicing' ) |
|
| 725 | + 'HONG KONG' => __('Hong Kong Island', 'invoicing'), |
|
| 726 | + 'KOWLOON' => __('Kowloon', 'invoicing'), |
|
| 727 | + 'NEW TERRITORIES' => __('New Territories', 'invoicing') |
|
| 728 | 728 | ); |
| 729 | 729 | |
| 730 | - return apply_filters( 'wpinv_hong_kong_states', $states ); |
|
| 730 | + return apply_filters('wpinv_hong_kong_states', $states); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | function wpinv_get_hungary_states_list() { |
| 734 | 734 | $states = array( |
| 735 | - 'BK' => __( 'Bács-Kiskun', 'invoicing' ), |
|
| 736 | - 'BE' => __( 'Békés', 'invoicing' ), |
|
| 737 | - 'BA' => __( 'Baranya', 'invoicing' ), |
|
| 738 | - 'BZ' => __( 'Borsod-Abaúj-Zemplén', 'invoicing' ), |
|
| 739 | - 'BU' => __( 'Budapest', 'invoicing' ), |
|
| 740 | - 'CS' => __( 'Csongrád', 'invoicing' ), |
|
| 741 | - 'FE' => __( 'Fejér', 'invoicing' ), |
|
| 742 | - 'GS' => __( 'Győr-Moson-Sopron', 'invoicing' ), |
|
| 743 | - 'HB' => __( 'Hajdú-Bihar', 'invoicing' ), |
|
| 744 | - 'HE' => __( 'Heves', 'invoicing' ), |
|
| 745 | - 'JN' => __( 'Jász-Nagykun-Szolnok', 'invoicing' ), |
|
| 746 | - 'KE' => __( 'Komárom-Esztergom', 'invoicing' ), |
|
| 747 | - 'NO' => __( 'Nógrád', 'invoicing' ), |
|
| 748 | - 'PE' => __( 'Pest', 'invoicing' ), |
|
| 749 | - 'SO' => __( 'Somogy', 'invoicing' ), |
|
| 750 | - 'SZ' => __( 'Szabolcs-Szatmár-Bereg', 'invoicing' ), |
|
| 751 | - 'TO' => __( 'Tolna', 'invoicing' ), |
|
| 752 | - 'VA' => __( 'Vas', 'invoicing' ), |
|
| 753 | - 'VE' => __( 'Veszprém', 'invoicing' ), |
|
| 754 | - 'ZA' => __( 'Zala', 'invoicing' ) |
|
| 735 | + 'BK' => __('Bács-Kiskun', 'invoicing'), |
|
| 736 | + 'BE' => __('Békés', 'invoicing'), |
|
| 737 | + 'BA' => __('Baranya', 'invoicing'), |
|
| 738 | + 'BZ' => __('Borsod-Abaúj-Zemplén', 'invoicing'), |
|
| 739 | + 'BU' => __('Budapest', 'invoicing'), |
|
| 740 | + 'CS' => __('Csongrád', 'invoicing'), |
|
| 741 | + 'FE' => __('Fejér', 'invoicing'), |
|
| 742 | + 'GS' => __('Győr-Moson-Sopron', 'invoicing'), |
|
| 743 | + 'HB' => __('Hajdú-Bihar', 'invoicing'), |
|
| 744 | + 'HE' => __('Heves', 'invoicing'), |
|
| 745 | + 'JN' => __('Jász-Nagykun-Szolnok', 'invoicing'), |
|
| 746 | + 'KE' => __('Komárom-Esztergom', 'invoicing'), |
|
| 747 | + 'NO' => __('Nógrád', 'invoicing'), |
|
| 748 | + 'PE' => __('Pest', 'invoicing'), |
|
| 749 | + 'SO' => __('Somogy', 'invoicing'), |
|
| 750 | + 'SZ' => __('Szabolcs-Szatmár-Bereg', 'invoicing'), |
|
| 751 | + 'TO' => __('Tolna', 'invoicing'), |
|
| 752 | + 'VA' => __('Vas', 'invoicing'), |
|
| 753 | + 'VE' => __('Veszprém', 'invoicing'), |
|
| 754 | + 'ZA' => __('Zala', 'invoicing') |
|
| 755 | 755 | ); |
| 756 | 756 | |
| 757 | - return apply_filters( 'wpinv_hungary_states', $states ); |
|
| 757 | + return apply_filters('wpinv_hungary_states', $states); |
|
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | function wpinv_get_japan_states_list() { |
| 761 | 761 | $states = array( |
| 762 | - 'JP01' => __( 'Hokkaido', 'invoicing' ), |
|
| 763 | - 'JP02' => __( 'Aomori', 'invoicing' ), |
|
| 764 | - 'JP03' => __( 'Iwate', 'invoicing' ), |
|
| 765 | - 'JP04' => __( 'Miyagi', 'invoicing' ), |
|
| 766 | - 'JP05' => __( 'Akita', 'invoicing' ), |
|
| 767 | - 'JP06' => __( 'Yamagata', 'invoicing' ), |
|
| 768 | - 'JP07' => __( 'Fukushima', 'invoicing' ), |
|
| 769 | - 'JP08' => __( 'Ibaraki', 'invoicing' ), |
|
| 770 | - 'JP09' => __( 'Tochigi', 'invoicing' ), |
|
| 771 | - 'JP10' => __( 'Gunma', 'invoicing' ), |
|
| 772 | - 'JP11' => __( 'Saitama', 'invoicing' ), |
|
| 773 | - 'JP12' => __( 'Chiba', 'invoicing' ), |
|
| 774 | - 'JP13' => __( 'Tokyo', 'invoicing' ), |
|
| 775 | - 'JP14' => __( 'Kanagawa', 'invoicing' ), |
|
| 776 | - 'JP15' => __( 'Niigata', 'invoicing' ), |
|
| 777 | - 'JP16' => __( 'Toyama', 'invoicing' ), |
|
| 778 | - 'JP17' => __( 'Ishikawa', 'invoicing' ), |
|
| 779 | - 'JP18' => __( 'Fukui', 'invoicing' ), |
|
| 780 | - 'JP19' => __( 'Yamanashi', 'invoicing' ), |
|
| 781 | - 'JP20' => __( 'Nagano', 'invoicing' ), |
|
| 782 | - 'JP21' => __( 'Gifu', 'invoicing' ), |
|
| 783 | - 'JP22' => __( 'Shizuoka', 'invoicing' ), |
|
| 784 | - 'JP23' => __( 'Aichi', 'invoicing' ), |
|
| 785 | - 'JP24' => __( 'Mie', 'invoicing' ), |
|
| 786 | - 'JP25' => __( 'Shiga', 'invoicing' ), |
|
| 787 | - 'JP26' => __( 'Kyouto', 'invoicing' ), |
|
| 788 | - 'JP27' => __( 'Osaka', 'invoicing' ), |
|
| 789 | - 'JP28' => __( 'Hyougo', 'invoicing' ), |
|
| 790 | - 'JP29' => __( 'Nara', 'invoicing' ), |
|
| 791 | - 'JP30' => __( 'Wakayama', 'invoicing' ), |
|
| 792 | - 'JP31' => __( 'Tottori', 'invoicing' ), |
|
| 793 | - 'JP32' => __( 'Shimane', 'invoicing' ), |
|
| 794 | - 'JP33' => __( 'Okayama', 'invoicing' ), |
|
| 795 | - 'JP34' => __( 'Hiroshima', 'invoicing' ), |
|
| 796 | - 'JP35' => __( 'Yamaguchi', 'invoicing' ), |
|
| 797 | - 'JP36' => __( 'Tokushima', 'invoicing' ), |
|
| 798 | - 'JP37' => __( 'Kagawa', 'invoicing' ), |
|
| 799 | - 'JP38' => __( 'Ehime', 'invoicing' ), |
|
| 800 | - 'JP39' => __( 'Kochi', 'invoicing' ), |
|
| 801 | - 'JP40' => __( 'Fukuoka', 'invoicing' ), |
|
| 802 | - 'JP41' => __( 'Saga', 'invoicing' ), |
|
| 803 | - 'JP42' => __( 'Nagasaki', 'invoicing' ), |
|
| 804 | - 'JP43' => __( 'Kumamoto', 'invoicing' ), |
|
| 805 | - 'JP44' => __( 'Oita', 'invoicing' ), |
|
| 806 | - 'JP45' => __( 'Miyazaki', 'invoicing' ), |
|
| 807 | - 'JP46' => __( 'Kagoshima', 'invoicing' ), |
|
| 808 | - 'JP47' => __( 'Okinawa', 'invoicing' ) |
|
| 762 | + 'JP01' => __('Hokkaido', 'invoicing'), |
|
| 763 | + 'JP02' => __('Aomori', 'invoicing'), |
|
| 764 | + 'JP03' => __('Iwate', 'invoicing'), |
|
| 765 | + 'JP04' => __('Miyagi', 'invoicing'), |
|
| 766 | + 'JP05' => __('Akita', 'invoicing'), |
|
| 767 | + 'JP06' => __('Yamagata', 'invoicing'), |
|
| 768 | + 'JP07' => __('Fukushima', 'invoicing'), |
|
| 769 | + 'JP08' => __('Ibaraki', 'invoicing'), |
|
| 770 | + 'JP09' => __('Tochigi', 'invoicing'), |
|
| 771 | + 'JP10' => __('Gunma', 'invoicing'), |
|
| 772 | + 'JP11' => __('Saitama', 'invoicing'), |
|
| 773 | + 'JP12' => __('Chiba', 'invoicing'), |
|
| 774 | + 'JP13' => __('Tokyo', 'invoicing'), |
|
| 775 | + 'JP14' => __('Kanagawa', 'invoicing'), |
|
| 776 | + 'JP15' => __('Niigata', 'invoicing'), |
|
| 777 | + 'JP16' => __('Toyama', 'invoicing'), |
|
| 778 | + 'JP17' => __('Ishikawa', 'invoicing'), |
|
| 779 | + 'JP18' => __('Fukui', 'invoicing'), |
|
| 780 | + 'JP19' => __('Yamanashi', 'invoicing'), |
|
| 781 | + 'JP20' => __('Nagano', 'invoicing'), |
|
| 782 | + 'JP21' => __('Gifu', 'invoicing'), |
|
| 783 | + 'JP22' => __('Shizuoka', 'invoicing'), |
|
| 784 | + 'JP23' => __('Aichi', 'invoicing'), |
|
| 785 | + 'JP24' => __('Mie', 'invoicing'), |
|
| 786 | + 'JP25' => __('Shiga', 'invoicing'), |
|
| 787 | + 'JP26' => __('Kyouto', 'invoicing'), |
|
| 788 | + 'JP27' => __('Osaka', 'invoicing'), |
|
| 789 | + 'JP28' => __('Hyougo', 'invoicing'), |
|
| 790 | + 'JP29' => __('Nara', 'invoicing'), |
|
| 791 | + 'JP30' => __('Wakayama', 'invoicing'), |
|
| 792 | + 'JP31' => __('Tottori', 'invoicing'), |
|
| 793 | + 'JP32' => __('Shimane', 'invoicing'), |
|
| 794 | + 'JP33' => __('Okayama', 'invoicing'), |
|
| 795 | + 'JP34' => __('Hiroshima', 'invoicing'), |
|
| 796 | + 'JP35' => __('Yamaguchi', 'invoicing'), |
|
| 797 | + 'JP36' => __('Tokushima', 'invoicing'), |
|
| 798 | + 'JP37' => __('Kagawa', 'invoicing'), |
|
| 799 | + 'JP38' => __('Ehime', 'invoicing'), |
|
| 800 | + 'JP39' => __('Kochi', 'invoicing'), |
|
| 801 | + 'JP40' => __('Fukuoka', 'invoicing'), |
|
| 802 | + 'JP41' => __('Saga', 'invoicing'), |
|
| 803 | + 'JP42' => __('Nagasaki', 'invoicing'), |
|
| 804 | + 'JP43' => __('Kumamoto', 'invoicing'), |
|
| 805 | + 'JP44' => __('Oita', 'invoicing'), |
|
| 806 | + 'JP45' => __('Miyazaki', 'invoicing'), |
|
| 807 | + 'JP46' => __('Kagoshima', 'invoicing'), |
|
| 808 | + 'JP47' => __('Okinawa', 'invoicing') |
|
| 809 | 809 | ); |
| 810 | 810 | |
| 811 | - return apply_filters( 'wpinv_japan_states', $states ); |
|
| 811 | + return apply_filters('wpinv_japan_states', $states); |
|
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | function wpinv_get_china_states_list() { |
| 815 | 815 | $states = array( |
| 816 | - 'CN1' => __( 'Yunnan / 云南', 'invoicing' ), |
|
| 817 | - 'CN2' => __( 'Beijing / 北京', 'invoicing' ), |
|
| 818 | - 'CN3' => __( 'Tianjin / 天津', 'invoicing' ), |
|
| 819 | - 'CN4' => __( 'Hebei / 河北', 'invoicing' ), |
|
| 820 | - 'CN5' => __( 'Shanxi / 山西', 'invoicing' ), |
|
| 821 | - 'CN6' => __( 'Inner Mongolia / 內蒙古', 'invoicing' ), |
|
| 822 | - 'CN7' => __( 'Liaoning / 辽宁', 'invoicing' ), |
|
| 823 | - 'CN8' => __( 'Jilin / 吉林', 'invoicing' ), |
|
| 824 | - 'CN9' => __( 'Heilongjiang / 黑龙江', 'invoicing' ), |
|
| 825 | - 'CN10' => __( 'Shanghai / 上海', 'invoicing' ), |
|
| 826 | - 'CN11' => __( 'Jiangsu / 江苏', 'invoicing' ), |
|
| 827 | - 'CN12' => __( 'Zhejiang / 浙江', 'invoicing' ), |
|
| 828 | - 'CN13' => __( 'Anhui / 安徽', 'invoicing' ), |
|
| 829 | - 'CN14' => __( 'Fujian / 福建', 'invoicing' ), |
|
| 830 | - 'CN15' => __( 'Jiangxi / 江西', 'invoicing' ), |
|
| 831 | - 'CN16' => __( 'Shandong / 山东', 'invoicing' ), |
|
| 832 | - 'CN17' => __( 'Henan / 河南', 'invoicing' ), |
|
| 833 | - 'CN18' => __( 'Hubei / 湖北', 'invoicing' ), |
|
| 834 | - 'CN19' => __( 'Hunan / 湖南', 'invoicing' ), |
|
| 835 | - 'CN20' => __( 'Guangdong / 广东', 'invoicing' ), |
|
| 836 | - 'CN21' => __( 'Guangxi Zhuang / 广西壮族', 'invoicing' ), |
|
| 837 | - 'CN22' => __( 'Hainan / 海南', 'invoicing' ), |
|
| 838 | - 'CN23' => __( 'Chongqing / 重庆', 'invoicing' ), |
|
| 839 | - 'CN24' => __( 'Sichuan / 四川', 'invoicing' ), |
|
| 840 | - 'CN25' => __( 'Guizhou / 贵州', 'invoicing' ), |
|
| 841 | - 'CN26' => __( 'Shaanxi / 陕西', 'invoicing' ), |
|
| 842 | - 'CN27' => __( 'Gansu / 甘肃', 'invoicing' ), |
|
| 843 | - 'CN28' => __( 'Qinghai / 青海', 'invoicing' ), |
|
| 844 | - 'CN29' => __( 'Ningxia Hui / 宁夏', 'invoicing' ), |
|
| 845 | - 'CN30' => __( 'Macau / 澳门', 'invoicing' ), |
|
| 846 | - 'CN31' => __( 'Tibet / 西藏', 'invoicing' ), |
|
| 847 | - 'CN32' => __( 'Xinjiang / 新疆', 'invoicing' ) |
|
| 816 | + 'CN1' => __('Yunnan / 云南', 'invoicing'), |
|
| 817 | + 'CN2' => __('Beijing / 北京', 'invoicing'), |
|
| 818 | + 'CN3' => __('Tianjin / 天津', 'invoicing'), |
|
| 819 | + 'CN4' => __('Hebei / 河北', 'invoicing'), |
|
| 820 | + 'CN5' => __('Shanxi / 山西', 'invoicing'), |
|
| 821 | + 'CN6' => __('Inner Mongolia / 內蒙古', 'invoicing'), |
|
| 822 | + 'CN7' => __('Liaoning / 辽宁', 'invoicing'), |
|
| 823 | + 'CN8' => __('Jilin / 吉林', 'invoicing'), |
|
| 824 | + 'CN9' => __('Heilongjiang / 黑龙江', 'invoicing'), |
|
| 825 | + 'CN10' => __('Shanghai / 上海', 'invoicing'), |
|
| 826 | + 'CN11' => __('Jiangsu / 江苏', 'invoicing'), |
|
| 827 | + 'CN12' => __('Zhejiang / 浙江', 'invoicing'), |
|
| 828 | + 'CN13' => __('Anhui / 安徽', 'invoicing'), |
|
| 829 | + 'CN14' => __('Fujian / 福建', 'invoicing'), |
|
| 830 | + 'CN15' => __('Jiangxi / 江西', 'invoicing'), |
|
| 831 | + 'CN16' => __('Shandong / 山东', 'invoicing'), |
|
| 832 | + 'CN17' => __('Henan / 河南', 'invoicing'), |
|
| 833 | + 'CN18' => __('Hubei / 湖北', 'invoicing'), |
|
| 834 | + 'CN19' => __('Hunan / 湖南', 'invoicing'), |
|
| 835 | + 'CN20' => __('Guangdong / 广东', 'invoicing'), |
|
| 836 | + 'CN21' => __('Guangxi Zhuang / 广西壮族', 'invoicing'), |
|
| 837 | + 'CN22' => __('Hainan / 海南', 'invoicing'), |
|
| 838 | + 'CN23' => __('Chongqing / 重庆', 'invoicing'), |
|
| 839 | + 'CN24' => __('Sichuan / 四川', 'invoicing'), |
|
| 840 | + 'CN25' => __('Guizhou / 贵州', 'invoicing'), |
|
| 841 | + 'CN26' => __('Shaanxi / 陕西', 'invoicing'), |
|
| 842 | + 'CN27' => __('Gansu / 甘肃', 'invoicing'), |
|
| 843 | + 'CN28' => __('Qinghai / 青海', 'invoicing'), |
|
| 844 | + 'CN29' => __('Ningxia Hui / 宁夏', 'invoicing'), |
|
| 845 | + 'CN30' => __('Macau / 澳门', 'invoicing'), |
|
| 846 | + 'CN31' => __('Tibet / 西藏', 'invoicing'), |
|
| 847 | + 'CN32' => __('Xinjiang / 新疆', 'invoicing') |
|
| 848 | 848 | ); |
| 849 | 849 | |
| 850 | - return apply_filters( 'wpinv_china_states', $states ); |
|
| 850 | + return apply_filters('wpinv_china_states', $states); |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | function wpinv_get_new_zealand_states_list() { |
| 854 | 854 | $states = array( |
| 855 | - 'AK' => __( 'Auckland', 'invoicing' ), |
|
| 856 | - 'BP' => __( 'Bay of Plenty', 'invoicing' ), |
|
| 857 | - 'CT' => __( 'Canterbury', 'invoicing' ), |
|
| 858 | - 'HB' => __( 'Hawke’s Bay', 'invoicing' ), |
|
| 859 | - 'MW' => __( 'Manawatu-Wanganui', 'invoicing' ), |
|
| 860 | - 'MB' => __( 'Marlborough', 'invoicing' ), |
|
| 861 | - 'NS' => __( 'Nelson', 'invoicing' ), |
|
| 862 | - 'NL' => __( 'Northland', 'invoicing' ), |
|
| 863 | - 'OT' => __( 'Otago', 'invoicing' ), |
|
| 864 | - 'SL' => __( 'Southland', 'invoicing' ), |
|
| 865 | - 'TK' => __( 'Taranaki', 'invoicing' ), |
|
| 866 | - 'TM' => __( 'Tasman', 'invoicing' ), |
|
| 867 | - 'WA' => __( 'Waikato', 'invoicing' ), |
|
| 868 | - 'WR' => __( 'Wairarapa', 'invoicing' ), |
|
| 869 | - 'WE' => __( 'Wellington', 'invoicing' ), |
|
| 870 | - 'WC' => __( 'West Coast', 'invoicing' ) |
|
| 855 | + 'AK' => __('Auckland', 'invoicing'), |
|
| 856 | + 'BP' => __('Bay of Plenty', 'invoicing'), |
|
| 857 | + 'CT' => __('Canterbury', 'invoicing'), |
|
| 858 | + 'HB' => __('Hawke’s Bay', 'invoicing'), |
|
| 859 | + 'MW' => __('Manawatu-Wanganui', 'invoicing'), |
|
| 860 | + 'MB' => __('Marlborough', 'invoicing'), |
|
| 861 | + 'NS' => __('Nelson', 'invoicing'), |
|
| 862 | + 'NL' => __('Northland', 'invoicing'), |
|
| 863 | + 'OT' => __('Otago', 'invoicing'), |
|
| 864 | + 'SL' => __('Southland', 'invoicing'), |
|
| 865 | + 'TK' => __('Taranaki', 'invoicing'), |
|
| 866 | + 'TM' => __('Tasman', 'invoicing'), |
|
| 867 | + 'WA' => __('Waikato', 'invoicing'), |
|
| 868 | + 'WR' => __('Wairarapa', 'invoicing'), |
|
| 869 | + 'WE' => __('Wellington', 'invoicing'), |
|
| 870 | + 'WC' => __('West Coast', 'invoicing') |
|
| 871 | 871 | ); |
| 872 | 872 | |
| 873 | - return apply_filters( 'wpinv_new_zealand_states', $states ); |
|
| 873 | + return apply_filters('wpinv_new_zealand_states', $states); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | function wpinv_get_peru_states_list() { |
| 877 | 877 | $states = array( |
| 878 | - 'CAL' => __( 'El Callao', 'invoicing' ), |
|
| 879 | - 'LMA' => __( 'Municipalidad Metropolitana de Lima', 'invoicing' ), |
|
| 880 | - 'AMA' => __( 'Amazonas', 'invoicing' ), |
|
| 881 | - 'ANC' => __( 'Ancash', 'invoicing' ), |
|
| 882 | - 'APU' => __( 'Apurímac', 'invoicing' ), |
|
| 883 | - 'ARE' => __( 'Arequipa', 'invoicing' ), |
|
| 884 | - 'AYA' => __( 'Ayacucho', 'invoicing' ), |
|
| 885 | - 'CAJ' => __( 'Cajamarca', 'invoicing' ), |
|
| 886 | - 'CUS' => __( 'Cusco', 'invoicing' ), |
|
| 887 | - 'HUV' => __( 'Huancavelica', 'invoicing' ), |
|
| 888 | - 'HUC' => __( 'Huánuco', 'invoicing' ), |
|
| 889 | - 'ICA' => __( 'Ica', 'invoicing' ), |
|
| 890 | - 'JUN' => __( 'Junín', 'invoicing' ), |
|
| 891 | - 'LAL' => __( 'La Libertad', 'invoicing' ), |
|
| 892 | - 'LAM' => __( 'Lambayeque', 'invoicing' ), |
|
| 893 | - 'LIM' => __( 'Lima', 'invoicing' ), |
|
| 894 | - 'LOR' => __( 'Loreto', 'invoicing' ), |
|
| 895 | - 'MDD' => __( 'Madre de Dios', 'invoicing' ), |
|
| 896 | - 'MOQ' => __( 'Moquegua', 'invoicing' ), |
|
| 897 | - 'PAS' => __( 'Pasco', 'invoicing' ), |
|
| 898 | - 'PIU' => __( 'Piura', 'invoicing' ), |
|
| 899 | - 'PUN' => __( 'Puno', 'invoicing' ), |
|
| 900 | - 'SAM' => __( 'San Martín', 'invoicing' ), |
|
| 901 | - 'TAC' => __( 'Tacna', 'invoicing' ), |
|
| 902 | - 'TUM' => __( 'Tumbes', 'invoicing' ), |
|
| 903 | - 'UCA' => __( 'Ucayali', 'invoicing' ) |
|
| 878 | + 'CAL' => __('El Callao', 'invoicing'), |
|
| 879 | + 'LMA' => __('Municipalidad Metropolitana de Lima', 'invoicing'), |
|
| 880 | + 'AMA' => __('Amazonas', 'invoicing'), |
|
| 881 | + 'ANC' => __('Ancash', 'invoicing'), |
|
| 882 | + 'APU' => __('Apurímac', 'invoicing'), |
|
| 883 | + 'ARE' => __('Arequipa', 'invoicing'), |
|
| 884 | + 'AYA' => __('Ayacucho', 'invoicing'), |
|
| 885 | + 'CAJ' => __('Cajamarca', 'invoicing'), |
|
| 886 | + 'CUS' => __('Cusco', 'invoicing'), |
|
| 887 | + 'HUV' => __('Huancavelica', 'invoicing'), |
|
| 888 | + 'HUC' => __('Huánuco', 'invoicing'), |
|
| 889 | + 'ICA' => __('Ica', 'invoicing'), |
|
| 890 | + 'JUN' => __('Junín', 'invoicing'), |
|
| 891 | + 'LAL' => __('La Libertad', 'invoicing'), |
|
| 892 | + 'LAM' => __('Lambayeque', 'invoicing'), |
|
| 893 | + 'LIM' => __('Lima', 'invoicing'), |
|
| 894 | + 'LOR' => __('Loreto', 'invoicing'), |
|
| 895 | + 'MDD' => __('Madre de Dios', 'invoicing'), |
|
| 896 | + 'MOQ' => __('Moquegua', 'invoicing'), |
|
| 897 | + 'PAS' => __('Pasco', 'invoicing'), |
|
| 898 | + 'PIU' => __('Piura', 'invoicing'), |
|
| 899 | + 'PUN' => __('Puno', 'invoicing'), |
|
| 900 | + 'SAM' => __('San Martín', 'invoicing'), |
|
| 901 | + 'TAC' => __('Tacna', 'invoicing'), |
|
| 902 | + 'TUM' => __('Tumbes', 'invoicing'), |
|
| 903 | + 'UCA' => __('Ucayali', 'invoicing') |
|
| 904 | 904 | ); |
| 905 | 905 | |
| 906 | - return apply_filters( 'wpinv_peru_states', $states ); |
|
| 906 | + return apply_filters('wpinv_peru_states', $states); |
|
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | function wpinv_get_indonesia_states_list() { |
| 910 | - $states = array( |
|
| 911 | - 'AC' => __( 'Daerah Istimewa Aceh', 'invoicing' ), |
|
| 912 | - 'SU' => __( 'Sumatera Utara', 'invoicing' ), |
|
| 913 | - 'SB' => __( 'Sumatera Barat', 'invoicing' ), |
|
| 914 | - 'RI' => __( 'Riau', 'invoicing' ), |
|
| 915 | - 'KR' => __( 'Kepulauan Riau', 'invoicing' ), |
|
| 916 | - 'JA' => __( 'Jambi', 'invoicing' ), |
|
| 917 | - 'SS' => __( 'Sumatera Selatan', 'invoicing' ), |
|
| 918 | - 'BB' => __( 'Bangka Belitung', 'invoicing' ), |
|
| 919 | - 'BE' => __( 'Bengkulu', 'invoicing' ), |
|
| 920 | - 'LA' => __( 'Lampung', 'invoicing' ), |
|
| 921 | - 'JK' => __( 'DKI Jakarta', 'invoicing' ), |
|
| 922 | - 'JB' => __( 'Jawa Barat', 'invoicing' ), |
|
| 923 | - 'BT' => __( 'Banten', 'invoicing' ), |
|
| 924 | - 'JT' => __( 'Jawa Tengah', 'invoicing' ), |
|
| 925 | - 'JI' => __( 'Jawa Timur', 'invoicing' ), |
|
| 926 | - 'YO' => __( 'Daerah Istimewa Yogyakarta', 'invoicing' ), |
|
| 927 | - 'BA' => __( 'Bali', 'invoicing' ), |
|
| 928 | - 'NB' => __( 'Nusa Tenggara Barat', 'invoicing' ), |
|
| 929 | - 'NT' => __( 'Nusa Tenggara Timur', 'invoicing' ), |
|
| 930 | - 'KB' => __( 'Kalimantan Barat', 'invoicing' ), |
|
| 931 | - 'KT' => __( 'Kalimantan Tengah', 'invoicing' ), |
|
| 932 | - 'KI' => __( 'Kalimantan Timur', 'invoicing' ), |
|
| 933 | - 'KS' => __( 'Kalimantan Selatan', 'invoicing' ), |
|
| 934 | - 'KU' => __( 'Kalimantan Utara', 'invoicing' ), |
|
| 935 | - 'SA' => __( 'Sulawesi Utara', 'invoicing' ), |
|
| 936 | - 'ST' => __( 'Sulawesi Tengah', 'invoicing' ), |
|
| 937 | - 'SG' => __( 'Sulawesi Tenggara', 'invoicing' ), |
|
| 938 | - 'SR' => __( 'Sulawesi Barat', 'invoicing' ), |
|
| 939 | - 'SN' => __( 'Sulawesi Selatan', 'invoicing' ), |
|
| 940 | - 'GO' => __( 'Gorontalo', 'invoicing' ), |
|
| 941 | - 'MA' => __( 'Maluku', 'invoicing' ), |
|
| 942 | - 'MU' => __( 'Maluku Utara', 'invoicing' ), |
|
| 943 | - 'PA' => __( 'Papua', 'invoicing' ), |
|
| 944 | - 'PB' => __( 'Papua Barat', 'invoicing' ) |
|
| 910 | + $states = array( |
|
| 911 | + 'AC' => __('Daerah Istimewa Aceh', 'invoicing'), |
|
| 912 | + 'SU' => __('Sumatera Utara', 'invoicing'), |
|
| 913 | + 'SB' => __('Sumatera Barat', 'invoicing'), |
|
| 914 | + 'RI' => __('Riau', 'invoicing'), |
|
| 915 | + 'KR' => __('Kepulauan Riau', 'invoicing'), |
|
| 916 | + 'JA' => __('Jambi', 'invoicing'), |
|
| 917 | + 'SS' => __('Sumatera Selatan', 'invoicing'), |
|
| 918 | + 'BB' => __('Bangka Belitung', 'invoicing'), |
|
| 919 | + 'BE' => __('Bengkulu', 'invoicing'), |
|
| 920 | + 'LA' => __('Lampung', 'invoicing'), |
|
| 921 | + 'JK' => __('DKI Jakarta', 'invoicing'), |
|
| 922 | + 'JB' => __('Jawa Barat', 'invoicing'), |
|
| 923 | + 'BT' => __('Banten', 'invoicing'), |
|
| 924 | + 'JT' => __('Jawa Tengah', 'invoicing'), |
|
| 925 | + 'JI' => __('Jawa Timur', 'invoicing'), |
|
| 926 | + 'YO' => __('Daerah Istimewa Yogyakarta', 'invoicing'), |
|
| 927 | + 'BA' => __('Bali', 'invoicing'), |
|
| 928 | + 'NB' => __('Nusa Tenggara Barat', 'invoicing'), |
|
| 929 | + 'NT' => __('Nusa Tenggara Timur', 'invoicing'), |
|
| 930 | + 'KB' => __('Kalimantan Barat', 'invoicing'), |
|
| 931 | + 'KT' => __('Kalimantan Tengah', 'invoicing'), |
|
| 932 | + 'KI' => __('Kalimantan Timur', 'invoicing'), |
|
| 933 | + 'KS' => __('Kalimantan Selatan', 'invoicing'), |
|
| 934 | + 'KU' => __('Kalimantan Utara', 'invoicing'), |
|
| 935 | + 'SA' => __('Sulawesi Utara', 'invoicing'), |
|
| 936 | + 'ST' => __('Sulawesi Tengah', 'invoicing'), |
|
| 937 | + 'SG' => __('Sulawesi Tenggara', 'invoicing'), |
|
| 938 | + 'SR' => __('Sulawesi Barat', 'invoicing'), |
|
| 939 | + 'SN' => __('Sulawesi Selatan', 'invoicing'), |
|
| 940 | + 'GO' => __('Gorontalo', 'invoicing'), |
|
| 941 | + 'MA' => __('Maluku', 'invoicing'), |
|
| 942 | + 'MU' => __('Maluku Utara', 'invoicing'), |
|
| 943 | + 'PA' => __('Papua', 'invoicing'), |
|
| 944 | + 'PB' => __('Papua Barat', 'invoicing') |
|
| 945 | 945 | ); |
| 946 | 946 | |
| 947 | - return apply_filters( 'wpinv_indonesia_states', $states ); |
|
| 947 | + return apply_filters('wpinv_indonesia_states', $states); |
|
| 948 | 948 | } |
| 949 | 949 | |
| 950 | 950 | function wpinv_get_india_states_list() { |
| 951 | 951 | $states = array( |
| 952 | - 'AP' => __( 'Andhra Pradesh', 'invoicing' ), |
|
| 953 | - 'AR' => __( 'Arunachal Pradesh', 'invoicing' ), |
|
| 954 | - 'AS' => __( 'Assam', 'invoicing' ), |
|
| 955 | - 'BR' => __( 'Bihar', 'invoicing' ), |
|
| 956 | - 'CT' => __( 'Chhattisgarh', 'invoicing' ), |
|
| 957 | - 'GA' => __( 'Goa', 'invoicing' ), |
|
| 958 | - 'GJ' => __( 'Gujarat', 'invoicing' ), |
|
| 959 | - 'HR' => __( 'Haryana', 'invoicing' ), |
|
| 960 | - 'HP' => __( 'Himachal Pradesh', 'invoicing' ), |
|
| 961 | - 'JK' => __( 'Jammu and Kashmir', 'invoicing' ), |
|
| 962 | - 'JH' => __( 'Jharkhand', 'invoicing' ), |
|
| 963 | - 'KA' => __( 'Karnataka', 'invoicing' ), |
|
| 964 | - 'KL' => __( 'Kerala', 'invoicing' ), |
|
| 965 | - 'MP' => __( 'Madhya Pradesh', 'invoicing' ), |
|
| 966 | - 'MH' => __( 'Maharashtra', 'invoicing' ), |
|
| 967 | - 'MN' => __( 'Manipur', 'invoicing' ), |
|
| 968 | - 'ML' => __( 'Meghalaya', 'invoicing' ), |
|
| 969 | - 'MZ' => __( 'Mizoram', 'invoicing' ), |
|
| 970 | - 'NL' => __( 'Nagaland', 'invoicing' ), |
|
| 971 | - 'OR' => __( 'Orissa', 'invoicing' ), |
|
| 972 | - 'PB' => __( 'Punjab', 'invoicing' ), |
|
| 973 | - 'RJ' => __( 'Rajasthan', 'invoicing' ), |
|
| 974 | - 'SK' => __( 'Sikkim', 'invoicing' ), |
|
| 975 | - 'TN' => __( 'Tamil Nadu', 'invoicing' ), |
|
| 976 | - 'TG' => __( 'Telangana', 'invoicing' ), |
|
| 977 | - 'TR' => __( 'Tripura', 'invoicing' ), |
|
| 978 | - 'UT' => __( 'Uttarakhand', 'invoicing' ), |
|
| 979 | - 'UP' => __( 'Uttar Pradesh', 'invoicing' ), |
|
| 980 | - 'WB' => __( 'West Bengal', 'invoicing' ), |
|
| 981 | - 'AN' => __( 'Andaman and Nicobar Islands', 'invoicing' ), |
|
| 982 | - 'CH' => __( 'Chandigarh', 'invoicing' ), |
|
| 983 | - 'DN' => __( 'Dadar and Nagar Haveli', 'invoicing' ), |
|
| 984 | - 'DD' => __( 'Daman and Diu', 'invoicing' ), |
|
| 985 | - 'DL' => __( 'Delhi', 'invoicing' ), |
|
| 986 | - 'LD' => __( 'Lakshadweep', 'invoicing' ), |
|
| 987 | - 'PY' => __( 'Pondicherry (Puducherry)', 'invoicing' ) |
|
| 952 | + 'AP' => __('Andhra Pradesh', 'invoicing'), |
|
| 953 | + 'AR' => __('Arunachal Pradesh', 'invoicing'), |
|
| 954 | + 'AS' => __('Assam', 'invoicing'), |
|
| 955 | + 'BR' => __('Bihar', 'invoicing'), |
|
| 956 | + 'CT' => __('Chhattisgarh', 'invoicing'), |
|
| 957 | + 'GA' => __('Goa', 'invoicing'), |
|
| 958 | + 'GJ' => __('Gujarat', 'invoicing'), |
|
| 959 | + 'HR' => __('Haryana', 'invoicing'), |
|
| 960 | + 'HP' => __('Himachal Pradesh', 'invoicing'), |
|
| 961 | + 'JK' => __('Jammu and Kashmir', 'invoicing'), |
|
| 962 | + 'JH' => __('Jharkhand', 'invoicing'), |
|
| 963 | + 'KA' => __('Karnataka', 'invoicing'), |
|
| 964 | + 'KL' => __('Kerala', 'invoicing'), |
|
| 965 | + 'MP' => __('Madhya Pradesh', 'invoicing'), |
|
| 966 | + 'MH' => __('Maharashtra', 'invoicing'), |
|
| 967 | + 'MN' => __('Manipur', 'invoicing'), |
|
| 968 | + 'ML' => __('Meghalaya', 'invoicing'), |
|
| 969 | + 'MZ' => __('Mizoram', 'invoicing'), |
|
| 970 | + 'NL' => __('Nagaland', 'invoicing'), |
|
| 971 | + 'OR' => __('Orissa', 'invoicing'), |
|
| 972 | + 'PB' => __('Punjab', 'invoicing'), |
|
| 973 | + 'RJ' => __('Rajasthan', 'invoicing'), |
|
| 974 | + 'SK' => __('Sikkim', 'invoicing'), |
|
| 975 | + 'TN' => __('Tamil Nadu', 'invoicing'), |
|
| 976 | + 'TG' => __('Telangana', 'invoicing'), |
|
| 977 | + 'TR' => __('Tripura', 'invoicing'), |
|
| 978 | + 'UT' => __('Uttarakhand', 'invoicing'), |
|
| 979 | + 'UP' => __('Uttar Pradesh', 'invoicing'), |
|
| 980 | + 'WB' => __('West Bengal', 'invoicing'), |
|
| 981 | + 'AN' => __('Andaman and Nicobar Islands', 'invoicing'), |
|
| 982 | + 'CH' => __('Chandigarh', 'invoicing'), |
|
| 983 | + 'DN' => __('Dadar and Nagar Haveli', 'invoicing'), |
|
| 984 | + 'DD' => __('Daman and Diu', 'invoicing'), |
|
| 985 | + 'DL' => __('Delhi', 'invoicing'), |
|
| 986 | + 'LD' => __('Lakshadweep', 'invoicing'), |
|
| 987 | + 'PY' => __('Pondicherry (Puducherry)', 'invoicing') |
|
| 988 | 988 | ); |
| 989 | 989 | |
| 990 | - return apply_filters( 'wpinv_india_states', $states ); |
|
| 990 | + return apply_filters('wpinv_india_states', $states); |
|
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | function wpinv_get_iran_states_list() { |
| 994 | 994 | $states = array( |
| 995 | - 'KHZ' => __( 'Khuzestan', 'invoicing' ), |
|
| 996 | - 'THR' => __( 'Tehran', 'invoicing' ), |
|
| 997 | - 'ILM' => __( 'Ilaam', 'invoicing' ), |
|
| 998 | - 'BHR' => __( 'Bushehr', 'invoicing' ), |
|
| 999 | - 'ADL' => __( 'Ardabil', 'invoicing' ), |
|
| 1000 | - 'ESF' => __( 'Isfahan', 'invoicing' ), |
|
| 1001 | - 'YZD' => __( 'Yazd', 'invoicing' ), |
|
| 1002 | - 'KRH' => __( 'Kermanshah', 'invoicing' ), |
|
| 1003 | - 'KRN' => __( 'Kerman', 'invoicing' ), |
|
| 1004 | - 'HDN' => __( 'Hamadan', 'invoicing' ), |
|
| 1005 | - 'GZN' => __( 'Ghazvin', 'invoicing' ), |
|
| 1006 | - 'ZJN' => __( 'Zanjan', 'invoicing' ), |
|
| 1007 | - 'LRS' => __( 'Luristan', 'invoicing' ), |
|
| 1008 | - 'ABZ' => __( 'Alborz', 'invoicing' ), |
|
| 1009 | - 'EAZ' => __( 'East Azerbaijan', 'invoicing' ), |
|
| 1010 | - 'WAZ' => __( 'West Azerbaijan', 'invoicing' ), |
|
| 1011 | - 'CHB' => __( 'Chaharmahal and Bakhtiari', 'invoicing' ), |
|
| 1012 | - 'SKH' => __( 'South Khorasan', 'invoicing' ), |
|
| 1013 | - 'RKH' => __( 'Razavi Khorasan', 'invoicing' ), |
|
| 1014 | - 'NKH' => __( 'North Khorasan', 'invoicing' ), |
|
| 1015 | - 'SMN' => __( 'Semnan', 'invoicing' ), |
|
| 1016 | - 'FRS' => __( 'Fars', 'invoicing' ), |
|
| 1017 | - 'QHM' => __( 'Qom', 'invoicing' ), |
|
| 1018 | - 'KRD' => __( 'Kurdistan', 'invoicing' ), |
|
| 1019 | - 'KBD' => __( 'Kohgiluyeh and BoyerAhmad', 'invoicing' ), |
|
| 1020 | - 'GLS' => __( 'Golestan', 'invoicing' ), |
|
| 1021 | - 'GIL' => __( 'Gilan', 'invoicing' ), |
|
| 1022 | - 'MZN' => __( 'Mazandaran', 'invoicing' ), |
|
| 1023 | - 'MKZ' => __( 'Markazi', 'invoicing' ), |
|
| 1024 | - 'HRZ' => __( 'Hormozgan', 'invoicing' ), |
|
| 1025 | - 'SBN' => __( 'Sistan and Baluchestan', 'invoicing' ) |
|
| 995 | + 'KHZ' => __('Khuzestan', 'invoicing'), |
|
| 996 | + 'THR' => __('Tehran', 'invoicing'), |
|
| 997 | + 'ILM' => __('Ilaam', 'invoicing'), |
|
| 998 | + 'BHR' => __('Bushehr', 'invoicing'), |
|
| 999 | + 'ADL' => __('Ardabil', 'invoicing'), |
|
| 1000 | + 'ESF' => __('Isfahan', 'invoicing'), |
|
| 1001 | + 'YZD' => __('Yazd', 'invoicing'), |
|
| 1002 | + 'KRH' => __('Kermanshah', 'invoicing'), |
|
| 1003 | + 'KRN' => __('Kerman', 'invoicing'), |
|
| 1004 | + 'HDN' => __('Hamadan', 'invoicing'), |
|
| 1005 | + 'GZN' => __('Ghazvin', 'invoicing'), |
|
| 1006 | + 'ZJN' => __('Zanjan', 'invoicing'), |
|
| 1007 | + 'LRS' => __('Luristan', 'invoicing'), |
|
| 1008 | + 'ABZ' => __('Alborz', 'invoicing'), |
|
| 1009 | + 'EAZ' => __('East Azerbaijan', 'invoicing'), |
|
| 1010 | + 'WAZ' => __('West Azerbaijan', 'invoicing'), |
|
| 1011 | + 'CHB' => __('Chaharmahal and Bakhtiari', 'invoicing'), |
|
| 1012 | + 'SKH' => __('South Khorasan', 'invoicing'), |
|
| 1013 | + 'RKH' => __('Razavi Khorasan', 'invoicing'), |
|
| 1014 | + 'NKH' => __('North Khorasan', 'invoicing'), |
|
| 1015 | + 'SMN' => __('Semnan', 'invoicing'), |
|
| 1016 | + 'FRS' => __('Fars', 'invoicing'), |
|
| 1017 | + 'QHM' => __('Qom', 'invoicing'), |
|
| 1018 | + 'KRD' => __('Kurdistan', 'invoicing'), |
|
| 1019 | + 'KBD' => __('Kohgiluyeh and BoyerAhmad', 'invoicing'), |
|
| 1020 | + 'GLS' => __('Golestan', 'invoicing'), |
|
| 1021 | + 'GIL' => __('Gilan', 'invoicing'), |
|
| 1022 | + 'MZN' => __('Mazandaran', 'invoicing'), |
|
| 1023 | + 'MKZ' => __('Markazi', 'invoicing'), |
|
| 1024 | + 'HRZ' => __('Hormozgan', 'invoicing'), |
|
| 1025 | + 'SBN' => __('Sistan and Baluchestan', 'invoicing') |
|
| 1026 | 1026 | ); |
| 1027 | 1027 | |
| 1028 | - return apply_filters( 'wpinv_iran_states', $states ); |
|
| 1028 | + return apply_filters('wpinv_iran_states', $states); |
|
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | 1031 | function wpinv_get_italy_states_list() { |
| 1032 | 1032 | $states = array( |
| 1033 | - 'AG' => __( 'Agrigento', 'invoicing' ), |
|
| 1034 | - 'AL' => __( 'Alessandria', 'invoicing' ), |
|
| 1035 | - 'AN' => __( 'Ancona', 'invoicing' ), |
|
| 1036 | - 'AO' => __( 'Aosta', 'invoicing' ), |
|
| 1037 | - 'AR' => __( 'Arezzo', 'invoicing' ), |
|
| 1038 | - 'AP' => __( 'Ascoli Piceno', 'invoicing' ), |
|
| 1039 | - 'AT' => __( 'Asti', 'invoicing' ), |
|
| 1040 | - 'AV' => __( 'Avellino', 'invoicing' ), |
|
| 1041 | - 'BA' => __( 'Bari', 'invoicing' ), |
|
| 1042 | - 'BT' => __( 'Barletta-Andria-Trani', 'invoicing' ), |
|
| 1043 | - 'BL' => __( 'Belluno', 'invoicing' ), |
|
| 1044 | - 'BN' => __( 'Benevento', 'invoicing' ), |
|
| 1045 | - 'BG' => __( 'Bergamo', 'invoicing' ), |
|
| 1046 | - 'BI' => __( 'Biella', 'invoicing' ), |
|
| 1047 | - 'BO' => __( 'Bologna', 'invoicing' ), |
|
| 1048 | - 'BZ' => __( 'Bolzano', 'invoicing' ), |
|
| 1049 | - 'BS' => __( 'Brescia', 'invoicing' ), |
|
| 1050 | - 'BR' => __( 'Brindisi', 'invoicing' ), |
|
| 1051 | - 'CA' => __( 'Cagliari', 'invoicing' ), |
|
| 1052 | - 'CL' => __( 'Caltanissetta', 'invoicing' ), |
|
| 1053 | - 'CB' => __( 'Campobasso', 'invoicing' ), |
|
| 1054 | - 'CI' => __( 'Caltanissetta', 'invoicing' ), |
|
| 1055 | - 'CE' => __( 'Caserta', 'invoicing' ), |
|
| 1056 | - 'CT' => __( 'Catania', 'invoicing' ), |
|
| 1057 | - 'CZ' => __( 'Catanzaro', 'invoicing' ), |
|
| 1058 | - 'CH' => __( 'Chieti', 'invoicing' ), |
|
| 1059 | - 'CO' => __( 'Como', 'invoicing' ), |
|
| 1060 | - 'CS' => __( 'Cosenza', 'invoicing' ), |
|
| 1061 | - 'CR' => __( 'Cremona', 'invoicing' ), |
|
| 1062 | - 'KR' => __( 'Crotone', 'invoicing' ), |
|
| 1063 | - 'CN' => __( 'Cuneo', 'invoicing' ), |
|
| 1064 | - 'EN' => __( 'Enna', 'invoicing' ), |
|
| 1065 | - 'FM' => __( 'Fermo', 'invoicing' ), |
|
| 1066 | - 'FE' => __( 'Ferrara', 'invoicing' ), |
|
| 1067 | - 'FI' => __( 'Firenze', 'invoicing' ), |
|
| 1068 | - 'FG' => __( 'Foggia', 'invoicing' ), |
|
| 1069 | - 'FC' => __( 'Forli-Cesena', 'invoicing' ), |
|
| 1070 | - 'FR' => __( 'Frosinone', 'invoicing' ), |
|
| 1071 | - 'GE' => __( 'Genova', 'invoicing' ), |
|
| 1072 | - 'GO' => __( 'Gorizia', 'invoicing' ), |
|
| 1073 | - 'GR' => __( 'Grosseto', 'invoicing' ), |
|
| 1074 | - 'IM' => __( 'Imperia', 'invoicing' ), |
|
| 1075 | - 'IS' => __( 'Isernia', 'invoicing' ), |
|
| 1076 | - 'SP' => __( 'La Spezia', 'invoicing' ), |
|
| 1077 | - 'AQ' => __( 'L'Aquila', 'invoicing' ), |
|
| 1078 | - 'LT' => __( 'Latina', 'invoicing' ), |
|
| 1079 | - 'LE' => __( 'Lecce', 'invoicing' ), |
|
| 1080 | - 'LC' => __( 'Lecco', 'invoicing' ), |
|
| 1081 | - 'LI' => __( 'Livorno', 'invoicing' ), |
|
| 1082 | - 'LO' => __( 'Lodi', 'invoicing' ), |
|
| 1083 | - 'LU' => __( 'Lucca', 'invoicing' ), |
|
| 1084 | - 'MC' => __( 'Macerata', 'invoicing' ), |
|
| 1085 | - 'MN' => __( 'Mantova', 'invoicing' ), |
|
| 1086 | - 'MS' => __( 'Massa-Carrara', 'invoicing' ), |
|
| 1087 | - 'MT' => __( 'Matera', 'invoicing' ), |
|
| 1088 | - 'ME' => __( 'Messina', 'invoicing' ), |
|
| 1089 | - 'MI' => __( 'Milano', 'invoicing' ), |
|
| 1090 | - 'MO' => __( 'Modena', 'invoicing' ), |
|
| 1091 | - 'MB' => __( 'Monza e della Brianza', 'invoicing' ), |
|
| 1092 | - 'NA' => __( 'Napoli', 'invoicing' ), |
|
| 1093 | - 'NO' => __( 'Novara', 'invoicing' ), |
|
| 1094 | - 'NU' => __( 'Nuoro', 'invoicing' ), |
|
| 1095 | - 'OT' => __( 'Olbia-Tempio', 'invoicing' ), |
|
| 1096 | - 'OR' => __( 'Oristano', 'invoicing' ), |
|
| 1097 | - 'PD' => __( 'Padova', 'invoicing' ), |
|
| 1098 | - 'PA' => __( 'Palermo', 'invoicing' ), |
|
| 1099 | - 'PR' => __( 'Parma', 'invoicing' ), |
|
| 1100 | - 'PV' => __( 'Pavia', 'invoicing' ), |
|
| 1101 | - 'PG' => __( 'Perugia', 'invoicing' ), |
|
| 1102 | - 'PU' => __( 'Pesaro e Urbino', 'invoicing' ), |
|
| 1103 | - 'PE' => __( 'Pescara', 'invoicing' ), |
|
| 1104 | - 'PC' => __( 'Piacenza', 'invoicing' ), |
|
| 1105 | - 'PI' => __( 'Pisa', 'invoicing' ), |
|
| 1106 | - 'PT' => __( 'Pistoia', 'invoicing' ), |
|
| 1107 | - 'PN' => __( 'Pordenone', 'invoicing' ), |
|
| 1108 | - 'PZ' => __( 'Potenza', 'invoicing' ), |
|
| 1109 | - 'PO' => __( 'Prato', 'invoicing' ), |
|
| 1110 | - 'RG' => __( 'Ragusa', 'invoicing' ), |
|
| 1111 | - 'RA' => __( 'Ravenna', 'invoicing' ), |
|
| 1112 | - 'RC' => __( 'Reggio Calabria', 'invoicing' ), |
|
| 1113 | - 'RE' => __( 'Reggio Emilia', 'invoicing' ), |
|
| 1114 | - 'RI' => __( 'Rieti', 'invoicing' ), |
|
| 1115 | - 'RN' => __( 'Rimini', 'invoicing' ), |
|
| 1116 | - 'RM' => __( 'Roma', 'invoicing' ), |
|
| 1117 | - 'RO' => __( 'Rovigo', 'invoicing' ), |
|
| 1118 | - 'SA' => __( 'Salerno', 'invoicing' ), |
|
| 1119 | - 'VS' => __( 'Medio Campidano', 'invoicing' ), |
|
| 1120 | - 'SS' => __( 'Sassari', 'invoicing' ), |
|
| 1121 | - 'SV' => __( 'Savona', 'invoicing' ), |
|
| 1122 | - 'SI' => __( 'Siena', 'invoicing' ), |
|
| 1123 | - 'SR' => __( 'Siracusa', 'invoicing' ), |
|
| 1124 | - 'SO' => __( 'Sondrio', 'invoicing' ), |
|
| 1125 | - 'TA' => __( 'Taranto', 'invoicing' ), |
|
| 1126 | - 'TE' => __( 'Teramo', 'invoicing' ), |
|
| 1127 | - 'TR' => __( 'Terni', 'invoicing' ), |
|
| 1128 | - 'TO' => __( 'Torino', 'invoicing' ), |
|
| 1129 | - 'OG' => __( 'Ogliastra', 'invoicing' ), |
|
| 1130 | - 'TP' => __( 'Trapani', 'invoicing' ), |
|
| 1131 | - 'TN' => __( 'Trento', 'invoicing' ), |
|
| 1132 | - 'TV' => __( 'Treviso', 'invoicing' ), |
|
| 1133 | - 'TS' => __( 'Trieste', 'invoicing' ), |
|
| 1134 | - 'UD' => __( 'Udine', 'invoicing' ), |
|
| 1135 | - 'VA' => __( 'Varesa', 'invoicing' ), |
|
| 1136 | - 'VE' => __( 'Venezia', 'invoicing' ), |
|
| 1137 | - 'VB' => __( 'Verbano-Cusio-Ossola', 'invoicing' ), |
|
| 1138 | - 'VC' => __( 'Vercelli', 'invoicing' ), |
|
| 1139 | - 'VR' => __( 'Verona', 'invoicing' ), |
|
| 1140 | - 'VV' => __( 'Vibo Valentia', 'invoicing' ), |
|
| 1141 | - 'VI' => __( 'Vicenza', 'invoicing' ), |
|
| 1142 | - 'VT' => __( 'Viterbo', 'invoicing' ) |
|
| 1033 | + 'AG' => __('Agrigento', 'invoicing'), |
|
| 1034 | + 'AL' => __('Alessandria', 'invoicing'), |
|
| 1035 | + 'AN' => __('Ancona', 'invoicing'), |
|
| 1036 | + 'AO' => __('Aosta', 'invoicing'), |
|
| 1037 | + 'AR' => __('Arezzo', 'invoicing'), |
|
| 1038 | + 'AP' => __('Ascoli Piceno', 'invoicing'), |
|
| 1039 | + 'AT' => __('Asti', 'invoicing'), |
|
| 1040 | + 'AV' => __('Avellino', 'invoicing'), |
|
| 1041 | + 'BA' => __('Bari', 'invoicing'), |
|
| 1042 | + 'BT' => __('Barletta-Andria-Trani', 'invoicing'), |
|
| 1043 | + 'BL' => __('Belluno', 'invoicing'), |
|
| 1044 | + 'BN' => __('Benevento', 'invoicing'), |
|
| 1045 | + 'BG' => __('Bergamo', 'invoicing'), |
|
| 1046 | + 'BI' => __('Biella', 'invoicing'), |
|
| 1047 | + 'BO' => __('Bologna', 'invoicing'), |
|
| 1048 | + 'BZ' => __('Bolzano', 'invoicing'), |
|
| 1049 | + 'BS' => __('Brescia', 'invoicing'), |
|
| 1050 | + 'BR' => __('Brindisi', 'invoicing'), |
|
| 1051 | + 'CA' => __('Cagliari', 'invoicing'), |
|
| 1052 | + 'CL' => __('Caltanissetta', 'invoicing'), |
|
| 1053 | + 'CB' => __('Campobasso', 'invoicing'), |
|
| 1054 | + 'CI' => __('Caltanissetta', 'invoicing'), |
|
| 1055 | + 'CE' => __('Caserta', 'invoicing'), |
|
| 1056 | + 'CT' => __('Catania', 'invoicing'), |
|
| 1057 | + 'CZ' => __('Catanzaro', 'invoicing'), |
|
| 1058 | + 'CH' => __('Chieti', 'invoicing'), |
|
| 1059 | + 'CO' => __('Como', 'invoicing'), |
|
| 1060 | + 'CS' => __('Cosenza', 'invoicing'), |
|
| 1061 | + 'CR' => __('Cremona', 'invoicing'), |
|
| 1062 | + 'KR' => __('Crotone', 'invoicing'), |
|
| 1063 | + 'CN' => __('Cuneo', 'invoicing'), |
|
| 1064 | + 'EN' => __('Enna', 'invoicing'), |
|
| 1065 | + 'FM' => __('Fermo', 'invoicing'), |
|
| 1066 | + 'FE' => __('Ferrara', 'invoicing'), |
|
| 1067 | + 'FI' => __('Firenze', 'invoicing'), |
|
| 1068 | + 'FG' => __('Foggia', 'invoicing'), |
|
| 1069 | + 'FC' => __('Forli-Cesena', 'invoicing'), |
|
| 1070 | + 'FR' => __('Frosinone', 'invoicing'), |
|
| 1071 | + 'GE' => __('Genova', 'invoicing'), |
|
| 1072 | + 'GO' => __('Gorizia', 'invoicing'), |
|
| 1073 | + 'GR' => __('Grosseto', 'invoicing'), |
|
| 1074 | + 'IM' => __('Imperia', 'invoicing'), |
|
| 1075 | + 'IS' => __('Isernia', 'invoicing'), |
|
| 1076 | + 'SP' => __('La Spezia', 'invoicing'), |
|
| 1077 | + 'AQ' => __('L'Aquila', 'invoicing'), |
|
| 1078 | + 'LT' => __('Latina', 'invoicing'), |
|
| 1079 | + 'LE' => __('Lecce', 'invoicing'), |
|
| 1080 | + 'LC' => __('Lecco', 'invoicing'), |
|
| 1081 | + 'LI' => __('Livorno', 'invoicing'), |
|
| 1082 | + 'LO' => __('Lodi', 'invoicing'), |
|
| 1083 | + 'LU' => __('Lucca', 'invoicing'), |
|
| 1084 | + 'MC' => __('Macerata', 'invoicing'), |
|
| 1085 | + 'MN' => __('Mantova', 'invoicing'), |
|
| 1086 | + 'MS' => __('Massa-Carrara', 'invoicing'), |
|
| 1087 | + 'MT' => __('Matera', 'invoicing'), |
|
| 1088 | + 'ME' => __('Messina', 'invoicing'), |
|
| 1089 | + 'MI' => __('Milano', 'invoicing'), |
|
| 1090 | + 'MO' => __('Modena', 'invoicing'), |
|
| 1091 | + 'MB' => __('Monza e della Brianza', 'invoicing'), |
|
| 1092 | + 'NA' => __('Napoli', 'invoicing'), |
|
| 1093 | + 'NO' => __('Novara', 'invoicing'), |
|
| 1094 | + 'NU' => __('Nuoro', 'invoicing'), |
|
| 1095 | + 'OT' => __('Olbia-Tempio', 'invoicing'), |
|
| 1096 | + 'OR' => __('Oristano', 'invoicing'), |
|
| 1097 | + 'PD' => __('Padova', 'invoicing'), |
|
| 1098 | + 'PA' => __('Palermo', 'invoicing'), |
|
| 1099 | + 'PR' => __('Parma', 'invoicing'), |
|
| 1100 | + 'PV' => __('Pavia', 'invoicing'), |
|
| 1101 | + 'PG' => __('Perugia', 'invoicing'), |
|
| 1102 | + 'PU' => __('Pesaro e Urbino', 'invoicing'), |
|
| 1103 | + 'PE' => __('Pescara', 'invoicing'), |
|
| 1104 | + 'PC' => __('Piacenza', 'invoicing'), |
|
| 1105 | + 'PI' => __('Pisa', 'invoicing'), |
|
| 1106 | + 'PT' => __('Pistoia', 'invoicing'), |
|
| 1107 | + 'PN' => __('Pordenone', 'invoicing'), |
|
| 1108 | + 'PZ' => __('Potenza', 'invoicing'), |
|
| 1109 | + 'PO' => __('Prato', 'invoicing'), |
|
| 1110 | + 'RG' => __('Ragusa', 'invoicing'), |
|
| 1111 | + 'RA' => __('Ravenna', 'invoicing'), |
|
| 1112 | + 'RC' => __('Reggio Calabria', 'invoicing'), |
|
| 1113 | + 'RE' => __('Reggio Emilia', 'invoicing'), |
|
| 1114 | + 'RI' => __('Rieti', 'invoicing'), |
|
| 1115 | + 'RN' => __('Rimini', 'invoicing'), |
|
| 1116 | + 'RM' => __('Roma', 'invoicing'), |
|
| 1117 | + 'RO' => __('Rovigo', 'invoicing'), |
|
| 1118 | + 'SA' => __('Salerno', 'invoicing'), |
|
| 1119 | + 'VS' => __('Medio Campidano', 'invoicing'), |
|
| 1120 | + 'SS' => __('Sassari', 'invoicing'), |
|
| 1121 | + 'SV' => __('Savona', 'invoicing'), |
|
| 1122 | + 'SI' => __('Siena', 'invoicing'), |
|
| 1123 | + 'SR' => __('Siracusa', 'invoicing'), |
|
| 1124 | + 'SO' => __('Sondrio', 'invoicing'), |
|
| 1125 | + 'TA' => __('Taranto', 'invoicing'), |
|
| 1126 | + 'TE' => __('Teramo', 'invoicing'), |
|
| 1127 | + 'TR' => __('Terni', 'invoicing'), |
|
| 1128 | + 'TO' => __('Torino', 'invoicing'), |
|
| 1129 | + 'OG' => __('Ogliastra', 'invoicing'), |
|
| 1130 | + 'TP' => __('Trapani', 'invoicing'), |
|
| 1131 | + 'TN' => __('Trento', 'invoicing'), |
|
| 1132 | + 'TV' => __('Treviso', 'invoicing'), |
|
| 1133 | + 'TS' => __('Trieste', 'invoicing'), |
|
| 1134 | + 'UD' => __('Udine', 'invoicing'), |
|
| 1135 | + 'VA' => __('Varesa', 'invoicing'), |
|
| 1136 | + 'VE' => __('Venezia', 'invoicing'), |
|
| 1137 | + 'VB' => __('Verbano-Cusio-Ossola', 'invoicing'), |
|
| 1138 | + 'VC' => __('Vercelli', 'invoicing'), |
|
| 1139 | + 'VR' => __('Verona', 'invoicing'), |
|
| 1140 | + 'VV' => __('Vibo Valentia', 'invoicing'), |
|
| 1141 | + 'VI' => __('Vicenza', 'invoicing'), |
|
| 1142 | + 'VT' => __('Viterbo', 'invoicing') |
|
| 1143 | 1143 | ); |
| 1144 | 1144 | |
| 1145 | - return apply_filters( 'wpinv_italy_states', $states ); |
|
| 1145 | + return apply_filters('wpinv_italy_states', $states); |
|
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | 1148 | function wpinv_get_malaysia_states_list() { |
| 1149 | 1149 | $states = array( |
| 1150 | - 'JHR' => __( 'Johor', 'invoicing' ), |
|
| 1151 | - 'KDH' => __( 'Kedah', 'invoicing' ), |
|
| 1152 | - 'KTN' => __( 'Kelantan', 'invoicing' ), |
|
| 1153 | - 'MLK' => __( 'Melaka', 'invoicing' ), |
|
| 1154 | - 'NSN' => __( 'Negeri Sembilan', 'invoicing' ), |
|
| 1155 | - 'PHG' => __( 'Pahang', 'invoicing' ), |
|
| 1156 | - 'PRK' => __( 'Perak', 'invoicing' ), |
|
| 1157 | - 'PLS' => __( 'Perlis', 'invoicing' ), |
|
| 1158 | - 'PNG' => __( 'Pulau Pinang', 'invoicing' ), |
|
| 1159 | - 'SBH' => __( 'Sabah', 'invoicing' ), |
|
| 1160 | - 'SWK' => __( 'Sarawak', 'invoicing' ), |
|
| 1161 | - 'SGR' => __( 'Selangor', 'invoicing' ), |
|
| 1162 | - 'TRG' => __( 'Terengganu', 'invoicing' ), |
|
| 1163 | - 'KUL' => __( 'W.P. Kuala Lumpur', 'invoicing' ), |
|
| 1164 | - 'LBN' => __( 'W.P. Labuan', 'invoicing' ), |
|
| 1165 | - 'PJY' => __( 'W.P. Putrajaya', 'invoicing' ) |
|
| 1150 | + 'JHR' => __('Johor', 'invoicing'), |
|
| 1151 | + 'KDH' => __('Kedah', 'invoicing'), |
|
| 1152 | + 'KTN' => __('Kelantan', 'invoicing'), |
|
| 1153 | + 'MLK' => __('Melaka', 'invoicing'), |
|
| 1154 | + 'NSN' => __('Negeri Sembilan', 'invoicing'), |
|
| 1155 | + 'PHG' => __('Pahang', 'invoicing'), |
|
| 1156 | + 'PRK' => __('Perak', 'invoicing'), |
|
| 1157 | + 'PLS' => __('Perlis', 'invoicing'), |
|
| 1158 | + 'PNG' => __('Pulau Pinang', 'invoicing'), |
|
| 1159 | + 'SBH' => __('Sabah', 'invoicing'), |
|
| 1160 | + 'SWK' => __('Sarawak', 'invoicing'), |
|
| 1161 | + 'SGR' => __('Selangor', 'invoicing'), |
|
| 1162 | + 'TRG' => __('Terengganu', 'invoicing'), |
|
| 1163 | + 'KUL' => __('W.P. Kuala Lumpur', 'invoicing'), |
|
| 1164 | + 'LBN' => __('W.P. Labuan', 'invoicing'), |
|
| 1165 | + 'PJY' => __('W.P. Putrajaya', 'invoicing') |
|
| 1166 | 1166 | ); |
| 1167 | 1167 | |
| 1168 | - return apply_filters( 'wpinv_malaysia_states', $states ); |
|
| 1168 | + return apply_filters('wpinv_malaysia_states', $states); |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | function wpinv_get_mexico_states_list() { |
| 1172 | 1172 | $states = array( |
| 1173 | - 'DIF' => __( 'Distrito Federal', 'invoicing' ), |
|
| 1174 | - 'JAL' => __( 'Jalisco', 'invoicing' ), |
|
| 1175 | - 'NLE' => __( 'Nuevo León', 'invoicing' ), |
|
| 1176 | - 'AGU' => __( 'Aguascalientes', 'invoicing' ), |
|
| 1177 | - 'BCN' => __( 'Baja California Norte', 'invoicing' ), |
|
| 1178 | - 'BCS' => __( 'Baja California Sur', 'invoicing' ), |
|
| 1179 | - 'CAM' => __( 'Campeche', 'invoicing' ), |
|
| 1180 | - 'CHP' => __( 'Chiapas', 'invoicing' ), |
|
| 1181 | - 'CHH' => __( 'Chihuahua', 'invoicing' ), |
|
| 1182 | - 'COA' => __( 'Coahuila', 'invoicing' ), |
|
| 1183 | - 'COL' => __( 'Colima', 'invoicing' ), |
|
| 1184 | - 'DUR' => __( 'Durango', 'invoicing' ), |
|
| 1185 | - 'GUA' => __( 'Guanajuato', 'invoicing' ), |
|
| 1186 | - 'GRO' => __( 'Guerrero', 'invoicing' ), |
|
| 1187 | - 'HID' => __( 'Hidalgo', 'invoicing' ), |
|
| 1188 | - 'MEX' => __( 'Edo. de México', 'invoicing' ), |
|
| 1189 | - 'MIC' => __( 'Michoacán', 'invoicing' ), |
|
| 1190 | - 'MOR' => __( 'Morelos', 'invoicing' ), |
|
| 1191 | - 'NAY' => __( 'Nayarit', 'invoicing' ), |
|
| 1192 | - 'OAX' => __( 'Oaxaca', 'invoicing' ), |
|
| 1193 | - 'PUE' => __( 'Puebla', 'invoicing' ), |
|
| 1194 | - 'QUE' => __( 'Querétaro', 'invoicing' ), |
|
| 1195 | - 'ROO' => __( 'Quintana Roo', 'invoicing' ), |
|
| 1196 | - 'SLP' => __( 'San Luis Potosí', 'invoicing' ), |
|
| 1197 | - 'SIN' => __( 'Sinaloa', 'invoicing' ), |
|
| 1198 | - 'SON' => __( 'Sonora', 'invoicing' ), |
|
| 1199 | - 'TAB' => __( 'Tabasco', 'invoicing' ), |
|
| 1200 | - 'TAM' => __( 'Tamaulipas', 'invoicing' ), |
|
| 1201 | - 'TLA' => __( 'Tlaxcala', 'invoicing' ), |
|
| 1202 | - 'VER' => __( 'Veracruz', 'invoicing' ), |
|
| 1203 | - 'YUC' => __( 'Yucatán', 'invoicing' ), |
|
| 1204 | - 'ZAC' => __( 'Zacatecas', 'invoicing' ) |
|
| 1173 | + 'DIF' => __('Distrito Federal', 'invoicing'), |
|
| 1174 | + 'JAL' => __('Jalisco', 'invoicing'), |
|
| 1175 | + 'NLE' => __('Nuevo León', 'invoicing'), |
|
| 1176 | + 'AGU' => __('Aguascalientes', 'invoicing'), |
|
| 1177 | + 'BCN' => __('Baja California Norte', 'invoicing'), |
|
| 1178 | + 'BCS' => __('Baja California Sur', 'invoicing'), |
|
| 1179 | + 'CAM' => __('Campeche', 'invoicing'), |
|
| 1180 | + 'CHP' => __('Chiapas', 'invoicing'), |
|
| 1181 | + 'CHH' => __('Chihuahua', 'invoicing'), |
|
| 1182 | + 'COA' => __('Coahuila', 'invoicing'), |
|
| 1183 | + 'COL' => __('Colima', 'invoicing'), |
|
| 1184 | + 'DUR' => __('Durango', 'invoicing'), |
|
| 1185 | + 'GUA' => __('Guanajuato', 'invoicing'), |
|
| 1186 | + 'GRO' => __('Guerrero', 'invoicing'), |
|
| 1187 | + 'HID' => __('Hidalgo', 'invoicing'), |
|
| 1188 | + 'MEX' => __('Edo. de México', 'invoicing'), |
|
| 1189 | + 'MIC' => __('Michoacán', 'invoicing'), |
|
| 1190 | + 'MOR' => __('Morelos', 'invoicing'), |
|
| 1191 | + 'NAY' => __('Nayarit', 'invoicing'), |
|
| 1192 | + 'OAX' => __('Oaxaca', 'invoicing'), |
|
| 1193 | + 'PUE' => __('Puebla', 'invoicing'), |
|
| 1194 | + 'QUE' => __('Querétaro', 'invoicing'), |
|
| 1195 | + 'ROO' => __('Quintana Roo', 'invoicing'), |
|
| 1196 | + 'SLP' => __('San Luis Potosí', 'invoicing'), |
|
| 1197 | + 'SIN' => __('Sinaloa', 'invoicing'), |
|
| 1198 | + 'SON' => __('Sonora', 'invoicing'), |
|
| 1199 | + 'TAB' => __('Tabasco', 'invoicing'), |
|
| 1200 | + 'TAM' => __('Tamaulipas', 'invoicing'), |
|
| 1201 | + 'TLA' => __('Tlaxcala', 'invoicing'), |
|
| 1202 | + 'VER' => __('Veracruz', 'invoicing'), |
|
| 1203 | + 'YUC' => __('Yucatán', 'invoicing'), |
|
| 1204 | + 'ZAC' => __('Zacatecas', 'invoicing') |
|
| 1205 | 1205 | ); |
| 1206 | 1206 | |
| 1207 | - return apply_filters( 'wpinv_mexico_states', $states ); |
|
| 1207 | + return apply_filters('wpinv_mexico_states', $states); |
|
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | 1210 | function wpinv_get_nepal_states_list() { |
| 1211 | 1211 | $states = array( |
| 1212 | - 'ILL' => __( 'Illam', 'invoicing' ), |
|
| 1213 | - 'JHA' => __( 'Jhapa', 'invoicing' ), |
|
| 1214 | - 'PAN' => __( 'Panchthar', 'invoicing' ), |
|
| 1215 | - 'TAP' => __( 'Taplejung', 'invoicing' ), |
|
| 1216 | - 'BHO' => __( 'Bhojpur', 'invoicing' ), |
|
| 1217 | - 'DKA' => __( 'Dhankuta', 'invoicing' ), |
|
| 1218 | - 'MOR' => __( 'Morang', 'invoicing' ), |
|
| 1219 | - 'SUN' => __( 'Sunsari', 'invoicing' ), |
|
| 1220 | - 'SAN' => __( 'Sankhuwa', 'invoicing' ), |
|
| 1221 | - 'TER' => __( 'Terhathum', 'invoicing' ), |
|
| 1222 | - 'KHO' => __( 'Khotang', 'invoicing' ), |
|
| 1223 | - 'OKH' => __( 'Okhaldhunga', 'invoicing' ), |
|
| 1224 | - 'SAP' => __( 'Saptari', 'invoicing' ), |
|
| 1225 | - 'SIR' => __( 'Siraha', 'invoicing' ), |
|
| 1226 | - 'SOL' => __( 'Solukhumbu', 'invoicing' ), |
|
| 1227 | - 'UDA' => __( 'Udayapur', 'invoicing' ), |
|
| 1228 | - 'DHA' => __( 'Dhanusa', 'invoicing' ), |
|
| 1229 | - 'DLK' => __( 'Dolakha', 'invoicing' ), |
|
| 1230 | - 'MOH' => __( 'Mohottari', 'invoicing' ), |
|
| 1231 | - 'RAM' => __( 'Ramechha', 'invoicing' ), |
|
| 1232 | - 'SAR' => __( 'Sarlahi', 'invoicing' ), |
|
| 1233 | - 'SIN' => __( 'Sindhuli', 'invoicing' ), |
|
| 1234 | - 'BHA' => __( 'Bhaktapur', 'invoicing' ), |
|
| 1235 | - 'DHD' => __( 'Dhading', 'invoicing' ), |
|
| 1236 | - 'KTM' => __( 'Kathmandu', 'invoicing' ), |
|
| 1237 | - 'KAV' => __( 'Kavrepalanchowk', 'invoicing' ), |
|
| 1238 | - 'LAL' => __( 'Lalitpur', 'invoicing' ), |
|
| 1239 | - 'NUW' => __( 'Nuwakot', 'invoicing' ), |
|
| 1240 | - 'RAS' => __( 'Rasuwa', 'invoicing' ), |
|
| 1241 | - 'SPC' => __( 'Sindhupalchowk', 'invoicing' ), |
|
| 1242 | - 'BAR' => __( 'Bara', 'invoicing' ), |
|
| 1243 | - 'CHI' => __( 'Chitwan', 'invoicing' ), |
|
| 1244 | - 'MAK' => __( 'Makwanpur', 'invoicing' ), |
|
| 1245 | - 'PAR' => __( 'Parsa', 'invoicing' ), |
|
| 1246 | - 'RAU' => __( 'Rautahat', 'invoicing' ), |
|
| 1247 | - 'GOR' => __( 'Gorkha', 'invoicing' ), |
|
| 1248 | - 'KAS' => __( 'Kaski', 'invoicing' ), |
|
| 1249 | - 'LAM' => __( 'Lamjung', 'invoicing' ), |
|
| 1250 | - 'MAN' => __( 'Manang', 'invoicing' ), |
|
| 1251 | - 'SYN' => __( 'Syangja', 'invoicing' ), |
|
| 1252 | - 'TAN' => __( 'Tanahun', 'invoicing' ), |
|
| 1253 | - 'BAG' => __( 'Baglung', 'invoicing' ), |
|
| 1254 | - 'PBT' => __( 'Parbat', 'invoicing' ), |
|
| 1255 | - 'MUS' => __( 'Mustang', 'invoicing' ), |
|
| 1256 | - 'MYG' => __( 'Myagdi', 'invoicing' ), |
|
| 1257 | - 'AGR' => __( 'Agrghakanchi', 'invoicing' ), |
|
| 1258 | - 'GUL' => __( 'Gulmi', 'invoicing' ), |
|
| 1259 | - 'KAP' => __( 'Kapilbastu', 'invoicing' ), |
|
| 1260 | - 'NAW' => __( 'Nawalparasi', 'invoicing' ), |
|
| 1261 | - 'PAL' => __( 'Palpa', 'invoicing' ), |
|
| 1262 | - 'RUP' => __( 'Rupandehi', 'invoicing' ), |
|
| 1263 | - 'DAN' => __( 'Dang', 'invoicing' ), |
|
| 1264 | - 'PYU' => __( 'Pyuthan', 'invoicing' ), |
|
| 1265 | - 'ROL' => __( 'Rolpa', 'invoicing' ), |
|
| 1266 | - 'RUK' => __( 'Rukum', 'invoicing' ), |
|
| 1267 | - 'SAL' => __( 'Salyan', 'invoicing' ), |
|
| 1268 | - 'BAN' => __( 'Banke', 'invoicing' ), |
|
| 1269 | - 'BDA' => __( 'Bardiya', 'invoicing' ), |
|
| 1270 | - 'DAI' => __( 'Dailekh', 'invoicing' ), |
|
| 1271 | - 'JAJ' => __( 'Jajarkot', 'invoicing' ), |
|
| 1272 | - 'SUR' => __( 'Surkhet', 'invoicing' ), |
|
| 1273 | - 'DOL' => __( 'Dolpa', 'invoicing' ), |
|
| 1274 | - 'HUM' => __( 'Humla', 'invoicing' ), |
|
| 1275 | - 'JUM' => __( 'Jumla', 'invoicing' ), |
|
| 1276 | - 'KAL' => __( 'Kalikot', 'invoicing' ), |
|
| 1277 | - 'MUG' => __( 'Mugu', 'invoicing' ), |
|
| 1278 | - 'ACH' => __( 'Achham', 'invoicing' ), |
|
| 1279 | - 'BJH' => __( 'Bajhang', 'invoicing' ), |
|
| 1280 | - 'BJU' => __( 'Bajura', 'invoicing' ), |
|
| 1281 | - 'DOT' => __( 'Doti', 'invoicing' ), |
|
| 1282 | - 'KAI' => __( 'Kailali', 'invoicing' ), |
|
| 1283 | - 'BAI' => __( 'Baitadi', 'invoicing' ), |
|
| 1284 | - 'DAD' => __( 'Dadeldhura', 'invoicing' ), |
|
| 1285 | - 'DAR' => __( 'Darchula', 'invoicing' ), |
|
| 1286 | - 'KAN' => __( 'Kanchanpur', 'invoicing' ) |
|
| 1212 | + 'ILL' => __('Illam', 'invoicing'), |
|
| 1213 | + 'JHA' => __('Jhapa', 'invoicing'), |
|
| 1214 | + 'PAN' => __('Panchthar', 'invoicing'), |
|
| 1215 | + 'TAP' => __('Taplejung', 'invoicing'), |
|
| 1216 | + 'BHO' => __('Bhojpur', 'invoicing'), |
|
| 1217 | + 'DKA' => __('Dhankuta', 'invoicing'), |
|
| 1218 | + 'MOR' => __('Morang', 'invoicing'), |
|
| 1219 | + 'SUN' => __('Sunsari', 'invoicing'), |
|
| 1220 | + 'SAN' => __('Sankhuwa', 'invoicing'), |
|
| 1221 | + 'TER' => __('Terhathum', 'invoicing'), |
|
| 1222 | + 'KHO' => __('Khotang', 'invoicing'), |
|
| 1223 | + 'OKH' => __('Okhaldhunga', 'invoicing'), |
|
| 1224 | + 'SAP' => __('Saptari', 'invoicing'), |
|
| 1225 | + 'SIR' => __('Siraha', 'invoicing'), |
|
| 1226 | + 'SOL' => __('Solukhumbu', 'invoicing'), |
|
| 1227 | + 'UDA' => __('Udayapur', 'invoicing'), |
|
| 1228 | + 'DHA' => __('Dhanusa', 'invoicing'), |
|
| 1229 | + 'DLK' => __('Dolakha', 'invoicing'), |
|
| 1230 | + 'MOH' => __('Mohottari', 'invoicing'), |
|
| 1231 | + 'RAM' => __('Ramechha', 'invoicing'), |
|
| 1232 | + 'SAR' => __('Sarlahi', 'invoicing'), |
|
| 1233 | + 'SIN' => __('Sindhuli', 'invoicing'), |
|
| 1234 | + 'BHA' => __('Bhaktapur', 'invoicing'), |
|
| 1235 | + 'DHD' => __('Dhading', 'invoicing'), |
|
| 1236 | + 'KTM' => __('Kathmandu', 'invoicing'), |
|
| 1237 | + 'KAV' => __('Kavrepalanchowk', 'invoicing'), |
|
| 1238 | + 'LAL' => __('Lalitpur', 'invoicing'), |
|
| 1239 | + 'NUW' => __('Nuwakot', 'invoicing'), |
|
| 1240 | + 'RAS' => __('Rasuwa', 'invoicing'), |
|
| 1241 | + 'SPC' => __('Sindhupalchowk', 'invoicing'), |
|
| 1242 | + 'BAR' => __('Bara', 'invoicing'), |
|
| 1243 | + 'CHI' => __('Chitwan', 'invoicing'), |
|
| 1244 | + 'MAK' => __('Makwanpur', 'invoicing'), |
|
| 1245 | + 'PAR' => __('Parsa', 'invoicing'), |
|
| 1246 | + 'RAU' => __('Rautahat', 'invoicing'), |
|
| 1247 | + 'GOR' => __('Gorkha', 'invoicing'), |
|
| 1248 | + 'KAS' => __('Kaski', 'invoicing'), |
|
| 1249 | + 'LAM' => __('Lamjung', 'invoicing'), |
|
| 1250 | + 'MAN' => __('Manang', 'invoicing'), |
|
| 1251 | + 'SYN' => __('Syangja', 'invoicing'), |
|
| 1252 | + 'TAN' => __('Tanahun', 'invoicing'), |
|
| 1253 | + 'BAG' => __('Baglung', 'invoicing'), |
|
| 1254 | + 'PBT' => __('Parbat', 'invoicing'), |
|
| 1255 | + 'MUS' => __('Mustang', 'invoicing'), |
|
| 1256 | + 'MYG' => __('Myagdi', 'invoicing'), |
|
| 1257 | + 'AGR' => __('Agrghakanchi', 'invoicing'), |
|
| 1258 | + 'GUL' => __('Gulmi', 'invoicing'), |
|
| 1259 | + 'KAP' => __('Kapilbastu', 'invoicing'), |
|
| 1260 | + 'NAW' => __('Nawalparasi', 'invoicing'), |
|
| 1261 | + 'PAL' => __('Palpa', 'invoicing'), |
|
| 1262 | + 'RUP' => __('Rupandehi', 'invoicing'), |
|
| 1263 | + 'DAN' => __('Dang', 'invoicing'), |
|
| 1264 | + 'PYU' => __('Pyuthan', 'invoicing'), |
|
| 1265 | + 'ROL' => __('Rolpa', 'invoicing'), |
|
| 1266 | + 'RUK' => __('Rukum', 'invoicing'), |
|
| 1267 | + 'SAL' => __('Salyan', 'invoicing'), |
|
| 1268 | + 'BAN' => __('Banke', 'invoicing'), |
|
| 1269 | + 'BDA' => __('Bardiya', 'invoicing'), |
|
| 1270 | + 'DAI' => __('Dailekh', 'invoicing'), |
|
| 1271 | + 'JAJ' => __('Jajarkot', 'invoicing'), |
|
| 1272 | + 'SUR' => __('Surkhet', 'invoicing'), |
|
| 1273 | + 'DOL' => __('Dolpa', 'invoicing'), |
|
| 1274 | + 'HUM' => __('Humla', 'invoicing'), |
|
| 1275 | + 'JUM' => __('Jumla', 'invoicing'), |
|
| 1276 | + 'KAL' => __('Kalikot', 'invoicing'), |
|
| 1277 | + 'MUG' => __('Mugu', 'invoicing'), |
|
| 1278 | + 'ACH' => __('Achham', 'invoicing'), |
|
| 1279 | + 'BJH' => __('Bajhang', 'invoicing'), |
|
| 1280 | + 'BJU' => __('Bajura', 'invoicing'), |
|
| 1281 | + 'DOT' => __('Doti', 'invoicing'), |
|
| 1282 | + 'KAI' => __('Kailali', 'invoicing'), |
|
| 1283 | + 'BAI' => __('Baitadi', 'invoicing'), |
|
| 1284 | + 'DAD' => __('Dadeldhura', 'invoicing'), |
|
| 1285 | + 'DAR' => __('Darchula', 'invoicing'), |
|
| 1286 | + 'KAN' => __('Kanchanpur', 'invoicing') |
|
| 1287 | 1287 | ); |
| 1288 | 1288 | |
| 1289 | - return apply_filters( 'wpinv_nepal_states', $states ); |
|
| 1289 | + return apply_filters('wpinv_nepal_states', $states); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | 1292 | function wpinv_get_south_africa_states_list() { |
| 1293 | 1293 | $states = array( |
| 1294 | - 'EC' => __( 'Eastern Cape', 'invoicing' ), |
|
| 1295 | - 'FS' => __( 'Free State', 'invoicing' ), |
|
| 1296 | - 'GP' => __( 'Gauteng', 'invoicing' ), |
|
| 1297 | - 'KZN' => __( 'KwaZulu-Natal', 'invoicing' ), |
|
| 1298 | - 'LP' => __( 'Limpopo', 'invoicing' ), |
|
| 1299 | - 'MP' => __( 'Mpumalanga', 'invoicing' ), |
|
| 1300 | - 'NC' => __( 'Northern Cape', 'invoicing' ), |
|
| 1301 | - 'NW' => __( 'North West', 'invoicing' ), |
|
| 1302 | - 'WC' => __( 'Western Cape', 'invoicing' ) |
|
| 1294 | + 'EC' => __('Eastern Cape', 'invoicing'), |
|
| 1295 | + 'FS' => __('Free State', 'invoicing'), |
|
| 1296 | + 'GP' => __('Gauteng', 'invoicing'), |
|
| 1297 | + 'KZN' => __('KwaZulu-Natal', 'invoicing'), |
|
| 1298 | + 'LP' => __('Limpopo', 'invoicing'), |
|
| 1299 | + 'MP' => __('Mpumalanga', 'invoicing'), |
|
| 1300 | + 'NC' => __('Northern Cape', 'invoicing'), |
|
| 1301 | + 'NW' => __('North West', 'invoicing'), |
|
| 1302 | + 'WC' => __('Western Cape', 'invoicing') |
|
| 1303 | 1303 | ); |
| 1304 | 1304 | |
| 1305 | - return apply_filters( 'wpinv_south_africa_states', $states ); |
|
| 1305 | + return apply_filters('wpinv_south_africa_states', $states); |
|
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | 1308 | function wpinv_get_thailand_states_list() { |
| 1309 | 1309 | $states = array( |
| 1310 | - 'TH-37' => __( 'Amnat Charoen (อำนาจเจริญ)', 'invoicing' ), |
|
| 1311 | - 'TH-15' => __( 'Ang Thong (อ่างทอง)', 'invoicing' ), |
|
| 1312 | - 'TH-14' => __( 'Ayutthaya (พระนครศรีอยุธยา)', 'invoicing' ), |
|
| 1313 | - 'TH-10' => __( 'Bangkok (กรุงเทพมหานคร)', 'invoicing' ), |
|
| 1314 | - 'TH-38' => __( 'Bueng Kan (บึงกาฬ)', 'invoicing' ), |
|
| 1315 | - 'TH-31' => __( 'Buri Ram (บุรีรัมย์)', 'invoicing' ), |
|
| 1316 | - 'TH-24' => __( 'Chachoengsao (ฉะเชิงเทรา)', 'invoicing' ), |
|
| 1317 | - 'TH-18' => __( 'Chai Nat (ชัยนาท)', 'invoicing' ), |
|
| 1318 | - 'TH-36' => __( 'Chaiyaphum (ชัยภูมิ)', 'invoicing' ), |
|
| 1319 | - 'TH-22' => __( 'Chanthaburi (จันทบุรี)', 'invoicing' ), |
|
| 1320 | - 'TH-50' => __( 'Chiang Mai (เชียงใหม่)', 'invoicing' ), |
|
| 1321 | - 'TH-57' => __( 'Chiang Rai (เชียงราย)', 'invoicing' ), |
|
| 1322 | - 'TH-20' => __( 'Chonburi (ชลบุรี)', 'invoicing' ), |
|
| 1323 | - 'TH-86' => __( 'Chumphon (ชุมพร)', 'invoicing' ), |
|
| 1324 | - 'TH-46' => __( 'Kalasin (กาฬสินธุ์)', 'invoicing' ), |
|
| 1325 | - 'TH-62' => __( 'Kamphaeng Phet (กำแพงเพชร)', 'invoicing' ), |
|
| 1326 | - 'TH-71' => __( 'Kanchanaburi (กาญจนบุรี)', 'invoicing' ), |
|
| 1327 | - 'TH-40' => __( 'Khon Kaen (ขอนแก่น)', 'invoicing' ), |
|
| 1328 | - 'TH-81' => __( 'Krabi (กระบี่)', 'invoicing' ), |
|
| 1329 | - 'TH-52' => __( 'Lampang (ลำปาง)', 'invoicing' ), |
|
| 1330 | - 'TH-51' => __( 'Lamphun (ลำพูน)', 'invoicing' ), |
|
| 1331 | - 'TH-42' => __( 'Loei (เลย)', 'invoicing' ), |
|
| 1332 | - 'TH-16' => __( 'Lopburi (ลพบุรี)', 'invoicing' ), |
|
| 1333 | - 'TH-58' => __( 'Mae Hong Son (แม่ฮ่องสอน)', 'invoicing' ), |
|
| 1334 | - 'TH-44' => __( 'Maha Sarakham (มหาสารคาม)', 'invoicing' ), |
|
| 1335 | - 'TH-49' => __( 'Mukdahan (มุกดาหาร)', 'invoicing' ), |
|
| 1336 | - 'TH-26' => __( 'Nakhon Nayok (นครนายก)', 'invoicing' ), |
|
| 1337 | - 'TH-73' => __( 'Nakhon Pathom (นครปฐม)', 'invoicing' ), |
|
| 1338 | - 'TH-48' => __( 'Nakhon Phanom (นครพนม)', 'invoicing' ), |
|
| 1339 | - 'TH-30' => __( 'Nakhon Ratchasima (นครราชสีมา)', 'invoicing' ), |
|
| 1340 | - 'TH-60' => __( 'Nakhon Sawan (นครสวรรค์)', 'invoicing' ), |
|
| 1341 | - 'TH-80' => __( 'Nakhon Si Thammarat (นครศรีธรรมราช)', 'invoicing' ), |
|
| 1342 | - 'TH-55' => __( 'Nan (น่าน)', 'invoicing' ), |
|
| 1343 | - 'TH-96' => __( 'Narathiwat (นราธิวาส)', 'invoicing' ), |
|
| 1344 | - 'TH-39' => __( 'Nong Bua Lam Phu (หนองบัวลำภู)', 'invoicing' ), |
|
| 1345 | - 'TH-43' => __( 'Nong Khai (หนองคาย)', 'invoicing' ), |
|
| 1346 | - 'TH-12' => __( 'Nonthaburi (นนทบุรี)', 'invoicing' ), |
|
| 1347 | - 'TH-13' => __( 'Pathum Thani (ปทุมธานี)', 'invoicing' ), |
|
| 1348 | - 'TH-94' => __( 'Pattani (ปัตตานี)', 'invoicing' ), |
|
| 1349 | - 'TH-82' => __( 'Phang Nga (พังงา)', 'invoicing' ), |
|
| 1350 | - 'TH-93' => __( 'Phatthalung (พัทลุง)', 'invoicing' ), |
|
| 1351 | - 'TH-56' => __( 'Phayao (พะเยา)', 'invoicing' ), |
|
| 1352 | - 'TH-67' => __( 'Phetchabun (เพชรบูรณ์)', 'invoicing' ), |
|
| 1353 | - 'TH-76' => __( 'Phetchaburi (เพชรบุรี)', 'invoicing' ), |
|
| 1354 | - 'TH-66' => __( 'Phichit (พิจิตร)', 'invoicing' ), |
|
| 1355 | - 'TH-65' => __( 'Phitsanulok (พิษณุโลก)', 'invoicing' ), |
|
| 1356 | - 'TH-54' => __( 'Phrae (แพร่)', 'invoicing' ), |
|
| 1357 | - 'TH-83' => __( 'Phuket (ภูเก็ต)', 'invoicing' ), |
|
| 1358 | - 'TH-25' => __( 'Prachin Buri (ปราจีนบุรี)', 'invoicing' ), |
|
| 1359 | - 'TH-77' => __( 'Prachuap Khiri Khan (ประจวบคีรีขันธ์)', 'invoicing' ), |
|
| 1360 | - 'TH-85' => __( 'Ranong (ระนอง)', 'invoicing' ), |
|
| 1361 | - 'TH-70' => __( 'Ratchaburi (ราชบุรี)', 'invoicing' ), |
|
| 1362 | - 'TH-21' => __( 'Rayong (ระยอง)', 'invoicing' ), |
|
| 1363 | - 'TH-45' => __( 'Roi Et (ร้อยเอ็ด)', 'invoicing' ), |
|
| 1364 | - 'TH-27' => __( 'Sa Kaeo (สระแก้ว)', 'invoicing' ), |
|
| 1365 | - 'TH-47' => __( 'Sakon Nakhon (สกลนคร)', 'invoicing' ), |
|
| 1366 | - 'TH-11' => __( 'Samut Prakan (สมุทรปราการ)', 'invoicing' ), |
|
| 1367 | - 'TH-74' => __( 'Samut Sakhon (สมุทรสาคร)', 'invoicing' ), |
|
| 1368 | - 'TH-75' => __( 'Samut Songkhram (สมุทรสงคราม)', 'invoicing' ), |
|
| 1369 | - 'TH-19' => __( 'Saraburi (สระบุรี)', 'invoicing' ), |
|
| 1370 | - 'TH-91' => __( 'Satun (สตูล)', 'invoicing' ), |
|
| 1371 | - 'TH-17' => __( 'Sing Buri (สิงห์บุรี)', 'invoicing' ), |
|
| 1372 | - 'TH-33' => __( 'Sisaket (ศรีสะเกษ)', 'invoicing' ), |
|
| 1373 | - 'TH-90' => __( 'Songkhla (สงขลา)', 'invoicing' ), |
|
| 1374 | - 'TH-64' => __( 'Sukhothai (สุโขทัย)', 'invoicing' ), |
|
| 1375 | - 'TH-72' => __( 'Suphan Buri (สุพรรณบุรี)', 'invoicing' ), |
|
| 1376 | - 'TH-84' => __( 'Surat Thani (สุราษฎร์ธานี)', 'invoicing' ), |
|
| 1377 | - 'TH-32' => __( 'Surin (สุรินทร์)', 'invoicing' ), |
|
| 1378 | - 'TH-63' => __( 'Tak (ตาก)', 'invoicing' ), |
|
| 1379 | - 'TH-92' => __( 'Trang (ตรัง)', 'invoicing' ), |
|
| 1380 | - 'TH-23' => __( 'Trat (ตราด)', 'invoicing' ), |
|
| 1381 | - 'TH-34' => __( 'Ubon Ratchathani (อุบลราชธานี)', 'invoicing' ), |
|
| 1382 | - 'TH-41' => __( 'Udon Thani (อุดรธานี)', 'invoicing' ), |
|
| 1383 | - 'TH-61' => __( 'Uthai Thani (อุทัยธานี)', 'invoicing' ), |
|
| 1384 | - 'TH-53' => __( 'Uttaradit (อุตรดิตถ์)', 'invoicing' ), |
|
| 1385 | - 'TH-95' => __( 'Yala (ยะลา)', 'invoicing' ), |
|
| 1386 | - 'TH-35' => __( 'Yasothon (ยโสธร)', 'invoicing' ) |
|
| 1310 | + 'TH-37' => __('Amnat Charoen (อำนาจเจริญ)', 'invoicing'), |
|
| 1311 | + 'TH-15' => __('Ang Thong (อ่างทอง)', 'invoicing'), |
|
| 1312 | + 'TH-14' => __('Ayutthaya (พระนครศรีอยุธยา)', 'invoicing'), |
|
| 1313 | + 'TH-10' => __('Bangkok (กรุงเทพมหานคร)', 'invoicing'), |
|
| 1314 | + 'TH-38' => __('Bueng Kan (บึงกาฬ)', 'invoicing'), |
|
| 1315 | + 'TH-31' => __('Buri Ram (บุรีรัมย์)', 'invoicing'), |
|
| 1316 | + 'TH-24' => __('Chachoengsao (ฉะเชิงเทรา)', 'invoicing'), |
|
| 1317 | + 'TH-18' => __('Chai Nat (ชัยนาท)', 'invoicing'), |
|
| 1318 | + 'TH-36' => __('Chaiyaphum (ชัยภูมิ)', 'invoicing'), |
|
| 1319 | + 'TH-22' => __('Chanthaburi (จันทบุรี)', 'invoicing'), |
|
| 1320 | + 'TH-50' => __('Chiang Mai (เชียงใหม่)', 'invoicing'), |
|
| 1321 | + 'TH-57' => __('Chiang Rai (เชียงราย)', 'invoicing'), |
|
| 1322 | + 'TH-20' => __('Chonburi (ชลบุรี)', 'invoicing'), |
|
| 1323 | + 'TH-86' => __('Chumphon (ชุมพร)', 'invoicing'), |
|
| 1324 | + 'TH-46' => __('Kalasin (กาฬสินธุ์)', 'invoicing'), |
|
| 1325 | + 'TH-62' => __('Kamphaeng Phet (กำแพงเพชร)', 'invoicing'), |
|
| 1326 | + 'TH-71' => __('Kanchanaburi (กาญจนบุรี)', 'invoicing'), |
|
| 1327 | + 'TH-40' => __('Khon Kaen (ขอนแก่น)', 'invoicing'), |
|
| 1328 | + 'TH-81' => __('Krabi (กระบี่)', 'invoicing'), |
|
| 1329 | + 'TH-52' => __('Lampang (ลำปาง)', 'invoicing'), |
|
| 1330 | + 'TH-51' => __('Lamphun (ลำพูน)', 'invoicing'), |
|
| 1331 | + 'TH-42' => __('Loei (เลย)', 'invoicing'), |
|
| 1332 | + 'TH-16' => __('Lopburi (ลพบุรี)', 'invoicing'), |
|
| 1333 | + 'TH-58' => __('Mae Hong Son (แม่ฮ่องสอน)', 'invoicing'), |
|
| 1334 | + 'TH-44' => __('Maha Sarakham (มหาสารคาม)', 'invoicing'), |
|
| 1335 | + 'TH-49' => __('Mukdahan (มุกดาหาร)', 'invoicing'), |
|
| 1336 | + 'TH-26' => __('Nakhon Nayok (นครนายก)', 'invoicing'), |
|
| 1337 | + 'TH-73' => __('Nakhon Pathom (นครปฐม)', 'invoicing'), |
|
| 1338 | + 'TH-48' => __('Nakhon Phanom (นครพนม)', 'invoicing'), |
|
| 1339 | + 'TH-30' => __('Nakhon Ratchasima (นครราชสีมา)', 'invoicing'), |
|
| 1340 | + 'TH-60' => __('Nakhon Sawan (นครสวรรค์)', 'invoicing'), |
|
| 1341 | + 'TH-80' => __('Nakhon Si Thammarat (นครศรีธรรมราช)', 'invoicing'), |
|
| 1342 | + 'TH-55' => __('Nan (น่าน)', 'invoicing'), |
|
| 1343 | + 'TH-96' => __('Narathiwat (นราธิวาส)', 'invoicing'), |
|
| 1344 | + 'TH-39' => __('Nong Bua Lam Phu (หนองบัวลำภู)', 'invoicing'), |
|
| 1345 | + 'TH-43' => __('Nong Khai (หนองคาย)', 'invoicing'), |
|
| 1346 | + 'TH-12' => __('Nonthaburi (นนทบุรี)', 'invoicing'), |
|
| 1347 | + 'TH-13' => __('Pathum Thani (ปทุมธานี)', 'invoicing'), |
|
| 1348 | + 'TH-94' => __('Pattani (ปัตตานี)', 'invoicing'), |
|
| 1349 | + 'TH-82' => __('Phang Nga (พังงา)', 'invoicing'), |
|
| 1350 | + 'TH-93' => __('Phatthalung (พัทลุง)', 'invoicing'), |
|
| 1351 | + 'TH-56' => __('Phayao (พะเยา)', 'invoicing'), |
|
| 1352 | + 'TH-67' => __('Phetchabun (เพชรบูรณ์)', 'invoicing'), |
|
| 1353 | + 'TH-76' => __('Phetchaburi (เพชรบุรี)', 'invoicing'), |
|
| 1354 | + 'TH-66' => __('Phichit (พิจิตร)', 'invoicing'), |
|
| 1355 | + 'TH-65' => __('Phitsanulok (พิษณุโลก)', 'invoicing'), |
|
| 1356 | + 'TH-54' => __('Phrae (แพร่)', 'invoicing'), |
|
| 1357 | + 'TH-83' => __('Phuket (ภูเก็ต)', 'invoicing'), |
|
| 1358 | + 'TH-25' => __('Prachin Buri (ปราจีนบุรี)', 'invoicing'), |
|
| 1359 | + 'TH-77' => __('Prachuap Khiri Khan (ประจวบคีรีขันธ์)', 'invoicing'), |
|
| 1360 | + 'TH-85' => __('Ranong (ระนอง)', 'invoicing'), |
|
| 1361 | + 'TH-70' => __('Ratchaburi (ราชบุรี)', 'invoicing'), |
|
| 1362 | + 'TH-21' => __('Rayong (ระยอง)', 'invoicing'), |
|
| 1363 | + 'TH-45' => __('Roi Et (ร้อยเอ็ด)', 'invoicing'), |
|
| 1364 | + 'TH-27' => __('Sa Kaeo (สระแก้ว)', 'invoicing'), |
|
| 1365 | + 'TH-47' => __('Sakon Nakhon (สกลนคร)', 'invoicing'), |
|
| 1366 | + 'TH-11' => __('Samut Prakan (สมุทรปราการ)', 'invoicing'), |
|
| 1367 | + 'TH-74' => __('Samut Sakhon (สมุทรสาคร)', 'invoicing'), |
|
| 1368 | + 'TH-75' => __('Samut Songkhram (สมุทรสงคราม)', 'invoicing'), |
|
| 1369 | + 'TH-19' => __('Saraburi (สระบุรี)', 'invoicing'), |
|
| 1370 | + 'TH-91' => __('Satun (สตูล)', 'invoicing'), |
|
| 1371 | + 'TH-17' => __('Sing Buri (สิงห์บุรี)', 'invoicing'), |
|
| 1372 | + 'TH-33' => __('Sisaket (ศรีสะเกษ)', 'invoicing'), |
|
| 1373 | + 'TH-90' => __('Songkhla (สงขลา)', 'invoicing'), |
|
| 1374 | + 'TH-64' => __('Sukhothai (สุโขทัย)', 'invoicing'), |
|
| 1375 | + 'TH-72' => __('Suphan Buri (สุพรรณบุรี)', 'invoicing'), |
|
| 1376 | + 'TH-84' => __('Surat Thani (สุราษฎร์ธานี)', 'invoicing'), |
|
| 1377 | + 'TH-32' => __('Surin (สุรินทร์)', 'invoicing'), |
|
| 1378 | + 'TH-63' => __('Tak (ตาก)', 'invoicing'), |
|
| 1379 | + 'TH-92' => __('Trang (ตรัง)', 'invoicing'), |
|
| 1380 | + 'TH-23' => __('Trat (ตราด)', 'invoicing'), |
|
| 1381 | + 'TH-34' => __('Ubon Ratchathani (อุบลราชธานี)', 'invoicing'), |
|
| 1382 | + 'TH-41' => __('Udon Thani (อุดรธานี)', 'invoicing'), |
|
| 1383 | + 'TH-61' => __('Uthai Thani (อุทัยธานี)', 'invoicing'), |
|
| 1384 | + 'TH-53' => __('Uttaradit (อุตรดิตถ์)', 'invoicing'), |
|
| 1385 | + 'TH-95' => __('Yala (ยะลา)', 'invoicing'), |
|
| 1386 | + 'TH-35' => __('Yasothon (ยโสธร)', 'invoicing') |
|
| 1387 | 1387 | ); |
| 1388 | 1388 | |
| 1389 | - return apply_filters( 'wpinv_thailand_states', $states ); |
|
| 1389 | + return apply_filters('wpinv_thailand_states', $states); |
|
| 1390 | 1390 | } |
| 1391 | 1391 | |
| 1392 | 1392 | function wpinv_get_turkey_states_list() { |
| 1393 | 1393 | $states = array( |
| 1394 | - 'TR01' => __( 'Adana', 'invoicing' ), |
|
| 1395 | - 'TR02' => __( 'Adıyaman', 'invoicing' ), |
|
| 1396 | - 'TR03' => __( 'Afyon', 'invoicing' ), |
|
| 1397 | - 'TR04' => __( 'Ağrı', 'invoicing' ), |
|
| 1398 | - 'TR05' => __( 'Amasya', 'invoicing' ), |
|
| 1399 | - 'TR06' => __( 'Ankara', 'invoicing' ), |
|
| 1400 | - 'TR07' => __( 'Antalya', 'invoicing' ), |
|
| 1401 | - 'TR08' => __( 'Artvin', 'invoicing' ), |
|
| 1402 | - 'TR09' => __( 'Aydın', 'invoicing' ), |
|
| 1403 | - 'TR10' => __( 'Balıkesir', 'invoicing' ), |
|
| 1404 | - 'TR11' => __( 'Bilecik', 'invoicing' ), |
|
| 1405 | - 'TR12' => __( 'Bingöl', 'invoicing' ), |
|
| 1406 | - 'TR13' => __( 'Bitlis', 'invoicing' ), |
|
| 1407 | - 'TR14' => __( 'Bolu', 'invoicing' ), |
|
| 1408 | - 'TR15' => __( 'Burdur', 'invoicing' ), |
|
| 1409 | - 'TR16' => __( 'Bursa', 'invoicing' ), |
|
| 1410 | - 'TR17' => __( 'Çanakkale', 'invoicing' ), |
|
| 1411 | - 'TR18' => __( 'Çankıkesir', 'invoicing' ), |
|
| 1412 | - 'TR19' => __( 'Çorum', 'invoicing' ), |
|
| 1413 | - 'TR20' => __( 'Denizli', 'invoicing' ), |
|
| 1414 | - 'TR21' => __( 'Diyarbakır', 'invoicing' ), |
|
| 1415 | - 'TR22' => __( 'Edirne', 'invoicing' ), |
|
| 1416 | - 'TR23' => __( 'Elazığ', 'invoicing' ), |
|
| 1417 | - 'TR24' => __( 'Erzincan', 'invoicing' ), |
|
| 1418 | - 'TR25' => __( 'Erzurum', 'invoicing' ), |
|
| 1419 | - 'TR26' => __( 'Eskişehir', 'invoicing' ), |
|
| 1420 | - 'TR27' => __( 'Gaziantep', 'invoicing' ), |
|
| 1421 | - 'TR28' => __( 'Giresun', 'invoicing' ), |
|
| 1422 | - 'TR29' => __( 'Gümüşhane', 'invoicing' ), |
|
| 1423 | - 'TR30' => __( 'Hakkari', 'invoicing' ), |
|
| 1424 | - 'TR31' => __( 'Hatay', 'invoicing' ), |
|
| 1425 | - 'TR32' => __( 'Isparta', 'invoicing' ), |
|
| 1426 | - 'TR33' => __( 'İçel', 'invoicing' ), |
|
| 1427 | - 'TR34' => __( 'İstanbul', 'invoicing' ), |
|
| 1428 | - 'TR35' => __( 'İzmir', 'invoicing' ), |
|
| 1429 | - 'TR36' => __( 'Kars', 'invoicing' ), |
|
| 1430 | - 'TR37' => __( 'Kastamonu', 'invoicing' ), |
|
| 1431 | - 'TR38' => __( 'Kayseri', 'invoicing' ), |
|
| 1432 | - 'TR39' => __( 'Kırklareli', 'invoicing' ), |
|
| 1433 | - 'TR40' => __( 'Kırşehir', 'invoicing' ), |
|
| 1434 | - 'TR41' => __( 'Kocaeli', 'invoicing' ), |
|
| 1435 | - 'TR42' => __( 'Konya', 'invoicing' ), |
|
| 1436 | - 'TR43' => __( 'Kütahya', 'invoicing' ), |
|
| 1437 | - 'TR44' => __( 'Malatya', 'invoicing' ), |
|
| 1438 | - 'TR45' => __( 'Manisa', 'invoicing' ), |
|
| 1439 | - 'TR46' => __( 'Kahramanmaraş', 'invoicing' ), |
|
| 1440 | - 'TR47' => __( 'Mardin', 'invoicing' ), |
|
| 1441 | - 'TR48' => __( 'Muğla', 'invoicing' ), |
|
| 1442 | - 'TR49' => __( 'Muş', 'invoicing' ), |
|
| 1443 | - 'TR50' => __( 'Nevşehir', 'invoicing' ), |
|
| 1444 | - 'TR51' => __( 'Niğde', 'invoicing' ), |
|
| 1445 | - 'TR52' => __( 'Ordu', 'invoicing' ), |
|
| 1446 | - 'TR53' => __( 'Rize', 'invoicing' ), |
|
| 1447 | - 'TR54' => __( 'Sakarya', 'invoicing' ), |
|
| 1448 | - 'TR55' => __( 'Samsun', 'invoicing' ), |
|
| 1449 | - 'TR56' => __( 'Siirt', 'invoicing' ), |
|
| 1450 | - 'TR57' => __( 'Sinop', 'invoicing' ), |
|
| 1451 | - 'TR58' => __( 'Sivas', 'invoicing' ), |
|
| 1452 | - 'TR59' => __( 'Tekirdağ', 'invoicing' ), |
|
| 1453 | - 'TR60' => __( 'Tokat', 'invoicing' ), |
|
| 1454 | - 'TR61' => __( 'Trabzon', 'invoicing' ), |
|
| 1455 | - 'TR62' => __( 'Tunceli', 'invoicing' ), |
|
| 1456 | - 'TR63' => __( 'Şanlıurfa', 'invoicing' ), |
|
| 1457 | - 'TR64' => __( 'Uşak', 'invoicing' ), |
|
| 1458 | - 'TR65' => __( 'Van', 'invoicing' ), |
|
| 1459 | - 'TR66' => __( 'Yozgat', 'invoicing' ), |
|
| 1460 | - 'TR67' => __( 'Zonguldak', 'invoicing' ), |
|
| 1461 | - 'TR68' => __( 'Aksaray', 'invoicing' ), |
|
| 1462 | - 'TR69' => __( 'Bayburt', 'invoicing' ), |
|
| 1463 | - 'TR70' => __( 'Karaman', 'invoicing' ), |
|
| 1464 | - 'TR71' => __( 'Kırıkkale', 'invoicing' ), |
|
| 1465 | - 'TR72' => __( 'Batman', 'invoicing' ), |
|
| 1466 | - 'TR73' => __( 'Şırnak', 'invoicing' ), |
|
| 1467 | - 'TR74' => __( 'Bartın', 'invoicing' ), |
|
| 1468 | - 'TR75' => __( 'Ardahan', 'invoicing' ), |
|
| 1469 | - 'TR76' => __( 'Iğdır', 'invoicing' ), |
|
| 1470 | - 'TR77' => __( 'Yalova', 'invoicing' ), |
|
| 1471 | - 'TR78' => __( 'Karabük', 'invoicing' ), |
|
| 1472 | - 'TR79' => __( 'Kilis', 'invoicing' ), |
|
| 1473 | - 'TR80' => __( 'Osmaniye', 'invoicing' ), |
|
| 1474 | - 'TR81' => __( 'Düzce', 'invoicing' ) |
|
| 1394 | + 'TR01' => __('Adana', 'invoicing'), |
|
| 1395 | + 'TR02' => __('Adıyaman', 'invoicing'), |
|
| 1396 | + 'TR03' => __('Afyon', 'invoicing'), |
|
| 1397 | + 'TR04' => __('Ağrı', 'invoicing'), |
|
| 1398 | + 'TR05' => __('Amasya', 'invoicing'), |
|
| 1399 | + 'TR06' => __('Ankara', 'invoicing'), |
|
| 1400 | + 'TR07' => __('Antalya', 'invoicing'), |
|
| 1401 | + 'TR08' => __('Artvin', 'invoicing'), |
|
| 1402 | + 'TR09' => __('Aydın', 'invoicing'), |
|
| 1403 | + 'TR10' => __('Balıkesir', 'invoicing'), |
|
| 1404 | + 'TR11' => __('Bilecik', 'invoicing'), |
|
| 1405 | + 'TR12' => __('Bingöl', 'invoicing'), |
|
| 1406 | + 'TR13' => __('Bitlis', 'invoicing'), |
|
| 1407 | + 'TR14' => __('Bolu', 'invoicing'), |
|
| 1408 | + 'TR15' => __('Burdur', 'invoicing'), |
|
| 1409 | + 'TR16' => __('Bursa', 'invoicing'), |
|
| 1410 | + 'TR17' => __('Çanakkale', 'invoicing'), |
|
| 1411 | + 'TR18' => __('Çankıkesir', 'invoicing'), |
|
| 1412 | + 'TR19' => __('Çorum', 'invoicing'), |
|
| 1413 | + 'TR20' => __('Denizli', 'invoicing'), |
|
| 1414 | + 'TR21' => __('Diyarbakır', 'invoicing'), |
|
| 1415 | + 'TR22' => __('Edirne', 'invoicing'), |
|
| 1416 | + 'TR23' => __('Elazığ', 'invoicing'), |
|
| 1417 | + 'TR24' => __('Erzincan', 'invoicing'), |
|
| 1418 | + 'TR25' => __('Erzurum', 'invoicing'), |
|
| 1419 | + 'TR26' => __('Eskişehir', 'invoicing'), |
|
| 1420 | + 'TR27' => __('Gaziantep', 'invoicing'), |
|
| 1421 | + 'TR28' => __('Giresun', 'invoicing'), |
|
| 1422 | + 'TR29' => __('Gümüşhane', 'invoicing'), |
|
| 1423 | + 'TR30' => __('Hakkari', 'invoicing'), |
|
| 1424 | + 'TR31' => __('Hatay', 'invoicing'), |
|
| 1425 | + 'TR32' => __('Isparta', 'invoicing'), |
|
| 1426 | + 'TR33' => __('İçel', 'invoicing'), |
|
| 1427 | + 'TR34' => __('İstanbul', 'invoicing'), |
|
| 1428 | + 'TR35' => __('İzmir', 'invoicing'), |
|
| 1429 | + 'TR36' => __('Kars', 'invoicing'), |
|
| 1430 | + 'TR37' => __('Kastamonu', 'invoicing'), |
|
| 1431 | + 'TR38' => __('Kayseri', 'invoicing'), |
|
| 1432 | + 'TR39' => __('Kırklareli', 'invoicing'), |
|
| 1433 | + 'TR40' => __('Kırşehir', 'invoicing'), |
|
| 1434 | + 'TR41' => __('Kocaeli', 'invoicing'), |
|
| 1435 | + 'TR42' => __('Konya', 'invoicing'), |
|
| 1436 | + 'TR43' => __('Kütahya', 'invoicing'), |
|
| 1437 | + 'TR44' => __('Malatya', 'invoicing'), |
|
| 1438 | + 'TR45' => __('Manisa', 'invoicing'), |
|
| 1439 | + 'TR46' => __('Kahramanmaraş', 'invoicing'), |
|
| 1440 | + 'TR47' => __('Mardin', 'invoicing'), |
|
| 1441 | + 'TR48' => __('Muğla', 'invoicing'), |
|
| 1442 | + 'TR49' => __('Muş', 'invoicing'), |
|
| 1443 | + 'TR50' => __('Nevşehir', 'invoicing'), |
|
| 1444 | + 'TR51' => __('Niğde', 'invoicing'), |
|
| 1445 | + 'TR52' => __('Ordu', 'invoicing'), |
|
| 1446 | + 'TR53' => __('Rize', 'invoicing'), |
|
| 1447 | + 'TR54' => __('Sakarya', 'invoicing'), |
|
| 1448 | + 'TR55' => __('Samsun', 'invoicing'), |
|
| 1449 | + 'TR56' => __('Siirt', 'invoicing'), |
|
| 1450 | + 'TR57' => __('Sinop', 'invoicing'), |
|
| 1451 | + 'TR58' => __('Sivas', 'invoicing'), |
|
| 1452 | + 'TR59' => __('Tekirdağ', 'invoicing'), |
|
| 1453 | + 'TR60' => __('Tokat', 'invoicing'), |
|
| 1454 | + 'TR61' => __('Trabzon', 'invoicing'), |
|
| 1455 | + 'TR62' => __('Tunceli', 'invoicing'), |
|
| 1456 | + 'TR63' => __('Şanlıurfa', 'invoicing'), |
|
| 1457 | + 'TR64' => __('Uşak', 'invoicing'), |
|
| 1458 | + 'TR65' => __('Van', 'invoicing'), |
|
| 1459 | + 'TR66' => __('Yozgat', 'invoicing'), |
|
| 1460 | + 'TR67' => __('Zonguldak', 'invoicing'), |
|
| 1461 | + 'TR68' => __('Aksaray', 'invoicing'), |
|
| 1462 | + 'TR69' => __('Bayburt', 'invoicing'), |
|
| 1463 | + 'TR70' => __('Karaman', 'invoicing'), |
|
| 1464 | + 'TR71' => __('Kırıkkale', 'invoicing'), |
|
| 1465 | + 'TR72' => __('Batman', 'invoicing'), |
|
| 1466 | + 'TR73' => __('Şırnak', 'invoicing'), |
|
| 1467 | + 'TR74' => __('Bartın', 'invoicing'), |
|
| 1468 | + 'TR75' => __('Ardahan', 'invoicing'), |
|
| 1469 | + 'TR76' => __('Iğdır', 'invoicing'), |
|
| 1470 | + 'TR77' => __('Yalova', 'invoicing'), |
|
| 1471 | + 'TR78' => __('Karabük', 'invoicing'), |
|
| 1472 | + 'TR79' => __('Kilis', 'invoicing'), |
|
| 1473 | + 'TR80' => __('Osmaniye', 'invoicing'), |
|
| 1474 | + 'TR81' => __('Düzce', 'invoicing') |
|
| 1475 | 1475 | ); |
| 1476 | 1476 | |
| 1477 | - return apply_filters( 'wpinv_turkey_states', $states ); |
|
| 1477 | + return apply_filters('wpinv_turkey_states', $states); |
|
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | 1480 | function wpinv_get_spain_states_list() { |
| 1481 | 1481 | $states = array( |
| 1482 | - 'C' => __( 'A Coruña', 'invoicing' ), |
|
| 1483 | - 'VI' => __( 'Araba', 'invoicing' ), |
|
| 1484 | - 'AB' => __( 'Albacete', 'invoicing' ), |
|
| 1485 | - 'A' => __( 'Alicante', 'invoicing' ), |
|
| 1486 | - 'AL' => __( 'Almería', 'invoicing' ), |
|
| 1487 | - 'O' => __( 'Asturias', 'invoicing' ), |
|
| 1488 | - 'AV' => __( 'Ávila', 'invoicing' ), |
|
| 1489 | - 'BA' => __( 'Badajoz', 'invoicing' ), |
|
| 1490 | - 'PM' => __( 'Baleares', 'invoicing' ), |
|
| 1491 | - 'B' => __( 'Barcelona', 'invoicing' ), |
|
| 1492 | - 'BU' => __( 'Burgos', 'invoicing' ), |
|
| 1493 | - 'CC' => __( 'Cáceres', 'invoicing' ), |
|
| 1494 | - 'CA' => __( 'Cádiz', 'invoicing' ), |
|
| 1495 | - 'S' => __( 'Cantabria', 'invoicing' ), |
|
| 1496 | - 'CS' => __( 'Castellón', 'invoicing' ), |
|
| 1497 | - 'CE' => __( 'Ceuta', 'invoicing' ), |
|
| 1498 | - 'CR' => __( 'Ciudad Real', 'invoicing' ), |
|
| 1499 | - 'CO' => __( 'Córdoba', 'invoicing' ), |
|
| 1500 | - 'CU' => __( 'Cuenca', 'invoicing' ), |
|
| 1501 | - 'GI' => __( 'Girona', 'invoicing' ), |
|
| 1502 | - 'GR' => __( 'Granada', 'invoicing' ), |
|
| 1503 | - 'GU' => __( 'Guadalajara', 'invoicing' ), |
|
| 1504 | - 'SS' => __( 'Gipuzkoa', 'invoicing' ), |
|
| 1505 | - 'H' => __( 'Huelva', 'invoicing' ), |
|
| 1506 | - 'HU' => __( 'Huesca', 'invoicing' ), |
|
| 1507 | - 'J' => __( 'Jaén', 'invoicing' ), |
|
| 1508 | - 'LO' => __( 'La Rioja', 'invoicing' ), |
|
| 1509 | - 'GC' => __( 'Las Palmas', 'invoicing' ), |
|
| 1510 | - 'LE' => __( 'León', 'invoicing' ), |
|
| 1511 | - 'L' => __( 'Lleida', 'invoicing' ), |
|
| 1512 | - 'LU' => __( 'Lugo', 'invoicing' ), |
|
| 1513 | - 'M' => __( 'Madrid', 'invoicing' ), |
|
| 1514 | - 'MA' => __( 'Málaga', 'invoicing' ), |
|
| 1515 | - 'ML' => __( 'Melilla', 'invoicing' ), |
|
| 1516 | - 'MU' => __( 'Murcia', 'invoicing' ), |
|
| 1517 | - 'NA' => __( 'Navarra', 'invoicing' ), |
|
| 1518 | - 'OR' => __( 'Ourense', 'invoicing' ), |
|
| 1519 | - 'P' => __( 'Palencia', 'invoicing' ), |
|
| 1520 | - 'PO' => __( 'Pontevedra', 'invoicing' ), |
|
| 1521 | - 'SA' => __( 'Salamanca', 'invoicing' ), |
|
| 1522 | - 'TF' => __( 'Santa Cruz de Tenerife', 'invoicing' ), |
|
| 1523 | - 'SG' => __( 'Segovia', 'invoicing' ), |
|
| 1524 | - 'SE' => __( 'Sevilla', 'invoicing' ), |
|
| 1525 | - 'SO' => __( 'Soria', 'invoicing' ), |
|
| 1526 | - 'T' => __( 'Tarragona', 'invoicing' ), |
|
| 1527 | - 'TE' => __( 'Teruel', 'invoicing' ), |
|
| 1528 | - 'TO' => __( 'Toledo', 'invoicing' ), |
|
| 1529 | - 'V' => __( 'Valencia', 'invoicing' ), |
|
| 1530 | - 'VA' => __( 'Valladolid', 'invoicing' ), |
|
| 1531 | - 'BI' => __( 'Bizkaia', 'invoicing' ), |
|
| 1532 | - 'ZA' => __( 'Zamora', 'invoicing' ), |
|
| 1533 | - 'Z' => __( 'Zaragoza', 'invoicing' ) |
|
| 1482 | + 'C' => __('A Coruña', 'invoicing'), |
|
| 1483 | + 'VI' => __('Araba', 'invoicing'), |
|
| 1484 | + 'AB' => __('Albacete', 'invoicing'), |
|
| 1485 | + 'A' => __('Alicante', 'invoicing'), |
|
| 1486 | + 'AL' => __('Almería', 'invoicing'), |
|
| 1487 | + 'O' => __('Asturias', 'invoicing'), |
|
| 1488 | + 'AV' => __('Ávila', 'invoicing'), |
|
| 1489 | + 'BA' => __('Badajoz', 'invoicing'), |
|
| 1490 | + 'PM' => __('Baleares', 'invoicing'), |
|
| 1491 | + 'B' => __('Barcelona', 'invoicing'), |
|
| 1492 | + 'BU' => __('Burgos', 'invoicing'), |
|
| 1493 | + 'CC' => __('Cáceres', 'invoicing'), |
|
| 1494 | + 'CA' => __('Cádiz', 'invoicing'), |
|
| 1495 | + 'S' => __('Cantabria', 'invoicing'), |
|
| 1496 | + 'CS' => __('Castellón', 'invoicing'), |
|
| 1497 | + 'CE' => __('Ceuta', 'invoicing'), |
|
| 1498 | + 'CR' => __('Ciudad Real', 'invoicing'), |
|
| 1499 | + 'CO' => __('Córdoba', 'invoicing'), |
|
| 1500 | + 'CU' => __('Cuenca', 'invoicing'), |
|
| 1501 | + 'GI' => __('Girona', 'invoicing'), |
|
| 1502 | + 'GR' => __('Granada', 'invoicing'), |
|
| 1503 | + 'GU' => __('Guadalajara', 'invoicing'), |
|
| 1504 | + 'SS' => __('Gipuzkoa', 'invoicing'), |
|
| 1505 | + 'H' => __('Huelva', 'invoicing'), |
|
| 1506 | + 'HU' => __('Huesca', 'invoicing'), |
|
| 1507 | + 'J' => __('Jaén', 'invoicing'), |
|
| 1508 | + 'LO' => __('La Rioja', 'invoicing'), |
|
| 1509 | + 'GC' => __('Las Palmas', 'invoicing'), |
|
| 1510 | + 'LE' => __('León', 'invoicing'), |
|
| 1511 | + 'L' => __('Lleida', 'invoicing'), |
|
| 1512 | + 'LU' => __('Lugo', 'invoicing'), |
|
| 1513 | + 'M' => __('Madrid', 'invoicing'), |
|
| 1514 | + 'MA' => __('Málaga', 'invoicing'), |
|
| 1515 | + 'ML' => __('Melilla', 'invoicing'), |
|
| 1516 | + 'MU' => __('Murcia', 'invoicing'), |
|
| 1517 | + 'NA' => __('Navarra', 'invoicing'), |
|
| 1518 | + 'OR' => __('Ourense', 'invoicing'), |
|
| 1519 | + 'P' => __('Palencia', 'invoicing'), |
|
| 1520 | + 'PO' => __('Pontevedra', 'invoicing'), |
|
| 1521 | + 'SA' => __('Salamanca', 'invoicing'), |
|
| 1522 | + 'TF' => __('Santa Cruz de Tenerife', 'invoicing'), |
|
| 1523 | + 'SG' => __('Segovia', 'invoicing'), |
|
| 1524 | + 'SE' => __('Sevilla', 'invoicing'), |
|
| 1525 | + 'SO' => __('Soria', 'invoicing'), |
|
| 1526 | + 'T' => __('Tarragona', 'invoicing'), |
|
| 1527 | + 'TE' => __('Teruel', 'invoicing'), |
|
| 1528 | + 'TO' => __('Toledo', 'invoicing'), |
|
| 1529 | + 'V' => __('Valencia', 'invoicing'), |
|
| 1530 | + 'VA' => __('Valladolid', 'invoicing'), |
|
| 1531 | + 'BI' => __('Bizkaia', 'invoicing'), |
|
| 1532 | + 'ZA' => __('Zamora', 'invoicing'), |
|
| 1533 | + 'Z' => __('Zaragoza', 'invoicing') |
|
| 1534 | 1534 | ); |
| 1535 | 1535 | |
| 1536 | - return apply_filters( 'wpinv_spain_states', $states ); |
|
| 1536 | + return apply_filters('wpinv_spain_states', $states); |
|
| 1537 | 1537 | } |
| 1538 | 1538 | |
| 1539 | 1539 | function wpinv_get_states_field() { |
| 1540 | - if( empty( $_POST['country'] ) ) { |
|
| 1540 | + if (empty($_POST['country'])) { |
|
| 1541 | 1541 | $_POST['country'] = wpinv_get_default_country(); |
| 1542 | 1542 | } |
| 1543 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
| 1543 | + $states = wpinv_get_country_states(sanitize_text_field($_POST['country'])); |
|
| 1544 | 1544 | |
| 1545 | - if( !empty( $states ) ) { |
|
| 1546 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
| 1545 | + if (!empty($states)) { |
|
| 1546 | + $sanitized_field_name = sanitize_text_field($_POST['field_name']); |
|
| 1547 | 1547 | |
| 1548 | 1548 | $args = array( |
| 1549 | 1549 | 'name' => $sanitized_field_name, |
| 1550 | 1550 | 'id' => $sanitized_field_name, |
| 1551 | 1551 | 'class' => $sanitized_field_name . ' wpinv-select wpi_select2', |
| 1552 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1552 | + 'options' => array_merge(array('' => ''), $states), |
|
| 1553 | 1553 | 'show_option_all' => false, |
| 1554 | 1554 | 'show_option_none' => false |
| 1555 | 1555 | ); |
| 1556 | 1556 | |
| 1557 | - $response = wpinv_html_select( $args ); |
|
| 1557 | + $response = wpinv_html_select($args); |
|
| 1558 | 1558 | |
| 1559 | 1559 | } else { |
| 1560 | 1560 | $response = 'nostates'; |
@@ -1563,8 +1563,8 @@ discard block |
||
| 1563 | 1563 | return $response; |
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | -function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
|
| 1567 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
| 1566 | +function wpinv_default_billing_country($country = '', $user_id = 0) { |
|
| 1567 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
| 1568 | 1568 | |
| 1569 | - return apply_filters( 'wpinv_default_billing_country', $country, $user_id ); |
|
| 1569 | + return apply_filters('wpinv_default_billing_country', $country, $user_id); |
|
| 1570 | 1570 | } |
| 1571 | 1571 | \ No newline at end of file |
@@ -7,206 +7,206 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | function wpinv_get_payment_gateways() { |
| 15 | 15 | // Default, built-in gateways |
| 16 | 16 | $gateways = array( |
| 17 | 17 | 'paypal' => array( |
| 18 | - 'admin_label' => __( 'PayPal Standard', 'invoicing' ), |
|
| 19 | - 'checkout_label' => __( 'PayPal Standard', 'invoicing' ), |
|
| 18 | + 'admin_label' => __('PayPal Standard', 'invoicing'), |
|
| 19 | + 'checkout_label' => __('PayPal Standard', 'invoicing'), |
|
| 20 | 20 | 'ordering' => 1, |
| 21 | 21 | ), |
| 22 | 22 | 'authorizenet' => array( |
| 23 | - 'admin_label' => __( 'Authorize.Net (AIM)', 'invoicing' ), |
|
| 24 | - 'checkout_label' => __( 'Authorize.Net - Credit Card / Debit Card', 'invoicing' ), |
|
| 23 | + 'admin_label' => __('Authorize.Net (AIM)', 'invoicing'), |
|
| 24 | + 'checkout_label' => __('Authorize.Net - Credit Card / Debit Card', 'invoicing'), |
|
| 25 | 25 | 'ordering' => 4, |
| 26 | 26 | ), |
| 27 | 27 | 'worldpay' => array( |
| 28 | - 'admin_label' => __( 'Worldpay', 'invoicing' ), |
|
| 29 | - 'checkout_label' => __( 'Worldpay - Credit Card / Debit Card', 'invoicing' ), |
|
| 28 | + 'admin_label' => __('Worldpay', 'invoicing'), |
|
| 29 | + 'checkout_label' => __('Worldpay - Credit Card / Debit Card', 'invoicing'), |
|
| 30 | 30 | 'ordering' => 5, |
| 31 | 31 | ), |
| 32 | 32 | 'bank_transfer' => array( |
| 33 | - 'admin_label' => __( 'Pre Bank Transfer', 'invoicing' ), |
|
| 34 | - 'checkout_label' => __( 'Pre Bank Transfer', 'invoicing' ), |
|
| 33 | + 'admin_label' => __('Pre Bank Transfer', 'invoicing'), |
|
| 34 | + 'checkout_label' => __('Pre Bank Transfer', 'invoicing'), |
|
| 35 | 35 | 'ordering' => 11, |
| 36 | 36 | ), |
| 37 | 37 | 'manual' => array( |
| 38 | - 'admin_label' => __( 'Test Payment', 'invoicing' ), |
|
| 39 | - 'checkout_label' => __( 'Test Payment', 'invoicing' ), |
|
| 38 | + 'admin_label' => __('Test Payment', 'invoicing'), |
|
| 39 | + 'checkout_label' => __('Test Payment', 'invoicing'), |
|
| 40 | 40 | 'ordering' => 12, |
| 41 | 41 | ), |
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | - return apply_filters( 'wpinv_payment_gateways', $gateways ); |
|
| 44 | + return apply_filters('wpinv_payment_gateways', $gateways); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -function wpinv_payment_gateway_titles( $all_gateways ) { |
|
| 47 | +function wpinv_payment_gateway_titles($all_gateways) { |
|
| 48 | 48 | global $wpinv_options; |
| 49 | 49 | |
| 50 | 50 | $gateways = array(); |
| 51 | - foreach ( $all_gateways as $key => $gateway ) { |
|
| 52 | - if ( !empty( $wpinv_options[$key . '_title'] ) ) { |
|
| 53 | - $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' ); |
|
| 51 | + foreach ($all_gateways as $key => $gateway) { |
|
| 52 | + if (!empty($wpinv_options[$key . '_title'])) { |
|
| 53 | + $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing'); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' ); |
|
| 56 | + $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : ''); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - asort( $gateways ); |
|
| 59 | + asort($gateways); |
|
| 60 | 60 | |
| 61 | - foreach ( $gateways as $gateway => $key ) { |
|
| 61 | + foreach ($gateways as $gateway => $key) { |
|
| 62 | 62 | $gateways[$gateway] = $all_gateways[$gateway]; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | return $gateways; |
| 66 | 66 | } |
| 67 | -add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 ); |
|
| 67 | +add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1); |
|
| 68 | 68 | |
| 69 | -function wpinv_get_enabled_payment_gateways( $sort = false ) { |
|
| 69 | +function wpinv_get_enabled_payment_gateways($sort = false) { |
|
| 70 | 70 | $gateways = wpinv_get_payment_gateways(); |
| 71 | - $enabled = wpinv_get_option( 'gateways', false ); |
|
| 71 | + $enabled = wpinv_get_option('gateways', false); |
|
| 72 | 72 | |
| 73 | 73 | $gateway_list = array(); |
| 74 | 74 | |
| 75 | - foreach ( $gateways as $key => $gateway ) { |
|
| 76 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
| 77 | - $gateway_list[ $key ] = $gateway; |
|
| 75 | + foreach ($gateways as $key => $gateway) { |
|
| 76 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
| 77 | + $gateway_list[$key] = $gateway; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if ( true === $sort ) { |
|
| 82 | - uasort( $gateway_list, 'wpinv_sort_gateway_order' ); |
|
| 81 | + if (true === $sort) { |
|
| 82 | + uasort($gateway_list, 'wpinv_sort_gateway_order'); |
|
| 83 | 83 | |
| 84 | 84 | // Reorder our gateways so the default is first |
| 85 | 85 | $default_gateway_id = wpinv_get_default_gateway(); |
| 86 | 86 | |
| 87 | - if ( wpinv_is_gateway_active( $default_gateway_id ) ) { |
|
| 88 | - $default_gateway = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] ); |
|
| 89 | - unset( $gateway_list[ $default_gateway_id ] ); |
|
| 87 | + if (wpinv_is_gateway_active($default_gateway_id)) { |
|
| 88 | + $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]); |
|
| 89 | + unset($gateway_list[$default_gateway_id]); |
|
| 90 | 90 | |
| 91 | - $gateway_list = array_merge( $default_gateway, $gateway_list ); |
|
| 91 | + $gateway_list = array_merge($default_gateway, $gateway_list); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list ); |
|
| 95 | + return apply_filters('wpinv_enabled_payment_gateways', $gateway_list); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | -function wpinv_sort_gateway_order( $a, $b ) { |
|
| 98 | +function wpinv_sort_gateway_order($a, $b) { |
|
| 99 | 99 | return $a['ordering'] - $b['ordering']; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | -function wpinv_is_gateway_active( $gateway ) { |
|
| 102 | +function wpinv_is_gateway_active($gateway) { |
|
| 103 | 103 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 104 | 104 | |
| 105 | - $ret = is_array($gateways) && $gateway ? array_key_exists( $gateway, $gateways ) : false; |
|
| 105 | + $ret = is_array($gateways) && $gateway ? array_key_exists($gateway, $gateways) : false; |
|
| 106 | 106 | |
| 107 | - return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways ); |
|
| 107 | + return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | function wpinv_get_default_gateway() { |
| 111 | - $default = wpinv_get_option( 'default_gateway', 'paypal' ); |
|
| 111 | + $default = wpinv_get_option('default_gateway', 'paypal'); |
|
| 112 | 112 | |
| 113 | - if ( !wpinv_is_gateway_active( $default ) ) { |
|
| 113 | + if (!wpinv_is_gateway_active($default)) { |
|
| 114 | 114 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 115 | - $gateways = array_keys( $gateways ); |
|
| 116 | - $default = reset( $gateways ); |
|
| 115 | + $gateways = array_keys($gateways); |
|
| 116 | + $default = reset($gateways); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - return apply_filters( 'wpinv_default_gateway', $default ); |
|
| 119 | + return apply_filters('wpinv_default_gateway', $default); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | -function wpinv_get_gateway_admin_label( $gateway ) { |
|
| 122 | +function wpinv_get_gateway_admin_label($gateway) { |
|
| 123 | 123 | $gateways = wpinv_get_payment_gateways(); |
| 124 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
| 125 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
| 124 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
| 125 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
| 126 | 126 | |
| 127 | - if( $gateway == 'manual' && $payment ) { |
|
| 128 | - if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) { |
|
| 129 | - $label = __( 'Free Purchase', 'invoicing' ); |
|
| 127 | + if ($gateway == 'manual' && $payment) { |
|
| 128 | + if (!((float)wpinv_payment_total($payment) > 0)) { |
|
| 129 | + $label = __('Free Purchase', 'invoicing'); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway ); |
|
| 133 | + return apply_filters('wpinv_gateway_admin_label', $label, $gateway); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | -function wpinv_get_gateway_description( $gateway ) { |
|
| 136 | +function wpinv_get_gateway_description($gateway) { |
|
| 137 | 137 | global $wpinv_options; |
| 138 | 138 | |
| 139 | - $description = isset( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
| 139 | + $description = isset($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
| 140 | 140 | |
| 141 | - return apply_filters( 'wpinv_gateway_description', $description, $gateway ); |
|
| 141 | + return apply_filters('wpinv_gateway_description', $description, $gateway); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | -function wpinv_get_gateway_button_label( $gateway ) { |
|
| 145 | - return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' ); |
|
| 144 | +function wpinv_get_gateway_button_label($gateway) { |
|
| 145 | + return apply_filters('wpinv_gateway_' . $gateway . '_button_label', ''); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | -function wpinv_get_gateway_checkout_label( $gateway ) { |
|
| 148 | +function wpinv_get_gateway_checkout_label($gateway) { |
|
| 149 | 149 | $gateways = wpinv_get_payment_gateways(); |
| 150 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
| 150 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
| 151 | 151 | |
| 152 | - if( $gateway == 'manual' ) { |
|
| 153 | - $label = __( 'Manual Payment', 'invoicing' ); |
|
| 152 | + if ($gateway == 'manual') { |
|
| 153 | + $label = __('Manual Payment', 'invoicing'); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - return apply_filters( 'wpinv_gateway_checkout_label', $label, $gateway ); |
|
| 156 | + return apply_filters('wpinv_gateway_checkout_label', $label, $gateway); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | -function wpinv_settings_sections_gateways( $settings ) { |
|
| 159 | +function wpinv_settings_sections_gateways($settings) { |
|
| 160 | 160 | $gateways = wpinv_get_payment_gateways(); |
| 161 | 161 | |
| 162 | 162 | if (!empty($gateways)) { |
| 163 | - foreach ($gateways as $key => $gateway) { |
|
| 163 | + foreach ($gateways as $key => $gateway) { |
|
| 164 | 164 | $settings[$key] = $gateway['admin_label']; |
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | return $settings; |
| 169 | 169 | } |
| 170 | -add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 ); |
|
| 170 | +add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1); |
|
| 171 | 171 | |
| 172 | -function wpinv_settings_gateways( $settings ) { |
|
| 172 | +function wpinv_settings_gateways($settings) { |
|
| 173 | 173 | $gateways = wpinv_get_payment_gateways(); |
| 174 | 174 | |
| 175 | 175 | if (!empty($gateways)) { |
| 176 | - foreach ($gateways as $key => $gateway) { |
|
| 176 | + foreach ($gateways as $key => $gateway) { |
|
| 177 | 177 | $setting = array(); |
| 178 | 178 | $setting[$key . '_header'] = array( |
| 179 | 179 | 'id' => 'gateway_header', |
| 180 | - 'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>', |
|
| 180 | + 'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>', |
|
| 181 | 181 | 'custom' => $key, |
| 182 | 182 | 'type' => 'gateway_header', |
| 183 | 183 | ); |
| 184 | 184 | $setting[$key . '_active'] = array( |
| 185 | 185 | 'id' => $key . '_active', |
| 186 | - 'name' => __( 'Active', 'invoicing' ), |
|
| 187 | - 'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ), |
|
| 186 | + 'name' => __('Active', 'invoicing'), |
|
| 187 | + 'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']), |
|
| 188 | 188 | 'type' => 'checkbox', |
| 189 | 189 | ); |
| 190 | 190 | |
| 191 | 191 | $setting[$key . '_title'] = array( |
| 192 | 192 | 'id' => $key . '_title', |
| 193 | - 'name' => __( 'Title', 'invoicing' ), |
|
| 194 | - 'desc' => __( 'This controls the title which the user sees during checkout.', 'invoicing' ), |
|
| 193 | + 'name' => __('Title', 'invoicing'), |
|
| 194 | + 'desc' => __('This controls the title which the user sees during checkout.', 'invoicing'), |
|
| 195 | 195 | 'type' => 'text', |
| 196 | 196 | 'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '' |
| 197 | 197 | ); |
| 198 | 198 | |
| 199 | 199 | $setting[$key . '_desc'] = array( |
| 200 | 200 | 'id' => $key . '_desc', |
| 201 | - 'name' => __( 'Description', 'invoicing' ), |
|
| 202 | - 'desc' => __( 'This controls the description which the user sees during checkout.', 'invoicing' ), |
|
| 201 | + 'name' => __('Description', 'invoicing'), |
|
| 202 | + 'desc' => __('This controls the description which the user sees during checkout.', 'invoicing'), |
|
| 203 | 203 | 'type' => 'text', |
| 204 | 204 | 'size' => 'large' |
| 205 | 205 | ); |
| 206 | 206 | |
| 207 | 207 | $setting[$key . '_ordering'] = array( |
| 208 | 208 | 'id' => $key . '_ordering', |
| 209 | - 'name' => __( 'Display Order', 'invoicing' ), |
|
| 209 | + 'name' => __('Display Order', 'invoicing'), |
|
| 210 | 210 | 'type' => 'number', |
| 211 | 211 | 'size' => 'small', |
| 212 | 212 | 'std' => isset($gateway['ordering']) ? $gateway['ordering'] : '10', |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | 'step' => '1' |
| 216 | 216 | ); |
| 217 | 217 | |
| 218 | - $setting = apply_filters( 'wpinv_gateway_settings', $setting, $key ); |
|
| 219 | - $setting = apply_filters( 'wpinv_gateway_settings_' . $key, $setting ); |
|
| 218 | + $setting = apply_filters('wpinv_gateway_settings', $setting, $key); |
|
| 219 | + $setting = apply_filters('wpinv_gateway_settings_' . $key, $setting); |
|
| 220 | 220 | |
| 221 | 221 | $settings[$key] = $setting; |
| 222 | 222 | } |
@@ -224,106 +224,106 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | return $settings; |
| 226 | 226 | } |
| 227 | -add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 ); |
|
| 227 | +add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1); |
|
| 228 | 228 | |
| 229 | -function wpinv_gateway_header_callback( $args ) { |
|
| 230 | - echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />'; |
|
| 229 | +function wpinv_gateway_header_callback($args) { |
|
| 230 | + echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />'; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | -function wpinv_get_gateway_supports( $gateway ) { |
|
| 233 | +function wpinv_get_gateway_supports($gateway) { |
|
| 234 | 234 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 235 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
| 236 | - return apply_filters( 'wpinv_gateway_supports', $supports, $gateway ); |
|
| 235 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
| 236 | + return apply_filters('wpinv_gateway_supports', $supports, $gateway); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | -function wpinv_gateway_supports_buy_now( $gateway ) { |
|
| 240 | - $supports = wpinv_get_gateway_supports( $gateway ); |
|
| 241 | - $ret = in_array( 'buy_now', $supports ); |
|
| 242 | - return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway ); |
|
| 239 | +function wpinv_gateway_supports_buy_now($gateway) { |
|
| 240 | + $supports = wpinv_get_gateway_supports($gateway); |
|
| 241 | + $ret = in_array('buy_now', $supports); |
|
| 242 | + return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | function wpinv_shop_supports_buy_now() { |
| 246 | 246 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 247 | 247 | $ret = false; |
| 248 | 248 | |
| 249 | - if ( !wpinv_use_taxes() && $gateways ) { |
|
| 250 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 251 | - if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) { |
|
| 249 | + if (!wpinv_use_taxes() && $gateways) { |
|
| 250 | + foreach ($gateways as $gateway_id => $gateway) { |
|
| 251 | + if (wpinv_gateway_supports_buy_now($gateway_id)) { |
|
| 252 | 252 | $ret = true; |
| 253 | 253 | break; |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - return apply_filters( 'wpinv_shop_supports_buy_now', $ret ); |
|
| 258 | + return apply_filters('wpinv_shop_supports_buy_now', $ret); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | -function wpinv_send_to_gateway( $gateway, $payment_data ) { |
|
| 262 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'wpi-gateway' ); |
|
| 261 | +function wpinv_send_to_gateway($gateway, $payment_data) { |
|
| 262 | + $payment_data['gateway_nonce'] = wp_create_nonce('wpi-gateway'); |
|
| 263 | 263 | |
| 264 | 264 | // $gateway must match the ID used when registering the gateway |
| 265 | - do_action( 'wpinv_gateway_' . $gateway, $payment_data ); |
|
| 265 | + do_action('wpinv_gateway_' . $gateway, $payment_data); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | function wpinv_show_gateways() { |
| 269 | 269 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 270 | 270 | $show_gateways = false; |
| 271 | 271 | |
| 272 | - $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false; |
|
| 272 | + $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false; |
|
| 273 | 273 | |
| 274 | - if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) { |
|
| 274 | + if (count($gateways) > 1 && empty($chosen_gateway)) { |
|
| 275 | 275 | $show_gateways = true; |
| 276 | - if ( wpinv_get_cart_total() <= 0 ) { |
|
| 276 | + if (wpinv_get_cart_total() <= 0) { |
|
| 277 | 277 | $show_gateways = false; |
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - if ( !$show_gateways && wpinv_cart_has_recurring_item() ) { |
|
| 281 | + if (!$show_gateways && wpinv_cart_has_recurring_item()) { |
|
| 282 | 282 | $show_gateways = true; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - return apply_filters( 'wpinv_show_gateways', $show_gateways ); |
|
| 285 | + return apply_filters('wpinv_show_gateways', $show_gateways); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
| 289 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 288 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
| 289 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
| 290 | 290 | |
| 291 | 291 | $chosen = false; |
| 292 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
| 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 ); |
|
| 298 | + if (false !== $chosen) { |
|
| 299 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - if ( ! empty ( $chosen ) ) { |
|
| 303 | - $enabled_gateway = urldecode( $chosen ); |
|
| 304 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
| 302 | + if (!empty ($chosen)) { |
|
| 303 | + $enabled_gateway = urldecode($chosen); |
|
| 304 | + } else if (!empty($invoice) && (float)$invoice->get_subtotal() <= 0) { |
|
| 305 | 305 | $enabled_gateway = 'manual'; |
| 306 | 306 | } else { |
| 307 | 307 | $enabled_gateway = wpinv_get_default_gateway(); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
|
| 311 | - if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
|
| 310 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
| 311 | + if (wpinv_is_gateway_active(wpinv_get_default_gateway())) { |
|
| 312 | 312 | $enabled_gateway = wpinv_get_default_gateway(); |
| 313 | - }else{ |
|
| 313 | + } else { |
|
| 314 | 314 | $enabled_gateway = $gateways[0]; |
| 315 | 315 | } |
| 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 | -function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
| 323 | - return wpinv_error_log( $message, $title ); |
|
| 322 | +function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
| 323 | + return wpinv_error_log($message, $title); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
| 326 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
| 327 | 327 | $ret = 0; |
| 328 | 328 | $args = array( |
| 329 | 329 | 'meta_key' => '_wpinv_gateway', |
@@ -334,48 +334,48 @@ discard block |
||
| 334 | 334 | 'fields' => 'ids' |
| 335 | 335 | ); |
| 336 | 336 | |
| 337 | - $payments = new WP_Query( $args ); |
|
| 337 | + $payments = new WP_Query($args); |
|
| 338 | 338 | |
| 339 | - if( $payments ) |
|
| 339 | + if ($payments) |
|
| 340 | 340 | $ret = $payments->post_count; |
| 341 | 341 | return $ret; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | -function wpinv_settings_update_gateways( $input ) { |
|
| 344 | +function wpinv_settings_update_gateways($input) { |
|
| 345 | 345 | global $wpinv_options; |
| 346 | 346 | |
| 347 | - if ( !empty( $input['save_gateway'] ) ) { |
|
| 348 | - $gateways = wpinv_get_option( 'gateways', false ); |
|
| 347 | + if (!empty($input['save_gateway'])) { |
|
| 348 | + $gateways = wpinv_get_option('gateways', false); |
|
| 349 | 349 | $gateways = !empty($gateways) ? $gateways : array(); |
| 350 | 350 | $gateway = $input['save_gateway']; |
| 351 | 351 | |
| 352 | - if ( !empty( $input[$gateway . '_active'] ) ) { |
|
| 352 | + if (!empty($input[$gateway . '_active'])) { |
|
| 353 | 353 | $gateways[$gateway] = 1; |
| 354 | 354 | } else { |
| 355 | - if ( isset( $gateways[$gateway] ) ) { |
|
| 356 | - unset( $gateways[$gateway] ); |
|
| 355 | + if (isset($gateways[$gateway])) { |
|
| 356 | + unset($gateways[$gateway]); |
|
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | $input['gateways'] = $gateways; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - if ( !empty( $input['default_gateway'] ) ) { |
|
| 363 | + if (!empty($input['default_gateway'])) { |
|
| 364 | 364 | $gateways = wpinv_get_payment_gateways(); |
| 365 | 365 | |
| 366 | - foreach ( $gateways as $key => $gateway ) { |
|
| 367 | - $active = 0; |
|
| 368 | - if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) { |
|
| 366 | + foreach ($gateways as $key => $gateway) { |
|
| 367 | + $active = 0; |
|
| 368 | + if (!empty($input['gateways']) && !empty($input['gateways'][$key])) { |
|
| 369 | 369 | $active = 1; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | $input[$key . '_active'] = $active; |
| 373 | 373 | |
| 374 | - if ( empty( $wpinv_options[$key . '_title'] ) ) { |
|
| 374 | + if (empty($wpinv_options[$key . '_title'])) { |
|
| 375 | 375 | $input[$key . '_title'] = $gateway['checkout_label']; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) { |
|
| 378 | + if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) { |
|
| 379 | 379 | $input[$key . '_ordering'] = $gateway['ordering']; |
| 380 | 380 | } |
| 381 | 381 | } |
@@ -383,27 +383,27 @@ discard block |
||
| 383 | 383 | |
| 384 | 384 | return $input; |
| 385 | 385 | } |
| 386 | -add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 ); |
|
| 386 | +add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1); |
|
| 387 | 387 | |
| 388 | 388 | // PayPal Standard settings |
| 389 | -function wpinv_gateway_settings_paypal( $setting ) { |
|
| 390 | - $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' ); |
|
| 391 | - $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' ); |
|
| 389 | +function wpinv_gateway_settings_paypal($setting) { |
|
| 390 | + $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing'); |
|
| 391 | + $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing'); |
|
| 392 | 392 | |
| 393 | 393 | $setting['paypal_sandbox'] = array( |
| 394 | 394 | 'type' => 'checkbox', |
| 395 | 395 | 'id' => 'paypal_sandbox', |
| 396 | - 'name' => __( 'PayPal Sandbox', 'invoicing' ), |
|
| 397 | - 'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ), |
|
| 396 | + 'name' => __('PayPal Sandbox', 'invoicing'), |
|
| 397 | + 'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'), |
|
| 398 | 398 | 'std' => 1 |
| 399 | 399 | ); |
| 400 | 400 | |
| 401 | 401 | $setting['paypal_email'] = array( |
| 402 | 402 | 'type' => 'text', |
| 403 | 403 | 'id' => 'paypal_email', |
| 404 | - 'name' => __( 'PayPal Email', 'invoicing' ), |
|
| 405 | - 'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ), |
|
| 406 | - 'std' => __( '[email protected]', 'invoicing' ), |
|
| 404 | + 'name' => __('PayPal Email', 'invoicing'), |
|
| 405 | + 'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'), |
|
| 406 | + 'std' => __('[email protected]', 'invoicing'), |
|
| 407 | 407 | ); |
| 408 | 408 | /* |
| 409 | 409 | $setting['paypal_ipn_url'] = array( |
@@ -417,139 +417,139 @@ discard block |
||
| 417 | 417 | |
| 418 | 418 | return $setting; |
| 419 | 419 | } |
| 420 | -add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 ); |
|
| 420 | +add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1); |
|
| 421 | 421 | |
| 422 | 422 | // Pre Bank Transfer settings |
| 423 | -function wpinv_gateway_settings_bank_transfer( $setting ) { |
|
| 424 | - $setting['bank_transfer_desc']['std'] = __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' ); |
|
| 423 | +function wpinv_gateway_settings_bank_transfer($setting) { |
|
| 424 | + $setting['bank_transfer_desc']['std'] = __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing'); |
|
| 425 | 425 | |
| 426 | 426 | $setting['bank_transfer_ac_name'] = array( |
| 427 | 427 | 'type' => 'text', |
| 428 | 428 | 'id' => 'bank_transfer_ac_name', |
| 429 | - 'name' => __( 'Account Name', 'invoicing' ), |
|
| 430 | - 'desc' => __( 'Enter the bank account name to which you want to transfer payment.', 'invoicing' ), |
|
| 431 | - 'std' => __( 'Mr. John Martin', 'invoicing' ), |
|
| 429 | + 'name' => __('Account Name', 'invoicing'), |
|
| 430 | + 'desc' => __('Enter the bank account name to which you want to transfer payment.', 'invoicing'), |
|
| 431 | + 'std' => __('Mr. John Martin', 'invoicing'), |
|
| 432 | 432 | ); |
| 433 | 433 | |
| 434 | 434 | $setting['bank_transfer_ac_no'] = array( |
| 435 | 435 | 'type' => 'text', |
| 436 | 436 | 'id' => 'bank_transfer_ac_no', |
| 437 | - 'name' => __( 'Account Number', 'invoicing' ), |
|
| 438 | - 'desc' => __( 'Enter your bank account number.', 'invoicing' ), |
|
| 439 | - 'std' => __( 'TEST1234567890', 'invoicing' ), |
|
| 437 | + 'name' => __('Account Number', 'invoicing'), |
|
| 438 | + 'desc' => __('Enter your bank account number.', 'invoicing'), |
|
| 439 | + 'std' => __('TEST1234567890', 'invoicing'), |
|
| 440 | 440 | ); |
| 441 | 441 | |
| 442 | 442 | $setting['bank_transfer_bank_name'] = array( |
| 443 | 443 | 'type' => 'text', |
| 444 | 444 | 'id' => 'bank_transfer_bank_name', |
| 445 | - 'name' => __( 'Bank Name', 'invoicing' ), |
|
| 446 | - 'desc' => __( 'Enter the bank name to which you want to transfer payment.', 'invoicing' ), |
|
| 447 | - 'std' => __( 'ICICI Bank', 'invoicing' ), |
|
| 445 | + 'name' => __('Bank Name', 'invoicing'), |
|
| 446 | + 'desc' => __('Enter the bank name to which you want to transfer payment.', 'invoicing'), |
|
| 447 | + 'std' => __('ICICI Bank', 'invoicing'), |
|
| 448 | 448 | ); |
| 449 | 449 | |
| 450 | 450 | $setting['bank_transfer_ifsc'] = array( |
| 451 | 451 | 'type' => 'text', |
| 452 | 452 | 'id' => 'bank_transfer_ifsc', |
| 453 | - 'name' => __( 'IFSC Code', 'invoicing' ), |
|
| 454 | - 'desc' => __( 'Enter your bank IFSC code.', 'invoicing' ), |
|
| 455 | - 'std' => __( 'ICIC0001234', 'invoicing' ), |
|
| 453 | + 'name' => __('IFSC Code', 'invoicing'), |
|
| 454 | + 'desc' => __('Enter your bank IFSC code.', 'invoicing'), |
|
| 455 | + 'std' => __('ICIC0001234', 'invoicing'), |
|
| 456 | 456 | ); |
| 457 | 457 | |
| 458 | 458 | $setting['bank_transfer_iban'] = array( |
| 459 | 459 | 'type' => 'text', |
| 460 | 460 | 'id' => 'bank_transfer_iban', |
| 461 | - 'name' => __( 'IBAN', 'invoicing' ), |
|
| 462 | - 'desc' => __( 'Enter your International Bank Account Number(IBAN).', 'invoicing' ), |
|
| 463 | - 'std' => __( 'GB29NWBK60161331926819', 'invoicing' ), |
|
| 461 | + 'name' => __('IBAN', 'invoicing'), |
|
| 462 | + 'desc' => __('Enter your International Bank Account Number(IBAN).', 'invoicing'), |
|
| 463 | + 'std' => __('GB29NWBK60161331926819', 'invoicing'), |
|
| 464 | 464 | ); |
| 465 | 465 | |
| 466 | 466 | $setting['bank_transfer_bic'] = array( |
| 467 | 467 | 'type' => 'text', |
| 468 | 468 | 'id' => 'bank_transfer_bic', |
| 469 | - 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
|
| 470 | - 'std' => __( 'ICICGB2L129', 'invoicing' ), |
|
| 469 | + 'name' => __('BIC/Swift Code', 'invoicing'), |
|
| 470 | + 'std' => __('ICICGB2L129', 'invoicing'), |
|
| 471 | 471 | ); |
| 472 | 472 | |
| 473 | 473 | $setting['bank_transfer_sort_code'] = array( |
| 474 | 474 | 'type' => 'text', |
| 475 | 475 | 'id' => 'bank_transfer_sort_code', |
| 476 | - 'name' => __( 'Sort Code', 'invoicing' ), |
|
| 477 | - 'std' => __( '12-34-56', 'invoicing' ), |
|
| 476 | + 'name' => __('Sort Code', 'invoicing'), |
|
| 477 | + 'std' => __('12-34-56', 'invoicing'), |
|
| 478 | 478 | ); |
| 479 | 479 | |
| 480 | 480 | $setting['bank_transfer_info'] = array( |
| 481 | 481 | 'id' => 'bank_transfer_info', |
| 482 | - 'name' => __( 'Instructions', 'invoicing' ), |
|
| 483 | - 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
|
| 482 | + 'name' => __('Instructions', 'invoicing'), |
|
| 483 | + 'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'), |
|
| 484 | 484 | 'type' => 'textarea', |
| 485 | - 'std' => __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' ), |
|
| 485 | + 'std' => __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing'), |
|
| 486 | 486 | 'cols' => 37, |
| 487 | 487 | 'rows' => 5 |
| 488 | 488 | ); |
| 489 | 489 | |
| 490 | 490 | return $setting; |
| 491 | 491 | } |
| 492 | -add_filter( 'wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1 ); |
|
| 492 | +add_filter('wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1); |
|
| 493 | 493 | |
| 494 | 494 | // Authorize.Net settings |
| 495 | -function wpinv_gateway_settings_authorizenet( $setting ) { |
|
| 496 | - $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing' ); |
|
| 497 | - $setting['authorizenet_desc']['std'] = __( 'Pay using a Authorize.Net to process Credit card / Debit card transactions.', 'invoicing' ); |
|
| 495 | +function wpinv_gateway_settings_authorizenet($setting) { |
|
| 496 | + $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __('( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing'); |
|
| 497 | + $setting['authorizenet_desc']['std'] = __('Pay using a Authorize.Net to process Credit card / Debit card transactions.', 'invoicing'); |
|
| 498 | 498 | |
| 499 | 499 | $setting['authorizenet_sandbox'] = array( |
| 500 | 500 | 'type' => 'checkbox', |
| 501 | 501 | 'id' => 'authorizenet_sandbox', |
| 502 | - 'name' => __( 'Authorize.Net Test Mode', 'invoicing' ), |
|
| 503 | - 'desc' => __( 'Enable Authorize.Net test mode to test payments.', 'invoicing' ), |
|
| 502 | + 'name' => __('Authorize.Net Test Mode', 'invoicing'), |
|
| 503 | + 'desc' => __('Enable Authorize.Net test mode to test payments.', 'invoicing'), |
|
| 504 | 504 | 'std' => 1 |
| 505 | 505 | ); |
| 506 | 506 | |
| 507 | 507 | $setting['authorizenet_login_id'] = array( |
| 508 | 508 | 'type' => 'text', |
| 509 | 509 | 'id' => 'authorizenet_login_id', |
| 510 | - 'name' => __( 'API Login ID', 'invoicing' ), |
|
| 511 | - 'desc' => __( 'API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing' ), |
|
| 510 | + 'name' => __('API Login ID', 'invoicing'), |
|
| 511 | + 'desc' => __('API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing'), |
|
| 512 | 512 | 'std' => '2j4rBekUnD', |
| 513 | 513 | ); |
| 514 | 514 | |
| 515 | 515 | $setting['authorizenet_transaction_key'] = array( |
| 516 | 516 | 'type' => 'text', |
| 517 | 517 | 'id' => 'authorizenet_transaction_key', |
| 518 | - 'name' => __( 'Transaction Key', 'invoicing' ), |
|
| 519 | - 'desc' => __( 'Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing' ), |
|
| 518 | + 'name' => __('Transaction Key', 'invoicing'), |
|
| 519 | + 'desc' => __('Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing'), |
|
| 520 | 520 | 'std' => '4vyBUOJgR74679xa', |
| 521 | 521 | ); |
| 522 | 522 | |
| 523 | 523 | $setting['authorizenet_md5_hash'] = array( |
| 524 | 524 | 'type' => 'text', |
| 525 | 525 | 'id' => 'authorizenet_md5_hash', |
| 526 | - 'name' => __( 'MD5-Hash', 'invoicing' ), |
|
| 527 | - 'desc' => __( 'The MD5 Hash security feature allows to authenticate transaction responses from the Authorize.Net for recurring payments. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing' ), |
|
| 526 | + 'name' => __('MD5-Hash', 'invoicing'), |
|
| 527 | + 'desc' => __('The MD5 Hash security feature allows to authenticate transaction responses from the Authorize.Net for recurring payments. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing'), |
|
| 528 | 528 | 'std' => '', |
| 529 | 529 | ); |
| 530 | 530 | |
| 531 | 531 | $setting['authorizenet_transaction_type'] = array( |
| 532 | 532 | 'id' => 'authorizenet_transaction_type', |
| 533 | - 'name' => __( 'Transaction Type', 'invoicing' ), |
|
| 534 | - 'desc' => __( 'Choose transaction type.', 'invoicing' ), |
|
| 533 | + 'name' => __('Transaction Type', 'invoicing'), |
|
| 534 | + 'desc' => __('Choose transaction type.', 'invoicing'), |
|
| 535 | 535 | 'type' => 'select', |
| 536 | 536 | 'class' => 'wpi_select2', |
| 537 | 537 | 'options' => array( |
| 538 | - 'authorize_capture' => __( 'Authorize And Capture', 'invoicing' ), |
|
| 539 | - 'authorize_only' => __( 'Authorize Only', 'invoicing' ), |
|
| 538 | + 'authorize_capture' => __('Authorize And Capture', 'invoicing'), |
|
| 539 | + 'authorize_only' => __('Authorize Only', 'invoicing'), |
|
| 540 | 540 | ), |
| 541 | 541 | 'std' => 'authorize_capture' |
| 542 | 542 | ); |
| 543 | 543 | |
| 544 | 544 | $setting['authorizenet_transaction_type_recurring'] = array( |
| 545 | 545 | 'id' => 'authorizenet_transaction_type_recurring', |
| 546 | - 'name' => __( 'Transaction Type for Recurring', 'invoicing' ), |
|
| 547 | - 'desc' => __( 'Choose transaction type for recurring payments.', 'invoicing' ), |
|
| 546 | + 'name' => __('Transaction Type for Recurring', 'invoicing'), |
|
| 547 | + 'desc' => __('Choose transaction type for recurring payments.', 'invoicing'), |
|
| 548 | 548 | 'type' => 'select', |
| 549 | 549 | 'class' => 'wpi_select2', |
| 550 | 550 | 'options' => array( |
| 551 | - 'authorize_capture' => __( 'Authorize And Capture', 'invoicing' ), |
|
| 552 | - 'authorize_only' => __( 'Authorize Only', 'invoicing' ), |
|
| 551 | + 'authorize_capture' => __('Authorize And Capture', 'invoicing'), |
|
| 552 | + 'authorize_only' => __('Authorize Only', 'invoicing'), |
|
| 553 | 553 | ), |
| 554 | 554 | 'std' => 'authorize_only' |
| 555 | 555 | ); |
@@ -557,9 +557,9 @@ discard block |
||
| 557 | 557 | $setting['authorizenet_ipn_url'] = array( |
| 558 | 558 | 'type' => 'ipn_url', |
| 559 | 559 | 'id' => 'authorizenet_ipn_url', |
| 560 | - 'name' => __( 'Silent Post URL', 'invoicing' ), |
|
| 561 | - 'std' => wpinv_get_ipn_url( 'authorizenet' ), |
|
| 562 | - 'desc' => __( 'If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing' ), |
|
| 560 | + 'name' => __('Silent Post URL', 'invoicing'), |
|
| 561 | + 'std' => wpinv_get_ipn_url('authorizenet'), |
|
| 562 | + 'desc' => __('If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing'), |
|
| 563 | 563 | 'size' => 'large', |
| 564 | 564 | 'custom' => 'authorizenet', |
| 565 | 565 | 'readonly' => true |
@@ -567,26 +567,26 @@ discard block |
||
| 567 | 567 | |
| 568 | 568 | return $setting; |
| 569 | 569 | } |
| 570 | -add_filter( 'wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1 ); |
|
| 570 | +add_filter('wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1); |
|
| 571 | 571 | |
| 572 | 572 | // Worldpay settings |
| 573 | -function wpinv_gateway_settings_worldpay( $setting ) { |
|
| 574 | - $setting['worldpay_active']['desc'] = $setting['worldpay_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, ARS, CAD, CHF, DKK, EUR, HKD, MYR, GBP, NZD, NOK, SGD, LKR, SEK, TRY, USD, ZAR )', 'invoicing' ); |
|
| 575 | - $setting['worldpay_desc']['std'] = __( 'Pay using a Worldpay account to process Credit card / Debit card transactions.', 'invoicing' ); |
|
| 573 | +function wpinv_gateway_settings_worldpay($setting) { |
|
| 574 | + $setting['worldpay_active']['desc'] = $setting['worldpay_active']['desc'] . ' ' . __('( Supported Currencies: AUD, ARS, CAD, CHF, DKK, EUR, HKD, MYR, GBP, NZD, NOK, SGD, LKR, SEK, TRY, USD, ZAR )', 'invoicing'); |
|
| 575 | + $setting['worldpay_desc']['std'] = __('Pay using a Worldpay account to process Credit card / Debit card transactions.', 'invoicing'); |
|
| 576 | 576 | |
| 577 | 577 | $setting['worldpay_sandbox'] = array( |
| 578 | 578 | 'type' => 'checkbox', |
| 579 | 579 | 'id' => 'worldpay_sandbox', |
| 580 | - 'name' => __( 'Worldpay Test Mode', 'invoicing' ), |
|
| 581 | - 'desc' => __( 'This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing' ), |
|
| 580 | + 'name' => __('Worldpay Test Mode', 'invoicing'), |
|
| 581 | + 'desc' => __('This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing'), |
|
| 582 | 582 | 'std' => 1 |
| 583 | 583 | ); |
| 584 | 584 | |
| 585 | 585 | $setting['worldpay_instId'] = array( |
| 586 | 586 | 'type' => 'text', |
| 587 | 587 | 'id' => 'worldpay_instId', |
| 588 | - 'name' => __( 'Installation Id', 'invoicing' ), |
|
| 589 | - 'desc' => __( 'Your installation id. Ex: 211616', 'invoicing' ), |
|
| 588 | + 'name' => __('Installation Id', 'invoicing'), |
|
| 589 | + 'desc' => __('Your installation id. Ex: 211616', 'invoicing'), |
|
| 590 | 590 | 'std' => '211616', |
| 591 | 591 | ); |
| 592 | 592 | /* |
@@ -602,9 +602,9 @@ discard block |
||
| 602 | 602 | $setting['worldpay_ipn_url'] = array( |
| 603 | 603 | 'type' => 'ipn_url', |
| 604 | 604 | 'id' => 'worldpay_ipn_url', |
| 605 | - 'name' => __( 'Worldpay Callback Url', 'invoicing' ), |
|
| 606 | - 'std' => wpinv_get_ipn_url( 'worldpay' ), |
|
| 607 | - 'desc' => wp_sprintf( __( 'Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing' ), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url( 'worldpay' ) . '</font>', '<font style="color:#000;font-style:normal"><wpdisplay item=MC_callback></font>' ), |
|
| 605 | + 'name' => __('Worldpay Callback Url', 'invoicing'), |
|
| 606 | + 'std' => wpinv_get_ipn_url('worldpay'), |
|
| 607 | + 'desc' => wp_sprintf(__('Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing'), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url('worldpay') . '</font>', '<font style="color:#000;font-style:normal"><wpdisplay item=MC_callback></font>'), |
|
| 608 | 608 | 'size' => 'large', |
| 609 | 609 | 'custom' => 'worldpay', |
| 610 | 610 | 'readonly' => true |
@@ -612,99 +612,99 @@ discard block |
||
| 612 | 612 | |
| 613 | 613 | return $setting; |
| 614 | 614 | } |
| 615 | -add_filter( 'wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1 ); |
|
| 615 | +add_filter('wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1); |
|
| 616 | 616 | |
| 617 | -function wpinv_ipn_url_callback( $args ) { |
|
| 618 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 617 | +function wpinv_ipn_url_callback($args) { |
|
| 618 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 619 | 619 | |
| 620 | 620 | $attrs = $args['readonly'] ? ' readonly' : ''; |
| 621 | 621 | |
| 622 | - $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">'; |
|
| 623 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
| 622 | + $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">'; |
|
| 623 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
| 624 | 624 | |
| 625 | 625 | echo $html; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
| 629 | - if ( empty( $gateway ) ) { |
|
| 628 | +function wpinv_is_test_mode($gateway = '') { |
|
| 629 | + if (empty($gateway)) { |
|
| 630 | 630 | return false; |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - $is_test_mode = wpinv_get_option( $gateway . '_sandbox', false ); |
|
| 633 | + $is_test_mode = wpinv_get_option($gateway . '_sandbox', false); |
|
| 634 | 634 | |
| 635 | - return apply_filters( 'wpinv_is_test_mode', $is_test_mode, $gateway ); |
|
| 635 | + return apply_filters('wpinv_is_test_mode', $is_test_mode, $gateway); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | -function wpinv_get_ipn_url( $gateway = '', $args = array() ) { |
|
| 639 | - $data = array( 'wpi-listener' => 'IPN' ); |
|
| 638 | +function wpinv_get_ipn_url($gateway = '', $args = array()) { |
|
| 639 | + $data = array('wpi-listener' => 'IPN'); |
|
| 640 | 640 | |
| 641 | - if ( !empty( $gateway ) ) { |
|
| 642 | - $data['wpi-gateway'] = wpinv_sanitize_key( $gateway ); |
|
| 641 | + if (!empty($gateway)) { |
|
| 642 | + $data['wpi-gateway'] = wpinv_sanitize_key($gateway); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - $args = !empty( $args ) && is_array( $args ) ? array_merge( $data, $args ) : $data; |
|
| 645 | + $args = !empty($args) && is_array($args) ? array_merge($data, $args) : $data; |
|
| 646 | 646 | |
| 647 | - $ipn_url = add_query_arg( $args, home_url( 'index.php' ) ); |
|
| 647 | + $ipn_url = add_query_arg($args, home_url('index.php')); |
|
| 648 | 648 | |
| 649 | - return apply_filters( 'wpinv_ipn_url', $ipn_url ); |
|
| 649 | + return apply_filters('wpinv_ipn_url', $ipn_url); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | function wpinv_listen_for_payment_ipn() { |
| 653 | 653 | // Regular PayPal IPN |
| 654 | - if ( isset( $_GET['wpi-listener'] ) && $_GET['wpi-listener'] == 'IPN' ) { |
|
| 655 | - do_action( 'wpinv_verify_payment_ipn' ); |
|
| 654 | + if (isset($_GET['wpi-listener']) && $_GET['wpi-listener'] == 'IPN') { |
|
| 655 | + do_action('wpinv_verify_payment_ipn'); |
|
| 656 | 656 | |
| 657 | - if ( !empty( $_GET['wpi-gateway'] ) ) { |
|
| 658 | - wpinv_error_log( sanitize_text_field( $_GET['wpi-gateway'] ), 'WP Invoicing IPN', __FILE__, __LINE__ ); |
|
| 659 | - do_action( 'wpinv_verify_' . sanitize_text_field( $_GET['wpi-gateway'] ) . '_ipn' ); |
|
| 657 | + if (!empty($_GET['wpi-gateway'])) { |
|
| 658 | + wpinv_error_log(sanitize_text_field($_GET['wpi-gateway']), 'WP Invoicing IPN', __FILE__, __LINE__); |
|
| 659 | + do_action('wpinv_verify_' . sanitize_text_field($_GET['wpi-gateway']) . '_ipn'); |
|
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | -add_action( 'init', 'wpinv_listen_for_payment_ipn' ); |
|
| 663 | +add_action('init', 'wpinv_listen_for_payment_ipn'); |
|
| 664 | 664 | |
| 665 | 665 | function wpinv_get_bank_instructions() { |
| 666 | - $bank_instructions = wpinv_get_option( 'bank_transfer_info' ); |
|
| 666 | + $bank_instructions = wpinv_get_option('bank_transfer_info'); |
|
| 667 | 667 | |
| 668 | - return apply_filters( 'wpinv_bank_instructions', $bank_instructions ); |
|
| 668 | + return apply_filters('wpinv_bank_instructions', $bank_instructions); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | -function wpinv_get_bank_info( $filtered = false ) { |
|
| 671 | +function wpinv_get_bank_info($filtered = false) { |
|
| 672 | 672 | $bank_fields = array( |
| 673 | - 'bank_transfer_ac_name' => __( 'Account Name', 'invoicing' ), |
|
| 674 | - 'bank_transfer_ac_no' => __( 'Account Number', 'invoicing' ), |
|
| 675 | - 'bank_transfer_bank_name' => __( 'Bank Name', 'invoicing' ), |
|
| 676 | - 'bank_transfer_ifsc' => __( 'IFSC code', 'invoicing' ), |
|
| 677 | - 'bank_transfer_iban' => __( 'IBAN', 'invoicing' ), |
|
| 678 | - 'bank_transfer_bic' => __( 'BIC/Swift code', 'invoicing' ), |
|
| 679 | - 'bank_transfer_sort_code' => __( 'Sort Code', 'invoicing' ) |
|
| 673 | + 'bank_transfer_ac_name' => __('Account Name', 'invoicing'), |
|
| 674 | + 'bank_transfer_ac_no' => __('Account Number', 'invoicing'), |
|
| 675 | + 'bank_transfer_bank_name' => __('Bank Name', 'invoicing'), |
|
| 676 | + 'bank_transfer_ifsc' => __('IFSC code', 'invoicing'), |
|
| 677 | + 'bank_transfer_iban' => __('IBAN', 'invoicing'), |
|
| 678 | + 'bank_transfer_bic' => __('BIC/Swift code', 'invoicing'), |
|
| 679 | + 'bank_transfer_sort_code' => __('Sort Code', 'invoicing') |
|
| 680 | 680 | ); |
| 681 | 681 | |
| 682 | 682 | $bank_info = array(); |
| 683 | - foreach ( $bank_fields as $field => $label ) { |
|
| 684 | - if ( $filtered && !( $value = wpinv_get_option( $field ) ) ) { |
|
| 683 | + foreach ($bank_fields as $field => $label) { |
|
| 684 | + if ($filtered && !($value = wpinv_get_option($field))) { |
|
| 685 | 685 | continue; |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | - $bank_info[$field] = array( 'label' => $label, 'value' => $value ); |
|
| 688 | + $bank_info[$field] = array('label' => $label, 'value' => $value); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - return apply_filters( 'wpinv_bank_info', $bank_info, $filtered ); |
|
| 691 | + return apply_filters('wpinv_bank_info', $bank_info, $filtered); |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | -function wpinv_get_post_data( $method = 'request' ) { |
|
| 694 | +function wpinv_get_post_data($method = 'request') { |
|
| 695 | 695 | $data = array(); |
| 696 | 696 | $request = $_REQUEST; |
| 697 | 697 | |
| 698 | - if ( $method == 'post' ) { |
|
| 699 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
| 698 | + if ($method == 'post') { |
|
| 699 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
| 700 | 700 | return $data; |
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | $request = $_POST; |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | - if ( $method == 'get' ) { |
|
| 707 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) { |
|
| 706 | + if ($method == 'get') { |
|
| 707 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') { |
|
| 708 | 708 | return $data; |
| 709 | 709 | } |
| 710 | 710 | |
@@ -715,11 +715,11 @@ discard block |
||
| 715 | 715 | $post_data = ''; |
| 716 | 716 | |
| 717 | 717 | // Fallback just in case post_max_size is lower than needed |
| 718 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
| 719 | - $post_data = file_get_contents( 'php://input' ); |
|
| 718 | + if (ini_get('allow_url_fopen')) { |
|
| 719 | + $post_data = file_get_contents('php://input'); |
|
| 720 | 720 | } else { |
| 721 | 721 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
| 722 | - ini_set( 'post_max_size', '12M' ); |
|
| 722 | + ini_set('post_max_size', '12M'); |
|
| 723 | 723 | } |
| 724 | 724 | // Start the encoded data collection with notification command |
| 725 | 725 | $encoded_data = 'cmd=_notify-validate'; |
@@ -728,58 +728,58 @@ discard block |
||
| 728 | 728 | $arg_separator = wpinv_get_php_arg_separator_output(); |
| 729 | 729 | |
| 730 | 730 | // Verify there is a post_data |
| 731 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
| 731 | + if ($post_data || strlen($post_data) > 0) { |
|
| 732 | 732 | // Append the data |
| 733 | 733 | $encoded_data .= $arg_separator . $post_data; |
| 734 | 734 | } else { |
| 735 | 735 | // Check if POST is empty |
| 736 | - if ( empty( $request ) ) { |
|
| 736 | + if (empty($request)) { |
|
| 737 | 737 | // Nothing to do |
| 738 | 738 | return; |
| 739 | 739 | } else { |
| 740 | 740 | // Loop through each POST |
| 741 | - foreach ( $request as $key => $value ) { |
|
| 741 | + foreach ($request as $key => $value) { |
|
| 742 | 742 | // Encode the value and append the data |
| 743 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
| 743 | + $encoded_data .= $arg_separator . "$key=" . urlencode($value); |
|
| 744 | 744 | } |
| 745 | 745 | } |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | // Convert collected post data to an array |
| 749 | - parse_str( $encoded_data, $data ); |
|
| 749 | + parse_str($encoded_data, $data); |
|
| 750 | 750 | |
| 751 | - foreach ( $data as $key => $value ) { |
|
| 752 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
| 753 | - $new_key = str_replace( '&', '&', $key ); |
|
| 754 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
| 751 | + foreach ($data as $key => $value) { |
|
| 752 | + if (false !== strpos($key, 'amp;')) { |
|
| 753 | + $new_key = str_replace('&', '&', $key); |
|
| 754 | + $new_key = str_replace('amp;', '&', $new_key); |
|
| 755 | 755 | |
| 756 | - unset( $data[ $key ] ); |
|
| 757 | - $data[ $new_key ] = sanitize_text_field( $value ); |
|
| 756 | + unset($data[$key]); |
|
| 757 | + $data[$new_key] = sanitize_text_field($value); |
|
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | return $data; |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
| 764 | +function wpinv_gateway_support_subscription($gateway) { |
|
| 765 | 765 | $return = false; |
| 766 | 766 | |
| 767 | - if ( wpinv_is_gateway_active( $gateway ) ) { |
|
| 768 | - $return = apply_filters( 'wpinv_' . $gateway . '_support_subscription', false ); |
|
| 767 | + if (wpinv_is_gateway_active($gateway)) { |
|
| 768 | + $return = apply_filters('wpinv_' . $gateway . '_support_subscription', false); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | return $return; |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | -function wpinv_payment_gateways_on_cart( $gateways = array() ) { |
|
| 775 | - if ( !empty( $gateways ) && wpinv_cart_has_recurring_item() ) { |
|
| 776 | - foreach ( $gateways as $gateway => $info ) { |
|
| 777 | - if ( !wpinv_gateway_support_subscription( $gateway ) ) { |
|
| 778 | - unset( $gateways[$gateway] ); |
|
| 774 | +function wpinv_payment_gateways_on_cart($gateways = array()) { |
|
| 775 | + if (!empty($gateways) && wpinv_cart_has_recurring_item()) { |
|
| 776 | + foreach ($gateways as $gateway => $info) { |
|
| 777 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
| 778 | + unset($gateways[$gateway]); |
|
| 779 | 779 | } |
| 780 | 780 | } |
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | return $gateways; |
| 784 | 784 | } |
| 785 | -add_filter( 'wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1 ); |
|
| 786 | 785 | \ No newline at end of file |
| 786 | +add_filter('wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1); |
|
| 787 | 787 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; // Exit if accessed directly |
| 4 | 4 | } |
| 5 | 5 | |
@@ -21,166 +21,166 @@ discard block |
||
| 21 | 21 | public function init() { |
| 22 | 22 | global $wp_filesystem; |
| 23 | 23 | |
| 24 | - if ( empty( $wp_filesystem ) ) { |
|
| 25 | - require_once( ABSPATH . '/wp-admin/includes/file.php' ); |
|
| 24 | + if (empty($wp_filesystem)) { |
|
| 25 | + require_once(ABSPATH . '/wp-admin/includes/file.php'); |
|
| 26 | 26 | WP_Filesystem(); |
| 27 | 27 | global $wp_filesystem; |
| 28 | 28 | } |
| 29 | 29 | $this->wp_filesystem = $wp_filesystem; |
| 30 | 30 | |
| 31 | 31 | $this->export_dir = $this->export_location(); |
| 32 | - $this->export_url = $this->export_location( true ); |
|
| 32 | + $this->export_url = $this->export_location(true); |
|
| 33 | 33 | $this->export = 'invoicing'; |
| 34 | 34 | $this->filetype = 'csv'; |
| 35 | 35 | $this->per_page = 20; |
| 36 | 36 | |
| 37 | - do_action( 'wpinv_class_reports_init', $this ); |
|
| 37 | + do_action('wpinv_class_reports_init', $this); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function includes() { |
| 41 | - do_action( 'wpinv_class_reports_includes', $this ); |
|
| 41 | + do_action('wpinv_class_reports_includes', $this); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function actions() { |
| 45 | - if ( is_admin() ) { |
|
| 46 | - add_action( 'admin_menu', array( $this, 'add_submenu' ), 10 ); |
|
| 47 | - add_action( 'wpinv_reports_tab_export', array( $this, 'export' ) ); |
|
| 48 | - add_action( 'wp_ajax_wpinv_ajax_export', array( $this, 'ajax_export' ) ); |
|
| 45 | + if (is_admin()) { |
|
| 46 | + add_action('admin_menu', array($this, 'add_submenu'), 10); |
|
| 47 | + add_action('wpinv_reports_tab_export', array($this, 'export')); |
|
| 48 | + add_action('wp_ajax_wpinv_ajax_export', array($this, 'ajax_export')); |
|
| 49 | 49 | |
| 50 | 50 | // Export Invoices. |
| 51 | - add_action( 'wpinv_export_set_params_invoices', array( $this, 'set_invoices_export' ) ); |
|
| 52 | - add_filter( 'wpinv_export_get_columns_invoices', array( $this, 'get_invoices_columns' ) ); |
|
| 53 | - add_filter( 'wpinv_export_get_data_invoices', array( $this, 'get_invoices_data' ) ); |
|
| 54 | - add_filter( 'wpinv_get_export_status_invoices', array( $this, 'invoices_export_status' ) ); |
|
| 51 | + add_action('wpinv_export_set_params_invoices', array($this, 'set_invoices_export')); |
|
| 52 | + add_filter('wpinv_export_get_columns_invoices', array($this, 'get_invoices_columns')); |
|
| 53 | + add_filter('wpinv_export_get_data_invoices', array($this, 'get_invoices_data')); |
|
| 54 | + add_filter('wpinv_get_export_status_invoices', array($this, 'invoices_export_status')); |
|
| 55 | 55 | } |
| 56 | - do_action( 'wpinv_class_reports_actions', $this ); |
|
| 56 | + do_action('wpinv_class_reports_actions', $this); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function add_submenu() { |
| 60 | 60 | global $wpi_reports_page; |
| 61 | - $wpi_reports_page = add_submenu_page( 'wpinv', __( 'Reports', 'invoicing' ), __( 'Reports', 'invoicing' ), 'manage_options', 'wpinv-reports', array( $this, 'reports_page' ) ); |
|
| 61 | + $wpi_reports_page = add_submenu_page('wpinv', __('Reports', 'invoicing'), __('Reports', 'invoicing'), 'manage_options', 'wpinv-reports', array($this, 'reports_page')); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public function reports_page() { |
| 65 | - if ( !wp_script_is( 'postbox', 'enqueued' ) ) { |
|
| 66 | - wp_enqueue_script( 'postbox' ); |
|
| 65 | + if (!wp_script_is('postbox', 'enqueued')) { |
|
| 66 | + wp_enqueue_script('postbox'); |
|
| 67 | 67 | } |
| 68 | - if ( !wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) { |
|
| 69 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 68 | + if (!wp_script_is('jquery-ui-datepicker', 'enqueued')) { |
|
| 69 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $current_page = admin_url( 'admin.php?page=wpinv-reports' ); |
|
| 73 | - $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'export'; |
|
| 72 | + $current_page = admin_url('admin.php?page=wpinv-reports'); |
|
| 73 | + $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'export'; |
|
| 74 | 74 | ?> |
| 75 | 75 | <div class="wrap wpi-reports-wrap"> |
| 76 | - <h1><?php echo esc_html( __( 'Reports', 'invoicing' ) ); ?></h1> |
|
| 76 | + <h1><?php echo esc_html(__('Reports', 'invoicing')); ?></h1> |
|
| 77 | 77 | <h2 class="nav-tab-wrapper wp-clearfix"> |
| 78 | - <a href="<?php echo add_query_arg( array( 'tab' => 'export', 'settings-updated' => false ), $current_page ); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Export', 'invoicing' ); ?></a> |
|
| 79 | - <?php do_action( 'wpinv_reports_page_tabs' ); ;?> |
|
| 78 | + <a href="<?php echo add_query_arg(array('tab' => 'export', 'settings-updated' => false), $current_page); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e('Export', 'invoicing'); ?></a> |
|
| 79 | + <?php do_action('wpinv_reports_page_tabs'); ;?> |
|
| 80 | 80 | </h2> |
| 81 | 81 | <div class="wpi-reports-content wpi-reports-<?php echo $active_tab; ?>"> |
| 82 | 82 | <?php |
| 83 | - do_action( 'wpinv_reports_page_top' ); |
|
| 84 | - do_action( 'wpinv_reports_tab_' . $active_tab ); |
|
| 85 | - do_action( 'wpinv_reports_page_bottom' ); |
|
| 83 | + do_action('wpinv_reports_page_top'); |
|
| 84 | + do_action('wpinv_reports_tab_' . $active_tab); |
|
| 85 | + do_action('wpinv_reports_page_bottom'); |
|
| 86 | 86 | ?> |
| 87 | 87 | </div> |
| 88 | 88 | <?php |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function export() { |
| 92 | - $statuses = wpinv_get_invoice_statuses( true ); |
|
| 93 | - $statuses = array_merge( array( 'any' => __( 'All Statuses', 'invoicing' ) ), $statuses ); |
|
| 92 | + $statuses = wpinv_get_invoice_statuses(true); |
|
| 93 | + $statuses = array_merge(array('any' => __('All Statuses', 'invoicing')), $statuses); |
|
| 94 | 94 | ?> |
| 95 | 95 | <div class="metabox-holder"> |
| 96 | 96 | <div id="post-body"> |
| 97 | 97 | <div id="post-body-content"> |
| 98 | - <?php do_action( 'wpinv_reports_tab_export_content_top' ); ?> |
|
| 98 | + <?php do_action('wpinv_reports_tab_export_content_top'); ?> |
|
| 99 | 99 | |
| 100 | 100 | <div class="postbox wpi-export-invoices"> |
| 101 | - <h2 class="hndle ui-sortabled-handle"><span><?php _e( 'Invoices','invoicing' ); ?></span></h2> |
|
| 101 | + <h2 class="hndle ui-sortabled-handle"><span><?php _e('Invoices', 'invoicing'); ?></span></h2> |
|
| 102 | 102 | <div class="inside"> |
| 103 | - <p><?php _e( 'Download a CSV of all payment invoices.', 'invoicing' ); ?></p> |
|
| 103 | + <p><?php _e('Download a CSV of all payment invoices.', 'invoicing'); ?></p> |
|
| 104 | 104 | <form id="wpi-export-invoices" class="wpi-export-form" method="post"> |
| 105 | - <?php echo wpinv_html_date_field( array( |
|
| 105 | + <?php echo wpinv_html_date_field(array( |
|
| 106 | 106 | 'id' => 'wpi_export_from_date', |
| 107 | 107 | 'name' => 'from_date', |
| 108 | 108 | 'data' => array( |
| 109 | 109 | 'dateFormat' => 'yy-mm-dd' |
| 110 | 110 | ), |
| 111 | - 'placeholder' => __( 'From date', 'invoicing' ) ) |
|
| 111 | + 'placeholder' => __('From date', 'invoicing') ) |
|
| 112 | 112 | ); ?> |
| 113 | - <?php echo wpinv_html_date_field( array( |
|
| 113 | + <?php echo wpinv_html_date_field(array( |
|
| 114 | 114 | 'id' => 'wpi_export_to_date', |
| 115 | 115 | 'name' => 'to_date', |
| 116 | 116 | 'data' => array( |
| 117 | 117 | 'dateFormat' => 'yy-mm-dd' |
| 118 | 118 | ), |
| 119 | - 'placeholder' => __( 'To date', 'invoicing' ) ) |
|
| 119 | + 'placeholder' => __('To date', 'invoicing') ) |
|
| 120 | 120 | ); ?> |
| 121 | 121 | <span id="wpinv-status-wrap"> |
| 122 | - <?php echo wpinv_html_select( array( |
|
| 122 | + <?php echo wpinv_html_select(array( |
|
| 123 | 123 | 'options' => $statuses, |
| 124 | 124 | 'name' => 'status', |
| 125 | 125 | 'id' => 'wpi_export_status', |
| 126 | 126 | 'show_option_all' => false, |
| 127 | 127 | 'show_option_none' => false, |
| 128 | 128 | 'class' => 'wpi_select2', |
| 129 | - ) ); ?> |
|
| 130 | - <?php wp_nonce_field( 'wpi_ajax_export', 'wpi_ajax_export' ); ?> |
|
| 129 | + )); ?> |
|
| 130 | + <?php wp_nonce_field('wpi_ajax_export', 'wpi_ajax_export'); ?> |
|
| 131 | 131 | </span> |
| 132 | 132 | <span id="wpinv-submit-wrap"> |
| 133 | 133 | <input type="hidden" value="invoices" name="export" /> |
| 134 | - <input type="submit" value="<?php _e( 'Generate CSV', 'invoicing' ); ?>" class="button-primary" /> |
|
| 134 | + <input type="submit" value="<?php _e('Generate CSV', 'invoicing'); ?>" class="button-primary" /> |
|
| 135 | 135 | </span> |
| 136 | 136 | </form> |
| 137 | 137 | </div> |
| 138 | 138 | </div> |
| 139 | 139 | |
| 140 | - <?php do_action( 'wpinv_reports_tab_export_content_bottom' ); ?> |
|
| 140 | + <?php do_action('wpinv_reports_tab_export_content_bottom'); ?> |
|
| 141 | 141 | </div> |
| 142 | 142 | </div> |
| 143 | 143 | </div> |
| 144 | 144 | <?php |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public function export_location( $relative = false ) { |
|
| 147 | + public function export_location($relative = false) { |
|
| 148 | 148 | $upload_dir = wp_upload_dir(); |
| 149 | - $export_location = $relative ? trailingslashit( $upload_dir['baseurl'] ) . 'cache' : trailingslashit( $upload_dir['basedir'] ) . 'cache'; |
|
| 150 | - $export_location = apply_filters( 'wpinv_export_location', $export_location, $relative ); |
|
| 149 | + $export_location = $relative ? trailingslashit($upload_dir['baseurl']) . 'cache' : trailingslashit($upload_dir['basedir']) . 'cache'; |
|
| 150 | + $export_location = apply_filters('wpinv_export_location', $export_location, $relative); |
|
| 151 | 151 | |
| 152 | - return trailingslashit( $export_location ); |
|
| 152 | + return trailingslashit($export_location); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | public function check_export_location() { |
| 156 | 156 | try { |
| 157 | - if ( empty( $this->wp_filesystem ) ) { |
|
| 158 | - return __( 'Filesystem ERROR: Could not access filesystem.', 'invoicing' ); |
|
| 157 | + if (empty($this->wp_filesystem)) { |
|
| 158 | + return __('Filesystem ERROR: Could not access filesystem.', 'invoicing'); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if ( is_wp_error( $this->wp_filesystem ) ) { |
|
| 162 | - return __( 'Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing' ); |
|
| 161 | + if (is_wp_error($this->wp_filesystem)) { |
|
| 162 | + return __('Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing'); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $is_dir = $this->wp_filesystem->is_dir( $this->export_dir ); |
|
| 166 | - $is_writeable = $is_dir && is_writeable( $this->export_dir ); |
|
| 165 | + $is_dir = $this->wp_filesystem->is_dir($this->export_dir); |
|
| 166 | + $is_writeable = $is_dir && is_writeable($this->export_dir); |
|
| 167 | 167 | |
| 168 | - if ( $is_dir && $is_writeable ) { |
|
| 168 | + if ($is_dir && $is_writeable) { |
|
| 169 | 169 | return true; |
| 170 | - } else if ( $is_dir && !$is_writeable ) { |
|
| 171 | - if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
| 172 | - return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir ); |
|
| 170 | + } else if ($is_dir && !$is_writeable) { |
|
| 171 | + if (!$this->wp_filesystem->chmod($this->export_dir, FS_CHMOD_DIR)) { |
|
| 172 | + return wp_sprintf(__('Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing'), $this->export_dir); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | return true; |
| 176 | 176 | } else { |
| 177 | - if ( !$this->wp_filesystem->mkdir( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
| 178 | - return wp_sprintf( __( 'Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing' ), $this->export_dir ); |
|
| 177 | + if (!$this->wp_filesystem->mkdir($this->export_dir, FS_CHMOD_DIR)) { |
|
| 178 | + return wp_sprintf(__('Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing'), $this->export_dir); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | return true; |
| 182 | 182 | } |
| 183 | - } catch ( Exception $e ) { |
|
| 183 | + } catch (Exception $e) { |
|
| 184 | 184 | return $e->getMessage(); |
| 185 | 185 | } |
| 186 | 186 | } |
@@ -188,130 +188,130 @@ discard block |
||
| 188 | 188 | public function ajax_export() { |
| 189 | 189 | $response = array(); |
| 190 | 190 | $response['success'] = false; |
| 191 | - $response['msg'] = __( 'Invalid export request found.', 'invoicing' ); |
|
| 191 | + $response['msg'] = __('Invalid export request found.', 'invoicing'); |
|
| 192 | 192 | |
| 193 | - if ( empty( $_POST['data'] ) || !current_user_can( 'manage_options' ) ) { |
|
| 194 | - wp_send_json( $response ); |
|
| 193 | + if (empty($_POST['data']) || !current_user_can('manage_options')) { |
|
| 194 | + wp_send_json($response); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - parse_str( $_POST['data'], $data ); |
|
| 197 | + parse_str($_POST['data'], $data); |
|
| 198 | 198 | |
| 199 | - $data['step'] = !empty( $_POST['step'] ) ? absint( $_POST['step'] ) : 1; |
|
| 199 | + $data['step'] = !empty($_POST['step']) ? absint($_POST['step']) : 1; |
|
| 200 | 200 | |
| 201 | 201 | $_REQUEST = (array)$data; |
| 202 | - if ( !( !empty( $_REQUEST['wpi_ajax_export'] ) && wp_verify_nonce( $_REQUEST['wpi_ajax_export'], 'wpi_ajax_export' ) ) ) { |
|
| 203 | - $response['msg'] = __( 'Security check failed.', 'invoicing' ); |
|
| 204 | - wp_send_json( $response ); |
|
| 202 | + if (!(!empty($_REQUEST['wpi_ajax_export']) && wp_verify_nonce($_REQUEST['wpi_ajax_export'], 'wpi_ajax_export'))) { |
|
| 203 | + $response['msg'] = __('Security check failed.', 'invoicing'); |
|
| 204 | + wp_send_json($response); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if ( ( $error = $this->check_export_location( true ) ) !== true ) { |
|
| 208 | - $response['msg'] = __( 'Filesystem ERROR: ' . $error, 'invoicing' ); |
|
| 209 | - wp_send_json( $response ); |
|
| 207 | + if (($error = $this->check_export_location(true)) !== true) { |
|
| 208 | + $response['msg'] = __('Filesystem ERROR: ' . $error, 'invoicing'); |
|
| 209 | + wp_send_json($response); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - $this->set_export_params( $_REQUEST ); |
|
| 212 | + $this->set_export_params($_REQUEST); |
|
| 213 | 213 | |
| 214 | 214 | $return = $this->process_export_step(); |
| 215 | 215 | $done = $this->get_export_status(); |
| 216 | 216 | |
| 217 | - if ( $return ) { |
|
| 217 | + if ($return) { |
|
| 218 | 218 | $this->step += 1; |
| 219 | 219 | |
| 220 | 220 | $response['success'] = true; |
| 221 | 221 | $response['msg'] = ''; |
| 222 | 222 | |
| 223 | - if ( $done >= 100 ) { |
|
| 223 | + if ($done >= 100) { |
|
| 224 | 224 | $this->step = 'done'; |
| 225 | - $new_filename = 'wpi-' . $this->export . '-' . date( 'y-m-d-H-i' ) . '.' . $this->filetype; |
|
| 225 | + $new_filename = 'wpi-' . $this->export . '-' . date('y-m-d-H-i') . '.' . $this->filetype; |
|
| 226 | 226 | $new_file = $this->export_dir . $new_filename; |
| 227 | 227 | |
| 228 | - if ( file_exists( $this->file ) ) { |
|
| 229 | - $this->wp_filesystem->move( $this->file, $new_file, true ); |
|
| 228 | + if (file_exists($this->file)) { |
|
| 229 | + $this->wp_filesystem->move($this->file, $new_file, true); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - if ( file_exists( $new_file ) ) { |
|
| 233 | - $response['data']['file'] = array( 'u' => $this->export_url . $new_filename, 's' => size_format( filesize( $new_file ), 2 ) ); |
|
| 232 | + if (file_exists($new_file)) { |
|
| 233 | + $response['data']['file'] = array('u' => $this->export_url . $new_filename, 's' => size_format(filesize($new_file), 2)); |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $response['data']['step'] = $this->step; |
| 238 | 238 | $response['data']['done'] = $done; |
| 239 | 239 | } else { |
| 240 | - $response['msg'] = __( 'No data found for export.', 'invoicing' ); |
|
| 240 | + $response['msg'] = __('No data found for export.', 'invoicing'); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - wp_send_json( $response ); |
|
| 243 | + wp_send_json($response); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - public function set_export_params( $request ) { |
|
| 246 | + public function set_export_params($request) { |
|
| 247 | 247 | $this->empty = false; |
| 248 | - $this->step = !empty( $request['step'] ) ? absint( $request['step'] ) : 1; |
|
| 249 | - $this->export = !empty( $request['export'] ) ? $request['export'] : $this->export; |
|
| 248 | + $this->step = !empty($request['step']) ? absint($request['step']) : 1; |
|
| 249 | + $this->export = !empty($request['export']) ? $request['export'] : $this->export; |
|
| 250 | 250 | $this->filename = 'wpi-' . $this->export . '-' . $request['wpi_ajax_export'] . '.' . $this->filetype; |
| 251 | 251 | $this->file = $this->export_dir . $this->filename; |
| 252 | 252 | |
| 253 | - do_action( 'wpinv_export_set_params_' . $this->export, $request ); |
|
| 253 | + do_action('wpinv_export_set_params_' . $this->export, $request); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | public function get_columns() { |
| 257 | 257 | $columns = array( |
| 258 | - 'id' => __( 'ID', 'invoicing' ), |
|
| 259 | - 'date' => __( 'Date', 'invoicing' ) |
|
| 258 | + 'id' => __('ID', 'invoicing'), |
|
| 259 | + 'date' => __('Date', 'invoicing') |
|
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | - return apply_filters( 'wpinv_export_get_columns_' . $this->export, $columns ); |
|
| 262 | + return apply_filters('wpinv_export_get_columns_' . $this->export, $columns); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | protected function get_export_file() { |
| 266 | 266 | $file = ''; |
| 267 | 267 | |
| 268 | - if ( $this->wp_filesystem->exists( $this->file ) ) { |
|
| 269 | - $file = $this->wp_filesystem->get_contents( $this->file ); |
|
| 268 | + if ($this->wp_filesystem->exists($this->file)) { |
|
| 269 | + $file = $this->wp_filesystem->get_contents($this->file); |
|
| 270 | 270 | } else { |
| 271 | - $this->wp_filesystem->put_contents( $this->file, '' ); |
|
| 271 | + $this->wp_filesystem->put_contents($this->file, ''); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | return $file; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - protected function attach_export_data( $data = '' ) { |
|
| 278 | - $filedata = $this->get_export_file(); |
|
| 279 | - $filedata .= $data; |
|
| 277 | + protected function attach_export_data($data = '') { |
|
| 278 | + $filedata = $this->get_export_file(); |
|
| 279 | + $filedata .= $data; |
|
| 280 | 280 | |
| 281 | - $this->wp_filesystem->put_contents( $this->file, $filedata ); |
|
| 281 | + $this->wp_filesystem->put_contents($this->file, $filedata); |
|
| 282 | 282 | |
| 283 | - $rows = file( $this->file, FILE_SKIP_EMPTY_LINES ); |
|
| 283 | + $rows = file($this->file, FILE_SKIP_EMPTY_LINES); |
|
| 284 | 284 | $columns = $this->get_columns(); |
| 285 | - $columns = empty( $columns ) ? 0 : 1; |
|
| 285 | + $columns = empty($columns) ? 0 : 1; |
|
| 286 | 286 | |
| 287 | - $this->empty = count( $rows ) == $columns ? true : false; |
|
| 287 | + $this->empty = count($rows) == $columns ? true : false; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | public function print_columns() { |
| 291 | 291 | $column_data = ''; |
| 292 | 292 | $columns = $this->get_columns(); |
| 293 | 293 | $i = 1; |
| 294 | - foreach( $columns as $key => $column ) { |
|
| 295 | - $column_data .= '"' . addslashes( $column ) . '"'; |
|
| 296 | - $column_data .= $i == count( $columns ) ? '' : ','; |
|
| 294 | + foreach ($columns as $key => $column) { |
|
| 295 | + $column_data .= '"' . addslashes($column) . '"'; |
|
| 296 | + $column_data .= $i == count($columns) ? '' : ','; |
|
| 297 | 297 | $i++; |
| 298 | 298 | } |
| 299 | 299 | $column_data .= "\r\n"; |
| 300 | 300 | |
| 301 | - $this->attach_export_data( $column_data ); |
|
| 301 | + $this->attach_export_data($column_data); |
|
| 302 | 302 | |
| 303 | 303 | return $column_data; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | public function process_export_step() { |
| 307 | - if ( $this->step < 2 ) { |
|
| 308 | - @unlink( $this->file ); |
|
| 307 | + if ($this->step < 2) { |
|
| 308 | + @unlink($this->file); |
|
| 309 | 309 | $this->print_columns(); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | $return = $this->print_rows(); |
| 313 | 313 | |
| 314 | - if ( $return ) { |
|
| 314 | + if ($return) { |
|
| 315 | 315 | return true; |
| 316 | 316 | } else { |
| 317 | 317 | return false; |
@@ -320,23 +320,23 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | public function get_export_status() { |
| 322 | 322 | $status = 100; |
| 323 | - return apply_filters( 'wpinv_get_export_status_' . $this->export, $status ); |
|
| 323 | + return apply_filters('wpinv_get_export_status_' . $this->export, $status); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | public function get_export_data() { |
| 327 | 327 | $data = array( |
| 328 | 328 | 0 => array( |
| 329 | 329 | 'id' => '', |
| 330 | - 'data' => date( 'F j, Y' ) |
|
| 330 | + 'data' => date('F j, Y') |
|
| 331 | 331 | ), |
| 332 | 332 | 1 => array( |
| 333 | 333 | 'id' => '', |
| 334 | - 'data' => date( 'F j, Y' ) |
|
| 334 | + 'data' => date('F j, Y') |
|
| 335 | 335 | ) |
| 336 | 336 | ); |
| 337 | 337 | |
| 338 | - $data = apply_filters( 'wpinv_export_get_data', $data ); |
|
| 339 | - $data = apply_filters( 'wpinv_export_get_data_' . $this->export, $data ); |
|
| 338 | + $data = apply_filters('wpinv_export_get_data', $data); |
|
| 339 | + $data = apply_filters('wpinv_export_get_data_' . $this->export, $data); |
|
| 340 | 340 | |
| 341 | 341 | return $data; |
| 342 | 342 | } |
@@ -346,20 +346,20 @@ discard block |
||
| 346 | 346 | $data = $this->get_export_data(); |
| 347 | 347 | $columns = $this->get_columns(); |
| 348 | 348 | |
| 349 | - if ( $data ) { |
|
| 350 | - foreach ( $data as $row ) { |
|
| 349 | + if ($data) { |
|
| 350 | + foreach ($data as $row) { |
|
| 351 | 351 | $i = 1; |
| 352 | - foreach ( $row as $key => $column ) { |
|
| 353 | - if ( array_key_exists( $key, $columns ) ) { |
|
| 354 | - $row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"'; |
|
| 355 | - $row_data .= $i == count( $columns ) ? '' : ','; |
|
| 352 | + foreach ($row as $key => $column) { |
|
| 353 | + if (array_key_exists($key, $columns)) { |
|
| 354 | + $row_data .= '"' . addslashes(preg_replace("/\"/", "'", $column)) . '"'; |
|
| 355 | + $row_data .= $i == count($columns) ? '' : ','; |
|
| 356 | 356 | $i++; |
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | $row_data .= "\r\n"; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $this->attach_export_data( $row_data ); |
|
| 362 | + $this->attach_export_data($row_data); |
|
| 363 | 363 | |
| 364 | 364 | return $row_data; |
| 365 | 365 | } |
@@ -368,46 +368,46 @@ discard block |
||
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | // Export Invoices. |
| 371 | - public function set_invoices_export( $request ) { |
|
| 372 | - $this->from_date = isset( $request['from_date'] ) ? sanitize_text_field( $request['from_date'] ) : ''; |
|
| 373 | - $this->to_date = isset( $request['to_date'] ) ? sanitize_text_field( $request['to_date'] ) : ''; |
|
| 374 | - $this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'publish'; |
|
| 371 | + public function set_invoices_export($request) { |
|
| 372 | + $this->from_date = isset($request['from_date']) ? sanitize_text_field($request['from_date']) : ''; |
|
| 373 | + $this->to_date = isset($request['to_date']) ? sanitize_text_field($request['to_date']) : ''; |
|
| 374 | + $this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'publish'; |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - public function get_invoices_columns( $columns = array() ) { |
|
| 377 | + public function get_invoices_columns($columns = array()) { |
|
| 378 | 378 | $columns = array( |
| 379 | - 'id' => __( 'ID', 'invoicing' ), |
|
| 380 | - 'number' => __( 'Number', 'invoicing' ), |
|
| 381 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 382 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 383 | - 'status_nicename' => __( 'Status Nicename', 'invoicing' ), |
|
| 384 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 385 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 386 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 387 | - 'user_id' => __( 'User ID', 'invoicing' ), |
|
| 388 | - 'email' => __( 'Email', 'invoicing' ), |
|
| 389 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
| 390 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
| 391 | - 'address' => __( 'Address', 'invoicing' ), |
|
| 392 | - 'city' => __( 'City', 'invoicing' ), |
|
| 393 | - 'state' => __( 'State', 'invoicing' ), |
|
| 394 | - 'country' => __( 'Country', 'invoicing' ), |
|
| 395 | - 'zip' => __( 'Zipcode', 'invoicing' ), |
|
| 396 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
| 397 | - 'company' => __( 'Company', 'invoicing' ), |
|
| 398 | - 'vat_number' => __( 'Vat Number', 'invoicing' ), |
|
| 399 | - 'ip' => __( 'IP', 'invoicing' ), |
|
| 400 | - 'gateway' => __( 'Gateway', 'invoicing' ), |
|
| 401 | - 'gateway_nicename' => __( 'Gateway Nicename', 'invoicing' ), |
|
| 402 | - 'transaction_id'=> __( 'Transaction ID', 'invoicing' ), |
|
| 403 | - 'currency' => __( 'Currency', 'invoicing' ), |
|
| 404 | - 'due_date' => __( 'Due Date', 'invoicing' ), |
|
| 379 | + 'id' => __('ID', 'invoicing'), |
|
| 380 | + 'number' => __('Number', 'invoicing'), |
|
| 381 | + 'date' => __('Date', 'invoicing'), |
|
| 382 | + 'amount' => __('Amount', 'invoicing'), |
|
| 383 | + 'status_nicename' => __('Status Nicename', 'invoicing'), |
|
| 384 | + 'status' => __('Status', 'invoicing'), |
|
| 385 | + 'tax' => __('Tax', 'invoicing'), |
|
| 386 | + 'discount' => __('Discount', 'invoicing'), |
|
| 387 | + 'user_id' => __('User ID', 'invoicing'), |
|
| 388 | + 'email' => __('Email', 'invoicing'), |
|
| 389 | + 'first_name' => __('First Name', 'invoicing'), |
|
| 390 | + 'last_name' => __('Last Name', 'invoicing'), |
|
| 391 | + 'address' => __('Address', 'invoicing'), |
|
| 392 | + 'city' => __('City', 'invoicing'), |
|
| 393 | + 'state' => __('State', 'invoicing'), |
|
| 394 | + 'country' => __('Country', 'invoicing'), |
|
| 395 | + 'zip' => __('Zipcode', 'invoicing'), |
|
| 396 | + 'phone' => __('Phone', 'invoicing'), |
|
| 397 | + 'company' => __('Company', 'invoicing'), |
|
| 398 | + 'vat_number' => __('Vat Number', 'invoicing'), |
|
| 399 | + 'ip' => __('IP', 'invoicing'), |
|
| 400 | + 'gateway' => __('Gateway', 'invoicing'), |
|
| 401 | + 'gateway_nicename' => __('Gateway Nicename', 'invoicing'), |
|
| 402 | + 'transaction_id'=> __('Transaction ID', 'invoicing'), |
|
| 403 | + 'currency' => __('Currency', 'invoicing'), |
|
| 404 | + 'due_date' => __('Due Date', 'invoicing'), |
|
| 405 | 405 | ); |
| 406 | 406 | |
| 407 | 407 | return $columns; |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - public function get_invoices_data( $response = array() ) { |
|
| 410 | + public function get_invoices_data($response = array()) { |
|
| 411 | 411 | $args = array( |
| 412 | 412 | 'limit' => $this->per_page, |
| 413 | 413 | 'page' => $this->step, |
@@ -415,37 +415,37 @@ discard block |
||
| 415 | 415 | 'orderby' => 'date', |
| 416 | 416 | ); |
| 417 | 417 | |
| 418 | - if ( $this->status != 'any' ) { |
|
| 418 | + if ($this->status != 'any') { |
|
| 419 | 419 | $args['status'] = $this->status; |
| 420 | 420 | } else { |
| 421 | - $args['status'] = array_keys( wpinv_get_invoice_statuses( true ) ); |
|
| 421 | + $args['status'] = array_keys(wpinv_get_invoice_statuses(true)); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) { |
|
| 424 | + if (!empty($this->from_date) || !empty($this->to_date)) { |
|
| 425 | 425 | $args['date_query'] = array( |
| 426 | 426 | array( |
| 427 | - 'after' => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ), |
|
| 428 | - 'before' => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ), |
|
| 427 | + 'after' => date('Y-n-d 00:00:00', strtotime($this->from_date)), |
|
| 428 | + 'before' => date('Y-n-d 23:59:59', strtotime($this->to_date)), |
|
| 429 | 429 | 'inclusive' => true |
| 430 | 430 | ) |
| 431 | 431 | ); |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - $invoices = wpinv_get_invoices( $args ); |
|
| 434 | + $invoices = wpinv_get_invoices($args); |
|
| 435 | 435 | |
| 436 | 436 | $data = array(); |
| 437 | 437 | |
| 438 | - if ( !empty( $invoices ) ) { |
|
| 439 | - foreach ( $invoices as $invoice ) { |
|
| 438 | + if (!empty($invoices)) { |
|
| 439 | + foreach ($invoices as $invoice) { |
|
| 440 | 440 | $row = array( |
| 441 | 441 | 'id' => $invoice->ID, |
| 442 | 442 | 'number' => $invoice->get_number(), |
| 443 | - 'date' => $invoice->get_invoice_date( false ), |
|
| 444 | - 'amount' => wpinv_round_amount( $invoice->get_total() ), |
|
| 445 | - 'status_nicename' => $invoice->get_status( true ), |
|
| 443 | + 'date' => $invoice->get_invoice_date(false), |
|
| 444 | + 'amount' => wpinv_round_amount($invoice->get_total()), |
|
| 445 | + 'status_nicename' => $invoice->get_status(true), |
|
| 446 | 446 | 'status' => $invoice->get_status(), |
| 447 | - 'tax' => $invoice->get_tax() > 0 ? wpinv_round_amount( $invoice->get_tax() ) : '', |
|
| 448 | - 'discount' => $invoice->get_discount() > 0 ? wpinv_round_amount( $invoice->get_discount() ) : '', |
|
| 447 | + 'tax' => $invoice->get_tax() > 0 ? wpinv_round_amount($invoice->get_tax()) : '', |
|
| 448 | + 'discount' => $invoice->get_discount() > 0 ? wpinv_round_amount($invoice->get_discount()) : '', |
|
| 449 | 449 | 'user_id' => $invoice->get_user_id(), |
| 450 | 450 | 'email' => $invoice->get_email(), |
| 451 | 451 | 'first_name' => $invoice->get_first_name(), |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | 'due_date' => $invoice->needs_payment() || $invoice->status == 'draft' ? $invoice->get_due_date() : '', |
| 467 | 467 | ); |
| 468 | 468 | |
| 469 | - $data[] = apply_filters( 'wpinv_export_invoice_row', $row, $invoice ); |
|
| 469 | + $data[] = apply_filters('wpinv_export_invoice_row', $row, $invoice); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | return $data; |
@@ -482,31 +482,31 @@ discard block |
||
| 482 | 482 | 'return' => 'ids', |
| 483 | 483 | ); |
| 484 | 484 | |
| 485 | - if ( $this->status != 'any' ) { |
|
| 485 | + if ($this->status != 'any') { |
|
| 486 | 486 | $args['status'] = $this->status; |
| 487 | 487 | } else { |
| 488 | - $args['status'] = array_keys( wpinv_get_invoice_statuses( true ) ); |
|
| 488 | + $args['status'] = array_keys(wpinv_get_invoice_statuses(true)); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | - if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) { |
|
| 491 | + if (!empty($this->from_date) || !empty($this->to_date)) { |
|
| 492 | 492 | $args['date_query'] = array( |
| 493 | 493 | array( |
| 494 | - 'after' => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ), |
|
| 495 | - 'before' => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ), |
|
| 494 | + 'after' => date('Y-n-d 00:00:00', strtotime($this->from_date)), |
|
| 495 | + 'before' => date('Y-n-d 23:59:59', strtotime($this->to_date)), |
|
| 496 | 496 | 'inclusive' => true |
| 497 | 497 | ) |
| 498 | 498 | ); |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | - $invoices = wpinv_get_invoices( $args ); |
|
| 502 | - $total = !empty( $invoices ) ? count( $invoices ) : 0; |
|
| 501 | + $invoices = wpinv_get_invoices($args); |
|
| 502 | + $total = !empty($invoices) ? count($invoices) : 0; |
|
| 503 | 503 | $status = 100; |
| 504 | 504 | |
| 505 | - if ( $total > 0 ) { |
|
| 506 | - $status = ( ( $this->per_page * $this->step ) / $total ) * 100; |
|
| 505 | + if ($total > 0) { |
|
| 506 | + $status = (($this->per_page * $this->step) / $total) * 100; |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - if ( $status > 100 ) { |
|
| 509 | + if ($status > 100) { |
|
| 510 | 510 | $status = 100; |
| 511 | 511 | } |
| 512 | 512 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly. |
| 3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | 5 | class WPInv_EUVat { |
| 6 | 6 | private static $is_ajax = false; |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | private static $instance = false; |
| 9 | 9 | |
| 10 | 10 | public static function get_instance() { |
| 11 | - if ( !self::$instance ) { |
|
| 11 | + if (!self::$instance) { |
|
| 12 | 12 | self::$instance = new self(); |
| 13 | 13 | self::$instance->actions(); |
| 14 | 14 | } |
@@ -17,137 +17,137 @@ discard block |
||
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | public function __construct() { |
| 20 | - self::$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
| 20 | + self::$is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
| 21 | 21 | self::$default_country = wpinv_get_default_country(); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public static function actions() { |
| 25 | - if ( is_admin() ) { |
|
| 26 | - add_action( 'admin_enqueue_scripts', array( self::$instance, 'enqueue_admin_scripts' ) ); |
|
| 27 | - add_action( 'wpinv_settings_sections_taxes', array( self::$instance, 'section_vat_settings' ) ); |
|
| 28 | - add_action( 'wpinv_settings_taxes', array( self::$instance, 'vat_settings' ) ); |
|
| 29 | - add_filter( 'wpinv_settings_taxes-vat_sanitize', array( self::$instance, 'sanitize_vat_settings' ) ); |
|
| 30 | - add_filter( 'wpinv_settings_taxes-vat_rates_sanitize', array( self::$instance, 'sanitize_vat_rates' ) ); |
|
| 31 | - add_action( 'wp_ajax_wpinv_add_vat_class', array( self::$instance, 'add_class' ) ); |
|
| 32 | - add_action( 'wp_ajax_nopriv_wpinv_add_vat_class', array( self::$instance, 'add_class' ) ); |
|
| 33 | - add_action( 'wp_ajax_wpinv_delete_vat_class', array( self::$instance, 'delete_class' ) ); |
|
| 34 | - add_action( 'wp_ajax_nopriv_wpinv_delete_vat_class', array( self::$instance, 'delete_class' ) ); |
|
| 35 | - add_action( 'wp_ajax_wpinv_update_vat_rates', array( self::$instance, 'update_eu_rates' ) ); |
|
| 36 | - add_action( 'wp_ajax_nopriv_wpinv_update_vat_rates', array( self::$instance, 'update_eu_rates' ) ); |
|
| 37 | - add_action( 'wp_ajax_wpinv_geoip2', array( self::$instance, 'geoip2_download_database' ) ); |
|
| 38 | - add_action( 'wp_ajax_nopriv_wpinv_geoip2', array( self::$instance, 'geoip2_download_database' ) ); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - add_action( 'wp_enqueue_scripts', array( self::$instance, 'enqueue_vat_scripts' ) ); |
|
| 42 | - add_filter( 'wpinv_default_billing_country', array( self::$instance, 'get_user_country' ), 10 ); |
|
| 43 | - add_filter( 'wpinv_get_user_country', array( self::$instance, 'set_user_country' ), 10 ); |
|
| 44 | - add_action( 'wp_ajax_wpinv_vat_validate', array( self::$instance, 'ajax_vat_validate' ) ); |
|
| 45 | - add_action( 'wp_ajax_nopriv_wpinv_vat_validate', array( self::$instance, 'ajax_vat_validate' ) ); |
|
| 46 | - add_action( 'wp_ajax_wpinv_vat_reset', array( self::$instance, 'ajax_vat_reset' ) ); |
|
| 47 | - add_action( 'wp_ajax_nopriv_wpinv_vat_reset', array( self::$instance, 'ajax_vat_reset' ) ); |
|
| 48 | - add_action( 'wpinv_invoice_print_after_line_items', array( self::$instance, 'show_vat_notice' ), 999, 1 ); |
|
| 49 | - if ( wpinv_use_taxes() ) { |
|
| 50 | - add_action( 'wpinv_after_billing_fields', array( self::$instance, 'checkout_vat_fields' ) ); |
|
| 51 | - if ( self::allow_vat_rules() ) { |
|
| 52 | - add_action( 'wpinv_checkout_error_checks', array( self::$instance, 'checkout_vat_validate' ), 10, 2 ); |
|
| 53 | - add_filter( 'wpinv_tax_rate', array( self::$instance, 'get_rate' ), 10, 4 ); |
|
| 25 | + if (is_admin()) { |
|
| 26 | + add_action('admin_enqueue_scripts', array(self::$instance, 'enqueue_admin_scripts')); |
|
| 27 | + add_action('wpinv_settings_sections_taxes', array(self::$instance, 'section_vat_settings')); |
|
| 28 | + add_action('wpinv_settings_taxes', array(self::$instance, 'vat_settings')); |
|
| 29 | + add_filter('wpinv_settings_taxes-vat_sanitize', array(self::$instance, 'sanitize_vat_settings')); |
|
| 30 | + add_filter('wpinv_settings_taxes-vat_rates_sanitize', array(self::$instance, 'sanitize_vat_rates')); |
|
| 31 | + add_action('wp_ajax_wpinv_add_vat_class', array(self::$instance, 'add_class')); |
|
| 32 | + add_action('wp_ajax_nopriv_wpinv_add_vat_class', array(self::$instance, 'add_class')); |
|
| 33 | + add_action('wp_ajax_wpinv_delete_vat_class', array(self::$instance, 'delete_class')); |
|
| 34 | + add_action('wp_ajax_nopriv_wpinv_delete_vat_class', array(self::$instance, 'delete_class')); |
|
| 35 | + add_action('wp_ajax_wpinv_update_vat_rates', array(self::$instance, 'update_eu_rates')); |
|
| 36 | + add_action('wp_ajax_nopriv_wpinv_update_vat_rates', array(self::$instance, 'update_eu_rates')); |
|
| 37 | + add_action('wp_ajax_wpinv_geoip2', array(self::$instance, 'geoip2_download_database')); |
|
| 38 | + add_action('wp_ajax_nopriv_wpinv_geoip2', array(self::$instance, 'geoip2_download_database')); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + add_action('wp_enqueue_scripts', array(self::$instance, 'enqueue_vat_scripts')); |
|
| 42 | + add_filter('wpinv_default_billing_country', array(self::$instance, 'get_user_country'), 10); |
|
| 43 | + add_filter('wpinv_get_user_country', array(self::$instance, 'set_user_country'), 10); |
|
| 44 | + add_action('wp_ajax_wpinv_vat_validate', array(self::$instance, 'ajax_vat_validate')); |
|
| 45 | + add_action('wp_ajax_nopriv_wpinv_vat_validate', array(self::$instance, 'ajax_vat_validate')); |
|
| 46 | + add_action('wp_ajax_wpinv_vat_reset', array(self::$instance, 'ajax_vat_reset')); |
|
| 47 | + add_action('wp_ajax_nopriv_wpinv_vat_reset', array(self::$instance, 'ajax_vat_reset')); |
|
| 48 | + add_action('wpinv_invoice_print_after_line_items', array(self::$instance, 'show_vat_notice'), 999, 1); |
|
| 49 | + if (wpinv_use_taxes()) { |
|
| 50 | + add_action('wpinv_after_billing_fields', array(self::$instance, 'checkout_vat_fields')); |
|
| 51 | + if (self::allow_vat_rules()) { |
|
| 52 | + add_action('wpinv_checkout_error_checks', array(self::$instance, 'checkout_vat_validate'), 10, 2); |
|
| 53 | + add_filter('wpinv_tax_rate', array(self::$instance, 'get_rate'), 10, 4); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public static function get_eu_states( $sort = true ) { |
|
| 59 | - $eu_states = array( 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE' ); |
|
| 60 | - if ( $sort ) { |
|
| 61 | - $sort = sort( $eu_states ); |
|
| 58 | + public static function get_eu_states($sort = true) { |
|
| 59 | + $eu_states = array('AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE'); |
|
| 60 | + if ($sort) { |
|
| 61 | + $sort = sort($eu_states); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - return apply_filters( 'wpinv_get_eu_states', $eu_states, $sort ); |
|
| 64 | + return apply_filters('wpinv_get_eu_states', $eu_states, $sort); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - public static function get_gst_countries( $sort = true ) { |
|
| 68 | - $gst_countries = array( 'AU', 'NZ', 'CA', 'CN' ); |
|
| 67 | + public static function get_gst_countries($sort = true) { |
|
| 68 | + $gst_countries = array('AU', 'NZ', 'CA', 'CN'); |
|
| 69 | 69 | |
| 70 | - if ( $sort ) { |
|
| 71 | - $sort = sort( $gst_countries ); |
|
| 70 | + if ($sort) { |
|
| 71 | + $sort = sort($gst_countries); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - return apply_filters( 'wpinv_get_gst_countries', $gst_countries, $sort ); |
|
| 74 | + return apply_filters('wpinv_get_gst_countries', $gst_countries, $sort); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public static function is_eu_state( $country_code ) { |
|
| 78 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_eu_states() ) ? true : false; |
|
| 77 | + public static function is_eu_state($country_code) { |
|
| 78 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_eu_states()) ? true : false; |
|
| 79 | 79 | |
| 80 | - return apply_filters( 'wpinv_is_eu_state', $return, $country_code ); |
|
| 80 | + return apply_filters('wpinv_is_eu_state', $return, $country_code); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - public static function is_gst_country( $country_code ) { |
|
| 84 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_gst_countries() ) ? true : false; |
|
| 83 | + public static function is_gst_country($country_code) { |
|
| 84 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_gst_countries()) ? true : false; |
|
| 85 | 85 | |
| 86 | - return apply_filters( 'wpinv_is_gst_country', $return, $country_code ); |
|
| 86 | + return apply_filters('wpinv_is_gst_country', $return, $country_code); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public static function enqueue_vat_scripts() { |
| 90 | - if( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ) { |
|
| 90 | + if (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules')) { |
|
| 91 | 91 | self::load_vat_scripts(); |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public static function load_vat_scripts(){ |
|
| 96 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 95 | + public static function load_vat_scripts() { |
|
| 96 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 97 | 97 | |
| 98 | - wp_register_script( 'wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 99 | - wp_register_script( 'wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 98 | + wp_register_script('wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 99 | + wp_register_script('wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 100 | 100 | |
| 101 | - $vat_name = self::get_vat_name(); |
|
| 101 | + $vat_name = self::get_vat_name(); |
|
| 102 | 102 | |
| 103 | 103 | $vars = array(); |
| 104 | 104 | $vars['UseTaxes'] = wpinv_use_taxes(); |
| 105 | 105 | $vars['EUStates'] = self::get_eu_states(); |
| 106 | - $vars['NoRateSet'] = __( 'You have not set a rate. Do you want to continue?', 'invoicing' ); |
|
| 107 | - $vars['EmptyCompany'] = __( 'Please enter your registered company name!', 'invoicing' ); |
|
| 108 | - $vars['EmptyVAT'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name ); |
|
| 109 | - $vars['TotalsRefreshed'] = wp_sprintf( __( 'The invoice totals will be refreshed to update the %s.', 'invoicing' ), $vat_name ); |
|
| 110 | - $vars['ErrValidateVAT'] = wp_sprintf( __( 'Fail to validate the %s number!', 'invoicing' ), $vat_name ); |
|
| 111 | - $vars['ErrResetVAT'] = wp_sprintf( __( 'Fail to reset the %s number!', 'invoicing' ), $vat_name ); |
|
| 112 | - $vars['ErrInvalidVat'] = wp_sprintf( __( 'The %s number supplied does not have a valid format!', 'invoicing' ), $vat_name ); |
|
| 113 | - $vars['ErrInvalidResponse'] = __( 'An invalid response has been received from the server!', 'invoicing' ); |
|
| 106 | + $vars['NoRateSet'] = __('You have not set a rate. Do you want to continue?', 'invoicing'); |
|
| 107 | + $vars['EmptyCompany'] = __('Please enter your registered company name!', 'invoicing'); |
|
| 108 | + $vars['EmptyVAT'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name); |
|
| 109 | + $vars['TotalsRefreshed'] = wp_sprintf(__('The invoice totals will be refreshed to update the %s.', 'invoicing'), $vat_name); |
|
| 110 | + $vars['ErrValidateVAT'] = wp_sprintf(__('Fail to validate the %s number!', 'invoicing'), $vat_name); |
|
| 111 | + $vars['ErrResetVAT'] = wp_sprintf(__('Fail to reset the %s number!', 'invoicing'), $vat_name); |
|
| 112 | + $vars['ErrInvalidVat'] = wp_sprintf(__('The %s number supplied does not have a valid format!', 'invoicing'), $vat_name); |
|
| 113 | + $vars['ErrInvalidResponse'] = __('An invalid response has been received from the server!', 'invoicing'); |
|
| 114 | 114 | $vars['ApplyVATRules'] = $vars['UseTaxes'] ? self::allow_vat_rules() : false; |
| 115 | 115 | $vars['HideVatFields'] = $vars['ApplyVATRules'] ? self::hide_vat_fields() : true; |
| 116 | - $vars['ErrResponse'] = __( 'The request response is invalid!', 'invoicing' ); |
|
| 117 | - $vars['ErrRateResponse'] = __( 'The get rate request response is invalid', 'invoicing' ); |
|
| 118 | - $vars['PageRefresh'] = __( 'The page will be refreshed in 10 seconds to show the new options.', 'invoicing' ); |
|
| 119 | - $vars['RequestResponseNotValidJSON'] = __( 'The get rate request response is not valid JSON', 'invoicing' ); |
|
| 120 | - $vars['GetRateRequestFailed'] = __( 'The get rate request failed: ', 'invoicing' ); |
|
| 121 | - $vars['NoRateInformationInResponse'] = __( 'The get rate request response does not contain any rate information', 'invoicing' ); |
|
| 122 | - $vars['RatesUpdated'] = __( 'The rates have been updated. Press the save button to record these new rates.', 'invoicing' ); |
|
| 123 | - $vars['IPAddressInformation'] = __( 'IP Address Information', 'invoicing' ); |
|
| 124 | - $vars['VatValidating'] = wp_sprintf( __( 'Validating %s number...', 'invoicing' ), $vat_name ); |
|
| 125 | - $vars['VatReseting'] = __( 'Reseting...', 'invoicing' ); |
|
| 126 | - $vars['VatValidated'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
| 127 | - $vars['VatNotValidated'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
| 128 | - $vars['ConfirmDeleteClass'] = __( 'Are you sure you wish to delete this rates class?', 'invoicing' ); |
|
| 116 | + $vars['ErrResponse'] = __('The request response is invalid!', 'invoicing'); |
|
| 117 | + $vars['ErrRateResponse'] = __('The get rate request response is invalid', 'invoicing'); |
|
| 118 | + $vars['PageRefresh'] = __('The page will be refreshed in 10 seconds to show the new options.', 'invoicing'); |
|
| 119 | + $vars['RequestResponseNotValidJSON'] = __('The get rate request response is not valid JSON', 'invoicing'); |
|
| 120 | + $vars['GetRateRequestFailed'] = __('The get rate request failed: ', 'invoicing'); |
|
| 121 | + $vars['NoRateInformationInResponse'] = __('The get rate request response does not contain any rate information', 'invoicing'); |
|
| 122 | + $vars['RatesUpdated'] = __('The rates have been updated. Press the save button to record these new rates.', 'invoicing'); |
|
| 123 | + $vars['IPAddressInformation'] = __('IP Address Information', 'invoicing'); |
|
| 124 | + $vars['VatValidating'] = wp_sprintf(__('Validating %s number...', 'invoicing'), $vat_name); |
|
| 125 | + $vars['VatReseting'] = __('Reseting...', 'invoicing'); |
|
| 126 | + $vars['VatValidated'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
| 127 | + $vars['VatNotValidated'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
| 128 | + $vars['ConfirmDeleteClass'] = __('Are you sure you wish to delete this rates class?', 'invoicing'); |
|
| 129 | 129 | $vars['isFront'] = is_admin() ? false : true; |
| 130 | 130 | $vars['baseCountry'] = wpinv_get_default_country(); |
| 131 | - $vars['disableVATSameCountry'] = ( self::same_country_rule() == 'no' ? true : false ); |
|
| 132 | - $vars['disableVATSimpleCheck'] = wpinv_get_option( 'vat_offline_check' ) ? true : false; |
|
| 131 | + $vars['disableVATSameCountry'] = (self::same_country_rule() == 'no' ? true : false); |
|
| 132 | + $vars['disableVATSimpleCheck'] = wpinv_get_option('vat_offline_check') ? true : false; |
|
| 133 | 133 | |
| 134 | - wp_enqueue_script( 'wpinv-vat-validation-script' ); |
|
| 135 | - wp_enqueue_script( 'wpinv-vat-script' ); |
|
| 136 | - wp_localize_script( 'wpinv-vat-script', 'WPInv_VAT_Vars', $vars ); |
|
| 134 | + wp_enqueue_script('wpinv-vat-validation-script'); |
|
| 135 | + wp_enqueue_script('wpinv-vat-script'); |
|
| 136 | + wp_localize_script('wpinv-vat-script', 'WPInv_VAT_Vars', $vars); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | public static function enqueue_admin_scripts() { |
| 140 | - if( isset( $_GET['page'] ) && 'wpinv-settings' == $_GET['page'] ) { |
|
| 140 | + if (isset($_GET['page']) && 'wpinv-settings' == $_GET['page']) { |
|
| 141 | 141 | self::load_vat_scripts(); |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - public static function section_vat_settings( $sections ) { |
|
| 146 | - if ( !empty( $sections ) ) { |
|
| 147 | - $sections['vat'] = __( 'EU VAT Settings', 'invoicing' ); |
|
| 145 | + public static function section_vat_settings($sections) { |
|
| 146 | + if (!empty($sections)) { |
|
| 147 | + $sections['vat'] = __('EU VAT Settings', 'invoicing'); |
|
| 148 | 148 | |
| 149 | - if ( self::allow_vat_classes() ) { |
|
| 150 | - $sections['vat_rates'] = __( 'EU VAT Rates', 'invoicing' ); |
|
| 149 | + if (self::allow_vat_classes()) { |
|
| 150 | + $sections['vat_rates'] = __('EU VAT Rates', 'invoicing'); |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | return $sections; |
@@ -156,52 +156,52 @@ discard block |
||
| 156 | 156 | public static function vat_rates_settings() { |
| 157 | 157 | $vat_classes = self::get_rate_classes(); |
| 158 | 158 | $vat_rates = array(); |
| 159 | - $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_new'; |
|
| 160 | - $current_url = remove_query_arg( 'wpi_sub' ); |
|
| 159 | + $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_new'; |
|
| 160 | + $current_url = remove_query_arg('wpi_sub'); |
|
| 161 | 161 | |
| 162 | 162 | $vat_rates['vat_rates_header'] = array( |
| 163 | 163 | 'id' => 'vat_rates_header', |
| 164 | - 'name' => '<h3>' . __( 'Manage VAT Rates', 'invoicing' ) . '</h3>', |
|
| 164 | + 'name' => '<h3>' . __('Manage VAT Rates', 'invoicing') . '</h3>', |
|
| 165 | 165 | 'desc' => '', |
| 166 | 166 | 'type' => 'header', |
| 167 | 167 | 'size' => 'regular' |
| 168 | 168 | ); |
| 169 | 169 | $vat_rates['vat_rates_class'] = array( |
| 170 | 170 | 'id' => 'vat_rates_class', |
| 171 | - 'name' => __( 'Edit VAT Rates', 'invoicing' ), |
|
| 172 | - 'desc' => __( 'The standard rate will apply where no explicit rate is provided.', 'invoicing' ), |
|
| 171 | + 'name' => __('Edit VAT Rates', 'invoicing'), |
|
| 172 | + 'desc' => __('The standard rate will apply where no explicit rate is provided.', 'invoicing'), |
|
| 173 | 173 | 'type' => 'select', |
| 174 | - 'options' => array_merge( $vat_classes, array( '_new' => __( 'Add New Rate Class', 'invoicing' ) ) ), |
|
| 175 | - 'placeholder' => __( 'Select a VAT Rate', 'invoicing' ), |
|
| 174 | + 'options' => array_merge($vat_classes, array('_new' => __('Add New Rate Class', 'invoicing'))), |
|
| 175 | + 'placeholder' => __('Select a VAT Rate', 'invoicing'), |
|
| 176 | 176 | 'selected' => $vat_class, |
| 177 | 177 | 'class' => 'wpi_select2', |
| 178 | 178 | 'onchange' => 'document.location.href="' . $current_url . '&wpi_sub=" + this.value;', |
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | - if ( $vat_class != '_standard' && $vat_class != '_new' ) { |
|
| 181 | + if ($vat_class != '_standard' && $vat_class != '_new') { |
|
| 182 | 182 | $vat_rates['vat_rate_delete'] = array( |
| 183 | 183 | 'id' => 'vat_rate_delete', |
| 184 | 184 | 'type' => 'vat_rate_delete', |
| 185 | 185 | ); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if ( $vat_class == '_new' ) { |
|
| 188 | + if ($vat_class == '_new') { |
|
| 189 | 189 | $vat_rates['vat_rates_settings'] = array( |
| 190 | 190 | 'id' => 'vat_rates_settings', |
| 191 | - 'name' => '<h3>' . __( 'Add New Rate Class', 'invoicing' ) . '</h3>', |
|
| 191 | + 'name' => '<h3>' . __('Add New Rate Class', 'invoicing') . '</h3>', |
|
| 192 | 192 | 'type' => 'header', |
| 193 | 193 | ); |
| 194 | 194 | $vat_rates['vat_rate_name'] = array( |
| 195 | 195 | 'id' => 'vat_rate_name', |
| 196 | - 'name' => __( 'Name', 'invoicing' ), |
|
| 197 | - 'desc' => __( 'A short name for the new VAT Rate class', 'invoicing' ), |
|
| 196 | + 'name' => __('Name', 'invoicing'), |
|
| 197 | + 'desc' => __('A short name for the new VAT Rate class', 'invoicing'), |
|
| 198 | 198 | 'type' => 'text', |
| 199 | 199 | 'size' => 'regular', |
| 200 | 200 | ); |
| 201 | 201 | $vat_rates['vat_rate_desc'] = array( |
| 202 | 202 | 'id' => 'vat_rate_desc', |
| 203 | - 'name' => __( 'Description', 'invoicing' ), |
|
| 204 | - 'desc' => __( 'Manage VAT Rate class', 'invoicing' ), |
|
| 203 | + 'name' => __('Description', 'invoicing'), |
|
| 204 | + 'desc' => __('Manage VAT Rate class', 'invoicing'), |
|
| 205 | 205 | 'type' => 'text', |
| 206 | 206 | 'size' => 'regular', |
| 207 | 207 | ); |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $vat_rates['vat_rates'] = array( |
| 214 | 214 | 'id' => 'vat_rates', |
| 215 | 215 | 'name' => '<h3>' . $vat_classes[$vat_class] . '</h3>', |
| 216 | - 'desc' => self::get_class_desc( $vat_class ), |
|
| 216 | + 'desc' => self::get_class_desc($vat_class), |
|
| 217 | 217 | 'type' => 'vat_rates', |
| 218 | 218 | ); |
| 219 | 219 | } |
@@ -221,12 +221,12 @@ discard block |
||
| 221 | 221 | return $vat_rates; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - public static function vat_settings( $settings ) { |
|
| 225 | - if ( !empty( $settings ) ) { |
|
| 224 | + public static function vat_settings($settings) { |
|
| 225 | + if (!empty($settings)) { |
|
| 226 | 226 | $vat_settings = array(); |
| 227 | 227 | $vat_settings['vat_company_title'] = array( |
| 228 | 228 | 'id' => 'vat_company_title', |
| 229 | - 'name' => '<h3>' . __( 'Your Company Details', 'invoicing' ) . '</h3>', |
|
| 229 | + 'name' => '<h3>' . __('Your Company Details', 'invoicing') . '</h3>', |
|
| 230 | 230 | 'desc' => '', |
| 231 | 231 | 'type' => 'header', |
| 232 | 232 | 'size' => 'regular' |
@@ -234,22 +234,22 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | $vat_settings['vat_company_name'] = array( |
| 236 | 236 | 'id' => 'vat_company_name', |
| 237 | - 'name' => __( 'Your Company Name', 'invoicing' ), |
|
| 238 | - 'desc' => wp_sprintf(__( 'Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
| 237 | + 'name' => __('Your Company Name', 'invoicing'), |
|
| 238 | + 'desc' => wp_sprintf(__('Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
| 239 | 239 | 'type' => 'text', |
| 240 | 240 | 'size' => 'regular', |
| 241 | 241 | ); |
| 242 | 242 | |
| 243 | 243 | $vat_settings['vat_number'] = array( |
| 244 | 244 | 'id' => 'vat_number', |
| 245 | - 'name' => __( 'Your VAT Number', 'invoicing' ), |
|
| 245 | + 'name' => __('Your VAT Number', 'invoicing'), |
|
| 246 | 246 | 'type' => 'vat_number', |
| 247 | 247 | 'size' => 'regular', |
| 248 | 248 | ); |
| 249 | 249 | |
| 250 | 250 | $vat_settings['vat_settings_title'] = array( |
| 251 | 251 | 'id' => 'vat_settings_title', |
| 252 | - 'name' => '<h3>' . __( 'Apply VAT Settings', 'invoicing' ) . '</h3>', |
|
| 252 | + 'name' => '<h3>' . __('Apply VAT Settings', 'invoicing') . '</h3>', |
|
| 253 | 253 | 'desc' => '', |
| 254 | 254 | 'type' => 'header', |
| 255 | 255 | 'size' => 'regular' |
@@ -257,8 +257,8 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | $vat_settings['apply_vat_rules'] = array( |
| 259 | 259 | 'id' => 'apply_vat_rules', |
| 260 | - 'name' => __( 'Enable VAT Rules', 'invoicing' ), |
|
| 261 | - 'desc' => __( 'Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable unless you know what you are doing.', 'invoicing' ) . '</font>', |
|
| 260 | + 'name' => __('Enable VAT Rules', 'invoicing'), |
|
| 261 | + 'desc' => __('Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable unless you know what you are doing.', 'invoicing') . '</font>', |
|
| 262 | 262 | 'type' => 'checkbox', |
| 263 | 263 | 'std' => '1' |
| 264 | 264 | ); |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | $vat_settings['vat_prevent_b2c_purchase'] = array( |
| 276 | 276 | 'id' => 'vat_prevent_b2c_purchase', |
| 277 | - 'name' => __( 'Prevent EU B2C Sales', 'invoicing' ), |
|
| 278 | - 'desc' => __( 'Enable this option if you are not registered for VAT in the EU.', 'invoicing' ), |
|
| 277 | + 'name' => __('Prevent EU B2C Sales', 'invoicing'), |
|
| 278 | + 'desc' => __('Enable this option if you are not registered for VAT in the EU.', 'invoicing'), |
|
| 279 | 279 | 'type' => 'checkbox' |
| 280 | 280 | ); |
| 281 | 281 | |
@@ -283,22 +283,22 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | $vat_settings['vat_same_country_rule'] = array( |
| 285 | 285 | 'id' => 'vat_same_country_rule', |
| 286 | - 'name' => __( 'Same Country Rule', 'invoicing' ), |
|
| 287 | - 'desc' => __( 'Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing' ), |
|
| 286 | + 'name' => __('Same Country Rule', 'invoicing'), |
|
| 287 | + 'desc' => __('Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing'), |
|
| 288 | 288 | 'type' => 'select', |
| 289 | 289 | 'options' => array( |
| 290 | - '' => __( 'Normal', 'invoicing' ), |
|
| 291 | - 'no' => __( 'No VAT', 'invoicing' ), |
|
| 292 | - 'always' => __( 'Always apply VAT', 'invoicing' ), |
|
| 290 | + '' => __('Normal', 'invoicing'), |
|
| 291 | + 'no' => __('No VAT', 'invoicing'), |
|
| 292 | + 'always' => __('Always apply VAT', 'invoicing'), |
|
| 293 | 293 | ), |
| 294 | - 'placeholder' => __( 'Select an option', 'invoicing' ), |
|
| 294 | + 'placeholder' => __('Select an option', 'invoicing'), |
|
| 295 | 295 | 'std' => '', |
| 296 | 296 | 'class' => 'wpi_select2', |
| 297 | 297 | ); |
| 298 | 298 | |
| 299 | 299 | $vat_settings['vat_checkout_title'] = array( |
| 300 | 300 | 'id' => 'vat_checkout_title', |
| 301 | - 'name' => '<h3>' . __( 'Checkout Fields', 'invoicing' ) . '</h3>', |
|
| 301 | + 'name' => '<h3>' . __('Checkout Fields', 'invoicing') . '</h3>', |
|
| 302 | 302 | 'desc' => '', |
| 303 | 303 | 'type' => 'header', |
| 304 | 304 | 'size' => 'regular' |
@@ -306,14 +306,14 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | $vat_settings['vat_disable_fields'] = array( |
| 308 | 308 | 'id' => 'vat_disable_fields', |
| 309 | - 'name' => __( 'Disable VAT Fields', 'invoicing' ), |
|
| 310 | - 'desc' => __( 'Disable VAT fields if Invoicing is being used for GST.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing' ) . '</font>', |
|
| 309 | + 'name' => __('Disable VAT Fields', 'invoicing'), |
|
| 310 | + 'desc' => __('Disable VAT fields if Invoicing is being used for GST.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing') . '</font>', |
|
| 311 | 311 | 'type' => 'checkbox' |
| 312 | 312 | ); |
| 313 | 313 | |
| 314 | 314 | $vat_settings['vat_ip_lookup'] = array( |
| 315 | 315 | 'id' => 'vat_ip_lookup', |
| 316 | - 'name' => __( 'IP Country Look-up', 'invoicing' ), |
|
| 316 | + 'name' => __('IP Country Look-up', 'invoicing'), |
|
| 317 | 317 | 'type' => 'vat_ip_lookup', |
| 318 | 318 | 'size' => 'regular', |
| 319 | 319 | 'std' => 'default', |
@@ -322,21 +322,21 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | $vat_settings['hide_ip_address'] = array( |
| 324 | 324 | 'id' => 'hide_ip_address', |
| 325 | - 'name' => __( 'Hide IP Info at Checkout', 'invoicing' ), |
|
| 326 | - 'desc' => __( 'Hide the user IP info at checkout.', 'invoicing' ), |
|
| 325 | + 'name' => __('Hide IP Info at Checkout', 'invoicing'), |
|
| 326 | + 'desc' => __('Hide the user IP info at checkout.', 'invoicing'), |
|
| 327 | 327 | 'type' => 'checkbox' |
| 328 | 328 | ); |
| 329 | 329 | |
| 330 | 330 | $vat_settings['vat_ip_country_default'] = array( |
| 331 | 331 | 'id' => 'vat_ip_country_default', |
| 332 | - 'name' => __( 'Enable IP Country as Default', 'invoicing' ), |
|
| 333 | - 'desc' => __( 'Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing' ), |
|
| 332 | + 'name' => __('Enable IP Country as Default', 'invoicing'), |
|
| 333 | + 'desc' => __('Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing'), |
|
| 334 | 334 | 'type' => 'checkbox' |
| 335 | 335 | ); |
| 336 | 336 | |
| 337 | 337 | $vat_settings['vies_validation_title'] = array( |
| 338 | 338 | 'id' => 'vies_validation_title', |
| 339 | - 'name' => '<h3>' . __( 'VIES Validation', 'invoicing' ) . '</h3>', |
|
| 339 | + 'name' => '<h3>' . __('VIES Validation', 'invoicing') . '</h3>', |
|
| 340 | 340 | 'desc' => '', |
| 341 | 341 | 'type' => 'header', |
| 342 | 342 | 'size' => 'regular' |
@@ -344,37 +344,37 @@ discard block |
||
| 344 | 344 | |
| 345 | 345 | $vat_settings['vat_vies_check'] = array( |
| 346 | 346 | 'id' => 'vat_vies_check', |
| 347 | - 'name' => __( 'Disable VIES VAT ID Check', 'invoicing' ), |
|
| 348 | - 'desc' => wp_sprintf( __( 'Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
| 347 | + 'name' => __('Disable VIES VAT ID Check', 'invoicing'), |
|
| 348 | + 'desc' => wp_sprintf(__('Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
| 349 | 349 | 'type' => 'checkbox' |
| 350 | 350 | ); |
| 351 | 351 | |
| 352 | 352 | $vat_settings['vat_disable_company_name_check'] = array( |
| 353 | 353 | 'id' => 'vat_disable_company_name_check', |
| 354 | - 'name' => __( 'Disable VIES Name Check', 'invoicing' ), |
|
| 355 | - 'desc' => wp_sprintf( __( 'Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
| 354 | + 'name' => __('Disable VIES Name Check', 'invoicing'), |
|
| 355 | + 'desc' => wp_sprintf(__('Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
| 356 | 356 | 'type' => 'checkbox' |
| 357 | 357 | ); |
| 358 | 358 | |
| 359 | 359 | $vat_settings['vat_offline_check'] = array( |
| 360 | 360 | 'id' => 'vat_offline_check', |
| 361 | - 'name' => __( 'Disable Basic Checks', 'invoicing' ), |
|
| 362 | - 'desc' => __( 'Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing' ), |
|
| 361 | + 'name' => __('Disable Basic Checks', 'invoicing'), |
|
| 362 | + 'desc' => __('Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing'), |
|
| 363 | 363 | 'type' => 'checkbox' |
| 364 | 364 | ); |
| 365 | 365 | |
| 366 | 366 | |
| 367 | 367 | $settings['vat'] = $vat_settings; |
| 368 | 368 | |
| 369 | - if ( self::allow_vat_classes() ) { |
|
| 369 | + if (self::allow_vat_classes()) { |
|
| 370 | 370 | $settings['vat_rates'] = self::vat_rates_settings(); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | $eu_fallback_rate = array( |
| 374 | 374 | 'id' => 'eu_fallback_rate', |
| 375 | - 'name' => '<h3>' . __( 'VAT rate for EU member states', 'invoicing' ) . '</h3>', |
|
| 375 | + 'name' => '<h3>' . __('VAT rate for EU member states', 'invoicing') . '</h3>', |
|
| 376 | 376 | 'type' => 'eu_fallback_rate', |
| 377 | - 'desc' => __( 'Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing' ), |
|
| 377 | + 'desc' => __('Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing'), |
|
| 378 | 378 | 'std' => '20', |
| 379 | 379 | 'size' => 'small' |
| 380 | 380 | ); |
@@ -390,11 +390,11 @@ discard block |
||
| 390 | 390 | $database_url = 'http' . (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === 'on' ? 's' : '') . '://geolite.maxmind.com/download/geoip/database/'; |
| 391 | 391 | $destination_dir = $upload_dir['basedir'] . '/invoicing'; |
| 392 | 392 | |
| 393 | - if ( !is_dir( $destination_dir ) ) { |
|
| 394 | - mkdir( $destination_dir ); |
|
| 393 | + if (!is_dir($destination_dir)) { |
|
| 394 | + mkdir($destination_dir); |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - $database_files = array( |
|
| 397 | + $database_files = array( |
|
| 398 | 398 | 'country' => array( |
| 399 | 399 | 'source' => $database_url . 'GeoLite2-Country.mmdb.gz', |
| 400 | 400 | 'destination' => $destination_dir . '/GeoLite2-Country.mmdb', |
@@ -405,57 +405,57 @@ discard block |
||
| 405 | 405 | ) |
| 406 | 406 | ); |
| 407 | 407 | |
| 408 | - foreach( $database_files as $database => $files ) { |
|
| 409 | - $result = self::geoip2_download_file( $files['source'], $files['destination'] ); |
|
| 408 | + foreach ($database_files as $database => $files) { |
|
| 409 | + $result = self::geoip2_download_file($files['source'], $files['destination']); |
|
| 410 | 410 | |
| 411 | - if ( empty( $result['success'] ) ) { |
|
| 411 | + if (empty($result['success'])) { |
|
| 412 | 412 | echo $result['message']; |
| 413 | 413 | exit; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - wpinv_update_option( 'wpinv_geoip2_date_updated', current_time( 'timestamp' ) ); |
|
| 417 | - echo sprintf(__( 'GeoIP2 %s database updated successfully.', 'invoicing' ), $database ) . ' '; |
|
| 416 | + wpinv_update_option('wpinv_geoip2_date_updated', current_time('timestamp')); |
|
| 417 | + echo sprintf(__('GeoIP2 %s database updated successfully.', 'invoicing'), $database) . ' '; |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | exit; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - public static function geoip2_download_file( $source_url, $destination_file ) { |
|
| 423 | + public static function geoip2_download_file($source_url, $destination_file) { |
|
| 424 | 424 | $success = false; |
| 425 | 425 | $message = ''; |
| 426 | 426 | |
| 427 | - if ( !function_exists( 'download_url' ) ) { |
|
| 428 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
| 427 | + if (!function_exists('download_url')) { |
|
| 428 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - $temp_file = download_url( $source_url ); |
|
| 431 | + $temp_file = download_url($source_url); |
|
| 432 | 432 | |
| 433 | - if ( is_wp_error( $temp_file ) ) { |
|
| 434 | - $message = sprintf( __( 'Error while downloading GeoIp2 database( %s ): %s', 'invoicing' ), $source_url, $temp_file->get_error_message() ); |
|
| 433 | + if (is_wp_error($temp_file)) { |
|
| 434 | + $message = sprintf(__('Error while downloading GeoIp2 database( %s ): %s', 'invoicing'), $source_url, $temp_file->get_error_message()); |
|
| 435 | 435 | } else { |
| 436 | - $handle = gzopen( $temp_file, 'rb' ); |
|
| 436 | + $handle = gzopen($temp_file, 'rb'); |
|
| 437 | 437 | |
| 438 | - if ( $handle ) { |
|
| 439 | - $fopen = fopen( $destination_file, 'wb' ); |
|
| 440 | - if ( $fopen ) { |
|
| 441 | - while ( ( $data = gzread( $handle, 4096 ) ) != false ) { |
|
| 442 | - fwrite( $fopen, $data ); |
|
| 438 | + if ($handle) { |
|
| 439 | + $fopen = fopen($destination_file, 'wb'); |
|
| 440 | + if ($fopen) { |
|
| 441 | + while (($data = gzread($handle, 4096)) != false) { |
|
| 442 | + fwrite($fopen, $data); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - gzclose( $handle ); |
|
| 446 | - fclose( $fopen ); |
|
| 445 | + gzclose($handle); |
|
| 446 | + fclose($fopen); |
|
| 447 | 447 | |
| 448 | 448 | $success = true; |
| 449 | 449 | } else { |
| 450 | - gzclose( $handle ); |
|
| 451 | - $message = sprintf( __( 'Error could not open destination GeoIp2 database file for writing: %s', 'invoicing' ), $destination_file ); |
|
| 450 | + gzclose($handle); |
|
| 451 | + $message = sprintf(__('Error could not open destination GeoIp2 database file for writing: %s', 'invoicing'), $destination_file); |
|
| 452 | 452 | } |
| 453 | 453 | } else { |
| 454 | - $message = sprintf( __( 'Error could not open GeoIp2 database file for reading: %s', 'invoicing' ), $temp_file ); |
|
| 454 | + $message = sprintf(__('Error could not open GeoIp2 database file for reading: %s', 'invoicing'), $temp_file); |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - if ( file_exists( $temp_file ) ) { |
|
| 458 | - unlink( $temp_file ); |
|
| 457 | + if (file_exists($temp_file)) { |
|
| 458 | + unlink($temp_file); |
|
| 459 | 459 | } |
| 460 | 460 | } |
| 461 | 461 | |
@@ -467,11 +467,11 @@ discard block |
||
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | public static function load_geoip2() { |
| 470 | - if ( defined( 'WPINV_GEOIP2_LODDED' ) ) { |
|
| 470 | + if (defined('WPINV_GEOIP2_LODDED')) { |
|
| 471 | 471 | return; |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | - if ( !class_exists( '\MaxMind\Db\Reader' ) ) { |
|
| 474 | + if (!class_exists('\MaxMind\Db\Reader')) { |
|
| 475 | 475 | $maxmind_db_files = array( |
| 476 | 476 | 'Reader/Decoder.php', |
| 477 | 477 | 'Reader/InvalidDatabaseException.php', |
@@ -480,12 +480,12 @@ discard block |
||
| 480 | 480 | 'Reader.php', |
| 481 | 481 | ); |
| 482 | 482 | |
| 483 | - foreach ( $maxmind_db_files as $key => $file ) { |
|
| 484 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file ); |
|
| 483 | + foreach ($maxmind_db_files as $key => $file) { |
|
| 484 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file); |
|
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - if ( !class_exists( '\GeoIp2\Database\Reader' ) ) { |
|
| 488 | + if (!class_exists('\GeoIp2\Database\Reader')) { |
|
| 489 | 489 | $geoip2_files = array( |
| 490 | 490 | 'ProviderInterface.php', |
| 491 | 491 | 'Compat/JsonSerializable.php', |
@@ -519,23 +519,23 @@ discard block |
||
| 519 | 519 | 'WebService/Client.php', |
| 520 | 520 | ); |
| 521 | 521 | |
| 522 | - foreach ( $geoip2_files as $key => $file ) { |
|
| 523 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file ); |
|
| 522 | + foreach ($geoip2_files as $key => $file) { |
|
| 523 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file); |
|
| 524 | 524 | } |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | - define( 'WPINV_GEOIP2_LODDED', true ); |
|
| 527 | + define('WPINV_GEOIP2_LODDED', true); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | public static function geoip2_country_dbfile() { |
| 531 | 531 | $upload_dir = wp_upload_dir(); |
| 532 | 532 | |
| 533 | - if ( !isset( $upload_dir['basedir'] ) ) { |
|
| 533 | + if (!isset($upload_dir['basedir'])) { |
|
| 534 | 534 | return false; |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-Country.mmdb'; |
| 538 | - if ( !file_exists( $filename ) ) { |
|
| 538 | + if (!file_exists($filename)) { |
|
| 539 | 539 | return false; |
| 540 | 540 | } |
| 541 | 541 | |
@@ -545,12 +545,12 @@ discard block |
||
| 545 | 545 | public static function geoip2_city_dbfile() { |
| 546 | 546 | $upload_dir = wp_upload_dir(); |
| 547 | 547 | |
| 548 | - if ( !isset( $upload_dir['basedir'] ) ) { |
|
| 548 | + if (!isset($upload_dir['basedir'])) { |
|
| 549 | 549 | return false; |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-City.mmdb'; |
| 553 | - if ( !file_exists( $filename ) ) { |
|
| 553 | + if (!file_exists($filename)) { |
|
| 554 | 554 | return false; |
| 555 | 555 | } |
| 556 | 556 | |
@@ -561,10 +561,10 @@ discard block |
||
| 561 | 561 | try { |
| 562 | 562 | self::load_geoip2(); |
| 563 | 563 | |
| 564 | - if ( $filename = self::geoip2_country_dbfile() ) { |
|
| 565 | - return new \GeoIp2\Database\Reader( $filename ); |
|
| 564 | + if ($filename = self::geoip2_country_dbfile()) { |
|
| 565 | + return new \GeoIp2\Database\Reader($filename); |
|
| 566 | 566 | } |
| 567 | - } catch( Exception $e ) { |
|
| 567 | + } catch (Exception $e) { |
|
| 568 | 568 | return false; |
| 569 | 569 | } |
| 570 | 570 | |
@@ -575,173 +575,173 @@ discard block |
||
| 575 | 575 | try { |
| 576 | 576 | self::load_geoip2(); |
| 577 | 577 | |
| 578 | - if ( $filename = self::geoip2_city_dbfile() ) { |
|
| 579 | - return new \GeoIp2\Database\Reader( $filename ); |
|
| 578 | + if ($filename = self::geoip2_city_dbfile()) { |
|
| 579 | + return new \GeoIp2\Database\Reader($filename); |
|
| 580 | 580 | } |
| 581 | - } catch( Exception $e ) { |
|
| 581 | + } catch (Exception $e) { |
|
| 582 | 582 | return false; |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | return false; |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | - public static function geoip2_country_record( $ip_address ) { |
|
| 588 | + public static function geoip2_country_record($ip_address) { |
|
| 589 | 589 | try { |
| 590 | 590 | $reader = self::geoip2_country_reader(); |
| 591 | 591 | |
| 592 | - if ( $reader ) { |
|
| 593 | - $record = $reader->country( $ip_address ); |
|
| 592 | + if ($reader) { |
|
| 593 | + $record = $reader->country($ip_address); |
|
| 594 | 594 | |
| 595 | - if ( !empty( $record->country->isoCode ) ) { |
|
| 595 | + if (!empty($record->country->isoCode)) { |
|
| 596 | 596 | return $record; |
| 597 | 597 | } |
| 598 | 598 | } |
| 599 | - } catch(\InvalidArgumentException $e) { |
|
| 600 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
| 599 | + } catch (\InvalidArgumentException $e) { |
|
| 600 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
| 601 | 601 | |
| 602 | 602 | return false; |
| 603 | - } catch(\GeoIp2\Exception\AddressNotFoundException $e) { |
|
| 604 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
| 603 | + } catch (\GeoIp2\Exception\AddressNotFoundException $e) { |
|
| 604 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
| 605 | 605 | |
| 606 | 606 | return false; |
| 607 | - } catch( Exception $e ) { |
|
| 607 | + } catch (Exception $e) { |
|
| 608 | 608 | return false; |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | return false; |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | - public static function geoip2_city_record( $ip_address ) { |
|
| 614 | + public static function geoip2_city_record($ip_address) { |
|
| 615 | 615 | try { |
| 616 | 616 | $reader = self::geoip2_city_reader(); |
| 617 | 617 | |
| 618 | - if ( $reader ) { |
|
| 619 | - $record = $reader->city( $ip_address ); |
|
| 618 | + if ($reader) { |
|
| 619 | + $record = $reader->city($ip_address); |
|
| 620 | 620 | |
| 621 | - if ( !empty( $record->country->isoCode ) ) { |
|
| 621 | + if (!empty($record->country->isoCode)) { |
|
| 622 | 622 | return $record; |
| 623 | 623 | } |
| 624 | 624 | } |
| 625 | - } catch(\InvalidArgumentException $e) { |
|
| 626 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
| 625 | + } catch (\InvalidArgumentException $e) { |
|
| 626 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
| 627 | 627 | |
| 628 | 628 | return false; |
| 629 | - } catch(\GeoIp2\Exception\AddressNotFoundException $e) { |
|
| 630 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
| 629 | + } catch (\GeoIp2\Exception\AddressNotFoundException $e) { |
|
| 630 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
| 631 | 631 | |
| 632 | 632 | return false; |
| 633 | - } catch( Exception $e ) { |
|
| 633 | + } catch (Exception $e) { |
|
| 634 | 634 | return false; |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | return false; |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - public static function geoip2_country_code( $ip_address ) { |
|
| 641 | - $record = self::geoip2_country_record( $ip_address ); |
|
| 642 | - return !empty( $record->country->isoCode ) ? $record->country->isoCode : wpinv_get_default_country(); |
|
| 640 | + public static function geoip2_country_code($ip_address) { |
|
| 641 | + $record = self::geoip2_country_record($ip_address); |
|
| 642 | + return !empty($record->country->isoCode) ? $record->country->isoCode : wpinv_get_default_country(); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | // Find country by IP address. |
| 646 | - public static function get_country_by_ip( $ip = '' ) { |
|
| 646 | + public static function get_country_by_ip($ip = '') { |
|
| 647 | 647 | global $wpinv_ip_address_country; |
| 648 | 648 | |
| 649 | - if ( !empty( $wpinv_ip_address_country ) ) { |
|
| 649 | + if (!empty($wpinv_ip_address_country)) { |
|
| 650 | 650 | return $wpinv_ip_address_country; |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - if ( empty( $ip ) ) { |
|
| 653 | + if (empty($ip)) { |
|
| 654 | 654 | $ip = wpinv_get_ip(); |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - $ip_country_service = wpinv_get_option( 'vat_ip_lookup' ); |
|
| 658 | - $is_default = empty( $ip_country_service ) || $ip_country_service === 'default' ? true : false; |
|
| 657 | + $ip_country_service = wpinv_get_option('vat_ip_lookup'); |
|
| 658 | + $is_default = empty($ip_country_service) || $ip_country_service === 'default' ? true : false; |
|
| 659 | 659 | |
| 660 | - if ( !empty( $ip ) && $ip !== '127.0.0.1' ) { // For 127.0.0.1(localhost) use default country. |
|
| 661 | - if ( function_exists( 'geoip_country_code_by_name') && ( $ip_country_service === 'geoip' || $is_default ) ) { |
|
| 660 | + if (!empty($ip) && $ip !== '127.0.0.1') { // For 127.0.0.1(localhost) use default country. |
|
| 661 | + if (function_exists('geoip_country_code_by_name') && ($ip_country_service === 'geoip' || $is_default)) { |
|
| 662 | 662 | try { |
| 663 | - $wpinv_ip_address_country = geoip_country_code_by_name( $ip ); |
|
| 664 | - } catch( Exception $e ) { |
|
| 665 | - wpinv_error_log( $e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )' ); |
|
| 663 | + $wpinv_ip_address_country = geoip_country_code_by_name($ip); |
|
| 664 | + } catch (Exception $e) { |
|
| 665 | + wpinv_error_log($e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )'); |
|
| 666 | 666 | } |
| 667 | - } else if ( self::geoip2_country_dbfile() && ( $ip_country_service === 'geoip2' || $is_default ) ) { |
|
| 668 | - $wpinv_ip_address_country = self::geoip2_country_code( $ip ); |
|
| 669 | - } else if ( function_exists( 'simplexml_load_file' ) && ( $ip_country_service === 'geoplugin' || $is_default ) ) { |
|
| 670 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
| 667 | + } else if (self::geoip2_country_dbfile() && ($ip_country_service === 'geoip2' || $is_default)) { |
|
| 668 | + $wpinv_ip_address_country = self::geoip2_country_code($ip); |
|
| 669 | + } else if (function_exists('simplexml_load_file') && ($ip_country_service === 'geoplugin' || $is_default)) { |
|
| 670 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
| 671 | 671 | |
| 672 | - if ( !empty( $load_xml ) && !empty( $load_xml->geoplugin_countryCode ) ) { |
|
| 672 | + if (!empty($load_xml) && !empty($load_xml->geoplugin_countryCode)) { |
|
| 673 | 673 | $wpinv_ip_address_country = (string)$load_xml->geoplugin_countryCode; |
| 674 | 674 | } |
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | - if ( empty( $wpinv_ip_address_country ) ) { |
|
| 678 | + if (empty($wpinv_ip_address_country)) { |
|
| 679 | 679 | $wpinv_ip_address_country = wpinv_get_default_country(); |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | return $wpinv_ip_address_country; |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | - public static function sanitize_vat_settings( $input ) { |
|
| 685 | + public static function sanitize_vat_settings($input) { |
|
| 686 | 686 | global $wpinv_options; |
| 687 | 687 | |
| 688 | 688 | $valid = false; |
| 689 | 689 | $message = ''; |
| 690 | 690 | |
| 691 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
| 692 | - if ( empty( $wpinv_options['vat_offline_check'] ) ) { |
|
| 693 | - $valid = self::offline_check( $input['vat_number'] ); |
|
| 691 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
| 692 | + if (empty($wpinv_options['vat_offline_check'])) { |
|
| 693 | + $valid = self::offline_check($input['vat_number']); |
|
| 694 | 694 | } else { |
| 695 | 695 | $valid = true; |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - $message = $valid ? '' : __( 'VAT number not validated', 'invoicing' ); |
|
| 698 | + $message = $valid ? '' : __('VAT number not validated', 'invoicing'); |
|
| 699 | 699 | } else { |
| 700 | - $result = self::check_vat( $input['vat_number'] ); |
|
| 700 | + $result = self::check_vat($input['vat_number']); |
|
| 701 | 701 | |
| 702 | - if ( empty( $result['valid'] ) ) { |
|
| 702 | + if (empty($result['valid'])) { |
|
| 703 | 703 | $valid = false; |
| 704 | 704 | $message = $result['message']; |
| 705 | 705 | } else { |
| 706 | - $valid = ( isset( $result['company'] ) && ( $result['company'] == '---' || ( strcasecmp( trim( $result['company'] ), trim( $input['vat_company_name'] ) ) == 0 ) ) ) || !empty( $wpinv_options['vat_disable_company_name_check'] ); |
|
| 707 | - $message = $valid ? '' : __( 'The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing' ); |
|
| 706 | + $valid = (isset($result['company']) && ($result['company'] == '---' || (strcasecmp(trim($result['company']), trim($input['vat_company_name'])) == 0))) || !empty($wpinv_options['vat_disable_company_name_check']); |
|
| 707 | + $message = $valid ? '' : __('The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing'); |
|
| 708 | 708 | } |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | - if ( $message && self::is_vat_validated() != $valid ) { |
|
| 712 | - add_settings_error( 'wpinv-notices', '', $message, ( $valid ? 'updated' : 'error' ) ); |
|
| 711 | + if ($message && self::is_vat_validated() != $valid) { |
|
| 712 | + add_settings_error('wpinv-notices', '', $message, ($valid ? 'updated' : 'error')); |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | $input['vat_valid'] = $valid; |
| 716 | 716 | return $input; |
| 717 | 717 | } |
| 718 | 718 | |
| 719 | - public static function sanitize_vat_rates( $input ) { |
|
| 720 | - if( !current_user_can( 'manage_options' ) ) { |
|
| 721 | - add_settings_error( 'wpinv-notices', '', __( 'Your account does not have permission to add rate classes.', 'invoicing' ), 'error' ); |
|
| 719 | + public static function sanitize_vat_rates($input) { |
|
| 720 | + if (!current_user_can('manage_options')) { |
|
| 721 | + add_settings_error('wpinv-notices', '', __('Your account does not have permission to add rate classes.', 'invoicing'), 'error'); |
|
| 722 | 722 | return $input; |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | $vat_classes = self::get_rate_classes(); |
| 726 | - $vat_class = !empty( $_REQUEST['wpi_vat_class'] ) && isset( $vat_classes[$_REQUEST['wpi_vat_class']] )? sanitize_text_field( $_REQUEST['wpi_vat_class'] ) : ''; |
|
| 726 | + $vat_class = !empty($_REQUEST['wpi_vat_class']) && isset($vat_classes[$_REQUEST['wpi_vat_class']]) ? sanitize_text_field($_REQUEST['wpi_vat_class']) : ''; |
|
| 727 | 727 | |
| 728 | - if ( empty( $vat_class ) ) { |
|
| 729 | - add_settings_error( 'wpinv-notices', '', __( 'No valid VAT rates class contained in the request to save rates.', 'invoicing' ), 'error' ); |
|
| 728 | + if (empty($vat_class)) { |
|
| 729 | + add_settings_error('wpinv-notices', '', __('No valid VAT rates class contained in the request to save rates.', 'invoicing'), 'error'); |
|
| 730 | 730 | |
| 731 | 731 | return $input; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | - $new_rates = ! empty( $_POST['vat_rates'] ) ? array_values( $_POST['vat_rates'] ) : array(); |
|
| 734 | + $new_rates = !empty($_POST['vat_rates']) ? array_values($_POST['vat_rates']) : array(); |
|
| 735 | 735 | |
| 736 | - if ( $vat_class === '_standard' ) { |
|
| 736 | + if ($vat_class === '_standard') { |
|
| 737 | 737 | // Save the active rates in the invoice settings |
| 738 | - update_option( 'wpinv_tax_rates', $new_rates ); |
|
| 738 | + update_option('wpinv_tax_rates', $new_rates); |
|
| 739 | 739 | } else { |
| 740 | 740 | // Get the existing set of rates |
| 741 | 741 | $rates = self::get_non_standard_rates(); |
| 742 | 742 | $rates[$vat_class] = $new_rates; |
| 743 | 743 | |
| 744 | - update_option( 'wpinv_vat_rates', $rates ); |
|
| 744 | + update_option('wpinv_vat_rates', $rates); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | return $input; |
@@ -751,71 +751,71 @@ discard block |
||
| 751 | 751 | $response = array(); |
| 752 | 752 | $response['success'] = false; |
| 753 | 753 | |
| 754 | - if ( !current_user_can( 'manage_options' ) ) { |
|
| 755 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
| 756 | - wp_send_json( $response ); |
|
| 754 | + if (!current_user_can('manage_options')) { |
|
| 755 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
| 756 | + wp_send_json($response); |
|
| 757 | 757 | } |
| 758 | 758 | |
| 759 | - $vat_class_name = !empty( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : false; |
|
| 760 | - $vat_class_desc = !empty( $_POST['desc'] ) ? sanitize_text_field( $_POST['desc'] ) : false; |
|
| 759 | + $vat_class_name = !empty($_POST['name']) ? sanitize_text_field($_POST['name']) : false; |
|
| 760 | + $vat_class_desc = !empty($_POST['desc']) ? sanitize_text_field($_POST['desc']) : false; |
|
| 761 | 761 | |
| 762 | - if ( empty( $vat_class_name ) ) { |
|
| 763 | - $response['error'] = __( 'Select the VAT rate name', 'invoicing' ); |
|
| 764 | - wp_send_json( $response ); |
|
| 762 | + if (empty($vat_class_name)) { |
|
| 763 | + $response['error'] = __('Select the VAT rate name', 'invoicing'); |
|
| 764 | + wp_send_json($response); |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | $vat_classes = (array)self::get_rate_classes(); |
| 768 | 768 | |
| 769 | - if ( !empty( $vat_classes ) && in_array( strtolower( $vat_class_name ), array_map( 'strtolower', array_values( $vat_classes ) ) ) ) { |
|
| 770 | - $response['error'] = wp_sprintf( __( 'A VAT Rate name "%s" already exists', 'invoicing' ), $vat_class_name ); |
|
| 771 | - wp_send_json( $response ); |
|
| 769 | + if (!empty($vat_classes) && in_array(strtolower($vat_class_name), array_map('strtolower', array_values($vat_classes)))) { |
|
| 770 | + $response['error'] = wp_sprintf(__('A VAT Rate name "%s" already exists', 'invoicing'), $vat_class_name); |
|
| 771 | + wp_send_json($response); |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - $rate_class_key = normalize_whitespace( 'wpi-' . $vat_class_name ); |
|
| 775 | - $rate_class_key = sanitize_key( str_replace( " ", "-", $rate_class_key ) ); |
|
| 774 | + $rate_class_key = normalize_whitespace('wpi-' . $vat_class_name); |
|
| 775 | + $rate_class_key = sanitize_key(str_replace(" ", "-", $rate_class_key)); |
|
| 776 | 776 | |
| 777 | - $vat_classes = (array)self::get_rate_classes( true ); |
|
| 778 | - $vat_classes[$rate_class_key] = array( 'name' => $vat_class_name, 'desc' => $vat_class_desc ); |
|
| 777 | + $vat_classes = (array)self::get_rate_classes(true); |
|
| 778 | + $vat_classes[$rate_class_key] = array('name' => $vat_class_name, 'desc' => $vat_class_desc); |
|
| 779 | 779 | |
| 780 | - update_option( '_wpinv_vat_rate_classes', $vat_classes ); |
|
| 780 | + update_option('_wpinv_vat_rate_classes', $vat_classes); |
|
| 781 | 781 | |
| 782 | 782 | $response['success'] = true; |
| 783 | - $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=' . $rate_class_key ); |
|
| 783 | + $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=' . $rate_class_key); |
|
| 784 | 784 | |
| 785 | - wp_send_json( $response ); |
|
| 785 | + wp_send_json($response); |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | public static function delete_class() { |
| 789 | 789 | $response = array(); |
| 790 | 790 | $response['success'] = false; |
| 791 | 791 | |
| 792 | - if ( !current_user_can( 'manage_options' ) || !isset( $_POST['class'] ) ) { |
|
| 793 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
| 794 | - wp_send_json( $response ); |
|
| 792 | + if (!current_user_can('manage_options') || !isset($_POST['class'])) { |
|
| 793 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
| 794 | + wp_send_json($response); |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | - $vat_class = isset( $_POST['class'] ) && $_POST['class'] !== '' ? sanitize_text_field( $_POST['class'] ) : false; |
|
| 797 | + $vat_class = isset($_POST['class']) && $_POST['class'] !== '' ? sanitize_text_field($_POST['class']) : false; |
|
| 798 | 798 | $vat_classes = (array)self::get_rate_classes(); |
| 799 | 799 | |
| 800 | - if ( !isset( $vat_classes[$vat_class] ) ) { |
|
| 801 | - $response['error'] = __( 'Requested class does not exists', 'invoicing' ); |
|
| 802 | - wp_send_json( $response ); |
|
| 800 | + if (!isset($vat_classes[$vat_class])) { |
|
| 801 | + $response['error'] = __('Requested class does not exists', 'invoicing'); |
|
| 802 | + wp_send_json($response); |
|
| 803 | 803 | } |
| 804 | 804 | |
| 805 | - if ( $vat_class == '_new' || $vat_class == '_standard' ) { |
|
| 806 | - $response['error'] = __( 'You can not delete standard rates class', 'invoicing' ); |
|
| 807 | - wp_send_json( $response ); |
|
| 805 | + if ($vat_class == '_new' || $vat_class == '_standard') { |
|
| 806 | + $response['error'] = __('You can not delete standard rates class', 'invoicing'); |
|
| 807 | + wp_send_json($response); |
|
| 808 | 808 | } |
| 809 | 809 | |
| 810 | - $vat_classes = (array)self::get_rate_classes( true ); |
|
| 811 | - unset( $vat_classes[$vat_class] ); |
|
| 810 | + $vat_classes = (array)self::get_rate_classes(true); |
|
| 811 | + unset($vat_classes[$vat_class]); |
|
| 812 | 812 | |
| 813 | - update_option( '_wpinv_vat_rate_classes', $vat_classes ); |
|
| 813 | + update_option('_wpinv_vat_rate_classes', $vat_classes); |
|
| 814 | 814 | |
| 815 | 815 | $response['success'] = true; |
| 816 | - $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=_new' ); |
|
| 816 | + $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=_new'); |
|
| 817 | 817 | |
| 818 | - wp_send_json( $response ); |
|
| 818 | + wp_send_json($response); |
|
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | public static function update_eu_rates() { |
@@ -824,72 +824,72 @@ discard block |
||
| 824 | 824 | $response['error'] = null; |
| 825 | 825 | $response['data'] = null; |
| 826 | 826 | |
| 827 | - if ( !current_user_can( 'manage_options' ) ) { |
|
| 828 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
| 829 | - wp_send_json( $response ); |
|
| 827 | + if (!current_user_can('manage_options')) { |
|
| 828 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
| 829 | + wp_send_json($response); |
|
| 830 | 830 | } |
| 831 | 831 | |
| 832 | - $group = !empty( $_POST['group'] ) ? sanitize_text_field( $_POST['group'] ) : ''; |
|
| 833 | - $euvatrates = self::request_euvatrates( $group ); |
|
| 832 | + $group = !empty($_POST['group']) ? sanitize_text_field($_POST['group']) : ''; |
|
| 833 | + $euvatrates = self::request_euvatrates($group); |
|
| 834 | 834 | |
| 835 | - if ( !empty( $euvatrates ) ) { |
|
| 836 | - if ( !empty( $euvatrates['success'] ) && !empty( $euvatrates['rates'] ) ) { |
|
| 835 | + if (!empty($euvatrates)) { |
|
| 836 | + if (!empty($euvatrates['success']) && !empty($euvatrates['rates'])) { |
|
| 837 | 837 | $response['success'] = true; |
| 838 | 838 | $response['data']['rates'] = $euvatrates['rates']; |
| 839 | - } else if ( !empty( $euvatrates['error'] ) ) { |
|
| 839 | + } else if (!empty($euvatrates['error'])) { |
|
| 840 | 840 | $response['error'] = $euvatrates['error']; |
| 841 | 841 | } |
| 842 | 842 | } |
| 843 | 843 | |
| 844 | - wp_send_json( $response ); |
|
| 844 | + wp_send_json($response); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | public static function hide_vat_fields() { |
| 848 | - $hide = wpinv_get_option( 'vat_disable_fields' ); |
|
| 848 | + $hide = wpinv_get_option('vat_disable_fields'); |
|
| 849 | 849 | |
| 850 | - return apply_filters( 'wpinv_hide_vat_fields', $hide ); |
|
| 850 | + return apply_filters('wpinv_hide_vat_fields', $hide); |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | public static function same_country_rule() { |
| 854 | - $same_country_rule = wpinv_get_option( 'vat_same_country_rule' ); |
|
| 854 | + $same_country_rule = wpinv_get_option('vat_same_country_rule'); |
|
| 855 | 855 | |
| 856 | - return apply_filters( 'wpinv_vat_same_country_rule', $same_country_rule ); |
|
| 856 | + return apply_filters('wpinv_vat_same_country_rule', $same_country_rule); |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | public static function get_vat_name() { |
| 860 | - $vat_name = wpinv_get_option( 'vat_name' ); |
|
| 861 | - $vat_name = !empty( $vat_name ) ? $vat_name : 'VAT'; |
|
| 860 | + $vat_name = wpinv_get_option('vat_name'); |
|
| 861 | + $vat_name = !empty($vat_name) ? $vat_name : 'VAT'; |
|
| 862 | 862 | |
| 863 | - return apply_filters( 'wpinv_get_owner_vat_name', $vat_name ); |
|
| 863 | + return apply_filters('wpinv_get_owner_vat_name', $vat_name); |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | public static function get_company_name() { |
| 867 | - $company_name = wpinv_get_option( 'vat_company_name' ); |
|
| 867 | + $company_name = wpinv_get_option('vat_company_name'); |
|
| 868 | 868 | |
| 869 | - return apply_filters( 'wpinv_get_owner_company_name', $company_name ); |
|
| 869 | + return apply_filters('wpinv_get_owner_company_name', $company_name); |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | public static function get_vat_number() { |
| 873 | - $vat_number = wpinv_get_option( 'vat_number' ); |
|
| 873 | + $vat_number = wpinv_get_option('vat_number'); |
|
| 874 | 874 | |
| 875 | - return apply_filters( 'wpinv_get_owner_vat_number', $vat_number ); |
|
| 875 | + return apply_filters('wpinv_get_owner_vat_number', $vat_number); |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | public static function is_vat_validated() { |
| 879 | - $validated = self::get_vat_number() && wpinv_get_option( 'vat_valid' ); |
|
| 879 | + $validated = self::get_vat_number() && wpinv_get_option('vat_valid'); |
|
| 880 | 880 | |
| 881 | - return apply_filters( 'wpinv_is_owner_vat_validated', $validated ); |
|
| 881 | + return apply_filters('wpinv_is_owner_vat_validated', $validated); |
|
| 882 | 882 | } |
| 883 | 883 | |
| 884 | - public static function sanitize_vat( $vat_number, $country_code = '' ) { |
|
| 885 | - $vat_number = str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) ); |
|
| 884 | + public static function sanitize_vat($vat_number, $country_code = '') { |
|
| 885 | + $vat_number = str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number))); |
|
| 886 | 886 | |
| 887 | - if ( empty( $country_code ) ) { |
|
| 888 | - $country_code = substr( $vat_number, 0, 2 ); |
|
| 887 | + if (empty($country_code)) { |
|
| 888 | + $country_code = substr($vat_number, 0, 2); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | - if ( strpos( $vat_number , $country_code ) === 0 ) { |
|
| 892 | - $vat = str_replace( $country_code, '', $vat_number ); |
|
| 891 | + if (strpos($vat_number, $country_code) === 0) { |
|
| 892 | + $vat = str_replace($country_code, '', $vat_number); |
|
| 893 | 893 | } else { |
| 894 | 894 | $vat = $country_code . $vat_number; |
| 895 | 895 | } |
@@ -902,140 +902,140 @@ discard block |
||
| 902 | 902 | return $return; |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | - public static function offline_check( $vat_number, $country_code = '', $formatted = false ) { |
|
| 906 | - $vat = self::sanitize_vat( $vat_number, $country_code ); |
|
| 905 | + public static function offline_check($vat_number, $country_code = '', $formatted = false) { |
|
| 906 | + $vat = self::sanitize_vat($vat_number, $country_code); |
|
| 907 | 907 | $vat_number = $vat['vat_number']; |
| 908 | 908 | $country_code = $vat['iso']; |
| 909 | 909 | $regex = array(); |
| 910 | 910 | |
| 911 | - switch ( $country_code ) { |
|
| 911 | + switch ($country_code) { |
|
| 912 | 912 | case 'AT': |
| 913 | - $regex[] = '/^(AT)U(\d{8})$/'; // Austria |
|
| 913 | + $regex[] = '/^(AT)U(\d{8})$/'; // Austria |
|
| 914 | 914 | break; |
| 915 | 915 | case 'BE': |
| 916 | - $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium |
|
| 916 | + $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium |
|
| 917 | 917 | break; |
| 918 | 918 | case 'BG': |
| 919 | - $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria |
|
| 919 | + $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria |
|
| 920 | 920 | break; |
| 921 | 921 | case 'CH': |
| 922 | 922 | case 'CHE': |
| 923 | - $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU) |
|
| 923 | + $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU) |
|
| 924 | 924 | break; |
| 925 | 925 | case 'CY': |
| 926 | - $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus |
|
| 926 | + $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus |
|
| 927 | 927 | break; |
| 928 | 928 | case 'CZ': |
| 929 | - $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic |
|
| 929 | + $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic |
|
| 930 | 930 | break; |
| 931 | 931 | case 'DE': |
| 932 | - $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany |
|
| 932 | + $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany |
|
| 933 | 933 | break; |
| 934 | 934 | case 'DK': |
| 935 | - $regex[] = '/^(DK)(\d{8})$/'; // Denmark |
|
| 935 | + $regex[] = '/^(DK)(\d{8})$/'; // Denmark |
|
| 936 | 936 | break; |
| 937 | 937 | case 'EE': |
| 938 | - $regex[] = '/^(EE)(10\d{7})$/'; // Estonia |
|
| 938 | + $regex[] = '/^(EE)(10\d{7})$/'; // Estonia |
|
| 939 | 939 | break; |
| 940 | 940 | case 'EL': |
| 941 | - $regex[] = '/^(EL)(\d{9})$/'; // Greece |
|
| 941 | + $regex[] = '/^(EL)(\d{9})$/'; // Greece |
|
| 942 | 942 | break; |
| 943 | 943 | case 'ES': |
| 944 | - $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities) |
|
| 945 | - $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities) |
|
| 946 | - $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1) |
|
| 947 | - $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2) |
|
| 944 | + $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities) |
|
| 945 | + $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities) |
|
| 946 | + $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1) |
|
| 947 | + $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2) |
|
| 948 | 948 | break; |
| 949 | 949 | case 'EU': |
| 950 | - $regex[] = '/^(EU)(\d{9})$/'; // EU-type |
|
| 950 | + $regex[] = '/^(EU)(\d{9})$/'; // EU-type |
|
| 951 | 951 | break; |
| 952 | 952 | case 'FI': |
| 953 | - $regex[] = '/^(FI)(\d{8})$/'; // Finland |
|
| 953 | + $regex[] = '/^(FI)(\d{8})$/'; // Finland |
|
| 954 | 954 | break; |
| 955 | 955 | case 'FR': |
| 956 | - $regex[] = '/^(FR)(\d{11})$/'; // France (1) |
|
| 957 | - $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2) |
|
| 958 | - $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3) |
|
| 959 | - $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4) |
|
| 956 | + $regex[] = '/^(FR)(\d{11})$/'; // France (1) |
|
| 957 | + $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2) |
|
| 958 | + $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3) |
|
| 959 | + $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4) |
|
| 960 | 960 | break; |
| 961 | 961 | case 'GB': |
| 962 | - $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard) |
|
| 963 | - $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches) |
|
| 964 | - $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government) |
|
| 965 | - $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority) |
|
| 962 | + $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard) |
|
| 963 | + $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches) |
|
| 964 | + $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government) |
|
| 965 | + $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority) |
|
| 966 | 966 | break; |
| 967 | 967 | case 'GR': |
| 968 | - $regex[] = '/^(GR)(\d{8,9})$/'; // Greece |
|
| 968 | + $regex[] = '/^(GR)(\d{8,9})$/'; // Greece |
|
| 969 | 969 | break; |
| 970 | 970 | case 'HR': |
| 971 | - $regex[] = '/^(HR)(\d{11})$/'; // Croatia |
|
| 971 | + $regex[] = '/^(HR)(\d{11})$/'; // Croatia |
|
| 972 | 972 | break; |
| 973 | 973 | case 'HU': |
| 974 | - $regex[] = '/^(HU)(\d{8})$/'; // Hungary |
|
| 974 | + $regex[] = '/^(HU)(\d{8})$/'; // Hungary |
|
| 975 | 975 | break; |
| 976 | 976 | case 'IE': |
| 977 | - $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1) |
|
| 978 | - $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2) |
|
| 979 | - $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013) |
|
| 977 | + $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1) |
|
| 978 | + $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2) |
|
| 979 | + $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013) |
|
| 980 | 980 | break; |
| 981 | 981 | case 'IT': |
| 982 | - $regex[] = '/^(IT)(\d{11})$/'; // Italy |
|
| 982 | + $regex[] = '/^(IT)(\d{11})$/'; // Italy |
|
| 983 | 983 | break; |
| 984 | 984 | case 'LV': |
| 985 | - $regex[] = '/^(LV)(\d{11})$/'; // Latvia |
|
| 985 | + $regex[] = '/^(LV)(\d{11})$/'; // Latvia |
|
| 986 | 986 | break; |
| 987 | 987 | case 'LT': |
| 988 | - $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania |
|
| 988 | + $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania |
|
| 989 | 989 | break; |
| 990 | 990 | case 'LU': |
| 991 | - $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg |
|
| 991 | + $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg |
|
| 992 | 992 | break; |
| 993 | 993 | case 'MT': |
| 994 | - $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta |
|
| 994 | + $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta |
|
| 995 | 995 | break; |
| 996 | 996 | case 'NL': |
| 997 | - $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands |
|
| 997 | + $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands |
|
| 998 | 998 | break; |
| 999 | 999 | case 'NO': |
| 1000 | - $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU) |
|
| 1000 | + $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU) |
|
| 1001 | 1001 | break; |
| 1002 | 1002 | case 'PL': |
| 1003 | - $regex[] = '/^(PL)(\d{10})$/'; // Poland |
|
| 1003 | + $regex[] = '/^(PL)(\d{10})$/'; // Poland |
|
| 1004 | 1004 | break; |
| 1005 | 1005 | case 'PT': |
| 1006 | - $regex[] = '/^(PT)(\d{9})$/'; // Portugal |
|
| 1006 | + $regex[] = '/^(PT)(\d{9})$/'; // Portugal |
|
| 1007 | 1007 | break; |
| 1008 | 1008 | case 'RO': |
| 1009 | - $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania |
|
| 1009 | + $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania |
|
| 1010 | 1010 | break; |
| 1011 | 1011 | case 'RS': |
| 1012 | - $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU) |
|
| 1012 | + $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU) |
|
| 1013 | 1013 | break; |
| 1014 | 1014 | case 'SI': |
| 1015 | - $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia |
|
| 1015 | + $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia |
|
| 1016 | 1016 | break; |
| 1017 | 1017 | case 'SK': |
| 1018 | - $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic |
|
| 1018 | + $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic |
|
| 1019 | 1019 | break; |
| 1020 | 1020 | case 'SE': |
| 1021 | - $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden |
|
| 1021 | + $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden |
|
| 1022 | 1022 | break; |
| 1023 | 1023 | default: |
| 1024 | 1024 | $regex = array(); |
| 1025 | 1025 | break; |
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | - if ( empty( $regex ) ) { |
|
| 1028 | + if (empty($regex)) { |
|
| 1029 | 1029 | return false; |
| 1030 | 1030 | } |
| 1031 | 1031 | |
| 1032 | - foreach ( $regex as $pattern ) { |
|
| 1032 | + foreach ($regex as $pattern) { |
|
| 1033 | 1033 | $matches = null; |
| 1034 | - preg_match_all( $pattern, $vat_number, $matches ); |
|
| 1034 | + preg_match_all($pattern, $vat_number, $matches); |
|
| 1035 | 1035 | |
| 1036 | - if ( !empty( $matches[1][0] ) && !empty( $matches[2][0] ) ) { |
|
| 1037 | - if ( $formatted ) { |
|
| 1038 | - return array( 'code' => $matches[1][0], 'number' => $matches[2][0] ); |
|
| 1036 | + if (!empty($matches[1][0]) && !empty($matches[2][0])) { |
|
| 1037 | + if ($formatted) { |
|
| 1038 | + return array('code' => $matches[1][0], 'number' => $matches[2][0]); |
|
| 1039 | 1039 | } else { |
| 1040 | 1040 | return true; |
| 1041 | 1041 | } |
@@ -1045,75 +1045,75 @@ discard block |
||
| 1045 | 1045 | return false; |
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | - public static function vies_check( $vat_number, $country_code = '', $result = false ) { |
|
| 1049 | - $vat = self::sanitize_vat( $vat_number, $country_code ); |
|
| 1048 | + public static function vies_check($vat_number, $country_code = '', $result = false) { |
|
| 1049 | + $vat = self::sanitize_vat($vat_number, $country_code); |
|
| 1050 | 1050 | $vat_number = $vat['vat']; |
| 1051 | 1051 | $iso = $vat['iso']; |
| 1052 | 1052 | |
| 1053 | - $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode( $iso ) . '&iso=' . urlencode( $iso ) . '&vat=' . urlencode( $vat_number ); |
|
| 1053 | + $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode($iso) . '&iso=' . urlencode($iso) . '&vat=' . urlencode($vat_number); |
|
| 1054 | 1054 | |
| 1055 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
| 1056 | - $response = file_get_contents( $url ); |
|
| 1057 | - } else if ( function_exists( 'curl_init' ) ) { |
|
| 1055 | + if (ini_get('allow_url_fopen')) { |
|
| 1056 | + $response = file_get_contents($url); |
|
| 1057 | + } else if (function_exists('curl_init')) { |
|
| 1058 | 1058 | $ch = curl_init(); |
| 1059 | 1059 | |
| 1060 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
| 1061 | - curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 ); |
|
| 1062 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
| 1063 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 ); |
|
| 1064 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); |
|
| 1060 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 1061 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); |
|
| 1062 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 1063 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
| 1064 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
| 1065 | 1065 | |
| 1066 | - $response = curl_exec( $ch ); |
|
| 1066 | + $response = curl_exec($ch); |
|
| 1067 | 1067 | |
| 1068 | - if ( curl_errno( $ch ) ) { |
|
| 1069 | - wpinv_error_log( curl_error( $ch ), 'VIES CHECK ERROR' ); |
|
| 1068 | + if (curl_errno($ch)) { |
|
| 1069 | + wpinv_error_log(curl_error($ch), 'VIES CHECK ERROR'); |
|
| 1070 | 1070 | $response = ''; |
| 1071 | 1071 | } |
| 1072 | 1072 | |
| 1073 | - curl_close( $ch ); |
|
| 1073 | + curl_close($ch); |
|
| 1074 | 1074 | } else { |
| 1075 | - wpinv_error_log( 'To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR' ); |
|
| 1075 | + wpinv_error_log('To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR'); |
|
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | - if ( empty( $response ) ) { |
|
| 1078 | + if (empty($response)) { |
|
| 1079 | 1079 | return $result; |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | - if ( preg_match( '/invalid VAT number/i', $response ) ) { |
|
| 1082 | + if (preg_match('/invalid VAT number/i', $response)) { |
|
| 1083 | 1083 | return false; |
| 1084 | - } else if ( preg_match( '/valid VAT number/i', $response, $matches ) ) { |
|
| 1085 | - $content = explode( "valid VAT number", htmlentities( $response ) ); |
|
| 1084 | + } else if (preg_match('/valid VAT number/i', $response, $matches)) { |
|
| 1085 | + $content = explode("valid VAT number", htmlentities($response)); |
|
| 1086 | 1086 | |
| 1087 | - if ( !empty( $content[1] ) ) { |
|
| 1088 | - preg_match_all( '/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode( $content[1] ), $matches ); |
|
| 1087 | + if (!empty($content[1])) { |
|
| 1088 | + preg_match_all('/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode($content[1]), $matches); |
|
| 1089 | 1089 | |
| 1090 | - if ( !empty( $matches[2] ) && $matches[3] ) { |
|
| 1090 | + if (!empty($matches[2]) && $matches[3]) { |
|
| 1091 | 1091 | $return = array(); |
| 1092 | 1092 | |
| 1093 | - foreach ( $matches[2] as $key => $label ) { |
|
| 1094 | - $label = trim( $label ); |
|
| 1093 | + foreach ($matches[2] as $key => $label) { |
|
| 1094 | + $label = trim($label); |
|
| 1095 | 1095 | |
| 1096 | - switch ( strtolower( $label ) ) { |
|
| 1096 | + switch (strtolower($label)) { |
|
| 1097 | 1097 | case 'member state': |
| 1098 | - $return['state'] = trim( strip_tags( $matches[3][$key] ) ); |
|
| 1098 | + $return['state'] = trim(strip_tags($matches[3][$key])); |
|
| 1099 | 1099 | break; |
| 1100 | 1100 | case 'vat number': |
| 1101 | - $return['number'] = trim( strip_tags( $matches[3][$key] ) ); |
|
| 1101 | + $return['number'] = trim(strip_tags($matches[3][$key])); |
|
| 1102 | 1102 | break; |
| 1103 | 1103 | case 'name': |
| 1104 | - $return['company'] = trim( strip_tags( $matches[3][$key] ) ); |
|
| 1104 | + $return['company'] = trim(strip_tags($matches[3][$key])); |
|
| 1105 | 1105 | break; |
| 1106 | 1106 | case 'address': |
| 1107 | - $address = str_replace( array( "<br><br>", "<br /><br />", "<br/><br/>" ), "<br>", html_entity_decode( trim( $matches[3][$key] ) ) ); |
|
| 1108 | - $return['address'] = trim( strip_tags( $address, '<br>' ) ); |
|
| 1107 | + $address = str_replace(array("<br><br>", "<br /><br />", "<br/><br/>"), "<br>", html_entity_decode(trim($matches[3][$key]))); |
|
| 1108 | + $return['address'] = trim(strip_tags($address, '<br>')); |
|
| 1109 | 1109 | break; |
| 1110 | 1110 | case 'consultation number': |
| 1111 | - $return['consultation'] = trim( strip_tags( $matches[3][$key] ) ); |
|
| 1111 | + $return['consultation'] = trim(strip_tags($matches[3][$key])); |
|
| 1112 | 1112 | break; |
| 1113 | 1113 | } |
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | - if ( !empty( $return ) ) { |
|
| 1116 | + if (!empty($return)) { |
|
| 1117 | 1117 | return $return; |
| 1118 | 1118 | } |
| 1119 | 1119 | } |
@@ -1125,55 +1125,55 @@ discard block |
||
| 1125 | 1125 | } |
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | - public static function check_vat( $vat_number, $country_code = '' ) { |
|
| 1128 | + public static function check_vat($vat_number, $country_code = '') { |
|
| 1129 | 1129 | $vat_name = self::get_vat_name(); |
| 1130 | 1130 | |
| 1131 | 1131 | $return = array(); |
| 1132 | 1132 | $return['valid'] = false; |
| 1133 | - $return['message'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
| 1133 | + $return['message'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
| 1134 | 1134 | |
| 1135 | - if ( !wpinv_get_option( 'vat_offline_check' ) && !self::offline_check( $vat_number, $country_code ) ) { |
|
| 1135 | + if (!wpinv_get_option('vat_offline_check') && !self::offline_check($vat_number, $country_code)) { |
|
| 1136 | 1136 | return $return; |
| 1137 | 1137 | } |
| 1138 | 1138 | |
| 1139 | - $response = self::vies_check( $vat_number, $country_code ); |
|
| 1139 | + $response = self::vies_check($vat_number, $country_code); |
|
| 1140 | 1140 | |
| 1141 | - if ( $response ) { |
|
| 1142 | - $return['valid'] = true; |
|
| 1141 | + if ($response) { |
|
| 1142 | + $return['valid'] = true; |
|
| 1143 | 1143 | |
| 1144 | - if ( is_array( $response ) ) { |
|
| 1145 | - $return['company'] = isset( $response['company'] ) ? $response['company'] : ''; |
|
| 1146 | - $return['address'] = isset( $response['address'] ) ? $response['address'] : ''; |
|
| 1144 | + if (is_array($response)) { |
|
| 1145 | + $return['company'] = isset($response['company']) ? $response['company'] : ''; |
|
| 1146 | + $return['address'] = isset($response['address']) ? $response['address'] : ''; |
|
| 1147 | 1147 | $return['message'] = $return['company'] . '<br/>' . $return['address']; |
| 1148 | 1148 | } |
| 1149 | 1149 | } else { |
| 1150 | 1150 | $return['valid'] = false; |
| 1151 | - $return['message'] = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name ); |
|
| 1151 | + $return['message'] = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name); |
|
| 1152 | 1152 | } |
| 1153 | 1153 | |
| 1154 | 1154 | return $return; |
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | - public static function request_euvatrates( $group ) { |
|
| 1157 | + public static function request_euvatrates($group) { |
|
| 1158 | 1158 | $response = array(); |
| 1159 | 1159 | $response['success'] = false; |
| 1160 | 1160 | $response['error'] = null; |
| 1161 | 1161 | $response['eurates'] = null; |
| 1162 | 1162 | |
| 1163 | 1163 | $euvatrates_url = 'https://euvatrates.com/rates.json'; |
| 1164 | - $euvatrates_url = apply_filters( 'wpinv_euvatrates_url', $euvatrates_url ); |
|
| 1165 | - $api_response = wp_remote_get( $euvatrates_url ); |
|
| 1164 | + $euvatrates_url = apply_filters('wpinv_euvatrates_url', $euvatrates_url); |
|
| 1165 | + $api_response = wp_remote_get($euvatrates_url); |
|
| 1166 | 1166 | |
| 1167 | 1167 | try { |
| 1168 | - if ( is_wp_error( $api_response ) ) { |
|
| 1169 | - $response['error'] = __( $api_response->get_error_message(), 'invoicing' ); |
|
| 1168 | + if (is_wp_error($api_response)) { |
|
| 1169 | + $response['error'] = __($api_response->get_error_message(), 'invoicing'); |
|
| 1170 | 1170 | } else { |
| 1171 | - $body = json_decode( $api_response['body'] ); |
|
| 1171 | + $body = json_decode($api_response['body']); |
|
| 1172 | 1172 | |
| 1173 | - if ( isset( $body->rates ) ) { |
|
| 1173 | + if (isset($body->rates)) { |
|
| 1174 | 1174 | $rates = array(); |
| 1175 | 1175 | |
| 1176 | - foreach ( $body->rates as $country_code => $rate ) { |
|
| 1176 | + foreach ($body->rates as $country_code => $rate) { |
|
| 1177 | 1177 | $vat_rate = array(); |
| 1178 | 1178 | $vat_rate['country'] = $rate->country; |
| 1179 | 1179 | $vat_rate['standard'] = (float)$rate->standard_rate; |
@@ -1181,7 +1181,7 @@ discard block |
||
| 1181 | 1181 | $vat_rate['superreduced'] = (float)$rate->super_reduced_rate; |
| 1182 | 1182 | $vat_rate['parking'] = (float)$rate->parking_rate; |
| 1183 | 1183 | |
| 1184 | - if ( $group !== '' && in_array( $group, array( 'standard', 'reduced', 'superreduced', 'parking' ) ) ) { |
|
| 1184 | + if ($group !== '' && in_array($group, array('standard', 'reduced', 'superreduced', 'parking'))) { |
|
| 1185 | 1185 | $vat_rate_group = array(); |
| 1186 | 1186 | $vat_rate_group['country'] = $rate->country; |
| 1187 | 1187 | $vat_rate_group[$group] = $vat_rate[$group]; |
@@ -1193,79 +1193,79 @@ discard block |
||
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | 1195 | $response['success'] = true; |
| 1196 | - $response['rates'] = apply_filters( 'wpinv_process_euvatrates', $rates, $api_response, $group ); |
|
| 1196 | + $response['rates'] = apply_filters('wpinv_process_euvatrates', $rates, $api_response, $group); |
|
| 1197 | 1197 | } else { |
| 1198 | - $response['error'] = __( 'No EU rates found!', 'invoicing' ); |
|
| 1198 | + $response['error'] = __('No EU rates found!', 'invoicing'); |
|
| 1199 | 1199 | } |
| 1200 | 1200 | } |
| 1201 | - } catch ( Exception $e ) { |
|
| 1202 | - $response['error'] = __( $e->getMessage(), 'invoicing' ); |
|
| 1201 | + } catch (Exception $e) { |
|
| 1202 | + $response['error'] = __($e->getMessage(), 'invoicing'); |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | - return apply_filters( 'wpinv_response_euvatrates', $response, $group ); |
|
| 1205 | + return apply_filters('wpinv_response_euvatrates', $response, $group); |
|
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | - public static function requires_vat( $requires_vat = false, $user_id = 0, $is_digital = null ) { |
|
| 1208 | + public static function requires_vat($requires_vat = false, $user_id = 0, $is_digital = null) { |
|
| 1209 | 1209 | global $wpi_item_id, $wpi_country; |
| 1210 | 1210 | |
| 1211 | - if ( !empty( $_POST['wpinv_country'] ) ) { |
|
| 1212 | - $country_code = trim( $_POST['wpinv_country'] ); |
|
| 1213 | - } else if ( !empty( $_POST['country'] ) ) { |
|
| 1214 | - $country_code = trim( $_POST['country'] ); |
|
| 1215 | - } else if ( !empty( $wpi_country ) ) { |
|
| 1211 | + if (!empty($_POST['wpinv_country'])) { |
|
| 1212 | + $country_code = trim($_POST['wpinv_country']); |
|
| 1213 | + } else if (!empty($_POST['country'])) { |
|
| 1214 | + $country_code = trim($_POST['country']); |
|
| 1215 | + } else if (!empty($wpi_country)) { |
|
| 1216 | 1216 | $country_code = $wpi_country; |
| 1217 | 1217 | } else { |
| 1218 | - $country_code = self::get_user_country( '', $user_id ); |
|
| 1218 | + $country_code = self::get_user_country('', $user_id); |
|
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | - if ( $is_digital === null && $wpi_item_id ) { |
|
| 1222 | - $is_digital = $wpi_item_id ? self::item_has_digital_rule( $wpi_item_id ) : self::allow_vat_rules(); |
|
| 1221 | + if ($is_digital === null && $wpi_item_id) { |
|
| 1222 | + $is_digital = $wpi_item_id ? self::item_has_digital_rule($wpi_item_id) : self::allow_vat_rules(); |
|
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | - if ( !empty( $country_code ) ) { |
|
| 1226 | - $requires_vat = ( self::is_eu_state( $country_code ) && ( self::is_eu_state( self::$default_country ) || $is_digital ) ) || ( self::is_gst_country( $country_code ) && self::is_gst_country( self::$default_country ) ); |
|
| 1225 | + if (!empty($country_code)) { |
|
| 1226 | + $requires_vat = (self::is_eu_state($country_code) && (self::is_eu_state(self::$default_country) || $is_digital)) || (self::is_gst_country($country_code) && self::is_gst_country(self::$default_country)); |
|
| 1227 | 1227 | } |
| 1228 | 1228 | |
| 1229 | - return apply_filters( 'wpinv_requires_vat', $requires_vat, $user_id ); |
|
| 1229 | + return apply_filters('wpinv_requires_vat', $requires_vat, $user_id); |
|
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | - public static function tax_label( $label = '' ) { |
|
| 1232 | + public static function tax_label($label = '') { |
|
| 1233 | 1233 | global $wpi_requires_vat; |
| 1234 | 1234 | |
| 1235 | - if ( !( $wpi_requires_vat !== 0 && $wpi_requires_vat ) ) { |
|
| 1236 | - $wpi_requires_vat = self::requires_vat( 0, false ); |
|
| 1235 | + if (!($wpi_requires_vat !== 0 && $wpi_requires_vat)) { |
|
| 1236 | + $wpi_requires_vat = self::requires_vat(0, false); |
|
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | - return $wpi_requires_vat ? __( self::get_vat_name(), 'invoicing' ) : ( $label ? $label : __( 'Tax', 'invoicing' ) ); |
|
| 1239 | + return $wpi_requires_vat ? __(self::get_vat_name(), 'invoicing') : ($label ? $label : __('Tax', 'invoicing')); |
|
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | 1242 | public static function standard_rates_label() { |
| 1243 | - return __( 'Standard Rates', 'invoicing' ); |
|
| 1243 | + return __('Standard Rates', 'invoicing'); |
|
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | - public static function get_rate_classes( $with_desc = false ) { |
|
| 1247 | - $rate_classes_option = get_option( '_wpinv_vat_rate_classes', true ); |
|
| 1248 | - $classes = maybe_unserialize( $rate_classes_option ); |
|
| 1246 | + public static function get_rate_classes($with_desc = false) { |
|
| 1247 | + $rate_classes_option = get_option('_wpinv_vat_rate_classes', true); |
|
| 1248 | + $classes = maybe_unserialize($rate_classes_option); |
|
| 1249 | 1249 | |
| 1250 | - if ( empty( $classes ) || !is_array( $classes ) ) { |
|
| 1250 | + if (empty($classes) || !is_array($classes)) { |
|
| 1251 | 1251 | $classes = array(); |
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | $rate_classes = array(); |
| 1255 | - if ( !array_key_exists( '_standard', $classes ) ) { |
|
| 1256 | - if ( $with_desc ) { |
|
| 1257 | - $rate_classes['_standard'] = array( 'name' => self::standard_rates_label(), 'desc' => __( 'EU member states standard VAT rates', 'invoicing' ) ); |
|
| 1255 | + if (!array_key_exists('_standard', $classes)) { |
|
| 1256 | + if ($with_desc) { |
|
| 1257 | + $rate_classes['_standard'] = array('name' => self::standard_rates_label(), 'desc' => __('EU member states standard VAT rates', 'invoicing')); |
|
| 1258 | 1258 | } else { |
| 1259 | 1259 | $rate_classes['_standard'] = self::standard_rates_label(); |
| 1260 | 1260 | } |
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | - foreach ( $classes as $key => $class ) { |
|
| 1264 | - $name = !empty( $class['name'] ) ? __( $class['name'], 'invoicing' ) : $key; |
|
| 1265 | - $desc = !empty( $class['desc'] ) ? __( $class['desc'], 'invoicing' ) : ''; |
|
| 1263 | + foreach ($classes as $key => $class) { |
|
| 1264 | + $name = !empty($class['name']) ? __($class['name'], 'invoicing') : $key; |
|
| 1265 | + $desc = !empty($class['desc']) ? __($class['desc'], 'invoicing') : ''; |
|
| 1266 | 1266 | |
| 1267 | - if ( $with_desc ) { |
|
| 1268 | - $rate_classes[$key] = array( 'name' => $name, 'desc' => $desc ); |
|
| 1267 | + if ($with_desc) { |
|
| 1268 | + $rate_classes[$key] = array('name' => $name, 'desc' => $desc); |
|
| 1269 | 1269 | } else { |
| 1270 | 1270 | $rate_classes[$key] = $name; |
| 1271 | 1271 | } |
@@ -1276,15 +1276,15 @@ discard block |
||
| 1276 | 1276 | |
| 1277 | 1277 | public static function get_all_classes() { |
| 1278 | 1278 | $classes = self::get_rate_classes(); |
| 1279 | - $classes['_exempt'] = __( 'Exempt (0%)', 'invoicing' ); |
|
| 1279 | + $classes['_exempt'] = __('Exempt (0%)', 'invoicing'); |
|
| 1280 | 1280 | |
| 1281 | - return apply_filters( 'wpinv_vat_get_all_classes', $classes ); |
|
| 1281 | + return apply_filters('wpinv_vat_get_all_classes', $classes); |
|
| 1282 | 1282 | } |
| 1283 | 1283 | |
| 1284 | - public static function get_class_desc( $rate_class ) { |
|
| 1285 | - $rate_classes = self::get_rate_classes( true ); |
|
| 1284 | + public static function get_class_desc($rate_class) { |
|
| 1285 | + $rate_classes = self::get_rate_classes(true); |
|
| 1286 | 1286 | |
| 1287 | - if ( !empty( $rate_classes ) && isset( $rate_classes[$rate_class] ) && isset( $rate_classes[$rate_class]['desc'] ) ) { |
|
| 1287 | + if (!empty($rate_classes) && isset($rate_classes[$rate_class]) && isset($rate_classes[$rate_class]['desc'])) { |
|
| 1288 | 1288 | return $rate_classes[$rate_class]['desc']; |
| 1289 | 1289 | } |
| 1290 | 1290 | |
@@ -1300,106 +1300,106 @@ discard block |
||
| 1300 | 1300 | 'increased' => 'Increased' |
| 1301 | 1301 | ); |
| 1302 | 1302 | |
| 1303 | - return apply_filters( 'wpinv_get_vat_groups', $vat_groups ); |
|
| 1303 | + return apply_filters('wpinv_get_vat_groups', $vat_groups); |
|
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | 1306 | public static function get_rules() { |
| 1307 | 1307 | $vat_rules = array( |
| 1308 | - 'digital' => __( 'Digital Product', 'invoicing' ), |
|
| 1309 | - 'physical' => __( 'Physical Product', 'invoicing' ) |
|
| 1308 | + 'digital' => __('Digital Product', 'invoicing'), |
|
| 1309 | + 'physical' => __('Physical Product', 'invoicing') |
|
| 1310 | 1310 | ); |
| 1311 | - return apply_filters( 'wpinv_get_vat_rules', $vat_rules ); |
|
| 1311 | + return apply_filters('wpinv_get_vat_rules', $vat_rules); |
|
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | - public static function get_vat_rates( $class ) { |
|
| 1315 | - if ( $class === '_standard' ) { |
|
| 1314 | + public static function get_vat_rates($class) { |
|
| 1315 | + if ($class === '_standard') { |
|
| 1316 | 1316 | return wpinv_get_tax_rates(); |
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | 1319 | $rates = self::get_non_standard_rates(); |
| 1320 | 1320 | |
| 1321 | - return array_key_exists( $class, $rates ) ? $rates[$class] : array(); |
|
| 1321 | + return array_key_exists($class, $rates) ? $rates[$class] : array(); |
|
| 1322 | 1322 | } |
| 1323 | 1323 | |
| 1324 | 1324 | public static function get_non_standard_rates() { |
| 1325 | - $option = get_option( 'wpinv_vat_rates', array()); |
|
| 1326 | - return is_array( $option ) ? $option : array(); |
|
| 1325 | + $option = get_option('wpinv_vat_rates', array()); |
|
| 1326 | + return is_array($option) ? $option : array(); |
|
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | 1329 | public static function allow_vat_rules() { |
| 1330 | - return ( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ? true : false ); |
|
| 1330 | + return (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules') ? true : false); |
|
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | 1333 | public static function allow_vat_classes() { |
| 1334 | 1334 | return false; // TODO |
| 1335 | - return ( wpinv_get_option( 'vat_allow_classes' ) ? true : false ); |
|
| 1335 | + return (wpinv_get_option('vat_allow_classes') ? true : false); |
|
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | - public static function get_item_class( $postID ) { |
|
| 1339 | - $class = get_post_meta( $postID, '_wpinv_vat_class', true ); |
|
| 1338 | + public static function get_item_class($postID) { |
|
| 1339 | + $class = get_post_meta($postID, '_wpinv_vat_class', true); |
|
| 1340 | 1340 | |
| 1341 | - if ( empty( $class ) ) { |
|
| 1341 | + if (empty($class)) { |
|
| 1342 | 1342 | $class = '_standard'; |
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | - return apply_filters( 'wpinv_get_item_vat_class', $class, $postID ); |
|
| 1345 | + return apply_filters('wpinv_get_item_vat_class', $class, $postID); |
|
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | - public static function item_class_label( $postID ) { |
|
| 1348 | + public static function item_class_label($postID) { |
|
| 1349 | 1349 | $vat_classes = self::get_all_classes(); |
| 1350 | 1350 | |
| 1351 | - $class = self::get_item_class( $postID ); |
|
| 1352 | - $class = isset( $vat_classes[$class] ) ? $vat_classes[$class] : __( $class, 'invoicing' ); |
|
| 1351 | + $class = self::get_item_class($postID); |
|
| 1352 | + $class = isset($vat_classes[$class]) ? $vat_classes[$class] : __($class, 'invoicing'); |
|
| 1353 | 1353 | |
| 1354 | - return apply_filters( 'wpinv_item_class_label', $class, $postID ); |
|
| 1354 | + return apply_filters('wpinv_item_class_label', $class, $postID); |
|
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | - public static function get_item_rule( $postID ) { |
|
| 1358 | - $rule_type = get_post_meta( $postID, '_wpinv_vat_rule', true ); |
|
| 1357 | + public static function get_item_rule($postID) { |
|
| 1358 | + $rule_type = get_post_meta($postID, '_wpinv_vat_rule', true); |
|
| 1359 | 1359 | |
| 1360 | - if ( empty( $rule_type ) ) { |
|
| 1360 | + if (empty($rule_type)) { |
|
| 1361 | 1361 | $rule_type = self::allow_vat_rules() ? 'digital' : 'physical'; |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | - return apply_filters( 'wpinv_item_get_vat_rule', $rule_type, $postID ); |
|
| 1364 | + return apply_filters('wpinv_item_get_vat_rule', $rule_type, $postID); |
|
| 1365 | 1365 | } |
| 1366 | 1366 | |
| 1367 | - public static function item_rule_label( $postID ) { |
|
| 1367 | + public static function item_rule_label($postID) { |
|
| 1368 | 1368 | $vat_rules = self::get_rules(); |
| 1369 | - $vat_rule = self::get_item_rule( $postID ); |
|
| 1370 | - $vat_rule = isset( $vat_rules[$vat_rule] ) ? $vat_rules[$vat_rule] : $vat_rule; |
|
| 1369 | + $vat_rule = self::get_item_rule($postID); |
|
| 1370 | + $vat_rule = isset($vat_rules[$vat_rule]) ? $vat_rules[$vat_rule] : $vat_rule; |
|
| 1371 | 1371 | |
| 1372 | - return apply_filters( 'wpinv_item_rule_label', $vat_rule, $postID ); |
|
| 1372 | + return apply_filters('wpinv_item_rule_label', $vat_rule, $postID); |
|
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | - public static function item_has_digital_rule( $item_id = 0 ) { |
|
| 1376 | - return self::get_item_rule( $item_id ) == 'digital' ? true : false; |
|
| 1375 | + public static function item_has_digital_rule($item_id = 0) { |
|
| 1376 | + return self::get_item_rule($item_id) == 'digital' ? true : false; |
|
| 1377 | 1377 | } |
| 1378 | 1378 | |
| 1379 | - public static function invoice_has_digital_rule( $invoice = 0 ) { |
|
| 1380 | - if ( !self::allow_vat_rules() ) { |
|
| 1379 | + public static function invoice_has_digital_rule($invoice = 0) { |
|
| 1380 | + if (!self::allow_vat_rules()) { |
|
| 1381 | 1381 | return false; |
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | - if ( empty( $invoice ) ) { |
|
| 1384 | + if (empty($invoice)) { |
|
| 1385 | 1385 | return true; |
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | - if ( is_int( $invoice ) ) { |
|
| 1389 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 1388 | + if (is_int($invoice)) { |
|
| 1389 | + $invoice = new WPInv_Invoice($invoice); |
|
| 1390 | 1390 | } |
| 1391 | 1391 | |
| 1392 | - if ( !( is_object( $invoice ) && is_a( $invoice, 'WPInv_Invoice' ) ) ) { |
|
| 1392 | + if (!(is_object($invoice) && is_a($invoice, 'WPInv_Invoice'))) { |
|
| 1393 | 1393 | return true; |
| 1394 | 1394 | } |
| 1395 | 1395 | |
| 1396 | - $cart_items = $invoice->get_cart_details(); |
|
| 1396 | + $cart_items = $invoice->get_cart_details(); |
|
| 1397 | 1397 | |
| 1398 | - if ( !empty( $cart_items ) ) { |
|
| 1398 | + if (!empty($cart_items)) { |
|
| 1399 | 1399 | $has_digital_rule = false; |
| 1400 | 1400 | |
| 1401 | - foreach ( $cart_items as $key => $item ) { |
|
| 1402 | - if ( self::item_has_digital_rule( $item['id'] ) ) { |
|
| 1401 | + foreach ($cart_items as $key => $item) { |
|
| 1402 | + if (self::item_has_digital_rule($item['id'])) { |
|
| 1403 | 1403 | $has_digital_rule = true; |
| 1404 | 1404 | break; |
| 1405 | 1405 | } |
@@ -1411,67 +1411,67 @@ discard block |
||
| 1411 | 1411 | return $has_digital_rule; |
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | - public static function item_is_taxable( $item_id = 0, $country = false, $state = false ) { |
|
| 1415 | - if ( !wpinv_use_taxes() ) { |
|
| 1414 | + public static function item_is_taxable($item_id = 0, $country = false, $state = false) { |
|
| 1415 | + if (!wpinv_use_taxes()) { |
|
| 1416 | 1416 | return false; |
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | 1419 | $is_taxable = true; |
| 1420 | 1420 | |
| 1421 | - if ( !empty( $item_id ) && self::get_item_class( $item_id ) == '_exempt' ) { |
|
| 1421 | + if (!empty($item_id) && self::get_item_class($item_id) == '_exempt') { |
|
| 1422 | 1422 | $is_taxable = false; |
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | - return apply_filters( 'wpinv_item_is_taxable', $is_taxable, $item_id, $country , $state ); |
|
| 1425 | + return apply_filters('wpinv_item_is_taxable', $is_taxable, $item_id, $country, $state); |
|
| 1426 | 1426 | } |
| 1427 | 1427 | |
| 1428 | - public static function find_rate( $country, $state, $rate, $class ) { |
|
| 1428 | + public static function find_rate($country, $state, $rate, $class) { |
|
| 1429 | 1429 | global $wpi_zero_tax; |
| 1430 | 1430 | |
| 1431 | - if ( $class === '_exempt' || $wpi_zero_tax ) { |
|
| 1431 | + if ($class === '_exempt' || $wpi_zero_tax) { |
|
| 1432 | 1432 | return 0; |
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | - $tax_rates = wpinv_get_tax_rates(); |
|
| 1435 | + $tax_rates = wpinv_get_tax_rates(); |
|
| 1436 | 1436 | |
| 1437 | - if ( $class !== '_standard' ) { |
|
| 1438 | - $class_rates = self::get_vat_rates( $class ); |
|
| 1437 | + if ($class !== '_standard') { |
|
| 1438 | + $class_rates = self::get_vat_rates($class); |
|
| 1439 | 1439 | |
| 1440 | - if ( is_array( $class_rates ) ) { |
|
| 1440 | + if (is_array($class_rates)) { |
|
| 1441 | 1441 | $indexed_class_rates = array(); |
| 1442 | 1442 | |
| 1443 | - foreach ( $class_rates as $key => $cr ) { |
|
| 1443 | + foreach ($class_rates as $key => $cr) { |
|
| 1444 | 1444 | $indexed_class_rates[$cr['country']] = $cr; |
| 1445 | 1445 | } |
| 1446 | 1446 | |
| 1447 | - $tax_rates = array_map( function( $tr ) use( $indexed_class_rates ) { |
|
| 1447 | + $tax_rates = array_map(function($tr) use($indexed_class_rates) { |
|
| 1448 | 1448 | $tr_country = $tr['country']; |
| 1449 | - if ( !isset( $indexed_class_rates[$tr_country] ) ) { |
|
| 1449 | + if (!isset($indexed_class_rates[$tr_country])) { |
|
| 1450 | 1450 | return $tr; |
| 1451 | 1451 | } |
| 1452 | 1452 | $icr = $indexed_class_rates[$tr_country]; |
| 1453 | - return ( empty( $icr['rate'] ) && $icr['rate'] !== '0' ) ? $tr : $icr; |
|
| 1453 | + return (empty($icr['rate']) && $icr['rate'] !== '0') ? $tr : $icr; |
|
| 1454 | 1454 | |
| 1455 | - }, $tax_rates, $class_rates ); |
|
| 1455 | + }, $tax_rates, $class_rates); |
|
| 1456 | 1456 | } |
| 1457 | 1457 | } |
| 1458 | 1458 | |
| 1459 | - if ( !empty( $tax_rates ) ) { |
|
| 1460 | - foreach ( $tax_rates as $key => $tax_rate ) { |
|
| 1461 | - if ( $country != $tax_rate['country'] ) |
|
| 1459 | + if (!empty($tax_rates)) { |
|
| 1460 | + foreach ($tax_rates as $key => $tax_rate) { |
|
| 1461 | + if ($country != $tax_rate['country']) |
|
| 1462 | 1462 | continue; |
| 1463 | 1463 | |
| 1464 | - if ( !empty( $tax_rate['global'] ) ) { |
|
| 1465 | - if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) { |
|
| 1466 | - $rate = number_format( $tax_rate['rate'], 4 ); |
|
| 1464 | + if (!empty($tax_rate['global'])) { |
|
| 1465 | + if (0 !== $tax_rate['rate'] || !empty($tax_rate['rate'])) { |
|
| 1466 | + $rate = number_format($tax_rate['rate'], 4); |
|
| 1467 | 1467 | } |
| 1468 | 1468 | } else { |
| 1469 | - if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
| 1469 | + if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state'])) |
|
| 1470 | 1470 | continue; |
| 1471 | 1471 | |
| 1472 | 1472 | $state_rate = $tax_rate['rate']; |
| 1473 | - if ( 0 !== $state_rate || !empty( $state_rate ) ) { |
|
| 1474 | - $rate = number_format( $state_rate, 4 ); |
|
| 1473 | + if (0 !== $state_rate || !empty($state_rate)) { |
|
| 1474 | + $rate = number_format($state_rate, 4); |
|
| 1475 | 1475 | } |
| 1476 | 1476 | } |
| 1477 | 1477 | } |
@@ -1480,84 +1480,84 @@ discard block |
||
| 1480 | 1480 | return $rate; |
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | - public static function get_rate( $rate = 1, $country = '', $state = '', $item_id = 0 ) { |
|
| 1483 | + public static function get_rate($rate = 1, $country = '', $state = '', $item_id = 0) { |
|
| 1484 | 1484 | global $wpinv_options, $wpi_session, $wpi_item_id, $wpi_zero_tax; |
| 1485 | 1485 | |
| 1486 | 1486 | $item_id = $item_id > 0 ? $item_id : $wpi_item_id; |
| 1487 | 1487 | $allow_vat_classes = self::allow_vat_classes(); |
| 1488 | - $class = $item_id ? self::get_item_class( $item_id ) : '_standard'; |
|
| 1488 | + $class = $item_id ? self::get_item_class($item_id) : '_standard'; |
|
| 1489 | 1489 | |
| 1490 | - if ( $class === '_exempt' || $wpi_zero_tax ) { |
|
| 1490 | + if ($class === '_exempt' || $wpi_zero_tax) { |
|
| 1491 | 1491 | return 0; |
| 1492 | - } else if ( !$allow_vat_classes ) { |
|
| 1492 | + } else if (!$allow_vat_classes) { |
|
| 1493 | 1493 | $class = '_standard'; |
| 1494 | 1494 | } |
| 1495 | 1495 | |
| 1496 | - if( !empty( $_POST['wpinv_country'] ) ) { |
|
| 1496 | + if (!empty($_POST['wpinv_country'])) { |
|
| 1497 | 1497 | $post_country = $_POST['wpinv_country']; |
| 1498 | - } elseif( !empty( $_POST['wpinv_country'] ) ) { |
|
| 1498 | + } elseif (!empty($_POST['wpinv_country'])) { |
|
| 1499 | 1499 | $post_country = $_POST['wpinv_country']; |
| 1500 | - } elseif( !empty( $_POST['country'] ) ) { |
|
| 1500 | + } elseif (!empty($_POST['country'])) { |
|
| 1501 | 1501 | $post_country = $_POST['country']; |
| 1502 | 1502 | } else { |
| 1503 | 1503 | $post_country = ''; |
| 1504 | 1504 | } |
| 1505 | 1505 | |
| 1506 | - $country = !empty( $post_country ) ? $post_country : wpinv_default_billing_country( $country ); |
|
| 1507 | - $base_country = wpinv_is_base_country( $country ); |
|
| 1506 | + $country = !empty($post_country) ? $post_country : wpinv_default_billing_country($country); |
|
| 1507 | + $base_country = wpinv_is_base_country($country); |
|
| 1508 | 1508 | |
| 1509 | - $requires_vat = self::requires_vat( 0, false ); |
|
| 1510 | - $is_digital = self::get_item_rule( $item_id ) == 'digital' ; |
|
| 1511 | - $rate = $requires_vat && isset( $wpinv_options['eu_fallback_rate'] ) ? $wpinv_options['eu_fallback_rate'] : $rate; |
|
| 1509 | + $requires_vat = self::requires_vat(0, false); |
|
| 1510 | + $is_digital = self::get_item_rule($item_id) == 'digital'; |
|
| 1511 | + $rate = $requires_vat && isset($wpinv_options['eu_fallback_rate']) ? $wpinv_options['eu_fallback_rate'] : $rate; |
|
| 1512 | 1512 | |
| 1513 | - if ( self::same_country_rule() == 'no' && $base_country ) { // Disable VAT to same country |
|
| 1513 | + if (self::same_country_rule() == 'no' && $base_country) { // Disable VAT to same country |
|
| 1514 | 1514 | $rate = 0; |
| 1515 | - } else if ( $requires_vat ) { |
|
| 1516 | - $vat_number = self::get_user_vat_number( '', 0, true ); |
|
| 1515 | + } else if ($requires_vat) { |
|
| 1516 | + $vat_number = self::get_user_vat_number('', 0, true); |
|
| 1517 | 1517 | $vat_info = self::current_vat_data(); |
| 1518 | 1518 | |
| 1519 | - if ( is_array( $vat_info ) ) { |
|
| 1520 | - $vat_number = isset( $vat_info['number'] ) && !empty( $vat_info['valid'] ) ? $vat_info['number'] : ""; |
|
| 1519 | + if (is_array($vat_info)) { |
|
| 1520 | + $vat_number = isset($vat_info['number']) && !empty($vat_info['valid']) ? $vat_info['number'] : ""; |
|
| 1521 | 1521 | } |
| 1522 | 1522 | |
| 1523 | - if ( $country == 'UK' ) { |
|
| 1523 | + if ($country == 'UK') { |
|
| 1524 | 1524 | $country = 'GB'; |
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | - if ( !empty( $vat_number ) ) { |
|
| 1527 | + if (!empty($vat_number)) { |
|
| 1528 | 1528 | $rate = 0; |
| 1529 | 1529 | } else { |
| 1530 | - $rate = self::find_rate( $country, $state, $rate, $class ); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate |
|
| 1530 | + $rate = self::find_rate($country, $state, $rate, $class); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate |
|
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | - if ( empty( $vat_number ) && !$is_digital ) { |
|
| 1534 | - if ( $base_country ) { |
|
| 1535 | - $rate = self::find_rate( $country, null, $rate, $class ); |
|
| 1533 | + if (empty($vat_number) && !$is_digital) { |
|
| 1534 | + if ($base_country) { |
|
| 1535 | + $rate = self::find_rate($country, null, $rate, $class); |
|
| 1536 | 1536 | } else { |
| 1537 | - if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) { |
|
| 1537 | + if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) { |
|
| 1538 | 1538 | $rate = $wpinv_options['eu_fallback_rate']; |
| 1539 | - } else if( !empty( $country ) ) { |
|
| 1540 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
| 1539 | + } else if (!empty($country)) { |
|
| 1540 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
| 1541 | 1541 | } |
| 1542 | 1542 | } |
| 1543 | - } else if ( empty( $vat_number ) || ( self::same_country_rule() == 'always' && $base_country ) ) { |
|
| 1544 | - if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) { |
|
| 1543 | + } else if (empty($vat_number) || (self::same_country_rule() == 'always' && $base_country)) { |
|
| 1544 | + if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) { |
|
| 1545 | 1545 | $rate = $wpinv_options['eu_fallback_rate']; |
| 1546 | - } else if( !empty( $country ) ) { |
|
| 1547 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
| 1546 | + } else if (!empty($country)) { |
|
| 1547 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
| 1548 | 1548 | } |
| 1549 | 1549 | } |
| 1550 | 1550 | } else { |
| 1551 | - if ( $is_digital ) { |
|
| 1551 | + if ($is_digital) { |
|
| 1552 | 1552 | $ip_country_code = self::get_country_by_ip(); |
| 1553 | 1553 | |
| 1554 | - if ( $ip_country_code && self::is_eu_state( $ip_country_code ) ) { |
|
| 1555 | - $rate = self::find_rate( $ip_country_code, '', 0, $class ); |
|
| 1554 | + if ($ip_country_code && self::is_eu_state($ip_country_code)) { |
|
| 1555 | + $rate = self::find_rate($ip_country_code, '', 0, $class); |
|
| 1556 | 1556 | } else { |
| 1557 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
| 1557 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
| 1558 | 1558 | } |
| 1559 | 1559 | } else { |
| 1560 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
| 1560 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
| 1561 | 1561 | } |
| 1562 | 1562 | } |
| 1563 | 1563 | |
@@ -1567,48 +1567,48 @@ discard block |
||
| 1567 | 1567 | public static function current_vat_data() { |
| 1568 | 1568 | global $wpi_session; |
| 1569 | 1569 | |
| 1570 | - return $wpi_session->get( 'user_vat_data' ); |
|
| 1570 | + return $wpi_session->get('user_vat_data'); |
|
| 1571 | 1571 | } |
| 1572 | 1572 | |
| 1573 | - public static function get_user_country( $country = '', $user_id = 0 ) { |
|
| 1574 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
| 1573 | + public static function get_user_country($country = '', $user_id = 0) { |
|
| 1574 | + $user_address = wpinv_get_user_address($user_id, false); |
|
| 1575 | 1575 | |
| 1576 | - if ( wpinv_get_option( 'vat_ip_country_default' ) ) { |
|
| 1576 | + if (wpinv_get_option('vat_ip_country_default')) { |
|
| 1577 | 1577 | $country = ''; |
| 1578 | 1578 | } |
| 1579 | 1579 | |
| 1580 | - $country = empty( $user_address ) || !isset( $user_address['country'] ) || empty( $user_address['country'] ) ? $country : $user_address['country']; |
|
| 1581 | - $result = apply_filters( 'wpinv_get_user_country', $country, $user_id ); |
|
| 1580 | + $country = empty($user_address) || !isset($user_address['country']) || empty($user_address['country']) ? $country : $user_address['country']; |
|
| 1581 | + $result = apply_filters('wpinv_get_user_country', $country, $user_id); |
|
| 1582 | 1582 | |
| 1583 | - if ( empty( $result ) ) { |
|
| 1583 | + if (empty($result)) { |
|
| 1584 | 1584 | $result = self::get_country_by_ip(); |
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | 1587 | return $result; |
| 1588 | 1588 | } |
| 1589 | 1589 | |
| 1590 | - public static function set_user_country( $country = '', $user_id = 0 ) { |
|
| 1590 | + public static function set_user_country($country = '', $user_id = 0) { |
|
| 1591 | 1591 | global $wpi_userID; |
| 1592 | 1592 | |
| 1593 | - if ( empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID ) { |
|
| 1593 | + if (empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID) { |
|
| 1594 | 1594 | $country = wpinv_get_default_country(); |
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | return $country; |
| 1598 | 1598 | } |
| 1599 | 1599 | |
| 1600 | - public static function get_user_vat_number( $vat_number = '', $user_id = 0, $is_valid = false ) { |
|
| 1600 | + public static function get_user_vat_number($vat_number = '', $user_id = 0, $is_valid = false) { |
|
| 1601 | 1601 | global $wpi_current_id, $wpi_userID; |
| 1602 | 1602 | |
| 1603 | - if ( !empty( $_POST['new_user'] ) ) { |
|
| 1603 | + if (!empty($_POST['new_user'])) { |
|
| 1604 | 1604 | return ''; |
| 1605 | 1605 | } |
| 1606 | 1606 | |
| 1607 | - if ( empty( $user_id ) ) { |
|
| 1608 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() ); |
|
| 1607 | + if (empty($user_id)) { |
|
| 1608 | + $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id()); |
|
| 1609 | 1609 | } |
| 1610 | 1610 | |
| 1611 | - $vat_number = empty( $user_id ) ? '' : get_user_meta( $user_id, '_wpinv_vat_number', true ); |
|
| 1611 | + $vat_number = empty($user_id) ? '' : get_user_meta($user_id, '_wpinv_vat_number', true); |
|
| 1612 | 1612 | |
| 1613 | 1613 | /* TODO |
| 1614 | 1614 | if ( $is_valid && $vat_number ) { |
@@ -1619,38 +1619,38 @@ discard block |
||
| 1619 | 1619 | } |
| 1620 | 1620 | */ |
| 1621 | 1621 | |
| 1622 | - return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid ); |
|
| 1622 | + return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid); |
|
| 1623 | 1623 | } |
| 1624 | 1624 | |
| 1625 | - public static function get_user_company( $company = '', $user_id = 0 ) { |
|
| 1625 | + public static function get_user_company($company = '', $user_id = 0) { |
|
| 1626 | 1626 | global $wpi_current_id, $wpi_userID; |
| 1627 | 1627 | |
| 1628 | - if ( empty( $user_id ) ) { |
|
| 1629 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() ); |
|
| 1628 | + if (empty($user_id)) { |
|
| 1629 | + $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id()); |
|
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
| 1632 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
| 1633 | 1633 | |
| 1634 | - return apply_filters( 'wpinv_user_company', $company, $user_id ); |
|
| 1634 | + return apply_filters('wpinv_user_company', $company, $user_id); |
|
| 1635 | 1635 | } |
| 1636 | 1636 | |
| 1637 | - public static function save_user_vat_details( $company = '', $vat_number = '' ) { |
|
| 1638 | - $save = apply_filters( 'wpinv_allow_save_user_vat_details', true ); |
|
| 1637 | + public static function save_user_vat_details($company = '', $vat_number = '') { |
|
| 1638 | + $save = apply_filters('wpinv_allow_save_user_vat_details', true); |
|
| 1639 | 1639 | |
| 1640 | - if ( is_user_logged_in() && $save ) { |
|
| 1640 | + if (is_user_logged_in() && $save) { |
|
| 1641 | 1641 | $user_id = get_current_user_id(); |
| 1642 | 1642 | |
| 1643 | - if ( !empty( $vat_number ) ) { |
|
| 1644 | - update_user_meta( $user_id, '_wpinv_vat_number', $vat_number ); |
|
| 1643 | + if (!empty($vat_number)) { |
|
| 1644 | + update_user_meta($user_id, '_wpinv_vat_number', $vat_number); |
|
| 1645 | 1645 | } else { |
| 1646 | - delete_user_meta( $user_id, '_wpinv_vat_number'); |
|
| 1646 | + delete_user_meta($user_id, '_wpinv_vat_number'); |
|
| 1647 | 1647 | } |
| 1648 | 1648 | |
| 1649 | - if ( !empty( $company ) ) { |
|
| 1650 | - update_user_meta( $user_id, '_wpinv_company', $company ); |
|
| 1649 | + if (!empty($company)) { |
|
| 1650 | + update_user_meta($user_id, '_wpinv_company', $company); |
|
| 1651 | 1651 | } else { |
| 1652 | - delete_user_meta( $user_id, '_wpinv_company'); |
|
| 1653 | - delete_user_meta( $user_id, '_wpinv_vat_number'); |
|
| 1652 | + delete_user_meta($user_id, '_wpinv_company'); |
|
| 1653 | + delete_user_meta($user_id, '_wpinv_vat_number'); |
|
| 1654 | 1654 | } |
| 1655 | 1655 | } |
| 1656 | 1656 | |
@@ -1660,113 +1660,113 @@ discard block |
||
| 1660 | 1660 | public static function ajax_vat_validate() { |
| 1661 | 1661 | global $wpinv_options, $wpi_session; |
| 1662 | 1662 | |
| 1663 | - $is_checkout = ( !empty( $_POST['source'] ) && $_POST['source'] == 'checkout' ) ? true : false; |
|
| 1663 | + $is_checkout = (!empty($_POST['source']) && $_POST['source'] == 'checkout') ? true : false; |
|
| 1664 | 1664 | $response = array(); |
| 1665 | 1665 | $response['success'] = false; |
| 1666 | 1666 | |
| 1667 | - if ( empty( $_REQUEST['_wpi_nonce'] ) || ( !empty( $_REQUEST['_wpi_nonce'] ) && !wp_verify_nonce( $_REQUEST['_wpi_nonce'], 'vat_validation' ) ) ) { |
|
| 1668 | - $response['error'] = __( 'Invalid security nonce', 'invoicing' ); |
|
| 1669 | - wp_send_json( $response ); |
|
| 1667 | + if (empty($_REQUEST['_wpi_nonce']) || (!empty($_REQUEST['_wpi_nonce']) && !wp_verify_nonce($_REQUEST['_wpi_nonce'], 'vat_validation'))) { |
|
| 1668 | + $response['error'] = __('Invalid security nonce', 'invoicing'); |
|
| 1669 | + wp_send_json($response); |
|
| 1670 | 1670 | } |
| 1671 | 1671 | |
| 1672 | - $vat_name = self::get_vat_name(); |
|
| 1672 | + $vat_name = self::get_vat_name(); |
|
| 1673 | 1673 | |
| 1674 | - if ( $is_checkout ) { |
|
| 1674 | + if ($is_checkout) { |
|
| 1675 | 1675 | $invoice = wpinv_get_invoice_cart(); |
| 1676 | 1676 | |
| 1677 | - if ( !self::requires_vat( false, 0, self::invoice_has_digital_rule( $invoice ) ) ) { |
|
| 1677 | + if (!self::requires_vat(false, 0, self::invoice_has_digital_rule($invoice))) { |
|
| 1678 | 1678 | $vat_info = array(); |
| 1679 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
| 1679 | + $wpi_session->set('user_vat_data', $vat_info); |
|
| 1680 | 1680 | |
| 1681 | 1681 | self::save_user_vat_details(); |
| 1682 | 1682 | |
| 1683 | 1683 | $response['success'] = true; |
| 1684 | - $response['message'] = wp_sprintf( __( 'Ignore %s', 'invoicing' ), $vat_name ); |
|
| 1685 | - wp_send_json( $response ); |
|
| 1684 | + $response['message'] = wp_sprintf(__('Ignore %s', 'invoicing'), $vat_name); |
|
| 1685 | + wp_send_json($response); |
|
| 1686 | 1686 | } |
| 1687 | 1687 | } |
| 1688 | 1688 | |
| 1689 | - $company = !empty( $_POST['company'] ) ? sanitize_text_field( $_POST['company'] ) : ''; |
|
| 1690 | - $vat_number = !empty( $_POST['number'] ) ? sanitize_text_field( $_POST['number'] ) : ''; |
|
| 1689 | + $company = !empty($_POST['company']) ? sanitize_text_field($_POST['company']) : ''; |
|
| 1690 | + $vat_number = !empty($_POST['number']) ? sanitize_text_field($_POST['number']) : ''; |
|
| 1691 | 1691 | |
| 1692 | - $vat_info = $wpi_session->get( 'user_vat_data' ); |
|
| 1693 | - if ( !is_array( $vat_info ) || empty( $vat_info ) ) { |
|
| 1694 | - $vat_info = array( 'company'=> $company, 'number' => '', 'valid' => true ); |
|
| 1692 | + $vat_info = $wpi_session->get('user_vat_data'); |
|
| 1693 | + if (!is_array($vat_info) || empty($vat_info)) { |
|
| 1694 | + $vat_info = array('company'=> $company, 'number' => '', 'valid' => true); |
|
| 1695 | 1695 | } |
| 1696 | 1696 | |
| 1697 | - if ( empty( $vat_number ) ) { |
|
| 1698 | - if ( $is_checkout ) { |
|
| 1697 | + if (empty($vat_number)) { |
|
| 1698 | + if ($is_checkout) { |
|
| 1699 | 1699 | $response['success'] = true; |
| 1700 | - $response['message'] = wp_sprintf( __( 'No %s number has been applied. %s will be added to invoice totals', 'invoicing' ), $vat_name, $vat_name ); |
|
| 1700 | + $response['message'] = wp_sprintf(__('No %s number has been applied. %s will be added to invoice totals', 'invoicing'), $vat_name, $vat_name); |
|
| 1701 | 1701 | |
| 1702 | - $vat_info = $wpi_session->get( 'user_vat_data' ); |
|
| 1702 | + $vat_info = $wpi_session->get('user_vat_data'); |
|
| 1703 | 1703 | $vat_info['number'] = ""; |
| 1704 | 1704 | $vat_info['valid'] = true; |
| 1705 | 1705 | |
| 1706 | - self::save_user_vat_details( $company ); |
|
| 1706 | + self::save_user_vat_details($company); |
|
| 1707 | 1707 | } else { |
| 1708 | - $response['error'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name ); |
|
| 1708 | + $response['error'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name); |
|
| 1709 | 1709 | |
| 1710 | 1710 | $vat_info['valid'] = false; |
| 1711 | 1711 | } |
| 1712 | 1712 | |
| 1713 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
| 1714 | - wp_send_json( $response ); |
|
| 1713 | + $wpi_session->set('user_vat_data', $vat_info); |
|
| 1714 | + wp_send_json($response); |
|
| 1715 | 1715 | } |
| 1716 | 1716 | |
| 1717 | - if ( empty( $company ) ) { |
|
| 1717 | + if (empty($company)) { |
|
| 1718 | 1718 | $vat_info['valid'] = false; |
| 1719 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
| 1719 | + $wpi_session->set('user_vat_data', $vat_info); |
|
| 1720 | 1720 | |
| 1721 | - $response['error'] = __( 'Please enter your registered company name!', 'invoicing' ); |
|
| 1722 | - wp_send_json( $response ); |
|
| 1721 | + $response['error'] = __('Please enter your registered company name!', 'invoicing'); |
|
| 1722 | + wp_send_json($response); |
|
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
| 1726 | - if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) { |
|
| 1725 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
| 1726 | + if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) { |
|
| 1727 | 1727 | $vat_info['valid'] = false; |
| 1728 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
| 1728 | + $wpi_session->set('user_vat_data', $vat_info); |
|
| 1729 | 1729 | |
| 1730 | - $response['error'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
| 1731 | - wp_send_json( $response ); |
|
| 1730 | + $response['error'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
| 1731 | + wp_send_json($response); |
|
| 1732 | 1732 | } |
| 1733 | 1733 | |
| 1734 | 1734 | $response['success'] = true; |
| 1735 | - $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
| 1735 | + $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
| 1736 | 1736 | } else { |
| 1737 | - $result = self::check_vat( $vat_number ); |
|
| 1737 | + $result = self::check_vat($vat_number); |
|
| 1738 | 1738 | |
| 1739 | - if ( empty( $result['valid'] ) ) { |
|
| 1739 | + if (empty($result['valid'])) { |
|
| 1740 | 1740 | $response['error'] = $result['message']; |
| 1741 | - wp_send_json( $response ); |
|
| 1741 | + wp_send_json($response); |
|
| 1742 | 1742 | } |
| 1743 | 1743 | |
| 1744 | - $vies_company = !empty( $result['company'] ) ? $result['company'] : ''; |
|
| 1745 | - $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company ); |
|
| 1744 | + $vies_company = !empty($result['company']) ? $result['company'] : ''; |
|
| 1745 | + $vies_company = apply_filters('wpinv_vies_company_name', $vies_company); |
|
| 1746 | 1746 | |
| 1747 | - $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
|
| 1747 | + $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false; |
|
| 1748 | 1748 | |
| 1749 | - if ( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) { |
|
| 1749 | + if (!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company) { |
|
| 1750 | 1750 | $response['success'] = true; |
| 1751 | - $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
| 1751 | + $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
| 1752 | 1752 | } else { |
| 1753 | 1753 | $vat_info['valid'] = false; |
| 1754 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
| 1754 | + $wpi_session->set('user_vat_data', $vat_info); |
|
| 1755 | 1755 | |
| 1756 | 1756 | $response['success'] = false; |
| 1757 | - $response['message'] = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name ); |
|
| 1758 | - wp_send_json( $response ); |
|
| 1757 | + $response['message'] = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name); |
|
| 1758 | + wp_send_json($response); |
|
| 1759 | 1759 | } |
| 1760 | 1760 | } |
| 1761 | 1761 | |
| 1762 | - if ( $is_checkout ) { |
|
| 1763 | - self::save_user_vat_details( $company, $vat_number ); |
|
| 1762 | + if ($is_checkout) { |
|
| 1763 | + self::save_user_vat_details($company, $vat_number); |
|
| 1764 | 1764 | |
| 1765 | - $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true ); |
|
| 1766 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
| 1765 | + $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true); |
|
| 1766 | + $wpi_session->set('user_vat_data', $vat_info); |
|
| 1767 | 1767 | } |
| 1768 | 1768 | |
| 1769 | - wp_send_json( $response ); |
|
| 1769 | + wp_send_json($response); |
|
| 1770 | 1770 | } |
| 1771 | 1771 | |
| 1772 | 1772 | public static function ajax_vat_reset() { |
@@ -1775,161 +1775,161 @@ discard block |
||
| 1775 | 1775 | $company = is_user_logged_in() ? self::get_user_company() : ''; |
| 1776 | 1776 | $vat_number = self::get_user_vat_number(); |
| 1777 | 1777 | |
| 1778 | - $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => false ); |
|
| 1779 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
| 1778 | + $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => false); |
|
| 1779 | + $wpi_session->set('user_vat_data', $vat_info); |
|
| 1780 | 1780 | |
| 1781 | 1781 | $response = array(); |
| 1782 | 1782 | $response['success'] = true; |
| 1783 | 1783 | $response['data']['company'] = $company; |
| 1784 | 1784 | $response['data']['number'] = $vat_number; |
| 1785 | 1785 | |
| 1786 | - wp_send_json( $response ); |
|
| 1786 | + wp_send_json($response); |
|
| 1787 | 1787 | } |
| 1788 | 1788 | |
| 1789 | - public static function checkout_vat_validate( $valid_data, $post ) { |
|
| 1789 | + public static function checkout_vat_validate($valid_data, $post) { |
|
| 1790 | 1790 | global $wpinv_options, $wpi_session; |
| 1791 | 1791 | |
| 1792 | - $vat_name = __( self::get_vat_name(), 'invoicing' ); |
|
| 1792 | + $vat_name = __(self::get_vat_name(), 'invoicing'); |
|
| 1793 | 1793 | |
| 1794 | - if ( !isset( $_POST['_wpi_nonce'] ) || !wp_verify_nonce( $_POST['_wpi_nonce'], 'vat_validation' ) ) { |
|
| 1795 | - wpinv_set_error( 'vat_validation', wp_sprintf( __( "Invalid %s validation request.", 'invoicing' ), $vat_name ) ); |
|
| 1794 | + if (!isset($_POST['_wpi_nonce']) || !wp_verify_nonce($_POST['_wpi_nonce'], 'vat_validation')) { |
|
| 1795 | + wpinv_set_error('vat_validation', wp_sprintf(__("Invalid %s validation request.", 'invoicing'), $vat_name)); |
|
| 1796 | 1796 | return; |
| 1797 | 1797 | } |
| 1798 | 1798 | |
| 1799 | - $vat_saved = $wpi_session->get( 'user_vat_data' ); |
|
| 1800 | - $wpi_session->set( 'user_vat_data', null ); |
|
| 1799 | + $vat_saved = $wpi_session->get('user_vat_data'); |
|
| 1800 | + $wpi_session->set('user_vat_data', null); |
|
| 1801 | 1801 | |
| 1802 | 1802 | $invoice = wpinv_get_invoice_cart(); |
| 1803 | 1803 | $amount = $invoice->get_total(); |
| 1804 | - $is_digital = self::invoice_has_digital_rule( $invoice ); |
|
| 1805 | - $no_vat = !self::requires_vat( 0, false, $is_digital ); |
|
| 1804 | + $is_digital = self::invoice_has_digital_rule($invoice); |
|
| 1805 | + $no_vat = !self::requires_vat(0, false, $is_digital); |
|
| 1806 | 1806 | |
| 1807 | - $company = !empty( $_POST['wpinv_company'] ) ? $_POST['wpinv_company'] : null; |
|
| 1808 | - $vat_number = !empty( $_POST['wpinv_vat_number'] ) ? $_POST['wpinv_vat_number'] : null; |
|
| 1809 | - $country = !empty( $_POST['wpinv_country'] ) ? $_POST['wpinv_country'] : $invoice->country; |
|
| 1810 | - if ( empty( $country ) ) { |
|
| 1807 | + $company = !empty($_POST['wpinv_company']) ? $_POST['wpinv_company'] : null; |
|
| 1808 | + $vat_number = !empty($_POST['wpinv_vat_number']) ? $_POST['wpinv_vat_number'] : null; |
|
| 1809 | + $country = !empty($_POST['wpinv_country']) ? $_POST['wpinv_country'] : $invoice->country; |
|
| 1810 | + if (empty($country)) { |
|
| 1811 | 1811 | $country = wpinv_default_billing_country(); |
| 1812 | 1812 | } |
| 1813 | 1813 | |
| 1814 | - if ( !$is_digital && $no_vat ) { |
|
| 1814 | + if (!$is_digital && $no_vat) { |
|
| 1815 | 1815 | return; |
| 1816 | 1816 | } |
| 1817 | 1817 | |
| 1818 | - $vat_data = array( 'company' => '', 'number' => '', 'valid' => false ); |
|
| 1818 | + $vat_data = array('company' => '', 'number' => '', 'valid' => false); |
|
| 1819 | 1819 | |
| 1820 | 1820 | $ip_country_code = self::get_country_by_ip(); |
| 1821 | - $is_eu_state = self::is_eu_state( $country ); |
|
| 1822 | - $is_eu_state_ip = self::is_eu_state( $ip_country_code ); |
|
| 1821 | + $is_eu_state = self::is_eu_state($country); |
|
| 1822 | + $is_eu_state_ip = self::is_eu_state($ip_country_code); |
|
| 1823 | 1823 | $is_non_eu_user = !$is_eu_state && !$is_eu_state_ip; |
| 1824 | 1824 | |
| 1825 | - if ( $is_digital && !$is_non_eu_user && empty( $vat_number ) && apply_filters( 'wpinv_checkout_requires_country', true, $amount ) ) { |
|
| 1825 | + if ($is_digital && !$is_non_eu_user && empty($vat_number) && apply_filters('wpinv_checkout_requires_country', true, $amount)) { |
|
| 1826 | 1826 | $vat_data['adddress_confirmed'] = false; |
| 1827 | 1827 | |
| 1828 | - if ( !isset( $_POST['wpinv_adddress_confirmed'] ) ) { |
|
| 1829 | - if ( $ip_country_code != $country ) { |
|
| 1830 | - wpinv_set_error( 'vat_validation', sprintf( __( 'The country of your current location must be the same as the country of your billing location or you must %s confirm %s the billing address is your home country.', 'invoicing' ), '<a href="#wpinv_adddress_confirm">', '</a>' ) ); |
|
| 1828 | + if (!isset($_POST['wpinv_adddress_confirmed'])) { |
|
| 1829 | + if ($ip_country_code != $country) { |
|
| 1830 | + wpinv_set_error('vat_validation', sprintf(__('The country of your current location must be the same as the country of your billing location or you must %s confirm %s the billing address is your home country.', 'invoicing'), '<a href="#wpinv_adddress_confirm">', '</a>')); |
|
| 1831 | 1831 | } |
| 1832 | 1832 | } else { |
| 1833 | 1833 | $vat_data['adddress_confirmed'] = true; |
| 1834 | 1834 | } |
| 1835 | 1835 | } |
| 1836 | 1836 | |
| 1837 | - if ( !empty( $wpinv_options['vat_prevent_b2c_purchase'] ) && !$is_non_eu_user && ( empty( $vat_number ) || $no_vat ) ) { |
|
| 1838 | - if ( $is_eu_state ) { |
|
| 1839 | - wpinv_set_error( 'vat_validation', wp_sprintf( __( 'Please enter and validate your %s number to verify your purchase is by an EU business.', 'invoicing' ), $vat_name ) ); |
|
| 1840 | - } else if ( $is_digital && $is_eu_state_ip ) { |
|
| 1841 | - wpinv_set_error( 'vat_validation', wp_sprintf( __( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ), $vat_name ) ); |
|
| 1837 | + if (!empty($wpinv_options['vat_prevent_b2c_purchase']) && !$is_non_eu_user && (empty($vat_number) || $no_vat)) { |
|
| 1838 | + if ($is_eu_state) { |
|
| 1839 | + wpinv_set_error('vat_validation', wp_sprintf(__('Please enter and validate your %s number to verify your purchase is by an EU business.', 'invoicing'), $vat_name)); |
|
| 1840 | + } else if ($is_digital && $is_eu_state_ip) { |
|
| 1841 | + wpinv_set_error('vat_validation', wp_sprintf(__('Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing'), $vat_name)); |
|
| 1842 | 1842 | } |
| 1843 | 1843 | } |
| 1844 | 1844 | |
| 1845 | - if ( !$is_eu_state || $no_vat || empty( $vat_number ) ) { |
|
| 1845 | + if (!$is_eu_state || $no_vat || empty($vat_number)) { |
|
| 1846 | 1846 | return; |
| 1847 | 1847 | } |
| 1848 | 1848 | |
| 1849 | - if ( !empty( $vat_saved ) && isset( $vat_saved['valid'] ) ) { |
|
| 1850 | - $vat_data['valid'] = $vat_saved['valid']; |
|
| 1849 | + if (!empty($vat_saved) && isset($vat_saved['valid'])) { |
|
| 1850 | + $vat_data['valid'] = $vat_saved['valid']; |
|
| 1851 | 1851 | } |
| 1852 | 1852 | |
| 1853 | - if ( $company !== null ) { |
|
| 1853 | + if ($company !== null) { |
|
| 1854 | 1854 | $vat_data['company'] = $company; |
| 1855 | 1855 | } |
| 1856 | 1856 | |
| 1857 | 1857 | $message = ''; |
| 1858 | - if ( $vat_number !== null ) { |
|
| 1858 | + if ($vat_number !== null) { |
|
| 1859 | 1859 | $vat_data['number'] = $vat_number; |
| 1860 | 1860 | |
| 1861 | - if ( !$vat_data['valid'] || ( $vat_saved['number'] !== $vat_data['number'] ) || ( $vat_saved['company'] !== $vat_data['company'] ) ) { |
|
| 1862 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
| 1863 | - if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) { |
|
| 1861 | + if (!$vat_data['valid'] || ($vat_saved['number'] !== $vat_data['number']) || ($vat_saved['company'] !== $vat_data['company'])) { |
|
| 1862 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
| 1863 | + if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) { |
|
| 1864 | 1864 | $vat_data['valid'] = false; |
| 1865 | 1865 | } |
| 1866 | 1866 | } else { |
| 1867 | - $result = self::check_vat( $vat_number ); |
|
| 1867 | + $result = self::check_vat($vat_number); |
|
| 1868 | 1868 | |
| 1869 | - if ( !empty( $result['valid'] ) ) { |
|
| 1869 | + if (!empty($result['valid'])) { |
|
| 1870 | 1870 | $vat_data['valid'] = true; |
| 1871 | - $vies_company = !empty( $result['company'] ) ? $result['company'] : ''; |
|
| 1872 | - $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company ); |
|
| 1871 | + $vies_company = !empty($result['company']) ? $result['company'] : ''; |
|
| 1872 | + $vies_company = apply_filters('wpinv_vies_company_name', $vies_company); |
|
| 1873 | 1873 | |
| 1874 | - $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
|
| 1874 | + $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false; |
|
| 1875 | 1875 | |
| 1876 | - if ( !( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) ) { |
|
| 1876 | + if (!(!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company)) { |
|
| 1877 | 1877 | $vat_data['valid'] = false; |
| 1878 | 1878 | |
| 1879 | - $message = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name ); |
|
| 1879 | + $message = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name); |
|
| 1880 | 1880 | } |
| 1881 | 1881 | } else { |
| 1882 | - $message = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name ); |
|
| 1882 | + $message = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name); |
|
| 1883 | 1883 | } |
| 1884 | 1884 | } |
| 1885 | 1885 | |
| 1886 | - if ( !$vat_data['valid'] ) { |
|
| 1887 | - $error = wp_sprintf( __( 'The %s %s number %s you have entered has not been validated', 'invoicing' ), '<a href="#wpi-vat-details">', $vat_name, '</a>' ) . ( $message ? ' ( ' . $message . ' )' : '' ); |
|
| 1888 | - wpinv_set_error( 'vat_validation', $error ); |
|
| 1886 | + if (!$vat_data['valid']) { |
|
| 1887 | + $error = wp_sprintf(__('The %s %s number %s you have entered has not been validated', 'invoicing'), '<a href="#wpi-vat-details">', $vat_name, '</a>') . ($message ? ' ( ' . $message . ' )' : ''); |
|
| 1888 | + wpinv_set_error('vat_validation', $error); |
|
| 1889 | 1889 | } |
| 1890 | 1890 | } |
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | - $wpi_session->set( 'user_vat_data', $vat_data ); |
|
| 1893 | + $wpi_session->set('user_vat_data', $vat_data); |
|
| 1894 | 1894 | } |
| 1895 | 1895 | |
| 1896 | - public static function checkout_vat_fields( $billing_details ) { |
|
| 1896 | + public static function checkout_vat_fields($billing_details) { |
|
| 1897 | 1897 | global $wpi_session, $wpinv_options, $wpi_country, $wpi_requires_vat; |
| 1898 | 1898 | |
| 1899 | 1899 | $ip_address = wpinv_get_ip(); |
| 1900 | 1900 | $ip_country_code = self::get_country_by_ip(); |
| 1901 | 1901 | |
| 1902 | - $tax_label = __( self::get_vat_name(), 'invoicing' ); |
|
| 1902 | + $tax_label = __(self::get_vat_name(), 'invoicing'); |
|
| 1903 | 1903 | $invoice = wpinv_get_invoice_cart(); |
| 1904 | - $is_digital = self::invoice_has_digital_rule( $invoice ); |
|
| 1904 | + $is_digital = self::invoice_has_digital_rule($invoice); |
|
| 1905 | 1905 | $wpi_country = $invoice->country; |
| 1906 | 1906 | |
| 1907 | - $requires_vat = !self::hide_vat_fields() && !$invoice->is_free() && self::requires_vat( 0, false, $is_digital ); |
|
| 1907 | + $requires_vat = !self::hide_vat_fields() && !$invoice->is_free() && self::requires_vat(0, false, $is_digital); |
|
| 1908 | 1908 | $wpi_requires_vat = $requires_vat; |
| 1909 | 1909 | |
| 1910 | 1910 | $company = self::get_user_company(); |
| 1911 | 1911 | $vat_number = self::get_user_vat_number(); |
| 1912 | 1912 | |
| 1913 | - $validated = $vat_number ? self::get_user_vat_number( '', 0, true ) : 1; |
|
| 1914 | - $vat_info = $wpi_session->get( 'user_vat_data' ); |
|
| 1913 | + $validated = $vat_number ? self::get_user_vat_number('', 0, true) : 1; |
|
| 1914 | + $vat_info = $wpi_session->get('user_vat_data'); |
|
| 1915 | 1915 | |
| 1916 | - if ( is_array( $vat_info ) ) { |
|
| 1917 | - $company = isset( $vat_info['company'] ) ? $vat_info['company'] : ''; |
|
| 1918 | - $vat_number = isset( $vat_info['number'] ) ? $vat_info['number'] : ''; |
|
| 1919 | - $validated = isset( $vat_info['valid'] ) ? $vat_info['valid'] : false; |
|
| 1916 | + if (is_array($vat_info)) { |
|
| 1917 | + $company = isset($vat_info['company']) ? $vat_info['company'] : ''; |
|
| 1918 | + $vat_number = isset($vat_info['number']) ? $vat_info['number'] : ''; |
|
| 1919 | + $validated = isset($vat_info['valid']) ? $vat_info['valid'] : false; |
|
| 1920 | 1920 | } |
| 1921 | 1921 | |
| 1922 | 1922 | $selected_country = $invoice->country ? $invoice->country : wpinv_default_billing_country(); |
| 1923 | 1923 | |
| 1924 | - if ( $ip_country_code == 'UK' ) { |
|
| 1924 | + if ($ip_country_code == 'UK') { |
|
| 1925 | 1925 | $ip_country_code = 'GB'; |
| 1926 | 1926 | } |
| 1927 | 1927 | |
| 1928 | - if ( $selected_country == 'UK' ) { |
|
| 1928 | + if ($selected_country == 'UK') { |
|
| 1929 | 1929 | $selected_country = 'GB'; |
| 1930 | 1930 | } |
| 1931 | 1931 | |
| 1932 | - if ( $requires_vat && ( self::same_country_rule() == 'no' && wpinv_is_base_country( $selected_country ) || !self::allow_vat_rules() ) ) { |
|
| 1932 | + if ($requires_vat && (self::same_country_rule() == 'no' && wpinv_is_base_country($selected_country) || !self::allow_vat_rules())) { |
|
| 1933 | 1933 | $requires_vat = false; |
| 1934 | 1934 | } |
| 1935 | 1935 | |
@@ -1937,52 +1937,52 @@ discard block |
||
| 1937 | 1937 | $display_validate_btn = 'none'; |
| 1938 | 1938 | $display_reset_btn = 'none'; |
| 1939 | 1939 | |
| 1940 | - if ( !empty( $vat_number ) && $validated ) { |
|
| 1941 | - $vat_vailidated_text = wp_sprintf( __( '%s number validated', 'invoicing' ), $tax_label ); |
|
| 1940 | + if (!empty($vat_number) && $validated) { |
|
| 1941 | + $vat_vailidated_text = wp_sprintf(__('%s number validated', 'invoicing'), $tax_label); |
|
| 1942 | 1942 | $vat_vailidated_class = 'wpinv-vat-stat-1'; |
| 1943 | 1943 | $display_reset_btn = 'block'; |
| 1944 | 1944 | } else { |
| 1945 | - $vat_vailidated_text = empty( $vat_number ) ? '' : wp_sprintf( __( '%s number not validated', 'invoicing' ), $tax_label ); |
|
| 1946 | - $vat_vailidated_class = empty( $vat_number ) ? '' : 'wpinv-vat-stat-0'; |
|
| 1945 | + $vat_vailidated_text = empty($vat_number) ? '' : wp_sprintf(__('%s number not validated', 'invoicing'), $tax_label); |
|
| 1946 | + $vat_vailidated_class = empty($vat_number) ? '' : 'wpinv-vat-stat-0'; |
|
| 1947 | 1947 | $display_validate_btn = 'block'; |
| 1948 | 1948 | } |
| 1949 | 1949 | |
| 1950 | - $show_ip_country = $is_digital && ( empty( $vat_number ) || !$requires_vat ) && $ip_country_code != $selected_country ? 'block' : 'none'; |
|
| 1950 | + $show_ip_country = $is_digital && (empty($vat_number) || !$requires_vat) && $ip_country_code != $selected_country ? 'block' : 'none'; |
|
| 1951 | 1951 | ?> |
| 1952 | 1952 | <div id="wpi-vat-details" class="wpi-vat-details clearfix" style="display:<?php echo $display_vat_details; ?>"> |
| 1953 | 1953 | <div id="wpi_vat_info" class="clearfix panel panel-default"> |
| 1954 | - <div class="panel-heading"><h3 class="panel-title"><?php echo wp_sprintf( __( '%s Details', 'invoicing' ), $tax_label );?></h3></div> |
|
| 1954 | + <div class="panel-heading"><h3 class="panel-title"><?php echo wp_sprintf(__('%s Details', 'invoicing'), $tax_label); ?></h3></div> |
|
| 1955 | 1955 | <div id="wpinv-fields-box" class="panel-body"> |
| 1956 | 1956 | <p id="wpi_show_vat_note"> |
| 1957 | - <?php echo wp_sprintf( __( 'Validate your registered %s number to exclude tax.', 'invoicing' ), $tax_label ); ?> |
|
| 1957 | + <?php echo wp_sprintf(__('Validate your registered %s number to exclude tax.', 'invoicing'), $tax_label); ?> |
|
| 1958 | 1958 | </p> |
| 1959 | 1959 | <div id="wpi_vat_fields" class="wpi_vat_info"> |
| 1960 | 1960 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1961 | - <label for="wpinv_company" class="wpi-label"><?php _e( 'Company Name', 'invoicing' );?></label> |
|
| 1961 | + <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label> |
|
| 1962 | 1962 | <?php |
| 1963 | - echo wpinv_html_text( array( |
|
| 1963 | + echo wpinv_html_text(array( |
|
| 1964 | 1964 | 'id' => 'wpinv_company', |
| 1965 | 1965 | 'name' => 'wpinv_company', |
| 1966 | 1966 | 'value' => $company, |
| 1967 | 1967 | 'class' => 'wpi-input form-control', |
| 1968 | - 'placeholder' => __( 'Company name', 'invoicing' ), |
|
| 1969 | - ) ); |
|
| 1968 | + 'placeholder' => __('Company name', 'invoicing'), |
|
| 1969 | + )); |
|
| 1970 | 1970 | ?> |
| 1971 | 1971 | </p> |
| 1972 | 1972 | <p class="wpi-cart-field wpi-col2 wpi-coll wpi-cart-field-vat"> |
| 1973 | - <label for="wpinv_vat_number" class="wpi-label"><?php echo wp_sprintf( __( '%s Number', 'invoicing' ), $tax_label );?></label> |
|
| 1973 | + <label for="wpinv_vat_number" class="wpi-label"><?php echo wp_sprintf(__('%s Number', 'invoicing'), $tax_label); ?></label> |
|
| 1974 | 1974 | <span id="wpinv_vat_number-wrap"> |
| 1975 | 1975 | <label for="wpinv_vat_number" class="wpinv-label"></label> |
| 1976 | - <input type="text" class="wpi-input form-control" placeholder="<?php echo esc_attr( wp_sprintf( __( '%s number', 'invoicing' ), $tax_label ) );?>" value="<?php esc_attr_e( $vat_number );?>" id="wpinv_vat_number" name="wpinv_vat_number"> |
|
| 1977 | - <span class="wpinv-vat-stat <?php echo $vat_vailidated_class;?>"><i class="fa"></i> <font><?php echo $vat_vailidated_text;?></font></span> |
|
| 1976 | + <input type="text" class="wpi-input form-control" placeholder="<?php echo esc_attr(wp_sprintf(__('%s number', 'invoicing'), $tax_label)); ?>" value="<?php esc_attr_e($vat_number); ?>" id="wpinv_vat_number" name="wpinv_vat_number"> |
|
| 1977 | + <span class="wpinv-vat-stat <?php echo $vat_vailidated_class; ?>"><i class="fa"></i> <font><?php echo $vat_vailidated_text; ?></font></span> |
|
| 1978 | 1978 | </span> |
| 1979 | 1979 | </p> |
| 1980 | 1980 | <p class="wpi-cart-field wpi-col wpi-colf wpi-cart-field-actions"> |
| 1981 | - <button class="btn btn-success btn-sm wpinv-vat-validate" type="button" id="wpinv_vat_validate" style="display:<?php echo $display_validate_btn; ?>"><?php echo wp_sprintf( __("Validate %s Number", 'invoicing'), $tax_label ); ?></button> |
|
| 1982 | - <button class="btn btn-danger btn-sm wpinv-vat-reset" type="button" id="wpinv_vat_reset" style="display:<?php echo $display_reset_btn; ?>"><?php echo wp_sprintf( __("Reset %s", 'invoicing'), $tax_label ); ?></button> |
|
| 1981 | + <button class="btn btn-success btn-sm wpinv-vat-validate" type="button" id="wpinv_vat_validate" style="display:<?php echo $display_validate_btn; ?>"><?php echo wp_sprintf(__("Validate %s Number", 'invoicing'), $tax_label); ?></button> |
|
| 1982 | + <button class="btn btn-danger btn-sm wpinv-vat-reset" type="button" id="wpinv_vat_reset" style="display:<?php echo $display_reset_btn; ?>"><?php echo wp_sprintf(__("Reset %s", 'invoicing'), $tax_label); ?></button> |
|
| 1983 | 1983 | <span class="wpi-vat-box wpi-vat-box-info"><span id="text"></span></span> |
| 1984 | 1984 | <span class="wpi-vat-box wpi-vat-box-error"><span id="text"></span></span> |
| 1985 | - <input type="hidden" name="_wpi_nonce" value="<?php echo wp_create_nonce( 'vat_validation' ) ?>" /> |
|
| 1985 | + <input type="hidden" name="_wpi_nonce" value="<?php echo wp_create_nonce('vat_validation') ?>" /> |
|
| 1986 | 1986 | </p> |
| 1987 | 1987 | </div> |
| 1988 | 1988 | </div> |
@@ -1996,32 +1996,32 @@ discard block |
||
| 1996 | 1996 | </span> |
| 1997 | 1997 | </div> |
| 1998 | 1998 | </div> |
| 1999 | - <?php if ( empty( $wpinv_options['hide_ip_address'] ) ) { |
|
| 2000 | - $ip_link = '<a title="' . esc_attr( __( 'View more details on map', 'invoicing' ) ) . '" target="_blank" href="' . esc_url( admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $ip_address ) ) . '" class="wpi-ip-address-link">' . $ip_address . ' <i class="fa fa-external-link-square" aria-hidden="true"></i></a>'; |
|
| 1999 | + <?php if (empty($wpinv_options['hide_ip_address'])) { |
|
| 2000 | + $ip_link = '<a title="' . esc_attr(__('View more details on map', 'invoicing')) . '" target="_blank" href="' . esc_url(admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $ip_address)) . '" class="wpi-ip-address-link">' . $ip_address . ' <i class="fa fa-external-link-square" aria-hidden="true"></i></a>'; |
|
| 2001 | 2001 | ?> |
| 2002 | 2002 | <div class="wpi-ip-info clearfix panel panel-info"> |
| 2003 | 2003 | <div id="wpinv-fields-box" class="panel-body"> |
| 2004 | - <span><?php echo wp_sprintf( __( "Your IP address is: %s", 'invoicing' ), $ip_link ); ?></span> |
|
| 2004 | + <span><?php echo wp_sprintf(__("Your IP address is: %s", 'invoicing'), $ip_link); ?></span> |
|
| 2005 | 2005 | </div> |
| 2006 | 2006 | </div> |
| 2007 | 2007 | <?php } |
| 2008 | 2008 | } |
| 2009 | 2009 | |
| 2010 | - public static function show_vat_notice( $invoice ) { |
|
| 2011 | - if ( empty( $invoice ) ) { |
|
| 2010 | + public static function show_vat_notice($invoice) { |
|
| 2011 | + if (empty($invoice)) { |
|
| 2012 | 2012 | return NULL; |
| 2013 | 2013 | } |
| 2014 | 2014 | |
| 2015 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
| 2016 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
| 2017 | - if ( $label || $notice ) { |
|
| 2015 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
| 2016 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
| 2017 | + if ($label || $notice) { |
|
| 2018 | 2018 | ?> |
| 2019 | 2019 | <div class="row wpinv-vat-notice"> |
| 2020 | 2020 | <div class="col-sm-12"> |
| 2021 | - <?php if ( $label ) { ?> |
|
| 2022 | - <strong><?php _e( $label, 'invoicing' ); ?></strong> |
|
| 2023 | - <?php } if ( $notice ) { ?> |
|
| 2024 | - <?php echo wpautop( wptexturize( __( $notice, 'invoicing' ) ) ) ?> |
|
| 2021 | + <?php if ($label) { ?> |
|
| 2022 | + <strong><?php _e($label, 'invoicing'); ?></strong> |
|
| 2023 | + <?php } if ($notice) { ?> |
|
| 2024 | + <?php echo wpautop(wptexturize(__($notice, 'invoicing'))) ?> |
|
| 2025 | 2025 | <?php } ?> |
| 2026 | 2026 | </div> |
| 2027 | 2027 | </div> |
@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | class WPInv_Plugin { |
| 15 | 15 | private static $instance; |
| 16 | 16 | |
| 17 | 17 | public static function run() { |
| 18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) { |
|
| 18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) { |
|
| 19 | 19 | self::$instance = new WPInv_Plugin; |
| 20 | 20 | self::$instance->includes(); |
| 21 | 21 | self::$instance->actions(); |
@@ -31,31 +31,31 @@ discard block |
||
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function define_constants() { |
| 34 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
| 35 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
| 34 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
| 35 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | private function actions() { |
| 39 | 39 | /* Internationalize the text strings used. */ |
| 40 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
| 40 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
| 41 | 41 | |
| 42 | 42 | /* Perform actions on admin initialization. */ |
| 43 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
| 44 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
| 45 | - add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) ); |
|
| 46 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
| 43 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
| 44 | + add_action('init', array(&$this, 'init'), 3); |
|
| 45 | + add_action('init', array('WPInv_Shortcodes', 'init')); |
|
| 46 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
| 47 | 47 | |
| 48 | - if ( class_exists( 'BuddyPress' ) ) { |
|
| 49 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
| 48 | + if (class_exists('BuddyPress')) { |
|
| 49 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
| 52 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
| 53 | 53 | |
| 54 | - if ( is_admin() ) { |
|
| 55 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
| 56 | - add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
| 54 | + if (is_admin()) { |
|
| 55 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
| 56 | + add_action('admin_body_class', array(&$this, 'admin_body_class')); |
|
| 57 | 57 | } else { |
| 58 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
| 58 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -65,16 +65,16 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
| 67 | 67 | */ |
| 68 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
| 68 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
| 69 | 69 | |
| 70 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
| 70 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | public function plugins_loaded() { |
| 74 | 74 | /* Internationalize the text strings used. */ |
| 75 | 75 | $this->load_textdomain(); |
| 76 | 76 | |
| 77 | - do_action( 'wpinv_loaded' ); |
|
| 77 | + do_action('wpinv_loaded'); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -82,217 +82,217 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @since 1.0 |
| 84 | 84 | */ |
| 85 | - public function load_textdomain( $locale = NULL ) { |
|
| 86 | - if ( empty( $locale ) ) { |
|
| 87 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
| 85 | + public function load_textdomain($locale = NULL) { |
|
| 86 | + if (empty($locale)) { |
|
| 87 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
| 90 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
| 91 | 91 | |
| 92 | - unload_textdomain( 'invoicing' ); |
|
| 93 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
| 94 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
| 92 | + unload_textdomain('invoicing'); |
|
| 93 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
| 94 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | * Define language constants. |
| 98 | 98 | */ |
| 99 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
| 99 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | public function includes() { |
| 103 | 103 | global $wpinv_options; |
| 104 | 104 | |
| 105 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
| 105 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
| 106 | 106 | $wpinv_options = wpinv_get_settings(); |
| 107 | 107 | |
| 108 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
| 109 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
| 110 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
| 111 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
| 112 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
| 113 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
| 114 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
| 115 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
| 116 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
| 117 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
| 118 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
| 119 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
| 120 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
| 121 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
| 122 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
| 123 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
| 124 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
| 125 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' ); |
|
| 126 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
| 127 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
| 128 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
| 129 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' ); |
|
| 130 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
| 131 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
| 132 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
| 133 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
| 134 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
| 135 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
| 136 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
| 137 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstract-wpinv-privacy.php' ); |
|
| 138 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
| 139 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
| 108 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
| 109 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
| 110 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
| 111 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
| 112 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
| 113 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
| 114 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
| 115 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
| 116 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
| 117 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
| 118 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
| 119 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
| 120 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
| 121 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
| 122 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
| 123 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
| 124 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
| 125 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php'); |
|
| 126 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
| 127 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
| 128 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
| 129 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php'); |
|
| 130 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
| 131 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
| 132 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
| 133 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
| 134 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
| 135 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
| 136 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
| 137 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstract-wpinv-privacy.php'); |
|
| 138 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
| 139 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
| 140 | 140 | |
| 141 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
| 142 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
| 141 | + if (!class_exists('WPInv_EUVat')) { |
|
| 142 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 146 | - if ( !empty( $gateways ) ) { |
|
| 147 | - foreach ( $gateways as $gateway ) { |
|
| 148 | - if ( $gateway == 'manual' ) { |
|
| 145 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
| 146 | + if (!empty($gateways)) { |
|
| 147 | + foreach ($gateways as $gateway) { |
|
| 148 | + if ($gateway == 'manual') { |
|
| 149 | 149 | continue; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
| 153 | 153 | |
| 154 | - if ( file_exists( $gateway_file ) ) { |
|
| 155 | - require_once( $gateway_file ); |
|
| 154 | + if (file_exists($gateway_file)) { |
|
| 155 | + require_once($gateway_file); |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
| 159 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
| 160 | 160 | |
| 161 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 162 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
| 163 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
| 164 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
| 161 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
| 162 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
| 163 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
| 164 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
| 165 | 165 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
| 166 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
| 167 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
| 168 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
| 169 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
| 170 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
| 171 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
| 172 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
| 166 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
| 167 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
| 168 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
| 169 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
| 170 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
| 171 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
| 172 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
| 173 | 173 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
| 174 | 174 | // load the user class only on the users.php page |
| 175 | 175 | global $pagenow; |
| 176 | - if($pagenow=='users.php'){ |
|
| 176 | + if ($pagenow == 'users.php') { |
|
| 177 | 177 | new WPInv_Admin_Users(); |
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // include css inliner |
| 182 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
| 183 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
| 182 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
| 183 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
| 186 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | public function init() { |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | public function admin_init() { |
| 193 | - if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
| 193 | + if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
| 196 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | public function activation_redirect() { |
| 200 | 200 | // Bail if no activation redirect |
| 201 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
| 201 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
| 202 | 202 | return; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // Delete the redirect transient |
| 206 | - delete_transient( '_wpinv_activation_redirect' ); |
|
| 206 | + delete_transient('_wpinv_activation_redirect'); |
|
| 207 | 207 | |
| 208 | 208 | // Bail if activating from network, or bulk |
| 209 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 209 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 210 | 210 | return; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
| 213 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
| 214 | 214 | exit; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | public function enqueue_scripts() { |
| 218 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 218 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 219 | 219 | |
| 220 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
| 221 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
| 220 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
| 221 | + wp_enqueue_style('wpinv_front_style'); |
|
| 222 | 222 | |
| 223 | 223 | // Register scripts |
| 224 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 225 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 224 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 225 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION); |
|
| 226 | 226 | |
| 227 | 227 | $localize = array(); |
| 228 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 229 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 228 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 229 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 230 | 230 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
| 231 | 231 | $localize['currency_pos'] = wpinv_currency_position(); |
| 232 | 232 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 233 | 233 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 234 | 234 | $localize['decimals'] = wpinv_decimals(); |
| 235 | - $localize['txtComplete'] = __( 'Complete', 'invoicing' ); |
|
| 235 | + $localize['txtComplete'] = __('Complete', 'invoicing'); |
|
| 236 | 236 | $localize['UseTaxes'] = wpinv_use_taxes(); |
| 237 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
| 237 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
| 238 | 238 | |
| 239 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
| 239 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
| 240 | 240 | |
| 241 | - wp_enqueue_script( 'jquery-blockui' ); |
|
| 241 | + wp_enqueue_script('jquery-blockui'); |
|
| 242 | 242 | $autofill_api = wpinv_get_option('address_autofill_api'); |
| 243 | 243 | $autofill_active = wpinv_get_option('address_autofill_active'); |
| 244 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
| 245 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
| 246 | - wp_dequeue_script( 'google-maps-api' ); |
|
| 244 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
| 245 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
| 246 | + wp_dequeue_script('google-maps-api'); |
|
| 247 | 247 | } |
| 248 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
| 249 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
| 248 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
| 249 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
| 253 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 252 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
| 253 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 254 | 254 | |
| 255 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
| 256 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
| 255 | + wp_enqueue_script('wpinv-front-script'); |
|
| 256 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | public function admin_enqueue_scripts() { |
| 260 | 260 | global $post, $pagenow; |
| 261 | 261 | |
| 262 | 262 | $post_type = wpinv_admin_post_type(); |
| 263 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 264 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
| 263 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 264 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
| 265 | 265 | |
| 266 | 266 | $jquery_ui_css = false; |
| 267 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
| 267 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
| 268 | 268 | $jquery_ui_css = true; |
| 269 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
| 269 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
| 270 | 270 | $jquery_ui_css = true; |
| 271 | 271 | } |
| 272 | - if ( $jquery_ui_css ) { |
|
| 273 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
| 274 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
| 272 | + if ($jquery_ui_css) { |
|
| 273 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
| 274 | + wp_enqueue_style('jquery-ui-css'); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
| 278 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
| 277 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
| 278 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
| 279 | 279 | |
| 280 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
| 281 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
| 280 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
| 281 | + wp_enqueue_style('wpinv_admin_style'); |
|
| 282 | 282 | |
| 283 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
| 284 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 285 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 283 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
| 284 | + if ($page == 'wpinv-subscriptions') { |
|
| 285 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
| 289 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 288 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
| 289 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 293 | - wp_enqueue_script( 'wp-color-picker' ); |
|
| 292 | + wp_enqueue_style('wp-color-picker'); |
|
| 293 | + wp_enqueue_script('wp-color-picker'); |
|
| 294 | 294 | |
| 295 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 295 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 296 | 296 | |
| 297 | 297 | if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
| 298 | 298 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -303,20 +303,20 @@ discard block |
||
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
| 307 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 306 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
| 307 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 308 | 308 | |
| 309 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
|
| 310 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
| 309 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
| 310 | + wp_enqueue_script('wpinv-admin-script'); |
|
| 311 | 311 | |
| 312 | 312 | $localize = array(); |
| 313 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 314 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
| 315 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 316 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
| 317 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
| 318 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
| 319 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
| 313 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 314 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
| 315 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 316 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
| 317 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
| 318 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
| 319 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
| 320 | 320 | $localize['tax'] = wpinv_tax_amount(); |
| 321 | 321 | $localize['discount'] = wpinv_discount_amount(); |
| 322 | 322 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -324,69 +324,69 @@ discard block |
||
| 324 | 324 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 325 | 325 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 326 | 326 | $localize['decimals'] = wpinv_decimals(); |
| 327 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
| 328 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
| 329 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
| 330 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
| 331 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
| 332 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
| 333 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
| 334 | - $localize['confirmCalcTotals'] = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ); |
|
| 335 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
| 336 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
| 337 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
| 338 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
| 339 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
| 340 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
| 327 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
| 328 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
| 329 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
| 330 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
| 331 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
| 332 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
| 333 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
| 334 | + $localize['confirmCalcTotals'] = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'); |
|
| 335 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
| 336 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
| 337 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
| 338 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
| 339 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
| 340 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
| 341 | 341 | |
| 342 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
| 342 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
| 343 | 343 | |
| 344 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
| 344 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
| 345 | 345 | |
| 346 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 347 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
| 348 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
| 346 | + if ($page == 'wpinv-subscriptions') { |
|
| 347 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
| 348 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - public function admin_body_class( $classes ) { |
|
| 352 | + public function admin_body_class($classes) { |
|
| 353 | 353 | global $pagenow, $post, $current_screen; |
| 354 | 354 | |
| 355 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
| 355 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
| 356 | 356 | $classes .= ' wpinv-cpt'; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
| 359 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
| 360 | 360 | |
| 361 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
| 362 | - if ( $add_class ) { |
|
| 363 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
| 361 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
| 362 | + if ($add_class) { |
|
| 363 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | $settings_class = array(); |
| 367 | - if ( $page == 'wpinv-settings' ) { |
|
| 368 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
| 369 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
| 367 | + if ($page == 'wpinv-settings') { |
|
| 368 | + if (!empty($_REQUEST['tab'])) { |
|
| 369 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
| 373 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
| 372 | + if (!empty($_REQUEST['section'])) { |
|
| 373 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
| 376 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - if ( !empty( $settings_class ) ) { |
|
| 380 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
| 379 | + if (!empty($settings_class)) { |
|
| 380 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | $post_type = wpinv_admin_post_type(); |
| 384 | 384 | |
| 385 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
| 385 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
| 386 | 386 | return $classes .= ' wpinv'; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
| 389 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
| 390 | 390 | $classes .= ' wpi-editable-n'; |
| 391 | 391 | } |
| 392 | 392 | |
@@ -398,20 +398,20 @@ discard block |
||
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | public function wpinv_actions() { |
| 401 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
| 402 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
| 401 | + if (isset($_REQUEST['wpi_action'])) { |
|
| 402 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - public function pre_get_posts( $wp_query ) { |
|
| 407 | - if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
| 408 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
| 406 | + public function pre_get_posts($wp_query) { |
|
| 407 | + if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
| 408 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | return $wp_query; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | public function bp_invoicing_init() { |
| 415 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
| 415 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
| 416 | 416 | } |
| 417 | 417 | } |
| 418 | 418 | \ No newline at end of file |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | -if ( ! class_exists( 'WP_Super_Duper' ) ) { |
|
| 6 | +if (!class_exists('WP_Super_Duper')) { |
|
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | /** |
@@ -39,27 +39,27 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * Take the array options and use them to build. |
| 41 | 41 | */ |
| 42 | - public function __construct( $options ) { |
|
| 42 | + public function __construct($options) { |
|
| 43 | 43 | global $sd_widgets; |
| 44 | 44 | |
| 45 | - $sd_widgets[ $options['base_id'] ] = array( |
|
| 45 | + $sd_widgets[$options['base_id']] = array( |
|
| 46 | 46 | 'name' => $options['name'], |
| 47 | 47 | 'class_name' => $options['class_name'] |
| 48 | 48 | ); |
| 49 | - $this->base_id = $options['base_id']; |
|
| 49 | + $this->base_id = $options['base_id']; |
|
| 50 | 50 | // lets filter the options before we do anything |
| 51 | - $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 52 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 53 | - $options = $this->add_name_from_key( $options ); |
|
| 51 | + $options = apply_filters("wp_super_duper_options", $options); |
|
| 52 | + $options = apply_filters("wp_super_duper_options_{$this->base_id}", $options); |
|
| 53 | + $options = $this->add_name_from_key($options); |
|
| 54 | 54 | $this->options = $options; |
| 55 | 55 | |
| 56 | 56 | $this->base_id = $options['base_id']; |
| 57 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 57 | + $this->arguments = isset($options['arguments']) ? $options['arguments'] : array(); |
|
| 58 | 58 | |
| 59 | 59 | // init parent |
| 60 | - parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
|
| 60 | + parent::__construct($options['base_id'], $options['name'], $options['widget_ops']); |
|
| 61 | 61 | |
| 62 | - if ( isset( $options['class_name'] ) ) { |
|
| 62 | + if (isset($options['class_name'])) { |
|
| 63 | 63 | // register widget |
| 64 | 64 | $this->class_name = $options['class_name']; |
| 65 | 65 | |
@@ -67,47 +67,47 @@ discard block |
||
| 67 | 67 | $this->register_shortcode(); |
| 68 | 68 | |
| 69 | 69 | // register block |
| 70 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 70 | + add_action('admin_enqueue_scripts', array($this, 'register_block')); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // add the CSS and JS we need ONCE |
| 74 | 74 | global $sd_widget_scripts; |
| 75 | 75 | |
| 76 | - if ( ! $sd_widget_scripts ) { |
|
| 77 | - wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 78 | - wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 79 | - wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 76 | + if (!$sd_widget_scripts) { |
|
| 77 | + wp_add_inline_script('admin-widgets', $this->widget_js()); |
|
| 78 | + wp_add_inline_script('customize-controls', $this->widget_js()); |
|
| 79 | + wp_add_inline_style('widgets', $this->widget_css()); |
|
| 80 | 80 | |
| 81 | 81 | $sd_widget_scripts = true; |
| 82 | 82 | |
| 83 | 83 | // add shortcode insert button once |
| 84 | - add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 85 | - if ( $this->is_preview() ) { |
|
| 86 | - add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 84 | + add_action('media_buttons', array($this, 'shortcode_insert_button')); |
|
| 85 | + if ($this->is_preview()) { |
|
| 86 | + add_action('wp_footer', array($this, 'shortcode_insert_button_script')); |
|
| 87 | 87 | // this makes the insert button work for elementor |
| 88 | - add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 88 | + add_action('elementor/editor/after_enqueue_scripts', array( |
|
| 89 | 89 | $this, |
| 90 | 90 | 'shortcode_insert_button_script' |
| 91 | - ) ); // for elementor |
|
| 91 | + )); // for elementor |
|
| 92 | 92 | } |
| 93 | 93 | // this makes the insert button work for cornerstone |
| 94 | - add_action('wp_print_footer_scripts',array( __CLASS__, 'maybe_cornerstone_builder' )); |
|
| 94 | + add_action('wp_print_footer_scripts', array(__CLASS__, 'maybe_cornerstone_builder')); |
|
| 95 | 95 | |
| 96 | - add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 97 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 96 | + add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings')); |
|
| 97 | + add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker')); |
|
| 98 | 98 | |
| 99 | 99 | // add generator text to admin head |
| 100 | - add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 100 | + add_action('admin_head', array($this, 'generator')); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 103 | + do_action('wp_super_duper_widget_init', $options, $this); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
| 108 | 108 | */ |
| 109 | - public static function maybe_cornerstone_builder(){ |
|
| 110 | - if(did_action('cornerstone_before_boot_app')){ |
|
| 109 | + public static function maybe_cornerstone_builder() { |
|
| 110 | + if (did_action('cornerstone_before_boot_app')) { |
|
| 111 | 111 | self::shortcode_insert_button_script(); |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -119,12 +119,12 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @return string |
| 121 | 121 | */ |
| 122 | - public static function get_picker( $editor_id = '' ) { |
|
| 122 | + public static function get_picker($editor_id = '') { |
|
| 123 | 123 | |
| 124 | 124 | ob_start(); |
| 125 | - if ( isset( $_POST['editor_id'] ) ) { |
|
| 126 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 127 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 125 | + if (isset($_POST['editor_id'])) { |
|
| 126 | + $editor_id = esc_attr($_POST['editor_id']); |
|
| 127 | + } elseif (isset($_REQUEST['et_fb'])) { |
|
| 128 | 128 | $editor_id = 'main_content_content_vb_tiny_mce'; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | <div class="sd-shortcode-left-wrap"> |
| 135 | 135 | <?php |
| 136 | - asort( $sd_widgets ); |
|
| 137 | - if ( ! empty( $sd_widgets ) ) { |
|
| 136 | + asort($sd_widgets); |
|
| 137 | + if (!empty($sd_widgets)) { |
|
| 138 | 138 | echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
| 139 | - echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 140 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 141 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 139 | + echo "<option>" . __('Select shortcode') . "</option>"; |
|
| 140 | + foreach ($sd_widgets as $shortcode => $class) { |
|
| 141 | + echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>"; |
|
| 142 | 142 | } |
| 143 | 143 | echo "</select>"; |
| 144 | 144 | |
@@ -151,37 +151,37 @@ discard block |
||
| 151 | 151 | <div class="sd-shortcode-right-wrap"> |
| 152 | 152 | <textarea id='sd-shortcode-output' disabled></textarea> |
| 153 | 153 | <div id='sd-shortcode-output-actions'> |
| 154 | - <?php if ( $editor_id != '' ) { ?> |
|
| 154 | + <?php if ($editor_id != '') { ?> |
|
| 155 | 155 | <button class="button sd-insert-shortcode-button" |
| 156 | - onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { |
|
| 156 | + onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) { |
|
| 157 | 157 | echo "'" . $editor_id . "'"; |
| 158 | - } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 158 | + } ?>)"><?php _e('Insert shortcode'); ?></button> |
|
| 159 | 159 | <?php } ?> |
| 160 | 160 | <button class="button" |
| 161 | - onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button> |
|
| 161 | + onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button> |
|
| 162 | 162 | </div> |
| 163 | 163 | </div> |
| 164 | 164 | <?php |
| 165 | 165 | |
| 166 | 166 | $html = ob_get_clean(); |
| 167 | 167 | |
| 168 | - if ( wp_doing_ajax() ) { |
|
| 168 | + if (wp_doing_ajax()) { |
|
| 169 | 169 | echo $html; |
| 170 | 170 | $should_die = true; |
| 171 | 171 | |
| 172 | 172 | // some builder get the editor via ajax so we should not die on those ocasions |
| 173 | 173 | $dont_die = array( |
| 174 | - 'parent_tag',// WP Bakery |
|
| 174 | + 'parent_tag', // WP Bakery |
|
| 175 | 175 | 'avia_request' // enfold |
| 176 | 176 | ); |
| 177 | 177 | |
| 178 | - foreach ( $dont_die as $request ) { |
|
| 179 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 178 | + foreach ($dont_die as $request) { |
|
| 179 | + if (isset($_REQUEST[$request])) { |
|
| 180 | 180 | $should_die = false; |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ( $should_die ) { |
|
| 184 | + if ($should_die) { |
|
| 185 | 185 | wp_die(); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -208,16 +208,16 @@ discard block |
||
| 208 | 208 | public static function get_widget_settings() { |
| 209 | 209 | global $sd_widgets; |
| 210 | 210 | |
| 211 | - $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 212 | - if ( ! $shortcode ) { |
|
| 211 | + $shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : ''; |
|
| 212 | + if (!$shortcode) { |
|
| 213 | 213 | wp_die(); |
| 214 | 214 | } |
| 215 | - $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 216 | - if ( ! $widget_args ) { |
|
| 215 | + $widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : ''; |
|
| 216 | + if (!$widget_args) { |
|
| 217 | 217 | wp_die(); |
| 218 | 218 | } |
| 219 | - $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 220 | - if ( ! $class_name ) { |
|
| 219 | + $class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 220 | + if (!$class_name) { |
|
| 221 | 221 | wp_die(); |
| 222 | 222 | } |
| 223 | 223 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $widget = new $class_name; |
| 226 | 226 | |
| 227 | 227 | ob_start(); |
| 228 | - $widget->form( array() ); |
|
| 228 | + $widget->form(array()); |
|
| 229 | 229 | $form = ob_get_clean(); |
| 230 | 230 | echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
| 231 | 231 | echo "<style>" . $widget->widget_css() . "</style>"; |
@@ -243,9 +243,9 @@ discard block |
||
| 243 | 243 | * @param string $editor_id Optional. Shortcode editor id. Default null. |
| 244 | 244 | * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null. |
| 245 | 245 | */ |
| 246 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 246 | + public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') { |
|
| 247 | 247 | global $sd_widgets, $shortcode_insert_button_once; |
| 248 | - if ( $shortcode_insert_button_once ) { |
|
| 248 | + if ($shortcode_insert_button_once) { |
|
| 249 | 249 | return; |
| 250 | 250 | } |
| 251 | 251 | add_thickbox(); |
@@ -255,18 +255,18 @@ discard block |
||
| 255 | 255 | * Cornerstone makes us play dirty tricks :/ |
| 256 | 256 | * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
| 257 | 257 | */ |
| 258 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 258 | + if (function_exists('cornerstone_plugin_init') && !is_admin()) { |
|
| 259 | 259 | echo '<span id="insert-media-button">'; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - echo self::shortcode_button( 'this', 'true' ); |
|
| 262 | + echo self::shortcode_button('this', 'true'); |
|
| 263 | 263 | |
| 264 | 264 | // see opening note |
| 265 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 265 | + if (function_exists('cornerstone_plugin_init') && !is_admin()) { |
|
| 266 | 266 | echo '</span>'; // end #insert-media-button |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 269 | + self::shortcode_insert_button_script($editor_id, $insert_shortcode_function); |
|
| 270 | 270 | $shortcode_insert_button_once = true; |
| 271 | 271 | } |
| 272 | 272 | |
@@ -278,12 +278,12 @@ discard block |
||
| 278 | 278 | * |
| 279 | 279 | * @return mixed |
| 280 | 280 | */ |
| 281 | - public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 281 | + public static function shortcode_button($id = '', $search_for_id = '') { |
|
| 282 | 282 | ob_start(); |
| 283 | 283 | ?> |
| 284 | 284 | <span class="sd-lable-shortcode-inserter"> |
| 285 | 285 | <a onclick="sd_ajax_get_picker(<?php echo $id; |
| 286 | - if ( $search_for_id ) { |
|
| 286 | + if ($search_for_id) { |
|
| 287 | 287 | echo "," . $search_for_id; |
| 288 | 288 | } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
| 289 | 289 | class="thickbox button super-duper-content-open" title="Add Shortcode"> |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | $html = ob_get_clean(); |
| 300 | 300 | |
| 301 | 301 | // remove line breaks so we can use it in js |
| 302 | - return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 302 | + return preg_replace("/\r|\n/", "", trim($html)); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | jQuery($this).data('sd-widget-enabled', true); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - var $button = '<button title="<?php _e( 'Advanced Settings' );?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>'; |
|
| 360 | + var $button = '<button title="<?php _e('Advanced Settings'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>'; |
|
| 361 | 361 | var form = jQuery($this).parents('' + $selector + ''); |
| 362 | 362 | |
| 363 | 363 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -394,10 +394,10 @@ discard block |
||
| 394 | 394 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 395 | 395 | */ |
| 396 | 396 | |
| 397 | - return str_replace( array( |
|
| 397 | + return str_replace(array( |
|
| 398 | 398 | '<script>', |
| 399 | 399 | '</script>' |
| 400 | - ), '', $output ); |
|
| 400 | + ), '', $output); |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | /** |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | * @param string $editor_id |
| 409 | 409 | * @param string $insert_shortcode_function |
| 410 | 410 | */ |
| 411 | - public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 411 | + public static function shortcode_insert_button_script($editor_id = '', $insert_shortcode_function = '') { |
|
| 412 | 412 | ?> |
| 413 | 413 | <style> |
| 414 | 414 | .sd-shortcode-left-wrap { |
@@ -528,15 +528,15 @@ discard block |
||
| 528 | 528 | } |
| 529 | 529 | </style> |
| 530 | 530 | <?php |
| 531 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 531 | + if (class_exists('SiteOrigin_Panels')) { |
|
| 532 | 532 | echo "<script>" . self::siteorigin_js() . "</script>"; |
| 533 | 533 | } |
| 534 | 534 | ?> |
| 535 | 535 | <script> |
| 536 | 536 | <?php |
| 537 | - if(! empty( $insert_shortcode_function )){ |
|
| 537 | + if (!empty($insert_shortcode_function)) { |
|
| 538 | 538 | echo $insert_shortcode_function; |
| 539 | - }else{ |
|
| 539 | + } else { |
|
| 540 | 540 | |
| 541 | 541 | /** |
| 542 | 542 | * Function for super duper insert shortcode. |
@@ -551,9 +551,9 @@ discard block |
||
| 551 | 551 | if (!$editor_id) { |
| 552 | 552 | |
| 553 | 553 | <?php |
| 554 | - if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 554 | + if (isset($_REQUEST['et_fb'])) { |
|
| 555 | 555 | echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
| 556 | - } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 556 | + } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') { |
|
| 557 | 557 | echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
| 558 | 558 | } else { |
| 559 | 559 | echo '$editor_id = "#wp-content-editor-container textarea";'; |
@@ -633,11 +633,11 @@ discard block |
||
| 633 | 633 | 'shortcode': $short_code, |
| 634 | 634 | 'attributes': 123, |
| 635 | 635 | 'post_id': 321, |
| 636 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
|
| 636 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>' |
|
| 637 | 637 | }; |
| 638 | 638 | |
| 639 | 639 | if (typeof ajaxurl === 'undefined') { |
| 640 | - var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>"; |
|
| 640 | + var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | jQuery.post(ajaxurl, data, function (response) { |
@@ -835,11 +835,11 @@ discard block |
||
| 835 | 835 | var data = { |
| 836 | 836 | 'action': 'super_duper_get_picker', |
| 837 | 837 | 'editor_id': $id, |
| 838 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_picker' );?>' |
|
| 838 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_picker'); ?>' |
|
| 839 | 839 | }; |
| 840 | 840 | |
| 841 | 841 | if (!ajaxurl) { |
| 842 | - var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>"; |
|
| 842 | + var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; |
|
| 843 | 843 | } |
| 844 | 844 | |
| 845 | 845 | jQuery.post(ajaxurl, data, function (response) { |
@@ -860,9 +860,9 @@ discard block |
||
| 860 | 860 | */ |
| 861 | 861 | function sd_shortcode_button($id) { |
| 862 | 862 | if ($id) { |
| 863 | - return '<?php echo self::shortcode_button( "\\''+\$id+'\\'" );?>'; |
|
| 863 | + return '<?php echo self::shortcode_button("\\''+\$id+'\\'"); ?>'; |
|
| 864 | 864 | } else { |
| 865 | - return '<?php echo self::shortcode_button();?>'; |
|
| 865 | + return '<?php echo self::shortcode_button(); ?>'; |
|
| 866 | 866 | } |
| 867 | 867 | } |
| 868 | 868 | |
@@ -904,10 +904,10 @@ discard block |
||
| 904 | 904 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 905 | 905 | */ |
| 906 | 906 | |
| 907 | - return str_replace( array( |
|
| 907 | + return str_replace(array( |
|
| 908 | 908 | '<style>', |
| 909 | 909 | '</style>' |
| 910 | - ), '', $output ); |
|
| 910 | + ), '', $output); |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | /** |
@@ -977,7 +977,7 @@ discard block |
||
| 977 | 977 | jQuery($this).data('sd-widget-enabled', true); |
| 978 | 978 | } |
| 979 | 979 | |
| 980 | - var $button = '<button title="<?php _e( 'Advanced Settings' );?>" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>'; |
|
| 980 | + var $button = '<button title="<?php _e('Advanced Settings'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>'; |
|
| 981 | 981 | var form = jQuery($this).parents('' + $selector + ''); |
| 982 | 982 | |
| 983 | 983 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | }); |
| 1070 | 1070 | |
| 1071 | 1071 | } |
| 1072 | - <?php do_action( 'wp_super_duper_widget_js', $this ); ?> |
|
| 1072 | + <?php do_action('wp_super_duper_widget_js', $this); ?> |
|
| 1073 | 1073 | </script> |
| 1074 | 1074 | <?php |
| 1075 | 1075 | $output = ob_get_clean(); |
@@ -1078,10 +1078,10 @@ discard block |
||
| 1078 | 1078 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1079 | 1079 | */ |
| 1080 | 1080 | |
| 1081 | - return str_replace( array( |
|
| 1081 | + return str_replace(array( |
|
| 1082 | 1082 | '<script>', |
| 1083 | 1083 | '</script>' |
| 1084 | - ), '', $output ); |
|
| 1084 | + ), '', $output); |
|
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | |
@@ -1092,14 +1092,14 @@ discard block |
||
| 1092 | 1092 | * |
| 1093 | 1093 | * @return mixed |
| 1094 | 1094 | */ |
| 1095 | - private function add_name_from_key( $options, $arguments = false ) { |
|
| 1096 | - if ( ! empty( $options['arguments'] ) ) { |
|
| 1097 | - foreach ( $options['arguments'] as $key => $val ) { |
|
| 1098 | - $options['arguments'][ $key ]['name'] = $key; |
|
| 1095 | + private function add_name_from_key($options, $arguments = false) { |
|
| 1096 | + if (!empty($options['arguments'])) { |
|
| 1097 | + foreach ($options['arguments'] as $key => $val) { |
|
| 1098 | + $options['arguments'][$key]['name'] = $key; |
|
| 1099 | 1099 | } |
| 1100 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1101 | - foreach ( $options as $key => $val ) { |
|
| 1102 | - $options[ $key ]['name'] = $key; |
|
| 1100 | + } elseif ($arguments && is_array($options) && !empty($options)) { |
|
| 1101 | + foreach ($options as $key => $val) { |
|
| 1102 | + $options[$key]['name'] = $key; |
|
| 1103 | 1103 | } |
| 1104 | 1104 | } |
| 1105 | 1105 | |
@@ -1112,8 +1112,8 @@ discard block |
||
| 1112 | 1112 | * @since 1.0.0 |
| 1113 | 1113 | */ |
| 1114 | 1114 | public function register_shortcode() { |
| 1115 | - add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1116 | - add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) ); |
|
| 1115 | + add_shortcode($this->base_id, array($this, 'shortcode_output')); |
|
| 1116 | + add_action('wp_ajax_super_duper_output_shortcode', array(__CLASS__, 'render_shortcode')); |
|
| 1117 | 1117 | } |
| 1118 | 1118 | |
| 1119 | 1119 | /** |
@@ -1123,33 +1123,33 @@ discard block |
||
| 1123 | 1123 | */ |
| 1124 | 1124 | public static function render_shortcode() { |
| 1125 | 1125 | |
| 1126 | - check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1127 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1126 | + check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true); |
|
| 1127 | + if (!current_user_can('manage_options')) { |
|
| 1128 | 1128 | wp_die(); |
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | 1131 | // we might need the $post value here so lets set it. |
| 1132 | - if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1133 | - $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1134 | - if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1132 | + if (isset($_POST['post_id']) && $_POST['post_id']) { |
|
| 1133 | + $post_obj = get_post(absint($_POST['post_id'])); |
|
| 1134 | + if (!empty($post_obj) && empty($post)) { |
|
| 1135 | 1135 | global $post; |
| 1136 | 1136 | $post = $post_obj; |
| 1137 | 1137 | } |
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | - if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1141 | - $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1142 | - $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1140 | + if (isset($_POST['shortcode']) && $_POST['shortcode']) { |
|
| 1141 | + $shortcode_name = sanitize_title_with_dashes($_POST['shortcode']); |
|
| 1142 | + $attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1143 | 1143 | $attributes = ''; |
| 1144 | - if ( ! empty( $attributes_array ) ) { |
|
| 1145 | - foreach ( $attributes_array as $key => $value ) { |
|
| 1146 | - $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' "; |
|
| 1144 | + if (!empty($attributes_array)) { |
|
| 1145 | + foreach ($attributes_array as $key => $value) { |
|
| 1146 | + $attributes .= " " . sanitize_title_with_dashes($key) . "='" . wp_slash($value) . "' "; |
|
| 1147 | 1147 | } |
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | 1150 | $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
| 1151 | 1151 | |
| 1152 | - echo do_shortcode( $shortcode ); |
|
| 1152 | + echo do_shortcode($shortcode); |
|
| 1153 | 1153 | |
| 1154 | 1154 | } |
| 1155 | 1155 | wp_die(); |
@@ -1163,37 +1163,37 @@ discard block |
||
| 1163 | 1163 | * |
| 1164 | 1164 | * @return string |
| 1165 | 1165 | */ |
| 1166 | - public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1167 | - $args = self::argument_values( $args ); |
|
| 1166 | + public function shortcode_output($args = array(), $content = '') { |
|
| 1167 | + $args = self::argument_values($args); |
|
| 1168 | 1168 | |
| 1169 | 1169 | // add extra argument so we know its a output to gutenberg |
| 1170 | 1170 | //$args |
| 1171 | - $args = $this->string_to_bool( $args ); |
|
| 1171 | + $args = $this->string_to_bool($args); |
|
| 1172 | 1172 | |
| 1173 | 1173 | |
| 1174 | - $calss = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1174 | + $calss = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : ''; |
|
| 1175 | 1175 | |
| 1176 | - $calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this ); |
|
| 1177 | - $calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this ); |
|
| 1176 | + $calss = apply_filters('wp_super_duper_div_classname', $calss, $args, $this); |
|
| 1177 | + $calss = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this); |
|
| 1178 | 1178 | |
| 1179 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1180 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 1179 | + $attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this); |
|
| 1180 | + $attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this); |
|
| 1181 | 1181 | |
| 1182 | 1182 | $shortcode_args = array(); |
| 1183 | 1183 | $output = ''; |
| 1184 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1185 | - $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1186 | - if ( $main_content && ! $no_wrap ) { |
|
| 1184 | + $no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false; |
|
| 1185 | + $main_content = $this->output($args, $shortcode_args, $content); |
|
| 1186 | + if ($main_content && !$no_wrap) { |
|
| 1187 | 1187 | // wrap the shortcode in a dive with the same class as the widget |
| 1188 | 1188 | $output .= '<div class="' . $calss . '" ' . $attrs . '>'; |
| 1189 | - if ( ! empty( $args['title'] ) ) { |
|
| 1189 | + if (!empty($args['title'])) { |
|
| 1190 | 1190 | // if its a shortcode and there is a title try to grab the title wrappers |
| 1191 | - $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1192 | - if ( empty( $instance ) ) { |
|
| 1191 | + $shortcode_args = array('before_title' => '', 'after_title' => ''); |
|
| 1192 | + if (empty($instance)) { |
|
| 1193 | 1193 | global $wp_registered_sidebars; |
| 1194 | - if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1195 | - foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1196 | - if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1194 | + if (!empty($wp_registered_sidebars)) { |
|
| 1195 | + foreach ($wp_registered_sidebars as $sidebar) { |
|
| 1196 | + if (!empty($sidebar['before_title'])) { |
|
| 1197 | 1197 | $shortcode_args['before_title'] = $sidebar['before_title']; |
| 1198 | 1198 | $shortcode_args['after_title'] = $sidebar['after_title']; |
| 1199 | 1199 | break; |
@@ -1201,17 +1201,17 @@ discard block |
||
| 1201 | 1201 | } |
| 1202 | 1202 | } |
| 1203 | 1203 | } |
| 1204 | - $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1204 | + $output .= $this->output_title($shortcode_args, $args); |
|
| 1205 | 1205 | } |
| 1206 | 1206 | $output .= $main_content; |
| 1207 | 1207 | $output .= '</div>'; |
| 1208 | - } elseif ( $main_content && $no_wrap ) { |
|
| 1208 | + } elseif ($main_content && $no_wrap) { |
|
| 1209 | 1209 | $output .= $main_content; |
| 1210 | 1210 | } |
| 1211 | 1211 | |
| 1212 | 1212 | // if preview show a placeholder if empty |
| 1213 | - if ( $this->is_preview() && $output == '' ) { |
|
| 1214 | - $output = $this->preview_placeholder_text( "[{" . $this->base_id . "}]" ); |
|
| 1213 | + if ($this->is_preview() && $output == '') { |
|
| 1214 | + $output = $this->preview_placeholder_text("[{" . $this->base_id . "}]"); |
|
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | 1217 | return $output; |
@@ -1224,8 +1224,8 @@ discard block |
||
| 1224 | 1224 | * |
| 1225 | 1225 | * @return string |
| 1226 | 1226 | */ |
| 1227 | - public function preview_placeholder_text( $name = '' ) { |
|
| 1228 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1227 | + public function preview_placeholder_text($name = '') { |
|
| 1228 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf(__('Placeholder for: %s'), $name) . "</div>"; |
|
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | 1231 | /** |
@@ -1235,13 +1235,13 @@ discard block |
||
| 1235 | 1235 | * |
| 1236 | 1236 | * @return mixed |
| 1237 | 1237 | */ |
| 1238 | - public function string_to_bool( $options ) { |
|
| 1238 | + public function string_to_bool($options) { |
|
| 1239 | 1239 | // convert bool strings to booleans |
| 1240 | - foreach ( $options as $key => $val ) { |
|
| 1241 | - if ( $val == 'false' ) { |
|
| 1242 | - $options[ $key ] = false; |
|
| 1243 | - } elseif ( $val == 'true' ) { |
|
| 1244 | - $options[ $key ] = true; |
|
| 1240 | + foreach ($options as $key => $val) { |
|
| 1241 | + if ($val == 'false') { |
|
| 1242 | + $options[$key] = false; |
|
| 1243 | + } elseif ($val == 'true') { |
|
| 1244 | + $options[$key] = true; |
|
| 1245 | 1245 | } |
| 1246 | 1246 | } |
| 1247 | 1247 | |
@@ -1257,27 +1257,27 @@ discard block |
||
| 1257 | 1257 | * |
| 1258 | 1258 | * @return array |
| 1259 | 1259 | */ |
| 1260 | - public function argument_values( $instance ) { |
|
| 1260 | + public function argument_values($instance) { |
|
| 1261 | 1261 | $argument_values = array(); |
| 1262 | 1262 | |
| 1263 | 1263 | // set widget instance |
| 1264 | 1264 | $this->instance = $instance; |
| 1265 | 1265 | |
| 1266 | - if ( empty( $this->arguments ) ) { |
|
| 1266 | + if (empty($this->arguments)) { |
|
| 1267 | 1267 | $this->arguments = $this->get_arguments(); |
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | - if ( ! empty( $this->arguments ) ) { |
|
| 1271 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1270 | + if (!empty($this->arguments)) { |
|
| 1271 | + foreach ($this->arguments as $key => $args) { |
|
| 1272 | 1272 | // set the input name from the key |
| 1273 | 1273 | $args['name'] = $key; |
| 1274 | 1274 | // |
| 1275 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1276 | - if($args['type']=='checkbox' && $argument_values[ $key ] == ''){ |
|
| 1275 | + $argument_values[$key] = isset($instance[$key]) ? $instance[$key] : ''; |
|
| 1276 | + if ($args['type'] == 'checkbox' && $argument_values[$key] == '') { |
|
| 1277 | 1277 | // don't set default for an empty checkbox |
| 1278 | 1278 | } |
| 1279 | - elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1280 | - $argument_values[ $key ] = $args['default']; |
|
| 1279 | + elseif ($argument_values[$key] == '' && isset($args['default'])) { |
|
| 1280 | + $argument_values[$key] = $args['default']; |
|
| 1281 | 1281 | } |
| 1282 | 1282 | } |
| 1283 | 1283 | } |
@@ -1304,12 +1304,12 @@ discard block |
||
| 1304 | 1304 | * @return array Get arguments. |
| 1305 | 1305 | */ |
| 1306 | 1306 | public function get_arguments() { |
| 1307 | - if ( empty( $this->arguments ) ) { |
|
| 1307 | + if (empty($this->arguments)) { |
|
| 1308 | 1308 | $this->arguments = $this->set_arguments(); |
| 1309 | 1309 | } |
| 1310 | 1310 | |
| 1311 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1312 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1311 | + $this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance); |
|
| 1312 | + $this->arguments = $this->add_name_from_key($this->arguments, true); |
|
| 1313 | 1313 | |
| 1314 | 1314 | return $this->arguments; |
| 1315 | 1315 | } |
@@ -1321,7 +1321,7 @@ discard block |
||
| 1321 | 1321 | * @param array $widget_args |
| 1322 | 1322 | * @param string $content |
| 1323 | 1323 | */ |
| 1324 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1324 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 1325 | 1325 | |
| 1326 | 1326 | } |
| 1327 | 1327 | |
@@ -1329,10 +1329,10 @@ discard block |
||
| 1329 | 1329 | * Add the dynamic block code inline when the wp-block in enqueued. |
| 1330 | 1330 | */ |
| 1331 | 1331 | public function register_block() { |
| 1332 | - wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1333 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1332 | + wp_add_inline_script('wp-blocks', $this->block()); |
|
| 1333 | + if (class_exists('SiteOrigin_Panels')) { |
|
| 1334 | 1334 | |
| 1335 | - wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1335 | + wp_add_inline_script('wp-blocks', $this->siteorigin_js()); |
|
| 1336 | 1336 | |
| 1337 | 1337 | } |
| 1338 | 1338 | } |
@@ -1347,13 +1347,13 @@ discard block |
||
| 1347 | 1347 | $show = false; |
| 1348 | 1348 | $arguments = $this->arguments; |
| 1349 | 1349 | |
| 1350 | - if ( empty( $arguments ) ) { |
|
| 1350 | + if (empty($arguments)) { |
|
| 1351 | 1351 | $arguments = $this->get_arguments(); |
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | - if ( ! empty( $arguments ) ) { |
|
| 1355 | - foreach ( $arguments as $argument ) { |
|
| 1356 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1354 | + if (!empty($arguments)) { |
|
| 1355 | + foreach ($arguments as $argument) { |
|
| 1356 | + if (isset($argument['advanced']) && $argument['advanced']) { |
|
| 1357 | 1357 | $show = true; |
| 1358 | 1358 | } |
| 1359 | 1359 | } |
@@ -1405,12 +1405,12 @@ discard block |
||
| 1405 | 1405 | * @return {?WPBlock} The block, if it has been successfully |
| 1406 | 1406 | * registered; otherwise `undefined`. |
| 1407 | 1407 | */ |
| 1408 | - registerBlockType('<?php echo str_replace( "_", "-", sanitize_title_with_dashes( $this->options['textdomain'] ) . '/' . sanitize_title_with_dashes( $this->options['class_name'] ) ); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block. |
|
| 1409 | - title: '<?php echo $this->options['name'];?>', // Block title. |
|
| 1410 | - description: '<?php echo esc_attr( $this->options['widget_ops']['description'] )?>', // Block title. |
|
| 1411 | - icon: '<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
|
| 1412 | - category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
|
| 1413 | - <?php if ( isset( $this->options['block-keywords'] ) ) { |
|
| 1408 | + registerBlockType('<?php echo str_replace("_", "-", sanitize_title_with_dashes($this->options['textdomain']) . '/' . sanitize_title_with_dashes($this->options['class_name'])); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block. |
|
| 1409 | + title: '<?php echo $this->options['name']; ?>', // Block title. |
|
| 1410 | + description: '<?php echo esc_attr($this->options['widget_ops']['description'])?>', // Block title. |
|
| 1411 | + icon: '<?php echo isset($this->options['block-icon']) ? esc_attr($this->options['block-icon']) : 'shield-alt'; ?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
|
| 1412 | + category: '<?php echo isset($this->options['block-category']) ? esc_attr($this->options['block-category']) : 'common'; ?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
|
| 1413 | + <?php if (isset($this->options['block-keywords'])) { |
|
| 1414 | 1414 | echo "keywords : " . $this->options['block-keywords'] . ","; |
| 1415 | 1415 | }?> |
| 1416 | 1416 | |
@@ -1420,10 +1420,10 @@ discard block |
||
| 1420 | 1420 | |
| 1421 | 1421 | $show_alignment = false; |
| 1422 | 1422 | |
| 1423 | - if ( ! empty( $this->arguments ) ) { |
|
| 1423 | + if (!empty($this->arguments)) { |
|
| 1424 | 1424 | echo "attributes : {"; |
| 1425 | 1425 | |
| 1426 | - if ( $show_advanced ) { |
|
| 1426 | + if ($show_advanced) { |
|
| 1427 | 1427 | echo "show_advanced: {"; |
| 1428 | 1428 | echo " type: 'boolean',"; |
| 1429 | 1429 | echo " default: false,"; |
@@ -1431,42 +1431,42 @@ discard block |
||
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | // block wrap element |
| 1434 | - if ( isset( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 1434 | + if (isset($this->options['block-wrap'])) { //@todo we should validate this? |
|
| 1435 | 1435 | echo "block_wrap: {"; |
| 1436 | 1436 | echo " type: 'string',"; |
| 1437 | - echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 1437 | + echo " default: '" . esc_attr($this->options['block-wrap']) . "',"; |
|
| 1438 | 1438 | echo "},"; |
| 1439 | 1439 | } |
| 1440 | 1440 | |
| 1441 | 1441 | |
| 1442 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1442 | + foreach ($this->arguments as $key => $args) { |
|
| 1443 | 1443 | |
| 1444 | 1444 | // set if we should show alignment |
| 1445 | - if ( $key == 'alignment' ) { |
|
| 1445 | + if ($key == 'alignment') { |
|
| 1446 | 1446 | $show_alignment = true; |
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | 1449 | $extra = ''; |
| 1450 | 1450 | |
| 1451 | - if ( $args['type'] == 'checkbox' ) { |
|
| 1451 | + if ($args['type'] == 'checkbox') { |
|
| 1452 | 1452 | $type = 'boolean'; |
| 1453 | - $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 1454 | - } elseif ( $args['type'] == 'number' ) { |
|
| 1453 | + $default = isset($args['default']) && $args['default'] ? 'true' : 'false'; |
|
| 1454 | + } elseif ($args['type'] == 'number') { |
|
| 1455 | 1455 | $type = 'number'; |
| 1456 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1457 | - } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 1456 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 1457 | + } elseif ($args['type'] == 'select' && !empty($args['multiple'])) { |
|
| 1458 | 1458 | $type = 'array'; |
| 1459 | - if ( is_array( $args['default'] ) ) { |
|
| 1460 | - $default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 1459 | + if (is_array($args['default'])) { |
|
| 1460 | + $default = isset($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]"; |
|
| 1461 | 1461 | } else { |
| 1462 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1462 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 1463 | 1463 | } |
| 1464 | - } elseif ( $args['type'] == 'multiselect' ) { |
|
| 1464 | + } elseif ($args['type'] == 'multiselect') { |
|
| 1465 | 1465 | $type = 'array'; |
| 1466 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1466 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 1467 | 1467 | } else { |
| 1468 | 1468 | $type = 'string'; |
| 1469 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1469 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 1470 | 1470 | } |
| 1471 | 1471 | echo $key . " : {"; |
| 1472 | 1472 | echo "type : '$type',"; |
@@ -1496,12 +1496,12 @@ discard block |
||
| 1496 | 1496 | is_fetching = true; |
| 1497 | 1497 | var data = { |
| 1498 | 1498 | 'action': 'super_duper_output_shortcode', |
| 1499 | - 'shortcode': '<?php echo $this->options['base_id'];?>', |
|
| 1499 | + 'shortcode': '<?php echo $this->options['base_id']; ?>', |
|
| 1500 | 1500 | 'attributes': props.attributes, |
| 1501 | - 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
|
| 1501 | + 'post_id': <?php global $post; if (isset($post->ID)) { |
|
| 1502 | 1502 | echo $post->ID; |
| 1503 | 1503 | }?>, |
| 1504 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
|
| 1504 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>' |
|
| 1505 | 1505 | }; |
| 1506 | 1506 | |
| 1507 | 1507 | jQuery.post(ajaxurl, data, function (response) { |
@@ -1510,7 +1510,7 @@ discard block |
||
| 1510 | 1510 | |
| 1511 | 1511 | // if the content is empty then we place some placeholder text |
| 1512 | 1512 | if (env == '') { |
| 1513 | - env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for: ' );?>" + props.name + "</div>"; |
|
| 1513 | + env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for: '); ?>" + props.name + "</div>"; |
|
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | props.setAttributes({content: env}); |
@@ -1529,7 +1529,7 @@ discard block |
||
| 1529 | 1529 | |
| 1530 | 1530 | el(wp.editor.BlockControls, {key: 'controls'}, |
| 1531 | 1531 | |
| 1532 | - <?php if($show_alignment){?> |
|
| 1532 | + <?php if ($show_alignment) {?> |
|
| 1533 | 1533 | el( |
| 1534 | 1534 | wp.editor.AlignmentToolbar, |
| 1535 | 1535 | { |
@@ -1547,9 +1547,9 @@ discard block |
||
| 1547 | 1547 | |
| 1548 | 1548 | <?php |
| 1549 | 1549 | |
| 1550 | - if(! empty( $this->arguments )){ |
|
| 1550 | + if (!empty($this->arguments)) { |
|
| 1551 | 1551 | |
| 1552 | - if ( $show_advanced ) { |
|
| 1552 | + if ($show_advanced) { |
|
| 1553 | 1553 | ?> |
| 1554 | 1554 | el( |
| 1555 | 1555 | wp.components.ToggleControl, |
@@ -1565,76 +1565,76 @@ discard block |
||
| 1565 | 1565 | |
| 1566 | 1566 | } |
| 1567 | 1567 | |
| 1568 | - foreach($this->arguments as $key => $args){ |
|
| 1569 | - $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 1568 | + foreach ($this->arguments as $key => $args) { |
|
| 1569 | + $custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : ''; |
|
| 1570 | 1570 | $options = ''; |
| 1571 | 1571 | $extra = ''; |
| 1572 | 1572 | $require = ''; |
| 1573 | 1573 | $onchange = "props.setAttributes({ $key: $key } )"; |
| 1574 | 1574 | $value = "props.attributes.$key"; |
| 1575 | - $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' ); |
|
| 1576 | - if ( in_array( $args['type'], $text_type ) ) { |
|
| 1575 | + $text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'color'); |
|
| 1576 | + if (in_array($args['type'], $text_type)) { |
|
| 1577 | 1577 | $type = 'TextControl'; |
| 1578 | 1578 | // Save numbers as numbers and not strings |
| 1579 | - if ( $args['type'] == 'number' ) { |
|
| 1579 | + if ($args['type'] == 'number') { |
|
| 1580 | 1580 | $onchange = "props.setAttributes({ $key: Number($key) } )"; |
| 1581 | 1581 | } |
| 1582 | 1582 | } |
| 1583 | 1583 | // elseif ( $args['type'] == 'color' ) { //@todo ColorPicker labels are not shown yet, we may have to add our own https://github.com/WordPress/gutenberg/issues/14378 |
| 1584 | 1584 | // $type = 'ColorPicker'; |
| 1585 | 1585 | // } |
| 1586 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 1586 | + elseif ($args['type'] == 'checkbox') { |
|
| 1587 | 1587 | $type = 'CheckboxControl'; |
| 1588 | 1588 | $extra .= "checked: props.attributes.$key,"; |
| 1589 | 1589 | $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
| 1590 | - } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 1590 | + } elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') { |
|
| 1591 | 1591 | $type = 'SelectControl'; |
| 1592 | - if ( ! empty( $args['options'] ) ) { |
|
| 1592 | + if (!empty($args['options'])) { |
|
| 1593 | 1593 | $options .= "options : ["; |
| 1594 | - foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 1595 | - $options .= "{ value : '" . esc_attr( $option_val ) . "', label : '" . esc_attr( $option_label ) . "' },"; |
|
| 1594 | + foreach ($args['options'] as $option_val => $option_label) { |
|
| 1595 | + $options .= "{ value : '" . esc_attr($option_val) . "', label : '" . esc_attr($option_label) . "' },"; |
|
| 1596 | 1596 | } |
| 1597 | 1597 | $options .= "],"; |
| 1598 | 1598 | } |
| 1599 | - if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 1599 | + if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 1600 | 1600 | $extra .= ' multiple: true, '; |
| 1601 | 1601 | //$onchange = "props.setAttributes({ $key: ['edit'] } )"; |
| 1602 | 1602 | //$value = "['edit', 'delete']"; |
| 1603 | 1603 | } |
| 1604 | - } elseif ( $args['type'] == 'alignment' ) { |
|
| 1604 | + } elseif ($args['type'] == 'alignment') { |
|
| 1605 | 1605 | $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
| 1606 | 1606 | } else { |
| 1607 | - continue;// if we have not implemented the control then don't break the JS. |
|
| 1607 | + continue; // if we have not implemented the control then don't break the JS. |
|
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | 1610 | // add show only if advanced |
| 1611 | - if ( ! empty( $args['advanced'] ) ) { |
|
| 1611 | + if (!empty($args['advanced'])) { |
|
| 1612 | 1612 | echo "props.attributes.show_advanced && "; |
| 1613 | 1613 | } |
| 1614 | 1614 | // add setting require if defined |
| 1615 | - if ( ! empty( $args['element_require'] ) ) { |
|
| 1616 | - echo $this->block_props_replace( $args['element_require'], true ) . " && "; |
|
| 1615 | + if (!empty($args['element_require'])) { |
|
| 1616 | + echo $this->block_props_replace($args['element_require'], true) . " && "; |
|
| 1617 | 1617 | } |
| 1618 | 1618 | ?> |
| 1619 | 1619 | el( |
| 1620 | - wp.components.<?php echo esc_attr( $type );?>, |
|
| 1620 | + wp.components.<?php echo esc_attr($type); ?>, |
|
| 1621 | 1621 | { |
| 1622 | - label: '<?php echo esc_attr( $args['title'] );?>', |
|
| 1623 | - help: '<?php if ( isset( $args['desc'] ) ) { |
|
| 1624 | - echo esc_attr( $args['desc'] ); |
|
| 1622 | + label: '<?php echo esc_attr($args['title']); ?>', |
|
| 1623 | + help: '<?php if (isset($args['desc'])) { |
|
| 1624 | + echo esc_attr($args['desc']); |
|
| 1625 | 1625 | }?>', |
| 1626 | - value: <?php echo $value;?>, |
|
| 1627 | - <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
|
| 1628 | - echo "type: '" . esc_attr( $args['type'] ) . "',"; |
|
| 1626 | + value: <?php echo $value; ?>, |
|
| 1627 | + <?php if ($type == 'TextControl' && $args['type'] != 'text') { |
|
| 1628 | + echo "type: '" . esc_attr($args['type']) . "',"; |
|
| 1629 | 1629 | }?> |
| 1630 | - <?php if ( ! empty( $args['placeholder'] ) ) { |
|
| 1631 | - echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',"; |
|
| 1630 | + <?php if (!empty($args['placeholder'])) { |
|
| 1631 | + echo "placeholder: '" . esc_attr($args['placeholder']) . "',"; |
|
| 1632 | 1632 | }?> |
| 1633 | - <?php echo $options;?> |
|
| 1634 | - <?php echo $extra;?> |
|
| 1635 | - <?php echo $custom_attributes;?> |
|
| 1636 | - onChange: function ( <?php echo $key;?> ) { |
|
| 1637 | - <?php echo $onchange;?> |
|
| 1633 | + <?php echo $options; ?> |
|
| 1634 | + <?php echo $extra; ?> |
|
| 1635 | + <?php echo $custom_attributes; ?> |
|
| 1636 | + onChange: function ( <?php echo $key; ?> ) { |
|
| 1637 | + <?php echo $onchange; ?> |
|
| 1638 | 1638 | } |
| 1639 | 1639 | } |
| 1640 | 1640 | ), |
@@ -1647,9 +1647,9 @@ discard block |
||
| 1647 | 1647 | |
| 1648 | 1648 | <?php |
| 1649 | 1649 | // If the user sets block-output array then build it |
| 1650 | - if ( ! empty( $this->options['block-output'] ) ) { |
|
| 1651 | - $this->block_element( $this->options['block-output'] ); |
|
| 1652 | - }else{ |
|
| 1650 | + if (!empty($this->options['block-output'])) { |
|
| 1651 | + $this->block_element($this->options['block-output']); |
|
| 1652 | + } else { |
|
| 1653 | 1653 | // if no block-output is set then we try and get the shortcode html output via ajax. |
| 1654 | 1654 | ?> |
| 1655 | 1655 | el('div', { |
@@ -1673,14 +1673,14 @@ discard block |
||
| 1673 | 1673 | var align = ''; |
| 1674 | 1674 | |
| 1675 | 1675 | // build the shortcode. |
| 1676 | - var content = "[<?php echo $this->options['base_id'];?>"; |
|
| 1676 | + var content = "[<?php echo $this->options['base_id']; ?>"; |
|
| 1677 | 1677 | <?php |
| 1678 | 1678 | |
| 1679 | - if(! empty( $this->arguments )){ |
|
| 1680 | - foreach($this->arguments as $key => $args){ |
|
| 1679 | + if (!empty($this->arguments)) { |
|
| 1680 | + foreach ($this->arguments as $key => $args) { |
|
| 1681 | 1681 | ?> |
| 1682 | - if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
|
| 1683 | - content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' "; |
|
| 1682 | + if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) { |
|
| 1683 | + content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>+ "' "; |
|
| 1684 | 1684 | } |
| 1685 | 1685 | <?php |
| 1686 | 1686 | } |
@@ -1721,10 +1721,10 @@ discard block |
||
| 1721 | 1721 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1722 | 1722 | */ |
| 1723 | 1723 | |
| 1724 | - return str_replace( array( |
|
| 1724 | + return str_replace(array( |
|
| 1725 | 1725 | '<script>', |
| 1726 | 1726 | '</script>' |
| 1727 | - ), '', $output ); |
|
| 1727 | + ), '', $output); |
|
| 1728 | 1728 | } |
| 1729 | 1729 | |
| 1730 | 1730 | /** |
@@ -1736,16 +1736,16 @@ discard block |
||
| 1736 | 1736 | * |
| 1737 | 1737 | * @return string |
| 1738 | 1738 | */ |
| 1739 | - public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 1739 | + public function array_to_attributes($custom_attributes, $html = false) { |
|
| 1740 | 1740 | $attributes = ''; |
| 1741 | - if ( ! empty( $custom_attributes ) ) { |
|
| 1741 | + if (!empty($custom_attributes)) { |
|
| 1742 | 1742 | |
| 1743 | - if ( $html ) { |
|
| 1744 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 1743 | + if ($html) { |
|
| 1744 | + foreach ($custom_attributes as $key => $val) { |
|
| 1745 | 1745 | $attributes .= " $key='$val' "; |
| 1746 | 1746 | } |
| 1747 | 1747 | } else { |
| 1748 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 1748 | + foreach ($custom_attributes as $key => $val) { |
|
| 1749 | 1749 | $attributes .= "'$key': '$val',"; |
| 1750 | 1750 | } |
| 1751 | 1751 | } |
@@ -1761,86 +1761,86 @@ discard block |
||
| 1761 | 1761 | * |
| 1762 | 1762 | * @param $args |
| 1763 | 1763 | */ |
| 1764 | - public function block_element( $args ) { |
|
| 1764 | + public function block_element($args) { |
|
| 1765 | 1765 | |
| 1766 | 1766 | |
| 1767 | - if ( ! empty( $args ) ) { |
|
| 1768 | - foreach ( $args as $element => $new_args ) { |
|
| 1767 | + if (!empty($args)) { |
|
| 1768 | + foreach ($args as $element => $new_args) { |
|
| 1769 | 1769 | |
| 1770 | - if ( is_array( $new_args ) ) { // its an element |
|
| 1770 | + if (is_array($new_args)) { // its an element |
|
| 1771 | 1771 | |
| 1772 | 1772 | |
| 1773 | - if ( isset( $new_args['element'] ) ) { |
|
| 1773 | + if (isset($new_args['element'])) { |
|
| 1774 | 1774 | |
| 1775 | - if ( isset( $new_args['element_require'] ) ) { |
|
| 1776 | - echo str_replace( array( |
|
| 1775 | + if (isset($new_args['element_require'])) { |
|
| 1776 | + echo str_replace(array( |
|
| 1777 | 1777 | "'+", |
| 1778 | 1778 | "+'" |
| 1779 | - ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 1780 | - unset( $new_args['element_require'] ); |
|
| 1779 | + ), '', $this->block_props_replace($new_args['element_require'])) . " && "; |
|
| 1780 | + unset($new_args['element_require']); |
|
| 1781 | 1781 | } |
| 1782 | 1782 | |
| 1783 | 1783 | echo "\n el( '" . $new_args['element'] . "', {"; |
| 1784 | 1784 | |
| 1785 | 1785 | // get the attributes |
| 1786 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 1786 | + foreach ($new_args as $new_key => $new_value) { |
|
| 1787 | 1787 | |
| 1788 | 1788 | |
| 1789 | - if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 1789 | + if ($new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) { |
|
| 1790 | 1790 | // do nothing |
| 1791 | 1791 | } else { |
| 1792 | - echo $this->block_element( array( $new_key => $new_value ) ); |
|
| 1792 | + echo $this->block_element(array($new_key => $new_value)); |
|
| 1793 | 1793 | } |
| 1794 | 1794 | } |
| 1795 | 1795 | |
| 1796 | - echo "},";// end attributes |
|
| 1796 | + echo "},"; // end attributes |
|
| 1797 | 1797 | |
| 1798 | 1798 | // get the content |
| 1799 | 1799 | $first_item = 0; |
| 1800 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 1801 | - if ( $new_key === 'content' || is_array( $new_value ) ) { |
|
| 1800 | + foreach ($new_args as $new_key => $new_value) { |
|
| 1801 | + if ($new_key === 'content' || is_array($new_value)) { |
|
| 1802 | 1802 | |
| 1803 | - if ( $new_key === 'content' ) { |
|
| 1804 | - echo "'" . $this->block_props_replace( $new_value ) . "'"; |
|
| 1803 | + if ($new_key === 'content') { |
|
| 1804 | + echo "'" . $this->block_props_replace($new_value) . "'"; |
|
| 1805 | 1805 | } |
| 1806 | 1806 | |
| 1807 | - if ( is_array( $new_value ) ) { |
|
| 1807 | + if (is_array($new_value)) { |
|
| 1808 | 1808 | |
| 1809 | - if ( isset( $new_value['element_require'] ) ) { |
|
| 1810 | - echo str_replace( array( |
|
| 1809 | + if (isset($new_value['element_require'])) { |
|
| 1810 | + echo str_replace(array( |
|
| 1811 | 1811 | "'+", |
| 1812 | 1812 | "+'" |
| 1813 | - ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 1814 | - unset( $new_value['element_require'] ); |
|
| 1813 | + ), '', $this->block_props_replace($new_value['element_require'])) . " && "; |
|
| 1814 | + unset($new_value['element_require']); |
|
| 1815 | 1815 | } |
| 1816 | 1816 | |
| 1817 | - if ( isset( $new_value['element_repeat'] ) ) { |
|
| 1817 | + if (isset($new_value['element_repeat'])) { |
|
| 1818 | 1818 | $x = 1; |
| 1819 | - while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 1820 | - $this->block_element( array( '' => $new_value ) ); |
|
| 1821 | - $x ++; |
|
| 1819 | + while ($x <= absint($new_value['element_repeat'])) { |
|
| 1820 | + $this->block_element(array('' => $new_value)); |
|
| 1821 | + $x++; |
|
| 1822 | 1822 | } |
| 1823 | 1823 | } else { |
| 1824 | - $this->block_element( array( '' => $new_value ) ); |
|
| 1824 | + $this->block_element(array('' => $new_value)); |
|
| 1825 | 1825 | } |
| 1826 | 1826 | } |
| 1827 | - $first_item ++; |
|
| 1827 | + $first_item++; |
|
| 1828 | 1828 | } |
| 1829 | 1829 | } |
| 1830 | 1830 | |
| 1831 | - echo ")";// end content |
|
| 1831 | + echo ")"; // end content |
|
| 1832 | 1832 | |
| 1833 | 1833 | echo ", \n"; |
| 1834 | 1834 | |
| 1835 | 1835 | } |
| 1836 | 1836 | } else { |
| 1837 | 1837 | |
| 1838 | - if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 1839 | - echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 1840 | - } elseif ( $element == 'style' ) { |
|
| 1841 | - echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 1838 | + if (substr($element, 0, 3) === "if_") { |
|
| 1839 | + echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ","; |
|
| 1840 | + } elseif ($element == 'style') { |
|
| 1841 | + echo $element . ": " . $this->block_props_replace($new_args) . ","; |
|
| 1842 | 1842 | } else { |
| 1843 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 1843 | + echo $element . ": '" . $this->block_props_replace($new_args) . "',"; |
|
| 1844 | 1844 | } |
| 1845 | 1845 | |
| 1846 | 1846 | } |
@@ -1855,12 +1855,12 @@ discard block |
||
| 1855 | 1855 | * |
| 1856 | 1856 | * @return mixed |
| 1857 | 1857 | */ |
| 1858 | - public function block_props_replace( $string, $no_wrap = false ) { |
|
| 1858 | + public function block_props_replace($string, $no_wrap = false) { |
|
| 1859 | 1859 | |
| 1860 | - if ( $no_wrap ) { |
|
| 1861 | - $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 1860 | + if ($no_wrap) { |
|
| 1861 | + $string = str_replace(array("[%", "%]"), array("props.attributes.", ""), $string); |
|
| 1862 | 1862 | } else { |
| 1863 | - $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 1863 | + $string = str_replace(array("[%", "%]"), array("'+props.attributes.", "+'"), $string); |
|
| 1864 | 1864 | } |
| 1865 | 1865 | |
| 1866 | 1866 | return $string; |
@@ -1872,37 +1872,37 @@ discard block |
||
| 1872 | 1872 | * @param array $args |
| 1873 | 1873 | * @param array $instance |
| 1874 | 1874 | */ |
| 1875 | - public function widget( $args, $instance ) { |
|
| 1875 | + public function widget($args, $instance) { |
|
| 1876 | 1876 | |
| 1877 | 1877 | // get the filtered values |
| 1878 | - $argument_values = $this->argument_values( $instance ); |
|
| 1879 | - $argument_values = $this->string_to_bool( $argument_values ); |
|
| 1880 | - $output = $this->output( $argument_values, $args ); |
|
| 1878 | + $argument_values = $this->argument_values($instance); |
|
| 1879 | + $argument_values = $this->string_to_bool($argument_values); |
|
| 1880 | + $output = $this->output($argument_values, $args); |
|
| 1881 | 1881 | |
| 1882 | - if ( $output ) { |
|
| 1882 | + if ($output) { |
|
| 1883 | 1883 | // Before widget |
| 1884 | 1884 | $before_widget = $args['before_widget']; |
| 1885 | - $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 1886 | - $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 1885 | + $before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this); |
|
| 1886 | + $before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this); |
|
| 1887 | 1887 | |
| 1888 | 1888 | // After widget |
| 1889 | 1889 | $after_widget = $args['after_widget']; |
| 1890 | - $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 1891 | - $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 1890 | + $after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this); |
|
| 1891 | + $after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this); |
|
| 1892 | 1892 | |
| 1893 | 1893 | echo $before_widget; |
| 1894 | 1894 | // elementor strips the widget wrapping div so we check for and add it back if needed |
| 1895 | - if ( $this->is_elementor_widget_output() ) { |
|
| 1896 | - echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $this->options['widget_ops']['classname'] ) . "'>" : ''; |
|
| 1895 | + if ($this->is_elementor_widget_output()) { |
|
| 1896 | + echo !empty($this->options['widget_ops']['classname']) ? "<span class='" . esc_attr($this->options['widget_ops']['classname']) . "'>" : ''; |
|
| 1897 | 1897 | } |
| 1898 | - echo $this->output_title( $args, $instance ); |
|
| 1898 | + echo $this->output_title($args, $instance); |
|
| 1899 | 1899 | echo $output; |
| 1900 | - if ( $this->is_elementor_widget_output() ) { |
|
| 1901 | - echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : ''; |
|
| 1900 | + if ($this->is_elementor_widget_output()) { |
|
| 1901 | + echo !empty($this->options['widget_ops']['classname']) ? "</span>" : ''; |
|
| 1902 | 1902 | } |
| 1903 | 1903 | echo $after_widget; |
| 1904 | - } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 1905 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1904 | + } elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty |
|
| 1905 | + $output = $this->preview_placeholder_text("{{" . $this->base_id . "}}"); |
|
| 1906 | 1906 | echo $output; |
| 1907 | 1907 | } |
| 1908 | 1908 | } |
@@ -1915,7 +1915,7 @@ discard block |
||
| 1915 | 1915 | */ |
| 1916 | 1916 | public function is_elementor_widget_output() { |
| 1917 | 1917 | $result = false; |
| 1918 | - if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 1918 | + if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') { |
|
| 1919 | 1919 | $result = true; |
| 1920 | 1920 | } |
| 1921 | 1921 | |
@@ -1930,7 +1930,7 @@ discard block |
||
| 1930 | 1930 | */ |
| 1931 | 1931 | public function is_elementor_preview() { |
| 1932 | 1932 | $result = false; |
| 1933 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 1933 | + if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) { |
|
| 1934 | 1934 | $result = true; |
| 1935 | 1935 | } |
| 1936 | 1936 | |
@@ -1945,7 +1945,7 @@ discard block |
||
| 1945 | 1945 | */ |
| 1946 | 1946 | public function is_divi_preview() { |
| 1947 | 1947 | $result = false; |
| 1948 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 1948 | + if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) { |
|
| 1949 | 1949 | $result = true; |
| 1950 | 1950 | } |
| 1951 | 1951 | |
@@ -1960,7 +1960,7 @@ discard block |
||
| 1960 | 1960 | */ |
| 1961 | 1961 | public function is_beaver_preview() { |
| 1962 | 1962 | $result = false; |
| 1963 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 1963 | + if (isset($_REQUEST['fl_builder'])) { |
|
| 1964 | 1964 | $result = true; |
| 1965 | 1965 | } |
| 1966 | 1966 | |
@@ -1975,7 +1975,7 @@ discard block |
||
| 1975 | 1975 | */ |
| 1976 | 1976 | public function is_siteorigin_preview() { |
| 1977 | 1977 | $result = false; |
| 1978 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 1978 | + if (!empty($_REQUEST['siteorigin_panels_live_editor'])) { |
|
| 1979 | 1979 | $result = true; |
| 1980 | 1980 | } |
| 1981 | 1981 | |
@@ -1990,7 +1990,7 @@ discard block |
||
| 1990 | 1990 | */ |
| 1991 | 1991 | public function is_cornerstone_preview() { |
| 1992 | 1992 | $result = false; |
| 1993 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 1993 | + if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') { |
|
| 1994 | 1994 | $result = true; |
| 1995 | 1995 | } |
| 1996 | 1996 | |
@@ -2005,15 +2005,15 @@ discard block |
||
| 2005 | 2005 | */ |
| 2006 | 2006 | public function is_preview() { |
| 2007 | 2007 | $preview = false; |
| 2008 | - if ( $this->is_divi_preview() ) { |
|
| 2008 | + if ($this->is_divi_preview()) { |
|
| 2009 | 2009 | $preview = true; |
| 2010 | - } elseif ( $this->is_elementor_preview() ) { |
|
| 2010 | + } elseif ($this->is_elementor_preview()) { |
|
| 2011 | 2011 | $preview = true; |
| 2012 | - } elseif ( $this->is_beaver_preview() ) { |
|
| 2012 | + } elseif ($this->is_beaver_preview()) { |
|
| 2013 | 2013 | $preview = true; |
| 2014 | - } elseif ( $this->is_siteorigin_preview() ) { |
|
| 2014 | + } elseif ($this->is_siteorigin_preview()) { |
|
| 2015 | 2015 | $preview = true; |
| 2016 | - } elseif ( $this->is_cornerstone_preview() ) { |
|
| 2016 | + } elseif ($this->is_cornerstone_preview()) { |
|
| 2017 | 2017 | $preview = true; |
| 2018 | 2018 | } |
| 2019 | 2019 | |
@@ -2028,11 +2028,11 @@ discard block |
||
| 2028 | 2028 | * |
| 2029 | 2029 | * @return string |
| 2030 | 2030 | */ |
| 2031 | - public function output_title( $args, $instance = array() ) { |
|
| 2031 | + public function output_title($args, $instance = array()) { |
|
| 2032 | 2032 | $output = ''; |
| 2033 | - if ( ! empty( $instance['title'] ) ) { |
|
| 2033 | + if (!empty($instance['title'])) { |
|
| 2034 | 2034 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
| 2035 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 2035 | + $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); |
|
| 2036 | 2036 | $output = $args['before_title'] . $title . $args['after_title']; |
| 2037 | 2037 | } |
| 2038 | 2038 | |
@@ -2044,7 +2044,7 @@ discard block |
||
| 2044 | 2044 | * |
| 2045 | 2045 | * @param array $instance The widget options. |
| 2046 | 2046 | */ |
| 2047 | - public function form( $instance ) { |
|
| 2047 | + public function form($instance) { |
|
| 2048 | 2048 | |
| 2049 | 2049 | // set widget instance |
| 2050 | 2050 | $this->instance = $instance; |
@@ -2052,12 +2052,12 @@ discard block |
||
| 2052 | 2052 | // set it as a SD widget |
| 2053 | 2053 | echo $this->widget_advanced_toggle(); |
| 2054 | 2054 | |
| 2055 | - echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 2055 | + echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>"; |
|
| 2056 | 2056 | $arguments = $this->get_arguments(); |
| 2057 | 2057 | |
| 2058 | - if ( is_array( $arguments ) ) { |
|
| 2059 | - foreach ( $arguments as $key => $args ) { |
|
| 2060 | - $this->widget_inputs( $args, $instance ); |
|
| 2058 | + if (is_array($arguments)) { |
|
| 2059 | + foreach ($arguments as $key => $args) { |
|
| 2060 | + $this->widget_inputs($args, $instance); |
|
| 2061 | 2061 | } |
| 2062 | 2062 | } |
| 2063 | 2063 | } |
@@ -2070,7 +2070,7 @@ discard block |
||
| 2070 | 2070 | public function widget_advanced_toggle() { |
| 2071 | 2071 | |
| 2072 | 2072 | $output = ''; |
| 2073 | - if ( $this->block_show_advanced() ) { |
|
| 2073 | + if ($this->block_show_advanced()) { |
|
| 2074 | 2074 | $val = 1; |
| 2075 | 2075 | } else { |
| 2076 | 2076 | $val = 0; |
@@ -2090,14 +2090,14 @@ discard block |
||
| 2090 | 2090 | * |
| 2091 | 2091 | * @return string $output |
| 2092 | 2092 | */ |
| 2093 | - public function convert_element_require( $input ) { |
|
| 2093 | + public function convert_element_require($input) { |
|
| 2094 | 2094 | |
| 2095 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 2095 | + $input = str_replace("'", '"', $input); // we only want double quotes |
|
| 2096 | 2096 | |
| 2097 | - $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 2097 | + $output = esc_attr(str_replace(array("[%", "%]"), array( |
|
| 2098 | 2098 | "jQuery(form).find('[data-argument=\"", |
| 2099 | 2099 | "\"]').find('input,select').val()" |
| 2100 | - ), $input ) ); |
|
| 2100 | + ), $input)); |
|
| 2101 | 2101 | |
| 2102 | 2102 | return $output; |
| 2103 | 2103 | } |
@@ -2108,54 +2108,54 @@ discard block |
||
| 2108 | 2108 | * @param $args |
| 2109 | 2109 | * @param $instance |
| 2110 | 2110 | */ |
| 2111 | - public function widget_inputs( $args, $instance ) { |
|
| 2111 | + public function widget_inputs($args, $instance) { |
|
| 2112 | 2112 | |
| 2113 | 2113 | $class = ""; |
| 2114 | 2114 | $element_require = ""; |
| 2115 | 2115 | $custom_attributes = ""; |
| 2116 | 2116 | |
| 2117 | 2117 | // get value |
| 2118 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 2119 | - $value = $instance[ $args['name'] ]; |
|
| 2120 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 2121 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 2118 | + if (isset($instance[$args['name']])) { |
|
| 2119 | + $value = $instance[$args['name']]; |
|
| 2120 | + } elseif (!isset($instance[$args['name']]) && !empty($args['default'])) { |
|
| 2121 | + $value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']); |
|
| 2122 | 2122 | } else { |
| 2123 | 2123 | $value = ''; |
| 2124 | 2124 | } |
| 2125 | 2125 | |
| 2126 | 2126 | // get placeholder |
| 2127 | - if ( ! empty( $args['placeholder'] ) ) { |
|
| 2128 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 2127 | + if (!empty($args['placeholder'])) { |
|
| 2128 | + $placeholder = "placeholder='" . esc_html($args['placeholder']) . "'"; |
|
| 2129 | 2129 | } else { |
| 2130 | 2130 | $placeholder = ''; |
| 2131 | 2131 | } |
| 2132 | 2132 | |
| 2133 | 2133 | // get if advanced |
| 2134 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 2134 | + if (isset($args['advanced']) && $args['advanced']) { |
|
| 2135 | 2135 | $class .= " sd-advanced-setting "; |
| 2136 | 2136 | } |
| 2137 | 2137 | |
| 2138 | 2138 | // element_require |
| 2139 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 2139 | + if (isset($args['element_require']) && $args['element_require']) { |
|
| 2140 | 2140 | $element_require = $args['element_require']; |
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | 2143 | // custom_attributes |
| 2144 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 2145 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 2144 | + if (isset($args['custom_attributes']) && $args['custom_attributes']) { |
|
| 2145 | + $custom_attributes = $this->array_to_attributes($args['custom_attributes'], true); |
|
| 2146 | 2146 | } |
| 2147 | 2147 | |
| 2148 | 2148 | // before wrapper |
| 2149 | 2149 | ?> |
| 2150 | - <p class="sd-argument <?php echo esc_attr( $class ); ?>" |
|
| 2151 | - data-argument='<?php echo esc_attr( $args['name'] ); ?>' |
|
| 2152 | - data-element_require='<?php if ( $element_require ) { |
|
| 2153 | - echo $this->convert_element_require( $element_require ); |
|
| 2150 | + <p class="sd-argument <?php echo esc_attr($class); ?>" |
|
| 2151 | + data-argument='<?php echo esc_attr($args['name']); ?>' |
|
| 2152 | + data-element_require='<?php if ($element_require) { |
|
| 2153 | + echo $this->convert_element_require($element_require); |
|
| 2154 | 2154 | } ?>' |
| 2155 | 2155 | > |
| 2156 | 2156 | <?php |
| 2157 | 2157 | |
| 2158 | - switch ( $args['type'] ) { |
|
| 2158 | + switch ($args['type']) { |
|
| 2159 | 2159 | //array('text','password','number','email','tel','url','color') |
| 2160 | 2160 | case "text": |
| 2161 | 2161 | case "password": |
@@ -2166,46 +2166,46 @@ discard block |
||
| 2166 | 2166 | case "color": |
| 2167 | 2167 | ?> |
| 2168 | 2168 | <label |
| 2169 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 2169 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 2170 | 2170 | <input <?php echo $placeholder; ?> class="widefat" |
| 2171 | 2171 | <?php echo $custom_attributes; ?> |
| 2172 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2173 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" |
|
| 2174 | - type="<?php echo esc_attr( $args['type'] ); ?>" |
|
| 2175 | - value="<?php echo esc_attr( $value ); ?>"> |
|
| 2172 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2173 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" |
|
| 2174 | + type="<?php echo esc_attr($args['type']); ?>" |
|
| 2175 | + value="<?php echo esc_attr($value); ?>"> |
|
| 2176 | 2176 | <?php |
| 2177 | 2177 | |
| 2178 | 2178 | break; |
| 2179 | 2179 | case "select": |
| 2180 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 2181 | - if ( $multiple ) { |
|
| 2182 | - if ( empty( $value ) ) { |
|
| 2180 | + $multiple = isset($args['multiple']) && $args['multiple'] ? true : false; |
|
| 2181 | + if ($multiple) { |
|
| 2182 | + if (empty($value)) { |
|
| 2183 | 2183 | $value = array(); |
| 2184 | 2184 | } |
| 2185 | 2185 | } |
| 2186 | 2186 | ?> |
| 2187 | 2187 | <label |
| 2188 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 2188 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 2189 | 2189 | <select <?php echo $placeholder; ?> class="widefat" |
| 2190 | 2190 | <?php echo $custom_attributes; ?> |
| 2191 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2192 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); |
|
| 2193 | - if ( $multiple ) { |
|
| 2191 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2192 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); |
|
| 2193 | + if ($multiple) { |
|
| 2194 | 2194 | echo "[]"; |
| 2195 | 2195 | } ?>" |
| 2196 | - <?php if ( $multiple ) { |
|
| 2196 | + <?php if ($multiple) { |
|
| 2197 | 2197 | echo "multiple"; |
| 2198 | 2198 | } //@todo not implemented yet due to gutenberg not supporting it |
| 2199 | 2199 | ?> |
| 2200 | 2200 | > |
| 2201 | 2201 | <?php |
| 2202 | 2202 | |
| 2203 | - if ( ! empty( $args['options'] ) ) { |
|
| 2204 | - foreach ( $args['options'] as $val => $label ) { |
|
| 2205 | - if ( $multiple ) { |
|
| 2206 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 2203 | + if (!empty($args['options'])) { |
|
| 2204 | + foreach ($args['options'] as $val => $label) { |
|
| 2205 | + if ($multiple) { |
|
| 2206 | + $selected = in_array($val, $value) ? 'selected="selected"' : ''; |
|
| 2207 | 2207 | } else { |
| 2208 | - $selected = selected( $value, $val, false ); |
|
| 2208 | + $selected = selected($value, $val, false); |
|
| 2209 | 2209 | } |
| 2210 | 2210 | echo "<option value='$val' " . $selected . ">$label</option>"; |
| 2211 | 2211 | } |
@@ -2217,20 +2217,20 @@ discard block |
||
| 2217 | 2217 | case "checkbox": |
| 2218 | 2218 | ?> |
| 2219 | 2219 | <input <?php echo $placeholder; ?> |
| 2220 | - <?php checked( 1, $value, true ) ?> |
|
| 2220 | + <?php checked(1, $value, true) ?> |
|
| 2221 | 2221 | <?php echo $custom_attributes; ?> |
| 2222 | - class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2223 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox" |
|
| 2222 | + class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2223 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox" |
|
| 2224 | 2224 | value="1"> |
| 2225 | 2225 | <label |
| 2226 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 2226 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 2227 | 2227 | <?php |
| 2228 | 2228 | break; |
| 2229 | 2229 | case "hidden": |
| 2230 | 2230 | ?> |
| 2231 | - <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2232 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" |
|
| 2233 | - value="<?php echo esc_attr( $value ); ?>"> |
|
| 2231 | + <input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2232 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden" |
|
| 2233 | + value="<?php echo esc_attr($value); ?>"> |
|
| 2234 | 2234 | <?php |
| 2235 | 2235 | break; |
| 2236 | 2236 | default: |
@@ -2252,14 +2252,14 @@ discard block |
||
| 2252 | 2252 | * @return string |
| 2253 | 2253 | * @todo, need to make its own tooltip script |
| 2254 | 2254 | */ |
| 2255 | - public function widget_field_desc( $args ) { |
|
| 2255 | + public function widget_field_desc($args) { |
|
| 2256 | 2256 | |
| 2257 | 2257 | $description = ''; |
| 2258 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 2259 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 2260 | - $description = $this->desc_tip( $args['desc'] ); |
|
| 2258 | + if (isset($args['desc']) && $args['desc']) { |
|
| 2259 | + if (isset($args['desc_tip']) && $args['desc_tip']) { |
|
| 2260 | + $description = $this->desc_tip($args['desc']); |
|
| 2261 | 2261 | } else { |
| 2262 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 2262 | + $description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>'; |
|
| 2263 | 2263 | } |
| 2264 | 2264 | } |
| 2265 | 2265 | |
@@ -2274,11 +2274,11 @@ discard block |
||
| 2274 | 2274 | * |
| 2275 | 2275 | * @return string |
| 2276 | 2276 | */ |
| 2277 | - function desc_tip( $tip, $allow_html = false ) { |
|
| 2278 | - if ( $allow_html ) { |
|
| 2279 | - $tip = $this->sanitize_tooltip( $tip ); |
|
| 2277 | + function desc_tip($tip, $allow_html = false) { |
|
| 2278 | + if ($allow_html) { |
|
| 2279 | + $tip = $this->sanitize_tooltip($tip); |
|
| 2280 | 2280 | } else { |
| 2281 | - $tip = esc_attr( $tip ); |
|
| 2281 | + $tip = esc_attr($tip); |
|
| 2282 | 2282 | } |
| 2283 | 2283 | |
| 2284 | 2284 | return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -2291,8 +2291,8 @@ discard block |
||
| 2291 | 2291 | * |
| 2292 | 2292 | * @return string |
| 2293 | 2293 | */ |
| 2294 | - public function sanitize_tooltip( $var ) { |
|
| 2295 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 2294 | + public function sanitize_tooltip($var) { |
|
| 2295 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
| 2296 | 2296 | 'br' => array(), |
| 2297 | 2297 | 'em' => array(), |
| 2298 | 2298 | 'strong' => array(), |
@@ -2302,7 +2302,7 @@ discard block |
||
| 2302 | 2302 | 'li' => array(), |
| 2303 | 2303 | 'ol' => array(), |
| 2304 | 2304 | 'p' => array(), |
| 2305 | - ) ) ); |
|
| 2305 | + ))); |
|
| 2306 | 2306 | } |
| 2307 | 2307 | |
| 2308 | 2308 | /** |
@@ -2314,23 +2314,23 @@ discard block |
||
| 2314 | 2314 | * @return array |
| 2315 | 2315 | * @todo we should add some sanitation here. |
| 2316 | 2316 | */ |
| 2317 | - public function update( $new_instance, $old_instance ) { |
|
| 2317 | + public function update($new_instance, $old_instance) { |
|
| 2318 | 2318 | |
| 2319 | 2319 | //save the widget |
| 2320 | - $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 2320 | + $instance = array_merge((array)$old_instance, (array)$new_instance); |
|
| 2321 | 2321 | |
| 2322 | 2322 | // set widget instance |
| 2323 | 2323 | $this->instance = $instance; |
| 2324 | 2324 | |
| 2325 | - if ( empty( $this->arguments ) ) { |
|
| 2325 | + if (empty($this->arguments)) { |
|
| 2326 | 2326 | $this->get_arguments(); |
| 2327 | 2327 | } |
| 2328 | 2328 | |
| 2329 | 2329 | // check for checkboxes |
| 2330 | - if ( ! empty( $this->arguments ) ) { |
|
| 2331 | - foreach ( $this->arguments as $argument ) { |
|
| 2332 | - if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 2333 | - $instance[ $argument['name'] ] = '0'; |
|
| 2330 | + if (!empty($this->arguments)) { |
|
| 2331 | + foreach ($this->arguments as $argument) { |
|
| 2332 | + if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) { |
|
| 2333 | + $instance[$argument['name']] = '0'; |
|
| 2334 | 2334 | } |
| 2335 | 2335 | } |
| 2336 | 2336 | } |
@@ -2348,7 +2348,7 @@ discard block |
||
| 2348 | 2348 | */ |
| 2349 | 2349 | public function is_block_content_call() { |
| 2350 | 2350 | $result = false; |
| 2351 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 2351 | + if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') { |
|
| 2352 | 2352 | $result = true; |
| 2353 | 2353 | } |
| 2354 | 2354 | |
@@ -7,245 +7,245 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -function wpinv_columns( $columns ) { |
|
| 14 | +function wpinv_columns($columns) { |
|
| 15 | 15 | $columns = array( |
| 16 | 16 | 'cb' => $columns['cb'], |
| 17 | - 'number' => __( 'Number', 'invoicing' ), |
|
| 18 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 19 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 20 | - 'invoice_date' => __( 'Created Date', 'invoicing' ), |
|
| 21 | - 'payment_date' => __( 'Payment Date', 'invoicing' ), |
|
| 22 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 23 | - 'ID' => __( 'ID', 'invoicing' ), |
|
| 24 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
| 17 | + 'number' => __('Number', 'invoicing'), |
|
| 18 | + 'customer' => __('Customer', 'invoicing'), |
|
| 19 | + 'amount' => __('Amount', 'invoicing'), |
|
| 20 | + 'invoice_date' => __('Created Date', 'invoicing'), |
|
| 21 | + 'payment_date' => __('Payment Date', 'invoicing'), |
|
| 22 | + 'status' => __('Status', 'invoicing'), |
|
| 23 | + 'ID' => __('ID', 'invoicing'), |
|
| 24 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
| 25 | 25 | ); |
| 26 | 26 | |
| 27 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 27 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
| 28 | 28 | } |
| 29 | -add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' ); |
|
| 29 | +add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns'); |
|
| 30 | 30 | |
| 31 | -function wpinv_bulk_actions( $actions ) { |
|
| 32 | - if ( isset( $actions['edit'] ) ) { |
|
| 33 | - unset( $actions['edit'] ); |
|
| 31 | +function wpinv_bulk_actions($actions) { |
|
| 32 | + if (isset($actions['edit'])) { |
|
| 33 | + unset($actions['edit']); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | return $actions; |
| 37 | 37 | } |
| 38 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
| 39 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
| 38 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
| 39 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
| 40 | 40 | |
| 41 | -function wpinv_sortable_columns( $columns ) { |
|
| 41 | +function wpinv_sortable_columns($columns) { |
|
| 42 | 42 | $columns = array( |
| 43 | - 'ID' => array( 'ID', true ), |
|
| 44 | - 'number' => array( 'number', false ), |
|
| 45 | - 'amount' => array( 'amount', false ), |
|
| 46 | - 'invoice_date' => array( 'date', false ), |
|
| 47 | - 'payment_date' => array( 'payment_date', true ), |
|
| 48 | - 'customer' => array( 'customer', false ), |
|
| 49 | - 'status' => array( 'status', false ), |
|
| 43 | + 'ID' => array('ID', true), |
|
| 44 | + 'number' => array('number', false), |
|
| 45 | + 'amount' => array('amount', false), |
|
| 46 | + 'invoice_date' => array('date', false), |
|
| 47 | + 'payment_date' => array('payment_date', true), |
|
| 48 | + 'customer' => array('customer', false), |
|
| 49 | + 'status' => array('status', false), |
|
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | - return apply_filters( 'wpi_invoice_table_sortable_columns', $columns ); |
|
| 52 | + return apply_filters('wpi_invoice_table_sortable_columns', $columns); |
|
| 53 | 53 | } |
| 54 | -add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' ); |
|
| 54 | +add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns'); |
|
| 55 | 55 | |
| 56 | -add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
| 57 | -function wpinv_posts_custom_column( $column_name, $post_id = 0 ) { |
|
| 56 | +add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
| 57 | +function wpinv_posts_custom_column($column_name, $post_id = 0) { |
|
| 58 | 58 | global $post, $wpi_invoice; |
| 59 | 59 | |
| 60 | - if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) { |
|
| 61 | - $wpi_invoice = new WPInv_Invoice( $post->ID ); |
|
| 60 | + if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) { |
|
| 61 | + $wpi_invoice = new WPInv_Invoice($post->ID); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $value = NULL; |
| 65 | 65 | |
| 66 | - switch ( $column_name ) { |
|
| 66 | + switch ($column_name) { |
|
| 67 | 67 | case 'email' : |
| 68 | - $value = $wpi_invoice->get_email(); |
|
| 68 | + $value = $wpi_invoice->get_email(); |
|
| 69 | 69 | break; |
| 70 | 70 | case 'customer' : |
| 71 | 71 | $customer_name = $wpi_invoice->get_user_full_name(); |
| 72 | - $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' ); |
|
| 73 | - $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>'; |
|
| 74 | - if ( $email = $wpi_invoice->get_email() ) { |
|
| 72 | + $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing'); |
|
| 73 | + $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>'; |
|
| 74 | + if ($email = $wpi_invoice->get_email()) { |
|
| 75 | 75 | $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>'; |
| 76 | 76 | } |
| 77 | 77 | break; |
| 78 | 78 | case 'amount' : |
| 79 | - echo $wpi_invoice->get_total( true ); |
|
| 79 | + echo $wpi_invoice->get_total(true); |
|
| 80 | 80 | break; |
| 81 | 81 | case 'invoice_date' : |
| 82 | - $date_format = get_option( 'date_format' ); |
|
| 83 | - $time_format = get_option( 'time_format' ); |
|
| 84 | - $date_time_format = $date_format . ' '. $time_format; |
|
| 82 | + $date_format = get_option('date_format'); |
|
| 83 | + $time_format = get_option('time_format'); |
|
| 84 | + $date_time_format = $date_format . ' ' . $time_format; |
|
| 85 | 85 | |
| 86 | 86 | $m_time = $post->post_date; |
| 87 | - $h_time = mysql2date( $date_format, $m_time ); |
|
| 87 | + $h_time = mysql2date($date_format, $m_time); |
|
| 88 | 88 | |
| 89 | - $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
| 89 | + $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
| 90 | 90 | break; |
| 91 | 91 | case 'payment_date' : |
| 92 | - if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) { |
|
| 93 | - $date_format = get_option( 'date_format' ); |
|
| 94 | - $time_format = get_option( 'time_format' ); |
|
| 95 | - $date_time_format = $date_format . ' '. $time_format; |
|
| 92 | + if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) { |
|
| 93 | + $date_format = get_option('date_format'); |
|
| 94 | + $time_format = get_option('time_format'); |
|
| 95 | + $date_time_format = $date_format . ' ' . $time_format; |
|
| 96 | 96 | |
| 97 | 97 | $m_time = $date_completed; |
| 98 | - $h_time = mysql2date( $date_format, $m_time ); |
|
| 98 | + $h_time = mysql2date($date_format, $m_time); |
|
| 99 | 99 | |
| 100 | - $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
| 100 | + $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
| 101 | 101 | } else { |
| 102 | 102 | $value = '-'; |
| 103 | 103 | } |
| 104 | 104 | break; |
| 105 | 105 | case 'status' : |
| 106 | - $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
|
| 107 | - $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID ); |
|
| 108 | - if ( 1 == $is_viewed ) { |
|
| 109 | - $value .= ' <i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 106 | + $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''); |
|
| 107 | + $is_viewed = wpinv_is_invoice_viewed($wpi_invoice->ID); |
|
| 108 | + if (1 == $is_viewed) { |
|
| 109 | + $value .= ' <i class="fa fa-eye" title="' . __('Viewed by Customer', 'invoicing') . '"></i>'; |
|
| 110 | 110 | } |
| 111 | - if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() ) && ( $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ) ) ) { |
|
| 112 | - $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>'; |
|
| 111 | + if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded()) && ($gateway_title = wpinv_get_gateway_admin_label($wpi_invoice->get_gateway()))) { |
|
| 112 | + $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>'; |
|
| 113 | 113 | } |
| 114 | 114 | break; |
| 115 | 115 | case 'number' : |
| 116 | - $edit_link = get_edit_post_link( $post->ID ); |
|
| 117 | - $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
| 116 | + $edit_link = get_edit_post_link($post->ID); |
|
| 117 | + $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
| 118 | 118 | break; |
| 119 | 119 | case 'wpi_actions' : |
| 120 | 120 | $value = ''; |
| 121 | - if ( !empty( $post->post_name ) ) { |
|
| 122 | - $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
| 121 | + if (!empty($post->post_name)) { |
|
| 122 | + $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if ( $email = $wpi_invoice->get_email() ) { |
|
| 126 | - $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
| 125 | + if ($email = $wpi_invoice->get_email()) { |
|
| 126 | + $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | break; |
| 130 | 130 | default: |
| 131 | - $value = isset( $post->$column_name ) ? $post->$column_name : ''; |
|
| 131 | + $value = isset($post->$column_name) ? $post->$column_name : ''; |
|
| 132 | 132 | break; |
| 133 | 133 | |
| 134 | 134 | } |
| 135 | - $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name ); |
|
| 135 | + $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name); |
|
| 136 | 136 | |
| 137 | - if ( $value !== NULL ) { |
|
| 137 | + if ($value !== NULL) { |
|
| 138 | 138 | echo $value; |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | -function wpinv_admin_post_id( $id = 0 ) { |
|
| 142 | +function wpinv_admin_post_id($id = 0) { |
|
| 143 | 143 | global $post; |
| 144 | 144 | |
| 145 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
| 145 | + if (isset($id) && !empty($id)) { |
|
| 146 | 146 | return (int)$id; |
| 147 | - } else if ( get_the_ID() ) { |
|
| 148 | - return (int) get_the_ID(); |
|
| 149 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
| 150 | - return (int) $post->ID; |
|
| 151 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
| 152 | - return (int) $_GET['post']; |
|
| 153 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
| 154 | - return (int) $_GET['id']; |
|
| 155 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
| 156 | - return (int) $_POST['id']; |
|
| 147 | + } else if (get_the_ID()) { |
|
| 148 | + return (int)get_the_ID(); |
|
| 149 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
| 150 | + return (int)$post->ID; |
|
| 151 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
| 152 | + return (int)$_GET['post']; |
|
| 153 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
| 154 | + return (int)$_GET['id']; |
|
| 155 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
| 156 | + return (int)$_POST['id']; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | return null; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | -function wpinv_admin_post_type( $id = 0 ) { |
|
| 163 | - if ( !$id ) { |
|
| 162 | +function wpinv_admin_post_type($id = 0) { |
|
| 163 | + if (!$id) { |
|
| 164 | 164 | $id = wpinv_admin_post_id(); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - $type = get_post_type( $id ); |
|
| 167 | + $type = get_post_type($id); |
|
| 168 | 168 | |
| 169 | - if ( !$type ) { |
|
| 170 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
| 169 | + if (!$type) { |
|
| 170 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
| 173 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | function wpinv_admin_messages() { |
| 177 | 177 | global $wpinv_options, $pagenow, $post; |
| 178 | 178 | |
| 179 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 180 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
| 179 | + if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 180 | + add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated'); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 184 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 183 | + if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 184 | + add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error'); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 188 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
| 187 | + if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 188 | + add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error'); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 192 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
| 191 | + if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 192 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated'); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 196 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 195 | + if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 196 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error'); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 200 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
| 199 | + if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 200 | + add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated'); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 204 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
| 203 | + if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 204 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error'); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 208 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
| 207 | + if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 208 | + add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated'); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 212 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
| 211 | + if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 212 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error'); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 216 | - add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
|
| 215 | + if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 216 | + add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated'); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 220 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
| 219 | + if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 220 | + add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated'); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 224 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
| 223 | + if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 224 | + add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated'); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 228 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
| 227 | + if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 228 | + add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated'); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
| 232 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
| 231 | + if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) { |
|
| 232 | + $message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID); |
|
| 233 | 233 | |
| 234 | - if ( !empty( $message ) ) { |
|
| 235 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
| 234 | + if (!empty($message)) { |
|
| 235 | + add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated'); |
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - settings_errors( 'wpinv-notices' ); |
|
| 239 | + settings_errors('wpinv-notices'); |
|
| 240 | 240 | } |
| 241 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
| 241 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
| 242 | 242 | |
| 243 | -add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' ); |
|
| 244 | -function wpinv_show_test_payment_gateway_notice(){ |
|
| 245 | - add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' ); |
|
| 243 | +add_action('admin_init', 'wpinv_show_test_payment_gateway_notice'); |
|
| 244 | +function wpinv_show_test_payment_gateway_notice() { |
|
| 245 | + add_action('admin_notices', 'wpinv_test_payment_gateway_messages'); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | -function wpinv_test_payment_gateway_messages(){ |
|
| 248 | +function wpinv_test_payment_gateway_messages() { |
|
| 249 | 249 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 250 | 250 | $name = array(); $test_gateways = ''; |
| 251 | 251 | if ($gateways) { |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | $test_gateways = implode(', ', $name); |
| 258 | 258 | } |
| 259 | - if(isset($test_gateways) && !empty($test_gateways)){ |
|
| 259 | + if (isset($test_gateways) && !empty($test_gateways)) { |
|
| 260 | 260 | $link = admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
| 261 | - $notice = wp_sprintf( __('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link ); |
|
| 261 | + $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link); |
|
| 262 | 262 | ?> |
| 263 | 263 | <div class="notice notice-warning is-dismissible"> |
| 264 | 264 | <p><?php echo $notice; ?></p> |
@@ -267,29 +267,29 @@ discard block |
||
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | -function wpinv_items_columns( $existing_columns ) { |
|
| 270 | +function wpinv_items_columns($existing_columns) { |
|
| 271 | 271 | global $wpinv_euvat; |
| 272 | 272 | |
| 273 | 273 | $columns = array(); |
| 274 | 274 | $columns['cb'] = $existing_columns['cb']; |
| 275 | - $columns['title'] = __( 'Title', 'invoicing' ); |
|
| 276 | - $columns['price'] = __( 'Price', 'invoicing' ); |
|
| 277 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 278 | - $columns['vat_rule'] = __( 'VAT rule type', 'invoicing' ); |
|
| 275 | + $columns['title'] = __('Title', 'invoicing'); |
|
| 276 | + $columns['price'] = __('Price', 'invoicing'); |
|
| 277 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 278 | + $columns['vat_rule'] = __('VAT rule type', 'invoicing'); |
|
| 279 | 279 | } |
| 280 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 281 | - $columns['vat_class'] = __( 'VAT class', 'invoicing' ); |
|
| 280 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 281 | + $columns['vat_class'] = __('VAT class', 'invoicing'); |
|
| 282 | 282 | } |
| 283 | - $columns['type'] = __( 'Type', 'invoicing' ); |
|
| 284 | - $columns['recurring'] = __( 'Recurring', 'invoicing' ); |
|
| 285 | - $columns['date'] = __( 'Date', 'invoicing' ); |
|
| 286 | - $columns['id'] = __( 'ID', 'invoicing' ); |
|
| 283 | + $columns['type'] = __('Type', 'invoicing'); |
|
| 284 | + $columns['recurring'] = __('Recurring', 'invoicing'); |
|
| 285 | + $columns['date'] = __('Date', 'invoicing'); |
|
| 286 | + $columns['id'] = __('ID', 'invoicing'); |
|
| 287 | 287 | |
| 288 | - return apply_filters( 'wpinv_items_columns', $columns ); |
|
| 288 | + return apply_filters('wpinv_items_columns', $columns); |
|
| 289 | 289 | } |
| 290 | -add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' ); |
|
| 290 | +add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns'); |
|
| 291 | 291 | |
| 292 | -function wpinv_items_sortable_columns( $columns ) { |
|
| 292 | +function wpinv_items_sortable_columns($columns) { |
|
| 293 | 293 | $columns['price'] = 'price'; |
| 294 | 294 | $columns['vat_rule'] = 'vat_rule'; |
| 295 | 295 | $columns['vat_class'] = 'vat_class'; |
@@ -299,151 +299,151 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | return $columns; |
| 301 | 301 | } |
| 302 | -add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' ); |
|
| 302 | +add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns'); |
|
| 303 | 303 | |
| 304 | -function wpinv_items_table_custom_column( $column ) { |
|
| 304 | +function wpinv_items_table_custom_column($column) { |
|
| 305 | 305 | global $wpinv_euvat, $post, $wpi_item; |
| 306 | 306 | |
| 307 | - if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) { |
|
| 308 | - $wpi_item = new WPInv_Item( $post->ID ); |
|
| 307 | + if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) { |
|
| 308 | + $wpi_item = new WPInv_Item($post->ID); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - switch ( $column ) { |
|
| 311 | + switch ($column) { |
|
| 312 | 312 | case 'price' : |
| 313 | - echo wpinv_item_price( $post->ID ); |
|
| 313 | + echo wpinv_item_price($post->ID); |
|
| 314 | 314 | break; |
| 315 | 315 | case 'vat_rule' : |
| 316 | - echo $wpinv_euvat->item_rule_label( $post->ID ); |
|
| 316 | + echo $wpinv_euvat->item_rule_label($post->ID); |
|
| 317 | 317 | break; |
| 318 | 318 | case 'vat_class' : |
| 319 | - echo $wpinv_euvat->item_class_label( $post->ID ); |
|
| 319 | + echo $wpinv_euvat->item_class_label($post->ID); |
|
| 320 | 320 | break; |
| 321 | 321 | case 'type' : |
| 322 | - echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
| 322 | + echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
| 323 | 323 | break; |
| 324 | 324 | case 'recurring' : |
| 325 | - echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' ); |
|
| 325 | + echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>'); |
|
| 326 | 326 | break; |
| 327 | 327 | case 'id' : |
| 328 | 328 | echo $post->ID; |
| 329 | 329 | echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
| 330 | - <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
|
| 331 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 332 | - echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
|
| 330 | + <div class="price">' . wpinv_get_item_price($post->ID) . '</div>'; |
|
| 331 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 332 | + echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>'; |
|
| 333 | 333 | } |
| 334 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 335 | - echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>'; |
|
| 334 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 335 | + echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>'; |
|
| 336 | 336 | } |
| 337 | - echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div> |
|
| 337 | + echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div> |
|
| 338 | 338 | </div>'; |
| 339 | 339 | break; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post ); |
|
| 342 | + do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post); |
|
| 343 | 343 | } |
| 344 | -add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' ); |
|
| 344 | +add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column'); |
|
| 345 | 345 | |
| 346 | 346 | function wpinv_add_items_filters() { |
| 347 | 347 | global $wpinv_euvat, $typenow; |
| 348 | 348 | |
| 349 | 349 | // Checks if the current post type is 'item' |
| 350 | - if ( $typenow == 'wpi_item') { |
|
| 351 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 352 | - echo wpinv_html_select( array( |
|
| 353 | - 'options' => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ), |
|
| 350 | + if ($typenow == 'wpi_item') { |
|
| 351 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 352 | + echo wpinv_html_select(array( |
|
| 353 | + 'options' => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()), |
|
| 354 | 354 | 'name' => 'vat_rule', |
| 355 | 355 | 'id' => 'vat_rule', |
| 356 | - 'selected' => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ), |
|
| 356 | + 'selected' => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''), |
|
| 357 | 357 | 'show_option_all' => false, |
| 358 | 358 | 'show_option_none' => false, |
| 359 | 359 | 'class' => 'gdmbx2-text-medium wpi_select2', |
| 360 | - ) ); |
|
| 360 | + )); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 364 | - echo wpinv_html_select( array( |
|
| 365 | - 'options' => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ), |
|
| 363 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 364 | + echo wpinv_html_select(array( |
|
| 365 | + 'options' => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()), |
|
| 366 | 366 | 'name' => 'vat_class', |
| 367 | 367 | 'id' => 'vat_class', |
| 368 | - 'selected' => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ), |
|
| 368 | + 'selected' => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''), |
|
| 369 | 369 | 'show_option_all' => false, |
| 370 | 370 | 'show_option_none' => false, |
| 371 | 371 | 'class' => 'gdmbx2-text-medium wpi_select2', |
| 372 | - ) ); |
|
| 372 | + )); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - echo wpinv_html_select( array( |
|
| 376 | - 'options' => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ), |
|
| 375 | + echo wpinv_html_select(array( |
|
| 376 | + 'options' => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()), |
|
| 377 | 377 | 'name' => 'type', |
| 378 | 378 | 'id' => 'type', |
| 379 | - 'selected' => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ), |
|
| 379 | + 'selected' => (isset($_GET['type']) ? $_GET['type'] : ''), |
|
| 380 | 380 | 'show_option_all' => false, |
| 381 | 381 | 'show_option_none' => false, |
| 382 | 382 | 'class' => 'gdmbx2-text-medium', |
| 383 | - ) ); |
|
| 383 | + )); |
|
| 384 | 384 | |
| 385 | - if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) { |
|
| 385 | + if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) { |
|
| 386 | 386 | echo '<input type="hidden" name="all_posts" value="1" />'; |
| 387 | 387 | } |
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | -add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 ); |
|
| 390 | +add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100); |
|
| 391 | 391 | |
| 392 | -function wpinv_send_invoice_after_save( $invoice ) { |
|
| 393 | - if ( empty( $_POST['wpi_save_send'] ) ) { |
|
| 392 | +function wpinv_send_invoice_after_save($invoice) { |
|
| 393 | + if (empty($_POST['wpi_save_send'])) { |
|
| 394 | 394 | return; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) { |
|
| 398 | - wpinv_user_invoice_notification( $invoice->ID ); |
|
| 397 | + if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) { |
|
| 398 | + wpinv_user_invoice_notification($invoice->ID); |
|
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | -add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
| 401 | +add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1); |
|
| 402 | 402 | |
| 403 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
| 404 | - if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) { |
|
| 405 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
| 406 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
| 403 | +function wpinv_send_register_new_user($data, $postarr) { |
|
| 404 | + if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) { |
|
| 405 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
| 406 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
| 407 | 407 | |
| 408 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
| 409 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
| 410 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
| 411 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
| 412 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
| 413 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
| 408 | + if ($is_new_user && $email && !email_exists($email)) { |
|
| 409 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
| 410 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
| 411 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
| 412 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
| 413 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
| 414 | 414 | |
| 415 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
| 416 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
| 415 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
| 416 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
| 417 | 417 | $new_user_login = strstr($email, '@', true); |
| 418 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
| 419 | - $user_login = sanitize_user($new_user_login, true ); |
|
| 418 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
| 419 | + $user_login = sanitize_user($new_user_login, true); |
|
| 420 | 420 | } |
| 421 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
| 422 | - $user_append_text = rand(10,1000); |
|
| 423 | - $user_login = sanitize_user($new_user_login.$user_append_text, true ); |
|
| 421 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
| 422 | + $user_append_text = rand(10, 1000); |
|
| 423 | + $user_login = sanitize_user($new_user_login . $user_append_text, true); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
| 426 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
| 427 | 427 | $user_login = $email; |
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | $userdata = array( |
| 432 | 432 | 'user_login' => $user_login, |
| 433 | - 'user_pass' => wp_generate_password( 12, false ), |
|
| 434 | - 'user_email' => sanitize_text_field( $email ), |
|
| 433 | + 'user_pass' => wp_generate_password(12, false), |
|
| 434 | + 'user_email' => sanitize_text_field($email), |
|
| 435 | 435 | 'first_name' => $first_name, |
| 436 | 436 | 'last_name' => $last_name, |
| 437 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
| 437 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
| 438 | 438 | 'nickname' => $display_name, |
| 439 | 439 | 'display_name' => $display_name, |
| 440 | 440 | ); |
| 441 | 441 | |
| 442 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
| 442 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
| 443 | 443 | |
| 444 | - $new_user_id = wp_insert_user( $userdata ); |
|
| 444 | + $new_user_id = wp_insert_user($userdata); |
|
| 445 | 445 | |
| 446 | - if ( !is_wp_error( $new_user_id ) ) { |
|
| 446 | + if (!is_wp_error($new_user_id)) { |
|
| 447 | 447 | $data['post_author'] = $new_user_id; |
| 448 | 448 | $_POST['post_author'] = $new_user_id; |
| 449 | 449 | $_POST['post_author_override'] = $new_user_id; |
@@ -464,72 +464,72 @@ discard block |
||
| 464 | 464 | |
| 465 | 465 | $meta = array(); |
| 466 | 466 | ///$meta['_wpinv_user_id'] = $new_user_id; |
| 467 | - foreach ( $meta_fields as $field ) { |
|
| 468 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
| 467 | + foreach ($meta_fields as $field) { |
|
| 468 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
| 471 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
| 472 | 472 | |
| 473 | 473 | // Update user meta. |
| 474 | - foreach ( $meta as $key => $value ) { |
|
| 475 | - update_user_meta( $new_user_id, $key, $value ); |
|
| 474 | + foreach ($meta as $key => $value) { |
|
| 475 | + update_user_meta($new_user_id, $key, $value); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
| 478 | + if (function_exists('wp_send_new_user_notifications')) { |
|
| 479 | 479 | // Send email notifications related to the creation of new user. |
| 480 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
| 480 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
| 481 | 481 | } |
| 482 | 482 | } else { |
| 483 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
| 483 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | return $data; |
| 489 | 489 | } |
| 490 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
| 490 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
| 491 | 491 | |
| 492 | -function wpinv_show_recurring_supported_gateways( $item_ID ) { |
|
| 492 | +function wpinv_show_recurring_supported_gateways($item_ID) { |
|
| 493 | 493 | $all_gateways = wpinv_get_payment_gateways(); |
| 494 | 494 | |
| 495 | - if ( !empty( $all_gateways ) ) { |
|
| 495 | + if (!empty($all_gateways)) { |
|
| 496 | 496 | $gateways = array(); |
| 497 | 497 | |
| 498 | - foreach ( $all_gateways as $key => $gateway ) { |
|
| 499 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
| 498 | + foreach ($all_gateways as $key => $gateway) { |
|
| 499 | + if (wpinv_gateway_support_subscription($key)) { |
|
| 500 | 500 | $gateways[] = $gateway['admin_label']; |
| 501 | 501 | } |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - if ( !empty( $gateways ) ) { |
|
| 504 | + if (!empty($gateways)) { |
|
| 505 | 505 | ?> |
| 506 | - <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span> |
|
| 506 | + <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span> |
|
| 507 | 507 | <?php |
| 508 | 508 | } |
| 509 | 509 | } |
| 510 | 510 | } |
| 511 | -add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 ); |
|
| 511 | +add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1); |
|
| 512 | 512 | |
| 513 | -function wpinv_post_updated_messages( $messages ) { |
|
| 513 | +function wpinv_post_updated_messages($messages) { |
|
| 514 | 514 | global $post, $post_ID; |
| 515 | 515 | |
| 516 | 516 | $messages['wpi_discount'] = array( |
| 517 | 517 | 0 => '', |
| 518 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
| 519 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 520 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 521 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
| 522 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 523 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
| 524 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
| 525 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
| 526 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 527 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
| 518 | + 1 => __('Discount updated.', 'invoicing'), |
|
| 519 | + 2 => __('Custom field updated.', 'invoicing'), |
|
| 520 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
| 521 | + 4 => __('Discount updated.', 'invoicing'), |
|
| 522 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
| 523 | + 6 => __('Discount updated.', 'invoicing'), |
|
| 524 | + 7 => __('Discount saved.', 'invoicing'), |
|
| 525 | + 8 => __('Discount submitted.', 'invoicing'), |
|
| 526 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
| 527 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
| 528 | 528 | ); |
| 529 | 529 | |
| 530 | 530 | return $messages; |
| 531 | 531 | } |
| 532 | -add_filter( 'post_updated_messages', 'wpinv_post_updated_messages', 10, 1 ); |
|
| 532 | +add_filter('post_updated_messages', 'wpinv_post_updated_messages', 10, 1); |
|
| 533 | 533 | |
| 534 | 534 | add_action('admin_init', 'admin_init_example_type'); |
| 535 | 535 | |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | function admin_init_example_type() { |
| 540 | 540 | global $typenow; |
| 541 | 541 | |
| 542 | - if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) { |
|
| 542 | + if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') { |
|
| 543 | 543 | add_filter('posts_search', 'posts_search_example_type', 10, 2); |
| 544 | 544 | } |
| 545 | 545 | } |
@@ -554,9 +554,9 @@ discard block |
||
| 554 | 554 | global $wpdb; |
| 555 | 555 | |
| 556 | 556 | if ($query->is_main_query() && !empty($query->query['s'])) { |
| 557 | - $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )"; |
|
| 558 | - if ( ! empty( $search ) ) { |
|
| 559 | - $search = preg_replace( '/^ AND /', '', $search ); |
|
| 557 | + $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )"; |
|
| 558 | + if (!empty($search)) { |
|
| 559 | + $search = preg_replace('/^ AND /', '', $search); |
|
| 560 | 560 | $search = " AND ( {$search} OR ( {$conditions_str} ) )"; |
| 561 | 561 | } else { |
| 562 | 562 | $search = " AND ( {$conditions_str} )"; |
@@ -566,9 +566,9 @@ discard block |
||
| 566 | 566 | return $search; |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | -add_action( 'admin_init', 'wpinv_reset_invoice_count' ); |
|
| 570 | -function wpinv_reset_invoice_count(){ |
|
| 571 | - if(isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) { |
|
| 569 | +add_action('admin_init', 'wpinv_reset_invoice_count'); |
|
| 570 | +function wpinv_reset_invoice_count() { |
|
| 571 | + if (isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) { |
|
| 572 | 572 | wpinv_update_option('invoice_sequence_start', 1); |
| 573 | 573 | delete_option('wpinv_last_invoice_number'); |
| 574 | 574 | $url = add_query_arg(array('reset_invoice_done' => 1)); |
@@ -579,8 +579,8 @@ discard block |
||
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | add_action('admin_notices', 'wpinv_invoice_count_reset_message'); |
| 582 | -function wpinv_invoice_count_reset_message(){ |
|
| 583 | - if(isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) { |
|
| 582 | +function wpinv_invoice_count_reset_message() { |
|
| 583 | + if (isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) { |
|
| 584 | 584 | $notice = __('Invoice number sequence reset successfully.', 'invoicing'); |
| 585 | 585 | ?> |
| 586 | 586 | <div class="notice notice-success is-dismissible"> |