Passed
Push — master ( a1d3e4...4cf75d )
by Brian
04:38
created
includes/admin/meta-boxes/class-getpaid-meta-box-item-info.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,20 +21,20 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         ?>
30 30
 
31 31
         <div class='bsui' style='padding-top: 10px;'>
32
-            <?php do_action( 'wpinv_item_before_info_metabox', $item ); ?>
32
+            <?php do_action('wpinv_item_before_info_metabox', $item); ?>
33 33
 
34 34
             <div class="wpinv_item_type form-group row">
35 35
                 <label for="wpinv_item_type" class="col-sm-12 col-form-label">
36
-                    <?php _e( 'Item Type', 'invoicing' );?>
37
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo strip_tags( self::get_tooltip( $post ) ); ?>"></span>
36
+                    <?php _e('Item Type', 'invoicing'); ?>
37
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo strip_tags(self::get_tooltip($post)); ?>"></span>
38 38
                 </label>
39 39
 
40 40
                 <div class="col-sm-12">
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
                             array(
45 45
                                 'id'               => 'wpinv_item_type',
46 46
                                 'name'             => 'wpinv_item_type',
47
-                                'placeholder'      => __( 'Select item type', 'invoicing' ),
48
-                                'value'            => $item->get_type( 'edit' ),
47
+                                'placeholder'      => __('Select item type', 'invoicing'),
48
+                                'value'            => $item->get_type('edit'),
49 49
                                 'select2'          => true,
50 50
                                 'data-allow-clear' => 'false',
51 51
                                 'no_wrap'          => true,
@@ -57,59 +57,59 @@  discard block
 block discarded – undo
57 57
                 </div>
58 58
             </div>
59 59
 
60
-            <?php if ( 'fee' === $item->get_type( 'edit' ) || 'custom' === $item->get_type( 'edit' ) ) : ?>
60
+            <?php if ('fee' === $item->get_type('edit') || 'custom' === $item->get_type('edit')) : ?>
61 61
 
62 62
                 <div class="wpinv_item_shortcode form-group row">
63 63
                     <label for="wpinv_item_shortcode" class="col-sm-12 col-form-label">
64
-                        <?php _e( 'Payment Form Shortcode', 'invoicing' );?>
65
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span>
64
+                        <?php _e('Payment Form Shortcode', 'invoicing'); ?>
65
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span>
66 66
                     </label>
67 67
 
68 68
                     <div class="col-sm-12">
69
-                        <input  onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?>]" style="width: 100%;" readonly/>
69
+                        <input  onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?>]" style="width: 100%;" readonly/>
70 70
                     </div>
71 71
                 </div>
72 72
 
73 73
                 <div class="wpinv_item_buy_shortcode form-group row">
74 74
                     <label for="wpinv_item_button_shortcode" class="col-sm-12 col-form-label">
75
-                        <?php _e( 'Payment Button Shortcode', 'invoicing' );?>
76
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span>
75
+                        <?php _e('Payment Button Shortcode', 'invoicing'); ?>
76
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span>
77 77
                     </label>
78 78
 
79 79
                     <div class="col-sm-12">
80
-                        <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?> button='Buy Now']" style="width: 100%;" readonly/>
80
+                        <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?> button='Buy Now']" style="width: 100%;" readonly/>
81 81
                         <small class="form-text text-muted">
82
-                            <?php _e( 'Or use the following URL in a link:', 'invoicing' );?>
83
-                            <code>#getpaid-item-<?php echo intval( $item->get_id() ); ?>|0</code>
82
+                            <?php _e('Or use the following URL in a link:', 'invoicing'); ?>
83
+                            <code>#getpaid-item-<?php echo intval($item->get_id()); ?>|0</code>
84 84
                         </small>
85 85
                     </div>
86 86
                 </div>
87 87
 
88 88
                 <div class="wpinv_item_buy_url form-group row">
89 89
                     <label for="wpinv_item_buy_url" class="col-sm-12 col-form-label">
90
-                        <?php _e( 'Direct Payment URL', 'invoicing' );?>
91
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'You can use this in an iFrame to embed the payment form on another website', 'invoicing' ); ?>"></span>
90
+                        <?php _e('Direct Payment URL', 'invoicing'); ?>
91
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('You can use this in an iFrame to embed the payment form on another website', 'invoicing'); ?>"></span>
92 92
                     </label>
93 93
 
94 94
                     <div class="col-sm-12">
95
-                        <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url( getpaid_embed_url( false, $item->get_id() . '|0' ) ); ?>" style="width: 100%;" readonly/>
95
+                        <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url(getpaid_embed_url(false, $item->get_id() . '|0')); ?>" style="width: 100%;" readonly/>
96 96
                     </div>
97 97
                 </div>
98 98
 
99 99
             <?php endif; ?>
100 100
 
101 101
             <div class="wpinv_item_custom_id form-group">
102
-                <?php _e( 'Custom ID', 'invoicing' );?> &mdash; <?php echo esc_html( $item->get_custom_id() ) ?>
102
+                <?php _e('Custom ID', 'invoicing'); ?> &mdash; <?php echo esc_html($item->get_custom_id()) ?>
103 103
             </div>
104 104
 
105
-            <?php do_action( 'wpinv_meta_values_metabox_before', $post ); ?>
106
-            <?php foreach ( apply_filters( 'wpinv_show_meta_values_for_keys', array() ) as $meta_key ) : ?>
105
+            <?php do_action('wpinv_meta_values_metabox_before', $post); ?>
106
+            <?php foreach (apply_filters('wpinv_show_meta_values_for_keys', array()) as $meta_key) : ?>
107 107
                 <div class="wpinv_item_custom_id form-group">
108
-                    <?php echo esc_html( $meta_key );?> &mdash; <?php echo esc_html( get_post_meta( $item->get_id(), '_wpinv_' . $meta_key, true ) ); ?>
108
+                    <?php echo esc_html($meta_key); ?> &mdash; <?php echo esc_html(get_post_meta($item->get_id(), '_wpinv_' . $meta_key, true)); ?>
109 109
                 </div>
110 110
             <?php endforeach; ?>
111
-            <?php do_action( 'wpinv_meta_values_metabox_after', $post ); ?>
112
-            <?php do_action( 'wpinv_item_info_metabox', $item ); ?>
111
+            <?php do_action('wpinv_meta_values_metabox_after', $post); ?>
112
+            <?php do_action('wpinv_item_info_metabox', $item); ?>
113 113
         </div>
114 114
         <?php
115 115
 
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
 	 * Returns item type tolltip.
120 120
 	 *
121 121
 	 */
122
-    public static function get_tooltip( $post ) {
122
+    public static function get_tooltip($post) {
123 123
 
124 124
         ob_start();
125 125
         ?>
126 126
 
127
-        <?php _e( 'Standard: Standard item type', 'invoicing' );?>
128
-        <?php _e( 'Fee: Like Registration Fee, Sign up Fee etc', 'invoicing' );?>
127
+        <?php _e('Standard: Standard item type', 'invoicing'); ?>
128
+        <?php _e('Fee: Like Registration Fee, Sign up Fee etc', 'invoicing'); ?>
129 129
 
130 130
         <?php
131
-        do_action( 'wpinv_item_info_metabox_after', $post );
131
+        do_action('wpinv_item_info_metabox_after', $post);
132 132
 
133 133
         return ob_get_clean();
134 134
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 2 patches
Indentation   +736 added lines, -736 removed lines patch added patch discarded remove patch
@@ -13,741 +13,741 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
-
30
-		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
-
36
-		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
-
44
-		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
-
49
-		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
-
53
-		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
-
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
-	}
59
-
60
-	/**
61
-	 * Post updated messages.
62
-	 */
63
-	public static function post_updated_messages( $messages ) {
64
-		global $post;
65
-
66
-		$messages['wpi_discount'] = array(
67
-			0   => '',
68
-			1   => __( 'Discount updated.', 'invoicing' ),
69
-			2   => __( 'Custom field updated.', 'invoicing' ),
70
-			3   => __( 'Custom field deleted.', 'invoicing' ),
71
-			4   => __( 'Discount updated.', 'invoicing' ),
72
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6   => __( 'Discount updated.', 'invoicing' ),
74
-			7   => __( 'Discount saved.', 'invoicing' ),
75
-			8   => __( 'Discount submitted.', 'invoicing' ),
76
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10  => __( 'Discount draft updated.', 'invoicing' ),
78
-		);
79
-
80
-		$messages['wpi_payment_form'] = array(
81
-			0   => '',
82
-			1   => __( 'Payment Form updated.', 'invoicing' ),
83
-			2   => __( 'Custom field updated.', 'invoicing' ),
84
-			3   => __( 'Custom field deleted.', 'invoicing' ),
85
-			4   => __( 'Payment Form updated.', 'invoicing' ),
86
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6   => __( 'Payment Form updated.', 'invoicing' ),
88
-			7   => __( 'Payment Form saved.', 'invoicing' ),
89
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
92
-		);
93
-
94
-		return $messages;
95
-
96
-	}
97
-
98
-	/**
99
-	 * Post row actions.
100
-	 */
101
-	public static function post_row_actions( $actions, $post ) {
102
-
103
-		$post = get_post( $post );
104
-
105
-		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
107
-
108
-			if ( $post->ID == wpinv_get_default_payment_form() ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
111
-			}
112
-
113
-			$actions['duplicate'] =  sprintf(
114
-				'<a href="%1$s">%2$s</a>',
115
-				esc_url(
116
-					wp_nonce_url(
117
-						add_query_arg(
118
-							array(
119
-								'getpaid-admin-action' => 'duplicate_form',
120
-								'form_id'              => $post->ID
121
-							)
122
-						),
123
-						'getpaid-nonce',
124
-						'getpaid-nonce'
125
-					)
126
-				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
128
-			);
129
-
130
-		}
131
-
132
-		// Link to item payment form.
133
-		if ( 'wpi_item' == $post->post_type ) {
134
-
135
-			if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
-
137
-				$actions['buy'] =  sprintf(
138
-					'<a href="%1$s">%2$s</a>',
139
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
-					esc_html( __( 'Buy', 'invoicing' ) )
141
-				);
142
-
143
-			}
144
-
145
-		}
146
-
147
-		return $actions;
148
-	}
149
-
150
-	/**
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
19
+
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
22
+
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
+
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
+
30
+        // Invoice table columns.
31
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
+        add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
+        add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
+
36
+        // Items table columns.
37
+        add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
+        add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
+        add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
+        add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
+        add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
+        add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
+
44
+        // Payment forms columns.
45
+        add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
+        add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
+
49
+        // Discount table columns.
50
+        add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
+        add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
+
53
+        // Deleting posts.
54
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
+
57
+        add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
+    }
59
+
60
+    /**
61
+     * Post updated messages.
62
+     */
63
+    public static function post_updated_messages( $messages ) {
64
+        global $post;
65
+
66
+        $messages['wpi_discount'] = array(
67
+            0   => '',
68
+            1   => __( 'Discount updated.', 'invoicing' ),
69
+            2   => __( 'Custom field updated.', 'invoicing' ),
70
+            3   => __( 'Custom field deleted.', 'invoicing' ),
71
+            4   => __( 'Discount updated.', 'invoicing' ),
72
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
+            6   => __( 'Discount updated.', 'invoicing' ),
74
+            7   => __( 'Discount saved.', 'invoicing' ),
75
+            8   => __( 'Discount submitted.', 'invoicing' ),
76
+            9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
+            10  => __( 'Discount draft updated.', 'invoicing' ),
78
+        );
79
+
80
+        $messages['wpi_payment_form'] = array(
81
+            0   => '',
82
+            1   => __( 'Payment Form updated.', 'invoicing' ),
83
+            2   => __( 'Custom field updated.', 'invoicing' ),
84
+            3   => __( 'Custom field deleted.', 'invoicing' ),
85
+            4   => __( 'Payment Form updated.', 'invoicing' ),
86
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
+            6   => __( 'Payment Form updated.', 'invoicing' ),
88
+            7   => __( 'Payment Form saved.', 'invoicing' ),
89
+            8   => __( 'Payment Form submitted.', 'invoicing' ),
90
+            9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
+            10  => __( 'Payment Form draft updated.', 'invoicing' ),
92
+        );
93
+
94
+        return $messages;
95
+
96
+    }
97
+
98
+    /**
99
+     * Post row actions.
100
+     */
101
+    public static function post_row_actions( $actions, $post ) {
102
+
103
+        $post = get_post( $post );
104
+
105
+        // We do not want to edit the default payment form.
106
+        if ( 'wpi_payment_form' == $post->post_type ) {
107
+
108
+            if ( $post->ID == wpinv_get_default_payment_form() ) {
109
+                unset( $actions['trash'] );
110
+                unset( $actions['inline hide-if-no-js'] );
111
+            }
112
+
113
+            $actions['duplicate'] =  sprintf(
114
+                '<a href="%1$s">%2$s</a>',
115
+                esc_url(
116
+                    wp_nonce_url(
117
+                        add_query_arg(
118
+                            array(
119
+                                'getpaid-admin-action' => 'duplicate_form',
120
+                                'form_id'              => $post->ID
121
+                            )
122
+                        ),
123
+                        'getpaid-nonce',
124
+                        'getpaid-nonce'
125
+                    )
126
+                ),
127
+                esc_html( __( 'Duplicate', 'invoicing' ) )
128
+            );
129
+
130
+        }
131
+
132
+        // Link to item payment form.
133
+        if ( 'wpi_item' == $post->post_type ) {
134
+
135
+            if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
+
137
+                $actions['buy'] =  sprintf(
138
+                    '<a href="%1$s">%2$s</a>',
139
+                    esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
+                    esc_html( __( 'Buy', 'invoicing' ) )
141
+                );
142
+
143
+            }
144
+
145
+        }
146
+
147
+        return $actions;
148
+    }
149
+
150
+    /**
151 151
      * Remove bulk edit option from admin side quote listing
152 152
      *
153 153
      * @since    1.0.0
154 154
      * @param array $actions post actions
155
-	 * @param WP_Post $post
155
+     * @param WP_Post $post
156 156
      * @return array $actions actions without edit option
157 157
      */
158 158
     public static function filter_invoice_row_actions( $actions, $post ) {
159 159
 
160 160
         if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
161 161
 
162
-			$actions = array();
163
-			$invoice = new WPInv_Invoice( $post );
164
-
165
-			$actions['edit'] =  sprintf(
166
-				'<a href="%1$s">%2$s</a>',
167
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
168
-				esc_html( __( 'Edit', 'invoicing' ) )
169
-			);
170
-
171
-			if ( ! $invoice->is_draft() ) {
172
-
173
-				$actions['view'] =  sprintf(
174
-					'<a href="%1$s">%2$s</a>',
175
-					esc_url( $invoice->get_view_url() ),
176
-					sprintf(
177
-						esc_html( __( 'View %s', 'invoicing' ) ),
178
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
179
-					)
180
-				);
181
-
182
-				$actions['send'] =  sprintf(
183
-					'<a href="%1$s">%2$s</a>',
184
-					esc_url(
185
-						wp_nonce_url(
186
-							add_query_arg(
187
-								array(
188
-									'getpaid-admin-action' => 'send_invoice',
189
-									'invoice_id'           => $invoice->get_id()
190
-								)
191
-							),
192
-							'getpaid-nonce',
193
-							'getpaid-nonce'
194
-						)
195
-					),
196
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
197
-				);
198
-
199
-			}
200
-
201
-			$actions['duplicate'] =  sprintf(
202
-				'<a href="%1$s">%2$s</a>',
203
-				esc_url(
204
-					wp_nonce_url(
205
-						add_query_arg(
206
-							array(
207
-								'getpaid-admin-action' => 'duplicate_invoice',
208
-								'invoice_id'           => $post->ID
209
-							)
210
-						),
211
-						'getpaid-nonce',
212
-						'getpaid-nonce'
213
-					)
214
-				),
215
-				esc_html( __( 'Duplicate', 'invoicing' ) )
216
-			);
162
+            $actions = array();
163
+            $invoice = new WPInv_Invoice( $post );
164
+
165
+            $actions['edit'] =  sprintf(
166
+                '<a href="%1$s">%2$s</a>',
167
+                esc_url( get_edit_post_link( $invoice->get_id() ) ),
168
+                esc_html( __( 'Edit', 'invoicing' ) )
169
+            );
170
+
171
+            if ( ! $invoice->is_draft() ) {
172
+
173
+                $actions['view'] =  sprintf(
174
+                    '<a href="%1$s">%2$s</a>',
175
+                    esc_url( $invoice->get_view_url() ),
176
+                    sprintf(
177
+                        esc_html( __( 'View %s', 'invoicing' ) ),
178
+                        getpaid_get_post_type_label( $invoice->get_post_type(), false )
179
+                    )
180
+                );
181
+
182
+                $actions['send'] =  sprintf(
183
+                    '<a href="%1$s">%2$s</a>',
184
+                    esc_url(
185
+                        wp_nonce_url(
186
+                            add_query_arg(
187
+                                array(
188
+                                    'getpaid-admin-action' => 'send_invoice',
189
+                                    'invoice_id'           => $invoice->get_id()
190
+                                )
191
+                            ),
192
+                            'getpaid-nonce',
193
+                            'getpaid-nonce'
194
+                        )
195
+                    ),
196
+                    esc_html( __( 'Send to Customer', 'invoicing' ) )
197
+                );
198
+
199
+            }
200
+
201
+            $actions['duplicate'] =  sprintf(
202
+                '<a href="%1$s">%2$s</a>',
203
+                esc_url(
204
+                    wp_nonce_url(
205
+                        add_query_arg(
206
+                            array(
207
+                                'getpaid-admin-action' => 'duplicate_invoice',
208
+                                'invoice_id'           => $post->ID
209
+                            )
210
+                        ),
211
+                        'getpaid-nonce',
212
+                        'getpaid-nonce'
213
+                    )
214
+                ),
215
+                esc_html( __( 'Duplicate', 'invoicing' ) )
216
+            );
217 217
 
218 218
         }
219 219
 
220 220
         return $actions;
221
-	}
222
-
223
-	/**
224
-	 * Returns an array of invoice table columns.
225
-	 */
226
-	public static function invoice_columns( $columns ) {
227
-
228
-		$columns = array(
229
-			'cb'                => $columns['cb'],
230
-			'number'            => __( 'Invoice', 'invoicing' ),
231
-			'customer'          => __( 'Customer', 'invoicing' ),
232
-			'invoice_date'      => __( 'Created', 'invoicing' ),
233
-			'payment_date'      => __( 'Completed', 'invoicing' ),
234
-			'amount'            => __( 'Amount', 'invoicing' ),
235
-			'recurring'         => __( 'Recurring', 'invoicing' ),
236
-			'status'            => __( 'Status', 'invoicing' ),
237
-		);
238
-
239
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
240
-	}
241
-
242
-	/**
243
-	 * Displays invoice table columns.
244
-	 */
245
-	public static function display_invoice_columns( $column_name, $post_id ) {
246
-
247
-		$invoice = new WPInv_Invoice( $post_id );
248
-
249
-		switch ( $column_name ) {
250
-
251
-			case 'invoice_date' :
252
-				$date_time = esc_attr( $invoice->get_created_date() );
253
-				$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
254
-				echo "<span title='$date_time'>$date</span>";
255
-				break;
256
-
257
-			case 'payment_date' :
258
-
259
-				if ( $invoice->is_paid() ) {
260
-					$date_time = esc_attr( $invoice->get_completed_date() );
261
-					$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
262
-					echo "<span title='$date_time'>$date</span>";
263
-				} else {
264
-					echo "&mdash;";
265
-				}
221
+    }
222
+
223
+    /**
224
+     * Returns an array of invoice table columns.
225
+     */
226
+    public static function invoice_columns( $columns ) {
227
+
228
+        $columns = array(
229
+            'cb'                => $columns['cb'],
230
+            'number'            => __( 'Invoice', 'invoicing' ),
231
+            'customer'          => __( 'Customer', 'invoicing' ),
232
+            'invoice_date'      => __( 'Created', 'invoicing' ),
233
+            'payment_date'      => __( 'Completed', 'invoicing' ),
234
+            'amount'            => __( 'Amount', 'invoicing' ),
235
+            'recurring'         => __( 'Recurring', 'invoicing' ),
236
+            'status'            => __( 'Status', 'invoicing' ),
237
+        );
238
+
239
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
240
+    }
241
+
242
+    /**
243
+     * Displays invoice table columns.
244
+     */
245
+    public static function display_invoice_columns( $column_name, $post_id ) {
246
+
247
+        $invoice = new WPInv_Invoice( $post_id );
248
+
249
+        switch ( $column_name ) {
250
+
251
+            case 'invoice_date' :
252
+                $date_time = esc_attr( $invoice->get_created_date() );
253
+                $date      = getpaid_format_date_value( $date_time, "&mdash;", true );
254
+                echo "<span title='$date_time'>$date</span>";
255
+                break;
256
+
257
+            case 'payment_date' :
258
+
259
+                if ( $invoice->is_paid() ) {
260
+                    $date_time = esc_attr( $invoice->get_completed_date() );
261
+                    $date      = getpaid_format_date_value( $date_time, "&mdash;", true );
262
+                    echo "<span title='$date_time'>$date</span>";
263
+                } else {
264
+                    echo "&mdash;";
265
+                }
266 266
 				
267
-				break;
267
+                break;
268 268
 
269
-			case 'amount' :
269
+            case 'amount' :
270 270
 
271
-				$amount = $invoice->get_total();
272
-				$formated_amount = wpinv_price( $amount, $invoice->get_currency() );
271
+                $amount = $invoice->get_total();
272
+                $formated_amount = wpinv_price( $amount, $invoice->get_currency() );
273 273
 
274
-				if ( $invoice->is_refunded() ) {
275
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
276
-					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
277
-				} else {
274
+                if ( $invoice->is_refunded() ) {
275
+                    $refunded_amount = wpinv_price( 0, $invoice->get_currency() );
276
+                    echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
277
+                } else {
278 278
 
279
-					$discount = $invoice->get_total_discount();
279
+                    $discount = $invoice->get_total_discount();
280 280
 
281
-					if ( ! empty( $discount ) ) {
282
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
283
-						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
284
-					} else {
285
-						echo $formated_amount;
286
-					}
281
+                    if ( ! empty( $discount ) ) {
282
+                        $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
283
+                        echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
284
+                    } else {
285
+                        echo $formated_amount;
286
+                    }
287 287
 
288
-				}
288
+                }
289 289
 
290
-				break;
290
+                break;
291 291
 
292
-			case 'status' :
293
-				$status       = esc_html( $invoice->get_status() );
294
-				$status_label = esc_html( $invoice->get_status_nicename() );
292
+            case 'status' :
293
+                $status       = esc_html( $invoice->get_status() );
294
+                $status_label = esc_html( $invoice->get_status_nicename() );
295 295
 
296
-				// If it is paid, show the gateway title.
297
-				if ( $invoice->is_paid() ) {
298
-					$gateway = esc_html( $invoice->get_gateway_title() );
299
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
296
+                // If it is paid, show the gateway title.
297
+                if ( $invoice->is_paid() ) {
298
+                    $gateway = esc_html( $invoice->get_gateway_title() );
299
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
300 300
 
301
-					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
302
-				} else {
303
-					echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
304
-				}
301
+                    echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
302
+                } else {
303
+                    echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
304
+                }
305 305
 
306
-				// If it is not paid, display the overdue and view status.
307
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
306
+                // If it is not paid, display the overdue and view status.
307
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
308 308
 
309
-					// Invoice view status.
310
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
311
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
312
-					} else {
313
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
314
-					}
309
+                    // Invoice view status.
310
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
311
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
312
+                    } else {
313
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
314
+                    }
315 315
 
316
-					// Display the overview status.
317
-					if ( wpinv_get_option( 'overdue_active' ) ) {
318
-						$due_date = $invoice->get_due_date();
319
-						$fomatted = getpaid_format_date( $due_date );
316
+                    // Display the overview status.
317
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
318
+                        $due_date = $invoice->get_due_date();
319
+                        $fomatted = getpaid_format_date( $due_date );
320 320
 
321
-						if ( ! empty( $fomatted ) ) {
322
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
323
-							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
324
-						}
325
-					}
321
+                        if ( ! empty( $fomatted ) ) {
322
+                            $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
323
+                            echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
324
+                        }
325
+                    }
326 326
 
327
-				}
327
+                }
328 328
 
329
-				break;
329
+                break;
330 330
 
331
-			case 'recurring':
331
+            case 'recurring':
332 332
 
333
-				if ( $invoice->is_recurring() ) {
334
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
335
-				} else {
336
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
337
-				}
338
-				break;
333
+                if ( $invoice->is_recurring() ) {
334
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
335
+                } else {
336
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
337
+                }
338
+                break;
339 339
 
340
-			case 'number' :
340
+            case 'number' :
341 341
 
342
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
343
-				$invoice_number  = esc_html( $invoice->get_number() );
344
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
342
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
343
+                $invoice_number  = esc_html( $invoice->get_number() );
344
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
345 345
 
346
-				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
346
+                echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
347 347
 
348
-				break;
348
+                break;
349 349
 
350
-			case 'customer' :
350
+            case 'customer' :
351 351
 	
352
-				$customer_name = $invoice->get_user_full_name();
352
+                $customer_name = $invoice->get_user_full_name();
353 353
 	
354
-				if ( empty( $customer_name ) ) {
355
-					$customer_name = $invoice->get_email();
356
-				}
354
+                if ( empty( $customer_name ) ) {
355
+                    $customer_name = $invoice->get_email();
356
+                }
357 357
 	
358
-				if ( ! empty( $customer_name ) ) {
359
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
360
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
361
-					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
362
-				} else {
363
-					echo '<div>&mdash;</div>';
364
-				}
358
+                if ( ! empty( $customer_name ) ) {
359
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
360
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
361
+                    echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
362
+                } else {
363
+                    echo '<div>&mdash;</div>';
364
+                }
365 365
 
366
-				break;
366
+                break;
367 367
 
368
-		}
368
+        }
369 369
 
370
-	}
370
+    }
371 371
 
372
-	/**
373
-	 * Displays invoice bulk actions.
374
-	 */
375
-	public static function invoice_bulk_actions( $actions ) {
376
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
377
-		return $actions;
378
-	}
372
+    /**
373
+     * Displays invoice bulk actions.
374
+     */
375
+    public static function invoice_bulk_actions( $actions ) {
376
+        $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
377
+        return $actions;
378
+    }
379 379
 
380
-	/**
381
-	 * Processes invoice bulk actions.
382
-	 */
383
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
380
+    /**
381
+     * Processes invoice bulk actions.
382
+     */
383
+    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
384 384
 
385
-		if ( $action == 'resend-invoice' ) {
385
+        if ( $action == 'resend-invoice' ) {
386 386
 
387
-			$success = false;
388
-			foreach ( $post_ids as $post_id ) {
389
-				$success = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
390
-			}
387
+            $success = false;
388
+            foreach ( $post_ids as $post_id ) {
389
+                $success = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
390
+            }
391 391
 
392
-			if ( $success ) {
393
-				getpaid_admin()->show_success( __( 'Invoices were successfully sent', 'invoicing' ) );
394
-			} else {
395
-				getpaid_admin()->show_error( __( 'Could not send some invoices', 'invoicing' ) );
396
-			}
392
+            if ( $success ) {
393
+                getpaid_admin()->show_success( __( 'Invoices were successfully sent', 'invoicing' ) );
394
+            } else {
395
+                getpaid_admin()->show_error( __( 'Could not send some invoices', 'invoicing' ) );
396
+            }
397 397
 
398
-		}
398
+        }
399 399
 
400
-		return $redirect_url;
400
+        return $redirect_url;
401 401
 
402
-	}
402
+    }
403 403
 
404
-	/**
405
-	 * Returns an array of payment forms table columns.
406
-	 */
407
-	public static function payment_form_columns( $columns ) {
404
+    /**
405
+     * Returns an array of payment forms table columns.
406
+     */
407
+    public static function payment_form_columns( $columns ) {
408 408
 
409
-		$columns = array(
410
-			'cb'                => $columns['cb'],
411
-			'title'             => __( 'Name', 'invoicing' ),
412
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
413
-			'earnings'          => __( 'Revenue', 'invoicing' ),
414
-			'refunds'           => __( 'Refunded', 'invoicing' ),
415
-			'items'             => __( 'Items', 'invoicing' ),
416
-			'date'              => __( 'Date', 'invoicing' ),
417
-		);
409
+        $columns = array(
410
+            'cb'                => $columns['cb'],
411
+            'title'             => __( 'Name', 'invoicing' ),
412
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
413
+            'earnings'          => __( 'Revenue', 'invoicing' ),
414
+            'refunds'           => __( 'Refunded', 'invoicing' ),
415
+            'items'             => __( 'Items', 'invoicing' ),
416
+            'date'              => __( 'Date', 'invoicing' ),
417
+        );
418 418
 
419
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
419
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
420 420
 
421
-	}
421
+    }
422 422
 
423
-	/**
424
-	 * Displays payment form table columns.
425
-	 */
426
-	public static function display_payment_form_columns( $column_name, $post_id ) {
423
+    /**
424
+     * Displays payment form table columns.
425
+     */
426
+    public static function display_payment_form_columns( $column_name, $post_id ) {
427 427
 
428
-		// Retrieve the payment form.
429
-		$form = new GetPaid_Payment_Form( $post_id );
428
+        // Retrieve the payment form.
429
+        $form = new GetPaid_Payment_Form( $post_id );
430 430
 
431
-		switch ( $column_name ) {
431
+        switch ( $column_name ) {
432 432
 
433
-			case 'earnings' :
434
-				echo wpinv_price( $form->get_earned() );
435
-				break;
433
+            case 'earnings' :
434
+                echo wpinv_price( $form->get_earned() );
435
+                break;
436 436
 
437
-			case 'refunds' :
438
-				echo wpinv_price( $form->get_refunded() );
439
-				break;
437
+            case 'refunds' :
438
+                echo wpinv_price( $form->get_refunded() );
439
+                break;
440 440
 
441
-			case 'refunds' :
442
-				echo wpinv_price( $form->get_refunded() );
443
-				break;
441
+            case 'refunds' :
442
+                echo wpinv_price( $form->get_refunded() );
443
+                break;
444 444
 
445
-			case 'shortcode' :
445
+            case 'shortcode' :
446 446
 
447
-				if ( $form->is_default() ) {
448
-					echo '&mdash;';
449
-				} else {
450
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
451
-				}
447
+                if ( $form->is_default() ) {
448
+                    echo '&mdash;';
449
+                } else {
450
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
451
+                }
452 452
 
453
-				break;
453
+                break;
454 454
 
455
-			case 'items' :
455
+            case 'items' :
456 456
 
457
-				$items = $form->get_items();
457
+                $items = $form->get_items();
458 458
 
459
-				if ( $form->is_default() || empty( $items ) ) {
460
-					echo '&mdash;';
461
-					return;
462
-				}
459
+                if ( $form->is_default() || empty( $items ) ) {
460
+                    echo '&mdash;';
461
+                    return;
462
+                }
463 463
 
464
-				$_items = array();
464
+                $_items = array();
465 465
 
466
-				foreach ( $items as $item ) {
467
-					$url = $item->get_edit_url();
466
+                foreach ( $items as $item ) {
467
+                    $url = $item->get_edit_url();
468 468
 
469
-					if ( empty( $url ) ) {
470
-						$_items[] = esc_html( $item->get_name() );
471
-					} else {
472
-						$_items[] = sprintf(
473
-							'<a href="%s">%s</a>',
474
-							esc_url( $url ),
475
-							esc_html( $item->get_name() )
476
-						);
477
-					}
469
+                    if ( empty( $url ) ) {
470
+                        $_items[] = esc_html( $item->get_name() );
471
+                    } else {
472
+                        $_items[] = sprintf(
473
+                            '<a href="%s">%s</a>',
474
+                            esc_url( $url ),
475
+                            esc_html( $item->get_name() )
476
+                        );
477
+                    }
478 478
 
479
-				}
479
+                }
480 480
 
481
-				echo implode( '<br>', $_items );
481
+                echo implode( '<br>', $_items );
482 482
 
483
-				break;
483
+                break;
484 484
 
485
-		}
485
+        }
486 486
 
487
-	}
487
+    }
488 488
 
489
-	/**
490
-	 * Filters post states.
491
-	 */
492
-	public static function filter_payment_form_state( $post_states, $post ) {
489
+    /**
490
+     * Filters post states.
491
+     */
492
+    public static function filter_payment_form_state( $post_states, $post ) {
493 493
 
494
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
495
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
496
-		}
494
+        if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
495
+            $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
496
+        }
497 497
 	
498
-		return $post_states;
499
-
500
-	}
501
-
502
-	/**
503
-	 * Returns an array of coupon table columns.
504
-	 */
505
-	public static function discount_columns( $columns ) {
506
-
507
-		$columns = array(
508
-			'cb'                => $columns['cb'],
509
-			'title'             => __( 'Name', 'invoicing' ),
510
-			'code'              => __( 'Code', 'invoicing' ),
511
-			'amount'            => __( 'Amount', 'invoicing' ),
512
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
513
-			'start_date'        => __( 'Start Date', 'invoicing' ),
514
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
515
-		);
516
-
517
-		return apply_filters( 'wpi_discount_table_columns', $columns );
518
-	}
519
-
520
-	/**
521
-	 * Filters post states.
522
-	 */
523
-	public static function filter_discount_state( $post_states, $post ) {
524
-
525
-		if ( 'wpi_discount' == $post->post_type ) {
526
-
527
-			$discount = new WPInv_Discount( $post );
528
-
529
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
530
-
531
-			if ( $status != 'publish' ) {
532
-				return array(
533
-					'discount_status' => wpinv_discount_status( $status ),
534
-				);
535
-			}
536
-
537
-			return array();
538
-
539
-		}
540
-
541
-		return $post_states;
542
-
543
-	}
544
-
545
-	/**
546
-	 * Returns an array of items table columns.
547
-	 */
548
-	public static function item_columns( $columns ) {
549
-
550
-		$columns = array(
551
-			'cb'                => $columns['cb'],
552
-			'title'             => __( 'Name', 'invoicing' ),
553
-			'price'             => __( 'Price', 'invoicing' ),
554
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
555
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
556
-			'type'              => __( 'Type', 'invoicing' ),
557
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
558
-		);
559
-
560
-		if ( ! wpinv_use_taxes() ) {
561
-			unset( $columns['vat_rule'] );
562
-			unset( $columns['vat_class'] );
563
-		}
564
-
565
-		return apply_filters( 'wpi_item_table_columns', $columns );
566
-	}
567
-
568
-	/**
569
-	 * Returns an array of sortable items table columns.
570
-	 */
571
-	public static function sortable_item_columns( $columns ) {
572
-
573
-		return array_merge(
574
-			$columns,
575
-			array(
576
-				'price'     => 'price',
577
-				'vat_rule'  => 'vat_rule',
578
-				'vat_class' => 'vat_class',
579
-				'type'      => 'type',
580
-			)
581
-		);
582
-
583
-	}
584
-
585
-	/**
586
-	 * Displays items table columns.
587
-	 */
588
-	public static function display_item_columns( $column_name, $post_id ) {
498
+        return $post_states;
499
+
500
+    }
501
+
502
+    /**
503
+     * Returns an array of coupon table columns.
504
+     */
505
+    public static function discount_columns( $columns ) {
506
+
507
+        $columns = array(
508
+            'cb'                => $columns['cb'],
509
+            'title'             => __( 'Name', 'invoicing' ),
510
+            'code'              => __( 'Code', 'invoicing' ),
511
+            'amount'            => __( 'Amount', 'invoicing' ),
512
+            'usage'             => __( 'Usage / Limit', 'invoicing' ),
513
+            'start_date'        => __( 'Start Date', 'invoicing' ),
514
+            'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
515
+        );
516
+
517
+        return apply_filters( 'wpi_discount_table_columns', $columns );
518
+    }
519
+
520
+    /**
521
+     * Filters post states.
522
+     */
523
+    public static function filter_discount_state( $post_states, $post ) {
524
+
525
+        if ( 'wpi_discount' == $post->post_type ) {
526
+
527
+            $discount = new WPInv_Discount( $post );
528
+
529
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
530
+
531
+            if ( $status != 'publish' ) {
532
+                return array(
533
+                    'discount_status' => wpinv_discount_status( $status ),
534
+                );
535
+            }
536
+
537
+            return array();
538
+
539
+        }
540
+
541
+        return $post_states;
542
+
543
+    }
544
+
545
+    /**
546
+     * Returns an array of items table columns.
547
+     */
548
+    public static function item_columns( $columns ) {
549
+
550
+        $columns = array(
551
+            'cb'                => $columns['cb'],
552
+            'title'             => __( 'Name', 'invoicing' ),
553
+            'price'             => __( 'Price', 'invoicing' ),
554
+            'vat_rule'          => __( 'VAT rule', 'invoicing' ),
555
+            'vat_class'         => __( 'VAT class', 'invoicing' ),
556
+            'type'              => __( 'Type', 'invoicing' ),
557
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
558
+        );
559
+
560
+        if ( ! wpinv_use_taxes() ) {
561
+            unset( $columns['vat_rule'] );
562
+            unset( $columns['vat_class'] );
563
+        }
564
+
565
+        return apply_filters( 'wpi_item_table_columns', $columns );
566
+    }
567
+
568
+    /**
569
+     * Returns an array of sortable items table columns.
570
+     */
571
+    public static function sortable_item_columns( $columns ) {
572
+
573
+        return array_merge(
574
+            $columns,
575
+            array(
576
+                'price'     => 'price',
577
+                'vat_rule'  => 'vat_rule',
578
+                'vat_class' => 'vat_class',
579
+                'type'      => 'type',
580
+            )
581
+        );
582
+
583
+    }
584
+
585
+    /**
586
+     * Displays items table columns.
587
+     */
588
+    public static function display_item_columns( $column_name, $post_id ) {
589 589
  
590
-		$item = new WPInv_Item( $post_id );
590
+        $item = new WPInv_Item( $post_id );
591 591
 
592
-		switch ( $column_name ) {
592
+        switch ( $column_name ) {
593 593
 
594
-			case 'price' :
594
+            case 'price' :
595 595
 
596
-				if ( ! $item->is_recurring() ) {
597
-					echo $item->get_the_price();
598
-					break;
599
-				}
596
+                if ( ! $item->is_recurring() ) {
597
+                    echo $item->get_the_price();
598
+                    break;
599
+                }
600 600
 
601
-				$price = wp_sprintf(
602
-					__( '%s / %s', 'invoicing' ),
603
-					$item->get_the_price(),
604
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
605
-				);
601
+                $price = wp_sprintf(
602
+                    __( '%s / %s', 'invoicing' ),
603
+                    $item->get_the_price(),
604
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
605
+                );
606 606
 
607
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
608
-					echo $price;
609
-					break;
610
-				}
607
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
608
+                    echo $price;
609
+                    break;
610
+                }
611 611
 
612
-				echo $item->get_the_initial_price();
612
+                echo $item->get_the_initial_price();
613 613
 
614
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
615
-				break;
614
+                echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
615
+                break;
616 616
 
617
-			case 'vat_rule' :
618
-				echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
619
-				break;
617
+            case 'vat_rule' :
618
+                echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
619
+                break;
620 620
 
621
-			case 'vat_class' :
622
-				echo getpaid_get_tax_class_label( $item->get_vat_class() );
623
-				break;
621
+            case 'vat_class' :
622
+                echo getpaid_get_tax_class_label( $item->get_vat_class() );
623
+                break;
624 624
 
625
-			case 'shortcode' :
625
+            case 'shortcode' :
626 626
 
627
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
628
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
629
-				} else {
630
-					echo "&mdash;";
631
-				}
627
+                if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
628
+                    echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
629
+                } else {
630
+                    echo "&mdash;";
631
+                }
632 632
 				
633
-				break;
633
+                break;
634 634
 
635
-			case 'type' :
636
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
637
-				break;
635
+            case 'type' :
636
+                echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
637
+                break;
638 638
 
639
-		}
639
+        }
640 640
 
641
-	}
641
+    }
642 642
 
643
-	/**
644
-	 * Lets users filter items using taxes.
645
-	 */
646
-	public static function add_item_filters( $post_type ) {
643
+    /**
644
+     * Lets users filter items using taxes.
645
+     */
646
+    public static function add_item_filters( $post_type ) {
647 647
 
648
-		// Abort if we're not dealing with items.
649
-		if ( $post_type != 'wpi_item' ) {
650
-			return;
651
-		}
648
+        // Abort if we're not dealing with items.
649
+        if ( $post_type != 'wpi_item' ) {
650
+            return;
651
+        }
652 652
 
653
-		// Filter by vat rules.
654
-		if ( wpinv_use_taxes() ) {
653
+        // Filter by vat rules.
654
+        if ( wpinv_use_taxes() ) {
655 655
 	
656
-			// Sanitize selected vat rule.
657
-			$vat_rule   = '';
658
-			$vat_rules  = getpaid_get_tax_rules();
659
-			if ( isset( $_GET['vat_rule'] ) ) {
660
-				$vat_rule   =  $_GET['vat_rule'];
661
-			}
662
-
663
-			// Filter by VAT rule.
664
-			echo wpinv_html_select(
665
-				array(
666
-					'options'          => array_merge(
667
-						array(
668
-							'' => __( 'All VAT rules', 'invoicing' )
669
-						),
670
-						$vat_rules
671
-					),
672
-					'name'             => 'vat_rule',
673
-					'id'               => 'vat_rule',
674
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
675
-					'show_option_all'  => false,
676
-					'show_option_none' => false,
677
-				)
678
-			);
679
-
680
-			// Filter by VAT class.
656
+            // Sanitize selected vat rule.
657
+            $vat_rule   = '';
658
+            $vat_rules  = getpaid_get_tax_rules();
659
+            if ( isset( $_GET['vat_rule'] ) ) {
660
+                $vat_rule   =  $_GET['vat_rule'];
661
+            }
662
+
663
+            // Filter by VAT rule.
664
+            echo wpinv_html_select(
665
+                array(
666
+                    'options'          => array_merge(
667
+                        array(
668
+                            '' => __( 'All VAT rules', 'invoicing' )
669
+                        ),
670
+                        $vat_rules
671
+                    ),
672
+                    'name'             => 'vat_rule',
673
+                    'id'               => 'vat_rule',
674
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
675
+                    'show_option_all'  => false,
676
+                    'show_option_none' => false,
677
+                )
678
+            );
679
+
680
+            // Filter by VAT class.
681 681
 	
682
-			// Sanitize selected vat rule.
683
-			$vat_class   = '';
684
-			$vat_classes = getpaid_get_tax_classes();
685
-			if ( isset( $_GET['vat_class'] ) ) {
686
-				$vat_class   =  $_GET['vat_class'];
687
-			}
688
-
689
-			echo wpinv_html_select(
690
-				array(
691
-					'options'          => array_merge(
692
-						array(
693
-							'' => __( 'All VAT classes', 'invoicing' )
694
-						),
695
-						$vat_classes
696
-					),
697
-					'name'             => 'vat_class',
698
-					'id'               => 'vat_class',
699
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
700
-					'show_option_all'  => false,
701
-					'show_option_none' => false,
702
-				)
703
-			);
704
-
705
-		}
706
-
707
-		// Filter by item type.
708
-		$type   = '';
709
-		if ( isset( $_GET['type'] ) ) {
710
-			$type   =  $_GET['type'];
711
-		}
712
-
713
-		echo wpinv_html_select(
714
-			array(
715
-				'options'          => array_merge(
716
-					array(
717
-						'' => __( 'All item types', 'invoicing' )
718
-					),
719
-					wpinv_get_item_types()
720
-				),
721
-				'name'             => 'type',
722
-				'id'               => 'type',
723
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
724
-				'show_option_all'  => false,
725
-				'show_option_none' => false,
726
-			)
727
-		);
728
-
729
-	}
730
-
731
-	/**
732
-	 * Filters the item query.
733
-	 */
734
-	public static function filter_item_query( $query ) {
735
-
736
-		// modify the query only if it admin and main query.
737
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
738
-			return $query;
739
-		}
740
-
741
-		// we want to modify the query for our items.
742
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
743
-			return $query;
744
-		}
745
-
746
-		if ( empty( $query->query_vars['meta_query'] ) ) {
747
-			$query->query_vars['meta_query'] = array();
748
-		}
749
-
750
-		// Filter vat rule type
682
+            // Sanitize selected vat rule.
683
+            $vat_class   = '';
684
+            $vat_classes = getpaid_get_tax_classes();
685
+            if ( isset( $_GET['vat_class'] ) ) {
686
+                $vat_class   =  $_GET['vat_class'];
687
+            }
688
+
689
+            echo wpinv_html_select(
690
+                array(
691
+                    'options'          => array_merge(
692
+                        array(
693
+                            '' => __( 'All VAT classes', 'invoicing' )
694
+                        ),
695
+                        $vat_classes
696
+                    ),
697
+                    'name'             => 'vat_class',
698
+                    'id'               => 'vat_class',
699
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
700
+                    'show_option_all'  => false,
701
+                    'show_option_none' => false,
702
+                )
703
+            );
704
+
705
+        }
706
+
707
+        // Filter by item type.
708
+        $type   = '';
709
+        if ( isset( $_GET['type'] ) ) {
710
+            $type   =  $_GET['type'];
711
+        }
712
+
713
+        echo wpinv_html_select(
714
+            array(
715
+                'options'          => array_merge(
716
+                    array(
717
+                        '' => __( 'All item types', 'invoicing' )
718
+                    ),
719
+                    wpinv_get_item_types()
720
+                ),
721
+                'name'             => 'type',
722
+                'id'               => 'type',
723
+                'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
724
+                'show_option_all'  => false,
725
+                'show_option_none' => false,
726
+            )
727
+        );
728
+
729
+    }
730
+
731
+    /**
732
+     * Filters the item query.
733
+     */
734
+    public static function filter_item_query( $query ) {
735
+
736
+        // modify the query only if it admin and main query.
737
+        if ( ! ( is_admin() && $query->is_main_query() ) ){ 
738
+            return $query;
739
+        }
740
+
741
+        // we want to modify the query for our items.
742
+        if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
743
+            return $query;
744
+        }
745
+
746
+        if ( empty( $query->query_vars['meta_query'] ) ) {
747
+            $query->query_vars['meta_query'] = array();
748
+        }
749
+
750
+        // Filter vat rule type
751 751
         if ( ! empty( $_GET['vat_rule'] ) ) {
752 752
             $query->query_vars['meta_query'][] = array(
753 753
                 'key'     => '_wpinv_vat_rule',
@@ -772,97 +772,97 @@  discard block
 block discarded – undo
772 772
                 'value'   => sanitize_text_field( $_GET['type'] ),
773 773
                 'compare' => '='
774 774
             );
775
-		}
776
-
777
-	}
778
-
779
-	/**
780
-	 * Reorders items.
781
-	 */
782
-	public static function reorder_items( $vars ) {
783
-		global $typenow;
784
-
785
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
786
-			return $vars;
787
-		}
788
-
789
-		// By item type.
790
-		if ( 'type' == $vars['orderby'] ) {
791
-			return array_merge(
792
-				$vars,
793
-				array(
794
-					'meta_key' => '_wpinv_type',
795
-					'orderby'  => 'meta_value'
796
-				)
797
-			);
798
-		}
799
-
800
-		// By vat class.
801
-		if ( 'vat_class' == $vars['orderby'] ) {
802
-			return array_merge(
803
-				$vars,
804
-				array(
805
-					'meta_key' => '_wpinv_vat_class',
806
-					'orderby'  => 'meta_value'
807
-				)
808
-			);
809
-		}
810
-
811
-		// By vat rule.
812
-		if ( 'vat_rule' == $vars['orderby'] ) {
813
-			return array_merge(
814
-				$vars,
815
-				array(
816
-					'meta_key' => '_wpinv_vat_rule',
817
-					'orderby'  => 'meta_value'
818
-				)
819
-			);
820
-		}
821
-
822
-		// By price.
823
-		if ( 'price' == $vars['orderby'] ) {
824
-			return array_merge(
825
-				$vars,
826
-				array(
827
-					'meta_key' => '_wpinv_price',
828
-					'orderby'  => 'meta_value_num'
829
-				)
830
-			);
831
-		}
832
-
833
-		return $vars;
834
-
835
-	}
836
-
837
-	/**
838
-	 * Fired when deleting a post.
839
-	 */
840
-	public static function delete_post( $post_id ) {
841
-
842
-		switch ( get_post_type( $post_id ) ) {
843
-
844
-			case 'wpi_item' :
845
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
846
-				break;
847
-
848
-			case 'wpi_payment_form' :
849
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
850
-				break;
851
-
852
-			case 'wpi_discount' :
853
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
854
-				break;
855
-
856
-			case 'wpi_invoice' :
857
-				$invoice = new WPInv_Invoice( $post_id );
858
-				do_action( "getpaid_before_delete_invoice", $invoice );
859
-				$invoice->get_data_store()->delete_items( $invoice );
860
-				$invoice->get_data_store()->delete_special_fields( $invoice );
861
-				break;
862
-		}
863
-	}
864
-
865
-	/**
775
+        }
776
+
777
+    }
778
+
779
+    /**
780
+     * Reorders items.
781
+     */
782
+    public static function reorder_items( $vars ) {
783
+        global $typenow;
784
+
785
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
786
+            return $vars;
787
+        }
788
+
789
+        // By item type.
790
+        if ( 'type' == $vars['orderby'] ) {
791
+            return array_merge(
792
+                $vars,
793
+                array(
794
+                    'meta_key' => '_wpinv_type',
795
+                    'orderby'  => 'meta_value'
796
+                )
797
+            );
798
+        }
799
+
800
+        // By vat class.
801
+        if ( 'vat_class' == $vars['orderby'] ) {
802
+            return array_merge(
803
+                $vars,
804
+                array(
805
+                    'meta_key' => '_wpinv_vat_class',
806
+                    'orderby'  => 'meta_value'
807
+                )
808
+            );
809
+        }
810
+
811
+        // By vat rule.
812
+        if ( 'vat_rule' == $vars['orderby'] ) {
813
+            return array_merge(
814
+                $vars,
815
+                array(
816
+                    'meta_key' => '_wpinv_vat_rule',
817
+                    'orderby'  => 'meta_value'
818
+                )
819
+            );
820
+        }
821
+
822
+        // By price.
823
+        if ( 'price' == $vars['orderby'] ) {
824
+            return array_merge(
825
+                $vars,
826
+                array(
827
+                    'meta_key' => '_wpinv_price',
828
+                    'orderby'  => 'meta_value_num'
829
+                )
830
+            );
831
+        }
832
+
833
+        return $vars;
834
+
835
+    }
836
+
837
+    /**
838
+     * Fired when deleting a post.
839
+     */
840
+    public static function delete_post( $post_id ) {
841
+
842
+        switch ( get_post_type( $post_id ) ) {
843
+
844
+            case 'wpi_item' :
845
+                do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
846
+                break;
847
+
848
+            case 'wpi_payment_form' :
849
+                do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
850
+                break;
851
+
852
+            case 'wpi_discount' :
853
+                do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
854
+                break;
855
+
856
+            case 'wpi_invoice' :
857
+                $invoice = new WPInv_Invoice( $post_id );
858
+                do_action( "getpaid_before_delete_invoice", $invoice );
859
+                $invoice->get_data_store()->delete_items( $invoice );
860
+                $invoice->get_data_store()->delete_special_fields( $invoice );
861
+                break;
862
+        }
863
+    }
864
+
865
+    /**
866 866
      * Add a post display state for special GetPaid pages in the page list table.
867 867
      *
868 868
      * @param array   $post_states An array of post display states.
@@ -876,22 +876,22 @@  discard block
 block discarded – undo
876 876
             $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
877 877
         }
878 878
 
879
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
879
+        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
880 880
 
881
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
882
-				$post_states["getpaid_{$post_type}_history_page"] = sprintf(
883
-					__( 'GetPaid %s History Page', 'invoicing' ),
884
-					$label
885
-				);
886
-			}
881
+            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
882
+                $post_states["getpaid_{$post_type}_history_page"] = sprintf(
883
+                    __( 'GetPaid %s History Page', 'invoicing' ),
884
+                    $label
885
+                );
886
+            }
887 887
 
888
-		}
888
+        }
889 889
 		
890
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
890
+        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
891 891
             $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
892 892
         }
893 893
 
894
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
894
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
895 895
             $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
896 896
         }
897 897
 
Please login to merge, or discard this patch.
Spacing   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Post types Admin Class
@@ -21,74 +21,74 @@  discard block
 block discarded – undo
21 21
 		GetPaid_Metaboxes::init();
22 22
 
23 23
 		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
24
+		add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages');
25 25
 
26 26
 		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
27
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2);
28
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2);
29 29
 
30 30
 		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
31
+		add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100);
32
+		add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2);
33
+		add_filter('bulk_actions-edit-wpi_invoice', array(__CLASS__, 'invoice_bulk_actions'));
34
+		add_filter('handle_bulk_actions-edit-wpi_invoice', array(__CLASS__, 'handle_invoice_bulk_actions'), 10, 3);
35 35
 
36 36
 		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
37
+		add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100);
38
+		add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20);
39
+		add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2);
40
+		add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100);
41
+		add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100);
42
+		add_action('request', array(__CLASS__, 'reorder_items'), 100);
43 43
 
44 44
 		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
45
+		add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100);
46
+		add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2);
47
+		add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2);
48 48
 
49 49
 		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
50
+		add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100);
51
+		add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100);
52 52
 
53 53
 		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
54
+		add_action('delete_post', array(__CLASS__, 'delete_post'));
55
+		add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2);
56 56
 
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
57
+		add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2);
58 58
 	}
59 59
 
60 60
 	/**
61 61
 	 * Post updated messages.
62 62
 	 */
63
-	public static function post_updated_messages( $messages ) {
63
+	public static function post_updated_messages($messages) {
64 64
 		global $post;
65 65
 
66 66
 		$messages['wpi_discount'] = array(
67 67
 			0   => '',
68
-			1   => __( 'Discount updated.', 'invoicing' ),
69
-			2   => __( 'Custom field updated.', 'invoicing' ),
70
-			3   => __( 'Custom field deleted.', 'invoicing' ),
71
-			4   => __( 'Discount updated.', 'invoicing' ),
72
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6   => __( 'Discount updated.', 'invoicing' ),
74
-			7   => __( 'Discount saved.', 'invoicing' ),
75
-			8   => __( 'Discount submitted.', 'invoicing' ),
76
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10  => __( 'Discount draft updated.', 'invoicing' ),
68
+			1   => __('Discount updated.', 'invoicing'),
69
+			2   => __('Custom field updated.', 'invoicing'),
70
+			3   => __('Custom field deleted.', 'invoicing'),
71
+			4   => __('Discount updated.', 'invoicing'),
72
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
73
+			6   => __('Discount updated.', 'invoicing'),
74
+			7   => __('Discount saved.', 'invoicing'),
75
+			8   => __('Discount submitted.', 'invoicing'),
76
+			9   => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
77
+			10  => __('Discount draft updated.', 'invoicing'),
78 78
 		);
79 79
 
80 80
 		$messages['wpi_payment_form'] = array(
81 81
 			0   => '',
82
-			1   => __( 'Payment Form updated.', 'invoicing' ),
83
-			2   => __( 'Custom field updated.', 'invoicing' ),
84
-			3   => __( 'Custom field deleted.', 'invoicing' ),
85
-			4   => __( 'Payment Form updated.', 'invoicing' ),
86
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6   => __( 'Payment Form updated.', 'invoicing' ),
88
-			7   => __( 'Payment Form saved.', 'invoicing' ),
89
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
82
+			1   => __('Payment Form updated.', 'invoicing'),
83
+			2   => __('Custom field updated.', 'invoicing'),
84
+			3   => __('Custom field deleted.', 'invoicing'),
85
+			4   => __('Payment Form updated.', 'invoicing'),
86
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
87
+			6   => __('Payment Form updated.', 'invoicing'),
88
+			7   => __('Payment Form saved.', 'invoicing'),
89
+			8   => __('Payment Form submitted.', 'invoicing'),
90
+			9   => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
91
+			10  => __('Payment Form draft updated.', 'invoicing'),
92 92
 		);
93 93
 
94 94
 		return $messages;
@@ -98,19 +98,19 @@  discard block
 block discarded – undo
98 98
 	/**
99 99
 	 * Post row actions.
100 100
 	 */
101
-	public static function post_row_actions( $actions, $post ) {
101
+	public static function post_row_actions($actions, $post) {
102 102
 
103
-		$post = get_post( $post );
103
+		$post = get_post($post);
104 104
 
105 105
 		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
106
+		if ('wpi_payment_form' == $post->post_type) {
107 107
 
108
-			if ( $post->ID == wpinv_get_default_payment_form() ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
108
+			if ($post->ID == wpinv_get_default_payment_form()) {
109
+				unset($actions['trash']);
110
+				unset($actions['inline hide-if-no-js']);
111 111
 			}
112 112
 
113
-			$actions['duplicate'] =  sprintf(
113
+			$actions['duplicate'] = sprintf(
114 114
 				'<a href="%1$s">%2$s</a>',
115 115
 				esc_url(
116 116
 					wp_nonce_url(
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
 						'getpaid-nonce'
125 125
 					)
126 126
 				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
127
+				esc_html(__('Duplicate', 'invoicing'))
128 128
 			);
129 129
 
130 130
 		}
131 131
 
132 132
 		// Link to item payment form.
133
-		if ( 'wpi_item' == $post->post_type ) {
133
+		if ('wpi_item' == $post->post_type) {
134 134
 
135
-			if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
135
+			if (in_array(get_post_meta($post->ID, '_wpinv_type', true), array('', 'fee', 'custom'))) {
136 136
 
137
-				$actions['buy'] =  sprintf(
137
+				$actions['buy'] = sprintf(
138 138
 					'<a href="%1$s">%2$s</a>',
139
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
-					esc_html( __( 'Buy', 'invoicing' ) )
139
+					esc_url(getpaid_embed_url(false, $post->ID . '|0')),
140
+					esc_html(__('Buy', 'invoicing'))
141 141
 				);
142 142
 
143 143
 			}
@@ -155,31 +155,31 @@  discard block
 block discarded – undo
155 155
 	 * @param WP_Post $post
156 156
      * @return array $actions actions without edit option
157 157
      */
158
-    public static function filter_invoice_row_actions( $actions, $post ) {
158
+    public static function filter_invoice_row_actions($actions, $post) {
159 159
 
160
-        if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
160
+        if (getpaid_is_invoice_post_type($post->post_type)) {
161 161
 
162 162
 			$actions = array();
163
-			$invoice = new WPInv_Invoice( $post );
163
+			$invoice = new WPInv_Invoice($post);
164 164
 
165
-			$actions['edit'] =  sprintf(
165
+			$actions['edit'] = sprintf(
166 166
 				'<a href="%1$s">%2$s</a>',
167
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
168
-				esc_html( __( 'Edit', 'invoicing' ) )
167
+				esc_url(get_edit_post_link($invoice->get_id())),
168
+				esc_html(__('Edit', 'invoicing'))
169 169
 			);
170 170
 
171
-			if ( ! $invoice->is_draft() ) {
171
+			if (!$invoice->is_draft()) {
172 172
 
173
-				$actions['view'] =  sprintf(
173
+				$actions['view'] = sprintf(
174 174
 					'<a href="%1$s">%2$s</a>',
175
-					esc_url( $invoice->get_view_url() ),
175
+					esc_url($invoice->get_view_url()),
176 176
 					sprintf(
177
-						esc_html( __( 'View %s', 'invoicing' ) ),
178
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
177
+						esc_html(__('View %s', 'invoicing')),
178
+						getpaid_get_post_type_label($invoice->get_post_type(), false)
179 179
 					)
180 180
 				);
181 181
 
182
-				$actions['send'] =  sprintf(
182
+				$actions['send'] = sprintf(
183 183
 					'<a href="%1$s">%2$s</a>',
184 184
 					esc_url(
185 185
 						wp_nonce_url(
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 							'getpaid-nonce'
194 194
 						)
195 195
 					),
196
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
196
+					esc_html(__('Send to Customer', 'invoicing'))
197 197
 				);
198 198
 
199 199
 			}
200 200
 
201
-			$actions['duplicate'] =  sprintf(
201
+			$actions['duplicate'] = sprintf(
202 202
 				'<a href="%1$s">%2$s</a>',
203 203
 				esc_url(
204 204
 					wp_nonce_url(
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 						'getpaid-nonce'
213 213
 					)
214 214
 				),
215
-				esc_html( __( 'Duplicate', 'invoicing' ) )
215
+				esc_html(__('Duplicate', 'invoicing'))
216 216
 			);
217 217
 
218 218
         }
@@ -223,42 +223,42 @@  discard block
 block discarded – undo
223 223
 	/**
224 224
 	 * Returns an array of invoice table columns.
225 225
 	 */
226
-	public static function invoice_columns( $columns ) {
226
+	public static function invoice_columns($columns) {
227 227
 
228 228
 		$columns = array(
229 229
 			'cb'                => $columns['cb'],
230
-			'number'            => __( 'Invoice', 'invoicing' ),
231
-			'customer'          => __( 'Customer', 'invoicing' ),
232
-			'invoice_date'      => __( 'Created', 'invoicing' ),
233
-			'payment_date'      => __( 'Completed', 'invoicing' ),
234
-			'amount'            => __( 'Amount', 'invoicing' ),
235
-			'recurring'         => __( 'Recurring', 'invoicing' ),
236
-			'status'            => __( 'Status', 'invoicing' ),
230
+			'number'            => __('Invoice', 'invoicing'),
231
+			'customer'          => __('Customer', 'invoicing'),
232
+			'invoice_date'      => __('Created', 'invoicing'),
233
+			'payment_date'      => __('Completed', 'invoicing'),
234
+			'amount'            => __('Amount', 'invoicing'),
235
+			'recurring'         => __('Recurring', 'invoicing'),
236
+			'status'            => __('Status', 'invoicing'),
237 237
 		);
238 238
 
239
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
239
+		return apply_filters('wpi_invoice_table_columns', $columns);
240 240
 	}
241 241
 
242 242
 	/**
243 243
 	 * Displays invoice table columns.
244 244
 	 */
245
-	public static function display_invoice_columns( $column_name, $post_id ) {
245
+	public static function display_invoice_columns($column_name, $post_id) {
246 246
 
247
-		$invoice = new WPInv_Invoice( $post_id );
247
+		$invoice = new WPInv_Invoice($post_id);
248 248
 
249
-		switch ( $column_name ) {
249
+		switch ($column_name) {
250 250
 
251 251
 			case 'invoice_date' :
252
-				$date_time = esc_attr( $invoice->get_created_date() );
253
-				$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
252
+				$date_time = esc_attr($invoice->get_created_date());
253
+				$date      = getpaid_format_date_value($date_time, "&mdash;", true);
254 254
 				echo "<span title='$date_time'>$date</span>";
255 255
 				break;
256 256
 
257 257
 			case 'payment_date' :
258 258
 
259
-				if ( $invoice->is_paid() ) {
260
-					$date_time = esc_attr( $invoice->get_completed_date() );
261
-					$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
259
+				if ($invoice->is_paid()) {
260
+					$date_time = esc_attr($invoice->get_completed_date());
261
+					$date      = getpaid_format_date_value($date_time, "&mdash;", true);
262 262
 					echo "<span title='$date_time'>$date</span>";
263 263
 				} else {
264 264
 					echo "&mdash;";
@@ -269,17 +269,17 @@  discard block
 block discarded – undo
269 269
 			case 'amount' :
270 270
 
271 271
 				$amount = $invoice->get_total();
272
-				$formated_amount = wpinv_price( $amount, $invoice->get_currency() );
272
+				$formated_amount = wpinv_price($amount, $invoice->get_currency());
273 273
 
274
-				if ( $invoice->is_refunded() ) {
275
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
274
+				if ($invoice->is_refunded()) {
275
+					$refunded_amount = wpinv_price(0, $invoice->get_currency());
276 276
 					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
277 277
 				} else {
278 278
 
279 279
 					$discount = $invoice->get_total_discount();
280 280
 
281
-					if ( ! empty( $discount ) ) {
282
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
281
+					if (!empty($discount)) {
282
+						$new_amount = wpinv_price($amount + $discount, $invoice->get_currency());
283 283
 						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
284 284
 					} else {
285 285
 						echo $formated_amount;
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
 				break;
291 291
 
292 292
 			case 'status' :
293
-				$status       = esc_html( $invoice->get_status() );
294
-				$status_label = esc_html( $invoice->get_status_nicename() );
293
+				$status       = esc_html($invoice->get_status());
294
+				$status_label = esc_html($invoice->get_status_nicename());
295 295
 
296 296
 				// If it is paid, show the gateway title.
297
-				if ( $invoice->is_paid() ) {
298
-					$gateway = esc_html( $invoice->get_gateway_title() );
299
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
297
+				if ($invoice->is_paid()) {
298
+					$gateway = esc_html($invoice->get_gateway_title());
299
+					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway);
300 300
 
301 301
 					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
302 302
 				} else {
@@ -304,22 +304,22 @@  discard block
 block discarded – undo
304 304
 				}
305 305
 
306 306
 				// If it is not paid, display the overdue and view status.
307
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
307
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
308 308
 
309 309
 					// Invoice view status.
310
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
311
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
310
+					if (wpinv_is_invoice_viewed($invoice->get_id())) {
311
+						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>';
312 312
 					} else {
313
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
313
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
314 314
 					}
315 315
 
316 316
 					// Display the overview status.
317
-					if ( wpinv_get_option( 'overdue_active' ) ) {
317
+					if (wpinv_get_option('overdue_active')) {
318 318
 						$due_date = $invoice->get_due_date();
319
-						$fomatted = getpaid_format_date( $due_date );
319
+						$fomatted = getpaid_format_date($due_date);
320 320
 
321
-						if ( ! empty( $fomatted ) ) {
322
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
321
+						if (!empty($fomatted)) {
322
+							$date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted);
323 323
 							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
324 324
 						}
325 325
 					}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 
331 331
 			case 'recurring':
332 332
 
333
-				if ( $invoice->is_recurring() ) {
333
+				if ($invoice->is_recurring()) {
334 334
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
335 335
 				} else {
336 336
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
 
340 340
 			case 'number' :
341 341
 
342
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
343
-				$invoice_number  = esc_html( $invoice->get_number() );
344
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
342
+				$edit_link       = esc_url(get_edit_post_link($invoice->get_id()));
343
+				$invoice_number  = esc_html($invoice->get_number());
344
+				$invoice_details = esc_attr__('View Invoice Details', 'invoicing');
345 345
 
346 346
 				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
347 347
 
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
 	
352 352
 				$customer_name = $invoice->get_user_full_name();
353 353
 	
354
-				if ( empty( $customer_name ) ) {
354
+				if (empty($customer_name)) {
355 355
 					$customer_name = $invoice->get_email();
356 356
 				}
357 357
 	
358
-				if ( ! empty( $customer_name ) ) {
359
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
360
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
358
+				if (!empty($customer_name)) {
359
+					$customer_details = esc_attr__('View Customer Details', 'invoicing');
360
+					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php')));
361 361
 					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
362 362
 				} else {
363 363
 					echo '<div>&mdash;</div>';
@@ -372,27 +372,27 @@  discard block
 block discarded – undo
372 372
 	/**
373 373
 	 * Displays invoice bulk actions.
374 374
 	 */
375
-	public static function invoice_bulk_actions( $actions ) {
376
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
375
+	public static function invoice_bulk_actions($actions) {
376
+		$actions['resend-invoice'] = __('Send to Customer', 'invoicing');
377 377
 		return $actions;
378 378
 	}
379 379
 
380 380
 	/**
381 381
 	 * Processes invoice bulk actions.
382 382
 	 */
383
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
383
+	public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) {
384 384
 
385
-		if ( $action == 'resend-invoice' ) {
385
+		if ($action == 'resend-invoice') {
386 386
 
387 387
 			$success = false;
388
-			foreach ( $post_ids as $post_id ) {
389
-				$success = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
388
+			foreach ($post_ids as $post_id) {
389
+				$success = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true);
390 390
 			}
391 391
 
392
-			if ( $success ) {
393
-				getpaid_admin()->show_success( __( 'Invoices were successfully sent', 'invoicing' ) );
392
+			if ($success) {
393
+				getpaid_admin()->show_success(__('Invoices were successfully sent', 'invoicing'));
394 394
 			} else {
395
-				getpaid_admin()->show_error( __( 'Could not send some invoices', 'invoicing' ) );
395
+				getpaid_admin()->show_error(__('Could not send some invoices', 'invoicing'));
396 396
 			}
397 397
 
398 398
 		}
@@ -404,50 +404,50 @@  discard block
 block discarded – undo
404 404
 	/**
405 405
 	 * Returns an array of payment forms table columns.
406 406
 	 */
407
-	public static function payment_form_columns( $columns ) {
407
+	public static function payment_form_columns($columns) {
408 408
 
409 409
 		$columns = array(
410 410
 			'cb'                => $columns['cb'],
411
-			'title'             => __( 'Name', 'invoicing' ),
412
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
413
-			'earnings'          => __( 'Revenue', 'invoicing' ),
414
-			'refunds'           => __( 'Refunded', 'invoicing' ),
415
-			'items'             => __( 'Items', 'invoicing' ),
416
-			'date'              => __( 'Date', 'invoicing' ),
411
+			'title'             => __('Name', 'invoicing'),
412
+			'shortcode'         => __('Shortcode', 'invoicing'),
413
+			'earnings'          => __('Revenue', 'invoicing'),
414
+			'refunds'           => __('Refunded', 'invoicing'),
415
+			'items'             => __('Items', 'invoicing'),
416
+			'date'              => __('Date', 'invoicing'),
417 417
 		);
418 418
 
419
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
419
+		return apply_filters('wpi_payment_form_table_columns', $columns);
420 420
 
421 421
 	}
422 422
 
423 423
 	/**
424 424
 	 * Displays payment form table columns.
425 425
 	 */
426
-	public static function display_payment_form_columns( $column_name, $post_id ) {
426
+	public static function display_payment_form_columns($column_name, $post_id) {
427 427
 
428 428
 		// Retrieve the payment form.
429
-		$form = new GetPaid_Payment_Form( $post_id );
429
+		$form = new GetPaid_Payment_Form($post_id);
430 430
 
431
-		switch ( $column_name ) {
431
+		switch ($column_name) {
432 432
 
433 433
 			case 'earnings' :
434
-				echo wpinv_price( $form->get_earned() );
434
+				echo wpinv_price($form->get_earned());
435 435
 				break;
436 436
 
437 437
 			case 'refunds' :
438
-				echo wpinv_price( $form->get_refunded() );
438
+				echo wpinv_price($form->get_refunded());
439 439
 				break;
440 440
 
441 441
 			case 'refunds' :
442
-				echo wpinv_price( $form->get_refunded() );
442
+				echo wpinv_price($form->get_refunded());
443 443
 				break;
444 444
 
445 445
 			case 'shortcode' :
446 446
 
447
-				if ( $form->is_default() ) {
447
+				if ($form->is_default()) {
448 448
 					echo '&mdash;';
449 449
 				} else {
450
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
450
+					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';
451 451
 				}
452 452
 
453 453
 				break;
@@ -456,29 +456,29 @@  discard block
 block discarded – undo
456 456
 
457 457
 				$items = $form->get_items();
458 458
 
459
-				if ( $form->is_default() || empty( $items ) ) {
459
+				if ($form->is_default() || empty($items)) {
460 460
 					echo '&mdash;';
461 461
 					return;
462 462
 				}
463 463
 
464 464
 				$_items = array();
465 465
 
466
-				foreach ( $items as $item ) {
466
+				foreach ($items as $item) {
467 467
 					$url = $item->get_edit_url();
468 468
 
469
-					if ( empty( $url ) ) {
470
-						$_items[] = esc_html( $item->get_name() );
469
+					if (empty($url)) {
470
+						$_items[] = esc_html($item->get_name());
471 471
 					} else {
472 472
 						$_items[] = sprintf(
473 473
 							'<a href="%s">%s</a>',
474
-							esc_url( $url ),
475
-							esc_html( $item->get_name() )
474
+							esc_url($url),
475
+							esc_html($item->get_name())
476 476
 						);
477 477
 					}
478 478
 
479 479
 				}
480 480
 
481
-				echo implode( '<br>', $_items );
481
+				echo implode('<br>', $_items);
482 482
 
483 483
 				break;
484 484
 
@@ -489,10 +489,10 @@  discard block
 block discarded – undo
489 489
 	/**
490 490
 	 * Filters post states.
491 491
 	 */
492
-	public static function filter_payment_form_state( $post_states, $post ) {
492
+	public static function filter_payment_form_state($post_states, $post) {
493 493
 
494
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
495
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
494
+		if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) {
495
+			$post_states['default_form'] = __('Default Payment Form', 'invoicing');
496 496
 		}
497 497
 	
498 498
 		return $post_states;
@@ -502,35 +502,35 @@  discard block
 block discarded – undo
502 502
 	/**
503 503
 	 * Returns an array of coupon table columns.
504 504
 	 */
505
-	public static function discount_columns( $columns ) {
505
+	public static function discount_columns($columns) {
506 506
 
507 507
 		$columns = array(
508 508
 			'cb'                => $columns['cb'],
509
-			'title'             => __( 'Name', 'invoicing' ),
510
-			'code'              => __( 'Code', 'invoicing' ),
511
-			'amount'            => __( 'Amount', 'invoicing' ),
512
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
513
-			'start_date'        => __( 'Start Date', 'invoicing' ),
514
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
509
+			'title'             => __('Name', 'invoicing'),
510
+			'code'              => __('Code', 'invoicing'),
511
+			'amount'            => __('Amount', 'invoicing'),
512
+			'usage'             => __('Usage / Limit', 'invoicing'),
513
+			'start_date'        => __('Start Date', 'invoicing'),
514
+			'expiry_date'       => __('Expiry Date', 'invoicing'),
515 515
 		);
516 516
 
517
-		return apply_filters( 'wpi_discount_table_columns', $columns );
517
+		return apply_filters('wpi_discount_table_columns', $columns);
518 518
 	}
519 519
 
520 520
 	/**
521 521
 	 * Filters post states.
522 522
 	 */
523
-	public static function filter_discount_state( $post_states, $post ) {
523
+	public static function filter_discount_state($post_states, $post) {
524 524
 
525
-		if ( 'wpi_discount' == $post->post_type ) {
525
+		if ('wpi_discount' == $post->post_type) {
526 526
 
527
-			$discount = new WPInv_Discount( $post );
527
+			$discount = new WPInv_Discount($post);
528 528
 
529 529
 			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
530 530
 
531
-			if ( $status != 'publish' ) {
531
+			if ($status != 'publish') {
532 532
 				return array(
533
-					'discount_status' => wpinv_discount_status( $status ),
533
+					'discount_status' => wpinv_discount_status($status),
534 534
 				);
535 535
 			}
536 536
 
@@ -545,30 +545,30 @@  discard block
 block discarded – undo
545 545
 	/**
546 546
 	 * Returns an array of items table columns.
547 547
 	 */
548
-	public static function item_columns( $columns ) {
548
+	public static function item_columns($columns) {
549 549
 
550 550
 		$columns = array(
551 551
 			'cb'                => $columns['cb'],
552
-			'title'             => __( 'Name', 'invoicing' ),
553
-			'price'             => __( 'Price', 'invoicing' ),
554
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
555
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
556
-			'type'              => __( 'Type', 'invoicing' ),
557
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
552
+			'title'             => __('Name', 'invoicing'),
553
+			'price'             => __('Price', 'invoicing'),
554
+			'vat_rule'          => __('VAT rule', 'invoicing'),
555
+			'vat_class'         => __('VAT class', 'invoicing'),
556
+			'type'              => __('Type', 'invoicing'),
557
+			'shortcode'         => __('Shortcode', 'invoicing'),
558 558
 		);
559 559
 
560
-		if ( ! wpinv_use_taxes() ) {
561
-			unset( $columns['vat_rule'] );
562
-			unset( $columns['vat_class'] );
560
+		if (!wpinv_use_taxes()) {
561
+			unset($columns['vat_rule']);
562
+			unset($columns['vat_class']);
563 563
 		}
564 564
 
565
-		return apply_filters( 'wpi_item_table_columns', $columns );
565
+		return apply_filters('wpi_item_table_columns', $columns);
566 566
 	}
567 567
 
568 568
 	/**
569 569
 	 * Returns an array of sortable items table columns.
570 570
 	 */
571
-	public static function sortable_item_columns( $columns ) {
571
+	public static function sortable_item_columns($columns) {
572 572
 
573 573
 		return array_merge(
574 574
 			$columns,
@@ -585,47 +585,47 @@  discard block
 block discarded – undo
585 585
 	/**
586 586
 	 * Displays items table columns.
587 587
 	 */
588
-	public static function display_item_columns( $column_name, $post_id ) {
588
+	public static function display_item_columns($column_name, $post_id) {
589 589
  
590
-		$item = new WPInv_Item( $post_id );
590
+		$item = new WPInv_Item($post_id);
591 591
 
592
-		switch ( $column_name ) {
592
+		switch ($column_name) {
593 593
 
594 594
 			case 'price' :
595 595
 
596
-				if ( ! $item->is_recurring() ) {
596
+				if (!$item->is_recurring()) {
597 597
 					echo $item->get_the_price();
598 598
 					break;
599 599
 				}
600 600
 
601 601
 				$price = wp_sprintf(
602
-					__( '%s / %s', 'invoicing' ),
602
+					__('%s / %s', 'invoicing'),
603 603
 					$item->get_the_price(),
604
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
604
+					getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '')
605 605
 				);
606 606
 
607
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
607
+				if ($item->get_the_price() == $item->get_the_initial_price()) {
608 608
 					echo $price;
609 609
 					break;
610 610
 				}
611 611
 
612 612
 				echo $item->get_the_initial_price();
613 613
 
614
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
614
+				echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>';
615 615
 				break;
616 616
 
617 617
 			case 'vat_rule' :
618
-				echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
618
+				echo getpaid_get_tax_rule_label($item->get_vat_rule());
619 619
 				break;
620 620
 
621 621
 			case 'vat_class' :
622
-				echo getpaid_get_tax_class_label( $item->get_vat_class() );
622
+				echo getpaid_get_tax_class_label($item->get_vat_class());
623 623
 				break;
624 624
 
625 625
 			case 'shortcode' :
626 626
 
627
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
628
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
627
+				if ($item->is_type(array('', 'fee', 'custom'))) {
628
+					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
629 629
 				} else {
630 630
 					echo "&mdash;";
631 631
 				}
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 				break;
634 634
 
635 635
 			case 'type' :
636
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
636
+				echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
637 637
 				break;
638 638
 
639 639
 		}
@@ -643,21 +643,21 @@  discard block
 block discarded – undo
643 643
 	/**
644 644
 	 * Lets users filter items using taxes.
645 645
 	 */
646
-	public static function add_item_filters( $post_type ) {
646
+	public static function add_item_filters($post_type) {
647 647
 
648 648
 		// Abort if we're not dealing with items.
649
-		if ( $post_type != 'wpi_item' ) {
649
+		if ($post_type != 'wpi_item') {
650 650
 			return;
651 651
 		}
652 652
 
653 653
 		// Filter by vat rules.
654
-		if ( wpinv_use_taxes() ) {
654
+		if (wpinv_use_taxes()) {
655 655
 	
656 656
 			// Sanitize selected vat rule.
657 657
 			$vat_rule   = '';
658 658
 			$vat_rules  = getpaid_get_tax_rules();
659
-			if ( isset( $_GET['vat_rule'] ) ) {
660
-				$vat_rule   =  $_GET['vat_rule'];
659
+			if (isset($_GET['vat_rule'])) {
660
+				$vat_rule = $_GET['vat_rule'];
661 661
 			}
662 662
 
663 663
 			// Filter by VAT rule.
@@ -665,13 +665,13 @@  discard block
 block discarded – undo
665 665
 				array(
666 666
 					'options'          => array_merge(
667 667
 						array(
668
-							'' => __( 'All VAT rules', 'invoicing' )
668
+							'' => __('All VAT rules', 'invoicing')
669 669
 						),
670 670
 						$vat_rules
671 671
 					),
672 672
 					'name'             => 'vat_rule',
673 673
 					'id'               => 'vat_rule',
674
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
674
+					'selected'         => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '',
675 675
 					'show_option_all'  => false,
676 676
 					'show_option_none' => false,
677 677
 				)
@@ -682,21 +682,21 @@  discard block
 block discarded – undo
682 682
 			// Sanitize selected vat rule.
683 683
 			$vat_class   = '';
684 684
 			$vat_classes = getpaid_get_tax_classes();
685
-			if ( isset( $_GET['vat_class'] ) ) {
686
-				$vat_class   =  $_GET['vat_class'];
685
+			if (isset($_GET['vat_class'])) {
686
+				$vat_class = $_GET['vat_class'];
687 687
 			}
688 688
 
689 689
 			echo wpinv_html_select(
690 690
 				array(
691 691
 					'options'          => array_merge(
692 692
 						array(
693
-							'' => __( 'All VAT classes', 'invoicing' )
693
+							'' => __('All VAT classes', 'invoicing')
694 694
 						),
695 695
 						$vat_classes
696 696
 					),
697 697
 					'name'             => 'vat_class',
698 698
 					'id'               => 'vat_class',
699
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
699
+					'selected'         => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '',
700 700
 					'show_option_all'  => false,
701 701
 					'show_option_none' => false,
702 702
 				)
@@ -705,22 +705,22 @@  discard block
 block discarded – undo
705 705
 		}
706 706
 
707 707
 		// Filter by item type.
708
-		$type   = '';
709
-		if ( isset( $_GET['type'] ) ) {
710
-			$type   =  $_GET['type'];
708
+		$type = '';
709
+		if (isset($_GET['type'])) {
710
+			$type = $_GET['type'];
711 711
 		}
712 712
 
713 713
 		echo wpinv_html_select(
714 714
 			array(
715 715
 				'options'          => array_merge(
716 716
 					array(
717
-						'' => __( 'All item types', 'invoicing' )
717
+						'' => __('All item types', 'invoicing')
718 718
 					),
719 719
 					wpinv_get_item_types()
720 720
 				),
721 721
 				'name'             => 'type',
722 722
 				'id'               => 'type',
723
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
723
+				'selected'         => in_array($type, wpinv_item_types()) ? $type : '',
724 724
 				'show_option_all'  => false,
725 725
 				'show_option_none' => false,
726 726
 			)
@@ -731,45 +731,45 @@  discard block
 block discarded – undo
731 731
 	/**
732 732
 	 * Filters the item query.
733 733
 	 */
734
-	public static function filter_item_query( $query ) {
734
+	public static function filter_item_query($query) {
735 735
 
736 736
 		// modify the query only if it admin and main query.
737
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
737
+		if (!(is_admin() && $query->is_main_query())) { 
738 738
 			return $query;
739 739
 		}
740 740
 
741 741
 		// we want to modify the query for our items.
742
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
742
+		if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) {
743 743
 			return $query;
744 744
 		}
745 745
 
746
-		if ( empty( $query->query_vars['meta_query'] ) ) {
746
+		if (empty($query->query_vars['meta_query'])) {
747 747
 			$query->query_vars['meta_query'] = array();
748 748
 		}
749 749
 
750 750
 		// Filter vat rule type
751
-        if ( ! empty( $_GET['vat_rule'] ) ) {
751
+        if (!empty($_GET['vat_rule'])) {
752 752
             $query->query_vars['meta_query'][] = array(
753 753
                 'key'     => '_wpinv_vat_rule',
754
-                'value'   => sanitize_text_field( $_GET['vat_rule'] ),
754
+                'value'   => sanitize_text_field($_GET['vat_rule']),
755 755
                 'compare' => '='
756 756
             );
757 757
         }
758 758
 
759 759
         // Filter vat class
760
-        if ( ! empty( $_GET['vat_class'] ) ) {
760
+        if (!empty($_GET['vat_class'])) {
761 761
             $query->query_vars['meta_query'][] = array(
762 762
                 'key'     => '_wpinv_vat_class',
763
-                'value'   => sanitize_text_field( $_GET['vat_class'] ),
763
+                'value'   => sanitize_text_field($_GET['vat_class']),
764 764
                 'compare' => '='
765 765
             );
766 766
         }
767 767
 
768 768
         // Filter item type
769
-        if ( ! empty( $_GET['type'] ) ) {
769
+        if (!empty($_GET['type'])) {
770 770
             $query->query_vars['meta_query'][] = array(
771 771
                 'key'     => '_wpinv_type',
772
-                'value'   => sanitize_text_field( $_GET['type'] ),
772
+                'value'   => sanitize_text_field($_GET['type']),
773 773
                 'compare' => '='
774 774
             );
775 775
 		}
@@ -779,15 +779,15 @@  discard block
 block discarded – undo
779 779
 	/**
780 780
 	 * Reorders items.
781 781
 	 */
782
-	public static function reorder_items( $vars ) {
782
+	public static function reorder_items($vars) {
783 783
 		global $typenow;
784 784
 
785
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
785
+		if ('wpi_item' !== $typenow || empty($vars['orderby'])) {
786 786
 			return $vars;
787 787
 		}
788 788
 
789 789
 		// By item type.
790
-		if ( 'type' == $vars['orderby'] ) {
790
+		if ('type' == $vars['orderby']) {
791 791
 			return array_merge(
792 792
 				$vars,
793 793
 				array(
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 		}
799 799
 
800 800
 		// By vat class.
801
-		if ( 'vat_class' == $vars['orderby'] ) {
801
+		if ('vat_class' == $vars['orderby']) {
802 802
 			return array_merge(
803 803
 				$vars,
804 804
 				array(
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 		}
810 810
 
811 811
 		// By vat rule.
812
-		if ( 'vat_rule' == $vars['orderby'] ) {
812
+		if ('vat_rule' == $vars['orderby']) {
813 813
 			return array_merge(
814 814
 				$vars,
815 815
 				array(
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 		}
821 821
 
822 822
 		// By price.
823
-		if ( 'price' == $vars['orderby'] ) {
823
+		if ('price' == $vars['orderby']) {
824 824
 			return array_merge(
825 825
 				$vars,
826 826
 				array(
@@ -837,27 +837,27 @@  discard block
 block discarded – undo
837 837
 	/**
838 838
 	 * Fired when deleting a post.
839 839
 	 */
840
-	public static function delete_post( $post_id ) {
840
+	public static function delete_post($post_id) {
841 841
 
842
-		switch ( get_post_type( $post_id ) ) {
842
+		switch (get_post_type($post_id)) {
843 843
 
844 844
 			case 'wpi_item' :
845
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
845
+				do_action("getpaid_before_delete_item", new WPInv_Item($post_id));
846 846
 				break;
847 847
 
848 848
 			case 'wpi_payment_form' :
849
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
849
+				do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id));
850 850
 				break;
851 851
 
852 852
 			case 'wpi_discount' :
853
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
853
+				do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id));
854 854
 				break;
855 855
 
856 856
 			case 'wpi_invoice' :
857
-				$invoice = new WPInv_Invoice( $post_id );
858
-				do_action( "getpaid_before_delete_invoice", $invoice );
859
-				$invoice->get_data_store()->delete_items( $invoice );
860
-				$invoice->get_data_store()->delete_special_fields( $invoice );
857
+				$invoice = new WPInv_Invoice($post_id);
858
+				do_action("getpaid_before_delete_invoice", $invoice);
859
+				$invoice->get_data_store()->delete_items($invoice);
860
+				$invoice->get_data_store()->delete_special_fields($invoice);
861 861
 				break;
862 862
 		}
863 863
 	}
@@ -870,29 +870,29 @@  discard block
 block discarded – undo
870 870
      *
871 871
      * @return mixed
872 872
      */
873
-    public static function add_display_post_states( $post_states, $post ) {
873
+    public static function add_display_post_states($post_states, $post) {
874 874
 
875
-        if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) {
876
-            $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
875
+        if (wpinv_get_option('success_page', 0) == $post->ID) {
876
+            $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing');
877 877
         }
878 878
 
879
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
879
+		foreach (getpaid_get_invoice_post_types() as $post_type => $label) {
880 880
 
881
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
881
+			if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) {
882 882
 				$post_states["getpaid_{$post_type}_history_page"] = sprintf(
883
-					__( 'GetPaid %s History Page', 'invoicing' ),
883
+					__('GetPaid %s History Page', 'invoicing'),
884 884
 					$label
885 885
 				);
886 886
 			}
887 887
 
888 888
 		}
889 889
 		
890
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
891
-            $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
890
+		if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) {
891
+            $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing');
892 892
         }
893 893
 
894
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
895
-            $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
894
+		if (wpinv_get_option('checkout_page', 0) == $post->ID) {
895
+            $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing');
896 896
         }
897 897
 
898 898
         return $post_states;
Please login to merge, or discard this patch.