@@ -70,7 +70,10 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | function wpinv_invoice_display_right_actions( $invoice ) { |
| 73 | - if ( empty( $invoice ) ) return; //Exit if invoice is not set. |
|
| 73 | + if ( empty( $invoice ) ) { |
|
| 74 | + return; |
|
| 75 | + } |
|
| 76 | + //Exit if invoice is not set. |
|
| 74 | 77 | |
| 75 | 78 | if($invoice->post_type == 'wpi_invoice'){ |
| 76 | 79 | $user_id = (int)$invoice->get_user_id(); |
@@ -177,8 +180,9 @@ discard block |
||
| 177 | 180 | |
| 178 | 181 | // Setup possible parts |
| 179 | 182 | $templates = array(); |
| 180 | - if ( isset( $name ) ) |
|
| 181 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 183 | + if ( isset( $name ) ) { |
|
| 184 | + $templates[] = $slug . '-' . $name . '.php'; |
|
| 185 | + } |
|
| 182 | 186 | $templates[] = $slug . '.php'; |
| 183 | 187 | |
| 184 | 188 | // Allow template parts to be filtered |
@@ -196,8 +200,9 @@ discard block |
||
| 196 | 200 | foreach ( (array)$template_names as $template_name ) { |
| 197 | 201 | |
| 198 | 202 | // Continue if template is empty |
| 199 | - if ( empty( $template_name ) ) |
|
| 200 | - continue; |
|
| 203 | + if ( empty( $template_name ) ) { |
|
| 204 | + continue; |
|
| 205 | + } |
|
| 201 | 206 | |
| 202 | 207 | // Trim off any slashes from the template name |
| 203 | 208 | $template_name = ltrim( $template_name, '/' ); |
@@ -216,8 +221,9 @@ discard block |
||
| 216 | 221 | } |
| 217 | 222 | } |
| 218 | 223 | |
| 219 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 220 | - load_template( $located, $require_once ); |
|
| 224 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 225 | + load_template( $located, $require_once ); |
|
| 226 | + } |
|
| 221 | 227 | |
| 222 | 228 | return $located; |
| 223 | 229 | } |
@@ -293,8 +299,9 @@ discard block |
||
| 293 | 299 | function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
| 294 | 300 | $args = array( 'nopaging' => true ); |
| 295 | 301 | |
| 296 | - if ( ! empty( $status ) ) |
|
| 297 | - $args['post_status'] = $status; |
|
| 302 | + if ( ! empty( $status ) ) { |
|
| 303 | + $args['post_status'] = $status; |
|
| 304 | + } |
|
| 298 | 305 | |
| 299 | 306 | $discounts = wpinv_get_discounts( $args ); |
| 300 | 307 | $options = array(); |
@@ -898,8 +905,11 @@ discard block |
||
| 898 | 905 | |
| 899 | 906 | $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
| 900 | 907 | |
| 901 | - if($invoice->post_type == 'wpi_invoice') $type = 'Invoice'; |
|
| 902 | - elseif($invoice->post_type == 'wpi_quote') $type = 'Quote'; |
|
| 908 | + if($invoice->post_type == 'wpi_invoice') { |
|
| 909 | + $type = 'Invoice'; |
|
| 910 | + } elseif($invoice->post_type == 'wpi_quote') { |
|
| 911 | + $type = 'Quote'; |
|
| 912 | + } |
|
| 903 | 913 | ?> |
| 904 | 914 | <table class="table table-bordered table-sm"> |
| 905 | 915 | <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
@@ -1466,17 +1476,19 @@ discard block |
||
| 1466 | 1476 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
| 1467 | 1477 | |
| 1468 | 1478 | function wpinv_save_cart_button() { |
| 1469 | - if ( wpinv_is_cart_saving_disabled() ) |
|
| 1470 | - return; |
|
| 1471 | -?> |
|
| 1479 | + if ( wpinv_is_cart_saving_disabled() ) { |
|
| 1480 | + return; |
|
| 1481 | + } |
|
| 1482 | + ?> |
|
| 1472 | 1483 | <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a> |
| 1473 | 1484 | <?php |
| 1474 | 1485 | } |
| 1475 | 1486 | |
| 1476 | 1487 | function wpinv_update_cart_button() { |
| 1477 | - if ( !wpinv_item_quantities_enabled() ) |
|
| 1478 | - return; |
|
| 1479 | -?> |
|
| 1488 | + if ( !wpinv_item_quantities_enabled() ) { |
|
| 1489 | + return; |
|
| 1490 | + } |
|
| 1491 | + ?> |
|
| 1480 | 1492 | <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
| 1481 | 1493 | <input type="hidden" name="wpi_action" value="update_cart"/> |
| 1482 | 1494 | <?php |
@@ -1615,7 +1627,7 @@ discard block |
||
| 1615 | 1627 | </div> |
| 1616 | 1628 | <?php |
| 1617 | 1629 | } |
| 1618 | - }else{ |
|
| 1630 | + } else{ |
|
| 1619 | 1631 | echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
| 1620 | 1632 | } |
| 1621 | 1633 | |
@@ -121,29 +121,29 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 123 | 123 | if ( ! empty( $args ) && is_array( $args ) ) { |
| 124 | - extract( $args ); |
|
| 125 | - } |
|
| 124 | + extract( $args ); |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 128 | - // Allow 3rd party plugin filter template file from their plugin. |
|
| 129 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 127 | + $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 128 | + // Allow 3rd party plugin filter template file from their plugin. |
|
| 129 | + $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 130 | 130 | |
| 131 | - if ( ! file_exists( $located ) ) { |
|
| 131 | + if ( ! file_exists( $located ) ) { |
|
| 132 | 132 | _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
| 133 | - return; |
|
| 134 | - } |
|
| 133 | + return; |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 136 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 137 | 137 | |
| 138 | - include( $located ); |
|
| 138 | + include( $located ); |
|
| 139 | 139 | |
| 140 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 140 | + do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 144 | - ob_start(); |
|
| 145 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 146 | - return ob_get_clean(); |
|
| 144 | + ob_start(); |
|
| 145 | + wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 146 | + return ob_get_clean(); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
@@ -173,120 +173,120 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
| 176 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 176 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 177 | 177 | |
| 178 | - // Setup possible parts |
|
| 179 | - $templates = array(); |
|
| 180 | - if ( isset( $name ) ) |
|
| 181 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 182 | - $templates[] = $slug . '.php'; |
|
| 178 | + // Setup possible parts |
|
| 179 | + $templates = array(); |
|
| 180 | + if ( isset( $name ) ) |
|
| 181 | + $templates[] = $slug . '-' . $name . '.php'; |
|
| 182 | + $templates[] = $slug . '.php'; |
|
| 183 | 183 | |
| 184 | - // Allow template parts to be filtered |
|
| 185 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 184 | + // Allow template parts to be filtered |
|
| 185 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 186 | 186 | |
| 187 | - // Return the part that is found |
|
| 188 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 187 | + // Return the part that is found |
|
| 188 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
| 192 | - // No file found yet |
|
| 193 | - $located = false; |
|
| 192 | + // No file found yet |
|
| 193 | + $located = false; |
|
| 194 | 194 | |
| 195 | - // Try to find a template file |
|
| 196 | - foreach ( (array)$template_names as $template_name ) { |
|
| 195 | + // Try to find a template file |
|
| 196 | + foreach ( (array)$template_names as $template_name ) { |
|
| 197 | 197 | |
| 198 | - // Continue if template is empty |
|
| 199 | - if ( empty( $template_name ) ) |
|
| 200 | - continue; |
|
| 198 | + // Continue if template is empty |
|
| 199 | + if ( empty( $template_name ) ) |
|
| 200 | + continue; |
|
| 201 | 201 | |
| 202 | - // Trim off any slashes from the template name |
|
| 203 | - $template_name = ltrim( $template_name, '/' ); |
|
| 202 | + // Trim off any slashes from the template name |
|
| 203 | + $template_name = ltrim( $template_name, '/' ); |
|
| 204 | 204 | |
| 205 | - // try locating this template file by looping through the template paths |
|
| 206 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 205 | + // try locating this template file by looping through the template paths |
|
| 206 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 207 | 207 | |
| 208 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 209 | - $located = $template_path . $template_name; |
|
| 210 | - break; |
|
| 211 | - } |
|
| 212 | - } |
|
| 208 | + if( file_exists( $template_path . $template_name ) ) { |
|
| 209 | + $located = $template_path . $template_name; |
|
| 210 | + break; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - if( !empty( $located ) ) { |
|
| 215 | - break; |
|
| 216 | - } |
|
| 217 | - } |
|
| 214 | + if( !empty( $located ) ) { |
|
| 215 | + break; |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 220 | - load_template( $located, $require_once ); |
|
| 219 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
| 220 | + load_template( $located, $require_once ); |
|
| 221 | 221 | |
| 222 | - return $located; |
|
| 222 | + return $located; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | function wpinv_get_theme_template_paths() { |
| 226 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 226 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 227 | 227 | |
| 228 | - $file_paths = array( |
|
| 229 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 230 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 231 | - 100 => wpinv_get_templates_dir() |
|
| 232 | - ); |
|
| 228 | + $file_paths = array( |
|
| 229 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 230 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 231 | + 100 => wpinv_get_templates_dir() |
|
| 232 | + ); |
|
| 233 | 233 | |
| 234 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 234 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 235 | 235 | |
| 236 | - // sort the file paths based on priority |
|
| 237 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 236 | + // sort the file paths based on priority |
|
| 237 | + ksort( $file_paths, SORT_NUMERIC ); |
|
| 238 | 238 | |
| 239 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 239 | + return array_map( 'trailingslashit', $file_paths ); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | function wpinv_get_theme_template_dir_name() { |
| 243 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
| 243 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | function wpinv_checkout_meta_tags() { |
| 247 | 247 | |
| 248 | - $pages = array(); |
|
| 249 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 250 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 251 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 248 | + $pages = array(); |
|
| 249 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
| 250 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 251 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 252 | 252 | |
| 253 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 254 | - return; |
|
| 255 | - } |
|
| 253 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 254 | + return; |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 257 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 258 | 258 | } |
| 259 | 259 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
| 260 | 260 | |
| 261 | 261 | function wpinv_add_body_classes( $class ) { |
| 262 | - $classes = (array)$class; |
|
| 262 | + $classes = (array)$class; |
|
| 263 | 263 | |
| 264 | - if( wpinv_is_checkout() ) { |
|
| 265 | - $classes[] = 'wpinv-checkout'; |
|
| 266 | - $classes[] = 'wpinv-page'; |
|
| 267 | - } |
|
| 264 | + if( wpinv_is_checkout() ) { |
|
| 265 | + $classes[] = 'wpinv-checkout'; |
|
| 266 | + $classes[] = 'wpinv-page'; |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | - if( wpinv_is_success_page() ) { |
|
| 270 | - $classes[] = 'wpinv-success'; |
|
| 271 | - $classes[] = 'wpinv-page'; |
|
| 272 | - } |
|
| 269 | + if( wpinv_is_success_page() ) { |
|
| 270 | + $classes[] = 'wpinv-success'; |
|
| 271 | + $classes[] = 'wpinv-page'; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 275 | - $classes[] = 'wpinv-failed-transaction'; |
|
| 276 | - $classes[] = 'wpinv-page'; |
|
| 277 | - } |
|
| 274 | + if( wpinv_is_failed_transaction_page() ) { |
|
| 275 | + $classes[] = 'wpinv-failed-transaction'; |
|
| 276 | + $classes[] = 'wpinv-page'; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - if( wpinv_is_invoice_history_page() ) { |
|
| 280 | - $classes[] = 'wpinv-history'; |
|
| 281 | - $classes[] = 'wpinv-page'; |
|
| 282 | - } |
|
| 279 | + if( wpinv_is_invoice_history_page() ) { |
|
| 280 | + $classes[] = 'wpinv-history'; |
|
| 281 | + $classes[] = 'wpinv-page'; |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | - if( wpinv_is_test_mode() ) { |
|
| 285 | - $classes[] = 'wpinv-test-mode'; |
|
| 286 | - $classes[] = 'wpinv-page'; |
|
| 287 | - } |
|
| 284 | + if( wpinv_is_test_mode() ) { |
|
| 285 | + $classes[] = 'wpinv-test-mode'; |
|
| 286 | + $classes[] = 'wpinv-page'; |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - return array_unique( $classes ); |
|
| 289 | + return array_unique( $classes ); |
|
| 290 | 290 | } |
| 291 | 291 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
| 292 | 292 | |
@@ -1451,7 +1451,7 @@ discard block |
||
| 1451 | 1451 | add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
| 1452 | 1452 | |
| 1453 | 1453 | function wpinv_empty_cart_message() { |
| 1454 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1454 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | 1457 | /** |
@@ -1461,7 +1461,7 @@ discard block |
||
| 1461 | 1461 | * @return void |
| 1462 | 1462 | */ |
| 1463 | 1463 | function wpinv_empty_checkout_cart() { |
| 1464 | - echo wpinv_empty_cart_message(); |
|
| 1464 | + echo wpinv_empty_cart_message(); |
|
| 1465 | 1465 | } |
| 1466 | 1466 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
| 1467 | 1467 | |
@@ -1597,11 +1597,11 @@ discard block |
||
| 1597 | 1597 | $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
| 1598 | 1598 | |
| 1599 | 1599 | if(!empty($gateways)){ |
| 1600 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1601 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1602 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1603 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1604 | - ?> |
|
| 1600 | + foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1601 | + $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1602 | + $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1603 | + $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1604 | + ?> |
|
| 1605 | 1605 | <div class="list-group-item"> |
| 1606 | 1606 | <div class="radio"> |
| 1607 | 1607 | <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
@@ -1614,9 +1614,9 @@ discard block |
||
| 1614 | 1614 | </div> |
| 1615 | 1615 | </div> |
| 1616 | 1616 | <?php |
| 1617 | - } |
|
| 1617 | + } |
|
| 1618 | 1618 | }else{ |
| 1619 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
| 1619 | + echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | 1622 | do_action( 'wpinv_payment_mode_after_gateways' ); |
@@ -688,8 +688,8 @@ |
||
| 688 | 688 | $overdue_days_options[$i] = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i ); |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - // Default, built-in gateways |
|
| 692 | - $emails = array( |
|
| 691 | + // Default, built-in gateways |
|
| 692 | + $emails = array( |
|
| 693 | 693 | 'new_invoice' => array( |
| 694 | 694 | 'email_new_invoice_header' => array( |
| 695 | 695 | 'id' => 'email_new_invoice_header', |