@@ -1,66 +1,66 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -function wpinv_get_option( $key = '', $default = false ) { |
|
| 7 | +function wpinv_get_option($key = '', $default = false) { |
|
| 8 | 8 | global $wpinv_options; |
| 9 | 9 | |
| 10 | - $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default; |
|
| 11 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
| 10 | + $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default; |
|
| 11 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
| 12 | 12 | |
| 13 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
| 13 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -function wpinv_update_option( $key = '', $value = false ) { |
|
| 16 | +function wpinv_update_option($key = '', $value = false) { |
|
| 17 | 17 | // If no key, exit |
| 18 | - if ( empty( $key ) ) { |
|
| 18 | + if (empty($key)) { |
|
| 19 | 19 | return false; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - if ( empty( $value ) ) { |
|
| 23 | - $remove_option = wpinv_delete_option( $key ); |
|
| 22 | + if (empty($value)) { |
|
| 23 | + $remove_option = wpinv_delete_option($key); |
|
| 24 | 24 | return $remove_option; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | // First let's grab the current settings |
| 28 | - $options = get_option( 'wpinv_settings' ); |
|
| 28 | + $options = get_option('wpinv_settings'); |
|
| 29 | 29 | |
| 30 | 30 | // Let other plugin alter the value |
| 31 | - $value = apply_filters( 'wpinv_update_option', $value, $key ); |
|
| 31 | + $value = apply_filters('wpinv_update_option', $value, $key); |
|
| 32 | 32 | |
| 33 | 33 | // Next let's try to update the value |
| 34 | - $options[ $key ] = $value; |
|
| 35 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
| 34 | + $options[$key] = $value; |
|
| 35 | + $did_update = update_option('wpinv_settings', $options); |
|
| 36 | 36 | |
| 37 | 37 | // If it's updated, let's update the global variable |
| 38 | - if ( $did_update ) { |
|
| 38 | + if ($did_update) { |
|
| 39 | 39 | global $wpinv_options; |
| 40 | - $wpinv_options[ $key ] = $value; |
|
| 40 | + $wpinv_options[$key] = $value; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | return $did_update; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | -function wpinv_delete_option( $key = '' ) { |
|
| 46 | +function wpinv_delete_option($key = '') { |
|
| 47 | 47 | // If no key, exit |
| 48 | - if ( empty( $key ) ) { |
|
| 48 | + if (empty($key)) { |
|
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // First let's grab the current settings |
| 53 | - $options = get_option( 'wpinv_settings' ); |
|
| 53 | + $options = get_option('wpinv_settings'); |
|
| 54 | 54 | |
| 55 | 55 | // Next let's try to update the value |
| 56 | - if( isset( $options[ $key ] ) ) { |
|
| 57 | - unset( $options[ $key ] ); |
|
| 56 | + if (isset($options[$key])) { |
|
| 57 | + unset($options[$key]); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
| 60 | + $did_update = update_option('wpinv_settings', $options); |
|
| 61 | 61 | |
| 62 | 62 | // If it updated, let's update the global variable |
| 63 | - if ( $did_update ){ |
|
| 63 | + if ($did_update) { |
|
| 64 | 64 | global $wpinv_options; |
| 65 | 65 | $wpinv_options = $options; |
| 66 | 66 | } |
@@ -69,37 +69,37 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | function wpinv_get_settings() { |
| 72 | - $settings = get_option( 'wpinv_settings' ); |
|
| 72 | + $settings = get_option('wpinv_settings'); |
|
| 73 | 73 | |
| 74 | - if ( empty( $settings ) ) { |
|
| 74 | + if (empty($settings)) { |
|
| 75 | 75 | // Update old settings with new single option |
| 76 | - $general_settings = is_array( get_option( 'wpinv_settings_general' ) ) ? get_option( 'wpinv_settings_general' ) : array(); |
|
| 77 | - $gateways_settings = is_array( get_option( 'wpinv_settings_gateways' ) ) ? get_option( 'wpinv_settings_gateways' ) : array(); |
|
| 78 | - $email_settings = is_array( get_option( 'wpinv_settings_emails' ) ) ? get_option( 'wpinv_settings_emails' ) : array(); |
|
| 79 | - $tax_settings = is_array( get_option( 'wpinv_settings_taxes' ) ) ? get_option( 'wpinv_settings_taxes' ) : array(); |
|
| 80 | - $misc_settings = is_array( get_option( 'wpinv_settings_misc' ) ) ? get_option( 'wpinv_settings_misc' ) : array(); |
|
| 81 | - $tool_settings = is_array( get_option( 'wpinv_settings_tools' ) ) ? get_option( 'wpinv_settings_tools' ) : array(); |
|
| 76 | + $general_settings = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array(); |
|
| 77 | + $gateways_settings = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array(); |
|
| 78 | + $email_settings = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array(); |
|
| 79 | + $tax_settings = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array(); |
|
| 80 | + $misc_settings = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array(); |
|
| 81 | + $tool_settings = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array(); |
|
| 82 | 82 | |
| 83 | - $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings ); |
|
| 83 | + $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings); |
|
| 84 | 84 | |
| 85 | - update_option( 'wpinv_settings', $settings ); |
|
| 85 | + update_option('wpinv_settings', $settings); |
|
| 86 | 86 | |
| 87 | 87 | } |
| 88 | - return apply_filters( 'wpinv_get_settings', $settings ); |
|
| 88 | + return apply_filters('wpinv_get_settings', $settings); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | function wpinv_register_settings() { |
| 92 | - if ( false == get_option( 'wpinv_settings' ) ) { |
|
| 93 | - add_option( 'wpinv_settings' ); |
|
| 92 | + if (false == get_option('wpinv_settings')) { |
|
| 93 | + add_option('wpinv_settings'); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $register_settings = wpinv_get_registered_settings(); |
| 97 | 97 | |
| 98 | - foreach ( $register_settings as $tab => $sections ) { |
|
| 99 | - foreach ( $sections as $section => $settings) { |
|
| 98 | + foreach ($register_settings as $tab => $sections) { |
|
| 99 | + foreach ($sections as $section => $settings) { |
|
| 100 | 100 | // Check for backwards compatibility |
| 101 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
| 102 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
| 101 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
| 102 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
| 103 | 103 | $section = 'main'; |
| 104 | 104 | $settings = $sections; |
| 105 | 105 | } |
@@ -111,42 +111,42 @@ discard block |
||
| 111 | 111 | 'wpinv_settings_' . $tab . '_' . $section |
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | - foreach ( $settings as $option ) { |
|
| 114 | + foreach ($settings as $option) { |
|
| 115 | 115 | // For backwards compatibility |
| 116 | - if ( empty( $option['id'] ) ) { |
|
| 116 | + if (empty($option['id'])) { |
|
| 117 | 117 | continue; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
| 120 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
| 121 | 121 | |
| 122 | 122 | add_settings_field( |
| 123 | 123 | 'wpinv_settings[' . $option['id'] . ']', |
| 124 | 124 | $name, |
| 125 | - function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
| 125 | + function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
| 126 | 126 | 'wpinv_settings_' . $tab . '_' . $section, |
| 127 | 127 | 'wpinv_settings_' . $tab . '_' . $section, |
| 128 | 128 | array( |
| 129 | 129 | 'section' => $section, |
| 130 | - 'id' => isset( $option['id'] ) ? $option['id'] : null, |
|
| 131 | - 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '', |
|
| 132 | - 'name' => isset( $option['name'] ) ? $option['name'] : null, |
|
| 133 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
| 134 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
| 135 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
| 136 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
| 137 | - 'min' => isset( $option['min'] ) ? $option['min'] : null, |
|
| 138 | - 'max' => isset( $option['max'] ) ? $option['max'] : null, |
|
| 139 | - 'step' => isset( $option['step'] ) ? $option['step'] : null, |
|
| 140 | - 'chosen' => isset( $option['chosen'] ) ? $option['chosen'] : null, |
|
| 141 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
| 142 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
| 143 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
| 144 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
| 145 | - 'onchange' => !empty( $option['onchange'] ) ? $option['onchange'] : '', |
|
| 146 | - 'custom' => !empty( $option['custom'] ) ? $option['custom'] : '', |
|
| 147 | - 'class' => !empty( $option['class'] ) ? $option['class'] : '', |
|
| 148 | - 'cols' => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
| 149 | - 'rows' => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
| 130 | + 'id' => isset($option['id']) ? $option['id'] : null, |
|
| 131 | + 'desc' => !empty($option['desc']) ? $option['desc'] : '', |
|
| 132 | + 'name' => isset($option['name']) ? $option['name'] : null, |
|
| 133 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
| 134 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
| 135 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
| 136 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
| 137 | + 'min' => isset($option['min']) ? $option['min'] : null, |
|
| 138 | + 'max' => isset($option['max']) ? $option['max'] : null, |
|
| 139 | + 'step' => isset($option['step']) ? $option['step'] : null, |
|
| 140 | + 'chosen' => isset($option['chosen']) ? $option['chosen'] : null, |
|
| 141 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
| 142 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
| 143 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
| 144 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
| 145 | + 'onchange' => !empty($option['onchange']) ? $option['onchange'] : '', |
|
| 146 | + 'custom' => !empty($option['custom']) ? $option['custom'] : '', |
|
| 147 | + 'class' => !empty($option['class']) ? $option['class'] : '', |
|
| 148 | + 'cols' => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
| 149 | + 'rows' => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
| 150 | 150 | ) |
| 151 | 151 | ); |
| 152 | 152 | } |
@@ -154,21 +154,21 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // Creates our settings in the options table |
| 157 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
| 157 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
| 158 | 158 | } |
| 159 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
| 159 | +add_action('admin_init', 'wpinv_register_settings'); |
|
| 160 | 160 | |
| 161 | 161 | function wpinv_get_registered_settings() { |
| 162 | - $pages = wpinv_get_pages( true ); |
|
| 162 | + $pages = wpinv_get_pages(true); |
|
| 163 | 163 | |
| 164 | 164 | $due_payment_options = array(); |
| 165 | - $due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
| 166 | - for ( $i = 1; $i <= 30; $i++ ) { |
|
| 165 | + $due_payment_options[0] = __('Now', 'invoicing'); |
|
| 166 | + for ($i = 1; $i <= 30; $i++) { |
|
| 167 | 167 | $due_payment_options[$i] = $i; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $invoice_number_padd_options = array(); |
| 171 | - for ( $i = 0; $i <= 20; $i++ ) { |
|
| 171 | + for ($i = 0; $i <= 20; $i++) { |
|
| 172 | 172 | $invoice_number_padd_options[$i] = $i; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -177,141 +177,141 @@ discard block |
||
| 177 | 177 | $alert_wrapper_start = '<p style="color: #F00">'; |
| 178 | 178 | $alert_wrapper_close = '</p>'; |
| 179 | 179 | $wpinv_settings = array( |
| 180 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
| 180 | + 'general' => apply_filters('wpinv_settings_general', |
|
| 181 | 181 | array( |
| 182 | 182 | 'main' => array( |
| 183 | 183 | 'location_settings' => array( |
| 184 | 184 | 'id' => 'location_settings', |
| 185 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
| 185 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
| 186 | 186 | 'desc' => '', |
| 187 | 187 | 'type' => 'header', |
| 188 | 188 | ), |
| 189 | 189 | 'default_country' => array( |
| 190 | 190 | 'id' => 'default_country', |
| 191 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
| 192 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
| 191 | + 'name' => __('Default Country', 'invoicing'), |
|
| 192 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
| 193 | 193 | 'type' => 'select', |
| 194 | 194 | 'options' => wpinv_get_country_list(), |
| 195 | 195 | 'std' => 'GB', |
| 196 | 196 | 'chosen' => true, |
| 197 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
| 197 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
| 198 | 198 | ), |
| 199 | 199 | 'default_state' => array( |
| 200 | 200 | 'id' => 'default_state', |
| 201 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
| 202 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
| 201 | + 'name' => __('Default State / Province', 'invoicing'), |
|
| 202 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
| 203 | 203 | 'type' => 'country_states', |
| 204 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
| 204 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
| 205 | 205 | ), |
| 206 | 206 | 'store_name' => array( |
| 207 | 207 | 'id' => 'store_name', |
| 208 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
| 209 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
| 208 | + 'name' => __('Store Name', 'invoicing'), |
|
| 209 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
| 210 | 210 | 'std' => get_option('blogname'), |
| 211 | 211 | 'type' => 'text', |
| 212 | 212 | ), |
| 213 | 213 | 'logo' => array( |
| 214 | 214 | 'id' => 'logo', |
| 215 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
| 216 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
| 215 | + 'name' => __('Logo URL', 'invoicing'), |
|
| 216 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
| 217 | 217 | 'type' => 'text', |
| 218 | 218 | ), |
| 219 | 219 | 'store_address' => array( |
| 220 | 220 | 'id' => 'store_address', |
| 221 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
| 222 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
| 221 | + 'name' => __('Store Address', 'invoicing'), |
|
| 222 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
| 223 | 223 | 'type' => 'textarea', |
| 224 | 224 | ), |
| 225 | 225 | 'page_settings' => array( |
| 226 | 226 | 'id' => 'page_settings', |
| 227 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
| 227 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
| 228 | 228 | 'desc' => '', |
| 229 | 229 | 'type' => 'header', |
| 230 | 230 | ), |
| 231 | 231 | 'checkout_page' => array( |
| 232 | 232 | 'id' => 'checkout_page', |
| 233 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
| 234 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
| 233 | + 'name' => __('Checkout Page', 'invoicing'), |
|
| 234 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
| 235 | 235 | 'type' => 'select', |
| 236 | 236 | 'options' => $pages, |
| 237 | 237 | 'chosen' => true, |
| 238 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 238 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 239 | 239 | ), |
| 240 | 240 | 'success_page' => array( |
| 241 | 241 | 'id' => 'success_page', |
| 242 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
| 243 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
| 242 | + 'name' => __('Success Page', 'invoicing'), |
|
| 243 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
| 244 | 244 | 'type' => 'select', |
| 245 | 245 | 'options' => $pages, |
| 246 | 246 | 'chosen' => true, |
| 247 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 247 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 248 | 248 | ), |
| 249 | 249 | 'failure_page' => array( |
| 250 | 250 | 'id' => 'failure_page', |
| 251 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
| 252 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing' ), |
|
| 251 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
| 252 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing'), |
|
| 253 | 253 | 'type' => 'select', |
| 254 | 254 | 'options' => $pages, |
| 255 | 255 | 'chosen' => true, |
| 256 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 256 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 257 | 257 | ), |
| 258 | 258 | 'invoice_history_page' => array( |
| 259 | 259 | 'id' => 'invoice_history_page', |
| 260 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
| 261 | - 'desc' => __( 'This page shows an invoice history for the current user', 'invoicing' ), |
|
| 260 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
| 261 | + 'desc' => __('This page shows an invoice history for the current user', 'invoicing'), |
|
| 262 | 262 | 'type' => 'select', |
| 263 | 263 | 'options' => $pages, |
| 264 | 264 | 'chosen' => true, |
| 265 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 265 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 266 | 266 | ) |
| 267 | 267 | ), |
| 268 | 268 | 'currency_section' => array( |
| 269 | 269 | 'currency_settings' => array( |
| 270 | 270 | 'id' => 'currency_settings', |
| 271 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
| 271 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
| 272 | 272 | 'desc' => '', |
| 273 | 273 | 'type' => 'header', |
| 274 | 274 | ), |
| 275 | 275 | 'currency' => array( |
| 276 | 276 | 'id' => 'currency', |
| 277 | - 'name' => __( 'Currency', 'invoicing' ), |
|
| 278 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
| 277 | + 'name' => __('Currency', 'invoicing'), |
|
| 278 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
| 279 | 279 | 'type' => 'select', |
| 280 | 280 | 'options' => wpinv_get_currencies(), |
| 281 | 281 | 'chosen' => true, |
| 282 | 282 | ), |
| 283 | 283 | 'currency_position' => array( |
| 284 | 284 | 'id' => 'currency_position', |
| 285 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
| 286 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
| 285 | + 'name' => __('Currency Position', 'invoicing'), |
|
| 286 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
| 287 | 287 | 'type' => 'select', |
| 288 | 288 | 'options' => array( |
| 289 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
| 290 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
| 291 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
| 292 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
| 289 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
| 290 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
| 291 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
| 292 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
| 293 | 293 | ) |
| 294 | 294 | ), |
| 295 | 295 | 'thousands_separator' => array( |
| 296 | 296 | 'id' => 'thousands_separator', |
| 297 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
| 298 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
| 297 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
| 298 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
| 299 | 299 | 'type' => 'text', |
| 300 | 300 | 'size' => 'small', |
| 301 | 301 | 'std' => ',', |
| 302 | 302 | ), |
| 303 | 303 | 'decimal_separator' => array( |
| 304 | 304 | 'id' => 'decimal_separator', |
| 305 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
| 306 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
| 305 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
| 306 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
| 307 | 307 | 'type' => 'text', |
| 308 | 308 | 'size' => 'small', |
| 309 | 309 | 'std' => '.', |
| 310 | 310 | ), |
| 311 | 311 | 'decimals' => array( |
| 312 | 312 | 'id' => 'decimals', |
| 313 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
| 314 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
| 313 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
| 314 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
| 315 | 315 | 'type' => 'number', |
| 316 | 316 | 'size' => 'small', |
| 317 | 317 | 'std' => '2', |
@@ -323,29 +323,29 @@ discard block |
||
| 323 | 323 | 'labels' => array( |
| 324 | 324 | 'labels' => array( |
| 325 | 325 | 'id' => 'labels_settings', |
| 326 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
| 326 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
| 327 | 327 | 'desc' => '', |
| 328 | 328 | 'type' => 'header', |
| 329 | 329 | ), |
| 330 | 330 | 'vat_name' => array( |
| 331 | 331 | 'id' => 'vat_name', |
| 332 | - 'name' => __( 'VAT Name', 'invoicing' ), |
|
| 333 | - 'desc' => __( 'Enter the VAT name', 'invoicing' ), |
|
| 332 | + 'name' => __('VAT Name', 'invoicing'), |
|
| 333 | + 'desc' => __('Enter the VAT name', 'invoicing'), |
|
| 334 | 334 | 'type' => 'text', |
| 335 | 335 | 'size' => 'regular', |
| 336 | 336 | 'std' => 'VAT' |
| 337 | 337 | ), |
| 338 | 338 | 'vat_invoice_notice_label' => array( |
| 339 | 339 | 'id' => 'vat_invoice_notice_label', |
| 340 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
| 341 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
| 340 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
| 341 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
| 342 | 342 | 'type' => 'text', |
| 343 | 343 | 'size' => 'regular', |
| 344 | 344 | ), |
| 345 | 345 | 'vat_invoice_notice' => array( |
| 346 | 346 | 'id' => 'vat_invoice_notice', |
| 347 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
| 348 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
| 347 | + 'name' => __('Invoice notice', 'invoicing'), |
|
| 348 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
| 349 | 349 | 'type' => 'text', |
| 350 | 350 | 'size' => 'regular', |
| 351 | 351 | ) |
@@ -357,22 +357,22 @@ discard block |
||
| 357 | 357 | 'main' => array( |
| 358 | 358 | 'gateway_settings' => array( |
| 359 | 359 | 'id' => 'api_header', |
| 360 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
| 360 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
| 361 | 361 | 'desc' => '', |
| 362 | 362 | 'type' => 'header', |
| 363 | 363 | ), |
| 364 | 364 | 'gateways' => array( |
| 365 | 365 | 'id' => 'gateways', |
| 366 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
| 367 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
| 366 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
| 367 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
| 368 | 368 | 'type' => 'gateways', |
| 369 | 369 | 'std' => array('manual'=>1), |
| 370 | 370 | 'options' => wpinv_get_payment_gateways(), |
| 371 | 371 | ), |
| 372 | 372 | 'default_gateway' => array( |
| 373 | 373 | 'id' => 'default_gateway', |
| 374 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
| 375 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
| 374 | + 'name' => __('Default Gateway', 'invoicing'), |
|
| 375 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
| 376 | 376 | 'type' => 'gateway_select', |
| 377 | 377 | 'std' => 'manual', |
| 378 | 378 | 'options' => wpinv_get_payment_gateways(), |
@@ -386,19 +386,19 @@ discard block |
||
| 386 | 386 | 'main' => array( |
| 387 | 387 | 'tax_settings' => array( |
| 388 | 388 | 'id' => 'tax_settings', |
| 389 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
| 389 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
| 390 | 390 | 'type' => 'header', |
| 391 | 391 | ), |
| 392 | 392 | 'enable_taxes' => array( |
| 393 | 393 | 'id' => 'enable_taxes', |
| 394 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
| 395 | - 'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ), |
|
| 394 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
| 395 | + 'desc' => __('Check this to enable taxes on invoices.', 'invoicing'), |
|
| 396 | 396 | 'type' => 'checkbox', |
| 397 | 397 | ), |
| 398 | 398 | 'tax_rate' => array( |
| 399 | 399 | 'id' => 'tax_rate', |
| 400 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
| 401 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
| 400 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
| 401 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
| 402 | 402 | 'type' => 'number', |
| 403 | 403 | 'size' => 'small', |
| 404 | 404 | 'min' => '0', |
@@ -410,8 +410,8 @@ discard block |
||
| 410 | 410 | 'rates' => array( |
| 411 | 411 | 'tax_rates' => array( |
| 412 | 412 | 'id' => 'tax_rates', |
| 413 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
| 414 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
| 413 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
| 414 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
| 415 | 415 | 'type' => 'tax_rates', |
| 416 | 416 | ), |
| 417 | 417 | ) |
@@ -423,62 +423,62 @@ discard block |
||
| 423 | 423 | 'main' => array( |
| 424 | 424 | 'email_settings_header' => array( |
| 425 | 425 | 'id' => 'email_settings_header', |
| 426 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
| 426 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
| 427 | 427 | 'type' => 'header', |
| 428 | 428 | ), |
| 429 | 429 | 'email_from_name' => array( |
| 430 | 430 | 'id' => 'email_from_name', |
| 431 | - 'name' => __( 'From Name', 'invoicing' ), |
|
| 432 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
| 433 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
| 431 | + 'name' => __('From Name', 'invoicing'), |
|
| 432 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
| 433 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
| 434 | 434 | 'type' => 'text', |
| 435 | 435 | ), |
| 436 | 436 | 'email_from' => array( |
| 437 | 437 | 'id' => 'email_from', |
| 438 | - 'name' => __( 'From Email', 'invoicing' ), |
|
| 439 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
| 440 | - 'std' => get_option( 'admin_email' ), |
|
| 438 | + 'name' => __('From Email', 'invoicing'), |
|
| 439 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
| 440 | + 'std' => get_option('admin_email'), |
|
| 441 | 441 | 'type' => 'text', |
| 442 | 442 | ), |
| 443 | 443 | 'overdue_settings_header' => array( |
| 444 | 444 | 'id' => 'overdue_settings_header', |
| 445 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
| 445 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
| 446 | 446 | 'type' => 'header', |
| 447 | 447 | ), |
| 448 | 448 | 'overdue_active' => array( |
| 449 | 449 | 'id' => 'overdue_active', |
| 450 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
| 451 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
| 450 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
| 451 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
| 452 | 452 | 'type' => 'checkbox', |
| 453 | 453 | 'std' => false, |
| 454 | 454 | ), |
| 455 | 455 | 'overdue_days' => array( |
| 456 | 456 | 'id' => 'overdue_days', |
| 457 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
| 458 | - 'desc' => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ), |
|
| 457 | + 'name' => __('Default Due Date', 'invoicing'), |
|
| 458 | + 'desc' => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'), |
|
| 459 | 459 | 'type' => 'select', |
| 460 | 460 | 'options' => $due_payment_options, |
| 461 | 461 | 'chosen' => true, |
| 462 | 462 | 'std' => 0, |
| 463 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 463 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 464 | 464 | ), |
| 465 | 465 | 'email_template_header' => array( |
| 466 | 466 | 'id' => 'email_template_header', |
| 467 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
| 467 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
| 468 | 468 | 'type' => 'header', |
| 469 | 469 | ), |
| 470 | 470 | 'email_header_image' => array( |
| 471 | 471 | 'id' => 'email_header_image', |
| 472 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
| 473 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
| 472 | + 'name' => __('Header Image', 'invoicing'), |
|
| 473 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
| 474 | 474 | 'std' => '', |
| 475 | 475 | 'type' => 'text', |
| 476 | 476 | ), |
| 477 | 477 | 'email_footer_text' => array( |
| 478 | 478 | 'id' => 'email_footer_text', |
| 479 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
| 480 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
| 481 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ), |
|
| 479 | + 'name' => __('Footer Text', 'invoicing'), |
|
| 480 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
| 481 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'), |
|
| 482 | 482 | 'type' => 'textarea', |
| 483 | 483 | 'class' => 'regular-text', |
| 484 | 484 | 'rows' => 2, |
@@ -486,29 +486,29 @@ discard block |
||
| 486 | 486 | ), |
| 487 | 487 | 'email_base_color' => array( |
| 488 | 488 | 'id' => 'email_base_color', |
| 489 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
| 490 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
| 489 | + 'name' => __('Base Color', 'invoicing'), |
|
| 490 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
| 491 | 491 | 'std' => '#557da2', |
| 492 | 492 | 'type' => 'color', |
| 493 | 493 | ), |
| 494 | 494 | 'email_background_color' => array( |
| 495 | 495 | 'id' => 'email_background_color', |
| 496 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
| 497 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
| 496 | + 'name' => __('Background Color', 'invoicing'), |
|
| 497 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
| 498 | 498 | 'std' => '#f5f5f5', |
| 499 | 499 | 'type' => 'color', |
| 500 | 500 | ), |
| 501 | 501 | 'email_body_background_color' => array( |
| 502 | 502 | 'id' => 'email_body_background_color', |
| 503 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
| 504 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
| 503 | + 'name' => __('Body Background Color', 'invoicing'), |
|
| 504 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
| 505 | 505 | 'std' => '#fdfdfd', |
| 506 | 506 | 'type' => 'color', |
| 507 | 507 | ), |
| 508 | 508 | 'email_text_color' => array( |
| 509 | 509 | 'id' => 'email_text_color', |
| 510 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
| 511 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
| 510 | + 'name' => __('Body Text Color', 'invoicing'), |
|
| 511 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
| 512 | 512 | 'std' => '#505050', |
| 513 | 513 | 'type' => 'color', |
| 514 | 514 | ), |
@@ -527,73 +527,73 @@ discard block |
||
| 527 | 527 | 'main' => array( |
| 528 | 528 | 'fields_settings' => array( |
| 529 | 529 | 'id' => 'fields_settings', |
| 530 | - 'name' => '<h3>' . __( 'Fields Settings', 'invoicing' ) . '</h3>', |
|
| 531 | - 'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ), |
|
| 530 | + 'name' => '<h3>' . __('Fields Settings', 'invoicing') . '</h3>', |
|
| 531 | + 'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'), |
|
| 532 | 532 | 'type' => 'header', |
| 533 | 533 | ), |
| 534 | 534 | 'fname_mandatory' => array( |
| 535 | 535 | 'id' => 'fname_mandatory', |
| 536 | - 'name' => __( 'First Name', 'invoicing' ), |
|
| 536 | + 'name' => __('First Name', 'invoicing'), |
|
| 537 | 537 | 'type' => 'checkbox', |
| 538 | 538 | 'std' => true, |
| 539 | 539 | ), |
| 540 | 540 | 'lname_mandatory' => array( |
| 541 | 541 | 'id' => 'lname_mandatory', |
| 542 | - 'name' => __( 'Last Name', 'invoicing' ), |
|
| 542 | + 'name' => __('Last Name', 'invoicing'), |
|
| 543 | 543 | 'type' => 'checkbox', |
| 544 | 544 | 'std' => true, |
| 545 | 545 | ), |
| 546 | 546 | 'address_mandatory' => array( |
| 547 | 547 | 'id' => 'address_mandatory', |
| 548 | - 'name' => __( 'Address', 'invoicing' ), |
|
| 548 | + 'name' => __('Address', 'invoicing'), |
|
| 549 | 549 | 'type' => 'checkbox', |
| 550 | 550 | 'std' => true, |
| 551 | 551 | ), |
| 552 | 552 | 'city_mandatory' => array( |
| 553 | 553 | 'id' => 'city_mandatory', |
| 554 | - 'name' => __( 'City', 'invoicing' ), |
|
| 554 | + 'name' => __('City', 'invoicing'), |
|
| 555 | 555 | 'type' => 'checkbox', |
| 556 | 556 | 'std' => true, |
| 557 | 557 | ), |
| 558 | 558 | 'country_mandatory' => array( |
| 559 | 559 | 'id' => 'country_mandatory', |
| 560 | - 'name' => __( 'Country', 'invoicing' ), |
|
| 560 | + 'name' => __('Country', 'invoicing'), |
|
| 561 | 561 | 'type' => 'checkbox', |
| 562 | 562 | 'std' => true, |
| 563 | 563 | ), |
| 564 | 564 | 'state_mandatory' => array( |
| 565 | 565 | 'id' => 'state_mandatory', |
| 566 | - 'name' => __( 'State / Province', 'invoicing' ), |
|
| 566 | + 'name' => __('State / Province', 'invoicing'), |
|
| 567 | 567 | 'type' => 'checkbox', |
| 568 | 568 | 'std' => true, |
| 569 | 569 | ), |
| 570 | 570 | 'zip_mandatory' => array( |
| 571 | 571 | 'id' => 'zip_mandatory', |
| 572 | - 'name' => __( 'ZIP / Postcode', 'invoicing' ), |
|
| 572 | + 'name' => __('ZIP / Postcode', 'invoicing'), |
|
| 573 | 573 | 'type' => 'checkbox', |
| 574 | 574 | 'std' => true, |
| 575 | 575 | ), |
| 576 | 576 | 'phone_mandatory' => array( |
| 577 | 577 | 'id' => 'phone_mandatory', |
| 578 | - 'name' => __( 'Phone Number', 'invoicing' ), |
|
| 578 | + 'name' => __('Phone Number', 'invoicing'), |
|
| 579 | 579 | 'type' => 'checkbox', |
| 580 | 580 | 'std' => true, |
| 581 | 581 | ), |
| 582 | 582 | 'invoice_number_format_settings' => array( |
| 583 | 583 | 'id' => 'invoice_number_format_settings', |
| 584 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
| 584 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
| 585 | 585 | 'type' => 'header', |
| 586 | 586 | ), |
| 587 | 587 | 'sequential_invoice_number' => array( |
| 588 | 588 | 'id' => 'sequential_invoice_number', |
| 589 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
| 590 | - 'desc' => __( 'Check this box to enable sequential invoice numbers.', 'invoicing' ), |
|
| 589 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
| 590 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing'), |
|
| 591 | 591 | 'type' => 'checkbox', |
| 592 | 592 | ), |
| 593 | 593 | 'invoice_sequence_start' => array( |
| 594 | 594 | 'id' => 'invoice_sequence_start', |
| 595 | - 'name' => __( 'Sequential Starting Number', 'easy-digital-downloads' ), |
|
| 596 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ), |
|
| 595 | + 'name' => __('Sequential Starting Number', 'easy-digital-downloads'), |
|
| 596 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing'), |
|
| 597 | 597 | 'type' => 'number', |
| 598 | 598 | 'size' => 'small', |
| 599 | 599 | 'std' => '1', |
@@ -601,8 +601,8 @@ discard block |
||
| 601 | 601 | ), |
| 602 | 602 | 'invoice_number_padd' => array( |
| 603 | 603 | 'id' => 'invoice_number_padd', |
| 604 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
| 605 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
| 604 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
| 605 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
| 606 | 606 | 'type' => 'select', |
| 607 | 607 | 'options' => $invoice_number_padd_options, |
| 608 | 608 | 'std' => 5, |
@@ -610,8 +610,8 @@ discard block |
||
| 610 | 610 | ), |
| 611 | 611 | 'invoice_number_prefix' => array( |
| 612 | 612 | 'id' => 'invoice_number_prefix', |
| 613 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
| 614 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: WPINV-', 'invoicing' ), |
|
| 613 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
| 614 | + 'desc' => __('Prefix for all invoice numbers. Ex: WPINV-', 'invoicing'), |
|
| 615 | 615 | 'type' => 'text', |
| 616 | 616 | 'size' => 'regular', |
| 617 | 617 | 'std' => 'WPINV-', |
@@ -619,44 +619,44 @@ discard block |
||
| 619 | 619 | ), |
| 620 | 620 | 'invoice_number_postfix' => array( |
| 621 | 621 | 'id' => 'invoice_number_postfix', |
| 622 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
| 623 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
| 622 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
| 623 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
| 624 | 624 | 'type' => 'text', |
| 625 | 625 | 'size' => 'regular', |
| 626 | 626 | 'std' => '' |
| 627 | 627 | ), |
| 628 | 628 | 'guest_checkout_settings' => array( |
| 629 | 629 | 'id' => 'guest_checkout_settings', |
| 630 | - 'name' => '<h3>' . __( 'Pay via Invoice Link', 'invoicing' ) . '</h3>', |
|
| 630 | + 'name' => '<h3>' . __('Pay via Invoice Link', 'invoicing') . '</h3>', |
|
| 631 | 631 | 'type' => 'header', |
| 632 | 632 | ), |
| 633 | 633 | 'guest_checkout' => array( |
| 634 | 634 | 'type' => 'radio', |
| 635 | 635 | 'id' => 'guest_checkout', |
| 636 | - 'name' => __( 'Pay via Invoice Link for non logged in user', 'invoicing' ), |
|
| 637 | - 'desc' => __( 'Select how invoice should be paid when non logged in user clicks on the invoice link sent to them via email to pay for invoice.', 'invoicing' ), |
|
| 636 | + 'name' => __('Pay via Invoice Link for non logged in user', 'invoicing'), |
|
| 637 | + 'desc' => __('Select how invoice should be paid when non logged in user clicks on the invoice link sent to them via email to pay for invoice.', 'invoicing'), |
|
| 638 | 638 | 'options' => array( |
| 639 | - 0 => __( 'Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing' ), |
|
| 640 | - 1 => __( 'Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing' ), |
|
| 639 | + 0 => __('Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing'), |
|
| 640 | + 1 => __('Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing'), |
|
| 641 | 641 | ), |
| 642 | 642 | 'std' => 0, |
| 643 | 643 | ), |
| 644 | 644 | 'address_autofill_settings' => array( |
| 645 | 645 | 'id' => 'address_autofill_settings', |
| 646 | - 'name' => '<h3>' . __( 'Google Address Auto Complete', 'invoicing' ) . '</h3>', |
|
| 646 | + 'name' => '<h3>' . __('Google Address Auto Complete', 'invoicing') . '</h3>', |
|
| 647 | 647 | 'type' => 'header', |
| 648 | 648 | ), |
| 649 | 649 | 'address_autofill_active' => array( |
| 650 | 650 | 'id' => 'address_autofill_active', |
| 651 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 652 | - 'desc' => __( 'Enable google address auto complete', 'invoicing' ), |
|
| 651 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 652 | + 'desc' => __('Enable google address auto complete', 'invoicing'), |
|
| 653 | 653 | 'type' => 'checkbox', |
| 654 | 654 | 'std' => 0 |
| 655 | 655 | ), |
| 656 | 656 | 'address_autofill_api' => array( |
| 657 | 657 | 'id' => 'address_autofill_api', |
| 658 | - 'name' => __( 'Google Place API Key', 'invoicing' ), |
|
| 659 | - 'desc' => wp_sprintf(__( 'Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing' ), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>' ), |
|
| 658 | + 'name' => __('Google Place API Key', 'invoicing'), |
|
| 659 | + 'desc' => wp_sprintf(__('Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing'), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>'), |
|
| 660 | 660 | 'type' => 'text', |
| 661 | 661 | 'size' => 'regular', |
| 662 | 662 | 'std' => '' |
@@ -671,8 +671,8 @@ discard block |
||
| 671 | 671 | 'main' => array( |
| 672 | 672 | 'tool_settings' => array( |
| 673 | 673 | 'id' => 'tool_settings', |
| 674 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
| 675 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
| 674 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
| 675 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
| 676 | 676 | 'type' => 'tools', |
| 677 | 677 | ), |
| 678 | 678 | ), |
@@ -680,135 +680,135 @@ discard block |
||
| 680 | 680 | ) |
| 681 | 681 | ); |
| 682 | 682 | |
| 683 | - return apply_filters( 'wpinv_registered_settings', $wpinv_settings ); |
|
| 683 | + return apply_filters('wpinv_registered_settings', $wpinv_settings); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | -function wpinv_settings_sanitize( $input = array() ) { |
|
| 686 | +function wpinv_settings_sanitize($input = array()) { |
|
| 687 | 687 | global $wpinv_options; |
| 688 | 688 | |
| 689 | - if ( empty( $_POST['_wp_http_referer'] ) ) { |
|
| 689 | + if (empty($_POST['_wp_http_referer'])) { |
|
| 690 | 690 | return $input; |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - parse_str( $_POST['_wp_http_referer'], $referrer ); |
|
| 693 | + parse_str($_POST['_wp_http_referer'], $referrer); |
|
| 694 | 694 | |
| 695 | 695 | $settings = wpinv_get_registered_settings(); |
| 696 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
| 697 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
| 696 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
| 697 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
| 698 | 698 | |
| 699 | 699 | $input = $input ? $input : array(); |
| 700 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
| 701 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
| 700 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
| 701 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
| 702 | 702 | |
| 703 | 703 | // Loop through each setting being saved and pass it through a sanitization filter |
| 704 | - foreach ( $input as $key => $value ) { |
|
| 704 | + foreach ($input as $key => $value) { |
|
| 705 | 705 | // Get the setting type (checkbox, select, etc) |
| 706 | - $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false; |
|
| 706 | + $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false; |
|
| 707 | 707 | |
| 708 | - if ( $type ) { |
|
| 708 | + if ($type) { |
|
| 709 | 709 | // Field type specific filter |
| 710 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
| 710 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | // General filter |
| 714 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 714 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | // Loop through the whitelist and unset any that are empty for the tab being saved |
| 718 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
| 719 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
| 718 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
| 719 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
| 720 | 720 | |
| 721 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
| 721 | + $found_settings = array_merge($main_settings, $section_settings); |
|
| 722 | 722 | |
| 723 | - if ( ! empty( $found_settings ) ) { |
|
| 724 | - foreach ( $found_settings as $key => $value ) { |
|
| 723 | + if (!empty($found_settings)) { |
|
| 724 | + foreach ($found_settings as $key => $value) { |
|
| 725 | 725 | |
| 726 | 726 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
| 727 | - if ( is_numeric( $key ) ) { |
|
| 727 | + if (is_numeric($key)) { |
|
| 728 | 728 | $key = $value['id']; |
| 729 | 729 | } |
| 730 | 730 | |
| 731 | - if ( empty( $input[ $key ] ) ) { |
|
| 732 | - unset( $wpinv_options[ $key ] ); |
|
| 731 | + if (empty($input[$key])) { |
|
| 732 | + unset($wpinv_options[$key]); |
|
| 733 | 733 | } |
| 734 | 734 | } |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | // Merge our new settings with the existing |
| 738 | - $output = array_merge( $wpinv_options, $input ); |
|
| 738 | + $output = array_merge($wpinv_options, $input); |
|
| 739 | 739 | |
| 740 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
| 740 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
| 741 | 741 | |
| 742 | 742 | return $output; |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
| 745 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
| 746 | 746 | global $wpinv_options, $wpi_session; |
| 747 | 747 | |
| 748 | - if ( !current_user_can( 'manage_options' ) ) { |
|
| 748 | + if (!current_user_can('manage_options')) { |
|
| 749 | 749 | return $input; |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
| 752 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
| 753 | 753 | // Shows an admin notice about upgrading previous order numbers |
| 754 | - $wpi_session->set( 'upgrade_sequential', '1' ); |
|
| 754 | + $wpi_session->set('upgrade_sequential', '1'); |
|
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | return $input; |
| 758 | 758 | } |
| 759 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
| 759 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
| 760 | 760 | |
| 761 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
| 762 | - if( !current_user_can( 'manage_options' ) ) { |
|
| 761 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
| 762 | + if (!current_user_can('manage_options')) { |
|
| 763 | 763 | return $input; |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
| 766 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
| 767 | 767 | |
| 768 | 768 | $tax_rates = array(); |
| 769 | 769 | |
| 770 | - if ( !empty( $new_rates ) ) { |
|
| 771 | - foreach ( $new_rates as $rate ) { |
|
| 772 | - if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) { |
|
| 770 | + if (!empty($new_rates)) { |
|
| 771 | + foreach ($new_rates as $rate) { |
|
| 772 | + if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) { |
|
| 773 | 773 | continue; |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 ); |
|
| 776 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4); |
|
| 777 | 777 | |
| 778 | 778 | $tax_rates[] = $rate; |
| 779 | 779 | } |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
| 782 | + update_option('wpinv_tax_rates', $tax_rates); |
|
| 783 | 783 | |
| 784 | 784 | return $input; |
| 785 | 785 | } |
| 786 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
| 786 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
| 787 | 787 | |
| 788 | -function wpinv_sanitize_text_field( $input ) { |
|
| 789 | - return trim( $input ); |
|
| 788 | +function wpinv_sanitize_text_field($input) { |
|
| 789 | + return trim($input); |
|
| 790 | 790 | } |
| 791 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
| 791 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
| 792 | 792 | |
| 793 | 793 | function wpinv_get_settings_tabs() { |
| 794 | 794 | $tabs = array(); |
| 795 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
| 796 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
| 797 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
| 798 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 799 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
| 800 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
| 801 | - |
|
| 802 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
| 795 | + $tabs['general'] = __('General', 'invoicing'); |
|
| 796 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
| 797 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
| 798 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
| 799 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
| 800 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
| 801 | + |
|
| 802 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
| 803 | 803 | } |
| 804 | 804 | |
| 805 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
| 805 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
| 806 | 806 | $tabs = false; |
| 807 | 807 | $sections = wpinv_get_registered_settings_sections(); |
| 808 | 808 | |
| 809 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
| 810 | - $tabs = $sections[ $tab ]; |
|
| 811 | - } else if ( $tab ) { |
|
| 809 | + if ($tab && !empty($sections[$tab])) { |
|
| 810 | + $tabs = $sections[$tab]; |
|
| 811 | + } else if ($tab) { |
|
| 812 | 812 | $tabs = false; |
| 813 | 813 | } |
| 814 | 814 | |
@@ -818,135 +818,135 @@ discard block |
||
| 818 | 818 | function wpinv_get_registered_settings_sections() { |
| 819 | 819 | static $sections = false; |
| 820 | 820 | |
| 821 | - if ( false !== $sections ) { |
|
| 821 | + if (false !== $sections) { |
|
| 822 | 822 | return $sections; |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | $sections = array( |
| 826 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
| 827 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
| 828 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
| 829 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
| 830 | - ) ), |
|
| 831 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
| 832 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
| 833 | - ) ), |
|
| 834 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
| 835 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
| 836 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 837 | - ) ), |
|
| 838 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
| 839 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
| 840 | - ) ), |
|
| 841 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
| 842 | - 'main' => __( 'Misc Settings', 'invoicing' ), |
|
| 843 | - ) ), |
|
| 844 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
| 845 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
| 846 | - ) ), |
|
| 826 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
| 827 | + 'main' => __('General Settings', 'invoicing'), |
|
| 828 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
| 829 | + 'labels' => __('Label Texts', 'invoicing'), |
|
| 830 | + )), |
|
| 831 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
| 832 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
| 833 | + )), |
|
| 834 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
| 835 | + 'main' => __('Tax Settings', 'invoicing'), |
|
| 836 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
| 837 | + )), |
|
| 838 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
| 839 | + 'main' => __('Email Settings', 'invoicing'), |
|
| 840 | + )), |
|
| 841 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
| 842 | + 'main' => __('Misc Settings', 'invoicing'), |
|
| 843 | + )), |
|
| 844 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
| 845 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
| 846 | + )), |
|
| 847 | 847 | ); |
| 848 | 848 | |
| 849 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
| 849 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
| 850 | 850 | |
| 851 | 851 | return $sections; |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
| 854 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
| 855 | 855 | $pages_options = array(); |
| 856 | 856 | |
| 857 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 858 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 857 | + if ($default_label !== NULL && $default_label !== false) { |
|
| 858 | + $pages_options = array('' => $default_label); // Blank option |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | $pages = get_pages(); |
| 862 | - if ( $pages ) { |
|
| 863 | - foreach ( $pages as $page ) { |
|
| 862 | + if ($pages) { |
|
| 863 | + foreach ($pages as $page) { |
|
| 864 | 864 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
| 865 | - $pages_options[ $page->ID ] = $title; |
|
| 865 | + $pages_options[$page->ID] = $title; |
|
| 866 | 866 | } |
| 867 | 867 | } |
| 868 | 868 | |
| 869 | 869 | return $pages_options; |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | -function wpinv_header_callback( $args ) { |
|
| 873 | - if ( !empty( $args['desc'] ) ) { |
|
| 872 | +function wpinv_header_callback($args) { |
|
| 873 | + if (!empty($args['desc'])) { |
|
| 874 | 874 | echo $args['desc']; |
| 875 | 875 | } |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | -function wpinv_hidden_callback( $args ) { |
|
| 878 | +function wpinv_hidden_callback($args) { |
|
| 879 | 879 | global $wpinv_options; |
| 880 | 880 | |
| 881 | - if ( isset( $args['set_value'] ) ) { |
|
| 881 | + if (isset($args['set_value'])) { |
|
| 882 | 882 | $value = $args['set_value']; |
| 883 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 884 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 883 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
| 884 | + $value = $wpinv_options[$args['id']]; |
|
| 885 | 885 | } else { |
| 886 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 886 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 887 | 887 | } |
| 888 | 888 | |
| 889 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 889 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 890 | 890 | $args['readonly'] = true; |
| 891 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 891 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 892 | 892 | $name = ''; |
| 893 | 893 | } else { |
| 894 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 894 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 897 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
| 898 | 898 | |
| 899 | 899 | echo $html; |
| 900 | 900 | } |
| 901 | 901 | |
| 902 | -function wpinv_checkbox_callback( $args ) { |
|
| 902 | +function wpinv_checkbox_callback($args) { |
|
| 903 | 903 | global $wpinv_options; |
| 904 | 904 | |
| 905 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 905 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 906 | 906 | |
| 907 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 907 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 908 | 908 | $name = ''; |
| 909 | 909 | } else { |
| 910 | 910 | $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
| 911 | 911 | } |
| 912 | 912 | |
| 913 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 913 | + $checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : ''; |
|
| 914 | 914 | $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
| 915 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 915 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 916 | 916 | |
| 917 | 917 | echo $html; |
| 918 | 918 | } |
| 919 | 919 | |
| 920 | -function wpinv_multicheck_callback( $args ) { |
|
| 920 | +function wpinv_multicheck_callback($args) { |
|
| 921 | 921 | global $wpinv_options; |
| 922 | 922 | |
| 923 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 923 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 924 | 924 | |
| 925 | - if ( ! empty( $args['options'] ) ) { |
|
| 926 | - foreach( $args['options'] as $key => $option ): |
|
| 927 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 928 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 925 | + if (!empty($args['options'])) { |
|
| 926 | + foreach ($args['options'] as $key => $option): |
|
| 927 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 928 | + if (isset($wpinv_options[$args['id']][$sanitize_key])) { |
|
| 929 | 929 | $enabled = $sanitize_key; |
| 930 | 930 | } else { |
| 931 | 931 | $enabled = NULL; |
| 932 | 932 | } |
| 933 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 934 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
| 933 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
| 934 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>'; |
|
| 935 | 935 | endforeach; |
| 936 | 936 | echo '<p class="description">' . $args['desc'] . '</p>'; |
| 937 | 937 | } |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | -function wpinv_payment_icons_callback( $args ) { |
|
| 940 | +function wpinv_payment_icons_callback($args) { |
|
| 941 | 941 | global $wpinv_options; |
| 942 | 942 | |
| 943 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 943 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 944 | 944 | |
| 945 | - if ( ! empty( $args['options'] ) ) { |
|
| 946 | - foreach( $args['options'] as $key => $option ) { |
|
| 947 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 945 | + if (!empty($args['options'])) { |
|
| 946 | + foreach ($args['options'] as $key => $option) { |
|
| 947 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 948 | 948 | |
| 949 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 949 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
| 950 | 950 | $enabled = $option; |
| 951 | 951 | } else { |
| 952 | 952 | $enabled = NULL; |
@@ -954,196 +954,196 @@ discard block |
||
| 954 | 954 | |
| 955 | 955 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
| 956 | 956 | |
| 957 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 957 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
| 958 | 958 | |
| 959 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 960 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 959 | + if (wpinv_string_is_image_url($key)) { |
|
| 960 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 961 | 961 | } else { |
| 962 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 962 | + $card = strtolower(str_replace(' ', '', $option)); |
|
| 963 | 963 | |
| 964 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 965 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 964 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
| 965 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
| 966 | 966 | } else { |
| 967 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 967 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
| 968 | 968 | $content_dir = WP_CONTENT_DIR; |
| 969 | 969 | |
| 970 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 970 | + if (function_exists('wp_normalize_path')) { |
|
| 971 | 971 | // Replaces backslashes with forward slashes for Windows systems |
| 972 | - $image = wp_normalize_path( $image ); |
|
| 973 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 972 | + $image = wp_normalize_path($image); |
|
| 973 | + $content_dir = wp_normalize_path($content_dir); |
|
| 974 | 974 | } |
| 975 | 975 | |
| 976 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 976 | + $image = str_replace($content_dir, content_url(), $image); |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 979 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 980 | 980 | } |
| 981 | 981 | echo $option . '</label>'; |
| 982 | 982 | } |
| 983 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 983 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 984 | 984 | } |
| 985 | 985 | } |
| 986 | 986 | |
| 987 | -function wpinv_radio_callback( $args ) { |
|
| 987 | +function wpinv_radio_callback($args) { |
|
| 988 | 988 | global $wpinv_options; |
| 989 | 989 | |
| 990 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 990 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 991 | 991 | |
| 992 | - foreach ( $args['options'] as $key => $option ) : |
|
| 993 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 992 | + foreach ($args['options'] as $key => $option) : |
|
| 993 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 994 | 994 | |
| 995 | 995 | $checked = false; |
| 996 | 996 | |
| 997 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 997 | + if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key) |
|
| 998 | 998 | $checked = true; |
| 999 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 999 | + elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']])) |
|
| 1000 | 1000 | $checked = true; |
| 1001 | 1001 | |
| 1002 | 1002 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
| 1003 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 1003 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>'; |
|
| 1004 | 1004 | endforeach; |
| 1005 | 1005 | |
| 1006 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 1006 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | -function wpinv_gateways_callback( $args ) { |
|
| 1009 | +function wpinv_gateways_callback($args) { |
|
| 1010 | 1010 | global $wpinv_options; |
| 1011 | 1011 | |
| 1012 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1012 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1013 | 1013 | |
| 1014 | - foreach ( $args['options'] as $key => $option ) : |
|
| 1015 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 1014 | + foreach ($args['options'] as $key => $option) : |
|
| 1015 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 1016 | 1016 | |
| 1017 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
| 1017 | + if (isset($wpinv_options['gateways'][$key])) |
|
| 1018 | 1018 | $enabled = '1'; |
| 1019 | 1019 | else |
| 1020 | 1020 | $enabled = null; |
| 1021 | 1021 | |
| 1022 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 1023 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 1022 | + echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 1023 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
| 1024 | 1024 | endforeach; |
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | 1027 | function wpinv_gateway_select_callback($args) { |
| 1028 | 1028 | global $wpinv_options; |
| 1029 | 1029 | |
| 1030 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1030 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1031 | 1031 | |
| 1032 | 1032 | echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
| 1033 | 1033 | |
| 1034 | - foreach ( $args['options'] as $key => $option ) : |
|
| 1035 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 1036 | - $selected = selected( $key, $args['selected'], false ); |
|
| 1034 | + foreach ($args['options'] as $key => $option) : |
|
| 1035 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
| 1036 | + $selected = selected($key, $args['selected'], false); |
|
| 1037 | 1037 | } else { |
| 1038 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
| 1038 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
| 1039 | 1039 | } |
| 1040 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 1040 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
| 1041 | 1041 | endforeach; |
| 1042 | 1042 | |
| 1043 | 1043 | echo '</select>'; |
| 1044 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1044 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | -function wpinv_text_callback( $args ) { |
|
| 1047 | +function wpinv_text_callback($args) { |
|
| 1048 | 1048 | global $wpinv_options; |
| 1049 | 1049 | |
| 1050 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1050 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1051 | 1051 | |
| 1052 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1053 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1052 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1053 | + $value = $wpinv_options[$args['id']]; |
|
| 1054 | 1054 | } else { |
| 1055 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1055 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1058 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 1059 | 1059 | $args['readonly'] = true; |
| 1060 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1060 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1061 | 1061 | $name = ''; |
| 1062 | 1062 | } else { |
| 1063 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1063 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 1064 | 1064 | } |
| 1065 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 1065 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
| 1066 | 1066 | |
| 1067 | 1067 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
| 1068 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1069 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 1070 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1068 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1069 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
| 1070 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1071 | 1071 | |
| 1072 | 1072 | echo $html; |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | -function wpinv_number_callback( $args ) { |
|
| 1075 | +function wpinv_number_callback($args) { |
|
| 1076 | 1076 | global $wpinv_options; |
| 1077 | 1077 | |
| 1078 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1078 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1079 | 1079 | |
| 1080 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1081 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1080 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1081 | + $value = $wpinv_options[$args['id']]; |
|
| 1082 | 1082 | } else { |
| 1083 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1083 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1086 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 1087 | 1087 | $args['readonly'] = true; |
| 1088 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1088 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1089 | 1089 | $name = ''; |
| 1090 | 1090 | } else { |
| 1091 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1091 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 1095 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 1096 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 1097 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 1094 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
| 1095 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
| 1096 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
| 1097 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
| 1098 | 1098 | |
| 1099 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1100 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1101 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1099 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1100 | + $html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
| 1101 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1102 | 1102 | |
| 1103 | 1103 | echo $html; |
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | -function wpinv_textarea_callback( $args ) { |
|
| 1106 | +function wpinv_textarea_callback($args) { |
|
| 1107 | 1107 | global $wpinv_options; |
| 1108 | 1108 | |
| 1109 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1109 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1110 | 1110 | |
| 1111 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1112 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1111 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1112 | + $value = $wpinv_options[$args['id']]; |
|
| 1113 | 1113 | } else { |
| 1114 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1114 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1118 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
| 1117 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1118 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
| 1119 | 1119 | |
| 1120 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1121 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1120 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 1121 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1122 | 1122 | |
| 1123 | 1123 | echo $html; |
| 1124 | 1124 | } |
| 1125 | 1125 | |
| 1126 | -function wpinv_password_callback( $args ) { |
|
| 1126 | +function wpinv_password_callback($args) { |
|
| 1127 | 1127 | global $wpinv_options; |
| 1128 | 1128 | |
| 1129 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1129 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1130 | 1130 | |
| 1131 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1132 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1131 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1132 | + $value = $wpinv_options[$args['id']]; |
|
| 1133 | 1133 | } else { |
| 1134 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1134 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1138 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 1139 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1137 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1138 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
| 1139 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1140 | 1140 | |
| 1141 | 1141 | echo $html; |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | function wpinv_missing_callback($args) { |
| 1145 | 1145 | printf( |
| 1146 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 1146 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
| 1147 | 1147 | '<strong>' . $args['id'] . '</strong>' |
| 1148 | 1148 | ); |
| 1149 | 1149 | } |
@@ -1151,137 +1151,137 @@ discard block |
||
| 1151 | 1151 | function wpinv_select_callback($args) { |
| 1152 | 1152 | global $wpinv_options; |
| 1153 | 1153 | |
| 1154 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1154 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1155 | 1155 | |
| 1156 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1157 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1156 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1157 | + $value = $wpinv_options[$args['id']]; |
|
| 1158 | 1158 | } else { |
| 1159 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1159 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1160 | 1160 | } |
| 1161 | 1161 | |
| 1162 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 1162 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
| 1163 | 1163 | $value = $args['selected']; |
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1166 | + if (isset($args['placeholder'])) { |
|
| 1167 | 1167 | $placeholder = $args['placeholder']; |
| 1168 | 1168 | } else { |
| 1169 | 1169 | $placeholder = ''; |
| 1170 | 1170 | } |
| 1171 | 1171 | |
| 1172 | - if ( isset( $args['chosen'] ) ) { |
|
| 1172 | + if (isset($args['chosen'])) { |
|
| 1173 | 1173 | $chosen = 'class="wpinv-chosen"'; |
| 1174 | 1174 | } else { |
| 1175 | 1175 | $chosen = ''; |
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | - if( !empty( $args['onchange'] ) ) { |
|
| 1179 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 1178 | + if (!empty($args['onchange'])) { |
|
| 1179 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 1180 | 1180 | } else { |
| 1181 | 1181 | $onchange = ''; |
| 1182 | 1182 | } |
| 1183 | 1183 | |
| 1184 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 1184 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $chosen . 'data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
| 1185 | 1185 | |
| 1186 | - foreach ( $args['options'] as $option => $name ) { |
|
| 1187 | - $selected = selected( $option, $value, false ); |
|
| 1188 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1186 | + foreach ($args['options'] as $option => $name) { |
|
| 1187 | + $selected = selected($option, $value, false); |
|
| 1188 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | 1191 | $html .= '</select>'; |
| 1192 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1192 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1193 | 1193 | |
| 1194 | 1194 | echo $html; |
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | -function wpinv_color_select_callback( $args ) { |
|
| 1197 | +function wpinv_color_select_callback($args) { |
|
| 1198 | 1198 | global $wpinv_options; |
| 1199 | 1199 | |
| 1200 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1200 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1201 | 1201 | |
| 1202 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1203 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1202 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1203 | + $value = $wpinv_options[$args['id']]; |
|
| 1204 | 1204 | } else { |
| 1205 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1205 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 1208 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
| 1209 | 1209 | |
| 1210 | - foreach ( $args['options'] as $option => $color ) { |
|
| 1211 | - $selected = selected( $option, $value, false ); |
|
| 1212 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 1210 | + foreach ($args['options'] as $option => $color) { |
|
| 1211 | + $selected = selected($option, $value, false); |
|
| 1212 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | 1215 | $html .= '</select>'; |
| 1216 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1216 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1217 | 1217 | |
| 1218 | 1218 | echo $html; |
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | -function wpinv_rich_editor_callback( $args ) { |
|
| 1221 | +function wpinv_rich_editor_callback($args) { |
|
| 1222 | 1222 | global $wpinv_options, $wp_version; |
| 1223 | 1223 | |
| 1224 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1224 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1225 | 1225 | |
| 1226 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1227 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1226 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1227 | + $value = $wpinv_options[$args['id']]; |
|
| 1228 | 1228 | |
| 1229 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 1230 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1229 | + if (empty($args['allow_blank']) && empty($value)) { |
|
| 1230 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1231 | 1231 | } |
| 1232 | 1232 | } else { |
| 1233 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1233 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1234 | 1234 | } |
| 1235 | 1235 | |
| 1236 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 1236 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
| 1237 | 1237 | |
| 1238 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 1238 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
| 1239 | 1239 | ob_start(); |
| 1240 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
| 1240 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows))); |
|
| 1241 | 1241 | $html = ob_get_clean(); |
| 1242 | 1242 | } else { |
| 1243 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1243 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1246 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1247 | 1247 | |
| 1248 | 1248 | echo $html; |
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | -function wpinv_upload_callback( $args ) { |
|
| 1251 | +function wpinv_upload_callback($args) { |
|
| 1252 | 1252 | global $wpinv_options; |
| 1253 | 1253 | |
| 1254 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1254 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1255 | 1255 | |
| 1256 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1256 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1257 | 1257 | $value = $wpinv_options[$args['id']]; |
| 1258 | 1258 | } else { |
| 1259 | 1259 | $value = isset($args['std']) ? $args['std'] : ''; |
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1263 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1264 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 1265 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1262 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1263 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
| 1264 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
| 1265 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1266 | 1266 | |
| 1267 | 1267 | echo $html; |
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | -function wpinv_color_callback( $args ) { |
|
| 1270 | +function wpinv_color_callback($args) { |
|
| 1271 | 1271 | global $wpinv_options; |
| 1272 | 1272 | |
| 1273 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1273 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1274 | 1274 | |
| 1275 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1276 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1275 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1276 | + $value = $wpinv_options[$args['id']]; |
|
| 1277 | 1277 | } else { |
| 1278 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1278 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1281 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
| 1282 | 1282 | |
| 1283 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
| 1284 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1283 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
| 1284 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1285 | 1285 | |
| 1286 | 1286 | echo $html; |
| 1287 | 1287 | } |
@@ -1289,9 +1289,9 @@ discard block |
||
| 1289 | 1289 | function wpinv_country_states_callback($args) { |
| 1290 | 1290 | global $wpinv_options; |
| 1291 | 1291 | |
| 1292 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1292 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1293 | 1293 | |
| 1294 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1294 | + if (isset($args['placeholder'])) { |
|
| 1295 | 1295 | $placeholder = $args['placeholder']; |
| 1296 | 1296 | } else { |
| 1297 | 1297 | $placeholder = ''; |
@@ -1299,17 +1299,17 @@ discard block |
||
| 1299 | 1299 | |
| 1300 | 1300 | $states = wpinv_get_country_states(); |
| 1301 | 1301 | |
| 1302 | - $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
| 1303 | - $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1304 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 1302 | + $chosen = ($args['chosen'] ? ' wpinv-chosen' : ''); |
|
| 1303 | + $class = empty($states) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1304 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
| 1305 | 1305 | |
| 1306 | - foreach ( $states as $option => $name ) { |
|
| 1307 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 1308 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1306 | + foreach ($states as $option => $name) { |
|
| 1307 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
| 1308 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
| 1309 | 1309 | } |
| 1310 | 1310 | |
| 1311 | 1311 | $html .= '</select>'; |
| 1312 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1312 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1313 | 1313 | |
| 1314 | 1314 | echo $html; |
| 1315 | 1315 | } |
@@ -1324,25 +1324,25 @@ discard block |
||
| 1324 | 1324 | <table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts"> |
| 1325 | 1325 | <thead> |
| 1326 | 1326 | <tr> |
| 1327 | - <th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
| 1328 | - <th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th> |
|
| 1329 | - <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
| 1330 | - <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
| 1331 | - <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th> |
|
| 1332 | - <th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th> |
|
| 1327 | + <th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th> |
|
| 1328 | + <th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th> |
|
| 1329 | + <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
| 1330 | + <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
| 1331 | + <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th> |
|
| 1332 | + <th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th> |
|
| 1333 | 1333 | </tr> |
| 1334 | 1334 | </thead> |
| 1335 | 1335 | <tbody> |
| 1336 | - <?php if( !empty( $rates ) ) : ?> |
|
| 1337 | - <?php foreach( $rates as $key => $rate ) : ?> |
|
| 1336 | + <?php if (!empty($rates)) : ?> |
|
| 1337 | + <?php foreach ($rates as $key => $rate) : ?> |
|
| 1338 | 1338 | <?php |
| 1339 | - $sanitized_key = wpinv_sanitize_key( $key ); |
|
| 1339 | + $sanitized_key = wpinv_sanitize_key($key); |
|
| 1340 | 1340 | ?> |
| 1341 | 1341 | <tr> |
| 1342 | 1342 | <td class="wpinv_tax_country"> |
| 1343 | 1343 | <?php |
| 1344 | - echo wpinv_html_select( array( |
|
| 1345 | - 'options' => wpinv_get_country_list( true ), |
|
| 1344 | + echo wpinv_html_select(array( |
|
| 1345 | + 'options' => wpinv_get_country_list(true), |
|
| 1346 | 1346 | 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1347 | 1347 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1348 | 1348 | 'selected' => $rate['country'], |
@@ -1350,72 +1350,72 @@ discard block |
||
| 1350 | 1350 | 'show_option_none' => false, |
| 1351 | 1351 | 'class' => 'wpinv-tax-country', |
| 1352 | 1352 | 'chosen' => false, |
| 1353 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1354 | - ) ); |
|
| 1353 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
| 1354 | + )); |
|
| 1355 | 1355 | ?> |
| 1356 | 1356 | </td> |
| 1357 | 1357 | <td class="wpinv_tax_state"> |
| 1358 | 1358 | <?php |
| 1359 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
| 1360 | - if( !empty( $states ) ) { |
|
| 1361 | - echo wpinv_html_select( array( |
|
| 1362 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1359 | + $states = wpinv_get_country_states($rate['country']); |
|
| 1360 | + if (!empty($states)) { |
|
| 1361 | + echo wpinv_html_select(array( |
|
| 1362 | + 'options' => array_merge(array('' => ''), $states), |
|
| 1363 | 1363 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1364 | 1364 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1365 | 1365 | 'selected' => $rate['state'], |
| 1366 | 1366 | 'show_option_all' => false, |
| 1367 | 1367 | 'show_option_none' => false, |
| 1368 | 1368 | 'chosen' => false, |
| 1369 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 1370 | - ) ); |
|
| 1369 | + 'placeholder' => __('Choose a state', 'invoicing') |
|
| 1370 | + )); |
|
| 1371 | 1371 | } else { |
| 1372 | - echo wpinv_html_text( array( |
|
| 1372 | + echo wpinv_html_text(array( |
|
| 1373 | 1373 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
| 1374 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 1374 | + 'value' => !empty($rate['state']) ? $rate['state'] : '', |
|
| 1375 | 1375 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1376 | - ) ); |
|
| 1376 | + )); |
|
| 1377 | 1377 | } |
| 1378 | 1378 | ?> |
| 1379 | 1379 | </td> |
| 1380 | 1380 | <td class="wpinv_tax_global"> |
| 1381 | - <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
|
| 1382 | - <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
| 1381 | + <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/> |
|
| 1382 | + <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
| 1383 | 1383 | </td> |
| 1384 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td> |
|
| 1385 | - <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td> |
|
| 1386 | - <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
| 1384 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td> |
|
| 1385 | + <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td> |
|
| 1386 | + <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
| 1387 | 1387 | </tr> |
| 1388 | 1388 | <?php endforeach; ?> |
| 1389 | 1389 | <?php else : ?> |
| 1390 | 1390 | <tr> |
| 1391 | 1391 | <td class="wpinv_tax_country"> |
| 1392 | 1392 | <?php |
| 1393 | - echo wpinv_html_select( array( |
|
| 1394 | - 'options' => wpinv_get_country_list( true ), |
|
| 1393 | + echo wpinv_html_select(array( |
|
| 1394 | + 'options' => wpinv_get_country_list(true), |
|
| 1395 | 1395 | 'name' => 'tax_rates[0][country]', |
| 1396 | 1396 | 'show_option_all' => false, |
| 1397 | 1397 | 'show_option_none' => false, |
| 1398 | 1398 | 'class' => 'wpinv-tax-country', |
| 1399 | 1399 | 'chosen' => false, |
| 1400 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1401 | - ) ); ?> |
|
| 1400 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
| 1401 | + )); ?> |
|
| 1402 | 1402 | </td> |
| 1403 | 1403 | <td class="wpinv_tax_state"> |
| 1404 | - <?php echo wpinv_html_text( array( |
|
| 1404 | + <?php echo wpinv_html_text(array( |
|
| 1405 | 1405 | 'name' => 'tax_rates[0][state]' |
| 1406 | - ) ); ?> |
|
| 1406 | + )); ?> |
|
| 1407 | 1407 | </td> |
| 1408 | 1408 | <td class="wpinv_tax_global"> |
| 1409 | 1409 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
| 1410 | - <label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
| 1410 | + <label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
| 1411 | 1411 | </td> |
| 1412 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td> |
|
| 1412 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>"/></td> |
|
| 1413 | 1413 | <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td> |
| 1414 | - <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
| 1414 | + <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
| 1415 | 1415 | </tr> |
| 1416 | 1416 | <?php endif; ?> |
| 1417 | 1417 | </tbody> |
| 1418 | - <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
|
| 1418 | + <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot> |
|
| 1419 | 1419 | </table> |
| 1420 | 1420 | <?php |
| 1421 | 1421 | echo ob_get_clean(); |
@@ -1426,44 +1426,44 @@ discard block |
||
| 1426 | 1426 | ob_start(); ?> |
| 1427 | 1427 | </td><tr> |
| 1428 | 1428 | <td colspan="2" class="wpinv_tools_tdbox"> |
| 1429 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 1430 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
| 1429 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 1430 | + <?php do_action('wpinv_tools_before'); ?> |
|
| 1431 | 1431 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
| 1432 | 1432 | <thead> |
| 1433 | 1433 | <tr> |
| 1434 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
| 1435 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
| 1436 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
| 1434 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
| 1435 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
| 1436 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
| 1437 | 1437 | </tr> |
| 1438 | 1438 | </thead> |
| 1439 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
| 1439 | + <?php do_action('wpinv_tools_row'); ?> |
|
| 1440 | 1440 | <tbody> |
| 1441 | 1441 | </tbody> |
| 1442 | 1442 | </table> |
| 1443 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
| 1443 | + <?php do_action('wpinv_tools_after'); ?> |
|
| 1444 | 1444 | <?php |
| 1445 | 1445 | echo ob_get_clean(); |
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | -function wpinv_descriptive_text_callback( $args ) { |
|
| 1449 | - echo wp_kses_post( $args['desc'] ); |
|
| 1448 | +function wpinv_descriptive_text_callback($args) { |
|
| 1449 | + echo wp_kses_post($args['desc']); |
|
| 1450 | 1450 | } |
| 1451 | 1451 | |
| 1452 | -function wpinv_hook_callback( $args ) { |
|
| 1453 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1452 | +function wpinv_hook_callback($args) { |
|
| 1453 | + do_action('wpinv_' . $args['id'], $args); |
|
| 1454 | 1454 | } |
| 1455 | 1455 | |
| 1456 | 1456 | function wpinv_set_settings_cap() { |
| 1457 | 1457 | return 'manage_options'; |
| 1458 | 1458 | } |
| 1459 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
| 1459 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
| 1460 | 1460 | |
| 1461 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
| 1462 | - if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) { |
|
| 1463 | - $value = wpinv_sanitize_amount( $value, 4 ); |
|
| 1461 | +function wpinv_settings_sanitize_input($value, $key) { |
|
| 1462 | + if ($key == 'tax_rate' || $key == 'eu_fallback_rate') { |
|
| 1463 | + $value = wpinv_sanitize_amount($value, 4); |
|
| 1464 | 1464 | $value = $value >= 100 ? 99 : $value; |
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | 1467 | return $value; |
| 1468 | 1468 | } |
| 1469 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
| 1470 | 1469 | \ No newline at end of file |
| 1470 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
| 1471 | 1471 | \ No newline at end of file |
@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | class WPInv_Plugin { |
| 15 | 15 | private static $instance; |
| 16 | 16 | |
| 17 | 17 | public static function run() { |
| 18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) { |
|
| 18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) { |
|
| 19 | 19 | self::$instance = new WPInv_Plugin; |
| 20 | 20 | self::$instance->includes(); |
| 21 | 21 | self::$instance->actions(); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | self::$instance->reports = new WPInv_Reports(); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - do_action( 'wpinv_loaded' ); |
|
| 26 | + do_action('wpinv_loaded'); |
|
| 27 | 27 | |
| 28 | 28 | return self::$instance; |
| 29 | 29 | } |
@@ -33,31 +33,31 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function define_constants() { |
| 36 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
| 37 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
| 36 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
| 37 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | private function actions() { |
| 41 | 41 | /* Internationalize the text strings used. */ |
| 42 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
| 42 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
| 43 | 43 | |
| 44 | 44 | /* Perform actions on admin initialization. */ |
| 45 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
| 46 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
| 47 | - add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) ); |
|
| 48 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
| 45 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
| 46 | + add_action('init', array(&$this, 'init'), 3); |
|
| 47 | + add_action('init', array('WPInv_Shortcodes', 'init')); |
|
| 48 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
| 49 | 49 | |
| 50 | - if ( class_exists( 'BuddyPress' ) ) { |
|
| 51 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
| 50 | + if (class_exists('BuddyPress')) { |
|
| 51 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
| 54 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
| 55 | 55 | |
| 56 | - if ( is_admin() ) { |
|
| 57 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
| 58 | - add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
| 56 | + if (is_admin()) { |
|
| 57 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
| 58 | + add_action('admin_body_class', array(&$this, 'admin_body_class')); |
|
| 59 | 59 | } else { |
| 60 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
| 60 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
| 69 | 69 | */ |
| 70 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
| 70 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
| 71 | 71 | |
| 72 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
| 72 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | public function plugins_loaded() { |
@@ -83,187 +83,187 @@ discard block |
||
| 83 | 83 | * @since 1.0 |
| 84 | 84 | */ |
| 85 | 85 | public function load_textdomain() { |
| 86 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'invoicing' ); |
|
| 86 | + $locale = apply_filters('plugin_locale', get_locale(), 'invoicing'); |
|
| 87 | 87 | |
| 88 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
| 89 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
| 88 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
| 89 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * Define language constants. |
| 93 | 93 | */ |
| 94 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
| 94 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function includes() { |
| 98 | 98 | global $wpinv_options; |
| 99 | 99 | |
| 100 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
| 100 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
| 101 | 101 | $wpinv_options = wpinv_get_settings(); |
| 102 | 102 | |
| 103 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
| 104 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
| 105 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
| 106 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
| 107 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
| 108 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
| 109 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
| 110 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
| 111 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
| 112 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
| 113 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
| 114 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
| 115 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
| 116 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php' ); |
|
| 117 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
| 103 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
| 104 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
| 105 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
| 106 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
| 107 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
| 108 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
| 109 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
| 110 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
| 111 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
| 112 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
| 113 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
| 114 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
| 115 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
| 116 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php'); |
|
| 117 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
| 118 | 118 | //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
| 119 | 119 | //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
| 120 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
| 120 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
| 121 | 121 | //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscription.php' ); |
| 122 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
| 123 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
| 124 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' ); |
|
| 125 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
| 126 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
| 127 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
| 128 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' ); |
|
| 129 | - if ( !class_exists( 'Geodir_EUVat' ) ) { |
|
| 130 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
| 122 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
| 123 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
| 124 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php'); |
|
| 125 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
| 126 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
| 127 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
| 128 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php'); |
|
| 129 | + if (!class_exists('Geodir_EUVat')) { |
|
| 130 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 134 | - if ( !empty( $gateways ) ) { |
|
| 135 | - foreach ( $gateways as $gateway ) { |
|
| 136 | - if ( $gateway == 'manual' ) { |
|
| 133 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
| 134 | + if (!empty($gateways)) { |
|
| 135 | + foreach ($gateways as $gateway) { |
|
| 136 | + if ($gateway == 'manual') { |
|
| 137 | 137 | continue; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
| 141 | 141 | |
| 142 | - if ( file_exists( $gateway_file ) ) { |
|
| 143 | - require_once( $gateway_file ); |
|
| 142 | + if (file_exists($gateway_file)) { |
|
| 143 | + require_once($gateway_file); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
| 147 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
| 148 | 148 | |
| 149 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 150 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
| 151 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
| 152 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
| 149 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
| 150 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
| 151 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
| 152 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
| 153 | 153 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
| 154 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
| 155 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
| 156 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
| 157 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
| 158 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
| 154 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
| 155 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
| 156 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
| 157 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
| 158 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
| 159 | 159 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | // include css inliner |
| 163 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
| 164 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
| 163 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
| 164 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
| 167 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | public function init() { |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | public function admin_init() { |
| 174 | - if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
| 174 | + if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
| 177 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | public function activation_redirect() { |
| 181 | 181 | // Bail if no activation redirect |
| 182 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
| 182 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
| 183 | 183 | return; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | // Delete the redirect transient |
| 187 | - delete_transient( '_wpinv_activation_redirect' ); |
|
| 187 | + delete_transient('_wpinv_activation_redirect'); |
|
| 188 | 188 | |
| 189 | 189 | // Bail if activating from network, or bulk |
| 190 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 190 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 191 | 191 | return; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
| 194 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
| 195 | 195 | exit; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | public function enqueue_scripts() { |
| 199 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 199 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 200 | 200 | |
| 201 | - wp_deregister_style( 'font-awesome' ); |
|
| 202 | - wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
|
| 203 | - wp_enqueue_style( 'font-awesome' ); |
|
| 201 | + wp_deregister_style('font-awesome'); |
|
| 202 | + wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
| 203 | + wp_enqueue_style('font-awesome'); |
|
| 204 | 204 | |
| 205 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
| 206 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
| 205 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
| 206 | + wp_enqueue_style('wpinv_front_style'); |
|
| 207 | 207 | |
| 208 | 208 | // Register scripts |
| 209 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 210 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ), WPINV_VERSION ); |
|
| 209 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 210 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION); |
|
| 211 | 211 | |
| 212 | 212 | $localize = array(); |
| 213 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 214 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 213 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 214 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 215 | 215 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
| 216 | 216 | $localize['currency_pos'] = wpinv_currency_position(); |
| 217 | 217 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 218 | 218 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 219 | 219 | $localize['decimals'] = wpinv_decimals(); |
| 220 | 220 | |
| 221 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
| 221 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
| 222 | 222 | |
| 223 | - wp_enqueue_script( 'jquery-blockui' ); |
|
| 223 | + wp_enqueue_script('jquery-blockui'); |
|
| 224 | 224 | $autofill_api = wpinv_get_option('address_autofill_api'); |
| 225 | 225 | $autofill_active = wpinv_get_option('address_autofill_active'); |
| 226 | 226 | if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
| 227 | 227 | wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
| 228 | 228 | wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery'), '', true); |
| 229 | 229 | } |
| 230 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
| 231 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
| 230 | + wp_enqueue_script('wpinv-front-script'); |
|
| 231 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | public function admin_enqueue_scripts() { |
| 235 | 235 | global $post, $pagenow; |
| 236 | 236 | |
| 237 | 237 | $post_type = wpinv_admin_post_type(); |
| 238 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 238 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 239 | 239 | |
| 240 | - wp_deregister_style( 'font-awesome' ); |
|
| 241 | - wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
|
| 242 | - wp_enqueue_style( 'font-awesome' ); |
|
| 240 | + wp_deregister_style('font-awesome'); |
|
| 241 | + wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
| 242 | + wp_enqueue_style('font-awesome'); |
|
| 243 | 243 | |
| 244 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
| 245 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
| 244 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
| 245 | + wp_enqueue_style('jquery-ui-css'); |
|
| 246 | 246 | |
| 247 | - wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' ); |
|
| 248 | - wp_enqueue_style( 'jquery-chosen' ); |
|
| 247 | + wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2'); |
|
| 248 | + wp_enqueue_style('jquery-chosen'); |
|
| 249 | 249 | |
| 250 | - wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' ); |
|
| 251 | - wp_enqueue_script( 'jquery-chosen' ); |
|
| 250 | + wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2'); |
|
| 251 | + wp_enqueue_script('jquery-chosen'); |
|
| 252 | 252 | |
| 253 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
| 254 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
| 253 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
| 254 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
| 255 | 255 | |
| 256 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
| 257 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
| 256 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
| 257 | + wp_enqueue_style('wpinv_admin_style'); |
|
| 258 | 258 | |
| 259 | - if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
| 260 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 259 | + if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
| 260 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 264 | - wp_enqueue_script( 'wp-color-picker' ); |
|
| 263 | + wp_enqueue_style('wp-color-picker'); |
|
| 264 | + wp_enqueue_script('wp-color-picker'); |
|
| 265 | 265 | |
| 266 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 266 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 267 | 267 | |
| 268 | 268 | if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
| 269 | 269 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -274,17 +274,17 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui' ), WPINV_VERSION ); |
|
| 278 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
| 277 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui'), WPINV_VERSION); |
|
| 278 | + wp_enqueue_script('wpinv-admin-script'); |
|
| 279 | 279 | |
| 280 | 280 | $localize = array(); |
| 281 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 282 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
| 283 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 284 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
| 285 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
| 286 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
| 287 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
| 281 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 282 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
| 283 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 284 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
| 285 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
| 286 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
| 287 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
| 288 | 288 | $localize['tax'] = wpinv_tax_amount(); |
| 289 | 289 | $localize['discount'] = wpinv_discount_amount(); |
| 290 | 290 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -292,65 +292,65 @@ discard block |
||
| 292 | 292 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 293 | 293 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 294 | 294 | $localize['decimals'] = wpinv_decimals(); |
| 295 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
| 296 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
| 297 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
| 298 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
| 299 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
| 300 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
| 301 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
| 302 | - $localize['confirmCalcTotals'] = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ); |
|
| 303 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
| 295 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
| 296 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
| 297 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
| 298 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
| 299 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
| 300 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
| 301 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
| 302 | + $localize['confirmCalcTotals'] = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'); |
|
| 303 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
| 304 | 304 | $localize['hasGD'] = wpinv_gd_active(); |
| 305 | 305 | $localize['hasPM'] = wpinv_pm_active(); |
| 306 | - $localize['emptyInvoice'] = __( 'Add atleast one item to save invoice!', 'invoicing' ); |
|
| 307 | - $localize['deletePackage'] = __( 'GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing' ); |
|
| 308 | - $localize['deletePackages'] = __( 'GD package items should be deleted from GD payment manager only', 'invoicing' ); |
|
| 309 | - $localize['deleteInvoiceFirst'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
| 306 | + $localize['emptyInvoice'] = __('Add atleast one item to save invoice!', 'invoicing'); |
|
| 307 | + $localize['deletePackage'] = __('GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing'); |
|
| 308 | + $localize['deletePackages'] = __('GD package items should be deleted from GD payment manager only', 'invoicing'); |
|
| 309 | + $localize['deleteInvoiceFirst'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
| 310 | 310 | |
| 311 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
| 311 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
| 312 | 312 | |
| 313 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
| 313 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - public function admin_body_class( $classes ) { |
|
| 316 | + public function admin_body_class($classes) { |
|
| 317 | 317 | global $pagenow, $post, $current_screen; |
| 318 | 318 | |
| 319 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
| 319 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
| 320 | 320 | $classes .= ' wpinv-cpt'; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
| 323 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
| 324 | 324 | |
| 325 | 325 | $add_class = false; |
| 326 | - if ( $pagenow == 'admin.php' && $page ) { |
|
| 327 | - $add_class = strpos( $page, 'wpinv-' ); |
|
| 326 | + if ($pagenow == 'admin.php' && $page) { |
|
| 327 | + $add_class = strpos($page, 'wpinv-'); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | $settings_class = array(); |
| 331 | - if ( $page == 'wpinv-settings' ) { |
|
| 332 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
| 333 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
| 331 | + if ($page == 'wpinv-settings') { |
|
| 332 | + if (!empty($_REQUEST['tab'])) { |
|
| 333 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
| 337 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
| 336 | + if (!empty($_REQUEST['section'])) { |
|
| 337 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
| 340 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if ( !empty( $settings_class ) ) { |
|
| 344 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
| 343 | + if (!empty($settings_class)) { |
|
| 344 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | $post_type = wpinv_admin_post_type(); |
| 348 | 348 | |
| 349 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
| 349 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
| 350 | 350 | return $classes .= ' wpinv'; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
| 353 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
| 354 | 354 | $classes .= ' wpi-editable-n'; |
| 355 | 355 | } |
| 356 | 356 | |
@@ -362,20 +362,20 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | public function wpinv_actions() { |
| 365 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
| 366 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
| 365 | + if (isset($_REQUEST['wpi_action'])) { |
|
| 366 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - public function pre_get_posts( $wp_query ) { |
|
| 371 | - if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
| 372 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
| 370 | + public function pre_get_posts($wp_query) { |
|
| 371 | + if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
| 372 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | return $wp_query; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | public function bp_invoicing_init() { |
| 379 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
| 379 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | \ No newline at end of file |
@@ -1,34 +1,34 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | class WPInv_Meta_Box_Billing_Details { |
| 8 | - public static function output( $post ) { |
|
| 8 | + public static function output($post) { |
|
| 9 | 9 | global $user_ID; |
| 10 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
| 11 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 10 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
| 11 | + $invoice = new WPInv_Invoice($post_id); |
|
| 12 | 12 | ?> |
| 13 | 13 | <div class="gdmbx2-wrap form-table"> |
| 14 | 14 | <div id="gdmbx2-metabox-wpinv_address" class="gdmbx2-metabox gdmbx-field-list wpinv-address gdmbx-row"> |
| 15 | 15 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-user-id table-layout"> |
| 16 | 16 | <div class="gdmbx-th"> |
| 17 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
| 17 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
| 18 | 18 | </div> |
| 19 | 19 | <div class="gdmbx-td gdmbx-customer-div"> |
| 20 | - <?php wpinv_dropdown_users( array( |
|
| 20 | + <?php wpinv_dropdown_users(array( |
|
| 21 | 21 | 'name' => 'post_author_override', |
| 22 | 22 | 'selected' => empty($post->ID) ? $user_ID : $post->post_author, |
| 23 | 23 | 'include_selected' => true, |
| 24 | 24 | 'show' => 'user_email', |
| 25 | 25 | 'orderby' => 'user_email', |
| 26 | 26 | 'class' => 'gdmbx2-text-large' |
| 27 | - ) ); ?> |
|
| 27 | + )); ?> |
|
| 28 | 28 | </div> |
| 29 | 29 | </div> |
| 30 | 30 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-email table-layout" style="display:none"> |
| 31 | - <div class="gdmbx-th"><label for="wpinv_email"><?php _e( 'Email', 'invoicing' );?> <span class="required">*</span></label> |
|
| 31 | + <div class="gdmbx-th"><label for="wpinv_email"><?php _e('Email', 'invoicing'); ?> <span class="required">*</span></label> |
|
| 32 | 32 | </div> |
| 33 | 33 | <div class="gdmbx-td"> |
| 34 | 34 | <input type="hidden" id="wpinv_new_user" name="wpinv_new_user" value="" /> |
@@ -36,58 +36,58 @@ discard block |
||
| 36 | 36 | </div> |
| 37 | 37 | </div> |
| 38 | 38 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-btns table-layout"> |
| 39 | - <div class="gdmbx-th"><label><?php _e( 'Actions', 'invoicing' );?></label> |
|
| 39 | + <div class="gdmbx-th"><label><?php _e('Actions', 'invoicing'); ?></label> |
|
| 40 | 40 | </div> |
| 41 | - <?php if($invoice->has_status(array('wpi-pending', 'wpi-quote-pending'))){ ?> |
|
| 41 | + <?php if ($invoice->has_status(array('wpi-pending', 'wpi-quote-pending'))) { ?> |
|
| 42 | 42 | <div class="gdmbx-td"> |
| 43 | - <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e( 'Fill User Details', 'invoicing' );?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e( 'Fill User Details', 'invoicing' );?></a> |
|
| 44 | - <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e( 'Add New User', 'invoicing' );?></a> |
|
| 45 | - <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e( 'Cancel', 'invoicing' );?> </a> |
|
| 43 | + <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e('Fill User Details', 'invoicing'); ?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e('Fill User Details', 'invoicing'); ?></a> |
|
| 44 | + <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e('Add New User', 'invoicing'); ?></a> |
|
| 45 | + <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e('Cancel', 'invoicing'); ?> </a> |
|
| 46 | 46 | </div> |
| 47 | 47 | <?php } ?> |
| 48 | 48 | </div> |
| 49 | 49 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout"> |
| 50 | - <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?></label></div> |
|
| 50 | + <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e('First Name', 'invoicing'); ?></label></div> |
|
| 51 | 51 | <div class="gdmbx-td"> |
| 52 | - <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" /> |
|
| 52 | + <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr($invoice->first_name); ?>" /> |
|
| 53 | 53 | </div> |
| 54 | 54 | </div> |
| 55 | 55 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout"> |
| 56 | - <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div> |
|
| 56 | + <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e('Last Name', 'invoicing'); ?></label></div> |
|
| 57 | 57 | <div class="gdmbx-td"> |
| 58 | - <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" /> |
|
| 58 | + <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr($invoice->last_name); ?>" /> |
|
| 59 | 59 | </div> |
| 60 | 60 | </div> |
| 61 | 61 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout"> |
| 62 | - <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div> |
|
| 62 | + <div class="gdmbx-th"><label for="wpinv_company"><?php _e('Company', 'invoicing'); ?></label></div> |
|
| 63 | 63 | <div class="gdmbx-td"> |
| 64 | - <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" /> |
|
| 64 | + <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr($invoice->company); ?>" /> |
|
| 65 | 65 | </div> |
| 66 | 66 | </div> |
| 67 | 67 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout"> |
| 68 | - <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div> |
|
| 68 | + <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e('Vat Number', 'invoicing'); ?></label></div> |
|
| 69 | 69 | <div class="gdmbx-td"> |
| 70 | - <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" /> |
|
| 70 | + <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr($invoice->vat_number); ?>" /> |
|
| 71 | 71 | </div> |
| 72 | 72 | </div> |
| 73 | 73 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout"> |
| 74 | - <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?></label></div> |
|
| 74 | + <div class="gdmbx-th"><label for="wpinv_address"><?php _e('Address', 'invoicing'); ?></label></div> |
|
| 75 | 75 | <div class="gdmbx-td"> |
| 76 | - <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" /> |
|
| 76 | + <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr($invoice->address); ?>" /> |
|
| 77 | 77 | </div> |
| 78 | 78 | </div> |
| 79 | 79 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout"> |
| 80 | - <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?></label></div> |
|
| 80 | + <div class="gdmbx-th"><label for="wpinv_city"><?php _e('City', 'invoicing'); ?></label></div> |
|
| 81 | 81 | <div class="gdmbx-td"> |
| 82 | - <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" /> |
|
| 82 | + <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr($invoice->city); ?>" /> |
|
| 83 | 83 | </div> |
| 84 | 84 | </div> |
| 85 | 85 | <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout"> |
| 86 | - <div class="gdmbx-th"><label for="wpinv_country"><?php _e( 'Country', 'invoicing' );?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
| 86 | + <div class="gdmbx-th"><label for="wpinv_country"><?php _e('Country', 'invoicing'); ?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
| 87 | 87 | <div class="gdmbx-td"> |
| 88 | 88 | <?php |
| 89 | - echo wpinv_html_select( array( |
|
| 90 | - 'options' => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ), |
|
| 89 | + echo wpinv_html_select(array( |
|
| 90 | + 'options' => array_merge(array('' => __('Choose a country', 'invoicing')), wpinv_get_country_list()), |
|
| 91 | 91 | 'name' => 'wpinv_country', |
| 92 | 92 | 'id' => 'wpinv_country', |
| 93 | 93 | 'selected' => $invoice->country, |
@@ -95,20 +95,20 @@ discard block |
||
| 95 | 95 | 'show_option_none' => false, |
| 96 | 96 | 'class' => 'gdmbx2-text-large', |
| 97 | 97 | 'chosen' => false, |
| 98 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 98 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
| 99 | 99 | 'required' => false, |
| 100 | - ) ); |
|
| 100 | + )); |
|
| 101 | 101 | ?> |
| 102 | 102 | </div> |
| 103 | 103 | </div> |
| 104 | 104 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout"> |
| 105 | - <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?></label></div> |
|
| 105 | + <div class="gdmbx-th"><label for="wpinv_state"><?php _e('State', 'invoicing'); ?></label></div> |
|
| 106 | 106 | <div class="gdmbx-td"> |
| 107 | 107 | <?php |
| 108 | - $states = wpinv_get_country_states( $invoice->country ); |
|
| 109 | - if( !empty( $states ) ) { |
|
| 110 | - echo wpinv_html_select( array( |
|
| 111 | - 'options' => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ), |
|
| 108 | + $states = wpinv_get_country_states($invoice->country); |
|
| 109 | + if (!empty($states)) { |
|
| 110 | + echo wpinv_html_select(array( |
|
| 111 | + 'options' => array_merge(array('' => __('Choose a state', 'invoicing')), $states), |
|
| 112 | 112 | 'name' => 'wpinv_state', |
| 113 | 113 | 'id' => 'wpinv_state', |
| 114 | 114 | 'selected' => $invoice->state, |
@@ -116,44 +116,44 @@ discard block |
||
| 116 | 116 | 'show_option_none' => false, |
| 117 | 117 | 'class' => 'gdmbx2-text-large', |
| 118 | 118 | 'chosen' => false, |
| 119 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 119 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 120 | 120 | 'required' => false, |
| 121 | - ) ); |
|
| 121 | + )); |
|
| 122 | 122 | } else { |
| 123 | - echo wpinv_html_text( array( |
|
| 123 | + echo wpinv_html_text(array( |
|
| 124 | 124 | 'name' => 'wpinv_state', |
| 125 | - 'value' => ! empty( $invoice->state ) ? $invoice->state : '', |
|
| 125 | + 'value' => !empty($invoice->state) ? $invoice->state : '', |
|
| 126 | 126 | 'id' => 'wpinv_state', |
| 127 | 127 | 'class' => 'gdmbx2-text-large', |
| 128 | 128 | 'required' => false, |
| 129 | - ) ); |
|
| 129 | + )); |
|
| 130 | 130 | } |
| 131 | 131 | ?> |
| 132 | 132 | </div> |
| 133 | 133 | </div> |
| 134 | 134 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-zip table-layout"> |
| 135 | - <div class="gdmbx-th"><label for="wpinv_zip"><?php _e( 'Zipcode', 'invoicing' );?></label></div> |
|
| 135 | + <div class="gdmbx-th"><label for="wpinv_zip"><?php _e('Zipcode', 'invoicing'); ?></label></div> |
|
| 136 | 136 | <div class="gdmbx-td"> |
| 137 | - <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr( $invoice->zip );?>" /> |
|
| 137 | + <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr($invoice->zip); ?>" /> |
|
| 138 | 138 | </div> |
| 139 | 139 | </div> |
| 140 | 140 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-phone table-layout"> |
| 141 | - <div class="gdmbx-th"><label for="wpinv_phone"><?php _e( 'Phone', 'invoicing' );?></label></div> |
|
| 141 | + <div class="gdmbx-th"><label for="wpinv_phone"><?php _e('Phone', 'invoicing'); ?></label></div> |
|
| 142 | 142 | <div class="gdmbx-td"> |
| 143 | - <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr( $invoice->phone );?>" /> |
|
| 143 | + <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr($invoice->phone); ?>" /> |
|
| 144 | 144 | </div> |
| 145 | 145 | </div> |
| 146 | 146 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-ip table-layout"> |
| 147 | - <div class="gdmbx-th"><label for="wpinv_ip"><?php _e( 'IP Address', 'invoicing' );?><?php if ($invoice->ip) { ?> |
|
| 148 | - <a href="<?php echo admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip ); ?>" title="<?php esc_attr_e( 'View IP information', 'invoicing' );?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
| 147 | + <div class="gdmbx-th"><label for="wpinv_ip"><?php _e('IP Address', 'invoicing'); ?><?php if ($invoice->ip) { ?> |
|
| 148 | + <a href="<?php echo admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip); ?>" title="<?php esc_attr_e('View IP information', 'invoicing'); ?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
| 149 | 149 | <?php } ?></label></div> |
| 150 | 150 | <div class="gdmbx-td"> |
| 151 | - <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr( $invoice->ip );?>" readonly /> |
|
| 151 | + <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr($invoice->ip); ?>" readonly /> |
|
| 152 | 152 | </div> |
| 153 | 153 | </div> |
| 154 | 154 | </div> |
| 155 | 155 | </div> |
| 156 | -<?php wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' ) ;?> |
|
| 156 | +<?php wp_nonce_field('wpinv_save_invoice', 'wpinv_save_invoice'); ?> |
|
| 157 | 157 | <?php |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -7,12 +7,12 @@ 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 | final class WPInv_Invoice { |
| 15 | - public $ID = 0; |
|
| 15 | + public $ID = 0; |
|
| 16 | 16 | public $title; |
| 17 | 17 | public $post_type; |
| 18 | 18 | |
@@ -65,17 +65,17 @@ discard block |
||
| 65 | 65 | public $full_name = ''; |
| 66 | 66 | public $parent_invoice = 0; |
| 67 | 67 | |
| 68 | - public function __construct( $invoice_id = false ) { |
|
| 69 | - if( empty( $invoice_id ) ) { |
|
| 68 | + public function __construct($invoice_id = false) { |
|
| 69 | + if (empty($invoice_id)) { |
|
| 70 | 70 | return false; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - $this->setup_invoice( $invoice_id ); |
|
| 73 | + $this->setup_invoice($invoice_id); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function get( $key ) { |
|
| 77 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 78 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
| 76 | + public function get($key) { |
|
| 77 | + if (method_exists($this, 'get_' . $key)) { |
|
| 78 | + $value = call_user_func(array($this, 'get_' . $key)); |
|
| 79 | 79 | } else { |
| 80 | 80 | $value = $this->$key; |
| 81 | 81 | } |
@@ -83,51 +83,51 @@ discard block |
||
| 83 | 83 | return $value; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function set( $key, $value ) { |
|
| 87 | - $ignore = array( 'items', 'cart_details', 'fees', '_ID' ); |
|
| 86 | + public function set($key, $value) { |
|
| 87 | + $ignore = array('items', 'cart_details', 'fees', '_ID'); |
|
| 88 | 88 | |
| 89 | - if ( $key === 'status' ) { |
|
| 89 | + if ($key === 'status') { |
|
| 90 | 90 | $this->old_status = $this->status; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if ( ! in_array( $key, $ignore ) ) { |
|
| 94 | - $this->pending[ $key ] = $value; |
|
| 93 | + if (!in_array($key, $ignore)) { |
|
| 94 | + $this->pending[$key] = $value; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if( '_ID' !== $key ) { |
|
| 97 | + if ('_ID' !== $key) { |
|
| 98 | 98 | $this->$key = $value; |
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public function _isset( $name ) { |
|
| 103 | - if ( property_exists( $this, $name) ) { |
|
| 104 | - return false === empty( $this->$name ); |
|
| 102 | + public function _isset($name) { |
|
| 103 | + if (property_exists($this, $name)) { |
|
| 104 | + return false === empty($this->$name); |
|
| 105 | 105 | } else { |
| 106 | 106 | return null; |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - private function setup_invoice( $invoice_id ) { |
|
| 110 | + private function setup_invoice($invoice_id) { |
|
| 111 | 111 | $this->pending = array(); |
| 112 | 112 | |
| 113 | - if ( empty( $invoice_id ) ) { |
|
| 113 | + if (empty($invoice_id)) { |
|
| 114 | 114 | return false; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $invoice = get_post( $invoice_id ); |
|
| 117 | + $invoice = get_post($invoice_id); |
|
| 118 | 118 | |
| 119 | - if( !$invoice || is_wp_error( $invoice ) ) { |
|
| 119 | + if (!$invoice || is_wp_error($invoice)) { |
|
| 120 | 120 | return false; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if( !('wpi_invoice' == $invoice->post_type OR 'wpi_quote' == $invoice->post_type) ) { |
|
| 123 | + if (!('wpi_invoice' == $invoice->post_type OR 'wpi_quote' == $invoice->post_type)) { |
|
| 124 | 124 | return false; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - do_action( 'wpinv_pre_setup_invoice', $this, $invoice_id ); |
|
| 127 | + do_action('wpinv_pre_setup_invoice', $this, $invoice_id); |
|
| 128 | 128 | |
| 129 | 129 | // Primary Identifier |
| 130 | - $this->ID = absint( $invoice_id ); |
|
| 130 | + $this->ID = absint($invoice_id); |
|
| 131 | 131 | $this->post_type = $invoice->post_type; |
| 132 | 132 | |
| 133 | 133 | // We have a payment, get the generic payment_meta item to reduce calls to it |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $this->post_status = $this->status; |
| 140 | 140 | $this->mode = $this->setup_mode(); |
| 141 | 141 | $this->parent_invoice = $invoice->post_parent; |
| 142 | - $this->post_name = $this->setup_post_name( $invoice ); |
|
| 142 | + $this->post_name = $this->setup_post_name($invoice); |
|
| 143 | 143 | $this->status_nicename = $this->setup_status_nicename($invoice->post_status); |
| 144 | 144 | |
| 145 | 145 | // Items |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | // User based |
| 163 | 163 | $this->ip = $this->setup_ip(); |
| 164 | - $this->user_id = !empty( $invoice->post_author ) ? $invoice->post_author : get_current_user_id();///$this->setup_user_id(); |
|
| 165 | - $this->email = get_the_author_meta( 'email', $this->user_id ); |
|
| 164 | + $this->user_id = !empty($invoice->post_author) ? $invoice->post_author : get_current_user_id(); ///$this->setup_user_id(); |
|
| 165 | + $this->email = get_the_author_meta('email', $this->user_id); |
|
| 166 | 166 | |
| 167 | 167 | $this->user_info = $this->setup_user_info(); |
| 168 | 168 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $this->company = $this->user_info['company']; |
| 172 | 172 | $this->vat_number = $this->user_info['vat_number']; |
| 173 | 173 | $this->vat_rate = $this->user_info['vat_rate']; |
| 174 | - $this->adddress_confirmed = $this->user_info['adddress_confirmed']; |
|
| 174 | + $this->adddress_confirmed = $this->user_info['adddress_confirmed']; |
|
| 175 | 175 | $this->address = $this->user_info['address']; |
| 176 | 176 | $this->city = $this->user_info['city']; |
| 177 | 177 | $this->country = $this->user_info['country']; |
@@ -186,35 +186,35 @@ discard block |
||
| 186 | 186 | // Other Identifiers |
| 187 | 187 | $this->key = $this->setup_invoice_key(); |
| 188 | 188 | $this->number = $this->setup_invoice_number(); |
| 189 | - $this->title = !empty( $invoice->post_title ) ? $invoice->post_title : $this->number; |
|
| 189 | + $this->title = !empty($invoice->post_title) ? $invoice->post_title : $this->number; |
|
| 190 | 190 | |
| 191 | - $this->full_name = trim( $this->first_name . ' '. $this->last_name ); |
|
| 191 | + $this->full_name = trim($this->first_name . ' ' . $this->last_name); |
|
| 192 | 192 | |
| 193 | 193 | // Allow extensions to add items to this object via hook |
| 194 | - do_action( 'wpinv_setup_invoice', $this, $invoice_id ); |
|
| 194 | + do_action('wpinv_setup_invoice', $this, $invoice_id); |
|
| 195 | 195 | |
| 196 | 196 | return true; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | private function setup_status_nicename($status) { |
| 200 | - $all_invoice_statuses = wpinv_get_invoice_statuses(); |
|
| 201 | - $status = isset( $all_invoice_statuses[$status] ) ? $all_invoice_statuses[$status] : __( $status, 'invoicing' ); |
|
| 200 | + $all_invoice_statuses = wpinv_get_invoice_statuses(); |
|
| 201 | + $status = isset($all_invoice_statuses[$status]) ? $all_invoice_statuses[$status] : __($status, 'invoicing'); |
|
| 202 | 202 | |
| 203 | - return apply_filters( 'setup_status_nicename', $status ); |
|
| 203 | + return apply_filters('setup_status_nicename', $status); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - private function setup_post_name( $post = NULL ) { |
|
| 206 | + private function setup_post_name($post = NULL) { |
|
| 207 | 207 | global $wpdb; |
| 208 | 208 | |
| 209 | 209 | $post_name = ''; |
| 210 | 210 | |
| 211 | - if ( !empty( $post ) ) { |
|
| 212 | - if( !empty( $post->post_name ) ) { |
|
| 211 | + if (!empty($post)) { |
|
| 212 | + if (!empty($post->post_name)) { |
|
| 213 | 213 | $post_name = $post->post_name; |
| 214 | - } else if ( !empty( $post->ID ) ) { |
|
| 214 | + } else if (!empty($post->ID)) { |
|
| 215 | 215 | $post_name = 'inv-' . $post->ID; |
| 216 | 216 | |
| 217 | - $wpdb->update( $wpdb->posts, array( 'post_name' => 'inv-' . $post->ID ), array( 'ID' => $post->ID ) ); |
|
| 217 | + $wpdb->update($wpdb->posts, array('post_name' => 'inv-' . $post->ID), array('ID' => $post->ID)); |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
@@ -222,12 +222,12 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | private function setup_due_date() { |
| 225 | - $due_date = $this->get_meta( '_wpinv_due_date' ); |
|
| 225 | + $due_date = $this->get_meta('_wpinv_due_date'); |
|
| 226 | 226 | |
| 227 | - if ( empty( $due_date ) ) { |
|
| 228 | - $overdue_time = strtotime( $this->date ) + ( DAY_IN_SECONDS * absint( wpinv_get_option( 'overdue_days' ) ) ); |
|
| 229 | - $due_date = date_i18n( 'Y-m-d', $overdue_time ); |
|
| 230 | - } else if ( $due_date == 'none' ) { |
|
| 227 | + if (empty($due_date)) { |
|
| 228 | + $overdue_time = strtotime($this->date) + (DAY_IN_SECONDS * absint(wpinv_get_option('overdue_days'))); |
|
| 229 | + $due_date = date_i18n('Y-m-d', $overdue_time); |
|
| 230 | + } else if ($due_date == 'none') { |
|
| 231 | 231 | $due_date = ''; |
| 232 | 232 | } |
| 233 | 233 | |
@@ -235,63 +235,63 @@ discard block |
||
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | private function setup_completed_date() { |
| 238 | - $invoice = get_post( $this->ID ); |
|
| 238 | + $invoice = get_post($this->ID); |
|
| 239 | 239 | |
| 240 | - if ( 'wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status ) { |
|
| 240 | + if ('wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status) { |
|
| 241 | 241 | return false; // This invoice was never paid |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - $date = ( $date = $this->get_meta( '_wpinv_completed_date', true ) ) ? $date : $invoice->modified_date; |
|
| 244 | + $date = ($date = $this->get_meta('_wpinv_completed_date', true)) ? $date : $invoice->modified_date; |
|
| 245 | 245 | |
| 246 | 246 | return $date; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | private function setup_cart_details() { |
| 250 | - $cart_details = isset( $this->payment_meta['cart_details'] ) ? maybe_unserialize( $this->payment_meta['cart_details'] ) : array(); |
|
| 250 | + $cart_details = isset($this->payment_meta['cart_details']) ? maybe_unserialize($this->payment_meta['cart_details']) : array(); |
|
| 251 | 251 | return $cart_details; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | public function array_convert() { |
| 255 | - return get_object_vars( $this ); |
|
| 255 | + return get_object_vars($this); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | private function setup_items() { |
| 259 | - $items = isset( $this->payment_meta['items'] ) ? maybe_unserialize( $this->payment_meta['items'] ) : array(); |
|
| 259 | + $items = isset($this->payment_meta['items']) ? maybe_unserialize($this->payment_meta['items']) : array(); |
|
| 260 | 260 | return $items; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | private function setup_fees() { |
| 264 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
| 264 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
| 265 | 265 | return $payment_fees; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | private function setup_currency() { |
| 269 | - $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'wpinv_currency_default', wpinv_get_currency(), $this ); |
|
| 269 | + $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('wpinv_currency_default', wpinv_get_currency(), $this); |
|
| 270 | 270 | return $currency; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | private function setup_discount() { |
| 274 | 274 | //$discount = $this->get_meta( '_wpinv_discount', true ); |
| 275 | - $discount = (float)$this->subtotal - ( (float)$this->total - (float)$this->tax - (float)$this->fees_total ); |
|
| 276 | - if ( $discount < 0 ) { |
|
| 275 | + $discount = (float)$this->subtotal - ((float)$this->total - (float)$this->tax - (float)$this->fees_total); |
|
| 276 | + if ($discount < 0) { |
|
| 277 | 277 | $discount = 0; |
| 278 | 278 | } |
| 279 | - $discount = wpinv_round_amount( $discount ); |
|
| 279 | + $discount = wpinv_round_amount($discount); |
|
| 280 | 280 | |
| 281 | 281 | return $discount; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | private function setup_discount_code() { |
| 285 | - $discount_code = !empty( $this->discounts ) ? $this->discounts : $this->get_meta( '_wpinv_discount_code', true ); |
|
| 285 | + $discount_code = !empty($this->discounts) ? $this->discounts : $this->get_meta('_wpinv_discount_code', true); |
|
| 286 | 286 | return $discount_code; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | private function setup_tax() { |
| 290 | - $tax = $this->get_meta( '_wpinv_tax', true ); |
|
| 290 | + $tax = $this->get_meta('_wpinv_tax', true); |
|
| 291 | 291 | |
| 292 | 292 | // We don't have tax as it's own meta and no meta was passed |
| 293 | - if ( '' === $tax ) { |
|
| 294 | - $tax = isset( $this->payment_meta['tax'] ) ? $this->payment_meta['tax'] : 0; |
|
| 293 | + if ('' === $tax) { |
|
| 294 | + $tax = isset($this->payment_meta['tax']) ? $this->payment_meta['tax'] : 0; |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | return $tax; |
@@ -301,9 +301,9 @@ discard block |
||
| 301 | 301 | $subtotal = 0; |
| 302 | 302 | $cart_details = $this->cart_details; |
| 303 | 303 | |
| 304 | - if ( is_array( $cart_details ) ) { |
|
| 305 | - foreach ( $cart_details as $item ) { |
|
| 306 | - if ( isset( $item['subtotal'] ) ) { |
|
| 304 | + if (is_array($cart_details)) { |
|
| 305 | + foreach ($cart_details as $item) { |
|
| 306 | + if (isset($item['subtotal'])) { |
|
| 307 | 307 | $subtotal += $item['subtotal']; |
| 308 | 308 | } |
| 309 | 309 | } |
@@ -317,23 +317,23 @@ discard block |
||
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | private function setup_discounts() { |
| 320 | - $discounts = ! empty( $this->payment_meta['user_info']['discount'] ) ? $this->payment_meta['user_info']['discount'] : array(); |
|
| 320 | + $discounts = !empty($this->payment_meta['user_info']['discount']) ? $this->payment_meta['user_info']['discount'] : array(); |
|
| 321 | 321 | return $discounts; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | private function setup_total() { |
| 325 | - $amount = $this->get_meta( '_wpinv_total', true ); |
|
| 325 | + $amount = $this->get_meta('_wpinv_total', true); |
|
| 326 | 326 | |
| 327 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
| 328 | - $meta = $this->get_meta( '_wpinv_payment_meta', true ); |
|
| 329 | - $meta = maybe_unserialize( $meta ); |
|
| 327 | + if (empty($amount) && '0.00' != $amount) { |
|
| 328 | + $meta = $this->get_meta('_wpinv_payment_meta', true); |
|
| 329 | + $meta = maybe_unserialize($meta); |
|
| 330 | 330 | |
| 331 | - if ( isset( $meta['amount'] ) ) { |
|
| 331 | + if (isset($meta['amount'])) { |
|
| 332 | 332 | $amount = $meta['amount']; |
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if($amount < 0){ |
|
| 336 | + if ($amount < 0) { |
|
| 337 | 337 | $amount = 0; |
| 338 | 338 | } |
| 339 | 339 | |
@@ -341,13 +341,13 @@ discard block |
||
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | private function setup_mode() { |
| 344 | - return $this->get_meta( '_wpinv_mode' ); |
|
| 344 | + return $this->get_meta('_wpinv_mode'); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | private function setup_gateway() { |
| 348 | - $gateway = $this->get_meta( '_wpinv_gateway' ); |
|
| 348 | + $gateway = $this->get_meta('_wpinv_gateway'); |
|
| 349 | 349 | |
| 350 | - if ( empty( $gateway ) && 'publish' === $this->status ) { |
|
| 350 | + if (empty($gateway) && 'publish' === $this->status) { |
|
| 351 | 351 | $gateway = 'manual'; |
| 352 | 352 | } |
| 353 | 353 | |
@@ -355,23 +355,23 @@ discard block |
||
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | private function setup_gateway_title() { |
| 358 | - $gateway_title = wpinv_get_gateway_checkout_label( $this->gateway ); |
|
| 358 | + $gateway_title = wpinv_get_gateway_checkout_label($this->gateway); |
|
| 359 | 359 | return $gateway_title; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | private function setup_transaction_id() { |
| 363 | - $transaction_id = $this->get_meta( '_wpinv_transaction_id' ); |
|
| 363 | + $transaction_id = $this->get_meta('_wpinv_transaction_id'); |
|
| 364 | 364 | |
| 365 | - if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) { |
|
| 365 | + if (empty($transaction_id) || (int)$transaction_id === (int)$this->ID) { |
|
| 366 | 366 | $gateway = $this->gateway; |
| 367 | - $transaction_id = apply_filters( 'wpinv_get_invoice_transaction_id-' . $gateway, $this->ID ); |
|
| 367 | + $transaction_id = apply_filters('wpinv_get_invoice_transaction_id-' . $gateway, $this->ID); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | return $transaction_id; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | private function setup_ip() { |
| 374 | - $ip = $this->get_meta( '_wpinv_user_ip' ); |
|
| 374 | + $ip = $this->get_meta('_wpinv_user_ip'); |
|
| 375 | 375 | return $ip; |
| 376 | 376 | } |
| 377 | 377 | |
@@ -381,62 +381,62 @@ discard block |
||
| 381 | 381 | ///} |
| 382 | 382 | |
| 383 | 383 | private function setup_first_name() { |
| 384 | - $first_name = $this->get_meta( '_wpinv_first_name' ); |
|
| 384 | + $first_name = $this->get_meta('_wpinv_first_name'); |
|
| 385 | 385 | return $first_name; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | private function setup_last_name() { |
| 389 | - $last_name = $this->get_meta( '_wpinv_last_name' ); |
|
| 389 | + $last_name = $this->get_meta('_wpinv_last_name'); |
|
| 390 | 390 | return $last_name; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | private function setup_company() { |
| 394 | - $company = $this->get_meta( '_wpinv_company' ); |
|
| 394 | + $company = $this->get_meta('_wpinv_company'); |
|
| 395 | 395 | return $company; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | private function setup_vat_number() { |
| 399 | - $vat_number = $this->get_meta( '_wpinv_vat_number' ); |
|
| 399 | + $vat_number = $this->get_meta('_wpinv_vat_number'); |
|
| 400 | 400 | return $vat_number; |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | private function setup_vat_rate() { |
| 404 | - $vat_rate = $this->get_meta( '_wpinv_vat_rate' ); |
|
| 404 | + $vat_rate = $this->get_meta('_wpinv_vat_rate'); |
|
| 405 | 405 | return $vat_rate; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | private function setup_adddress_confirmed() { |
| 409 | - $adddress_confirmed = $this->get_meta( '_wpinv_adddress_confirmed' ); |
|
| 409 | + $adddress_confirmed = $this->get_meta('_wpinv_adddress_confirmed'); |
|
| 410 | 410 | return $adddress_confirmed; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | private function setup_phone() { |
| 414 | - $phone = $this->get_meta( '_wpinv_phone' ); |
|
| 414 | + $phone = $this->get_meta('_wpinv_phone'); |
|
| 415 | 415 | return $phone; |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | private function setup_address() { |
| 419 | - $address = $this->get_meta( '_wpinv_address', true ); |
|
| 419 | + $address = $this->get_meta('_wpinv_address', true); |
|
| 420 | 420 | return $address; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | private function setup_city() { |
| 424 | - $city = $this->get_meta( '_wpinv_city', true ); |
|
| 424 | + $city = $this->get_meta('_wpinv_city', true); |
|
| 425 | 425 | return $city; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | private function setup_country() { |
| 429 | - $country = $this->get_meta( '_wpinv_country', true ); |
|
| 429 | + $country = $this->get_meta('_wpinv_country', true); |
|
| 430 | 430 | return $country; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | private function setup_state() { |
| 434 | - $state = $this->get_meta( '_wpinv_state', true ); |
|
| 434 | + $state = $this->get_meta('_wpinv_state', true); |
|
| 435 | 435 | return $state; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | private function setup_zip() { |
| 439 | - $zip = $this->get_meta( '_wpinv_zip', true ); |
|
| 439 | + $zip = $this->get_meta('_wpinv_zip', true); |
|
| 440 | 440 | return $zip; |
| 441 | 441 | } |
| 442 | 442 | |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | 'user_id' => $this->user_id, |
| 446 | 446 | 'first_name' => $this->first_name, |
| 447 | 447 | 'last_name' => $this->last_name, |
| 448 | - 'email' => get_the_author_meta( 'email', $this->user_id ), |
|
| 448 | + 'email' => get_the_author_meta('email', $this->user_id), |
|
| 449 | 449 | 'phone' => $this->phone, |
| 450 | 450 | 'address' => $this->address, |
| 451 | 451 | 'city' => $this->city, |
@@ -460,12 +460,12 @@ discard block |
||
| 460 | 460 | ); |
| 461 | 461 | |
| 462 | 462 | $user_info = array(); |
| 463 | - if ( isset( $this->payment_meta['user_info'] ) ) { |
|
| 464 | - $user_info = maybe_unserialize( $this->payment_meta['user_info'] ); |
|
| 463 | + if (isset($this->payment_meta['user_info'])) { |
|
| 464 | + $user_info = maybe_unserialize($this->payment_meta['user_info']); |
|
| 465 | 465 | |
| 466 | - if ( !empty( $user_info ) && isset( $user_info['user_id'] ) && $post = get_post( $this->ID ) ) { |
|
| 466 | + if (!empty($user_info) && isset($user_info['user_id']) && $post = get_post($this->ID)) { |
|
| 467 | 467 | $this->user_id = $post->post_author; |
| 468 | - $this->email = get_the_author_meta( 'email', $this->user_id ); |
|
| 468 | + $this->email = get_the_author_meta('email', $this->user_id); |
|
| 469 | 469 | |
| 470 | 470 | $user_info['user_id'] = $this->user_id; |
| 471 | 471 | $user_info['email'] = $this->email; |
@@ -474,13 +474,13 @@ discard block |
||
| 474 | 474 | } |
| 475 | 475 | } |
| 476 | 476 | |
| 477 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
| 477 | + $user_info = wp_parse_args($user_info, $defaults); |
|
| 478 | 478 | |
| 479 | 479 | // Get the user, but only if it's been created |
| 480 | - $user = get_userdata( $this->user_id ); |
|
| 480 | + $user = get_userdata($this->user_id); |
|
| 481 | 481 | |
| 482 | - if ( !empty( $user ) && $user->ID > 0 ) { |
|
| 483 | - if ( empty( $user_info ) ) { |
|
| 482 | + if (!empty($user) && $user->ID > 0) { |
|
| 483 | + if (empty($user_info)) { |
|
| 484 | 484 | $user_info = array( |
| 485 | 485 | 'user_id' => $user->ID, |
| 486 | 486 | 'first_name' => $user->first_name, |
@@ -489,23 +489,23 @@ discard block |
||
| 489 | 489 | 'discount' => '', |
| 490 | 490 | ); |
| 491 | 491 | } else { |
| 492 | - foreach ( $user_info as $key => $value ) { |
|
| 493 | - if ( ! empty( $value ) ) { |
|
| 492 | + foreach ($user_info as $key => $value) { |
|
| 493 | + if (!empty($value)) { |
|
| 494 | 494 | continue; |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - switch( $key ) { |
|
| 497 | + switch ($key) { |
|
| 498 | 498 | case 'user_id': |
| 499 | - $user_info[ $key ] = $user->ID; |
|
| 499 | + $user_info[$key] = $user->ID; |
|
| 500 | 500 | break; |
| 501 | 501 | case 'first_name': |
| 502 | - $user_info[ $key ] = $user->first_name; |
|
| 502 | + $user_info[$key] = $user->first_name; |
|
| 503 | 503 | break; |
| 504 | 504 | case 'last_name': |
| 505 | - $user_info[ $key ] = $user->last_name; |
|
| 505 | + $user_info[$key] = $user->last_name; |
|
| 506 | 506 | break; |
| 507 | 507 | case 'email': |
| 508 | - $user_info[ $key ] = $user->user_email; |
|
| 508 | + $user_info[$key] = $user->user_email; |
|
| 509 | 509 | break; |
| 510 | 510 | } |
| 511 | 511 | } |
@@ -516,25 +516,25 @@ discard block |
||
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | private function setup_invoice_key() { |
| 519 | - $key = $this->get_meta( '_wpinv_key', true ); |
|
| 519 | + $key = $this->get_meta('_wpinv_key', true); |
|
| 520 | 520 | |
| 521 | 521 | return $key; |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | private function setup_invoice_number() { |
| 525 | - $number = $this->get_meta( '_wpinv_number', true ); |
|
| 525 | + $number = $this->get_meta('_wpinv_number', true); |
|
| 526 | 526 | |
| 527 | - if ( !$number ) { |
|
| 527 | + if (!$number) { |
|
| 528 | 528 | $number = $this->ID; |
| 529 | 529 | |
| 530 | - if ( $this->status == 'auto-draft' ) { |
|
| 531 | - if ( wpinv_get_option( 'sequential_invoice_number' ) ) { |
|
| 530 | + if ($this->status == 'auto-draft') { |
|
| 531 | + if (wpinv_get_option('sequential_invoice_number')) { |
|
| 532 | 532 | $next_number = wpinv_get_next_invoice_number(); |
| 533 | 533 | $number = $next_number; |
| 534 | 534 | } |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | - $number = wpinv_format_invoice_number( $number ); |
|
| 537 | + $number = wpinv_format_invoice_number($number); |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | return $number; |
@@ -544,16 +544,16 @@ discard block |
||
| 544 | 544 | global $wpdb; |
| 545 | 545 | |
| 546 | 546 | $invoice_number = $this->ID; |
| 547 | - if ( $number = $this->get_meta( '_wpinv_number', true ) ) { |
|
| 547 | + if ($number = $this->get_meta('_wpinv_number', true)) { |
|
| 548 | 548 | $invoice_number = $number; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - if ( empty( $this->key ) ) { |
|
| 551 | + if (empty($this->key)) { |
|
| 552 | 552 | $this->key = self::generate_key(); |
| 553 | 553 | $this->pending['key'] = $this->key; |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - if ( empty( $this->ip ) ) { |
|
| 556 | + if (empty($this->ip)) { |
|
| 557 | 557 | $this->ip = wpinv_get_ip(); |
| 558 | 558 | $this->pending['ip'] = $this->ip; |
| 559 | 559 | } |
@@ -590,61 +590,61 @@ discard block |
||
| 590 | 590 | 'post_status' => $this->status, |
| 591 | 591 | 'post_author' => $this->user_id, |
| 592 | 592 | 'post_type' => $this->post_type, |
| 593 | - 'post_date' => ! empty( $this->date ) && $this->date != '0000-00-00 00:00:00' ? $this->date : current_time( 'mysql' ), |
|
| 594 | - 'post_date_gmt' => ! empty( $this->date ) && $this->date != '0000-00-00 00:00:00' ? get_gmt_from_date( $this->date ) : current_time( 'mysql', 1 ), |
|
| 593 | + 'post_date' => !empty($this->date) && $this->date != '0000-00-00 00:00:00' ? $this->date : current_time('mysql'), |
|
| 594 | + 'post_date_gmt' => !empty($this->date) && $this->date != '0000-00-00 00:00:00' ? get_gmt_from_date($this->date) : current_time('mysql', 1), |
|
| 595 | 595 | 'post_parent' => $this->parent_invoice, |
| 596 | 596 | ); |
| 597 | - $args = apply_filters( 'wpinv_insert_invoice_args', $post_data, $this ); |
|
| 597 | + $args = apply_filters('wpinv_insert_invoice_args', $post_data, $this); |
|
| 598 | 598 | |
| 599 | 599 | // Create a blank invoice |
| 600 | - if ( !empty( $this->ID ) ) { |
|
| 601 | - $args['ID'] = $this->ID; |
|
| 600 | + if (!empty($this->ID)) { |
|
| 601 | + $args['ID'] = $this->ID; |
|
| 602 | 602 | |
| 603 | - $invoice_id = wp_update_post( $args, true ); |
|
| 603 | + $invoice_id = wp_update_post($args, true); |
|
| 604 | 604 | } else { |
| 605 | - $invoice_id = wp_insert_post( $args, true ); |
|
| 605 | + $invoice_id = wp_insert_post($args, true); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | - if ( is_wp_error( $invoice_id ) ) { |
|
| 608 | + if (is_wp_error($invoice_id)) { |
|
| 609 | 609 | return false; |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - if ( !empty( $invoice_id ) ) { |
|
| 612 | + if (!empty($invoice_id)) { |
|
| 613 | 613 | $this->ID = $invoice_id; |
| 614 | 614 | $this->_ID = $invoice_id; |
| 615 | 615 | |
| 616 | - $this->payment_meta = apply_filters( 'wpinv_payment_meta', $this->payment_meta, $payment_data ); |
|
| 617 | - if ( ! empty( $this->payment_meta['fees'] ) ) { |
|
| 618 | - $this->fees = array_merge( $this->fees, $this->payment_meta['fees'] ); |
|
| 619 | - foreach( $this->fees as $fee ) { |
|
| 620 | - $this->increase_fees( $fee['amount'] ); |
|
| 616 | + $this->payment_meta = apply_filters('wpinv_payment_meta', $this->payment_meta, $payment_data); |
|
| 617 | + if (!empty($this->payment_meta['fees'])) { |
|
| 618 | + $this->fees = array_merge($this->fees, $this->payment_meta['fees']); |
|
| 619 | + foreach ($this->fees as $fee) { |
|
| 620 | + $this->increase_fees($fee['amount']); |
|
| 621 | 621 | } |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | - $this->update_meta( '_wpinv_payment_meta', $this->payment_meta ); |
|
| 624 | + $this->update_meta('_wpinv_payment_meta', $this->payment_meta); |
|
| 625 | 625 | $this->new = true; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | return $this->ID; |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | - public function save( $setup = false ) { |
|
| 631 | + public function save($setup = false) { |
|
| 632 | 632 | global $wpi_session; |
| 633 | 633 | |
| 634 | 634 | $saved = false; |
| 635 | - if ( empty( $this->items ) ) { |
|
| 635 | + if (empty($this->items)) { |
|
| 636 | 636 | return $saved; // Don't save empty invoice. |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - if ( empty( $this->key ) ) { |
|
| 639 | + if (empty($this->key)) { |
|
| 640 | 640 | $this->key = self::generate_key(); |
| 641 | 641 | $this->pending['key'] = $this->key; |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | - if ( empty( $this->ID ) ) { |
|
| 644 | + if (empty($this->ID)) { |
|
| 645 | 645 | $invoice_id = $this->insert_invoice(); |
| 646 | 646 | |
| 647 | - if ( false === $invoice_id ) { |
|
| 647 | + if (false === $invoice_id) { |
|
| 648 | 648 | $saved = false; |
| 649 | 649 | } else { |
| 650 | 650 | $this->ID = $invoice_id; |
@@ -652,27 +652,27 @@ discard block |
||
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | // If we have something pending, let's save it |
| 655 | - if ( !empty( $this->pending ) ) { |
|
| 655 | + if (!empty($this->pending)) { |
|
| 656 | 656 | $total_increase = 0; |
| 657 | 657 | $total_decrease = 0; |
| 658 | 658 | |
| 659 | - foreach ( $this->pending as $key => $value ) { |
|
| 660 | - switch( $key ) { |
|
| 659 | + foreach ($this->pending as $key => $value) { |
|
| 660 | + switch ($key) { |
|
| 661 | 661 | case 'items': |
| 662 | 662 | // Update totals for pending items |
| 663 | - foreach ( $this->pending[ $key ] as $item ) { |
|
| 664 | - switch( $item['action'] ) { |
|
| 663 | + foreach ($this->pending[$key] as $item) { |
|
| 664 | + switch ($item['action']) { |
|
| 665 | 665 | case 'add': |
| 666 | 666 | $price = $item['price']; |
| 667 | 667 | $taxes = $item['tax']; |
| 668 | 668 | |
| 669 | - if ( 'publish' === $this->status ) { |
|
| 669 | + if ('publish' === $this->status) { |
|
| 670 | 670 | $total_increase += $price; |
| 671 | 671 | } |
| 672 | 672 | break; |
| 673 | 673 | |
| 674 | 674 | case 'remove': |
| 675 | - if ( 'publish' === $this->status ) { |
|
| 675 | + if ('publish' === $this->status) { |
|
| 676 | 676 | $total_decrease += $item['price']; |
| 677 | 677 | } |
| 678 | 678 | break; |
@@ -680,16 +680,16 @@ discard block |
||
| 680 | 680 | } |
| 681 | 681 | break; |
| 682 | 682 | case 'fees': |
| 683 | - if ( 'publish' !== $this->status ) { |
|
| 683 | + if ('publish' !== $this->status) { |
|
| 684 | 684 | break; |
| 685 | 685 | } |
| 686 | 686 | |
| 687 | - if ( empty( $this->pending[ $key ] ) ) { |
|
| 687 | + if (empty($this->pending[$key])) { |
|
| 688 | 688 | break; |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - foreach ( $this->pending[ $key ] as $fee ) { |
|
| 692 | - switch( $fee['action'] ) { |
|
| 691 | + foreach ($this->pending[$key] as $fee) { |
|
| 692 | + switch ($fee['action']) { |
|
| 693 | 693 | case 'add': |
| 694 | 694 | $total_increase += $fee['amount']; |
| 695 | 695 | break; |
@@ -701,83 +701,83 @@ discard block |
||
| 701 | 701 | } |
| 702 | 702 | break; |
| 703 | 703 | case 'status': |
| 704 | - $this->update_status( $this->status ); |
|
| 704 | + $this->update_status($this->status); |
|
| 705 | 705 | break; |
| 706 | 706 | case 'gateway': |
| 707 | - $this->update_meta( '_wpinv_gateway', $this->gateway ); |
|
| 707 | + $this->update_meta('_wpinv_gateway', $this->gateway); |
|
| 708 | 708 | break; |
| 709 | 709 | case 'mode': |
| 710 | - $this->update_meta( '_wpinv_mode', $this->mode ); |
|
| 710 | + $this->update_meta('_wpinv_mode', $this->mode); |
|
| 711 | 711 | break; |
| 712 | 712 | case 'transaction_id': |
| 713 | - $this->update_meta( '_wpinv_transaction_id', $this->transaction_id ); |
|
| 713 | + $this->update_meta('_wpinv_transaction_id', $this->transaction_id); |
|
| 714 | 714 | break; |
| 715 | 715 | case 'ip': |
| 716 | - $this->update_meta( '_wpinv_user_ip', $this->ip ); |
|
| 716 | + $this->update_meta('_wpinv_user_ip', $this->ip); |
|
| 717 | 717 | break; |
| 718 | 718 | ///case 'user_id': |
| 719 | 719 | ///$this->update_meta( '_wpinv_user_id', $this->user_id ); |
| 720 | 720 | ///$this->user_info['user_id'] = $this->user_id; |
| 721 | 721 | ///break; |
| 722 | 722 | case 'first_name': |
| 723 | - $this->update_meta( '_wpinv_first_name', $this->first_name ); |
|
| 723 | + $this->update_meta('_wpinv_first_name', $this->first_name); |
|
| 724 | 724 | $this->user_info['first_name'] = $this->first_name; |
| 725 | 725 | break; |
| 726 | 726 | case 'last_name': |
| 727 | - $this->update_meta( '_wpinv_last_name', $this->last_name ); |
|
| 727 | + $this->update_meta('_wpinv_last_name', $this->last_name); |
|
| 728 | 728 | $this->user_info['last_name'] = $this->last_name; |
| 729 | 729 | break; |
| 730 | 730 | case 'phone': |
| 731 | - $this->update_meta( '_wpinv_phone', $this->phone ); |
|
| 731 | + $this->update_meta('_wpinv_phone', $this->phone); |
|
| 732 | 732 | $this->user_info['phone'] = $this->phone; |
| 733 | 733 | break; |
| 734 | 734 | case 'address': |
| 735 | - $this->update_meta( '_wpinv_address', $this->address ); |
|
| 735 | + $this->update_meta('_wpinv_address', $this->address); |
|
| 736 | 736 | $this->user_info['address'] = $this->address; |
| 737 | 737 | break; |
| 738 | 738 | case 'city': |
| 739 | - $this->update_meta( '_wpinv_city', $this->city ); |
|
| 739 | + $this->update_meta('_wpinv_city', $this->city); |
|
| 740 | 740 | $this->user_info['city'] = $this->city; |
| 741 | 741 | break; |
| 742 | 742 | case 'country': |
| 743 | - $this->update_meta( '_wpinv_country', $this->country ); |
|
| 743 | + $this->update_meta('_wpinv_country', $this->country); |
|
| 744 | 744 | $this->user_info['country'] = $this->country; |
| 745 | 745 | break; |
| 746 | 746 | case 'state': |
| 747 | - $this->update_meta( '_wpinv_state', $this->state ); |
|
| 747 | + $this->update_meta('_wpinv_state', $this->state); |
|
| 748 | 748 | $this->user_info['state'] = $this->state; |
| 749 | 749 | break; |
| 750 | 750 | case 'zip': |
| 751 | - $this->update_meta( '_wpinv_zip', $this->zip ); |
|
| 751 | + $this->update_meta('_wpinv_zip', $this->zip); |
|
| 752 | 752 | $this->user_info['zip'] = $this->zip; |
| 753 | 753 | break; |
| 754 | 754 | case 'company': |
| 755 | - $this->update_meta( '_wpinv_company', $this->company ); |
|
| 755 | + $this->update_meta('_wpinv_company', $this->company); |
|
| 756 | 756 | $this->user_info['company'] = $this->company; |
| 757 | 757 | break; |
| 758 | 758 | case 'vat_number': |
| 759 | - $this->update_meta( '_wpinv_vat_number', $this->vat_number ); |
|
| 759 | + $this->update_meta('_wpinv_vat_number', $this->vat_number); |
|
| 760 | 760 | $this->user_info['vat_number'] = $this->vat_number; |
| 761 | 761 | |
| 762 | - $vat_info = $wpi_session->get( 'user_vat_data' ); |
|
| 763 | - if ( $this->vat_number && !empty( $vat_info ) && isset( $vat_info['number'] ) && isset( $vat_info['valid'] ) && $vat_info['number'] == $this->vat_number ) { |
|
| 764 | - $adddress_confirmed = isset( $vat_info['adddress_confirmed'] ) ? $vat_info['adddress_confirmed'] : false; |
|
| 765 | - $this->update_meta( '_wpinv_adddress_confirmed', (bool)$adddress_confirmed ); |
|
| 762 | + $vat_info = $wpi_session->get('user_vat_data'); |
|
| 763 | + if ($this->vat_number && !empty($vat_info) && isset($vat_info['number']) && isset($vat_info['valid']) && $vat_info['number'] == $this->vat_number) { |
|
| 764 | + $adddress_confirmed = isset($vat_info['adddress_confirmed']) ? $vat_info['adddress_confirmed'] : false; |
|
| 765 | + $this->update_meta('_wpinv_adddress_confirmed', (bool)$adddress_confirmed); |
|
| 766 | 766 | $this->user_info['adddress_confirmed'] = (bool)$adddress_confirmed; |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | break; |
| 770 | 770 | case 'vat_rate': |
| 771 | - $this->update_meta( '_wpinv_vat_rate', $this->vat_rate ); |
|
| 771 | + $this->update_meta('_wpinv_vat_rate', $this->vat_rate); |
|
| 772 | 772 | $this->user_info['vat_rate'] = $this->vat_rate; |
| 773 | 773 | break; |
| 774 | 774 | case 'adddress_confirmed': |
| 775 | - $this->update_meta( '_wpinv_adddress_confirmed', $this->adddress_confirmed ); |
|
| 775 | + $this->update_meta('_wpinv_adddress_confirmed', $this->adddress_confirmed); |
|
| 776 | 776 | $this->user_info['adddress_confirmed'] = $this->adddress_confirmed; |
| 777 | 777 | break; |
| 778 | 778 | |
| 779 | 779 | case 'key': |
| 780 | - $this->update_meta( '_wpinv_key', $this->key ); |
|
| 780 | + $this->update_meta('_wpinv_key', $this->key); |
|
| 781 | 781 | break; |
| 782 | 782 | case 'date': |
| 783 | 783 | $args = array( |
@@ -786,49 +786,49 @@ discard block |
||
| 786 | 786 | 'edit_date' => true, |
| 787 | 787 | ); |
| 788 | 788 | |
| 789 | - wp_update_post( $args ); |
|
| 789 | + wp_update_post($args); |
|
| 790 | 790 | break; |
| 791 | 791 | case 'due_date': |
| 792 | - if ( empty( $this->due_date ) ) { |
|
| 792 | + if (empty($this->due_date)) { |
|
| 793 | 793 | $this->due_date = 'none'; |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | - $this->update_meta( '_wpinv_due_date', $this->due_date ); |
|
| 796 | + $this->update_meta('_wpinv_due_date', $this->due_date); |
|
| 797 | 797 | break; |
| 798 | 798 | case 'completed_date': |
| 799 | - $this->update_meta( '_wpinv_completed_date', $this->completed_date ); |
|
| 799 | + $this->update_meta('_wpinv_completed_date', $this->completed_date); |
|
| 800 | 800 | break; |
| 801 | 801 | case 'discounts': |
| 802 | - if ( ! is_array( $this->discounts ) ) { |
|
| 803 | - $this->discounts = explode( ',', $this->discounts ); |
|
| 802 | + if (!is_array($this->discounts)) { |
|
| 803 | + $this->discounts = explode(',', $this->discounts); |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | - $this->user_info['discount'] = implode( ',', $this->discounts ); |
|
| 806 | + $this->user_info['discount'] = implode(',', $this->discounts); |
|
| 807 | 807 | break; |
| 808 | 808 | case 'discount': |
| 809 | - $this->update_meta( '_wpinv_discount', wpinv_round_amount( $this->discount ) ); |
|
| 809 | + $this->update_meta('_wpinv_discount', wpinv_round_amount($this->discount)); |
|
| 810 | 810 | break; |
| 811 | 811 | case 'discount_code': |
| 812 | - $this->update_meta( '_wpinv_discount_code', $this->discount_code ); |
|
| 812 | + $this->update_meta('_wpinv_discount_code', $this->discount_code); |
|
| 813 | 813 | break; |
| 814 | 814 | case 'parent_invoice': |
| 815 | 815 | $args = array( |
| 816 | 816 | 'ID' => $this->ID, |
| 817 | 817 | 'post_parent' => $this->parent_invoice, |
| 818 | 818 | ); |
| 819 | - wp_update_post( $args ); |
|
| 819 | + wp_update_post($args); |
|
| 820 | 820 | break; |
| 821 | 821 | default: |
| 822 | - do_action( 'wpinv_save', $this, $key ); |
|
| 822 | + do_action('wpinv_save', $this, $key); |
|
| 823 | 823 | break; |
| 824 | 824 | } |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | - $this->update_meta( '_wpinv_subtotal', wpinv_round_amount( $this->subtotal ) ); |
|
| 828 | - $this->update_meta( '_wpinv_total', wpinv_round_amount( $this->total ) ); |
|
| 829 | - $this->update_meta( '_wpinv_tax', wpinv_round_amount( $this->tax ) ); |
|
| 827 | + $this->update_meta('_wpinv_subtotal', wpinv_round_amount($this->subtotal)); |
|
| 828 | + $this->update_meta('_wpinv_total', wpinv_round_amount($this->total)); |
|
| 829 | + $this->update_meta('_wpinv_tax', wpinv_round_amount($this->tax)); |
|
| 830 | 830 | |
| 831 | - $this->items = array_values( $this->items ); |
|
| 831 | + $this->items = array_values($this->items); |
|
| 832 | 832 | |
| 833 | 833 | $new_meta = array( |
| 834 | 834 | 'items' => $this->items, |
@@ -839,12 +839,12 @@ discard block |
||
| 839 | 839 | ); |
| 840 | 840 | |
| 841 | 841 | $meta = $this->get_meta(); |
| 842 | - $merged_meta = array_merge( $meta, $new_meta ); |
|
| 842 | + $merged_meta = array_merge($meta, $new_meta); |
|
| 843 | 843 | |
| 844 | 844 | // Only save the payment meta if it's changed |
| 845 | - if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta) ) ) { |
|
| 846 | - $updated = $this->update_meta( '_wpinv_payment_meta', $merged_meta ); |
|
| 847 | - if ( false !== $updated ) { |
|
| 845 | + if (md5(serialize($meta)) !== md5(serialize($merged_meta))) { |
|
| 846 | + $updated = $this->update_meta('_wpinv_payment_meta', $merged_meta); |
|
| 847 | + if (false !== $updated) { |
|
| 848 | 848 | $saved = true; |
| 849 | 849 | } |
| 850 | 850 | } |
@@ -852,15 +852,15 @@ discard block |
||
| 852 | 852 | $this->pending = array(); |
| 853 | 853 | $saved = true; |
| 854 | 854 | } else { |
| 855 | - $this->update_meta( '_wpinv_subtotal', wpinv_round_amount( $this->subtotal ) ); |
|
| 856 | - $this->update_meta( '_wpinv_total', wpinv_round_amount( $this->total ) ); |
|
| 857 | - $this->update_meta( '_wpinv_tax', wpinv_round_amount( $this->tax ) ); |
|
| 855 | + $this->update_meta('_wpinv_subtotal', wpinv_round_amount($this->subtotal)); |
|
| 856 | + $this->update_meta('_wpinv_total', wpinv_round_amount($this->total)); |
|
| 857 | + $this->update_meta('_wpinv_tax', wpinv_round_amount($this->tax)); |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - do_action( 'wpinv_invoice_save', $this, $saved ); |
|
| 860 | + do_action('wpinv_invoice_save', $this, $saved); |
|
| 861 | 861 | |
| 862 | - if ( true === $saved || $setup ) { |
|
| 863 | - $this->setup_invoice( $this->ID ); |
|
| 862 | + if (true === $saved || $setup) { |
|
| 863 | + $this->setup_invoice($this->ID); |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | $this->refresh_item_ids(); |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | return $saved; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - public function add_fee( $args, $global = true ) { |
|
| 871 | + public function add_fee($args, $global = true) { |
|
| 872 | 872 | $default_args = array( |
| 873 | 873 | 'label' => '', |
| 874 | 874 | 'amount' => 0, |
@@ -878,75 +878,75 @@ discard block |
||
| 878 | 878 | 'item_id' => 0, |
| 879 | 879 | ); |
| 880 | 880 | |
| 881 | - $fee = wp_parse_args( $args, $default_args ); |
|
| 881 | + $fee = wp_parse_args($args, $default_args); |
|
| 882 | 882 | |
| 883 | - if ( !empty( $fee['label'] ) ) { |
|
| 883 | + if (!empty($fee['label'])) { |
|
| 884 | 884 | return false; |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - $fee['id'] = sanitize_title( $fee['label'] ); |
|
| 887 | + $fee['id'] = sanitize_title($fee['label']); |
|
| 888 | 888 | |
| 889 | - $this->fees[] = $fee; |
|
| 889 | + $this->fees[] = $fee; |
|
| 890 | 890 | |
| 891 | 891 | $added_fee = $fee; |
| 892 | 892 | $added_fee['action'] = 'add'; |
| 893 | 893 | $this->pending['fees'][] = $added_fee; |
| 894 | - reset( $this->fees ); |
|
| 894 | + reset($this->fees); |
|
| 895 | 895 | |
| 896 | - $this->increase_fees( $fee['amount'] ); |
|
| 896 | + $this->increase_fees($fee['amount']); |
|
| 897 | 897 | return true; |
| 898 | 898 | } |
| 899 | 899 | |
| 900 | - public function remove_fee( $key ) { |
|
| 900 | + public function remove_fee($key) { |
|
| 901 | 901 | $removed = false; |
| 902 | 902 | |
| 903 | - if ( is_numeric( $key ) ) { |
|
| 904 | - $removed = $this->remove_fee_by( 'index', $key ); |
|
| 903 | + if (is_numeric($key)) { |
|
| 904 | + $removed = $this->remove_fee_by('index', $key); |
|
| 905 | 905 | } |
| 906 | 906 | |
| 907 | 907 | return $removed; |
| 908 | 908 | } |
| 909 | 909 | |
| 910 | - public function remove_fee_by( $key, $value, $global = false ) { |
|
| 911 | - $allowed_fee_keys = apply_filters( 'wpinv_fee_keys', array( |
|
| 910 | + public function remove_fee_by($key, $value, $global = false) { |
|
| 911 | + $allowed_fee_keys = apply_filters('wpinv_fee_keys', array( |
|
| 912 | 912 | 'index', 'label', 'amount', 'type', |
| 913 | - ) ); |
|
| 913 | + )); |
|
| 914 | 914 | |
| 915 | - if ( ! in_array( $key, $allowed_fee_keys ) ) { |
|
| 915 | + if (!in_array($key, $allowed_fee_keys)) { |
|
| 916 | 916 | return false; |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | $removed = false; |
| 920 | - if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) { |
|
| 921 | - $removed_fee = $this->fees[ $value ]; |
|
| 920 | + if ('index' === $key && array_key_exists($value, $this->fees)) { |
|
| 921 | + $removed_fee = $this->fees[$value]; |
|
| 922 | 922 | $removed_fee['action'] = 'remove'; |
| 923 | 923 | $this->pending['fees'][] = $removed_fee; |
| 924 | 924 | |
| 925 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
| 925 | + $this->decrease_fees($removed_fee['amount']); |
|
| 926 | 926 | |
| 927 | - unset( $this->fees[ $value ] ); |
|
| 927 | + unset($this->fees[$value]); |
|
| 928 | 928 | $removed = true; |
| 929 | - } else if ( 'index' !== $key ) { |
|
| 930 | - foreach ( $this->fees as $index => $fee ) { |
|
| 931 | - if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) { |
|
| 929 | + } else if ('index' !== $key) { |
|
| 930 | + foreach ($this->fees as $index => $fee) { |
|
| 931 | + if (isset($fee[$key]) && $fee[$key] == $value) { |
|
| 932 | 932 | $removed_fee = $fee; |
| 933 | 933 | $removed_fee['action'] = 'remove'; |
| 934 | 934 | $this->pending['fees'][] = $removed_fee; |
| 935 | 935 | |
| 936 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
| 936 | + $this->decrease_fees($removed_fee['amount']); |
|
| 937 | 937 | |
| 938 | - unset( $this->fees[ $index ] ); |
|
| 938 | + unset($this->fees[$index]); |
|
| 939 | 939 | $removed = true; |
| 940 | 940 | |
| 941 | - if ( false === $global ) { |
|
| 941 | + if (false === $global) { |
|
| 942 | 942 | break; |
| 943 | 943 | } |
| 944 | 944 | } |
| 945 | 945 | } |
| 946 | 946 | } |
| 947 | 947 | |
| 948 | - if ( true === $removed ) { |
|
| 949 | - $this->fees = array_values( $this->fees ); |
|
| 948 | + if (true === $removed) { |
|
| 949 | + $this->fees = array_values($this->fees); |
|
| 950 | 950 | } |
| 951 | 951 | |
| 952 | 952 | return $removed; |
@@ -954,35 +954,35 @@ discard block |
||
| 954 | 954 | |
| 955 | 955 | |
| 956 | 956 | |
| 957 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
| 957 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
| 958 | 958 | // Bail if no note specified |
| 959 | - if( !$note ) { |
|
| 959 | + if (!$note) { |
|
| 960 | 960 | return false; |
| 961 | 961 | } |
| 962 | 962 | |
| 963 | - if ( empty( $this->ID ) ) |
|
| 963 | + if (empty($this->ID)) |
|
| 964 | 964 | return false; |
| 965 | 965 | |
| 966 | - if ( ( ( is_user_logged_in() && current_user_can( 'manage_options' ) ) || $added_by_user ) && !$system ) { |
|
| 967 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 966 | + if (((is_user_logged_in() && current_user_can('manage_options')) || $added_by_user) && !$system) { |
|
| 967 | + $user = get_user_by('id', get_current_user_id()); |
|
| 968 | 968 | $comment_author = $user->display_name; |
| 969 | 969 | $comment_author_email = $user->user_email; |
| 970 | 970 | } else { |
| 971 | - $comment_author = __( 'System', 'invoicing' ); |
|
| 972 | - $comment_author_email = strtolower( __( 'System', 'invoicing' ) ) . '@'; |
|
| 973 | - $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com'; |
|
| 974 | - $comment_author_email = sanitize_email( $comment_author_email ); |
|
| 971 | + $comment_author = __('System', 'invoicing'); |
|
| 972 | + $comment_author_email = strtolower(__('System', 'invoicing')) . '@'; |
|
| 973 | + $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com'; |
|
| 974 | + $comment_author_email = sanitize_email($comment_author_email); |
|
| 975 | 975 | } |
| 976 | 976 | |
| 977 | - do_action( 'wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type ); |
|
| 977 | + do_action('wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type); |
|
| 978 | 978 | |
| 979 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
| 979 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
| 980 | 980 | 'comment_post_ID' => $this->ID, |
| 981 | 981 | 'comment_content' => $note, |
| 982 | 982 | 'comment_agent' => 'GeoDirectory', |
| 983 | 983 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
| 984 | - 'comment_date' => current_time( 'mysql' ), |
|
| 985 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
| 984 | + 'comment_date' => current_time('mysql'), |
|
| 985 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
| 986 | 986 | 'comment_approved' => 1, |
| 987 | 987 | 'comment_parent' => 0, |
| 988 | 988 | 'comment_author' => $comment_author, |
@@ -990,53 +990,53 @@ discard block |
||
| 990 | 990 | 'comment_author_url' => '', |
| 991 | 991 | 'comment_author_email' => $comment_author_email, |
| 992 | 992 | 'comment_type' => 'wpinv_note' |
| 993 | - ) ) ); |
|
| 993 | + ))); |
|
| 994 | 994 | |
| 995 | - do_action( 'wpinv_insert_payment_note', $note_id, $this->ID, $note ); |
|
| 995 | + do_action('wpinv_insert_payment_note', $note_id, $this->ID, $note); |
|
| 996 | 996 | |
| 997 | - if ( $customer_type ) { |
|
| 998 | - add_comment_meta( $note_id, '_wpi_customer_note', 1 ); |
|
| 997 | + if ($customer_type) { |
|
| 998 | + add_comment_meta($note_id, '_wpi_customer_note', 1); |
|
| 999 | 999 | |
| 1000 | - do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $this->ID, 'user_note' => $note ) ); |
|
| 1000 | + do_action('wpinv_new_customer_note', array('invoice_id' => $this->ID, 'user_note' => $note)); |
|
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | return $note_id; |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | - private function increase_subtotal( $amount = 0.00 ) { |
|
| 1007 | - $amount = (float) $amount; |
|
| 1006 | + private function increase_subtotal($amount = 0.00) { |
|
| 1007 | + $amount = (float)$amount; |
|
| 1008 | 1008 | $this->subtotal += $amount; |
| 1009 | - $this->subtotal = wpinv_round_amount( $this->subtotal ); |
|
| 1009 | + $this->subtotal = wpinv_round_amount($this->subtotal); |
|
| 1010 | 1010 | |
| 1011 | 1011 | $this->recalculate_total(); |
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
| 1015 | - $amount = (float) $amount; |
|
| 1014 | + private function decrease_subtotal($amount = 0.00) { |
|
| 1015 | + $amount = (float)$amount; |
|
| 1016 | 1016 | $this->subtotal -= $amount; |
| 1017 | - $this->subtotal = wpinv_round_amount( $this->subtotal ); |
|
| 1017 | + $this->subtotal = wpinv_round_amount($this->subtotal); |
|
| 1018 | 1018 | |
| 1019 | - if ( $this->subtotal < 0 ) { |
|
| 1019 | + if ($this->subtotal < 0) { |
|
| 1020 | 1020 | $this->subtotal = 0; |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | $this->recalculate_total(); |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | - private function increase_fees( $amount = 0.00 ) { |
|
| 1026 | + private function increase_fees($amount = 0.00) { |
|
| 1027 | 1027 | $amount = (float)$amount; |
| 1028 | 1028 | $this->fees_total += $amount; |
| 1029 | - $this->fees_total = wpinv_round_amount( $this->fees_total ); |
|
| 1029 | + $this->fees_total = wpinv_round_amount($this->fees_total); |
|
| 1030 | 1030 | |
| 1031 | 1031 | $this->recalculate_total(); |
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | - private function decrease_fees( $amount = 0.00 ) { |
|
| 1035 | - $amount = (float) $amount; |
|
| 1034 | + private function decrease_fees($amount = 0.00) { |
|
| 1035 | + $amount = (float)$amount; |
|
| 1036 | 1036 | $this->fees_total -= $amount; |
| 1037 | - $this->fees_total = wpinv_round_amount( $this->fees_total ); |
|
| 1037 | + $this->fees_total = wpinv_round_amount($this->fees_total); |
|
| 1038 | 1038 | |
| 1039 | - if ( $this->fees_total < 0 ) { |
|
| 1039 | + if ($this->fees_total < 0) { |
|
| 1040 | 1040 | $this->fees_total = 0; |
| 1041 | 1041 | } |
| 1042 | 1042 | |
@@ -1047,54 +1047,54 @@ discard block |
||
| 1047 | 1047 | global $wpi_nosave; |
| 1048 | 1048 | |
| 1049 | 1049 | $this->total = $this->subtotal + $this->tax + $this->fees_total; |
| 1050 | - $this->total = wpinv_round_amount( $this->total ); |
|
| 1050 | + $this->total = wpinv_round_amount($this->total); |
|
| 1051 | 1051 | |
| 1052 | - do_action( 'wpinv_invoice_recalculate_total', $this, $wpi_nosave ); |
|
| 1052 | + do_action('wpinv_invoice_recalculate_total', $this, $wpi_nosave); |
|
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | - public function increase_tax( $amount = 0.00 ) { |
|
| 1056 | - $amount = (float) $amount; |
|
| 1055 | + public function increase_tax($amount = 0.00) { |
|
| 1056 | + $amount = (float)$amount; |
|
| 1057 | 1057 | $this->tax += $amount; |
| 1058 | 1058 | |
| 1059 | 1059 | $this->recalculate_total(); |
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | - public function decrease_tax( $amount = 0.00 ) { |
|
| 1063 | - $amount = (float) $amount; |
|
| 1062 | + public function decrease_tax($amount = 0.00) { |
|
| 1063 | + $amount = (float)$amount; |
|
| 1064 | 1064 | $this->tax -= $amount; |
| 1065 | 1065 | |
| 1066 | - if ( $this->tax < 0 ) { |
|
| 1066 | + if ($this->tax < 0) { |
|
| 1067 | 1067 | $this->tax = 0; |
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | $this->recalculate_total(); |
| 1071 | 1071 | } |
| 1072 | 1072 | |
| 1073 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 1074 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : get_post_status( $this->ID ); |
|
| 1073 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
| 1074 | + $old_status = !empty($this->old_status) ? $this->old_status : get_post_status($this->ID); |
|
| 1075 | 1075 | |
| 1076 | - if ( $old_status === $new_status && in_array( $new_status, array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
| 1076 | + if ($old_status === $new_status && in_array($new_status, array_keys(wpinv_get_invoice_statuses()))) { |
|
| 1077 | 1077 | return false; // Don't permit status changes that aren't changes |
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | - $do_change = apply_filters( 'wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status ); |
|
| 1080 | + $do_change = apply_filters('wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status); |
|
| 1081 | 1081 | $updated = false; |
| 1082 | 1082 | |
| 1083 | - if ( $do_change ) { |
|
| 1084 | - do_action( 'wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status ); |
|
| 1083 | + if ($do_change) { |
|
| 1084 | + do_action('wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status); |
|
| 1085 | 1085 | |
| 1086 | 1086 | $update_post_data = array(); |
| 1087 | 1087 | $update_post_data['ID'] = $this->ID; |
| 1088 | 1088 | $update_post_data['post_status'] = $new_status; |
| 1089 | - $update_post_data['edit_date'] = current_time( 'mysql', 0 ); |
|
| 1090 | - $update_post_data['edit_date_gmt'] = current_time( 'mysql', 1 ); |
|
| 1089 | + $update_post_data['edit_date'] = current_time('mysql', 0); |
|
| 1090 | + $update_post_data['edit_date_gmt'] = current_time('mysql', 1); |
|
| 1091 | 1091 | |
| 1092 | - $update_post_data = apply_filters( 'wpinv_update_invoice_status_fields', $update_post_data, $this->ID ); |
|
| 1092 | + $update_post_data = apply_filters('wpinv_update_invoice_status_fields', $update_post_data, $this->ID); |
|
| 1093 | 1093 | |
| 1094 | - $updated = wp_update_post( $update_post_data ); |
|
| 1094 | + $updated = wp_update_post($update_post_data); |
|
| 1095 | 1095 | |
| 1096 | 1096 | // Process any specific status functions |
| 1097 | - switch( $new_status ) { |
|
| 1097 | + switch ($new_status) { |
|
| 1098 | 1098 | case 'wpi-refunded': |
| 1099 | 1099 | $this->process_refund(); |
| 1100 | 1100 | break; |
@@ -1107,9 +1107,9 @@ discard block |
||
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | 1109 | // Status was changed. |
| 1110 | - do_action( 'wpinv_status_' . $new_status, $this->ID, $old_status ); |
|
| 1111 | - do_action( 'wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status ); |
|
| 1112 | - do_action( 'wpinv_update_status', $this->ID, $new_status, $old_status ); |
|
| 1110 | + do_action('wpinv_status_' . $new_status, $this->ID, $old_status); |
|
| 1111 | + do_action('wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status); |
|
| 1112 | + do_action('wpinv_update_status', $this->ID, $new_status, $old_status); |
|
| 1113 | 1113 | } |
| 1114 | 1114 | |
| 1115 | 1115 | return $updated; |
@@ -1123,72 +1123,72 @@ discard block |
||
| 1123 | 1123 | $this->save(); |
| 1124 | 1124 | } |
| 1125 | 1125 | |
| 1126 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 1127 | - if ( empty( $meta_key ) ) { |
|
| 1126 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 1127 | + if (empty($meta_key)) { |
|
| 1128 | 1128 | return false; |
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | - if ( $meta_key == 'key' || $meta_key == 'date' ) { |
|
| 1131 | + if ($meta_key == 'key' || $meta_key == 'date') { |
|
| 1132 | 1132 | $current_meta = $this->get_meta(); |
| 1133 | - $current_meta[ $meta_key ] = $meta_value; |
|
| 1133 | + $current_meta[$meta_key] = $meta_value; |
|
| 1134 | 1134 | |
| 1135 | 1135 | $meta_key = '_wpinv_payment_meta'; |
| 1136 | 1136 | $meta_value = $current_meta; |
| 1137 | 1137 | } |
| 1138 | 1138 | |
| 1139 | - $meta_value = apply_filters( 'wpinv_update_payment_meta_' . $meta_key, $meta_value, $this->ID ); |
|
| 1139 | + $meta_value = apply_filters('wpinv_update_payment_meta_' . $meta_key, $meta_value, $this->ID); |
|
| 1140 | 1140 | |
| 1141 | - if ( $meta_key == '_wpinv_completed_date' && !empty( $meta_value ) ) { |
|
| 1141 | + if ($meta_key == '_wpinv_completed_date' && !empty($meta_value)) { |
|
| 1142 | 1142 | $args = array( |
| 1143 | 1143 | 'ID' => $this->ID, |
| 1144 | 1144 | 'post_date' => $meta_value, |
| 1145 | 1145 | 'edit_date' => true, |
| 1146 | - 'post_date_gmt' => get_gmt_from_date( $meta_value ), |
|
| 1146 | + 'post_date_gmt' => get_gmt_from_date($meta_value), |
|
| 1147 | 1147 | 'post_modified' => $meta_value, |
| 1148 | - 'post_modified_gmt' => get_gmt_from_date( $meta_value ) |
|
| 1148 | + 'post_modified_gmt' => get_gmt_from_date($meta_value) |
|
| 1149 | 1149 | ); |
| 1150 | - wp_update_post( $args ); |
|
| 1150 | + wp_update_post($args); |
|
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | - return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
| 1153 | + return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | private function process_refund() { |
| 1157 | 1157 | $process_refund = true; |
| 1158 | 1158 | |
| 1159 | 1159 | // If the payment was not in publish, don't decrement stats as they were never incremented |
| 1160 | - if ( 'publish' != $this->old_status || 'wpi-refunded' != $this->status ) { |
|
| 1160 | + if ('publish' != $this->old_status || 'wpi-refunded' != $this->status) { |
|
| 1161 | 1161 | $process_refund = false; |
| 1162 | 1162 | } |
| 1163 | 1163 | |
| 1164 | 1164 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
| 1165 | - $process_refund = apply_filters( 'wpinv_should_process_refund', $process_refund, $this ); |
|
| 1165 | + $process_refund = apply_filters('wpinv_should_process_refund', $process_refund, $this); |
|
| 1166 | 1166 | |
| 1167 | - if ( false === $process_refund ) { |
|
| 1167 | + if (false === $process_refund) { |
|
| 1168 | 1168 | return; |
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | - do_action( 'wpinv_pre_refund_invoice', $this ); |
|
| 1171 | + do_action('wpinv_pre_refund_invoice', $this); |
|
| 1172 | 1172 | |
| 1173 | - $decrease_store_earnings = apply_filters( 'wpinv_decrease_store_earnings_on_refund', true, $this ); |
|
| 1174 | - $decrease_customer_value = apply_filters( 'wpinv_decrease_customer_value_on_refund', true, $this ); |
|
| 1175 | - $decrease_purchase_count = apply_filters( 'wpinv_decrease_customer_purchase_count_on_refund', true, $this ); |
|
| 1173 | + $decrease_store_earnings = apply_filters('wpinv_decrease_store_earnings_on_refund', true, $this); |
|
| 1174 | + $decrease_customer_value = apply_filters('wpinv_decrease_customer_value_on_refund', true, $this); |
|
| 1175 | + $decrease_purchase_count = apply_filters('wpinv_decrease_customer_purchase_count_on_refund', true, $this); |
|
| 1176 | 1176 | |
| 1177 | - do_action( 'wpinv_post_refund_invoice', $this ); |
|
| 1177 | + do_action('wpinv_post_refund_invoice', $this); |
|
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | 1180 | private function process_failure() { |
| 1181 | 1181 | $discounts = $this->discounts; |
| 1182 | - if ( empty( $discounts ) ) { |
|
| 1182 | + if (empty($discounts)) { |
|
| 1183 | 1183 | return; |
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | - if ( ! is_array( $discounts ) ) { |
|
| 1187 | - $discounts = array_map( 'trim', explode( ',', $discounts ) ); |
|
| 1186 | + if (!is_array($discounts)) { |
|
| 1187 | + $discounts = array_map('trim', explode(',', $discounts)); |
|
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | - foreach ( $discounts as $discount ) { |
|
| 1191 | - wpinv_decrease_discount_usage( $discount ); |
|
| 1190 | + foreach ($discounts as $discount) { |
|
| 1191 | + wpinv_decrease_discount_usage($discount); |
|
| 1192 | 1192 | } |
| 1193 | 1193 | } |
| 1194 | 1194 | |
@@ -1196,92 +1196,92 @@ discard block |
||
| 1196 | 1196 | $process_pending = true; |
| 1197 | 1197 | |
| 1198 | 1198 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
| 1199 | - if ( ( 'publish' != $this->old_status && 'revoked' != $this->old_status ) || 'wpi-pending' != $this->status ) { |
|
| 1199 | + if (('publish' != $this->old_status && 'revoked' != $this->old_status) || 'wpi-pending' != $this->status) { |
|
| 1200 | 1200 | $process_pending = false; |
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | 1203 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
| 1204 | - $process_pending = apply_filters( 'wpinv_should_process_pending', $process_pending, $this ); |
|
| 1204 | + $process_pending = apply_filters('wpinv_should_process_pending', $process_pending, $this); |
|
| 1205 | 1205 | |
| 1206 | - if ( false === $process_pending ) { |
|
| 1206 | + if (false === $process_pending) { |
|
| 1207 | 1207 | return; |
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | - $decrease_store_earnings = apply_filters( 'wpinv_decrease_store_earnings_on_pending', true, $this ); |
|
| 1211 | - $decrease_customer_value = apply_filters( 'wpinv_decrease_customer_value_on_pending', true, $this ); |
|
| 1212 | - $decrease_purchase_count = apply_filters( 'wpinv_decrease_customer_purchase_count_on_pending', true, $this ); |
|
| 1210 | + $decrease_store_earnings = apply_filters('wpinv_decrease_store_earnings_on_pending', true, $this); |
|
| 1211 | + $decrease_customer_value = apply_filters('wpinv_decrease_customer_value_on_pending', true, $this); |
|
| 1212 | + $decrease_purchase_count = apply_filters('wpinv_decrease_customer_purchase_count_on_pending', true, $this); |
|
| 1213 | 1213 | |
| 1214 | 1214 | $this->completed_date = ''; |
| 1215 | - $this->update_meta( '_wpinv_completed_date', '' ); |
|
| 1215 | + $this->update_meta('_wpinv_completed_date', ''); |
|
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | // get data |
| 1219 | - public function get_meta( $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
| 1220 | - $meta = get_post_meta( $this->ID, $meta_key, $single ); |
|
| 1219 | + public function get_meta($meta_key = '_wpinv_payment_meta', $single = true) { |
|
| 1220 | + $meta = get_post_meta($this->ID, $meta_key, $single); |
|
| 1221 | 1221 | |
| 1222 | - if ( $meta_key === '_wpinv_payment_meta' ) { |
|
| 1222 | + if ($meta_key === '_wpinv_payment_meta') { |
|
| 1223 | 1223 | |
| 1224 | - if(!is_array($meta)){$meta = array();} // we need this to be an array so make sure it is. |
|
| 1224 | + if (!is_array($meta)) {$meta = array(); } // we need this to be an array so make sure it is. |
|
| 1225 | 1225 | |
| 1226 | - if ( empty( $meta['key'] ) ) { |
|
| 1226 | + if (empty($meta['key'])) { |
|
| 1227 | 1227 | $meta['key'] = $this->setup_invoice_key(); |
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | - if ( empty( $meta['date'] ) ) { |
|
| 1231 | - $meta['date'] = get_post_field( 'post_date', $this->ID ); |
|
| 1230 | + if (empty($meta['date'])) { |
|
| 1231 | + $meta['date'] = get_post_field('post_date', $this->ID); |
|
| 1232 | 1232 | } |
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | - $meta = apply_filters( 'wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID ); |
|
| 1235 | + $meta = apply_filters('wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID); |
|
| 1236 | 1236 | |
| 1237 | - return apply_filters( 'wpinv_get_invoice_meta', $meta, $this->ID, $meta_key ); |
|
| 1237 | + return apply_filters('wpinv_get_invoice_meta', $meta, $this->ID, $meta_key); |
|
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | 1240 | public function get_description() { |
| 1241 | - $post = get_post( $this->ID ); |
|
| 1241 | + $post = get_post($this->ID); |
|
| 1242 | 1242 | |
| 1243 | - $description = !empty( $post ) ? $post->post_content : ''; |
|
| 1244 | - return apply_filters( 'wpinv_get_description', $description, $this->ID, $this ); |
|
| 1243 | + $description = !empty($post) ? $post->post_content : ''; |
|
| 1244 | + return apply_filters('wpinv_get_description', $description, $this->ID, $this); |
|
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | - public function get_status( $nicename = false ) { |
|
| 1248 | - if ( !$nicename ) { |
|
| 1247 | + public function get_status($nicename = false) { |
|
| 1248 | + if (!$nicename) { |
|
| 1249 | 1249 | $status = $this->status; |
| 1250 | 1250 | } else { |
| 1251 | 1251 | $status = $this->status_nicename; |
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | - return apply_filters( 'wpinv_get_status', $status, $nicename, $this->ID, $this ); |
|
| 1254 | + return apply_filters('wpinv_get_status', $status, $nicename, $this->ID, $this); |
|
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | 1257 | public function get_cart_details() { |
| 1258 | - return apply_filters( 'wpinv_cart_details', $this->cart_details, $this->ID, $this ); |
|
| 1258 | + return apply_filters('wpinv_cart_details', $this->cart_details, $this->ID, $this); |
|
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | - public function get_subtotal( $currency = false ) { |
|
| 1262 | - $subtotal = wpinv_round_amount( $this->subtotal ); |
|
| 1261 | + public function get_subtotal($currency = false) { |
|
| 1262 | + $subtotal = wpinv_round_amount($this->subtotal); |
|
| 1263 | 1263 | |
| 1264 | - if ( $currency ) { |
|
| 1265 | - $subtotal = wpinv_price( wpinv_format_amount( $subtotal, NULL, !$currency ), $this->get_currency() ); |
|
| 1264 | + if ($currency) { |
|
| 1265 | + $subtotal = wpinv_price(wpinv_format_amount($subtotal, NULL, !$currency), $this->get_currency()); |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | - return apply_filters( 'wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency ); |
|
| 1268 | + return apply_filters('wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency); |
|
| 1269 | 1269 | } |
| 1270 | 1270 | |
| 1271 | - public function get_total( $currency = false ) { |
|
| 1272 | - if ( $this->is_free_trial() ) { |
|
| 1273 | - $total = wpinv_round_amount( 0 ); |
|
| 1271 | + public function get_total($currency = false) { |
|
| 1272 | + if ($this->is_free_trial()) { |
|
| 1273 | + $total = wpinv_round_amount(0); |
|
| 1274 | 1274 | } else { |
| 1275 | - $total = wpinv_round_amount( $this->total ); |
|
| 1275 | + $total = wpinv_round_amount($this->total); |
|
| 1276 | 1276 | } |
| 1277 | - if ( $currency ) { |
|
| 1278 | - $total = wpinv_price( wpinv_format_amount( $total, NULL, !$currency ), $this->get_currency() ); |
|
| 1277 | + if ($currency) { |
|
| 1278 | + $total = wpinv_price(wpinv_format_amount($total, NULL, !$currency), $this->get_currency()); |
|
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | - return apply_filters( 'wpinv_get_invoice_total', $total, $this->ID, $this, $currency ); |
|
| 1281 | + return apply_filters('wpinv_get_invoice_total', $total, $this->ID, $this, $currency); |
|
| 1282 | 1282 | } |
| 1283 | 1283 | |
| 1284 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
| 1284 | + public function get_recurring_details($field = '', $currency = false) { |
|
| 1285 | 1285 | $data = array(); |
| 1286 | 1286 | $data['cart_details'] = $this->cart_details; |
| 1287 | 1287 | $data['subtotal'] = $this->get_subtotal(); |
@@ -1289,45 +1289,45 @@ discard block |
||
| 1289 | 1289 | $data['tax'] = $this->get_tax(); |
| 1290 | 1290 | $data['total'] = $this->get_total(); |
| 1291 | 1291 | |
| 1292 | - if ( !empty( $this->cart_details ) && ( $this->is_parent() || $this->is_renewal() ) ) { |
|
| 1292 | + if (!empty($this->cart_details) && ($this->is_parent() || $this->is_renewal())) { |
|
| 1293 | 1293 | $is_free_trial = $this->is_free_trial(); |
| 1294 | - $discounts = $this->get_discounts( true ); |
|
| 1294 | + $discounts = $this->get_discounts(true); |
|
| 1295 | 1295 | |
| 1296 | - if ( $is_free_trial || !empty( $discounts ) ) { |
|
| 1296 | + if ($is_free_trial || !empty($discounts)) { |
|
| 1297 | 1297 | $first_use_only = false; |
| 1298 | 1298 | |
| 1299 | - if ( !empty( $discounts ) ) { |
|
| 1300 | - foreach ( $discounts as $key => $code ) { |
|
| 1301 | - if ( wpinv_discount_is_recurring( $code, true ) ) { |
|
| 1299 | + if (!empty($discounts)) { |
|
| 1300 | + foreach ($discounts as $key => $code) { |
|
| 1301 | + if (wpinv_discount_is_recurring($code, true)) { |
|
| 1302 | 1302 | $first_use_only = true; |
| 1303 | 1303 | break; |
| 1304 | 1304 | } |
| 1305 | 1305 | } |
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | - if ( !$first_use_only ) { |
|
| 1309 | - $data['subtotal'] = wpinv_round_amount( $this->subtotal ); |
|
| 1310 | - $data['discount'] = wpinv_round_amount( $this->discount ); |
|
| 1311 | - $data['tax'] = wpinv_round_amount( $this->tax ); |
|
| 1312 | - $data['total'] = wpinv_round_amount( $this->total ); |
|
| 1308 | + if (!$first_use_only) { |
|
| 1309 | + $data['subtotal'] = wpinv_round_amount($this->subtotal); |
|
| 1310 | + $data['discount'] = wpinv_round_amount($this->discount); |
|
| 1311 | + $data['tax'] = wpinv_round_amount($this->tax); |
|
| 1312 | + $data['total'] = wpinv_round_amount($this->total); |
|
| 1313 | 1313 | } else { |
| 1314 | 1314 | $cart_subtotal = 0; |
| 1315 | 1315 | $cart_discount = 0; |
| 1316 | 1316 | $cart_tax = 0; |
| 1317 | 1317 | |
| 1318 | - foreach ( $this->cart_details as $key => $item ) { |
|
| 1319 | - $item_quantity = $item['quantity'] > 0 ? absint( $item['quantity'] ) : 1; |
|
| 1320 | - $item_subtotal = !empty( $item['subtotal'] ) ? $item['subtotal'] : $item['item_price'] * $item_quantity; |
|
| 1318 | + foreach ($this->cart_details as $key => $item) { |
|
| 1319 | + $item_quantity = $item['quantity'] > 0 ? absint($item['quantity']) : 1; |
|
| 1320 | + $item_subtotal = !empty($item['subtotal']) ? $item['subtotal'] : $item['item_price'] * $item_quantity; |
|
| 1321 | 1321 | $item_discount = 0; |
| 1322 | - $item_tax = $item_subtotal > 0 && !empty( $item['vat_rate'] ) ? ( $item_subtotal * 0.01 * (float)$item['vat_rate'] ) : 0; |
|
| 1322 | + $item_tax = $item_subtotal > 0 && !empty($item['vat_rate']) ? ($item_subtotal * 0.01 * (float)$item['vat_rate']) : 0; |
|
| 1323 | 1323 | |
| 1324 | - if ( wpinv_prices_include_tax() ) { |
|
| 1325 | - $item_subtotal -= wpinv_round_amount( $item_tax ); |
|
| 1324 | + if (wpinv_prices_include_tax()) { |
|
| 1325 | + $item_subtotal -= wpinv_round_amount($item_tax); |
|
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | 1328 | $item_total = $item_subtotal - $item_discount + $item_tax; |
| 1329 | 1329 | // Do not allow totals to go negative |
| 1330 | - if ( $item_total < 0 ) { |
|
| 1330 | + if ($item_total < 0) { |
|
| 1331 | 1331 | $item_total = 0; |
| 1332 | 1332 | } |
| 1333 | 1333 | |
@@ -1335,113 +1335,113 @@ discard block |
||
| 1335 | 1335 | $cart_discount += (float)($item_discount); |
| 1336 | 1336 | $cart_tax += (float)($item_tax); |
| 1337 | 1337 | |
| 1338 | - $data['cart_details'][$key]['discount'] = wpinv_round_amount( $item_discount ); |
|
| 1339 | - $data['cart_details'][$key]['tax'] = wpinv_round_amount( $item_tax ); |
|
| 1340 | - $data['cart_details'][$key]['price'] = wpinv_round_amount( $item_total ); |
|
| 1338 | + $data['cart_details'][$key]['discount'] = wpinv_round_amount($item_discount); |
|
| 1339 | + $data['cart_details'][$key]['tax'] = wpinv_round_amount($item_tax); |
|
| 1340 | + $data['cart_details'][$key]['price'] = wpinv_round_amount($item_total); |
|
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | - $data['subtotal'] = wpinv_round_amount( $cart_subtotal ); |
|
| 1344 | - $data['discount'] = wpinv_round_amount( $cart_discount ); |
|
| 1345 | - $data['tax'] = wpinv_round_amount( $cart_tax ); |
|
| 1346 | - $data['total'] = wpinv_round_amount( $data['subtotal'] + $data['tax'] ); |
|
| 1343 | + $data['subtotal'] = wpinv_round_amount($cart_subtotal); |
|
| 1344 | + $data['discount'] = wpinv_round_amount($cart_discount); |
|
| 1345 | + $data['tax'] = wpinv_round_amount($cart_tax); |
|
| 1346 | + $data['total'] = wpinv_round_amount($data['subtotal'] + $data['tax']); |
|
| 1347 | 1347 | } |
| 1348 | 1348 | } |
| 1349 | 1349 | } |
| 1350 | 1350 | |
| 1351 | - $data = apply_filters( 'wpinv_get_invoice_recurring_details', $data, $this, $field, $currency ); |
|
| 1351 | + $data = apply_filters('wpinv_get_invoice_recurring_details', $data, $this, $field, $currency); |
|
| 1352 | 1352 | |
| 1353 | - if ( isset( $data[$field] ) ) { |
|
| 1354 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
| 1353 | + if (isset($data[$field])) { |
|
| 1354 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | 1357 | return $data; |
| 1358 | 1358 | } |
| 1359 | 1359 | |
| 1360 | - public function get_final_tax( $currency = false ) { |
|
| 1361 | - $final_total = wpinv_round_amount( $this->tax ); |
|
| 1362 | - if ( $currency ) { |
|
| 1363 | - $final_total = wpinv_price( wpinv_format_amount( $final_total, NULL, !$currency ), $this->get_currency() ); |
|
| 1360 | + public function get_final_tax($currency = false) { |
|
| 1361 | + $final_total = wpinv_round_amount($this->tax); |
|
| 1362 | + if ($currency) { |
|
| 1363 | + $final_total = wpinv_price(wpinv_format_amount($final_total, NULL, !$currency), $this->get_currency()); |
|
| 1364 | 1364 | } |
| 1365 | 1365 | |
| 1366 | - return apply_filters( 'wpinv_get_invoice_final_total', $final_total, $this, $currency ); |
|
| 1366 | + return apply_filters('wpinv_get_invoice_final_total', $final_total, $this, $currency); |
|
| 1367 | 1367 | } |
| 1368 | 1368 | |
| 1369 | - public function get_discounts( $array = false ) { |
|
| 1369 | + public function get_discounts($array = false) { |
|
| 1370 | 1370 | $discounts = $this->discounts; |
| 1371 | - if ( $array && $discounts ) { |
|
| 1372 | - $discounts = explode( ',', $discounts ); |
|
| 1371 | + if ($array && $discounts) { |
|
| 1372 | + $discounts = explode(',', $discounts); |
|
| 1373 | 1373 | } |
| 1374 | - return apply_filters( 'wpinv_payment_discounts', $discounts, $this->ID, $this, $array ); |
|
| 1374 | + return apply_filters('wpinv_payment_discounts', $discounts, $this->ID, $this, $array); |
|
| 1375 | 1375 | } |
| 1376 | 1376 | |
| 1377 | - public function get_discount( $currency = false, $dash = false ) { |
|
| 1378 | - if ( !empty( $this->discounts ) ) { |
|
| 1377 | + public function get_discount($currency = false, $dash = false) { |
|
| 1378 | + if (!empty($this->discounts)) { |
|
| 1379 | 1379 | global $ajax_cart_details; |
| 1380 | 1380 | $ajax_cart_details = $this->get_cart_details(); |
| 1381 | 1381 | |
| 1382 | - if ( !empty( $ajax_cart_details ) && count( $ajax_cart_details ) == count( $this->items ) ) { |
|
| 1382 | + if (!empty($ajax_cart_details) && count($ajax_cart_details) == count($this->items)) { |
|
| 1383 | 1383 | $cart_items = $ajax_cart_details; |
| 1384 | 1384 | } else { |
| 1385 | 1385 | $cart_items = $this->items; |
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | - $this->discount = wpinv_get_cart_items_discount_amount( $cart_items , $this->discounts ); |
|
| 1388 | + $this->discount = wpinv_get_cart_items_discount_amount($cart_items, $this->discounts); |
|
| 1389 | 1389 | } |
| 1390 | - $discount = wpinv_round_amount( $this->discount ); |
|
| 1390 | + $discount = wpinv_round_amount($this->discount); |
|
| 1391 | 1391 | $dash = $dash && $discount > 0 ? '–' : ''; |
| 1392 | 1392 | |
| 1393 | - if ( $currency ) { |
|
| 1394 | - $discount = wpinv_price( wpinv_format_amount( $discount, NULL, !$currency ), $this->get_currency() ); |
|
| 1393 | + if ($currency) { |
|
| 1394 | + $discount = wpinv_price(wpinv_format_amount($discount, NULL, !$currency), $this->get_currency()); |
|
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | - $discount = $dash . $discount; |
|
| 1397 | + $discount = $dash . $discount; |
|
| 1398 | 1398 | |
| 1399 | - return apply_filters( 'wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash ); |
|
| 1399 | + return apply_filters('wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash); |
|
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | 1402 | public function get_discount_code() { |
| 1403 | 1403 | return $this->discount_code; |
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | - public function get_tax( $currency = false ) { |
|
| 1407 | - $tax = wpinv_round_amount( $this->tax ); |
|
| 1406 | + public function get_tax($currency = false) { |
|
| 1407 | + $tax = wpinv_round_amount($this->tax); |
|
| 1408 | 1408 | |
| 1409 | - if ( $currency ) { |
|
| 1410 | - $tax = wpinv_price( wpinv_format_amount( $tax, NULL, !$currency ), $this->get_currency() ); |
|
| 1409 | + if ($currency) { |
|
| 1410 | + $tax = wpinv_price(wpinv_format_amount($tax, NULL, !$currency), $this->get_currency()); |
|
| 1411 | 1411 | } |
| 1412 | 1412 | |
| 1413 | - return apply_filters( 'wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency ); |
|
| 1413 | + return apply_filters('wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency); |
|
| 1414 | 1414 | } |
| 1415 | 1415 | |
| 1416 | - public function get_fees( $type = 'all' ) { |
|
| 1417 | - $fees = array(); |
|
| 1416 | + public function get_fees($type = 'all') { |
|
| 1417 | + $fees = array(); |
|
| 1418 | 1418 | |
| 1419 | - if ( ! empty( $this->fees ) && is_array( $this->fees ) ) { |
|
| 1420 | - foreach ( $this->fees as $fee ) { |
|
| 1421 | - if( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
| 1419 | + if (!empty($this->fees) && is_array($this->fees)) { |
|
| 1420 | + foreach ($this->fees as $fee) { |
|
| 1421 | + if ('all' != $type && !empty($fee['type']) && $type != $fee['type']) { |
|
| 1422 | 1422 | continue; |
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | - $fee['label'] = stripslashes( $fee['label'] ); |
|
| 1426 | - $fee['amount_display'] = wpinv_price( $fee['amount'], $this->get_currency() ); |
|
| 1427 | - $fees[] = $fee; |
|
| 1425 | + $fee['label'] = stripslashes($fee['label']); |
|
| 1426 | + $fee['amount_display'] = wpinv_price($fee['amount'], $this->get_currency()); |
|
| 1427 | + $fees[] = $fee; |
|
| 1428 | 1428 | } |
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | - return apply_filters( 'wpinv_get_invoice_fees', $fees, $this->ID, $this ); |
|
| 1431 | + return apply_filters('wpinv_get_invoice_fees', $fees, $this->ID, $this); |
|
| 1432 | 1432 | } |
| 1433 | 1433 | |
| 1434 | - public function get_fees_total( $type = 'all' ) { |
|
| 1435 | - $fees_total = (float) 0.00; |
|
| 1434 | + public function get_fees_total($type = 'all') { |
|
| 1435 | + $fees_total = (float)0.00; |
|
| 1436 | 1436 | |
| 1437 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
| 1438 | - if ( ! empty( $payment_fees ) ) { |
|
| 1439 | - foreach ( $payment_fees as $fee ) { |
|
| 1440 | - $fees_total += (float) $fee['amount']; |
|
| 1437 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
| 1438 | + if (!empty($payment_fees)) { |
|
| 1439 | + foreach ($payment_fees as $fee) { |
|
| 1440 | + $fees_total += (float)$fee['amount']; |
|
| 1441 | 1441 | } |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | - return apply_filters( 'wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this ); |
|
| 1444 | + return apply_filters('wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this); |
|
| 1445 | 1445 | /* |
| 1446 | 1446 | $fees = $this->get_fees( $type ); |
| 1447 | 1447 | |
@@ -1461,116 +1461,116 @@ discard block |
||
| 1461 | 1461 | } |
| 1462 | 1462 | |
| 1463 | 1463 | public function get_user_id() { |
| 1464 | - return apply_filters( 'wpinv_user_id', $this->user_id, $this->ID, $this ); |
|
| 1464 | + return apply_filters('wpinv_user_id', $this->user_id, $this->ID, $this); |
|
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | 1467 | public function get_first_name() { |
| 1468 | - return apply_filters( 'wpinv_first_name', $this->first_name, $this->ID, $this ); |
|
| 1468 | + return apply_filters('wpinv_first_name', $this->first_name, $this->ID, $this); |
|
| 1469 | 1469 | } |
| 1470 | 1470 | |
| 1471 | 1471 | public function get_last_name() { |
| 1472 | - return apply_filters( 'wpinv_last_name', $this->last_name, $this->ID, $this ); |
|
| 1472 | + return apply_filters('wpinv_last_name', $this->last_name, $this->ID, $this); |
|
| 1473 | 1473 | } |
| 1474 | 1474 | |
| 1475 | 1475 | public function get_user_full_name() { |
| 1476 | - return apply_filters( 'wpinv_user_full_name', $this->full_name, $this->ID, $this ); |
|
| 1476 | + return apply_filters('wpinv_user_full_name', $this->full_name, $this->ID, $this); |
|
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | 1479 | public function get_user_info() { |
| 1480 | - return apply_filters( 'wpinv_user_info', $this->user_info, $this->ID, $this ); |
|
| 1480 | + return apply_filters('wpinv_user_info', $this->user_info, $this->ID, $this); |
|
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | 1483 | public function get_email() { |
| 1484 | - return apply_filters( 'wpinv_user_email', $this->email, $this->ID, $this ); |
|
| 1484 | + return apply_filters('wpinv_user_email', $this->email, $this->ID, $this); |
|
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | 1487 | public function get_address() { |
| 1488 | - return apply_filters( 'wpinv_address', $this->address, $this->ID, $this ); |
|
| 1488 | + return apply_filters('wpinv_address', $this->address, $this->ID, $this); |
|
| 1489 | 1489 | } |
| 1490 | 1490 | |
| 1491 | 1491 | public function get_phone() { |
| 1492 | - return apply_filters( 'wpinv_phone', $this->phone, $this->ID, $this ); |
|
| 1492 | + return apply_filters('wpinv_phone', $this->phone, $this->ID, $this); |
|
| 1493 | 1493 | } |
| 1494 | 1494 | |
| 1495 | 1495 | public function get_number() { |
| 1496 | - return apply_filters( 'wpinv_number', $this->number, $this->ID, $this ); |
|
| 1496 | + return apply_filters('wpinv_number', $this->number, $this->ID, $this); |
|
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | 1499 | public function get_items() { |
| 1500 | - return apply_filters( 'wpinv_payment_meta_items', $this->items, $this->ID, $this ); |
|
| 1500 | + return apply_filters('wpinv_payment_meta_items', $this->items, $this->ID, $this); |
|
| 1501 | 1501 | } |
| 1502 | 1502 | |
| 1503 | 1503 | public function get_key() { |
| 1504 | - return apply_filters( 'wpinv_key', $this->key, $this->ID, $this ); |
|
| 1504 | + return apply_filters('wpinv_key', $this->key, $this->ID, $this); |
|
| 1505 | 1505 | } |
| 1506 | 1506 | |
| 1507 | 1507 | public function get_transaction_id() { |
| 1508 | - return apply_filters( 'wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
| 1508 | + return apply_filters('wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this); |
|
| 1509 | 1509 | } |
| 1510 | 1510 | |
| 1511 | 1511 | public function get_gateway() { |
| 1512 | - return apply_filters( 'wpinv_gateway', $this->gateway, $this->ID, $this ); |
|
| 1512 | + return apply_filters('wpinv_gateway', $this->gateway, $this->ID, $this); |
|
| 1513 | 1513 | } |
| 1514 | 1514 | |
| 1515 | 1515 | public function get_gateway_title() { |
| 1516 | - $this->gateway_title = !empty( $this->gateway_title ) ? $this->gateway_title : wpinv_get_gateway_checkout_label( $this->gateway ); |
|
| 1516 | + $this->gateway_title = !empty($this->gateway_title) ? $this->gateway_title : wpinv_get_gateway_checkout_label($this->gateway); |
|
| 1517 | 1517 | |
| 1518 | - return apply_filters( 'wpinv_gateway_title', $this->gateway_title, $this->ID, $this ); |
|
| 1518 | + return apply_filters('wpinv_gateway_title', $this->gateway_title, $this->ID, $this); |
|
| 1519 | 1519 | } |
| 1520 | 1520 | |
| 1521 | 1521 | public function get_currency() { |
| 1522 | - return apply_filters( 'wpinv_currency_code', $this->currency, $this->ID, $this ); |
|
| 1522 | + return apply_filters('wpinv_currency_code', $this->currency, $this->ID, $this); |
|
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | public function get_created_date() { |
| 1526 | - return apply_filters( 'wpinv_created_date', $this->date, $this->ID, $this ); |
|
| 1526 | + return apply_filters('wpinv_created_date', $this->date, $this->ID, $this); |
|
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | - public function get_due_date( $display = false ) { |
|
| 1530 | - $due_date = apply_filters( 'wpinv_due_date', $this->due_date, $this->ID, $this ); |
|
| 1529 | + public function get_due_date($display = false) { |
|
| 1530 | + $due_date = apply_filters('wpinv_due_date', $this->due_date, $this->ID, $this); |
|
| 1531 | 1531 | |
| 1532 | - if ( !$display || empty( $due_date ) ) { |
|
| 1532 | + if (!$display || empty($due_date)) { |
|
| 1533 | 1533 | return $due_date; |
| 1534 | 1534 | } |
| 1535 | 1535 | |
| 1536 | - return date_i18n( get_option( 'date_format' ), strtotime( $due_date ) ); |
|
| 1536 | + return date_i18n(get_option('date_format'), strtotime($due_date)); |
|
| 1537 | 1537 | } |
| 1538 | 1538 | |
| 1539 | 1539 | public function get_completed_date() { |
| 1540 | - return apply_filters( 'wpinv_completed_date', $this->completed_date, $this->ID, $this ); |
|
| 1540 | + return apply_filters('wpinv_completed_date', $this->completed_date, $this->ID, $this); |
|
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | - public function get_invoice_date( $formatted = true ) { |
|
| 1543 | + public function get_invoice_date($formatted = true) { |
|
| 1544 | 1544 | $date_completed = $this->completed_date; |
| 1545 | 1545 | $invoice_date = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |
| 1546 | 1546 | |
| 1547 | - if ( $invoice_date == '' ) { |
|
| 1547 | + if ($invoice_date == '') { |
|
| 1548 | 1548 | $date_created = $this->date; |
| 1549 | 1549 | $invoice_date = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? $date_created : ''; |
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | - if ( $formatted && $invoice_date ) { |
|
| 1553 | - $invoice_date = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) ); |
|
| 1552 | + if ($formatted && $invoice_date) { |
|
| 1553 | + $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date)); |
|
| 1554 | 1554 | } |
| 1555 | 1555 | |
| 1556 | - return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this ); |
|
| 1556 | + return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this); |
|
| 1557 | 1557 | } |
| 1558 | 1558 | |
| 1559 | 1559 | public function get_ip() { |
| 1560 | - return apply_filters( 'wpinv_user_ip', $this->ip, $this->ID, $this ); |
|
| 1560 | + return apply_filters('wpinv_user_ip', $this->ip, $this->ID, $this); |
|
| 1561 | 1561 | } |
| 1562 | 1562 | |
| 1563 | - public function has_status( $status ) { |
|
| 1564 | - return apply_filters( 'wpinv_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status ) ) || $this->get_status() === $status ? true : false, $this, $status ); |
|
| 1563 | + public function has_status($status) { |
|
| 1564 | + return apply_filters('wpinv_has_status', (is_array($status) && in_array($this->get_status(), $status)) || $this->get_status() === $status ? true : false, $this, $status); |
|
| 1565 | 1565 | } |
| 1566 | 1566 | |
| 1567 | - public function add_item( $item_id = 0, $args = array() ) { |
|
| 1567 | + public function add_item($item_id = 0, $args = array()) { |
|
| 1568 | 1568 | global $wpi_current_id, $wpi_item_id; |
| 1569 | 1569 | |
| 1570 | - $item = new WPInv_Item( $item_id ); |
|
| 1570 | + $item = new WPInv_Item($item_id); |
|
| 1571 | 1571 | |
| 1572 | 1572 | // Bail if this post isn't a item |
| 1573 | - if( !$item || $item->post_type !== 'wpi_item' ) { |
|
| 1573 | + if (!$item || $item->post_type !== 'wpi_item') { |
|
| 1574 | 1574 | return false; |
| 1575 | 1575 | } |
| 1576 | 1576 | |
@@ -1589,8 +1589,8 @@ discard block |
||
| 1589 | 1589 | 'fees' => array() |
| 1590 | 1590 | ); |
| 1591 | 1591 | |
| 1592 | - $args = wp_parse_args( apply_filters( 'wpinv_add_item_args', $args, $item->ID ), $defaults ); |
|
| 1593 | - $args['quantity'] = $has_quantities && $args['quantity'] > 0 ? absint( $args['quantity'] ) : 1; |
|
| 1592 | + $args = wp_parse_args(apply_filters('wpinv_add_item_args', $args, $item->ID), $defaults); |
|
| 1593 | + $args['quantity'] = $has_quantities && $args['quantity'] > 0 ? absint($args['quantity']) : 1; |
|
| 1594 | 1594 | |
| 1595 | 1595 | $wpi_current_id = $this->ID; |
| 1596 | 1596 | $wpi_item_id = $item->ID; |
@@ -1602,19 +1602,19 @@ discard block |
||
| 1602 | 1602 | $found_cart_key = false; |
| 1603 | 1603 | |
| 1604 | 1604 | if ($has_quantities) { |
| 1605 | - $this->cart_details = !empty( $this->cart_details ) ? array_values( $this->cart_details ) : $this->cart_details; |
|
| 1605 | + $this->cart_details = !empty($this->cart_details) ? array_values($this->cart_details) : $this->cart_details; |
|
| 1606 | 1606 | |
| 1607 | - foreach ( $this->items as $key => $cart_item ) { |
|
| 1608 | - if ( (int)$item_id !== (int)$cart_item['id'] ) { |
|
| 1607 | + foreach ($this->items as $key => $cart_item) { |
|
| 1608 | + if ((int)$item_id !== (int)$cart_item['id']) { |
|
| 1609 | 1609 | continue; |
| 1610 | 1610 | } |
| 1611 | 1611 | |
| 1612 | - $this->items[ $key ]['quantity'] += $args['quantity']; |
|
| 1612 | + $this->items[$key]['quantity'] += $args['quantity']; |
|
| 1613 | 1613 | break; |
| 1614 | 1614 | } |
| 1615 | 1615 | |
| 1616 | - foreach ( $this->cart_details as $cart_key => $cart_item ) { |
|
| 1617 | - if ( $item_id != $cart_item['id'] ) { |
|
| 1616 | + foreach ($this->cart_details as $cart_key => $cart_item) { |
|
| 1617 | + if ($item_id != $cart_item['id']) { |
|
| 1618 | 1618 | continue; |
| 1619 | 1619 | } |
| 1620 | 1620 | |
@@ -1626,29 +1626,29 @@ discard block |
||
| 1626 | 1626 | if ($has_quantities && $found_cart_key !== false) { |
| 1627 | 1627 | $cart_item = $this->cart_details[$found_cart_key]; |
| 1628 | 1628 | $item_price = $cart_item['item_price']; |
| 1629 | - $quantity = !empty( $cart_item['quantity'] ) ? $cart_item['quantity'] : 1; |
|
| 1630 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : 0; |
|
| 1629 | + $quantity = !empty($cart_item['quantity']) ? $cart_item['quantity'] : 1; |
|
| 1630 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : 0; |
|
| 1631 | 1631 | |
| 1632 | 1632 | $new_quantity = $quantity + $args['quantity']; |
| 1633 | 1633 | $subtotal = $item_price * $new_quantity; |
| 1634 | 1634 | |
| 1635 | 1635 | $args['quantity'] = $new_quantity; |
| 1636 | - $discount = !empty( $args['discount'] ) ? $args['discount'] : 0; |
|
| 1637 | - $tax = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0; |
|
| 1636 | + $discount = !empty($args['discount']) ? $args['discount'] : 0; |
|
| 1637 | + $tax = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float)$tax_rate) : 0; |
|
| 1638 | 1638 | |
| 1639 | 1639 | $discount_increased = $discount > 0 && $subtotal > 0 && $discount > (float)$cart_item['discount'] ? $discount - (float)$cart_item['discount'] : 0; |
| 1640 | 1640 | $tax_increased = $tax > 0 && $subtotal > 0 && $tax > (float)$cart_item['tax'] ? $tax - (float)$cart_item['tax'] : 0; |
| 1641 | 1641 | // The total increase equals the number removed * the item_price |
| 1642 | - $total_increased = wpinv_round_amount( $item_price ); |
|
| 1642 | + $total_increased = wpinv_round_amount($item_price); |
|
| 1643 | 1643 | |
| 1644 | - if ( wpinv_prices_include_tax() ) { |
|
| 1645 | - $subtotal -= wpinv_round_amount( $tax ); |
|
| 1644 | + if (wpinv_prices_include_tax()) { |
|
| 1645 | + $subtotal -= wpinv_round_amount($tax); |
|
| 1646 | 1646 | } |
| 1647 | 1647 | |
| 1648 | - $total = $subtotal - $discount + $tax; |
|
| 1648 | + $total = $subtotal - $discount + $tax; |
|
| 1649 | 1649 | |
| 1650 | 1650 | // Do not allow totals to go negative |
| 1651 | - if( $total < 0 ) { |
|
| 1651 | + if ($total < 0) { |
|
| 1652 | 1652 | $total = 0; |
| 1653 | 1653 | } |
| 1654 | 1654 | |
@@ -1664,25 +1664,25 @@ discard block |
||
| 1664 | 1664 | $this->cart_details[$found_cart_key] = $cart_item; |
| 1665 | 1665 | } else { |
| 1666 | 1666 | // Set custom price. |
| 1667 | - if ( $args['custom_price'] !== '' ) { |
|
| 1667 | + if ($args['custom_price'] !== '') { |
|
| 1668 | 1668 | $item_price = $args['custom_price']; |
| 1669 | 1669 | } else { |
| 1670 | 1670 | // Allow overriding the price |
| 1671 | - if ( false !== $args['item_price'] ) { |
|
| 1671 | + if (false !== $args['item_price']) { |
|
| 1672 | 1672 | $item_price = $args['item_price']; |
| 1673 | 1673 | } else { |
| 1674 | - $item_price = wpinv_get_item_price( $item->ID ); |
|
| 1674 | + $item_price = wpinv_get_item_price($item->ID); |
|
| 1675 | 1675 | } |
| 1676 | 1676 | } |
| 1677 | 1677 | |
| 1678 | 1678 | // Sanitizing the price here so we don't have a dozen calls later |
| 1679 | - $item_price = wpinv_sanitize_amount( $item_price ); |
|
| 1680 | - $subtotal = wpinv_round_amount( $item_price * $args['quantity'] ); |
|
| 1679 | + $item_price = wpinv_sanitize_amount($item_price); |
|
| 1680 | + $subtotal = wpinv_round_amount($item_price * $args['quantity']); |
|
| 1681 | 1681 | |
| 1682 | - $discount = !empty( $args['discount'] ) ? $args['discount'] : 0; |
|
| 1683 | - $tax_class = !empty( $args['vat_class'] ) ? $args['vat_class'] : ''; |
|
| 1684 | - $tax_rate = !empty( $args['vat_rate'] ) ? $args['vat_rate'] : 0; |
|
| 1685 | - $tax = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0; |
|
| 1682 | + $discount = !empty($args['discount']) ? $args['discount'] : 0; |
|
| 1683 | + $tax_class = !empty($args['vat_class']) ? $args['vat_class'] : ''; |
|
| 1684 | + $tax_rate = !empty($args['vat_rate']) ? $args['vat_rate'] : 0; |
|
| 1685 | + $tax = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float)$tax_rate) : 0; |
|
| 1686 | 1686 | |
| 1687 | 1687 | // Setup the items meta item |
| 1688 | 1688 | $new_item = array( |
@@ -1690,29 +1690,29 @@ discard block |
||
| 1690 | 1690 | 'quantity' => $args['quantity'], |
| 1691 | 1691 | ); |
| 1692 | 1692 | |
| 1693 | - $this->items[] = $new_item; |
|
| 1693 | + $this->items[] = $new_item; |
|
| 1694 | 1694 | |
| 1695 | - if ( wpinv_prices_include_tax() ) { |
|
| 1696 | - $subtotal -= wpinv_round_amount( $tax ); |
|
| 1695 | + if (wpinv_prices_include_tax()) { |
|
| 1696 | + $subtotal -= wpinv_round_amount($tax); |
|
| 1697 | 1697 | } |
| 1698 | 1698 | |
| 1699 | - $total = $subtotal - $discount + $tax; |
|
| 1699 | + $total = $subtotal - $discount + $tax; |
|
| 1700 | 1700 | |
| 1701 | 1701 | // Do not allow totals to go negative |
| 1702 | - if( $total < 0 ) { |
|
| 1702 | + if ($total < 0) { |
|
| 1703 | 1703 | $total = 0; |
| 1704 | 1704 | } |
| 1705 | 1705 | |
| 1706 | 1706 | $this->cart_details[] = array( |
| 1707 | 1707 | 'name' => !empty($args['name']) ? $args['name'] : $item->get_name(), |
| 1708 | 1708 | 'id' => $item->ID, |
| 1709 | - 'item_price' => wpinv_round_amount( $item_price ), |
|
| 1710 | - 'custom_price' => ( $args['custom_price'] !== '' ? wpinv_round_amount( $args['custom_price'] ) : '' ), |
|
| 1709 | + 'item_price' => wpinv_round_amount($item_price), |
|
| 1710 | + 'custom_price' => ($args['custom_price'] !== '' ? wpinv_round_amount($args['custom_price']) : ''), |
|
| 1711 | 1711 | 'quantity' => $args['quantity'], |
| 1712 | 1712 | 'discount' => $discount, |
| 1713 | - 'subtotal' => wpinv_round_amount( $subtotal ), |
|
| 1714 | - 'tax' => wpinv_round_amount( $tax ), |
|
| 1715 | - 'price' => wpinv_round_amount( $total ), |
|
| 1713 | + 'subtotal' => wpinv_round_amount($subtotal), |
|
| 1714 | + 'tax' => wpinv_round_amount($tax), |
|
| 1715 | + 'price' => wpinv_round_amount($total), |
|
| 1716 | 1716 | 'vat_rate' => $tax_rate, |
| 1717 | 1717 | 'vat_class' => $tax_class, |
| 1718 | 1718 | 'meta' => $args['meta'], |
@@ -1722,18 +1722,18 @@ discard block |
||
| 1722 | 1722 | $subtotal = $subtotal - $discount; |
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | - $added_item = end( $this->cart_details ); |
|
| 1726 | - $added_item['action'] = 'add'; |
|
| 1725 | + $added_item = end($this->cart_details); |
|
| 1726 | + $added_item['action'] = 'add'; |
|
| 1727 | 1727 | |
| 1728 | 1728 | $this->pending['items'][] = $added_item; |
| 1729 | 1729 | |
| 1730 | - $this->increase_subtotal( $subtotal ); |
|
| 1731 | - $this->increase_tax( $tax ); |
|
| 1730 | + $this->increase_subtotal($subtotal); |
|
| 1731 | + $this->increase_tax($tax); |
|
| 1732 | 1732 | |
| 1733 | 1733 | return true; |
| 1734 | 1734 | } |
| 1735 | 1735 | |
| 1736 | - public function remove_item( $item_id, $args = array() ) { |
|
| 1736 | + public function remove_item($item_id, $args = array()) { |
|
| 1737 | 1737 | // Set some defaults |
| 1738 | 1738 | $defaults = array( |
| 1739 | 1739 | 'quantity' => 1, |
@@ -1741,51 +1741,51 @@ discard block |
||
| 1741 | 1741 | 'custom_price' => '', |
| 1742 | 1742 | 'cart_index' => false, |
| 1743 | 1743 | ); |
| 1744 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1744 | + $args = wp_parse_args($args, $defaults); |
|
| 1745 | 1745 | |
| 1746 | 1746 | // Bail if this post isn't a item |
| 1747 | - if ( get_post_type( $item_id ) !== 'wpi_item' ) { |
|
| 1747 | + if (get_post_type($item_id) !== 'wpi_item') { |
|
| 1748 | 1748 | return false; |
| 1749 | 1749 | } |
| 1750 | 1750 | |
| 1751 | - $this->cart_details = !empty( $this->cart_details ) ? array_values( $this->cart_details ) : $this->cart_details; |
|
| 1751 | + $this->cart_details = !empty($this->cart_details) ? array_values($this->cart_details) : $this->cart_details; |
|
| 1752 | 1752 | |
| 1753 | - foreach ( $this->items as $key => $item ) { |
|
| 1754 | - if ( !empty($item['id']) && (int)$item_id !== (int)$item['id'] ) { |
|
| 1753 | + foreach ($this->items as $key => $item) { |
|
| 1754 | + if (!empty($item['id']) && (int)$item_id !== (int)$item['id']) { |
|
| 1755 | 1755 | continue; |
| 1756 | 1756 | } |
| 1757 | 1757 | |
| 1758 | - if ( false !== $args['cart_index'] ) { |
|
| 1759 | - $cart_index = absint( $args['cart_index'] ); |
|
| 1760 | - $cart_item = ! empty( $this->cart_details[ $cart_index ] ) ? $this->cart_details[ $cart_index ] : false; |
|
| 1758 | + if (false !== $args['cart_index']) { |
|
| 1759 | + $cart_index = absint($args['cart_index']); |
|
| 1760 | + $cart_item = !empty($this->cart_details[$cart_index]) ? $this->cart_details[$cart_index] : false; |
|
| 1761 | 1761 | |
| 1762 | - if ( ! empty( $cart_item ) ) { |
|
| 1762 | + if (!empty($cart_item)) { |
|
| 1763 | 1763 | // If the cart index item isn't the same item ID, don't remove it |
| 1764 | - if ( !empty($cart_item['id']) && $cart_item['id'] != $item['id'] ) { |
|
| 1764 | + if (!empty($cart_item['id']) && $cart_item['id'] != $item['id']) { |
|
| 1765 | 1765 | continue; |
| 1766 | 1766 | } |
| 1767 | 1767 | } |
| 1768 | 1768 | } |
| 1769 | 1769 | |
| 1770 | - $item_quantity = $this->items[ $key ]['quantity']; |
|
| 1771 | - if ( $item_quantity > $args['quantity'] ) { |
|
| 1772 | - $this->items[ $key ]['quantity'] -= $args['quantity']; |
|
| 1770 | + $item_quantity = $this->items[$key]['quantity']; |
|
| 1771 | + if ($item_quantity > $args['quantity']) { |
|
| 1772 | + $this->items[$key]['quantity'] -= $args['quantity']; |
|
| 1773 | 1773 | break; |
| 1774 | 1774 | } else { |
| 1775 | - unset( $this->items[ $key ] ); |
|
| 1775 | + unset($this->items[$key]); |
|
| 1776 | 1776 | break; |
| 1777 | 1777 | } |
| 1778 | 1778 | } |
| 1779 | 1779 | |
| 1780 | 1780 | $found_cart_key = false; |
| 1781 | - if ( false === $args['cart_index'] ) { |
|
| 1782 | - foreach ( $this->cart_details as $cart_key => $item ) { |
|
| 1783 | - if ( $item_id != $item['id'] ) { |
|
| 1781 | + if (false === $args['cart_index']) { |
|
| 1782 | + foreach ($this->cart_details as $cart_key => $item) { |
|
| 1783 | + if ($item_id != $item['id']) { |
|
| 1784 | 1784 | continue; |
| 1785 | 1785 | } |
| 1786 | 1786 | |
| 1787 | - if ( false !== $args['item_price'] ) { |
|
| 1788 | - if ( isset( $item['item_price'] ) && (float) $args['item_price'] != (float) $item['item_price'] ) { |
|
| 1787 | + if (false !== $args['item_price']) { |
|
| 1788 | + if (isset($item['item_price']) && (float)$args['item_price'] != (float)$item['item_price']) { |
|
| 1789 | 1789 | continue; |
| 1790 | 1790 | } |
| 1791 | 1791 | } |
@@ -1794,13 +1794,13 @@ discard block |
||
| 1794 | 1794 | break; |
| 1795 | 1795 | } |
| 1796 | 1796 | } else { |
| 1797 | - $cart_index = absint( $args['cart_index'] ); |
|
| 1797 | + $cart_index = absint($args['cart_index']); |
|
| 1798 | 1798 | |
| 1799 | - if ( ! array_key_exists( $cart_index, $this->cart_details ) ) { |
|
| 1799 | + if (!array_key_exists($cart_index, $this->cart_details)) { |
|
| 1800 | 1800 | return false; // Invalid cart index passed. |
| 1801 | 1801 | } |
| 1802 | 1802 | |
| 1803 | - if ( (int) $this->cart_details[ $cart_index ]['id'] > 0 && (int) $this->cart_details[ $cart_index ]['id'] !== (int) $item_id ) { |
|
| 1803 | + if ((int)$this->cart_details[$cart_index]['id'] > 0 && (int)$this->cart_details[$cart_index]['id'] !== (int)$item_id) { |
|
| 1804 | 1804 | return false; // We still need the proper Item ID to be sure. |
| 1805 | 1805 | } |
| 1806 | 1806 | |
@@ -1808,41 +1808,41 @@ discard block |
||
| 1808 | 1808 | } |
| 1809 | 1809 | |
| 1810 | 1810 | $cart_item = $this->cart_details[$found_cart_key]; |
| 1811 | - $quantity = !empty( $cart_item['quantity'] ) ? $cart_item['quantity'] : 1; |
|
| 1811 | + $quantity = !empty($cart_item['quantity']) ? $cart_item['quantity'] : 1; |
|
| 1812 | 1812 | |
| 1813 | - if ( count( $this->cart_details ) == 1 && ( $quantity - $args['quantity'] ) < 1 ) { |
|
| 1813 | + if (count($this->cart_details) == 1 && ($quantity - $args['quantity']) < 1) { |
|
| 1814 | 1814 | return false; // Invoice must contain at least one item. |
| 1815 | 1815 | } |
| 1816 | 1816 | |
| 1817 | - $discounts = $this->get_discounts(); |
|
| 1817 | + $discounts = $this->get_discounts(); |
|
| 1818 | 1818 | |
| 1819 | - if ( $quantity > $args['quantity'] ) { |
|
| 1819 | + if ($quantity > $args['quantity']) { |
|
| 1820 | 1820 | $item_price = $cart_item['item_price']; |
| 1821 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : 0; |
|
| 1821 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : 0; |
|
| 1822 | 1822 | |
| 1823 | - $new_quantity = max( $quantity - $args['quantity'], 1); |
|
| 1823 | + $new_quantity = max($quantity - $args['quantity'], 1); |
|
| 1824 | 1824 | $subtotal = $item_price * $new_quantity; |
| 1825 | 1825 | |
| 1826 | 1826 | $args['quantity'] = $new_quantity; |
| 1827 | - $discount = !empty( $cart_item['discount'] ) ? $cart_item['discount'] : 0; |
|
| 1828 | - $tax = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0; |
|
| 1827 | + $discount = !empty($cart_item['discount']) ? $cart_item['discount'] : 0; |
|
| 1828 | + $tax = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float)$tax_rate) : 0; |
|
| 1829 | 1829 | |
| 1830 | - $discount_decrease = (float)$cart_item['discount'] > 0 && $quantity > 0 ? wpinv_round_amount( ( (float)$cart_item['discount'] / $quantity ) ) : 0; |
|
| 1830 | + $discount_decrease = (float)$cart_item['discount'] > 0 && $quantity > 0 ? wpinv_round_amount(((float)$cart_item['discount'] / $quantity)) : 0; |
|
| 1831 | 1831 | $discount_decrease = $discount > 0 && $subtotal > 0 && (float)$cart_item['discount'] > $discount ? (float)$cart_item['discount'] - $discount : $discount_decrease; |
| 1832 | - $tax_decrease = (float)$cart_item['tax'] > 0 && $quantity > 0 ? wpinv_round_amount( ( (float)$cart_item['tax'] / $quantity ) ) : 0; |
|
| 1832 | + $tax_decrease = (float)$cart_item['tax'] > 0 && $quantity > 0 ? wpinv_round_amount(((float)$cart_item['tax'] / $quantity)) : 0; |
|
| 1833 | 1833 | $tax_decrease = $tax > 0 && $subtotal > 0 && (float)$cart_item['tax'] > $tax ? (float)$cart_item['tax'] - $tax : $tax_decrease; |
| 1834 | 1834 | |
| 1835 | 1835 | // The total increase equals the number removed * the item_price |
| 1836 | - $total_decrease = wpinv_round_amount( $item_price ); |
|
| 1836 | + $total_decrease = wpinv_round_amount($item_price); |
|
| 1837 | 1837 | |
| 1838 | - if ( wpinv_prices_include_tax() ) { |
|
| 1839 | - $subtotal -= wpinv_round_amount( $tax ); |
|
| 1838 | + if (wpinv_prices_include_tax()) { |
|
| 1839 | + $subtotal -= wpinv_round_amount($tax); |
|
| 1840 | 1840 | } |
| 1841 | 1841 | |
| 1842 | - $total = $subtotal - $discount + $tax; |
|
| 1842 | + $total = $subtotal - $discount + $tax; |
|
| 1843 | 1843 | |
| 1844 | 1844 | // Do not allow totals to go negative |
| 1845 | - if( $total < 0 ) { |
|
| 1845 | + if ($total < 0) { |
|
| 1846 | 1846 | $total = 0; |
| 1847 | 1847 | } |
| 1848 | 1848 | |
@@ -1861,16 +1861,16 @@ discard block |
||
| 1861 | 1861 | |
| 1862 | 1862 | $this->cart_details[$found_cart_key] = $cart_item; |
| 1863 | 1863 | |
| 1864 | - $remove_item = end( $this->cart_details ); |
|
| 1864 | + $remove_item = end($this->cart_details); |
|
| 1865 | 1865 | } else { |
| 1866 | 1866 | $item_price = $cart_item['item_price']; |
| 1867 | - $discount = !empty( $cart_item['discount'] ) ? $cart_item['discount'] : 0; |
|
| 1868 | - $tax = !empty( $cart_item['tax'] ) ? $cart_item['tax'] : 0; |
|
| 1867 | + $discount = !empty($cart_item['discount']) ? $cart_item['discount'] : 0; |
|
| 1868 | + $tax = !empty($cart_item['tax']) ? $cart_item['tax'] : 0; |
|
| 1869 | 1869 | |
| 1870 | - $subtotal_decrease = ( $item_price * $quantity ) - $discount; |
|
| 1870 | + $subtotal_decrease = ($item_price * $quantity) - $discount; |
|
| 1871 | 1871 | $tax_decrease = $tax; |
| 1872 | 1872 | |
| 1873 | - unset( $this->cart_details[$found_cart_key] ); |
|
| 1873 | + unset($this->cart_details[$found_cart_key]); |
|
| 1874 | 1874 | |
| 1875 | 1875 | $remove_item = $args; |
| 1876 | 1876 | $remove_item['id'] = $item_id; |
@@ -1881,8 +1881,8 @@ discard block |
||
| 1881 | 1881 | $remove_item['action'] = 'remove'; |
| 1882 | 1882 | $this->pending['items'][] = $remove_item; |
| 1883 | 1883 | |
| 1884 | - $this->decrease_subtotal( $subtotal_decrease ); |
|
| 1885 | - $this->decrease_tax( $tax_decrease ); |
|
| 1884 | + $this->decrease_subtotal($subtotal_decrease); |
|
| 1885 | + $this->decrease_tax($tax_decrease); |
|
| 1886 | 1886 | |
| 1887 | 1887 | return true; |
| 1888 | 1888 | } |
@@ -1890,7 +1890,7 @@ discard block |
||
| 1890 | 1890 | public function update_items($temp = false) { |
| 1891 | 1891 | global $wpinv_euvat, $wpi_current_id, $wpi_item_id, $wpi_nosave; |
| 1892 | 1892 | |
| 1893 | - if ( !empty( $this->cart_details ) ) { |
|
| 1893 | + if (!empty($this->cart_details)) { |
|
| 1894 | 1894 | $wpi_nosave = $temp; |
| 1895 | 1895 | $cart_subtotal = 0; |
| 1896 | 1896 | $cart_discount = 0; |
@@ -1900,42 +1900,42 @@ discard block |
||
| 1900 | 1900 | $_POST['wpinv_country'] = $this->country; |
| 1901 | 1901 | $_POST['wpinv_state'] = $this->state; |
| 1902 | 1902 | |
| 1903 | - foreach ( $this->cart_details as $key => $item ) { |
|
| 1903 | + foreach ($this->cart_details as $key => $item) { |
|
| 1904 | 1904 | $item_price = $item['item_price']; |
| 1905 | - $quantity = wpinv_item_quantities_enabled() && $item['quantity'] > 0 ? absint( $item['quantity'] ) : 1; |
|
| 1906 | - $amount = wpinv_round_amount( $item_price * $quantity ); |
|
| 1905 | + $quantity = wpinv_item_quantities_enabled() && $item['quantity'] > 0 ? absint($item['quantity']) : 1; |
|
| 1906 | + $amount = wpinv_round_amount($item_price * $quantity); |
|
| 1907 | 1907 | $subtotal = $item_price * $quantity; |
| 1908 | 1908 | |
| 1909 | 1909 | $wpi_current_id = $this->ID; |
| 1910 | 1910 | $wpi_item_id = $item['id']; |
| 1911 | 1911 | |
| 1912 | - $discount = wpinv_get_cart_item_discount_amount( $item, $this->get_discounts() ); |
|
| 1912 | + $discount = wpinv_get_cart_item_discount_amount($item, $this->get_discounts()); |
|
| 1913 | 1913 | |
| 1914 | - $tax_rate = wpinv_get_tax_rate( $this->country, $this->state, $wpi_item_id ); |
|
| 1915 | - $tax_class = $wpinv_euvat->get_item_class( $wpi_item_id ); |
|
| 1916 | - $tax = $item_price > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0; |
|
| 1914 | + $tax_rate = wpinv_get_tax_rate($this->country, $this->state, $wpi_item_id); |
|
| 1915 | + $tax_class = $wpinv_euvat->get_item_class($wpi_item_id); |
|
| 1916 | + $tax = $item_price > 0 ? (($subtotal - $discount) * 0.01 * (float)$tax_rate) : 0; |
|
| 1917 | 1917 | |
| 1918 | - if ( wpinv_prices_include_tax() ) { |
|
| 1919 | - $subtotal -= wpinv_round_amount( $tax ); |
|
| 1918 | + if (wpinv_prices_include_tax()) { |
|
| 1919 | + $subtotal -= wpinv_round_amount($tax); |
|
| 1920 | 1920 | } |
| 1921 | 1921 | |
| 1922 | - $total = $subtotal - $discount + $tax; |
|
| 1922 | + $total = $subtotal - $discount + $tax; |
|
| 1923 | 1923 | |
| 1924 | 1924 | // Do not allow totals to go negative |
| 1925 | - if( $total < 0 ) { |
|
| 1925 | + if ($total < 0) { |
|
| 1926 | 1926 | $total = 0; |
| 1927 | 1927 | } |
| 1928 | 1928 | |
| 1929 | 1929 | $cart_details[] = array( |
| 1930 | 1930 | 'id' => $item['id'], |
| 1931 | 1931 | 'name' => $item['name'], |
| 1932 | - 'item_price' => wpinv_round_amount( $item_price ), |
|
| 1933 | - 'custom_price'=> ( isset( $item['custom_price'] ) ? $item['custom_price'] : '' ), |
|
| 1932 | + 'item_price' => wpinv_round_amount($item_price), |
|
| 1933 | + 'custom_price'=> (isset($item['custom_price']) ? $item['custom_price'] : ''), |
|
| 1934 | 1934 | 'quantity' => $quantity, |
| 1935 | 1935 | 'discount' => $discount, |
| 1936 | - 'subtotal' => wpinv_round_amount( $subtotal ), |
|
| 1937 | - 'tax' => wpinv_round_amount( $tax ), |
|
| 1938 | - 'price' => wpinv_round_amount( $total ), |
|
| 1936 | + 'subtotal' => wpinv_round_amount($subtotal), |
|
| 1937 | + 'tax' => wpinv_round_amount($tax), |
|
| 1938 | + 'price' => wpinv_round_amount($total), |
|
| 1939 | 1939 | 'vat_rate' => $tax_rate, |
| 1940 | 1940 | 'vat_class' => $tax_class, |
| 1941 | 1941 | 'meta' => isset($item['meta']) ? $item['meta'] : array(), |
@@ -1946,9 +1946,9 @@ discard block |
||
| 1946 | 1946 | $cart_discount += (float)($discount); |
| 1947 | 1947 | $cart_tax += (float)($tax); |
| 1948 | 1948 | } |
| 1949 | - $this->subtotal = wpinv_round_amount( $cart_subtotal ); |
|
| 1950 | - $this->tax = wpinv_round_amount( $cart_tax ); |
|
| 1951 | - $this->discount = wpinv_round_amount( $cart_discount ); |
|
| 1949 | + $this->subtotal = wpinv_round_amount($cart_subtotal); |
|
| 1950 | + $this->tax = wpinv_round_amount($cart_tax); |
|
| 1951 | + $this->discount = wpinv_round_amount($cart_discount); |
|
| 1952 | 1952 | |
| 1953 | 1953 | $this->recalculate_total(); |
| 1954 | 1954 | |
@@ -1960,225 +1960,225 @@ discard block |
||
| 1960 | 1960 | |
| 1961 | 1961 | public function recalculate_totals($temp = false) { |
| 1962 | 1962 | $this->update_items($temp); |
| 1963 | - $this->save( true ); |
|
| 1963 | + $this->save(true); |
|
| 1964 | 1964 | |
| 1965 | 1965 | return $this; |
| 1966 | 1966 | } |
| 1967 | 1967 | |
| 1968 | 1968 | public function needs_payment() { |
| 1969 | - $valid_invoice_statuses = apply_filters( 'wpinv_valid_invoice_statuses_for_payment', array( 'wpi-pending' ), $this ); |
|
| 1969 | + $valid_invoice_statuses = apply_filters('wpinv_valid_invoice_statuses_for_payment', array('wpi-pending'), $this); |
|
| 1970 | 1970 | |
| 1971 | - if ( $this->has_status( $valid_invoice_statuses ) && ( $this->get_total() > 0 || $this->is_free_trial() || $this->is_free() ) ) { |
|
| 1971 | + if ($this->has_status($valid_invoice_statuses) && ($this->get_total() > 0 || $this->is_free_trial() || $this->is_free())) { |
|
| 1972 | 1972 | $needs_payment = true; |
| 1973 | 1973 | } else { |
| 1974 | 1974 | $needs_payment = false; |
| 1975 | 1975 | } |
| 1976 | 1976 | |
| 1977 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this, $valid_invoice_statuses ); |
|
| 1977 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this, $valid_invoice_statuses); |
|
| 1978 | 1978 | } |
| 1979 | 1979 | |
| 1980 | - public function get_checkout_payment_url( $with_key = false, $secret = false ) { |
|
| 1980 | + public function get_checkout_payment_url($with_key = false, $secret = false) { |
|
| 1981 | 1981 | $pay_url = wpinv_get_checkout_uri(); |
| 1982 | 1982 | |
| 1983 | - if ( is_ssl() ) { |
|
| 1984 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
| 1983 | + if (is_ssl()) { |
|
| 1984 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | 1987 | $key = $this->get_key(); |
| 1988 | 1988 | |
| 1989 | - if ( $with_key ) { |
|
| 1990 | - $pay_url = add_query_arg( 'invoice_key', $key, $pay_url ); |
|
| 1989 | + if ($with_key) { |
|
| 1990 | + $pay_url = add_query_arg('invoice_key', $key, $pay_url); |
|
| 1991 | 1991 | } else { |
| 1992 | - $pay_url = add_query_arg( array( 'wpi_action' => 'pay_for_invoice', 'invoice_key' => $key ), $pay_url ); |
|
| 1992 | + $pay_url = add_query_arg(array('wpi_action' => 'pay_for_invoice', 'invoice_key' => $key), $pay_url); |
|
| 1993 | 1993 | } |
| 1994 | 1994 | |
| 1995 | - if ( $secret ) { |
|
| 1996 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $key ) ), $pay_url ); |
|
| 1995 | + if ($secret) { |
|
| 1996 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $key)), $pay_url); |
|
| 1997 | 1997 | } |
| 1998 | 1998 | |
| 1999 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $with_key, $secret ); |
|
| 1999 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $with_key, $secret); |
|
| 2000 | 2000 | } |
| 2001 | 2001 | |
| 2002 | - public function get_view_url( $secret = false, $with_key = false ) { |
|
| 2003 | - $print_url = get_permalink( $this->ID ); |
|
| 2002 | + public function get_view_url($secret = false, $with_key = false) { |
|
| 2003 | + $print_url = get_permalink($this->ID); |
|
| 2004 | 2004 | |
| 2005 | - if ( $secret ) { |
|
| 2006 | - $print_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $print_url ); |
|
| 2005 | + if ($secret) { |
|
| 2006 | + $print_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $print_url); |
|
| 2007 | 2007 | } |
| 2008 | 2008 | |
| 2009 | - if ( $with_key ) { |
|
| 2010 | - $print_url = add_query_arg( 'invoice_key', $this->get_key(), $print_url ); |
|
| 2009 | + if ($with_key) { |
|
| 2010 | + $print_url = add_query_arg('invoice_key', $this->get_key(), $print_url); |
|
| 2011 | 2011 | } |
| 2012 | 2012 | |
| 2013 | - return apply_filters( 'wpinv_get_view_url', $print_url, $this, $secret, $with_key ); |
|
| 2013 | + return apply_filters('wpinv_get_view_url', $print_url, $this, $secret, $with_key); |
|
| 2014 | 2014 | } |
| 2015 | 2015 | |
| 2016 | - public function generate_key( $string = '' ) { |
|
| 2017 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 2018 | - return strtolower( md5( $string . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) ); // Unique key |
|
| 2016 | + public function generate_key($string = '') { |
|
| 2017 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 2018 | + return strtolower(md5($string . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))); // Unique key |
|
| 2019 | 2019 | } |
| 2020 | 2020 | |
| 2021 | 2021 | public function is_recurring() { |
| 2022 | - if ( empty( $this->cart_details ) ) { |
|
| 2022 | + if (empty($this->cart_details)) { |
|
| 2023 | 2023 | return false; |
| 2024 | 2024 | } |
| 2025 | 2025 | |
| 2026 | 2026 | $has_subscription = false; |
| 2027 | - foreach( $this->cart_details as $cart_item ) { |
|
| 2028 | - if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] ) ) { |
|
| 2027 | + foreach ($this->cart_details as $cart_item) { |
|
| 2028 | + if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) { |
|
| 2029 | 2029 | $has_subscription = true; |
| 2030 | 2030 | break; |
| 2031 | 2031 | } |
| 2032 | 2032 | } |
| 2033 | 2033 | |
| 2034 | - if ( count( $this->cart_details ) > 1 ) { |
|
| 2034 | + if (count($this->cart_details) > 1) { |
|
| 2035 | 2035 | $has_subscription = false; |
| 2036 | 2036 | } |
| 2037 | 2037 | |
| 2038 | - return apply_filters( 'wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details ); |
|
| 2038 | + return apply_filters('wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details); |
|
| 2039 | 2039 | } |
| 2040 | 2040 | |
| 2041 | 2041 | public function is_free_trial() { |
| 2042 | 2042 | $is_free_trial = false; |
| 2043 | 2043 | |
| 2044 | - if ( $this->is_parent() && $item = $this->get_recurring( true ) ) { |
|
| 2045 | - if ( !empty( $item ) && $item->has_free_trial() ) { |
|
| 2044 | + if ($this->is_parent() && $item = $this->get_recurring(true)) { |
|
| 2045 | + if (!empty($item) && $item->has_free_trial()) { |
|
| 2046 | 2046 | $is_free_trial = true; |
| 2047 | 2047 | } |
| 2048 | 2048 | } |
| 2049 | 2049 | |
| 2050 | - return apply_filters( 'wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details ); |
|
| 2050 | + return apply_filters('wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details); |
|
| 2051 | 2051 | } |
| 2052 | 2052 | |
| 2053 | - public function get_recurring( $object = false ) { |
|
| 2053 | + public function get_recurring($object = false) { |
|
| 2054 | 2054 | $item = NULL; |
| 2055 | 2055 | |
| 2056 | - if ( empty( $this->cart_details ) ) { |
|
| 2056 | + if (empty($this->cart_details)) { |
|
| 2057 | 2057 | return $item; |
| 2058 | 2058 | } |
| 2059 | 2059 | |
| 2060 | - foreach( $this->cart_details as $cart_item ) { |
|
| 2061 | - if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] ) ) { |
|
| 2060 | + foreach ($this->cart_details as $cart_item) { |
|
| 2061 | + if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) { |
|
| 2062 | 2062 | $item = $cart_item['id']; |
| 2063 | 2063 | break; |
| 2064 | 2064 | } |
| 2065 | 2065 | } |
| 2066 | 2066 | |
| 2067 | - if ( $object ) { |
|
| 2068 | - $item = $item ? new WPInv_Item( $item ) : NULL; |
|
| 2067 | + if ($object) { |
|
| 2068 | + $item = $item ? new WPInv_Item($item) : NULL; |
|
| 2069 | 2069 | |
| 2070 | - apply_filters( 'wpinv_invoice_get_recurring_item', $item, $this ); |
|
| 2070 | + apply_filters('wpinv_invoice_get_recurring_item', $item, $this); |
|
| 2071 | 2071 | } |
| 2072 | 2072 | |
| 2073 | - return apply_filters( 'wpinv_invoice_get_recurring_item_id', $item, $this ); |
|
| 2073 | + return apply_filters('wpinv_invoice_get_recurring_item_id', $item, $this); |
|
| 2074 | 2074 | } |
| 2075 | 2075 | |
| 2076 | 2076 | public function get_subscription_name() { |
| 2077 | - $item = $this->get_recurring( true ); |
|
| 2077 | + $item = $this->get_recurring(true); |
|
| 2078 | 2078 | |
| 2079 | - if ( empty( $item ) ) { |
|
| 2079 | + if (empty($item)) { |
|
| 2080 | 2080 | return NULL; |
| 2081 | 2081 | } |
| 2082 | 2082 | |
| 2083 | - if ( !($name = $item->get_name()) ) { |
|
| 2083 | + if (!($name = $item->get_name())) { |
|
| 2084 | 2084 | $name = $item->post_name; |
| 2085 | 2085 | } |
| 2086 | 2086 | |
| 2087 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $name, $this ); |
|
| 2087 | + return apply_filters('wpinv_invoice_get_subscription_name', $name, $this); |
|
| 2088 | 2088 | } |
| 2089 | 2089 | |
| 2090 | 2090 | public function get_expiration() { |
| 2091 | - $expiration = $this->get_meta( '_wpinv_subscr_expiration', true ); |
|
| 2091 | + $expiration = $this->get_meta('_wpinv_subscr_expiration', true); |
|
| 2092 | 2092 | return $expiration; |
| 2093 | 2093 | } |
| 2094 | 2094 | |
| 2095 | - public function get_cancelled_date( $formatted = true ) { |
|
| 2096 | - $cancelled_date = $this->get_subscription_status() == 'cancelled' ? $this->get_meta( '_wpinv_subscr_cancelled_on', true ) : ''; |
|
| 2095 | + public function get_cancelled_date($formatted = true) { |
|
| 2096 | + $cancelled_date = $this->get_subscription_status() == 'cancelled' ? $this->get_meta('_wpinv_subscr_cancelled_on', true) : ''; |
|
| 2097 | 2097 | |
| 2098 | - if ( $formatted && $cancelled_date ) { |
|
| 2099 | - $cancelled_date = date_i18n( get_option( 'date_format' ), strtotime( $cancelled_date ) ); |
|
| 2098 | + if ($formatted && $cancelled_date) { |
|
| 2099 | + $cancelled_date = date_i18n(get_option('date_format'), strtotime($cancelled_date)); |
|
| 2100 | 2100 | } |
| 2101 | 2101 | |
| 2102 | 2102 | return $cancelled_date; |
| 2103 | 2103 | } |
| 2104 | 2104 | |
| 2105 | - public function get_trial_end_date( $formatted = true ) { |
|
| 2106 | - if ( !$this->is_free_trial() || !$this->is_paid() ) { |
|
| 2105 | + public function get_trial_end_date($formatted = true) { |
|
| 2106 | + if (!$this->is_free_trial() || !$this->is_paid()) { |
|
| 2107 | 2107 | return NULL; |
| 2108 | 2108 | } |
| 2109 | 2109 | |
| 2110 | - $trial_end_date = $this->get_subscription_status() == 'trialing' ? $this->get_meta( '_wpinv_subscr_trial_end', true ) : ''; |
|
| 2110 | + $trial_end_date = $this->get_subscription_status() == 'trialing' ? $this->get_meta('_wpinv_subscr_trial_end', true) : ''; |
|
| 2111 | 2111 | |
| 2112 | - if ( empty( $trial_end_date ) ) { |
|
| 2113 | - $trial_start_time = strtotime( $this->get_subscription_start() ); |
|
| 2114 | - $trial_start_time += ( wpinv_period_in_days( $this->get_subscription_trial_interval(), $this->get_subscription_trial_period() ) * DAY_IN_SECONDS ) ; |
|
| 2112 | + if (empty($trial_end_date)) { |
|
| 2113 | + $trial_start_time = strtotime($this->get_subscription_start()); |
|
| 2114 | + $trial_start_time += (wpinv_period_in_days($this->get_subscription_trial_interval(), $this->get_subscription_trial_period()) * DAY_IN_SECONDS); |
|
| 2115 | 2115 | |
| 2116 | - $trial_end_date = date_i18n( 'Y-m-d H:i:s', $trial_start_time ); |
|
| 2116 | + $trial_end_date = date_i18n('Y-m-d H:i:s', $trial_start_time); |
|
| 2117 | 2117 | } |
| 2118 | 2118 | |
| 2119 | - if ( $formatted && $trial_end_date ) { |
|
| 2120 | - $trial_end_date = date_i18n( get_option( 'date_format' ), strtotime( $trial_end_date ) ); |
|
| 2119 | + if ($formatted && $trial_end_date) { |
|
| 2120 | + $trial_end_date = date_i18n(get_option('date_format'), strtotime($trial_end_date)); |
|
| 2121 | 2121 | } |
| 2122 | 2122 | |
| 2123 | 2123 | return $trial_end_date; |
| 2124 | 2124 | } |
| 2125 | 2125 | |
| 2126 | - public function get_subscription_created( $default = true ) { |
|
| 2127 | - $created = $this->get_meta( '_wpinv_subscr_created', true ); |
|
| 2126 | + public function get_subscription_created($default = true) { |
|
| 2127 | + $created = $this->get_meta('_wpinv_subscr_created', true); |
|
| 2128 | 2128 | |
| 2129 | - if ( empty( $created ) && $default ) { |
|
| 2129 | + if (empty($created) && $default) { |
|
| 2130 | 2130 | $created = $this->date; |
| 2131 | 2131 | } |
| 2132 | 2132 | return $created; |
| 2133 | 2133 | } |
| 2134 | 2134 | |
| 2135 | - public function get_subscription_start( $formatted = true ) { |
|
| 2136 | - if ( !$this->is_paid() ) { |
|
| 2135 | + public function get_subscription_start($formatted = true) { |
|
| 2136 | + if (!$this->is_paid()) { |
|
| 2137 | 2137 | return '-'; |
| 2138 | 2138 | } |
| 2139 | - $start = $this->get_subscription_created(); |
|
| 2139 | + $start = $this->get_subscription_created(); |
|
| 2140 | 2140 | |
| 2141 | - if ( $formatted ) { |
|
| 2142 | - $date = date_i18n( get_option( 'date_format' ), strtotime( $start ) ); |
|
| 2141 | + if ($formatted) { |
|
| 2142 | + $date = date_i18n(get_option('date_format'), strtotime($start)); |
|
| 2143 | 2143 | } else { |
| 2144 | - $date = date_i18n( 'Y-m-d H:i:s', strtotime( $start ) ); |
|
| 2144 | + $date = date_i18n('Y-m-d H:i:s', strtotime($start)); |
|
| 2145 | 2145 | } |
| 2146 | 2146 | |
| 2147 | 2147 | return $date; |
| 2148 | 2148 | } |
| 2149 | 2149 | |
| 2150 | - public function get_subscription_end( $formatted = true ) { |
|
| 2151 | - if ( !$this->is_paid() ) { |
|
| 2150 | + public function get_subscription_end($formatted = true) { |
|
| 2151 | + if (!$this->is_paid()) { |
|
| 2152 | 2152 | return '-'; |
| 2153 | 2153 | } |
| 2154 | 2154 | $start = $this->get_subscription_created(); |
| 2155 | 2155 | $interval = $this->get_subscription_interval(); |
| 2156 | - $period = $this->get_subscription_period( true ); |
|
| 2156 | + $period = $this->get_subscription_period(true); |
|
| 2157 | 2157 | $bill_times = (int)$this->get_bill_times(); |
| 2158 | 2158 | |
| 2159 | - if ( $bill_times == 0 ) { |
|
| 2160 | - return $formatted ? __( 'Until cancelled', 'invoicing' ) : $bill_times; |
|
| 2159 | + if ($bill_times == 0) { |
|
| 2160 | + return $formatted ? __('Until cancelled', 'invoicing') : $bill_times; |
|
| 2161 | 2161 | } |
| 2162 | 2162 | |
| 2163 | - $total_period = $start . '+' . ( $interval * $bill_times ) . ' ' . $period; |
|
| 2163 | + $total_period = $start . '+' . ($interval * $bill_times) . ' ' . $period; |
|
| 2164 | 2164 | |
| 2165 | - $end_time = strtotime( $start . '+' . ( $interval * $bill_times ) . ' ' . $period ); |
|
| 2165 | + $end_time = strtotime($start . '+' . ($interval * $bill_times) . ' ' . $period); |
|
| 2166 | 2166 | |
| 2167 | - if ( $this->is_free_trial() ) { |
|
| 2168 | - $end_time += ( wpinv_period_in_days( $this->get_subscription_trial_interval(), $this->get_subscription_trial_period() ) * DAY_IN_SECONDS ) ; |
|
| 2167 | + if ($this->is_free_trial()) { |
|
| 2168 | + $end_time += (wpinv_period_in_days($this->get_subscription_trial_interval(), $this->get_subscription_trial_period()) * DAY_IN_SECONDS); |
|
| 2169 | 2169 | } |
| 2170 | 2170 | |
| 2171 | - if ( $formatted ) { |
|
| 2172 | - $date = date_i18n( get_option( 'date_format' ), $end_time ); |
|
| 2171 | + if ($formatted) { |
|
| 2172 | + $date = date_i18n(get_option('date_format'), $end_time); |
|
| 2173 | 2173 | } else { |
| 2174 | - $date = date_i18n( 'Y-m-d H:i:s', $end_time ); |
|
| 2174 | + $date = date_i18n('Y-m-d H:i:s', $end_time); |
|
| 2175 | 2175 | } |
| 2176 | 2176 | |
| 2177 | 2177 | return $date; |
| 2178 | 2178 | } |
| 2179 | 2179 | |
| 2180 | 2180 | public function get_expiration_time() { |
| 2181 | - return strtotime( $this->get_expiration(), current_time( 'timestamp' ) ); |
|
| 2181 | + return strtotime($this->get_expiration(), current_time('timestamp')); |
|
| 2182 | 2182 | } |
| 2183 | 2183 | |
| 2184 | 2184 | public function get_original_invoice_id() { |
@@ -2190,125 +2190,125 @@ discard block |
||
| 2190 | 2190 | return $subscription_data['bill_times']; |
| 2191 | 2191 | } |
| 2192 | 2192 | |
| 2193 | - public function get_child_payments( $self = false ) { |
|
| 2194 | - $invoices = get_posts( array( |
|
| 2193 | + public function get_child_payments($self = false) { |
|
| 2194 | + $invoices = get_posts(array( |
|
| 2195 | 2195 | 'post_type' => $this->post_type, |
| 2196 | 2196 | 'post_parent' => (int)$this->ID, |
| 2197 | 2197 | 'posts_per_page' => '999', |
| 2198 | - 'post_status' => array( 'publish', 'wpi-processing', 'wpi-renewal' ), |
|
| 2198 | + 'post_status' => array('publish', 'wpi-processing', 'wpi-renewal'), |
|
| 2199 | 2199 | 'orderby' => 'ID', |
| 2200 | 2200 | 'order' => 'DESC', |
| 2201 | 2201 | 'fields' => 'ids' |
| 2202 | - ) ); |
|
| 2202 | + )); |
|
| 2203 | 2203 | |
| 2204 | - if ( $this->is_free_trial() ) { |
|
| 2204 | + if ($this->is_free_trial()) { |
|
| 2205 | 2205 | $self = false; |
| 2206 | 2206 | } |
| 2207 | 2207 | |
| 2208 | - if ( $self && $this->is_paid() ) { |
|
| 2209 | - if ( !empty( $invoices ) ) { |
|
| 2208 | + if ($self && $this->is_paid()) { |
|
| 2209 | + if (!empty($invoices)) { |
|
| 2210 | 2210 | $invoices[] = (int)$this->ID; |
| 2211 | 2211 | } else { |
| 2212 | - $invoices = array( $this->ID ); |
|
| 2212 | + $invoices = array($this->ID); |
|
| 2213 | 2213 | } |
| 2214 | 2214 | |
| 2215 | - $invoices = array_unique( $invoices ); |
|
| 2215 | + $invoices = array_unique($invoices); |
|
| 2216 | 2216 | } |
| 2217 | 2217 | |
| 2218 | 2218 | return $invoices; |
| 2219 | 2219 | } |
| 2220 | 2220 | |
| 2221 | - public function get_total_payments( $self = true ) { |
|
| 2222 | - return count( $this->get_child_payments( $self ) ); |
|
| 2221 | + public function get_total_payments($self = true) { |
|
| 2222 | + return count($this->get_child_payments($self)); |
|
| 2223 | 2223 | } |
| 2224 | 2224 | |
| 2225 | - public function get_subscriptions( $limit = -1 ) { |
|
| 2226 | - $subscriptions = wpinv_get_subscriptions( array( 'parent_invoice_id' => $this->ID, 'numberposts' => $limit ) ); |
|
| 2225 | + public function get_subscriptions($limit = -1) { |
|
| 2226 | + $subscriptions = wpinv_get_subscriptions(array('parent_invoice_id' => $this->ID, 'numberposts' => $limit)); |
|
| 2227 | 2227 | |
| 2228 | 2228 | return $subscriptions; |
| 2229 | 2229 | } |
| 2230 | 2230 | |
| 2231 | 2231 | public function get_subscription_id() { |
| 2232 | - $subscription_id = $this->get_meta( '_wpinv_subscr_profile_id', true ); |
|
| 2232 | + $subscription_id = $this->get_meta('_wpinv_subscr_profile_id', true); |
|
| 2233 | 2233 | |
| 2234 | - if ( empty( $subscription_id ) && !empty( $this->parent_invoice ) ) { |
|
| 2235 | - $parent_invoice = wpinv_get_invoice( $this->parent_invoice ); |
|
| 2234 | + if (empty($subscription_id) && !empty($this->parent_invoice)) { |
|
| 2235 | + $parent_invoice = wpinv_get_invoice($this->parent_invoice); |
|
| 2236 | 2236 | |
| 2237 | - $subscription_id = $parent_invoice->get_meta( '_wpinv_subscr_profile_id', true ); |
|
| 2237 | + $subscription_id = $parent_invoice->get_meta('_wpinv_subscr_profile_id', true); |
|
| 2238 | 2238 | } |
| 2239 | 2239 | |
| 2240 | 2240 | return $subscription_id; |
| 2241 | 2241 | } |
| 2242 | 2242 | |
| 2243 | 2243 | public function get_subscription_status() { |
| 2244 | - $subscription_status = $this->get_meta( '_wpinv_subscr_status', true ); |
|
| 2244 | + $subscription_status = $this->get_meta('_wpinv_subscr_status', true); |
|
| 2245 | 2245 | |
| 2246 | - if ( empty( $subscription_status ) ) { |
|
| 2246 | + if (empty($subscription_status)) { |
|
| 2247 | 2247 | $status = 'pending'; |
| 2248 | 2248 | |
| 2249 | - if ( $this->is_paid() ) { |
|
| 2249 | + if ($this->is_paid()) { |
|
| 2250 | 2250 | $bill_times = (int)$this->get_bill_times(); |
| 2251 | 2251 | $times_billed = (int)$this->get_total_payments(); |
| 2252 | - $expiration = $this->get_subscription_end( false ); |
|
| 2253 | - $expired = $bill_times != 0 && $expiration != '' && $expiration != '-' && strtotime( date_i18n( 'Y-m-d', strtotime( $expiration ) ) ) < strtotime( date_i18n( 'Y-m-d', current_time( 'timestamp' ) ) ) ? true : false; |
|
| 2252 | + $expiration = $this->get_subscription_end(false); |
|
| 2253 | + $expired = $bill_times != 0 && $expiration != '' && $expiration != '-' && strtotime(date_i18n('Y-m-d', strtotime($expiration))) < strtotime(date_i18n('Y-m-d', current_time('timestamp'))) ? true : false; |
|
| 2254 | 2254 | |
| 2255 | - if ( (int)$bill_times == 0 ) { |
|
| 2255 | + if ((int)$bill_times == 0) { |
|
| 2256 | 2256 | $status = $expired ? 'expired' : 'active'; |
| 2257 | - } else if ( $bill_times > 0 && $times_billed >= $bill_times ) { |
|
| 2257 | + } else if ($bill_times > 0 && $times_billed >= $bill_times) { |
|
| 2258 | 2258 | $status = 'completed'; |
| 2259 | - } else if ( $expired ) { |
|
| 2259 | + } else if ($expired) { |
|
| 2260 | 2260 | $status = 'expired'; |
| 2261 | - } else if ( $bill_times > 0 ) { |
|
| 2261 | + } else if ($bill_times > 0) { |
|
| 2262 | 2262 | $status = 'active'; |
| 2263 | 2263 | } else { |
| 2264 | 2264 | $status = 'pending'; |
| 2265 | 2265 | } |
| 2266 | 2266 | } |
| 2267 | 2267 | |
| 2268 | - if ( $status && $status != $subscription_status ) { |
|
| 2268 | + if ($status && $status != $subscription_status) { |
|
| 2269 | 2269 | $subscription_status = $status; |
| 2270 | 2270 | |
| 2271 | - $this->update_meta( '_wpinv_subscr_status', $status ); |
|
| 2271 | + $this->update_meta('_wpinv_subscr_status', $status); |
|
| 2272 | 2272 | } |
| 2273 | 2273 | } |
| 2274 | 2274 | |
| 2275 | 2275 | return $subscription_status; |
| 2276 | 2276 | } |
| 2277 | 2277 | |
| 2278 | - public function get_subscription_status_label( $status = '' ) { |
|
| 2279 | - $status = !empty( $status ) ? $status : $this->get_subscription_status(); |
|
| 2278 | + public function get_subscription_status_label($status = '') { |
|
| 2279 | + $status = !empty($status) ? $status : $this->get_subscription_status(); |
|
| 2280 | 2280 | |
| 2281 | - switch( $status ) { |
|
| 2281 | + switch ($status) { |
|
| 2282 | 2282 | case 'active' : |
| 2283 | - $status_label = __( 'Active', 'invoicing' ); |
|
| 2283 | + $status_label = __('Active', 'invoicing'); |
|
| 2284 | 2284 | break; |
| 2285 | 2285 | |
| 2286 | 2286 | case 'cancelled' : |
| 2287 | - $status_label = __( 'Cancelled', 'invoicing' ); |
|
| 2287 | + $status_label = __('Cancelled', 'invoicing'); |
|
| 2288 | 2288 | break; |
| 2289 | 2289 | |
| 2290 | 2290 | case 'completed' : |
| 2291 | - $status_label = __( 'Completed', 'invoicing' ); |
|
| 2291 | + $status_label = __('Completed', 'invoicing'); |
|
| 2292 | 2292 | break; |
| 2293 | 2293 | |
| 2294 | 2294 | case 'expired' : |
| 2295 | - $status_label = __( 'Expired', 'invoicing' ); |
|
| 2295 | + $status_label = __('Expired', 'invoicing'); |
|
| 2296 | 2296 | break; |
| 2297 | 2297 | |
| 2298 | 2298 | case 'pending' : |
| 2299 | - $status_label = __( 'Pending', 'invoicing' ); |
|
| 2299 | + $status_label = __('Pending', 'invoicing'); |
|
| 2300 | 2300 | break; |
| 2301 | 2301 | |
| 2302 | 2302 | case 'failing' : |
| 2303 | - $status_label = __( 'Failing', 'invoicing' ); |
|
| 2303 | + $status_label = __('Failing', 'invoicing'); |
|
| 2304 | 2304 | break; |
| 2305 | 2305 | |
| 2306 | 2306 | case 'stopped' : |
| 2307 | - $status_label = __( 'Stopped', 'invoicing' ); |
|
| 2307 | + $status_label = __('Stopped', 'invoicing'); |
|
| 2308 | 2308 | break; |
| 2309 | 2309 | |
| 2310 | 2310 | case 'trialing' : |
| 2311 | - $status_label = __( 'Trialing', 'invoicing' ); |
|
| 2311 | + $status_label = __('Trialing', 'invoicing'); |
|
| 2312 | 2312 | break; |
| 2313 | 2313 | |
| 2314 | 2314 | default: |
@@ -2319,26 +2319,26 @@ discard block |
||
| 2319 | 2319 | return $status_label; |
| 2320 | 2320 | } |
| 2321 | 2321 | |
| 2322 | - public function get_subscription_period( $full = false ) { |
|
| 2323 | - $period = $this->get_meta( '_wpinv_subscr_period', true ); |
|
| 2322 | + public function get_subscription_period($full = false) { |
|
| 2323 | + $period = $this->get_meta('_wpinv_subscr_period', true); |
|
| 2324 | 2324 | |
| 2325 | 2325 | // Fix period for old invoices |
| 2326 | - if ( $period == 'day' ) { |
|
| 2326 | + if ($period == 'day') { |
|
| 2327 | 2327 | $period = 'D'; |
| 2328 | - } else if ( $period == 'week' ) { |
|
| 2328 | + } else if ($period == 'week') { |
|
| 2329 | 2329 | $period = 'W'; |
| 2330 | - } else if ( $period == 'month' ) { |
|
| 2330 | + } else if ($period == 'month') { |
|
| 2331 | 2331 | $period = 'M'; |
| 2332 | - } else if ( $period == 'year' ) { |
|
| 2332 | + } else if ($period == 'year') { |
|
| 2333 | 2333 | $period = 'Y'; |
| 2334 | 2334 | } |
| 2335 | 2335 | |
| 2336 | - if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) { |
|
| 2336 | + if (!in_array($period, array('D', 'W', 'M', 'Y'))) { |
|
| 2337 | 2337 | $period = 'D'; |
| 2338 | 2338 | } |
| 2339 | 2339 | |
| 2340 | - if ( $full ) { |
|
| 2341 | - switch( $period ) { |
|
| 2340 | + if ($full) { |
|
| 2341 | + switch ($period) { |
|
| 2342 | 2342 | case 'D': |
| 2343 | 2343 | $period = 'day'; |
| 2344 | 2344 | break; |
@@ -2358,39 +2358,39 @@ discard block |
||
| 2358 | 2358 | } |
| 2359 | 2359 | |
| 2360 | 2360 | public function get_subscription_interval() { |
| 2361 | - $interval = (int)$this->get_meta( '_wpinv_subscr_interval', true ); |
|
| 2361 | + $interval = (int)$this->get_meta('_wpinv_subscr_interval', true); |
|
| 2362 | 2362 | |
| 2363 | - if ( !$interval > 0 ) { |
|
| 2363 | + if (!$interval > 0) { |
|
| 2364 | 2364 | $interval = 1; |
| 2365 | 2365 | } |
| 2366 | 2366 | |
| 2367 | 2367 | return $interval; |
| 2368 | 2368 | } |
| 2369 | 2369 | |
| 2370 | - public function get_subscription_trial_period( $full = false ) { |
|
| 2371 | - if ( !$this->is_free_trial() ) { |
|
| 2370 | + public function get_subscription_trial_period($full = false) { |
|
| 2371 | + if (!$this->is_free_trial()) { |
|
| 2372 | 2372 | return ''; |
| 2373 | 2373 | } |
| 2374 | 2374 | |
| 2375 | - $period = $this->get_meta( '_wpinv_subscr_trial_period', true ); |
|
| 2375 | + $period = $this->get_meta('_wpinv_subscr_trial_period', true); |
|
| 2376 | 2376 | |
| 2377 | 2377 | // Fix period for old invoices |
| 2378 | - if ( $period == 'day' ) { |
|
| 2378 | + if ($period == 'day') { |
|
| 2379 | 2379 | $period = 'D'; |
| 2380 | - } else if ( $period == 'week' ) { |
|
| 2380 | + } else if ($period == 'week') { |
|
| 2381 | 2381 | $period = 'W'; |
| 2382 | - } else if ( $period == 'month' ) { |
|
| 2382 | + } else if ($period == 'month') { |
|
| 2383 | 2383 | $period = 'M'; |
| 2384 | - } else if ( $period == 'year' ) { |
|
| 2384 | + } else if ($period == 'year') { |
|
| 2385 | 2385 | $period = 'Y'; |
| 2386 | 2386 | } |
| 2387 | 2387 | |
| 2388 | - if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) { |
|
| 2388 | + if (!in_array($period, array('D', 'W', 'M', 'Y'))) { |
|
| 2389 | 2389 | $period = 'D'; |
| 2390 | 2390 | } |
| 2391 | 2391 | |
| 2392 | - if ( $full ) { |
|
| 2393 | - switch( $period ) { |
|
| 2392 | + if ($full) { |
|
| 2393 | + switch ($period) { |
|
| 2394 | 2394 | case 'D': |
| 2395 | 2395 | $period = 'day'; |
| 2396 | 2396 | break; |
@@ -2410,13 +2410,13 @@ discard block |
||
| 2410 | 2410 | } |
| 2411 | 2411 | |
| 2412 | 2412 | public function get_subscription_trial_interval() { |
| 2413 | - if ( !$this->is_free_trial() ) { |
|
| 2413 | + if (!$this->is_free_trial()) { |
|
| 2414 | 2414 | return 0; |
| 2415 | 2415 | } |
| 2416 | 2416 | |
| 2417 | - $interval = (int)$this->get_meta( '_wpinv_subscr_trial_interval', true ); |
|
| 2417 | + $interval = (int)$this->get_meta('_wpinv_subscr_trial_interval', true); |
|
| 2418 | 2418 | |
| 2419 | - if ( !$interval > 0 ) { |
|
| 2419 | + if (!$interval > 0) { |
|
| 2420 | 2420 | $interval = 1; |
| 2421 | 2421 | } |
| 2422 | 2422 | |
@@ -2428,8 +2428,8 @@ discard block |
||
| 2428 | 2428 | 'status' => 'failing' |
| 2429 | 2429 | ); |
| 2430 | 2430 | |
| 2431 | - if ( $this->update_subscription( $args ) ) { |
|
| 2432 | - do_action( 'wpinv_subscription_failing', $this->ID, $this ); |
|
| 2431 | + if ($this->update_subscription($args)) { |
|
| 2432 | + do_action('wpinv_subscription_failing', $this->ID, $this); |
|
| 2433 | 2433 | return true; |
| 2434 | 2434 | } |
| 2435 | 2435 | |
@@ -2441,8 +2441,8 @@ discard block |
||
| 2441 | 2441 | 'status' => 'stopped' |
| 2442 | 2442 | ); |
| 2443 | 2443 | |
| 2444 | - if ( $this->update_subscription( $args ) ) { |
|
| 2445 | - do_action( 'wpinv_subscription_stopped', $this->ID, $this ); |
|
| 2444 | + if ($this->update_subscription($args)) { |
|
| 2445 | + do_action('wpinv_subscription_stopped', $this->ID, $this); |
|
| 2446 | 2446 | return true; |
| 2447 | 2447 | } |
| 2448 | 2448 | |
@@ -2454,8 +2454,8 @@ discard block |
||
| 2454 | 2454 | 'status' => 'active' |
| 2455 | 2455 | ); |
| 2456 | 2456 | |
| 2457 | - if ( $this->update_subscription( $args ) ) { |
|
| 2458 | - do_action( 'wpinv_subscription_restarted', $this->ID, $this ); |
|
| 2457 | + if ($this->update_subscription($args)) { |
|
| 2458 | + do_action('wpinv_subscription_restarted', $this->ID, $this); |
|
| 2459 | 2459 | return true; |
| 2460 | 2460 | } |
| 2461 | 2461 | |
@@ -2467,23 +2467,23 @@ discard block |
||
| 2467 | 2467 | 'status' => 'cancelled' |
| 2468 | 2468 | ); |
| 2469 | 2469 | |
| 2470 | - if ( $this->update_subscription( $args ) ) { |
|
| 2471 | - if ( is_user_logged_in() ) { |
|
| 2472 | - $userdata = get_userdata( get_current_user_id() ); |
|
| 2470 | + if ($this->update_subscription($args)) { |
|
| 2471 | + if (is_user_logged_in()) { |
|
| 2472 | + $userdata = get_userdata(get_current_user_id()); |
|
| 2473 | 2473 | $user = $userdata->user_login; |
| 2474 | 2474 | } else { |
| 2475 | - $user = __( 'gateway', 'invoicing' ); |
|
| 2475 | + $user = __('gateway', 'invoicing'); |
|
| 2476 | 2476 | } |
| 2477 | 2477 | |
| 2478 | 2478 | $subscription_id = $this->get_subscription_id(); |
| 2479 | - if ( !$subscription_id ) { |
|
| 2479 | + if (!$subscription_id) { |
|
| 2480 | 2480 | $subscription_id = $this->ID; |
| 2481 | 2481 | } |
| 2482 | 2482 | |
| 2483 | - $note = sprintf( __( 'Subscription %s has been cancelled by %s', 'invoicing' ), $subscription_id, $user ); |
|
| 2484 | - $this->add_note( $note ); |
|
| 2483 | + $note = sprintf(__('Subscription %s has been cancelled by %s', 'invoicing'), $subscription_id, $user); |
|
| 2484 | + $this->add_note($note); |
|
| 2485 | 2485 | |
| 2486 | - do_action( 'wpinv_subscription_cancelled', $this->ID, $this ); |
|
| 2486 | + do_action('wpinv_subscription_cancelled', $this->ID, $this); |
|
| 2487 | 2487 | return true; |
| 2488 | 2488 | } |
| 2489 | 2489 | |
@@ -2491,11 +2491,11 @@ discard block |
||
| 2491 | 2491 | } |
| 2492 | 2492 | |
| 2493 | 2493 | public function can_cancel() { |
| 2494 | - return apply_filters( 'wpinv_subscription_can_cancel', false, $this ); |
|
| 2494 | + return apply_filters('wpinv_subscription_can_cancel', false, $this); |
|
| 2495 | 2495 | } |
| 2496 | 2496 | |
| 2497 | - public function add_subscription( $data = array() ) { |
|
| 2498 | - if ( empty( $this->ID ) ) { |
|
| 2497 | + public function add_subscription($data = array()) { |
|
| 2498 | + if (empty($this->ID)) { |
|
| 2499 | 2499 | return false; |
| 2500 | 2500 | } |
| 2501 | 2501 | |
@@ -2514,85 +2514,85 @@ discard block |
||
| 2514 | 2514 | 'profile_id' => '', |
| 2515 | 2515 | ); |
| 2516 | 2516 | |
| 2517 | - $args = wp_parse_args( $data, $defaults ); |
|
| 2517 | + $args = wp_parse_args($data, $defaults); |
|
| 2518 | 2518 | |
| 2519 | - if ( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) { |
|
| 2520 | - if ( 'active' == $args['status'] || $args['status'] == 'trialing' ) { |
|
| 2519 | + if ($args['expiration'] && strtotime('NOW', current_time('timestamp')) > strtotime($args['expiration'], current_time('timestamp'))) { |
|
| 2520 | + if ('active' == $args['status'] || $args['status'] == 'trialing') { |
|
| 2521 | 2521 | $args['status'] = 'expired'; |
| 2522 | 2522 | } |
| 2523 | 2523 | } |
| 2524 | 2524 | |
| 2525 | - do_action( 'wpinv_subscription_pre_create', $args, $data, $this ); |
|
| 2525 | + do_action('wpinv_subscription_pre_create', $args, $data, $this); |
|
| 2526 | 2526 | |
| 2527 | - if ( !empty( $args ) ) { |
|
| 2528 | - foreach ( $args as $key => $value ) { |
|
| 2529 | - $this->update_meta( '_wpinv_subscr_' . $key, $value ); |
|
| 2527 | + if (!empty($args)) { |
|
| 2528 | + foreach ($args as $key => $value) { |
|
| 2529 | + $this->update_meta('_wpinv_subscr_' . $key, $value); |
|
| 2530 | 2530 | } |
| 2531 | 2531 | } |
| 2532 | 2532 | |
| 2533 | - do_action( 'wpinv_subscription_post_create', $args, $data, $this ); |
|
| 2533 | + do_action('wpinv_subscription_post_create', $args, $data, $this); |
|
| 2534 | 2534 | |
| 2535 | 2535 | return true; |
| 2536 | 2536 | } |
| 2537 | 2537 | |
| 2538 | - public function update_subscription( $args = array() ) { |
|
| 2539 | - if ( empty( $this->ID ) ) { |
|
| 2538 | + public function update_subscription($args = array()) { |
|
| 2539 | + if (empty($this->ID)) { |
|
| 2540 | 2540 | return false; |
| 2541 | 2541 | } |
| 2542 | 2542 | |
| 2543 | - if ( !empty( $args['expiration'] ) && $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) { |
|
| 2544 | - if ( !isset( $args['status'] ) || ( isset( $args['status'] ) && ( 'active' == $args['status'] || $args['status'] == 'trialing' ) ) ) { |
|
| 2543 | + if (!empty($args['expiration']) && $args['expiration'] && strtotime('NOW', current_time('timestamp')) > strtotime($args['expiration'], current_time('timestamp'))) { |
|
| 2544 | + if (!isset($args['status']) || (isset($args['status']) && ('active' == $args['status'] || $args['status'] == 'trialing'))) { |
|
| 2545 | 2545 | $args['status'] = 'expired'; |
| 2546 | 2546 | } |
| 2547 | 2547 | } |
| 2548 | 2548 | |
| 2549 | - if ( isset( $args['status'] ) && $args['status'] == 'cancelled' && empty( $args['cancelled_on'] ) ) { |
|
| 2550 | - $args['cancelled_on'] = date_i18n( 'Y-m-d H:i:s', current_time( 'timestamp' ) ); |
|
| 2549 | + if (isset($args['status']) && $args['status'] == 'cancelled' && empty($args['cancelled_on'])) { |
|
| 2550 | + $args['cancelled_on'] = date_i18n('Y-m-d H:i:s', current_time('timestamp')); |
|
| 2551 | 2551 | } |
| 2552 | 2552 | |
| 2553 | - do_action( 'wpinv_subscription_pre_update', $args, $this ); |
|
| 2553 | + do_action('wpinv_subscription_pre_update', $args, $this); |
|
| 2554 | 2554 | |
| 2555 | - if ( !empty( $args ) ) { |
|
| 2556 | - foreach ( $args as $key => $value ) { |
|
| 2557 | - $this->update_meta( '_wpinv_subscr_' . $key, $value ); |
|
| 2555 | + if (!empty($args)) { |
|
| 2556 | + foreach ($args as $key => $value) { |
|
| 2557 | + $this->update_meta('_wpinv_subscr_' . $key, $value); |
|
| 2558 | 2558 | } |
| 2559 | 2559 | } |
| 2560 | 2560 | |
| 2561 | - do_action( 'wpinv_subscription_post_update', $args, $this ); |
|
| 2561 | + do_action('wpinv_subscription_post_update', $args, $this); |
|
| 2562 | 2562 | |
| 2563 | 2563 | return true; |
| 2564 | 2564 | } |
| 2565 | 2565 | |
| 2566 | 2566 | public function renew_subscription() { |
| 2567 | 2567 | $parent_invoice = $this->get_parent_payment(); |
| 2568 | - $parent_invoice = empty( $parent_invoice ) ? $this : $parent_invoice; |
|
| 2568 | + $parent_invoice = empty($parent_invoice) ? $this : $parent_invoice; |
|
| 2569 | 2569 | |
| 2570 | - $current_time = current_time( 'timestamp' ); |
|
| 2570 | + $current_time = current_time('timestamp'); |
|
| 2571 | 2571 | $start = $this->get_subscription_created(); |
| 2572 | - $start = $start ? strtotime( $start ) : $current_time; |
|
| 2572 | + $start = $start ? strtotime($start) : $current_time; |
|
| 2573 | 2573 | $expires = $this->get_expiration_time(); |
| 2574 | 2574 | |
| 2575 | - if ( !$expires ) { |
|
| 2576 | - $expires = strtotime( '+' . $parent_invoice->get_subscription_interval() . ' ' . $parent_invoice->get_subscription_period( true ), $start ); |
|
| 2575 | + if (!$expires) { |
|
| 2576 | + $expires = strtotime('+' . $parent_invoice->get_subscription_interval() . ' ' . $parent_invoice->get_subscription_period(true), $start); |
|
| 2577 | 2577 | } |
| 2578 | 2578 | |
| 2579 | - $expiration = date_i18n( 'Y-m-d 23:59:59', $expires ); |
|
| 2580 | - $expiration = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->ID, $this ); |
|
| 2579 | + $expiration = date_i18n('Y-m-d 23:59:59', $expires); |
|
| 2580 | + $expiration = apply_filters('wpinv_subscription_renewal_expiration', $expiration, $this->ID, $this); |
|
| 2581 | 2581 | $bill_times = $parent_invoice->get_bill_times(); |
| 2582 | 2582 | $times_billed = $parent_invoice->get_total_payments(); |
| 2583 | 2583 | |
| 2584 | - if ( $parent_invoice->get_subscription_status() == 'trialing' && ( $times_billed > 0 || strtotime( date_i18n( 'Y-m-d' ) ) < strtotime( $parent_invoice->get_trial_end_date( false ) ) ) ) { |
|
| 2584 | + if ($parent_invoice->get_subscription_status() == 'trialing' && ($times_billed > 0 || strtotime(date_i18n('Y-m-d')) < strtotime($parent_invoice->get_trial_end_date(false)))) { |
|
| 2585 | 2585 | $args = array( |
| 2586 | 2586 | 'status' => 'active', |
| 2587 | 2587 | ); |
| 2588 | 2588 | |
| 2589 | - $parent_invoice->update_subscription( $args ); |
|
| 2589 | + $parent_invoice->update_subscription($args); |
|
| 2590 | 2590 | } |
| 2591 | 2591 | |
| 2592 | - do_action( 'wpinv_subscription_pre_renew', $this->ID, $expiration, $this ); |
|
| 2592 | + do_action('wpinv_subscription_pre_renew', $this->ID, $expiration, $this); |
|
| 2593 | 2593 | |
| 2594 | - $status = 'active'; |
|
| 2595 | - if ( $bill_times > 0 && $times_billed >= $bill_times ) { |
|
| 2594 | + $status = 'active'; |
|
| 2595 | + if ($bill_times > 0 && $times_billed >= $bill_times) { |
|
| 2596 | 2596 | $this->complete_subscription(); |
| 2597 | 2597 | $status = 'completed'; |
| 2598 | 2598 | } |
@@ -2602,10 +2602,10 @@ discard block |
||
| 2602 | 2602 | 'status' => $status, |
| 2603 | 2603 | ); |
| 2604 | 2604 | |
| 2605 | - $this->update_subscription( $args ); |
|
| 2605 | + $this->update_subscription($args); |
|
| 2606 | 2606 | |
| 2607 | - do_action( 'wpinv_subscription_post_renew', $this->ID, $expiration, $this ); |
|
| 2608 | - do_action( 'wpinv_recurring_set_subscription_status', $this->ID, $status, $this ); |
|
| 2607 | + do_action('wpinv_subscription_post_renew', $this->ID, $expiration, $this); |
|
| 2608 | + do_action('wpinv_recurring_set_subscription_status', $this->ID, $status, $this); |
|
| 2609 | 2609 | } |
| 2610 | 2610 | |
| 2611 | 2611 | public function complete_subscription() { |
@@ -2613,8 +2613,8 @@ discard block |
||
| 2613 | 2613 | 'status' => 'completed' |
| 2614 | 2614 | ); |
| 2615 | 2615 | |
| 2616 | - if ( $this->update_subscription( $args ) ) { |
|
| 2617 | - do_action( 'wpinv_subscription_completed', $this->ID, $this ); |
|
| 2616 | + if ($this->update_subscription($args)) { |
|
| 2617 | + do_action('wpinv_subscription_completed', $this->ID, $this); |
|
| 2618 | 2618 | } |
| 2619 | 2619 | } |
| 2620 | 2620 | |
@@ -2623,44 +2623,44 @@ discard block |
||
| 2623 | 2623 | 'status' => 'expired' |
| 2624 | 2624 | ); |
| 2625 | 2625 | |
| 2626 | - if ( $this->update_subscription( $args ) ) { |
|
| 2627 | - do_action( 'wpinv_subscription_expired', $this->ID, $this ); |
|
| 2626 | + if ($this->update_subscription($args)) { |
|
| 2627 | + do_action('wpinv_subscription_expired', $this->ID, $this); |
|
| 2628 | 2628 | } |
| 2629 | 2629 | } |
| 2630 | 2630 | |
| 2631 | 2631 | public function get_cancel_url() { |
| 2632 | - $url = wp_nonce_url( add_query_arg( array( 'wpi_action' => 'cancel_subscription', 'sub_id' => $this->ID ) ), 'wpinv-recurring-cancel' ); |
|
| 2632 | + $url = wp_nonce_url(add_query_arg(array('wpi_action' => 'cancel_subscription', 'sub_id' => $this->ID)), 'wpinv-recurring-cancel'); |
|
| 2633 | 2633 | |
| 2634 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
| 2634 | + return apply_filters('wpinv_subscription_cancel_url', $url, $this); |
|
| 2635 | 2635 | } |
| 2636 | 2636 | |
| 2637 | 2637 | public function can_update() { |
| 2638 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
| 2638 | + return apply_filters('wpinv_subscription_can_update', false, $this); |
|
| 2639 | 2639 | } |
| 2640 | 2640 | |
| 2641 | 2641 | public function get_update_url() { |
| 2642 | - $url = add_query_arg( array( 'action' => 'update', 'sub_id' => $this->ID ) ); |
|
| 2642 | + $url = add_query_arg(array('action' => 'update', 'sub_id' => $this->ID)); |
|
| 2643 | 2643 | |
| 2644 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
| 2644 | + return apply_filters('wpinv_subscription_update_url', $url, $this); |
|
| 2645 | 2645 | } |
| 2646 | 2646 | |
| 2647 | 2647 | public function is_parent() { |
| 2648 | - $is_parent = empty( $this->parent_invoice ) ? true : false; |
|
| 2648 | + $is_parent = empty($this->parent_invoice) ? true : false; |
|
| 2649 | 2649 | |
| 2650 | - return apply_filters( 'wpinv_invoice_is_parent', $is_parent, $this ); |
|
| 2650 | + return apply_filters('wpinv_invoice_is_parent', $is_parent, $this); |
|
| 2651 | 2651 | } |
| 2652 | 2652 | |
| 2653 | 2653 | public function is_renewal() { |
| 2654 | 2654 | $is_renewal = $this->parent_invoice && $this->parent_invoice != $this->ID ? true : false; |
| 2655 | 2655 | |
| 2656 | - return apply_filters( 'wpinv_invoice_is_renewal', $is_renewal, $this ); |
|
| 2656 | + return apply_filters('wpinv_invoice_is_renewal', $is_renewal, $this); |
|
| 2657 | 2657 | } |
| 2658 | 2658 | |
| 2659 | 2659 | public function get_parent_payment() { |
| 2660 | 2660 | $parent_payment = NULL; |
| 2661 | 2661 | |
| 2662 | - if ( $this->is_renewal() ) { |
|
| 2663 | - $parent_payment = wpinv_get_invoice( $this->parent_invoice ); |
|
| 2662 | + if ($this->is_renewal()) { |
|
| 2663 | + $parent_payment = wpinv_get_invoice($this->parent_invoice); |
|
| 2664 | 2664 | } |
| 2665 | 2665 | |
| 2666 | 2666 | return $parent_payment; |
@@ -2671,100 +2671,100 @@ discard block |
||
| 2671 | 2671 | |
| 2672 | 2672 | $subscription_status = $this->get_subscription_status(); |
| 2673 | 2673 | |
| 2674 | - if( ! $this->is_subscription_expired() && ( $subscription_status == 'active' || $subscription_status == 'cancelled' || $subscription_status == 'trialing' ) ) { |
|
| 2674 | + if (!$this->is_subscription_expired() && ($subscription_status == 'active' || $subscription_status == 'cancelled' || $subscription_status == 'trialing')) { |
|
| 2675 | 2675 | $ret = true; |
| 2676 | 2676 | } |
| 2677 | 2677 | |
| 2678 | - return apply_filters( 'wpinv_subscription_is_active', $ret, $this->ID, $this ); |
|
| 2678 | + return apply_filters('wpinv_subscription_is_active', $ret, $this->ID, $this); |
|
| 2679 | 2679 | } |
| 2680 | 2680 | |
| 2681 | 2681 | public function is_subscription_expired() { |
| 2682 | 2682 | $ret = false; |
| 2683 | 2683 | $subscription_status = $this->get_subscription_status(); |
| 2684 | 2684 | |
| 2685 | - if ( $subscription_status == 'expired' ) { |
|
| 2685 | + if ($subscription_status == 'expired') { |
|
| 2686 | 2686 | $ret = true; |
| 2687 | - } else if ( 'active' === $subscription_status || 'cancelled' === $subscription_status || 'trialing' == $subscription_status ) { |
|
| 2687 | + } else if ('active' === $subscription_status || 'cancelled' === $subscription_status || 'trialing' == $subscription_status) { |
|
| 2688 | 2688 | $ret = false; |
| 2689 | 2689 | $expiration = $this->get_expiration_time(); |
| 2690 | 2690 | |
| 2691 | - if ( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) { |
|
| 2691 | + if ($expiration && strtotime('NOW', current_time('timestamp')) > $expiration) { |
|
| 2692 | 2692 | $ret = true; |
| 2693 | 2693 | |
| 2694 | - if ( 'active' === $subscription_status || 'trialing' === $subscription_status ) { |
|
| 2694 | + if ('active' === $subscription_status || 'trialing' === $subscription_status) { |
|
| 2695 | 2695 | $this->expire_subscription(); |
| 2696 | 2696 | } |
| 2697 | 2697 | } |
| 2698 | 2698 | } |
| 2699 | 2699 | |
| 2700 | - return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->ID, $this ); |
|
| 2700 | + return apply_filters('wpinv_subscription_is_expired', $ret, $this->ID, $this); |
|
| 2701 | 2701 | } |
| 2702 | 2702 | |
| 2703 | - public function get_new_expiration( $item_id = 0, $trial = true ) { |
|
| 2704 | - $item = new WPInv_Item( $item_id ); |
|
| 2703 | + public function get_new_expiration($item_id = 0, $trial = true) { |
|
| 2704 | + $item = new WPInv_Item($item_id); |
|
| 2705 | 2705 | $interval = $item->get_recurring_interval(); |
| 2706 | - $period = $item->get_recurring_period( true ); |
|
| 2706 | + $period = $item->get_recurring_period(true); |
|
| 2707 | 2707 | |
| 2708 | - $expiration_time = strtotime( '+' . $interval . ' ' . $period ); |
|
| 2708 | + $expiration_time = strtotime('+' . $interval . ' ' . $period); |
|
| 2709 | 2709 | |
| 2710 | - if ( $trial && $this->is_free_trial() && $item->has_free_trial() ) { |
|
| 2711 | - $expiration_time += ( wpinv_period_in_days( $item->get_trial_interval(), $item->get_trial_period() ) * DAY_IN_SECONDS ) ; |
|
| 2710 | + if ($trial && $this->is_free_trial() && $item->has_free_trial()) { |
|
| 2711 | + $expiration_time += (wpinv_period_in_days($item->get_trial_interval(), $item->get_trial_period()) * DAY_IN_SECONDS); |
|
| 2712 | 2712 | } |
| 2713 | 2713 | |
| 2714 | - return date_i18n( 'Y-m-d 23:59:59', $expiration_time ); |
|
| 2714 | + return date_i18n('Y-m-d 23:59:59', $expiration_time); |
|
| 2715 | 2715 | } |
| 2716 | 2716 | |
| 2717 | - public function get_subscription_data( $filed = '' ) { |
|
| 2718 | - $fields = array( 'item_id', 'status', 'period', 'initial_amount', 'recurring_amount', 'interval', 'bill_times', 'trial_period', 'trial_interval', 'expiration', 'profile_id', 'created', 'cancelled_on' ); |
|
| 2717 | + public function get_subscription_data($filed = '') { |
|
| 2718 | + $fields = array('item_id', 'status', 'period', 'initial_amount', 'recurring_amount', 'interval', 'bill_times', 'trial_period', 'trial_interval', 'expiration', 'profile_id', 'created', 'cancelled_on'); |
|
| 2719 | 2719 | |
| 2720 | 2720 | $subscription_meta = array(); |
| 2721 | - foreach ( $fields as $field ) { |
|
| 2722 | - $subscription_meta[ $field ] = $this->get_meta( '_wpinv_subscr_' . $field ); |
|
| 2721 | + foreach ($fields as $field) { |
|
| 2722 | + $subscription_meta[$field] = $this->get_meta('_wpinv_subscr_' . $field); |
|
| 2723 | 2723 | } |
| 2724 | 2724 | |
| 2725 | - $item = $this->get_recurring( true ); |
|
| 2725 | + $item = $this->get_recurring(true); |
|
| 2726 | 2726 | |
| 2727 | - if ( !empty( $item ) ) { |
|
| 2728 | - if ( empty( $subscription_meta['item_id'] ) ) { |
|
| 2727 | + if (!empty($item)) { |
|
| 2728 | + if (empty($subscription_meta['item_id'])) { |
|
| 2729 | 2729 | $subscription_meta['item_id'] = $item->ID; |
| 2730 | 2730 | } |
| 2731 | - if ( empty( $subscription_meta['period'] ) ) { |
|
| 2731 | + if (empty($subscription_meta['period'])) { |
|
| 2732 | 2732 | $subscription_meta['period'] = $item->get_recurring_period(); |
| 2733 | 2733 | } |
| 2734 | - if ( empty( $subscription_meta['interval'] ) ) { |
|
| 2734 | + if (empty($subscription_meta['interval'])) { |
|
| 2735 | 2735 | $subscription_meta['interval'] = $item->get_recurring_interval(); |
| 2736 | 2736 | } |
| 2737 | - if ( $item->has_free_trial() ) { |
|
| 2738 | - if ( empty( $subscription_meta['trial_period'] ) ) { |
|
| 2737 | + if ($item->has_free_trial()) { |
|
| 2738 | + if (empty($subscription_meta['trial_period'])) { |
|
| 2739 | 2739 | $subscription_meta['trial_period'] = $item->get_trial_period(); |
| 2740 | 2740 | } |
| 2741 | - if ( empty( $subscription_meta['trial_interval'] ) ) { |
|
| 2741 | + if (empty($subscription_meta['trial_interval'])) { |
|
| 2742 | 2742 | $subscription_meta['trial_interval'] = $item->get_trial_interval(); |
| 2743 | 2743 | } |
| 2744 | 2744 | } else { |
| 2745 | 2745 | $subscription_meta['trial_period'] = ''; |
| 2746 | 2746 | $subscription_meta['trial_interval'] = 0; |
| 2747 | 2747 | } |
| 2748 | - if ( !$subscription_meta['bill_times'] && $subscription_meta['bill_times'] !== 0 ) { |
|
| 2748 | + if (!$subscription_meta['bill_times'] && $subscription_meta['bill_times'] !== 0) { |
|
| 2749 | 2749 | $subscription_meta['bill_times'] = $item->get_recurring_limit(); |
| 2750 | 2750 | } |
| 2751 | - if ( $subscription_meta['initial_amount'] === '' || $subscription_meta['recurring_amount'] === '' ) { |
|
| 2752 | - $subscription_meta['initial_amount'] = wpinv_round_amount( $this->get_total() ); |
|
| 2753 | - $subscription_meta['recurring_amount'] = wpinv_round_amount( $this->get_recurring_details( 'total' ) ); |
|
| 2751 | + if ($subscription_meta['initial_amount'] === '' || $subscription_meta['recurring_amount'] === '') { |
|
| 2752 | + $subscription_meta['initial_amount'] = wpinv_round_amount($this->get_total()); |
|
| 2753 | + $subscription_meta['recurring_amount'] = wpinv_round_amount($this->get_recurring_details('total')); |
|
| 2754 | 2754 | } |
| 2755 | 2755 | } |
| 2756 | 2756 | |
| 2757 | - if ( $filed === '' ) { |
|
| 2758 | - return apply_filters( 'wpinv_get_invoice_subscription_data', $subscription_meta, $this ); |
|
| 2757 | + if ($filed === '') { |
|
| 2758 | + return apply_filters('wpinv_get_invoice_subscription_data', $subscription_meta, $this); |
|
| 2759 | 2759 | } |
| 2760 | 2760 | |
| 2761 | - $value = isset( $subscription_meta[$filed] ) ? $subscription_meta[$filed] : ''; |
|
| 2761 | + $value = isset($subscription_meta[$filed]) ? $subscription_meta[$filed] : ''; |
|
| 2762 | 2762 | |
| 2763 | - return apply_filters( 'wpinv_invoice_subscription_data_value', $value, $subscription_meta, $this ); |
|
| 2763 | + return apply_filters('wpinv_invoice_subscription_data_value', $value, $subscription_meta, $this); |
|
| 2764 | 2764 | } |
| 2765 | 2765 | |
| 2766 | 2766 | public function is_paid() { |
| 2767 | - if ( $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
| 2767 | + if ($this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
| 2768 | 2768 | return true; |
| 2769 | 2769 | } |
| 2770 | 2770 | |
@@ -2772,23 +2772,23 @@ discard block |
||
| 2772 | 2772 | } |
| 2773 | 2773 | |
| 2774 | 2774 | public function is_refunded() { |
| 2775 | - $is_refunded = $this->has_status( array( 'wpi-refunded' ) ); |
|
| 2775 | + $is_refunded = $this->has_status(array('wpi-refunded')); |
|
| 2776 | 2776 | |
| 2777 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
| 2777 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
| 2778 | 2778 | } |
| 2779 | 2779 | |
| 2780 | 2780 | public function is_free() { |
| 2781 | 2781 | $is_free = false; |
| 2782 | 2782 | |
| 2783 | - if ( !( (float)wpinv_round_amount( $this->get_total() ) > 0 ) ) { |
|
| 2784 | - if ( $this->is_parent() && $this->is_recurring() ) { |
|
| 2785 | - $is_free = (float)wpinv_round_amount( $this->get_recurring_details( 'total' ) ) > 0 ? false : true; |
|
| 2783 | + if (!((float)wpinv_round_amount($this->get_total()) > 0)) { |
|
| 2784 | + if ($this->is_parent() && $this->is_recurring()) { |
|
| 2785 | + $is_free = (float)wpinv_round_amount($this->get_recurring_details('total')) > 0 ? false : true; |
|
| 2786 | 2786 | } else { |
| 2787 | 2787 | $is_free = true; |
| 2788 | 2788 | } |
| 2789 | 2789 | } |
| 2790 | 2790 | |
| 2791 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
| 2791 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
| 2792 | 2792 | } |
| 2793 | 2793 | |
| 2794 | 2794 | public function has_vat() { |
@@ -2796,41 +2796,41 @@ discard block |
||
| 2796 | 2796 | |
| 2797 | 2797 | $requires_vat = false; |
| 2798 | 2798 | |
| 2799 | - if ( $this->country ) { |
|
| 2799 | + if ($this->country) { |
|
| 2800 | 2800 | $wpi_country = $this->country; |
| 2801 | 2801 | |
| 2802 | - $requires_vat = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) ); |
|
| 2802 | + $requires_vat = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this)); |
|
| 2803 | 2803 | } |
| 2804 | 2804 | |
| 2805 | - return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
|
| 2805 | + return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this); |
|
| 2806 | 2806 | } |
| 2807 | 2807 | |
| 2808 | 2808 | public function refresh_item_ids() { |
| 2809 | 2809 | $item_ids = array(); |
| 2810 | 2810 | |
| 2811 | - if ( !empty( $this->cart_details ) ) { |
|
| 2812 | - foreach ( $this->cart_details as $key => $item ) { |
|
| 2813 | - if ( !empty( $item['id'] ) ) { |
|
| 2811 | + if (!empty($this->cart_details)) { |
|
| 2812 | + foreach ($this->cart_details as $key => $item) { |
|
| 2813 | + if (!empty($item['id'])) { |
|
| 2814 | 2814 | $item_ids[] = $item['id']; |
| 2815 | 2815 | } |
| 2816 | 2816 | } |
| 2817 | 2817 | } |
| 2818 | 2818 | |
| 2819 | - $item_ids = !empty( $item_ids ) ? implode( ',', array_unique( $item_ids ) ) : ''; |
|
| 2819 | + $item_ids = !empty($item_ids) ? implode(',', array_unique($item_ids)) : ''; |
|
| 2820 | 2820 | |
| 2821 | - update_post_meta( $this->ID, '_wpinv_item_ids', $item_ids ); |
|
| 2821 | + update_post_meta($this->ID, '_wpinv_item_ids', $item_ids); |
|
| 2822 | 2822 | } |
| 2823 | 2823 | |
| 2824 | - public function get_invoice_quote_type( $post_id ) { |
|
| 2825 | - if ( empty( $post_id ) ) { |
|
| 2824 | + public function get_invoice_quote_type($post_id) { |
|
| 2825 | + if (empty($post_id)) { |
|
| 2826 | 2826 | return ''; |
| 2827 | 2827 | } |
| 2828 | 2828 | |
| 2829 | - $type = get_post_type( $post_id ); |
|
| 2829 | + $type = get_post_type($post_id); |
|
| 2830 | 2830 | |
| 2831 | - if ( 'wpi_invoice' === $type ) { |
|
| 2831 | + if ('wpi_invoice' === $type) { |
|
| 2832 | 2832 | $post_type = __('Invoice', 'invoicing'); |
| 2833 | - } else{ |
|
| 2833 | + } else { |
|
| 2834 | 2834 | $post_type = __('Quote', 'invoicing'); |
| 2835 | 2835 | } |
| 2836 | 2836 | |