@@ -7,38 +7,38 @@ 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 | -add_action( 'init', 'wpinv_register_post_types', 1 ); |
|
| 14 | +add_action('init', 'wpinv_register_post_types', 1); |
|
| 15 | 15 | function wpinv_register_post_types() { |
| 16 | 16 | |
| 17 | 17 | $labels = array( |
| 18 | - 'name' => _x( 'Invoices', 'post type general name', 'invoicing' ), |
|
| 19 | - 'singular_name' => _x( 'Invoice', 'post type singular name', 'invoicing' ), |
|
| 20 | - 'menu_name' => _x( 'Invoices', 'admin menu', 'invoicing' ), |
|
| 21 | - 'name_admin_bar' => _x( 'Invoice', 'add new on admin bar', 'invoicing' ), |
|
| 22 | - 'add_new' => _x( 'Add New', 'book', 'invoicing' ), |
|
| 23 | - 'add_new_item' => __( 'Add New Invoice', 'invoicing' ), |
|
| 24 | - 'new_item' => __( 'New Invoice', 'invoicing' ), |
|
| 25 | - 'edit_item' => __( 'Edit Invoice', 'invoicing' ), |
|
| 26 | - 'view_item' => __( 'View Invoice', 'invoicing' ), |
|
| 27 | - 'all_items' => __( 'Invoices', 'invoicing' ), |
|
| 28 | - 'search_items' => __( 'Search Invoices', 'invoicing' ), |
|
| 29 | - 'parent_item_colon' => __( 'Parent Invoices:', 'invoicing' ), |
|
| 30 | - 'not_found' => __( 'No invoices found.', 'invoicing' ), |
|
| 31 | - 'not_found_in_trash' => __( 'No invoices found in trash.', 'invoicing' ) |
|
| 18 | + 'name' => _x('Invoices', 'post type general name', 'invoicing'), |
|
| 19 | + 'singular_name' => _x('Invoice', 'post type singular name', 'invoicing'), |
|
| 20 | + 'menu_name' => _x('Invoices', 'admin menu', 'invoicing'), |
|
| 21 | + 'name_admin_bar' => _x('Invoice', 'add new on admin bar', 'invoicing'), |
|
| 22 | + 'add_new' => _x('Add New', 'book', 'invoicing'), |
|
| 23 | + 'add_new_item' => __('Add New Invoice', 'invoicing'), |
|
| 24 | + 'new_item' => __('New Invoice', 'invoicing'), |
|
| 25 | + 'edit_item' => __('Edit Invoice', 'invoicing'), |
|
| 26 | + 'view_item' => __('View Invoice', 'invoicing'), |
|
| 27 | + 'all_items' => __('Invoices', 'invoicing'), |
|
| 28 | + 'search_items' => __('Search Invoices', 'invoicing'), |
|
| 29 | + 'parent_item_colon' => __('Parent Invoices:', 'invoicing'), |
|
| 30 | + 'not_found' => __('No invoices found.', 'invoicing'), |
|
| 31 | + 'not_found_in_trash' => __('No invoices found in trash.', 'invoicing') |
|
| 32 | 32 | ); |
| 33 | - $labels = apply_filters( 'wpinv_labels', $labels ); |
|
| 33 | + $labels = apply_filters('wpinv_labels', $labels); |
|
| 34 | 34 | |
| 35 | 35 | $menu_icon = WPINV_PLUGIN_URL . '/assets/images/favicon.ico'; |
| 36 | - $menu_icon = apply_filters( 'wpinv_menu_icon_invoice', $menu_icon ); |
|
| 36 | + $menu_icon = apply_filters('wpinv_menu_icon_invoice', $menu_icon); |
|
| 37 | 37 | |
| 38 | 38 | $cap_type = 'wpi_invoice'; |
| 39 | 39 | $args = array( |
| 40 | 40 | 'labels' => $labels, |
| 41 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
| 41 | + 'description' => __('This is where invoices are stored.', 'invoicing'), |
|
| 42 | 42 | 'public' => true, |
| 43 | 43 | 'can_export' => true, |
| 44 | 44 | '_builtin' => false, |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | 'has_archive' => false, |
| 72 | 72 | 'hierarchical' => false, |
| 73 | 73 | 'menu_position' => null, |
| 74 | - 'supports' => array( 'title', 'author' ), |
|
| 74 | + 'supports' => array('title', 'author'), |
|
| 75 | 75 | 'menu_icon' => 'dashicons-media-spreadsheet', |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - $args = apply_filters( 'wpinv_register_post_type_invoice', $args ); |
|
| 78 | + $args = apply_filters('wpinv_register_post_type_invoice', $args); |
|
| 79 | 79 | |
| 80 | - register_post_type( 'wpi_invoice', $args ); |
|
| 80 | + register_post_type('wpi_invoice', $args); |
|
| 81 | 81 | |
| 82 | 82 | $cap_type = 'wpi_payment_form'; |
| 83 | 83 | register_post_type( |
@@ -86,22 +86,22 @@ discard block |
||
| 86 | 86 | 'wpinv_register_post_type_payment_form', |
| 87 | 87 | array( |
| 88 | 88 | 'labels' => array( |
| 89 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
| 90 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
| 91 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
| 92 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
| 93 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
| 94 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
| 95 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
| 96 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
| 97 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
| 98 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
| 99 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
| 100 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
| 101 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
| 102 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
| 89 | + 'name' => _x('Payment Forms', 'post type general name', 'invoicing'), |
|
| 90 | + 'singular_name' => _x('Payment Form', 'post type singular name', 'invoicing'), |
|
| 91 | + 'menu_name' => _x('Payment Forms', 'admin menu', 'invoicing'), |
|
| 92 | + 'name_admin_bar' => _x('Payment Form', 'add new on admin bar', 'invoicing'), |
|
| 93 | + 'add_new' => _x('Add New', 'Payment Form', 'invoicing'), |
|
| 94 | + 'add_new_item' => __('Add New Payment Form', 'invoicing'), |
|
| 95 | + 'new_item' => __('New Payment Form', 'invoicing'), |
|
| 96 | + 'edit_item' => __('Edit Payment Form', 'invoicing'), |
|
| 97 | + 'view_item' => __('View Payment Form', 'invoicing'), |
|
| 98 | + 'all_items' => __('Payment Forms', 'invoicing'), |
|
| 99 | + 'search_items' => __('Search Payment Forms', 'invoicing'), |
|
| 100 | + 'parent_item_colon' => __('Parent Payment Forms:', 'invoicing'), |
|
| 101 | + 'not_found' => __('No payment forms found.', 'invoicing'), |
|
| 102 | + 'not_found_in_trash' => __('No payment forms found in trash.', 'invoicing') |
|
| 103 | 103 | ), |
| 104 | - 'description' => __( 'Stores payment forms.', 'invoicing' ), |
|
| 104 | + 'description' => __('Stores payment forms.', 'invoicing'), |
|
| 105 | 105 | 'public' => false, |
| 106 | 106 | 'show_ui' => true, |
| 107 | 107 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true, |
@@ -112,40 +112,40 @@ discard block |
||
| 112 | 112 | 'has_archive' => false, |
| 113 | 113 | 'hierarchical' => false, |
| 114 | 114 | 'menu_position' => null, |
| 115 | - 'supports' => array( 'title' ), |
|
| 115 | + 'supports' => array('title'), |
|
| 116 | 116 | 'menu_icon' => 'dashicons-media-form', |
| 117 | 117 | ) |
| 118 | 118 | ) |
| 119 | 119 | ); |
| 120 | 120 | |
| 121 | 121 | $items_labels = array( |
| 122 | - 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
| 123 | - 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
| 124 | - 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
| 125 | - 'add_new' => _x( 'Add New', 'wpi_item', 'invoicing' ), |
|
| 126 | - 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
| 127 | - 'new_item' => __( 'New Item', 'invoicing' ), |
|
| 128 | - 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
| 129 | - 'view_item' => __( 'View Item', 'invoicing' ), |
|
| 130 | - 'all_items' => __( 'Items', 'invoicing' ), |
|
| 131 | - 'search_items' => __( 'Search Items', 'invoicing' ), |
|
| 122 | + 'name' => _x('Items', 'post type general name', 'invoicing'), |
|
| 123 | + 'singular_name' => _x('Item', 'post type singular name', 'invoicing'), |
|
| 124 | + 'menu_name' => _x('Items', 'admin menu', 'invoicing'), |
|
| 125 | + 'add_new' => _x('Add New', 'wpi_item', 'invoicing'), |
|
| 126 | + 'add_new_item' => __('Add New Item', 'invoicing'), |
|
| 127 | + 'new_item' => __('New Item', 'invoicing'), |
|
| 128 | + 'edit_item' => __('Edit Item', 'invoicing'), |
|
| 129 | + 'view_item' => __('View Item', 'invoicing'), |
|
| 130 | + 'all_items' => __('Items', 'invoicing'), |
|
| 131 | + 'search_items' => __('Search Items', 'invoicing'), |
|
| 132 | 132 | 'parent_item_colon' => '', |
| 133 | - 'not_found' => __( 'No items found.', 'invoicing' ), |
|
| 134 | - 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
| 133 | + 'not_found' => __('No items found.', 'invoicing'), |
|
| 134 | + 'not_found_in_trash' => __('No items found in trash.', 'invoicing') |
|
| 135 | 135 | ); |
| 136 | - $items_labels = apply_filters( 'wpinv_items_labels', $items_labels ); |
|
| 136 | + $items_labels = apply_filters('wpinv_items_labels', $items_labels); |
|
| 137 | 137 | |
| 138 | 138 | $cap_type = 'wpi_item'; |
| 139 | 139 | $invoice_item_args = array( |
| 140 | 140 | 'labels' => $items_labels, |
| 141 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
| 141 | + 'description' => __('This is where you can add new invoice items.', 'invoicing'), |
|
| 142 | 142 | 'public' => false, |
| 143 | 143 | 'has_archive' => false, |
| 144 | 144 | '_builtin' => false, |
| 145 | 145 | 'show_ui' => true, |
| 146 | 146 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
| 147 | 147 | 'show_in_nav_menus' => false, |
| 148 | - 'supports' => array( 'title', 'excerpt' ), |
|
| 148 | + 'supports' => array('title', 'excerpt'), |
|
| 149 | 149 | 'register_meta_box_cb' => 'wpinv_register_item_meta_boxes', |
| 150 | 150 | 'rewrite' => false, |
| 151 | 151 | 'query_var' => false, |
@@ -172,33 +172,33 @@ discard block |
||
| 172 | 172 | ), |
| 173 | 173 | 'can_export' => true, |
| 174 | 174 | ); |
| 175 | - $invoice_item_args = apply_filters( 'wpinv_register_post_type_invoice_item', $invoice_item_args ); |
|
| 175 | + $invoice_item_args = apply_filters('wpinv_register_post_type_invoice_item', $invoice_item_args); |
|
| 176 | 176 | |
| 177 | - register_post_type( 'wpi_item', $invoice_item_args ); |
|
| 177 | + register_post_type('wpi_item', $invoice_item_args); |
|
| 178 | 178 | |
| 179 | 179 | $labels = array( |
| 180 | - 'name' => _x( 'Discounts', 'post type general name', 'invoicing' ), |
|
| 181 | - 'singular_name' => _x( 'Discount', 'post type singular name', 'invoicing' ), |
|
| 182 | - 'menu_name' => _x( 'Discounts', 'admin menu', 'invoicing' ), |
|
| 183 | - 'name_admin_bar' => _x( 'Discount', 'add new on admin bar', 'invoicing' ), |
|
| 184 | - 'add_new' => _x( 'Add New', 'book', 'invoicing' ), |
|
| 185 | - 'add_new_item' => __( 'Add New Discount', 'invoicing' ), |
|
| 186 | - 'new_item' => __( 'New Discount', 'invoicing' ), |
|
| 187 | - 'edit_item' => __( 'Edit Discount', 'invoicing' ), |
|
| 188 | - 'view_item' => __( 'View Discount', 'invoicing' ), |
|
| 189 | - 'all_items' => __( 'Discounts', 'invoicing' ), |
|
| 190 | - 'search_items' => __( 'Search Discounts', 'invoicing' ), |
|
| 191 | - 'parent_item_colon' => __( 'Parent Discounts:', 'invoicing' ), |
|
| 192 | - 'not_found' => __( 'No discounts found.', 'invoicing' ), |
|
| 193 | - 'not_found_in_trash' => __( 'No discounts found in trash.', 'invoicing' ) |
|
| 180 | + 'name' => _x('Discounts', 'post type general name', 'invoicing'), |
|
| 181 | + 'singular_name' => _x('Discount', 'post type singular name', 'invoicing'), |
|
| 182 | + 'menu_name' => _x('Discounts', 'admin menu', 'invoicing'), |
|
| 183 | + 'name_admin_bar' => _x('Discount', 'add new on admin bar', 'invoicing'), |
|
| 184 | + 'add_new' => _x('Add New', 'book', 'invoicing'), |
|
| 185 | + 'add_new_item' => __('Add New Discount', 'invoicing'), |
|
| 186 | + 'new_item' => __('New Discount', 'invoicing'), |
|
| 187 | + 'edit_item' => __('Edit Discount', 'invoicing'), |
|
| 188 | + 'view_item' => __('View Discount', 'invoicing'), |
|
| 189 | + 'all_items' => __('Discounts', 'invoicing'), |
|
| 190 | + 'search_items' => __('Search Discounts', 'invoicing'), |
|
| 191 | + 'parent_item_colon' => __('Parent Discounts:', 'invoicing'), |
|
| 192 | + 'not_found' => __('No discounts found.', 'invoicing'), |
|
| 193 | + 'not_found_in_trash' => __('No discounts found in trash.', 'invoicing') |
|
| 194 | 194 | ); |
| 195 | - $labels = apply_filters( 'wpinv_discounts_labels', $labels ); |
|
| 195 | + $labels = apply_filters('wpinv_discounts_labels', $labels); |
|
| 196 | 196 | |
| 197 | 197 | $cap_type = 'wpi_discount'; |
| 198 | 198 | |
| 199 | 199 | $args = array( |
| 200 | 200 | 'labels' => $labels, |
| 201 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
| 201 | + 'description' => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'), |
|
| 202 | 202 | 'public' => false, |
| 203 | 203 | 'can_export' => true, |
| 204 | 204 | '_builtin' => false, |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | ), |
| 230 | 230 | 'has_archive' => false, |
| 231 | 231 | 'hierarchical' => false, |
| 232 | - 'supports' => array( 'title', 'excerpt' ), |
|
| 232 | + 'supports' => array('title', 'excerpt'), |
|
| 233 | 233 | 'register_meta_box_cb' => 'wpinv_register_discount_meta_boxes', |
| 234 | 234 | 'show_in_nav_menus' => false, |
| 235 | 235 | 'show_in_admin_bar' => true, |
@@ -237,106 +237,106 @@ discard block |
||
| 237 | 237 | 'menu_position' => null, |
| 238 | 238 | ); |
| 239 | 239 | |
| 240 | - $args = apply_filters( 'wpinv_register_post_type_discount', $args ); |
|
| 240 | + $args = apply_filters('wpinv_register_post_type_discount', $args); |
|
| 241 | 241 | |
| 242 | - register_post_type( 'wpi_discount', $args ); |
|
| 242 | + register_post_type('wpi_discount', $args); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | function wpinv_get_default_labels() { |
| 246 | 246 | $defaults = array( |
| 247 | - 'singular' => __( 'Invoice', 'invoicing' ), |
|
| 248 | - 'plural' => __( 'Invoices', 'invoicing' ) |
|
| 247 | + 'singular' => __('Invoice', 'invoicing'), |
|
| 248 | + 'plural' => __('Invoices', 'invoicing') |
|
| 249 | 249 | ); |
| 250 | 250 | |
| 251 | - return apply_filters( 'wpinv_default_invoices_name', $defaults ); |
|
| 251 | + return apply_filters('wpinv_default_invoices_name', $defaults); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | -function wpinv_get_label_singular( $lowercase = false ) { |
|
| 254 | +function wpinv_get_label_singular($lowercase = false) { |
|
| 255 | 255 | $defaults = wpinv_get_default_labels(); |
| 256 | 256 | |
| 257 | - return ($lowercase) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
| 257 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | -function wpinv_get_label_plural( $lowercase = false ) { |
|
| 260 | +function wpinv_get_label_plural($lowercase = false) { |
|
| 261 | 261 | $defaults = wpinv_get_default_labels(); |
| 262 | 262 | |
| 263 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
| 263 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | -function wpinv_change_default_title( $title ) { |
|
| 267 | - if ( !is_admin() ) { |
|
| 266 | +function wpinv_change_default_title($title) { |
|
| 267 | + if (!is_admin()) { |
|
| 268 | 268 | $label = wpinv_get_label_singular(); |
| 269 | - $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label ); |
|
| 269 | + $title = sprintf(__('Enter %s name here', 'invoicing'), $label); |
|
| 270 | 270 | return $title; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | $screen = get_current_screen(); |
| 274 | 274 | |
| 275 | - if ( 'wpi_invoice' == $screen->post_type ) { |
|
| 275 | + if ('wpi_invoice' == $screen->post_type) { |
|
| 276 | 276 | $label = wpinv_get_label_singular(); |
| 277 | - $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label ); |
|
| 277 | + $title = sprintf(__('Enter %s name here', 'invoicing'), $label); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | return $title; |
| 281 | 281 | } |
| 282 | -add_filter( 'enter_title_here', 'wpinv_change_default_title' ); |
|
| 282 | +add_filter('enter_title_here', 'wpinv_change_default_title'); |
|
| 283 | 283 | |
| 284 | 284 | function wpinv_register_post_status() { |
| 285 | - register_post_status( 'wpi-pending', array( |
|
| 286 | - 'label' => _x( 'Pending', 'Invoice status', 'invoicing' ), |
|
| 285 | + register_post_status('wpi-pending', array( |
|
| 286 | + 'label' => _x('Pending', 'Invoice status', 'invoicing'), |
|
| 287 | 287 | 'public' => true, |
| 288 | 288 | 'exclude_from_search' => true, |
| 289 | 289 | 'show_in_admin_all_list' => true, |
| 290 | 290 | 'show_in_admin_status_list' => true, |
| 291 | - 'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing' ) |
|
| 292 | - ) ); |
|
| 293 | - register_post_status( 'wpi-processing', array( |
|
| 294 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
| 291 | + 'label_count' => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing') |
|
| 292 | + )); |
|
| 293 | + register_post_status('wpi-processing', array( |
|
| 294 | + 'label' => _x('Processing', 'Invoice status', 'invoicing'), |
|
| 295 | 295 | 'public' => true, |
| 296 | 296 | 'exclude_from_search' => true, |
| 297 | 297 | 'show_in_admin_all_list' => true, |
| 298 | 298 | 'show_in_admin_status_list' => true, |
| 299 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
| 300 | - ) ); |
|
| 301 | - register_post_status( 'wpi-onhold', array( |
|
| 302 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
| 299 | + 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing') |
|
| 300 | + )); |
|
| 301 | + register_post_status('wpi-onhold', array( |
|
| 302 | + 'label' => _x('On Hold', 'Invoice status', 'invoicing'), |
|
| 303 | 303 | 'public' => true, |
| 304 | 304 | 'exclude_from_search' => true, |
| 305 | 305 | 'show_in_admin_all_list' => true, |
| 306 | 306 | 'show_in_admin_status_list' => true, |
| 307 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
| 308 | - ) ); |
|
| 309 | - register_post_status( 'wpi-cancelled', array( |
|
| 310 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
| 307 | + 'label_count' => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing') |
|
| 308 | + )); |
|
| 309 | + register_post_status('wpi-cancelled', array( |
|
| 310 | + 'label' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
| 311 | 311 | 'public' => true, |
| 312 | 312 | 'exclude_from_search' => true, |
| 313 | 313 | 'show_in_admin_all_list' => true, |
| 314 | 314 | 'show_in_admin_status_list' => true, |
| 315 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
| 316 | - ) ); |
|
| 317 | - register_post_status( 'wpi-refunded', array( |
|
| 318 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
| 315 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing') |
|
| 316 | + )); |
|
| 317 | + register_post_status('wpi-refunded', array( |
|
| 318 | + 'label' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
| 319 | 319 | 'public' => true, |
| 320 | 320 | 'exclude_from_search' => true, |
| 321 | 321 | 'show_in_admin_all_list' => true, |
| 322 | 322 | 'show_in_admin_status_list' => true, |
| 323 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
| 324 | - ) ); |
|
| 325 | - register_post_status( 'wpi-failed', array( |
|
| 326 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
| 323 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing') |
|
| 324 | + )); |
|
| 325 | + register_post_status('wpi-failed', array( |
|
| 326 | + 'label' => _x('Failed', 'Invoice status', 'invoicing'), |
|
| 327 | 327 | 'public' => true, |
| 328 | 328 | 'exclude_from_search' => true, |
| 329 | 329 | 'show_in_admin_all_list' => true, |
| 330 | 330 | 'show_in_admin_status_list' => true, |
| 331 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
| 332 | - ) ); |
|
| 333 | - register_post_status( 'wpi-renewal', array( |
|
| 334 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
| 331 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing') |
|
| 332 | + )); |
|
| 333 | + register_post_status('wpi-renewal', array( |
|
| 334 | + 'label' => _x('Renewal', 'Invoice status', 'invoicing'), |
|
| 335 | 335 | 'public' => true, |
| 336 | 336 | 'exclude_from_search' => true, |
| 337 | 337 | 'show_in_admin_all_list' => true, |
| 338 | 338 | 'show_in_admin_status_list' => true, |
| 339 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
| 340 | - ) ); |
|
| 339 | + 'label_count' => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing') |
|
| 340 | + )); |
|
| 341 | 341 | } |
| 342 | -add_action( 'init', 'wpinv_register_post_status', 10 ); |
|
| 342 | +add_action('init', 'wpinv_register_post_status', 10); |
|
@@ -7,91 +7,91 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -if ( !is_admin() ) { |
|
| 15 | - add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 16 | - add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' ); |
|
| 17 | - add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' ); |
|
| 18 | - add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' ); |
|
| 14 | +if (!is_admin()) { |
|
| 15 | + add_filter('template_include', 'wpinv_template', 10, 1); |
|
| 16 | + add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar'); |
|
| 17 | + add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions'); |
|
| 18 | + add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions'); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | function wpinv_template_path() { |
| 22 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
| 22 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -function wpinv_display_invoice_top_bar( $invoice ) { |
|
| 26 | - if ( empty( $invoice ) ) { |
|
| 25 | +function wpinv_display_invoice_top_bar($invoice) { |
|
| 26 | + if (empty($invoice)) { |
|
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | ?> |
| 30 | 30 | <div class="row wpinv-top-bar no-print"> |
| 31 | 31 | <div class="container"> |
| 32 | 32 | <div class="col-xs-6"> |
| 33 | - <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?> |
|
| 33 | + <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?> |
|
| 34 | 34 | </div> |
| 35 | 35 | <div class="col-xs-6 text-right"> |
| 36 | - <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?> |
|
| 36 | + <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?> |
|
| 37 | 37 | </div> |
| 38 | 38 | </div> |
| 39 | 39 | </div> |
| 40 | 40 | <?php |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -function wpinv_invoice_display_left_actions( $invoice ) { |
|
| 44 | - if ( empty( $invoice ) ) { |
|
| 43 | +function wpinv_invoice_display_left_actions($invoice) { |
|
| 44 | + if (empty($invoice)) { |
|
| 45 | 45 | return; // Exit if invoice is not set. |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if ( $invoice->post_type == 'wpi_invoice' ) { |
|
| 49 | - if ( $invoice->needs_payment() ) { |
|
| 50 | - ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php |
|
| 48 | + if ($invoice->post_type == 'wpi_invoice') { |
|
| 49 | + if ($invoice->needs_payment()) { |
|
| 50 | + ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | do_action('wpinv_invoice_display_left_actions', $invoice); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
| 57 | - if ( empty( $invoice ) ) { |
|
| 56 | +function wpinv_invoice_display_right_actions($invoice) { |
|
| 57 | + if (empty($invoice)) { |
|
| 58 | 58 | return; // Exit if invoice is not set. |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if ( $invoice->post_type == 'wpi_invoice' ) { ?> |
|
| 62 | - <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
| 63 | - <?php if ( is_user_logged_in() ) { ?> |
|
| 64 | - <a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
| 61 | + if ($invoice->post_type == 'wpi_invoice') { ?> |
|
| 62 | + <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
| 63 | + <?php if (is_user_logged_in()) { ?> |
|
| 64 | + <a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
| 65 | 65 | <?php } |
| 66 | 66 | } |
| 67 | 67 | do_action('wpinv_invoice_display_right_actions', $invoice); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | -function wpinv_before_invoice_content( $content ) { |
|
| 70 | +function wpinv_before_invoice_content($content) { |
|
| 71 | 71 | global $post; |
| 72 | 72 | |
| 73 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
| 73 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
| 74 | 74 | ob_start(); |
| 75 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
| 75 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
| 76 | 76 | $content = ob_get_clean() . $content; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | return $content; |
| 80 | 80 | } |
| 81 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
| 81 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
| 82 | 82 | |
| 83 | -function wpinv_after_invoice_content( $content ) { |
|
| 83 | +function wpinv_after_invoice_content($content) { |
|
| 84 | 84 | global $post; |
| 85 | 85 | |
| 86 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
| 86 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
| 87 | 87 | ob_start(); |
| 88 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
| 88 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
| 89 | 89 | $content .= ob_get_clean(); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $content; |
| 93 | 93 | } |
| 94 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
| 94 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
| 95 | 95 | |
| 96 | 96 | function wpinv_get_templates_dir() { |
| 97 | 97 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -101,105 +101,105 @@ discard block |
||
| 101 | 101 | return WPINV_PLUGIN_URL . 'templates'; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 105 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
| 106 | - extract( $args ); |
|
| 104 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 105 | + if (!empty($args) && is_array($args)) { |
|
| 106 | + extract($args); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 109 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
| 110 | 110 | // Allow 3rd party plugin filter template file from their plugin. |
| 111 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 111 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
| 112 | 112 | |
| 113 | - if ( ! file_exists( $located ) ) { |
|
| 114 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
| 113 | + if (!file_exists($located)) { |
|
| 114 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
| 115 | 115 | return; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 118 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
| 119 | 119 | |
| 120 | - include( $located ); |
|
| 120 | + include($located); |
|
| 121 | 121 | |
| 122 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 122 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 125 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 126 | 126 | ob_start(); |
| 127 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 127 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
| 128 | 128 | return ob_get_clean(); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 132 | - if ( ! $template_path ) { |
|
| 131 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 132 | + if (!$template_path) { |
|
| 133 | 133 | $template_path = wpinv_template_path(); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if ( ! $default_path ) { |
|
| 136 | + if (!$default_path) { |
|
| 137 | 137 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Look within passed path within the theme - this is priority. |
| 141 | 141 | $template = locate_template( |
| 142 | 142 | array( |
| 143 | - trailingslashit( $template_path ) . $template_name, |
|
| 143 | + trailingslashit($template_path) . $template_name, |
|
| 144 | 144 | $template_name |
| 145 | 145 | ) |
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | 148 | // Get default templates/ |
| 149 | - if ( !$template && $default_path ) { |
|
| 150 | - $template = trailingslashit( $default_path ) . $template_name; |
|
| 149 | + if (!$template && $default_path) { |
|
| 150 | + $template = trailingslashit($default_path) . $template_name; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Return what we found. |
| 154 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
| 154 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
| 158 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 157 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
| 158 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
| 159 | 159 | |
| 160 | 160 | // Setup possible parts |
| 161 | 161 | $templates = array(); |
| 162 | - if ( isset( $name ) ) |
|
| 162 | + if (isset($name)) |
|
| 163 | 163 | $templates[] = $slug . '-' . $name . '.php'; |
| 164 | 164 | $templates[] = $slug . '.php'; |
| 165 | 165 | |
| 166 | 166 | // Allow template parts to be filtered |
| 167 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 167 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
| 168 | 168 | |
| 169 | 169 | // Return the part that is found |
| 170 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 170 | + return wpinv_locate_tmpl($templates, $load, false); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
| 173 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
| 174 | 174 | // No file found yet |
| 175 | 175 | $located = false; |
| 176 | 176 | |
| 177 | 177 | // Try to find a template file |
| 178 | - foreach ( (array)$template_names as $template_name ) { |
|
| 178 | + foreach ((array) $template_names as $template_name) { |
|
| 179 | 179 | |
| 180 | 180 | // Continue if template is empty |
| 181 | - if ( empty( $template_name ) ) |
|
| 181 | + if (empty($template_name)) |
|
| 182 | 182 | continue; |
| 183 | 183 | |
| 184 | 184 | // Trim off any slashes from the template name |
| 185 | - $template_name = ltrim( $template_name, '/' ); |
|
| 185 | + $template_name = ltrim($template_name, '/'); |
|
| 186 | 186 | |
| 187 | 187 | // try locating this template file by looping through the template paths |
| 188 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 188 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
| 189 | 189 | |
| 190 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 190 | + if (file_exists($template_path . $template_name)) { |
|
| 191 | 191 | $located = $template_path . $template_name; |
| 192 | 192 | break; |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - if( !empty( $located ) ) { |
|
| 196 | + if (!empty($located)) { |
|
| 197 | 197 | break; |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 202 | - load_template( $located, $require_once ); |
|
| 201 | + if ((true == $load) && !empty($located)) |
|
| 202 | + load_template($located, $require_once); |
|
| 203 | 203 | |
| 204 | 204 | return $located; |
| 205 | 205 | } |
@@ -208,159 +208,159 @@ discard block |
||
| 208 | 208 | $template_dir = wpinv_get_theme_template_dir_name(); |
| 209 | 209 | |
| 210 | 210 | $file_paths = array( |
| 211 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 212 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 211 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
| 212 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
| 213 | 213 | 100 => wpinv_get_templates_dir() |
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 216 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
| 217 | 217 | |
| 218 | 218 | // sort the file paths based on priority |
| 219 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 219 | + ksort($file_paths, SORT_NUMERIC); |
|
| 220 | 220 | |
| 221 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 221 | + return array_map('trailingslashit', $file_paths); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | function wpinv_get_theme_template_dir_name() { |
| 225 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 225 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | function wpinv_checkout_meta_tags() { |
| 229 | 229 | |
| 230 | 230 | $pages = array(); |
| 231 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 232 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 233 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 234 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 231 | + $pages[] = wpinv_get_option('success_page'); |
|
| 232 | + $pages[] = wpinv_get_option('failure_page'); |
|
| 233 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
| 234 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
| 235 | 235 | |
| 236 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 236 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
| 241 | 241 | } |
| 242 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
| 242 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
| 243 | 243 | |
| 244 | -function wpinv_add_body_classes( $class ) { |
|
| 245 | - $classes = (array)$class; |
|
| 244 | +function wpinv_add_body_classes($class) { |
|
| 245 | + $classes = (array) $class; |
|
| 246 | 246 | |
| 247 | - if( wpinv_is_checkout() ) { |
|
| 247 | + if (wpinv_is_checkout()) { |
|
| 248 | 248 | $classes[] = 'wpinv-checkout'; |
| 249 | 249 | $classes[] = 'wpinv-page'; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - if( wpinv_is_success_page() ) { |
|
| 252 | + if (wpinv_is_success_page()) { |
|
| 253 | 253 | $classes[] = 'wpinv-success'; |
| 254 | 254 | $classes[] = 'wpinv-page'; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 257 | + if (wpinv_is_failed_transaction_page()) { |
|
| 258 | 258 | $classes[] = 'wpinv-failed-transaction'; |
| 259 | 259 | $classes[] = 'wpinv-page'; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - if( wpinv_is_invoice_history_page() ) { |
|
| 262 | + if (wpinv_is_invoice_history_page()) { |
|
| 263 | 263 | $classes[] = 'wpinv-history'; |
| 264 | 264 | $classes[] = 'wpinv-page'; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if( wpinv_is_subscriptions_history_page() ) { |
|
| 267 | + if (wpinv_is_subscriptions_history_page()) { |
|
| 268 | 268 | $classes[] = 'wpinv-subscription'; |
| 269 | 269 | $classes[] = 'wpinv-page'; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if( wpinv_is_test_mode() ) { |
|
| 272 | + if (wpinv_is_test_mode()) { |
|
| 273 | 273 | $classes[] = 'wpinv-test-mode'; |
| 274 | 274 | $classes[] = 'wpinv-page'; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - return array_unique( $classes ); |
|
| 277 | + return array_unique($classes); |
|
| 278 | 278 | } |
| 279 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
| 279 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
| 280 | 280 | |
| 281 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
| 282 | - $args = array( 'nopaging' => true ); |
|
| 281 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
| 282 | + $args = array('nopaging' => true); |
|
| 283 | 283 | |
| 284 | - if ( ! empty( $status ) ) |
|
| 284 | + if (!empty($status)) |
|
| 285 | 285 | $args['post_status'] = $status; |
| 286 | 286 | |
| 287 | - $discounts = wpinv_get_discounts( $args ); |
|
| 287 | + $discounts = wpinv_get_discounts($args); |
|
| 288 | 288 | $options = array(); |
| 289 | 289 | |
| 290 | - if ( $discounts ) { |
|
| 291 | - foreach ( $discounts as $discount ) { |
|
| 292 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
| 290 | + if ($discounts) { |
|
| 291 | + foreach ($discounts as $discount) { |
|
| 292 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
| 293 | 293 | } |
| 294 | 294 | } else { |
| 295 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
| 295 | + $options[0] = __('No discounts found', 'invoicing'); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - $output = wpinv_html_select( array( |
|
| 298 | + $output = wpinv_html_select(array( |
|
| 299 | 299 | 'name' => $name, |
| 300 | 300 | 'selected' => $selected, |
| 301 | 301 | 'options' => $options, |
| 302 | 302 | 'show_option_all' => false, |
| 303 | 303 | 'show_option_none' => false, |
| 304 | - ) ); |
|
| 304 | + )); |
|
| 305 | 305 | |
| 306 | 306 | return $output; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
| 310 | - $current = date( 'Y' ); |
|
| 311 | - $start_year = $current - absint( $years_before ); |
|
| 312 | - $end_year = $current + absint( $years_after ); |
|
| 313 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
| 309 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
| 310 | + $current = date('Y'); |
|
| 311 | + $start_year = $current - absint($years_before); |
|
| 312 | + $end_year = $current + absint($years_after); |
|
| 313 | + $selected = empty($selected) ? date('Y') : $selected; |
|
| 314 | 314 | $options = array(); |
| 315 | 315 | |
| 316 | - while ( $start_year <= $end_year ) { |
|
| 317 | - $options[ absint( $start_year ) ] = $start_year; |
|
| 316 | + while ($start_year <= $end_year) { |
|
| 317 | + $options[absint($start_year)] = $start_year; |
|
| 318 | 318 | $start_year++; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - $output = wpinv_html_select( array( |
|
| 321 | + $output = wpinv_html_select(array( |
|
| 322 | 322 | 'name' => $name, |
| 323 | 323 | 'selected' => $selected, |
| 324 | 324 | 'options' => $options, |
| 325 | 325 | 'show_option_all' => false, |
| 326 | 326 | 'show_option_none' => false |
| 327 | - ) ); |
|
| 327 | + )); |
|
| 328 | 328 | |
| 329 | 329 | return $output; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
| 332 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
| 333 | 333 | |
| 334 | 334 | $options = array( |
| 335 | - '1' => __( 'January', 'invoicing' ), |
|
| 336 | - '2' => __( 'February', 'invoicing' ), |
|
| 337 | - '3' => __( 'March', 'invoicing' ), |
|
| 338 | - '4' => __( 'April', 'invoicing' ), |
|
| 339 | - '5' => __( 'May', 'invoicing' ), |
|
| 340 | - '6' => __( 'June', 'invoicing' ), |
|
| 341 | - '7' => __( 'July', 'invoicing' ), |
|
| 342 | - '8' => __( 'August', 'invoicing' ), |
|
| 343 | - '9' => __( 'September', 'invoicing' ), |
|
| 344 | - '10' => __( 'October', 'invoicing' ), |
|
| 345 | - '11' => __( 'November', 'invoicing' ), |
|
| 346 | - '12' => __( 'December', 'invoicing' ), |
|
| 335 | + '1' => __('January', 'invoicing'), |
|
| 336 | + '2' => __('February', 'invoicing'), |
|
| 337 | + '3' => __('March', 'invoicing'), |
|
| 338 | + '4' => __('April', 'invoicing'), |
|
| 339 | + '5' => __('May', 'invoicing'), |
|
| 340 | + '6' => __('June', 'invoicing'), |
|
| 341 | + '7' => __('July', 'invoicing'), |
|
| 342 | + '8' => __('August', 'invoicing'), |
|
| 343 | + '9' => __('September', 'invoicing'), |
|
| 344 | + '10' => __('October', 'invoicing'), |
|
| 345 | + '11' => __('November', 'invoicing'), |
|
| 346 | + '12' => __('December', 'invoicing'), |
|
| 347 | 347 | ); |
| 348 | 348 | |
| 349 | 349 | // If no month is selected, default to the current month |
| 350 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
| 350 | + $selected = empty($selected) ? date('n') : $selected; |
|
| 351 | 351 | |
| 352 | - $output = wpinv_html_select( array( |
|
| 352 | + $output = wpinv_html_select(array( |
|
| 353 | 353 | 'name' => $name, |
| 354 | 354 | 'selected' => $selected, |
| 355 | 355 | 'options' => $options, |
| 356 | 356 | 'show_option_all' => false, |
| 357 | 357 | 'show_option_none' => false |
| 358 | - ) ); |
|
| 358 | + )); |
|
| 359 | 359 | |
| 360 | 360 | return $output; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | -function wpinv_html_select( $args = array() ) { |
|
| 363 | +function wpinv_html_select($args = array()) { |
|
| 364 | 364 | $defaults = array( |
| 365 | 365 | 'options' => array(), |
| 366 | 366 | 'name' => null, |
@@ -369,8 +369,8 @@ discard block |
||
| 369 | 369 | 'selected' => 0, |
| 370 | 370 | 'placeholder' => null, |
| 371 | 371 | 'multiple' => false, |
| 372 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
| 373 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
| 372 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
| 373 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
| 374 | 374 | 'data' => array(), |
| 375 | 375 | 'onchange' => null, |
| 376 | 376 | 'required' => false, |
@@ -378,74 +378,74 @@ discard block |
||
| 378 | 378 | 'readonly' => false, |
| 379 | 379 | ); |
| 380 | 380 | |
| 381 | - $args = wp_parse_args( $args, $defaults ); |
|
| 381 | + $args = wp_parse_args($args, $defaults); |
|
| 382 | 382 | |
| 383 | 383 | $data_elements = ''; |
| 384 | - foreach ( $args['data'] as $key => $value ) { |
|
| 385 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
| 384 | + foreach ($args['data'] as $key => $value) { |
|
| 385 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - if( $args['multiple'] ) { |
|
| 388 | + if ($args['multiple']) { |
|
| 389 | 389 | $multiple = ' MULTIPLE'; |
| 390 | 390 | } else { |
| 391 | 391 | $multiple = ''; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - if( $args['placeholder'] ) { |
|
| 394 | + if ($args['placeholder']) { |
|
| 395 | 395 | $placeholder = $args['placeholder']; |
| 396 | 396 | } else { |
| 397 | 397 | $placeholder = ''; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | $options = ''; |
| 401 | - if( !empty( $args['onchange'] ) ) { |
|
| 402 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 401 | + if (!empty($args['onchange'])) { |
|
| 402 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - if( !empty( $args['required'] ) ) { |
|
| 405 | + if (!empty($args['required'])) { |
|
| 406 | 406 | $options .= ' required="required"'; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - if( !empty( $args['disabled'] ) ) { |
|
| 409 | + if (!empty($args['disabled'])) { |
|
| 410 | 410 | $options .= ' disabled'; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if( !empty( $args['readonly'] ) ) { |
|
| 413 | + if (!empty($args['readonly'])) { |
|
| 414 | 414 | $options .= ' readonly'; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 418 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
| 417 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 418 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
| 419 | 419 | |
| 420 | - if ( $args['show_option_all'] ) { |
|
| 421 | - if( $args['multiple'] ) { |
|
| 422 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
| 420 | + if ($args['show_option_all']) { |
|
| 421 | + if ($args['multiple']) { |
|
| 422 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
| 423 | 423 | } else { |
| 424 | - $selected = selected( $args['selected'], 0, false ); |
|
| 424 | + $selected = selected($args['selected'], 0, false); |
|
| 425 | 425 | } |
| 426 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
| 426 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - if ( !empty( $args['options'] ) ) { |
|
| 429 | + if (!empty($args['options'])) { |
|
| 430 | 430 | |
| 431 | - if ( $args['show_option_none'] ) { |
|
| 432 | - if( $args['multiple'] ) { |
|
| 433 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
| 431 | + if ($args['show_option_none']) { |
|
| 432 | + if ($args['multiple']) { |
|
| 433 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
| 434 | 434 | } else { |
| 435 | - $selected = selected( $args['selected'] === "", true, false ); |
|
| 435 | + $selected = selected($args['selected'] === "", true, false); |
|
| 436 | 436 | } |
| 437 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 437 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - foreach( $args['options'] as $key => $option ) { |
|
| 440 | + foreach ($args['options'] as $key => $option) { |
|
| 441 | 441 | |
| 442 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 443 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
| 442 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
| 443 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
| 444 | 444 | } else { |
| 445 | - $selected = selected( $args['selected'], $key, false ); |
|
| 445 | + $selected = selected($args['selected'], $key, false); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
| 448 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | 451 | |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | return $output; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | -function wpinv_item_dropdown( $args = array() ) { |
|
| 457 | +function wpinv_item_dropdown($args = array()) { |
|
| 458 | 458 | $defaults = array( |
| 459 | 459 | 'name' => 'wpi_item', |
| 460 | 460 | 'id' => 'wpi_item', |
@@ -462,14 +462,14 @@ discard block |
||
| 462 | 462 | 'multiple' => false, |
| 463 | 463 | 'selected' => 0, |
| 464 | 464 | 'number' => 100, |
| 465 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
| 466 | - 'data' => array( 'search-type' => 'item' ), |
|
| 465 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
| 466 | + 'data' => array('search-type' => 'item'), |
|
| 467 | 467 | 'show_option_all' => false, |
| 468 | 468 | 'show_option_none' => false, |
| 469 | 469 | 'show_recurring' => false, |
| 470 | 470 | ); |
| 471 | 471 | |
| 472 | - $args = wp_parse_args( $args, $defaults ); |
|
| 472 | + $args = wp_parse_args($args, $defaults); |
|
| 473 | 473 | |
| 474 | 474 | $item_args = array( |
| 475 | 475 | 'post_type' => 'wpi_item', |
@@ -478,44 +478,44 @@ discard block |
||
| 478 | 478 | 'posts_per_page' => $args['number'] |
| 479 | 479 | ); |
| 480 | 480 | |
| 481 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
| 481 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
| 482 | 482 | |
| 483 | - $items = get_posts( $item_args ); |
|
| 483 | + $items = get_posts($item_args); |
|
| 484 | 484 | $options = array(); |
| 485 | - if ( $items ) { |
|
| 486 | - foreach ( $items as $item ) { |
|
| 487 | - $title = esc_html( $item->post_title ); |
|
| 485 | + if ($items) { |
|
| 486 | + foreach ($items as $item) { |
|
| 487 | + $title = esc_html($item->post_title); |
|
| 488 | 488 | |
| 489 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 490 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
| 489 | + if (!empty($args['show_recurring'])) { |
|
| 490 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - $options[ absint( $item->ID ) ] = $title; |
|
| 493 | + $options[absint($item->ID)] = $title; |
|
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | // This ensures that any selected items are included in the drop down |
| 498 | - if( is_array( $args['selected'] ) ) { |
|
| 499 | - foreach( $args['selected'] as $item ) { |
|
| 500 | - if( ! in_array( $item, $options ) ) { |
|
| 501 | - $title = get_the_title( $item ); |
|
| 502 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 503 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
| 498 | + if (is_array($args['selected'])) { |
|
| 499 | + foreach ($args['selected'] as $item) { |
|
| 500 | + if (!in_array($item, $options)) { |
|
| 501 | + $title = get_the_title($item); |
|
| 502 | + if (!empty($args['show_recurring'])) { |
|
| 503 | + $title .= wpinv_get_item_suffix($item, false); |
|
| 504 | 504 | } |
| 505 | 505 | $options[$item] = $title; |
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
| 509 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
| 510 | - $title = get_the_title( $args['selected'] ); |
|
| 511 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 512 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
| 508 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
| 509 | + if (!in_array($args['selected'], $options)) { |
|
| 510 | + $title = get_the_title($args['selected']); |
|
| 511 | + if (!empty($args['show_recurring'])) { |
|
| 512 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
| 513 | 513 | } |
| 514 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
| 514 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
| 515 | 515 | } |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - $output = wpinv_html_select( array( |
|
| 518 | + $output = wpinv_html_select(array( |
|
| 519 | 519 | 'name' => $args['name'], |
| 520 | 520 | 'selected' => $args['selected'], |
| 521 | 521 | 'id' => $args['id'], |
@@ -526,12 +526,12 @@ discard block |
||
| 526 | 526 | 'show_option_all' => $args['show_option_all'], |
| 527 | 527 | 'show_option_none' => $args['show_option_none'], |
| 528 | 528 | 'data' => $args['data'], |
| 529 | - ) ); |
|
| 529 | + )); |
|
| 530 | 530 | |
| 531 | 531 | return $output; |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | -function wpinv_html_checkbox( $args = array() ) { |
|
| 534 | +function wpinv_html_checkbox($args = array()) { |
|
| 535 | 535 | $defaults = array( |
| 536 | 536 | 'name' => null, |
| 537 | 537 | 'current' => null, |
@@ -542,38 +542,38 @@ discard block |
||
| 542 | 542 | ) |
| 543 | 543 | ); |
| 544 | 544 | |
| 545 | - $args = wp_parse_args( $args, $defaults ); |
|
| 545 | + $args = wp_parse_args($args, $defaults); |
|
| 546 | 546 | |
| 547 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 547 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 548 | 548 | $options = ''; |
| 549 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 549 | + if (!empty($args['options']['disabled'])) { |
|
| 550 | 550 | $options .= ' disabled="disabled"'; |
| 551 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 551 | + } elseif (!empty($args['options']['readonly'])) { |
|
| 552 | 552 | $options .= ' readonly'; |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
| 555 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
| 556 | 556 | |
| 557 | 557 | return $output; |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | -function wpinv_html_text( $args = array() ) { |
|
| 560 | +function wpinv_html_text($args = array()) { |
|
| 561 | 561 | // Backwards compatibility |
| 562 | - if ( func_num_args() > 1 ) { |
|
| 562 | + if (func_num_args() > 1) { |
|
| 563 | 563 | $args = func_get_args(); |
| 564 | 564 | |
| 565 | 565 | $name = $args[0]; |
| 566 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 567 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 568 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 566 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 567 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 568 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | $defaults = array( |
| 572 | 572 | 'id' => '', |
| 573 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 574 | - 'value' => isset( $value ) ? $value : null, |
|
| 575 | - 'label' => isset( $label ) ? $label : null, |
|
| 576 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 573 | + 'name' => isset($name) ? $name : 'text', |
|
| 574 | + 'value' => isset($value) ? $value : null, |
|
| 575 | + 'label' => isset($label) ? $label : null, |
|
| 576 | + 'desc' => isset($desc) ? $desc : null, |
|
| 577 | 577 | 'placeholder' => '', |
| 578 | 578 | 'class' => 'regular-text', |
| 579 | 579 | 'disabled' => false, |
@@ -583,51 +583,51 @@ discard block |
||
| 583 | 583 | 'data' => false |
| 584 | 584 | ); |
| 585 | 585 | |
| 586 | - $args = wp_parse_args( $args, $defaults ); |
|
| 586 | + $args = wp_parse_args($args, $defaults); |
|
| 587 | 587 | |
| 588 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 588 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 589 | 589 | $options = ''; |
| 590 | - if( $args['required'] ) { |
|
| 590 | + if ($args['required']) { |
|
| 591 | 591 | $options .= ' required="required"'; |
| 592 | 592 | } |
| 593 | - if( $args['readonly'] ) { |
|
| 593 | + if ($args['readonly']) { |
|
| 594 | 594 | $options .= ' readonly'; |
| 595 | 595 | } |
| 596 | - if( $args['readonly'] ) { |
|
| 596 | + if ($args['readonly']) { |
|
| 597 | 597 | $options .= ' readonly'; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | $data = ''; |
| 601 | - if ( !empty( $args['data'] ) ) { |
|
| 602 | - foreach ( $args['data'] as $key => $value ) { |
|
| 603 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 601 | + if (!empty($args['data'])) { |
|
| 602 | + foreach ($args['data'] as $key => $value) { |
|
| 603 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 608 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 609 | - if ( ! empty( $args['desc'] ) ) { |
|
| 610 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 607 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 608 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 609 | + if (!empty($args['desc'])) { |
|
| 610 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
| 613 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
| 614 | 614 | |
| 615 | 615 | $output .= '</span>'; |
| 616 | 616 | |
| 617 | 617 | return $output; |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | -function wpinv_html_date_field( $args = array() ) { |
|
| 621 | - if( empty( $args['class'] ) ) { |
|
| 620 | +function wpinv_html_date_field($args = array()) { |
|
| 621 | + if (empty($args['class'])) { |
|
| 622 | 622 | $args['class'] = 'wpiDatepicker'; |
| 623 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
| 623 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
| 624 | 624 | $args['class'] .= ' wpiDatepicker'; |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - return wpinv_html_text( $args ); |
|
| 627 | + return wpinv_html_text($args); |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | -function wpinv_html_textarea( $args = array() ) { |
|
| 630 | +function wpinv_html_textarea($args = array()) { |
|
| 631 | 631 | $defaults = array( |
| 632 | 632 | 'name' => 'textarea', |
| 633 | 633 | 'value' => null, |
@@ -638,31 +638,31 @@ discard block |
||
| 638 | 638 | 'placeholder' => '', |
| 639 | 639 | ); |
| 640 | 640 | |
| 641 | - $args = wp_parse_args( $args, $defaults ); |
|
| 641 | + $args = wp_parse_args($args, $defaults); |
|
| 642 | 642 | |
| 643 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 643 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 644 | 644 | $disabled = ''; |
| 645 | - if( $args['disabled'] ) { |
|
| 645 | + if ($args['disabled']) { |
|
| 646 | 646 | $disabled = ' disabled="disabled"'; |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 650 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 651 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
| 649 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 650 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 651 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
| 652 | 652 | |
| 653 | - if ( ! empty( $args['desc'] ) ) { |
|
| 654 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 653 | + if (!empty($args['desc'])) { |
|
| 654 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 655 | 655 | } |
| 656 | 656 | $output .= '</span>'; |
| 657 | 657 | |
| 658 | 658 | return $output; |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
| 661 | +function wpinv_html_ajax_user_search($args = array()) { |
|
| 662 | 662 | $defaults = array( |
| 663 | 663 | 'name' => 'user_id', |
| 664 | 664 | 'value' => null, |
| 665 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
| 665 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
| 666 | 666 | 'label' => null, |
| 667 | 667 | 'desc' => null, |
| 668 | 668 | 'class' => '', |
@@ -671,13 +671,13 @@ discard block |
||
| 671 | 671 | 'data' => false |
| 672 | 672 | ); |
| 673 | 673 | |
| 674 | - $args = wp_parse_args( $args, $defaults ); |
|
| 674 | + $args = wp_parse_args($args, $defaults); |
|
| 675 | 675 | |
| 676 | 676 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
| 677 | 677 | |
| 678 | 678 | $output = '<span class="wpinv_user_search_wrap">'; |
| 679 | - $output .= wpinv_html_text( $args ); |
|
| 680 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
| 679 | + $output .= wpinv_html_text($args); |
|
| 680 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
| 681 | 681 | $output .= '</span>'; |
| 682 | 682 | |
| 683 | 683 | return $output; |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | function wpinv_ip_geolocation() { |
| 687 | 687 | global $wpinv_euvat; |
| 688 | 688 | |
| 689 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
| 689 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
| 690 | 690 | $content = ''; |
| 691 | 691 | $iso = ''; |
| 692 | 692 | $country = ''; |
@@ -697,69 +697,69 @@ discard block |
||
| 697 | 697 | $credit = ''; |
| 698 | 698 | $address = ''; |
| 699 | 699 | |
| 700 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
| 700 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
| 701 | 701 | try { |
| 702 | 702 | $iso = $geoip2_city->country->isoCode; |
| 703 | 703 | $country = $geoip2_city->country->name; |
| 704 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 704 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 705 | 705 | $city = $geoip2_city->city->name; |
| 706 | 706 | $longitude = $geoip2_city->location->longitude; |
| 707 | 707 | $latitude = $geoip2_city->location->latitude; |
| 708 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
| 709 | - } catch( Exception $e ) { } |
|
| 708 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
| 709 | + } catch (Exception $e) { } |
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
| 712 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
| 713 | 713 | try { |
| 714 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
| 714 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
| 715 | 715 | |
| 716 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
| 716 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
| 717 | 717 | $iso = $load_xml->geoplugin_countryCode; |
| 718 | 718 | $country = $load_xml->geoplugin_countryName; |
| 719 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
| 720 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
| 719 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
| 720 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
| 721 | 721 | $longitude = $load_xml->geoplugin_longitude; |
| 722 | 722 | $latitude = $load_xml->geoplugin_latitude; |
| 723 | 723 | $credit = $load_xml->geoplugin_credit; |
| 724 | - $credit = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit; |
|
| 724 | + $credit = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit; |
|
| 725 | 725 | } |
| 726 | - } catch( Exception $e ) { } |
|
| 726 | + } catch (Exception $e) { } |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | - if ( $iso && $longitude && $latitude ) { |
|
| 730 | - if ( $city ) { |
|
| 729 | + if ($iso && $longitude && $latitude) { |
|
| 730 | + if ($city) { |
|
| 731 | 731 | $address .= $city . ', '; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | - if ( $region ) { |
|
| 734 | + if ($region) { |
|
| 735 | 735 | $address .= $region . ', '; |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | $address .= $country . ' (' . $iso . ')'; |
| 739 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
| 740 | - $content .= '<p>'. $credit . '</p>'; |
|
| 739 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
| 740 | + $content .= '<p>' . $credit . '</p>'; |
|
| 741 | 741 | } else { |
| 742 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
| 742 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
| 743 | 743 | } |
| 744 | 744 | ?> |
| 745 | 745 | <!DOCTYPE html> |
| 746 | -<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
| 746 | +<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
| 747 | 747 | <body> |
| 748 | - <?php if ( $latitude && $latitude ) { ?> |
|
| 748 | + <?php if ($latitude && $latitude) { ?> |
|
| 749 | 749 | <div id="map"></div> |
| 750 | 750 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
| 751 | 751 | <script type="text/javascript"> |
| 752 | 752 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
| 753 | 753 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
| 754 | 754 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
| 755 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
| 755 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
| 756 | 756 | |
| 757 | 757 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
| 758 | 758 | |
| 759 | 759 | var marker = new L.Marker(latlng); |
| 760 | 760 | map.addLayer(marker); |
| 761 | 761 | |
| 762 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
| 762 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
| 763 | 763 | </script> |
| 764 | 764 | <?php } ?> |
| 765 | 765 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -767,18 +767,18 @@ discard block |
||
| 767 | 767 | <?php |
| 768 | 768 | exit; |
| 769 | 769 | } |
| 770 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
| 771 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
| 770 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
| 771 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
| 772 | 772 | |
| 773 | 773 | // Set up the template for the invoice. |
| 774 | -function wpinv_template( $template ) { |
|
| 774 | +function wpinv_template($template) { |
|
| 775 | 775 | global $post, $wp_query; |
| 776 | 776 | |
| 777 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) { |
|
| 778 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
| 779 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
| 777 | + if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) { |
|
| 778 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
| 779 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
| 780 | 780 | } else { |
| 781 | - $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
| 781 | + $template = wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | 784 | |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | |
| 788 | 788 | function wpinv_get_business_address() { |
| 789 | 789 | $business_address = wpinv_store_address(); |
| 790 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
| 790 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
| 791 | 791 | |
| 792 | 792 | /* |
| 793 | 793 | $default_country = wpinv_get_default_country(); |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | |
| 812 | 812 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
| 813 | 813 | |
| 814 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
| 814 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | function wpinv_display_from_address() { |
@@ -821,107 +821,107 @@ discard block |
||
| 821 | 821 | if (empty($from_name)) { |
| 822 | 822 | $from_name = wpinv_get_business_name(); |
| 823 | 823 | } |
| 824 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
| 824 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
| 825 | 825 | <div class="wrapper col-xs-10"> |
| 826 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
| 827 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
| 828 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
| 826 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
| 827 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
| 828 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
| 829 | 829 | <?php } ?> |
| 830 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
| 831 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div> |
|
| 830 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
| 831 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div> |
|
| 832 | 832 | <?php } ?> |
| 833 | 833 | </div> |
| 834 | 834 | <?php |
| 835 | 835 | } |
| 836 | 836 | |
| 837 | -function wpinv_watermark( $id = 0 ) { |
|
| 838 | - $output = wpinv_get_watermark( $id ); |
|
| 837 | +function wpinv_watermark($id = 0) { |
|
| 838 | + $output = wpinv_get_watermark($id); |
|
| 839 | 839 | |
| 840 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
| 840 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
| 841 | 841 | } |
| 842 | 842 | |
| 843 | -function wpinv_get_watermark( $id ) { |
|
| 844 | - if ( !$id > 0 ) { |
|
| 843 | +function wpinv_get_watermark($id) { |
|
| 844 | + if (!$id > 0) { |
|
| 845 | 845 | return NULL; |
| 846 | 846 | } |
| 847 | - $invoice = wpinv_get_invoice( $id ); |
|
| 847 | + $invoice = wpinv_get_invoice($id); |
|
| 848 | 848 | |
| 849 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
| 850 | - if ( $invoice->is_paid() ) { |
|
| 851 | - return __( 'Paid', 'invoicing' ); |
|
| 849 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
| 850 | + if ($invoice->is_paid()) { |
|
| 851 | + return __('Paid', 'invoicing'); |
|
| 852 | 852 | } |
| 853 | - if ( $invoice->is_refunded() ) { |
|
| 854 | - return __( 'Refunded', 'invoicing' ); |
|
| 853 | + if ($invoice->is_refunded()) { |
|
| 854 | + return __('Refunded', 'invoicing'); |
|
| 855 | 855 | } |
| 856 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
| 857 | - return __( 'Cancelled', 'invoicing' ); |
|
| 856 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
| 857 | + return __('Cancelled', 'invoicing'); |
|
| 858 | 858 | } |
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | return NULL; |
| 862 | 862 | } |
| 863 | 863 | |
| 864 | -function wpinv_display_invoice_details( $invoice ) { |
|
| 864 | +function wpinv_display_invoice_details($invoice) { |
|
| 865 | 865 | global $wpinv_euvat; |
| 866 | 866 | |
| 867 | 867 | $invoice_id = $invoice->ID; |
| 868 | 868 | $vat_name = $wpinv_euvat->get_vat_name(); |
| 869 | 869 | $use_taxes = wpinv_use_taxes(); |
| 870 | 870 | |
| 871 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
| 871 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
| 872 | 872 | ?> |
| 873 | 873 | <table class="table table-bordered table-sm"> |
| 874 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
| 874 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
| 875 | 875 | <tr class="wpi-row-number"> |
| 876 | - <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th> |
|
| 877 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
| 876 | + <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th> |
|
| 877 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
| 878 | 878 | </tr> |
| 879 | 879 | <?php } ?> |
| 880 | 880 | <tr class="wpi-row-status"> |
| 881 | - <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th> |
|
| 882 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
| 881 | + <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th> |
|
| 882 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
| 883 | 883 | </tr> |
| 884 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
| 884 | + <?php if ($invoice->is_renewal()) { ?> |
|
| 885 | 885 | <tr class="wpi-row-parent"> |
| 886 | - <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th> |
|
| 887 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
| 886 | + <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th> |
|
| 887 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
| 888 | 888 | </tr> |
| 889 | 889 | <?php } ?> |
| 890 | - <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
| 890 | + <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
| 891 | 891 | <tr class="wpi-row-gateway"> |
| 892 | - <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th> |
|
| 892 | + <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th> |
|
| 893 | 893 | <td><?php echo $gateway_name; ?></td> |
| 894 | 894 | </tr> |
| 895 | 895 | <?php } ?> |
| 896 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
| 896 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
| 897 | 897 | <tr class="wpi-row-date"> |
| 898 | - <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th> |
|
| 898 | + <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th> |
|
| 899 | 899 | <td><?php echo $invoice_date; ?></td> |
| 900 | 900 | </tr> |
| 901 | 901 | <?php } ?> |
| 902 | - <?php do_action( 'wpinv_display_details_before_due_date', $invoice_id ); ?> |
|
| 903 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
| 902 | + <?php do_action('wpinv_display_details_before_due_date', $invoice_id); ?> |
|
| 903 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
| 904 | 904 | <tr class="wpi-row-date"> |
| 905 | - <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th> |
|
| 905 | + <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th> |
|
| 906 | 906 | <td><?php echo $due_date; ?></td> |
| 907 | 907 | </tr> |
| 908 | 908 | <?php } ?> |
| 909 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
| 910 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
| 909 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
| 910 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
| 911 | 911 | <tr class="wpi-row-ovatno"> |
| 912 | - <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
| 912 | + <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
| 913 | 913 | <td><?php echo $owner_vat_number; ?></td> |
| 914 | 914 | </tr> |
| 915 | 915 | <?php } ?> |
| 916 | - <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?> |
|
| 916 | + <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?> |
|
| 917 | 917 | <tr class="wpi-row-uvatno"> |
| 918 | - <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
| 918 | + <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
| 919 | 919 | <td><?php echo $user_vat_number; ?></td> |
| 920 | 920 | </tr> |
| 921 | 921 | <?php } ?> |
| 922 | 922 | <tr class="table-active tr-total wpi-row-total"> |
| 923 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
| 924 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
| 923 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
| 924 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
| 925 | 925 | </tr> |
| 926 | 926 | </table> |
| 927 | 927 | <?php |
@@ -937,84 +937,84 @@ discard block |
||
| 937 | 937 | * @param string $separator How to separate address lines. |
| 938 | 938 | * @return string |
| 939 | 939 | */ |
| 940 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
| 940 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
| 941 | 941 | |
| 942 | 942 | // Retrieve the address markup... |
| 943 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
| 944 | - $format = wpinv_get_full_address_format( $country ); |
|
| 943 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
| 944 | + $format = wpinv_get_full_address_format($country); |
|
| 945 | 945 | |
| 946 | 946 | // ... and the replacements. |
| 947 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
| 947 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
| 948 | 948 | |
| 949 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
| 949 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
| 950 | 950 | |
| 951 | 951 | // Remove unavailable tags. |
| 952 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
| 952 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
| 953 | 953 | |
| 954 | 954 | // Clean up white space. |
| 955 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 956 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
| 955 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
| 956 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
| 957 | 957 | |
| 958 | 958 | // Break newlines apart and remove empty lines/trim commas and white space. |
| 959 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 959 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
| 960 | 960 | |
| 961 | 961 | // Add html breaks. |
| 962 | - $formatted_address = implode( $separator, $formatted_address ); |
|
| 962 | + $formatted_address = implode($separator, $formatted_address); |
|
| 963 | 963 | |
| 964 | 964 | // We're done! |
| 965 | 965 | return $formatted_address; |
| 966 | 966 | |
| 967 | 967 | } |
| 968 | 968 | |
| 969 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
| 970 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 969 | +function wpinv_display_to_address($invoice_id = 0) { |
|
| 970 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 971 | 971 | |
| 972 | - if ( empty( $invoice ) ) { |
|
| 972 | + if (empty($invoice)) { |
|
| 973 | 973 | return NULL; |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | $billing_details = $invoice->get_user_info(); |
| 977 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
| 977 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
| 978 | 978 | $output .= '<div class="wrapper col-xs-10">'; |
| 979 | 979 | |
| 980 | 980 | ob_start(); |
| 981 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
| 981 | + do_action('wpinv_display_to_address_top', $invoice); |
|
| 982 | 982 | $output .= ob_get_clean(); |
| 983 | 983 | |
| 984 | - $address_row = wpinv_get_invoice_address_markup( $billing_details ); |
|
| 984 | + $address_row = wpinv_get_invoice_address_markup($billing_details); |
|
| 985 | 985 | |
| 986 | - if ( $address_row ) { |
|
| 986 | + if ($address_row) { |
|
| 987 | 987 | $output .= '<div class="address">' . $address_row . '</div>'; |
| 988 | 988 | } |
| 989 | 989 | |
| 990 | - if ( $phone = $invoice->get_phone() ) { |
|
| 991 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>'; |
|
| 990 | + if ($phone = $invoice->get_phone()) { |
|
| 991 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>'; |
|
| 992 | 992 | } |
| 993 | - if ( $email = $invoice->get_email() ) { |
|
| 994 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>'; |
|
| 993 | + if ($email = $invoice->get_email()) { |
|
| 994 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>'; |
|
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | ob_start(); |
| 998 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
| 998 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
| 999 | 999 | $output .= ob_get_clean(); |
| 1000 | 1000 | |
| 1001 | 1001 | $output .= '</div>'; |
| 1002 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
| 1002 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
| 1003 | 1003 | |
| 1004 | 1004 | echo $output; |
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
| 1007 | +function wpinv_display_line_items($invoice_id = 0) { |
|
| 1008 | 1008 | global $wpinv_euvat, $ajax_cart_details; |
| 1009 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1009 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1010 | 1010 | $quantities_enabled = wpinv_item_quantities_enabled(); |
| 1011 | 1011 | $use_taxes = wpinv_use_taxes(); |
| 1012 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
| 1012 | + if (!$use_taxes && (float) $invoice->get_tax() > 0) { |
|
| 1013 | 1013 | $use_taxes = true; |
| 1014 | 1014 | } |
| 1015 | - $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
|
| 1016 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
| 1017 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
| 1015 | + $zero_tax = !(float) $invoice->get_tax() > 0 ? true : false; |
|
| 1016 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
| 1017 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
| 1018 | 1018 | |
| 1019 | 1019 | $cart_details = $invoice->get_cart_details(); |
| 1020 | 1020 | $ajax_cart_details = $cart_details; |
@@ -1023,67 +1023,67 @@ discard block |
||
| 1023 | 1023 | <table class="table table-sm table-bordered table-responsive"> |
| 1024 | 1024 | <thead> |
| 1025 | 1025 | <tr> |
| 1026 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
| 1027 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
| 1026 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
| 1027 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
| 1028 | 1028 | <?php if ($quantities_enabled) { ?> |
| 1029 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
| 1029 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
| 1030 | 1030 | <?php } ?> |
| 1031 | 1031 | <?php if ($use_taxes && !$zero_tax) { ?> |
| 1032 | 1032 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
| 1033 | 1033 | <?php } ?> |
| 1034 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
| 1034 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
| 1035 | 1035 | </tr> |
| 1036 | 1036 | </thead> |
| 1037 | 1037 | <tbody> |
| 1038 | 1038 | <?php |
| 1039 | - if ( !empty( $cart_details ) ) { |
|
| 1040 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
| 1039 | + if (!empty($cart_details)) { |
|
| 1040 | + do_action('wpinv_display_line_items_start', $invoice); |
|
| 1041 | 1041 | |
| 1042 | 1042 | $count = 0; |
| 1043 | 1043 | $cols = 3; |
| 1044 | - foreach ( $cart_details as $key => $cart_item ) { |
|
| 1045 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
| 1046 | - $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0; |
|
| 1047 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0; |
|
| 1048 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
| 1044 | + foreach ($cart_details as $key => $cart_item) { |
|
| 1045 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
| 1046 | + $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0; |
|
| 1047 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0; |
|
| 1048 | + $quantity = !empty($cart_item['quantity']) && (int) $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
| 1049 | 1049 | |
| 1050 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
| 1050 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
| 1051 | 1051 | $summary = ''; |
| 1052 | - $item_name = ''; |
|
| 1052 | + $item_name = ''; |
|
| 1053 | 1053 | $cols = 3; |
| 1054 | - if ( !empty($item) ) { |
|
| 1054 | + if (!empty($item)) { |
|
| 1055 | 1055 | $item_name = $item->get_name(); |
| 1056 | 1056 | $summary = $item->get_summary(); |
| 1057 | 1057 | } |
| 1058 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
| 1058 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
| 1059 | 1059 | |
| 1060 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
| 1060 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
| 1061 | 1061 | |
| 1062 | 1062 | $item_tax = ''; |
| 1063 | 1063 | $tax_rate = ''; |
| 1064 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
| 1065 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
| 1066 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
| 1067 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
| 1064 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
| 1065 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
| 1066 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
| 1067 | + $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : ''; |
|
| 1068 | 1068 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | 1071 | $line_item_tax = $item_tax . $tax_rate; |
| 1072 | 1072 | |
| 1073 | - if ( $line_item_tax === '' ) { |
|
| 1073 | + if ($line_item_tax === '') { |
|
| 1074 | 1074 | $line_item_tax = 0; // Zero tax |
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | - $action = apply_filters( 'wpinv_display_line_item_action', '', $cart_item, $invoice, $cols ); |
|
| 1077 | + $action = apply_filters('wpinv_display_line_item_action', '', $cart_item, $invoice, $cols); |
|
| 1078 | 1078 | |
| 1079 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
| 1080 | - $line_item .= '<td class="name">' . $action. esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
| 1081 | - if ( $summary !== '' ) { |
|
| 1082 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
| 1079 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
| 1080 | + $line_item .= '<td class="name">' . $action . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
| 1081 | + if ($summary !== '') { |
|
| 1082 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
| 1083 | 1083 | } |
| 1084 | 1084 | $line_item .= '</td>'; |
| 1085 | 1085 | |
| 1086 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>'; |
|
| 1086 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>'; |
|
| 1087 | 1087 | if ($quantities_enabled) { |
| 1088 | 1088 | $cols++; |
| 1089 | 1089 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1092,55 +1092,55 @@ discard block |
||
| 1092 | 1092 | $cols++; |
| 1093 | 1093 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
| 1094 | 1094 | } |
| 1095 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>'; |
|
| 1095 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>'; |
|
| 1096 | 1096 | $line_item .= '</tr>'; |
| 1097 | 1097 | |
| 1098 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
| 1098 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
| 1099 | 1099 | |
| 1100 | 1100 | $count++; |
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
| 1103 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
| 1104 | 1104 | ?> |
| 1105 | 1105 | <tr class="row-sub-total row_odd"> |
| 1106 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
| 1107 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
| 1106 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
| 1107 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
| 1108 | 1108 | </tr> |
| 1109 | 1109 | <?php |
| 1110 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
| 1110 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
| 1111 | 1111 | |
| 1112 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
| 1113 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
| 1112 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
| 1113 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
| 1114 | 1114 | ?> |
| 1115 | 1115 | <tr class="row-discount"> |
| 1116 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
| 1117 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
| 1116 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
| 1117 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
| 1118 | 1118 | </tr> |
| 1119 | 1119 | <?php |
| 1120 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
| 1120 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | - if ( $use_taxes ) { |
|
| 1124 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
| 1123 | + if ($use_taxes) { |
|
| 1124 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
| 1125 | 1125 | ?> |
| 1126 | 1126 | <tr class="row-tax"> |
| 1127 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
| 1128 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
| 1127 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
| 1128 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
| 1129 | 1129 | </tr> |
| 1130 | 1130 | <?php |
| 1131 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
| 1131 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
| 1134 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
| 1135 | 1135 | ?> |
| 1136 | 1136 | <tr class="table-active row-total"> |
| 1137 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
| 1138 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
| 1137 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
| 1138 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
| 1139 | 1139 | </tr> |
| 1140 | 1140 | <?php |
| 1141 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
| 1141 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
| 1142 | 1142 | |
| 1143 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
| 1143 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
| 1144 | 1144 | } |
| 1145 | 1145 | ?> |
| 1146 | 1146 | </tbody> |
@@ -1152,56 +1152,56 @@ discard block |
||
| 1152 | 1152 | /** |
| 1153 | 1153 | * @param WPInv_Invoice $invoice |
| 1154 | 1154 | */ |
| 1155 | -function wpinv_display_invoice_notes( $invoice ) { |
|
| 1155 | +function wpinv_display_invoice_notes($invoice) { |
|
| 1156 | 1156 | |
| 1157 | - $notes = wpinv_get_invoice_notes( $invoice->ID, 'customer' ); |
|
| 1157 | + $notes = wpinv_get_invoice_notes($invoice->ID, 'customer'); |
|
| 1158 | 1158 | |
| 1159 | - if ( empty( $notes ) ) { |
|
| 1159 | + if (empty($notes)) { |
|
| 1160 | 1160 | return; |
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | echo '<div class="wpi_invoice_notes_container">'; |
| 1164 | - echo '<h2>' . __( 'Invoice Notes', 'invoicing' ) .'</h2>'; |
|
| 1164 | + echo '<h2>' . __('Invoice Notes', 'invoicing') . '</h2>'; |
|
| 1165 | 1165 | echo '<ul class="wpi_invoice_notes">'; |
| 1166 | 1166 | |
| 1167 | - foreach( $notes as $note ) { |
|
| 1168 | - wpinv_get_invoice_note_line_item( $note ); |
|
| 1167 | + foreach ($notes as $note) { |
|
| 1168 | + wpinv_get_invoice_note_line_item($note); |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | echo '</ul>'; |
| 1172 | 1172 | echo '</div>'; |
| 1173 | 1173 | } |
| 1174 | -add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes' ); |
|
| 1174 | +add_action('wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes'); |
|
| 1175 | 1175 | |
| 1176 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
| 1176 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
| 1177 | 1177 | $use_taxes = wpinv_use_taxes(); |
| 1178 | 1178 | |
| 1179 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
| 1179 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
| 1180 | 1180 | ?> |
| 1181 | 1181 | <table class="table table-sm table-bordered table-responsive"> |
| 1182 | 1182 | <tbody> |
| 1183 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
| 1183 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
| 1184 | 1184 | <tr class="row-sub-total"> |
| 1185 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
| 1186 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
| 1185 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
| 1186 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
| 1187 | 1187 | </tr> |
| 1188 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
| 1189 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
| 1188 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
| 1189 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
| 1190 | 1190 | <tr class="row-discount"> |
| 1191 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
| 1192 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
| 1191 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
| 1192 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
| 1193 | 1193 | </tr> |
| 1194 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
| 1194 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
| 1195 | 1195 | <?php } ?> |
| 1196 | - <?php if ( $use_taxes ) { ?> |
|
| 1196 | + <?php if ($use_taxes) { ?> |
|
| 1197 | 1197 | <tr class="row-tax"> |
| 1198 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
| 1199 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
| 1198 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
| 1199 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
| 1200 | 1200 | </tr> |
| 1201 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
| 1201 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
| 1202 | 1202 | <?php } ?> |
| 1203 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
| 1204 | - <?php foreach ( $fees as $fee ) { ?> |
|
| 1203 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
| 1204 | + <?php foreach ($fees as $fee) { ?> |
|
| 1205 | 1205 | <tr class="row-fee"> |
| 1206 | 1206 | <td class="rate"><?php echo $fee['label']; ?></td> |
| 1207 | 1207 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1209,82 +1209,82 @@ discard block |
||
| 1209 | 1209 | <?php } ?> |
| 1210 | 1210 | <?php } ?> |
| 1211 | 1211 | <tr class="table-active row-total"> |
| 1212 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
| 1213 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
| 1212 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
| 1213 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
| 1214 | 1214 | </tr> |
| 1215 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
| 1215 | + <?php do_action('wpinv_after_totals'); ?> |
|
| 1216 | 1216 | </tbody> |
| 1217 | 1217 | |
| 1218 | 1218 | </table> |
| 1219 | 1219 | |
| 1220 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
| 1220 | + <?php do_action('wpinv_after_totals_table'); |
|
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
| 1224 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1223 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
| 1224 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1225 | 1225 | |
| 1226 | 1226 | ob_start(); |
| 1227 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
| 1228 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 1227 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
| 1228 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 1229 | 1229 | ?> |
| 1230 | 1230 | <div class="wpi-payment-info"> |
| 1231 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
| 1232 | - <?php if ( $gateway_title ) { ?> |
|
| 1233 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
| 1231 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
| 1232 | + <?php if ($gateway_title) { ?> |
|
| 1233 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
| 1234 | 1234 | <?php } ?> |
| 1235 | 1235 | </div> |
| 1236 | 1236 | <?php |
| 1237 | 1237 | } |
| 1238 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
| 1238 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
| 1239 | 1239 | $outout = ob_get_clean(); |
| 1240 | 1240 | |
| 1241 | - if ( $echo ) { |
|
| 1241 | + if ($echo) { |
|
| 1242 | 1242 | echo $outout; |
| 1243 | 1243 | } else { |
| 1244 | 1244 | return $outout; |
| 1245 | 1245 | } |
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | -function wpinv_display_style( $invoice ) { |
|
| 1249 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
| 1248 | +function wpinv_display_style($invoice) { |
|
| 1249 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
| 1250 | 1250 | |
| 1251 | - wp_print_styles( 'open-sans' ); |
|
| 1252 | - wp_print_styles( 'wpinv-single-style' ); |
|
| 1251 | + wp_print_styles('open-sans'); |
|
| 1252 | + wp_print_styles('wpinv-single-style'); |
|
| 1253 | 1253 | |
| 1254 | 1254 | $custom_css = wpinv_get_option('template_custom_css'); |
| 1255 | - if(isset($custom_css) && !empty($custom_css)){ |
|
| 1256 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
| 1257 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
| 1255 | + if (isset($custom_css) && !empty($custom_css)) { |
|
| 1256 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
| 1257 | + $custom_css = str_replace('>', '>', $custom_css); |
|
| 1258 | 1258 | echo '<style type="text/css">'; |
| 1259 | 1259 | echo $custom_css; |
| 1260 | 1260 | echo '</style>'; |
| 1261 | 1261 | } |
| 1262 | 1262 | } |
| 1263 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
| 1264 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
| 1263 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
| 1264 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
| 1265 | 1265 | |
| 1266 | 1266 | function wpinv_checkout_billing_details() { |
| 1267 | - $invoice_id = (int)wpinv_get_invoice_cart_id(); |
|
| 1267 | + $invoice_id = (int) wpinv_get_invoice_cart_id(); |
|
| 1268 | 1268 | if (empty($invoice_id)) { |
| 1269 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
| 1269 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
| 1270 | 1270 | return null; |
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
| 1273 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
| 1274 | 1274 | if (empty($invoice)) { |
| 1275 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
| 1275 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
| 1276 | 1276 | return null; |
| 1277 | 1277 | } |
| 1278 | 1278 | $user_id = $invoice->get_user_id(); |
| 1279 | 1279 | $user_info = $invoice->get_user_info(); |
| 1280 | - $address_info = wpinv_get_user_address( $user_id ); |
|
| 1280 | + $address_info = wpinv_get_user_address($user_id); |
|
| 1281 | 1281 | |
| 1282 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
| 1282 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
| 1283 | 1283 | $user_info['first_name'] = $user_info['first_name']; |
| 1284 | 1284 | $user_info['last_name'] = $user_info['last_name']; |
| 1285 | 1285 | } |
| 1286 | 1286 | |
| 1287 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
| 1287 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
| 1288 | 1288 | $user_info['country'] = $address_info['country']; |
| 1289 | 1289 | $user_info['state'] = $address_info['state']; |
| 1290 | 1290 | $user_info['city'] = $address_info['city']; |
@@ -1300,98 +1300,98 @@ discard block |
||
| 1300 | 1300 | 'address' |
| 1301 | 1301 | ); |
| 1302 | 1302 | |
| 1303 | - foreach ( $address_fields as $field ) { |
|
| 1304 | - if ( empty( $user_info[$field] ) ) { |
|
| 1303 | + foreach ($address_fields as $field) { |
|
| 1304 | + if (empty($user_info[$field])) { |
|
| 1305 | 1305 | $user_info[$field] = $address_info[$field]; |
| 1306 | 1306 | } |
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
| 1309 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
| 1310 | 1310 | } |
| 1311 | 1311 | |
| 1312 | 1312 | function wpinv_admin_get_line_items($invoice = array()) { |
| 1313 | 1313 | $item_quantities = wpinv_item_quantities_enabled(); |
| 1314 | 1314 | $use_taxes = wpinv_use_taxes(); |
| 1315 | 1315 | |
| 1316 | - if ( empty( $invoice ) ) { |
|
| 1316 | + if (empty($invoice)) { |
|
| 1317 | 1317 | return NULL; |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | $cart_items = $invoice->get_cart_details(); |
| 1321 | - if ( empty( $cart_items ) ) { |
|
| 1321 | + if (empty($cart_items)) { |
|
| 1322 | 1322 | return NULL; |
| 1323 | 1323 | } |
| 1324 | 1324 | ob_start(); |
| 1325 | 1325 | |
| 1326 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
| 1326 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
| 1327 | 1327 | |
| 1328 | 1328 | $count = 0; |
| 1329 | - foreach ( $cart_items as $key => $cart_item ) { |
|
| 1329 | + foreach ($cart_items as $key => $cart_item) { |
|
| 1330 | 1330 | $item_id = $cart_item['id']; |
| 1331 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
| 1331 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
| 1332 | 1332 | |
| 1333 | 1333 | if (empty($wpi_item)) { |
| 1334 | 1334 | continue; |
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 1337 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() ); |
|
| 1338 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
| 1339 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() ); |
|
| 1337 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency()); |
|
| 1338 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
| 1339 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency()); |
|
| 1340 | 1340 | $can_remove = true; |
| 1341 | 1341 | |
| 1342 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice ); |
|
| 1342 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice); |
|
| 1343 | 1343 | |
| 1344 | 1344 | $item_tax = ''; |
| 1345 | 1345 | $tax_rate = ''; |
| 1346 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
| 1347 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
| 1348 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
| 1349 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
| 1346 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
| 1347 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
| 1348 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
| 1349 | + $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : ''; |
|
| 1350 | 1350 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
| 1351 | 1351 | } |
| 1352 | 1352 | $line_item_tax = $item_tax . $tax_rate; |
| 1353 | 1353 | |
| 1354 | - if ( $line_item_tax === '' ) { |
|
| 1354 | + if ($line_item_tax === '') { |
|
| 1355 | 1355 | $line_item_tax = 0; // Zero tax |
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
| 1358 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
| 1359 | 1359 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
| 1360 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item ); |
|
| 1361 | - if ( $summary !== '' ) { |
|
| 1362 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
| 1360 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item); |
|
| 1361 | + if ($summary !== '') { |
|
| 1362 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
| 1363 | 1363 | } |
| 1364 | 1364 | $line_item .= '</td>'; |
| 1365 | 1365 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
| 1366 | 1366 | |
| 1367 | - if ( $item_quantities ) { |
|
| 1368 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
| 1367 | + if ($item_quantities) { |
|
| 1368 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
| 1369 | 1369 | $can_remove = false; |
| 1370 | 1370 | } |
| 1371 | 1371 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
| 1372 | 1372 | } else { |
| 1373 | - if ( count( $cart_items ) == 1 ) { |
|
| 1373 | + if (count($cart_items) == 1) { |
|
| 1374 | 1374 | $can_remove = false; |
| 1375 | 1375 | } |
| 1376 | 1376 | } |
| 1377 | 1377 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
| 1378 | 1378 | |
| 1379 | - if ( $use_taxes ) { |
|
| 1379 | + if ($use_taxes) { |
|
| 1380 | 1380 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
| 1381 | 1381 | } |
| 1382 | 1382 | $line_item .= '<td class="action">'; |
| 1383 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
| 1383 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 1384 | 1384 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
| 1385 | 1385 | } |
| 1386 | 1386 | $line_item .= '</td>'; |
| 1387 | 1387 | $line_item .= '</tr>'; |
| 1388 | 1388 | |
| 1389 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
| 1389 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
| 1390 | 1390 | |
| 1391 | 1391 | $count++; |
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
| 1394 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
| 1395 | 1395 | |
| 1396 | 1396 | return ob_get_clean(); |
| 1397 | 1397 | } |
@@ -1403,32 +1403,32 @@ discard block |
||
| 1403 | 1403 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
| 1404 | 1404 | |
| 1405 | 1405 | //Maybe update the prices |
| 1406 | - if(! empty( $_GET['wpi_dynamic_item'] ) && ! empty( $_GET['wpi_dynamic_price'] ) ) { |
|
| 1406 | + if (!empty($_GET['wpi_dynamic_item']) && !empty($_GET['wpi_dynamic_price'])) { |
|
| 1407 | 1407 | |
| 1408 | 1408 | //If the invoice exists, update it with new pricing details |
| 1409 | - if (! empty( $wpi_checkout_id ) ) { |
|
| 1409 | + if (!empty($wpi_checkout_id)) { |
|
| 1410 | 1410 | |
| 1411 | 1411 | $_invoice = wpinv_get_invoice_cart(); |
| 1412 | 1412 | $_cart_details = $_invoice->get_cart_details(); |
| 1413 | - $_dynamic_item = sanitize_text_field( $_GET['wpi_dynamic_item'] ); |
|
| 1413 | + $_dynamic_item = sanitize_text_field($_GET['wpi_dynamic_item']); |
|
| 1414 | 1414 | |
| 1415 | 1415 | //First, fetch the item |
| 1416 | - $item = new WPInv_Item( $_dynamic_item ); |
|
| 1416 | + $item = new WPInv_Item($_dynamic_item); |
|
| 1417 | 1417 | |
| 1418 | 1418 | //Next, ensure it supports dynamic pricing... |
| 1419 | - if( $item->supports_dynamic_pricing() && $item->get_is_dynamic_pricing() ) { |
|
| 1419 | + if ($item->supports_dynamic_pricing() && $item->get_is_dynamic_pricing()) { |
|
| 1420 | 1420 | |
| 1421 | 1421 | //... and that the new price is not lower than the minimum price |
| 1422 | - $_dynamic_price = (float) wpinv_sanitize_amount( sanitize_text_field( $_GET['wpi_dynamic_price'] ) ); |
|
| 1423 | - if( $_dynamic_price < $item->get_minimum_price() ) { |
|
| 1422 | + $_dynamic_price = (float) wpinv_sanitize_amount(sanitize_text_field($_GET['wpi_dynamic_price'])); |
|
| 1423 | + if ($_dynamic_price < $item->get_minimum_price()) { |
|
| 1424 | 1424 | $_dynamic_price = $item->get_minimum_price(); |
| 1425 | 1425 | } |
| 1426 | 1426 | |
| 1427 | 1427 | //Finally, update our invoice with the new price |
| 1428 | - if ( !empty( $_cart_details ) ) { |
|
| 1428 | + if (!empty($_cart_details)) { |
|
| 1429 | 1429 | |
| 1430 | - foreach ( $_cart_details as $key => $item ) { |
|
| 1431 | - if ( !empty( $item['id'] ) && $_dynamic_item == $item['id'] ) { |
|
| 1430 | + foreach ($_cart_details as $key => $item) { |
|
| 1431 | + if (!empty($item['id']) && $_dynamic_item == $item['id']) { |
|
| 1432 | 1432 | $_cart_details[$key]['custom_price'] = $_dynamic_price; |
| 1433 | 1433 | $_cart_details[$key]['item_price'] = $_dynamic_price; |
| 1434 | 1434 | } |
@@ -1436,8 +1436,8 @@ discard block |
||
| 1436 | 1436 | |
| 1437 | 1437 | $_meta = $_invoice->get_meta(); |
| 1438 | 1438 | $_meta['cart_details'] = $_cart_details; |
| 1439 | - $_invoice->set( 'payment_meta', $_meta ); |
|
| 1440 | - $_invoice->set( 'cart_details', $_cart_details ); |
|
| 1439 | + $_invoice->set('payment_meta', $_meta); |
|
| 1440 | + $_invoice->set('cart_details', $_cart_details); |
|
| 1441 | 1441 | $_invoice->recalculate_totals(); |
| 1442 | 1442 | |
| 1443 | 1443 | } |
@@ -1448,60 +1448,60 @@ discard block |
||
| 1448 | 1448 | |
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
| 1451 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
| 1452 | 1452 | |
| 1453 | 1453 | ob_start(); |
| 1454 | - do_action( 'wpinv_checkout_content_before' ); |
|
| 1454 | + do_action('wpinv_checkout_content_before'); |
|
| 1455 | 1455 | echo '<div id="wpinv_checkout_wrap">'; |
| 1456 | 1456 | |
| 1457 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
| 1457 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
| 1458 | 1458 | ?> |
| 1459 | 1459 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
| 1460 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
| 1460 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
| 1461 | 1461 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
| 1462 | 1462 | <?php |
| 1463 | - do_action( 'wpinv_checkout_form_top' ); |
|
| 1464 | - do_action( 'wpinv_checkout_billing_info' ); |
|
| 1465 | - do_action( 'wpinv_checkout_cart' ); |
|
| 1466 | - do_action( 'wpinv_payment_mode_select' ); |
|
| 1467 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
| 1463 | + do_action('wpinv_checkout_form_top'); |
|
| 1464 | + do_action('wpinv_checkout_billing_info'); |
|
| 1465 | + do_action('wpinv_checkout_cart'); |
|
| 1466 | + do_action('wpinv_payment_mode_select'); |
|
| 1467 | + do_action('wpinv_checkout_form_bottom') |
|
| 1468 | 1468 | ?> |
| 1469 | 1469 | </form> |
| 1470 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
| 1470 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
| 1471 | 1471 | </div><!--end #wpinv_checkout_form_wrap--> |
| 1472 | 1472 | <?php |
| 1473 | 1473 | } else { |
| 1474 | - do_action( 'wpinv_cart_empty' ); |
|
| 1474 | + do_action('wpinv_cart_empty'); |
|
| 1475 | 1475 | } |
| 1476 | 1476 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
| 1477 | - do_action( 'wpinv_checkout_content_after' ); |
|
| 1477 | + do_action('wpinv_checkout_content_after'); |
|
| 1478 | 1478 | return ob_get_clean(); |
| 1479 | 1479 | } |
| 1480 | 1480 | |
| 1481 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
| 1481 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
| 1482 | 1482 | global $ajax_cart_details; |
| 1483 | 1483 | $ajax_cart_details = $cart_details; |
| 1484 | 1484 | |
| 1485 | 1485 | ob_start(); |
| 1486 | - do_action( 'wpinv_before_checkout_cart' ); |
|
| 1486 | + do_action('wpinv_before_checkout_cart'); |
|
| 1487 | 1487 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
| 1488 | 1488 | echo '<div id="wpinv_checkout_cart_wrap">'; |
| 1489 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
| 1489 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
| 1490 | 1490 | echo '</div>'; |
| 1491 | 1491 | echo '</div>'; |
| 1492 | - do_action( 'wpinv_after_checkout_cart' ); |
|
| 1492 | + do_action('wpinv_after_checkout_cart'); |
|
| 1493 | 1493 | $content = ob_get_clean(); |
| 1494 | 1494 | |
| 1495 | - if ( $echo ) { |
|
| 1495 | + if ($echo) { |
|
| 1496 | 1496 | echo $content; |
| 1497 | 1497 | } else { |
| 1498 | 1498 | return $content; |
| 1499 | 1499 | } |
| 1500 | 1500 | } |
| 1501 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
| 1501 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
| 1502 | 1502 | |
| 1503 | 1503 | function wpinv_empty_cart_message() { |
| 1504 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1504 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
| 1505 | 1505 | } |
| 1506 | 1506 | |
| 1507 | 1507 | /** |
@@ -1513,83 +1513,83 @@ discard block |
||
| 1513 | 1513 | function wpinv_empty_checkout_cart() { |
| 1514 | 1514 | echo wpinv_empty_cart_message(); |
| 1515 | 1515 | } |
| 1516 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
| 1516 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
| 1517 | 1517 | |
| 1518 | 1518 | function wpinv_update_cart_button() { |
| 1519 | - if ( !wpinv_item_quantities_enabled() ) |
|
| 1519 | + if (!wpinv_item_quantities_enabled()) |
|
| 1520 | 1520 | return; |
| 1521 | 1521 | ?> |
| 1522 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
| 1522 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
| 1523 | 1523 | <input type="hidden" name="wpi_action" value="update_cart"/> |
| 1524 | 1524 | <?php |
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | function wpinv_checkout_cart_columns() { |
| 1528 | 1528 | $default = 3; |
| 1529 | - if ( wpinv_item_quantities_enabled() ) { |
|
| 1529 | + if (wpinv_item_quantities_enabled()) { |
|
| 1530 | 1530 | $default++; |
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | - if ( wpinv_use_taxes() ) { |
|
| 1533 | + if (wpinv_use_taxes()) { |
|
| 1534 | 1534 | $default++; |
| 1535 | 1535 | } |
| 1536 | 1536 | |
| 1537 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
| 1537 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
| 1538 | 1538 | } |
| 1539 | 1539 | |
| 1540 | 1540 | function wpinv_display_cart_messages() { |
| 1541 | 1541 | global $wpi_session; |
| 1542 | 1542 | |
| 1543 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
| 1543 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
| 1544 | 1544 | |
| 1545 | - if ( $messages ) { |
|
| 1546 | - foreach ( $messages as $message_id => $message ) { |
|
| 1545 | + if ($messages) { |
|
| 1546 | + foreach ($messages as $message_id => $message) { |
|
| 1547 | 1547 | // Try and detect what type of message this is |
| 1548 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
| 1548 | + if (strpos(strtolower($message), 'error')) { |
|
| 1549 | 1549 | $type = 'error'; |
| 1550 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
| 1550 | + } elseif (strpos(strtolower($message), 'success')) { |
|
| 1551 | 1551 | $type = 'success'; |
| 1552 | 1552 | } else { |
| 1553 | 1553 | $type = 'info'; |
| 1554 | 1554 | } |
| 1555 | 1555 | |
| 1556 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
| 1556 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
| 1557 | 1557 | |
| 1558 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
| 1558 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
| 1559 | 1559 | // Loop message codes and display messages |
| 1560 | 1560 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
| 1561 | 1561 | echo '</div>'; |
| 1562 | 1562 | } |
| 1563 | 1563 | |
| 1564 | 1564 | // Remove all of the cart saving messages |
| 1565 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
| 1565 | + $wpi_session->set('wpinv_cart_messages', null); |
|
| 1566 | 1566 | } |
| 1567 | 1567 | } |
| 1568 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
| 1568 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
| 1569 | 1569 | |
| 1570 | 1570 | function wpinv_discount_field() { |
| 1571 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
| 1571 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
| 1572 | 1572 | return; // Only show before a payment method has been selected if ajax is disabled |
| 1573 | 1573 | } |
| 1574 | 1574 | |
| 1575 | - if ( !wpinv_is_checkout() ) { |
|
| 1575 | + if (!wpinv_is_checkout()) { |
|
| 1576 | 1576 | return; |
| 1577 | 1577 | } |
| 1578 | 1578 | |
| 1579 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
| 1579 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
| 1580 | 1580 | ?> |
| 1581 | 1581 | <div id="wpinv-discount-field" class="panel panel-default"> |
| 1582 | 1582 | <div class="panel-body"> |
| 1583 | 1583 | <p> |
| 1584 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
| 1585 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
| 1584 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
| 1585 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
| 1586 | 1586 | </p> |
| 1587 | 1587 | <div class="form-group row"> |
| 1588 | 1588 | <div class="col-sm-4"> |
| 1589 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
| 1589 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
| 1590 | 1590 | </div> |
| 1591 | 1591 | <div class="col-sm-3"> |
| 1592 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
| 1592 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
| 1593 | 1593 | </div> |
| 1594 | 1594 | <div style="clear:both"></div> |
| 1595 | 1595 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1602,10 +1602,10 @@ discard block |
||
| 1602 | 1602 | <?php |
| 1603 | 1603 | } |
| 1604 | 1604 | } |
| 1605 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
| 1605 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
| 1606 | 1606 | |
| 1607 | 1607 | function wpinv_agree_to_terms_js() { |
| 1608 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
| 1608 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
| 1609 | 1609 | ?> |
| 1610 | 1610 | <script type="text/javascript"> |
| 1611 | 1611 | jQuery(document).ready(function($){ |
@@ -1620,125 +1620,125 @@ discard block |
||
| 1620 | 1620 | <?php |
| 1621 | 1621 | } |
| 1622 | 1622 | } |
| 1623 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
| 1623 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
| 1624 | 1624 | |
| 1625 | 1625 | function wpinv_payment_mode_select() { |
| 1626 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
| 1627 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
| 1628 | - $invoice = wpinv_get_invoice( 0, true ); |
|
| 1626 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
| 1627 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
| 1628 | + $invoice = wpinv_get_invoice(0, true); |
|
| 1629 | 1629 | |
| 1630 | 1630 | do_action('wpinv_payment_mode_top'); |
| 1631 | - $invoice_id = (int)$invoice->ID; |
|
| 1632 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
| 1631 | + $invoice_id = (int) $invoice->ID; |
|
| 1632 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
| 1633 | 1633 | ?> |
| 1634 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;" data-free="1"' : '' ); ?>> |
|
| 1635 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
| 1634 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;" data-free="1"' : ''); ?>> |
|
| 1635 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
| 1636 | 1636 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
| 1637 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
| 1637 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
| 1638 | 1638 | <div class="panel-body list-group wpi-payment_methods"> |
| 1639 | 1639 | <?php |
| 1640 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
| 1641 | - |
|
| 1642 | - if ( !empty( $gateways ) ) { |
|
| 1643 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1644 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1645 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1646 | - $gateway_label = wpinv_get_gateway_checkout_label( $gateway_id ); |
|
| 1647 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1640 | + do_action('wpinv_payment_mode_before_gateways'); |
|
| 1641 | + |
|
| 1642 | + if (!empty($gateways)) { |
|
| 1643 | + foreach ($gateways as $gateway_id => $gateway) { |
|
| 1644 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
| 1645 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
| 1646 | + $gateway_label = wpinv_get_gateway_checkout_label($gateway_id); |
|
| 1647 | + $description = wpinv_get_gateway_description($gateway_id); |
|
| 1648 | 1648 | ?> |
| 1649 | 1649 | <div class="list-group-item"> |
| 1650 | 1650 | <div class="radio"> |
| 1651 | - <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_label ); ?></label> |
|
| 1651 | + <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_label); ?></label> |
|
| 1652 | 1652 | </div> |
| 1653 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
| 1654 | - <?php if ( !empty( $description ) ) { ?> |
|
| 1655 | - <div class="wpi-gateway-desc alert alert-info"><?php _e( $description, 'invoicing' ); ?></div> |
|
| 1653 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
| 1654 | + <?php if (!empty($description)) { ?> |
|
| 1655 | + <div class="wpi-gateway-desc alert alert-info"><?php _e($description, 'invoicing'); ?></div> |
|
| 1656 | 1656 | <?php } ?> |
| 1657 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
| 1657 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
| 1658 | 1658 | </div> |
| 1659 | 1659 | </div> |
| 1660 | 1660 | <?php |
| 1661 | 1661 | } |
| 1662 | 1662 | } else { |
| 1663 | - echo '<div class="alert alert-warning">'. __( 'No payment gateway active', 'invoicing' ) .'</div>'; |
|
| 1663 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
| 1664 | 1664 | } |
| 1665 | 1665 | |
| 1666 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
| 1666 | + do_action('wpinv_payment_mode_after_gateways'); |
|
| 1667 | 1667 | ?> |
| 1668 | 1668 | </div> |
| 1669 | 1669 | </div> |
| 1670 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
| 1670 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
| 1671 | 1671 | </div> |
| 1672 | 1672 | <?php |
| 1673 | 1673 | do_action('wpinv_payment_mode_bottom'); |
| 1674 | 1674 | } |
| 1675 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
| 1675 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
| 1676 | 1676 | |
| 1677 | 1677 | function wpinv_checkout_billing_info() { |
| 1678 | - if ( wpinv_is_checkout() ) { |
|
| 1678 | + if (wpinv_is_checkout()) { |
|
| 1679 | 1679 | $billing_details = wpinv_checkout_billing_details(); |
| 1680 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
| 1680 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
| 1681 | 1681 | ?> |
| 1682 | 1682 | <div id="wpinv-fields" class="clearfix"> |
| 1683 | 1683 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
| 1684 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
| 1684 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
| 1685 | 1685 | <div id="wpinv-fields-box" class="panel-body"> |
| 1686 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
| 1686 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
| 1687 | 1687 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1688 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1688 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1689 | 1689 | <?php |
| 1690 | - echo wpinv_html_text( array( |
|
| 1690 | + echo wpinv_html_text(array( |
|
| 1691 | 1691 | 'id' => 'wpinv_first_name', |
| 1692 | 1692 | 'name' => 'wpinv_first_name', |
| 1693 | 1693 | 'value' => $billing_details['first_name'], |
| 1694 | 1694 | 'class' => 'wpi-input form-control', |
| 1695 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
| 1696 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
| 1697 | - ) ); |
|
| 1695 | + 'placeholder' => __('First name', 'invoicing'), |
|
| 1696 | + 'required' => (bool) wpinv_get_option('fname_mandatory'), |
|
| 1697 | + )); |
|
| 1698 | 1698 | ?> |
| 1699 | 1699 | </p> |
| 1700 | 1700 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1701 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1701 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1702 | 1702 | <?php |
| 1703 | - echo wpinv_html_text( array( |
|
| 1703 | + echo wpinv_html_text(array( |
|
| 1704 | 1704 | 'id' => 'wpinv_last_name', |
| 1705 | 1705 | 'name' => 'wpinv_last_name', |
| 1706 | 1706 | 'value' => $billing_details['last_name'], |
| 1707 | 1707 | 'class' => 'wpi-input form-control', |
| 1708 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
| 1709 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
| 1710 | - ) ); |
|
| 1708 | + 'placeholder' => __('Last name', 'invoicing'), |
|
| 1709 | + 'required' => (bool) wpinv_get_option('lname_mandatory'), |
|
| 1710 | + )); |
|
| 1711 | 1711 | ?> |
| 1712 | 1712 | </p> |
| 1713 | 1713 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1714 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1714 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1715 | 1715 | <?php |
| 1716 | - echo wpinv_html_text( array( |
|
| 1716 | + echo wpinv_html_text(array( |
|
| 1717 | 1717 | 'id' => 'wpinv_address', |
| 1718 | 1718 | 'name' => 'wpinv_address', |
| 1719 | 1719 | 'value' => $billing_details['address'], |
| 1720 | 1720 | 'class' => 'wpi-input form-control', |
| 1721 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
| 1722 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
| 1723 | - ) ); |
|
| 1721 | + 'placeholder' => __('Address', 'invoicing'), |
|
| 1722 | + 'required' => (bool) wpinv_get_option('address_mandatory'), |
|
| 1723 | + )); |
|
| 1724 | 1724 | ?> |
| 1725 | 1725 | </p> |
| 1726 | 1726 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1727 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1727 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1728 | 1728 | <?php |
| 1729 | - echo wpinv_html_text( array( |
|
| 1729 | + echo wpinv_html_text(array( |
|
| 1730 | 1730 | 'id' => 'wpinv_city', |
| 1731 | 1731 | 'name' => 'wpinv_city', |
| 1732 | 1732 | 'value' => $billing_details['city'], |
| 1733 | 1733 | 'class' => 'wpi-input form-control', |
| 1734 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
| 1735 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
| 1736 | - ) ); |
|
| 1734 | + 'placeholder' => __('City', 'invoicing'), |
|
| 1735 | + 'required' => (bool) wpinv_get_option('city_mandatory'), |
|
| 1736 | + )); |
|
| 1737 | 1737 | ?> |
| 1738 | 1738 | </p> |
| 1739 | 1739 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1740 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1741 | - <?php echo wpinv_html_select( array( |
|
| 1740 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1741 | + <?php echo wpinv_html_select(array( |
|
| 1742 | 1742 | 'options' => wpinv_get_country_list(), |
| 1743 | 1743 | 'name' => 'wpinv_country', |
| 1744 | 1744 | 'id' => 'wpinv_country', |
@@ -1746,16 +1746,16 @@ discard block |
||
| 1746 | 1746 | 'show_option_all' => false, |
| 1747 | 1747 | 'show_option_none' => false, |
| 1748 | 1748 | 'class' => 'wpi-input form-control wpi_select2', |
| 1749 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 1750 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
| 1751 | - ) ); ?> |
|
| 1749 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
| 1750 | + 'required' => (bool) wpinv_get_option('country_mandatory'), |
|
| 1751 | + )); ?> |
|
| 1752 | 1752 | </p> |
| 1753 | 1753 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1754 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1754 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1755 | 1755 | <?php |
| 1756 | - $states = wpinv_get_country_states( $selected_country ); |
|
| 1757 | - if( !empty( $states ) ) { |
|
| 1758 | - echo wpinv_html_select( array( |
|
| 1756 | + $states = wpinv_get_country_states($selected_country); |
|
| 1757 | + if (!empty($states)) { |
|
| 1758 | + echo wpinv_html_select(array( |
|
| 1759 | 1759 | 'options' => $states, |
| 1760 | 1760 | 'name' => 'wpinv_state', |
| 1761 | 1761 | 'id' => 'wpinv_state', |
@@ -1763,61 +1763,61 @@ discard block |
||
| 1763 | 1763 | 'show_option_all' => false, |
| 1764 | 1764 | 'show_option_none' => false, |
| 1765 | 1765 | 'class' => 'wpi-input form-control wpi_select2', |
| 1766 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 1767 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
| 1768 | - ) ); |
|
| 1766 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 1767 | + 'required' => (bool) wpinv_get_option('state_mandatory'), |
|
| 1768 | + )); |
|
| 1769 | 1769 | } else { |
| 1770 | - echo wpinv_html_text( array( |
|
| 1770 | + echo wpinv_html_text(array( |
|
| 1771 | 1771 | 'name' => 'wpinv_state', |
| 1772 | 1772 | 'value' => $billing_details['state'], |
| 1773 | 1773 | 'id' => 'wpinv_state', |
| 1774 | 1774 | 'class' => 'wpi-input form-control', |
| 1775 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
| 1776 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
| 1777 | - ) ); |
|
| 1775 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
| 1776 | + 'required' => (bool) wpinv_get_option('state_mandatory'), |
|
| 1777 | + )); |
|
| 1778 | 1778 | } |
| 1779 | 1779 | ?> |
| 1780 | 1780 | </p> |
| 1781 | 1781 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1782 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1782 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1783 | 1783 | <?php |
| 1784 | - echo wpinv_html_text( array( |
|
| 1784 | + echo wpinv_html_text(array( |
|
| 1785 | 1785 | 'name' => 'wpinv_zip', |
| 1786 | 1786 | 'value' => $billing_details['zip'], |
| 1787 | 1787 | 'id' => 'wpinv_zip', |
| 1788 | 1788 | 'class' => 'wpi-input form-control', |
| 1789 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
| 1790 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
| 1791 | - ) ); |
|
| 1789 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
| 1790 | + 'required' => (bool) wpinv_get_option('zip_mandatory'), |
|
| 1791 | + )); |
|
| 1792 | 1792 | ?> |
| 1793 | 1793 | </p> |
| 1794 | 1794 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1795 | - <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1795 | + <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1796 | 1796 | <?php |
| 1797 | - echo wpinv_html_text( array( |
|
| 1797 | + echo wpinv_html_text(array( |
|
| 1798 | 1798 | 'id' => 'wpinv_phone', |
| 1799 | 1799 | 'name' => 'wpinv_phone', |
| 1800 | 1800 | 'value' => $billing_details['phone'], |
| 1801 | 1801 | 'class' => 'wpi-input form-control', |
| 1802 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
| 1803 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
| 1804 | - ) ); |
|
| 1802 | + 'placeholder' => __('Phone', 'invoicing'), |
|
| 1803 | + 'required' => (bool) wpinv_get_option('phone_mandatory'), |
|
| 1804 | + )); |
|
| 1805 | 1805 | ?> |
| 1806 | 1806 | </p> |
| 1807 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
| 1807 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
| 1808 | 1808 | <div class="clearfix"></div> |
| 1809 | 1809 | </div> |
| 1810 | 1810 | </div> |
| 1811 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
| 1811 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
| 1812 | 1812 | </div> |
| 1813 | 1813 | <?php |
| 1814 | 1814 | } |
| 1815 | 1815 | } |
| 1816 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
| 1816 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
| 1817 | 1817 | |
| 1818 | 1818 | function wpinv_checkout_hidden_fields() { |
| 1819 | 1819 | ?> |
| 1820 | - <?php if ( is_user_logged_in() ) { ?> |
|
| 1820 | + <?php if (is_user_logged_in()) { ?> |
|
| 1821 | 1821 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
| 1822 | 1822 | <?php } ?> |
| 1823 | 1823 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1827,9 +1827,9 @@ discard block |
||
| 1827 | 1827 | function wpinv_checkout_button_purchase() { |
| 1828 | 1828 | ob_start(); |
| 1829 | 1829 | ?> |
| 1830 | - <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/> |
|
| 1830 | + <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/> |
|
| 1831 | 1831 | <?php |
| 1832 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
| 1832 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
| 1833 | 1833 | } |
| 1834 | 1834 | |
| 1835 | 1835 | function wpinv_checkout_total() { |
@@ -1838,84 +1838,84 @@ discard block |
||
| 1838 | 1838 | <div id="wpinv_checkout_total" class="panel panel-info"> |
| 1839 | 1839 | <div class="panel-body"> |
| 1840 | 1840 | <?php |
| 1841 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
| 1841 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
| 1842 | 1842 | ?> |
| 1843 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
| 1843 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
| 1844 | 1844 | <?php |
| 1845 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
| 1845 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
| 1846 | 1846 | ?> |
| 1847 | 1847 | </div> |
| 1848 | 1848 | </div> |
| 1849 | 1849 | <?php |
| 1850 | 1850 | } |
| 1851 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
| 1851 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
| 1852 | 1852 | |
| 1853 | 1853 | function wpinv_checkout_accept_tandc() { |
| 1854 | - $page = wpinv_get_option( 'tandc_page' ); |
|
| 1854 | + $page = wpinv_get_option('tandc_page'); |
|
| 1855 | 1855 | ?> |
| 1856 | 1856 | <div id="wpinv_checkout_tandc" class="panel panel-success"> |
| 1857 | 1857 | <div class="panel-body"> |
| 1858 | 1858 | <?php echo wpinv_get_policy_text(); ?> |
| 1859 | 1859 | <?php |
| 1860 | - if(isset($page) && (int)$page > 0 && apply_filters( 'wpinv_checkout_show_terms', true )){ |
|
| 1861 | - $terms_link = esc_url( get_permalink( $page ) ); |
|
| 1860 | + if (isset($page) && (int) $page > 0 && apply_filters('wpinv_checkout_show_terms', true)) { |
|
| 1861 | + $terms_link = esc_url(get_permalink($page)); |
|
| 1862 | 1862 | ?> |
| 1863 | 1863 | <label class=""> |
| 1864 | - <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked( apply_filters( 'wpinv_terms_is_checked_default', isset( $_POST['wpi_terms'] ) ), true ); ?>> <span><?php printf( __( 'I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing' ), $terms_link ); ?></span> <span class="wpi-required">*</span> |
|
| 1864 | + <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked(apply_filters('wpinv_terms_is_checked_default', isset($_POST['wpi_terms'])), true); ?>> <span><?php printf(__('I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing'), $terms_link); ?></span> <span class="wpi-required">*</span> |
|
| 1865 | 1865 | </label> |
| 1866 | 1866 | <?php } ?> |
| 1867 | 1867 | </div> |
| 1868 | 1868 | </div> |
| 1869 | 1869 | <?php |
| 1870 | 1870 | } |
| 1871 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995 ); |
|
| 1871 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995); |
|
| 1872 | 1872 | |
| 1873 | 1873 | function wpinv_checkout_submit() { |
| 1874 | 1874 | ?> |
| 1875 | 1875 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
| 1876 | 1876 | <div class="panel-body text-center"> |
| 1877 | 1877 | <?php |
| 1878 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
| 1878 | + do_action('wpinv_purchase_form_before_submit'); |
|
| 1879 | 1879 | wpinv_checkout_hidden_fields(); |
| 1880 | 1880 | echo wpinv_checkout_button_purchase(); |
| 1881 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
| 1881 | + do_action('wpinv_purchase_form_after_submit'); |
|
| 1882 | 1882 | ?> |
| 1883 | 1883 | </div> |
| 1884 | 1884 | </div> |
| 1885 | 1885 | <?php |
| 1886 | 1886 | } |
| 1887 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
| 1887 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
| 1888 | 1888 | |
| 1889 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
| 1890 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1889 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
| 1890 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1891 | 1891 | |
| 1892 | - if ( empty( $invoice ) ) { |
|
| 1892 | + if (empty($invoice)) { |
|
| 1893 | 1893 | return NULL; |
| 1894 | 1894 | } |
| 1895 | 1895 | |
| 1896 | 1896 | $billing_details = $invoice->get_user_info(); |
| 1897 | - $address_row = wpinv_get_invoice_address_markup( $billing_details ); |
|
| 1897 | + $address_row = wpinv_get_invoice_address_markup($billing_details); |
|
| 1898 | 1898 | |
| 1899 | 1899 | ob_start(); |
| 1900 | 1900 | ?> |
| 1901 | 1901 | <table class="table table-bordered table-sm wpi-billing-details"> |
| 1902 | 1902 | <tbody> |
| 1903 | 1903 | <tr class="wpi-receipt-name"> |
| 1904 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
| 1905 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
| 1904 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
| 1905 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
| 1906 | 1906 | </tr> |
| 1907 | 1907 | <tr class="wpi-receipt-email"> |
| 1908 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
| 1909 | - <td><?php echo $billing_details['email'] ;?></td> |
|
| 1908 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
| 1909 | + <td><?php echo $billing_details['email']; ?></td> |
|
| 1910 | 1910 | </tr> |
| 1911 | 1911 | <tr class="wpi-receipt-address"> |
| 1912 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
| 1913 | - <td><?php echo $address_row ;?></td> |
|
| 1912 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
| 1913 | + <td><?php echo $address_row; ?></td> |
|
| 1914 | 1914 | </tr> |
| 1915 | - <?php if ( $billing_details['phone'] ) { ?> |
|
| 1915 | + <?php if ($billing_details['phone']) { ?> |
|
| 1916 | 1916 | <tr class="wpi-receipt-phone"> |
| 1917 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
| 1918 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
| 1917 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
| 1918 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
| 1919 | 1919 | </tr> |
| 1920 | 1920 | <?php } ?> |
| 1921 | 1921 | </tbody> |
@@ -1923,74 +1923,74 @@ discard block |
||
| 1923 | 1923 | <?php |
| 1924 | 1924 | $output = ob_get_clean(); |
| 1925 | 1925 | |
| 1926 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
| 1926 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
| 1927 | 1927 | |
| 1928 | 1928 | echo $output; |
| 1929 | 1929 | } |
| 1930 | 1930 | |
| 1931 | -function wpinv_filter_success_page_content( $content ) { |
|
| 1932 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
| 1933 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
| 1934 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
| 1931 | +function wpinv_filter_success_page_content($content) { |
|
| 1932 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
| 1933 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
| 1934 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
| 1935 | 1935 | } |
| 1936 | 1936 | } |
| 1937 | 1937 | |
| 1938 | 1938 | return $content; |
| 1939 | 1939 | } |
| 1940 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
| 1940 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
| 1941 | 1941 | |
| 1942 | -function wpinv_receipt_actions( $invoice ) { |
|
| 1943 | - if ( !empty( $invoice ) ) { |
|
| 1942 | +function wpinv_receipt_actions($invoice) { |
|
| 1943 | + if (!empty($invoice)) { |
|
| 1944 | 1944 | $actions = array(); |
| 1945 | 1945 | |
| 1946 | - if ( wpinv_user_can_view_invoice( $invoice->ID ) ) { |
|
| 1947 | - $actions['print'] = array( |
|
| 1948 | - 'url' => $invoice->get_view_url( true ), |
|
| 1949 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
| 1946 | + if (wpinv_user_can_view_invoice($invoice->ID)) { |
|
| 1947 | + $actions['print'] = array( |
|
| 1948 | + 'url' => $invoice->get_view_url(true), |
|
| 1949 | + 'name' => __('Print Invoice', 'invoicing'), |
|
| 1950 | 1950 | 'class' => 'btn-primary', |
| 1951 | 1951 | ); |
| 1952 | 1952 | } |
| 1953 | 1953 | |
| 1954 | - if ( is_user_logged_in() ) { |
|
| 1954 | + if (is_user_logged_in()) { |
|
| 1955 | 1955 | $actions['history'] = array( |
| 1956 | 1956 | 'url' => wpinv_get_history_page_uri(), |
| 1957 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
| 1957 | + 'name' => __('Invoice History', 'invoicing'), |
|
| 1958 | 1958 | 'class' => 'btn-warning', |
| 1959 | 1959 | ); |
| 1960 | 1960 | } |
| 1961 | 1961 | |
| 1962 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
| 1962 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
| 1963 | 1963 | |
| 1964 | - if ( !empty( $actions ) ) { |
|
| 1964 | + if (!empty($actions)) { |
|
| 1965 | 1965 | ?> |
| 1966 | 1966 | <div class="wpinv-receipt-actions text-right"> |
| 1967 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
| 1968 | - <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a> |
|
| 1967 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
| 1968 | + <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a> |
|
| 1969 | 1969 | <?php } ?> |
| 1970 | 1970 | </div> |
| 1971 | 1971 | <?php |
| 1972 | 1972 | } |
| 1973 | 1973 | } |
| 1974 | 1974 | } |
| 1975 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
| 1975 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
| 1976 | 1976 | |
| 1977 | -function wpinv_invoice_link( $invoice_id ) { |
|
| 1978 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1977 | +function wpinv_invoice_link($invoice_id) { |
|
| 1978 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1979 | 1979 | |
| 1980 | - if ( empty( $invoice ) ) { |
|
| 1980 | + if (empty($invoice)) { |
|
| 1981 | 1981 | return NULL; |
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
| 1984 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
| 1985 | 1985 | |
| 1986 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
| 1986 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
| 1987 | 1987 | } |
| 1988 | 1988 | |
| 1989 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
| 1990 | - if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) { |
|
| 1991 | - $subscription = wpinv_get_subscription( $invoice, true ); |
|
| 1989 | +function wpinv_invoice_subscription_details($invoice) { |
|
| 1990 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
| 1991 | + $subscription = wpinv_get_subscription($invoice, true); |
|
| 1992 | 1992 | |
| 1993 | - if ( empty( $subscription ) ) { |
|
| 1993 | + if (empty($subscription)) { |
|
| 1994 | 1994 | return; |
| 1995 | 1995 | } |
| 1996 | 1996 | |
@@ -2001,15 +2001,15 @@ discard block |
||
| 2001 | 2001 | $payments = $subscription->get_child_payments(); |
| 2002 | 2002 | ?> |
| 2003 | 2003 | <div class="wpinv-subscriptions-details"> |
| 2004 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
| 2004 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
| 2005 | 2005 | <table class="table"> |
| 2006 | 2006 | <thead> |
| 2007 | 2007 | <tr> |
| 2008 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
| 2009 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
| 2010 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
| 2011 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
| 2012 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
| 2008 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
| 2009 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
| 2010 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
| 2011 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
| 2012 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
| 2013 | 2013 | </tr> |
| 2014 | 2014 | </thead> |
| 2015 | 2015 | <tbody> |
@@ -2023,29 +2023,29 @@ discard block |
||
| 2023 | 2023 | </tbody> |
| 2024 | 2024 | </table> |
| 2025 | 2025 | </div> |
| 2026 | - <?php if ( !empty( $payments ) ) { ?> |
|
| 2026 | + <?php if (!empty($payments)) { ?> |
|
| 2027 | 2027 | <div class="wpinv-renewal-payments"> |
| 2028 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
| 2028 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
| 2029 | 2029 | <table class="table"> |
| 2030 | 2030 | <thead> |
| 2031 | 2031 | <tr> |
| 2032 | 2032 | <th>#</th> |
| 2033 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
| 2034 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
| 2035 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
| 2033 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
| 2034 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
| 2035 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
| 2036 | 2036 | </tr> |
| 2037 | 2037 | </thead> |
| 2038 | 2038 | <tbody> |
| 2039 | 2039 | <?php |
| 2040 | 2040 | $i = 1; |
| 2041 | - foreach ( $payments as $payment ) { |
|
| 2041 | + foreach ($payments as $payment) { |
|
| 2042 | 2042 | $invoice_id = $payment->ID; |
| 2043 | 2043 | ?> |
| 2044 | 2044 | <tr> |
| 2045 | - <th scope="row"><?php echo $i;?></th> |
|
| 2046 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
| 2047 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
| 2048 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
| 2045 | + <th scope="row"><?php echo $i; ?></th> |
|
| 2046 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
| 2047 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
| 2048 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
| 2049 | 2049 | </tr> |
| 2050 | 2050 | <?php $i++; } ?> |
| 2051 | 2051 | </tbody> |
@@ -2056,52 +2056,52 @@ discard block |
||
| 2056 | 2056 | } |
| 2057 | 2057 | } |
| 2058 | 2058 | |
| 2059 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
| 2060 | - if ( empty( $invoice ) ) { |
|
| 2059 | +function wpinv_cart_total_label($label, $invoice) { |
|
| 2060 | + if (empty($invoice)) { |
|
| 2061 | 2061 | return $label; |
| 2062 | 2062 | } |
| 2063 | 2063 | |
| 2064 | 2064 | $prefix_label = ''; |
| 2065 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
| 2066 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
| 2067 | - } else if ( $invoice->is_renewal() ) { |
|
| 2068 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
| 2065 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
| 2066 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
| 2067 | + } else if ($invoice->is_renewal()) { |
|
| 2068 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
| 2069 | 2069 | } |
| 2070 | 2070 | |
| 2071 | - if ( $prefix_label != '' ) { |
|
| 2072 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 2071 | + if ($prefix_label != '') { |
|
| 2072 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 2073 | 2073 | } |
| 2074 | 2074 | |
| 2075 | 2075 | return $label; |
| 2076 | 2076 | } |
| 2077 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2078 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2079 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2077 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2078 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2079 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2080 | 2080 | |
| 2081 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
| 2081 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
| 2082 | 2082 | |
| 2083 | -function wpinv_invoice_print_description( $invoice ) { |
|
| 2084 | - if ( empty( $invoice ) ) { |
|
| 2083 | +function wpinv_invoice_print_description($invoice) { |
|
| 2084 | + if (empty($invoice)) { |
|
| 2085 | 2085 | return NULL; |
| 2086 | 2086 | } |
| 2087 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
| 2087 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
| 2088 | 2088 | ?> |
| 2089 | 2089 | <div class="row wpinv-lower"> |
| 2090 | 2090 | <div class="col-sm-12 wpinv-description"> |
| 2091 | - <?php echo wpautop( $description ); ?> |
|
| 2091 | + <?php echo wpautop($description); ?> |
|
| 2092 | 2092 | </div> |
| 2093 | 2093 | </div> |
| 2094 | 2094 | <?php |
| 2095 | 2095 | } |
| 2096 | 2096 | } |
| 2097 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
| 2097 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
| 2098 | 2098 | |
| 2099 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
| 2100 | - if ( empty( $invoice ) ) { |
|
| 2099 | +function wpinv_invoice_print_payment_info($invoice) { |
|
| 2100 | + if (empty($invoice)) { |
|
| 2101 | 2101 | return NULL; |
| 2102 | 2102 | } |
| 2103 | 2103 | |
| 2104 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
| 2104 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
| 2105 | 2105 | ?> |
| 2106 | 2106 | <div class="row wpinv-payments"> |
| 2107 | 2107 | <div class="col-sm-12"> |
@@ -2113,43 +2113,43 @@ discard block |
||
| 2113 | 2113 | } |
| 2114 | 2114 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
| 2115 | 2115 | |
| 2116 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
| 2117 | - if ( empty( $note ) ) { |
|
| 2116 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
| 2117 | + if (empty($note)) { |
|
| 2118 | 2118 | return NULL; |
| 2119 | 2119 | } |
| 2120 | 2120 | |
| 2121 | - if ( is_int( $note ) ) { |
|
| 2122 | - $note = get_comment( $note ); |
|
| 2121 | + if (is_int($note)) { |
|
| 2122 | + $note = get_comment($note); |
|
| 2123 | 2123 | } |
| 2124 | 2124 | |
| 2125 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
| 2125 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
| 2126 | 2126 | return NULL; |
| 2127 | 2127 | } |
| 2128 | 2128 | |
| 2129 | - $note_classes = array( 'note' ); |
|
| 2130 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
| 2129 | + $note_classes = array('note'); |
|
| 2130 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
| 2131 | 2131 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
| 2132 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
| 2133 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
| 2132 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
| 2133 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
| 2134 | 2134 | |
| 2135 | 2135 | ob_start(); |
| 2136 | 2136 | ?> |
| 2137 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
| 2137 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
| 2138 | 2138 | <div class="note_content"> |
| 2139 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
| 2139 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
| 2140 | 2140 | </div> |
| 2141 | 2141 | <p class="meta"> |
| 2142 | - <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr> |
|
| 2143 | - <?php if ( is_admin() && ( $note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing() ) ) { ?> |
|
| 2144 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
| 2142 | + <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr> |
|
| 2143 | + <?php if (is_admin() && ($note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing())) { ?> |
|
| 2144 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
| 2145 | 2145 | <?php } ?> |
| 2146 | 2146 | </p> |
| 2147 | 2147 | </li> |
| 2148 | 2148 | <?php |
| 2149 | 2149 | $note_content = ob_get_clean(); |
| 2150 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
| 2150 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
| 2151 | 2151 | |
| 2152 | - if ( $echo ) { |
|
| 2152 | + if ($echo) { |
|
| 2153 | 2153 | echo $note_content; |
| 2154 | 2154 | } else { |
| 2155 | 2155 | return $note_content; |
@@ -2159,43 +2159,43 @@ discard block |
||
| 2159 | 2159 | function wpinv_invalid_invoice_content() { |
| 2160 | 2160 | global $post; |
| 2161 | 2161 | |
| 2162 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
| 2162 | + $invoice = wpinv_get_invoice($post->ID); |
|
| 2163 | 2163 | |
| 2164 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
| 2165 | - if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
| 2166 | - if ( is_user_logged_in() ) { |
|
| 2167 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 2168 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2169 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
| 2164 | + $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing'); |
|
| 2165 | + if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
| 2166 | + if (is_user_logged_in()) { |
|
| 2167 | + if (wpinv_require_login_to_checkout()) { |
|
| 2168 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 2169 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
| 2170 | 2170 | } |
| 2171 | 2171 | } |
| 2172 | 2172 | } else { |
| 2173 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 2174 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2175 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
| 2173 | + if (wpinv_require_login_to_checkout()) { |
|
| 2174 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 2175 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
| 2176 | 2176 | } |
| 2177 | 2177 | } |
| 2178 | 2178 | } |
| 2179 | 2179 | } else { |
| 2180 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
| 2180 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
| 2181 | 2181 | } |
| 2182 | 2182 | ?> |
| 2183 | 2183 | <div class="row wpinv-row-invalid"> |
| 2184 | 2184 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
| 2185 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
| 2185 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
| 2186 | 2186 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
| 2187 | 2187 | </div> |
| 2188 | 2188 | </div> |
| 2189 | 2189 | <?php |
| 2190 | 2190 | } |
| 2191 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
| 2191 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
| 2192 | 2192 | |
| 2193 | -add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
| 2194 | -function wpinv_force_company_name_field(){ |
|
| 2193 | +add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
| 2194 | +function wpinv_force_company_name_field() { |
|
| 2195 | 2195 | $invoice = wpinv_get_invoice_cart(); |
| 2196 | - $user_id = wpinv_get_user_id( $invoice->ID ); |
|
| 2197 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
| 2198 | - if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) { |
|
| 2196 | + $user_id = wpinv_get_user_id($invoice->ID); |
|
| 2197 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
| 2198 | + if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) { |
|
| 2199 | 2199 | ?> |
| 2200 | 2200 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 2201 | 2201 | <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label> |
@@ -2220,21 +2220,21 @@ discard block |
||
| 2220 | 2220 | * @return string |
| 2221 | 2221 | */ |
| 2222 | 2222 | function wpinv_get_policy_text() { |
| 2223 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
| 2223 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
| 2224 | 2224 | |
| 2225 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
| 2225 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
| 2226 | 2226 | |
| 2227 | - if(!$privacy_page_id){ |
|
| 2228 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
| 2227 | + if (!$privacy_page_id) { |
|
| 2228 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
| 2229 | 2229 | } |
| 2230 | 2230 | |
| 2231 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
| 2231 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
| 2232 | 2232 | |
| 2233 | 2233 | $find_replace = array( |
| 2234 | 2234 | '[wpinv_privacy_policy]' => $privacy_link, |
| 2235 | 2235 | ); |
| 2236 | 2236 | |
| 2237 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
| 2237 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
| 2238 | 2238 | |
| 2239 | 2239 | return wp_kses_post(wpautop($privacy_text)); |
| 2240 | 2240 | } |
@@ -2243,25 +2243,25 @@ discard block |
||
| 2243 | 2243 | /** |
| 2244 | 2244 | * Allows the user to set their own price for an invoice item |
| 2245 | 2245 | */ |
| 2246 | -function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) { |
|
| 2246 | +function wpinv_checkout_cart_item_name_your_price($cart_item, $key) { |
|
| 2247 | 2247 | |
| 2248 | 2248 | //Ensure we have an item id |
| 2249 | - if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) { |
|
| 2249 | + if (!is_array($cart_item) || empty($cart_item['id'])) { |
|
| 2250 | 2250 | return; |
| 2251 | 2251 | } |
| 2252 | 2252 | |
| 2253 | 2253 | //Fetch the item |
| 2254 | 2254 | $item_id = $cart_item['id']; |
| 2255 | - $item = new WPInv_Item( $item_id ); |
|
| 2255 | + $item = new WPInv_Item($item_id); |
|
| 2256 | 2256 | |
| 2257 | - if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) { |
|
| 2257 | + if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) { |
|
| 2258 | 2258 | return; |
| 2259 | 2259 | } |
| 2260 | 2260 | |
| 2261 | 2261 | //Fetch the dynamic pricing "strings" |
| 2262 | - $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) ); |
|
| 2263 | - $minimum_price_text = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) ); |
|
| 2264 | - $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) ); |
|
| 2262 | + $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing'))); |
|
| 2263 | + $minimum_price_text = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing'))); |
|
| 2264 | + $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing'))); |
|
| 2265 | 2265 | |
| 2266 | 2266 | //Display a "name_your_price" button |
| 2267 | 2267 | echo " — <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>"; |
@@ -2270,7 +2270,7 @@ discard block |
||
| 2270 | 2270 | echo '<div class="name-your-price-miniform">'; |
| 2271 | 2271 | |
| 2272 | 2272 | //Maybe display the recommended price |
| 2273 | - if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) { |
|
| 2273 | + if ($item->get_price() > 0 && !empty($suggested_price_text)) { |
|
| 2274 | 2274 | $suggested_price = $item->get_the_price(); |
| 2275 | 2275 | echo "<div>$suggested_price_text — $suggested_price</div>"; |
| 2276 | 2276 | } |
@@ -2278,50 +2278,50 @@ discard block |
||
| 2278 | 2278 | //Display the update price form |
| 2279 | 2279 | $symbol = wpinv_currency_symbol(); |
| 2280 | 2280 | $position = wpinv_currency_position(); |
| 2281 | - $minimum = esc_attr( $item->get_minimum_price() ); |
|
| 2282 | - $price = esc_attr( $cart_item['item_price'] ); |
|
| 2283 | - $update = esc_attr__( "Update", 'invoicing' ); |
|
| 2281 | + $minimum = esc_attr($item->get_minimum_price()); |
|
| 2282 | + $price = esc_attr($cart_item['item_price']); |
|
| 2283 | + $update = esc_attr__("Update", 'invoicing'); |
|
| 2284 | 2284 | |
| 2285 | 2285 | //Ensure it supports dynamic prici |
| 2286 | - if( $price < $minimum ) { |
|
| 2286 | + if ($price < $minimum) { |
|
| 2287 | 2287 | $price = $minimum; |
| 2288 | 2288 | } |
| 2289 | 2289 | |
| 2290 | 2290 | echo '<label>'; |
| 2291 | 2291 | echo $position != 'right' ? $symbol . ' ' : ''; |
| 2292 | 2292 | echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />"; |
| 2293 | - echo $position == 'right' ? ' ' . $symbol : '' ; |
|
| 2293 | + echo $position == 'right' ? ' ' . $symbol : ''; |
|
| 2294 | 2294 | echo "</label>"; |
| 2295 | 2295 | echo "<input type='hidden' value='$item_id' class='wpi-field-item' />"; |
| 2296 | 2296 | echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>"; |
| 2297 | 2297 | |
| 2298 | 2298 | //Maybe display the minimum price |
| 2299 | - if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) { |
|
| 2300 | - $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) ); |
|
| 2299 | + if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) { |
|
| 2300 | + $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price())); |
|
| 2301 | 2301 | echo "<div>$minimum_price_text — $minimum_price</div>"; |
| 2302 | 2302 | } |
| 2303 | 2303 | |
| 2304 | 2304 | echo "</div>"; |
| 2305 | 2305 | |
| 2306 | 2306 | } |
| 2307 | -add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 ); |
|
| 2307 | +add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2); |
|
| 2308 | 2308 | |
| 2309 | 2309 | function wpinv_oxygen_fix_conflict() { |
| 2310 | 2310 | global $ct_ignore_post_types; |
| 2311 | 2311 | |
| 2312 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
| 2312 | + if (!is_array($ct_ignore_post_types)) { |
|
| 2313 | 2313 | $ct_ignore_post_types = array(); |
| 2314 | 2314 | } |
| 2315 | 2315 | |
| 2316 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' ); |
|
| 2316 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item'); |
|
| 2317 | 2317 | |
| 2318 | - foreach ( $post_types as $post_type ) { |
|
| 2318 | + foreach ($post_types as $post_type) { |
|
| 2319 | 2319 | $ct_ignore_post_types[] = $post_type; |
| 2320 | 2320 | |
| 2321 | 2321 | // Ignore post type |
| 2322 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
| 2322 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
| 2323 | 2323 | } |
| 2324 | 2324 | |
| 2325 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 2326 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
| 2325 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
| 2326 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
| 2327 | 2327 | } |
| 2328 | 2328 | \ No newline at end of file |
@@ -6,33 +6,33 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5 |
| 8 | 8 | { |
| 9 | - public static $files = array ( |
|
| 9 | + public static $files = array( |
|
| 10 | 10 | 'e8d544c98e79f913e13eae1306ab635e' => __DIR__ . '/..' . '/ayecode/wp-ayecode-ui/ayecode-ui-loader.php', |
| 11 | 11 | '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php', |
| 12 | 12 | ); |
| 13 | 13 | |
| 14 | - public static $prefixLengthsPsr4 = array ( |
|
| 14 | + public static $prefixLengthsPsr4 = array( |
|
| 15 | 15 | 'C' => |
| 16 | - array ( |
|
| 16 | + array( |
|
| 17 | 17 | 'Composer\\Installers\\' => 20, |
| 18 | 18 | ), |
| 19 | 19 | ); |
| 20 | 20 | |
| 21 | - public static $prefixDirsPsr4 = array ( |
|
| 21 | + public static $prefixDirsPsr4 = array( |
|
| 22 | 22 | 'Composer\\Installers\\' => |
| 23 | - array ( |
|
| 23 | + array( |
|
| 24 | 24 | 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', |
| 25 | 25 | ), |
| 26 | 26 | ); |
| 27 | 27 | |
| 28 | - public static $classMap = array ( |
|
| 28 | + public static $classMap = array( |
|
| 29 | 29 | 'AyeCode_Connect_Helper' => __DIR__ . '/..' . '/ayecode/ayecode-connect-helper/ayecode-connect-helper.php', |
| 30 | 30 | 'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php', |
| 31 | 31 | ); |
| 32 | 32 | |
| 33 | 33 | public static function getInitializer(ClassLoader $loader) |
| 34 | 34 | { |
| 35 | - return \Closure::bind(function () use ($loader) { |
|
| 35 | + return \Closure::bind(function() use ($loader) { |
|
| 36 | 36 | $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4; |
| 37 | 37 | $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4; |
| 38 | 38 | $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap; |
@@ -8,13 +8,13 @@ discard block |
||
| 8 | 8 | * @version 1.0.19 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | return array( |
| 14 | 14 | |
| 15 | 15 | array( |
| 16 | 16 | |
| 17 | - 'title' => __( 'My Cool Item', 'invoicing' ), |
|
| 17 | + 'title' => __('My Cool Item', 'invoicing'), |
|
| 18 | 18 | 'id' => 'fxhnagzi', |
| 19 | 19 | 'price' => '999.00', |
| 20 | 20 | 'recurring' => false, |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | array( |
| 26 | 26 | |
| 27 | - 'title' => __( 'Shipping Fee', 'invoicing' ), |
|
| 27 | + 'title' => __('Shipping Fee', 'invoicing'), |
|
| 28 | 28 | 'id' => 'rxnymibri', |
| 29 | 29 | 'price' => '19.99', |
| 30 | 30 | 'recurring' => false, |
@@ -8,14 +8,14 @@ discard block |
||
| 8 | 8 | * @version 1.0.19 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | return array( |
| 14 | 14 | |
| 15 | 15 | array( |
| 16 | 16 | |
| 17 | 17 | 'level' => 'h2', |
| 18 | - 'text' => __( 'Payment Form', 'invoicing' ), |
|
| 18 | + 'text' => __('Payment Form', 'invoicing'), |
|
| 19 | 19 | 'id' => 'uiylyczw', |
| 20 | 20 | 'name' => 'uiylyczw', |
| 21 | 21 | 'type' => 'heading' |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | array( |
| 25 | 25 | |
| 26 | - 'text' => __( 'Fill the form below to place an order for my cool item', 'invoicing' ), |
|
| 26 | + 'text' => __('Fill the form below to place an order for my cool item', 'invoicing'), |
|
| 27 | 27 | 'id' => 'pcvqjj', |
| 28 | 28 | 'name' => 'pcvqjj', |
| 29 | 29 | 'type' => 'paragraph' |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | 'placeholder' => 'Jon', |
| 36 | 36 | 'value' => '', |
| 37 | - 'label' => __( 'First Name', 'invoicing' ), |
|
| 37 | + 'label' => __('First Name', 'invoicing'), |
|
| 38 | 38 | 'description' => '', |
| 39 | 39 | 'required' => false, |
| 40 | 40 | 'id' => 'ynkzkjyc', |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | 'placeholder' => 'Snow', |
| 49 | 49 | 'value' => '', |
| 50 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
| 50 | + 'label' => __('Last Name', 'invoicing'), |
|
| 51 | 51 | 'description' => '', |
| 52 | 52 | 'required' => false, |
| 53 | 53 | 'id' => 'wfjcdmzox', |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | 'placeholder' => '[email protected]', |
| 62 | 62 | 'value' => '', |
| 63 | - 'label' => __( 'Billing Email', 'invoicing' ), |
|
| 63 | + 'label' => __('Billing Email', 'invoicing'), |
|
| 64 | 64 | 'description' => '', |
| 65 | 65 | 'required' => true, |
| 66 | 66 | 'id' => 'mmdwqzpox', |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | 'value' =>'', |
| 87 | 87 | 'class' => 'btn-primary', |
| 88 | - 'label' => __( 'Pay Now »', 'invoicing' ), |
|
| 89 | - 'description' => __( 'By continuing with your payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ), |
|
| 88 | + 'label' => __('Pay Now »', 'invoicing'), |
|
| 89 | + 'description' => __('By continuing with your payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'), |
|
| 90 | 90 | 'id' => 'rtqljyy', |
| 91 | 91 | 'name' => 'rtqljyy', |
| 92 | 92 | 'type' => 'pay_button', |
@@ -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 | -add_filter( 'manage_wpi_payment_form_posts_columns', 'wpinv_payment_form_columns' ); |
|
| 8 | -function wpinv_payment_form_columns( $existing_columns ) { |
|
| 7 | +add_filter('manage_wpi_payment_form_posts_columns', 'wpinv_payment_form_columns'); |
|
| 8 | +function wpinv_payment_form_columns($existing_columns) { |
|
| 9 | 9 | $date = $existing_columns['date']; |
| 10 | - unset( $existing_columns['date'] ); |
|
| 11 | - $existing_columns['shortcode'] = __( 'Shortcode', 'invoicing' ); |
|
| 10 | + unset($existing_columns['date']); |
|
| 11 | + $existing_columns['shortcode'] = __('Shortcode', 'invoicing'); |
|
| 12 | 12 | $existing_columns['date'] = $date; |
| 13 | 13 | return $existing_columns; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -add_action( 'manage_wpi_payment_form_posts_custom_column', 'wpinv_payment_form_custom_column' ); |
|
| 17 | -function wpinv_payment_form_custom_column( $column ) { |
|
| 16 | +add_action('manage_wpi_payment_form_posts_custom_column', 'wpinv_payment_form_custom_column'); |
|
| 17 | +function wpinv_payment_form_custom_column($column) { |
|
| 18 | 18 | global $post; |
| 19 | 19 | |
| 20 | - if( 'shortcode' == $column ) { |
|
| 21 | - WPInv_Meta_Box_Payment_Form::output_shortcode( $post ); |
|
| 20 | + if ('shortcode' == $column) { |
|
| 21 | + WPInv_Meta_Box_Payment_Form::output_shortcode($post); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | -add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' ); |
|
| 27 | -function wpinv_discount_columns( $existing_columns ) { |
|
| 26 | +add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns'); |
|
| 27 | +function wpinv_discount_columns($existing_columns) { |
|
| 28 | 28 | $columns = array(); |
| 29 | 29 | $columns['cb'] = $existing_columns['cb']; |
| 30 | - $columns['name'] = __( 'Name', 'invoicing' ); |
|
| 31 | - $columns['code'] = __( 'Code', 'invoicing' ); |
|
| 32 | - $columns['amount'] = __( 'Amount', 'invoicing' ); |
|
| 33 | - $columns['usage'] = __( 'Usage / Limit', 'invoicing' ); |
|
| 34 | - $columns['start_date'] = __( 'Start Date', 'invoicing' ); |
|
| 35 | - $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' ); |
|
| 36 | - $columns['status'] = __( 'Status', 'invoicing' ); |
|
| 30 | + $columns['name'] = __('Name', 'invoicing'); |
|
| 31 | + $columns['code'] = __('Code', 'invoicing'); |
|
| 32 | + $columns['amount'] = __('Amount', 'invoicing'); |
|
| 33 | + $columns['usage'] = __('Usage / Limit', 'invoicing'); |
|
| 34 | + $columns['start_date'] = __('Start Date', 'invoicing'); |
|
| 35 | + $columns['expiry_date'] = __('Expiry Date', 'invoicing'); |
|
| 36 | + $columns['status'] = __('Status', 'invoicing'); |
|
| 37 | 37 | |
| 38 | 38 | return $columns; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
| 42 | -function wpinv_discount_custom_column( $column ) { |
|
| 41 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
| 42 | +function wpinv_discount_custom_column($column) { |
|
| 43 | 43 | global $post; |
| 44 | 44 | |
| 45 | 45 | $discount = $post; |
| 46 | 46 | |
| 47 | - switch ( $column ) { |
|
| 47 | + switch ($column) { |
|
| 48 | 48 | case 'name' : |
| 49 | - echo get_the_title( $discount->ID ); |
|
| 49 | + echo get_the_title($discount->ID); |
|
| 50 | 50 | break; |
| 51 | 51 | case 'code' : |
| 52 | - echo wpinv_get_discount_code( $discount->ID ); |
|
| 52 | + echo wpinv_get_discount_code($discount->ID); |
|
| 53 | 53 | break; |
| 54 | 54 | case 'amount' : |
| 55 | - echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
| 55 | + echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
| 56 | 56 | break; |
| 57 | 57 | case 'usage_limit' : |
| 58 | - echo wpinv_get_discount_uses( $discount->ID ); |
|
| 58 | + echo wpinv_get_discount_uses($discount->ID); |
|
| 59 | 59 | break; |
| 60 | 60 | case 'usage' : |
| 61 | - $usage = wpinv_get_discount_uses( $discount->ID ) . ' / '; |
|
| 62 | - if ( wpinv_get_discount_max_uses( $discount->ID ) ) { |
|
| 63 | - $usage .= wpinv_get_discount_max_uses( $discount->ID ); |
|
| 61 | + $usage = wpinv_get_discount_uses($discount->ID) . ' / '; |
|
| 62 | + if (wpinv_get_discount_max_uses($discount->ID)) { |
|
| 63 | + $usage .= wpinv_get_discount_max_uses($discount->ID); |
|
| 64 | 64 | } else { |
| 65 | 65 | $usage .= ' ∞'; |
| 66 | 66 | } |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | echo $usage; |
| 69 | 69 | break; |
| 70 | 70 | case 'start_date' : |
| 71 | - if ( $start_date = wpinv_get_discount_start_date( $discount->ID ) ) { |
|
| 72 | - $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $start_date ) ); |
|
| 71 | + if ($start_date = wpinv_get_discount_start_date($discount->ID)) { |
|
| 72 | + $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($start_date)); |
|
| 73 | 73 | } else { |
| 74 | 74 | $value = '-'; |
| 75 | 75 | } |
@@ -77,163 +77,163 @@ discard block |
||
| 77 | 77 | echo $value; |
| 78 | 78 | break; |
| 79 | 79 | case 'expiry_date' : |
| 80 | - if ( $expiration = wpinv_get_discount_expiration( $discount->ID ) ) { |
|
| 81 | - $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $expiration ) ); |
|
| 80 | + if ($expiration = wpinv_get_discount_expiration($discount->ID)) { |
|
| 81 | + $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($expiration)); |
|
| 82 | 82 | } else { |
| 83 | - $value = __( 'Never', 'invoicing' ); |
|
| 83 | + $value = __('Never', 'invoicing'); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | echo $value; |
| 87 | 87 | break; |
| 88 | 88 | break; |
| 89 | 89 | case 'description' : |
| 90 | - echo wp_kses_post( $post->post_excerpt ); |
|
| 90 | + echo wp_kses_post($post->post_excerpt); |
|
| 91 | 91 | break; |
| 92 | 92 | case 'status' : |
| 93 | - $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status; |
|
| 93 | + $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status; |
|
| 94 | 94 | |
| 95 | - echo wpinv_discount_status( $status ); |
|
| 95 | + echo wpinv_discount_status($status); |
|
| 96 | 96 | break; |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 ); |
|
| 101 | -function wpinv_post_row_actions( $actions, $post ) { |
|
| 102 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
| 100 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2); |
|
| 101 | +function wpinv_post_row_actions($actions, $post) { |
|
| 102 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
| 103 | 103 | |
| 104 | - if ( $post_type == 'wpi_invoice' ) { |
|
| 104 | + if ($post_type == 'wpi_invoice') { |
|
| 105 | 105 | $actions = array(); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if ( $post_type == 'wpi_discount' ) { |
|
| 109 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
| 108 | + if ($post_type == 'wpi_discount') { |
|
| 109 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | return $actions; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
| 116 | - $row_actions = array(); |
|
| 117 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
| 118 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
| 115 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
| 116 | + $row_actions = array(); |
|
| 117 | + $edit_link = get_edit_post_link($discount->ID); |
|
| 118 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
| 119 | 119 | |
| 120 | - if( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
| 121 | - $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>'; |
|
| 122 | - } elseif( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
| 123 | - $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>'; |
|
| 120 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
| 121 | + $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>'; |
|
| 122 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
| 123 | + $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>'; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) { |
|
| 127 | - if ( isset( $row_actions['delete'] ) ) { |
|
| 128 | - unset( $row_actions['delete'] ); // Don't delete used discounts. |
|
| 126 | + if (wpinv_get_discount_uses($discount->ID) > 0) { |
|
| 127 | + if (isset($row_actions['delete'])) { |
|
| 128 | + unset($row_actions['delete']); // Don't delete used discounts. |
|
| 129 | 129 | } |
| 130 | 130 | } else { |
| 131 | - $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>'; |
|
| 131 | + $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>'; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | |
| 135 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
| 135 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
| 136 | 136 | |
| 137 | 137 | return $row_actions; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | -add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 ); |
|
| 141 | -function wpinv_table_primary_column( $default, $screen_id ) { |
|
| 142 | - if ( 'edit-wpi_invoice' === $screen_id ) { |
|
| 140 | +add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2); |
|
| 141 | +function wpinv_table_primary_column($default, $screen_id) { |
|
| 142 | + if ('edit-wpi_invoice' === $screen_id) { |
|
| 143 | 143 | return 'name'; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | return $default; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | -function wpinv_discount_bulk_actions( $actions, $display = false ) { |
|
| 150 | - if ( !$display ) { |
|
| 149 | +function wpinv_discount_bulk_actions($actions, $display = false) { |
|
| 150 | + if (!$display) { |
|
| 151 | 151 | return array(); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | $actions = array( |
| 155 | - 'activate' => __( 'Activate', 'invoicing' ), |
|
| 156 | - 'deactivate' => __( 'Deactivate', 'invoicing' ), |
|
| 157 | - 'delete' => __( 'Delete', 'invoicing' ), |
|
| 155 | + 'activate' => __('Activate', 'invoicing'), |
|
| 156 | + 'deactivate' => __('Deactivate', 'invoicing'), |
|
| 157 | + 'delete' => __('Delete', 'invoicing'), |
|
| 158 | 158 | ); |
| 159 | 159 | $two = ''; |
| 160 | 160 | $which = 'top'; |
| 161 | 161 | echo '</div><div class="alignleft actions bulkactions">'; |
| 162 | - echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; |
|
| 163 | - echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">"; |
|
| 164 | - echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>"; |
|
| 162 | + echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>'; |
|
| 163 | + echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">"; |
|
| 164 | + echo '<option value="-1">' . __('Bulk Actions') . "</option>"; |
|
| 165 | 165 | |
| 166 | - foreach ( $actions as $name => $title ) { |
|
| 166 | + foreach ($actions as $name => $title) { |
|
| 167 | 167 | $class = 'edit' === $name ? ' class="hide-if-no-js"' : ''; |
| 168 | 168 | |
| 169 | 169 | echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>"; |
| 170 | 170 | } |
| 171 | 171 | echo "</select>"; |
| 172 | 172 | |
| 173 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
| 173 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
| 174 | 174 | |
| 175 | 175 | echo '</div><div class="alignleft actions">'; |
| 176 | 176 | } |
| 177 | -add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 ); |
|
| 177 | +add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10); |
|
| 178 | 178 | |
| 179 | -function wpinv_disable_months_dropdown( $disable, $post_type ) { |
|
| 180 | - if ( $post_type == 'wpi_discount' ) { |
|
| 179 | +function wpinv_disable_months_dropdown($disable, $post_type) { |
|
| 180 | + if ($post_type == 'wpi_discount') { |
|
| 181 | 181 | $disable = true; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | return $disable; |
| 185 | 185 | } |
| 186 | -add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 ); |
|
| 186 | +add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2); |
|
| 187 | 187 | |
| 188 | 188 | function wpinv_restrict_manage_posts() { |
| 189 | 189 | global $typenow; |
| 190 | 190 | |
| 191 | - if( 'wpi_discount' == $typenow ) { |
|
| 191 | + if ('wpi_discount' == $typenow) { |
|
| 192 | 192 | wpinv_discount_filters(); |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
| 195 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
| 196 | 196 | |
| 197 | 197 | function wpinv_discount_filters() { |
| 198 | - echo wpinv_discount_bulk_actions( array(), true ); |
|
| 198 | + echo wpinv_discount_bulk_actions(array(), true); |
|
| 199 | 199 | |
| 200 | 200 | ?> |
| 201 | 201 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
| 202 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
| 202 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
| 203 | 203 | <?php |
| 204 | 204 | $types = wpinv_get_discount_types(); |
| 205 | 205 | |
| 206 | - foreach ( $types as $name => $type ) { |
|
| 207 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
| 206 | + foreach ($types as $name => $type) { |
|
| 207 | + echo '<option value="' . esc_attr($name) . '"'; |
|
| 208 | 208 | |
| 209 | - if ( isset( $_GET['discount_type'] ) ) |
|
| 210 | - selected( $name, $_GET['discount_type'] ); |
|
| 209 | + if (isset($_GET['discount_type'])) |
|
| 210 | + selected($name, $_GET['discount_type']); |
|
| 211 | 211 | |
| 212 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
| 212 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
| 213 | 213 | } |
| 214 | 214 | ?> |
| 215 | 215 | </select> |
| 216 | 216 | <?php |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | -function wpinv_request( $vars ) { |
|
| 219 | +function wpinv_request($vars) { |
|
| 220 | 220 | global $typenow, $wp_query, $wp_post_statuses; |
| 221 | 221 | |
| 222 | - if ( 'wpi_invoice' === $typenow ) { |
|
| 223 | - if ( !isset( $vars['post_status'] ) ) { |
|
| 222 | + if ('wpi_invoice' === $typenow) { |
|
| 223 | + if (!isset($vars['post_status'])) { |
|
| 224 | 224 | $post_statuses = wpinv_get_invoice_statuses(); |
| 225 | 225 | |
| 226 | - foreach ( $post_statuses as $status => $value ) { |
|
| 227 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
| 228 | - unset( $post_statuses[ $status ] ); |
|
| 226 | + foreach ($post_statuses as $status => $value) { |
|
| 227 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
| 228 | + unset($post_statuses[$status]); |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
| 232 | + $vars['post_status'] = array_keys($post_statuses); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - if ( isset( $vars['orderby'] ) ) { |
|
| 236 | - if ( 'amount' == $vars['orderby'] ) { |
|
| 235 | + if (isset($vars['orderby'])) { |
|
| 236 | + if ('amount' == $vars['orderby']) { |
|
| 237 | 237 | $vars = array_merge( |
| 238 | 238 | $vars, |
| 239 | 239 | array( |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | 'orderby' => 'meta_value_num' |
| 242 | 242 | ) |
| 243 | 243 | ); |
| 244 | - } else if ( 'customer' == $vars['orderby'] ) { |
|
| 244 | + } else if ('customer' == $vars['orderby']) { |
|
| 245 | 245 | $vars = array_merge( |
| 246 | 246 | $vars, |
| 247 | 247 | array( |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | 'orderby' => 'meta_value' |
| 250 | 250 | ) |
| 251 | 251 | ); |
| 252 | - } else if ( 'number' == $vars['orderby'] ) { |
|
| 252 | + } else if ('number' == $vars['orderby']) { |
|
| 253 | 253 | $vars = array_merge( |
| 254 | 254 | $vars, |
| 255 | 255 | array( |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | 'orderby' => 'meta_value' |
| 258 | 258 | ) |
| 259 | 259 | ); |
| 260 | - } else if ( 'payment_date' == $vars['orderby'] ) { |
|
| 260 | + } else if ('payment_date' == $vars['orderby']) { |
|
| 261 | 261 | $vars = array_merge( |
| 262 | 262 | $vars, |
| 263 | 263 | array( |
@@ -267,9 +267,9 @@ discard block |
||
| 267 | 267 | ); |
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | - } else if ( 'wpi_item' == $typenow ) { |
|
| 270 | + } else if ('wpi_item' == $typenow) { |
|
| 271 | 271 | // Check if 'orderby' is set to "price" |
| 272 | - if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) { |
|
| 272 | + if (isset($vars['orderby']) && 'price' == $vars['orderby']) { |
|
| 273 | 273 | $vars = array_merge( |
| 274 | 274 | $vars, |
| 275 | 275 | array( |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | // Check if "orderby" is set to "vat_rule" |
| 283 | - if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) { |
|
| 283 | + if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) { |
|
| 284 | 284 | $vars = array_merge( |
| 285 | 285 | $vars, |
| 286 | 286 | array( |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // Check if "orderby" is set to "vat_class" |
| 294 | - if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) { |
|
| 294 | + if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) { |
|
| 295 | 295 | $vars = array_merge( |
| 296 | 296 | $vars, |
| 297 | 297 | array( |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | // Check if "orderby" is set to "type" |
| 305 | - if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) { |
|
| 305 | + if (isset($vars['orderby']) && 'type' == $vars['orderby']) { |
|
| 306 | 306 | $vars = array_merge( |
| 307 | 307 | $vars, |
| 308 | 308 | array( |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | // Check if "orderby" is set to "recurring" |
| 316 | - if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) { |
|
| 316 | + if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) { |
|
| 317 | 317 | $vars = array_merge( |
| 318 | 318 | $vars, |
| 319 | 319 | array( |
@@ -323,104 +323,104 @@ discard block |
||
| 323 | 323 | ); |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
| 326 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
| 327 | 327 | // Filter vat rule type |
| 328 | - if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) { |
|
| 328 | + if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') { |
|
| 329 | 329 | $meta_query[] = array( |
| 330 | 330 | 'key' => '_wpinv_vat_rule', |
| 331 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
| 331 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
| 332 | 332 | 'compare' => '=' |
| 333 | 333 | ); |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | // Filter vat class |
| 337 | - if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) { |
|
| 337 | + if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') { |
|
| 338 | 338 | $meta_query[] = array( |
| 339 | 339 | 'key' => '_wpinv_vat_class', |
| 340 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
| 340 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
| 341 | 341 | 'compare' => '=' |
| 342 | 342 | ); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | // Filter item type |
| 346 | - if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) { |
|
| 346 | + if (isset($_GET['type']) && $_GET['type'] !== '') { |
|
| 347 | 347 | $meta_query[] = array( |
| 348 | 348 | 'key' => '_wpinv_type', |
| 349 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
| 349 | + 'value' => sanitize_text_field($_GET['type']), |
|
| 350 | 350 | 'compare' => '=' |
| 351 | 351 | ); |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - if ( !empty( $meta_query ) ) { |
|
| 354 | + if (!empty($meta_query)) { |
|
| 355 | 355 | $vars['meta_query'] = $meta_query; |
| 356 | 356 | } |
| 357 | - } else if ( 'wpi_discount' == $typenow ) { |
|
| 358 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
| 357 | + } else if ('wpi_discount' == $typenow) { |
|
| 358 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
| 359 | 359 | // Filter vat rule type |
| 360 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
| 360 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
| 361 | 361 | $meta_query[] = array( |
| 362 | 362 | 'key' => '_wpi_discount_type', |
| 363 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
| 363 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
| 364 | 364 | 'compare' => '=' |
| 365 | 365 | ); |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - if ( !empty( $meta_query ) ) { |
|
| 368 | + if (!empty($meta_query)) { |
|
| 369 | 369 | $vars['meta_query'] = $meta_query; |
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | return $vars; |
| 374 | 374 | } |
| 375 | -add_filter( 'request', 'wpinv_request' ); |
|
| 375 | +add_filter('request', 'wpinv_request'); |
|
| 376 | 376 | |
| 377 | -function wpinv_item_type_class( $classes, $class, $post_id ) { |
|
| 377 | +function wpinv_item_type_class($classes, $class, $post_id) { |
|
| 378 | 378 | global $pagenow, $typenow; |
| 379 | 379 | |
| 380 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) { |
|
| 381 | - if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) { |
|
| 382 | - $classes[] = 'wpi-type-' . sanitize_html_class( $type ); |
|
| 380 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) { |
|
| 381 | + if ($type = get_post_meta($post_id, '_wpinv_type', true)) { |
|
| 382 | + $classes[] = 'wpi-type-' . sanitize_html_class($type); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - if ( !wpinv_item_is_editable( $post_id ) ) { |
|
| 385 | + if (!wpinv_item_is_editable($post_id)) { |
|
| 386 | 386 | $classes[] = 'wpi-editable-n'; |
| 387 | 387 | } |
| 388 | 388 | } |
| 389 | 389 | return $classes; |
| 390 | 390 | } |
| 391 | -add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 ); |
|
| 391 | +add_filter('post_class', 'wpinv_item_type_class', 10, 3); |
|
| 392 | 392 | |
| 393 | 393 | function wpinv_check_quick_edit() { |
| 394 | 394 | global $pagenow, $current_screen, $wpinv_item_screen; |
| 395 | 395 | |
| 396 | - if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) { |
|
| 397 | - if ( empty( $wpinv_item_screen ) ) { |
|
| 398 | - if ( $current_screen->post_type == 'wpi_item' ) { |
|
| 396 | + if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) { |
|
| 397 | + if (empty($wpinv_item_screen)) { |
|
| 398 | + if ($current_screen->post_type == 'wpi_item') { |
|
| 399 | 399 | $wpinv_item_screen = 'y'; |
| 400 | 400 | } else { |
| 401 | 401 | $wpinv_item_screen = 'n'; |
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) { |
|
| 406 | - add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
| 407 | - add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
| 405 | + if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') { |
|
| 406 | + add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
| 407 | + add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | -add_action( 'admin_head', 'wpinv_check_quick_edit', 10 ); |
|
| 411 | +add_action('admin_head', 'wpinv_check_quick_edit', 10); |
|
| 412 | 412 | |
| 413 | -function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) { |
|
| 414 | - if ( isset( $actions['inline hide-if-no-js'] ) ) { |
|
| 415 | - unset( $actions['inline hide-if-no-js'] ); |
|
| 413 | +function wpinv_item_disable_quick_edit($actions = array(), $row = null) { |
|
| 414 | + if (isset($actions['inline hide-if-no-js'])) { |
|
| 415 | + unset($actions['inline hide-if-no-js']); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) { |
|
| 419 | - if ( isset( $actions['trash'] ) ) { |
|
| 420 | - unset( $actions['trash'] ); |
|
| 418 | + if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) { |
|
| 419 | + if (isset($actions['trash'])) { |
|
| 420 | + unset($actions['trash']); |
|
| 421 | 421 | } |
| 422 | - if ( isset( $actions['delete'] ) ) { |
|
| 423 | - unset( $actions['delete'] ); |
|
| 422 | + if (isset($actions['delete'])) { |
|
| 423 | + unset($actions['delete']); |
|
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
@@ -437,19 +437,19 @@ discard block |
||
| 437 | 437 | * @param int $post_parent (default: 0) Parent for the new page |
| 438 | 438 | * @return int page ID |
| 439 | 439 | */ |
| 440 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
| 440 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
| 441 | 441 | global $wpdb; |
| 442 | 442 | |
| 443 | - $option_value = wpinv_get_option( $option ); |
|
| 443 | + $option_value = wpinv_get_option($option); |
|
| 444 | 444 | |
| 445 | - if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) { |
|
| 446 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
| 445 | + if ($option_value > 0 && ($page_object = get_post($option_value))) { |
|
| 446 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
| 447 | 447 | // Valid page is already in place |
| 448 | 448 | return $page_object->ID; |
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - if(!empty($post_parent)){ |
|
| 452 | + if (!empty($post_parent)) { |
|
| 453 | 453 | $page = get_page_by_path($post_parent); |
| 454 | 454 | if ($page) { |
| 455 | 455 | $post_parent = $page->ID; |
@@ -458,40 +458,40 @@ discard block |
||
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - if ( strlen( $page_content ) > 0 ) { |
|
| 461 | + if (strlen($page_content) > 0) { |
|
| 462 | 462 | // Search for an existing page with the specified page content (typically a shortcode) |
| 463 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
| 463 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
| 464 | 464 | } else { |
| 465 | 465 | // Search for an existing page with the specified page slug |
| 466 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); |
|
| 466 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug)); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
| 469 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
| 470 | 470 | |
| 471 | - if ( $valid_page_found ) { |
|
| 472 | - if ( $option ) { |
|
| 473 | - wpinv_update_option( $option, $valid_page_found ); |
|
| 471 | + if ($valid_page_found) { |
|
| 472 | + if ($option) { |
|
| 473 | + wpinv_update_option($option, $valid_page_found); |
|
| 474 | 474 | } |
| 475 | 475 | return $valid_page_found; |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | // Search for a matching valid trashed page |
| 479 | - if ( strlen( $page_content ) > 0 ) { |
|
| 479 | + if (strlen($page_content) > 0) { |
|
| 480 | 480 | // Search for an existing page with the specified page content (typically a shortcode) |
| 481 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
| 481 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
| 482 | 482 | } else { |
| 483 | 483 | // Search for an existing page with the specified page slug |
| 484 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); |
|
| 484 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug)); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | - if ( $trashed_page_found ) { |
|
| 487 | + if ($trashed_page_found) { |
|
| 488 | 488 | $page_id = $trashed_page_found; |
| 489 | 489 | $page_data = array( |
| 490 | 490 | 'ID' => $page_id, |
| 491 | 491 | 'post_status' => 'publish', |
| 492 | 492 | 'post_parent' => $post_parent, |
| 493 | 493 | ); |
| 494 | - wp_update_post( $page_data ); |
|
| 494 | + wp_update_post($page_data); |
|
| 495 | 495 | } else { |
| 496 | 496 | $page_data = array( |
| 497 | 497 | 'post_status' => 'publish', |
@@ -503,11 +503,11 @@ discard block |
||
| 503 | 503 | 'post_parent' => $post_parent, |
| 504 | 504 | 'comment_status' => 'closed', |
| 505 | 505 | ); |
| 506 | - $page_id = wp_insert_post( $page_data ); |
|
| 506 | + $page_id = wp_insert_post($page_data); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - if ( $option ) { |
|
| 510 | - wpinv_update_option( $option, (int)$page_id ); |
|
| 509 | + if ($option) { |
|
| 510 | + wpinv_update_option($option, (int) $page_id); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | return $page_id; |
@@ -16,23 +16,23 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | public function __construct() { |
| 18 | 18 | |
| 19 | - $forms = get_posts( |
|
| 20 | - array( |
|
| 21 | - 'post_type' => 'wpi_payment_form', |
|
| 22 | - 'orderby' => 'title', |
|
| 23 | - 'order' => 'ASC', |
|
| 24 | - 'posts_per_page' => -1, |
|
| 25 | - 'post_status' => array( 'publish' ), |
|
| 26 | - ) |
|
| 27 | - ); |
|
| 28 | - |
|
| 29 | - $options = array( |
|
| 30 | - '' => __('Select a Form','invoicing') |
|
| 31 | - ); |
|
| 32 | - |
|
| 33 | - foreach( $forms as $form ) { |
|
| 34 | - $options[ $form->ID ] = $form->post_title; |
|
| 35 | - } |
|
| 19 | + $forms = get_posts( |
|
| 20 | + array( |
|
| 21 | + 'post_type' => 'wpi_payment_form', |
|
| 22 | + 'orderby' => 'title', |
|
| 23 | + 'order' => 'ASC', |
|
| 24 | + 'posts_per_page' => -1, |
|
| 25 | + 'post_status' => array( 'publish' ), |
|
| 26 | + ) |
|
| 27 | + ); |
|
| 28 | + |
|
| 29 | + $options = array( |
|
| 30 | + '' => __('Select a Form','invoicing') |
|
| 31 | + ); |
|
| 32 | + |
|
| 33 | + foreach( $forms as $form ) { |
|
| 34 | + $options[ $form->ID ] = $form->post_title; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | $options = array( |
| 38 | 38 | 'textdomain' => 'invoicing', |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | 'form' => array( |
| 51 | 51 | 'title' => __( 'Payment Form', 'invoicing' ), |
| 52 | 52 | 'desc' => __( 'Select your payment form.', 'invoicing' ), |
| 53 | - 'type' => 'select', |
|
| 54 | - 'options' => $options, |
|
| 53 | + 'type' => 'select', |
|
| 54 | + 'options' => $options, |
|
| 55 | 55 | 'desc_tip' => true, |
| 56 | 56 | 'default' => '', |
| 57 | 57 | 'advanced' => false |
@@ -64,59 +64,59 @@ discard block |
||
| 64 | 64 | parent::__construct( $options ); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * The Super block output function. |
|
| 69 | - * |
|
| 70 | - * @param array $args |
|
| 71 | - * @param array $widget_args |
|
| 72 | - * @param string $content |
|
| 73 | - * |
|
| 74 | - * @return string |
|
| 75 | - */ |
|
| 67 | + /** |
|
| 68 | + * The Super block output function. |
|
| 69 | + * |
|
| 70 | + * @param array $args |
|
| 71 | + * @param array $widget_args |
|
| 72 | + * @param string $content |
|
| 73 | + * |
|
| 74 | + * @return string |
|
| 75 | + */ |
|
| 76 | 76 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 77 | - global $invoicing; |
|
| 78 | - |
|
| 79 | - // Do we have a payment form? |
|
| 80 | - if ( empty( $args['form'] ) ) { |
|
| 81 | - return aui()->alert( |
|
| 82 | - array( |
|
| 83 | - 'type' => 'warning', |
|
| 84 | - 'content' => __( 'No payment form selected', 'invoicing' ), |
|
| 85 | - ) |
|
| 86 | - ); |
|
| 87 | - |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - // If yes, ensure that it is published. |
|
| 91 | - if ( 'publish' != get_post_status( $args['form'] ) ) { |
|
| 92 | - return aui()->alert( |
|
| 93 | - array( |
|
| 94 | - 'type' => 'warning', |
|
| 95 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
| 96 | - ) |
|
| 97 | - ); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - // Get the form elements and items. |
|
| 101 | - $elements = $invoicing->form_elements->get_form_elements( $args['form'] ); |
|
| 102 | - $items = $invoicing->form_elements->get_form_items( $args['form'] ); |
|
| 103 | - |
|
| 104 | - ob_start(); |
|
| 105 | - echo "<form class='wpinv_payment_form'>"; |
|
| 106 | - echo "<input type='hidden' name='form_id' value='{$args['form']}'/>"; |
|
| 107 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
| 108 | - |
|
| 109 | - foreach ( $elements as $element ) { |
|
| 110 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] ); |
|
| 111 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] ); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
| 115 | - echo '</form>'; |
|
| 116 | - |
|
| 117 | - $content = ob_get_clean(); |
|
| 77 | + global $invoicing; |
|
| 78 | + |
|
| 79 | + // Do we have a payment form? |
|
| 80 | + if ( empty( $args['form'] ) ) { |
|
| 81 | + return aui()->alert( |
|
| 82 | + array( |
|
| 83 | + 'type' => 'warning', |
|
| 84 | + 'content' => __( 'No payment form selected', 'invoicing' ), |
|
| 85 | + ) |
|
| 86 | + ); |
|
| 87 | + |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + // If yes, ensure that it is published. |
|
| 91 | + if ( 'publish' != get_post_status( $args['form'] ) ) { |
|
| 92 | + return aui()->alert( |
|
| 93 | + array( |
|
| 94 | + 'type' => 'warning', |
|
| 95 | + 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
| 96 | + ) |
|
| 97 | + ); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + // Get the form elements and items. |
|
| 101 | + $elements = $invoicing->form_elements->get_form_elements( $args['form'] ); |
|
| 102 | + $items = $invoicing->form_elements->get_form_items( $args['form'] ); |
|
| 103 | + |
|
| 104 | + ob_start(); |
|
| 105 | + echo "<form class='wpinv_payment_form'>"; |
|
| 106 | + echo "<input type='hidden' name='form_id' value='{$args['form']}'/>"; |
|
| 107 | + wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
| 108 | + |
|
| 109 | + foreach ( $elements as $element ) { |
|
| 110 | + do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] ); |
|
| 111 | + do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] ); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
| 115 | + echo '</form>'; |
|
| 116 | + |
|
| 117 | + $content = ob_get_clean(); |
|
| 118 | 118 | |
| 119 | - return str_replace( 'sr-only', '', $content ); |
|
| 119 | + return str_replace( 'sr-only', '', $content ); |
|
| 120 | 120 | |
| 121 | 121 | } |
| 122 | 122 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if (!defined('ABSPATH')) { |
|
| 4 | 4 | exit; // Exit if accessed directly |
| 5 | 5 | } |
| 6 | 6 | |
@@ -22,16 +22,16 @@ discard block |
||
| 22 | 22 | 'orderby' => 'title', |
| 23 | 23 | 'order' => 'ASC', |
| 24 | 24 | 'posts_per_page' => -1, |
| 25 | - 'post_status' => array( 'publish' ), |
|
| 25 | + 'post_status' => array('publish'), |
|
| 26 | 26 | ) |
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | 29 | $options = array( |
| 30 | - '' => __('Select a Form','invoicing') |
|
| 30 | + '' => __('Select a Form', 'invoicing') |
|
| 31 | 31 | ); |
| 32 | 32 | |
| 33 | - foreach( $forms as $form ) { |
|
| 34 | - $options[ $form->ID ] = $form->post_title; |
|
| 33 | + foreach ($forms as $form) { |
|
| 34 | + $options[$form->ID] = $form->post_title; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $options = array( |
@@ -41,15 +41,15 @@ discard block |
||
| 41 | 41 | 'block-keywords'=> "['invoicing','buy', 'buy item', 'pay', 'payment form']", |
| 42 | 42 | 'class_name' => __CLASS__, |
| 43 | 43 | 'base_id' => 'wpinv_payment_form', |
| 44 | - 'name' => __('Invoicing > Payment Form','invoicing'), |
|
| 44 | + 'name' => __('Invoicing > Payment Form', 'invoicing'), |
|
| 45 | 45 | 'widget_ops' => array( |
| 46 | 46 | 'classname' => 'wpinv-payment-form-class bsui', |
| 47 | - 'description' => esc_html__('Displays a payment form.','invoicing'), |
|
| 47 | + 'description' => esc_html__('Displays a payment form.', 'invoicing'), |
|
| 48 | 48 | ), |
| 49 | 49 | 'arguments' => array( |
| 50 | 50 | 'form' => array( |
| 51 | - 'title' => __( 'Payment Form', 'invoicing' ), |
|
| 52 | - 'desc' => __( 'Select your payment form.', 'invoicing' ), |
|
| 51 | + 'title' => __('Payment Form', 'invoicing'), |
|
| 52 | + 'desc' => __('Select your payment form.', 'invoicing'), |
|
| 53 | 53 | 'type' => 'select', |
| 54 | 54 | 'options' => $options, |
| 55 | 55 | 'desc_tip' => true, |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | ); |
| 62 | 62 | |
| 63 | 63 | |
| 64 | - parent::__construct( $options ); |
|
| 64 | + parent::__construct($options); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -73,42 +73,42 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return string |
| 75 | 75 | */ |
| 76 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 76 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 77 | 77 | global $invoicing; |
| 78 | 78 | |
| 79 | 79 | // Do we have a payment form? |
| 80 | - if ( empty( $args['form'] ) ) { |
|
| 80 | + if (empty($args['form'])) { |
|
| 81 | 81 | return aui()->alert( |
| 82 | 82 | array( |
| 83 | 83 | 'type' => 'warning', |
| 84 | - 'content' => __( 'No payment form selected', 'invoicing' ), |
|
| 84 | + 'content' => __('No payment form selected', 'invoicing'), |
|
| 85 | 85 | ) |
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // If yes, ensure that it is published. |
| 91 | - if ( 'publish' != get_post_status( $args['form'] ) ) { |
|
| 91 | + if ('publish' != get_post_status($args['form'])) { |
|
| 92 | 92 | return aui()->alert( |
| 93 | 93 | array( |
| 94 | 94 | 'type' => 'warning', |
| 95 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
| 95 | + 'content' => __('This payment form is no longer active', 'invoicing'), |
|
| 96 | 96 | ) |
| 97 | 97 | ); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Get the form elements and items. |
| 101 | - $elements = $invoicing->form_elements->get_form_elements( $args['form'] ); |
|
| 102 | - $items = $invoicing->form_elements->get_form_items( $args['form'] ); |
|
| 101 | + $elements = $invoicing->form_elements->get_form_elements($args['form']); |
|
| 102 | + $items = $invoicing->form_elements->get_form_items($args['form']); |
|
| 103 | 103 | |
| 104 | 104 | ob_start(); |
| 105 | 105 | echo "<form class='wpinv_payment_form'>"; |
| 106 | 106 | echo "<input type='hidden' name='form_id' value='{$args['form']}'/>"; |
| 107 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
| 107 | + wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form'); |
|
| 108 | 108 | |
| 109 | - foreach ( $elements as $element ) { |
|
| 110 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] ); |
|
| 111 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] ); |
|
| 109 | + foreach ($elements as $element) { |
|
| 110 | + do_action('wpinv_frontend_render_payment_form_element', $element, $items, $args['form']); |
|
| 111 | + do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form']); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $content = ob_get_clean(); |
| 118 | 118 | |
| 119 | - return str_replace( 'sr-only', '', $content ); |
|
| 119 | + return str_replace('sr-only', '', $content); |
|
| 120 | 120 | |
| 121 | 121 | } |
| 122 | 122 | |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
| 161 | 161 | |
| 162 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 163 | - return 'manage_options'; |
|
| 164 | - }; |
|
| 162 | + if ( current_user_can( 'manage_options' ) ) { |
|
| 163 | + return 'manage_options'; |
|
| 164 | + }; |
|
| 165 | 165 | |
| 166 | - return $capalibilty; |
|
| 166 | + return $capalibilty; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | function wpinv_create_user( $email ) { |
| 186 | 186 | |
| 187 | 187 | // Prepare user values. |
| 188 | - $args = array( |
|
| 189 | - 'user_login' => wpinv_generate_user_name( $email ), |
|
| 190 | - 'user_pass' => wp_generate_password(), |
|
| 191 | - 'user_email' => $email, |
|
| 192 | - 'role' => 'subscriber', |
|
| 188 | + $args = array( |
|
| 189 | + 'user_login' => wpinv_generate_user_name( $email ), |
|
| 190 | + 'user_pass' => wp_generate_password(), |
|
| 191 | + 'user_email' => $email, |
|
| 192 | + 'role' => 'subscriber', |
|
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | 195 | return wp_insert_user( $args ); |
@@ -205,19 +205,19 @@ discard block |
||
| 205 | 205 | function wpinv_generate_user_name( $prefix = '' ) { |
| 206 | 206 | |
| 207 | 207 | // If prefix is an email, retrieve the part before the email. |
| 208 | - $prefix = strtok( $prefix, '@' ); |
|
| 208 | + $prefix = strtok( $prefix, '@' ); |
|
| 209 | 209 | |
| 210 | - // Trim to 4 characters max. |
|
| 211 | - $prefix = sanitize_user( substr( $prefix, 0, 4 ) ); |
|
| 210 | + // Trim to 4 characters max. |
|
| 211 | + $prefix = sanitize_user( substr( $prefix, 0, 4 ) ); |
|
| 212 | 212 | |
| 213 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
| 214 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
| 215 | - $prefix = 'paywp'; |
|
| 216 | - } |
|
| 213 | + $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
| 214 | + if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
| 215 | + $prefix = 'paywp'; |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - $username = $prefix . '_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
| 219 | - if ( username_exists( $username ) ) { |
|
| 220 | - return wpinv_generate_user_name( $prefix ); |
|
| 221 | - } |
|
| 218 | + $username = $prefix . '_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
| 219 | + if ( username_exists( $username ) ) { |
|
| 220 | + return wpinv_generate_user_name( $prefix ); |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | 223 | } |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | -function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'publish', $orderby = 'ID', $order = 'DESC' ) { |
|
| 6 | - if ( empty( $user ) ) { |
|
| 5 | +function wpinv_get_users_invoices($user = 0, $number = 20, $pagination = false, $status = 'publish', $orderby = 'ID', $order = 'DESC') { |
|
| 6 | + if (empty($user)) { |
|
| 7 | 7 | $user = get_current_user_id(); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | - if ( empty( $user ) ) { |
|
| 10 | + if (empty($user)) { |
|
| 11 | 11 | return false; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - $args = apply_filters( 'wpinv_get_users_invoices_args', array( 'user' => $user, 'limit' => $number, 'status' => $status, 'paginate' => $pagination, 'orderby' => $orderby, 'order' => $order ) ); |
|
| 14 | + $args = apply_filters('wpinv_get_users_invoices_args', array('user' => $user, 'limit' => $number, 'status' => $status, 'paginate' => $pagination, 'orderby' => $orderby, 'order' => $order)); |
|
| 15 | 15 | |
| 16 | - return wpinv_get_invoices( $args ); |
|
| 16 | + return wpinv_get_invoices($args); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -function wpinv_dropdown_users( $args = '' ) { |
|
| 19 | +function wpinv_dropdown_users($args = '') { |
|
| 20 | 20 | $defaults = array( |
| 21 | 21 | 'show_option_all' => '', 'show_option_none' => '', 'hide_if_only_one_author' => '', |
| 22 | 22 | 'orderby' => 'display_name', 'order' => 'ASC', |
@@ -27,18 +27,18 @@ discard block |
||
| 27 | 27 | 'option_none_value' => -1 |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; |
|
| 30 | + $defaults['selected'] = is_author() ? get_query_var('author') : 0; |
|
| 31 | 31 | |
| 32 | - $r = wp_parse_args( $args, $defaults ); |
|
| 32 | + $r = wp_parse_args($args, $defaults); |
|
| 33 | 33 | |
| 34 | - $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) ); |
|
| 34 | + $query_args = wp_array_slice_assoc($r, array('blog_id', 'include', 'exclude', 'orderby', 'order', 'who')); |
|
| 35 | 35 | |
| 36 | - $fields = array( 'ID', 'user_login', 'user_email' ); |
|
| 36 | + $fields = array('ID', 'user_login', 'user_email'); |
|
| 37 | 37 | |
| 38 | - $show = ! empty( $r['show'] ) ? $r['show'] : 'display_name'; |
|
| 39 | - if ( 'display_name_with_login' === $show ) { |
|
| 38 | + $show = !empty($r['show']) ? $r['show'] : 'display_name'; |
|
| 39 | + if ('display_name_with_login' === $show) { |
|
| 40 | 40 | $fields[] = 'display_name'; |
| 41 | - } else if ( 'display_name_with_email' === $show ) { |
|
| 41 | + } else if ('display_name_with_email' === $show) { |
|
| 42 | 42 | $fields[] = 'display_name'; |
| 43 | 43 | } else { |
| 44 | 44 | $fields[] = $show; |
@@ -50,99 +50,99 @@ discard block |
||
| 50 | 50 | $show_option_none = $r['show_option_none']; |
| 51 | 51 | $option_none_value = $r['option_none_value']; |
| 52 | 52 | |
| 53 | - $query_args = apply_filters( 'wpinv_dropdown_users_args', $query_args, $r ); |
|
| 53 | + $query_args = apply_filters('wpinv_dropdown_users_args', $query_args, $r); |
|
| 54 | 54 | |
| 55 | - $users = get_users( $query_args ); |
|
| 55 | + $users = get_users($query_args); |
|
| 56 | 56 | |
| 57 | 57 | $output = ''; |
| 58 | - if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) { |
|
| 59 | - $name = esc_attr( $r['name'] ); |
|
| 60 | - if ( $r['multi'] && ! $r['id'] ) { |
|
| 58 | + if (!empty($users) && (empty($r['hide_if_only_one_author']) || count($users) > 1)) { |
|
| 59 | + $name = esc_attr($r['name']); |
|
| 60 | + if ($r['multi'] && !$r['id']) { |
|
| 61 | 61 | $id = ''; |
| 62 | 62 | } else { |
| 63 | - $id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'"; |
|
| 63 | + $id = $r['id'] ? " id='" . esc_attr($r['id']) . "'" : " id='$name'"; |
|
| 64 | 64 | } |
| 65 | 65 | $output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n"; |
| 66 | 66 | |
| 67 | - if ( $show_option_all ) { |
|
| 67 | + if ($show_option_all) { |
|
| 68 | 68 | $output .= "\t<option value='0'>$show_option_all</option>\n"; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if ( $show_option_none ) { |
|
| 72 | - $_selected = selected( $option_none_value, $r['selected'], false ); |
|
| 73 | - $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n"; |
|
| 71 | + if ($show_option_none) { |
|
| 72 | + $_selected = selected($option_none_value, $r['selected'], false); |
|
| 73 | + $output .= "\t<option value='" . esc_attr($option_none_value) . "'$_selected>$show_option_none</option>\n"; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if ( $r['include_selected'] && ( $r['selected'] > 0 ) ) { |
|
| 76 | + if ($r['include_selected'] && ($r['selected'] > 0)) { |
|
| 77 | 77 | $found_selected = false; |
| 78 | 78 | $r['selected'] = (int) $r['selected']; |
| 79 | - foreach ( (array) $users as $user ) { |
|
| 79 | + foreach ((array) $users as $user) { |
|
| 80 | 80 | $user->ID = (int) $user->ID; |
| 81 | - if ( $user->ID === $r['selected'] ) { |
|
| 81 | + if ($user->ID === $r['selected']) { |
|
| 82 | 82 | $found_selected = true; |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ( ! $found_selected ) { |
|
| 87 | - $users[] = get_userdata( $r['selected'] ); |
|
| 86 | + if (!$found_selected) { |
|
| 87 | + $users[] = get_userdata($r['selected']); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - foreach ( (array) $users as $user ) { |
|
| 92 | - if ( 'display_name_with_login' === $show ) { |
|
| 91 | + foreach ((array) $users as $user) { |
|
| 92 | + if ('display_name_with_login' === $show) { |
|
| 93 | 93 | /* translators: 1: display name, 2: user_login */ |
| 94 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_login ); |
|
| 95 | - } elseif ( 'display_name_with_email' === $show ) { |
|
| 94 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_login); |
|
| 95 | + } elseif ('display_name_with_email' === $show) { |
|
| 96 | 96 | /* translators: 1: display name, 2: user_email */ |
| 97 | - if ( $user->display_name == $user->user_email ) { |
|
| 97 | + if ($user->display_name == $user->user_email) { |
|
| 98 | 98 | $display = $user->display_name; |
| 99 | 99 | } else { |
| 100 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_email ); |
|
| 100 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_email); |
|
| 101 | 101 | } |
| 102 | - } elseif ( ! empty( $user->$show ) ) { |
|
| 102 | + } elseif (!empty($user->$show)) { |
|
| 103 | 103 | $display = $user->$show; |
| 104 | 104 | } else { |
| 105 | 105 | $display = '(' . $user->user_login . ')'; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - $_selected = selected( $user->ID, $r['selected'], false ); |
|
| 109 | - $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n"; |
|
| 108 | + $_selected = selected($user->ID, $r['selected'], false); |
|
| 109 | + $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n"; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $output .= "</select>"; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $html = apply_filters( 'wpinv_dropdown_users', $output ); |
|
| 115 | + $html = apply_filters('wpinv_dropdown_users', $output); |
|
| 116 | 116 | |
| 117 | - if ( $r['echo'] ) { |
|
| 117 | + if ($r['echo']) { |
|
| 118 | 118 | echo $html; |
| 119 | 119 | } |
| 120 | 120 | return $html; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | -function wpinv_guest_redirect( $redirect_to, $user_id = 0 ) { |
|
| 124 | - if ( (int)wpinv_get_option( 'guest_checkout' ) && $user_id > 0 ) { |
|
| 125 | - wpinv_login_user( $user_id ); |
|
| 123 | +function wpinv_guest_redirect($redirect_to, $user_id = 0) { |
|
| 124 | + if ((int) wpinv_get_option('guest_checkout') && $user_id > 0) { |
|
| 125 | + wpinv_login_user($user_id); |
|
| 126 | 126 | } else { |
| 127 | - $redirect_to = wp_login_url( $redirect_to ); |
|
| 127 | + $redirect_to = wp_login_url($redirect_to); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $redirect_to = apply_filters( 'wpinv_invoice_link_guest_redirect', $redirect_to, $user_id ); |
|
| 130 | + $redirect_to = apply_filters('wpinv_invoice_link_guest_redirect', $redirect_to, $user_id); |
|
| 131 | 131 | |
| 132 | - wp_redirect( $redirect_to ); |
|
| 132 | + wp_redirect($redirect_to); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | -function wpinv_login_user( $user_id ) { |
|
| 136 | - if ( is_user_logged_in() ) { |
|
| 135 | +function wpinv_login_user($user_id) { |
|
| 136 | + if (is_user_logged_in()) { |
|
| 137 | 137 | return true; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $user = get_user_by( 'id', $user_id ); |
|
| 140 | + $user = get_user_by('id', $user_id); |
|
| 141 | 141 | |
| 142 | - if ( !empty( $user ) && !is_wp_error( $user ) && !empty( $user->user_login ) ) { |
|
| 143 | - wp_set_current_user( $user_id, $user->user_login ); |
|
| 144 | - wp_set_auth_cookie( $user_id ); |
|
| 145 | - do_action( 'wp_login', $user->user_login ); |
|
| 142 | + if (!empty($user) && !is_wp_error($user) && !empty($user->user_login)) { |
|
| 143 | + wp_set_current_user($user_id, $user->user_login); |
|
| 144 | + wp_set_auth_cookie($user_id); |
|
| 145 | + do_action('wp_login', $user->user_login); |
|
| 146 | 146 | |
| 147 | 147 | return true; |
| 148 | 148 | } |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | * @return string capability to check against |
| 158 | 158 | * @param string $capalibilty Optional. The alternative capability to check against. |
| 159 | 159 | */ |
| 160 | -function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
|
| 160 | +function wpinv_get_capability($capalibilty = 'manage_invoicing') { |
|
| 161 | 161 | |
| 162 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 162 | + if (current_user_can('manage_options')) { |
|
| 163 | 163 | return 'manage_options'; |
| 164 | 164 | }; |
| 165 | 165 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @return bool |
| 174 | 174 | */ |
| 175 | 175 | function wpinv_current_user_can_manage_invoicing() { |
| 176 | - return current_user_can( wpinv_get_capability() ); |
|
| 176 | + return current_user_can(wpinv_get_capability()); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -182,17 +182,17 @@ discard block |
||
| 182 | 182 | * @since 1.0.19 |
| 183 | 183 | * @return int|WP_Error |
| 184 | 184 | */ |
| 185 | -function wpinv_create_user( $email ) { |
|
| 185 | +function wpinv_create_user($email) { |
|
| 186 | 186 | |
| 187 | 187 | // Prepare user values. |
| 188 | 188 | $args = array( |
| 189 | - 'user_login' => wpinv_generate_user_name( $email ), |
|
| 189 | + 'user_login' => wpinv_generate_user_name($email), |
|
| 190 | 190 | 'user_pass' => wp_generate_password(), |
| 191 | 191 | 'user_email' => $email, |
| 192 | 192 | 'role' => 'subscriber', |
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | - return wp_insert_user( $args ); |
|
| 195 | + return wp_insert_user($args); |
|
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
@@ -202,22 +202,22 @@ discard block |
||
| 202 | 202 | * @since 1.0.19 |
| 203 | 203 | * @return bool|WP_User |
| 204 | 204 | */ |
| 205 | -function wpinv_generate_user_name( $prefix = '' ) { |
|
| 205 | +function wpinv_generate_user_name($prefix = '') { |
|
| 206 | 206 | |
| 207 | 207 | // If prefix is an email, retrieve the part before the email. |
| 208 | - $prefix = strtok( $prefix, '@' ); |
|
| 208 | + $prefix = strtok($prefix, '@'); |
|
| 209 | 209 | |
| 210 | 210 | // Trim to 4 characters max. |
| 211 | - $prefix = sanitize_user( substr( $prefix, 0, 4 ) ); |
|
| 211 | + $prefix = sanitize_user(substr($prefix, 0, 4)); |
|
| 212 | 212 | |
| 213 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
| 214 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
| 213 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
| 214 | + if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) { |
|
| 215 | 215 | $prefix = 'paywp'; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - $username = $prefix . '_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
| 219 | - if ( username_exists( $username ) ) { |
|
| 220 | - return wpinv_generate_user_name( $prefix ); |
|
| 218 | + $username = $prefix . '_' . zeroise(wp_rand(0, 9999), 4); |
|
| 219 | + if (username_exists($username)) { |
|
| 220 | + return wpinv_generate_user_name($prefix); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | } |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
| 172 | 172 | require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
| 173 | 173 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
| 174 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
| 175 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
| 176 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
| 177 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
| 178 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
| 174 | + require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
| 175 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
| 176 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
| 177 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
| 178 | + require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
| 179 | 179 | require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
| 180 | 180 | require_once( WPINV_PLUGIN_DIR . 'widgets/payment-form.php' ); |
| 181 | 181 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' ); |
@@ -491,19 +491,19 @@ discard block |
||
| 491 | 491 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - /** |
|
| 495 | - * Register widgets |
|
| 496 | - * |
|
| 497 | - */ |
|
| 498 | - public function register_widgets() { |
|
| 499 | - register_widget( "WPInv_Checkout_Widget" ); |
|
| 500 | - register_widget( "WPInv_History_Widget" ); |
|
| 501 | - register_widget( "WPInv_Receipt_Widget" ); |
|
| 502 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
| 503 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
| 494 | + /** |
|
| 495 | + * Register widgets |
|
| 496 | + * |
|
| 497 | + */ |
|
| 498 | + public function register_widgets() { |
|
| 499 | + register_widget( "WPInv_Checkout_Widget" ); |
|
| 500 | + register_widget( "WPInv_History_Widget" ); |
|
| 501 | + register_widget( "WPInv_Receipt_Widget" ); |
|
| 502 | + register_widget( "WPInv_Subscriptions_Widget" ); |
|
| 503 | + register_widget( "WPInv_Buy_Item_Widget" ); |
|
| 504 | 504 | register_widget( "WPInv_Messages_Widget" ); |
| 505 | 505 | register_widget( 'WPInv_Payment_Form_Widget' ); |
| 506 | - } |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | 508 | /** |
| 509 | 509 | * Remove our pages from yoast sitemaps. |
@@ -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(); |
@@ -33,34 +33,34 @@ 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( &$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(&$this, 'wpinv_actions')); |
|
| 48 | 48 | |
| 49 | - if ( class_exists( 'BuddyPress' ) ) { |
|
| 50 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
| 49 | + if (class_exists('BuddyPress')) { |
|
| 50 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
| 54 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
| 55 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
| 53 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
| 54 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
| 55 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
| 56 | 56 | |
| 57 | - if ( is_admin() ) { |
|
| 58 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
| 59 | - add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
| 60 | - add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) ); |
|
| 57 | + if (is_admin()) { |
|
| 58 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
| 59 | + add_filter('admin_body_class', array(&$this, 'admin_body_class')); |
|
| 60 | + add_action('admin_init', array(&$this, 'init_ayecode_connect_helper')); |
|
| 61 | 61 | |
| 62 | 62 | } else { |
| 63 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
| 63 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -70,28 +70,28 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
| 72 | 72 | */ |
| 73 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
| 73 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
| 74 | 74 | |
| 75 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
| 75 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Maybe show the AyeCode Connect Notice. |
| 80 | 80 | */ |
| 81 | - public function init_ayecode_connect_helper(){ |
|
| 81 | + public function init_ayecode_connect_helper() { |
|
| 82 | 82 | // AyeCode Connect notice |
| 83 | - if ( is_admin() ){ |
|
| 83 | + if (is_admin()) { |
|
| 84 | 84 | // set the strings so they can be translated |
| 85 | 85 | $strings = array( |
| 86 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
| 87 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
| 88 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
| 89 | - 'connect_button' => __("Connect Site","invoicing"), |
|
| 90 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
| 91 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
| 92 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
| 86 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
| 87 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
| 88 | + 'connect' => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
| 89 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
| 90 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
| 91 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
| 92 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
| 93 | 93 | ); |
| 94 | - new AyeCode_Connect_Helper($strings,array('wpi-addons')); |
|
| 94 | + new AyeCode_Connect_Helper($strings, array('wpi-addons')); |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
@@ -99,10 +99,10 @@ discard block |
||
| 99 | 99 | /* Internationalize the text strings used. */ |
| 100 | 100 | $this->load_textdomain(); |
| 101 | 101 | |
| 102 | - do_action( 'wpinv_loaded' ); |
|
| 102 | + do_action('wpinv_loaded'); |
|
| 103 | 103 | |
| 104 | 104 | // Fix oxygen page builder conflict |
| 105 | - if ( function_exists( 'ct_css_output' ) ) { |
|
| 105 | + if (function_exists('ct_css_output')) { |
|
| 106 | 106 | wpinv_oxygen_fix_conflict(); |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -112,237 +112,237 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @since 1.0 |
| 114 | 114 | */ |
| 115 | - public function load_textdomain( $locale = NULL ) { |
|
| 116 | - if ( empty( $locale ) ) { |
|
| 117 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
| 115 | + public function load_textdomain($locale = NULL) { |
|
| 116 | + if (empty($locale)) { |
|
| 117 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
| 120 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
| 121 | 121 | |
| 122 | - unload_textdomain( 'invoicing' ); |
|
| 123 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
| 124 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
| 122 | + unload_textdomain('invoicing'); |
|
| 123 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
| 124 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * Define language constants. |
| 128 | 128 | */ |
| 129 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
| 129 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | public function includes() { |
| 133 | 133 | global $wpinv_options; |
| 134 | 134 | |
| 135 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
| 135 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
| 136 | 136 | $wpinv_options = wpinv_get_settings(); |
| 137 | 137 | |
| 138 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
| 139 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' ); |
|
| 140 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
| 141 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
| 142 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
| 143 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
| 144 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
| 145 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
| 146 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
| 147 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
| 148 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
| 149 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
| 150 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
| 151 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
| 152 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
| 153 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
| 154 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
| 155 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' ); |
|
| 156 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
| 157 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
| 158 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
| 159 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
| 160 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
| 161 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
| 162 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
| 163 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
| 164 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
| 165 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
| 166 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
| 167 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
| 168 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
| 169 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
| 170 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
| 171 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
| 172 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
| 173 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
| 174 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
| 175 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
| 176 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
| 177 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
| 178 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
| 179 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
| 180 | - require_once( WPINV_PLUGIN_DIR . 'widgets/payment-form.php' ); |
|
| 181 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' ); |
|
| 182 | - |
|
| 183 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
| 184 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
| 138 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
| 139 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php'); |
|
| 140 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
| 141 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
| 142 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
| 143 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
| 144 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
| 145 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
| 146 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
| 147 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
| 148 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
| 149 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
| 150 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
| 151 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
| 152 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
| 153 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
| 154 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
| 155 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php'); |
|
| 156 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
| 157 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
| 158 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
| 159 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
| 160 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
| 161 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
| 162 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
| 163 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
| 164 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
| 165 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
| 166 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
| 167 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
| 168 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
| 169 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
| 170 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
| 171 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
| 172 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
| 173 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
| 174 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
| 175 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
| 176 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
| 177 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
| 178 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
| 179 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
| 180 | + require_once(WPINV_PLUGIN_DIR . 'widgets/payment-form.php'); |
|
| 181 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php'); |
|
| 182 | + |
|
| 183 | + if (!class_exists('WPInv_EUVat')) { |
|
| 184 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 188 | - if ( !empty( $gateways ) ) { |
|
| 189 | - foreach ( $gateways as $gateway ) { |
|
| 190 | - if ( $gateway == 'manual' ) { |
|
| 187 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
| 188 | + if (!empty($gateways)) { |
|
| 189 | + foreach ($gateways as $gateway) { |
|
| 190 | + if ($gateway == 'manual') { |
|
| 191 | 191 | continue; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
| 195 | 195 | |
| 196 | - if ( file_exists( $gateway_file ) ) { |
|
| 197 | - require_once( $gateway_file ); |
|
| 196 | + if (file_exists($gateway_file)) { |
|
| 197 | + require_once($gateway_file); |
|
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
| 201 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
| 202 | 202 | |
| 203 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 204 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
| 205 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
| 206 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
| 203 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
| 204 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
| 205 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
| 206 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
| 207 | 207 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
| 208 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
| 209 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
| 210 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
| 211 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
| 212 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
| 213 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
| 214 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
| 215 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
| 208 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
| 209 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
| 210 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
| 211 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
| 212 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
| 213 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
| 214 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
| 215 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
| 216 | 216 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
| 217 | 217 | // load the user class only on the users.php page |
| 218 | 218 | global $pagenow; |
| 219 | - if($pagenow=='users.php'){ |
|
| 219 | + if ($pagenow == 'users.php') { |
|
| 220 | 220 | new WPInv_Admin_Users(); |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // Register cli commands |
| 225 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 226 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
| 227 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
| 225 | + if (defined('WP_CLI') && WP_CLI) { |
|
| 226 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
| 227 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | // include css inliner |
| 231 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
| 232 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
| 231 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
| 232 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
| 235 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | public function init() { |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | public function admin_init() { |
| 242 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
| 242 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | public function activation_redirect() { |
| 246 | 246 | // Bail if no activation redirect |
| 247 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
| 247 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
| 248 | 248 | return; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // Delete the redirect transient |
| 252 | - delete_transient( '_wpinv_activation_redirect' ); |
|
| 252 | + delete_transient('_wpinv_activation_redirect'); |
|
| 253 | 253 | |
| 254 | 254 | // Bail if activating from network, or bulk |
| 255 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 255 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 256 | 256 | return; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
| 259 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
| 260 | 260 | exit; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | public function enqueue_scripts() { |
| 264 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 264 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 265 | 265 | |
| 266 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
| 267 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
| 266 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
| 267 | + wp_enqueue_style('wpinv_front_style'); |
|
| 268 | 268 | |
| 269 | 269 | // Register scripts |
| 270 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 271 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 270 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 271 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION); |
|
| 272 | 272 | |
| 273 | 273 | $localize = array(); |
| 274 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 275 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 274 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 275 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 276 | 276 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
| 277 | 277 | $localize['currency_pos'] = wpinv_currency_position(); |
| 278 | 278 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 279 | 279 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 280 | 280 | $localize['decimals'] = wpinv_decimals(); |
| 281 | - $localize['txtComplete'] = __( 'Complete', 'invoicing' ); |
|
| 281 | + $localize['txtComplete'] = __('Complete', 'invoicing'); |
|
| 282 | 282 | $localize['UseTaxes'] = wpinv_use_taxes(); |
| 283 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
| 283 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
| 284 | 284 | |
| 285 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
| 285 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
| 286 | 286 | |
| 287 | - wp_enqueue_script( 'jquery-blockui' ); |
|
| 287 | + wp_enqueue_script('jquery-blockui'); |
|
| 288 | 288 | $autofill_api = wpinv_get_option('address_autofill_api'); |
| 289 | 289 | $autofill_active = wpinv_get_option('address_autofill_active'); |
| 290 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
| 291 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
| 292 | - wp_dequeue_script( 'google-maps-api' ); |
|
| 290 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
| 291 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
| 292 | + wp_dequeue_script('google-maps-api'); |
|
| 293 | 293 | } |
| 294 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
| 295 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
| 294 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
| 295 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
| 299 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 298 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
| 299 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 300 | 300 | |
| 301 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
| 302 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
| 301 | + wp_enqueue_script('wpinv-front-script'); |
|
| 302 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
| 303 | 303 | |
| 304 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
| 305 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script' ), $version, true ); |
|
| 304 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
| 305 | + wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script'), $version, true); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - public function admin_enqueue_scripts( $hook ) { |
|
| 308 | + public function admin_enqueue_scripts($hook) { |
|
| 309 | 309 | global $post, $pagenow; |
| 310 | 310 | |
| 311 | 311 | $post_type = wpinv_admin_post_type(); |
| 312 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 313 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
| 312 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 313 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
| 314 | 314 | |
| 315 | 315 | $jquery_ui_css = false; |
| 316 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
| 316 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
| 317 | 317 | $jquery_ui_css = true; |
| 318 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
| 318 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
| 319 | 319 | $jquery_ui_css = true; |
| 320 | 320 | } |
| 321 | - if ( $jquery_ui_css ) { |
|
| 322 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
| 323 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
| 321 | + if ($jquery_ui_css) { |
|
| 322 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
| 323 | + wp_enqueue_style('jquery-ui-css'); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
| 327 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
| 326 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
| 327 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
| 328 | 328 | |
| 329 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
| 330 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version ); |
|
| 331 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
| 329 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
| 330 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version); |
|
| 331 | + wp_enqueue_style('wpinv_admin_style'); |
|
| 332 | 332 | |
| 333 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
| 334 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 335 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 333 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
| 334 | + if ($page == 'wpinv-subscriptions') { |
|
| 335 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
| 339 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 338 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
| 339 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 343 | - wp_enqueue_script( 'wp-color-picker' ); |
|
| 342 | + wp_enqueue_style('wp-color-picker'); |
|
| 343 | + wp_enqueue_script('wp-color-picker'); |
|
| 344 | 344 | |
| 345 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 345 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 346 | 346 | |
| 347 | 347 | if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
| 348 | 348 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -353,20 +353,20 @@ discard block |
||
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
| 357 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 356 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
| 357 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 358 | 358 | |
| 359 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
|
| 360 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
| 359 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
| 360 | + wp_enqueue_script('wpinv-admin-script'); |
|
| 361 | 361 | |
| 362 | 362 | $localize = array(); |
| 363 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 364 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
| 365 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 366 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
| 367 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
| 368 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
| 369 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
| 363 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 364 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
| 365 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 366 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
| 367 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
| 368 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
| 369 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
| 370 | 370 | $localize['tax'] = wpinv_tax_amount(); |
| 371 | 371 | $localize['discount'] = wpinv_discount_amount(); |
| 372 | 372 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -374,95 +374,95 @@ discard block |
||
| 374 | 374 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 375 | 375 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 376 | 376 | $localize['decimals'] = wpinv_decimals(); |
| 377 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
| 378 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
| 379 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
| 380 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
| 381 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
| 382 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
| 383 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
| 384 | - $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' ); |
|
| 385 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
| 386 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
| 387 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
| 388 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
| 389 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
| 390 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
| 391 | - |
|
| 392 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
| 393 | - |
|
| 394 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
| 377 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
| 378 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
| 379 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
| 380 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
| 381 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
| 382 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
| 383 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
| 384 | + $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'); |
|
| 385 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
| 386 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
| 387 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
| 388 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
| 389 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
| 390 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
| 391 | + |
|
| 392 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
| 393 | + |
|
| 394 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
| 395 | 395 | |
| 396 | 396 | // Load payment form scripts on our admin pages only. |
| 397 | - if ( ( $hook == 'post-new.php' || $hook == 'post.php' ) && 'wpi_payment_form' === $post->post_type ) { |
|
| 397 | + if (($hook == 'post-new.php' || $hook == 'post.php') && 'wpi_payment_form' === $post->post_type) { |
|
| 398 | 398 | |
| 399 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
|
| 400 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
| 401 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
| 399 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION); |
|
| 400 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
| 401 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
| 402 | 402 | |
| 403 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
| 404 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
| 403 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
| 404 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version); |
|
| 405 | 405 | |
| 406 | - wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array( |
|
| 406 | + wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array( |
|
| 407 | 407 | 'elements' => $this->form_elements->get_elements(), |
| 408 | - 'form_elements' => $this->form_elements->get_form_elements( $post->ID ), |
|
| 408 | + 'form_elements' => $this->form_elements->get_form_elements($post->ID), |
|
| 409 | 409 | 'all_items' => $this->form_elements->get_published_items(), |
| 410 | 410 | 'currency' => wpinv_currency_symbol(), |
| 411 | 411 | 'position' => wpinv_currency_position(), |
| 412 | 412 | 'decimals' => (int) wpinv_decimals(), |
| 413 | 413 | 'thousands_sep' => wpinv_thousands_separator(), |
| 414 | 414 | 'decimals_sep' => wpinv_decimal_separator(), |
| 415 | - 'form_items' => $this->form_elements->get_form_items( $post->ID ), |
|
| 416 | - ) ); |
|
| 415 | + 'form_items' => $this->form_elements->get_form_items($post->ID), |
|
| 416 | + )); |
|
| 417 | 417 | |
| 418 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
| 418 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 422 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
| 423 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
| 421 | + if ($page == 'wpinv-subscriptions') { |
|
| 422 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
| 423 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - public function admin_body_class( $classes ) { |
|
| 428 | + public function admin_body_class($classes) { |
|
| 429 | 429 | global $pagenow, $post, $current_screen; |
| 430 | 430 | |
| 431 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
| 431 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote')) { |
|
| 432 | 432 | $classes .= ' wpinv-cpt'; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
| 435 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
| 436 | 436 | |
| 437 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
| 438 | - if ( $add_class ) { |
|
| 439 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
| 437 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
| 438 | + if ($add_class) { |
|
| 439 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | $settings_class = array(); |
| 443 | - if ( $page == 'wpinv-settings' ) { |
|
| 444 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
| 445 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
| 443 | + if ($page == 'wpinv-settings') { |
|
| 444 | + if (!empty($_REQUEST['tab'])) { |
|
| 445 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
| 449 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
| 448 | + if (!empty($_REQUEST['section'])) { |
|
| 449 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
| 452 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - if ( !empty( $settings_class ) ) { |
|
| 456 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
| 455 | + if (!empty($settings_class)) { |
|
| 456 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | $post_type = wpinv_admin_post_type(); |
| 460 | 460 | |
| 461 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
| 461 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
| 462 | 462 | return $classes .= ' wpinv'; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
| 465 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
| 466 | 466 | $classes .= ' wpi-editable-n'; |
| 467 | 467 | } |
| 468 | 468 | |
@@ -474,21 +474,21 @@ discard block |
||
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | public function wpinv_actions() { |
| 477 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
| 478 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
| 477 | + if (isset($_REQUEST['wpi_action'])) { |
|
| 478 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
| 479 | 479 | } |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - public function pre_get_posts( $wp_query ) { |
|
| 483 | - 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() ) { |
|
| 484 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
| 482 | + public function pre_get_posts($wp_query) { |
|
| 483 | + 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()) { |
|
| 484 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | return $wp_query; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | public function bp_invoicing_init() { |
| 491 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
| 491 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | /** |
@@ -496,13 +496,13 @@ discard block |
||
| 496 | 496 | * |
| 497 | 497 | */ |
| 498 | 498 | public function register_widgets() { |
| 499 | - register_widget( "WPInv_Checkout_Widget" ); |
|
| 500 | - register_widget( "WPInv_History_Widget" ); |
|
| 501 | - register_widget( "WPInv_Receipt_Widget" ); |
|
| 502 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
| 503 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
| 504 | - register_widget( "WPInv_Messages_Widget" ); |
|
| 505 | - register_widget( 'WPInv_Payment_Form_Widget' ); |
|
| 499 | + register_widget("WPInv_Checkout_Widget"); |
|
| 500 | + register_widget("WPInv_History_Widget"); |
|
| 501 | + register_widget("WPInv_Receipt_Widget"); |
|
| 502 | + register_widget("WPInv_Subscriptions_Widget"); |
|
| 503 | + register_widget("WPInv_Buy_Item_Widget"); |
|
| 504 | + register_widget("WPInv_Messages_Widget"); |
|
| 505 | + register_widget('WPInv_Payment_Form_Widget'); |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | /** |
@@ -511,10 +511,10 @@ discard block |
||
| 511 | 511 | * @since 1.0.19 |
| 512 | 512 | * @param int[] $excluded_posts_ids |
| 513 | 513 | */ |
| 514 | - function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
| 514 | + function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
| 515 | 515 | |
| 516 | 516 | // Ensure that we have an array. |
| 517 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
| 517 | + if (!is_array($excluded_posts_ids)) { |
|
| 518 | 518 | $excluded_posts_ids = array(); |
| 519 | 519 | } |
| 520 | 520 | |
@@ -522,24 +522,24 @@ discard block |
||
| 522 | 522 | $our_pages = array(); |
| 523 | 523 | |
| 524 | 524 | // Checkout page. |
| 525 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
| 525 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
| 526 | 526 | |
| 527 | 527 | // Success page. |
| 528 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
| 528 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
| 529 | 529 | |
| 530 | 530 | // Failure page. |
| 531 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
| 531 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
| 532 | 532 | |
| 533 | 533 | // History page. |
| 534 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
| 534 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
| 535 | 535 | |
| 536 | 536 | // Subscriptions page. |
| 537 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
| 537 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
| 538 | 538 | |
| 539 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
| 539 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
| 540 | 540 | |
| 541 | 541 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
| 542 | - return array_unique( $excluded_posts_ids ); |
|
| 542 | + return array_unique($excluded_posts_ids); |
|
| 543 | 543 | |
| 544 | 544 | } |
| 545 | 545 | } |