Passed
Push — master ( 8aff18...2c4223 )
by Brian
06:32
created
admin/meta-boxes/class-getpaid-meta-box-invoice-shipping-address.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit; // Exit if accessed directly
10
+    exit; // Exit if accessed directly
11 11
 }
12 12
 
13 13
 /**
@@ -15,22 +15,22 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class GetPaid_Meta_Box_Invoice_Shipping_Address {
17 17
 
18
-	/**
19
-	 * Output the metabox.
20
-	 *
21
-	 * @param WP_Post $post
22
-	 */
23
-	public static function output( $post ) {
18
+    /**
19
+     * Output the metabox.
20
+     *
21
+     * @param WP_Post $post
22
+     */
23
+    public static function output( $post ) {
24 24
 
25
-		// Retrieve shipping address.
26
-		$shipping_address = get_post_meta( $post->ID, 'shipping_address', true );
25
+        // Retrieve shipping address.
26
+        $shipping_address = get_post_meta( $post->ID, 'shipping_address', true );
27 27
 
28
-		// Abort if it is invalid.
29
-		if ( ! is_array( $shipping_address ) ) {
30
-			return;
31
-		}
28
+        // Abort if it is invalid.
29
+        if ( ! is_array( $shipping_address ) ) {
30
+            return;
31
+        }
32 32
 
33
-		?>
33
+        ?>
34 34
 
35 35
 		<div class="bsui">
36 36
 
@@ -55,31 +55,31 @@  discard block
 block discarded – undo
55 55
 
56 56
 		<?php
57 57
 
58
-	}
58
+    }
59 59
 
60
-	/**
61
-	 * Prepares a value.
62
-	 *
63
-	 * @param array $address
64
-	 * @param string $key
65
-	 * @return string
66
-	 */
67
-	public static function prepare_for_display( $address, $key ) {
60
+    /**
61
+     * Prepares a value.
62
+     *
63
+     * @param array $address
64
+     * @param string $key
65
+     * @return string
66
+     */
67
+    public static function prepare_for_display( $address, $key ) {
68 68
 
69
-		// Prepare the value.
70
-		$value = $address[ $key ];
69
+        // Prepare the value.
70
+        $value = $address[ $key ];
71 71
 
72
-		if ( $key == 'country' ) {
73
-			$value = wpinv_country_name( $value );
74
-		}
72
+        if ( $key == 'country' ) {
73
+            $value = wpinv_country_name( $value );
74
+        }
75 75
 
76
-		if ( $key == 'state' ) {
77
-			$country = isset( $address[ 'country' ] ) ? $address[ 'country' ] : wpinv_get_default_country();
78
-			$value = wpinv_state_name( $value, $country );
79
-		}
76
+        if ( $key == 'state' ) {
77
+            $country = isset( $address[ 'country' ] ) ? $address[ 'country' ] : wpinv_get_default_country();
78
+            $value = wpinv_state_name( $value, $country );
79
+        }
80 80
 
81
-		return esc_html( $value );
81
+        return esc_html( $value );
82 82
 
83
-	}
83
+    }
84 84
 
85 85
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit; // Exit if accessed directly
11 11
 }
12 12
 
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param WP_Post $post
22 22
 	 */
23
-	public static function output( $post ) {
23
+	public static function output($post) {
24 24
 
25 25
 		// Retrieve shipping address.
26
-		$shipping_address = get_post_meta( $post->ID, 'shipping_address', true );
26
+		$shipping_address = get_post_meta($post->ID, 'shipping_address', true);
27 27
 
28 28
 		// Abort if it is invalid.
29
-		if ( ! is_array( $shipping_address ) ) {
29
+		if (!is_array($shipping_address)) {
30 30
 			return;
31 31
 		}
32 32
 
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 
35 35
 		<div class="bsui">
36 36
 
37
-			<?php foreach ( getpaid_user_address_fields() as $key => $label ) : ?>
37
+			<?php foreach (getpaid_user_address_fields() as $key => $label) : ?>
38 38
 
39
-					<?php if ( ! empty( $shipping_address[ $key ] ) ) : ?>
39
+					<?php if (!empty($shipping_address[$key])) : ?>
40 40
 
41 41
 						<div class="form-group form-row">
42 42
 							<div class="col">
43
-								<span style="font-weight: 600"><?php echo esc_html( $label ); ?>:</span>
43
+								<span style="font-weight: 600"><?php echo esc_html($label); ?>:</span>
44 44
 							</div>
45 45
 							<div class="col">
46
-								<?php echo self::prepare_for_display( $shipping_address, $key ); ?>
46
+								<?php echo self::prepare_for_display($shipping_address, $key); ?>
47 47
 							</div>
48 48
 						</div>
49 49
 
@@ -64,21 +64,21 @@  discard block
 block discarded – undo
64 64
 	 * @param string $key
65 65
 	 * @return string
66 66
 	 */
67
-	public static function prepare_for_display( $address, $key ) {
67
+	public static function prepare_for_display($address, $key) {
68 68
 
69 69
 		// Prepare the value.
70
-		$value = $address[ $key ];
70
+		$value = $address[$key];
71 71
 
72
-		if ( $key == 'country' ) {
73
-			$value = wpinv_country_name( $value );
72
+		if ($key == 'country') {
73
+			$value = wpinv_country_name($value);
74 74
 		}
75 75
 
76
-		if ( $key == 'state' ) {
77
-			$country = isset( $address[ 'country' ] ) ? $address[ 'country' ] : wpinv_get_default_country();
78
-			$value = wpinv_state_name( $value, $country );
76
+		if ($key == 'state') {
77
+			$country = isset($address['country']) ? $address['country'] : wpinv_get_default_country();
78
+			$value = wpinv_state_name($value, $country);
79 79
 		}
80 80
 
81
-		return esc_html( $value );
81
+		return esc_html($value);
82 82
 
83 83
 	}
84 84
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-payment-form.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Payment_Form {
@@ -11,23 +11,23 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @param WP_Post $post
13 13
      */
14
-    public static function output_details( $post ) {
15
-        $details = get_post_meta( $post->ID, 'payment_form_data', true );
14
+    public static function output_details($post) {
15
+        $details = get_post_meta($post->ID, 'payment_form_data', true);
16 16
 
17
-        if ( ! is_array( $details ) ) {
17
+        if (!is_array($details)) {
18 18
             return;
19 19
         }
20 20
 
21 21
         echo '<div class="bsui"> <div class="form-row">';
22 22
 
23
-        foreach ( $details as $key => $value ) {
24
-            $key = esc_html( $key );
23
+        foreach ($details as $key => $value) {
24
+            $key = esc_html($key);
25 25
 
26
-            if ( is_array( $value ) ) {
27
-                $value = implode( ',', $value );
26
+            if (is_array($value)) {
27
+                $value = implode(',', $value);
28 28
             }
29 29
 
30
-            $value = esc_html( $value );
30
+            $value = esc_html($value);
31 31
             echo "<div class='col-6 form-group'><strong>$key:</strong></div><div class='col-6 form-group'>$value</div>";
32 32
         }
33 33
 
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @param WP_Post $post
42 42
      */
43
-    public static function output_shortcode( $post ) {
43
+    public static function output_shortcode($post) {
44 44
 
45
-        if ( ! is_numeric( $post ) ) {
45
+        if (!is_numeric($post)) {
46 46
             $post = $post->ID;
47 47
         }
48 48
 
49
-        if ( $post == wpinv_get_default_payment_form() ) {
49
+        if ($post == wpinv_get_default_payment_form()) {
50 50
             echo '&mdash;';
51 51
             return;
52 52
         }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 2 patches
Indentation   +700 added lines, -700 removed lines patch added patch discarded remove patch
@@ -13,703 +13,703 @@  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
-		return $actions;
133
-	}
134
-
135
-	/**
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
+        return $actions;
133
+    }
134
+
135
+    /**
136 136
      * Remove bulk edit option from admin side quote listing
137 137
      *
138 138
      * @since    1.0.0
139 139
      * @param array $actions post actions
140
-	 * @param WP_Post $post
140
+     * @param WP_Post $post
141 141
      * @return array $actions actions without edit option
142 142
      */
143 143
     public static function filter_invoice_row_actions( $actions, $post ) {
144 144
 
145 145
         if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
146 146
 
147
-			$actions = array();
148
-			$invoice = new WPInv_Invoice( $post );
149
-
150
-			$actions['edit'] =  sprintf(
151
-				'<a href="%1$s">%2$s</a>',
152
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
153
-				esc_html( __( 'Edit', 'invoicing' ) )
154
-			);
155
-
156
-			if ( ! $invoice->is_draft() ) {
157
-
158
-				$actions['view'] =  sprintf(
159
-					'<a href="%1$s">%2$s</a>',
160
-					esc_url( $invoice->get_view_url() ),
161
-					sprintf(
162
-						esc_html( __( 'View %s', 'invoicing' ) ),
163
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
164
-					)
165
-				);
166
-
167
-				$actions['send'] =  sprintf(
168
-					'<a href="%1$s">%2$s</a>',
169
-					esc_url(
170
-						wp_nonce_url(
171
-							add_query_arg(
172
-								array(
173
-									'getpaid-admin-action' => 'send_invoice',
174
-									'invoice_id'           => $invoice->get_id()
175
-								)
176
-							),
177
-							'getpaid-nonce',
178
-							'getpaid-nonce'
179
-						)
180
-					),
181
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
182
-				);
183
-
184
-			}
147
+            $actions = array();
148
+            $invoice = new WPInv_Invoice( $post );
149
+
150
+            $actions['edit'] =  sprintf(
151
+                '<a href="%1$s">%2$s</a>',
152
+                esc_url( get_edit_post_link( $invoice->get_id() ) ),
153
+                esc_html( __( 'Edit', 'invoicing' ) )
154
+            );
155
+
156
+            if ( ! $invoice->is_draft() ) {
157
+
158
+                $actions['view'] =  sprintf(
159
+                    '<a href="%1$s">%2$s</a>',
160
+                    esc_url( $invoice->get_view_url() ),
161
+                    sprintf(
162
+                        esc_html( __( 'View %s', 'invoicing' ) ),
163
+                        getpaid_get_post_type_label( $invoice->get_post_type(), false )
164
+                    )
165
+                );
166
+
167
+                $actions['send'] =  sprintf(
168
+                    '<a href="%1$s">%2$s</a>',
169
+                    esc_url(
170
+                        wp_nonce_url(
171
+                            add_query_arg(
172
+                                array(
173
+                                    'getpaid-admin-action' => 'send_invoice',
174
+                                    'invoice_id'           => $invoice->get_id()
175
+                                )
176
+                            ),
177
+                            'getpaid-nonce',
178
+                            'getpaid-nonce'
179
+                        )
180
+                    ),
181
+                    esc_html( __( 'Send to Customer', 'invoicing' ) )
182
+                );
183
+
184
+            }
185 185
 
186 186
         }
187 187
 
188 188
         return $actions;
189
-	}
190
-
191
-	/**
192
-	 * Returns an array of invoice table columns.
193
-	 */
194
-	public static function invoice_columns( $columns ) {
195
-
196
-		$columns = array(
197
-			'cb'                => $columns['cb'],
198
-			'number'            => __( 'Invoice', 'invoicing' ),
199
-			'customer'          => __( 'Customer', 'invoicing' ),
200
-			'invoice_date'      => __( 'Created', 'invoicing' ),
201
-			'payment_date'      => __( 'Completed', 'invoicing' ),
202
-			'amount'            => __( 'Amount', 'invoicing' ),
203
-			'recurring'         => __( 'Recurring', 'invoicing' ),
204
-			'status'            => __( 'Status', 'invoicing' ),
205
-		);
206
-
207
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
208
-	}
209
-
210
-	/**
211
-	 * Displays invoice table columns.
212
-	 */
213
-	public static function display_invoice_columns( $column_name, $post_id ) {
214
-
215
-		$invoice = new WPInv_Invoice( $post_id );
216
-
217
-		switch ( $column_name ) {
218
-
219
-			case 'invoice_date' :
220
-				$date_time = esc_attr( $invoice->get_created_date() );
221
-				$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
222
-				echo "<span title='$date_time'>$date</span>";
223
-				break;
224
-
225
-			case 'payment_date' :
226
-
227
-				if ( $invoice->is_paid() ) {
228
-					$date_time = esc_attr( $invoice->get_completed_date() );
229
-					$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
230
-					echo "<span title='$date_time'>$date</span>";
231
-				} else {
232
-					echo "&mdash;";
233
-				}
189
+    }
190
+
191
+    /**
192
+     * Returns an array of invoice table columns.
193
+     */
194
+    public static function invoice_columns( $columns ) {
195
+
196
+        $columns = array(
197
+            'cb'                => $columns['cb'],
198
+            'number'            => __( 'Invoice', 'invoicing' ),
199
+            'customer'          => __( 'Customer', 'invoicing' ),
200
+            'invoice_date'      => __( 'Created', 'invoicing' ),
201
+            'payment_date'      => __( 'Completed', 'invoicing' ),
202
+            'amount'            => __( 'Amount', 'invoicing' ),
203
+            'recurring'         => __( 'Recurring', 'invoicing' ),
204
+            'status'            => __( 'Status', 'invoicing' ),
205
+        );
206
+
207
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
208
+    }
209
+
210
+    /**
211
+     * Displays invoice table columns.
212
+     */
213
+    public static function display_invoice_columns( $column_name, $post_id ) {
214
+
215
+        $invoice = new WPInv_Invoice( $post_id );
216
+
217
+        switch ( $column_name ) {
218
+
219
+            case 'invoice_date' :
220
+                $date_time = esc_attr( $invoice->get_created_date() );
221
+                $date      = getpaid_format_date_value( $date_time, "&mdash;", true );
222
+                echo "<span title='$date_time'>$date</span>";
223
+                break;
224
+
225
+            case 'payment_date' :
226
+
227
+                if ( $invoice->is_paid() ) {
228
+                    $date_time = esc_attr( $invoice->get_completed_date() );
229
+                    $date      = getpaid_format_date_value( $date_time, "&mdash;", true );
230
+                    echo "<span title='$date_time'>$date</span>";
231
+                } else {
232
+                    echo "&mdash;";
233
+                }
234 234
 				
235
-				break;
235
+                break;
236 236
 
237
-			case 'amount' :
237
+            case 'amount' :
238 238
 
239
-				$amount = $invoice->get_total();
240
-				$formated_amount = wpinv_price( $amount, $invoice->get_currency() );
239
+                $amount = $invoice->get_total();
240
+                $formated_amount = wpinv_price( $amount, $invoice->get_currency() );
241 241
 
242
-				if ( $invoice->is_refunded() ) {
243
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
244
-					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
245
-				} else {
242
+                if ( $invoice->is_refunded() ) {
243
+                    $refunded_amount = wpinv_price( 0, $invoice->get_currency() );
244
+                    echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
245
+                } else {
246 246
 
247
-					$discount = $invoice->get_total_discount();
247
+                    $discount = $invoice->get_total_discount();
248 248
 
249
-					if ( ! empty( $discount ) ) {
250
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
251
-						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
252
-					} else {
253
-						echo $formated_amount;
254
-					}
249
+                    if ( ! empty( $discount ) ) {
250
+                        $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
251
+                        echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
252
+                    } else {
253
+                        echo $formated_amount;
254
+                    }
255 255
 
256
-				}
256
+                }
257 257
 
258
-				break;
258
+                break;
259 259
 
260
-			case 'status' :
261
-				$status       = esc_html( $invoice->get_status() );
262
-				$status_label = esc_html( $invoice->get_status_nicename() );
260
+            case 'status' :
261
+                $status       = esc_html( $invoice->get_status() );
262
+                $status_label = esc_html( $invoice->get_status_nicename() );
263 263
 
264
-				// If it is paid, show the gateway title.
265
-				if ( $invoice->is_paid() ) {
266
-					$gateway = esc_html( $invoice->get_gateway_title() );
267
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
264
+                // If it is paid, show the gateway title.
265
+                if ( $invoice->is_paid() ) {
266
+                    $gateway = esc_html( $invoice->get_gateway_title() );
267
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
268 268
 
269
-					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
270
-				} else {
271
-					echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
272
-				}
269
+                    echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
270
+                } else {
271
+                    echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
272
+                }
273 273
 
274
-				// If it is not paid, display the overdue and view status.
275
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
274
+                // If it is not paid, display the overdue and view status.
275
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
276 276
 
277
-					// Invoice view status.
278
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
279
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
280
-					} else {
281
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
282
-					}
277
+                    // Invoice view status.
278
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
279
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
280
+                    } else {
281
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
282
+                    }
283 283
 
284
-					// Display the overview status.
285
-					if ( wpinv_get_option( 'overdue_active' ) ) {
286
-						$due_date = $invoice->get_due_date();
287
-						$fomatted = getpaid_format_date( $due_date );
284
+                    // Display the overview status.
285
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
286
+                        $due_date = $invoice->get_due_date();
287
+                        $fomatted = getpaid_format_date( $due_date );
288 288
 
289
-						if ( ! empty( $fomatted ) ) {
290
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
291
-							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
292
-						}
293
-					}
289
+                        if ( ! empty( $fomatted ) ) {
290
+                            $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
291
+                            echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
292
+                        }
293
+                    }
294 294
 
295
-				}
295
+                }
296 296
 
297
-				break;
297
+                break;
298 298
 
299
-			case 'recurring':
299
+            case 'recurring':
300 300
 
301
-				if ( $invoice->is_recurring() ) {
302
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
303
-				} else {
304
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
305
-				}
306
-				break;
301
+                if ( $invoice->is_recurring() ) {
302
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
303
+                } else {
304
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
305
+                }
306
+                break;
307 307
 
308
-			case 'number' :
308
+            case 'number' :
309 309
 
310
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
311
-				$invoice_number  = esc_html( $invoice->get_number() );
312
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
310
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
311
+                $invoice_number  = esc_html( $invoice->get_number() );
312
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
313 313
 
314
-				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
314
+                echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
315 315
 
316
-				break;
316
+                break;
317 317
 
318
-			case 'customer' :
318
+            case 'customer' :
319 319
 	
320
-				$customer_name = $invoice->get_user_full_name();
320
+                $customer_name = $invoice->get_user_full_name();
321 321
 	
322
-				if ( empty( $customer_name ) ) {
323
-					$customer_name = $invoice->get_email();
324
-				}
322
+                if ( empty( $customer_name ) ) {
323
+                    $customer_name = $invoice->get_email();
324
+                }
325 325
 	
326
-				if ( ! empty( $customer_name ) ) {
327
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
328
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
329
-					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
330
-				} else {
331
-					echo '<div>&mdash;</div>';
332
-				}
326
+                if ( ! empty( $customer_name ) ) {
327
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
328
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
329
+                    echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
330
+                } else {
331
+                    echo '<div>&mdash;</div>';
332
+                }
333 333
 
334
-				break;
334
+                break;
335 335
 
336
-		}
336
+        }
337 337
 
338
-	}
338
+    }
339 339
 
340
-	/**
341
-	 * Displays invoice bulk actions.
342
-	 */
343
-	public static function invoice_bulk_actions( $actions ) {
344
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
345
-		return $actions;
346
-	}
340
+    /**
341
+     * Displays invoice bulk actions.
342
+     */
343
+    public static function invoice_bulk_actions( $actions ) {
344
+        $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
345
+        return $actions;
346
+    }
347 347
 
348
-	/**
349
-	 * Processes invoice bulk actions.
350
-	 */
351
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
348
+    /**
349
+     * Processes invoice bulk actions.
350
+     */
351
+    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
352 352
 
353
-		if ( $action == 'resend-invoice' ) {
353
+        if ( $action == 'resend-invoice' ) {
354 354
 
355
-			$success = false;
356
-			foreach ( $post_ids as $post_id ) {
357
-				$success = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
358
-			}
355
+            $success = false;
356
+            foreach ( $post_ids as $post_id ) {
357
+                $success = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
358
+            }
359 359
 
360
-			if ( $success ) {
361
-				getpaid_admin()->show_success( __( 'Invoices were successfully sent', 'invoicing' ) );
362
-			} else {
363
-				getpaid_admin()->show_error( __( 'Could not send some invoices', 'invoicing' ) );
364
-			}
360
+            if ( $success ) {
361
+                getpaid_admin()->show_success( __( 'Invoices were successfully sent', 'invoicing' ) );
362
+            } else {
363
+                getpaid_admin()->show_error( __( 'Could not send some invoices', 'invoicing' ) );
364
+            }
365 365
 
366
-		}
366
+        }
367 367
 
368
-		return $redirect_url;
368
+        return $redirect_url;
369 369
 
370
-	}
370
+    }
371 371
 
372
-	/**
373
-	 * Returns an array of payment forms table columns.
374
-	 */
375
-	public static function payment_form_columns( $columns ) {
372
+    /**
373
+     * Returns an array of payment forms table columns.
374
+     */
375
+    public static function payment_form_columns( $columns ) {
376 376
 
377
-		$columns = array(
378
-			'cb'                => $columns['cb'],
379
-			'title'             => __( 'Name', 'invoicing' ),
380
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
381
-			'earnings'          => __( 'Revenue', 'invoicing' ),
382
-			'refunds'           => __( 'Refunded', 'invoicing' ),
383
-			'items'             => __( 'Items', 'invoicing' ),
384
-			'date'              => __( 'Date', 'invoicing' ),
385
-		);
377
+        $columns = array(
378
+            'cb'                => $columns['cb'],
379
+            'title'             => __( 'Name', 'invoicing' ),
380
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
381
+            'earnings'          => __( 'Revenue', 'invoicing' ),
382
+            'refunds'           => __( 'Refunded', 'invoicing' ),
383
+            'items'             => __( 'Items', 'invoicing' ),
384
+            'date'              => __( 'Date', 'invoicing' ),
385
+        );
386 386
 
387
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
387
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
388 388
 
389
-	}
389
+    }
390 390
 
391
-	/**
392
-	 * Displays payment form table columns.
393
-	 */
394
-	public static function display_payment_form_columns( $column_name, $post_id ) {
391
+    /**
392
+     * Displays payment form table columns.
393
+     */
394
+    public static function display_payment_form_columns( $column_name, $post_id ) {
395 395
 
396
-		// Retrieve the payment form.
397
-		$form = new GetPaid_Payment_Form( $post_id );
396
+        // Retrieve the payment form.
397
+        $form = new GetPaid_Payment_Form( $post_id );
398 398
 
399
-		switch ( $column_name ) {
399
+        switch ( $column_name ) {
400 400
 
401
-			case 'earnings' :
402
-				echo wpinv_price( $form->get_earned() );
403
-				break;
401
+            case 'earnings' :
402
+                echo wpinv_price( $form->get_earned() );
403
+                break;
404 404
 
405
-			case 'refunds' :
406
-				echo wpinv_price( $form->get_refunded() );
407
-				break;
405
+            case 'refunds' :
406
+                echo wpinv_price( $form->get_refunded() );
407
+                break;
408 408
 
409
-			case 'refunds' :
410
-				echo wpinv_price( $form->get_refunded() );
411
-				break;
409
+            case 'refunds' :
410
+                echo wpinv_price( $form->get_refunded() );
411
+                break;
412 412
 
413
-			case 'shortcode' :
413
+            case 'shortcode' :
414 414
 
415
-				if ( $form->is_default() ) {
416
-					echo '&mdash;';
417
-				} else {
418
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
419
-				}
415
+                if ( $form->is_default() ) {
416
+                    echo '&mdash;';
417
+                } else {
418
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
419
+                }
420 420
 
421
-				break;
421
+                break;
422 422
 
423
-			case 'items' :
423
+            case 'items' :
424 424
 
425
-				$items = $form->get_items();
425
+                $items = $form->get_items();
426 426
 
427
-				if ( $form->is_default() || empty( $items ) ) {
428
-					echo '&mdash;';
429
-					return;
430
-				}
427
+                if ( $form->is_default() || empty( $items ) ) {
428
+                    echo '&mdash;';
429
+                    return;
430
+                }
431 431
 
432
-				$_items = array();
432
+                $_items = array();
433 433
 
434
-				foreach ( $items as $item ) {
435
-					$url = $item->get_edit_url();
434
+                foreach ( $items as $item ) {
435
+                    $url = $item->get_edit_url();
436 436
 
437
-					if ( empty( $url ) ) {
438
-						$_items[] = esc_html( $item->get_name() );
439
-					} else {
440
-						$_items[] = sprintf(
441
-							'<a href="%s">%s</a>',
442
-							esc_url( $url ),
443
-							esc_html( $item->get_name() )
444
-						);
445
-					}
437
+                    if ( empty( $url ) ) {
438
+                        $_items[] = esc_html( $item->get_name() );
439
+                    } else {
440
+                        $_items[] = sprintf(
441
+                            '<a href="%s">%s</a>',
442
+                            esc_url( $url ),
443
+                            esc_html( $item->get_name() )
444
+                        );
445
+                    }
446 446
 
447
-				}
447
+                }
448 448
 
449
-				echo implode( '<br>', $_items );
449
+                echo implode( '<br>', $_items );
450 450
 
451
-				break;
451
+                break;
452 452
 
453
-		}
453
+        }
454 454
 
455
-	}
455
+    }
456 456
 
457
-	/**
458
-	 * Filters post states.
459
-	 */
460
-	public static function filter_payment_form_state( $post_states, $post ) {
457
+    /**
458
+     * Filters post states.
459
+     */
460
+    public static function filter_payment_form_state( $post_states, $post ) {
461 461
 
462
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
463
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
464
-		}
462
+        if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
463
+            $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
464
+        }
465 465
 	
466
-		return $post_states;
467
-
468
-	}
469
-
470
-	/**
471
-	 * Returns an array of coupon table columns.
472
-	 */
473
-	public static function discount_columns( $columns ) {
474
-
475
-		$columns = array(
476
-			'cb'                => $columns['cb'],
477
-			'title'             => __( 'Name', 'invoicing' ),
478
-			'code'              => __( 'Code', 'invoicing' ),
479
-			'amount'            => __( 'Amount', 'invoicing' ),
480
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
481
-			'start_date'        => __( 'Start Date', 'invoicing' ),
482
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
483
-		);
484
-
485
-		return apply_filters( 'wpi_discount_table_columns', $columns );
486
-	}
487
-
488
-	/**
489
-	 * Filters post states.
490
-	 */
491
-	public static function filter_discount_state( $post_states, $post ) {
492
-
493
-		if ( 'wpi_discount' == $post->post_type ) {
494
-
495
-			$discount = new WPInv_Discount( $post );
496
-
497
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
498
-
499
-			if ( $status != 'publish' ) {
500
-				return array(
501
-					'discount_status' => wpinv_discount_status( $status ),
502
-				);
503
-			}
504
-
505
-			return array();
506
-
507
-		}
508
-
509
-		return $post_states;
510
-
511
-	}
512
-
513
-	/**
514
-	 * Returns an array of items table columns.
515
-	 */
516
-	public static function item_columns( $columns ) {
517
-
518
-		$columns = array(
519
-			'cb'                => $columns['cb'],
520
-			'title'             => __( 'Name', 'invoicing' ),
521
-			'price'             => __( 'Price', 'invoicing' ),
522
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
523
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
524
-			'type'              => __( 'Type', 'invoicing' ),
525
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
526
-		);
527
-
528
-		if ( ! wpinv_use_taxes() ) {
529
-			unset( $columns['vat_rule'] );
530
-			unset( $columns['vat_class'] );
531
-		}
532
-
533
-		return apply_filters( 'wpi_item_table_columns', $columns );
534
-	}
535
-
536
-	/**
537
-	 * Returns an array of sortable items table columns.
538
-	 */
539
-	public static function sortable_item_columns( $columns ) {
540
-
541
-		return array_merge(
542
-			$columns,
543
-			array(
544
-				'price'     => 'price',
545
-				'vat_rule'  => 'vat_rule',
546
-				'vat_class' => 'vat_class',
547
-				'type'      => 'type',
548
-			)
549
-		);
550
-
551
-	}
552
-
553
-	/**
554
-	 * Displays items table columns.
555
-	 */
556
-	public static function display_item_columns( $column_name, $post_id ) {
466
+        return $post_states;
467
+
468
+    }
469
+
470
+    /**
471
+     * Returns an array of coupon table columns.
472
+     */
473
+    public static function discount_columns( $columns ) {
474
+
475
+        $columns = array(
476
+            'cb'                => $columns['cb'],
477
+            'title'             => __( 'Name', 'invoicing' ),
478
+            'code'              => __( 'Code', 'invoicing' ),
479
+            'amount'            => __( 'Amount', 'invoicing' ),
480
+            'usage'             => __( 'Usage / Limit', 'invoicing' ),
481
+            'start_date'        => __( 'Start Date', 'invoicing' ),
482
+            'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
483
+        );
484
+
485
+        return apply_filters( 'wpi_discount_table_columns', $columns );
486
+    }
487
+
488
+    /**
489
+     * Filters post states.
490
+     */
491
+    public static function filter_discount_state( $post_states, $post ) {
492
+
493
+        if ( 'wpi_discount' == $post->post_type ) {
494
+
495
+            $discount = new WPInv_Discount( $post );
496
+
497
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
498
+
499
+            if ( $status != 'publish' ) {
500
+                return array(
501
+                    'discount_status' => wpinv_discount_status( $status ),
502
+                );
503
+            }
504
+
505
+            return array();
506
+
507
+        }
508
+
509
+        return $post_states;
510
+
511
+    }
512
+
513
+    /**
514
+     * Returns an array of items table columns.
515
+     */
516
+    public static function item_columns( $columns ) {
517
+
518
+        $columns = array(
519
+            'cb'                => $columns['cb'],
520
+            'title'             => __( 'Name', 'invoicing' ),
521
+            'price'             => __( 'Price', 'invoicing' ),
522
+            'vat_rule'          => __( 'VAT rule', 'invoicing' ),
523
+            'vat_class'         => __( 'VAT class', 'invoicing' ),
524
+            'type'              => __( 'Type', 'invoicing' ),
525
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
526
+        );
527
+
528
+        if ( ! wpinv_use_taxes() ) {
529
+            unset( $columns['vat_rule'] );
530
+            unset( $columns['vat_class'] );
531
+        }
532
+
533
+        return apply_filters( 'wpi_item_table_columns', $columns );
534
+    }
535
+
536
+    /**
537
+     * Returns an array of sortable items table columns.
538
+     */
539
+    public static function sortable_item_columns( $columns ) {
540
+
541
+        return array_merge(
542
+            $columns,
543
+            array(
544
+                'price'     => 'price',
545
+                'vat_rule'  => 'vat_rule',
546
+                'vat_class' => 'vat_class',
547
+                'type'      => 'type',
548
+            )
549
+        );
550
+
551
+    }
552
+
553
+    /**
554
+     * Displays items table columns.
555
+     */
556
+    public static function display_item_columns( $column_name, $post_id ) {
557 557
  
558
-		$item = new WPInv_Item( $post_id );
558
+        $item = new WPInv_Item( $post_id );
559 559
 
560
-		switch ( $column_name ) {
560
+        switch ( $column_name ) {
561 561
 
562
-			case 'price' :
562
+            case 'price' :
563 563
 
564
-				if ( ! $item->is_recurring() ) {
565
-					echo $item->get_the_price();
566
-					break;
567
-				}
564
+                if ( ! $item->is_recurring() ) {
565
+                    echo $item->get_the_price();
566
+                    break;
567
+                }
568 568
 
569
-				$price = wp_sprintf(
570
-					__( '%s / %s', 'invoicing' ),
571
-					$item->get_the_price(),
572
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
573
-				);
569
+                $price = wp_sprintf(
570
+                    __( '%s / %s', 'invoicing' ),
571
+                    $item->get_the_price(),
572
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
573
+                );
574 574
 
575
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
576
-					echo $price;
577
-					break;
578
-				}
575
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
576
+                    echo $price;
577
+                    break;
578
+                }
579 579
 
580
-				echo $item->get_the_initial_price();
580
+                echo $item->get_the_initial_price();
581 581
 
582
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
583
-				break;
582
+                echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
583
+                break;
584 584
 
585
-			case 'vat_rule' :
586
-				echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
587
-				break;
585
+            case 'vat_rule' :
586
+                echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
587
+                break;
588 588
 
589
-			case 'vat_class' :
590
-				echo getpaid_get_tax_class_label( $item->get_vat_class() );
591
-				break;
589
+            case 'vat_class' :
590
+                echo getpaid_get_tax_class_label( $item->get_vat_class() );
591
+                break;
592 592
 
593
-			case 'shortcode' :
594
-				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
595
-				break;
593
+            case 'shortcode' :
594
+                echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
595
+                break;
596 596
 
597
-			case 'type' :
598
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
599
-				break;
597
+            case 'type' :
598
+                echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
599
+                break;
600 600
 
601
-		}
601
+        }
602 602
 
603
-	}
603
+    }
604 604
 
605
-	/**
606
-	 * Lets users filter items using taxes.
607
-	 */
608
-	public static function add_item_filters( $post_type ) {
605
+    /**
606
+     * Lets users filter items using taxes.
607
+     */
608
+    public static function add_item_filters( $post_type ) {
609 609
 
610
-		// Abort if we're not dealing with items.
611
-		if ( $post_type != 'wpi_item' ) {
612
-			return;
613
-		}
610
+        // Abort if we're not dealing with items.
611
+        if ( $post_type != 'wpi_item' ) {
612
+            return;
613
+        }
614 614
 
615
-		// Filter by vat rules.
616
-		if ( wpinv_use_taxes() ) {
615
+        // Filter by vat rules.
616
+        if ( wpinv_use_taxes() ) {
617 617
 	
618
-			// Sanitize selected vat rule.
619
-			$vat_rule   = '';
620
-			$vat_rules  = getpaid_get_tax_rules();
621
-			if ( isset( $_GET['vat_rule'] ) ) {
622
-				$vat_rule   =  $_GET['vat_rule'];
623
-			}
624
-
625
-			// Filter by VAT rule.
626
-			echo wpinv_html_select(
627
-				array(
628
-					'options'          => array_merge(
629
-						array(
630
-							'' => __( 'All VAT rules', 'invoicing' )
631
-						),
632
-						$vat_rules
633
-					),
634
-					'name'             => 'vat_rule',
635
-					'id'               => 'vat_rule',
636
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
637
-					'show_option_all'  => false,
638
-					'show_option_none' => false,
639
-				)
640
-			);
641
-
642
-			// Filter by VAT class.
618
+            // Sanitize selected vat rule.
619
+            $vat_rule   = '';
620
+            $vat_rules  = getpaid_get_tax_rules();
621
+            if ( isset( $_GET['vat_rule'] ) ) {
622
+                $vat_rule   =  $_GET['vat_rule'];
623
+            }
624
+
625
+            // Filter by VAT rule.
626
+            echo wpinv_html_select(
627
+                array(
628
+                    'options'          => array_merge(
629
+                        array(
630
+                            '' => __( 'All VAT rules', 'invoicing' )
631
+                        ),
632
+                        $vat_rules
633
+                    ),
634
+                    'name'             => 'vat_rule',
635
+                    'id'               => 'vat_rule',
636
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
637
+                    'show_option_all'  => false,
638
+                    'show_option_none' => false,
639
+                )
640
+            );
641
+
642
+            // Filter by VAT class.
643 643
 	
644
-			// Sanitize selected vat rule.
645
-			$vat_class   = '';
646
-			$vat_classes = getpaid_get_tax_classes();
647
-			if ( isset( $_GET['vat_class'] ) ) {
648
-				$vat_class   =  $_GET['vat_class'];
649
-			}
650
-
651
-			echo wpinv_html_select(
652
-				array(
653
-					'options'          => array_merge(
654
-						array(
655
-							'' => __( 'All VAT classes', 'invoicing' )
656
-						),
657
-						$vat_classes
658
-					),
659
-					'name'             => 'vat_class',
660
-					'id'               => 'vat_class',
661
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
662
-					'show_option_all'  => false,
663
-					'show_option_none' => false,
664
-				)
665
-			);
666
-
667
-		}
668
-
669
-		// Filter by item type.
670
-		$type   = '';
671
-		if ( isset( $_GET['type'] ) ) {
672
-			$type   =  $_GET['type'];
673
-		}
674
-
675
-		echo wpinv_html_select(
676
-			array(
677
-				'options'          => array_merge(
678
-					array(
679
-						'' => __( 'All item types', 'invoicing' )
680
-					),
681
-					wpinv_get_item_types()
682
-				),
683
-				'name'             => 'type',
684
-				'id'               => 'type',
685
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
686
-				'show_option_all'  => false,
687
-				'show_option_none' => false,
688
-			)
689
-		);
690
-
691
-	}
692
-
693
-	/**
694
-	 * Filters the item query.
695
-	 */
696
-	public static function filter_item_query( $query ) {
697
-
698
-		// modify the query only if it admin and main query.
699
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
700
-			return $query;
701
-		}
702
-
703
-		// we want to modify the query for our items.
704
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
705
-			return $query;
706
-		}
707
-
708
-		if ( empty( $query->query_vars['meta_query'] ) ) {
709
-			$query->query_vars['meta_query'] = array();
710
-		}
711
-
712
-		// Filter vat rule type
644
+            // Sanitize selected vat rule.
645
+            $vat_class   = '';
646
+            $vat_classes = getpaid_get_tax_classes();
647
+            if ( isset( $_GET['vat_class'] ) ) {
648
+                $vat_class   =  $_GET['vat_class'];
649
+            }
650
+
651
+            echo wpinv_html_select(
652
+                array(
653
+                    'options'          => array_merge(
654
+                        array(
655
+                            '' => __( 'All VAT classes', 'invoicing' )
656
+                        ),
657
+                        $vat_classes
658
+                    ),
659
+                    'name'             => 'vat_class',
660
+                    'id'               => 'vat_class',
661
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
662
+                    'show_option_all'  => false,
663
+                    'show_option_none' => false,
664
+                )
665
+            );
666
+
667
+        }
668
+
669
+        // Filter by item type.
670
+        $type   = '';
671
+        if ( isset( $_GET['type'] ) ) {
672
+            $type   =  $_GET['type'];
673
+        }
674
+
675
+        echo wpinv_html_select(
676
+            array(
677
+                'options'          => array_merge(
678
+                    array(
679
+                        '' => __( 'All item types', 'invoicing' )
680
+                    ),
681
+                    wpinv_get_item_types()
682
+                ),
683
+                'name'             => 'type',
684
+                'id'               => 'type',
685
+                'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
686
+                'show_option_all'  => false,
687
+                'show_option_none' => false,
688
+            )
689
+        );
690
+
691
+    }
692
+
693
+    /**
694
+     * Filters the item query.
695
+     */
696
+    public static function filter_item_query( $query ) {
697
+
698
+        // modify the query only if it admin and main query.
699
+        if ( ! ( is_admin() && $query->is_main_query() ) ){ 
700
+            return $query;
701
+        }
702
+
703
+        // we want to modify the query for our items.
704
+        if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
705
+            return $query;
706
+        }
707
+
708
+        if ( empty( $query->query_vars['meta_query'] ) ) {
709
+            $query->query_vars['meta_query'] = array();
710
+        }
711
+
712
+        // Filter vat rule type
713 713
         if ( ! empty( $_GET['vat_rule'] ) ) {
714 714
             $query->query_vars['meta_query'][] = array(
715 715
                 'key'     => '_wpinv_vat_rule',
@@ -734,97 +734,97 @@  discard block
 block discarded – undo
734 734
                 'value'   => sanitize_text_field( $_GET['type'] ),
735 735
                 'compare' => '='
736 736
             );
737
-		}
738
-
739
-	}
740
-
741
-	/**
742
-	 * Reorders items.
743
-	 */
744
-	public static function reorder_items( $vars ) {
745
-		global $typenow;
746
-
747
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
748
-			return $vars;
749
-		}
750
-
751
-		// By item type.
752
-		if ( 'type' == $vars['orderby'] ) {
753
-			return array_merge(
754
-				$vars,
755
-				array(
756
-					'meta_key' => '_wpinv_type',
757
-					'orderby'  => 'meta_value'
758
-				)
759
-			);
760
-		}
761
-
762
-		// By vat class.
763
-		if ( 'vat_class' == $vars['orderby'] ) {
764
-			return array_merge(
765
-				$vars,
766
-				array(
767
-					'meta_key' => '_wpinv_vat_class',
768
-					'orderby'  => 'meta_value'
769
-				)
770
-			);
771
-		}
772
-
773
-		// By vat rule.
774
-		if ( 'vat_rule' == $vars['orderby'] ) {
775
-			return array_merge(
776
-				$vars,
777
-				array(
778
-					'meta_key' => '_wpinv_vat_rule',
779
-					'orderby'  => 'meta_value'
780
-				)
781
-			);
782
-		}
783
-
784
-		// By price.
785
-		if ( 'price' == $vars['orderby'] ) {
786
-			return array_merge(
787
-				$vars,
788
-				array(
789
-					'meta_key' => '_wpinv_price',
790
-					'orderby'  => 'meta_value_num'
791
-				)
792
-			);
793
-		}
794
-
795
-		return $vars;
796
-
797
-	}
798
-
799
-	/**
800
-	 * Fired when deleting a post.
801
-	 */
802
-	public static function delete_post( $post_id ) {
803
-
804
-		switch ( get_post_type( $post_id ) ) {
805
-
806
-			case 'wpi_item' :
807
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
808
-				break;
809
-
810
-			case 'wpi_payment_form' :
811
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
812
-				break;
813
-
814
-			case 'wpi_discount' :
815
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
816
-				break;
817
-
818
-			case 'wpi_invoice' :
819
-				$invoice = new WPInv_Invoice( $post_id );
820
-				do_action( "getpaid_before_delete_invoice", $invoice );
821
-				$invoice->get_data_store()->delete_items( $invoice );
822
-				$invoice->get_data_store()->delete_special_fields( $invoice );
823
-				break;
824
-		}
825
-	}
826
-
827
-	/**
737
+        }
738
+
739
+    }
740
+
741
+    /**
742
+     * Reorders items.
743
+     */
744
+    public static function reorder_items( $vars ) {
745
+        global $typenow;
746
+
747
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
748
+            return $vars;
749
+        }
750
+
751
+        // By item type.
752
+        if ( 'type' == $vars['orderby'] ) {
753
+            return array_merge(
754
+                $vars,
755
+                array(
756
+                    'meta_key' => '_wpinv_type',
757
+                    'orderby'  => 'meta_value'
758
+                )
759
+            );
760
+        }
761
+
762
+        // By vat class.
763
+        if ( 'vat_class' == $vars['orderby'] ) {
764
+            return array_merge(
765
+                $vars,
766
+                array(
767
+                    'meta_key' => '_wpinv_vat_class',
768
+                    'orderby'  => 'meta_value'
769
+                )
770
+            );
771
+        }
772
+
773
+        // By vat rule.
774
+        if ( 'vat_rule' == $vars['orderby'] ) {
775
+            return array_merge(
776
+                $vars,
777
+                array(
778
+                    'meta_key' => '_wpinv_vat_rule',
779
+                    'orderby'  => 'meta_value'
780
+                )
781
+            );
782
+        }
783
+
784
+        // By price.
785
+        if ( 'price' == $vars['orderby'] ) {
786
+            return array_merge(
787
+                $vars,
788
+                array(
789
+                    'meta_key' => '_wpinv_price',
790
+                    'orderby'  => 'meta_value_num'
791
+                )
792
+            );
793
+        }
794
+
795
+        return $vars;
796
+
797
+    }
798
+
799
+    /**
800
+     * Fired when deleting a post.
801
+     */
802
+    public static function delete_post( $post_id ) {
803
+
804
+        switch ( get_post_type( $post_id ) ) {
805
+
806
+            case 'wpi_item' :
807
+                do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
808
+                break;
809
+
810
+            case 'wpi_payment_form' :
811
+                do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
812
+                break;
813
+
814
+            case 'wpi_discount' :
815
+                do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
816
+                break;
817
+
818
+            case 'wpi_invoice' :
819
+                $invoice = new WPInv_Invoice( $post_id );
820
+                do_action( "getpaid_before_delete_invoice", $invoice );
821
+                $invoice->get_data_store()->delete_items( $invoice );
822
+                $invoice->get_data_store()->delete_special_fields( $invoice );
823
+                break;
824
+        }
825
+    }
826
+
827
+    /**
828 828
      * Add a post display state for special GetPaid pages in the page list table.
829 829
      *
830 830
      * @param array   $post_states An array of post display states.
@@ -838,22 +838,22 @@  discard block
 block discarded – undo
838 838
             $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
839 839
         }
840 840
 
841
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
841
+        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
842 842
 
843
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
844
-				$post_states["getpaid_{$post_type}_history_page"] = sprintf(
845
-					__( 'GetPaid %s History Page', 'invoicing' ),
846
-					$label
847
-				);
848
-			}
843
+            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
844
+                $post_states["getpaid_{$post_type}_history_page"] = sprintf(
845
+                    __( 'GetPaid %s History Page', 'invoicing' ),
846
+                    $label
847
+                );
848
+            }
849 849
 
850
-		}
850
+        }
851 851
 		
852
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
852
+        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
853 853
             $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
854 854
         }
855 855
 
856
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
856
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
857 857
             $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
858 858
         }
859 859
 
Please login to merge, or discard this patch.
Spacing   +230 added lines, -230 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,7 +124,7 @@  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
 		}
@@ -140,31 +140,31 @@  discard block
 block discarded – undo
140 140
 	 * @param WP_Post $post
141 141
      * @return array $actions actions without edit option
142 142
      */
143
-    public static function filter_invoice_row_actions( $actions, $post ) {
143
+    public static function filter_invoice_row_actions($actions, $post) {
144 144
 
145
-        if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
145
+        if (getpaid_is_invoice_post_type($post->post_type)) {
146 146
 
147 147
 			$actions = array();
148
-			$invoice = new WPInv_Invoice( $post );
148
+			$invoice = new WPInv_Invoice($post);
149 149
 
150
-			$actions['edit'] =  sprintf(
150
+			$actions['edit'] = sprintf(
151 151
 				'<a href="%1$s">%2$s</a>',
152
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
153
-				esc_html( __( 'Edit', 'invoicing' ) )
152
+				esc_url(get_edit_post_link($invoice->get_id())),
153
+				esc_html(__('Edit', 'invoicing'))
154 154
 			);
155 155
 
156
-			if ( ! $invoice->is_draft() ) {
156
+			if (!$invoice->is_draft()) {
157 157
 
158
-				$actions['view'] =  sprintf(
158
+				$actions['view'] = sprintf(
159 159
 					'<a href="%1$s">%2$s</a>',
160
-					esc_url( $invoice->get_view_url() ),
160
+					esc_url($invoice->get_view_url()),
161 161
 					sprintf(
162
-						esc_html( __( 'View %s', 'invoicing' ) ),
163
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
162
+						esc_html(__('View %s', 'invoicing')),
163
+						getpaid_get_post_type_label($invoice->get_post_type(), false)
164 164
 					)
165 165
 				);
166 166
 
167
-				$actions['send'] =  sprintf(
167
+				$actions['send'] = sprintf(
168 168
 					'<a href="%1$s">%2$s</a>',
169 169
 					esc_url(
170 170
 						wp_nonce_url(
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 							'getpaid-nonce'
179 179
 						)
180 180
 					),
181
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
181
+					esc_html(__('Send to Customer', 'invoicing'))
182 182
 				);
183 183
 
184 184
 			}
@@ -191,42 +191,42 @@  discard block
 block discarded – undo
191 191
 	/**
192 192
 	 * Returns an array of invoice table columns.
193 193
 	 */
194
-	public static function invoice_columns( $columns ) {
194
+	public static function invoice_columns($columns) {
195 195
 
196 196
 		$columns = array(
197 197
 			'cb'                => $columns['cb'],
198
-			'number'            => __( 'Invoice', 'invoicing' ),
199
-			'customer'          => __( 'Customer', 'invoicing' ),
200
-			'invoice_date'      => __( 'Created', 'invoicing' ),
201
-			'payment_date'      => __( 'Completed', 'invoicing' ),
202
-			'amount'            => __( 'Amount', 'invoicing' ),
203
-			'recurring'         => __( 'Recurring', 'invoicing' ),
204
-			'status'            => __( 'Status', 'invoicing' ),
198
+			'number'            => __('Invoice', 'invoicing'),
199
+			'customer'          => __('Customer', 'invoicing'),
200
+			'invoice_date'      => __('Created', 'invoicing'),
201
+			'payment_date'      => __('Completed', 'invoicing'),
202
+			'amount'            => __('Amount', 'invoicing'),
203
+			'recurring'         => __('Recurring', 'invoicing'),
204
+			'status'            => __('Status', 'invoicing'),
205 205
 		);
206 206
 
207
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
207
+		return apply_filters('wpi_invoice_table_columns', $columns);
208 208
 	}
209 209
 
210 210
 	/**
211 211
 	 * Displays invoice table columns.
212 212
 	 */
213
-	public static function display_invoice_columns( $column_name, $post_id ) {
213
+	public static function display_invoice_columns($column_name, $post_id) {
214 214
 
215
-		$invoice = new WPInv_Invoice( $post_id );
215
+		$invoice = new WPInv_Invoice($post_id);
216 216
 
217
-		switch ( $column_name ) {
217
+		switch ($column_name) {
218 218
 
219 219
 			case 'invoice_date' :
220
-				$date_time = esc_attr( $invoice->get_created_date() );
221
-				$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
220
+				$date_time = esc_attr($invoice->get_created_date());
221
+				$date      = getpaid_format_date_value($date_time, "&mdash;", true);
222 222
 				echo "<span title='$date_time'>$date</span>";
223 223
 				break;
224 224
 
225 225
 			case 'payment_date' :
226 226
 
227
-				if ( $invoice->is_paid() ) {
228
-					$date_time = esc_attr( $invoice->get_completed_date() );
229
-					$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
227
+				if ($invoice->is_paid()) {
228
+					$date_time = esc_attr($invoice->get_completed_date());
229
+					$date      = getpaid_format_date_value($date_time, "&mdash;", true);
230 230
 					echo "<span title='$date_time'>$date</span>";
231 231
 				} else {
232 232
 					echo "&mdash;";
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
 			case 'amount' :
238 238
 
239 239
 				$amount = $invoice->get_total();
240
-				$formated_amount = wpinv_price( $amount, $invoice->get_currency() );
240
+				$formated_amount = wpinv_price($amount, $invoice->get_currency());
241 241
 
242
-				if ( $invoice->is_refunded() ) {
243
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
242
+				if ($invoice->is_refunded()) {
243
+					$refunded_amount = wpinv_price(0, $invoice->get_currency());
244 244
 					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
245 245
 				} else {
246 246
 
247 247
 					$discount = $invoice->get_total_discount();
248 248
 
249
-					if ( ! empty( $discount ) ) {
250
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
249
+					if (!empty($discount)) {
250
+						$new_amount = wpinv_price($amount + $discount, $invoice->get_currency());
251 251
 						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
252 252
 					} else {
253 253
 						echo $formated_amount;
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
 				break;
259 259
 
260 260
 			case 'status' :
261
-				$status       = esc_html( $invoice->get_status() );
262
-				$status_label = esc_html( $invoice->get_status_nicename() );
261
+				$status       = esc_html($invoice->get_status());
262
+				$status_label = esc_html($invoice->get_status_nicename());
263 263
 
264 264
 				// If it is paid, show the gateway title.
265
-				if ( $invoice->is_paid() ) {
266
-					$gateway = esc_html( $invoice->get_gateway_title() );
267
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
265
+				if ($invoice->is_paid()) {
266
+					$gateway = esc_html($invoice->get_gateway_title());
267
+					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway);
268 268
 
269 269
 					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
270 270
 				} else {
@@ -272,22 +272,22 @@  discard block
 block discarded – undo
272 272
 				}
273 273
 
274 274
 				// If it is not paid, display the overdue and view status.
275
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
275
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
276 276
 
277 277
 					// Invoice view status.
278
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
279
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
278
+					if (wpinv_is_invoice_viewed($invoice->get_id())) {
279
+						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>';
280 280
 					} else {
281
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
281
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
282 282
 					}
283 283
 
284 284
 					// Display the overview status.
285
-					if ( wpinv_get_option( 'overdue_active' ) ) {
285
+					if (wpinv_get_option('overdue_active')) {
286 286
 						$due_date = $invoice->get_due_date();
287
-						$fomatted = getpaid_format_date( $due_date );
287
+						$fomatted = getpaid_format_date($due_date);
288 288
 
289
-						if ( ! empty( $fomatted ) ) {
290
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
289
+						if (!empty($fomatted)) {
290
+							$date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted);
291 291
 							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
292 292
 						}
293 293
 					}
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 
299 299
 			case 'recurring':
300 300
 
301
-				if ( $invoice->is_recurring() ) {
301
+				if ($invoice->is_recurring()) {
302 302
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
303 303
 				} else {
304 304
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -307,9 +307,9 @@  discard block
 block discarded – undo
307 307
 
308 308
 			case 'number' :
309 309
 
310
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
311
-				$invoice_number  = esc_html( $invoice->get_number() );
312
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
310
+				$edit_link       = esc_url(get_edit_post_link($invoice->get_id()));
311
+				$invoice_number  = esc_html($invoice->get_number());
312
+				$invoice_details = esc_attr__('View Invoice Details', 'invoicing');
313 313
 
314 314
 				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
315 315
 
@@ -319,13 +319,13 @@  discard block
 block discarded – undo
319 319
 	
320 320
 				$customer_name = $invoice->get_user_full_name();
321 321
 	
322
-				if ( empty( $customer_name ) ) {
322
+				if (empty($customer_name)) {
323 323
 					$customer_name = $invoice->get_email();
324 324
 				}
325 325
 	
326
-				if ( ! empty( $customer_name ) ) {
327
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
328
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
326
+				if (!empty($customer_name)) {
327
+					$customer_details = esc_attr__('View Customer Details', 'invoicing');
328
+					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php')));
329 329
 					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
330 330
 				} else {
331 331
 					echo '<div>&mdash;</div>';
@@ -340,27 +340,27 @@  discard block
 block discarded – undo
340 340
 	/**
341 341
 	 * Displays invoice bulk actions.
342 342
 	 */
343
-	public static function invoice_bulk_actions( $actions ) {
344
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
343
+	public static function invoice_bulk_actions($actions) {
344
+		$actions['resend-invoice'] = __('Send to Customer', 'invoicing');
345 345
 		return $actions;
346 346
 	}
347 347
 
348 348
 	/**
349 349
 	 * Processes invoice bulk actions.
350 350
 	 */
351
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
351
+	public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) {
352 352
 
353
-		if ( $action == 'resend-invoice' ) {
353
+		if ($action == 'resend-invoice') {
354 354
 
355 355
 			$success = false;
356
-			foreach ( $post_ids as $post_id ) {
357
-				$success = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
356
+			foreach ($post_ids as $post_id) {
357
+				$success = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true);
358 358
 			}
359 359
 
360
-			if ( $success ) {
361
-				getpaid_admin()->show_success( __( 'Invoices were successfully sent', 'invoicing' ) );
360
+			if ($success) {
361
+				getpaid_admin()->show_success(__('Invoices were successfully sent', 'invoicing'));
362 362
 			} else {
363
-				getpaid_admin()->show_error( __( 'Could not send some invoices', 'invoicing' ) );
363
+				getpaid_admin()->show_error(__('Could not send some invoices', 'invoicing'));
364 364
 			}
365 365
 
366 366
 		}
@@ -372,50 +372,50 @@  discard block
 block discarded – undo
372 372
 	/**
373 373
 	 * Returns an array of payment forms table columns.
374 374
 	 */
375
-	public static function payment_form_columns( $columns ) {
375
+	public static function payment_form_columns($columns) {
376 376
 
377 377
 		$columns = array(
378 378
 			'cb'                => $columns['cb'],
379
-			'title'             => __( 'Name', 'invoicing' ),
380
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
381
-			'earnings'          => __( 'Revenue', 'invoicing' ),
382
-			'refunds'           => __( 'Refunded', 'invoicing' ),
383
-			'items'             => __( 'Items', 'invoicing' ),
384
-			'date'              => __( 'Date', 'invoicing' ),
379
+			'title'             => __('Name', 'invoicing'),
380
+			'shortcode'         => __('Shortcode', 'invoicing'),
381
+			'earnings'          => __('Revenue', 'invoicing'),
382
+			'refunds'           => __('Refunded', 'invoicing'),
383
+			'items'             => __('Items', 'invoicing'),
384
+			'date'              => __('Date', 'invoicing'),
385 385
 		);
386 386
 
387
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
387
+		return apply_filters('wpi_payment_form_table_columns', $columns);
388 388
 
389 389
 	}
390 390
 
391 391
 	/**
392 392
 	 * Displays payment form table columns.
393 393
 	 */
394
-	public static function display_payment_form_columns( $column_name, $post_id ) {
394
+	public static function display_payment_form_columns($column_name, $post_id) {
395 395
 
396 396
 		// Retrieve the payment form.
397
-		$form = new GetPaid_Payment_Form( $post_id );
397
+		$form = new GetPaid_Payment_Form($post_id);
398 398
 
399
-		switch ( $column_name ) {
399
+		switch ($column_name) {
400 400
 
401 401
 			case 'earnings' :
402
-				echo wpinv_price( $form->get_earned() );
402
+				echo wpinv_price($form->get_earned());
403 403
 				break;
404 404
 
405 405
 			case 'refunds' :
406
-				echo wpinv_price( $form->get_refunded() );
406
+				echo wpinv_price($form->get_refunded());
407 407
 				break;
408 408
 
409 409
 			case 'refunds' :
410
-				echo wpinv_price( $form->get_refunded() );
410
+				echo wpinv_price($form->get_refunded());
411 411
 				break;
412 412
 
413 413
 			case 'shortcode' :
414 414
 
415
-				if ( $form->is_default() ) {
415
+				if ($form->is_default()) {
416 416
 					echo '&mdash;';
417 417
 				} else {
418
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
418
+					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';
419 419
 				}
420 420
 
421 421
 				break;
@@ -424,29 +424,29 @@  discard block
 block discarded – undo
424 424
 
425 425
 				$items = $form->get_items();
426 426
 
427
-				if ( $form->is_default() || empty( $items ) ) {
427
+				if ($form->is_default() || empty($items)) {
428 428
 					echo '&mdash;';
429 429
 					return;
430 430
 				}
431 431
 
432 432
 				$_items = array();
433 433
 
434
-				foreach ( $items as $item ) {
434
+				foreach ($items as $item) {
435 435
 					$url = $item->get_edit_url();
436 436
 
437
-					if ( empty( $url ) ) {
438
-						$_items[] = esc_html( $item->get_name() );
437
+					if (empty($url)) {
438
+						$_items[] = esc_html($item->get_name());
439 439
 					} else {
440 440
 						$_items[] = sprintf(
441 441
 							'<a href="%s">%s</a>',
442
-							esc_url( $url ),
443
-							esc_html( $item->get_name() )
442
+							esc_url($url),
443
+							esc_html($item->get_name())
444 444
 						);
445 445
 					}
446 446
 
447 447
 				}
448 448
 
449
-				echo implode( '<br>', $_items );
449
+				echo implode('<br>', $_items);
450 450
 
451 451
 				break;
452 452
 
@@ -457,10 +457,10 @@  discard block
 block discarded – undo
457 457
 	/**
458 458
 	 * Filters post states.
459 459
 	 */
460
-	public static function filter_payment_form_state( $post_states, $post ) {
460
+	public static function filter_payment_form_state($post_states, $post) {
461 461
 
462
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
463
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
462
+		if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) {
463
+			$post_states['default_form'] = __('Default Payment Form', 'invoicing');
464 464
 		}
465 465
 	
466 466
 		return $post_states;
@@ -470,35 +470,35 @@  discard block
 block discarded – undo
470 470
 	/**
471 471
 	 * Returns an array of coupon table columns.
472 472
 	 */
473
-	public static function discount_columns( $columns ) {
473
+	public static function discount_columns($columns) {
474 474
 
475 475
 		$columns = array(
476 476
 			'cb'                => $columns['cb'],
477
-			'title'             => __( 'Name', 'invoicing' ),
478
-			'code'              => __( 'Code', 'invoicing' ),
479
-			'amount'            => __( 'Amount', 'invoicing' ),
480
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
481
-			'start_date'        => __( 'Start Date', 'invoicing' ),
482
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
477
+			'title'             => __('Name', 'invoicing'),
478
+			'code'              => __('Code', 'invoicing'),
479
+			'amount'            => __('Amount', 'invoicing'),
480
+			'usage'             => __('Usage / Limit', 'invoicing'),
481
+			'start_date'        => __('Start Date', 'invoicing'),
482
+			'expiry_date'       => __('Expiry Date', 'invoicing'),
483 483
 		);
484 484
 
485
-		return apply_filters( 'wpi_discount_table_columns', $columns );
485
+		return apply_filters('wpi_discount_table_columns', $columns);
486 486
 	}
487 487
 
488 488
 	/**
489 489
 	 * Filters post states.
490 490
 	 */
491
-	public static function filter_discount_state( $post_states, $post ) {
491
+	public static function filter_discount_state($post_states, $post) {
492 492
 
493
-		if ( 'wpi_discount' == $post->post_type ) {
493
+		if ('wpi_discount' == $post->post_type) {
494 494
 
495
-			$discount = new WPInv_Discount( $post );
495
+			$discount = new WPInv_Discount($post);
496 496
 
497 497
 			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
498 498
 
499
-			if ( $status != 'publish' ) {
499
+			if ($status != 'publish') {
500 500
 				return array(
501
-					'discount_status' => wpinv_discount_status( $status ),
501
+					'discount_status' => wpinv_discount_status($status),
502 502
 				);
503 503
 			}
504 504
 
@@ -513,30 +513,30 @@  discard block
 block discarded – undo
513 513
 	/**
514 514
 	 * Returns an array of items table columns.
515 515
 	 */
516
-	public static function item_columns( $columns ) {
516
+	public static function item_columns($columns) {
517 517
 
518 518
 		$columns = array(
519 519
 			'cb'                => $columns['cb'],
520
-			'title'             => __( 'Name', 'invoicing' ),
521
-			'price'             => __( 'Price', 'invoicing' ),
522
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
523
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
524
-			'type'              => __( 'Type', 'invoicing' ),
525
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
520
+			'title'             => __('Name', 'invoicing'),
521
+			'price'             => __('Price', 'invoicing'),
522
+			'vat_rule'          => __('VAT rule', 'invoicing'),
523
+			'vat_class'         => __('VAT class', 'invoicing'),
524
+			'type'              => __('Type', 'invoicing'),
525
+			'shortcode'         => __('Shortcode', 'invoicing'),
526 526
 		);
527 527
 
528
-		if ( ! wpinv_use_taxes() ) {
529
-			unset( $columns['vat_rule'] );
530
-			unset( $columns['vat_class'] );
528
+		if (!wpinv_use_taxes()) {
529
+			unset($columns['vat_rule']);
530
+			unset($columns['vat_class']);
531 531
 		}
532 532
 
533
-		return apply_filters( 'wpi_item_table_columns', $columns );
533
+		return apply_filters('wpi_item_table_columns', $columns);
534 534
 	}
535 535
 
536 536
 	/**
537 537
 	 * Returns an array of sortable items table columns.
538 538
 	 */
539
-	public static function sortable_item_columns( $columns ) {
539
+	public static function sortable_item_columns($columns) {
540 540
 
541 541
 		return array_merge(
542 542
 			$columns,
@@ -553,49 +553,49 @@  discard block
 block discarded – undo
553 553
 	/**
554 554
 	 * Displays items table columns.
555 555
 	 */
556
-	public static function display_item_columns( $column_name, $post_id ) {
556
+	public static function display_item_columns($column_name, $post_id) {
557 557
  
558
-		$item = new WPInv_Item( $post_id );
558
+		$item = new WPInv_Item($post_id);
559 559
 
560
-		switch ( $column_name ) {
560
+		switch ($column_name) {
561 561
 
562 562
 			case 'price' :
563 563
 
564
-				if ( ! $item->is_recurring() ) {
564
+				if (!$item->is_recurring()) {
565 565
 					echo $item->get_the_price();
566 566
 					break;
567 567
 				}
568 568
 
569 569
 				$price = wp_sprintf(
570
-					__( '%s / %s', 'invoicing' ),
570
+					__('%s / %s', 'invoicing'),
571 571
 					$item->get_the_price(),
572
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
572
+					getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '')
573 573
 				);
574 574
 
575
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
575
+				if ($item->get_the_price() == $item->get_the_initial_price()) {
576 576
 					echo $price;
577 577
 					break;
578 578
 				}
579 579
 
580 580
 				echo $item->get_the_initial_price();
581 581
 
582
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
582
+				echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>';
583 583
 				break;
584 584
 
585 585
 			case 'vat_rule' :
586
-				echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
586
+				echo getpaid_get_tax_rule_label($item->get_vat_rule());
587 587
 				break;
588 588
 
589 589
 			case 'vat_class' :
590
-				echo getpaid_get_tax_class_label( $item->get_vat_class() );
590
+				echo getpaid_get_tax_class_label($item->get_vat_class());
591 591
 				break;
592 592
 
593 593
 			case 'shortcode' :
594
-				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
594
+				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
595 595
 				break;
596 596
 
597 597
 			case 'type' :
598
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
598
+				echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
599 599
 				break;
600 600
 
601 601
 		}
@@ -605,21 +605,21 @@  discard block
 block discarded – undo
605 605
 	/**
606 606
 	 * Lets users filter items using taxes.
607 607
 	 */
608
-	public static function add_item_filters( $post_type ) {
608
+	public static function add_item_filters($post_type) {
609 609
 
610 610
 		// Abort if we're not dealing with items.
611
-		if ( $post_type != 'wpi_item' ) {
611
+		if ($post_type != 'wpi_item') {
612 612
 			return;
613 613
 		}
614 614
 
615 615
 		// Filter by vat rules.
616
-		if ( wpinv_use_taxes() ) {
616
+		if (wpinv_use_taxes()) {
617 617
 	
618 618
 			// Sanitize selected vat rule.
619 619
 			$vat_rule   = '';
620 620
 			$vat_rules  = getpaid_get_tax_rules();
621
-			if ( isset( $_GET['vat_rule'] ) ) {
622
-				$vat_rule   =  $_GET['vat_rule'];
621
+			if (isset($_GET['vat_rule'])) {
622
+				$vat_rule = $_GET['vat_rule'];
623 623
 			}
624 624
 
625 625
 			// Filter by VAT rule.
@@ -627,13 +627,13 @@  discard block
 block discarded – undo
627 627
 				array(
628 628
 					'options'          => array_merge(
629 629
 						array(
630
-							'' => __( 'All VAT rules', 'invoicing' )
630
+							'' => __('All VAT rules', 'invoicing')
631 631
 						),
632 632
 						$vat_rules
633 633
 					),
634 634
 					'name'             => 'vat_rule',
635 635
 					'id'               => 'vat_rule',
636
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
636
+					'selected'         => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '',
637 637
 					'show_option_all'  => false,
638 638
 					'show_option_none' => false,
639 639
 				)
@@ -644,21 +644,21 @@  discard block
 block discarded – undo
644 644
 			// Sanitize selected vat rule.
645 645
 			$vat_class   = '';
646 646
 			$vat_classes = getpaid_get_tax_classes();
647
-			if ( isset( $_GET['vat_class'] ) ) {
648
-				$vat_class   =  $_GET['vat_class'];
647
+			if (isset($_GET['vat_class'])) {
648
+				$vat_class = $_GET['vat_class'];
649 649
 			}
650 650
 
651 651
 			echo wpinv_html_select(
652 652
 				array(
653 653
 					'options'          => array_merge(
654 654
 						array(
655
-							'' => __( 'All VAT classes', 'invoicing' )
655
+							'' => __('All VAT classes', 'invoicing')
656 656
 						),
657 657
 						$vat_classes
658 658
 					),
659 659
 					'name'             => 'vat_class',
660 660
 					'id'               => 'vat_class',
661
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
661
+					'selected'         => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '',
662 662
 					'show_option_all'  => false,
663 663
 					'show_option_none' => false,
664 664
 				)
@@ -667,22 +667,22 @@  discard block
 block discarded – undo
667 667
 		}
668 668
 
669 669
 		// Filter by item type.
670
-		$type   = '';
671
-		if ( isset( $_GET['type'] ) ) {
672
-			$type   =  $_GET['type'];
670
+		$type = '';
671
+		if (isset($_GET['type'])) {
672
+			$type = $_GET['type'];
673 673
 		}
674 674
 
675 675
 		echo wpinv_html_select(
676 676
 			array(
677 677
 				'options'          => array_merge(
678 678
 					array(
679
-						'' => __( 'All item types', 'invoicing' )
679
+						'' => __('All item types', 'invoicing')
680 680
 					),
681 681
 					wpinv_get_item_types()
682 682
 				),
683 683
 				'name'             => 'type',
684 684
 				'id'               => 'type',
685
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
685
+				'selected'         => in_array($type, wpinv_item_types()) ? $type : '',
686 686
 				'show_option_all'  => false,
687 687
 				'show_option_none' => false,
688 688
 			)
@@ -693,45 +693,45 @@  discard block
 block discarded – undo
693 693
 	/**
694 694
 	 * Filters the item query.
695 695
 	 */
696
-	public static function filter_item_query( $query ) {
696
+	public static function filter_item_query($query) {
697 697
 
698 698
 		// modify the query only if it admin and main query.
699
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
699
+		if (!(is_admin() && $query->is_main_query())) { 
700 700
 			return $query;
701 701
 		}
702 702
 
703 703
 		// we want to modify the query for our items.
704
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
704
+		if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) {
705 705
 			return $query;
706 706
 		}
707 707
 
708
-		if ( empty( $query->query_vars['meta_query'] ) ) {
708
+		if (empty($query->query_vars['meta_query'])) {
709 709
 			$query->query_vars['meta_query'] = array();
710 710
 		}
711 711
 
712 712
 		// Filter vat rule type
713
-        if ( ! empty( $_GET['vat_rule'] ) ) {
713
+        if (!empty($_GET['vat_rule'])) {
714 714
             $query->query_vars['meta_query'][] = array(
715 715
                 'key'     => '_wpinv_vat_rule',
716
-                'value'   => sanitize_text_field( $_GET['vat_rule'] ),
716
+                'value'   => sanitize_text_field($_GET['vat_rule']),
717 717
                 'compare' => '='
718 718
             );
719 719
         }
720 720
 
721 721
         // Filter vat class
722
-        if ( ! empty( $_GET['vat_class'] ) ) {
722
+        if (!empty($_GET['vat_class'])) {
723 723
             $query->query_vars['meta_query'][] = array(
724 724
                 'key'     => '_wpinv_vat_class',
725
-                'value'   => sanitize_text_field( $_GET['vat_class'] ),
725
+                'value'   => sanitize_text_field($_GET['vat_class']),
726 726
                 'compare' => '='
727 727
             );
728 728
         }
729 729
 
730 730
         // Filter item type
731
-        if ( ! empty( $_GET['type'] ) ) {
731
+        if (!empty($_GET['type'])) {
732 732
             $query->query_vars['meta_query'][] = array(
733 733
                 'key'     => '_wpinv_type',
734
-                'value'   => sanitize_text_field( $_GET['type'] ),
734
+                'value'   => sanitize_text_field($_GET['type']),
735 735
                 'compare' => '='
736 736
             );
737 737
 		}
@@ -741,15 +741,15 @@  discard block
 block discarded – undo
741 741
 	/**
742 742
 	 * Reorders items.
743 743
 	 */
744
-	public static function reorder_items( $vars ) {
744
+	public static function reorder_items($vars) {
745 745
 		global $typenow;
746 746
 
747
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
747
+		if ('wpi_item' !== $typenow || empty($vars['orderby'])) {
748 748
 			return $vars;
749 749
 		}
750 750
 
751 751
 		// By item type.
752
-		if ( 'type' == $vars['orderby'] ) {
752
+		if ('type' == $vars['orderby']) {
753 753
 			return array_merge(
754 754
 				$vars,
755 755
 				array(
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 		}
761 761
 
762 762
 		// By vat class.
763
-		if ( 'vat_class' == $vars['orderby'] ) {
763
+		if ('vat_class' == $vars['orderby']) {
764 764
 			return array_merge(
765 765
 				$vars,
766 766
 				array(
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 		}
772 772
 
773 773
 		// By vat rule.
774
-		if ( 'vat_rule' == $vars['orderby'] ) {
774
+		if ('vat_rule' == $vars['orderby']) {
775 775
 			return array_merge(
776 776
 				$vars,
777 777
 				array(
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 		}
783 783
 
784 784
 		// By price.
785
-		if ( 'price' == $vars['orderby'] ) {
785
+		if ('price' == $vars['orderby']) {
786 786
 			return array_merge(
787 787
 				$vars,
788 788
 				array(
@@ -799,27 +799,27 @@  discard block
 block discarded – undo
799 799
 	/**
800 800
 	 * Fired when deleting a post.
801 801
 	 */
802
-	public static function delete_post( $post_id ) {
802
+	public static function delete_post($post_id) {
803 803
 
804
-		switch ( get_post_type( $post_id ) ) {
804
+		switch (get_post_type($post_id)) {
805 805
 
806 806
 			case 'wpi_item' :
807
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
807
+				do_action("getpaid_before_delete_item", new WPInv_Item($post_id));
808 808
 				break;
809 809
 
810 810
 			case 'wpi_payment_form' :
811
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
811
+				do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id));
812 812
 				break;
813 813
 
814 814
 			case 'wpi_discount' :
815
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
815
+				do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id));
816 816
 				break;
817 817
 
818 818
 			case 'wpi_invoice' :
819
-				$invoice = new WPInv_Invoice( $post_id );
820
-				do_action( "getpaid_before_delete_invoice", $invoice );
821
-				$invoice->get_data_store()->delete_items( $invoice );
822
-				$invoice->get_data_store()->delete_special_fields( $invoice );
819
+				$invoice = new WPInv_Invoice($post_id);
820
+				do_action("getpaid_before_delete_invoice", $invoice);
821
+				$invoice->get_data_store()->delete_items($invoice);
822
+				$invoice->get_data_store()->delete_special_fields($invoice);
823 823
 				break;
824 824
 		}
825 825
 	}
@@ -832,29 +832,29 @@  discard block
 block discarded – undo
832 832
      *
833 833
      * @return mixed
834 834
      */
835
-    public static function add_display_post_states( $post_states, $post ) {
835
+    public static function add_display_post_states($post_states, $post) {
836 836
 
837
-        if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) {
838
-            $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
837
+        if (wpinv_get_option('success_page', 0) == $post->ID) {
838
+            $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing');
839 839
         }
840 840
 
841
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
841
+		foreach (getpaid_get_invoice_post_types() as $post_type => $label) {
842 842
 
843
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
843
+			if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) {
844 844
 				$post_states["getpaid_{$post_type}_history_page"] = sprintf(
845
-					__( 'GetPaid %s History Page', 'invoicing' ),
845
+					__('GetPaid %s History Page', 'invoicing'),
846 846
 					$label
847 847
 				);
848 848
 			}
849 849
 
850 850
 		}
851 851
 		
852
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
853
-            $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
852
+		if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) {
853
+            $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing');
854 854
         }
855 855
 
856
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
857
-            $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
856
+		if (wpinv_get_option('checkout_page', 0) == $post->ID) {
857
+            $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing');
858 858
         }
859 859
 
860 860
         return $post_states;
Please login to merge, or discard this patch.
includes/admin/views/html-gateways-edit.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,29 +4,29 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 $gateways = wpinv_get_payment_gateways();
10
-ksort( $gateways );
10
+ksort($gateways);
11 11
 
12 12
 ?>
13 13
 <div class="table-responsive">
14 14
     <table id="wpinv_gateways_select" class="table border bg-white form-table">
15
-        <caption><?php echo esc_html_e( 'This table displays installed payment methods.', 'invoicing' ); ?></caption>
15
+        <caption><?php echo esc_html_e('This table displays installed payment methods.', 'invoicing'); ?></caption>
16 16
 
17 17
         <thead>
18 18
             <tr class="table-light">
19 19
 
20 20
                 <th scope="col" class="border-bottom border-top text-left">
21
-                    <?php _e( 'Payment Method', 'invoicing' ); ?>
21
+                    <?php _e('Payment Method', 'invoicing'); ?>
22 22
                 </th>
23 23
 
24 24
                 <th scope="col" class="border-bottom border-top text-center">
25
-                    <?php _e( 'Enabled', 'invoicing' ); ?>
25
+                    <?php _e('Enabled', 'invoicing'); ?>
26 26
                 </th>
27 27
 
28 28
                 <th scope="col" class="border-bottom border-top text-center">
29
-                    <?php _e( 'Supports Subscriptions', 'invoicing' ); ?>
29
+                    <?php _e('Supports Subscriptions', 'invoicing'); ?>
30 30
                 </th>
31 31
 
32 32
                 <th scope="col" class="border-bottom border-top text-right" style="width:32px">&nbsp;</th>
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
35 35
         </thead>
36 36
 
37 37
         <tbody>
38
-            <?php foreach ( $gateways as $id => $gateway ) : ?>
38
+            <?php foreach ($gateways as $id => $gateway) : ?>
39 39
                 <tr>
40 40
                     <td class="getpaid-payment-method text-left">
41
-                        <a style="color: #0073aa;" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>" class="font-weight-bold"><?php echo esc_html( $gateway['admin_label'] ); ?></a>
41
+                        <a style="color: #0073aa;" href="<?php echo esc_url(add_query_arg('section', $id)); ?>" class="font-weight-bold"><?php echo esc_html($gateway['admin_label']); ?></a>
42 42
                     </td>
43 43
                     <td class="getpaid-payment-method-enabled text-center">
44 44
                         <?php
45 45
 
46
-                            if ( wpinv_is_gateway_active( $id ) ) {
46
+                            if (wpinv_is_gateway_active($id)) {
47 47
                                 echo "<i class='text-success fa fa-check'></i>";
48 48
                             } else {
49 49
                                 echo "<i class='text-dark fa fa-times'></i>";
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
                     <td class="getpaid-payment-method-subscription text-center">
55 55
                         <?php
56 56
 
57
-                            $supports = apply_filters( "wpinv_{$id}_support_subscription", false );
58
-                            $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $id );
57
+                            $supports = apply_filters("wpinv_{$id}_support_subscription", false);
58
+                            $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $id);
59 59
 
60
-                            if ( $supports ) {
60
+                            if ($supports) {
61 61
                                 echo "<i class='text-success fa fa-check'></i>";
62 62
                             } else {
63 63
                                 echo "<i class='text-dark fa fa-times'></i>";
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
                     </td>
68 68
 
69 69
                     <td class="getpaid-payment-method-action text-right">
70
-                        <a class="button button-secondary" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>"><?php _e( 'Manage', 'invoicing' ); ?></a>
70
+                        <a class="button button-secondary" href="<?php echo esc_url(add_query_arg('section', $id)); ?>"><?php _e('Manage', 'invoicing'); ?></a>
71 71
                     </td>
72 72
 
73 73
                 </tr>
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
         <tfoot>
78 78
             <tr class="table-light">
79 79
                 <td colspan="4" class="border-top">
80
-                    <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url( admin_url( 'admin.php?page=wpi-addons&tab=gateways' ) ); ?>">
81
-                        <span><?php _e( 'Add Payment Methods', 'invoicing' ); ?></span>
80
+                    <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url(admin_url('admin.php?page=wpi-addons&tab=gateways')); ?>">
81
+                        <span><?php _e('Add Payment Methods', 'invoicing'); ?></span>
82 82
                     </a>
83 83
                 </td>
84 84
             </tr>
Please login to merge, or discard this patch.
includes/admin/views/html-tax-rate-edit.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @var array $tax_rate
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 ?>
12 12
 
@@ -18,54 +18,54 @@  discard block
 block discarded – undo
18 18
             $country = aui()->select(
19 19
                 array(
20 20
                     'options'     => array_merge(
21
-                        array( '' => __( 'All Countries', 'invoicing' ) ),
21
+                        array('' => __('All Countries', 'invoicing')),
22 22
                         wpinv_get_country_list()
23 23
                     ),
24 24
                     'name'        => "tax_rates[$key][country]",
25
-                    'id'          => uniqid( 'tax_rate_country' ),
26
-                    'value'       => esc_html( $tax_rate['country'] ),
27
-                    'label'       => __( 'Country', 'invoicing' ),
25
+                    'id'          => uniqid('tax_rate_country'),
26
+                    'value'       => esc_html($tax_rate['country']),
27
+                    'label'       => __('Country', 'invoicing'),
28 28
                     'class'       => 'wpinv_country',
29 29
                     'no_wrap'     => true,
30 30
                 )
31 31
             );
32 32
 
33
-            echo str_replace( 'custom-select', '', $country );
33
+            echo str_replace('custom-select', '', $country);
34 34
         ?>
35 35
     </td>
36 36
 
37 37
     <td class="wpinv_tax_state">
38 38
 
39 39
         <label class="w-100">
40
-            <span class="screen-reader-text"><?php _e( 'States', 'invoicing' ); ?></span>
41
-            <input type="text" placeholder="<?php esc_attr_e( 'Apply to whole country', 'invoicing' ); ?>" name="tax_rates[<?php echo esc_attr( $key ) ?>][state]" value="<?php echo empty( $tax_rate['global'] ) ? esc_attr( $tax_rate['state'] ) : ''; ?>"/>
40
+            <span class="screen-reader-text"><?php _e('States', 'invoicing'); ?></span>
41
+            <input type="text" placeholder="<?php esc_attr_e('Apply to whole country', 'invoicing'); ?>" name="tax_rates[<?php echo esc_attr($key) ?>][state]" value="<?php echo empty($tax_rate['global']) ? esc_attr($tax_rate['state']) : ''; ?>"/>
42 42
         </label>
43 43
 
44 44
     </td>
45 45
 
46 46
     <td class="wpinv_standard_rate">
47 47
         <label class="w-100">
48
-            <span class="screen-reader-text"><?php _e( 'Standard Rate', 'invoicing' ); ?></span>
49
-            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ) ?>][rate]" value="<?php echo wpinv_sanitize_amount( $tax_rate['rate'] ); ?>"/>
48
+            <span class="screen-reader-text"><?php _e('Standard Rate', 'invoicing'); ?></span>
49
+            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key) ?>][rate]" value="<?php echo wpinv_sanitize_amount($tax_rate['rate']); ?>"/>
50 50
         </label>
51 51
     </td>
52 52
 
53 53
     <td class="wpinv_reduced_rate">
54 54
         <label class="w-100">
55
-            <span class="screen-reader-text"><?php _e( 'Reduced Rate', 'invoicing' ); ?></span>
56
-            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ) ?>][reduced_rate]" value="<?php echo wpinv_sanitize_amount( $tax_rate['reduced_rate'] ); ?>"/>
55
+            <span class="screen-reader-text"><?php _e('Reduced Rate', 'invoicing'); ?></span>
56
+            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key) ?>][reduced_rate]" value="<?php echo wpinv_sanitize_amount($tax_rate['reduced_rate']); ?>"/>
57 57
         </label>
58 58
     </td>
59 59
 
60 60
     <td class="wpinv_tax_name">
61 61
         <label class="w-100">
62
-            <span class="screen-reader-text"><?php _e( 'Tax Name', 'invoicing' ); ?></span>
63
-            <input type="text" name="tax_rates[<?php echo esc_attr( $key ) ?>][name]" value="<?php echo esc_attr( $tax_rate['name'] ); ?>"/>
62
+            <span class="screen-reader-text"><?php _e('Tax Name', 'invoicing'); ?></span>
63
+            <input type="text" name="tax_rates[<?php echo esc_attr($key) ?>][name]" value="<?php echo esc_attr($tax_rate['name']); ?>"/>
64 64
         </label>
65 65
     </td>
66 66
 
67 67
     <td class="wpinv_tax_remove">
68
-        <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>" title="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>">
68
+        <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e('Delete', 'invoicing'); ?>" title="<?php esc_attr_e('Delete', 'invoicing'); ?>">
69 69
             <span aria-hidden="true">&times;</span>
70 70
         </button>
71 71
     </td>
Please login to merge, or discard this patch.
templates/payment-forms/cart.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,36 +7,36 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Cart table columns.
13 13
 $columns = array(
14
-    'name'     => __( 'Item', 'invoicing' ),
15
-    'price'    => __( 'Price', 'invoicing' ),
16
-    'quantity' => __( 'Qty', 'invoicing' ),
17
-    'subtotal' => __( 'Subtotal', 'invoicing' ),
14
+    'name'     => __('Item', 'invoicing'),
15
+    'price'    => __('Price', 'invoicing'),
16
+    'quantity' => __('Qty', 'invoicing'),
17
+    'subtotal' => __('Subtotal', 'invoicing'),
18 18
 );
19 19
 
20
-if ( ! empty( $form->invoice ) ) {
21
-    $columns = getpaid_invoice_item_columns( $form->invoice );
20
+if (!empty($form->invoice)) {
21
+    $columns = getpaid_invoice_item_columns($form->invoice);
22 22
 }
23 23
 
24
-if ( isset( $columns['tax_rate'] ) ) {
25
-    unset( $columns['tax_rate'] );
24
+if (isset($columns['tax_rate'])) {
25
+    unset($columns['tax_rate']);
26 26
 }
27 27
 
28
-$columns = apply_filters( 'getpaid_payment_form_cart_table_columns', $columns, $form );
28
+$columns = apply_filters('getpaid_payment_form_cart_table_columns', $columns, $form);
29 29
 
30
-do_action( 'getpaid_before_payment_form_cart', $form );
30
+do_action('getpaid_before_payment_form_cart', $form);
31 31
 
32 32
 ?>
33 33
     <div class="getpaid-payment-form-items-cart border form-group">
34 34
 
35 35
         <div class="getpaid-payment-form-items-cart-header font-weight-bold bg-light border-bottom py-2 px-3">
36 36
             <div class="form-row">
37
-                <?php foreach ( $columns as $key => $label ) : ?>
38
-                    <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>">
39
-                        <span><?php echo esc_html( $label ); ?></span>
37
+                <?php foreach ($columns as $key => $label) : ?>
38
+                    <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>">
39
+                        <span><?php echo esc_html($label); ?></span>
40 40
                     </div>
41 41
                 <?php endforeach; ?>
42 42
             </div>
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
         <?php
46 46
 
47 47
             // Display the item totals.
48
-            foreach ( $form->get_items() as $item ) {
49
-                wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) );
48
+            foreach ($form->get_items() as $item) {
49
+                wpinv_get_template('payment-forms/cart-item.php', compact('form', 'item', 'columns'));
50 50
             }
51 51
 
52 52
             // Display the cart totals.
53
-            wpinv_get_template( 'payment-forms/cart-totals.php', compact( 'form' ) );
53
+            wpinv_get_template('payment-forms/cart-totals.php', compact('form'));
54 54
 
55 55
         ?>
56 56
     </div>
57 57
 
58 58
 <?php 
59 59
 
60
-do_action( 'getpaid_after_payment_form_cart', $form );
60
+do_action('getpaid_after_payment_form_cart', $form);
Please login to merge, or discard this patch.
templates/payment-forms/elements/price_select.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Ensure that we have options.
13
-if ( empty( $options ) ) {
13
+if (empty($options)) {
14 14
     return;
15 15
 }
16 16
 
17 17
 // Prepare price options.
18
-$options = getpaid_convert_price_string_to_options( $options );
19
-$keys    = array_keys( $options );
20
-$value   = empty( $options ) ? '' : $keys[0];
18
+$options = getpaid_convert_price_string_to_options($options);
19
+$keys    = array_keys($options);
20
+$value   = empty($options) ? '' : $keys[0];
21 21
 
22 22
 // Prepare id.
23
-$id = esc_attr( $id );
23
+$id = esc_attr($id);
24 24
 
25
-$select_type = empty( $select_type ) ? 'select' : $select_type;
25
+$select_type = empty($select_type) ? 'select' : $select_type;
26 26
 
27 27
 // Item select;
28
-if ( $select_type == 'select' ) {
28
+if ($select_type == 'select') {
29 29
     echo aui()->select(
30 30
         array(
31 31
             'name'       => $id,
32
-            'id'         => $id . uniqid( '_' ),
33
-            'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ),
32
+            'id'         => $id . uniqid('_'),
33
+            'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder),
34 34
             'value'      => $value,
35
-            'label'      => empty( $label ) ? '' : esc_html( $label ),
35
+            'label'      => empty($label) ? '' : esc_html($label),
36 36
             'label_type' => 'vertical',
37 37
             'class'      => 'getpaid-price-select-dropdown getpaid-refresh-on-change',
38
-            'help_text'  => empty( $description ) ? '' : wp_kses_post( $description ),
38
+            'help_text'  => empty($description) ? '' : wp_kses_post($description),
39 39
             'options'    => $options,
40 40
         )
41 41
     );
@@ -43,18 +43,18 @@  discard block
 block discarded – undo
43 43
 }
44 44
 
45 45
 // Item radios;
46
-if ( $select_type == 'radios' ) {
46
+if ($select_type == 'radios') {
47 47
     echo aui()->radio(
48 48
         array(
49
-            'name'       => esc_attr( $id ),
50
-            'id'         => esc_attr( $id ) . uniqid( '_' ),
51
-            'label'      => empty( $label ) ? '' : esc_html( $label ),
49
+            'name'       => esc_attr($id),
50
+            'id'         => esc_attr($id) . uniqid('_'),
51
+            'label'      => empty($label) ? '' : esc_html($label),
52 52
             'label_type' => 'vertical',
53 53
             'class'      => 'getpaid-price-select-radio getpaid-refresh-on-change w-100',
54 54
             'value'      => $value,
55 55
             'inline'     => false,
56 56
             'options'    => $options,
57
-            'help_text'  => empty( $description ) ? '' : wp_kses_post( $description ),
57
+            'help_text'  => empty($description) ? '' : wp_kses_post($description),
58 58
         )
59 59
     );
60 60
     return;
@@ -62,30 +62,30 @@  discard block
 block discarded – undo
62 62
 
63 63
 
64 64
 // Display the label.
65
-if ( ! empty( $label ) ) {
66
-    $label = esc_html( $label );
65
+if (!empty($label)) {
66
+    $label = esc_html($label);
67 67
     echo "<label>$label</label>";
68 68
 }
69 69
 
70 70
 // Item buttons;
71
-if ( $select_type == 'buttons' || $select_type == 'circles' ) {
71
+if ($select_type == 'buttons' || $select_type == 'circles') {
72 72
 
73 73
     $class = 'getpaid-price-buttons';
74 74
 
75
-    if ( $select_type == 'circles' ) {
75
+    if ($select_type == 'circles') {
76 76
         $class .= ' getpaid-price-circles';
77 77
     }
78 78
     echo "<div class='$class'>";
79 79
 
80
-    foreach ( $options as $price => $label ) {
81
-        $label   = esc_html( $label );
82
-        $price   = esc_attr( $price );
83
-        $_id     = $id . uniqid( '_' );
84
-        $checked = checked( $price, $value, false );
80
+    foreach ($options as $price => $label) {
81
+        $label   = esc_html($label);
82
+        $price   = esc_attr($price);
83
+        $_id     = $id . uniqid('_');
84
+        $checked = checked($price, $value, false);
85 85
 
86 86
         $class = 'rounded';
87 87
 
88
-        if ( $select_type == 'circles' ) {
88
+        if ($select_type == 'circles') {
89 89
             $class = '';
90 90
         }
91 91
         echo "
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
 }
102 102
 
103 103
 // Item checkboxes;
104
-if ( $select_type == 'checkboxes' ) {
104
+if ($select_type == 'checkboxes') {
105 105
     echo '<div class="form-group">';
106 106
 
107
-    foreach ( $options as $price => $label ) {
108
-        $label   = esc_html( $label );
109
-        $price   = esc_attr( $price );
110
-        $checked = checked( $price, $value, false );
107
+    foreach ($options as $price => $label) {
108
+        $label   = esc_html($label);
109
+        $price   = esc_attr($price);
110
+        $checked = checked($price, $value, false);
111 111
         echo "
112 112
             <label class='d-block'>
113 113
                 <input type='checkbox' class='getpaid-price-select-checkbox getpaid-refresh-on-change w-auto' name='{$id}[]' value='$price' $checked />
@@ -120,6 +120,6 @@  discard block
 block discarded – undo
120 120
 
121 121
 }
122 122
 
123
-if ( ! empty( $description ) ) {
123
+if (!empty($description)) {
124 124
     echo "<small class='form-text text-muted'>$description</small>";
125 125
 }
Please login to merge, or discard this patch.
templates/payment-forms/elements/ip_address.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-if ( empty( $text ) ) {
13
-    $text = __( 'Your IP address is:', 'invoicing' );
12
+if (empty($text)) {
13
+    $text = __('Your IP address is:', 'invoicing');
14 14
 }
15 15
 
16
-$ip_address = esc_html( wpinv_get_ip() );
16
+$ip_address = esc_html(wpinv_get_ip());
17 17
 
18 18
 ?>
19 19
 <div class="form-group getpaid-ip-info">
20
-    <span><?php echo wp_kses_post( $text ); ?></span>
20
+    <span><?php echo wp_kses_post($text); ?></span>
21 21
     <strong><?php echo $ip_address; ?></strong>
22 22
 </div>
Please login to merge, or discard this patch.
templates/payment-forms/elements/discount.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@
 block discarded – undo
8 8
  * @var GetPaid_Payment_Form $form The current payment form
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13
-if ( ! getpaid_has_published_discount() ) {
13
+if (!getpaid_has_published_discount()) {
14 14
     return;
15 15
 }
16 16
 
17
-$placeholder = esc_attr( $input_label );
18
-$label       = esc_html( $button_label );
17
+$placeholder = esc_attr($input_label);
18
+$label       = esc_html($button_label);
19 19
 
20
-if ( ! empty( $description ) ) {
20
+if (!empty($description)) {
21 21
     $description = "<small class='form-text text-muted'>$description</small>";
22 22
 } else {
23 23
     $description = '';
24 24
 }
25 25
 
26 26
 $discount_code = '';
27
-if ( ! empty( $form->invoice ) ) {
28
-    $discount_code = esc_attr( $form->invoice->get_discount_code() );
27
+if (!empty($form->invoice)) {
28
+    $discount_code = esc_attr($form->invoice->get_discount_code());
29 29
 }
30 30
 
31 31
 ?>
Please login to merge, or discard this patch.