@@ -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,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,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> |
@@ -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 | |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * Setup menus in WP admin. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -defined( 'ABSPATH' ) || exit; |
|
| 6 | +defined('ABSPATH') || exit; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * WC_Admin_Menus Class. |
@@ -13,34 +13,34 @@ discard block |
||
| 13 | 13 | * Hook in tabs. |
| 14 | 14 | */ |
| 15 | 15 | public function __construct() { |
| 16 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
|
| 17 | - add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 99 ); |
|
| 18 | - add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 ); |
|
| 19 | - add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); |
|
| 16 | + add_action('admin_menu', array($this, 'admin_menu'), 10); |
|
| 17 | + add_action('admin_menu', array($this, 'add_addons_menu'), 99); |
|
| 18 | + add_action('admin_menu', array($this, 'remove_admin_submenus'), 10); |
|
| 19 | + add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes')); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function admin_menu() { |
| 23 | 23 | global $menu; |
| 24 | 24 | |
| 25 | - if ( !(current_user_can( 'manage_invoicing' ) || current_user_can( 'manage_options' )) ) { |
|
| 25 | + if (!(current_user_can('manage_invoicing') || current_user_can('manage_options'))) { |
|
| 26 | 26 | return; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - $capability = apply_filters( 'invoicing_capability', 'manage_invoicing' ); |
|
| 29 | + $capability = apply_filters('invoicing_capability', 'manage_invoicing'); |
|
| 30 | 30 | |
| 31 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 32 | - $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' ); |
|
| 31 | + if (current_user_can('manage_options')) { |
|
| 32 | + $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - $wpi_invoice = get_post_type_object( 'wpi_invoice' ); |
|
| 35 | + $wpi_invoice = get_post_type_object('wpi_invoice'); |
|
| 36 | 36 | |
| 37 | - add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' ); |
|
| 37 | + add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460'); |
|
| 38 | 38 | |
| 39 | - add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), $capability, 'wpinv-settings', array( $this, 'options_page' )); |
|
| 39 | + add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), $capability, 'wpinv-settings', array($this, 'options_page')); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function add_addons_menu(){ |
|
| 43 | - if ( !apply_filters( 'wpi_show_addons_page', true ) ) { |
|
| 42 | + public function add_addons_menu() { |
|
| 43 | + if (!apply_filters('wpi_show_addons_page', true)) { |
|
| 44 | 44 | return; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -50,78 +50,78 @@ discard block |
||
| 50 | 50 | __('Extensions', 'userswp'), |
| 51 | 51 | 'manage_options', |
| 52 | 52 | 'wpi-addons', |
| 53 | - array( $this, 'addons_page' ) |
|
| 53 | + array($this, 'addons_page') |
|
| 54 | 54 | ); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function addons_page(){ |
|
| 57 | + public function addons_page() { |
|
| 58 | 58 | $addon_obj = new WPInv_Admin_Addons(); |
| 59 | 59 | $addon_obj->output(); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | function options_page() { |
| 63 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
| 63 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
| 64 | 64 | |
| 65 | - if ( $page !== 'wpinv-settings' ) { |
|
| 65 | + if ($page !== 'wpinv-settings') { |
|
| 66 | 66 | return; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $settings_tabs = wpinv_get_settings_tabs(); |
| 70 | 70 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
| 71 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
| 72 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
| 71 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
| 72 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
| 73 | 73 | $key = 'main'; |
| 74 | 74 | |
| 75 | - if ( is_array( $sections ) ) { |
|
| 76 | - $key = key( $sections ); |
|
| 75 | + if (is_array($sections)) { |
|
| 76 | + $key = key($sections); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
| 80 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
| 79 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
| 80 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
| 81 | 81 | ob_start(); |
| 82 | 82 | ?> |
| 83 | 83 | <div class="wrap"> |
| 84 | 84 | <h1 class="nav-tab-wrapper"> |
| 85 | 85 | <?php |
| 86 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
| 87 | - $tab_url = add_query_arg( array( |
|
| 86 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
| 87 | + $tab_url = add_query_arg(array( |
|
| 88 | 88 | 'settings-updated' => false, |
| 89 | 89 | 'tab' => $tab_id, |
| 90 | - ) ); |
|
| 90 | + )); |
|
| 91 | 91 | |
| 92 | 92 | // Remove the section from the tabs so we always end up at the main section |
| 93 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
| 94 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
| 93 | + $tab_url = remove_query_arg('section', $tab_url); |
|
| 94 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
| 95 | 95 | |
| 96 | 96 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
| 97 | 97 | |
| 98 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
| 99 | - echo esc_html( $tab_name ); |
|
| 98 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
| 99 | + echo esc_html($tab_name); |
|
| 100 | 100 | echo '</a>'; |
| 101 | 101 | } |
| 102 | 102 | ?> |
| 103 | 103 | </h1> |
| 104 | 104 | <?php |
| 105 | - $number_of_sections = count( $sections ); |
|
| 105 | + $number_of_sections = count($sections); |
|
| 106 | 106 | $number = 0; |
| 107 | - if ( $number_of_sections > 1 ) { |
|
| 107 | + if ($number_of_sections > 1) { |
|
| 108 | 108 | echo '<div><ul class="subsubsub">'; |
| 109 | - foreach( $sections as $section_id => $section_name ) { |
|
| 109 | + foreach ($sections as $section_id => $section_name) { |
|
| 110 | 110 | echo '<li>'; |
| 111 | 111 | $number++; |
| 112 | - $tab_url = add_query_arg( array( |
|
| 112 | + $tab_url = add_query_arg(array( |
|
| 113 | 113 | 'settings-updated' => false, |
| 114 | 114 | 'tab' => $active_tab, |
| 115 | 115 | 'section' => $section_id |
| 116 | - ) ); |
|
| 117 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
| 116 | + )); |
|
| 117 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
| 118 | 118 | $class = ''; |
| 119 | - if ( $section == $section_id ) { |
|
| 119 | + if ($section == $section_id) { |
|
| 120 | 120 | $class = 'current'; |
| 121 | 121 | } |
| 122 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
| 122 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
| 123 | 123 | |
| 124 | - if ( $number != $number_of_sections ) { |
|
| 124 | + if ($number != $number_of_sections) { |
|
| 125 | 125 | echo ' | '; |
| 126 | 126 | } |
| 127 | 127 | echo '</li>'; |
@@ -133,19 +133,19 @@ discard block |
||
| 133 | 133 | <form method="post" action="options.php"> |
| 134 | 134 | <table class="form-table"> |
| 135 | 135 | <?php |
| 136 | - settings_fields( 'wpinv_settings' ); |
|
| 136 | + settings_fields('wpinv_settings'); |
|
| 137 | 137 | |
| 138 | - if ( 'main' === $section ) { |
|
| 139 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
| 138 | + if ('main' === $section) { |
|
| 139 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
| 143 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
| 144 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
| 142 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section); |
|
| 143 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section); |
|
| 144 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section); |
|
| 145 | 145 | |
| 146 | 146 | // For backwards compatibility |
| 147 | - if ( 'main' === $section ) { |
|
| 148 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
| 147 | + if ('main' === $section) { |
|
| 148 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
| 149 | 149 | } |
| 150 | 150 | ?> |
| 151 | 151 | </table> |
@@ -159,52 +159,52 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | public function remove_admin_submenus() { |
| 162 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
| 162 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - public function add_nav_menu_meta_boxes(){ |
|
| 166 | - add_meta_box( 'wpinv_endpoints_nav_link', __( 'Invoicing Pages', 'invoicing' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' ); |
|
| 165 | + public function add_nav_menu_meta_boxes() { |
|
| 166 | + add_meta_box('wpinv_endpoints_nav_link', __('Invoicing Pages', 'invoicing'), array($this, 'nav_menu_links'), 'nav-menus', 'side', 'low'); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - public function nav_menu_links(){ |
|
| 169 | + public function nav_menu_links() { |
|
| 170 | 170 | $endpoints = $this->get_menu_items(); |
| 171 | 171 | ?> |
| 172 | 172 | <div id="invoicing-endpoints" class="posttypediv"> |
| 173 | - <?php if(!empty($endpoints['pages'])){ ?> |
|
| 173 | + <?php if (!empty($endpoints['pages'])) { ?> |
|
| 174 | 174 | <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active"> |
| 175 | 175 | <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear"> |
| 176 | 176 | <?php |
| 177 | 177 | $walker = new Walker_Nav_Menu_Checklist(array()); |
| 178 | - echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker)); |
|
| 178 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object)array('walker' => $walker)); |
|
| 179 | 179 | ?> |
| 180 | 180 | </ul> |
| 181 | 181 | </div> |
| 182 | 182 | <?php } ?> |
| 183 | 183 | <p class="button-controls"> |
| 184 | 184 | <span class="list-controls"> |
| 185 | - <a href="<?php echo admin_url( 'nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints' ); ?>" class="select-all"><?php _e( 'Select all', 'invoicing' ); ?></a> |
|
| 185 | + <a href="<?php echo admin_url('nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints'); ?>" class="select-all"><?php _e('Select all', 'invoicing'); ?></a> |
|
| 186 | 186 | </span> |
| 187 | 187 | <span class="add-to-menu"> |
| 188 | - <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints"> |
|
| 188 | + <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints"> |
|
| 189 | 189 | <span class="spinner"></span> |
| 190 | 190 | </span> |
| 191 | 191 | </p> |
| 192 | 192 | <?php |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - public function get_menu_items(){ |
|
| 195 | + public function get_menu_items() { |
|
| 196 | 196 | $items = array(); |
| 197 | 197 | |
| 198 | - $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' ); |
|
| 199 | - if($wpinv_history_page_id > 0){ |
|
| 198 | + $wpinv_history_page_id = (int)wpinv_get_option('invoice_history_page'); |
|
| 199 | + if ($wpinv_history_page_id > 0) { |
|
| 200 | 200 | $item = new stdClass(); |
| 201 | 201 | $item->object_id = $wpinv_history_page_id; |
| 202 | 202 | $item->db_id = 0; |
| 203 | - $item->object = 'page'; |
|
| 203 | + $item->object = 'page'; |
|
| 204 | 204 | $item->menu_item_parent = 0; |
| 205 | 205 | $item->type = 'post_type'; |
| 206 | - $item->title = __('Invoice History Page','invoicing'); |
|
| 207 | - $item->url = get_permalink( $wpinv_history_page_id ); |
|
| 206 | + $item->title = __('Invoice History Page', 'invoicing'); |
|
| 207 | + $item->url = get_permalink($wpinv_history_page_id); |
|
| 208 | 208 | $item->target = ''; |
| 209 | 209 | $item->attr_title = ''; |
| 210 | 210 | $item->classes = array('wpinv-menu-item'); |
@@ -213,16 +213,16 @@ discard block |
||
| 213 | 213 | $items['pages'][] = $item; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' ); |
|
| 217 | - if($wpinv_sub_history_page_id > 0){ |
|
| 216 | + $wpinv_sub_history_page_id = (int)wpinv_get_option('invoice_subscription_page'); |
|
| 217 | + if ($wpinv_sub_history_page_id > 0) { |
|
| 218 | 218 | $item = new stdClass(); |
| 219 | 219 | $item->object_id = $wpinv_sub_history_page_id; |
| 220 | 220 | $item->db_id = 0; |
| 221 | - $item->object = 'page'; |
|
| 221 | + $item->object = 'page'; |
|
| 222 | 222 | $item->menu_item_parent = 0; |
| 223 | 223 | $item->type = 'post_type'; |
| 224 | - $item->title = __('Invoice Subscriptions Page','invoicing'); |
|
| 225 | - $item->url = get_permalink( $wpinv_sub_history_page_id ); |
|
| 224 | + $item->title = __('Invoice Subscriptions Page', 'invoicing'); |
|
| 225 | + $item->url = get_permalink($wpinv_sub_history_page_id); |
|
| 226 | 226 | $item->target = ''; |
| 227 | 227 | $item->attr_title = ''; |
| 228 | 228 | $item->classes = array('wpinv-menu-item'); |
@@ -231,16 +231,16 @@ discard block |
||
| 231 | 231 | $items['pages'][] = $item; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' ); |
|
| 235 | - if($wpinv_checkout_page_id > 0){ |
|
| 234 | + $wpinv_checkout_page_id = (int)wpinv_get_option('checkout_page'); |
|
| 235 | + if ($wpinv_checkout_page_id > 0) { |
|
| 236 | 236 | $item = new stdClass(); |
| 237 | 237 | $item->object_id = $wpinv_checkout_page_id; |
| 238 | 238 | $item->db_id = 0; |
| 239 | - $item->object = 'page'; |
|
| 239 | + $item->object = 'page'; |
|
| 240 | 240 | $item->menu_item_parent = 0; |
| 241 | 241 | $item->type = 'post_type'; |
| 242 | - $item->title = __('Checkout Page','invoicing'); |
|
| 243 | - $item->url = get_permalink( $wpinv_checkout_page_id ); |
|
| 242 | + $item->title = __('Checkout Page', 'invoicing'); |
|
| 243 | + $item->url = get_permalink($wpinv_checkout_page_id); |
|
| 244 | 244 | $item->target = ''; |
| 245 | 245 | $item->attr_title = ''; |
| 246 | 246 | $item->classes = array('wpinv-menu-item'); |
@@ -249,16 +249,16 @@ discard block |
||
| 249 | 249 | $items['pages'][] = $item; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - $wpinv_tandc_page_id = (int)wpinv_get_option( 'tandc_page' ); |
|
| 253 | - if($wpinv_tandc_page_id > 0){ |
|
| 252 | + $wpinv_tandc_page_id = (int)wpinv_get_option('tandc_page'); |
|
| 253 | + if ($wpinv_tandc_page_id > 0) { |
|
| 254 | 254 | $item = new stdClass(); |
| 255 | 255 | $item->object_id = $wpinv_tandc_page_id; |
| 256 | 256 | $item->db_id = 0; |
| 257 | - $item->object = 'page'; |
|
| 257 | + $item->object = 'page'; |
|
| 258 | 258 | $item->menu_item_parent = 0; |
| 259 | 259 | $item->type = 'post_type'; |
| 260 | - $item->title = __('Terms & Conditions','invoicing'); |
|
| 261 | - $item->url = get_permalink( $wpinv_tandc_page_id ); |
|
| 260 | + $item->title = __('Terms & Conditions', 'invoicing'); |
|
| 261 | + $item->url = get_permalink($wpinv_tandc_page_id); |
|
| 262 | 262 | $item->target = ''; |
| 263 | 263 | $item->attr_title = ''; |
| 264 | 264 | $item->classes = array('wpinv-menu-item'); |
@@ -267,16 +267,16 @@ discard block |
||
| 267 | 267 | $items['pages'][] = $item; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' ); |
|
| 271 | - if($wpinv_success_page_id > 0){ |
|
| 270 | + $wpinv_success_page_id = (int)wpinv_get_option('success_page'); |
|
| 271 | + if ($wpinv_success_page_id > 0) { |
|
| 272 | 272 | $item = new stdClass(); |
| 273 | 273 | $item->object_id = $wpinv_success_page_id; |
| 274 | 274 | $item->db_id = 0; |
| 275 | - $item->object = 'page'; |
|
| 275 | + $item->object = 'page'; |
|
| 276 | 276 | $item->menu_item_parent = 0; |
| 277 | 277 | $item->type = 'post_type'; |
| 278 | - $item->title = __('Success Page','invoicing'); |
|
| 279 | - $item->url = get_permalink( $wpinv_success_page_id ); |
|
| 278 | + $item->title = __('Success Page', 'invoicing'); |
|
| 279 | + $item->url = get_permalink($wpinv_success_page_id); |
|
| 280 | 280 | $item->target = ''; |
| 281 | 281 | $item->attr_title = ''; |
| 282 | 282 | $item->classes = array('wpinv-menu-item'); |
@@ -285,16 +285,16 @@ discard block |
||
| 285 | 285 | $items['pages'][] = $item; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' ); |
|
| 289 | - if($wpinv_failure_page_id > 0){ |
|
| 288 | + $wpinv_failure_page_id = (int)wpinv_get_option('failure_page'); |
|
| 289 | + if ($wpinv_failure_page_id > 0) { |
|
| 290 | 290 | $item = new stdClass(); |
| 291 | 291 | $item->object_id = $wpinv_failure_page_id; |
| 292 | 292 | $item->db_id = 0; |
| 293 | - $item->object = 'page'; |
|
| 293 | + $item->object = 'page'; |
|
| 294 | 294 | $item->menu_item_parent = 0; |
| 295 | 295 | $item->type = 'post_type'; |
| 296 | - $item->title = __('Failed Transaction Page','invoicing'); |
|
| 297 | - $item->url = get_permalink( $wpinv_failure_page_id ); |
|
| 296 | + $item->title = __('Failed Transaction Page', 'invoicing'); |
|
| 297 | + $item->url = get_permalink($wpinv_failure_page_id); |
|
| 298 | 298 | $item->target = ''; |
| 299 | 299 | $item->attr_title = ''; |
| 300 | 300 | $item->classes = array('wpinv-menu-item'); |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | $items['pages'][] = $item; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - return apply_filters( 'wpinv_menu_items', $items ); |
|
| 306 | + return apply_filters('wpinv_menu_items', $items); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | } |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 4 | -if(!class_exists('Ayecode_Addons')) { |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | +if (!class_exists('Ayecode_Addons')) { |
|
| 5 | 5 | |
| 6 | 6 | abstract class Ayecode_Addons |
| 7 | 7 | { |
@@ -12,14 +12,14 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * Bail if we are not in WP. |
| 14 | 14 | */ |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if (!defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Only add if the class does not already exist. |
| 21 | 21 | */ |
| 22 | -if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) { |
|
| 22 | +if (!class_exists('WP_Font_Awesome_Settings')) { |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -87,17 +87,17 @@ discard block |
||
| 87 | 87 | * @return WP_Font_Awesome_Settings - Main instance. |
| 88 | 88 | */ |
| 89 | 89 | public static function instance() { |
| 90 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) { |
|
| 90 | + if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) { |
|
| 91 | 91 | self::$instance = new WP_Font_Awesome_Settings; |
| 92 | 92 | |
| 93 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 93 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
| 94 | 94 | |
| 95 | - if ( is_admin() ) { |
|
| 96 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 97 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 95 | + if (is_admin()) { |
|
| 96 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
| 97 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - do_action( 'wp_font_awesome_settings_loaded' ); |
|
| 100 | + do_action('wp_font_awesome_settings_loaded'); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | return self::$instance; |
@@ -111,30 +111,30 @@ discard block |
||
| 111 | 111 | public function init() { |
| 112 | 112 | $this->settings = $this->get_settings(); |
| 113 | 113 | |
| 114 | - if ( $this->settings['type'] == 'CSS' ) { |
|
| 114 | + if ($this->settings['type'] == 'CSS') { |
|
| 115 | 115 | |
| 116 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
| 117 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
| 116 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') { |
|
| 117 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
| 121 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
| 120 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') { |
|
| 121 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | } else { |
| 125 | 125 | |
| 126 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
| 127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
| 126 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') { |
|
| 127 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
| 131 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
| 130 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') { |
|
| 131 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // remove font awesome if set to do so |
| 136 | - if ( $this->settings['dequeue'] == '1' ) { |
|
| 137 | - add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 ); |
|
| 136 | + if ($this->settings['dequeue'] == '1') { |
|
| 137 | + add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | } |
@@ -146,15 +146,15 @@ discard block |
||
| 146 | 146 | // build url |
| 147 | 147 | $url = $this->get_url(); |
| 148 | 148 | |
| 149 | - wp_deregister_style( 'font-awesome' ); // deregister in case its already there |
|
| 150 | - wp_register_style( 'font-awesome', $url, array(), null ); |
|
| 151 | - wp_enqueue_style( 'font-awesome' ); |
|
| 149 | + wp_deregister_style('font-awesome'); // deregister in case its already there |
|
| 150 | + wp_register_style('font-awesome', $url, array(), null); |
|
| 151 | + wp_enqueue_style('font-awesome'); |
|
| 152 | 152 | |
| 153 | - if ( $this->settings['shims'] ) { |
|
| 154 | - $url = $this->get_url( true ); |
|
| 155 | - wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there |
|
| 156 | - wp_register_style( 'font-awesome-shims', $url, array(), null ); |
|
| 157 | - wp_enqueue_style( 'font-awesome-shims' ); |
|
| 153 | + if ($this->settings['shims']) { |
|
| 154 | + $url = $this->get_url(true); |
|
| 155 | + wp_deregister_style('font-awesome-shims'); // deregister in case its already there |
|
| 156 | + wp_register_style('font-awesome-shims', $url, array(), null); |
|
| 157 | + wp_enqueue_style('font-awesome-shims'); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
@@ -166,15 +166,15 @@ discard block |
||
| 166 | 166 | $url = $this->get_url(); |
| 167 | 167 | |
| 168 | 168 | $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script'; |
| 169 | - call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there |
|
| 170 | - wp_register_script( 'font-awesome', $url, array(), null ); |
|
| 171 | - wp_enqueue_script( 'font-awesome' ); |
|
| 172 | - |
|
| 173 | - if ( $this->settings['shims'] ) { |
|
| 174 | - $url = $this->get_url( true ); |
|
| 175 | - call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there |
|
| 176 | - wp_register_script( 'font-awesome-shims', $url, array(), null ); |
|
| 177 | - wp_enqueue_script( 'font-awesome-shims' ); |
|
| 169 | + call_user_func($deregister_function, 'font-awesome'); // deregister in case its already there |
|
| 170 | + wp_register_script('font-awesome', $url, array(), null); |
|
| 171 | + wp_enqueue_script('font-awesome'); |
|
| 172 | + |
|
| 173 | + if ($this->settings['shims']) { |
|
| 174 | + $url = $this->get_url(true); |
|
| 175 | + call_user_func($deregister_function, 'font-awesome-shims'); // deregister in case its already there |
|
| 176 | + wp_register_script('font-awesome-shims', $url, array(), null); |
|
| 177 | + wp_enqueue_script('font-awesome-shims'); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
@@ -185,16 +185,16 @@ discard block |
||
| 185 | 185 | * |
| 186 | 186 | * @return string The url to the file. |
| 187 | 187 | */ |
| 188 | - public function get_url( $shims = false ) { |
|
| 188 | + public function get_url($shims = false) { |
|
| 189 | 189 | $script = $shims ? 'v4-shims' : 'all'; |
| 190 | 190 | $sub = $this->settings['pro'] ? 'pro' : 'use'; |
| 191 | 191 | $type = $this->settings['type']; |
| 192 | 192 | $version = $this->settings['version']; |
| 193 | - $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : ''; |
|
| 193 | + $kit_url = $this->settings['kit-url'] ? esc_url($this->settings['kit-url']) : ''; |
|
| 194 | 194 | $url = ''; |
| 195 | 195 | |
| 196 | - if ( $type == 'KIT' && $kit_url ) { |
|
| 197 | - if ( $shims ) { |
|
| 196 | + if ($type == 'KIT' && $kit_url) { |
|
| 197 | + if ($shims) { |
|
| 198 | 198 | // if its a kit then we don't add shims here |
| 199 | 199 | return ''; |
| 200 | 200 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $url .= "?wpfas=true"; // set our var so our version is not removed |
| 203 | 203 | } else { |
| 204 | 204 | $url .= "https://$sub.fontawesome.com/releases/"; // CDN |
| 205 | - $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
| 205 | + $url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
| 206 | 206 | $url .= $type == 'CSS' ? 'css/' : 'js/'; // type |
| 207 | 207 | $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type |
| 208 | 208 | $url .= "?wpfas=true"; // set our var so our version is not removed |
@@ -222,16 +222,16 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @return string The filtered url. |
| 224 | 224 | */ |
| 225 | - public function remove_font_awesome( $url, $original_url, $_context ) { |
|
| 225 | + public function remove_font_awesome($url, $original_url, $_context) { |
|
| 226 | 226 | |
| 227 | - if ( $_context == 'display' |
|
| 228 | - && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false ) |
|
| 229 | - && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false ) |
|
| 227 | + if ($_context == 'display' |
|
| 228 | + && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false) |
|
| 229 | + && (strstr($url, ".js") !== false || strstr($url, ".css") !== false) |
|
| 230 | 230 | ) {// it's a font-awesome-url (probably) |
| 231 | 231 | |
| 232 | - if ( strstr( $url, "wpfas=true" ) !== false ) { |
|
| 233 | - if ( $this->settings['type'] == 'JS' ) { |
|
| 234 | - if ( $this->settings['js-pseudo'] ) { |
|
| 232 | + if (strstr($url, "wpfas=true") !== false) { |
|
| 233 | + if ($this->settings['type'] == 'JS') { |
|
| 234 | + if ($this->settings['js-pseudo']) { |
|
| 235 | 235 | $url .= "' data-search-pseudo-elements defer='defer"; |
| 236 | 236 | } else { |
| 237 | 237 | $url .= "' defer='defer"; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * Register the database settings with WordPress. |
| 251 | 251 | */ |
| 252 | 252 | public function register_settings() { |
| 253 | - register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' ); |
|
| 253 | + register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings'); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -259,10 +259,10 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | public function menu_item() { |
| 261 | 261 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
| 262 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
| 262 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
| 263 | 263 | $this, |
| 264 | 264 | 'settings_page' |
| 265 | - ) ); |
|
| 265 | + )); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | public function get_settings() { |
| 274 | 274 | |
| 275 | - $db_settings = get_option( 'wp-font-awesome-settings' ); |
|
| 275 | + $db_settings = get_option('wp-font-awesome-settings'); |
|
| 276 | 276 | |
| 277 | 277 | $defaults = array( |
| 278 | 278 | 'type' => 'CSS', // type to use, CSS or JS or KIT |
@@ -285,14 +285,14 @@ discard block |
||
| 285 | 285 | 'kit-url' => '', // the kit url |
| 286 | 286 | ); |
| 287 | 287 | |
| 288 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 288 | + $settings = wp_parse_args($db_settings, $defaults); |
|
| 289 | 289 | |
| 290 | 290 | /** |
| 291 | 291 | * Filter the Font Awesome settings. |
| 292 | 292 | * |
| 293 | 293 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
| 294 | 294 | */ |
| 295 | - return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults ); |
|
| 295 | + return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | |
@@ -300,13 +300,13 @@ discard block |
||
| 300 | 300 | * The settings page html output. |
| 301 | 301 | */ |
| 302 | 302 | public function settings_page() { |
| 303 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 304 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) ); |
|
| 303 | + if (!current_user_can('manage_options')) { |
|
| 304 | + wp_die(__('You do not have sufficient permissions to access this page.', 'font-awesome-settings')); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | // a hidden way to force the update of the verison number vai api instead of waiting the 48 hours |
| 308 | - if ( isset( $_REQUEST['force-version-check'] ) ) { |
|
| 309 | - $this->get_latest_version( $force_api = true ); |
|
| 308 | + if (isset($_REQUEST['force-version-check'])) { |
|
| 309 | + $this->get_latest_version($force_api = true); |
|
| 310 | 310 | } |
| 311 | 311 | ?> |
| 312 | 312 | <style> |
@@ -326,37 +326,37 @@ discard block |
||
| 326 | 326 | <h1><?php echo $this->name; ?></h1> |
| 327 | 327 | <form method="post" action="options.php"> |
| 328 | 328 | <?php |
| 329 | - settings_fields( 'wp-font-awesome-settings' ); |
|
| 330 | - do_settings_sections( 'wp-font-awesome-settings' ); |
|
| 329 | + settings_fields('wp-font-awesome-settings'); |
|
| 330 | + do_settings_sections('wp-font-awesome-settings'); |
|
| 331 | 331 | $kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : ''; |
| 332 | 332 | ?> |
| 333 | - <table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>"> |
|
| 333 | + <table class="form-table wpfas-table-settings <?php echo esc_attr($kit_set); ?>"> |
|
| 334 | 334 | <tr valign="top"> |
| 335 | 335 | <th scope="row"><label |
| 336 | - for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th> |
|
| 336 | + for="wpfas-type"><?php _e('Type', 'font-awesome-settings'); ?></label></th> |
|
| 337 | 337 | <td> |
| 338 | 338 | <select name="wp-font-awesome-settings[type]" id="wpfas-type" |
| 339 | 339 | onchange="if(this.value=='KIT'){jQuery('.wpfas-table-settings').addClass('wpfas-kit-set');}else{jQuery('.wpfas-table-settings').removeClass('wpfas-kit-set');}"> |
| 340 | 340 | <option |
| 341 | - value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'font-awesome-settings' ); ?></option> |
|
| 342 | - <option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option> |
|
| 341 | + value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'font-awesome-settings'); ?></option> |
|
| 342 | + <option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option> |
|
| 343 | 343 | <option |
| 344 | - value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'font-awesome-settings' ); ?></option> |
|
| 344 | + value="KIT" <?php selected($this->settings['type'], 'KIT'); ?>><?php _e('Kits (settings managed on fontawesome.com)', 'font-awesome-settings'); ?></option> |
|
| 345 | 345 | </select> |
| 346 | 346 | </td> |
| 347 | 347 | </tr> |
| 348 | 348 | |
| 349 | 349 | <tr valign="top" class="wpfas-kit-show"> |
| 350 | 350 | <th scope="row"><label |
| 351 | - for="wpfas-kit-url"><?php _e( 'Kit URL', 'font-awesome-settings' ); ?></label></th> |
|
| 351 | + for="wpfas-kit-url"><?php _e('Kit URL', 'font-awesome-settings'); ?></label></th> |
|
| 352 | 352 | <td> |
| 353 | 353 | <input class="regular-text" id="wpfas-kit-url" type="url" |
| 354 | 354 | name="wp-font-awesome-settings[kit-url]" |
| 355 | - value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>" |
|
| 355 | + value="<?php echo esc_attr($this->settings['kit-url']); ?>" |
|
| 356 | 356 | placeholder="https://kit.fontawesome.com/123abc.js"/> |
| 357 | 357 | <span><?php |
| 358 | 358 | echo sprintf( |
| 359 | - __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ), |
|
| 359 | + __('Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings'), |
|
| 360 | 360 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>', |
| 361 | 361 | '</a>' |
| 362 | 362 | ); |
@@ -366,31 +366,31 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | <tr valign="top" class="wpfas-kit-hide"> |
| 368 | 368 | <th scope="row"><label |
| 369 | - for="wpfas-version"><?php _e( 'Version', 'font-awesome-settings' ); ?></label></th> |
|
| 369 | + for="wpfas-version"><?php _e('Version', 'font-awesome-settings'); ?></label></th> |
|
| 370 | 370 | <td> |
| 371 | 371 | <select name="wp-font-awesome-settings[version]" id="wpfas-version"> |
| 372 | 372 | <option |
| 373 | - value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)', 'font-awesome-settings' ), $this->get_latest_version() ); ?> |
|
| 373 | + value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)', 'font-awesome-settings'), $this->get_latest_version()); ?> |
|
| 374 | 374 | </option> |
| 375 | - <option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>> |
|
| 375 | + <option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>> |
|
| 376 | 376 | 5.6.0 |
| 377 | 377 | </option> |
| 378 | - <option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>> |
|
| 378 | + <option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>> |
|
| 379 | 379 | 5.5.0 |
| 380 | 380 | </option> |
| 381 | - <option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>> |
|
| 381 | + <option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>> |
|
| 382 | 382 | 5.4.0 |
| 383 | 383 | </option> |
| 384 | - <option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>> |
|
| 384 | + <option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>> |
|
| 385 | 385 | 5.3.0 |
| 386 | 386 | </option> |
| 387 | - <option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>> |
|
| 387 | + <option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>> |
|
| 388 | 388 | 5.2.0 |
| 389 | 389 | </option> |
| 390 | - <option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>> |
|
| 390 | + <option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>> |
|
| 391 | 391 | 5.1.0 |
| 392 | 392 | </option> |
| 393 | - <option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>> |
|
| 393 | + <option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>> |
|
| 394 | 394 | 4.7.1 (CSS only) |
| 395 | 395 | </option> |
| 396 | 396 | </select> |
@@ -399,29 +399,29 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | <tr valign="top"> |
| 401 | 401 | <th scope="row"><label |
| 402 | - for="wpfas-enqueue"><?php _e( 'Enqueue', 'font-awesome-settings' ); ?></label></th> |
|
| 402 | + for="wpfas-enqueue"><?php _e('Enqueue', 'font-awesome-settings'); ?></label></th> |
|
| 403 | 403 | <td> |
| 404 | 404 | <select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue"> |
| 405 | 405 | <option |
| 406 | - value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'font-awesome-settings' ); ?></option> |
|
| 406 | + value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'font-awesome-settings'); ?></option> |
|
| 407 | 407 | <option |
| 408 | - value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'font-awesome-settings' ); ?></option> |
|
| 408 | + value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'font-awesome-settings'); ?></option> |
|
| 409 | 409 | <option |
| 410 | - value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'font-awesome-settings' ); ?></option> |
|
| 410 | + value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'font-awesome-settings'); ?></option> |
|
| 411 | 411 | </select> |
| 412 | 412 | </td> |
| 413 | 413 | </tr> |
| 414 | 414 | |
| 415 | 415 | <tr valign="top" class="wpfas-kit-hide"> |
| 416 | 416 | <th scope="row"><label |
| 417 | - for="wpfas-pro"><?php _e( 'Enable pro', 'font-awesome-settings' ); ?></label></th> |
|
| 417 | + for="wpfas-pro"><?php _e('Enable pro', 'font-awesome-settings'); ?></label></th> |
|
| 418 | 418 | <td> |
| 419 | 419 | <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/> |
| 420 | 420 | <input type="checkbox" name="wp-font-awesome-settings[pro]" |
| 421 | - value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/> |
|
| 421 | + value="1" <?php checked($this->settings['pro'], '1'); ?> id="wpfas-pro"/> |
|
| 422 | 422 | <span><?php |
| 423 | 423 | echo sprintf( |
| 424 | - __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ), |
|
| 424 | + __('Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings'), |
|
| 425 | 425 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>', |
| 426 | 426 | '</a>', |
| 427 | 427 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>', |
@@ -433,38 +433,38 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | <tr valign="top" class="wpfas-kit-hide"> |
| 435 | 435 | <th scope="row"><label |
| 436 | - for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'font-awesome-settings' ); ?></label> |
|
| 436 | + for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'font-awesome-settings'); ?></label> |
|
| 437 | 437 | </th> |
| 438 | 438 | <td> |
| 439 | 439 | <input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/> |
| 440 | 440 | <input type="checkbox" name="wp-font-awesome-settings[shims]" |
| 441 | - value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/> |
|
| 442 | - <span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings' ); ?></span> |
|
| 441 | + value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/> |
|
| 442 | + <span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings'); ?></span> |
|
| 443 | 443 | </td> |
| 444 | 444 | </tr> |
| 445 | 445 | |
| 446 | 446 | <tr valign="top" class="wpfas-kit-hide"> |
| 447 | 447 | <th scope="row"><label |
| 448 | - for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'font-awesome-settings' ); ?></label> |
|
| 448 | + for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'font-awesome-settings'); ?></label> |
|
| 449 | 449 | </th> |
| 450 | 450 | <td> |
| 451 | 451 | <input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/> |
| 452 | 452 | <input type="checkbox" name="wp-font-awesome-settings[js-pseudo]" |
| 453 | - value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?> |
|
| 453 | + value="1" <?php checked($this->settings['js-pseudo'], '1'); ?> |
|
| 454 | 454 | id="wpfas-js-pseudo"/> |
| 455 | - <span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings' ); ?></span> |
|
| 455 | + <span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings'); ?></span> |
|
| 456 | 456 | </td> |
| 457 | 457 | </tr> |
| 458 | 458 | |
| 459 | 459 | <tr valign="top"> |
| 460 | 460 | <th scope="row"><label |
| 461 | - for="wpfas-dequeue"><?php _e( 'Dequeue', 'font-awesome-settings' ); ?></label></th> |
|
| 461 | + for="wpfas-dequeue"><?php _e('Dequeue', 'font-awesome-settings'); ?></label></th> |
|
| 462 | 462 | <td> |
| 463 | 463 | <input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/> |
| 464 | 464 | <input type="checkbox" name="wp-font-awesome-settings[dequeue]" |
| 465 | - value="1" <?php checked( $this->settings['dequeue'], '1' ); ?> |
|
| 465 | + value="1" <?php checked($this->settings['dequeue'], '1'); ?> |
|
| 466 | 466 | id="wpfas-dequeue"/> |
| 467 | - <span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings' ); ?></span> |
|
| 467 | + <span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings'); ?></span> |
|
| 468 | 468 | </td> |
| 469 | 469 | </tr> |
| 470 | 470 | |
@@ -489,12 +489,12 @@ discard block |
||
| 489 | 489 | * |
| 490 | 490 | * @return string Either a valid version number or an empty string. |
| 491 | 491 | */ |
| 492 | - public function validate_version_number( $version ) { |
|
| 492 | + public function validate_version_number($version) { |
|
| 493 | 493 | |
| 494 | - if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) { |
|
| 494 | + if (version_compare($version, '0.0.1', '>=') >= 0) { |
|
| 495 | 495 | // valid |
| 496 | 496 | } else { |
| 497 | - $version = '';// not validated |
|
| 497 | + $version = ''; // not validated |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | return $version; |
@@ -509,19 +509,19 @@ discard block |
||
| 509 | 509 | * @since 1.0.7 |
| 510 | 510 | * @return mixed|string The latest version number found. |
| 511 | 511 | */ |
| 512 | - public function get_latest_version( $force_api = false ) { |
|
| 512 | + public function get_latest_version($force_api = false) { |
|
| 513 | 513 | $latest_version = $this->latest; |
| 514 | 514 | |
| 515 | - $cache = get_transient( 'wp-font-awesome-settings-version' ); |
|
| 515 | + $cache = get_transient('wp-font-awesome-settings-version'); |
|
| 516 | 516 | |
| 517 | - if ( $cache === false || $force_api ) { // its not set |
|
| 517 | + if ($cache === false || $force_api) { // its not set |
|
| 518 | 518 | $api_ver = $this->get_latest_version_from_api(); |
| 519 | - if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) { |
|
| 519 | + if (version_compare($api_ver, $this->latest, '>=') >= 0) { |
|
| 520 | 520 | $latest_version = $api_ver; |
| 521 | - set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS ); |
|
| 521 | + set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS); |
|
| 522 | 522 | } |
| 523 | - } elseif ( $this->validate_version_number( $cache ) ) { |
|
| 524 | - if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) { |
|
| 523 | + } elseif ($this->validate_version_number($cache)) { |
|
| 524 | + if (version_compare($cache, $this->latest, '>=') >= 0) { |
|
| 525 | 525 | $latest_version = $cache; |
| 526 | 526 | } |
| 527 | 527 | } |
@@ -537,10 +537,10 @@ discard block |
||
| 537 | 537 | */ |
| 538 | 538 | public function get_latest_version_from_api() { |
| 539 | 539 | $version = "0"; |
| 540 | - $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" ); |
|
| 541 | - if ( ! is_wp_error( $response ) && is_array( $response ) ) { |
|
| 542 | - $api_response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
| 543 | - if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) { |
|
| 540 | + $response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest"); |
|
| 541 | + if (!is_wp_error($response) && is_array($response)) { |
|
| 542 | + $api_response = json_decode(wp_remote_retrieve_body($response), true); |
|
| 543 | + if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) { |
|
| 544 | 544 | $version = $api_response['tag_name']; |
| 545 | 545 | } |
| 546 | 546 | } |
@@ -7,132 +7,132 @@ 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_item_quantities_enabled() { |
| 15 | - $ret = wpinv_get_option( 'item_quantities', true ); |
|
| 15 | + $ret = wpinv_get_option('item_quantities', true); |
|
| 16 | 16 | |
| 17 | - return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret ); |
|
| 17 | + return (bool)apply_filters('wpinv_item_quantities_enabled', $ret); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | function wpinv_get_ip() { |
| 21 | 21 | $ip = '127.0.0.1'; |
| 22 | 22 | |
| 23 | - if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
| 24 | - $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] ); |
|
| 25 | - } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
| 26 | - $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] ); |
|
| 27 | - } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 28 | - $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
|
| 23 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 24 | + $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']); |
|
| 25 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 26 | + $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']); |
|
| 27 | + } elseif (!empty($_SERVER['REMOTE_ADDR'])) { |
|
| 28 | + $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - return apply_filters( 'wpinv_get_ip', $ip ); |
|
| 31 | + return apply_filters('wpinv_get_ip', $ip); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function wpinv_get_user_agent() { |
| 35 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 36 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
| 35 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
| 36 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
| 37 | 37 | } else { |
| 38 | 38 | $user_agent = ''; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
| 41 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -function wpinv_sanitize_amount( $amount, $decimals = NULL ) { |
|
| 44 | +function wpinv_sanitize_amount($amount, $decimals = NULL) { |
|
| 45 | 45 | $is_negative = false; |
| 46 | 46 | $thousands_sep = wpinv_thousands_separator(); |
| 47 | 47 | $decimal_sep = wpinv_decimal_separator(); |
| 48 | - if ( $decimals === NULL ) { |
|
| 48 | + if ($decimals === NULL) { |
|
| 49 | 49 | $decimals = wpinv_decimals(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Sanitize the amount |
| 53 | - if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) { |
|
| 54 | - if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 55 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
| 56 | - } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) { |
|
| 57 | - $amount = str_replace( '.', '', $amount ); |
|
| 53 | + if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) { |
|
| 54 | + if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 55 | + $amount = str_replace($thousands_sep, '', $amount); |
|
| 56 | + } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) { |
|
| 57 | + $amount = str_replace('.', '', $amount); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
| 61 | - } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 62 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
| 60 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
| 61 | + } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 62 | + $amount = str_replace($thousands_sep, '', $amount); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if( $amount < 0 ) { |
|
| 65 | + if ($amount < 0) { |
|
| 66 | 66 | $is_negative = true; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $amount = preg_replace( '/[^0-9\.]/', '', $amount ); |
|
| 69 | + $amount = preg_replace('/[^0-9\.]/', '', $amount); |
|
| 70 | 70 | |
| 71 | - $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount ); |
|
| 72 | - $amount = number_format( (double) $amount, absint( $decimals ), '.', '' ); |
|
| 71 | + $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount); |
|
| 72 | + $amount = number_format((double)$amount, absint($decimals), '.', ''); |
|
| 73 | 73 | |
| 74 | - if( $is_negative ) { |
|
| 74 | + if ($is_negative) { |
|
| 75 | 75 | $amount *= -1; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals ); |
|
| 78 | + return apply_filters('wpinv_sanitize_amount', $amount, $decimals); |
|
| 79 | 79 | } |
| 80 | -add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
| 80 | +add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
| 81 | 81 | |
| 82 | -function wpinv_round_amount( $amount, $decimals = NULL ) { |
|
| 83 | - if ( $decimals === NULL ) { |
|
| 82 | +function wpinv_round_amount($amount, $decimals = NULL) { |
|
| 83 | + if ($decimals === NULL) { |
|
| 84 | 84 | $decimals = wpinv_decimals(); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) ); |
|
| 87 | + $amount = round((double)$amount, wpinv_currency_decimal_filter(absint($decimals))); |
|
| 88 | 88 | |
| 89 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
| 89 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
| 92 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
| 93 | 93 | global $post; |
| 94 | 94 | |
| 95 | 95 | $invoice_statuses = array( |
| 96 | - 'wpi-pending' => __( 'Pending Payment', 'invoicing' ), |
|
| 97 | - 'publish' => __( 'Paid', 'invoicing'), |
|
| 98 | - 'wpi-processing' => __( 'Processing', 'invoicing' ), |
|
| 99 | - 'wpi-onhold' => __( 'On Hold', 'invoicing' ), |
|
| 100 | - 'wpi-refunded' => __( 'Refunded', 'invoicing' ), |
|
| 101 | - 'wpi-cancelled' => __( 'Cancelled', 'invoicing' ), |
|
| 102 | - 'wpi-failed' => __( 'Failed', 'invoicing' ), |
|
| 103 | - 'wpi-renewal' => __( 'Renewal Payment', 'invoicing' ) |
|
| 96 | + 'wpi-pending' => __('Pending Payment', 'invoicing'), |
|
| 97 | + 'publish' => __('Paid', 'invoicing'), |
|
| 98 | + 'wpi-processing' => __('Processing', 'invoicing'), |
|
| 99 | + 'wpi-onhold' => __('On Hold', 'invoicing'), |
|
| 100 | + 'wpi-refunded' => __('Refunded', 'invoicing'), |
|
| 101 | + 'wpi-cancelled' => __('Cancelled', 'invoicing'), |
|
| 102 | + 'wpi-failed' => __('Failed', 'invoicing'), |
|
| 103 | + 'wpi-renewal' => __('Renewal Payment', 'invoicing') |
|
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | - if ( $draft ) { |
|
| 107 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
| 106 | + if ($draft) { |
|
| 107 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if ( $trashed ) { |
|
| 111 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
| 110 | + if ($trashed) { |
|
| 111 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
| 114 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | -function wpinv_status_nicename( $status ) { |
|
| 118 | - $statuses = wpinv_get_invoice_statuses( true, true ); |
|
| 119 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' ); |
|
| 117 | +function wpinv_status_nicename($status) { |
|
| 118 | + $statuses = wpinv_get_invoice_statuses(true, true); |
|
| 119 | + $status = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing'); |
|
| 120 | 120 | |
| 121 | 121 | return $status; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | function wpinv_get_currency() { |
| 125 | - $currency = wpinv_get_option( 'currency', 'USD' ); |
|
| 125 | + $currency = wpinv_get_option('currency', 'USD'); |
|
| 126 | 126 | |
| 127 | - return apply_filters( 'wpinv_currency', $currency ); |
|
| 127 | + return apply_filters('wpinv_currency', $currency); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | -function wpinv_currency_symbol( $currency = '' ) { |
|
| 131 | - if ( empty( $currency ) ) { |
|
| 130 | +function wpinv_currency_symbol($currency = '') { |
|
| 131 | + if (empty($currency)) { |
|
| 132 | 132 | $currency = wpinv_get_currency(); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $symbols = apply_filters( 'wpinv_currency_symbols', array( |
|
| 135 | + $symbols = apply_filters('wpinv_currency_symbols', array( |
|
| 136 | 136 | 'AED' => 'د.إ', |
| 137 | 137 | 'AFN' => '؋', |
| 138 | 138 | 'ALL' => 'L', |
@@ -295,209 +295,209 @@ discard block |
||
| 295 | 295 | 'YER' => '﷼', |
| 296 | 296 | 'ZAR' => 'R', |
| 297 | 297 | 'ZMW' => 'ZK', |
| 298 | - ) ); |
|
| 298 | + )); |
|
| 299 | 299 | |
| 300 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
| 300 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
| 301 | 301 | |
| 302 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
| 302 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | function wpinv_currency_position() { |
| 306 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
| 306 | + $position = wpinv_get_option('currency_position', 'left'); |
|
| 307 | 307 | |
| 308 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
| 308 | + return apply_filters('wpinv_currency_position', $position); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | function wpinv_thousands_separator() { |
| 312 | - $thousand_sep = wpinv_get_option( 'thousands_separator', ',' ); |
|
| 312 | + $thousand_sep = wpinv_get_option('thousands_separator', ','); |
|
| 313 | 313 | |
| 314 | - return apply_filters( 'wpinv_thousands_separator', $thousand_sep ); |
|
| 314 | + return apply_filters('wpinv_thousands_separator', $thousand_sep); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | function wpinv_decimal_separator() { |
| 318 | - $decimal_sep = wpinv_get_option( 'decimal_separator', '.' ); |
|
| 318 | + $decimal_sep = wpinv_get_option('decimal_separator', '.'); |
|
| 319 | 319 | |
| 320 | - return apply_filters( 'wpinv_decimal_separator', $decimal_sep ); |
|
| 320 | + return apply_filters('wpinv_decimal_separator', $decimal_sep); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | function wpinv_decimals() { |
| 324 | - $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) ); |
|
| 324 | + $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2)); |
|
| 325 | 325 | |
| 326 | - return absint( $decimals ); |
|
| 326 | + return absint($decimals); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | function wpinv_get_currencies() { |
| 330 | 330 | $currencies = array( |
| 331 | - 'USD' => __( 'US Dollar', 'invoicing' ), |
|
| 332 | - 'EUR' => __( 'Euro', 'invoicing' ), |
|
| 333 | - 'GBP' => __( 'Pound Sterling', 'invoicing' ), |
|
| 334 | - 'AED' => __( 'United Arab Emirates', 'invoicing' ), |
|
| 335 | - 'AFN' => __( 'Afghan Afghani', 'invoicing' ), |
|
| 336 | - 'ALL' => __( 'Albanian Lek', 'invoicing' ), |
|
| 337 | - 'AMD' => __( 'Armenian Dram', 'invoicing' ), |
|
| 338 | - 'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ), |
|
| 339 | - 'AOA' => __( 'Angolan Kwanza', 'invoicing' ), |
|
| 340 | - 'ARS' => __( 'Argentine Peso', 'invoicing' ), |
|
| 341 | - 'AUD' => __( 'Australian Dollar', 'invoicing' ), |
|
| 342 | - 'AWG' => __( 'Aruban Florin', 'invoicing' ), |
|
| 343 | - 'AZN' => __( 'Azerbaijani Manat', 'invoicing' ), |
|
| 344 | - 'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ), |
|
| 345 | - 'BBD' => __( 'Barbadian Dollar', 'invoicing' ), |
|
| 346 | - 'BDT' => __( 'Bangladeshi Taka', 'invoicing' ), |
|
| 347 | - 'BGN' => __( 'Bulgarian Lev', 'invoicing' ), |
|
| 348 | - 'BHD' => __( 'Bahraini Dinar', 'invoicing' ), |
|
| 349 | - 'BIF' => __( 'Burundian Franc', 'invoicing' ), |
|
| 350 | - 'BMD' => __( 'Bermudian Dollar', 'invoicing' ), |
|
| 351 | - 'BND' => __( 'Brunei Dollar', 'invoicing' ), |
|
| 352 | - 'BOB' => __( 'Bolivian Boliviano', 'invoicing' ), |
|
| 353 | - 'BRL' => __( 'Brazilian Real', 'invoicing' ), |
|
| 354 | - 'BSD' => __( 'Bahamian Dollar', 'invoicing' ), |
|
| 355 | - 'BTC' => __( 'Bitcoin', 'invoicing' ), |
|
| 356 | - 'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ), |
|
| 357 | - 'BWP' => __( 'Botswana Pula', 'invoicing' ), |
|
| 358 | - 'BYN' => __( 'Belarusian Ruble', 'invoicing' ), |
|
| 359 | - 'BZD' => __( 'Belize Dollar', 'invoicing' ), |
|
| 360 | - 'CAD' => __( 'Canadian Dollar', 'invoicing' ), |
|
| 361 | - 'CDF' => __( 'Congolese Franc', 'invoicing' ), |
|
| 362 | - 'CHF' => __( 'Swiss Franc', 'invoicing' ), |
|
| 363 | - 'CLP' => __( 'Chilean Peso', 'invoicing' ), |
|
| 364 | - 'CNY' => __( 'Chinese Yuan', 'invoicing' ), |
|
| 365 | - 'COP' => __( 'Colombian Peso', 'invoicing' ), |
|
| 366 | - 'CRC' => __( 'Costa Rican Colon', 'invoicing' ), |
|
| 367 | - 'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ), |
|
| 368 | - 'CUP' => __( 'Cuban Peso', 'invoicing' ), |
|
| 369 | - 'CVE' => __( 'Cape Verdean escudo', 'invoicing' ), |
|
| 370 | - 'CZK' => __( 'Czech Koruna', 'invoicing' ), |
|
| 371 | - 'DJF' => __( 'Djiboutian Franc', 'invoicing' ), |
|
| 372 | - 'DKK' => __( 'Danish Krone', 'invoicing' ), |
|
| 373 | - 'DOP' => __( 'Dominican Peso', 'invoicing' ), |
|
| 374 | - 'DZD' => __( 'Algerian Dinar', 'invoicing' ), |
|
| 375 | - 'EGP' => __( 'Egyptian Pound', 'invoicing' ), |
|
| 376 | - 'ERN' => __( 'Eritrean Nakfa', 'invoicing' ), |
|
| 377 | - 'ETB' => __( 'Ethiopian Irr', 'invoicing' ), |
|
| 378 | - 'FJD' => __( 'Fijian Dollar', 'invoicing' ), |
|
| 379 | - 'FKP' => __( 'Falkland Islands Pound', 'invoicing' ), |
|
| 380 | - 'GEL' => __( 'Georgian Lari', 'invoicing' ), |
|
| 381 | - 'GGP' => __( 'Guernsey Pound', 'invoicing' ), |
|
| 382 | - 'GHS' => __( 'Ghana Cedi', 'invoicing' ), |
|
| 383 | - 'GIP' => __( 'Gibraltar Pound', 'invoicing' ), |
|
| 384 | - 'GMD' => __( 'Gambian Dalasi', 'invoicing' ), |
|
| 385 | - 'GNF' => __( 'Guinean Franc', 'invoicing' ), |
|
| 386 | - 'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ), |
|
| 387 | - 'GYD' => __( 'Guyanese Dollar', 'invoicing' ), |
|
| 388 | - 'HKD' => __( 'Hong Kong Dollar', 'invoicing' ), |
|
| 389 | - 'HNL' => __( 'Honduran Lempira', 'invoicing' ), |
|
| 390 | - 'HRK' => __( 'Croatian Kuna', 'invoicing' ), |
|
| 391 | - 'HTG' => __( 'Haitian Gourde', 'invoicing' ), |
|
| 392 | - 'HUF' => __( 'Hungarian Forint', 'invoicing' ), |
|
| 393 | - 'IDR' => __( 'Indonesian Rupiah', 'invoicing' ), |
|
| 394 | - 'ILS' => __( 'Israeli New Shekel', 'invoicing' ), |
|
| 395 | - 'IMP' => __( 'Manx Pound', 'invoicing' ), |
|
| 396 | - 'INR' => __( 'Indian Rupee', 'invoicing' ), |
|
| 397 | - 'IQD' => __( 'Iraqi Dinar', 'invoicing' ), |
|
| 398 | - 'IRR' => __( 'Iranian Rial', 'invoicing' ), |
|
| 399 | - 'IRT' => __( 'Iranian Toman', 'invoicing' ), |
|
| 400 | - 'ISK' => __( 'Icelandic Krona', 'invoicing' ), |
|
| 401 | - 'JEP' => __( 'Jersey Pound', 'invoicing' ), |
|
| 402 | - 'JMD' => __( 'Jamaican Dollar', 'invoicing' ), |
|
| 403 | - 'JOD' => __( 'Jordanian Dinar', 'invoicing' ), |
|
| 404 | - 'JPY' => __( 'Japanese Yen', 'invoicing' ), |
|
| 405 | - 'KES' => __( 'Kenyan Shilling', 'invoicing' ), |
|
| 406 | - 'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ), |
|
| 407 | - 'KHR' => __( 'Cambodian Riel', 'invoicing' ), |
|
| 408 | - 'KMF' => __( 'Comorian Franc', 'invoicing' ), |
|
| 409 | - 'KPW' => __( 'North Korean Won', 'invoicing' ), |
|
| 410 | - 'KRW' => __( 'South Korean Won', 'invoicing' ), |
|
| 411 | - 'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ), |
|
| 412 | - 'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ), |
|
| 413 | - 'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ), |
|
| 414 | - 'LAK' => __( 'Lao Kip', 'invoicing' ), |
|
| 415 | - 'LBP' => __( 'Lebanese Pound', 'invoicing' ), |
|
| 416 | - 'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ), |
|
| 417 | - 'LRD' => __( 'Liberian Dollar', 'invoicing' ), |
|
| 418 | - 'LSL' => __( 'Lesotho Loti', 'invoicing' ), |
|
| 419 | - 'LYD' => __( 'Libyan Dinar', 'invoicing' ), |
|
| 420 | - 'MAD' => __( 'Moroccan Dirham', 'invoicing' ), |
|
| 421 | - 'MDL' => __( 'Moldovan Leu', 'invoicing' ), |
|
| 422 | - 'MGA' => __( 'Malagasy Ariary', 'invoicing' ), |
|
| 423 | - 'MKD' => __( 'Macedonian Denar', 'invoicing' ), |
|
| 424 | - 'MMK' => __( 'Burmese Kyat', 'invoicing' ), |
|
| 425 | - 'MNT' => __( 'Mongolian Tughrik', 'invoicing' ), |
|
| 426 | - 'MOP' => __( 'Macanese Pataca', 'invoicing' ), |
|
| 427 | - 'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ), |
|
| 428 | - 'MUR' => __( 'Mauritian Rupee', 'invoicing' ), |
|
| 429 | - 'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ), |
|
| 430 | - 'MWK' => __( 'Malawian Kwacha', 'invoicing' ), |
|
| 431 | - 'MXN' => __( 'Mexican Peso', 'invoicing' ), |
|
| 432 | - 'MYR' => __( 'Malaysian Ringgit', 'invoicing' ), |
|
| 433 | - 'MZN' => __( 'Mozambican Metical', 'invoicing' ), |
|
| 434 | - 'NAD' => __( 'Namibian Dollar', 'invoicing' ), |
|
| 435 | - 'NGN' => __( 'Nigerian Naira', 'invoicing' ), |
|
| 436 | - 'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ), |
|
| 437 | - 'NOK' => __( 'Norwegian Krone', 'invoicing' ), |
|
| 438 | - 'NPR' => __( 'Nepalese Rupee', 'invoicing' ), |
|
| 439 | - 'NZD' => __( 'New Zealand Dollar', 'invoicing' ), |
|
| 440 | - 'OMR' => __( 'Omani Rial', 'invoicing' ), |
|
| 441 | - 'PAB' => __( 'Panamanian Balboa', 'invoicing' ), |
|
| 442 | - 'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ), |
|
| 443 | - 'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ), |
|
| 444 | - 'PHP' => __( 'Philippine Peso', 'invoicing' ), |
|
| 445 | - 'PKR' => __( 'Pakistani Rupee', 'invoicing' ), |
|
| 446 | - 'PLN' => __( 'Polish Zloty', 'invoicing' ), |
|
| 447 | - 'PRB' => __( 'Transnistrian Ruble', 'invoicing' ), |
|
| 448 | - 'PYG' => __( 'Paraguayan Guarani', 'invoicing' ), |
|
| 449 | - 'QAR' => __( 'Qatari Riyal', 'invoicing' ), |
|
| 450 | - 'RON' => __( 'Romanian Leu', 'invoicing' ), |
|
| 451 | - 'RSD' => __( 'Serbian Dinar', 'invoicing' ), |
|
| 452 | - 'RUB' => __( 'Russian Ruble', 'invoicing' ), |
|
| 453 | - 'RWF' => __( 'Rwandan Franc', 'invoicing' ), |
|
| 454 | - 'SAR' => __( 'Saudi Riyal', 'invoicing' ), |
|
| 455 | - 'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ), |
|
| 456 | - 'SCR' => __( 'Seychellois Rupee', 'invoicing' ), |
|
| 457 | - 'SDG' => __( 'Sudanese Pound', 'invoicing' ), |
|
| 458 | - 'SEK' => __( 'Swedish Krona', 'invoicing' ), |
|
| 459 | - 'SGD' => __( 'Singapore Dollar', 'invoicing' ), |
|
| 460 | - 'SHP' => __( 'Saint Helena Pound', 'invoicing' ), |
|
| 461 | - 'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ), |
|
| 462 | - 'SOS' => __( 'Somali Shilling', 'invoicing' ), |
|
| 463 | - 'SRD' => __( 'Surinamese Dollar', 'invoicing' ), |
|
| 464 | - 'SSP' => __( 'South Sudanese Pound', 'invoicing' ), |
|
| 465 | - 'STD' => __( 'Sao Tomean Dobra', 'invoicing' ), |
|
| 466 | - 'SYP' => __( 'Syrian Pound', 'invoicing' ), |
|
| 467 | - 'SZL' => __( 'Swazi Lilangeni', 'invoicing' ), |
|
| 468 | - 'THB' => __( 'Thai Baht', 'invoicing' ), |
|
| 469 | - 'TJS' => __( 'Tajikistani Somoni', 'invoicing' ), |
|
| 470 | - 'TMT' => __( 'Turkmenistan Manat', 'invoicing' ), |
|
| 471 | - 'TND' => __( 'Tunisian Dinar', 'invoicing' ), |
|
| 472 | - 'TOP' => __( 'Tongan Paʻanga', 'invoicing' ), |
|
| 473 | - 'TRY' => __( 'Turkish Lira', 'invoicing' ), |
|
| 474 | - 'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ), |
|
| 475 | - 'TWD' => __( 'New Taiwan Dollar', 'invoicing' ), |
|
| 476 | - 'TZS' => __( 'Tanzanian Shilling', 'invoicing' ), |
|
| 477 | - 'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ), |
|
| 478 | - 'UGX' => __( 'Ugandan Shilling', 'invoicing' ), |
|
| 479 | - 'UYU' => __( 'Uruguayan Peso', 'invoicing' ), |
|
| 480 | - 'UZS' => __( 'Uzbekistani Som', 'invoicing' ), |
|
| 481 | - 'VEF' => __( 'Venezuelan Bolívar', 'invoicing' ), |
|
| 482 | - 'VND' => __( 'Vietnamese Dong', 'invoicing' ), |
|
| 483 | - 'VUV' => __( 'Vanuatu Vatu', 'invoicing' ), |
|
| 484 | - 'WST' => __( 'Samoan Tala', 'invoicing' ), |
|
| 485 | - 'XAF' => __( 'Central African CFA Franc', 'invoicing' ), |
|
| 486 | - 'XCD' => __( 'East Caribbean Dollar', 'invoicing' ), |
|
| 487 | - 'XOF' => __( 'West African CFA Franc', 'invoicing' ), |
|
| 488 | - 'XPF' => __( 'CFP Franc', 'invoicing' ), |
|
| 489 | - 'YER' => __( 'Yemeni Rial', 'invoicing' ), |
|
| 490 | - 'ZAR' => __( 'South African Rand', 'invoicing' ), |
|
| 491 | - 'ZMW' => __( 'Zambian Kwacha', 'invoicing' ), |
|
| 331 | + 'USD' => __('US Dollar', 'invoicing'), |
|
| 332 | + 'EUR' => __('Euro', 'invoicing'), |
|
| 333 | + 'GBP' => __('Pound Sterling', 'invoicing'), |
|
| 334 | + 'AED' => __('United Arab Emirates', 'invoicing'), |
|
| 335 | + 'AFN' => __('Afghan Afghani', 'invoicing'), |
|
| 336 | + 'ALL' => __('Albanian Lek', 'invoicing'), |
|
| 337 | + 'AMD' => __('Armenian Dram', 'invoicing'), |
|
| 338 | + 'ANG' => __('Netherlands Antillean Guilder', 'invoicing'), |
|
| 339 | + 'AOA' => __('Angolan Kwanza', 'invoicing'), |
|
| 340 | + 'ARS' => __('Argentine Peso', 'invoicing'), |
|
| 341 | + 'AUD' => __('Australian Dollar', 'invoicing'), |
|
| 342 | + 'AWG' => __('Aruban Florin', 'invoicing'), |
|
| 343 | + 'AZN' => __('Azerbaijani Manat', 'invoicing'), |
|
| 344 | + 'BAM' => __('Bosnia and Herzegovina Convertible Marka', 'invoicing'), |
|
| 345 | + 'BBD' => __('Barbadian Dollar', 'invoicing'), |
|
| 346 | + 'BDT' => __('Bangladeshi Taka', 'invoicing'), |
|
| 347 | + 'BGN' => __('Bulgarian Lev', 'invoicing'), |
|
| 348 | + 'BHD' => __('Bahraini Dinar', 'invoicing'), |
|
| 349 | + 'BIF' => __('Burundian Franc', 'invoicing'), |
|
| 350 | + 'BMD' => __('Bermudian Dollar', 'invoicing'), |
|
| 351 | + 'BND' => __('Brunei Dollar', 'invoicing'), |
|
| 352 | + 'BOB' => __('Bolivian Boliviano', 'invoicing'), |
|
| 353 | + 'BRL' => __('Brazilian Real', 'invoicing'), |
|
| 354 | + 'BSD' => __('Bahamian Dollar', 'invoicing'), |
|
| 355 | + 'BTC' => __('Bitcoin', 'invoicing'), |
|
| 356 | + 'BTN' => __('Bhutanese Ngultrum', 'invoicing'), |
|
| 357 | + 'BWP' => __('Botswana Pula', 'invoicing'), |
|
| 358 | + 'BYN' => __('Belarusian Ruble', 'invoicing'), |
|
| 359 | + 'BZD' => __('Belize Dollar', 'invoicing'), |
|
| 360 | + 'CAD' => __('Canadian Dollar', 'invoicing'), |
|
| 361 | + 'CDF' => __('Congolese Franc', 'invoicing'), |
|
| 362 | + 'CHF' => __('Swiss Franc', 'invoicing'), |
|
| 363 | + 'CLP' => __('Chilean Peso', 'invoicing'), |
|
| 364 | + 'CNY' => __('Chinese Yuan', 'invoicing'), |
|
| 365 | + 'COP' => __('Colombian Peso', 'invoicing'), |
|
| 366 | + 'CRC' => __('Costa Rican Colon', 'invoicing'), |
|
| 367 | + 'CUC' => __('Cuban Convertible Peso', 'invoicing'), |
|
| 368 | + 'CUP' => __('Cuban Peso', 'invoicing'), |
|
| 369 | + 'CVE' => __('Cape Verdean escudo', 'invoicing'), |
|
| 370 | + 'CZK' => __('Czech Koruna', 'invoicing'), |
|
| 371 | + 'DJF' => __('Djiboutian Franc', 'invoicing'), |
|
| 372 | + 'DKK' => __('Danish Krone', 'invoicing'), |
|
| 373 | + 'DOP' => __('Dominican Peso', 'invoicing'), |
|
| 374 | + 'DZD' => __('Algerian Dinar', 'invoicing'), |
|
| 375 | + 'EGP' => __('Egyptian Pound', 'invoicing'), |
|
| 376 | + 'ERN' => __('Eritrean Nakfa', 'invoicing'), |
|
| 377 | + 'ETB' => __('Ethiopian Irr', 'invoicing'), |
|
| 378 | + 'FJD' => __('Fijian Dollar', 'invoicing'), |
|
| 379 | + 'FKP' => __('Falkland Islands Pound', 'invoicing'), |
|
| 380 | + 'GEL' => __('Georgian Lari', 'invoicing'), |
|
| 381 | + 'GGP' => __('Guernsey Pound', 'invoicing'), |
|
| 382 | + 'GHS' => __('Ghana Cedi', 'invoicing'), |
|
| 383 | + 'GIP' => __('Gibraltar Pound', 'invoicing'), |
|
| 384 | + 'GMD' => __('Gambian Dalasi', 'invoicing'), |
|
| 385 | + 'GNF' => __('Guinean Franc', 'invoicing'), |
|
| 386 | + 'GTQ' => __('Guatemalan Quetzal', 'invoicing'), |
|
| 387 | + 'GYD' => __('Guyanese Dollar', 'invoicing'), |
|
| 388 | + 'HKD' => __('Hong Kong Dollar', 'invoicing'), |
|
| 389 | + 'HNL' => __('Honduran Lempira', 'invoicing'), |
|
| 390 | + 'HRK' => __('Croatian Kuna', 'invoicing'), |
|
| 391 | + 'HTG' => __('Haitian Gourde', 'invoicing'), |
|
| 392 | + 'HUF' => __('Hungarian Forint', 'invoicing'), |
|
| 393 | + 'IDR' => __('Indonesian Rupiah', 'invoicing'), |
|
| 394 | + 'ILS' => __('Israeli New Shekel', 'invoicing'), |
|
| 395 | + 'IMP' => __('Manx Pound', 'invoicing'), |
|
| 396 | + 'INR' => __('Indian Rupee', 'invoicing'), |
|
| 397 | + 'IQD' => __('Iraqi Dinar', 'invoicing'), |
|
| 398 | + 'IRR' => __('Iranian Rial', 'invoicing'), |
|
| 399 | + 'IRT' => __('Iranian Toman', 'invoicing'), |
|
| 400 | + 'ISK' => __('Icelandic Krona', 'invoicing'), |
|
| 401 | + 'JEP' => __('Jersey Pound', 'invoicing'), |
|
| 402 | + 'JMD' => __('Jamaican Dollar', 'invoicing'), |
|
| 403 | + 'JOD' => __('Jordanian Dinar', 'invoicing'), |
|
| 404 | + 'JPY' => __('Japanese Yen', 'invoicing'), |
|
| 405 | + 'KES' => __('Kenyan Shilling', 'invoicing'), |
|
| 406 | + 'KGS' => __('Kyrgyzstani Som', 'invoicing'), |
|
| 407 | + 'KHR' => __('Cambodian Riel', 'invoicing'), |
|
| 408 | + 'KMF' => __('Comorian Franc', 'invoicing'), |
|
| 409 | + 'KPW' => __('North Korean Won', 'invoicing'), |
|
| 410 | + 'KRW' => __('South Korean Won', 'invoicing'), |
|
| 411 | + 'KWD' => __('Kuwaiti Dinar', 'invoicing'), |
|
| 412 | + 'KYD' => __('Cayman Islands Dollar', 'invoicing'), |
|
| 413 | + 'KZT' => __('Kazakhstani Tenge', 'invoicing'), |
|
| 414 | + 'LAK' => __('Lao Kip', 'invoicing'), |
|
| 415 | + 'LBP' => __('Lebanese Pound', 'invoicing'), |
|
| 416 | + 'LKR' => __('Sri Lankan Rupee', 'invoicing'), |
|
| 417 | + 'LRD' => __('Liberian Dollar', 'invoicing'), |
|
| 418 | + 'LSL' => __('Lesotho Loti', 'invoicing'), |
|
| 419 | + 'LYD' => __('Libyan Dinar', 'invoicing'), |
|
| 420 | + 'MAD' => __('Moroccan Dirham', 'invoicing'), |
|
| 421 | + 'MDL' => __('Moldovan Leu', 'invoicing'), |
|
| 422 | + 'MGA' => __('Malagasy Ariary', 'invoicing'), |
|
| 423 | + 'MKD' => __('Macedonian Denar', 'invoicing'), |
|
| 424 | + 'MMK' => __('Burmese Kyat', 'invoicing'), |
|
| 425 | + 'MNT' => __('Mongolian Tughrik', 'invoicing'), |
|
| 426 | + 'MOP' => __('Macanese Pataca', 'invoicing'), |
|
| 427 | + 'MRO' => __('Mauritanian Ouguiya', 'invoicing'), |
|
| 428 | + 'MUR' => __('Mauritian Rupee', 'invoicing'), |
|
| 429 | + 'MVR' => __('Maldivian Rufiyaa', 'invoicing'), |
|
| 430 | + 'MWK' => __('Malawian Kwacha', 'invoicing'), |
|
| 431 | + 'MXN' => __('Mexican Peso', 'invoicing'), |
|
| 432 | + 'MYR' => __('Malaysian Ringgit', 'invoicing'), |
|
| 433 | + 'MZN' => __('Mozambican Metical', 'invoicing'), |
|
| 434 | + 'NAD' => __('Namibian Dollar', 'invoicing'), |
|
| 435 | + 'NGN' => __('Nigerian Naira', 'invoicing'), |
|
| 436 | + 'NIO' => __('Nicaraguan Cordoba', 'invoicing'), |
|
| 437 | + 'NOK' => __('Norwegian Krone', 'invoicing'), |
|
| 438 | + 'NPR' => __('Nepalese Rupee', 'invoicing'), |
|
| 439 | + 'NZD' => __('New Zealand Dollar', 'invoicing'), |
|
| 440 | + 'OMR' => __('Omani Rial', 'invoicing'), |
|
| 441 | + 'PAB' => __('Panamanian Balboa', 'invoicing'), |
|
| 442 | + 'PEN' => __('Peruvian Nuevo Sol', 'invoicing'), |
|
| 443 | + 'PGK' => __('Papua New Guinean Kina', 'invoicing'), |
|
| 444 | + 'PHP' => __('Philippine Peso', 'invoicing'), |
|
| 445 | + 'PKR' => __('Pakistani Rupee', 'invoicing'), |
|
| 446 | + 'PLN' => __('Polish Zloty', 'invoicing'), |
|
| 447 | + 'PRB' => __('Transnistrian Ruble', 'invoicing'), |
|
| 448 | + 'PYG' => __('Paraguayan Guarani', 'invoicing'), |
|
| 449 | + 'QAR' => __('Qatari Riyal', 'invoicing'), |
|
| 450 | + 'RON' => __('Romanian Leu', 'invoicing'), |
|
| 451 | + 'RSD' => __('Serbian Dinar', 'invoicing'), |
|
| 452 | + 'RUB' => __('Russian Ruble', 'invoicing'), |
|
| 453 | + 'RWF' => __('Rwandan Franc', 'invoicing'), |
|
| 454 | + 'SAR' => __('Saudi Riyal', 'invoicing'), |
|
| 455 | + 'SBD' => __('Solomon Islands Dollar', 'invoicing'), |
|
| 456 | + 'SCR' => __('Seychellois Rupee', 'invoicing'), |
|
| 457 | + 'SDG' => __('Sudanese Pound', 'invoicing'), |
|
| 458 | + 'SEK' => __('Swedish Krona', 'invoicing'), |
|
| 459 | + 'SGD' => __('Singapore Dollar', 'invoicing'), |
|
| 460 | + 'SHP' => __('Saint Helena Pound', 'invoicing'), |
|
| 461 | + 'SLL' => __('Sierra Leonean Leone', 'invoicing'), |
|
| 462 | + 'SOS' => __('Somali Shilling', 'invoicing'), |
|
| 463 | + 'SRD' => __('Surinamese Dollar', 'invoicing'), |
|
| 464 | + 'SSP' => __('South Sudanese Pound', 'invoicing'), |
|
| 465 | + 'STD' => __('Sao Tomean Dobra', 'invoicing'), |
|
| 466 | + 'SYP' => __('Syrian Pound', 'invoicing'), |
|
| 467 | + 'SZL' => __('Swazi Lilangeni', 'invoicing'), |
|
| 468 | + 'THB' => __('Thai Baht', 'invoicing'), |
|
| 469 | + 'TJS' => __('Tajikistani Somoni', 'invoicing'), |
|
| 470 | + 'TMT' => __('Turkmenistan Manat', 'invoicing'), |
|
| 471 | + 'TND' => __('Tunisian Dinar', 'invoicing'), |
|
| 472 | + 'TOP' => __('Tongan Paʻanga', 'invoicing'), |
|
| 473 | + 'TRY' => __('Turkish Lira', 'invoicing'), |
|
| 474 | + 'TTD' => __('Trinidad and Tobago Dollar', 'invoicing'), |
|
| 475 | + 'TWD' => __('New Taiwan Dollar', 'invoicing'), |
|
| 476 | + 'TZS' => __('Tanzanian Shilling', 'invoicing'), |
|
| 477 | + 'UAH' => __('Ukrainian Hryvnia', 'invoicing'), |
|
| 478 | + 'UGX' => __('Ugandan Shilling', 'invoicing'), |
|
| 479 | + 'UYU' => __('Uruguayan Peso', 'invoicing'), |
|
| 480 | + 'UZS' => __('Uzbekistani Som', 'invoicing'), |
|
| 481 | + 'VEF' => __('Venezuelan Bolívar', 'invoicing'), |
|
| 482 | + 'VND' => __('Vietnamese Dong', 'invoicing'), |
|
| 483 | + 'VUV' => __('Vanuatu Vatu', 'invoicing'), |
|
| 484 | + 'WST' => __('Samoan Tala', 'invoicing'), |
|
| 485 | + 'XAF' => __('Central African CFA Franc', 'invoicing'), |
|
| 486 | + 'XCD' => __('East Caribbean Dollar', 'invoicing'), |
|
| 487 | + 'XOF' => __('West African CFA Franc', 'invoicing'), |
|
| 488 | + 'XPF' => __('CFP Franc', 'invoicing'), |
|
| 489 | + 'YER' => __('Yemeni Rial', 'invoicing'), |
|
| 490 | + 'ZAR' => __('South African Rand', 'invoicing'), |
|
| 491 | + 'ZMW' => __('Zambian Kwacha', 'invoicing'), |
|
| 492 | 492 | ); |
| 493 | 493 | |
| 494 | 494 | //asort( $currencies ); // this |
| 495 | 495 | |
| 496 | - return apply_filters( 'wpinv_currencies', $currencies ); |
|
| 496 | + return apply_filters('wpinv_currencies', $currencies); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | -function wpinv_price( $amount = '', $currency = '' ) { |
|
| 500 | - if( empty( $currency ) ) { |
|
| 499 | +function wpinv_price($amount = '', $currency = '') { |
|
| 500 | + if (empty($currency)) { |
|
| 501 | 501 | $currency = wpinv_get_currency(); |
| 502 | 502 | } |
| 503 | 503 | |
@@ -505,14 +505,14 @@ discard block |
||
| 505 | 505 | |
| 506 | 506 | $negative = $amount < 0; |
| 507 | 507 | |
| 508 | - if ( $negative ) { |
|
| 509 | - $amount = substr( $amount, 1 ); |
|
| 508 | + if ($negative) { |
|
| 509 | + $amount = substr($amount, 1); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | - $symbol = wpinv_currency_symbol( $currency ); |
|
| 512 | + $symbol = wpinv_currency_symbol($currency); |
|
| 513 | 513 | |
| 514 | - if ( $position == 'left' || $position == 'left_space' ) { |
|
| 515 | - switch ( $currency ) { |
|
| 514 | + if ($position == 'left' || $position == 'left_space') { |
|
| 515 | + switch ($currency) { |
|
| 516 | 516 | case "GBP" : |
| 517 | 517 | case "BRL" : |
| 518 | 518 | case "EUR" : |
@@ -524,15 +524,15 @@ discard block |
||
| 524 | 524 | case "NZD" : |
| 525 | 525 | case "SGD" : |
| 526 | 526 | case "JPY" : |
| 527 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 527 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 528 | 528 | break; |
| 529 | 529 | default : |
| 530 | 530 | //$price = $currency . ' ' . $amount; |
| 531 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 531 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 532 | 532 | break; |
| 533 | 533 | } |
| 534 | 534 | } else { |
| 535 | - switch ( $currency ) { |
|
| 535 | + switch ($currency) { |
|
| 536 | 536 | case "GBP" : |
| 537 | 537 | case "BRL" : |
| 538 | 538 | case "EUR" : |
@@ -543,83 +543,83 @@ discard block |
||
| 543 | 543 | case "MXN" : |
| 544 | 544 | case "SGD" : |
| 545 | 545 | case "JPY" : |
| 546 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 546 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 547 | 547 | break; |
| 548 | 548 | default : |
| 549 | 549 | //$price = $amount . ' ' . $currency; |
| 550 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 550 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 551 | 551 | break; |
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - if ( $negative ) { |
|
| 555 | + if ($negative) { |
|
| 556 | 556 | $price = '-' . $price; |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount ); |
|
| 559 | + $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount); |
|
| 560 | 560 | |
| 561 | 561 | return $price; |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | -function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) { |
|
| 564 | +function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) { |
|
| 565 | 565 | $thousands_sep = wpinv_thousands_separator(); |
| 566 | 566 | $decimal_sep = wpinv_decimal_separator(); |
| 567 | 567 | |
| 568 | - if ( $decimals === NULL ) { |
|
| 568 | + if ($decimals === NULL) { |
|
| 569 | 569 | $decimals = wpinv_decimals(); |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | - if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) { |
|
| 573 | - $whole = substr( $amount, 0, $sep_found ); |
|
| 574 | - $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) ); |
|
| 572 | + if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) { |
|
| 573 | + $whole = substr($amount, 0, $sep_found); |
|
| 574 | + $part = substr($amount, $sep_found + 1, (strlen($amount) - 1)); |
|
| 575 | 575 | $amount = $whole . '.' . $part; |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 579 | - $amount = str_replace( ',', '', $amount ); |
|
| 578 | + if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 579 | + $amount = str_replace(',', '', $amount); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | - if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 583 | - $amount = str_replace( ' ', '', $amount ); |
|
| 582 | + if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 583 | + $amount = str_replace(' ', '', $amount); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - if ( empty( $amount ) ) { |
|
| 586 | + if (empty($amount)) { |
|
| 587 | 587 | $amount = 0; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - $decimals = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate ); |
|
| 591 | - $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 590 | + $decimals = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate); |
|
| 591 | + $formatted = number_format((float)$amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 592 | 592 | |
| 593 | - if ( $calculate ) { |
|
| 594 | - if ( $thousands_sep === "," ) { |
|
| 595 | - $formatted = str_replace( ",", "", $formatted ); |
|
| 593 | + if ($calculate) { |
|
| 594 | + if ($thousands_sep === ",") { |
|
| 595 | + $formatted = str_replace(",", "", $formatted); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - if ( $decimal_sep === "," ) { |
|
| 599 | - $formatted = str_replace( ",", ".", $formatted ); |
|
| 598 | + if ($decimal_sep === ",") { |
|
| 599 | + $formatted = str_replace(",", ".", $formatted); |
|
| 600 | 600 | } |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate ); |
|
| 603 | + return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate); |
|
| 604 | 604 | } |
| 605 | -add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
| 605 | +add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
| 606 | 606 | |
| 607 | -function wpinv_sanitize_key( $key ) { |
|
| 607 | +function wpinv_sanitize_key($key) { |
|
| 608 | 608 | $raw_key = $key; |
| 609 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
| 609 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
| 610 | 610 | |
| 611 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
| 611 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | -function wpinv_get_file_extension( $str ) { |
|
| 615 | - $parts = explode( '.', $str ); |
|
| 616 | - return end( $parts ); |
|
| 614 | +function wpinv_get_file_extension($str) { |
|
| 615 | + $parts = explode('.', $str); |
|
| 616 | + return end($parts); |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | -function wpinv_string_is_image_url( $str ) { |
|
| 620 | - $ext = wpinv_get_file_extension( $str ); |
|
| 619 | +function wpinv_string_is_image_url($str) { |
|
| 620 | + $ext = wpinv_get_file_extension($str); |
|
| 621 | 621 | |
| 622 | - switch ( strtolower( $ext ) ) { |
|
| 622 | + switch (strtolower($ext)) { |
|
| 623 | 623 | case 'jpeg'; |
| 624 | 624 | case 'jpg'; |
| 625 | 625 | $return = true; |
@@ -635,32 +635,32 @@ discard block |
||
| 635 | 635 | break; |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | - return (bool)apply_filters( 'wpinv_string_is_image', $return, $str ); |
|
| 638 | + return (bool)apply_filters('wpinv_string_is_image', $return, $str); |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
| 642 | - $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG ); |
|
| 641 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
| 642 | + $should_log = apply_filters('wpinv_log_errors', WP_DEBUG); |
|
| 643 | 643 | |
| 644 | - if ( true === $should_log ) { |
|
| 644 | + if (true === $should_log) { |
|
| 645 | 645 | $label = ''; |
| 646 | - if ( $file && $file !== '' ) { |
|
| 647 | - $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' ); |
|
| 646 | + if ($file && $file !== '') { |
|
| 647 | + $label .= basename($file) . ($line ? '(' . $line . ')' : ''); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | - if ( $title && $title !== '' ) { |
|
| 650 | + if ($title && $title !== '') { |
|
| 651 | 651 | $label = $label !== '' ? $label . ' ' : ''; |
| 652 | 652 | $label .= $title . ' '; |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - $label = $label !== '' ? trim( $label ) . ' : ' : ''; |
|
| 655 | + $label = $label !== '' ? trim($label) . ' : ' : ''; |
|
| 656 | 656 | |
| 657 | - if ( is_array( $log ) || is_object( $log ) ) { |
|
| 658 | - error_log( $label . print_r( $log, true ) ); |
|
| 657 | + if (is_array($log) || is_object($log)) { |
|
| 658 | + error_log($label . print_r($log, true)); |
|
| 659 | 659 | } else { |
| 660 | - error_log( $label . $log ); |
|
| 660 | + error_log($label . $log); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | - if ( $exit ) { |
|
| 663 | + if ($exit) { |
|
| 664 | 664 | exit; |
| 665 | 665 | } |
| 666 | 666 | } |
@@ -668,65 +668,65 @@ discard block |
||
| 668 | 668 | |
| 669 | 669 | function wpinv_is_ajax_disabled() { |
| 670 | 670 | $retval = false; |
| 671 | - return apply_filters( 'wpinv_is_ajax_disabled', $retval ); |
|
| 671 | + return apply_filters('wpinv_is_ajax_disabled', $retval); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | -function wpinv_get_current_page_url( $nocache = false ) { |
|
| 674 | +function wpinv_get_current_page_url($nocache = false) { |
|
| 675 | 675 | global $wp; |
| 676 | 676 | |
| 677 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 678 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
| 677 | + if (get_option('permalink_structure')) { |
|
| 678 | + $base = trailingslashit(home_url($wp->request)); |
|
| 679 | 679 | } else { |
| 680 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
| 681 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
| 680 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
| 681 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | $scheme = is_ssl() ? 'https' : 'http'; |
| 685 | - $uri = set_url_scheme( $base, $scheme ); |
|
| 685 | + $uri = set_url_scheme($base, $scheme); |
|
| 686 | 686 | |
| 687 | - if ( is_front_page() ) { |
|
| 688 | - $uri = home_url( '/' ); |
|
| 689 | - } elseif ( wpinv_is_checkout( array(), false ) ) { |
|
| 687 | + if (is_front_page()) { |
|
| 688 | + $uri = home_url('/'); |
|
| 689 | + } elseif (wpinv_is_checkout(array(), false)) { |
|
| 690 | 690 | $uri = wpinv_get_checkout_uri(); |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - $uri = apply_filters( 'wpinv_get_current_page_url', $uri ); |
|
| 693 | + $uri = apply_filters('wpinv_get_current_page_url', $uri); |
|
| 694 | 694 | |
| 695 | - if ( $nocache ) { |
|
| 696 | - $uri = wpinv_add_cache_busting( $uri ); |
|
| 695 | + if ($nocache) { |
|
| 696 | + $uri = wpinv_add_cache_busting($uri); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | return $uri; |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | function wpinv_get_php_arg_separator_output() { |
| 703 | - return ini_get( 'arg_separator.output' ); |
|
| 703 | + return ini_get('arg_separator.output'); |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | -function wpinv_rgb_from_hex( $color ) { |
|
| 707 | - $color = str_replace( '#', '', $color ); |
|
| 706 | +function wpinv_rgb_from_hex($color) { |
|
| 707 | + $color = str_replace('#', '', $color); |
|
| 708 | 708 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
| 709 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
| 709 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
| 710 | 710 | |
| 711 | 711 | $rgb = array(); |
| 712 | - $rgb['R'] = hexdec( $color{0}.$color{1} ); |
|
| 713 | - $rgb['G'] = hexdec( $color{2}.$color{3} ); |
|
| 714 | - $rgb['B'] = hexdec( $color{4}.$color{5} ); |
|
| 712 | + $rgb['R'] = hexdec($color{0} . $color{1} ); |
|
| 713 | + $rgb['G'] = hexdec($color{2} . $color{3} ); |
|
| 714 | + $rgb['B'] = hexdec($color{4} . $color{5} ); |
|
| 715 | 715 | |
| 716 | 716 | return $rgb; |
| 717 | 717 | } |
| 718 | 718 | |
| 719 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
| 720 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 719 | +function wpinv_hex_darker($color, $factor = 30) { |
|
| 720 | + $base = wpinv_rgb_from_hex($color); |
|
| 721 | 721 | $color = '#'; |
| 722 | 722 | |
| 723 | - foreach ( $base as $k => $v ) { |
|
| 723 | + foreach ($base as $k => $v) { |
|
| 724 | 724 | $amount = $v / 100; |
| 725 | - $amount = round( $amount * $factor ); |
|
| 725 | + $amount = round($amount * $factor); |
|
| 726 | 726 | $new_decimal = $v - $amount; |
| 727 | 727 | |
| 728 | - $new_hex_component = dechex( $new_decimal ); |
|
| 729 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 728 | + $new_hex_component = dechex($new_decimal); |
|
| 729 | + if (strlen($new_hex_component) < 2) { |
|
| 730 | 730 | $new_hex_component = "0" . $new_hex_component; |
| 731 | 731 | } |
| 732 | 732 | $color .= $new_hex_component; |
@@ -735,18 +735,18 @@ discard block |
||
| 735 | 735 | return $color; |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
| 739 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 738 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
| 739 | + $base = wpinv_rgb_from_hex($color); |
|
| 740 | 740 | $color = '#'; |
| 741 | 741 | |
| 742 | - foreach ( $base as $k => $v ) { |
|
| 742 | + foreach ($base as $k => $v) { |
|
| 743 | 743 | $amount = 255 - $v; |
| 744 | 744 | $amount = $amount / 100; |
| 745 | - $amount = round( $amount * $factor ); |
|
| 745 | + $amount = round($amount * $factor); |
|
| 746 | 746 | $new_decimal = $v + $amount; |
| 747 | 747 | |
| 748 | - $new_hex_component = dechex( $new_decimal ); |
|
| 749 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 748 | + $new_hex_component = dechex($new_decimal); |
|
| 749 | + if (strlen($new_hex_component) < 2) { |
|
| 750 | 750 | $new_hex_component = "0" . $new_hex_component; |
| 751 | 751 | } |
| 752 | 752 | $color .= $new_hex_component; |
@@ -755,22 +755,22 @@ discard block |
||
| 755 | 755 | return $color; |
| 756 | 756 | } |
| 757 | 757 | |
| 758 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
| 759 | - $hex = str_replace( '#', '', $color ); |
|
| 758 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
| 759 | + $hex = str_replace('#', '', $color); |
|
| 760 | 760 | |
| 761 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
| 762 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
| 763 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
| 761 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
| 762 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
| 763 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
| 764 | 764 | |
| 765 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
| 765 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
| 766 | 766 | |
| 767 | 767 | return $brightness > 155 ? $dark : $light; |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | -function wpinv_format_hex( $hex ) { |
|
| 771 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
| 770 | +function wpinv_format_hex($hex) { |
|
| 771 | + $hex = trim(str_replace('#', '', $hex)); |
|
| 772 | 772 | |
| 773 | - if ( strlen( $hex ) == 3 ) { |
|
| 773 | + if (strlen($hex) == 3) { |
|
| 774 | 774 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
| 775 | 775 | } |
| 776 | 776 | |
@@ -790,12 +790,12 @@ discard block |
||
| 790 | 790 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 791 | 791 | * @return string |
| 792 | 792 | */ |
| 793 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
| 794 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 795 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
| 793 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
| 794 | + if (function_exists('mb_strimwidth')) { |
|
| 795 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
| 798 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | /** |
@@ -807,28 +807,28 @@ discard block |
||
| 807 | 807 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 808 | 808 | * @return int Returns the number of characters in string. |
| 809 | 809 | */ |
| 810 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
| 811 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 812 | - return mb_strlen( $str, $encoding ); |
|
| 810 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
| 811 | + if (function_exists('mb_strlen')) { |
|
| 812 | + return mb_strlen($str, $encoding); |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - return strlen( $str ); |
|
| 815 | + return strlen($str); |
|
| 816 | 816 | } |
| 817 | 817 | |
| 818 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
| 819 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
| 820 | - return mb_strtolower( $str, $encoding ); |
|
| 818 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
| 819 | + if (function_exists('mb_strtolower')) { |
|
| 820 | + return mb_strtolower($str, $encoding); |
|
| 821 | 821 | } |
| 822 | 822 | |
| 823 | - return strtolower( $str ); |
|
| 823 | + return strtolower($str); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
| 827 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
| 828 | - return mb_strtoupper( $str, $encoding ); |
|
| 826 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
| 827 | + if (function_exists('mb_strtoupper')) { |
|
| 828 | + return mb_strtoupper($str, $encoding); |
|
| 829 | 829 | } |
| 830 | 830 | |
| 831 | - return strtoupper( $str ); |
|
| 831 | + return strtoupper($str); |
|
| 832 | 832 | } |
| 833 | 833 | |
| 834 | 834 | /** |
@@ -842,12 +842,12 @@ discard block |
||
| 842 | 842 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 843 | 843 | * @return int Returns the position of the first occurrence of search in the string. |
| 844 | 844 | */ |
| 845 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 846 | - if ( function_exists( 'mb_strpos' ) ) { |
|
| 847 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
| 845 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 846 | + if (function_exists('mb_strpos')) { |
|
| 847 | + return mb_strpos($str, $find, $offset, $encoding); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | - return strpos( $str, $find, $offset ); |
|
| 850 | + return strpos($str, $find, $offset); |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | /** |
@@ -861,12 +861,12 @@ discard block |
||
| 861 | 861 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 862 | 862 | * @return int Returns the position of the last occurrence of search. |
| 863 | 863 | */ |
| 864 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 865 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
| 866 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
| 864 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 865 | + if (function_exists('mb_strrpos')) { |
|
| 866 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
| 867 | 867 | } |
| 868 | 868 | |
| 869 | - return strrpos( $str, $find, $offset ); |
|
| 869 | + return strrpos($str, $find, $offset); |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | /** |
@@ -881,16 +881,16 @@ discard block |
||
| 881 | 881 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 882 | 882 | * @return string |
| 883 | 883 | */ |
| 884 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
| 885 | - if ( function_exists( 'mb_substr' ) ) { |
|
| 886 | - if ( $length === null ) { |
|
| 887 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 884 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
| 885 | + if (function_exists('mb_substr')) { |
|
| 886 | + if ($length === null) { |
|
| 887 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 888 | 888 | } else { |
| 889 | - return mb_substr( $str, $start, $length, $encoding ); |
|
| 889 | + return mb_substr($str, $start, $length, $encoding); |
|
| 890 | 890 | } |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - return substr( $str, $start, $length ); |
|
| 893 | + return substr($str, $start, $length); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | /** |
@@ -902,48 +902,48 @@ discard block |
||
| 902 | 902 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 903 | 903 | * @return string The width of string. |
| 904 | 904 | */ |
| 905 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
| 906 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
| 907 | - return mb_strwidth( $str, $encoding ); |
|
| 905 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
| 906 | + if (function_exists('mb_strwidth')) { |
|
| 907 | + return mb_strwidth($str, $encoding); |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
| 910 | + return wpinv_utf8_strlen($str, $encoding); |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
| 914 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 915 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
| 913 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
| 914 | + if (function_exists('mb_strlen')) { |
|
| 915 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
| 916 | 916 | $str_end = ""; |
| 917 | 917 | |
| 918 | - if ( $lower_str_end ) { |
|
| 919 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
| 918 | + if ($lower_str_end) { |
|
| 919 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
| 920 | 920 | } else { |
| 921 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 921 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 922 | 922 | } |
| 923 | 923 | |
| 924 | 924 | return $first_letter . $str_end; |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | - return ucfirst( $str ); |
|
| 927 | + return ucfirst($str); |
|
| 928 | 928 | } |
| 929 | 929 | |
| 930 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
| 931 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
| 932 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
| 930 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
| 931 | + if (function_exists('mb_convert_case')) { |
|
| 932 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | - return ucwords( $str ); |
|
| 935 | + return ucwords($str); |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | -function wpinv_period_in_days( $period, $unit ) { |
|
| 939 | - $period = absint( $period ); |
|
| 938 | +function wpinv_period_in_days($period, $unit) { |
|
| 939 | + $period = absint($period); |
|
| 940 | 940 | |
| 941 | - if ( $period > 0 ) { |
|
| 942 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
| 941 | + if ($period > 0) { |
|
| 942 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
| 943 | 943 | $period = $period * 7; |
| 944 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
| 944 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
| 945 | 945 | $period = $period * 30; |
| 946 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
| 946 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
| 947 | 947 | $period = $period * 365; |
| 948 | 948 | } |
| 949 | 949 | } |
@@ -951,14 +951,14 @@ discard block |
||
| 951 | 951 | return $period; |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
| 955 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
| 956 | - return cal_days_in_month( $calendar, $month, $year ); |
|
| 954 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
| 955 | + if (function_exists('cal_days_in_month')) { |
|
| 956 | + return cal_days_in_month($calendar, $month, $year); |
|
| 957 | 957 | } |
| 958 | 958 | |
| 959 | 959 | // Fallback in case the calendar extension is not loaded in PHP |
| 960 | 960 | // Only supports Gregorian calendar |
| 961 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
| 961 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | /** |
@@ -969,11 +969,11 @@ discard block |
||
| 969 | 969 | * |
| 970 | 970 | * @return string |
| 971 | 971 | */ |
| 972 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
| 973 | - if ( $allow_html ) { |
|
| 974 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
| 972 | +function wpi_help_tip($tip, $allow_html = false) { |
|
| 973 | + if ($allow_html) { |
|
| 974 | + $tip = wpi_sanitize_tooltip($tip); |
|
| 975 | 975 | } else { |
| 976 | - $tip = esc_attr( $tip ); |
|
| 976 | + $tip = esc_attr($tip); |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -987,8 +987,8 @@ discard block |
||
| 987 | 987 | * @param string $var |
| 988 | 988 | * @return string |
| 989 | 989 | */ |
| 990 | -function wpi_sanitize_tooltip( $var ) { |
|
| 991 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 990 | +function wpi_sanitize_tooltip($var) { |
|
| 991 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
| 992 | 992 | 'br' => array(), |
| 993 | 993 | 'em' => array(), |
| 994 | 994 | 'strong' => array(), |
@@ -998,7 +998,7 @@ discard block |
||
| 998 | 998 | 'li' => array(), |
| 999 | 999 | 'ol' => array(), |
| 1000 | 1000 | 'p' => array(), |
| 1001 | - ) ) ); |
|
| 1001 | + ))); |
|
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | /** |
@@ -1008,7 +1008,7 @@ discard block |
||
| 1008 | 1008 | */ |
| 1009 | 1009 | function wpinv_get_screen_ids() { |
| 1010 | 1010 | |
| 1011 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
| 1011 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
| 1012 | 1012 | |
| 1013 | 1013 | $screen_ids = array( |
| 1014 | 1014 | 'toplevel_page_' . $screen_id, |
@@ -1026,5 +1026,5 @@ discard block |
||
| 1026 | 1026 | 'invoicing_page_wpi-addons', |
| 1027 | 1027 | ); |
| 1028 | 1028 | |
| 1029 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
| 1029 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
| 1030 | 1030 | } |
| 1031 | 1031 | \ No newline at end of file |