Passed
Push — master ( 29dccc...57b45a )
by Brian
05:48
created
includes/class-getpaid-post-types.php 2 patches
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -15,321 +15,321 @@
 block discarded – undo
15 15
 class GetPaid_Post_Types {
16 16
 
17 17
     /**
18
-	 * Hook in methods.
19
-	 */
20
-	public function __construct() {
21
-		add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
-		add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
-		add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
-		add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
25
-	}
18
+     * Hook in methods.
19
+     */
20
+    public function __construct() {
21
+        add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
+        add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
+        add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
+        add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
25
+    }
26 26
 
27
-	/**
28
-	 * Register core post types.
29
-	 */
30
-	public static function register_post_types() {
27
+    /**
28
+     * Register core post types.
29
+     */
30
+    public static function register_post_types() {
31 31
 
32
-		if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
33
-			return;
34
-		}
32
+        if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
33
+            return;
34
+        }
35 35
 
36
-		$capabilities = wpinv_current_user_can_manage_invoicing();
36
+        $capabilities = wpinv_current_user_can_manage_invoicing();
37 37
 
38
-		// Fires before registering post types.
39
-		do_action( 'getpaid_register_post_types' );
38
+        // Fires before registering post types.
39
+        do_action( 'getpaid_register_post_types' );
40 40
 
41
-		// Register item post type.
42
-		register_post_type(
43
-			'wpi_item',
44
-			apply_filters(
45
-				'wpinv_register_post_type_invoice_item',
46
-				array(
47
-					'labels'             => array(
48
-						'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
49
-						'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
50
-						'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
51
-						'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
52
-						'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
53
-						'add_new_item'       => __( 'Add New Item', 'invoicing' ),
54
-						'new_item'           => __( 'New Item', 'invoicing' ),
55
-						'edit_item'          => __( 'Edit Item', 'invoicing' ),
56
-						'view_item'          => __( 'View Item', 'invoicing' ),
57
-						'all_items'          => __( 'Items', 'invoicing' ),
58
-						'search_items'       => __( 'Search items', 'invoicing' ),
59
-						'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
60
-						'not_found'          => __( 'No items found.', 'invoicing' ),
61
-						'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
62
-					),
63
-					'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
64
-					'public'                => false,
65
-					'has_archive'           => false,
66
-					'_builtin'              => false,
67
-					'show_ui'               => true,
68
-					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
69
-					'show_in_nav_menus'     => false,
70
-					'supports'              => array( 'title', 'excerpt', 'thumbnail' ),
71
-					'rewrite'               => false,
72
-					'query_var'             => false,
73
-					'map_meta_cap'          => true,
74
-					'show_in_admin_bar'     => true,
75
-					'can_export'            => true,
76
-				)
77
-			)
78
-		);
41
+        // Register item post type.
42
+        register_post_type(
43
+            'wpi_item',
44
+            apply_filters(
45
+                'wpinv_register_post_type_invoice_item',
46
+                array(
47
+                    'labels'             => array(
48
+                        'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
49
+                        'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
50
+                        'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
51
+                        'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
52
+                        'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
53
+                        'add_new_item'       => __( 'Add New Item', 'invoicing' ),
54
+                        'new_item'           => __( 'New Item', 'invoicing' ),
55
+                        'edit_item'          => __( 'Edit Item', 'invoicing' ),
56
+                        'view_item'          => __( 'View Item', 'invoicing' ),
57
+                        'all_items'          => __( 'Items', 'invoicing' ),
58
+                        'search_items'       => __( 'Search items', 'invoicing' ),
59
+                        'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
60
+                        'not_found'          => __( 'No items found.', 'invoicing' ),
61
+                        'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
62
+                    ),
63
+                    'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
64
+                    'public'                => false,
65
+                    'has_archive'           => false,
66
+                    '_builtin'              => false,
67
+                    'show_ui'               => true,
68
+                    'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
69
+                    'show_in_nav_menus'     => false,
70
+                    'supports'              => array( 'title', 'excerpt', 'thumbnail' ),
71
+                    'rewrite'               => false,
72
+                    'query_var'             => false,
73
+                    'map_meta_cap'          => true,
74
+                    'show_in_admin_bar'     => true,
75
+                    'can_export'            => true,
76
+                )
77
+            )
78
+        );
79 79
 
80
-		// Register payment form post type.
81
-		register_post_type(
82
-			'wpi_payment_form',
83
-			apply_filters(
84
-				'wpinv_register_post_type_payment_form',
85
-				array(
86
-					'labels'             => array(
87
-						'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
88
-						'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
89
-						'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
90
-						'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
91
-						'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
92
-						'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
93
-						'new_item'           => __( 'New Payment Form', 'invoicing' ),
94
-						'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
95
-						'view_item'          => __( 'View Payment Form', 'invoicing' ),
96
-						'all_items'          => __( 'Payment Forms', 'invoicing' ),
97
-						'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
98
-						'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
99
-						'not_found'          => __( 'No payment forms found.', 'invoicing' ),
100
-						'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
101
-					),
102
-					'description'        => __( 'Add new payment forms.', 'invoicing' ),
103
-					'public'             => false,
104
-					'show_ui'            => true,
105
-					'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
106
-					'show_in_nav_menus'  => false,
107
-					'query_var'          => false,
108
-					'rewrite'            => true,
109
-					'map_meta_cap'       => true,
110
-					'has_archive'        => false,
111
-					'hierarchical'       => false,
112
-					'menu_position'      => null,
113
-					'supports'           => array( 'title' ),
114
-					'menu_icon'          => 'dashicons-media-form',
115
-				)
116
-			)
117
-		);
80
+        // Register payment form post type.
81
+        register_post_type(
82
+            'wpi_payment_form',
83
+            apply_filters(
84
+                'wpinv_register_post_type_payment_form',
85
+                array(
86
+                    'labels'             => array(
87
+                        'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
88
+                        'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
89
+                        'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
90
+                        'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
91
+                        'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
92
+                        'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
93
+                        'new_item'           => __( 'New Payment Form', 'invoicing' ),
94
+                        'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
95
+                        'view_item'          => __( 'View Payment Form', 'invoicing' ),
96
+                        'all_items'          => __( 'Payment Forms', 'invoicing' ),
97
+                        'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
98
+                        'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
99
+                        'not_found'          => __( 'No payment forms found.', 'invoicing' ),
100
+                        'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
101
+                    ),
102
+                    'description'        => __( 'Add new payment forms.', 'invoicing' ),
103
+                    'public'             => false,
104
+                    'show_ui'            => true,
105
+                    'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
106
+                    'show_in_nav_menus'  => false,
107
+                    'query_var'          => false,
108
+                    'rewrite'            => true,
109
+                    'map_meta_cap'       => true,
110
+                    'has_archive'        => false,
111
+                    'hierarchical'       => false,
112
+                    'menu_position'      => null,
113
+                    'supports'           => array( 'title' ),
114
+                    'menu_icon'          => 'dashicons-media-form',
115
+                )
116
+            )
117
+        );
118 118
 
119
-		// Register invoice post type.
120
-		register_post_type(
121
-			'wpi_invoice',
122
-			apply_filters(
123
-				'wpinv_register_post_type_invoice',
124
-				array(
125
-					'labels'                 => array(
126
-						'name'                  => __( 'Invoices', 'invoicing' ),
127
-						'singular_name'         => __( 'Invoice', 'invoicing' ),
128
-						'all_items'             => __( 'Invoices', 'invoicing' ),
129
-						'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
130
-						'add_new'               => __( 'Add New', 'invoicing' ),
131
-						'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
132
-						'edit'                  => __( 'Edit', 'invoicing' ),
133
-						'edit_item'             => __( 'Edit invoice', 'invoicing' ),
134
-						'new_item'              => __( 'New invoice', 'invoicing' ),
135
-						'view_item'             => __( 'View invoice', 'invoicing' ),
136
-						'view_items'            => __( 'View Invoices', 'invoicing' ),
137
-						'search_items'          => __( 'Search invoices', 'invoicing' ),
138
-						'not_found'             => __( 'No invoices found', 'invoicing' ),
139
-						'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
140
-						'parent'                => __( 'Parent invoice', 'invoicing' ),
141
-						'featured_image'        => __( 'Invoice image', 'invoicing' ),
142
-						'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
143
-						'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
144
-						'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
145
-						'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
146
-						'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
147
-						'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
148
-						'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
149
-						'items_list'            => __( 'Invoices list', 'invoicing' ),
150
-					),
151
-					'description'           => __( 'This is where invoices are stored.', 'invoicing' ),
152
-					'public'                => true,
153
-					'has_archive'           => false,
154
-					'publicly_queryable'    => true,
155
-        			'exclude_from_search'   => true,
156
-        			'show_ui'               => true,
157
-					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
158
-					'show_in_nav_menus'     => false,
159
-					'supports'              => array( 'title', 'author', 'excerpt'  ),
160
-					'rewrite'               => array(
161
-						'slug'              => 'invoice',
162
-						'with_front'        => false,
163
-					),
164
-					'query_var'             => false,
165
-					'map_meta_cap'          => true,
166
-					'show_in_admin_bar'     => true,
167
-					'can_export'            => true,
168
-					'hierarchical'          => false,
169
-					'menu_position'         => null,
170
-					'menu_icon'             => 'dashicons-media-spreadsheet',
171
-				)
172
-			)
173
-		);
119
+        // Register invoice post type.
120
+        register_post_type(
121
+            'wpi_invoice',
122
+            apply_filters(
123
+                'wpinv_register_post_type_invoice',
124
+                array(
125
+                    'labels'                 => array(
126
+                        'name'                  => __( 'Invoices', 'invoicing' ),
127
+                        'singular_name'         => __( 'Invoice', 'invoicing' ),
128
+                        'all_items'             => __( 'Invoices', 'invoicing' ),
129
+                        'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
130
+                        'add_new'               => __( 'Add New', 'invoicing' ),
131
+                        'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
132
+                        'edit'                  => __( 'Edit', 'invoicing' ),
133
+                        'edit_item'             => __( 'Edit invoice', 'invoicing' ),
134
+                        'new_item'              => __( 'New invoice', 'invoicing' ),
135
+                        'view_item'             => __( 'View invoice', 'invoicing' ),
136
+                        'view_items'            => __( 'View Invoices', 'invoicing' ),
137
+                        'search_items'          => __( 'Search invoices', 'invoicing' ),
138
+                        'not_found'             => __( 'No invoices found', 'invoicing' ),
139
+                        'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
140
+                        'parent'                => __( 'Parent invoice', 'invoicing' ),
141
+                        'featured_image'        => __( 'Invoice image', 'invoicing' ),
142
+                        'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
143
+                        'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
144
+                        'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
145
+                        'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
146
+                        'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
147
+                        'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
148
+                        'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
149
+                        'items_list'            => __( 'Invoices list', 'invoicing' ),
150
+                    ),
151
+                    'description'           => __( 'This is where invoices are stored.', 'invoicing' ),
152
+                    'public'                => true,
153
+                    'has_archive'           => false,
154
+                    'publicly_queryable'    => true,
155
+                    'exclude_from_search'   => true,
156
+                    'show_ui'               => true,
157
+                    'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
158
+                    'show_in_nav_menus'     => false,
159
+                    'supports'              => array( 'title', 'author', 'excerpt'  ),
160
+                    'rewrite'               => array(
161
+                        'slug'              => 'invoice',
162
+                        'with_front'        => false,
163
+                    ),
164
+                    'query_var'             => false,
165
+                    'map_meta_cap'          => true,
166
+                    'show_in_admin_bar'     => true,
167
+                    'can_export'            => true,
168
+                    'hierarchical'          => false,
169
+                    'menu_position'         => null,
170
+                    'menu_icon'             => 'dashicons-media-spreadsheet',
171
+                )
172
+            )
173
+        );
174 174
 
175
-		// Register discount post type.
176
-		register_post_type(
177
-			'wpi_discount',
178
-			apply_filters(
179
-				'wpinv_register_post_type_discount',
180
-				array(
181
-					'labels'                 => array(
182
-						'name'                  => __( 'Discounts', 'invoicing' ),
183
-						'singular_name'         => __( 'Discount', 'invoicing' ),
184
-						'all_items'             => __( 'Discounts', 'invoicing' ),
185
-						'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
186
-						'add_new'               => __( 'Add New', 'invoicing' ),
187
-						'add_new_item'          => __( 'Add new discount', 'invoicing' ),
188
-						'edit'                  => __( 'Edit', 'invoicing' ),
189
-						'edit_item'             => __( 'Edit discount', 'invoicing' ),
190
-						'new_item'              => __( 'New discount', 'invoicing' ),
191
-						'view_item'             => __( 'View discount', 'invoicing' ),
192
-						'view_items'            => __( 'View Discounts', 'invoicing' ),
193
-						'search_items'          => __( 'Search discounts', 'invoicing' ),
194
-						'not_found'             => __( 'No discounts found', 'invoicing' ),
195
-						'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
196
-						'parent'                => __( 'Parent discount', 'invoicing' ),
197
-						'featured_image'        => __( 'Discount image', 'invoicing' ),
198
-						'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
199
-						'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
200
-						'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
201
-						'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
202
-						'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
203
-						'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
204
-						'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
205
-						'items_list'            => __( 'Discounts list', 'invoicing' ),
206
-					),
207
-					'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
208
-					'public'             => false,
209
-					'can_export'         => true,
210
-					'_builtin'           => false,
211
-					'publicly_queryable' => false,
212
-					'exclude_from_search'=> true,
213
-					'show_ui'            => true,
214
-					'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
215
-					'query_var'          => false,
216
-					'rewrite'            => false,
217
-					'map_meta_cap'       => true,
218
-					'has_archive'        => false,
219
-					'hierarchical'       => false,
220
-					'supports'           => array( 'title', 'excerpt' ),
221
-					'show_in_nav_menus'  => false,
222
-					'show_in_admin_bar'  => true,
223
-					'menu_position'      => null,
224
-				)
225
-			)
226
-		);
175
+        // Register discount post type.
176
+        register_post_type(
177
+            'wpi_discount',
178
+            apply_filters(
179
+                'wpinv_register_post_type_discount',
180
+                array(
181
+                    'labels'                 => array(
182
+                        'name'                  => __( 'Discounts', 'invoicing' ),
183
+                        'singular_name'         => __( 'Discount', 'invoicing' ),
184
+                        'all_items'             => __( 'Discounts', 'invoicing' ),
185
+                        'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
186
+                        'add_new'               => __( 'Add New', 'invoicing' ),
187
+                        'add_new_item'          => __( 'Add new discount', 'invoicing' ),
188
+                        'edit'                  => __( 'Edit', 'invoicing' ),
189
+                        'edit_item'             => __( 'Edit discount', 'invoicing' ),
190
+                        'new_item'              => __( 'New discount', 'invoicing' ),
191
+                        'view_item'             => __( 'View discount', 'invoicing' ),
192
+                        'view_items'            => __( 'View Discounts', 'invoicing' ),
193
+                        'search_items'          => __( 'Search discounts', 'invoicing' ),
194
+                        'not_found'             => __( 'No discounts found', 'invoicing' ),
195
+                        'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
196
+                        'parent'                => __( 'Parent discount', 'invoicing' ),
197
+                        'featured_image'        => __( 'Discount image', 'invoicing' ),
198
+                        'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
199
+                        'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
200
+                        'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
201
+                        'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
202
+                        'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
203
+                        'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
204
+                        'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
205
+                        'items_list'            => __( 'Discounts list', 'invoicing' ),
206
+                    ),
207
+                    'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
208
+                    'public'             => false,
209
+                    'can_export'         => true,
210
+                    '_builtin'           => false,
211
+                    'publicly_queryable' => false,
212
+                    'exclude_from_search'=> true,
213
+                    'show_ui'            => true,
214
+                    'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
215
+                    'query_var'          => false,
216
+                    'rewrite'            => false,
217
+                    'map_meta_cap'       => true,
218
+                    'has_archive'        => false,
219
+                    'hierarchical'       => false,
220
+                    'supports'           => array( 'title', 'excerpt' ),
221
+                    'show_in_nav_menus'  => false,
222
+                    'show_in_admin_bar'  => true,
223
+                    'menu_position'      => null,
224
+                )
225
+            )
226
+        );
227 227
 
228
-		do_action( 'getpaid_after_register_post_types' );
229
-	}
228
+        do_action( 'getpaid_after_register_post_types' );
229
+    }
230 230
 
231
-	/**
232
-	 * Register our custom post statuses.
233
-	 */
234
-	public static function register_post_status() {
231
+    /**
232
+     * Register our custom post statuses.
233
+     */
234
+    public static function register_post_status() {
235 235
 
236
-		$invoice_statuses = apply_filters(
237
-			'getpaid_register_invoice_post_statuses',
238
-			array(
236
+        $invoice_statuses = apply_filters(
237
+            'getpaid_register_invoice_post_statuses',
238
+            array(
239 239
 
240
-				'wpi-pending' => array(
241
-					'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
242
-        			'public'                    => true,
243
-        			'exclude_from_search'       => true,
244
-        			'show_in_admin_all_list'    => true,
245
-					'show_in_admin_status_list' => true,
246
-					/* translators: %s: number of invoices */
247
-        			'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' )
248
-				),
240
+                'wpi-pending' => array(
241
+                    'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
242
+                    'public'                    => true,
243
+                    'exclude_from_search'       => true,
244
+                    'show_in_admin_all_list'    => true,
245
+                    'show_in_admin_status_list' => true,
246
+                    /* translators: %s: number of invoices */
247
+                    'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' )
248
+                ),
249 249
 
250
-				'wpi-processing' => array(
251
-					'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
252
-        			'public'                    => true,
253
-        			'exclude_from_search'       => true,
254
-        			'show_in_admin_all_list'    => true,
255
-					'show_in_admin_status_list' => true,
256
-					/* translators: %s: number of invoices */
257
-        			'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
258
-				),
250
+                'wpi-processing' => array(
251
+                    'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
252
+                    'public'                    => true,
253
+                    'exclude_from_search'       => true,
254
+                    'show_in_admin_all_list'    => true,
255
+                    'show_in_admin_status_list' => true,
256
+                    /* translators: %s: number of invoices */
257
+                    'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
258
+                ),
259 259
 
260
-				'wpi-onhold' => array(
261
-					'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
262
-        			'public'                    => true,
263
-        			'exclude_from_search'       => true,
264
-        			'show_in_admin_all_list'    => true,
265
-					'show_in_admin_status_list' => true,
266
-					/* translators: %s: number of invoices */
267
-        			'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
268
-				),
260
+                'wpi-onhold' => array(
261
+                    'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
262
+                    'public'                    => true,
263
+                    'exclude_from_search'       => true,
264
+                    'show_in_admin_all_list'    => true,
265
+                    'show_in_admin_status_list' => true,
266
+                    /* translators: %s: number of invoices */
267
+                    'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
268
+                ),
269 269
 
270
-				'wpi-cancelled' => array(
271
-					'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
272
-        			'public'                    => true,
273
-        			'exclude_from_search'       => true,
274
-        			'show_in_admin_all_list'    => true,
275
-					'show_in_admin_status_list' => true,
276
-					/* translators: %s: number of invoices */
277
-        			'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
278
-				),
270
+                'wpi-cancelled' => array(
271
+                    'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
272
+                    'public'                    => true,
273
+                    'exclude_from_search'       => true,
274
+                    'show_in_admin_all_list'    => true,
275
+                    'show_in_admin_status_list' => true,
276
+                    /* translators: %s: number of invoices */
277
+                    'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
278
+                ),
279 279
 
280
-				'wpi-refunded' => array(
281
-					'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
282
-        			'public'                    => true,
283
-        			'exclude_from_search'       => true,
284
-        			'show_in_admin_all_list'    => true,
285
-					'show_in_admin_status_list' => true,
286
-					/* translators: %s: number of invoices */
287
-        			'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
288
-				),
280
+                'wpi-refunded' => array(
281
+                    'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
282
+                    'public'                    => true,
283
+                    'exclude_from_search'       => true,
284
+                    'show_in_admin_all_list'    => true,
285
+                    'show_in_admin_status_list' => true,
286
+                    /* translators: %s: number of invoices */
287
+                    'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
288
+                ),
289 289
 
290
-				'wpi-failed' => array(
291
-					'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
292
-        			'public'                    => true,
293
-        			'exclude_from_search'       => true,
294
-        			'show_in_admin_all_list'    => true,
295
-					'show_in_admin_status_list' => true,
296
-					/* translators: %s: number of invoices */
297
-        			'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
298
-				),
290
+                'wpi-failed' => array(
291
+                    'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
292
+                    'public'                    => true,
293
+                    'exclude_from_search'       => true,
294
+                    'show_in_admin_all_list'    => true,
295
+                    'show_in_admin_status_list' => true,
296
+                    /* translators: %s: number of invoices */
297
+                    'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
298
+                ),
299 299
 
300
-				'wpi-renewal' => array(
301
-					'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
302
-        			'public'                    => true,
303
-        			'exclude_from_search'       => true,
304
-        			'show_in_admin_all_list'    => true,
305
-					'show_in_admin_status_list' => true,
306
-					/* translators: %s: number of invoices */
307
-        			'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
308
-				)
309
-			)
310
-		);
300
+                'wpi-renewal' => array(
301
+                    'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
302
+                    'public'                    => true,
303
+                    'exclude_from_search'       => true,
304
+                    'show_in_admin_all_list'    => true,
305
+                    'show_in_admin_status_list' => true,
306
+                    /* translators: %s: number of invoices */
307
+                    'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
308
+                )
309
+            )
310
+        );
311 311
 
312
-		foreach ( $invoice_statuses as $invoice_statuse => $args ) {
313
-			register_post_status( $invoice_statuse, $args );
314
-		}
315
-	}
312
+        foreach ( $invoice_statuses as $invoice_statuse => $args ) {
313
+            register_post_status( $invoice_statuse, $args );
314
+        }
315
+    }
316 316
 
317
-	/**
318
-	 * Flush rewrite rules.
319
-	 */
320
-	public static function flush_rewrite_rules() {
321
-		flush_rewrite_rules();
322
-	}
317
+    /**
318
+     * Flush rewrite rules.
319
+     */
320
+    public static function flush_rewrite_rules() {
321
+        flush_rewrite_rules();
322
+    }
323 323
 
324
-	/**
325
-	 * Flush rules to prevent 404.
326
-	 *
327
-	 */
328
-	public static function maybe_flush_rewrite_rules() {
329
-		if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
330
-			update_option( 'getpaid_flushed_rewrite_rules', '1' );
331
-			self::flush_rewrite_rules();
332
-		}
333
-	}
324
+    /**
325
+     * Flush rules to prevent 404.
326
+     *
327
+     */
328
+    public static function maybe_flush_rewrite_rules() {
329
+        if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
330
+            update_option( 'getpaid_flushed_rewrite_rules', '1' );
331
+            self::flush_rewrite_rules();
332
+        }
333
+    }
334 334
 
335 335
 }
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Post types Class
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 	 * Hook in methods.
19 19
 	 */
20 20
 	public function __construct() {
21
-		add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
-		add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
-		add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
-		add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
21
+		add_action('init', array(__CLASS__, 'register_post_types'), 1);
22
+		add_action('init', array(__CLASS__, 'register_post_status'), 4);
23
+		add_action('getpaid_flush_rewrite_rules', array(__CLASS__, 'flush_rewrite_rules'));
24
+		add_action('getpaid_after_register_post_types', array(__CLASS__, 'maybe_flush_rewrite_rules'));
25 25
 	}
26 26
 
27 27
 	/**
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public static function register_post_types() {
31 31
 
32
-		if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
32
+		if (!is_blog_installed() || post_type_exists('wpi_item')) {
33 33
 			return;
34 34
 		}
35 35
 
36 36
 		$capabilities = wpinv_current_user_can_manage_invoicing();
37 37
 
38 38
 		// Fires before registering post types.
39
-		do_action( 'getpaid_register_post_types' );
39
+		do_action('getpaid_register_post_types');
40 40
 
41 41
 		// Register item post type.
42 42
 		register_post_type(
@@ -45,29 +45,29 @@  discard block
 block discarded – undo
45 45
 				'wpinv_register_post_type_invoice_item',
46 46
 				array(
47 47
 					'labels'             => array(
48
-						'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
49
-						'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
50
-						'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
51
-						'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
52
-						'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
53
-						'add_new_item'       => __( 'Add New Item', 'invoicing' ),
54
-						'new_item'           => __( 'New Item', 'invoicing' ),
55
-						'edit_item'          => __( 'Edit Item', 'invoicing' ),
56
-						'view_item'          => __( 'View Item', 'invoicing' ),
57
-						'all_items'          => __( 'Items', 'invoicing' ),
58
-						'search_items'       => __( 'Search items', 'invoicing' ),
59
-						'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
60
-						'not_found'          => __( 'No items found.', 'invoicing' ),
61
-						'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
48
+						'name'               => _x('Items', 'post type general name', 'invoicing'),
49
+						'singular_name'      => _x('Item', 'post type singular name', 'invoicing'),
50
+						'menu_name'          => _x('Items', 'admin menu', 'invoicing'),
51
+						'name_admin_bar'     => _x('Item', 'add new on admin bar', 'invoicing'),
52
+						'add_new'            => _x('Add New', 'Item', 'invoicing'),
53
+						'add_new_item'       => __('Add New Item', 'invoicing'),
54
+						'new_item'           => __('New Item', 'invoicing'),
55
+						'edit_item'          => __('Edit Item', 'invoicing'),
56
+						'view_item'          => __('View Item', 'invoicing'),
57
+						'all_items'          => __('Items', 'invoicing'),
58
+						'search_items'       => __('Search items', 'invoicing'),
59
+						'parent_item_colon'  => __('Parent item:', 'invoicing'),
60
+						'not_found'          => __('No items found.', 'invoicing'),
61
+						'not_found_in_trash' => __('No items found in trash.', 'invoicing')
62 62
 					),
63
-					'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
63
+					'description'           => __('This is where you can add new invoice items.', 'invoicing'),
64 64
 					'public'                => false,
65 65
 					'has_archive'           => false,
66 66
 					'_builtin'              => false,
67 67
 					'show_ui'               => true,
68 68
 					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
69 69
 					'show_in_nav_menus'     => false,
70
-					'supports'              => array( 'title', 'excerpt', 'thumbnail' ),
70
+					'supports'              => array('title', 'excerpt', 'thumbnail'),
71 71
 					'rewrite'               => false,
72 72
 					'query_var'             => false,
73 73
 					'map_meta_cap'          => true,
@@ -84,22 +84,22 @@  discard block
 block discarded – undo
84 84
 				'wpinv_register_post_type_payment_form',
85 85
 				array(
86 86
 					'labels'             => array(
87
-						'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
88
-						'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
89
-						'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
90
-						'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
91
-						'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
92
-						'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
93
-						'new_item'           => __( 'New Payment Form', 'invoicing' ),
94
-						'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
95
-						'view_item'          => __( 'View Payment Form', 'invoicing' ),
96
-						'all_items'          => __( 'Payment Forms', 'invoicing' ),
97
-						'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
98
-						'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
99
-						'not_found'          => __( 'No payment forms found.', 'invoicing' ),
100
-						'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
87
+						'name'               => _x('Payment Forms', 'post type general name', 'invoicing'),
88
+						'singular_name'      => _x('Payment Form', 'post type singular name', 'invoicing'),
89
+						'menu_name'          => _x('Payment Forms', 'admin menu', 'invoicing'),
90
+						'name_admin_bar'     => _x('Payment Form', 'add new on admin bar', 'invoicing'),
91
+						'add_new'            => _x('Add New', 'Payment Form', 'invoicing'),
92
+						'add_new_item'       => __('Add New Payment Form', 'invoicing'),
93
+						'new_item'           => __('New Payment Form', 'invoicing'),
94
+						'edit_item'          => __('Edit Payment Form', 'invoicing'),
95
+						'view_item'          => __('View Payment Form', 'invoicing'),
96
+						'all_items'          => __('Payment Forms', 'invoicing'),
97
+						'search_items'       => __('Search Payment Forms', 'invoicing'),
98
+						'parent_item_colon'  => __('Parent Payment Forms:', 'invoicing'),
99
+						'not_found'          => __('No payment forms found.', 'invoicing'),
100
+						'not_found_in_trash' => __('No payment forms found in trash.', 'invoicing')
101 101
 					),
102
-					'description'        => __( 'Add new payment forms.', 'invoicing' ),
102
+					'description'        => __('Add new payment forms.', 'invoicing'),
103 103
 					'public'             => false,
104 104
 					'show_ui'            => true,
105 105
 					'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 					'has_archive'        => false,
111 111
 					'hierarchical'       => false,
112 112
 					'menu_position'      => null,
113
-					'supports'           => array( 'title' ),
113
+					'supports'           => array('title'),
114 114
 					'menu_icon'          => 'dashicons-media-form',
115 115
 				)
116 116
 			)
@@ -123,32 +123,32 @@  discard block
 block discarded – undo
123 123
 				'wpinv_register_post_type_invoice',
124 124
 				array(
125 125
 					'labels'                 => array(
126
-						'name'                  => __( 'Invoices', 'invoicing' ),
127
-						'singular_name'         => __( 'Invoice', 'invoicing' ),
128
-						'all_items'             => __( 'Invoices', 'invoicing' ),
129
-						'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
130
-						'add_new'               => __( 'Add New', 'invoicing' ),
131
-						'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
132
-						'edit'                  => __( 'Edit', 'invoicing' ),
133
-						'edit_item'             => __( 'Edit invoice', 'invoicing' ),
134
-						'new_item'              => __( 'New invoice', 'invoicing' ),
135
-						'view_item'             => __( 'View invoice', 'invoicing' ),
136
-						'view_items'            => __( 'View Invoices', 'invoicing' ),
137
-						'search_items'          => __( 'Search invoices', 'invoicing' ),
138
-						'not_found'             => __( 'No invoices found', 'invoicing' ),
139
-						'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
140
-						'parent'                => __( 'Parent invoice', 'invoicing' ),
141
-						'featured_image'        => __( 'Invoice image', 'invoicing' ),
142
-						'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
143
-						'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
144
-						'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
145
-						'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
146
-						'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
147
-						'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
148
-						'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
149
-						'items_list'            => __( 'Invoices list', 'invoicing' ),
126
+						'name'                  => __('Invoices', 'invoicing'),
127
+						'singular_name'         => __('Invoice', 'invoicing'),
128
+						'all_items'             => __('Invoices', 'invoicing'),
129
+						'menu_name'             => _x('Invoices', 'Admin menu name', 'invoicing'),
130
+						'add_new'               => __('Add New', 'invoicing'),
131
+						'add_new_item'          => __('Add new invoice', 'invoicing'),
132
+						'edit'                  => __('Edit', 'invoicing'),
133
+						'edit_item'             => __('Edit invoice', 'invoicing'),
134
+						'new_item'              => __('New invoice', 'invoicing'),
135
+						'view_item'             => __('View invoice', 'invoicing'),
136
+						'view_items'            => __('View Invoices', 'invoicing'),
137
+						'search_items'          => __('Search invoices', 'invoicing'),
138
+						'not_found'             => __('No invoices found', 'invoicing'),
139
+						'not_found_in_trash'    => __('No invoices found in trash', 'invoicing'),
140
+						'parent'                => __('Parent invoice', 'invoicing'),
141
+						'featured_image'        => __('Invoice image', 'invoicing'),
142
+						'set_featured_image'    => __('Set invoice image', 'invoicing'),
143
+						'remove_featured_image' => __('Remove invoice image', 'invoicing'),
144
+						'use_featured_image'    => __('Use as invoice image', 'invoicing'),
145
+						'insert_into_item'      => __('Insert into invoice', 'invoicing'),
146
+						'uploaded_to_this_item' => __('Uploaded to this invoice', 'invoicing'),
147
+						'filter_items_list'     => __('Filter invoices', 'invoicing'),
148
+						'items_list_navigation' => __('Invoices navigation', 'invoicing'),
149
+						'items_list'            => __('Invoices list', 'invoicing'),
150 150
 					),
151
-					'description'           => __( 'This is where invoices are stored.', 'invoicing' ),
151
+					'description'           => __('This is where invoices are stored.', 'invoicing'),
152 152
 					'public'                => true,
153 153
 					'has_archive'           => false,
154 154
 					'publicly_queryable'    => true,
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         			'show_ui'               => true,
157 157
 					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
158 158
 					'show_in_nav_menus'     => false,
159
-					'supports'              => array( 'title', 'author', 'excerpt'  ),
159
+					'supports'              => array('title', 'author', 'excerpt'),
160 160
 					'rewrite'               => array(
161 161
 						'slug'              => 'invoice',
162 162
 						'with_front'        => false,
@@ -179,32 +179,32 @@  discard block
 block discarded – undo
179 179
 				'wpinv_register_post_type_discount',
180 180
 				array(
181 181
 					'labels'                 => array(
182
-						'name'                  => __( 'Discounts', 'invoicing' ),
183
-						'singular_name'         => __( 'Discount', 'invoicing' ),
184
-						'all_items'             => __( 'Discounts', 'invoicing' ),
185
-						'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
186
-						'add_new'               => __( 'Add New', 'invoicing' ),
187
-						'add_new_item'          => __( 'Add new discount', 'invoicing' ),
188
-						'edit'                  => __( 'Edit', 'invoicing' ),
189
-						'edit_item'             => __( 'Edit discount', 'invoicing' ),
190
-						'new_item'              => __( 'New discount', 'invoicing' ),
191
-						'view_item'             => __( 'View discount', 'invoicing' ),
192
-						'view_items'            => __( 'View Discounts', 'invoicing' ),
193
-						'search_items'          => __( 'Search discounts', 'invoicing' ),
194
-						'not_found'             => __( 'No discounts found', 'invoicing' ),
195
-						'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
196
-						'parent'                => __( 'Parent discount', 'invoicing' ),
197
-						'featured_image'        => __( 'Discount image', 'invoicing' ),
198
-						'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
199
-						'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
200
-						'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
201
-						'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
202
-						'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
203
-						'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
204
-						'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
205
-						'items_list'            => __( 'Discounts list', 'invoicing' ),
182
+						'name'                  => __('Discounts', 'invoicing'),
183
+						'singular_name'         => __('Discount', 'invoicing'),
184
+						'all_items'             => __('Discounts', 'invoicing'),
185
+						'menu_name'             => _x('Discounts', 'Admin menu name', 'invoicing'),
186
+						'add_new'               => __('Add New', 'invoicing'),
187
+						'add_new_item'          => __('Add new discount', 'invoicing'),
188
+						'edit'                  => __('Edit', 'invoicing'),
189
+						'edit_item'             => __('Edit discount', 'invoicing'),
190
+						'new_item'              => __('New discount', 'invoicing'),
191
+						'view_item'             => __('View discount', 'invoicing'),
192
+						'view_items'            => __('View Discounts', 'invoicing'),
193
+						'search_items'          => __('Search discounts', 'invoicing'),
194
+						'not_found'             => __('No discounts found', 'invoicing'),
195
+						'not_found_in_trash'    => __('No discounts found in trash', 'invoicing'),
196
+						'parent'                => __('Parent discount', 'invoicing'),
197
+						'featured_image'        => __('Discount image', 'invoicing'),
198
+						'set_featured_image'    => __('Set discount image', 'invoicing'),
199
+						'remove_featured_image' => __('Remove discount image', 'invoicing'),
200
+						'use_featured_image'    => __('Use as discount image', 'invoicing'),
201
+						'insert_into_item'      => __('Insert into discount', 'invoicing'),
202
+						'uploaded_to_this_item' => __('Uploaded to this discount', 'invoicing'),
203
+						'filter_items_list'     => __('Filter discounts', 'invoicing'),
204
+						'items_list_navigation' => __('Discount navigation', 'invoicing'),
205
+						'items_list'            => __('Discounts list', 'invoicing'),
206 206
 					),
207
-					'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
207
+					'description'        => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'),
208 208
 					'public'             => false,
209 209
 					'can_export'         => true,
210 210
 					'_builtin'           => false,
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 					'map_meta_cap'       => true,
218 218
 					'has_archive'        => false,
219 219
 					'hierarchical'       => false,
220
-					'supports'           => array( 'title', 'excerpt' ),
220
+					'supports'           => array('title', 'excerpt'),
221 221
 					'show_in_nav_menus'  => false,
222 222
 					'show_in_admin_bar'  => true,
223 223
 					'menu_position'      => null,
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 			)
226 226
 		);
227 227
 
228
-		do_action( 'getpaid_after_register_post_types' );
228
+		do_action('getpaid_after_register_post_types');
229 229
 	}
230 230
 
231 231
 	/**
@@ -238,79 +238,79 @@  discard block
 block discarded – undo
238 238
 			array(
239 239
 
240 240
 				'wpi-pending' => array(
241
-					'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
241
+					'label'                     => _x('Pending Payment', 'Invoice status', 'invoicing'),
242 242
         			'public'                    => true,
243 243
         			'exclude_from_search'       => true,
244 244
         			'show_in_admin_all_list'    => true,
245 245
 					'show_in_admin_status_list' => true,
246 246
 					/* translators: %s: number of invoices */
247
-        			'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' )
247
+        			'label_count'               => _n_noop('Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing')
248 248
 				),
249 249
 
250 250
 				'wpi-processing' => array(
251
-					'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
251
+					'label'                     => _x('Processing', 'Invoice status', 'invoicing'),
252 252
         			'public'                    => true,
253 253
         			'exclude_from_search'       => true,
254 254
         			'show_in_admin_all_list'    => true,
255 255
 					'show_in_admin_status_list' => true,
256 256
 					/* translators: %s: number of invoices */
257
-        			'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
257
+        			'label_count'               => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing')
258 258
 				),
259 259
 
260 260
 				'wpi-onhold' => array(
261
-					'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
261
+					'label'                     => _x('On Hold', 'Invoice status', 'invoicing'),
262 262
         			'public'                    => true,
263 263
         			'exclude_from_search'       => true,
264 264
         			'show_in_admin_all_list'    => true,
265 265
 					'show_in_admin_status_list' => true,
266 266
 					/* translators: %s: number of invoices */
267
-        			'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
267
+        			'label_count'               => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing')
268 268
 				),
269 269
 
270 270
 				'wpi-cancelled' => array(
271
-					'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
271
+					'label'                     => _x('Cancelled', 'Invoice status', 'invoicing'),
272 272
         			'public'                    => true,
273 273
         			'exclude_from_search'       => true,
274 274
         			'show_in_admin_all_list'    => true,
275 275
 					'show_in_admin_status_list' => true,
276 276
 					/* translators: %s: number of invoices */
277
-        			'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
277
+        			'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing')
278 278
 				),
279 279
 
280 280
 				'wpi-refunded' => array(
281
-					'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
281
+					'label'                     => _x('Refunded', 'Invoice status', 'invoicing'),
282 282
         			'public'                    => true,
283 283
         			'exclude_from_search'       => true,
284 284
         			'show_in_admin_all_list'    => true,
285 285
 					'show_in_admin_status_list' => true,
286 286
 					/* translators: %s: number of invoices */
287
-        			'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
287
+        			'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing')
288 288
 				),
289 289
 
290 290
 				'wpi-failed' => array(
291
-					'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
291
+					'label'                     => _x('Failed', 'Invoice status', 'invoicing'),
292 292
         			'public'                    => true,
293 293
         			'exclude_from_search'       => true,
294 294
         			'show_in_admin_all_list'    => true,
295 295
 					'show_in_admin_status_list' => true,
296 296
 					/* translators: %s: number of invoices */
297
-        			'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
297
+        			'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing')
298 298
 				),
299 299
 
300 300
 				'wpi-renewal' => array(
301
-					'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
301
+					'label'                     => _x('Renewal', 'Invoice status', 'invoicing'),
302 302
         			'public'                    => true,
303 303
         			'exclude_from_search'       => true,
304 304
         			'show_in_admin_all_list'    => true,
305 305
 					'show_in_admin_status_list' => true,
306 306
 					/* translators: %s: number of invoices */
307
-        			'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
307
+        			'label_count'               => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing')
308 308
 				)
309 309
 			)
310 310
 		);
311 311
 
312
-		foreach ( $invoice_statuses as $invoice_statuse => $args ) {
313
-			register_post_status( $invoice_statuse, $args );
312
+		foreach ($invoice_statuses as $invoice_statuse => $args) {
313
+			register_post_status($invoice_statuse, $args);
314 314
 		}
315 315
 	}
316 316
 
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
 	 *
327 327
 	 */
328 328
 	public static function maybe_flush_rewrite_rules() {
329
-		if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
330
-			update_option( 'getpaid_flushed_rewrite_rules', '1' );
329
+		if (!get_option('getpaid_flushed_rewrite_rules')) {
330
+			update_option('getpaid_flushed_rewrite_rules', '1');
331 331
 			self::flush_rewrite_rules();
332 332
 		}
333 333
 	}
Please login to merge, or discard this patch.
includes/data/email-settings.php 1 patch
Spacing   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 // Prepare the due date reminder options.
14 14
 $overdue_days_options       = array();
15
-$overdue_days_options['0']  = __( 'On the Due Date', 'invoicing' );
16
-$overdue_days_options['1']  = __( '1 day after Due Date', 'invoicing' );
15
+$overdue_days_options['0']  = __('On the Due Date', 'invoicing');
16
+$overdue_days_options['1']  = __('1 day after Due Date', 'invoicing');
17 17
 
18
-for ( $i = 2; $i <= 10; $i++ ) {
19
-    $overdue_days_options["$i"] = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i );
18
+for ($i = 2; $i <= 10; $i++) {
19
+    $overdue_days_options["$i"] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i);
20 20
 }
21 21
 
22 22
 // Prepare up coming renewal reminder options.
23 23
 $renewal_days_options       = array();
24
-$renewal_days_options['0']  = __( 'On the renewal date', 'invoicing' );
25
-$renewal_days_options['1']  = __( '1 day before the renewal date', 'invoicing' );
24
+$renewal_days_options['0']  = __('On the renewal date', 'invoicing');
25
+$renewal_days_options['1']  = __('1 day before the renewal date', 'invoicing');
26 26
 
27
-for ( $i = 2; $i <= 10; $i++ ) {
28
-    $renewal_days_options["$i"]   = wp_sprintf( __( '%d days before the renewal date', 'invoicing' ), $i );
27
+for ($i = 2; $i <= 10; $i++) {
28
+    $renewal_days_options["$i"] = wp_sprintf(__('%d days before the renewal date', 'invoicing'), $i);
29 29
 }
30 30
 
31 31
 // Default, built-in gateways
@@ -34,45 +34,45 @@  discard block
 block discarded – undo
34 34
 
35 35
         'email_new_invoice_header' => array(
36 36
             'id'       => 'email_new_invoice_header',
37
-            'name'     => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>',
38
-            'desc'     => __( 'These emails are sent to the site admin whenever there is a new invoice.', 'invoicing' ),
37
+            'name'     => '<h3>' . __('New Invoice', 'invoicing') . '</h3>',
38
+            'desc'     => __('These emails are sent to the site admin whenever there is a new invoice.', 'invoicing'),
39 39
             'type'     => 'header',
40 40
         ),
41 41
 
42 42
         'email_new_invoice_active' => array(
43 43
             'id'       => 'email_new_invoice_active',
44
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
45
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
44
+            'name'     => __('Enable/Disable', 'invoicing'),
45
+            'desc'     => __('Enable this email notification', 'invoicing'),
46 46
             'type'     => 'checkbox',
47 47
             'std'      => 1
48 48
         ),
49 49
 
50 50
         'email_new_invoice_subject' => array(
51 51
             'id'       => 'email_new_invoice_subject',
52
-            'name'     => __( 'Subject', 'invoicing' ),
53
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
52
+            'name'     => __('Subject', 'invoicing'),
53
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
54 54
             'help-tip' => true,
55 55
             'type'     => 'text',
56
-            'std'      => __( '[{site_title}] New invoice ({invoice_number}) for {invoice_total} {invoice_currency}', 'invoicing' ),
56
+            'std'      => __('[{site_title}] New invoice ({invoice_number}) for {invoice_total} {invoice_currency}', 'invoicing'),
57 57
             'size'     => 'large'
58 58
         ),
59 59
 
60 60
         'email_new_invoice_heading' => array(
61 61
             'id'       => 'email_new_invoice_heading',
62
-            'name'     => __( 'Email Heading', 'invoicing' ),
63
-            'desc'     => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
62
+            'name'     => __('Email Heading', 'invoicing'),
63
+            'desc'     => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
64 64
             'help-tip' => true,
65 65
             'type'     => 'text',
66
-            'std'      => __( 'New invoice', 'invoicing' ),
66
+            'std'      => __('New invoice', 'invoicing'),
67 67
             'size'     => 'large'
68 68
         ),
69 69
 
70 70
         'email_new_invoice_body' => array(
71 71
             'id'       => 'email_new_invoice_body',
72
-            'name'     => __( 'Email Content', 'invoicing' ),
72
+            'name'     => __('Email Content', 'invoicing'),
73 73
             'desc'     => wpinv_get_merge_tags_help_text(),
74 74
             'type'     => 'rich_editor',
75
-            'std'      => __( '<p>A new invoice <a href="{invoice_link}">({invoice_number})</a> to {name} for {invoice_total} {invoice_currency} has been created on your site. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
75
+            'std'      => __('<p>A new invoice <a href="{invoice_link}">({invoice_number})</a> to {name} for {invoice_total} {invoice_currency} has been created on your site. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
76 76
             'class'    => 'large',
77 77
             'size'     => '10'
78 78
         ),
@@ -82,45 +82,45 @@  discard block
 block discarded – undo
82 82
 
83 83
         'email_cancelled_invoice_header' => array(
84 84
             'id'       => 'email_cancelled_invoice_header',
85
-            'name'     => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>',
86
-            'desc'     => __( 'These emails are sent to the site admin whenever invoices are cancelled.', 'invoicing' ),
85
+            'name'     => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>',
86
+            'desc'     => __('These emails are sent to the site admin whenever invoices are cancelled.', 'invoicing'),
87 87
             'type'     => 'header',
88 88
         ),
89 89
 
90 90
         'email_cancelled_invoice_active' => array(
91 91
             'id'       => 'email_cancelled_invoice_active',
92
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
93
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
92
+            'name'     => __('Enable/Disable', 'invoicing'),
93
+            'desc'     => __('Enable this email notification', 'invoicing'),
94 94
             'type'     => 'checkbox',
95 95
             'std'      => 1
96 96
         ),
97 97
 
98 98
         'email_cancelled_invoice_subject' => array(
99 99
             'id'       => 'email_cancelled_invoice_subject',
100
-            'name'     => __( 'Subject', 'invoicing' ),
101
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
100
+            'name'     => __('Subject', 'invoicing'),
101
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
102 102
             'help-tip' => true,
103 103
             'type'     => 'text',
104
-            'std'      => __( '[{site_title}] Invoice ({invoice_number}) Cancelled', 'invoicing' ),
104
+            'std'      => __('[{site_title}] Invoice ({invoice_number}) Cancelled', 'invoicing'),
105 105
             'size'     => 'large'
106 106
         ),
107 107
 
108 108
         'email_cancelled_invoice_heading' => array(
109 109
             'id'       => 'email_cancelled_invoice_heading',
110
-            'name'     => __( 'Email Heading', 'invoicing' ),
111
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
110
+            'name'     => __('Email Heading', 'invoicing'),
111
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
112 112
             'help-tip' => true,
113 113
             'type'     => 'text',
114
-            'std'      => __( 'Invoice Cancelled', 'invoicing' ),
114
+            'std'      => __('Invoice Cancelled', 'invoicing'),
115 115
             'size'     => 'large'
116 116
         ),
117 117
 
118 118
         'email_cancelled_invoice_body' => array(
119 119
             'id'       => 'email_cancelled_invoice_body',
120
-            'name'     => __( 'Email Content', 'invoicing' ),
120
+            'name'     => __('Email Content', 'invoicing'),
121 121
             'desc'     => wpinv_get_merge_tags_help_text(),
122 122
             'type'     => 'rich_editor',
123
-            'std'      => __( '<p>The invoice <a href="{invoice_link}">#{invoice_number}</a> created for {name} on {site_title} has been cancelled. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
123
+            'std'      => __('<p>The invoice <a href="{invoice_link}">#{invoice_number}</a> created for {name} on {site_title} has been cancelled. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
124 124
             'class'    => 'large',
125 125
             'size'     => '10'
126 126
         ),
@@ -131,45 +131,45 @@  discard block
 block discarded – undo
131 131
 
132 132
         'email_failed_invoice_header' => array(
133 133
             'id'       => 'email_failed_invoice_header',
134
-            'name'     => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>',
135
-            'desc'     => __( 'Failed invoice emails are sent to the site admin when invoice payments fail.', 'invoicing' ),
134
+            'name'     => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>',
135
+            'desc'     => __('Failed invoice emails are sent to the site admin when invoice payments fail.', 'invoicing'),
136 136
             'type'     => 'header',
137 137
         ),
138 138
 
139 139
         'email_failed_invoice_active' => array(
140 140
             'id'       => 'email_failed_invoice_active',
141
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
142
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
141
+            'name'     => __('Enable/Disable', 'invoicing'),
142
+            'desc'     => __('Enable this email notification', 'invoicing'),
143 143
             'type'     => 'checkbox',
144 144
             'std'      => 1
145 145
         ),
146 146
 
147 147
         'email_failed_invoice_subject' => array(
148 148
             'id'       => 'email_failed_invoice_subject',
149
-            'name'     => __( 'Subject', 'invoicing' ),
150
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
149
+            'name'     => __('Subject', 'invoicing'),
150
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
151 151
             'help-tip' => true,
152 152
             'type'     => 'text',
153
-            'std'      => __( '[{site_title}] Invoice ({invoice_number}) Payment Failed', 'invoicing' ),
153
+            'std'      => __('[{site_title}] Invoice ({invoice_number}) Payment Failed', 'invoicing'),
154 154
             'size'     => 'large'
155 155
         ),
156 156
 
157 157
         'email_failed_invoice_heading' => array(
158 158
             'id'       => 'email_failed_invoice_heading',
159
-            'name'     => __( 'Email Heading', 'invoicing' ),
160
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
159
+            'name'     => __('Email Heading', 'invoicing'),
160
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
161 161
             'help-tip' => true,
162 162
             'type'     => 'text',
163
-            'std'      => __( 'Invoice Payment Failed', 'invoicing' ),
163
+            'std'      => __('Invoice Payment Failed', 'invoicing'),
164 164
             'size'     => 'large'
165 165
         ),
166 166
 
167 167
         'email_failed_invoice_body' => array(
168 168
             'id'       => 'email_failed_invoice_body',
169
-            'name'     => __( 'Email Content', 'invoicing' ),
169
+            'name'     => __('Email Content', 'invoicing'),
170 170
             'desc'     => wpinv_get_merge_tags_help_text(),
171 171
             'type'     => 'rich_editor',
172
-            'std'      => __( '<p>Payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title} has failed to go through. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
172
+            'std'      => __('<p>Payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title} has failed to go through. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
173 173
             'class'    => 'large',
174 174
             'size'     => '10'
175 175
         ),
@@ -179,53 +179,53 @@  discard block
 block discarded – undo
179 179
 
180 180
         'email_onhold_invoice_header' => array(
181 181
             'id'       => 'email_onhold_invoice_header',
182
-            'name'     => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>',
183
-            'desc'     => __( 'These emails are sent to customers whenever their invoices are held.', 'invoicing' ),
182
+            'name'     => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>',
183
+            'desc'     => __('These emails are sent to customers whenever their invoices are held.', 'invoicing'),
184 184
             'type'     => 'header',
185 185
         ),
186 186
 
187 187
         'email_onhold_invoice_active' => array(
188 188
             'id'       => 'email_onhold_invoice_active',
189
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
190
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
189
+            'name'     => __('Enable/Disable', 'invoicing'),
190
+            'desc'     => __('Enable this email notification', 'invoicing'),
191 191
             'type'     => 'checkbox',
192 192
             'std'      => 1
193 193
         ),
194 194
 
195 195
         'email_onhold_invoice_admin_bcc' => array(
196 196
             'id'       => 'email_onhold_invoice_admin_bcc',
197
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
198
-            'desc'     => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
197
+            'name'     => __('Enable Admin BCC', 'invoicing'),
198
+            'desc'     => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
199 199
             'type'     => 'checkbox',
200 200
             'std'      => 1
201 201
         ),
202 202
 
203 203
         'email_onhold_invoice_subject' => array(
204 204
             'id'       => 'email_onhold_invoice_subject',
205
-            'name'     => __( 'Subject', 'invoicing' ),
206
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
205
+            'name'     => __('Subject', 'invoicing'),
206
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
207 207
             'help-tip' => true,
208 208
             'type'     => 'text',
209
-            'std'      => __( '[{site_title}] Your invoice is on hold', 'invoicing' ),
209
+            'std'      => __('[{site_title}] Your invoice is on hold', 'invoicing'),
210 210
             'size'     => 'large'
211 211
         ),
212 212
 
213 213
         'email_onhold_invoice_heading' => array(
214 214
             'id'       => 'email_onhold_invoice_heading',
215
-            'name'     => __( 'Email Heading', 'invoicing' ),
216
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
215
+            'name'     => __('Email Heading', 'invoicing'),
216
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
217 217
             'help-tip' => true,
218 218
             'type'     => 'text',
219
-            'std'      => __( 'Your invoice is on hold', 'invoicing' ),
219
+            'std'      => __('Your invoice is on hold', 'invoicing'),
220 220
             'size'     => 'large'
221 221
         ),
222 222
 
223 223
         'email_onhold_invoice_body' => array(
224 224
             'id'       => 'email_onhold_invoice_body',
225
-            'name'     => __( 'Email Content', 'invoicing' ),
225
+            'name'     => __('Email Content', 'invoicing'),
226 226
             'desc'     => wpinv_get_merge_tags_help_text(),
227 227
             'type'     => 'rich_editor',
228
-            'std'      => __( '<p>Hi {name},</p><p>Your invoice is on-hold and will be processed when we receive your payment. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
228
+            'std'      => __('<p>Hi {name},</p><p>Your invoice is on-hold and will be processed when we receive your payment. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
229 229
             'class'    => 'large',
230 230
             'size'     => '10'
231 231
         ),
@@ -236,53 +236,53 @@  discard block
 block discarded – undo
236 236
 
237 237
         'email_processing_invoice_header' => array(
238 238
             'id'       => 'email_processing_invoice_header',
239
-            'name'     => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>',
240
-            'desc'     => __( 'These emails are sent to users whenever payments for their invoices are processing.', 'invoicing' ),
239
+            'name'     => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>',
240
+            'desc'     => __('These emails are sent to users whenever payments for their invoices are processing.', 'invoicing'),
241 241
             'type'     => 'header',
242 242
         ),
243 243
 
244 244
         'email_processing_invoice_active' => array(
245 245
             'id'       => 'email_processing_invoice_active',
246
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
247
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
246
+            'name'     => __('Enable/Disable', 'invoicing'),
247
+            'desc'     => __('Enable this email notification', 'invoicing'),
248 248
             'type'     => 'checkbox',
249 249
             'std'      => 1
250 250
         ),
251 251
 
252 252
         'email_processing_invoice_admin_bcc' => array(
253 253
             'id'       => 'email_processing_invoice_admin_bcc',
254
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
255
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
254
+            'name'     => __('Enable Admin BCC', 'invoicing'),
255
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
256 256
             'type'     => 'checkbox',
257 257
             'std'      => 1
258 258
         ),
259 259
 
260 260
         'email_processing_invoice_subject' => array(
261 261
             'id'       => 'email_processing_invoice_subject',
262
-            'name'     => __( 'Subject', 'invoicing' ),
263
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
262
+            'name'     => __('Subject', 'invoicing'),
263
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
264 264
             'help-tip' => true,
265 265
             'type'     => 'text',
266
-            'std'      => __( '[{site_title}] Your payment is being processed', 'invoicing' ),
266
+            'std'      => __('[{site_title}] Your payment is being processed', 'invoicing'),
267 267
             'size'     => 'large'
268 268
         ),
269 269
 
270 270
         'email_processing_invoice_heading' => array(
271 271
             'id'       => 'email_processing_invoice_heading',
272
-            'name'     => __( 'Email Heading', 'invoicing' ),
273
-            'desc'     => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
272
+            'name'     => __('Email Heading', 'invoicing'),
273
+            'desc'     => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
274 274
             'help-tip' => true,
275 275
             'type'     => 'text',
276
-            'std'      => __( 'Your payment is being processed', 'invoicing' ),
276
+            'std'      => __('Your payment is being processed', 'invoicing'),
277 277
             'size'     => 'large'
278 278
         ),
279 279
 
280 280
         'email_processing_invoice_body' => array(
281 281
             'id'       => 'email_processing_invoice_body',
282
-            'name'     => __( 'Email Content', 'invoicing' ),
282
+            'name'     => __('Email Content', 'invoicing'),
283 283
             'desc'     => wpinv_get_merge_tags_help_text(),
284 284
             'type'     => 'rich_editor',
285
-            'std'      => __( '<p>Hi {name},</p><p>I would like to let you know that we have received and are currently processing your payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title}. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
285
+            'std'      => __('<p>Hi {name},</p><p>I would like to let you know that we have received and are currently processing your payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title}. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
286 286
             'class'    => 'large',
287 287
             'size'     => '10'
288 288
         ),
@@ -293,61 +293,61 @@  discard block
 block discarded – undo
293 293
 
294 294
         'email_completed_invoice_header' => array(
295 295
             'id'       => 'email_completed_invoice_header',
296
-            'name'     => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>',
297
-            'desc'     => __( 'These emails are sent to customers when their invoices are marked as paid.', 'invoicing' ),
296
+            'name'     => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>',
297
+            'desc'     => __('These emails are sent to customers when their invoices are marked as paid.', 'invoicing'),
298 298
             'type'     => 'header',
299 299
         ),
300 300
 
301 301
         'email_completed_invoice_active' => array(
302 302
             'id'       => 'email_completed_invoice_active',
303
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
304
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
303
+            'name'     => __('Enable/Disable', 'invoicing'),
304
+            'desc'     => __('Enable this email notification', 'invoicing'),
305 305
             'type'     => 'checkbox',
306 306
             'std'      => 1
307 307
         ),
308 308
 
309 309
         'email_completed_invoice_renewal_active' => array(
310 310
             'id'       => 'email_completed_invoice_renewal_active',
311
-            'name'     => __( 'Enable renewal notification', 'invoicing' ),
312
-            'desc'     => __( 'Should this email be sent for renewals too?', 'invoicing' ),
311
+            'name'     => __('Enable renewal notification', 'invoicing'),
312
+            'desc'     => __('Should this email be sent for renewals too?', 'invoicing'),
313 313
             'type'     => 'checkbox',
314 314
             'std'      => 1
315 315
         ),
316 316
 
317 317
         'email_completed_invoice_admin_bcc' => array(
318 318
             'id'       => 'email_completed_invoice_admin_bcc',
319
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
320
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
319
+            'name'     => __('Enable Admin BCC', 'invoicing'),
320
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
321 321
             'type'     => 'checkbox',
322 322
             'std'      => 1,
323 323
         ),
324 324
 
325 325
         'email_completed_invoice_subject' => array(
326 326
             'id'       => 'email_completed_invoice_subject',
327
-            'name'     => __( 'Subject', 'invoicing' ),
328
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
327
+            'name'     => __('Subject', 'invoicing'),
328
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
329 329
             'help-tip' => true,
330 330
             'type'     => 'text',
331
-            'std'      => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ),
331
+            'std'      => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'),
332 332
             'size'     => 'large'
333 333
         ),
334 334
 
335 335
         'email_completed_invoice_heading' => array(
336 336
             'id'       => 'email_completed_invoice_heading',
337
-            'name'     => __( 'Email Heading', 'invoicing' ),
338
-            'desc'     => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
337
+            'name'     => __('Email Heading', 'invoicing'),
338
+            'desc'     => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
339 339
             'help-tip' => true,
340 340
             'type'     => 'text',
341
-            'std'      => __( 'Your invoice has been paid', 'invoicing' ),
341
+            'std'      => __('Your invoice has been paid', 'invoicing'),
342 342
             'size'     => 'large'
343 343
         ),
344 344
 
345 345
         'email_completed_invoice_body' => array(
346 346
             'id'       => 'email_completed_invoice_body',
347
-            'name'     => __( 'Email Content', 'invoicing' ),
347
+            'name'     => __('Email Content', 'invoicing'),
348 348
             'desc'     => wpinv_get_merge_tags_help_text(),
349 349
             'type'     => 'rich_editor',
350
-            'std'      => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
350
+            'std'      => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
351 351
             'class'    => 'large',
352 352
             'size'     => '10'
353 353
         ),
@@ -358,53 +358,53 @@  discard block
 block discarded – undo
358 358
 
359 359
         'email_refunded_invoice_header' => array(
360 360
             'id'       => 'email_refunded_invoice_header',
361
-            'name'     => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>',
362
-            'desc'     => __( 'These emails are sent to users when their invoices are marked as refunded.', 'invoicing' ),
361
+            'name'     => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>',
362
+            'desc'     => __('These emails are sent to users when their invoices are marked as refunded.', 'invoicing'),
363 363
             'type'     => 'header',
364 364
         ),
365 365
 
366 366
         'email_refunded_invoice_active' => array(
367 367
             'id'       => 'email_refunded_invoice_active',
368
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
369
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
368
+            'name'     => __('Enable/Disable', 'invoicing'),
369
+            'desc'     => __('Enable this email notification', 'invoicing'),
370 370
             'type'     => 'checkbox',
371 371
             'std'      => 1
372 372
         ),
373 373
 
374 374
         'email_refunded_invoice_admin_bcc' => array(
375 375
             'id'       => 'email_refunded_invoice_admin_bcc',
376
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
377
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
376
+            'name'     => __('Enable Admin BCC', 'invoicing'),
377
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
378 378
             'type'     => 'checkbox',
379 379
             'std'      => 1
380 380
         ),
381 381
 
382 382
         'email_refunded_invoice_subject' => array(
383 383
             'id'       => 'email_refunded_invoice_subject',
384
-            'name'     => __( 'Subject', 'invoicing' ),
385
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
384
+            'name'     => __('Subject', 'invoicing'),
385
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
386 386
             'help-tip' => true,
387 387
             'type'     => 'text',
388
-            'std'      => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ),
388
+            'std'      => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'),
389 389
             'size'     => 'large'
390 390
         ),
391 391
 
392 392
         'email_refunded_invoice_heading' => array(
393 393
             'id'       => 'email_refunded_invoice_heading',
394
-            'name'     => __( 'Email Heading', 'invoicing' ),
395
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
394
+            'name'     => __('Email Heading', 'invoicing'),
395
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
396 396
             'help-tip' => true,
397 397
             'type'     => 'text',
398
-            'std'      => __( 'Your invoice has been refunded', 'invoicing' ),
398
+            'std'      => __('Your invoice has been refunded', 'invoicing'),
399 399
             'size'     => 'large'
400 400
         ),
401 401
 
402 402
         'email_refunded_invoice_body' => array(
403 403
             'id'       => 'email_refunded_invoice_body',
404
-            'name'     => __( 'Email Content', 'invoicing' ),
404
+            'name'     => __('Email Content', 'invoicing'),
405 405
             'desc'     => wpinv_get_merge_tags_help_text(),
406 406
             'type'     => 'rich_editor',
407
-            'std'      => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ),
407
+            'std'      => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'),
408 408
             'class'    => 'large',
409 409
             'size'     => '10'
410 410
         ),
@@ -415,53 +415,53 @@  discard block
 block discarded – undo
415 415
 
416 416
         'email_user_invoice_header' => array(
417 417
             'id'       => 'email_user_invoice_header',
418
-            'name'     => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>',
419
-            'desc'     => __( 'These emails are sent to customers containing their invoice information and payment links.', 'invoicing' ),
418
+            'name'     => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>',
419
+            'desc'     => __('These emails are sent to customers containing their invoice information and payment links.', 'invoicing'),
420 420
             'type'     => 'header',
421 421
         ),
422 422
 
423 423
         'email_user_invoice_active' => array(
424 424
             'id'       => 'email_user_invoice_active',
425
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
426
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
425
+            'name'     => __('Enable/Disable', 'invoicing'),
426
+            'desc'     => __('Enable this email notification', 'invoicing'),
427 427
             'type'     => 'checkbox',
428 428
             'std'      => 1
429 429
         ),
430 430
 
431 431
         'email_user_invoice_admin_bcc' => array(
432 432
             'id'       => 'email_user_invoice_admin_bcc',
433
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
434
-            'desc'     => __( 'Check if you want to send a copy of this notification email to to the site admin.', 'invoicing' ),
433
+            'name'     => __('Enable Admin BCC', 'invoicing'),
434
+            'desc'     => __('Check if you want to send a copy of this notification email to to the site admin.', 'invoicing'),
435 435
             'type'     => 'checkbox',
436 436
             'std'      => 0
437 437
         ),
438 438
 
439 439
         'email_user_invoice_subject' => array(
440 440
             'id'       => 'email_user_invoice_subject',
441
-            'name'     => __( 'Subject', 'invoicing' ),
442
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
441
+            'name'     => __('Subject', 'invoicing'),
442
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
443 443
             'help-tip' => true,
444 444
             'type'     => 'text',
445
-            'std'      => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ),
445
+            'std'      => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'),
446 446
             'size'     => 'large'
447 447
         ),
448 448
 
449 449
         'email_user_invoice_heading' => array(
450 450
             'id'       => 'email_user_invoice_heading',
451
-            'name'     => __( 'Email Heading', 'invoicing' ),
452
-            'desc'     => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
451
+            'name'     => __('Email Heading', 'invoicing'),
452
+            'desc'     => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
453 453
             'help-tip' => true,
454 454
             'type'     => 'text',
455
-            'std'      => __( 'Your invoice {invoice_number} details', 'invoicing' ),
455
+            'std'      => __('Your invoice {invoice_number} details', 'invoicing'),
456 456
             'size'     => 'large'
457 457
         ),
458 458
 
459 459
         'email_user_invoice_body' => array(
460 460
             'id'       => 'email_user_invoice_body',
461
-            'name'     => __( 'Email Content', 'invoicing' ),
461
+            'name'     => __('Email Content', 'invoicing'),
462 462
             'desc'     => wpinv_get_merge_tags_help_text(),
463 463
             'type'     => 'rich_editor',
464
-            'std'      => __( '<p>Hi {name},</p><p>An invoice of {invoice_total} has been created for you on {site_title}. You can <a href="{invoice_link}">view</a> or <a href="{invoice_pay_link}">pay</a> the invoice. Please reply to this email if you have any questions about the invoice.', 'invoicing' ),
464
+            'std'      => __('<p>Hi {name},</p><p>An invoice of {invoice_total} has been created for you on {site_title}. You can <a href="{invoice_link}">view</a> or <a href="{invoice_pay_link}">pay</a> the invoice. Please reply to this email if you have any questions about the invoice.', 'invoicing'),
465 465
             'class'    => 'large',
466 466
             'size'     => '10'
467 467
         ),
@@ -471,53 +471,53 @@  discard block
 block discarded – undo
471 471
 
472 472
         'email_user_note_header' => array(
473 473
             'id'       => 'email_user_note_header',
474
-            'name'     => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>',
475
-            'desc'     => __( 'These emails are sent when you add a customer note to an invoice/quote.', 'invoicing' ),
474
+            'name'     => '<h3>' . __('Customer Note', 'invoicing') . '</h3>',
475
+            'desc'     => __('These emails are sent when you add a customer note to an invoice/quote.', 'invoicing'),
476 476
             'type'     => 'header',
477 477
         ),
478 478
 
479 479
         'email_user_note_active' => array(
480 480
             'id'       => 'email_user_note_active',
481
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
482
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
481
+            'name'     => __('Enable/Disable', 'invoicing'),
482
+            'desc'     => __('Enable this email notification', 'invoicing'),
483 483
             'type'     => 'checkbox',
484 484
             'std'      => 1
485 485
         ),
486 486
 
487 487
         'email_user_note_admin_bcc' => array(
488 488
             'id'       => 'email_user_note_admin_bcc',
489
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
490
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
489
+            'name'     => __('Enable Admin BCC', 'invoicing'),
490
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
491 491
             'type'     => 'checkbox',
492 492
             'std'      => 0
493 493
         ),
494 494
 
495 495
         'email_user_note_subject' => array(
496 496
             'id'       => 'email_user_note_subject',
497
-            'name'     => __( 'Subject', 'invoicing' ),
498
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
497
+            'name'     => __('Subject', 'invoicing'),
498
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
499 499
             'help-tip' => true,
500 500
             'type'     => 'text',
501
-            'std'      => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ),
501
+            'std'      => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'),
502 502
             'size'     => 'large'
503 503
         ),
504 504
 
505 505
         'email_user_note_heading' => array(
506 506
             'id'       => 'email_user_note_heading',
507
-            'name'     => __( 'Email Heading', 'invoicing' ),
508
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
507
+            'name'     => __('Email Heading', 'invoicing'),
508
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
509 509
             'help-tip' => true,
510 510
             'type'     => 'text',
511
-            'std'      => __( 'A note has been added to your {invoice_label}', 'invoicing' ),
511
+            'std'      => __('A note has been added to your {invoice_label}', 'invoicing'),
512 512
             'size'     => 'large'
513 513
         ),
514 514
 
515 515
         'email_user_note_body' => array(
516 516
             'id'       => 'email_user_note_body',
517
-            'name'     => __( 'Email Content', 'invoicing' ),
517
+            'name'     => __('Email Content', 'invoicing'),
518 518
             'desc'     => wpinv_get_merge_tags_help_text(),
519 519
             'type'     => 'rich_editor',
520
-            'std'      => __( '<p>Hi {name},</p><p>The following note has been added to your {invoice_label} <a href="{invoice_link}">#{invoice_number}</a>:</p><blockquote class="wpinv-note">{customer_note}</blockquote><a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a>', 'invoicing' ),
520
+            'std'      => __('<p>Hi {name},</p><p>The following note has been added to your {invoice_label} <a href="{invoice_link}">#{invoice_number}</a>:</p><blockquote class="wpinv-note">{customer_note}</blockquote><a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a>', 'invoicing'),
521 521
             'class'    => 'large',
522 522
             'size'     => '10'
523 523
         ),
@@ -527,63 +527,63 @@  discard block
 block discarded – undo
527 527
 
528 528
         'email_overdue_header' => array(
529 529
             'id'       => 'email_overdue_header',
530
-            'name'     => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>',
531
-            'desc'     => __( 'Payment reminder emails are sent to customers whenever their invoices are due.', 'invoicing' ),
530
+            'name'     => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>',
531
+            'desc'     => __('Payment reminder emails are sent to customers whenever their invoices are due.', 'invoicing'),
532 532
             'type'     => 'header',
533 533
         ),
534 534
 
535 535
         'email_overdue_active' => array(
536 536
             'id'       => 'email_overdue_active',
537
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
538
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
537
+            'name'     => __('Enable/Disable', 'invoicing'),
538
+            'desc'     => __('Enable this email notification', 'invoicing'),
539 539
             'type'     => 'checkbox',
540 540
             'std'      => 1
541 541
         ),
542 542
 
543 543
         'email_overdue_admin_bcc' => array(
544 544
             'id'       => 'email_overdue_admin_bcc',
545
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
546
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
545
+            'name'     => __('Enable Admin BCC', 'invoicing'),
546
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
547 547
             'type'     => 'checkbox',
548 548
             'std'      => 0
549 549
         ),
550 550
 
551 551
         'email_overdue_days' => array(
552 552
             'id'       => 'email_overdue_days',
553
-            'name'     => __( 'When to Send', 'invoicing' ),
554
-            'desc'     => __( 'Check when you would like payment reminders sent out.', 'invoicing' ),
553
+            'name'     => __('When to Send', 'invoicing'),
554
+            'desc'     => __('Check when you would like payment reminders sent out.', 'invoicing'),
555 555
             'help-tip' => true,
556
-            'std'      => array( '1' ),
556
+            'std'      => array('1'),
557 557
             'type'     => 'multicheck',
558 558
             'options'  => $overdue_days_options,
559 559
         ),
560 560
 
561 561
         'email_overdue_subject' => array(
562 562
             'id'       => 'email_overdue_subject',
563
-            'name'     => __( 'Subject', 'invoicing' ),
564
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
563
+            'name'     => __('Subject', 'invoicing'),
564
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
565 565
             'help-tip' => true,
566 566
             'type'     => 'text',
567
-            'std'      => __( '[{site_title}] Payment Reminder', 'invoicing' ),
567
+            'std'      => __('[{site_title}] Payment Reminder', 'invoicing'),
568 568
             'size'     => 'large'
569 569
         ),
570 570
 
571 571
         'email_overdue_heading' => array(
572 572
             'id'       => 'email_overdue_heading',
573
-            'name'     => __( 'Email Heading', 'invoicing' ),
574
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
573
+            'name'     => __('Email Heading', 'invoicing'),
574
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
575 575
             'help-tip' => true,
576 576
             'type'     => 'text',
577
-            'std'      => __( 'Payment reminder for your invoice', 'invoicing' ),
577
+            'std'      => __('Payment reminder for your invoice', 'invoicing'),
578 578
             'size'     => 'large'
579 579
         ),
580 580
 
581 581
         'email_overdue_body' => array(
582 582
             'id'       => 'email_overdue_body',
583
-            'name'     => __( 'Email Content', 'invoicing' ),
583
+            'name'     => __('Email Content', 'invoicing'),
584 584
             'desc'     => wpinv_get_merge_tags_help_text(),
585 585
             'type'     => 'rich_editor',
586
-            'std'      => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
586
+            'std'      => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
587 587
             'class'    => 'large',
588 588
             'size'     => 10,
589 589
         ),
@@ -594,63 +594,63 @@  discard block
 block discarded – undo
594 594
 
595 595
         'email_renewal_reminder_header' => array(
596 596
             'id'       => 'email_renewal_reminder_header',
597
-            'name'     => '<h3>' . __( 'Renewal Reminder', 'invoicing' ) . '</h3>',
598
-            'desc'     => __( 'These emails are sent to customers whenever their subscription is about to renew.', 'invoicing' ),
597
+            'name'     => '<h3>' . __('Renewal Reminder', 'invoicing') . '</h3>',
598
+            'desc'     => __('These emails are sent to customers whenever their subscription is about to renew.', 'invoicing'),
599 599
             'type'     => 'header',
600 600
         ),
601 601
 
602 602
         'email_renewal_reminder_active' => array(
603 603
             'id'       => 'email_renewal_reminder_active',
604
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
605
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
604
+            'name'     => __('Enable/Disable', 'invoicing'),
605
+            'desc'     => __('Enable this email notification', 'invoicing'),
606 606
             'type'     => 'checkbox',
607 607
             'std'      => 0
608 608
         ),
609 609
 
610 610
         'email_renewal_reminder_admin_bcc' => array(
611 611
             'id'       => 'email_renewal_reminder_admin_bcc',
612
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
613
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
612
+            'name'     => __('Enable Admin BCC', 'invoicing'),
613
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
614 614
             'type'     => 'checkbox',
615 615
             'std'      => 0
616 616
         ),
617 617
 
618 618
         'email_renewal_reminder_days' => array(
619 619
             'id'       => 'email_renewal_reminder_days',
620
-            'name'     => __( 'When to Send', 'invoicing' ),
621
-            'desc'     => __( 'Check when you would like renewal reminders sent out.', 'invoicing' ),
620
+            'name'     => __('When to Send', 'invoicing'),
621
+            'desc'     => __('Check when you would like renewal reminders sent out.', 'invoicing'),
622 622
             'help-tip' => true,
623
-            'std'      => array( '1', '5', '10' ),
623
+            'std'      => array('1', '5', '10'),
624 624
             'type'     => 'multicheck',
625 625
             'options'  => $renewal_days_options,
626 626
         ),
627 627
 
628 628
         'email_renewal_reminder_subject' => array(
629 629
             'id'       => 'email_renewal_reminder_subject',
630
-            'name'     => __( 'Subject', 'invoicing' ),
631
-            'desc'     => __( 'Enter the subject line for the email.', 'invoicing' ),
630
+            'name'     => __('Subject', 'invoicing'),
631
+            'desc'     => __('Enter the subject line for the email.', 'invoicing'),
632 632
             'help-tip' => true,
633 633
             'type'     => 'text',
634
-            'std'      => __( '[{site_title}] Renewal Reminder', 'invoicing' ),
634
+            'std'      => __('[{site_title}] Renewal Reminder', 'invoicing'),
635 635
             'size'     => 'large'
636 636
         ),
637 637
 
638 638
         'email_renewal_reminder_heading' => array(
639 639
             'id'       => 'email_renewal_reminder_heading',
640
-            'name'     => __( 'Email Heading', 'invoicing' ),
641
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
640
+            'name'     => __('Email Heading', 'invoicing'),
641
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
642 642
             'help-tip' => true,
643 643
             'type'     => 'text',
644
-            'std'      => __( 'Upcoming renewal reminder', 'invoicing' ),
644
+            'std'      => __('Upcoming renewal reminder', 'invoicing'),
645 645
             'size'     => 'large'
646 646
         ),
647 647
 
648 648
         'email_renewal_reminder_body' => array(
649 649
             'id'       => 'email_renewal_reminder_body',
650
-            'name'     => __( 'Email Content', 'invoicing' ),
651
-            'desc'     => wpinv_get_merge_tags_help_text( true ),
650
+            'name'     => __('Email Content', 'invoicing'),
651
+            'desc'     => wpinv_get_merge_tags_help_text(true),
652 652
             'type'     => 'rich_editor',
653
-            'std'      => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing' ),
653
+            'std'      => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing'),
654 654
             'class'    => 'large',
655 655
             'size'     => 10,
656 656
         ),
@@ -661,53 +661,53 @@  discard block
 block discarded – undo
661 661
 
662 662
         'email_subscription_trial_header' => array(
663 663
             'id'       => 'email_subscription_trial_header',
664
-            'name'     => '<h3>' . __( 'Trial Started', 'invoicing' ) . '</h3>',
665
-            'desc'     => __( 'These emails are sent when a customer starts a subscription trial.', 'invoicing' ),
664
+            'name'     => '<h3>' . __('Trial Started', 'invoicing') . '</h3>',
665
+            'desc'     => __('These emails are sent when a customer starts a subscription trial.', 'invoicing'),
666 666
             'type'     => 'header',
667 667
         ),
668 668
 
669 669
         'email_subscription_trial_active' => array(
670 670
             'id'       => 'email_subscription_trial_active',
671
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
672
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
671
+            'name'     => __('Enable/Disable', 'invoicing'),
672
+            'desc'     => __('Enable this email notification', 'invoicing'),
673 673
             'type'     => 'checkbox',
674 674
             'std'      => 0
675 675
         ),
676 676
 
677 677
         'email_subscription_trial_admin_bcc' => array(
678 678
             'id'       => 'email_subscription_trial_admin_bcc',
679
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
680
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
679
+            'name'     => __('Enable Admin BCC', 'invoicing'),
680
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
681 681
             'type'     => 'checkbox',
682 682
             'std'      => 0
683 683
         ),
684 684
 
685 685
         'email_subscription_trial_subject' => array(
686 686
             'id'       => 'email_subscription_trial_subject',
687
-            'name'     => __( 'Subject', 'invoicing' ),
688
-            'desc'     => __( 'Enter the subject line for the subscription trial email.', 'invoicing' ),
687
+            'name'     => __('Subject', 'invoicing'),
688
+            'desc'     => __('Enter the subject line for the subscription trial email.', 'invoicing'),
689 689
             'help-tip' => true,
690 690
             'type'     => 'text',
691
-            'std'      => __( '[{site_title}] Trial Started', 'invoicing' ),
691
+            'std'      => __('[{site_title}] Trial Started', 'invoicing'),
692 692
             'size'     => 'large'
693 693
         ),
694 694
 
695 695
         'email_subscription_trial_heading' => array(
696 696
             'id'       => 'email_subscription_trial_heading',
697
-            'name'     => __( 'Email Heading', 'invoicing' ),
698
-            'desc'     => __( 'Enter the main heading of this email.', 'invoicing' ),
697
+            'name'     => __('Email Heading', 'invoicing'),
698
+            'desc'     => __('Enter the main heading of this email.', 'invoicing'),
699 699
             'help-tip' => true,
700 700
             'type'     => 'text',
701
-            'std'      => __( 'Trial Started', 'invoicing' ),
701
+            'std'      => __('Trial Started', 'invoicing'),
702 702
             'size'     => 'large'
703 703
         ),
704 704
 
705 705
         'email_subscription_trial_body' => array(
706 706
             'id'       => 'email_subscription_trial_body',
707
-            'name'     => __( 'Email Content', 'invoicing' ),
708
-            'desc'     => wpinv_get_merge_tags_help_text( true ),
707
+            'name'     => __('Email Content', 'invoicing'),
708
+            'desc'     => wpinv_get_merge_tags_help_text(true),
709 709
             'type'     => 'rich_editor',
710
-            'std'      => __( '<p>Hi {first_name},</p><p>Your trial for {subscription_name} is now active and will renew on {subscription_renewal_date}.</p>', 'invoicing' ),
710
+            'std'      => __('<p>Hi {first_name},</p><p>Your trial for {subscription_name} is now active and will renew on {subscription_renewal_date}.</p>', 'invoicing'),
711 711
             'class'    => 'large',
712 712
             'size'     => 10,
713 713
         ),
@@ -717,53 +717,53 @@  discard block
 block discarded – undo
717 717
 
718 718
         'email_subscription_cancelled_header' => array(
719 719
             'id'       => 'email_subscription_cancelled_header',
720
-            'name'     => '<h3>' . __( 'Subscription Cancelled', 'invoicing' ) . '</h3>',
721
-            'desc'     => __( 'These emails are sent when a customer cancels their subscription.', 'invoicing' ),
720
+            'name'     => '<h3>' . __('Subscription Cancelled', 'invoicing') . '</h3>',
721
+            'desc'     => __('These emails are sent when a customer cancels their subscription.', 'invoicing'),
722 722
             'type'     => 'header',
723 723
         ),
724 724
 
725 725
         'email_subscription_cancelled_active' => array(
726 726
             'id'       => 'email_subscription_cancelled_active',
727
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
728
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
727
+            'name'     => __('Enable/Disable', 'invoicing'),
728
+            'desc'     => __('Enable this email notification', 'invoicing'),
729 729
             'type'     => 'checkbox',
730 730
             'std'      => 1
731 731
         ),
732 732
 
733 733
         'email_subscription_cancelled_admin_bcc' => array(
734 734
             'id'       => 'email_subscription_cancelled_admin_bcc',
735
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
736
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
735
+            'name'     => __('Enable Admin BCC', 'invoicing'),
736
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
737 737
             'type'     => 'checkbox',
738 738
             'std'      => 1
739 739
         ),
740 740
 
741 741
         'email_subscription_cancelled_subject' => array(
742 742
             'id'       => 'email_subscription_cancelled_subject',
743
-            'name'     => __( 'Subject', 'invoicing' ),
744
-            'desc'     => __( 'Enter the subject line for the subscription cancelled email.', 'invoicing' ),
743
+            'name'     => __('Subject', 'invoicing'),
744
+            'desc'     => __('Enter the subject line for the subscription cancelled email.', 'invoicing'),
745 745
             'help-tip' => true,
746 746
             'type'     => 'text',
747
-            'std'      => __( '[{site_title}] Subscription Cancelled', 'invoicing' ),
747
+            'std'      => __('[{site_title}] Subscription Cancelled', 'invoicing'),
748 748
             'size'     => 'large'
749 749
         ),
750 750
 
751 751
         'email_subscription_cancelled_heading' => array(
752 752
             'id'       => 'email_subscription_cancelled_heading',
753
-            'name'     => __( 'Email Heading', 'invoicing' ),
754
-            'desc'     => __( 'Enter the main heading of this email.', 'invoicing' ),
753
+            'name'     => __('Email Heading', 'invoicing'),
754
+            'desc'     => __('Enter the main heading of this email.', 'invoicing'),
755 755
             'help-tip' => true,
756 756
             'type'     => 'text',
757
-            'std'      => __( 'Subscription Cancelled', 'invoicing' ),
757
+            'std'      => __('Subscription Cancelled', 'invoicing'),
758 758
             'size'     => 'large'
759 759
         ),
760 760
 
761 761
         'email_subscription_cancelled_body' => array(
762 762
             'id'       => 'email_subscription_cancelled_body',
763
-            'name'     => __( 'Email Content', 'invoicing' ),
764
-            'desc'     => wpinv_get_merge_tags_help_text( true ),
763
+            'name'     => __('Email Content', 'invoicing'),
764
+            'desc'     => wpinv_get_merge_tags_help_text(true),
765 765
             'type'     => 'rich_editor',
766
-            'std'      => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has been cancelled and will no longer renew.</p>', 'invoicing' ),
766
+            'std'      => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has been cancelled and will no longer renew.</p>', 'invoicing'),
767 767
             'class'    => 'large',
768 768
             'size'     => 10,
769 769
         ),
@@ -773,53 +773,53 @@  discard block
 block discarded – undo
773 773
 
774 774
         'email_subscription_expired_header' => array(
775 775
             'id'       => 'email_subscription_expired_header',
776
-            'name'     => '<h3>' . __( 'Subscription Expired', 'invoicing' ) . '</h3>',
777
-            'desc'     => __( "These emails are sent when a customer's subscription expires and automatic renewal fails.", 'invoicing' ),
776
+            'name'     => '<h3>' . __('Subscription Expired', 'invoicing') . '</h3>',
777
+            'desc'     => __("These emails are sent when a customer's subscription expires and automatic renewal fails.", 'invoicing'),
778 778
             'type'     => 'header',
779 779
         ),
780 780
 
781 781
         'email_subscription_expired_active' => array(
782 782
             'id'       => 'email_subscription_expired_active',
783
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
784
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
783
+            'name'     => __('Enable/Disable', 'invoicing'),
784
+            'desc'     => __('Enable this email notification', 'invoicing'),
785 785
             'type'     => 'checkbox',
786 786
             'std'      => 1
787 787
         ),
788 788
 
789 789
         'email_subscription_expired_admin_bcc' => array(
790 790
             'id'       => 'email_subscription_expired_admin_bcc',
791
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
792
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
791
+            'name'     => __('Enable Admin BCC', 'invoicing'),
792
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
793 793
             'type'     => 'checkbox',
794 794
             'std'      => 1
795 795
         ),
796 796
 
797 797
         'email_subscription_expired_subject' => array(
798 798
             'id'       => 'email_subscription_expired_subject',
799
-            'name'     => __( 'Subject', 'invoicing' ),
800
-            'desc'     => __( 'Enter the subject line for the subscription expired email.', 'invoicing' ),
799
+            'name'     => __('Subject', 'invoicing'),
800
+            'desc'     => __('Enter the subject line for the subscription expired email.', 'invoicing'),
801 801
             'help-tip' => true,
802 802
             'type'     => 'text',
803
-            'std'      => __( '[{site_title}] Subscription Expired', 'invoicing' ),
803
+            'std'      => __('[{site_title}] Subscription Expired', 'invoicing'),
804 804
             'size'     => 'large'
805 805
         ),
806 806
 
807 807
         'email_subscription_expired_heading' => array(
808 808
             'id'       => 'email_subscription_expired_heading',
809
-            'name'     => __( 'Email Heading', 'invoicing' ),
810
-            'desc'     => __( 'Enter the main heading of this email.', 'invoicing' ),
809
+            'name'     => __('Email Heading', 'invoicing'),
810
+            'desc'     => __('Enter the main heading of this email.', 'invoicing'),
811 811
             'type'     => 'text',
812
-            'std'      => __( 'Subscription Expired', 'invoicing' ),
812
+            'std'      => __('Subscription Expired', 'invoicing'),
813 813
             'help-tip' => true,
814 814
             'size'     => 'large'
815 815
         ),
816 816
 
817 817
         'email_subscription_expired_body' => array(
818 818
             'id'       => 'email_subscription_expired_body',
819
-            'name'     => __( 'Email Content', 'invoicing' ),
820
-            'desc'     => wpinv_get_merge_tags_help_text( true ),
819
+            'name'     => __('Email Content', 'invoicing'),
820
+            'desc'     => wpinv_get_merge_tags_help_text(true),
821 821
             'type'     => 'rich_editor',
822
-            'std'      => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has expired.</p>', 'invoicing' ),
822
+            'std'      => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has expired.</p>', 'invoicing'),
823 823
             'class'    => 'large',
824 824
             'size'     => 10,
825 825
         ),
@@ -829,53 +829,53 @@  discard block
 block discarded – undo
829 829
 
830 830
         'email_subscription_complete_header' => array(
831 831
             'id'     => 'email_subscription_complete_header',
832
-            'name'   => '<h3>' . __( 'Subscription Complete', 'invoicing' ) . '</h3>',
833
-            'desc'   => __( 'These emails are sent when a customer completes their subscription.', 'invoicing' ),
832
+            'name'   => '<h3>' . __('Subscription Complete', 'invoicing') . '</h3>',
833
+            'desc'   => __('These emails are sent when a customer completes their subscription.', 'invoicing'),
834 834
             'type'   => 'header',
835 835
         ),
836 836
 
837 837
         'email_subscription_complete_active' => array(
838 838
             'id'      => 'email_subscription_complete_active',
839
-            'name'    => __( 'Enable/Disable', 'invoicing' ),
840
-            'desc'    => __( 'Enable this email notification', 'invoicing' ),
839
+            'name'    => __('Enable/Disable', 'invoicing'),
840
+            'desc'    => __('Enable this email notification', 'invoicing'),
841 841
             'type'    => 'checkbox',
842 842
             'std'     => 1
843 843
         ),
844 844
 
845 845
         'email_subscription_complete_admin_bcc' => array(
846 846
             'id'      => 'email_subscription_complete_admin_bcc',
847
-            'name'    => __( 'Enable Admin BCC', 'invoicing' ),
848
-            'desc'    => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
847
+            'name'    => __('Enable Admin BCC', 'invoicing'),
848
+            'desc'    => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
849 849
             'type'    => 'checkbox',
850 850
             'std'     => 1
851 851
         ),
852 852
 
853 853
         'email_subscription_complete_subject' => array(
854 854
             'id'       => 'email_subscription_complete_subject',
855
-            'name'     => __( 'Subject', 'invoicing' ),
856
-            'desc'     => __( 'Enter the subject line for the subscription complete email.', 'invoicing' ),
855
+            'name'     => __('Subject', 'invoicing'),
856
+            'desc'     => __('Enter the subject line for the subscription complete email.', 'invoicing'),
857 857
             'help-tip' => true,
858 858
             'type'     => 'text',
859
-            'std'      => __( '[{site_title}] Subscription Complete', 'invoicing' ),
859
+            'std'      => __('[{site_title}] Subscription Complete', 'invoicing'),
860 860
             'size'     => 'large'
861 861
         ),
862 862
 
863 863
         'email_subscription_complete_heading' => array(
864 864
             'id'       => 'email_subscription_complete_heading',
865
-            'name'     => __( 'Email Heading', 'invoicing' ),
866
-            'desc'     => __( 'Enter the main heading of this email.', 'invoicing' ),
865
+            'name'     => __('Email Heading', 'invoicing'),
866
+            'desc'     => __('Enter the main heading of this email.', 'invoicing'),
867 867
             'help-tip' => true,
868 868
             'type'     => 'text',
869
-            'std'      => __( 'Subscription Complete', 'invoicing' ),
869
+            'std'      => __('Subscription Complete', 'invoicing'),
870 870
             'size'     => 'large'
871 871
         ),
872 872
 
873 873
         'email_subscription_complete_body' => array(
874 874
             'id'       => 'email_subscription_complete_body',
875
-            'name'     => __( 'Email Content', 'invoicing' ),
876
-            'desc'     => wpinv_get_merge_tags_help_text( true ),
875
+            'name'     => __('Email Content', 'invoicing'),
876
+            'desc'     => wpinv_get_merge_tags_help_text(true),
877 877
             'type'     => 'rich_editor',
878
-            'std'      => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} is now complete.</p>', 'invoicing' ),
878
+            'std'      => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} is now complete.</p>', 'invoicing'),
879 879
             'class'    => 'large',
880 880
             'size'     => 10,
881 881
         ),
Please login to merge, or discard this patch.
includes/wpinv-subscription.php 2 patches
Indentation   +1035 added lines, -1035 removed lines patch added patch discarded remove patch
@@ -15,125 +15,125 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class WPInv_Subscription extends GetPaid_Data {
17 17
 
18
-	/**
19
-	 * Which data store to load.
20
-	 *
21
-	 * @var string
22
-	 */
23
-	protected $data_store_name = 'subscription';
24
-
25
-	/**
26
-	 * This is the name of this object type.
27
-	 *
28
-	 * @var string
29
-	 */
30
-	protected $object_type = 'subscription';
31
-
32
-	/**
33
-	 * Item Data array. This is the core item data exposed in APIs.
34
-	 *
35
-	 * @since 1.0.19
36
-	 * @var array
37
-	 */
38
-	protected $data = array(
39
-		'customer_id'       => 0,
40
-		'frequency'         => 1,
41
-		'period'            => 'D',
42
-		'initial_amount'    => null,
43
-		'recurring_amount'  => null,
44
-		'bill_times'        => 0,
45
-		'transaction_id'    => '',
46
-		'parent_payment_id' => null,
47
-		'product_id'        => 0,
48
-		'created'           => '0000-00-00 00:00:00',
49
-		'expiration'        => '0000-00-00 00:00:00',
50
-		'trial_period'      => '',
51
-		'status'            => 'pending',
52
-		'profile_id'        => '',
53
-		'gateway'           => '',
54
-		'customer'          => '',
55
-	);
56
-
57
-	/**
58
-	 * Stores the status transition information.
59
-	 *
60
-	 * @since 1.0.19
61
-	 * @var bool
62
-	 */
63
-	protected $status_transition = false;
64
-
65
-	/**
66
-	 * Get the subscription if ID is passed, otherwise the subscription is new and empty.
67
-	 *
68
-	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69
-	 * @param  bool $deprecated
70
-	 */
71
-	function __construct( $subscription = 0, $deprecated = false ) {
72
-
73
-		parent::__construct( $subscription );
74
-
75
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
-			$this->set_id( $subscription );
77
-		} elseif ( $subscription instanceof self ) {
78
-			$this->set_id( $subscription->get_id() );
79
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
-			$this->set_id( $subscription_id );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
83
-		} else {
84
-			$this->set_object_read( true );
85
-		}
86
-
87
-		// Load the datastore.
88
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
89
-
90
-		if ( $this->get_id() > 0 ) {
91
-			$this->data_store->read( $this );
92
-		}
93
-
94
-	}
95
-
96
-	/**
97
-	 * Given an invoice id, profile id, transaction id, it returns the subscription's id.
98
-	 *
99
-	 *
100
-	 * @static
101
-	 * @param string $value
102
-	 * @param string $field Either invoice_id, transaction_id or profile_id.
103
-	 * @since 1.0.19
104
-	 * @return int
105
-	 */
106
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
18
+    /**
19
+     * Which data store to load.
20
+     *
21
+     * @var string
22
+     */
23
+    protected $data_store_name = 'subscription';
24
+
25
+    /**
26
+     * This is the name of this object type.
27
+     *
28
+     * @var string
29
+     */
30
+    protected $object_type = 'subscription';
31
+
32
+    /**
33
+     * Item Data array. This is the core item data exposed in APIs.
34
+     *
35
+     * @since 1.0.19
36
+     * @var array
37
+     */
38
+    protected $data = array(
39
+        'customer_id'       => 0,
40
+        'frequency'         => 1,
41
+        'period'            => 'D',
42
+        'initial_amount'    => null,
43
+        'recurring_amount'  => null,
44
+        'bill_times'        => 0,
45
+        'transaction_id'    => '',
46
+        'parent_payment_id' => null,
47
+        'product_id'        => 0,
48
+        'created'           => '0000-00-00 00:00:00',
49
+        'expiration'        => '0000-00-00 00:00:00',
50
+        'trial_period'      => '',
51
+        'status'            => 'pending',
52
+        'profile_id'        => '',
53
+        'gateway'           => '',
54
+        'customer'          => '',
55
+    );
56
+
57
+    /**
58
+     * Stores the status transition information.
59
+     *
60
+     * @since 1.0.19
61
+     * @var bool
62
+     */
63
+    protected $status_transition = false;
64
+
65
+    /**
66
+     * Get the subscription if ID is passed, otherwise the subscription is new and empty.
67
+     *
68
+     * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69
+     * @param  bool $deprecated
70
+     */
71
+    function __construct( $subscription = 0, $deprecated = false ) {
72
+
73
+        parent::__construct( $subscription );
74
+
75
+        if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
+            $this->set_id( $subscription );
77
+        } elseif ( $subscription instanceof self ) {
78
+            $this->set_id( $subscription->get_id() );
79
+        } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
+            $this->set_id( $subscription_id );
81
+        } elseif ( ! empty( $subscription->id ) ) {
82
+            $this->set_id( $subscription->id );
83
+        } else {
84
+            $this->set_object_read( true );
85
+        }
86
+
87
+        // Load the datastore.
88
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
89
+
90
+        if ( $this->get_id() > 0 ) {
91
+            $this->data_store->read( $this );
92
+        }
93
+
94
+    }
95
+
96
+    /**
97
+     * Given an invoice id, profile id, transaction id, it returns the subscription's id.
98
+     *
99
+     *
100
+     * @static
101
+     * @param string $value
102
+     * @param string $field Either invoice_id, transaction_id or profile_id.
103
+     * @since 1.0.19
104
+     * @return int
105
+     */
106
+    public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
107 107
         global $wpdb;
108 108
 
109
-		// Trim the value.
110
-		$value = trim( $value );
109
+        // Trim the value.
110
+        $value = trim( $value );
111 111
 
112
-		if ( empty( $value ) ) {
113
-			return 0;
114
-		}
112
+        if ( empty( $value ) ) {
113
+            return 0;
114
+        }
115 115
 
116
-		if ( 'invoice_id' == $field ) {
117
-			$field = 'parent_payment_id';
118
-		}
116
+        if ( 'invoice_id' == $field ) {
117
+            $field = 'parent_payment_id';
118
+        }
119 119
 
120 120
         // Valid fields.
121 121
         $fields = array(
122
-			'parent_payment_id',
123
-			'transaction_id',
124
-			'profile_id'
125
-		);
126
-
127
-		// Ensure a field has been passed.
128
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
129
-			return 0;
130
-		}
131
-
132
-		// Maybe retrieve from the cache.
133
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
-		if ( ! empty( $subscription_id ) ) {
135
-			return $subscription_id;
136
-		}
122
+            'parent_payment_id',
123
+            'transaction_id',
124
+            'profile_id'
125
+        );
126
+
127
+        // Ensure a field has been passed.
128
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
129
+            return 0;
130
+        }
131
+
132
+        // Maybe retrieve from the cache.
133
+        $subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
+        if ( ! empty( $subscription_id ) ) {
135
+            return $subscription_id;
136
+        }
137 137
 
138 138
         // Fetch from the db.
139 139
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
@@ -141,34 +141,34 @@  discard block
 block discarded – undo
141 141
             $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
142 142
         );
143 143
 
144
-		if ( empty( $subscription_id ) ) {
145
-			return 0;
146
-		}
144
+        if ( empty( $subscription_id ) ) {
145
+            return 0;
146
+        }
147 147
 
148
-		// Update the cache with our data.
149
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
148
+        // Update the cache with our data.
149
+        wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
150 150
 
151
-		return $subscription_id;
152
-	}
151
+        return $subscription_id;
152
+    }
153 153
 
154
-	/**
154
+    /**
155 155
      * Clears the subscription's cache.
156 156
      */
157 157
     public function clear_cache() {
158
-		wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' );
159
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' );
160
-		wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' );
161
-		wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' );
162
-	}
158
+        wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' );
159
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' );
160
+        wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' );
161
+        wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' );
162
+    }
163 163
 
164
-	/**
164
+    /**
165 165
      * Checks if a subscription key is set.
166 166
      */
167 167
     public function _isset( $key ) {
168 168
         return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
169
-	}
169
+    }
170 170
 
171
-	/*
171
+    /*
172 172
 	|--------------------------------------------------------------------------
173 173
 	| CRUD methods
174 174
 	|--------------------------------------------------------------------------
@@ -177,545 +177,545 @@  discard block
 block discarded – undo
177 177
 	|
178 178
     */
179 179
 
180
-	/*
181
-	|--------------------------------------------------------------------------
182
-	| Getters
183
-	|--------------------------------------------------------------------------
184
-	*/
180
+    /*
181
+	|--------------------------------------------------------------------------
182
+	| Getters
183
+	|--------------------------------------------------------------------------
184
+	*/
185
+
186
+    /**
187
+     * Get customer id.
188
+     *
189
+     * @since 1.0.19
190
+     * @param  string $context View or edit context.
191
+     * @return int
192
+     */
193
+    public function get_customer_id( $context = 'view' ) {
194
+        return (int) $this->get_prop( 'customer_id', $context );
195
+    }
196
+
197
+    /**
198
+     * Get customer information.
199
+     *
200
+     * @since 1.0.19
201
+     * @param  string $context View or edit context.
202
+     * @return WP_User|false WP_User object on success, false on failure.
203
+     */
204
+    public function get_customer( $context = 'view' ) {
205
+        return get_userdata( $this->get_customer_id( $context ) );
206
+    }
207
+
208
+    /**
209
+     * Get parent invoice id.
210
+     *
211
+     * @since 1.0.19
212
+     * @param  string $context View or edit context.
213
+     * @return int
214
+     */
215
+    public function get_parent_invoice_id( $context = 'view' ) {
216
+        return (int) $this->get_prop( 'parent_payment_id', $context );
217
+    }
218
+
219
+    /**
220
+     * Alias for self::get_parent_invoice_id().
221
+     *
222
+     * @since 1.0.19
223
+     * @param  string $context View or edit context.
224
+     * @return int
225
+     */
226
+    public function get_parent_payment_id( $context = 'view' ) {
227
+        return $this->get_parent_invoice_id( $context );
228
+    }
229
+
230
+    /**
231
+     * Alias for self::get_parent_invoice_id().
232
+     *
233
+     * @since  1.0.0
234
+     * @return int
235
+     */
236
+    public function get_original_payment_id( $context = 'view' ) {
237
+        return $this->get_parent_invoice_id( $context );
238
+    }
239
+
240
+    /**
241
+     * Get parent invoice.
242
+     *
243
+     * @since 1.0.19
244
+     * @param  string $context View or edit context.
245
+     * @return WPInv_Invoice
246
+     */
247
+    public function get_parent_invoice( $context = 'view' ) {
248
+        return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
249
+    }
250
+
251
+    /**
252
+     * Alias for self::get_parent_invoice().
253
+     *
254
+     * @since 1.0.19
255
+     * @param  string $context View or edit context.
256
+     * @return WPInv_Invoice
257
+     */
258
+    public function get_parent_payment( $context = 'view' ) {
259
+        return $this->get_parent_invoice( $context );
260
+    }
261
+
262
+    /**
263
+     * Get subscription's product id.
264
+     *
265
+     * @since 1.0.19
266
+     * @param  string $context View or edit context.
267
+     * @return int
268
+     */
269
+    public function get_product_id( $context = 'view' ) {
270
+        return (int) $this->get_prop( 'product_id', $context );
271
+    }
272
+
273
+    /**
274
+     * Get the subscription product.
275
+     *
276
+     * @since 1.0.19
277
+     * @param  string $context View or edit context.
278
+     * @return WPInv_Item
279
+     */
280
+    public function get_product( $context = 'view' ) {
281
+        return new WPInv_Item( $this->get_product_id( $context ) );
282
+    }
283
+
284
+    /**
285
+     * Get parent invoice's gateway.
286
+     *
287
+     * Here for backwards compatibility.
288
+     *
289
+     * @since 1.0.19
290
+     * @param  string $context View or edit context.
291
+     * @return string
292
+     */
293
+    public function get_gateway( $context = 'view' ) {
294
+        return $this->get_parent_invoice( $context )->get_gateway();
295
+    }
296
+
297
+    /**
298
+     * Get the period of a renewal.
299
+     *
300
+     * @since 1.0.19
301
+     * @param  string $context View or edit context.
302
+     * @return string
303
+     */
304
+    public function get_period( $context = 'view' ) {
305
+        return $this->get_prop( 'period', $context );
306
+    }
307
+
308
+    /**
309
+     * Get number of periods each renewal is valid for.
310
+     *
311
+     * @since 1.0.19
312
+     * @param  string $context View or edit context.
313
+     * @return int
314
+     */
315
+    public function get_frequency( $context = 'view' ) {
316
+        return (int) $this->get_prop( 'frequency', $context );
317
+    }
318
+
319
+    /**
320
+     * Get the initial amount for the subscription.
321
+     *
322
+     * @since 1.0.19
323
+     * @param  string $context View or edit context.
324
+     * @return float
325
+     */
326
+    public function get_initial_amount( $context = 'view' ) {
327
+        return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
328
+    }
329
+
330
+    /**
331
+     * Get the recurring amount for the subscription.
332
+     *
333
+     * @since 1.0.19
334
+     * @param  string $context View or edit context.
335
+     * @return float
336
+     */
337
+    public function get_recurring_amount( $context = 'view' ) {
338
+        return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
339
+    }
340
+
341
+    /**
342
+     * Get number of times that this subscription can be renewed.
343
+     *
344
+     * @since 1.0.19
345
+     * @param  string $context View or edit context.
346
+     * @return int
347
+     */
348
+    public function get_bill_times( $context = 'view' ) {
349
+        return (int) $this->get_prop( 'bill_times', $context );
350
+    }
351
+
352
+    /**
353
+     * Get transaction id of this subscription's parent invoice.
354
+     *
355
+     * @since 1.0.19
356
+     * @param  string $context View or edit context.
357
+     * @return string
358
+     */
359
+    public function get_transaction_id( $context = 'view' ) {
360
+        return $this->get_prop( 'transaction_id', $context );
361
+    }
362
+
363
+    /**
364
+     * Get the date that the subscription was created.
365
+     *
366
+     * @since 1.0.19
367
+     * @param  string $context View or edit context.
368
+     * @return string
369
+     */
370
+    public function get_created( $context = 'view' ) {
371
+        return $this->get_prop( 'created', $context );
372
+    }
373
+
374
+    /**
375
+     * Alias for self::get_created().
376
+     *
377
+     * @since 1.0.19
378
+     * @param  string $context View or edit context.
379
+     * @return string
380
+     */
381
+    public function get_date_created( $context = 'view' ) {
382
+        return $this->get_created( $context );
383
+    }
384
+
385
+    /**
386
+     * Retrieves the creation date in a timestamp
387
+     *
388
+     * @since  1.0.0
389
+     * @return int
390
+     */
391
+    public function get_time_created() {
392
+        $created = $this->get_date_created();
393
+        return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
394
+    }
395
+
396
+    /**
397
+     * Get GMT date when the subscription was created.
398
+     *
399
+     * @since 1.0.19
400
+     * @param  string $context View or edit context.
401
+     * @return string
402
+     */
403
+    public function get_date_created_gmt( $context = 'view' ) {
404
+        $date = $this->get_date_created( $context );
405
+
406
+        if ( $date ) {
407
+            $date = get_gmt_from_date( $date );
408
+        }
409
+        return $date;
410
+    }
411
+
412
+    /**
413
+     * Get the date that the subscription will renew.
414
+     *
415
+     * @since 1.0.19
416
+     * @param  string $context View or edit context.
417
+     * @return string
418
+     */
419
+    public function get_next_renewal_date( $context = 'view' ) {
420
+        return $this->get_prop( 'expiration', $context );
421
+    }
422
+
423
+    /**
424
+     * Alias for self::get_next_renewal_date().
425
+     *
426
+     * @since 1.0.19
427
+     * @param  string $context View or edit context.
428
+     * @return string
429
+     */
430
+    public function get_expiration( $context = 'view' ) {
431
+        return $this->get_next_renewal_date( $context );
432
+    }
433
+
434
+    /**
435
+     * Retrieves the expiration date in a timestamp
436
+     *
437
+     * @since  1.0.0
438
+     * @return int
439
+     */
440
+    public function get_expiration_time() {
441
+        $expiration = $this->get_expiration();
442
+
443
+        if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
444
+            return current_time( 'timestamp' );
445
+        }
446
+
447
+        $expiration = strtotime( $expiration, current_time( 'timestamp' ) );
448
+        return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
449
+    }
450
+
451
+    /**
452
+     * Get GMT date when the subscription will renew.
453
+     *
454
+     * @since 1.0.19
455
+     * @param  string $context View or edit context.
456
+     * @return string
457
+     */
458
+    public function get_next_renewal_date_gmt( $context = 'view' ) {
459
+        $date = $this->get_next_renewal_date( $context );
460
+
461
+        if ( $date ) {
462
+            $date = get_gmt_from_date( $date );
463
+        }
464
+        return $date;
465
+    }
466
+
467
+    /**
468
+     * Get the subscription's trial period.
469
+     *
470
+     * @since 1.0.19
471
+     * @param  string $context View or edit context.
472
+     * @return string
473
+     */
474
+    public function get_trial_period( $context = 'view' ) {
475
+        return $this->get_prop( 'trial_period', $context );
476
+    }
477
+
478
+    /**
479
+     * Get the subscription's status.
480
+     *
481
+     * @since 1.0.19
482
+     * @param  string $context View or edit context.
483
+     * @return string
484
+     */
485
+    public function get_status( $context = 'view' ) {
486
+        return $this->get_prop( 'status', $context );
487
+    }
488
+
489
+    /**
490
+     * Get the subscription's profile id.
491
+     *
492
+     * @since 1.0.19
493
+     * @param  string $context View or edit context.
494
+     * @return string
495
+     */
496
+    public function get_profile_id( $context = 'view' ) {
497
+        return $this->get_prop( 'profile_id', $context );
498
+    }
499
+
500
+    /*
501
+	|--------------------------------------------------------------------------
502
+	| Setters
503
+	|--------------------------------------------------------------------------
504
+	*/
505
+
506
+    /**
507
+     * Set customer id.
508
+     *
509
+     * @since 1.0.19
510
+     * @param  int $value The customer's id.
511
+     */
512
+    public function set_customer_id( $value ) {
513
+        $this->set_prop( 'customer_id', (int) $value );
514
+    }
515
+
516
+    /**
517
+     * Set parent invoice id.
518
+     *
519
+     * @since 1.0.19
520
+     * @param  int $value The parent invoice id.
521
+     */
522
+    public function set_parent_invoice_id( $value ) {
523
+        $this->set_prop( 'parent_payment_id', (int) $value );
524
+    }
525
+
526
+    /**
527
+     * Alias for self::set_parent_invoice_id().
528
+     *
529
+     * @since 1.0.19
530
+     * @param  int $value The parent invoice id.
531
+     */
532
+    public function set_parent_payment_id( $value ) {
533
+        $this->set_parent_invoice_id( $value );
534
+    }
535
+
536
+    /**
537
+     * Alias for self::set_parent_invoice_id().
538
+     *
539
+     * @since 1.0.19
540
+     * @param  int $value The parent invoice id.
541
+     */
542
+    public function set_original_payment_id( $value ) {
543
+        $this->set_parent_invoice_id( $value );
544
+    }
545
+
546
+    /**
547
+     * Set subscription's product id.
548
+     *
549
+     * @since 1.0.19
550
+     * @param  int $value The subscription product id.
551
+     */
552
+    public function set_product_id( $value ) {
553
+        $this->set_prop( 'product_id', (int) $value );
554
+    }
555
+
556
+    /**
557
+     * Set the period of a renewal.
558
+     *
559
+     * @since 1.0.19
560
+     * @param  string $value The renewal period.
561
+     */
562
+    public function set_period( $value ) {
563
+        $this->set_prop( 'period', $value );
564
+    }
565
+
566
+    /**
567
+     * Set number of periods each renewal is valid for.
568
+     *
569
+     * @since 1.0.19
570
+     * @param  int $value The subscription frequency.
571
+     */
572
+    public function set_frequency( $value ) {
573
+        $value = empty( $value ) ? 1 : (int) $value;
574
+        $this->set_prop( 'frequency', absint( $value ) );
575
+    }
576
+
577
+    /**
578
+     * Set the initial amount for the subscription.
579
+     *
580
+     * @since 1.0.19
581
+     * @param  float $value The initial subcription amount.
582
+     */
583
+    public function set_initial_amount( $value ) {
584
+        $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
585
+    }
586
+
587
+    /**
588
+     * Set the recurring amount for the subscription.
589
+     *
590
+     * @since 1.0.19
591
+     * @param  float $value The recurring subcription amount.
592
+     */
593
+    public function set_recurring_amount( $value ) {
594
+        $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
595
+    }
596
+
597
+    /**
598
+     * Set number of times that this subscription can be renewed.
599
+     *
600
+     * @since 1.0.19
601
+     * @param  int $value Bill times.
602
+     */
603
+    public function set_bill_times( $value ) {
604
+        $this->set_prop( 'bill_times', (int) $value );
605
+    }
606
+
607
+    /**
608
+     * Get transaction id of this subscription's parent invoice.
609
+     *
610
+     * @since 1.0.19
611
+     * @param string $value Bill times.
612
+     */
613
+    public function set_transaction_id( $value ) {
614
+        $this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
615
+    }
616
+
617
+    /**
618
+     * Set date when this subscription started.
619
+     *
620
+     * @since 1.0.19
621
+     * @param string $value strtotime compliant date.
622
+     */
623
+    public function set_created( $value ) {
624
+        $date = strtotime( $value );
625
+
626
+        if ( $date && $value !== '0000-00-00 00:00:00' ) {
627
+            $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) );
628
+            return;
629
+        }
630
+
631
+        $this->set_prop( 'created', '' );
185 632
 
186
-	/**
187
-	 * Get customer id.
188
-	 *
189
-	 * @since 1.0.19
190
-	 * @param  string $context View or edit context.
191
-	 * @return int
192
-	 */
193
-	public function get_customer_id( $context = 'view' ) {
194
-		return (int) $this->get_prop( 'customer_id', $context );
195
-	}
196
-
197
-	/**
198
-	 * Get customer information.
199
-	 *
200
-	 * @since 1.0.19
201
-	 * @param  string $context View or edit context.
202
-	 * @return WP_User|false WP_User object on success, false on failure.
203
-	 */
204
-	public function get_customer( $context = 'view' ) {
205
-		return get_userdata( $this->get_customer_id( $context ) );
206
-	}
207
-
208
-	/**
209
-	 * Get parent invoice id.
210
-	 *
211
-	 * @since 1.0.19
212
-	 * @param  string $context View or edit context.
213
-	 * @return int
214
-	 */
215
-	public function get_parent_invoice_id( $context = 'view' ) {
216
-		return (int) $this->get_prop( 'parent_payment_id', $context );
217
-	}
218
-
219
-	/**
220
-	 * Alias for self::get_parent_invoice_id().
221
-	 *
222
-	 * @since 1.0.19
223
-	 * @param  string $context View or edit context.
224
-	 * @return int
225
-	 */
226
-    public function get_parent_payment_id( $context = 'view' ) {
227
-        return $this->get_parent_invoice_id( $context );
228
-	}
633
+    }
229 634
 
230
-	/**
231
-     * Alias for self::get_parent_invoice_id().
635
+    /**
636
+     * Alias for self::set_created().
232 637
      *
233
-     * @since  1.0.0
234
-     * @return int
638
+     * @since 1.0.19
639
+     * @param string $value strtotime compliant date.
235 640
      */
236
-    public function get_original_payment_id( $context = 'view' ) {
237
-        return $this->get_parent_invoice_id( $context );
641
+    public function set_date_created( $value ) {
642
+        $this->set_created( $value );
238 643
     }
239 644
 
240
-	/**
241
-	 * Get parent invoice.
242
-	 *
243
-	 * @since 1.0.19
244
-	 * @param  string $context View or edit context.
245
-	 * @return WPInv_Invoice
246
-	 */
247
-	public function get_parent_invoice( $context = 'view' ) {
248
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
249
-	}
250
-
251
-	/**
252
-	 * Alias for self::get_parent_invoice().
253
-	 *
254
-	 * @since 1.0.19
255
-	 * @param  string $context View or edit context.
256
-	 * @return WPInv_Invoice
257
-	 */
258
-    public function get_parent_payment( $context = 'view' ) {
259
-        return $this->get_parent_invoice( $context );
260
-	}
261
-
262
-	/**
263
-	 * Get subscription's product id.
264
-	 *
265
-	 * @since 1.0.19
266
-	 * @param  string $context View or edit context.
267
-	 * @return int
268
-	 */
269
-	public function get_product_id( $context = 'view' ) {
270
-		return (int) $this->get_prop( 'product_id', $context );
271
-	}
272
-
273
-	/**
274
-	 * Get the subscription product.
275
-	 *
276
-	 * @since 1.0.19
277
-	 * @param  string $context View or edit context.
278
-	 * @return WPInv_Item
279
-	 */
280
-	public function get_product( $context = 'view' ) {
281
-		return new WPInv_Item( $this->get_product_id( $context ) );
282
-	}
283
-
284
-	/**
285
-	 * Get parent invoice's gateway.
286
-	 *
287
-	 * Here for backwards compatibility.
288
-	 *
289
-	 * @since 1.0.19
290
-	 * @param  string $context View or edit context.
291
-	 * @return string
292
-	 */
293
-	public function get_gateway( $context = 'view' ) {
294
-		return $this->get_parent_invoice( $context )->get_gateway();
295
-	}
296
-
297
-	/**
298
-	 * Get the period of a renewal.
299
-	 *
300
-	 * @since 1.0.19
301
-	 * @param  string $context View or edit context.
302
-	 * @return string
303
-	 */
304
-	public function get_period( $context = 'view' ) {
305
-		return $this->get_prop( 'period', $context );
306
-	}
307
-
308
-	/**
309
-	 * Get number of periods each renewal is valid for.
310
-	 *
311
-	 * @since 1.0.19
312
-	 * @param  string $context View or edit context.
313
-	 * @return int
314
-	 */
315
-	public function get_frequency( $context = 'view' ) {
316
-		return (int) $this->get_prop( 'frequency', $context );
317
-	}
318
-
319
-	/**
320
-	 * Get the initial amount for the subscription.
321
-	 *
322
-	 * @since 1.0.19
323
-	 * @param  string $context View or edit context.
324
-	 * @return float
325
-	 */
326
-	public function get_initial_amount( $context = 'view' ) {
327
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
328
-	}
329
-
330
-	/**
331
-	 * Get the recurring amount for the subscription.
332
-	 *
333
-	 * @since 1.0.19
334
-	 * @param  string $context View or edit context.
335
-	 * @return float
336
-	 */
337
-	public function get_recurring_amount( $context = 'view' ) {
338
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
339
-	}
340
-
341
-	/**
342
-	 * Get number of times that this subscription can be renewed.
343
-	 *
344
-	 * @since 1.0.19
345
-	 * @param  string $context View or edit context.
346
-	 * @return int
347
-	 */
348
-	public function get_bill_times( $context = 'view' ) {
349
-		return (int) $this->get_prop( 'bill_times', $context );
350
-	}
351
-
352
-	/**
353
-	 * Get transaction id of this subscription's parent invoice.
354
-	 *
355
-	 * @since 1.0.19
356
-	 * @param  string $context View or edit context.
357
-	 * @return string
358
-	 */
359
-	public function get_transaction_id( $context = 'view' ) {
360
-		return $this->get_prop( 'transaction_id', $context );
361
-	}
362
-
363
-	/**
364
-	 * Get the date that the subscription was created.
365
-	 *
366
-	 * @since 1.0.19
367
-	 * @param  string $context View or edit context.
368
-	 * @return string
369
-	 */
370
-	public function get_created( $context = 'view' ) {
371
-		return $this->get_prop( 'created', $context );
372
-	}
373
-
374
-	/**
375
-	 * Alias for self::get_created().
376
-	 *
377
-	 * @since 1.0.19
378
-	 * @param  string $context View or edit context.
379
-	 * @return string
380
-	 */
381
-	public function get_date_created( $context = 'view' ) {
382
-		return $this->get_created( $context );
383
-	}
384
-
385
-	/**
386
-	 * Retrieves the creation date in a timestamp
387
-	 *
388
-	 * @since  1.0.0
389
-	 * @return int
390
-	 */
391
-	public function get_time_created() {
392
-		$created = $this->get_date_created();
393
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
394
-	}
395
-
396
-	/**
397
-	 * Get GMT date when the subscription was created.
398
-	 *
399
-	 * @since 1.0.19
400
-	 * @param  string $context View or edit context.
401
-	 * @return string
402
-	 */
403
-	public function get_date_created_gmt( $context = 'view' ) {
404
-        $date = $this->get_date_created( $context );
645
+    /**
646
+     * Set the date that the subscription will renew.
647
+     *
648
+     * @since 1.0.19
649
+     * @param string $value strtotime compliant date.
650
+     */
651
+    public function set_next_renewal_date( $value ) {
652
+        $date = strtotime( $value );
405 653
 
406
-        if ( $date ) {
407
-            $date = get_gmt_from_date( $date );
654
+        if ( $date && $value !== '0000-00-00 00:00:00' ) {
655
+            $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) );
656
+            return;
408 657
         }
409
-		return $date;
410
-	}
411
-
412
-	/**
413
-	 * Get the date that the subscription will renew.
414
-	 *
415
-	 * @since 1.0.19
416
-	 * @param  string $context View or edit context.
417
-	 * @return string
418
-	 */
419
-	public function get_next_renewal_date( $context = 'view' ) {
420
-		return $this->get_prop( 'expiration', $context );
421
-	}
422
-
423
-	/**
424
-	 * Alias for self::get_next_renewal_date().
425
-	 *
426
-	 * @since 1.0.19
427
-	 * @param  string $context View or edit context.
428
-	 * @return string
429
-	 */
430
-	public function get_expiration( $context = 'view' ) {
431
-		return $this->get_next_renewal_date( $context );
432
-	}
433
-
434
-	/**
435
-	 * Retrieves the expiration date in a timestamp
436
-	 *
437
-	 * @since  1.0.0
438
-	 * @return int
439
-	 */
440
-	public function get_expiration_time() {
441
-		$expiration = $this->get_expiration();
442
-
443
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
444
-			return current_time( 'timestamp' );
445
-		}
446
-
447
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
448
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
449
-	}
450
-
451
-	/**
452
-	 * Get GMT date when the subscription will renew.
453
-	 *
454
-	 * @since 1.0.19
455
-	 * @param  string $context View or edit context.
456
-	 * @return string
457
-	 */
458
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
459
-        $date = $this->get_next_renewal_date( $context );
460 658
 
461
-        if ( $date ) {
462
-            $date = get_gmt_from_date( $date );
463
-        }
464
-		return $date;
465
-	}
466
-
467
-	/**
468
-	 * Get the subscription's trial period.
469
-	 *
470
-	 * @since 1.0.19
471
-	 * @param  string $context View or edit context.
472
-	 * @return string
473
-	 */
474
-	public function get_trial_period( $context = 'view' ) {
475
-		return $this->get_prop( 'trial_period', $context );
476
-	}
477
-
478
-	/**
479
-	 * Get the subscription's status.
480
-	 *
481
-	 * @since 1.0.19
482
-	 * @param  string $context View or edit context.
483
-	 * @return string
484
-	 */
485
-	public function get_status( $context = 'view' ) {
486
-		return $this->get_prop( 'status', $context );
487
-	}
488
-
489
-	/**
490
-	 * Get the subscription's profile id.
491
-	 *
492
-	 * @since 1.0.19
493
-	 * @param  string $context View or edit context.
494
-	 * @return string
495
-	 */
496
-	public function get_profile_id( $context = 'view' ) {
497
-		return $this->get_prop( 'profile_id', $context );
498
-	}
499
-
500
-	/*
501
-	|--------------------------------------------------------------------------
502
-	| Setters
503
-	|--------------------------------------------------------------------------
504
-	*/
659
+        $this->set_prop( 'expiration', '' );
505 660
 
506
-	/**
507
-	 * Set customer id.
508
-	 *
509
-	 * @since 1.0.19
510
-	 * @param  int $value The customer's id.
511
-	 */
512
-	public function set_customer_id( $value ) {
513
-		$this->set_prop( 'customer_id', (int) $value );
514
-	}
515
-
516
-	/**
517
-	 * Set parent invoice id.
518
-	 *
519
-	 * @since 1.0.19
520
-	 * @param  int $value The parent invoice id.
521
-	 */
522
-	public function set_parent_invoice_id( $value ) {
523
-		$this->set_prop( 'parent_payment_id', (int) $value );
524
-	}
525
-
526
-	/**
527
-	 * Alias for self::set_parent_invoice_id().
528
-	 *
529
-	 * @since 1.0.19
530
-	 * @param  int $value The parent invoice id.
531
-	 */
532
-    public function set_parent_payment_id( $value ) {
533
-        $this->set_parent_invoice_id( $value );
534
-	}
661
+    }
535 662
 
536
-	/**
537
-     * Alias for self::set_parent_invoice_id().
663
+    /**
664
+     * Alias for self::set_next_renewal_date().
538 665
      *
539 666
      * @since 1.0.19
540
-	 * @param  int $value The parent invoice id.
667
+     * @param string $value strtotime compliant date.
541 668
      */
542
-    public function set_original_payment_id( $value ) {
543
-        $this->set_parent_invoice_id( $value );
544
-	}
545
-
546
-	/**
547
-	 * Set subscription's product id.
548
-	 *
549
-	 * @since 1.0.19
550
-	 * @param  int $value The subscription product id.
551
-	 */
552
-	public function set_product_id( $value ) {
553
-		$this->set_prop( 'product_id', (int) $value );
554
-	}
555
-
556
-	/**
557
-	 * Set the period of a renewal.
558
-	 *
559
-	 * @since 1.0.19
560
-	 * @param  string $value The renewal period.
561
-	 */
562
-	public function set_period( $value ) {
563
-		$this->set_prop( 'period', $value );
564
-	}
565
-
566
-	/**
567
-	 * Set number of periods each renewal is valid for.
568
-	 *
569
-	 * @since 1.0.19
570
-	 * @param  int $value The subscription frequency.
571
-	 */
572
-	public function set_frequency( $value ) {
573
-		$value = empty( $value ) ? 1 : (int) $value;
574
-		$this->set_prop( 'frequency', absint( $value ) );
575
-	}
576
-
577
-	/**
578
-	 * Set the initial amount for the subscription.
579
-	 *
580
-	 * @since 1.0.19
581
-	 * @param  float $value The initial subcription amount.
582
-	 */
583
-	public function set_initial_amount( $value ) {
584
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
585
-	}
586
-
587
-	/**
588
-	 * Set the recurring amount for the subscription.
589
-	 *
590
-	 * @since 1.0.19
591
-	 * @param  float $value The recurring subcription amount.
592
-	 */
593
-	public function set_recurring_amount( $value ) {
594
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
595
-	}
596
-
597
-	/**
598
-	 * Set number of times that this subscription can be renewed.
599
-	 *
600
-	 * @since 1.0.19
601
-	 * @param  int $value Bill times.
602
-	 */
603
-	public function set_bill_times( $value ) {
604
-		$this->set_prop( 'bill_times', (int) $value );
605
-	}
606
-
607
-	/**
608
-	 * Get transaction id of this subscription's parent invoice.
609
-	 *
610
-	 * @since 1.0.19
611
-	 * @param string $value Bill times.
612
-	 */
613
-	public function set_transaction_id( $value ) {
614
-		$this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
615
-	}
616
-
617
-	/**
618
-	 * Set date when this subscription started.
619
-	 *
620
-	 * @since 1.0.19
621
-	 * @param string $value strtotime compliant date.
622
-	 */
623
-	public function set_created( $value ) {
624
-        $date = strtotime( $value );
669
+    public function set_expiration( $value ) {
670
+        $this->set_next_renewal_date( $value );
671
+    }
625 672
 
626
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
627
-            $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) );
673
+    /**
674
+     * Set the subscription's trial period.
675
+     *
676
+     * @since 1.0.19
677
+     * @param string $value trial period e.g 1 year.
678
+     */
679
+    public function set_trial_period( $value ) {
680
+        $this->set_prop( 'trial_period', $value );
681
+    }
682
+
683
+    /**
684
+     * Set the subscription's status.
685
+     *
686
+     * @since 1.0.19
687
+     * @param string $new_status    New subscription status.
688
+     */
689
+    public function set_status( $new_status ) {
690
+
691
+        // Abort if this is not a valid status;
692
+        if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
628 693
             return;
629 694
         }
630 695
 
631
-		$this->set_prop( 'created', '' );
632 696
 
633
-	}
697
+        $old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
698
+        if ( true === $this->object_read && $old_status !== $new_status ) {
699
+            $this->status_transition = array(
700
+                'from'   => $old_status,
701
+                'to'     => $new_status,
702
+            );
703
+        }
634 704
 
635
-	/**
636
-	 * Alias for self::set_created().
637
-	 *
638
-	 * @since 1.0.19
639
-	 * @param string $value strtotime compliant date.
640
-	 */
641
-	public function set_date_created( $value ) {
642
-		$this->set_created( $value );
705
+        $this->set_prop( 'status', $new_status );
643 706
     }
644 707
 
645
-	/**
646
-	 * Set the date that the subscription will renew.
647
-	 *
648
-	 * @since 1.0.19
649
-	 * @param string $value strtotime compliant date.
650
-	 */
651
-	public function set_next_renewal_date( $value ) {
652
-		$date = strtotime( $value );
708
+    /**
709
+     * Set the subscription's (remote) profile id.
710
+     *
711
+     * @since 1.0.19
712
+     * @param  string $value the remote profile id.
713
+     */
714
+    public function set_profile_id( $value ) {
715
+        $this->set_prop( 'profile_id', sanitize_text_field( $value ) );
716
+    }
653 717
 
654
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
655
-            $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) );
656
-            return;
657
-		}
658
-
659
-		$this->set_prop( 'expiration', '' );
660
-
661
-	}
662
-
663
-	/**
664
-	 * Alias for self::set_next_renewal_date().
665
-	 *
666
-	 * @since 1.0.19
667
-	 * @param string $value strtotime compliant date.
668
-	 */
669
-	public function set_expiration( $value ) {
670
-		$this->set_next_renewal_date( $value );
671
-    }
672
-
673
-	/**
674
-	 * Set the subscription's trial period.
675
-	 *
676
-	 * @since 1.0.19
677
-	 * @param string $value trial period e.g 1 year.
678
-	 */
679
-	public function set_trial_period( $value ) {
680
-		$this->set_prop( 'trial_period', $value );
681
-	}
682
-
683
-	/**
684
-	 * Set the subscription's status.
685
-	 *
686
-	 * @since 1.0.19
687
-	 * @param string $new_status    New subscription status.
688
-	 */
689
-	public function set_status( $new_status ) {
690
-
691
-		// Abort if this is not a valid status;
692
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
693
-			return;
694
-		}
695
-
696
-
697
-		$old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
698
-		if ( true === $this->object_read && $old_status !== $new_status ) {
699
-			$this->status_transition = array(
700
-				'from'   => $old_status,
701
-				'to'     => $new_status,
702
-			);
703
-		}
704
-
705
-		$this->set_prop( 'status', $new_status );
706
-	}
707
-
708
-	/**
709
-	 * Set the subscription's (remote) profile id.
710
-	 *
711
-	 * @since 1.0.19
712
-	 * @param  string $value the remote profile id.
713
-	 */
714
-	public function set_profile_id( $value ) {
715
-		$this->set_prop( 'profile_id', sanitize_text_field( $value ) );
716
-	}
717
-
718
-	/*
718
+    /*
719 719
 	|--------------------------------------------------------------------------
720 720
 	| Boolean methods
721 721
 	|--------------------------------------------------------------------------
@@ -724,55 +724,55 @@  discard block
 block discarded – undo
724 724
 	|
725 725
 	*/
726 726
 
727
-	/**
727
+    /**
728 728
      * Checks if the subscription has a given status.
729
-	 *
730
-	 * @param string|array String or array of strings to check for.
731
-	 * @return bool
729
+     *
730
+     * @param string|array String or array of strings to check for.
731
+     * @return bool
732 732
      */
733 733
     public function has_status( $status ) {
734 734
         return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) );
735
-	}
735
+    }
736 736
 
737
-	/**
737
+    /**
738 738
      * Checks if the subscription has a trial period.
739
-	 *
740
-	 * @return bool
739
+     *
740
+     * @return bool
741 741
      */
742 742
     public function has_trial_period() {
743
-		$period = $this->get_trial_period();
743
+        $period = $this->get_trial_period();
744 744
         return ! empty( $period );
745
-	}
746
-
747
-	/**
748
-	 * Is the subscription active?
749
-	 *
750
-	 * @return bool
751
-	 */
752
-	public function is_active() {
753
-		return $this->has_status( 'active trialling' ) && ! $this->is_expired();
754
-	}
755
-
756
-	/**
757
-	 * Is the subscription expired?
758
-	 *
759
-	 * @return bool
760
-	 */
761
-	public function is_expired() {
762
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) );
763
-	}
764
-
765
-	/**
766
-	 * Is this the last renewals?
767
-	 *
768
-	 * @return bool
769
-	 */
770
-	public function is_last_renewal() {
771
-		$max_bills = $this->get_bill_times();
772
-		return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
773
-	}
774
-
775
-	/*
745
+    }
746
+
747
+    /**
748
+     * Is the subscription active?
749
+     *
750
+     * @return bool
751
+     */
752
+    public function is_active() {
753
+        return $this->has_status( 'active trialling' ) && ! $this->is_expired();
754
+    }
755
+
756
+    /**
757
+     * Is the subscription expired?
758
+     *
759
+     * @return bool
760
+     */
761
+    public function is_expired() {
762
+        return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) );
763
+    }
764
+
765
+    /**
766
+     * Is this the last renewals?
767
+     *
768
+     * @return bool
769
+     */
770
+    public function is_last_renewal() {
771
+        $max_bills = $this->get_bill_times();
772
+        return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
773
+    }
774
+
775
+    /*
776 776
 	|--------------------------------------------------------------------------
777 777
 	| Additional methods
778 778
 	|--------------------------------------------------------------------------
@@ -781,27 +781,27 @@  discard block
 block discarded – undo
781 781
 	|
782 782
 	*/
783 783
 
784
-	/**
785
-	 * Backwards compatibilty.
786
-	 */
787
-	public function create( $data = array() ) {
784
+    /**
785
+     * Backwards compatibilty.
786
+     */
787
+    public function create( $data = array() ) {
788 788
 
789
-		// Set the properties.
790
-		if ( is_array( $data ) ) {
791
-			$this->set_props( $data );
792
-		}
789
+        // Set the properties.
790
+        if ( is_array( $data ) ) {
791
+            $this->set_props( $data );
792
+        }
793 793
 
794
-		// Save the item.
795
-		return $this->save();
794
+        // Save the item.
795
+        return $this->save();
796 796
 
797
-	}
797
+    }
798 798
 
799
-	/**
800
-	 * Backwards compatibilty.
801
-	 */
802
-	public function update( $args = array() ) {
803
-		return $this->create( $args );
804
-	}
799
+    /**
800
+     * Backwards compatibilty.
801
+     */
802
+    public function update( $args = array() ) {
803
+        return $this->create( $args );
804
+    }
805 805
 
806 806
     /**
807 807
      * Retrieve renewal payments for a subscription
@@ -811,22 +811,22 @@  discard block
 block discarded – undo
811 811
      */
812 812
     public function get_child_payments( $hide_pending = true ) {
813 813
 
814
-		$statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
814
+        $statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
815 815
 
816
-		if ( ! $hide_pending ) {
817
-			$statuses = array_keys( wpinv_get_invoice_statuses() );
818
-		}
816
+        if ( ! $hide_pending ) {
817
+            $statuses = array_keys( wpinv_get_invoice_statuses() );
818
+        }
819 819
 
820 820
         return get_posts(
821
-			array(
822
-            	'post_parent'    => $this->get_parent_payment_id(),
823
-            	'numberposts'    => -1,
824
-            	'post_status'    => $statuses,
825
-            	'orderby'        => 'ID',
826
-            	'order'          => 'ASC',
827
-            	'post_type'      => 'wpi_invoice'
828
-			)
829
-		);
821
+            array(
822
+                'post_parent'    => $this->get_parent_payment_id(),
823
+                'numberposts'    => -1,
824
+                'post_status'    => $statuses,
825
+                'orderby'        => 'ID',
826
+                'order'          => 'ASC',
827
+                'post_type'      => 'wpi_invoice'
828
+            )
829
+        );
830 830
     }
831 831
 
832 832
     /**
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
      * @return int
837 837
      */
838 838
     public function get_total_payments() {
839
-		return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
839
+        return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
840 840
     }
841 841
 
842 842
     /**
@@ -860,57 +860,57 @@  discard block
 block discarded – undo
860 860
      *
861 861
      * @since  2.4
862 862
      * @param  array $args Array of values for the payment, including amount and transaction ID
863
-	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
863
+     * @param  WPInv_Invoice $invoice If adding an existing invoice.
864 864
      * @return bool
865 865
      */
866 866
     public function add_payment( $args = array(), $invoice = false ) {
867 867
 
868
-		// Process each payment once.
868
+        // Process each payment once.
869 869
         if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
870 870
             return false;
871 871
         }
872 872
 
873
-		// Are we creating a new invoice?
874
-		if ( empty( $invoice ) ) {
875
-			$invoice = $this->create_payment();
873
+        // Are we creating a new invoice?
874
+        if ( empty( $invoice ) ) {
875
+            $invoice = $this->create_payment();
876 876
 
877
-			if ( empty( $invoice ) ) {
878
-				return false;
879
-			}
877
+            if ( empty( $invoice ) ) {
878
+                return false;
879
+            }
880 880
 
881
-		}
881
+        }
882 882
 
883
-		$invoice->set_status( 'wpi-renewal' );
883
+        $invoice->set_status( 'wpi-renewal' );
884 884
 
885
-		// Maybe set a transaction id.
886
-		if ( ! empty( $args['transaction_id'] ) ) {
887
-			$invoice->set_transaction_id( $args['transaction_id'] );
888
-		}
885
+        // Maybe set a transaction id.
886
+        if ( ! empty( $args['transaction_id'] ) ) {
887
+            $invoice->set_transaction_id( $args['transaction_id'] );
888
+        }
889 889
 
890
-		// Set the completed date.
891
-		$invoice->set_completed_date( current_time( 'mysql' ) );
890
+        // Set the completed date.
891
+        $invoice->set_completed_date( current_time( 'mysql' ) );
892 892
 
893
-		// And the gateway.
894
-		if ( ! empty( $args['gateway'] ) ) {
895
-			$invoice->set_gateway( $args['gateway'] );
896
-		}
893
+        // And the gateway.
894
+        if ( ! empty( $args['gateway'] ) ) {
895
+            $invoice->set_gateway( $args['gateway'] );
896
+        }
897 897
 
898
-		$invoice->save();
898
+        $invoice->save();
899 899
 
900
-		if ( ! $invoice->exists() ) {
901
-			return false;
902
-		}
900
+        if ( ! $invoice->exists() ) {
901
+            return false;
902
+        }
903 903
 
904
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
905
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
904
+        do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
905
+        do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
906 906
         do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
907 907
 
908 908
         update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
909 909
 
910 910
         return $invoice->get_id();
911
-	}
911
+    }
912 912
 
913
-	/**
913
+    /**
914 914
      * Creates a new invoice and returns it.
915 915
      *
916 916
      * @since  1.0.19
@@ -918,124 +918,124 @@  discard block
 block discarded – undo
918 918
      */
919 919
     public function create_payment() {
920 920
 
921
-		$parent_invoice = $this->get_parent_payment();
922
-
923
-		if ( ! $parent_invoice->exists() ) {
924
-			return false;
925
-		}
926
-
927
-		// Duplicate the parent invoice.
928
-		$invoice = getpaid_duplicate_invoice( $parent_invoice );
929
-		$invoice->set_parent_id( $parent_invoice->get_id() );
930
-		$invoice->set_subscription_id( $this->get_id() );
931
-		$invoice->set_remote_subscription_id( $this->get_profile_id() );
932
-
933
-		// Set invoice items.
934
-		$subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
935
-		$allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
936
-		$invoice_items      = array();
937
-
938
-		foreach ( $invoice->get_items() as $item ) {
939
-			if ( in_array( $item->get_id(), $allowed_items ) ) {
940
-				$invoice_items[] = $item;
941
-			}
942
-		}
943
-
944
-		$invoice->set_items( $invoice_items );
945
-
946
-		if ( ! empty( $subscription_group['fees'] ) ) {
947
-			$invoice->set_fees( $subscription_group['fees'] );
948
-		}
949
-
950
-		// Maybe recalculate discount (Pre-GetPaid Fix).
951
-		$discount = new WPInv_Discount( $invoice->get_discount_code() );
952
-		if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) {
953
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
954
-		}
955
-
956
-		$invoice->recalculate_total();
957
-		$invoice->set_status( 'wpi-pending' );
958
-		$invoice->save();
959
-
960
-		return $invoice->exists() ? $invoice : false;
961
-    }
962
-
963
-	/**
964
-	 * Renews or completes a subscription
965
-	 *
966
-	 * @since  1.0.0
967
-	 * @return int The subscription's id
968
-	 */
969
-	public function renew() {
970
-
971
-		// Complete subscription if applicable
972
-		if ( $this->is_last_renewal() ) {
973
-			return $this->complete();
974
-		}
975
-
976
-		// Calculate new expiration
977
-		$frequency      = $this->get_frequency();
978
-		$period         = $this->get_period();
979
-		$new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() );
980
-
981
-		$this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) );
982
-		$this->set_status( 'active' );
983
-		$this->save();
984
-
985
-		do_action( 'getpaid_subscription_renewed', $this );
986
-
987
-		return $this->get_id();
988
-	}
989
-
990
-	/**
991
-	 * Marks a subscription as completed
992
-	 *
993
-	 * Subscription is completed when the number of payments matches the billing_times field
994
-	 *
995
-	 * @since  1.0.0
996
-	 * @return int|bool Subscription id or false if the subscription is cancelled.
997
-	 */
998
-	public function complete() {
999
-
1000
-		// Only mark a subscription as complete if it's not already cancelled.
1001
-		if ( $this->has_status( 'cancelled' ) ) {
1002
-			return false;
1003
-		}
1004
-
1005
-		$this->set_status( 'completed' );
1006
-		return $this->save();
1007
-
1008
-	}
1009
-
1010
-	/**
1011
-	 * Marks a subscription as expired
1012
-	 *
1013
-	 * @since  1.0.0
1014
-	 * @param  bool $check_expiration
1015
-	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1016
-	 */
1017
-	public function expire( $check_expiration = false ) {
1018
-
1019
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1020
-			// Do not mark as expired since real expiration date is in the future
1021
-			return false;
1022
-		}
1023
-
1024
-		$this->set_status( 'expired' );
1025
-		return $this->save();
1026
-
1027
-	}
1028
-
1029
-	/**
1030
-	 * Marks a subscription as failing
1031
-	 *
1032
-	 * @since  2.4.2
1033
-	 * @return int Subscription id.
1034
-	 */
1035
-	public function failing() {
1036
-		$this->set_status( 'failing' );
1037
-		return $this->save();
1038
-	}
921
+        $parent_invoice = $this->get_parent_payment();
922
+
923
+        if ( ! $parent_invoice->exists() ) {
924
+            return false;
925
+        }
926
+
927
+        // Duplicate the parent invoice.
928
+        $invoice = getpaid_duplicate_invoice( $parent_invoice );
929
+        $invoice->set_parent_id( $parent_invoice->get_id() );
930
+        $invoice->set_subscription_id( $this->get_id() );
931
+        $invoice->set_remote_subscription_id( $this->get_profile_id() );
932
+
933
+        // Set invoice items.
934
+        $subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
935
+        $allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
936
+        $invoice_items      = array();
937
+
938
+        foreach ( $invoice->get_items() as $item ) {
939
+            if ( in_array( $item->get_id(), $allowed_items ) ) {
940
+                $invoice_items[] = $item;
941
+            }
942
+        }
943
+
944
+        $invoice->set_items( $invoice_items );
945
+
946
+        if ( ! empty( $subscription_group['fees'] ) ) {
947
+            $invoice->set_fees( $subscription_group['fees'] );
948
+        }
949
+
950
+        // Maybe recalculate discount (Pre-GetPaid Fix).
951
+        $discount = new WPInv_Discount( $invoice->get_discount_code() );
952
+        if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) {
953
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
954
+        }
955
+
956
+        $invoice->recalculate_total();
957
+        $invoice->set_status( 'wpi-pending' );
958
+        $invoice->save();
959
+
960
+        return $invoice->exists() ? $invoice : false;
961
+    }
962
+
963
+    /**
964
+     * Renews or completes a subscription
965
+     *
966
+     * @since  1.0.0
967
+     * @return int The subscription's id
968
+     */
969
+    public function renew() {
970
+
971
+        // Complete subscription if applicable
972
+        if ( $this->is_last_renewal() ) {
973
+            return $this->complete();
974
+        }
975
+
976
+        // Calculate new expiration
977
+        $frequency      = $this->get_frequency();
978
+        $period         = $this->get_period();
979
+        $new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() );
980
+
981
+        $this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) );
982
+        $this->set_status( 'active' );
983
+        $this->save();
984
+
985
+        do_action( 'getpaid_subscription_renewed', $this );
986
+
987
+        return $this->get_id();
988
+    }
989
+
990
+    /**
991
+     * Marks a subscription as completed
992
+     *
993
+     * Subscription is completed when the number of payments matches the billing_times field
994
+     *
995
+     * @since  1.0.0
996
+     * @return int|bool Subscription id or false if the subscription is cancelled.
997
+     */
998
+    public function complete() {
999
+
1000
+        // Only mark a subscription as complete if it's not already cancelled.
1001
+        if ( $this->has_status( 'cancelled' ) ) {
1002
+            return false;
1003
+        }
1004
+
1005
+        $this->set_status( 'completed' );
1006
+        return $this->save();
1007
+
1008
+    }
1009
+
1010
+    /**
1011
+     * Marks a subscription as expired
1012
+     *
1013
+     * @since  1.0.0
1014
+     * @param  bool $check_expiration
1015
+     * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1016
+     */
1017
+    public function expire( $check_expiration = false ) {
1018
+
1019
+        if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1020
+            // Do not mark as expired since real expiration date is in the future
1021
+            return false;
1022
+        }
1023
+
1024
+        $this->set_status( 'expired' );
1025
+        return $this->save();
1026
+
1027
+    }
1028
+
1029
+    /**
1030
+     * Marks a subscription as failing
1031
+     *
1032
+     * @since  2.4.2
1033
+     * @return int Subscription id.
1034
+     */
1035
+    public function failing() {
1036
+        $this->set_status( 'failing' );
1037
+        return $this->save();
1038
+    }
1039 1039
 
1040 1040
     /**
1041 1041
      * Marks a subscription as cancelled
@@ -1044,19 +1044,19 @@  discard block
 block discarded – undo
1044 1044
      * @return int Subscription id.
1045 1045
      */
1046 1046
     public function cancel() {
1047
-		$this->set_status( 'cancelled' );
1048
-		return $this->save();
1047
+        $this->set_status( 'cancelled' );
1048
+        return $this->save();
1049 1049
     }
1050 1050
 
1051
-	/**
1052
-	 * Determines if a subscription can be cancelled both locally and with a payment processor.
1053
-	 *
1054
-	 * @since  1.0.0
1055
-	 * @return bool
1056
-	 */
1057
-	public function can_cancel() {
1058
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1059
-	}
1051
+    /**
1052
+     * Determines if a subscription can be cancelled both locally and with a payment processor.
1053
+     *
1054
+     * @since  1.0.0
1055
+     * @return bool
1056
+     */
1057
+    public function can_cancel() {
1058
+        return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1059
+    }
1060 1060
 
1061 1061
     /**
1062 1062
      * Returns an array of subscription statuses that can be cancelled
@@ -1069,96 +1069,96 @@  discard block
 block discarded – undo
1069 1069
         return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1070 1070
     }
1071 1071
 
1072
-	/**
1073
-	 * Retrieves the URL to cancel subscription
1074
-	 *
1075
-	 * @since  1.0.0
1076
-	 * @return string
1077
-	 */
1078
-	public function get_cancel_url() {
1079
-		$url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1080
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1081
-	}
1082
-
1083
-	/**
1084
-	 * Retrieves the URL to view a subscription
1085
-	 *
1086
-	 * @since  1.0.19
1087
-	 * @return string
1088
-	 */
1089
-	public function get_view_url() {
1090
-
1091
-		$url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1092
-		$url = add_query_arg( 'subscription', $this->get_id(), $url );
1093
-
1094
-		return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1095
-	}
1096
-
1097
-	/**
1098
-	 * Determines if subscription can be manually renewed
1099
-	 *
1100
-	 * This method is filtered by payment gateways in order to return true on subscriptions
1101
-	 * that can be renewed manually
1102
-	 *
1103
-	 * @since  2.5
1104
-	 * @return bool
1105
-	 */
1106
-	public function can_renew() {
1107
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1108
-	}
1109
-
1110
-	/**
1111
-	 * Retrieves the URL to renew a subscription
1112
-	 *
1113
-	 * @since  2.5
1114
-	 * @return string
1115
-	 */
1116
-	public function get_renew_url() {
1117
-		$url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' );
1118
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1119
-	}
1120
-
1121
-	/**
1122
-	 * Determines if subscription can have their payment method updated
1123
-	 *
1124
-	 * @since  1.0.0
1125
-	 * @return bool
1126
-	 */
1127
-	public function can_update() {
1128
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1129
-	}
1130
-
1131
-	/**
1132
-	 * Retrieves the URL to update subscription
1133
-	 *
1134
-	 * @since  1.0.0
1135
-	 * @return string
1136
-	 */
1137
-	public function get_update_url() {
1138
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) );
1139
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1140
-	}
1141
-
1142
-	/**
1143
-	 * Retrieves the subscription status label
1144
-	 *
1145
-	 * @since  1.0.0
1146
-	 * @return string
1147
-	 */
1148
-	public function get_status_label() {
1149
-		return getpaid_get_subscription_status_label( $this->get_status() );
1150
-	}
1151
-
1152
-	/**
1153
-	 * Retrieves the subscription status class
1154
-	 *
1155
-	 * @since  1.0.19
1156
-	 * @return string
1157
-	 */
1158
-	public function get_status_class() {
1159
-		$statuses = getpaid_get_subscription_status_classes();
1160
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
1161
-	}
1072
+    /**
1073
+     * Retrieves the URL to cancel subscription
1074
+     *
1075
+     * @since  1.0.0
1076
+     * @return string
1077
+     */
1078
+    public function get_cancel_url() {
1079
+        $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1080
+        return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1081
+    }
1082
+
1083
+    /**
1084
+     * Retrieves the URL to view a subscription
1085
+     *
1086
+     * @since  1.0.19
1087
+     * @return string
1088
+     */
1089
+    public function get_view_url() {
1090
+
1091
+        $url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1092
+        $url = add_query_arg( 'subscription', $this->get_id(), $url );
1093
+
1094
+        return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1095
+    }
1096
+
1097
+    /**
1098
+     * Determines if subscription can be manually renewed
1099
+     *
1100
+     * This method is filtered by payment gateways in order to return true on subscriptions
1101
+     * that can be renewed manually
1102
+     *
1103
+     * @since  2.5
1104
+     * @return bool
1105
+     */
1106
+    public function can_renew() {
1107
+        return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1108
+    }
1109
+
1110
+    /**
1111
+     * Retrieves the URL to renew a subscription
1112
+     *
1113
+     * @since  2.5
1114
+     * @return string
1115
+     */
1116
+    public function get_renew_url() {
1117
+        $url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' );
1118
+        return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1119
+    }
1120
+
1121
+    /**
1122
+     * Determines if subscription can have their payment method updated
1123
+     *
1124
+     * @since  1.0.0
1125
+     * @return bool
1126
+     */
1127
+    public function can_update() {
1128
+        return apply_filters( 'wpinv_subscription_can_update', false, $this );
1129
+    }
1130
+
1131
+    /**
1132
+     * Retrieves the URL to update subscription
1133
+     *
1134
+     * @since  1.0.0
1135
+     * @return string
1136
+     */
1137
+    public function get_update_url() {
1138
+        $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) );
1139
+        return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1140
+    }
1141
+
1142
+    /**
1143
+     * Retrieves the subscription status label
1144
+     *
1145
+     * @since  1.0.0
1146
+     * @return string
1147
+     */
1148
+    public function get_status_label() {
1149
+        return getpaid_get_subscription_status_label( $this->get_status() );
1150
+    }
1151
+
1152
+    /**
1153
+     * Retrieves the subscription status class
1154
+     *
1155
+     * @since  1.0.19
1156
+     * @return string
1157
+     */
1158
+    public function get_status_class() {
1159
+        $statuses = getpaid_get_subscription_status_classes();
1160
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
1161
+    }
1162 1162
 
1163 1163
     /**
1164 1164
      * Retrieves the subscription status label
@@ -1168,11 +1168,11 @@  discard block
 block discarded – undo
1168 1168
      */
1169 1169
     public function get_status_label_html() {
1170 1170
 
1171
-		$status_label = sanitize_text_field( $this->get_status_label() );
1172
-		$class        = esc_attr( $this->get_status_class() );
1173
-		$status       = sanitize_html_class( $this->get_status() );
1171
+        $status_label = sanitize_text_field( $this->get_status_label() );
1172
+        $class        = esc_attr( $this->get_status_class() );
1173
+        $status       = sanitize_html_class( $this->get_status() );
1174 1174
 
1175
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1175
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1176 1176
     }
1177 1177
 
1178 1178
     /**
@@ -1183,75 +1183,75 @@  discard block
 block discarded – undo
1183 1183
      * @return bool
1184 1184
      */
1185 1185
     public function payment_exists( $txn_id = '' ) {
1186
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1186
+        $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1187 1187
         return ! empty( $invoice_id );
1188
-	}
1189
-
1190
-	/**
1191
-	 * Handle the status transition.
1192
-	 */
1193
-	protected function status_transition() {
1194
-		$status_transition = $this->status_transition;
1195
-
1196
-		// Reset status transition variable.
1197
-		$this->status_transition = false;
1198
-
1199
-		if ( $status_transition ) {
1200
-			try {
1201
-
1202
-				// Fire a hook for the status change.
1203
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1204
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1205
-
1206
-				if ( ! empty( $status_transition['from'] ) ) {
1207
-
1208
-					/* translators: 1: old subscription status 2: new subscription status */
1209
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1210
-
1211
-					// Note the transition occurred.
1212
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1213
-
1214
-					// Fire another hook.
1215
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1216
-					do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1217
-
1218
-				} else {
1219
-					/* translators: %s: new invoice status */
1220
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1221
-
1222
-					// Note the transition occurred.
1223
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1224
-
1225
-				}
1226
-			} catch ( Exception $e ) {
1227
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1228
-			}
1229
-		}
1230
-
1231
-	}
1232
-
1233
-	/**
1234
-	 * Save data to the database.
1235
-	 *
1236
-	 * @since 1.0.19
1237
-	 * @return int subscription ID
1238
-	 */
1239
-	public function save() {
1240
-		parent::save();
1241
-		$this->status_transition();
1242
-		return $this->get_id();
1243
-	}
1244
-
1245
-	/**
1246
-	 * Activates a subscription.
1247
-	 *
1248
-	 * @since 1.0.19
1249
-	 * @return int subscription ID
1250
-	 */
1251
-	public function activate() {
1252
-		$status = 'trialling' == $this->get_status() ? 'trialling' : 'active';
1253
-		$this->set_status( $status );
1254
-		return $this->save();
1255
-	}
1188
+    }
1189
+
1190
+    /**
1191
+     * Handle the status transition.
1192
+     */
1193
+    protected function status_transition() {
1194
+        $status_transition = $this->status_transition;
1195
+
1196
+        // Reset status transition variable.
1197
+        $this->status_transition = false;
1198
+
1199
+        if ( $status_transition ) {
1200
+            try {
1201
+
1202
+                // Fire a hook for the status change.
1203
+                do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1204
+                do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1205
+
1206
+                if ( ! empty( $status_transition['from'] ) ) {
1207
+
1208
+                    /* translators: 1: old subscription status 2: new subscription status */
1209
+                    $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1210
+
1211
+                    // Note the transition occurred.
1212
+                    $this->get_parent_payment()->add_note( $transition_note, false, false, true );
1213
+
1214
+                    // Fire another hook.
1215
+                    do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1216
+                    do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1217
+
1218
+                } else {
1219
+                    /* translators: %s: new invoice status */
1220
+                    $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1221
+
1222
+                    // Note the transition occurred.
1223
+                    $this->get_parent_payment()->add_note( $transition_note, false, false, true );
1224
+
1225
+                }
1226
+            } catch ( Exception $e ) {
1227
+                $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1228
+            }
1229
+        }
1230
+
1231
+    }
1232
+
1233
+    /**
1234
+     * Save data to the database.
1235
+     *
1236
+     * @since 1.0.19
1237
+     * @return int subscription ID
1238
+     */
1239
+    public function save() {
1240
+        parent::save();
1241
+        $this->status_transition();
1242
+        return $this->get_id();
1243
+    }
1244
+
1245
+    /**
1246
+     * Activates a subscription.
1247
+     *
1248
+     * @since 1.0.19
1249
+     * @return int subscription ID
1250
+     */
1251
+    public function activate() {
1252
+        $status = 'trialling' == $this->get_status() ? 'trialling' : 'active';
1253
+        $this->set_status( $status );
1254
+        return $this->save();
1255
+    }
1256 1256
 
1257 1257
 }
Please login to merge, or discard this patch.
Spacing   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * The Subscription Class
@@ -68,27 +68,27 @@  discard block
 block discarded – undo
68 68
 	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69 69
 	 * @param  bool $deprecated
70 70
 	 */
71
-	function __construct( $subscription = 0, $deprecated = false ) {
71
+	function __construct($subscription = 0, $deprecated = false) {
72 72
 
73
-		parent::__construct( $subscription );
73
+		parent::__construct($subscription);
74 74
 
75
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
-			$this->set_id( $subscription );
77
-		} elseif ( $subscription instanceof self ) {
78
-			$this->set_id( $subscription->get_id() );
79
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
-			$this->set_id( $subscription_id );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
75
+		if (!$deprecated && !empty($subscription) && is_numeric($subscription)) {
76
+			$this->set_id($subscription);
77
+		} elseif ($subscription instanceof self) {
78
+			$this->set_id($subscription->get_id());
79
+		} elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) {
80
+			$this->set_id($subscription_id);
81
+		} elseif (!empty($subscription->id)) {
82
+			$this->set_id($subscription->id);
83 83
 		} else {
84
-			$this->set_object_read( true );
84
+			$this->set_object_read(true);
85 85
 		}
86 86
 
87 87
 		// Load the datastore.
88
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
88
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
89 89
 
90
-		if ( $this->get_id() > 0 ) {
91
-			$this->data_store->read( $this );
90
+		if ($this->get_id() > 0) {
91
+			$this->data_store->read($this);
92 92
 		}
93 93
 
94 94
 	}
@@ -103,17 +103,17 @@  discard block
 block discarded – undo
103 103
 	 * @since 1.0.19
104 104
 	 * @return int
105 105
 	 */
106
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
106
+	public static function get_subscription_id_by_field($value, $field = 'profile_id') {
107 107
         global $wpdb;
108 108
 
109 109
 		// Trim the value.
110
-		$value = trim( $value );
110
+		$value = trim($value);
111 111
 
112
-		if ( empty( $value ) ) {
112
+		if (empty($value)) {
113 113
 			return 0;
114 114
 		}
115 115
 
116
-		if ( 'invoice_id' == $field ) {
116
+		if ('invoice_id' == $field) {
117 117
 			$field = 'parent_payment_id';
118 118
 		}
119 119
 
@@ -125,28 +125,28 @@  discard block
 block discarded – undo
125 125
 		);
126 126
 
127 127
 		// Ensure a field has been passed.
128
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
128
+		if (empty($field) || !in_array($field, $fields)) {
129 129
 			return 0;
130 130
 		}
131 131
 
132 132
 		// Maybe retrieve from the cache.
133
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
-		if ( ! empty( $subscription_id ) ) {
133
+		$subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids");
134
+		if (!empty($subscription_id)) {
135 135
 			return $subscription_id;
136 136
 		}
137 137
 
138 138
         // Fetch from the db.
139 139
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
140 140
         $subscription_id  = (int) $wpdb->get_var(
141
-            $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
141
+            $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
142 142
         );
143 143
 
144
-		if ( empty( $subscription_id ) ) {
144
+		if (empty($subscription_id)) {
145 145
 			return 0;
146 146
 		}
147 147
 
148 148
 		// Update the cache with our data.
149
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
149
+		wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids");
150 150
 
151 151
 		return $subscription_id;
152 152
 	}
@@ -155,17 +155,17 @@  discard block
 block discarded – undo
155 155
      * Clears the subscription's cache.
156 156
      */
157 157
     public function clear_cache() {
158
-		wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' );
159
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' );
160
-		wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' );
161
-		wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' );
158
+		wp_cache_delete($this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids');
159
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids');
160
+		wp_cache_delete($this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids');
161
+		wp_cache_delete($this->get_id(), 'getpaid_subscriptions');
162 162
 	}
163 163
 
164 164
 	/**
165 165
      * Checks if a subscription key is set.
166 166
      */
167
-    public function _isset( $key ) {
168
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
167
+    public function _isset($key) {
168
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
169 169
 	}
170 170
 
171 171
 	/*
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 	 * @param  string $context View or edit context.
191 191
 	 * @return int
192 192
 	 */
193
-	public function get_customer_id( $context = 'view' ) {
194
-		return (int) $this->get_prop( 'customer_id', $context );
193
+	public function get_customer_id($context = 'view') {
194
+		return (int) $this->get_prop('customer_id', $context);
195 195
 	}
196 196
 
197 197
 	/**
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 	 * @param  string $context View or edit context.
202 202
 	 * @return WP_User|false WP_User object on success, false on failure.
203 203
 	 */
204
-	public function get_customer( $context = 'view' ) {
205
-		return get_userdata( $this->get_customer_id( $context ) );
204
+	public function get_customer($context = 'view') {
205
+		return get_userdata($this->get_customer_id($context));
206 206
 	}
207 207
 
208 208
 	/**
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 	 * @param  string $context View or edit context.
213 213
 	 * @return int
214 214
 	 */
215
-	public function get_parent_invoice_id( $context = 'view' ) {
216
-		return (int) $this->get_prop( 'parent_payment_id', $context );
215
+	public function get_parent_invoice_id($context = 'view') {
216
+		return (int) $this->get_prop('parent_payment_id', $context);
217 217
 	}
218 218
 
219 219
 	/**
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 	 * @param  string $context View or edit context.
224 224
 	 * @return int
225 225
 	 */
226
-    public function get_parent_payment_id( $context = 'view' ) {
227
-        return $this->get_parent_invoice_id( $context );
226
+    public function get_parent_payment_id($context = 'view') {
227
+        return $this->get_parent_invoice_id($context);
228 228
 	}
229 229
 
230 230
 	/**
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
      * @since  1.0.0
234 234
      * @return int
235 235
      */
236
-    public function get_original_payment_id( $context = 'view' ) {
237
-        return $this->get_parent_invoice_id( $context );
236
+    public function get_original_payment_id($context = 'view') {
237
+        return $this->get_parent_invoice_id($context);
238 238
     }
239 239
 
240 240
 	/**
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 	 * @param  string $context View or edit context.
245 245
 	 * @return WPInv_Invoice
246 246
 	 */
247
-	public function get_parent_invoice( $context = 'view' ) {
248
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
247
+	public function get_parent_invoice($context = 'view') {
248
+		return new WPInv_Invoice($this->get_parent_invoice_id($context));
249 249
 	}
250 250
 
251 251
 	/**
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 	 * @param  string $context View or edit context.
256 256
 	 * @return WPInv_Invoice
257 257
 	 */
258
-    public function get_parent_payment( $context = 'view' ) {
259
-        return $this->get_parent_invoice( $context );
258
+    public function get_parent_payment($context = 'view') {
259
+        return $this->get_parent_invoice($context);
260 260
 	}
261 261
 
262 262
 	/**
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	 * @param  string $context View or edit context.
267 267
 	 * @return int
268 268
 	 */
269
-	public function get_product_id( $context = 'view' ) {
270
-		return (int) $this->get_prop( 'product_id', $context );
269
+	public function get_product_id($context = 'view') {
270
+		return (int) $this->get_prop('product_id', $context);
271 271
 	}
272 272
 
273 273
 	/**
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	 * @param  string $context View or edit context.
278 278
 	 * @return WPInv_Item
279 279
 	 */
280
-	public function get_product( $context = 'view' ) {
281
-		return new WPInv_Item( $this->get_product_id( $context ) );
280
+	public function get_product($context = 'view') {
281
+		return new WPInv_Item($this->get_product_id($context));
282 282
 	}
283 283
 
284 284
 	/**
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
 	 * @param  string $context View or edit context.
291 291
 	 * @return string
292 292
 	 */
293
-	public function get_gateway( $context = 'view' ) {
294
-		return $this->get_parent_invoice( $context )->get_gateway();
293
+	public function get_gateway($context = 'view') {
294
+		return $this->get_parent_invoice($context)->get_gateway();
295 295
 	}
296 296
 
297 297
 	/**
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
 	 * @param  string $context View or edit context.
302 302
 	 * @return string
303 303
 	 */
304
-	public function get_period( $context = 'view' ) {
305
-		return $this->get_prop( 'period', $context );
304
+	public function get_period($context = 'view') {
305
+		return $this->get_prop('period', $context);
306 306
 	}
307 307
 
308 308
 	/**
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
 	 * @param  string $context View or edit context.
313 313
 	 * @return int
314 314
 	 */
315
-	public function get_frequency( $context = 'view' ) {
316
-		return (int) $this->get_prop( 'frequency', $context );
315
+	public function get_frequency($context = 'view') {
316
+		return (int) $this->get_prop('frequency', $context);
317 317
 	}
318 318
 
319 319
 	/**
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
 	 * @param  string $context View or edit context.
324 324
 	 * @return float
325 325
 	 */
326
-	public function get_initial_amount( $context = 'view' ) {
327
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
326
+	public function get_initial_amount($context = 'view') {
327
+		return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context));
328 328
 	}
329 329
 
330 330
 	/**
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
 	 * @param  string $context View or edit context.
335 335
 	 * @return float
336 336
 	 */
337
-	public function get_recurring_amount( $context = 'view' ) {
338
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
337
+	public function get_recurring_amount($context = 'view') {
338
+		return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context));
339 339
 	}
340 340
 
341 341
 	/**
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
 	 * @param  string $context View or edit context.
346 346
 	 * @return int
347 347
 	 */
348
-	public function get_bill_times( $context = 'view' ) {
349
-		return (int) $this->get_prop( 'bill_times', $context );
348
+	public function get_bill_times($context = 'view') {
349
+		return (int) $this->get_prop('bill_times', $context);
350 350
 	}
351 351
 
352 352
 	/**
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 	 * @param  string $context View or edit context.
357 357
 	 * @return string
358 358
 	 */
359
-	public function get_transaction_id( $context = 'view' ) {
360
-		return $this->get_prop( 'transaction_id', $context );
359
+	public function get_transaction_id($context = 'view') {
360
+		return $this->get_prop('transaction_id', $context);
361 361
 	}
362 362
 
363 363
 	/**
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 	 * @param  string $context View or edit context.
368 368
 	 * @return string
369 369
 	 */
370
-	public function get_created( $context = 'view' ) {
371
-		return $this->get_prop( 'created', $context );
370
+	public function get_created($context = 'view') {
371
+		return $this->get_prop('created', $context);
372 372
 	}
373 373
 
374 374
 	/**
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 	 * @param  string $context View or edit context.
379 379
 	 * @return string
380 380
 	 */
381
-	public function get_date_created( $context = 'view' ) {
382
-		return $this->get_created( $context );
381
+	public function get_date_created($context = 'view') {
382
+		return $this->get_created($context);
383 383
 	}
384 384
 
385 385
 	/**
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 	 */
391 391
 	public function get_time_created() {
392 392
 		$created = $this->get_date_created();
393
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
393
+		return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp'));
394 394
 	}
395 395
 
396 396
 	/**
@@ -400,11 +400,11 @@  discard block
 block discarded – undo
400 400
 	 * @param  string $context View or edit context.
401 401
 	 * @return string
402 402
 	 */
403
-	public function get_date_created_gmt( $context = 'view' ) {
404
-        $date = $this->get_date_created( $context );
403
+	public function get_date_created_gmt($context = 'view') {
404
+        $date = $this->get_date_created($context);
405 405
 
406
-        if ( $date ) {
407
-            $date = get_gmt_from_date( $date );
406
+        if ($date) {
407
+            $date = get_gmt_from_date($date);
408 408
         }
409 409
 		return $date;
410 410
 	}
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 	 * @param  string $context View or edit context.
417 417
 	 * @return string
418 418
 	 */
419
-	public function get_next_renewal_date( $context = 'view' ) {
420
-		return $this->get_prop( 'expiration', $context );
419
+	public function get_next_renewal_date($context = 'view') {
420
+		return $this->get_prop('expiration', $context);
421 421
 	}
422 422
 
423 423
 	/**
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
 	 * @param  string $context View or edit context.
428 428
 	 * @return string
429 429
 	 */
430
-	public function get_expiration( $context = 'view' ) {
431
-		return $this->get_next_renewal_date( $context );
430
+	public function get_expiration($context = 'view') {
431
+		return $this->get_next_renewal_date($context);
432 432
 	}
433 433
 
434 434
 	/**
@@ -440,12 +440,12 @@  discard block
 block discarded – undo
440 440
 	public function get_expiration_time() {
441 441
 		$expiration = $this->get_expiration();
442 442
 
443
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
444
-			return current_time( 'timestamp' );
443
+		if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) {
444
+			return current_time('timestamp');
445 445
 		}
446 446
 
447
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
448
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
447
+		$expiration = strtotime($expiration, current_time('timestamp'));
448
+		return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration;
449 449
 	}
450 450
 
451 451
 	/**
@@ -455,11 +455,11 @@  discard block
 block discarded – undo
455 455
 	 * @param  string $context View or edit context.
456 456
 	 * @return string
457 457
 	 */
458
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
459
-        $date = $this->get_next_renewal_date( $context );
458
+	public function get_next_renewal_date_gmt($context = 'view') {
459
+        $date = $this->get_next_renewal_date($context);
460 460
 
461
-        if ( $date ) {
462
-            $date = get_gmt_from_date( $date );
461
+        if ($date) {
462
+            $date = get_gmt_from_date($date);
463 463
         }
464 464
 		return $date;
465 465
 	}
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
 	 * @param  string $context View or edit context.
472 472
 	 * @return string
473 473
 	 */
474
-	public function get_trial_period( $context = 'view' ) {
475
-		return $this->get_prop( 'trial_period', $context );
474
+	public function get_trial_period($context = 'view') {
475
+		return $this->get_prop('trial_period', $context);
476 476
 	}
477 477
 
478 478
 	/**
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
 	 * @param  string $context View or edit context.
483 483
 	 * @return string
484 484
 	 */
485
-	public function get_status( $context = 'view' ) {
486
-		return $this->get_prop( 'status', $context );
485
+	public function get_status($context = 'view') {
486
+		return $this->get_prop('status', $context);
487 487
 	}
488 488
 
489 489
 	/**
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 	 * @param  string $context View or edit context.
494 494
 	 * @return string
495 495
 	 */
496
-	public function get_profile_id( $context = 'view' ) {
497
-		return $this->get_prop( 'profile_id', $context );
496
+	public function get_profile_id($context = 'view') {
497
+		return $this->get_prop('profile_id', $context);
498 498
 	}
499 499
 
500 500
 	/*
@@ -509,8 +509,8 @@  discard block
 block discarded – undo
509 509
 	 * @since 1.0.19
510 510
 	 * @param  int $value The customer's id.
511 511
 	 */
512
-	public function set_customer_id( $value ) {
513
-		$this->set_prop( 'customer_id', (int) $value );
512
+	public function set_customer_id($value) {
513
+		$this->set_prop('customer_id', (int) $value);
514 514
 	}
515 515
 
516 516
 	/**
@@ -519,8 +519,8 @@  discard block
 block discarded – undo
519 519
 	 * @since 1.0.19
520 520
 	 * @param  int $value The parent invoice id.
521 521
 	 */
522
-	public function set_parent_invoice_id( $value ) {
523
-		$this->set_prop( 'parent_payment_id', (int) $value );
522
+	public function set_parent_invoice_id($value) {
523
+		$this->set_prop('parent_payment_id', (int) $value);
524 524
 	}
525 525
 
526 526
 	/**
@@ -529,8 +529,8 @@  discard block
 block discarded – undo
529 529
 	 * @since 1.0.19
530 530
 	 * @param  int $value The parent invoice id.
531 531
 	 */
532
-    public function set_parent_payment_id( $value ) {
533
-        $this->set_parent_invoice_id( $value );
532
+    public function set_parent_payment_id($value) {
533
+        $this->set_parent_invoice_id($value);
534 534
 	}
535 535
 
536 536
 	/**
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
      * @since 1.0.19
540 540
 	 * @param  int $value The parent invoice id.
541 541
      */
542
-    public function set_original_payment_id( $value ) {
543
-        $this->set_parent_invoice_id( $value );
542
+    public function set_original_payment_id($value) {
543
+        $this->set_parent_invoice_id($value);
544 544
 	}
545 545
 
546 546
 	/**
@@ -549,8 +549,8 @@  discard block
 block discarded – undo
549 549
 	 * @since 1.0.19
550 550
 	 * @param  int $value The subscription product id.
551 551
 	 */
552
-	public function set_product_id( $value ) {
553
-		$this->set_prop( 'product_id', (int) $value );
552
+	public function set_product_id($value) {
553
+		$this->set_prop('product_id', (int) $value);
554 554
 	}
555 555
 
556 556
 	/**
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
 	 * @since 1.0.19
560 560
 	 * @param  string $value The renewal period.
561 561
 	 */
562
-	public function set_period( $value ) {
563
-		$this->set_prop( 'period', $value );
562
+	public function set_period($value) {
563
+		$this->set_prop('period', $value);
564 564
 	}
565 565
 
566 566
 	/**
@@ -569,9 +569,9 @@  discard block
 block discarded – undo
569 569
 	 * @since 1.0.19
570 570
 	 * @param  int $value The subscription frequency.
571 571
 	 */
572
-	public function set_frequency( $value ) {
573
-		$value = empty( $value ) ? 1 : (int) $value;
574
-		$this->set_prop( 'frequency', absint( $value ) );
572
+	public function set_frequency($value) {
573
+		$value = empty($value) ? 1 : (int) $value;
574
+		$this->set_prop('frequency', absint($value));
575 575
 	}
576 576
 
577 577
 	/**
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 	 * @since 1.0.19
581 581
 	 * @param  float $value The initial subcription amount.
582 582
 	 */
583
-	public function set_initial_amount( $value ) {
584
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
583
+	public function set_initial_amount($value) {
584
+		$this->set_prop('initial_amount', wpinv_sanitize_amount($value));
585 585
 	}
586 586
 
587 587
 	/**
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
 	 * @since 1.0.19
591 591
 	 * @param  float $value The recurring subcription amount.
592 592
 	 */
593
-	public function set_recurring_amount( $value ) {
594
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
593
+	public function set_recurring_amount($value) {
594
+		$this->set_prop('recurring_amount', wpinv_sanitize_amount($value));
595 595
 	}
596 596
 
597 597
 	/**
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 	 * @since 1.0.19
601 601
 	 * @param  int $value Bill times.
602 602
 	 */
603
-	public function set_bill_times( $value ) {
604
-		$this->set_prop( 'bill_times', (int) $value );
603
+	public function set_bill_times($value) {
604
+		$this->set_prop('bill_times', (int) $value);
605 605
 	}
606 606
 
607 607
 	/**
@@ -610,8 +610,8 @@  discard block
 block discarded – undo
610 610
 	 * @since 1.0.19
611 611
 	 * @param string $value Bill times.
612 612
 	 */
613
-	public function set_transaction_id( $value ) {
614
-		$this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
613
+	public function set_transaction_id($value) {
614
+		$this->set_prop('transaction_id', sanitize_text_field($value));
615 615
 	}
616 616
 
617 617
 	/**
@@ -620,15 +620,15 @@  discard block
 block discarded – undo
620 620
 	 * @since 1.0.19
621 621
 	 * @param string $value strtotime compliant date.
622 622
 	 */
623
-	public function set_created( $value ) {
624
-        $date = strtotime( $value );
623
+	public function set_created($value) {
624
+        $date = strtotime($value);
625 625
 
626
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
627
-            $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) );
626
+        if ($date && $value !== '0000-00-00 00:00:00') {
627
+            $this->set_prop('created', date('Y-m-d H:i:s', $date));
628 628
             return;
629 629
         }
630 630
 
631
-		$this->set_prop( 'created', '' );
631
+		$this->set_prop('created', '');
632 632
 
633 633
 	}
634 634
 
@@ -638,8 +638,8 @@  discard block
 block discarded – undo
638 638
 	 * @since 1.0.19
639 639
 	 * @param string $value strtotime compliant date.
640 640
 	 */
641
-	public function set_date_created( $value ) {
642
-		$this->set_created( $value );
641
+	public function set_date_created($value) {
642
+		$this->set_created($value);
643 643
     }
644 644
 
645 645
 	/**
@@ -648,15 +648,15 @@  discard block
 block discarded – undo
648 648
 	 * @since 1.0.19
649 649
 	 * @param string $value strtotime compliant date.
650 650
 	 */
651
-	public function set_next_renewal_date( $value ) {
652
-		$date = strtotime( $value );
651
+	public function set_next_renewal_date($value) {
652
+		$date = strtotime($value);
653 653
 
654
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
655
-            $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) );
654
+        if ($date && $value !== '0000-00-00 00:00:00') {
655
+            $this->set_prop('expiration', date('Y-m-d H:i:s', $date));
656 656
             return;
657 657
 		}
658 658
 
659
-		$this->set_prop( 'expiration', '' );
659
+		$this->set_prop('expiration', '');
660 660
 
661 661
 	}
662 662
 
@@ -666,8 +666,8 @@  discard block
 block discarded – undo
666 666
 	 * @since 1.0.19
667 667
 	 * @param string $value strtotime compliant date.
668 668
 	 */
669
-	public function set_expiration( $value ) {
670
-		$this->set_next_renewal_date( $value );
669
+	public function set_expiration($value) {
670
+		$this->set_next_renewal_date($value);
671 671
     }
672 672
 
673 673
 	/**
@@ -676,8 +676,8 @@  discard block
 block discarded – undo
676 676
 	 * @since 1.0.19
677 677
 	 * @param string $value trial period e.g 1 year.
678 678
 	 */
679
-	public function set_trial_period( $value ) {
680
-		$this->set_prop( 'trial_period', $value );
679
+	public function set_trial_period($value) {
680
+		$this->set_prop('trial_period', $value);
681 681
 	}
682 682
 
683 683
 	/**
@@ -686,23 +686,23 @@  discard block
 block discarded – undo
686 686
 	 * @since 1.0.19
687 687
 	 * @param string $new_status    New subscription status.
688 688
 	 */
689
-	public function set_status( $new_status ) {
689
+	public function set_status($new_status) {
690 690
 
691 691
 		// Abort if this is not a valid status;
692
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
692
+		if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) {
693 693
 			return;
694 694
 		}
695 695
 
696 696
 
697
-		$old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
698
-		if ( true === $this->object_read && $old_status !== $new_status ) {
697
+		$old_status = !empty($this->status_transition['from']) ? $this->status_transition['from'] : $this->get_status();
698
+		if (true === $this->object_read && $old_status !== $new_status) {
699 699
 			$this->status_transition = array(
700 700
 				'from'   => $old_status,
701 701
 				'to'     => $new_status,
702 702
 			);
703 703
 		}
704 704
 
705
-		$this->set_prop( 'status', $new_status );
705
+		$this->set_prop('status', $new_status);
706 706
 	}
707 707
 
708 708
 	/**
@@ -711,8 +711,8 @@  discard block
 block discarded – undo
711 711
 	 * @since 1.0.19
712 712
 	 * @param  string $value the remote profile id.
713 713
 	 */
714
-	public function set_profile_id( $value ) {
715
-		$this->set_prop( 'profile_id', sanitize_text_field( $value ) );
714
+	public function set_profile_id($value) {
715
+		$this->set_prop('profile_id', sanitize_text_field($value));
716 716
 	}
717 717
 
718 718
 	/*
@@ -730,8 +730,8 @@  discard block
 block discarded – undo
730 730
 	 * @param string|array String or array of strings to check for.
731 731
 	 * @return bool
732 732
      */
733
-    public function has_status( $status ) {
734
-        return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) );
733
+    public function has_status($status) {
734
+        return in_array($this->get_status(), wpinv_clean(wpinv_parse_list($status)));
735 735
 	}
736 736
 
737 737
 	/**
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
      */
742 742
     public function has_trial_period() {
743 743
 		$period = $this->get_trial_period();
744
-        return ! empty( $period );
744
+        return !empty($period);
745 745
 	}
746 746
 
747 747
 	/**
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 	 * @return bool
751 751
 	 */
752 752
 	public function is_active() {
753
-		return $this->has_status( 'active trialling' ) && ! $this->is_expired();
753
+		return $this->has_status('active trialling') && !$this->is_expired();
754 754
 	}
755 755
 
756 756
 	/**
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 	 * @return bool
760 760
 	 */
761 761
 	public function is_expired() {
762
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) );
762
+		return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('mysql'));
763 763
 	}
764 764
 
765 765
 	/**
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 	 */
770 770
 	public function is_last_renewal() {
771 771
 		$max_bills = $this->get_bill_times();
772
-		return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
772
+		return !empty($max_bills) && $max_bills <= $this->get_times_billed();
773 773
 	}
774 774
 
775 775
 	/*
@@ -784,11 +784,11 @@  discard block
 block discarded – undo
784 784
 	/**
785 785
 	 * Backwards compatibilty.
786 786
 	 */
787
-	public function create( $data = array() ) {
787
+	public function create($data = array()) {
788 788
 
789 789
 		// Set the properties.
790
-		if ( is_array( $data ) ) {
791
-			$this->set_props( $data );
790
+		if (is_array($data)) {
791
+			$this->set_props($data);
792 792
 		}
793 793
 
794 794
 		// Save the item.
@@ -799,8 +799,8 @@  discard block
 block discarded – undo
799 799
 	/**
800 800
 	 * Backwards compatibilty.
801 801
 	 */
802
-	public function update( $args = array() ) {
803
-		return $this->create( $args );
802
+	public function update($args = array()) {
803
+		return $this->create($args);
804 804
 	}
805 805
 
806 806
     /**
@@ -809,12 +809,12 @@  discard block
 block discarded – undo
809 809
      * @since  1.0.0
810 810
      * @return WP_Post[]
811 811
      */
812
-    public function get_child_payments( $hide_pending = true ) {
812
+    public function get_child_payments($hide_pending = true) {
813 813
 
814
-		$statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
814
+		$statuses = array('publish', 'wpi-processing', 'wpi-renewal');
815 815
 
816
-		if ( ! $hide_pending ) {
817
-			$statuses = array_keys( wpinv_get_invoice_statuses() );
816
+		if (!$hide_pending) {
817
+			$statuses = array_keys(wpinv_get_invoice_statuses());
818 818
 		}
819 819
 
820 820
         return get_posts(
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
      * @return int
837 837
      */
838 838
     public function get_total_payments() {
839
-		return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
839
+		return getpaid_count_subscription_invoices($this->get_parent_invoice_id(), $this->get_id());
840 840
     }
841 841
 
842 842
     /**
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
     public function get_times_billed() {
849 849
         $times_billed = $this->get_total_payments();
850 850
 
851
-        if ( (float) $this->get_initial_amount() == 0 && $times_billed > 0 ) {
851
+        if ((float) $this->get_initial_amount() == 0 && $times_billed > 0) {
852 852
             $times_billed--;
853 853
         }
854 854
 
@@ -863,49 +863,49 @@  discard block
 block discarded – undo
863 863
 	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
864 864
      * @return bool
865 865
      */
866
-    public function add_payment( $args = array(), $invoice = false ) {
866
+    public function add_payment($args = array(), $invoice = false) {
867 867
 
868 868
 		// Process each payment once.
869
-        if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
869
+        if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) {
870 870
             return false;
871 871
         }
872 872
 
873 873
 		// Are we creating a new invoice?
874
-		if ( empty( $invoice ) ) {
874
+		if (empty($invoice)) {
875 875
 			$invoice = $this->create_payment();
876 876
 
877
-			if ( empty( $invoice ) ) {
877
+			if (empty($invoice)) {
878 878
 				return false;
879 879
 			}
880 880
 
881 881
 		}
882 882
 
883
-		$invoice->set_status( 'wpi-renewal' );
883
+		$invoice->set_status('wpi-renewal');
884 884
 
885 885
 		// Maybe set a transaction id.
886
-		if ( ! empty( $args['transaction_id'] ) ) {
887
-			$invoice->set_transaction_id( $args['transaction_id'] );
886
+		if (!empty($args['transaction_id'])) {
887
+			$invoice->set_transaction_id($args['transaction_id']);
888 888
 		}
889 889
 
890 890
 		// Set the completed date.
891
-		$invoice->set_completed_date( current_time( 'mysql' ) );
891
+		$invoice->set_completed_date(current_time('mysql'));
892 892
 
893 893
 		// And the gateway.
894
-		if ( ! empty( $args['gateway'] ) ) {
895
-			$invoice->set_gateway( $args['gateway'] );
894
+		if (!empty($args['gateway'])) {
895
+			$invoice->set_gateway($args['gateway']);
896 896
 		}
897 897
 
898 898
 		$invoice->save();
899 899
 
900
-		if ( ! $invoice->exists() ) {
900
+		if (!$invoice->exists()) {
901 901
 			return false;
902 902
 		}
903 903
 
904
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
905
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
906
-        do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
904
+		do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this);
905
+		do_action('wpinv_recurring_add_subscription_payment', $invoice, $this);
906
+        do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id());
907 907
 
908
-        update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
908
+        update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id);
909 909
 
910 910
         return $invoice->get_id();
911 911
 	}
@@ -920,41 +920,41 @@  discard block
 block discarded – undo
920 920
 
921 921
 		$parent_invoice = $this->get_parent_payment();
922 922
 
923
-		if ( ! $parent_invoice->exists() ) {
923
+		if (!$parent_invoice->exists()) {
924 924
 			return false;
925 925
 		}
926 926
 
927 927
 		// Duplicate the parent invoice.
928
-		$invoice = getpaid_duplicate_invoice( $parent_invoice );
929
-		$invoice->set_parent_id( $parent_invoice->get_id() );
930
-		$invoice->set_subscription_id( $this->get_id() );
931
-		$invoice->set_remote_subscription_id( $this->get_profile_id() );
928
+		$invoice = getpaid_duplicate_invoice($parent_invoice);
929
+		$invoice->set_parent_id($parent_invoice->get_id());
930
+		$invoice->set_subscription_id($this->get_id());
931
+		$invoice->set_remote_subscription_id($this->get_profile_id());
932 932
 
933 933
 		// Set invoice items.
934
-		$subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
935
-		$allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
934
+		$subscription_group = getpaid_get_invoice_subscription_group($parent_invoice->get_id(), $this->get_id());
935
+		$allowed_items      = empty($subscription_group) ? array($this->get_product_id()) : array_keys($subscription_group['items']);
936 936
 		$invoice_items      = array();
937 937
 
938
-		foreach ( $invoice->get_items() as $item ) {
939
-			if ( in_array( $item->get_id(), $allowed_items ) ) {
938
+		foreach ($invoice->get_items() as $item) {
939
+			if (in_array($item->get_id(), $allowed_items)) {
940 940
 				$invoice_items[] = $item;
941 941
 			}
942 942
 		}
943 943
 
944
-		$invoice->set_items( $invoice_items );
944
+		$invoice->set_items($invoice_items);
945 945
 
946
-		if ( ! empty( $subscription_group['fees'] ) ) {
947
-			$invoice->set_fees( $subscription_group['fees'] );
946
+		if (!empty($subscription_group['fees'])) {
947
+			$invoice->set_fees($subscription_group['fees']);
948 948
 		}
949 949
 
950 950
 		// Maybe recalculate discount (Pre-GetPaid Fix).
951
-		$discount = new WPInv_Discount( $invoice->get_discount_code() );
952
-		if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) {
953
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
951
+		$discount = new WPInv_Discount($invoice->get_discount_code());
952
+		if ($discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount()) {
953
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
954 954
 		}
955 955
 
956 956
 		$invoice->recalculate_total();
957
-		$invoice->set_status( 'wpi-pending' );
957
+		$invoice->set_status('wpi-pending');
958 958
 		$invoice->save();
959 959
 
960 960
 		return $invoice->exists() ? $invoice : false;
@@ -969,20 +969,20 @@  discard block
 block discarded – undo
969 969
 	public function renew() {
970 970
 
971 971
 		// Complete subscription if applicable
972
-		if ( $this->is_last_renewal() ) {
972
+		if ($this->is_last_renewal()) {
973 973
 			return $this->complete();
974 974
 		}
975 975
 
976 976
 		// Calculate new expiration
977 977
 		$frequency      = $this->get_frequency();
978 978
 		$period         = $this->get_period();
979
-		$new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() );
979
+		$new_expiration = strtotime("+ $frequency $period", $this->get_expiration_time());
980 980
 
981
-		$this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) );
982
-		$this->set_status( 'active' );
981
+		$this->set_expiration(date('Y-m-d H:i:s', $new_expiration));
982
+		$this->set_status('active');
983 983
 		$this->save();
984 984
 
985
-		do_action( 'getpaid_subscription_renewed', $this );
985
+		do_action('getpaid_subscription_renewed', $this);
986 986
 
987 987
 		return $this->get_id();
988 988
 	}
@@ -998,11 +998,11 @@  discard block
 block discarded – undo
998 998
 	public function complete() {
999 999
 
1000 1000
 		// Only mark a subscription as complete if it's not already cancelled.
1001
-		if ( $this->has_status( 'cancelled' ) ) {
1001
+		if ($this->has_status('cancelled')) {
1002 1002
 			return false;
1003 1003
 		}
1004 1004
 
1005
-		$this->set_status( 'completed' );
1005
+		$this->set_status('completed');
1006 1006
 		return $this->save();
1007 1007
 
1008 1008
 	}
@@ -1014,14 +1014,14 @@  discard block
 block discarded – undo
1014 1014
 	 * @param  bool $check_expiration
1015 1015
 	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1016 1016
 	 */
1017
-	public function expire( $check_expiration = false ) {
1017
+	public function expire($check_expiration = false) {
1018 1018
 
1019
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1019
+		if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) {
1020 1020
 			// Do not mark as expired since real expiration date is in the future
1021 1021
 			return false;
1022 1022
 		}
1023 1023
 
1024
-		$this->set_status( 'expired' );
1024
+		$this->set_status('expired');
1025 1025
 		return $this->save();
1026 1026
 
1027 1027
 	}
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 	 * @return int Subscription id.
1034 1034
 	 */
1035 1035
 	public function failing() {
1036
-		$this->set_status( 'failing' );
1036
+		$this->set_status('failing');
1037 1037
 		return $this->save();
1038 1038
 	}
1039 1039
 
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
      * @return int Subscription id.
1045 1045
      */
1046 1046
     public function cancel() {
1047
-		$this->set_status( 'cancelled' );
1047
+		$this->set_status('cancelled');
1048 1048
 		return $this->save();
1049 1049
     }
1050 1050
 
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 	 * @return bool
1056 1056
 	 */
1057 1057
 	public function can_cancel() {
1058
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1058
+		return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this);
1059 1059
 	}
1060 1060
 
1061 1061
     /**
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
      * @return      array
1067 1067
      */
1068 1068
     public function get_cancellable_statuses() {
1069
-        return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1069
+        return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing'));
1070 1070
     }
1071 1071
 
1072 1072
 	/**
@@ -1076,8 +1076,8 @@  discard block
 block discarded – undo
1076 1076
 	 * @return string
1077 1077
 	 */
1078 1078
 	public function get_cancel_url() {
1079
-		$url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1080
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1079
+		$url = getpaid_get_authenticated_action_url('subscription_cancel', $this->get_view_url());
1080
+		return apply_filters('wpinv_subscription_cancel_url', $url, $this);
1081 1081
 	}
1082 1082
 
1083 1083
 	/**
@@ -1088,10 +1088,10 @@  discard block
 block discarded – undo
1088 1088
 	 */
1089 1089
 	public function get_view_url() {
1090 1090
 
1091
-		$url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1092
-		$url = add_query_arg( 'subscription', $this->get_id(), $url );
1091
+		$url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')));
1092
+		$url = add_query_arg('subscription', $this->get_id(), $url);
1093 1093
 
1094
-		return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1094
+		return apply_filters('getpaid_get_subscription_view_url', $url, $this);
1095 1095
 	}
1096 1096
 
1097 1097
 	/**
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 	 * @return bool
1105 1105
 	 */
1106 1106
 	public function can_renew() {
1107
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1107
+		return apply_filters('wpinv_subscription_can_renew', true, $this);
1108 1108
 	}
1109 1109
 
1110 1110
 	/**
@@ -1114,8 +1114,8 @@  discard block
 block discarded – undo
1114 1114
 	 * @return string
1115 1115
 	 */
1116 1116
 	public function get_renew_url() {
1117
-		$url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' );
1118
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1117
+		$url = wp_nonce_url(add_query_arg(array('getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id)), 'getpaid-nonce');
1118
+		return apply_filters('wpinv_subscription_renew_url', $url, $this);
1119 1119
 	}
1120 1120
 
1121 1121
 	/**
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 	 * @return bool
1126 1126
 	 */
1127 1127
 	public function can_update() {
1128
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1128
+		return apply_filters('wpinv_subscription_can_update', false, $this);
1129 1129
 	}
1130 1130
 
1131 1131
 	/**
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 	 * @return string
1136 1136
 	 */
1137 1137
 	public function get_update_url() {
1138
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) );
1139
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1138
+		$url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->get_id()));
1139
+		return apply_filters('wpinv_subscription_update_url', $url, $this);
1140 1140
 	}
1141 1141
 
1142 1142
 	/**
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 	 * @return string
1147 1147
 	 */
1148 1148
 	public function get_status_label() {
1149
-		return getpaid_get_subscription_status_label( $this->get_status() );
1149
+		return getpaid_get_subscription_status_label($this->get_status());
1150 1150
 	}
1151 1151
 
1152 1152
 	/**
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 	 */
1158 1158
 	public function get_status_class() {
1159 1159
 		$statuses = getpaid_get_subscription_status_classes();
1160
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
1160
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark';
1161 1161
 	}
1162 1162
 
1163 1163
     /**
@@ -1168,9 +1168,9 @@  discard block
 block discarded – undo
1168 1168
      */
1169 1169
     public function get_status_label_html() {
1170 1170
 
1171
-		$status_label = sanitize_text_field( $this->get_status_label() );
1172
-		$class        = esc_attr( $this->get_status_class() );
1173
-		$status       = sanitize_html_class( $this->get_status() );
1171
+		$status_label = sanitize_text_field($this->get_status_label());
1172
+		$class        = esc_attr($this->get_status_class());
1173
+		$status       = sanitize_html_class($this->get_status());
1174 1174
 
1175 1175
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1176 1176
     }
@@ -1182,9 +1182,9 @@  discard block
 block discarded – undo
1182 1182
      * @param  string $txn_id The transaction ID from the merchant processor
1183 1183
      * @return bool
1184 1184
      */
1185
-    public function payment_exists( $txn_id = '' ) {
1186
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1187
-        return ! empty( $invoice_id );
1185
+    public function payment_exists($txn_id = '') {
1186
+		$invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id');
1187
+        return !empty($invoice_id);
1188 1188
 	}
1189 1189
 
1190 1190
 	/**
@@ -1196,35 +1196,35 @@  discard block
 block discarded – undo
1196 1196
 		// Reset status transition variable.
1197 1197
 		$this->status_transition = false;
1198 1198
 
1199
-		if ( $status_transition ) {
1199
+		if ($status_transition) {
1200 1200
 			try {
1201 1201
 
1202 1202
 				// Fire a hook for the status change.
1203
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1204
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1203
+				do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
1204
+				do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition);
1205 1205
 
1206
-				if ( ! empty( $status_transition['from'] ) ) {
1206
+				if (!empty($status_transition['from'])) {
1207 1207
 
1208 1208
 					/* translators: 1: old subscription status 2: new subscription status */
1209
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1209
+					$transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to']));
1210 1210
 
1211 1211
 					// Note the transition occurred.
1212
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1212
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1213 1213
 
1214 1214
 					// Fire another hook.
1215
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1216
-					do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1215
+					do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
1216
+					do_action('getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to']);
1217 1217
 
1218 1218
 				} else {
1219 1219
 					/* translators: %s: new invoice status */
1220
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1220
+					$transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to']));
1221 1221
 
1222 1222
 					// Note the transition occurred.
1223
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1223
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1224 1224
 
1225 1225
 				}
1226
-			} catch ( Exception $e ) {
1227
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1226
+			} catch (Exception $e) {
1227
+				$this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage());
1228 1228
 			}
1229 1229
 		}
1230 1230
 
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 	 */
1251 1251
 	public function activate() {
1252 1252
 		$status = 'trialling' == $this->get_status() ? 'trialling' : 'active';
1253
-		$this->set_status( $status );
1253
+		$this->set_status($status);
1254 1254
 		return $this->save();
1255 1255
 	}
1256 1256
 
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 2 patches
Indentation   +429 added lines, -429 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function wpinv_subscriptions_page() {
16 16
 
17
-	?>
17
+    ?>
18 18
 
19 19
 	<div class="wrap">
20 20
 		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
@@ -22,27 +22,27 @@  discard block
 block discarded – undo
22 22
 
23 23
 			<?php
24 24
 
25
-				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
25
+                // Verify user permissions.
26
+                if ( ! wpinv_current_user_can_manage_invoicing() ) {
27 27
 
28
-					echo aui()->alert(
29
-						array(
30
-							'type'    => 'danger',
31
-							'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
-						)
33
-					);
28
+                    echo aui()->alert(
29
+                        array(
30
+                            'type'    => 'danger',
31
+                            'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
+                        )
33
+                    );
34 34
 
35
-				} else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
35
+                } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
36 36
 
37
-					// Display a single subscription.
38
-					wpinv_recurring_subscription_details();
39
-				} else {
37
+                    // Display a single subscription.
38
+                    wpinv_recurring_subscription_details();
39
+                } else {
40 40
 
41
-					// Display a list of available subscriptions.
42
-					getpaid_print_subscriptions_list();
43
-				}
41
+                    // Display a list of available subscriptions.
42
+                    getpaid_print_subscriptions_list();
43
+                }
44 44
 
45
-			?>
45
+            ?>
46 46
 
47 47
 		</div>
48 48
 	</div>
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function getpaid_print_subscriptions_list() {
61 61
 
62
-	$subscribers_table = new WPInv_Subscriptions_List_Table();
63
-	$subscribers_table->prepare_items();
62
+    $subscribers_table = new WPInv_Subscriptions_List_Table();
63
+    $subscribers_table->prepare_items();
64 64
 
65
-	?>
65
+    ?>
66 66
 	<form id="subscribers-filter" class="bsui" method="get">
67 67
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
68 68
 		<?php $subscribers_table->views(); ?>
@@ -80,41 +80,41 @@  discard block
 block discarded – undo
80 80
  */
81 81
 function wpinv_recurring_subscription_details() {
82 82
 
83
-	// Fetch the subscription.
84
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
85
-	if ( ! $sub->exists() ) {
83
+    // Fetch the subscription.
84
+    $sub = new WPInv_Subscription( (int) $_GET['id'] );
85
+    if ( ! $sub->exists() ) {
86 86
 
87
-		echo aui()->alert(
88
-			array(
89
-				'type'    => 'danger',
90
-				'content' => __( 'Subscription not found.', 'invoicing' ),
91
-			)
92
-		);
87
+        echo aui()->alert(
88
+            array(
89
+                'type'    => 'danger',
90
+                'content' => __( 'Subscription not found.', 'invoicing' ),
91
+            )
92
+        );
93 93
 
94
-		return;
95
-	}
94
+        return;
95
+    }
96 96
 
97
-	// Use metaboxes to display the subscription details.
98
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
99
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
97
+    // Use metaboxes to display the subscription details.
98
+    add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
99
+    add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
100 100
 
101
-	$subscription_id     = $sub->get_id();
102
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
103
-	$subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
101
+    $subscription_id     = $sub->get_id();
102
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
103
+    $subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
104 104
 
105
-	if ( 1 < count( $subscription_groups ) ) {
106
-		add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
107
-	}
105
+    if ( 1 < count( $subscription_groups ) ) {
106
+        add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
107
+    }
108 108
 
109
-	if ( ! empty( $subscription_group ) ) {
110
-		add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
111
-	}
109
+    if ( ! empty( $subscription_group ) ) {
110
+        add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
111
+    }
112 112
 
113
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
113
+    add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
114 114
 
115
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
115
+    do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
116 116
 
117
-	?>
117
+    ?>
118 118
 
119 119
 		<form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>">
120 120
 
@@ -154,45 +154,45 @@  discard block
 block discarded – undo
154 154
  */
155 155
 function getpaid_admin_subscription_details_metabox( $sub ) {
156 156
 
157
-	// Subscription items.
158
-	$subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
159
-	$items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
160
-
161
-	// Prepare subscription detail columns.
162
-	$fields = apply_filters(
163
-		'getpaid_subscription_admin_page_fields',
164
-		array(
165
-			'subscription'   => __( 'Subscription', 'invoicing' ),
166
-			'customer'       => __( 'Customer', 'invoicing' ),
167
-			'amount'         => __( 'Amount', 'invoicing' ),
168
-			'start_date'     => __( 'Start Date', 'invoicing' ),
169
-			'renews_on'      => __( 'Next Payment', 'invoicing' ),
170
-			'renewals'       => __( 'Payments', 'invoicing' ),
171
-			'item'           => _n( 'Item', 'Items', $items_count,  'invoicing' ),
172
-			'gateway'        => __( 'Payment Method', 'invoicing' ),
173
-			'profile_id'     => __( 'Profile ID', 'invoicing' ),
174
-			'status'         => __( 'Status', 'invoicing' ),
175
-		)
176
-	);
177
-
178
-	if ( ! $sub->is_active() ) {
179
-
180
-		if ( isset( $fields['renews_on'] ) ) {
181
-			unset( $fields['renews_on'] );
182
-		}
183
-
184
-		if ( isset( $fields['gateway'] ) ) {
185
-			unset( $fields['gateway'] );
186
-		}
187
-
188
-	}
189
-
190
-	$profile_id = $sub->get_profile_id();
191
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
192
-		unset( $fields['profile_id'] );
193
-	}
194
-
195
-	?>
157
+    // Subscription items.
158
+    $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
159
+    $items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
160
+
161
+    // Prepare subscription detail columns.
162
+    $fields = apply_filters(
163
+        'getpaid_subscription_admin_page_fields',
164
+        array(
165
+            'subscription'   => __( 'Subscription', 'invoicing' ),
166
+            'customer'       => __( 'Customer', 'invoicing' ),
167
+            'amount'         => __( 'Amount', 'invoicing' ),
168
+            'start_date'     => __( 'Start Date', 'invoicing' ),
169
+            'renews_on'      => __( 'Next Payment', 'invoicing' ),
170
+            'renewals'       => __( 'Payments', 'invoicing' ),
171
+            'item'           => _n( 'Item', 'Items', $items_count,  'invoicing' ),
172
+            'gateway'        => __( 'Payment Method', 'invoicing' ),
173
+            'profile_id'     => __( 'Profile ID', 'invoicing' ),
174
+            'status'         => __( 'Status', 'invoicing' ),
175
+        )
176
+    );
177
+
178
+    if ( ! $sub->is_active() ) {
179
+
180
+        if ( isset( $fields['renews_on'] ) ) {
181
+            unset( $fields['renews_on'] );
182
+        }
183
+
184
+        if ( isset( $fields['gateway'] ) ) {
185
+            unset( $fields['gateway'] );
186
+        }
187
+
188
+    }
189
+
190
+    $profile_id = $sub->get_profile_id();
191
+    if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
192
+        unset( $fields['profile_id'] );
193
+    }
194
+
195
+    ?>
196 196
 
197 197
 		<table class="table table-borderless" style="font-size: 14px;">
198 198
 			<tbody>
@@ -226,20 +226,20 @@  discard block
 block discarded – undo
226 226
  */
227 227
 function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
228 228
 
229
-	$username = __( '(Missing User)', 'invoicing' );
229
+    $username = __( '(Missing User)', 'invoicing' );
230 230
 
231
-	$user = get_userdata( $subscription->get_customer_id() );
232
-	if ( $user ) {
231
+    $user = get_userdata( $subscription->get_customer_id() );
232
+    if ( $user ) {
233 233
 
234
-		$username = sprintf(
235
-			'<a href="user-edit.php?user_id=%s">%s</a>',
236
-			absint( $user->ID ),
237
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
238
-		);
234
+        $username = sprintf(
235
+            '<a href="user-edit.php?user_id=%s">%s</a>',
236
+            absint( $user->ID ),
237
+            ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
238
+        );
239 239
 
240
-	}
240
+    }
241 241
 
242
-	echo  $username;
242
+    echo  $username;
243 243
 }
244 244
 add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
245 245
 
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
  * @param WPInv_Subscription $subscription
250 250
  */
251 251
 function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
252
-	$amount    = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) );
253
-	echo "<span>$amount</span>";
252
+    $amount    = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) );
253
+    echo "<span>$amount</span>";
254 254
 }
255 255
 add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
256 256
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
  * @param WPInv_Subscription $subscription
261 261
  */
262 262
 function getpaid_admin_subscription_metabox_display_id( $subscription ) {
263
-	echo  '#' . absint( $subscription->get_id() );
263
+    echo  '#' . absint( $subscription->get_id() );
264 264
 }
265 265
 add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
266 266
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
  * @param WPInv_Subscription $subscription
271 271
  */
272 272
 function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
273
-	echo getpaid_format_date_value( $subscription->get_date_created() );
273
+    echo getpaid_format_date_value( $subscription->get_date_created() );
274 274
 }
275 275
 add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
276 276
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
  * @param WPInv_Subscription $subscription
281 281
  */
282 282
 function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
283
-	echo getpaid_format_date_value( $subscription->get_expiration() );
283
+    echo getpaid_format_date_value( $subscription->get_expiration() );
284 284
 }
285 285
 add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
286 286
 
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
  * @param WPInv_Subscription $subscription
291 291
  */
292 292
 function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
293
-	$max_bills = $subscription->get_bill_times();
294
-	echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
293
+    $max_bills = $subscription->get_bill_times();
294
+    echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
295 295
 }
296 296
 add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
297 297
 /**
@@ -302,13 +302,13 @@  discard block
 block discarded – undo
302 302
  */
303 303
 function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
304 304
 
305
-	if ( empty( $subscription_group ) ) {
306
-		echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() );
307
-		return;
308
-	}
305
+    if ( empty( $subscription_group ) ) {
306
+        echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() );
307
+        return;
308
+    }
309 309
 
310
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
311
-	echo implode( ' | ', $markup );
310
+    $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
311
+    echo implode( ' | ', $markup );
312 312
 
313 313
 }
314 314
 add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
@@ -320,13 +320,13 @@  discard block
 block discarded – undo
320 320
  */
321 321
 function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
322 322
 
323
-	$gateway = $subscription->get_gateway();
323
+    $gateway = $subscription->get_gateway();
324 324
 
325
-	if ( ! empty( $gateway ) ) {
326
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
327
-	} else {
328
-		echo "&mdash;";
329
-	}
325
+    if ( ! empty( $gateway ) ) {
326
+        echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
327
+    } else {
328
+        echo "&mdash;";
329
+    }
330 330
 
331 331
 }
332 332
 add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
  * @param WPInv_Subscription $subscription
338 338
  */
339 339
 function getpaid_admin_subscription_metabox_display_status( $subscription ) {
340
-	echo $subscription->get_status_label_html();
340
+    echo $subscription->get_status_label_html();
341 341
 }
342 342
 add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
343 343
 
@@ -348,29 +348,29 @@  discard block
 block discarded – undo
348 348
  */
349 349
 function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
350 350
 
351
-	$profile_id = $subscription->get_profile_id();
352
-
353
-	$input = aui()->input(
354
-		array(
355
-			'type'        => 'text',
356
-			'id'          => 'wpinv_subscription_profile_id',
357
-			'name'        => 'wpinv_subscription_profile_id',
358
-			'label'       => __( 'Profile Id', 'invoicing' ),
359
-			'label_type'  => 'hidden',
360
-			'placeholder' => __( 'Profile Id', 'invoicing' ),
361
-			'value'       => esc_attr( $profile_id ),
362
-			'input_group_right' => '',
363
-			'no_wrap'     => true,
364
-		)
365
-	);
366
-
367
-	echo str_ireplace( 'form-control', 'regular-text', $input );
368
-
369
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
370
-	if ( ! empty( $url ) ) {
371
-		$url = esc_url_raw( $url );
372
-		echo '&nbsp;<a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
373
-	}
351
+    $profile_id = $subscription->get_profile_id();
352
+
353
+    $input = aui()->input(
354
+        array(
355
+            'type'        => 'text',
356
+            'id'          => 'wpinv_subscription_profile_id',
357
+            'name'        => 'wpinv_subscription_profile_id',
358
+            'label'       => __( 'Profile Id', 'invoicing' ),
359
+            'label_type'  => 'hidden',
360
+            'placeholder' => __( 'Profile Id', 'invoicing' ),
361
+            'value'       => esc_attr( $profile_id ),
362
+            'input_group_right' => '',
363
+            'no_wrap'     => true,
364
+        )
365
+    );
366
+
367
+    echo str_ireplace( 'form-control', 'regular-text', $input );
368
+
369
+    $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
370
+    if ( ! empty( $url ) ) {
371
+        $url = esc_url_raw( $url );
372
+        echo '&nbsp;<a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
373
+    }
374 374
 
375 375
 }
376 376
 add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
@@ -382,39 +382,39 @@  discard block
 block discarded – undo
382 382
  */
383 383
 function getpaid_admin_subscription_update_metabox( $subscription ) {
384 384
 
385
-	?>
385
+    ?>
386 386
 	<div class="mt-3">
387 387
 
388 388
 		<?php
389
-			echo aui()->select(
390
-				array(
391
-					'options'          => getpaid_get_subscription_statuses(),
392
-					'name'             => 'subscription_status',
393
-					'id'               => 'subscription_status_update_select',
394
-					'required'         => true,
395
-					'no_wrap'          => false,
396
-					'label'            => __( 'Subscription Status', 'invoicing' ),
397
-					'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
398
-					'select2'          => true,
399
-					'value'            => $subscription->get_status( 'edit' ),
400
-				)
401
-			);
402
-		?>
389
+            echo aui()->select(
390
+                array(
391
+                    'options'          => getpaid_get_subscription_statuses(),
392
+                    'name'             => 'subscription_status',
393
+                    'id'               => 'subscription_status_update_select',
394
+                    'required'         => true,
395
+                    'no_wrap'          => false,
396
+                    'label'            => __( 'Subscription Status', 'invoicing' ),
397
+                    'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
398
+                    'select2'          => true,
399
+                    'value'            => $subscription->get_status( 'edit' ),
400
+                )
401
+            );
402
+        ?>
403 403
 
404 404
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
405 405
 
406 406
 		<?php
407
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
407
+            submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
408 408
 
409
-			$url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
410
-			$anchor = __( 'Renew Subscription', 'invoicing' );
411
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
409
+            $url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
410
+            $anchor = __( 'Renew Subscription', 'invoicing' );
411
+            $title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
412 412
 
413
-			if ( $subscription->is_active() ) {
414
-				echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
415
-			}
413
+            if ( $subscription->is_active() ) {
414
+                echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
415
+            }
416 416
 
417
-	echo '</div></div>';
417
+    echo '</div></div>';
418 418
 }
419 419
 
420 420
 /**
@@ -425,33 +425,33 @@  discard block
 block discarded – undo
425 425
  */
426 426
 function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
427 427
 
428
-	$columns = apply_filters(
429
-		'getpaid_subscription_related_invoices_columns',
430
-		array(
431
-			'invoice'      => __( 'Invoice', 'invoicing' ),
432
-			'relationship' => __( 'Relationship', 'invoicing' ),
433
-			'date'         => __( 'Date', 'invoicing' ),
434
-			'status'       => __( 'Status', 'invoicing' ),
435
-			'total'        => __( 'Total', 'invoicing' ),
436
-		),
437
-		$subscription
438
-	);
439
-
440
-	// Prepare the invoices.
441
-	$payments = $subscription->get_child_payments( ! is_admin() );
442
-	$parent   = $subscription->get_parent_invoice();
443
-
444
-	if ( $parent->exists() ) {
445
-		$payments = array_merge( array( $parent ), $payments );
446
-	}
447
-
448
-	$table_class = 'w-100 bg-white';
449
-
450
-	if ( ! is_admin() ) {
451
-		$table_class = 'table table-bordered';
452
-	}
453
-
454
-	?>
428
+    $columns = apply_filters(
429
+        'getpaid_subscription_related_invoices_columns',
430
+        array(
431
+            'invoice'      => __( 'Invoice', 'invoicing' ),
432
+            'relationship' => __( 'Relationship', 'invoicing' ),
433
+            'date'         => __( 'Date', 'invoicing' ),
434
+            'status'       => __( 'Status', 'invoicing' ),
435
+            'total'        => __( 'Total', 'invoicing' ),
436
+        ),
437
+        $subscription
438
+    );
439
+
440
+    // Prepare the invoices.
441
+    $payments = $subscription->get_child_payments( ! is_admin() );
442
+    $parent   = $subscription->get_parent_invoice();
443
+
444
+    if ( $parent->exists() ) {
445
+        $payments = array_merge( array( $parent ), $payments );
446
+    }
447
+
448
+    $table_class = 'w-100 bg-white';
449
+
450
+    if ( ! is_admin() ) {
451
+        $table_class = 'table table-bordered';
452
+    }
453
+
454
+    ?>
455 455
 		<div class="m-0" style="overflow: auto;">
456 456
 
457 457
 			<table class="<?php echo $table_class; ?>">
@@ -459,14 +459,14 @@  discard block
 block discarded – undo
459 459
 				<thead>
460 460
 					<tr>
461 461
 						<?php
462
-							foreach ( $columns as $key => $label ) {
463
-								$key   = esc_attr( $key );
464
-								$label = esc_html( $label );
465
-								$class = 'text-left';
466
-
467
-								echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
468
-							}
469
-						?>
462
+                            foreach ( $columns as $key => $label ) {
463
+                                $key   = esc_attr( $key );
464
+                                $label = esc_html( $label );
465
+                                $class = 'text-left';
466
+
467
+                                echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
468
+                            }
469
+                        ?>
470 470
 					</tr>
471 471
 				</thead>
472 472
 
@@ -482,73 +482,73 @@  discard block
 block discarded – undo
482 482
 
483 483
 					<?php
484 484
 
485
-						foreach( $payments as $payment ) :
485
+                        foreach( $payments as $payment ) :
486 486
 
487
-							// Ensure that we have an invoice.
488
-							$payment = new WPInv_Invoice( $payment );
487
+                            // Ensure that we have an invoice.
488
+                            $payment = new WPInv_Invoice( $payment );
489 489
 
490
-							// Abort if the invoice is invalid...
491
-							if ( ! $payment->exists() ) {
492
-								continue;
493
-							}
490
+                            // Abort if the invoice is invalid...
491
+                            if ( ! $payment->exists() ) {
492
+                                continue;
493
+                            }
494 494
 
495
-							// ... or belongs to a different subscription.
496
-							if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
497
-								continue;
498
-							}
495
+                            // ... or belongs to a different subscription.
496
+                            if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
497
+                                continue;
498
+                            }
499 499
 
500
-							echo '<tr>';
500
+                            echo '<tr>';
501 501
 
502
-								foreach ( array_keys( $columns ) as $key ) {
502
+                                foreach ( array_keys( $columns ) as $key ) {
503 503
 
504
-									$class = 'text-left';
504
+                                    $class = 'text-left';
505 505
 
506
-									echo "<td class='p-2 $class'>";
506
+                                    echo "<td class='p-2 $class'>";
507 507
 
508
-										switch( $key ) {
508
+                                        switch( $key ) {
509 509
 
510
-											case 'total':
511
-												echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>';
512
-												break;
510
+                                            case 'total':
511
+                                                echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>';
512
+                                                break;
513 513
 
514
-											case 'relationship':
515
-												echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
516
-												break;
514
+                                            case 'relationship':
515
+                                                echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
516
+                                                break;
517 517
 
518
-											case 'date':
519
-												echo getpaid_format_date_value( $payment->get_date_created() );
520
-												break;
518
+                                            case 'date':
519
+                                                echo getpaid_format_date_value( $payment->get_date_created() );
520
+                                                break;
521 521
 
522
-											case 'status':
522
+                                            case 'status':
523 523
 
524
-												$status = $payment->get_status_nicename();
525
-												if ( is_admin() ) {
526
-													$status = $payment->get_status_label_html();
527
-												}
524
+                                                $status = $payment->get_status_nicename();
525
+                                                if ( is_admin() ) {
526
+                                                    $status = $payment->get_status_label_html();
527
+                                                }
528 528
 
529
-												echo $status;
530
-												break;
529
+                                                echo $status;
530
+                                                break;
531 531
 
532
-											case 'invoice':
533
-												$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
532
+                                            case 'invoice':
533
+                                                $link    = esc_url( get_edit_post_link( $payment->get_id() ) );
534 534
 
535
-												if ( ! is_admin() ) {
536
-													$link = esc_url( $payment->get_view_url() );
537
-												}
535
+                                                if ( ! is_admin() ) {
536
+                                                    $link = esc_url( $payment->get_view_url() );
537
+                                                }
538 538
 
539
-												$invoice = esc_html( $payment->get_number() );
540
-												echo "<a href='$link'>$invoice</a>";
541
-												break;
542
-										}
539
+                                                $invoice = esc_html( $payment->get_number() );
540
+                                                echo "<a href='$link'>$invoice</a>";
541
+                                                break;
542
+                                        }
543 543
 
544
-									echo '</td>';
544
+                                    echo '</td>';
545 545
 
546
-								}
546
+                                }
547 547
 
548
-							echo '</tr>';
548
+                            echo '</tr>';
549 549
 
550
-						endforeach;
551
-					?>
550
+                        endforeach;
551
+                    ?>
552 552
 
553 553
 				</tbody>
554 554
 
@@ -566,42 +566,42 @@  discard block
 block discarded – undo
566 566
  */
567 567
 function getpaid_admin_subscription_item_details_metabox( $subscription ) {
568 568
 
569
-	// Fetch the subscription group.
570
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
569
+    // Fetch the subscription group.
570
+    $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
571 571
 
572
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
573
-		return;
574
-	}
572
+    if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
573
+        return;
574
+    }
575 575
 
576
-	// Prepare table columns.
577
-	$columns = apply_filters(
578
-		'getpaid_subscription_item_details_columns',
579
-		array(
580
-			'item_name'    => __( 'Item', 'invoicing' ),
581
-			'price'        => __( 'Price', 'invoicing' ),
582
-			'tax'          => __( 'Tax', 'invoicing' ),
583
-			'discount'     => __( 'Discount', 'invoicing' ),
584
-			//'initial'      => __( 'Initial Amount', 'invoicing' ),
585
-			'recurring'    => __( 'Subtotal', 'invoicing' ),
586
-		),
587
-		$subscription
588
-	);
576
+    // Prepare table columns.
577
+    $columns = apply_filters(
578
+        'getpaid_subscription_item_details_columns',
579
+        array(
580
+            'item_name'    => __( 'Item', 'invoicing' ),
581
+            'price'        => __( 'Price', 'invoicing' ),
582
+            'tax'          => __( 'Tax', 'invoicing' ),
583
+            'discount'     => __( 'Discount', 'invoicing' ),
584
+            //'initial'      => __( 'Initial Amount', 'invoicing' ),
585
+            'recurring'    => __( 'Subtotal', 'invoicing' ),
586
+        ),
587
+        $subscription
588
+    );
589 589
 
590
-	// Prepare the invoices.
590
+    // Prepare the invoices.
591 591
 
592
-	$invoice = $subscription->get_parent_invoice();
592
+    $invoice = $subscription->get_parent_invoice();
593 593
 
594
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
595
-		unset( $columns['tax'] );
596
-	}
594
+    if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
595
+        unset( $columns['tax'] );
596
+    }
597 597
 
598
-	$table_class = 'w-100 bg-white';
598
+    $table_class = 'w-100 bg-white';
599 599
 
600
-	if ( ! is_admin() ) {
601
-		$table_class = 'table table-bordered';
602
-	}
600
+    if ( ! is_admin() ) {
601
+        $table_class = 'table table-bordered';
602
+    }
603 603
 
604
-	?>
604
+    ?>
605 605
 		<div class="m-0" style="overflow: auto;">
606 606
 
607 607
 			<table class="<?php echo $table_class; ?>">
@@ -610,14 +610,14 @@  discard block
 block discarded – undo
610 610
 					<tr>
611 611
 						<?php
612 612
 
613
-							foreach ( $columns as $key => $label ) {
614
-								$key   = esc_attr( $key );
615
-								$label = esc_html( $label );
616
-								$class = 'text-left';
613
+                            foreach ( $columns as $key => $label ) {
614
+                                $key   = esc_attr( $key );
615
+                                $label = esc_html( $label );
616
+                                $class = 'text-left';
617 617
 
618
-								echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
619
-							}
620
-						?>
618
+                                echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
619
+                            }
620
+                        ?>
621 621
 					</tr>
622 622
 				</thead>
623 623
 
@@ -625,106 +625,106 @@  discard block
 block discarded – undo
625 625
 
626 626
 					<?php
627 627
 
628
-						foreach( $subscription_group['items'] as $subscription_group_item ) :
628
+                        foreach( $subscription_group['items'] as $subscription_group_item ) :
629 629
 
630
-							echo '<tr>';
630
+                            echo '<tr>';
631 631
 
632
-								foreach ( array_keys( $columns ) as $key ) {
632
+                                foreach ( array_keys( $columns ) as $key ) {
633 633
 
634
-									$class = 'text-left';
634
+                                    $class = 'text-left';
635 635
 
636
-									echo "<td class='p-2 $class'>";
636
+                                    echo "<td class='p-2 $class'>";
637 637
 
638
-										switch( $key ) {
638
+                                        switch( $key ) {
639 639
 
640
-											case 'item_name':
641
-												$item_name = get_the_title( $subscription_group_item['item_id'] );
642
-												$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
640
+                                            case 'item_name':
641
+                                                $item_name = get_the_title( $subscription_group_item['item_id'] );
642
+                                                $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
643 643
 
644
-												if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
645
-													echo esc_html( $item_name );
646
-												} else {
647
-													printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
648
-												}
644
+                                                if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
645
+                                                    echo esc_html( $item_name );
646
+                                                } else {
647
+                                                    printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
648
+                                                }
649 649
 
650
-												break;
650
+                                                break;
651 651
 
652
-											case 'price':
653
-												echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() );
654
-												break;
652
+                                            case 'price':
653
+                                                echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() );
654
+                                                break;
655 655
 
656
-											case 'tax':
657
-												echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() );
658
-												break;
656
+                                            case 'tax':
657
+                                                echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() );
658
+                                                break;
659 659
 
660
-											case 'discount':
661
-												echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() );
662
-												break;
660
+                                            case 'discount':
661
+                                                echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() );
662
+                                                break;
663 663
 
664
-											case 'initial':
665
-												echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
666
-												break;
664
+                                            case 'initial':
665
+                                                echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
666
+                                                break;
667 667
 
668
-											case 'recurring':
669
-												echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>';
670
-												break;
668
+                                            case 'recurring':
669
+                                                echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>';
670
+                                                break;
671 671
 
672
-										}
672
+                                        }
673 673
 
674
-									echo '</td>';
674
+                                    echo '</td>';
675 675
 
676
-								}
676
+                                }
677 677
 
678
-							echo '</tr>';
678
+                            echo '</tr>';
679 679
 
680
-						endforeach;
680
+                        endforeach;
681 681
 
682
-						foreach( $subscription_group['fees'] as $subscription_group_fee ) :
682
+                        foreach( $subscription_group['fees'] as $subscription_group_fee ) :
683 683
 
684
-							echo '<tr>';
684
+                            echo '<tr>';
685 685
 
686
-								foreach ( array_keys( $columns ) as $key ) {
686
+                                foreach ( array_keys( $columns ) as $key ) {
687 687
 
688
-									$class = 'text-left';
688
+                                    $class = 'text-left';
689 689
 
690
-									echo "<td class='p-2 $class'>";
690
+                                    echo "<td class='p-2 $class'>";
691 691
 
692
-										switch( $key ) {
692
+                                        switch( $key ) {
693 693
 
694
-											case 'item_name':
695
-												echo esc_html( $subscription_group_fee['name'] );
696
-												break;
694
+                                            case 'item_name':
695
+                                                echo esc_html( $subscription_group_fee['name'] );
696
+                                                break;
697 697
 
698
-											case 'price':
699
-												echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
700
-												break;
698
+                                            case 'price':
699
+                                                echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
700
+                                                break;
701 701
 
702
-											case 'tax':
703
-												echo "&mdash;";
704
-												break;
702
+                                            case 'tax':
703
+                                                echo "&mdash;";
704
+                                                break;
705 705
 
706
-											case 'discount':
707
-												echo "&mdash;";
708
-												break;
706
+                                            case 'discount':
707
+                                                echo "&mdash;";
708
+                                                break;
709 709
 
710
-											case 'initial':
711
-												echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
712
-												break;
710
+                                            case 'initial':
711
+                                                echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
712
+                                                break;
713 713
 
714
-											case 'recurring':
715
-												echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>';
716
-												break;
714
+                                            case 'recurring':
715
+                                                echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>';
716
+                                                break;
717 717
 
718
-										}
718
+                                        }
719 719
 
720
-									echo '</td>';
720
+                                    echo '</td>';
721 721
 
722
-								}
722
+                                }
723 723
 
724
-							echo '</tr>';
724
+                            echo '</tr>';
725 725
 
726
-						endforeach;
727
-					?>
726
+                        endforeach;
727
+                    ?>
728 728
 
729 729
 				</tbody>
730 730
 
@@ -743,38 +743,38 @@  discard block
 block discarded – undo
743 743
  */
744 744
 function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
745 745
 
746
-	// Fetch the subscription groups.
747
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
748
-
749
-	if ( empty( $subscription_groups ) ) {
750
-		return;
751
-	}
752
-
753
-	// Prepare table columns.
754
-	$columns = apply_filters(
755
-		'getpaid_subscription_related_subscriptions_columns',
756
-		array(
757
-			'subscription'      => __( 'Subscription', 'invoicing' ),
758
-			'start_date'        => __( 'Start Date', 'invoicing' ),
759
-			'renewal_date'      => __( 'Next Payment', 'invoicing' ),
760
-			'renewals'          => __( 'Payments', 'invoicing' ),
761
-			'item'              => __( 'Items', 'invoicing' ),
762
-			'status'            => __( 'Status', 'invoicing' ),
763
-		),
764
-		$subscription
765
-	);
766
-
767
-	if ( $subscription->get_status() == 'pending' ) {
768
-		unset( $columns['start_date'], $columns['renewal_date'] );
769
-	}
770
-
771
-	$table_class = 'w-100 bg-white';
772
-
773
-	if ( ! is_admin() ) {
774
-		$table_class = 'table table-bordered';
775
-	}
776
-
777
-	?>
746
+    // Fetch the subscription groups.
747
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
748
+
749
+    if ( empty( $subscription_groups ) ) {
750
+        return;
751
+    }
752
+
753
+    // Prepare table columns.
754
+    $columns = apply_filters(
755
+        'getpaid_subscription_related_subscriptions_columns',
756
+        array(
757
+            'subscription'      => __( 'Subscription', 'invoicing' ),
758
+            'start_date'        => __( 'Start Date', 'invoicing' ),
759
+            'renewal_date'      => __( 'Next Payment', 'invoicing' ),
760
+            'renewals'          => __( 'Payments', 'invoicing' ),
761
+            'item'              => __( 'Items', 'invoicing' ),
762
+            'status'            => __( 'Status', 'invoicing' ),
763
+        ),
764
+        $subscription
765
+    );
766
+
767
+    if ( $subscription->get_status() == 'pending' ) {
768
+        unset( $columns['start_date'], $columns['renewal_date'] );
769
+    }
770
+
771
+    $table_class = 'w-100 bg-white';
772
+
773
+    if ( ! is_admin() ) {
774
+        $table_class = 'table table-bordered';
775
+    }
776
+
777
+    ?>
778 778
 		<div class="m-0" style="overflow: auto;">
779 779
 
780 780
 			<table class="<?php echo $table_class; ?>">
@@ -783,14 +783,14 @@  discard block
 block discarded – undo
783 783
 					<tr>
784 784
 						<?php
785 785
 
786
-							foreach ( $columns as $key => $label ) {
787
-								$key   = esc_attr( $key );
788
-								$label = esc_html( $label );
789
-								$class = 'text-left';
786
+                            foreach ( $columns as $key => $label ) {
787
+                                $key   = esc_attr( $key );
788
+                                $label = esc_html( $label );
789
+                                $class = 'text-left';
790 790
 
791
-								echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
792
-							}
793
-						?>
791
+                                echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
792
+                            }
793
+                        ?>
794 794
 					</tr>
795 795
 				</thead>
796 796
 
@@ -798,74 +798,74 @@  discard block
 block discarded – undo
798 798
 
799 799
 					<?php
800 800
 
801
-						foreach( $subscription_groups as $subscription_group ) :
801
+                        foreach( $subscription_groups as $subscription_group ) :
802 802
 
803
-							// Do not list current subscription.
804
-							if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
805
-								continue;
806
-							}
803
+                            // Do not list current subscription.
804
+                            if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
805
+                                continue;
806
+                            }
807 807
 
808
-							// Ensure the subscription exists.
809
-							$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
808
+                            // Ensure the subscription exists.
809
+                            $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
810 810
 
811
-							if ( ! $_suscription->exists() ) {
812
-								continue;
813
-							}
811
+                            if ( ! $_suscription->exists() ) {
812
+                                continue;
813
+                            }
814 814
 
815
-							echo '<tr>';
815
+                            echo '<tr>';
816 816
 
817
-								foreach ( array_keys( $columns ) as $key ) {
817
+                                foreach ( array_keys( $columns ) as $key ) {
818 818
 
819
-									$class = 'text-left';
819
+                                    $class = 'text-left';
820 820
 
821
-									echo "<td class='p-2 $class'>";
821
+                                    echo "<td class='p-2 $class'>";
822 822
 
823
-										switch( $key ) {
823
+                                        switch( $key ) {
824 824
 
825
-											case 'status':
826
-												echo $_suscription->get_status_label_html();
827
-												break;
825
+                                            case 'status':
826
+                                                echo $_suscription->get_status_label_html();
827
+                                                break;
828 828
 
829
-											case 'item':
830
-												$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
831
-												echo implode( ' | ', $markup );
832
-												break;
829
+                                            case 'item':
830
+                                                $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
831
+                                                echo implode( ' | ', $markup );
832
+                                                break;
833 833
 
834
-											case 'renewals':
835
-												$max_bills = $_suscription->get_bill_times();
836
-												echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
837
-												break;
834
+                                            case 'renewals':
835
+                                                $max_bills = $_suscription->get_bill_times();
836
+                                                echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
837
+                                                break;
838 838
 
839
-											case 'renewal_date':
840
-												echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "&mdash;";
841
-												break;
839
+                                            case 'renewal_date':
840
+                                                echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "&mdash;";
841
+                                                break;
842 842
 
843
-											case 'start_date':
844
-												echo 'pending' == $_suscription->get_status() ? "&mdash;" : getpaid_format_date_value( $_suscription->get_date_created() );
845
-												break;
843
+                                            case 'start_date':
844
+                                                echo 'pending' == $_suscription->get_status() ? "&mdash;" : getpaid_format_date_value( $_suscription->get_date_created() );
845
+                                                break;
846 846
 
847
-											case 'subscription':
848
-												$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
849
-												printf(
850
-													'%1$s#%2$s%3$s',
851
-													'<a href="' . esc_url( $url ) . '">',
852
-													'<strong>' . intval( $_suscription->get_id() ) . '</strong>',
853
-													'</a>'
854
-												);
847
+                                            case 'subscription':
848
+                                                $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
849
+                                                printf(
850
+                                                    '%1$s#%2$s%3$s',
851
+                                                    '<a href="' . esc_url( $url ) . '">',
852
+                                                    '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
853
+                                                    '</a>'
854
+                                                );
855 855
 
856
-												echo WPInv_Subscriptions_List_Table::column_amount( $_suscription );
857
-												break;
856
+                                                echo WPInv_Subscriptions_List_Table::column_amount( $_suscription );
857
+                                                break;
858 858
 
859
-										}
859
+                                        }
860 860
 
861
-									echo '</td>';
861
+                                    echo '</td>';
862 862
 
863
-								}
863
+                                }
864 864
 
865
-							echo '</tr>';
865
+                            echo '</tr>';
866 866
 
867
-						endforeach;
868
-					?>
867
+                        endforeach;
868
+                    ?>
869 869
 
870 870
 				</tbody>
871 871
 
Please login to merge, or discard this patch.
Spacing   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains functions that display the subscriptions admin page.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Render the Subscriptions page
@@ -17,22 +17,22 @@  discard block
 block discarded – undo
17 17
 	?>
18 18
 
19 19
 	<div class="wrap">
20
-		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
20
+		<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
21 21
 		<div class="bsui">
22 22
 
23 23
 			<?php
24 24
 
25 25
 				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
26
+				if (!wpinv_current_user_can_manage_invoicing()) {
27 27
 
28 28
 					echo aui()->alert(
29 29
 						array(
30 30
 							'type'    => 'danger',
31
-							'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
31
+							'content' => __('You are not permitted to view this page.', 'invoicing'),
32 32
 						)
33 33
 					);
34 34
 
35
-				} else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
35
+				} else if (!empty($_GET['id']) && is_numeric($_GET['id'])) {
36 36
 
37 37
 					// Display a single subscription.
38 38
 					wpinv_recurring_subscription_details();
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 function wpinv_recurring_subscription_details() {
82 82
 
83 83
 	// Fetch the subscription.
84
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
85
-	if ( ! $sub->exists() ) {
84
+	$sub = new WPInv_Subscription((int) $_GET['id']);
85
+	if (!$sub->exists()) {
86 86
 
87 87
 		echo aui()->alert(
88 88
 			array(
89 89
 				'type'    => 'danger',
90
-				'content' => __( 'Subscription not found.', 'invoicing' ),
90
+				'content' => __('Subscription not found.', 'invoicing'),
91 91
 			)
92 92
 		);
93 93
 
@@ -95,45 +95,45 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	// Use metaboxes to display the subscription details.
98
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
99
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
98
+	add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high');
99
+	add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side');
100 100
 
101 101
 	$subscription_id     = $sub->get_id();
102
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
103
-	$subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
102
+	$subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id());
103
+	$subscription_group  = wp_list_filter($subscription_groups, compact('subscription_id'));
104 104
 
105
-	if ( 1 < count( $subscription_groups ) ) {
106
-		add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
105
+	if (1 < count($subscription_groups)) {
106
+		add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced');
107 107
 	}
108 108
 
109
-	if ( ! empty( $subscription_group ) ) {
110
-		add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
109
+	if (!empty($subscription_group)) {
110
+		add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low');
111 111
 	}
112 112
 
113
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
113
+	add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced');
114 114
 
115
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
115
+	do_action('getpaid_admin_single_subscription_register_metabox', $sub);
116 116
 
117 117
 	?>
118 118
 
119
-		<form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>">
119
+		<form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>">
120 120
 
121
-			<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
122
-			<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
123
-			<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
121
+			<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
122
+			<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
123
+			<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
124 124
 			<input type="hidden" name="getpaid-admin-action" value="update_single_subscription" />
125
-			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" />
125
+			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" />
126 126
 
127 127
 			<div id="poststuff">
128 128
 				<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
129 129
 
130 130
 					<div id="postbox-container-1" class="postbox-container">
131
-						<?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?>
131
+						<?php do_meta_boxes(get_current_screen(), 'side', $sub); ?>
132 132
 					</div>
133 133
 
134 134
 					<div id="postbox-container-2" class="postbox-container">
135
-						<?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?>
136
-						<?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?>
135
+						<?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?>
136
+						<?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?>
137 137
 					</div>
138 138
 
139 139
 				</div>
@@ -152,44 +152,44 @@  discard block
 block discarded – undo
152 152
  *
153 153
  * @param WPInv_Subscription $sub
154 154
  */
155
-function getpaid_admin_subscription_details_metabox( $sub ) {
155
+function getpaid_admin_subscription_details_metabox($sub) {
156 156
 
157 157
 	// Subscription items.
158
-	$subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
159
-	$items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
158
+	$subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id());
159
+	$items_count        = empty($subscription_group) ? 1 : count($subscription_group['items']);
160 160
 
161 161
 	// Prepare subscription detail columns.
162 162
 	$fields = apply_filters(
163 163
 		'getpaid_subscription_admin_page_fields',
164 164
 		array(
165
-			'subscription'   => __( 'Subscription', 'invoicing' ),
166
-			'customer'       => __( 'Customer', 'invoicing' ),
167
-			'amount'         => __( 'Amount', 'invoicing' ),
168
-			'start_date'     => __( 'Start Date', 'invoicing' ),
169
-			'renews_on'      => __( 'Next Payment', 'invoicing' ),
170
-			'renewals'       => __( 'Payments', 'invoicing' ),
171
-			'item'           => _n( 'Item', 'Items', $items_count,  'invoicing' ),
172
-			'gateway'        => __( 'Payment Method', 'invoicing' ),
173
-			'profile_id'     => __( 'Profile ID', 'invoicing' ),
174
-			'status'         => __( 'Status', 'invoicing' ),
165
+			'subscription'   => __('Subscription', 'invoicing'),
166
+			'customer'       => __('Customer', 'invoicing'),
167
+			'amount'         => __('Amount', 'invoicing'),
168
+			'start_date'     => __('Start Date', 'invoicing'),
169
+			'renews_on'      => __('Next Payment', 'invoicing'),
170
+			'renewals'       => __('Payments', 'invoicing'),
171
+			'item'           => _n('Item', 'Items', $items_count, 'invoicing'),
172
+			'gateway'        => __('Payment Method', 'invoicing'),
173
+			'profile_id'     => __('Profile ID', 'invoicing'),
174
+			'status'         => __('Status', 'invoicing'),
175 175
 		)
176 176
 	);
177 177
 
178
-	if ( ! $sub->is_active() ) {
178
+	if (!$sub->is_active()) {
179 179
 
180
-		if ( isset( $fields['renews_on'] ) ) {
181
-			unset( $fields['renews_on'] );
180
+		if (isset($fields['renews_on'])) {
181
+			unset($fields['renews_on']);
182 182
 		}
183 183
 
184
-		if ( isset( $fields['gateway'] ) ) {
185
-			unset( $fields['gateway'] );
184
+		if (isset($fields['gateway'])) {
185
+			unset($fields['gateway']);
186 186
 		}
187 187
 
188 188
 	}
189 189
 
190 190
 	$profile_id = $sub->get_profile_id();
191
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
192
-		unset( $fields['profile_id'] );
191
+	if (empty($profile_id) && isset($fields['profile_id'])) {
192
+		unset($fields['profile_id']);
193 193
 	}
194 194
 
195 195
 	?>
@@ -197,16 +197,16 @@  discard block
 block discarded – undo
197 197
 		<table class="table table-borderless" style="font-size: 14px;">
198 198
 			<tbody>
199 199
 
200
-				<?php foreach ( $fields as $key => $label ) : ?>
200
+				<?php foreach ($fields as $key => $label) : ?>
201 201
 
202
-					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>">
202
+					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>">
203 203
 
204 204
 						<th class="w-25" style="font-weight: 500;">
205
-							<?php echo esc_html( $label ); ?>
205
+							<?php echo esc_html($label); ?>
206 206
 						</th>
207 207
 
208 208
 						<td class="w-75 text-muted">
209
-							<?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?>
209
+							<?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?>
210 210
 						</td>
211 211
 
212 212
 					</tr>
@@ -224,129 +224,129 @@  discard block
 block discarded – undo
224 224
  *
225 225
  * @param WPInv_Subscription $subscription
226 226
  */
227
-function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
227
+function getpaid_admin_subscription_metabox_display_customer($subscription) {
228 228
 
229
-	$username = __( '(Missing User)', 'invoicing' );
229
+	$username = __('(Missing User)', 'invoicing');
230 230
 
231
-	$user = get_userdata( $subscription->get_customer_id() );
232
-	if ( $user ) {
231
+	$user = get_userdata($subscription->get_customer_id());
232
+	if ($user) {
233 233
 
234 234
 		$username = sprintf(
235 235
 			'<a href="user-edit.php?user_id=%s">%s</a>',
236
-			absint( $user->ID ),
237
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
236
+			absint($user->ID),
237
+			!empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email)
238 238
 		);
239 239
 
240 240
 	}
241 241
 
242 242
 	echo  $username;
243 243
 }
244
-add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
244
+add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer');
245 245
 
246 246
 /**
247 247
  * Displays the subscription amount.
248 248
  *
249 249
  * @param WPInv_Subscription $subscription
250 250
  */
251
-function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
252
-	$amount    = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) );
251
+function getpaid_admin_subscription_metabox_display_amount($subscription) {
252
+	$amount = wp_kses_post(getpaid_get_formatted_subscription_amount($subscription));
253 253
 	echo "<span>$amount</span>";
254 254
 }
255
-add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
255
+add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount');
256 256
 
257 257
 /**
258 258
  * Displays the subscription id.
259 259
  *
260 260
  * @param WPInv_Subscription $subscription
261 261
  */
262
-function getpaid_admin_subscription_metabox_display_id( $subscription ) {
263
-	echo  '#' . absint( $subscription->get_id() );
262
+function getpaid_admin_subscription_metabox_display_id($subscription) {
263
+	echo  '#' . absint($subscription->get_id());
264 264
 }
265
-add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
265
+add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id');
266 266
 
267 267
 /**
268 268
  * Displays the subscription renewal date.
269 269
  *
270 270
  * @param WPInv_Subscription $subscription
271 271
  */
272
-function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
273
-	echo getpaid_format_date_value( $subscription->get_date_created() );
272
+function getpaid_admin_subscription_metabox_display_start_date($subscription) {
273
+	echo getpaid_format_date_value($subscription->get_date_created());
274 274
 }
275
-add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
275
+add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date');
276 276
 
277 277
 /**
278 278
  * Displays the subscription renewal date.
279 279
  *
280 280
  * @param WPInv_Subscription $subscription
281 281
  */
282
-function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
283
-	echo getpaid_format_date_value( $subscription->get_expiration() );
282
+function getpaid_admin_subscription_metabox_display_renews_on($subscription) {
283
+	echo getpaid_format_date_value($subscription->get_expiration());
284 284
 }
285
-add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
285
+add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on');
286 286
 
287 287
 /**
288 288
  * Displays the subscription renewal count.
289 289
  *
290 290
  * @param WPInv_Subscription $subscription
291 291
  */
292
-function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
292
+function getpaid_admin_subscription_metabox_display_renewals($subscription) {
293 293
 	$max_bills = $subscription->get_bill_times();
294
-	echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
294
+	echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
295 295
 }
296
-add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
296
+add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals');
297 297
 /**
298 298
  * Displays the subscription item.
299 299
  *
300 300
  * @param WPInv_Subscription $subscription
301 301
  * @param false|array $subscription_group
302 302
  */
303
-function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
303
+function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) {
304 304
 
305
-	if ( empty( $subscription_group ) ) {
306
-		echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() );
305
+	if (empty($subscription_group)) {
306
+		echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id());
307 307
 		return;
308 308
 	}
309 309
 
310
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
311
-	echo implode( ' | ', $markup );
310
+	$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
311
+	echo implode(' | ', $markup);
312 312
 
313 313
 }
314
-add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
314
+add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2);
315 315
 
316 316
 /**
317 317
  * Displays the subscription gateway.
318 318
  *
319 319
  * @param WPInv_Subscription $subscription
320 320
  */
321
-function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
321
+function getpaid_admin_subscription_metabox_display_gateway($subscription) {
322 322
 
323 323
 	$gateway = $subscription->get_gateway();
324 324
 
325
-	if ( ! empty( $gateway ) ) {
326
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
325
+	if (!empty($gateway)) {
326
+		echo esc_html(wpinv_get_gateway_admin_label($gateway));
327 327
 	} else {
328 328
 		echo "&mdash;";
329 329
 	}
330 330
 
331 331
 }
332
-add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
332
+add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway');
333 333
 
334 334
 /**
335 335
  * Displays the subscription status.
336 336
  *
337 337
  * @param WPInv_Subscription $subscription
338 338
  */
339
-function getpaid_admin_subscription_metabox_display_status( $subscription ) {
339
+function getpaid_admin_subscription_metabox_display_status($subscription) {
340 340
 	echo $subscription->get_status_label_html();
341 341
 }
342
-add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
342
+add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status');
343 343
 
344 344
 /**
345 345
  * Displays the subscription profile id.
346 346
  *
347 347
  * @param WPInv_Subscription $subscription
348 348
  */
349
-function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
349
+function getpaid_admin_subscription_metabox_display_profile_id($subscription) {
350 350
 
351 351
 	$profile_id = $subscription->get_profile_id();
352 352
 
@@ -355,32 +355,32 @@  discard block
 block discarded – undo
355 355
 			'type'        => 'text',
356 356
 			'id'          => 'wpinv_subscription_profile_id',
357 357
 			'name'        => 'wpinv_subscription_profile_id',
358
-			'label'       => __( 'Profile Id', 'invoicing' ),
358
+			'label'       => __('Profile Id', 'invoicing'),
359 359
 			'label_type'  => 'hidden',
360
-			'placeholder' => __( 'Profile Id', 'invoicing' ),
361
-			'value'       => esc_attr( $profile_id ),
360
+			'placeholder' => __('Profile Id', 'invoicing'),
361
+			'value'       => esc_attr($profile_id),
362 362
 			'input_group_right' => '',
363 363
 			'no_wrap'     => true,
364 364
 		)
365 365
 	);
366 366
 
367
-	echo str_ireplace( 'form-control', 'regular-text', $input );
367
+	echo str_ireplace('form-control', 'regular-text', $input);
368 368
 
369
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
370
-	if ( ! empty( $url ) ) {
371
-		$url = esc_url_raw( $url );
372
-		echo '&nbsp;<a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
369
+	$url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription);
370
+	if (!empty($url)) {
371
+		$url = esc_url_raw($url);
372
+		echo '&nbsp;<a href="' . $url . '" title="' . __('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
373 373
 	}
374 374
 
375 375
 }
376
-add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
376
+add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id');
377 377
 
378 378
 /**
379 379
  * Displays the subscriptions update metabox.
380 380
  *
381 381
  * @param WPInv_Subscription $subscription
382 382
  */
383
-function getpaid_admin_subscription_update_metabox( $subscription ) {
383
+function getpaid_admin_subscription_update_metabox($subscription) {
384 384
 
385 385
 	?>
386 386
 	<div class="mt-3">
@@ -393,10 +393,10 @@  discard block
 block discarded – undo
393 393
 					'id'               => 'subscription_status_update_select',
394 394
 					'required'         => true,
395 395
 					'no_wrap'          => false,
396
-					'label'            => __( 'Subscription Status', 'invoicing' ),
397
-					'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
396
+					'label'            => __('Subscription Status', 'invoicing'),
397
+					'help_text'        => __('Updating the status will trigger related actions and hooks', 'invoicing'),
398 398
 					'select2'          => true,
399
-					'value'            => $subscription->get_status( 'edit' ),
399
+					'value'            => $subscription->get_status('edit'),
400 400
 				)
401 401
 			);
402 402
 		?>
@@ -404,13 +404,13 @@  discard block
 block discarded – undo
404 404
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
405 405
 
406 406
 		<?php
407
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
407
+			submit_button(__('Update', 'invoicing'), 'primary', 'submit', false);
408 408
 
409
-			$url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
410
-			$anchor = __( 'Renew Subscription', 'invoicing' );
411
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
409
+			$url    = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'));
410
+			$anchor = __('Renew Subscription', 'invoicing');
411
+			$title  = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing');
412 412
 
413
-			if ( $subscription->is_active() ) {
413
+			if ($subscription->is_active()) {
414 414
 				echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
415 415
 			}
416 416
 
@@ -423,31 +423,31 @@  discard block
 block discarded – undo
423 423
  * @param WPInv_Subscription $subscription
424 424
  * @param bool $strict Whether or not to skip invoices of sibling subscriptions
425 425
  */
426
-function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
426
+function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) {
427 427
 
428 428
 	$columns = apply_filters(
429 429
 		'getpaid_subscription_related_invoices_columns',
430 430
 		array(
431
-			'invoice'      => __( 'Invoice', 'invoicing' ),
432
-			'relationship' => __( 'Relationship', 'invoicing' ),
433
-			'date'         => __( 'Date', 'invoicing' ),
434
-			'status'       => __( 'Status', 'invoicing' ),
435
-			'total'        => __( 'Total', 'invoicing' ),
431
+			'invoice'      => __('Invoice', 'invoicing'),
432
+			'relationship' => __('Relationship', 'invoicing'),
433
+			'date'         => __('Date', 'invoicing'),
434
+			'status'       => __('Status', 'invoicing'),
435
+			'total'        => __('Total', 'invoicing'),
436 436
 		),
437 437
 		$subscription
438 438
 	);
439 439
 
440 440
 	// Prepare the invoices.
441
-	$payments = $subscription->get_child_payments( ! is_admin() );
441
+	$payments = $subscription->get_child_payments(!is_admin());
442 442
 	$parent   = $subscription->get_parent_invoice();
443 443
 
444
-	if ( $parent->exists() ) {
445
-		$payments = array_merge( array( $parent ), $payments );
444
+	if ($parent->exists()) {
445
+		$payments = array_merge(array($parent), $payments);
446 446
 	}
447 447
 
448 448
 	$table_class = 'w-100 bg-white';
449 449
 
450
-	if ( ! is_admin() ) {
450
+	if (!is_admin()) {
451 451
 		$table_class = 'table table-bordered';
452 452
 	}
453 453
 
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
 				<thead>
460 460
 					<tr>
461 461
 						<?php
462
-							foreach ( $columns as $key => $label ) {
463
-								$key   = esc_attr( $key );
464
-								$label = esc_html( $label );
462
+							foreach ($columns as $key => $label) {
463
+								$key   = esc_attr($key);
464
+								$label = esc_html($label);
465 465
 								$class = 'text-left';
466 466
 
467 467
 								echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
@@ -472,57 +472,57 @@  discard block
 block discarded – undo
472 472
 
473 473
 				<tbody>
474 474
 
475
-					<?php if ( empty( $payments ) ) : ?>
475
+					<?php if (empty($payments)) : ?>
476 476
 						<tr>
477 477
 							<td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted">
478
-								<?php _e( 'This subscription has no invoices.', 'invoicing' ); ?>
478
+								<?php _e('This subscription has no invoices.', 'invoicing'); ?>
479 479
 							</td>
480 480
 						</tr>
481 481
 					<?php endif; ?>
482 482
 
483 483
 					<?php
484 484
 
485
-						foreach( $payments as $payment ) :
485
+						foreach ($payments as $payment) :
486 486
 
487 487
 							// Ensure that we have an invoice.
488
-							$payment = new WPInv_Invoice( $payment );
488
+							$payment = new WPInv_Invoice($payment);
489 489
 
490 490
 							// Abort if the invoice is invalid...
491
-							if ( ! $payment->exists() ) {
491
+							if (!$payment->exists()) {
492 492
 								continue;
493 493
 							}
494 494
 
495 495
 							// ... or belongs to a different subscription.
496
-							if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
496
+							if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) {
497 497
 								continue;
498 498
 							}
499 499
 
500 500
 							echo '<tr>';
501 501
 
502
-								foreach ( array_keys( $columns ) as $key ) {
502
+								foreach (array_keys($columns) as $key) {
503 503
 
504 504
 									$class = 'text-left';
505 505
 
506 506
 									echo "<td class='p-2 $class'>";
507 507
 
508
-										switch( $key ) {
508
+										switch ($key) {
509 509
 
510 510
 											case 'total':
511
-												echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>';
511
+												echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>';
512 512
 												break;
513 513
 
514 514
 											case 'relationship':
515
-												echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
515
+												echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing');
516 516
 												break;
517 517
 
518 518
 											case 'date':
519
-												echo getpaid_format_date_value( $payment->get_date_created() );
519
+												echo getpaid_format_date_value($payment->get_date_created());
520 520
 												break;
521 521
 
522 522
 											case 'status':
523 523
 
524 524
 												$status = $payment->get_status_nicename();
525
-												if ( is_admin() ) {
525
+												if (is_admin()) {
526 526
 													$status = $payment->get_status_label_html();
527 527
 												}
528 528
 
@@ -530,13 +530,13 @@  discard block
 block discarded – undo
530 530
 												break;
531 531
 
532 532
 											case 'invoice':
533
-												$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
533
+												$link = esc_url(get_edit_post_link($payment->get_id()));
534 534
 
535
-												if ( ! is_admin() ) {
536
-													$link = esc_url( $payment->get_view_url() );
535
+												if (!is_admin()) {
536
+													$link = esc_url($payment->get_view_url());
537 537
 												}
538 538
 
539
-												$invoice = esc_html( $payment->get_number() );
539
+												$invoice = esc_html($payment->get_number());
540 540
 												echo "<a href='$link'>$invoice</a>";
541 541
 												break;
542 542
 										}
@@ -564,12 +564,12 @@  discard block
 block discarded – undo
564 564
  *
565 565
  * @param WPInv_Subscription $subscription
566 566
  */
567
-function getpaid_admin_subscription_item_details_metabox( $subscription ) {
567
+function getpaid_admin_subscription_item_details_metabox($subscription) {
568 568
 
569 569
 	// Fetch the subscription group.
570
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
570
+	$subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id());
571 571
 
572
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
572
+	if (empty($subscription_group) || empty($subscription_group['items'])) {
573 573
 		return;
574 574
 	}
575 575
 
@@ -577,12 +577,12 @@  discard block
 block discarded – undo
577 577
 	$columns = apply_filters(
578 578
 		'getpaid_subscription_item_details_columns',
579 579
 		array(
580
-			'item_name'    => __( 'Item', 'invoicing' ),
581
-			'price'        => __( 'Price', 'invoicing' ),
582
-			'tax'          => __( 'Tax', 'invoicing' ),
583
-			'discount'     => __( 'Discount', 'invoicing' ),
580
+			'item_name'    => __('Item', 'invoicing'),
581
+			'price'        => __('Price', 'invoicing'),
582
+			'tax'          => __('Tax', 'invoicing'),
583
+			'discount'     => __('Discount', 'invoicing'),
584 584
 			//'initial'      => __( 'Initial Amount', 'invoicing' ),
585
-			'recurring'    => __( 'Subtotal', 'invoicing' ),
585
+			'recurring'    => __('Subtotal', 'invoicing'),
586 586
 		),
587 587
 		$subscription
588 588
 	);
@@ -591,13 +591,13 @@  discard block
 block discarded – undo
591 591
 
592 592
 	$invoice = $subscription->get_parent_invoice();
593 593
 
594
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
595
-		unset( $columns['tax'] );
594
+	if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) {
595
+		unset($columns['tax']);
596 596
 	}
597 597
 
598 598
 	$table_class = 'w-100 bg-white';
599 599
 
600
-	if ( ! is_admin() ) {
600
+	if (!is_admin()) {
601 601
 		$table_class = 'table table-bordered';
602 602
 	}
603 603
 
@@ -610,9 +610,9 @@  discard block
 block discarded – undo
610 610
 					<tr>
611 611
 						<?php
612 612
 
613
-							foreach ( $columns as $key => $label ) {
614
-								$key   = esc_attr( $key );
615
-								$label = esc_html( $label );
613
+							foreach ($columns as $key => $label) {
614
+								$key   = esc_attr($key);
615
+								$label = esc_html($label);
616 616
 								$class = 'text-left';
617 617
 
618 618
 								echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
@@ -625,48 +625,48 @@  discard block
 block discarded – undo
625 625
 
626 626
 					<?php
627 627
 
628
-						foreach( $subscription_group['items'] as $subscription_group_item ) :
628
+						foreach ($subscription_group['items'] as $subscription_group_item) :
629 629
 
630 630
 							echo '<tr>';
631 631
 
632
-								foreach ( array_keys( $columns ) as $key ) {
632
+								foreach (array_keys($columns) as $key) {
633 633
 
634 634
 									$class = 'text-left';
635 635
 
636 636
 									echo "<td class='p-2 $class'>";
637 637
 
638
-										switch( $key ) {
638
+										switch ($key) {
639 639
 
640 640
 											case 'item_name':
641
-												$item_name = get_the_title( $subscription_group_item['item_id'] );
642
-												$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
641
+												$item_name = get_the_title($subscription_group_item['item_id']);
642
+												$item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name;
643 643
 
644
-												if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
645
-													echo esc_html( $item_name );
644
+												if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) {
645
+													echo esc_html($item_name);
646 646
 												} else {
647
-													printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
647
+													printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']);
648 648
 												}
649 649
 
650 650
 												break;
651 651
 
652 652
 											case 'price':
653
-												echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() );
653
+												echo wpinv_price($subscription_group_item['item_price'], $invoice->get_currency());
654 654
 												break;
655 655
 
656 656
 											case 'tax':
657
-												echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() );
657
+												echo wpinv_price($subscription_group_item['tax'], $invoice->get_currency());
658 658
 												break;
659 659
 
660 660
 											case 'discount':
661
-												echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() );
661
+												echo wpinv_price($subscription_group_item['discount'], $invoice->get_currency());
662 662
 												break;
663 663
 
664 664
 											case 'initial':
665
-												echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
665
+												echo wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency());
666 666
 												break;
667 667
 
668 668
 											case 'recurring':
669
-												echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>';
669
+												echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>';
670 670
 												break;
671 671
 
672 672
 										}
@@ -679,24 +679,24 @@  discard block
 block discarded – undo
679 679
 
680 680
 						endforeach;
681 681
 
682
-						foreach( $subscription_group['fees'] as $subscription_group_fee ) :
682
+						foreach ($subscription_group['fees'] as $subscription_group_fee) :
683 683
 
684 684
 							echo '<tr>';
685 685
 
686
-								foreach ( array_keys( $columns ) as $key ) {
686
+								foreach (array_keys($columns) as $key) {
687 687
 
688 688
 									$class = 'text-left';
689 689
 
690 690
 									echo "<td class='p-2 $class'>";
691 691
 
692
-										switch( $key ) {
692
+										switch ($key) {
693 693
 
694 694
 											case 'item_name':
695
-												echo esc_html( $subscription_group_fee['name'] );
695
+												echo esc_html($subscription_group_fee['name']);
696 696
 												break;
697 697
 
698 698
 											case 'price':
699
-												echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
699
+												echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
700 700
 												break;
701 701
 
702 702
 											case 'tax':
@@ -708,11 +708,11 @@  discard block
 block discarded – undo
708 708
 												break;
709 709
 
710 710
 											case 'initial':
711
-												echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
711
+												echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
712 712
 												break;
713 713
 
714 714
 											case 'recurring':
715
-												echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>';
715
+												echo '<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>';
716 716
 												break;
717 717
 
718 718
 										}
@@ -741,12 +741,12 @@  discard block
 block discarded – undo
741 741
  * @param WPInv_Subscription $subscription
742 742
  * @param bool $skip_current
743 743
  */
744
-function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
744
+function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) {
745 745
 
746 746
 	// Fetch the subscription groups.
747
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
747
+	$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id());
748 748
 
749
-	if ( empty( $subscription_groups ) ) {
749
+	if (empty($subscription_groups)) {
750 750
 		return;
751 751
 	}
752 752
 
@@ -754,23 +754,23 @@  discard block
 block discarded – undo
754 754
 	$columns = apply_filters(
755 755
 		'getpaid_subscription_related_subscriptions_columns',
756 756
 		array(
757
-			'subscription'      => __( 'Subscription', 'invoicing' ),
758
-			'start_date'        => __( 'Start Date', 'invoicing' ),
759
-			'renewal_date'      => __( 'Next Payment', 'invoicing' ),
760
-			'renewals'          => __( 'Payments', 'invoicing' ),
761
-			'item'              => __( 'Items', 'invoicing' ),
762
-			'status'            => __( 'Status', 'invoicing' ),
757
+			'subscription'      => __('Subscription', 'invoicing'),
758
+			'start_date'        => __('Start Date', 'invoicing'),
759
+			'renewal_date'      => __('Next Payment', 'invoicing'),
760
+			'renewals'          => __('Payments', 'invoicing'),
761
+			'item'              => __('Items', 'invoicing'),
762
+			'status'            => __('Status', 'invoicing'),
763 763
 		),
764 764
 		$subscription
765 765
 	);
766 766
 
767
-	if ( $subscription->get_status() == 'pending' ) {
768
-		unset( $columns['start_date'], $columns['renewal_date'] );
767
+	if ($subscription->get_status() == 'pending') {
768
+		unset($columns['start_date'], $columns['renewal_date']);
769 769
 	}
770 770
 
771 771
 	$table_class = 'w-100 bg-white';
772 772
 
773
-	if ( ! is_admin() ) {
773
+	if (!is_admin()) {
774 774
 		$table_class = 'table table-bordered';
775 775
 	}
776 776
 
@@ -783,9 +783,9 @@  discard block
 block discarded – undo
783 783
 					<tr>
784 784
 						<?php
785 785
 
786
-							foreach ( $columns as $key => $label ) {
787
-								$key   = esc_attr( $key );
788
-								$label = esc_html( $label );
786
+							foreach ($columns as $key => $label) {
787
+								$key   = esc_attr($key);
788
+								$label = esc_html($label);
789 789
 								$class = 'text-left';
790 790
 
791 791
 								echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
@@ -798,62 +798,62 @@  discard block
 block discarded – undo
798 798
 
799 799
 					<?php
800 800
 
801
-						foreach( $subscription_groups as $subscription_group ) :
801
+						foreach ($subscription_groups as $subscription_group) :
802 802
 
803 803
 							// Do not list current subscription.
804
-							if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
804
+							if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) {
805 805
 								continue;
806 806
 							}
807 807
 
808 808
 							// Ensure the subscription exists.
809
-							$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
809
+							$_suscription = new WPInv_Subscription($subscription_group['subscription_id']);
810 810
 
811
-							if ( ! $_suscription->exists() ) {
811
+							if (!$_suscription->exists()) {
812 812
 								continue;
813 813
 							}
814 814
 
815 815
 							echo '<tr>';
816 816
 
817
-								foreach ( array_keys( $columns ) as $key ) {
817
+								foreach (array_keys($columns) as $key) {
818 818
 
819 819
 									$class = 'text-left';
820 820
 
821 821
 									echo "<td class='p-2 $class'>";
822 822
 
823
-										switch( $key ) {
823
+										switch ($key) {
824 824
 
825 825
 											case 'status':
826 826
 												echo $_suscription->get_status_label_html();
827 827
 												break;
828 828
 
829 829
 											case 'item':
830
-												$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
831
-												echo implode( ' | ', $markup );
830
+												$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
831
+												echo implode(' | ', $markup);
832 832
 												break;
833 833
 
834 834
 											case 'renewals':
835 835
 												$max_bills = $_suscription->get_bill_times();
836
-												echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
836
+												echo $_suscription->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
837 837
 												break;
838 838
 
839 839
 											case 'renewal_date':
840
-												echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "&mdash;";
840
+												echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : "&mdash;";
841 841
 												break;
842 842
 
843 843
 											case 'start_date':
844
-												echo 'pending' == $_suscription->get_status() ? "&mdash;" : getpaid_format_date_value( $_suscription->get_date_created() );
844
+												echo 'pending' == $_suscription->get_status() ? "&mdash;" : getpaid_format_date_value($_suscription->get_date_created());
845 845
 												break;
846 846
 
847 847
 											case 'subscription':
848
-												$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
848
+												$url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url();
849 849
 												printf(
850 850
 													'%1$s#%2$s%3$s',
851
-													'<a href="' . esc_url( $url ) . '">',
852
-													'<strong>' . intval( $_suscription->get_id() ) . '</strong>',
851
+													'<a href="' . esc_url($url) . '">',
852
+													'<strong>' . intval($_suscription->get_id()) . '</strong>',
853 853
 													'</a>'
854 854
 												);
855 855
 
856
-												echo WPInv_Subscriptions_List_Table::column_amount( $_suscription );
856
+												echo WPInv_Subscriptions_List_Table::column_amount($_suscription);
857 857
 												break;
858 858
 
859 859
 										}
Please login to merge, or discard this patch.
templates/invoice-receipt.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -7,64 +7,64 @@  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
 // Fetch the invoice.
13
-$invoice = new WPInv_Invoice( $invoice );
13
+$invoice = new WPInv_Invoice($invoice);
14 14
 
15 15
 // @deprecated
16
-do_action( 'wpinv_success_content_before', $invoice );
17
-do_action( 'wpinv_before_receipt', $invoice );
16
+do_action('wpinv_success_content_before', $invoice);
17
+do_action('wpinv_before_receipt', $invoice);
18 18
 
19 19
 wpinv_print_errors();
20 20
 
21 21
 // Prepare header text.
22
-if ( $invoice->is_paid() ) {
22
+if ($invoice->is_paid()) {
23 23
 
24 24
     $alert = aui()->alert(
25 25
         array(
26 26
             'type'    => 'success',
27
-            'content' => __( 'Thank you for your payment!', 'invoicing' ),
27
+            'content' => __('Thank you for your payment!', 'invoicing'),
28 28
         )
29 29
     );
30 30
 
31
-} else if ( $invoice->is_refunded() ) {
31
+} else if ($invoice->is_refunded()) {
32 32
 
33 33
     $alert = aui()->alert(
34 34
         array(
35 35
             'type'    => 'info',
36
-            'content' => __( 'This invoice was refunded.', 'invoicing' ),
36
+            'content' => __('This invoice was refunded.', 'invoicing'),
37 37
         )
38 38
     );
39 39
 
40
-} else if ( $invoice->is_held() ) {
40
+} else if ($invoice->is_held()) {
41 41
 
42 42
     $alert = aui()->alert(
43 43
         array(
44 44
             'type'    => 'info',
45
-            'content' => __( 'This invoice will be processed as soon we verify your payment.', 'invoicing' ),
45
+            'content' => __('This invoice will be processed as soon we verify your payment.', 'invoicing'),
46 46
         )
47 47
     );
48 48
 
49
-} else if ( $invoice->needs_payment() ) {
49
+} else if ($invoice->needs_payment()) {
50 50
 
51
-    if ( ! empty( $_GET['token'] ) ) {
51
+    if (!empty($_GET['token'])) {
52 52
 
53 53
         $alert = aui()->alert(
54 54
             array(
55 55
                 'type'    => 'info',
56
-                'content' => __( "Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing' ),
56
+                'content' => __("Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing'),
57 57
             )
58 58
         );
59 59
 
60
-    } else if ( $invoice->is_due() ) {
60
+    } else if ($invoice->is_due()) {
61 61
 
62 62
         $alert = aui()->alert(
63 63
             array(
64 64
                 'type'    => 'danger',
65 65
                 'content' => sprintf(
66
-                    __( 'This invoice was due on %.', 'invoicing' ),
67
-                    getpaid_format_date_value( $invoice->get_due_date() )
66
+                    __('This invoice was due on %.', 'invoicing'),
67
+                    getpaid_format_date_value($invoice->get_due_date())
68 68
                 ),
69 69
             )
70 70
         );
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         $alert = aui()->alert(
75 75
             array(
76 76
                 'type'    => 'warning',
77
-                'content' => __( 'This invoice needs payment.', 'invoicing' ),
77
+                'content' => __('This invoice needs payment.', 'invoicing'),
78 78
             )
79 79
         );
80 80
 
@@ -89,19 +89,19 @@  discard block
 block discarded – undo
89 89
 
90 90
         'pay' => array(
91 91
             'url'   => $invoice->get_checkout_payment_url(),
92
-            'name'  => __( 'Pay For Invoice', 'invoicing' ),
92
+            'name'  => __('Pay For Invoice', 'invoicing'),
93 93
             'class' => 'btn-success',
94 94
         ),
95 95
 
96 96
         'view' => array(
97 97
             'url'   => $invoice->get_view_url(),
98
-            'name'  => __( 'View Invoice', 'invoicing' ),
98
+            'name'  => __('View Invoice', 'invoicing'),
99 99
             'class' => 'btn-primary',
100 100
         ),
101 101
 
102 102
         'history' => array(
103 103
             'url'   => wpinv_get_history_page_uri(),
104
-            'name'  => __( 'Invoice History', 'invoicing' ),
104
+            'name'  => __('Invoice History', 'invoicing'),
105 105
             'class' => 'btn-warning',
106 106
         ),
107 107
 
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
 
111 111
 );
112 112
 
113
-if ( ( ! $invoice->needs_payment() || $invoice->is_held() ) && isset( $actions['pay'] ) ) {
114
-    unset( $actions['pay'] );
113
+if ((!$invoice->needs_payment() || $invoice->is_held()) && isset($actions['pay'])) {
114
+    unset($actions['pay']);
115 115
 }
116 116
 
117
-if ( ! is_user_logged_in() && isset( $actions['history'] ) ) {
118
-    unset( $actions['history'] );
117
+if (!is_user_logged_in() && isset($actions['history'])) {
118
+    unset($actions['history']);
119 119
 }
120 120
 
121 121
 ?>
@@ -124,19 +124,19 @@  discard block
 block discarded – undo
124 124
 
125 125
         <?php
126 126
         
127
-            do_action( 'wpinv_receipt_start', $invoice );
127
+            do_action('wpinv_receipt_start', $invoice);
128 128
 
129
-            if ( ! empty( $actions ) ) {
129
+            if (!empty($actions)) {
130 130
 
131 131
                 echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">';
132 132
 
133
-                foreach ( $actions as $key => $action ) {
133
+                foreach ($actions as $key => $action) {
134 134
 
135
-                    $key    = sanitize_html_class( $key );
136
-                    $class  = empty( $action['class'] ) ? 'btn-dark' : sanitize_html_class( $action['class'] );
137
-                    $url    = empty( $action['url'] ) ? '#' : esc_url( $action['url'] );
138
-                    $attrs  = empty( $action['attrs'] ) ? '' : $action['attrs'];
139
-                    $anchor = esc_html( $action['name'] );
135
+                    $key    = sanitize_html_class($key);
136
+                    $class  = empty($action['class']) ? 'btn-dark' : sanitize_html_class($action['class']);
137
+                    $url    = empty($action['url']) ? '#' : esc_url($action['url']);
138
+                    $attrs  = empty($action['attrs']) ? '' : $action['attrs'];
139
+                    $anchor = esc_html($action['name']);
140 140
 
141 141
                     echo "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>";
142 142
                 }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
             }
147 147
 
148
-            if ( ! empty( $alert ) ) {
148
+            if (!empty($alert)) {
149 149
                 echo $alert;
150 150
             }
151 151
 
@@ -154,19 +154,19 @@  discard block
 block discarded – undo
154 154
         <div class="wpinv-receipt-details">
155 155
 
156 156
             <h4 class="wpinv-details-t mb-3 mt-3">
157
-                <?php echo apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?>
157
+                <?php echo apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing'), $invoice); ?>
158 158
             </h4>
159 159
 
160
-            <?php getpaid_invoice_meta( $invoice ); ?>
160
+            <?php getpaid_invoice_meta($invoice); ?>
161 161
 
162 162
         </div>
163 163
 
164
-        <?php do_action( 'wpinv_receipt_end', $invoice ); ?>
164
+        <?php do_action('wpinv_receipt_end', $invoice); ?>
165 165
 
166 166
     </div>
167 167
 
168 168
 <?php
169 169
 
170 170
 // @deprecated
171
-do_action( 'wpinv_success_content_after', $invoice );
172
-do_action( 'wpinv_after_receipt', $invoice );
171
+do_action('wpinv_success_content_after', $invoice);
172
+do_action('wpinv_after_receipt', $invoice);
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-bank-transfer-gateway.php 2 patches
Indentation   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'bank_transfer';
21 21
 
22
-	/**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
27
-	protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
22
+    /**
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27
+    protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
34
-	public $order = 8;
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34
+    public $order = 8;
35 35
 
36 36
     /**
37
-	 * Class constructor.
38
-	 */
39
-	public function __construct() {
37
+     * Class constructor.
38
+     */
39
+    public function __construct() {
40 40
         parent::__construct();
41 41
 
42 42
         $this->title                = __( 'Direct bank transfer', 'invoicing' );
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
         $this->checkout_button_text = __( 'Proceed', 'invoicing' );
45 45
         $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
46 46
 
47
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
51
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
52
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
47
+        add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
+        add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
+        add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
+        add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
51
+        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
52
+        add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
53 53
 
54 54
     }
55 55
 
56 56
     /**
57
-	 * Process Payment.
58
-	 *
59
-	 * @param WPInv_Invoice $invoice Invoice.
60
-	 * @param array $submission_data Posted checkout fields.
61
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
62
-	 * @return array
63
-	 */
64
-	public function process_payment( $invoice, $submission_data, $submission ) {
57
+     * Process Payment.
58
+     *
59
+     * @param WPInv_Invoice $invoice Invoice.
60
+     * @param array $submission_data Posted checkout fields.
61
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
62
+     * @return array
63
+     */
64
+    public function process_payment( $invoice, $submission_data, $submission ) {
65 65
 
66 66
         // Add a transaction id.
67 67
         $invoice->set_transaction_id( $invoice->generate_key('bt_') );
@@ -82,66 +82,66 @@  discard block
 block discarded – undo
82 82
     }
83 83
 
84 84
     /**
85
-	 * Output for the order received page.
86
-	 *
87
-	 * @param WPInv_Invoice $invoice Invoice.
88
-	 */
89
-	public function thankyou_page( $invoice ) {
85
+     * Output for the order received page.
86
+     *
87
+     * @param WPInv_Invoice $invoice Invoice.
88
+     */
89
+    public function thankyou_page( $invoice ) {
90 90
 
91 91
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
92 92
 
93
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
93
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
94 94
 
95 95
             if ( ! empty( $this->instructions ) ) {
96 96
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
97
-			}
97
+            }
98 98
 
99
-			$this->bank_details( $invoice );
99
+            $this->bank_details( $invoice );
100 100
 
101
-			echo '</div>';
101
+            echo '</div>';
102 102
 
103 103
         }
104 104
 
105
-	}
105
+    }
106 106
 
107 107
     /**
108
-	 * Add content to the WPI emails.
109
-	 *
110
-	 * @param WPInv_Invoice $invoice Invoice.
111
-	 * @param string     $email_type Email format: plain text or HTML.
112
-	 * @param bool     $sent_to_admin Sent to admin.
113
-	 */
114
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
108
+     * Add content to the WPI emails.
109
+     *
110
+     * @param WPInv_Invoice $invoice Invoice.
111
+     * @param string     $email_type Email format: plain text or HTML.
112
+     * @param bool     $sent_to_admin Sent to admin.
113
+     */
114
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
115 115
 
116
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
116
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
117 117
 
118
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
118
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
119 119
 
120
-			if ( $this->instructions ) {
121
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
120
+            if ( $this->instructions ) {
121
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
122 122
             }
123 123
 
124
-			$this->bank_details( $invoice );
124
+            $this->bank_details( $invoice );
125 125
 
126
-			echo '</div>';
126
+            echo '</div>';
127 127
 
128
-		}
128
+        }
129 129
 
130 130
     }
131 131
 
132 132
     /**
133
-	 * Get bank details and place into a list format.
134
-	 *
135
-	 * @param WPInv_Invoice $invoice Invoice.
136
-	 */
137
-	protected function bank_details( $invoice ) {
133
+     * Get bank details and place into a list format.
134
+     *
135
+     * @param WPInv_Invoice $invoice Invoice.
136
+     */
137
+    protected function bank_details( $invoice ) {
138 138
 
139
-		// Get the invoice country and country $locale.
140
-		$country = $invoice->get_country();
141
-		$locale  = $this->get_country_locale();
139
+        // Get the invoice country and country $locale.
140
+        $country = $invoice->get_country();
141
+        $locale  = $this->get_country_locale();
142 142
 
143
-		// Get sortcode label in the $locale array and use appropriate one.
144
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
143
+        // Get sortcode label in the $locale array and use appropriate one.
144
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
145 145
 
146 146
         $bank_fields = array(
147 147
             'ac_name'     => __( 'Account Name', 'invoicing' ),
@@ -170,144 +170,144 @@  discard block
 block discarded – undo
170 170
             return;
171 171
         }
172 172
 
173
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
173
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
174
+
175
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
176
+
177
+        foreach ( $bank_info as $key => $data ) {
178
+
179
+            $key   = sanitize_html_class( $key );
180
+            $label = wp_kses_post( $data['label'] );
181
+            $value = wp_kses_post( wptexturize( $data['value'] ) );
182
+
183
+            echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL;
184
+        }
174 185
 
175
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
186
+        echo '</table>';
176 187
 
177
-		foreach ( $bank_info as $key => $data ) {
188
+    }
178 189
 
179
-			$key   = sanitize_html_class( $key );
180
-			$label = wp_kses_post( $data['label'] );
181
-			$value = wp_kses_post( wptexturize( $data['value'] ) );
190
+    /**
191
+     * Get country locale if localized.
192
+     *
193
+     * @return array
194
+     */
195
+    public function get_country_locale() {
196
+
197
+        if ( empty( $this->locale ) ) {
198
+
199
+            // Locale information to be used - only those that are not 'Sort Code'.
200
+            $this->locale = apply_filters(
201
+                'getpaid_get_bank_transfer_locale',
202
+                array(
203
+                    'AU' => array(
204
+                        'sortcode' => array(
205
+                            'label' => __( 'BSB', 'invoicing' ),
206
+                        ),
207
+                    ),
208
+                    'CA' => array(
209
+                        'sortcode' => array(
210
+                            'label' => __( 'Bank transit number', 'invoicing' ),
211
+                        ),
212
+                    ),
213
+                    'IN' => array(
214
+                        'sortcode' => array(
215
+                            'label' => __( 'IFSC', 'invoicing' ),
216
+                        ),
217
+                    ),
218
+                    'IT' => array(
219
+                        'sortcode' => array(
220
+                            'label' => __( 'Branch sort', 'invoicing' ),
221
+                        ),
222
+                    ),
223
+                    'NZ' => array(
224
+                        'sortcode' => array(
225
+                            'label' => __( 'Bank code', 'invoicing' ),
226
+                        ),
227
+                    ),
228
+                    'SE' => array(
229
+                        'sortcode' => array(
230
+                            'label' => __( 'Bank code', 'invoicing' ),
231
+                        ),
232
+                    ),
233
+                    'US' => array(
234
+                        'sortcode' => array(
235
+                            'label' => __( 'Routing number', 'invoicing' ),
236
+                        ),
237
+                    ),
238
+                    'ZA' => array(
239
+                        'sortcode' => array(
240
+                            'label' => __( 'Branch code', 'invoicing' ),
241
+                        ),
242
+                    ),
243
+                )
244
+            );
182 245
 
183
-			echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL;
184
-		}
246
+        }
185 247
 
186
-		echo '</table>';
248
+        return $this->locale;
187 249
 
188 250
     }
189 251
 
190 252
     /**
191
-	 * Get country locale if localized.
192
-	 *
193
-	 * @return array
194
-	 */
195
-	public function get_country_locale() {
196
-
197
-		if ( empty( $this->locale ) ) {
198
-
199
-			// Locale information to be used - only those that are not 'Sort Code'.
200
-			$this->locale = apply_filters(
201
-				'getpaid_get_bank_transfer_locale',
202
-				array(
203
-					'AU' => array(
204
-						'sortcode' => array(
205
-							'label' => __( 'BSB', 'invoicing' ),
206
-						),
207
-					),
208
-					'CA' => array(
209
-						'sortcode' => array(
210
-							'label' => __( 'Bank transit number', 'invoicing' ),
211
-						),
212
-					),
213
-					'IN' => array(
214
-						'sortcode' => array(
215
-							'label' => __( 'IFSC', 'invoicing' ),
216
-						),
217
-					),
218
-					'IT' => array(
219
-						'sortcode' => array(
220
-							'label' => __( 'Branch sort', 'invoicing' ),
221
-						),
222
-					),
223
-					'NZ' => array(
224
-						'sortcode' => array(
225
-							'label' => __( 'Bank code', 'invoicing' ),
226
-						),
227
-					),
228
-					'SE' => array(
229
-						'sortcode' => array(
230
-							'label' => __( 'Bank code', 'invoicing' ),
231
-						),
232
-					),
233
-					'US' => array(
234
-						'sortcode' => array(
235
-							'label' => __( 'Routing number', 'invoicing' ),
236
-						),
237
-					),
238
-					'ZA' => array(
239
-						'sortcode' => array(
240
-							'label' => __( 'Branch code', 'invoicing' ),
241
-						),
242
-					),
243
-				)
244
-			);
245
-
246
-		}
247
-
248
-		return $this->locale;
249
-
250
-	}
251
-
252
-	/**
253
-	 * Filters the gateway settings.
254
-	 *
255
-	 * @param array $admin_settings
256
-	 */
257
-	public function admin_settings( $admin_settings ) {
253
+     * Filters the gateway settings.
254
+     *
255
+     * @param array $admin_settings
256
+     */
257
+    public function admin_settings( $admin_settings ) {
258 258
 
259 259
         $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
260
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
260
+        $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
261 261
 
262
-		$locale  = $this->get_country_locale();
262
+        $locale  = $this->get_country_locale();
263 263
 
264
-		// Get sortcode label in the $locale array and use appropriate one.
265
-		$country  = wpinv_default_billing_country();
266
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
264
+        // Get sortcode label in the $locale array and use appropriate one.
265
+        $country  = wpinv_default_billing_country();
266
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
267 267
 
268
-		$admin_settings['bank_transfer_ac_name'] = array(
268
+        $admin_settings['bank_transfer_ac_name'] = array(
269 269
             'type' => 'text',
270 270
             'id'   => 'bank_transfer_ac_name',
271 271
             'name' => __( 'Account Name', 'invoicing' ),
272
-		);
272
+        );
273 273
 
274
-		$admin_settings['bank_transfer_ac_no'] = array(
274
+        $admin_settings['bank_transfer_ac_no'] = array(
275 275
             'type' => 'text',
276 276
             'id'   => 'bank_transfer_ac_no',
277 277
             'name' => __( 'Account Number', 'invoicing' ),
278
-		);
278
+        );
279 279
 
280
-		$admin_settings['bank_transfer_bank_name'] = array(
280
+        $admin_settings['bank_transfer_bank_name'] = array(
281 281
             'type' => 'text',
282 282
             'id'   => 'bank_transfer_bank_name',
283 283
             'name' => __( 'Bank Name', 'invoicing' ),
284
-		);
284
+        );
285 285
 
286
-		$admin_settings['bank_transfer_ifsc'] = array(
286
+        $admin_settings['bank_transfer_ifsc'] = array(
287 287
             'type' => 'text',
288 288
             'id'   => 'bank_transfer_ifsc',
289 289
             'name' => __( 'IFSC Code', 'invoicing' ),
290
-		);
290
+        );
291 291
 
292
-		$admin_settings['bank_transfer_iban'] = array(
292
+        $admin_settings['bank_transfer_iban'] = array(
293 293
             'type' => 'text',
294 294
             'id'   => 'bank_transfer_iban',
295 295
             'name' => __( 'IBAN', 'invoicing' ),
296
-		);
296
+        );
297 297
 
298
-		$admin_settings['bank_transfer_bic'] = array(
298
+        $admin_settings['bank_transfer_bic'] = array(
299 299
             'type' => 'text',
300 300
             'id'   => 'bank_transfer_bic',
301 301
             'name' => __( 'BIC/Swift Code', 'invoicing' ),
302
-		);
302
+        );
303 303
 
304
-		$admin_settings['bank_transfer_sort_code'] = array(
305
-			'type' => 'text',
306
-			'id'   => 'bank_transfer_sort_code',
307
-			'name' => $sortcode,
308
-		);
304
+        $admin_settings['bank_transfer_sort_code'] = array(
305
+            'type' => 'text',
306
+            'id'   => 'bank_transfer_sort_code',
307
+            'name' => $sortcode,
308
+        );
309 309
 
310
-		$admin_settings['bank_transfer_info'] = array(
310
+        $admin_settings['bank_transfer_info'] = array(
311 311
             'id'   => 'bank_transfer_info',
312 312
             'name' => __( 'Instructions', 'invoicing' ),
313 313
             'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
@@ -317,17 +317,17 @@  discard block
 block discarded – undo
317 317
             'rows' => 5
318 318
         );
319 319
 
320
-		return $admin_settings;
321
-	}
320
+        return $admin_settings;
321
+    }
322 322
 
323
-	/**
324
-	 * Processes invoice addons.
325
-	 *
326
-	 * @param WPInv_Invoice $invoice
327
-	 * @param GetPaid_Form_Item[] $items
328
-	 * @return WPInv_Invoice
329
-	 */
330
-	public function process_addons( $invoice, $items ) {
323
+    /**
324
+     * Processes invoice addons.
325
+     *
326
+     * @param WPInv_Invoice $invoice
327
+     * @param GetPaid_Form_Item[] $items
328
+     * @return WPInv_Invoice
329
+     */
330
+    public function process_addons( $invoice, $items ) {
331 331
 
332 332
         foreach ( $items as $item ) {
333 333
             $invoice->add_item( $item );
@@ -335,70 +335,70 @@  discard block
 block discarded – undo
335 335
 
336 336
         $invoice->recalculate_total();
337 337
         $invoice->save();
338
-	}
338
+    }
339 339
 
340
-	/**
341
-	 * (Maybe) renews a bank transfer subscription profile.
342
-	 *
343
-	 *
340
+    /**
341
+     * (Maybe) renews a bank transfer subscription profile.
342
+     *
343
+     *
344 344
      * @param WPInv_Subscription $subscription
345
-	 */
346
-	public function maybe_renew_subscription( $subscription ) {
345
+     */
346
+    public function maybe_renew_subscription( $subscription ) {
347 347
 
348 348
         // Ensure its our subscription && it's active.
349 349
         if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
350
-			$subscription->create_payment();
350
+            $subscription->create_payment();
351 351
         }
352 352
 
353 353
     }
354 354
 
355
-	/**
356
-	 * Process a bank transfer payment.
357
-	 *
358
-	 *
355
+    /**
356
+     * Process a bank transfer payment.
357
+     *
358
+     *
359 359
      * @param WPInv_Invoice $invoice
360
-	 */
361
-	public function invoice_paid( $invoice ) {
360
+     */
361
+    public function invoice_paid( $invoice ) {
362 362
 
363
-		// Abort if not paid by bank transfer.
364
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
365
-			return;
366
-		}
363
+        // Abort if not paid by bank transfer.
364
+        if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
365
+            return;
366
+        }
367 367
 
368
-		// Is it a parent payment?
369
-		if ( 0 == $invoice->get_parent_id() ) {
368
+        // Is it a parent payment?
369
+        if ( 0 == $invoice->get_parent_id() ) {
370 370
 
371
-			// (Maybe) activate subscriptions.
372
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
371
+            // (Maybe) activate subscriptions.
372
+            $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
373 373
 
374
-			if ( ! empty( $subscriptions ) ) {
375
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
374
+            if ( ! empty( $subscriptions ) ) {
375
+                $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
376 376
 
377
-				foreach ( $subscriptions as $subscription ) {
378
-					if ( $subscription->exists() ) {
379
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
380
-						$expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
377
+                foreach ( $subscriptions as $subscription ) {
378
+                    if ( $subscription->exists() ) {
379
+                        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
380
+                        $expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
381 381
 
382
-						$subscription->set_next_renewal_date( $expiry );
383
-						$subscription->set_date_created( current_time( 'mysql' ) );
384
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
385
-						$subscription->activate();
386
-					}
387
-				}
382
+                        $subscription->set_next_renewal_date( $expiry );
383
+                        $subscription->set_date_created( current_time( 'mysql' ) );
384
+                        $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
385
+                        $subscription->activate();
386
+                    }
387
+                }
388 388
 
389
-			}
389
+            }
390 390
 
391
-		} else {
391
+        } else {
392 392
 
393
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
393
+            $subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
394 394
 
395
-			// Renew the subscription.
396
-			if ( $subscription && $subscription->exists() ) {
397
-				$subscription->add_payment( array(), $invoice );
398
-				$subscription->renew();
399
-			}
395
+            // Renew the subscription.
396
+            if ( $subscription && $subscription->exists() ) {
397
+                $subscription->add_payment( array(), $invoice );
398
+                $subscription->renew();
399
+            }
400 400
 
401
-		}
401
+        }
402 402
 
403 403
     }
404 404
 
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 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
  * Bank transfer Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-	protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
27
+	protected $supports = array('subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
 	public function __construct() {
40 40
         parent::__construct();
41 41
 
42
-        $this->title                = __( 'Direct bank transfer', 'invoicing' );
43
-        $this->method_title         = __( 'Bank transfer', 'invoicing' );
44
-        $this->checkout_button_text = __( 'Proceed', 'invoicing' );
45
-        $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
42
+        $this->title                = __('Direct bank transfer', 'invoicing');
43
+        $this->method_title         = __('Bank transfer', 'invoicing');
44
+        $this->checkout_button_text = __('Proceed', 'invoicing');
45
+        $this->instructions         = apply_filters('wpinv_bank_instructions', $this->get_option('info'));
46 46
 
47
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
51
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
52
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
47
+		add_action('wpinv_receipt_end', array($this, 'thankyou_page'));
48
+		add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40);
49
+		add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11);
50
+		add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3);
51
+		add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'));
52
+		add_action('getpaid_invoice_status_publish', array($this, 'invoice_paid'), 20);
53 53
 
54 54
     }
55 55
 
@@ -61,23 +61,23 @@  discard block
 block discarded – undo
61 61
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
62 62
 	 * @return array
63 63
 	 */
64
-	public function process_payment( $invoice, $submission_data, $submission ) {
64
+	public function process_payment($invoice, $submission_data, $submission) {
65 65
 
66 66
         // Add a transaction id.
67
-        $invoice->set_transaction_id( $invoice->generate_key('bt_') );
67
+        $invoice->set_transaction_id($invoice->generate_key('bt_'));
68 68
 
69 69
         // Set it as pending payment.
70
-        if ( ! $invoice->needs_payment() ) {
70
+        if (!$invoice->needs_payment()) {
71 71
             $invoice->mark_paid();
72
-        } else if ( ! $invoice->is_paid() ) {
73
-            $invoice->set_status( 'wpi-onhold' );
72
+        } else if (!$invoice->is_paid()) {
73
+            $invoice->set_status('wpi-onhold');
74 74
         }
75 75
 
76 76
         // Save it.
77 77
         $invoice->save();
78 78
 
79 79
         // Send to the success page.
80
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
80
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
81 81
 
82 82
     }
83 83
 
@@ -86,17 +86,17 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @param WPInv_Invoice $invoice Invoice.
88 88
 	 */
89
-	public function thankyou_page( $invoice ) {
89
+	public function thankyou_page($invoice) {
90 90
 
91
-        if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
91
+        if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
92 92
 
93 93
 			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
94 94
 
95
-            if ( ! empty( $this->instructions ) ) {
96
-                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
95
+            if (!empty($this->instructions)) {
96
+                echo wp_kses_post(wpautop(wptexturize($this->instructions)));
97 97
 			}
98 98
 
99
-			$this->bank_details( $invoice );
99
+			$this->bank_details($invoice);
100 100
 
101 101
 			echo '</div>';
102 102
 
@@ -111,17 +111,17 @@  discard block
 block discarded – undo
111 111
 	 * @param string     $email_type Email format: plain text or HTML.
112 112
 	 * @param bool     $sent_to_admin Sent to admin.
113 113
 	 */
114
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
114
+	public function email_instructions($invoice, $email_type, $sent_to_admin) {
115 115
 
116
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
116
+		if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
117 117
 
118 118
 			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
119 119
 
120
-			if ( $this->instructions ) {
121
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
120
+			if ($this->instructions) {
121
+				echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL);
122 122
             }
123 123
 
124
-			$this->bank_details( $invoice );
124
+			$this->bank_details($invoice);
125 125
 
126 126
 			echo '</div>';
127 127
 
@@ -134,51 +134,51 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param WPInv_Invoice $invoice Invoice.
136 136
 	 */
137
-	protected function bank_details( $invoice ) {
137
+	protected function bank_details($invoice) {
138 138
 
139 139
 		// Get the invoice country and country $locale.
140 140
 		$country = $invoice->get_country();
141 141
 		$locale  = $this->get_country_locale();
142 142
 
143 143
 		// Get sortcode label in the $locale array and use appropriate one.
144
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
144
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
145 145
 
146 146
         $bank_fields = array(
147
-            'ac_name'     => __( 'Account Name', 'invoicing' ),
148
-            'ac_no'       => __( 'Account Number', 'invoicing' ),
149
-            'bank_name'   => __( 'Bank Name', 'invoicing' ),
150
-            'ifsc'        => __( 'IFSC code', 'invoicing' ),
151
-            'iban'        => __( 'IBAN', 'invoicing' ),
152
-            'bic'         => __( 'BIC/Swift code', 'invoicing' ),
147
+            'ac_name'     => __('Account Name', 'invoicing'),
148
+            'ac_no'       => __('Account Number', 'invoicing'),
149
+            'bank_name'   => __('Bank Name', 'invoicing'),
150
+            'ifsc'        => __('IFSC code', 'invoicing'),
151
+            'iban'        => __('IBAN', 'invoicing'),
152
+            'bic'         => __('BIC/Swift code', 'invoicing'),
153 153
             'sort_code'   => $sortcode,
154 154
         );
155 155
 
156 156
         $bank_info = array();
157 157
 
158
-        foreach ( $bank_fields as $field => $label ) {
159
-            $value = $this->get_option( $field );
158
+        foreach ($bank_fields as $field => $label) {
159
+            $value = $this->get_option($field);
160 160
 
161
-            if ( ! empty( $value ) ) {
162
-                $bank_info[$field] = array( 'label' => $label, 'value' => $value );
161
+            if (!empty($value)) {
162
+                $bank_info[$field] = array('label' => $label, 'value' => $value);
163 163
             }
164 164
 
165 165
         }
166 166
 
167
-        $bank_info = apply_filters( 'wpinv_bank_info', $bank_info );
167
+        $bank_info = apply_filters('wpinv_bank_info', $bank_info);
168 168
 
169
-        if ( empty( $bank_info ) ) {
169
+        if (empty($bank_info)) {
170 170
             return;
171 171
         }
172 172
 
173
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
173
+		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing')) . '</h3>' . PHP_EOL;
174 174
 
175 175
 		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
176 176
 
177
-		foreach ( $bank_info as $key => $data ) {
177
+		foreach ($bank_info as $key => $data) {
178 178
 
179
-			$key   = sanitize_html_class( $key );
180
-			$label = wp_kses_post( $data['label'] );
181
-			$value = wp_kses_post( wptexturize( $data['value'] ) );
179
+			$key   = sanitize_html_class($key);
180
+			$label = wp_kses_post($data['label']);
181
+			$value = wp_kses_post(wptexturize($data['value']));
182 182
 
183 183
 			echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL;
184 184
 		}
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 */
195 195
 	public function get_country_locale() {
196 196
 
197
-		if ( empty( $this->locale ) ) {
197
+		if (empty($this->locale)) {
198 198
 
199 199
 			// Locale information to be used - only those that are not 'Sort Code'.
200 200
 			$this->locale = apply_filters(
@@ -202,42 +202,42 @@  discard block
 block discarded – undo
202 202
 				array(
203 203
 					'AU' => array(
204 204
 						'sortcode' => array(
205
-							'label' => __( 'BSB', 'invoicing' ),
205
+							'label' => __('BSB', 'invoicing'),
206 206
 						),
207 207
 					),
208 208
 					'CA' => array(
209 209
 						'sortcode' => array(
210
-							'label' => __( 'Bank transit number', 'invoicing' ),
210
+							'label' => __('Bank transit number', 'invoicing'),
211 211
 						),
212 212
 					),
213 213
 					'IN' => array(
214 214
 						'sortcode' => array(
215
-							'label' => __( 'IFSC', 'invoicing' ),
215
+							'label' => __('IFSC', 'invoicing'),
216 216
 						),
217 217
 					),
218 218
 					'IT' => array(
219 219
 						'sortcode' => array(
220
-							'label' => __( 'Branch sort', 'invoicing' ),
220
+							'label' => __('Branch sort', 'invoicing'),
221 221
 						),
222 222
 					),
223 223
 					'NZ' => array(
224 224
 						'sortcode' => array(
225
-							'label' => __( 'Bank code', 'invoicing' ),
225
+							'label' => __('Bank code', 'invoicing'),
226 226
 						),
227 227
 					),
228 228
 					'SE' => array(
229 229
 						'sortcode' => array(
230
-							'label' => __( 'Bank code', 'invoicing' ),
230
+							'label' => __('Bank code', 'invoicing'),
231 231
 						),
232 232
 					),
233 233
 					'US' => array(
234 234
 						'sortcode' => array(
235
-							'label' => __( 'Routing number', 'invoicing' ),
235
+							'label' => __('Routing number', 'invoicing'),
236 236
 						),
237 237
 					),
238 238
 					'ZA' => array(
239 239
 						'sortcode' => array(
240
-							'label' => __( 'Branch code', 'invoicing' ),
240
+							'label' => __('Branch code', 'invoicing'),
241 241
 						),
242 242
 					),
243 243
 				)
@@ -254,51 +254,51 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @param array $admin_settings
256 256
 	 */
257
-	public function admin_settings( $admin_settings ) {
257
+	public function admin_settings($admin_settings) {
258 258
 
259
-        $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
260
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
259
+        $admin_settings['bank_transfer_desc']['std'] = __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing');
260
+		$admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing');
261 261
 
262
-		$locale  = $this->get_country_locale();
262
+		$locale = $this->get_country_locale();
263 263
 
264 264
 		// Get sortcode label in the $locale array and use appropriate one.
265 265
 		$country  = wpinv_default_billing_country();
266
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
266
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
267 267
 
268 268
 		$admin_settings['bank_transfer_ac_name'] = array(
269 269
             'type' => 'text',
270 270
             'id'   => 'bank_transfer_ac_name',
271
-            'name' => __( 'Account Name', 'invoicing' ),
271
+            'name' => __('Account Name', 'invoicing'),
272 272
 		);
273 273
 
274 274
 		$admin_settings['bank_transfer_ac_no'] = array(
275 275
             'type' => 'text',
276 276
             'id'   => 'bank_transfer_ac_no',
277
-            'name' => __( 'Account Number', 'invoicing' ),
277
+            'name' => __('Account Number', 'invoicing'),
278 278
 		);
279 279
 
280 280
 		$admin_settings['bank_transfer_bank_name'] = array(
281 281
             'type' => 'text',
282 282
             'id'   => 'bank_transfer_bank_name',
283
-            'name' => __( 'Bank Name', 'invoicing' ),
283
+            'name' => __('Bank Name', 'invoicing'),
284 284
 		);
285 285
 
286 286
 		$admin_settings['bank_transfer_ifsc'] = array(
287 287
             'type' => 'text',
288 288
             'id'   => 'bank_transfer_ifsc',
289
-            'name' => __( 'IFSC Code', 'invoicing' ),
289
+            'name' => __('IFSC Code', 'invoicing'),
290 290
 		);
291 291
 
292 292
 		$admin_settings['bank_transfer_iban'] = array(
293 293
             'type' => 'text',
294 294
             'id'   => 'bank_transfer_iban',
295
-            'name' => __( 'IBAN', 'invoicing' ),
295
+            'name' => __('IBAN', 'invoicing'),
296 296
 		);
297 297
 
298 298
 		$admin_settings['bank_transfer_bic'] = array(
299 299
             'type' => 'text',
300 300
             'id'   => 'bank_transfer_bic',
301
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
301
+            'name' => __('BIC/Swift Code', 'invoicing'),
302 302
 		);
303 303
 
304 304
 		$admin_settings['bank_transfer_sort_code'] = array(
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
 
310 310
 		$admin_settings['bank_transfer_info'] = array(
311 311
             'id'   => 'bank_transfer_info',
312
-            'name' => __( 'Instructions', 'invoicing' ),
313
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
312
+            'name' => __('Instructions', 'invoicing'),
313
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
314 314
             'type' => 'textarea',
315
-            'std'  => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ),
315
+            'std'  => __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'),
316 316
             'cols' => 50,
317 317
             'rows' => 5
318 318
         );
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 	 * @param GetPaid_Form_Item[] $items
328 328
 	 * @return WPInv_Invoice
329 329
 	 */
330
-	public function process_addons( $invoice, $items ) {
330
+	public function process_addons($invoice, $items) {
331 331
 
332
-        foreach ( $items as $item ) {
333
-            $invoice->add_item( $item );
332
+        foreach ($items as $item) {
333
+            $invoice->add_item($item);
334 334
         }
335 335
 
336 336
         $invoice->recalculate_total();
@@ -343,10 +343,10 @@  discard block
 block discarded – undo
343 343
 	 *
344 344
      * @param WPInv_Subscription $subscription
345 345
 	 */
346
-	public function maybe_renew_subscription( $subscription ) {
346
+	public function maybe_renew_subscription($subscription) {
347 347
 
348 348
         // Ensure its our subscription && it's active.
349
-        if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
349
+        if ($this->id == $subscription->get_gateway() && $subscription->has_status('active trialling')) {
350 350
 			$subscription->create_payment();
351 351
         }
352 352
 
@@ -358,30 +358,30 @@  discard block
 block discarded – undo
358 358
 	 *
359 359
      * @param WPInv_Invoice $invoice
360 360
 	 */
361
-	public function invoice_paid( $invoice ) {
361
+	public function invoice_paid($invoice) {
362 362
 
363 363
 		// Abort if not paid by bank transfer.
364
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
364
+		if ($this->id !== $invoice->get_gateway() || !$invoice->is_recurring()) {
365 365
 			return;
366 366
 		}
367 367
 
368 368
 		// Is it a parent payment?
369
-		if ( 0 == $invoice->get_parent_id() ) {
369
+		if (0 == $invoice->get_parent_id()) {
370 370
 
371 371
 			// (Maybe) activate subscriptions.
372
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
372
+			$subscriptions = getpaid_get_invoice_subscriptions($invoice);
373 373
 
374
-			if ( ! empty( $subscriptions ) ) {
375
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
374
+			if (!empty($subscriptions)) {
375
+				$subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
376 376
 
377
-				foreach ( $subscriptions as $subscription ) {
378
-					if ( $subscription->exists() ) {
379
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
380
-						$expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
377
+				foreach ($subscriptions as $subscription) {
378
+					if ($subscription->exists()) {
379
+						$duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
380
+						$expiry   = date('Y-m-d H:i:s', (current_time('timestamp') + $duration));
381 381
 
382
-						$subscription->set_next_renewal_date( $expiry );
383
-						$subscription->set_date_created( current_time( 'mysql' ) );
384
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
382
+						$subscription->set_next_renewal_date($expiry);
383
+						$subscription->set_date_created(current_time('mysql'));
384
+						$subscription->set_profile_id('bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id());
385 385
 						$subscription->activate();
386 386
 					}
387 387
 				}
@@ -390,11 +390,11 @@  discard block
 block discarded – undo
390 390
 
391 391
 		} else {
392 392
 
393
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
393
+			$subscription = getpaid_get_subscription($invoice->get_subscription_id());
394 394
 
395 395
 			// Renew the subscription.
396
-			if ( $subscription && $subscription->exists() ) {
397
-				$subscription->add_payment( array(), $invoice );
396
+			if ($subscription && $subscription->exists()) {
397
+				$subscription->add_payment(array(), $invoice);
398 398
 				$subscription->renew();
399 399
 			}
400 400
 
Please login to merge, or discard this patch.
includes/class-wpinv.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -436,7 +436,7 @@
 block discarded – undo
436 436
 
437 437
 		if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
438 438
 			// don't initiate in these conditions.
439
-		}else{
439
+		} else{
440 440
 
441 441
 			// Only load allowed widgets.
442 442
 			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
Please login to merge, or discard this patch.
Indentation   +567 added lines, -567 removed lines patch added patch discarded remove patch
@@ -14,619 +14,619 @@
 block discarded – undo
14 14
  */
15 15
 class WPInv_Plugin {
16 16
 
17
-	/**
18
-	 * GetPaid version.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	public $version;
23
-
24
-	/**
25
-	 * Data container.
26
-	 *
27
-	 * @var array
28
-	 */
29
-	protected $data = array();
30
-
31
-	/**
32
-	 * Form elements instance.
33
-	 *
34
-	 * @var WPInv_Payment_Form_Elements
35
-	 */
36
-	public $form_elements;
37
-
38
-	/**
39
-	 * @var array An array of payment gateways.
40
-	 */
41
-	public $gateways;
42
-
43
-	/**
44
-	 * Class constructor.
45
-	 */
46
-	public function __construct() {
47
-		$this->define_constants();
48
-		$this->includes();
49
-		$this->init_hooks();
50
-		$this->set_properties();
51
-	}
52
-
53
-	/**
54
-	 * Sets a custom data property.
55
-	 *
56
-	 * @param string $prop The prop to set.
57
-	 * @param mixed $value The value to retrieve.
58
-	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
61
-	}
62
-
63
-	/**
64
-	 * Gets a custom data property.
65
-	 *
66
-	 * @param string $prop The prop to set.
67
-	 * @return mixed The value.
68
-	 */
69
-	public function get( $prop ) {
70
-
71
-		if ( isset( $this->data[ $prop ] ) ) {
72
-			return $this->data[ $prop ];
73
-		}
74
-
75
-		return null;
76
-	}
77
-
78
-	/**
79
-	 * Define class properties.
80
-	 */
81
-	public function set_properties() {
82
-
83
-		// Sessions.
84
-		$this->set( 'session', new WPInv_Session_Handler() );
85
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
86
-		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87
-
88
-		// Init other objects.
89
-		$this->set( 'session', new WPInv_Session_Handler() );
90
-		$this->set( 'notes', new WPInv_Notes() );
91
-		$this->set( 'api', new WPInv_API() );
92
-		$this->set( 'post_types', new GetPaid_Post_Types() );
93
-		$this->set( 'template', new GetPaid_Template() );
94
-		$this->set( 'admin', new GetPaid_Admin() );
95
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
96
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
97
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
98
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
99
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
100
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
101
-
102
-	}
103
-
104
-	 /**
105
-	 * Define plugin constants.
106
-	 */
107
-	public function define_constants() {
108
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
109
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
110
-		$this->version = WPINV_VERSION;
111
-	}
112
-
113
-	/**
114
-	 * Hook into actions and filters.
115
-	 *
116
-	 * @since 1.0.19
117
-	 */
118
-	protected function init_hooks() {
119
-		/* Internationalize the text strings used. */
120
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
121
-
122
-		// Init the plugin after WordPress inits.
123
-		add_action( 'init', array( $this, 'init' ), 1 );
124
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
125
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
126
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
127
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
128
-		add_action( 'wp_footer', array( $this, 'wp_footer' ) );
129
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
130
-		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
131
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
132
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
133
-
134
-		add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
17
+    /**
18
+     * GetPaid version.
19
+     *
20
+     * @var string
21
+     */
22
+    public $version;
23
+
24
+    /**
25
+     * Data container.
26
+     *
27
+     * @var array
28
+     */
29
+    protected $data = array();
30
+
31
+    /**
32
+     * Form elements instance.
33
+     *
34
+     * @var WPInv_Payment_Form_Elements
35
+     */
36
+    public $form_elements;
37
+
38
+    /**
39
+     * @var array An array of payment gateways.
40
+     */
41
+    public $gateways;
42
+
43
+    /**
44
+     * Class constructor.
45
+     */
46
+    public function __construct() {
47
+        $this->define_constants();
48
+        $this->includes();
49
+        $this->init_hooks();
50
+        $this->set_properties();
51
+    }
52
+
53
+    /**
54
+     * Sets a custom data property.
55
+     *
56
+     * @param string $prop The prop to set.
57
+     * @param mixed $value The value to retrieve.
58
+     */
59
+    public function set( $prop, $value ) {
60
+        $this->data[ $prop ] = $value;
61
+    }
62
+
63
+    /**
64
+     * Gets a custom data property.
65
+     *
66
+     * @param string $prop The prop to set.
67
+     * @return mixed The value.
68
+     */
69
+    public function get( $prop ) {
70
+
71
+        if ( isset( $this->data[ $prop ] ) ) {
72
+            return $this->data[ $prop ];
73
+        }
74
+
75
+        return null;
76
+    }
77
+
78
+    /**
79
+     * Define class properties.
80
+     */
81
+    public function set_properties() {
82
+
83
+        // Sessions.
84
+        $this->set( 'session', new WPInv_Session_Handler() );
85
+        $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
86
+        $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87
+
88
+        // Init other objects.
89
+        $this->set( 'session', new WPInv_Session_Handler() );
90
+        $this->set( 'notes', new WPInv_Notes() );
91
+        $this->set( 'api', new WPInv_API() );
92
+        $this->set( 'post_types', new GetPaid_Post_Types() );
93
+        $this->set( 'template', new GetPaid_Template() );
94
+        $this->set( 'admin', new GetPaid_Admin() );
95
+        $this->set( 'subscriptions', new WPInv_Subscriptions() );
96
+        $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
97
+        $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
98
+        $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
99
+        $this->set( 'payment_forms', new GetPaid_Payment_Forms() );
100
+        $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
101
+
102
+    }
103
+
104
+        /**
105
+         * Define plugin constants.
106
+         */
107
+    public function define_constants() {
108
+        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
109
+        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
110
+        $this->version = WPINV_VERSION;
111
+    }
112
+
113
+    /**
114
+     * Hook into actions and filters.
115
+     *
116
+     * @since 1.0.19
117
+     */
118
+    protected function init_hooks() {
119
+        /* Internationalize the text strings used. */
120
+        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
121
+
122
+        // Init the plugin after WordPress inits.
123
+        add_action( 'init', array( $this, 'init' ), 1 );
124
+        add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
125
+        add_action( 'init', array( $this, 'wpinv_actions' ) );
126
+        add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
127
+        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
128
+        add_action( 'wp_footer', array( $this, 'wp_footer' ) );
129
+        add_action( 'wp_head', array( $this, 'wp_head' ) );
130
+        add_action( 'widgets_init', array( $this, 'register_widgets' ) );
131
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
132
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
133
+
134
+        add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
135 135
         add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
136
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
137
-
138
-		// Fires after registering actions.
139
-		do_action( 'wpinv_actions', $this );
140
-		do_action( 'getpaid_actions', $this );
141
-
142
-	}
143
-
144
-	public function plugins_loaded() {
145
-		/* Internationalize the text strings used. */
146
-		$this->load_textdomain();
147
-
148
-		do_action( 'wpinv_loaded' );
149
-
150
-		// Fix oxygen page builder conflict
151
-		if ( function_exists( 'ct_css_output' ) ) {
152
-			wpinv_oxygen_fix_conflict();
153
-		}
154
-	}
155
-
156
-	/**
157
-	 * Load Localisation files.
158
-	 *
159
-	 * Note: the first-loaded translation file overrides any following ones if the same translation is present.
160
-	 *
161
-	 * Locales found in:
162
-	 *      - WP_LANG_DIR/plugins/invoicing-LOCALE.mo
163
-	 *      - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo
164
-	 *
165
-	 * @since 1.0.0
166
-	 */
167
-	public function load_textdomain() {
168
-
169
-		load_plugin_textdomain(
170
-			'invoicing',
171
-			false,
172
-			plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/'
173
-		);
174
-
175
-	}
176
-
177
-	/**
178
-	 * Include required core files used in admin and on the frontend.
179
-	 */
180
-	public function includes() {
181
-
182
-		// Start with the settings.
183
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
184
-
185
-		// Packages/libraries.
186
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
187
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
188
-
189
-		// Load functions.
190
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
191
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
192
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
193
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
195
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
196
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
197
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
199
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
200
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
205
-
206
-		// Register autoloader.
207
-		try {
208
-			spl_autoload_register( array( $this, 'autoload' ), true );
209
-		} catch ( Exception $e ) {
210
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
211
-		}
212
-
213
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
216
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
217
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
218
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
219
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
220
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
221
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
222
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
234
-
235
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
236
-			GetPaid_Post_Types_Admin::init();
237
-
238
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
239
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
240
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
241
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
242
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
243
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
244
-			// load the user class only on the users.php page
245
-			global $pagenow;
246
-			if($pagenow=='users.php'){
247
-				new WPInv_Admin_Users();
248
-			}
249
-		}
250
-
251
-		// Register cli commands
252
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
253
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
254
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
255
-		}
256
-
257
-	}
258
-
259
-	/**
260
-	 * Class autoloader
261
-	 *
262
-	 * @param       string $class_name The name of the class to load.
263
-	 * @access      public
264
-	 * @since       1.0.19
265
-	 * @return      void
266
-	 */
267
-	public function autoload( $class_name ) {
268
-
269
-		// Normalize the class name...
270
-		$class_name  = strtolower( $class_name );
271
-
272
-		// ... and make sure it is our class.
273
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
274
-			return;
275
-		}
276
-
277
-		// Next, prepare the file name from the class.
278
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
279
-
280
-		// Base path of the classes.
281
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
282
-
283
-		// And an array of possible locations in order of importance.
284
-		$locations = array(
285
-			"$plugin_path/includes",
286
-			"$plugin_path/includes/data-stores",
287
-			"$plugin_path/includes/gateways",
288
-			"$plugin_path/includes/payments",
289
-			"$plugin_path/includes/geolocation",
290
-			"$plugin_path/includes/reports",
291
-			"$plugin_path/includes/api",
292
-			"$plugin_path/includes/admin",
293
-			"$plugin_path/includes/admin/meta-boxes",
294
-		);
295
-
296
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
297
-
298
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
299
-				include trailingslashit( $location ) . $file_name;
300
-				break;
301
-			}
302
-
303
-		}
304
-
305
-	}
306
-
307
-	/**
308
-	 * Inits hooks etc.
309
-	 */
310
-	public function init() {
311
-
312
-		// Fires before getpaid inits.
313
-		do_action( 'before_getpaid_init', $this );
314
-
315
-		// Maybe upgrade.
316
-		$this->maybe_upgrade_database();
317
-
318
-		// Load default gateways.
319
-		$gateways = apply_filters(
320
-			'getpaid_default_gateways',
321
-			array(
322
-				'manual'        => 'GetPaid_Manual_Gateway',
323
-				'paypal'        => 'GetPaid_Paypal_Gateway',
324
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
325
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
326
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
327
-			)
328
-		);
329
-
330
-		foreach ( $gateways as $id => $class ) {
331
-			$this->gateways[ $id ] = new $class();
332
-		}
333
-
334
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
335
-			GetPaid_Installer::rename_gateways_label();
336
-			update_option( 'wpinv_renamed_gateways', 'yes' );
337
-		}
338
-
339
-		// Fires after getpaid inits.
340
-		do_action( 'getpaid_init', $this );
341
-
342
-	}
343
-
344
-	/**
345
-	 * Checks if this is an IPN request and processes it.
346
-	 */
347
-	public function maybe_process_ipn() {
348
-
349
-		// Ensure that this is an IPN request.
350
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
351
-			return;
352
-		}
353
-
354
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
355
-
356
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
357
-		do_action( "wpinv_verify_{$gateway}_ipn" );
358
-		exit;
359
-
360
-	}
361
-
362
-	public function enqueue_scripts() {
363
-
364
-		// Fires before adding scripts.
365
-		do_action( 'getpaid_enqueue_scripts' );
366
-
367
-		$localize                         = array();
368
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
369
-		$localize['thousands']            = wpinv_thousands_separator();
370
-		$localize['decimals']             = wpinv_decimal_separator();
371
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
372
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
373
-		$localize['UseTaxes']             = wpinv_use_taxes();
374
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
375
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
376
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
377
-
378
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
379
-
380
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
381
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ),  $version, true );
382
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
383
-	}
384
-
385
-	public function wpinv_actions() {
386
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
387
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
388
-		}
389
-
390
-		if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
391
-			include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
392
-		}
393
-	}
136
+        add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
137
+
138
+        // Fires after registering actions.
139
+        do_action( 'wpinv_actions', $this );
140
+        do_action( 'getpaid_actions', $this );
141
+
142
+    }
143
+
144
+    public function plugins_loaded() {
145
+        /* Internationalize the text strings used. */
146
+        $this->load_textdomain();
147
+
148
+        do_action( 'wpinv_loaded' );
149
+
150
+        // Fix oxygen page builder conflict
151
+        if ( function_exists( 'ct_css_output' ) ) {
152
+            wpinv_oxygen_fix_conflict();
153
+        }
154
+    }
155
+
156
+    /**
157
+     * Load Localisation files.
158
+     *
159
+     * Note: the first-loaded translation file overrides any following ones if the same translation is present.
160
+     *
161
+     * Locales found in:
162
+     *      - WP_LANG_DIR/plugins/invoicing-LOCALE.mo
163
+     *      - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo
164
+     *
165
+     * @since 1.0.0
166
+     */
167
+    public function load_textdomain() {
168
+
169
+        load_plugin_textdomain(
170
+            'invoicing',
171
+            false,
172
+            plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/'
173
+        );
174
+
175
+    }
176
+
177
+    /**
178
+     * Include required core files used in admin and on the frontend.
179
+     */
180
+    public function includes() {
181
+
182
+        // Start with the settings.
183
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
184
+
185
+        // Packages/libraries.
186
+        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
187
+        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
188
+
189
+        // Load functions.
190
+        require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
191
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
192
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
193
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
194
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
195
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
196
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
197
+        require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
198
+        require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
199
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
200
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
201
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
202
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
203
+        require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' );
204
+        require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
205
+
206
+        // Register autoloader.
207
+        try {
208
+            spl_autoload_register( array( $this, 'autoload' ), true );
209
+        } catch ( Exception $e ) {
210
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
211
+        }
212
+
213
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
214
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
215
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
216
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
217
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
218
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
219
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
220
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
221
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
222
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
223
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
224
+        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
225
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
226
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
227
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
228
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
229
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
230
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
231
+        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
232
+        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
233
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
234
+
235
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
236
+            GetPaid_Post_Types_Admin::init();
237
+
238
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
239
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
240
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
241
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
242
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
243
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
244
+            // load the user class only on the users.php page
245
+            global $pagenow;
246
+            if($pagenow=='users.php'){
247
+                new WPInv_Admin_Users();
248
+            }
249
+        }
250
+
251
+        // Register cli commands
252
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
253
+            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
254
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
255
+        }
256
+
257
+    }
258
+
259
+    /**
260
+     * Class autoloader
261
+     *
262
+     * @param       string $class_name The name of the class to load.
263
+     * @access      public
264
+     * @since       1.0.19
265
+     * @return      void
266
+     */
267
+    public function autoload( $class_name ) {
268
+
269
+        // Normalize the class name...
270
+        $class_name  = strtolower( $class_name );
271
+
272
+        // ... and make sure it is our class.
273
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
274
+            return;
275
+        }
276
+
277
+        // Next, prepare the file name from the class.
278
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
279
+
280
+        // Base path of the classes.
281
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
282
+
283
+        // And an array of possible locations in order of importance.
284
+        $locations = array(
285
+            "$plugin_path/includes",
286
+            "$plugin_path/includes/data-stores",
287
+            "$plugin_path/includes/gateways",
288
+            "$plugin_path/includes/payments",
289
+            "$plugin_path/includes/geolocation",
290
+            "$plugin_path/includes/reports",
291
+            "$plugin_path/includes/api",
292
+            "$plugin_path/includes/admin",
293
+            "$plugin_path/includes/admin/meta-boxes",
294
+        );
295
+
296
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
297
+
298
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
299
+                include trailingslashit( $location ) . $file_name;
300
+                break;
301
+            }
302
+
303
+        }
304
+
305
+    }
306
+
307
+    /**
308
+     * Inits hooks etc.
309
+     */
310
+    public function init() {
311
+
312
+        // Fires before getpaid inits.
313
+        do_action( 'before_getpaid_init', $this );
314
+
315
+        // Maybe upgrade.
316
+        $this->maybe_upgrade_database();
317
+
318
+        // Load default gateways.
319
+        $gateways = apply_filters(
320
+            'getpaid_default_gateways',
321
+            array(
322
+                'manual'        => 'GetPaid_Manual_Gateway',
323
+                'paypal'        => 'GetPaid_Paypal_Gateway',
324
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
325
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
326
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
327
+            )
328
+        );
329
+
330
+        foreach ( $gateways as $id => $class ) {
331
+            $this->gateways[ $id ] = new $class();
332
+        }
333
+
334
+        if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
335
+            GetPaid_Installer::rename_gateways_label();
336
+            update_option( 'wpinv_renamed_gateways', 'yes' );
337
+        }
338
+
339
+        // Fires after getpaid inits.
340
+        do_action( 'getpaid_init', $this );
394 341
 
395
-	/**
342
+    }
343
+
344
+    /**
345
+     * Checks if this is an IPN request and processes it.
346
+     */
347
+    public function maybe_process_ipn() {
348
+
349
+        // Ensure that this is an IPN request.
350
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
351
+            return;
352
+        }
353
+
354
+        $gateway = wpinv_clean( $_GET['wpi-gateway'] );
355
+
356
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
357
+        do_action( "wpinv_verify_{$gateway}_ipn" );
358
+        exit;
359
+
360
+    }
361
+
362
+    public function enqueue_scripts() {
363
+
364
+        // Fires before adding scripts.
365
+        do_action( 'getpaid_enqueue_scripts' );
366
+
367
+        $localize                         = array();
368
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
369
+        $localize['thousands']            = wpinv_thousands_separator();
370
+        $localize['decimals']             = wpinv_decimal_separator();
371
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
372
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
373
+        $localize['UseTaxes']             = wpinv_use_taxes();
374
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
375
+        $localize['loading']              = __( 'Loading...', 'invoicing' );
376
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
377
+
378
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
379
+
380
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
381
+        wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ),  $version, true );
382
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
383
+    }
384
+
385
+    public function wpinv_actions() {
386
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
387
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
388
+        }
389
+
390
+        if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
391
+            include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
392
+        }
393
+    }
394
+
395
+    /**
396 396
      * Fires an action after verifying that a user can fire them.
397
-	 *
398
-	 * Note: If the action is on an invoice, subscription etc, esure that the
399
-	 * current user owns the invoice/subscription.
397
+     *
398
+     * Note: If the action is on an invoice, subscription etc, esure that the
399
+     * current user owns the invoice/subscription.
400 400
      */
401 401
     public function maybe_do_authenticated_action() {
402 402
 
403
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
403
+        if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
404
+
405
+            $key  = sanitize_key( $_REQUEST['getpaid-action'] );
406
+            $data = wp_unslash( $_REQUEST );
407
+            if ( is_user_logged_in() ) {
408
+                do_action( "getpaid_authenticated_action_$key", $data );
409
+            }
410
+
411
+            do_action( "getpaid_unauthenticated_action_$key", $data );
412
+
413
+        }
414
+
415
+    }
416
+
417
+    public function pre_get_posts( $wp_query ) {
418
+
419
+        if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
420
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
421
+        }
422
+
423
+        return $wp_query;
424
+    }
425
+
426
+    /**
427
+     * Register widgets
428
+     *
429
+     */
430
+    public function register_widgets() {
431
+        global $pagenow;
432
+
433
+        // Currently, UX Builder does not work particulaly well with SuperDuper.
434
+        // So we disable our widgets when editing a page with UX Builder.
435
+        if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
436
+            return;
437
+        }
438
+
439
+        $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array();
440
+
441
+        if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
442
+            // don't initiate in these conditions.
443
+        }else{
444
+
445
+            // Only load allowed widgets.
446
+            $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
447
+            $widgets = apply_filters(
448
+                'getpaid_widget_classes',
449
+                array(
450
+                    'WPInv_Checkout_Widget',
451
+                    'WPInv_History_Widget',
452
+                    'WPInv_Receipt_Widget',
453
+                    'WPInv_Subscriptions_Widget',
454
+                    'WPInv_Buy_Item_Widget',
455
+                    'WPInv_Messages_Widget',
456
+                    'WPInv_GetPaid_Widget'
457
+                )
458
+            );
459
+
460
+            // For each widget...
461
+            foreach ( $widgets as $widget ) {
462
+
463
+                // Abort early if it is excluded for this page.
464
+                if ( in_array( $widget, $exclude ) ) {
465
+                    continue;
466
+                }
467
+
468
+                // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
469
+                if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
470
+                    register_widget( $widget );
471
+                } else {
472
+                    new $widget();
473
+                }
474
+
475
+            }
476
+
477
+        }
478
+
479
+    }
480
+
481
+    /**
482
+     * Upgrades the database.
483
+     *
484
+     * @since 2.0.2
485
+     */
486
+    public function maybe_upgrade_database() {
404 487
 
405
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
406
-			$data = wp_unslash( $_REQUEST );
407
-			if ( is_user_logged_in() ) {
408
-				do_action( "getpaid_authenticated_action_$key", $data );
409
-			}
488
+        $wpi_version = get_option( 'wpinv_version', 0 );
410 489
 
411
-			do_action( "getpaid_unauthenticated_action_$key", $data );
490
+        if ( $wpi_version == WPINV_VERSION ) {
491
+            return;
492
+        }
412 493
 
413
-		}
494
+        $installer = new GetPaid_Installer();
495
+
496
+        if ( empty( $wpi_version ) ) {
497
+            return $installer->upgrade_db( 0 );
498
+        }
499
+
500
+        $upgrades  = array(
501
+            '0.0.5' => '004',
502
+            '1.0.3' => '102',
503
+            '2.0.0' => '118',
504
+            '2.0.8' => '207',
505
+        );
506
+
507
+        foreach ( $upgrades as $key => $method ) {
508
+
509
+            if ( version_compare( $wpi_version, $key, '<' ) ) {
510
+                return $installer->upgrade_db( $method );
511
+            }
512
+
513
+        }
414 514
 
415 515
     }
416 516
 
417
-	public function pre_get_posts( $wp_query ) {
517
+    /**
518
+     * Flushes the permalinks if needed.
519
+     *
520
+     * @since 2.0.8
521
+     */
522
+    public function maybe_flush_permalinks() {
418 523
 
419
-		if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
420
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
421
-		}
422
-
423
-		return $wp_query;
424
-	}
524
+        $flush = get_option( 'wpinv_flush_permalinks', 0 );
425 525
 
426
-	/**
427
-	 * Register widgets
428
-	 *
429
-	 */
430
-	public function register_widgets() {
431
-		global $pagenow;
526
+        if ( ! empty( $flush ) ) {
527
+            flush_rewrite_rules();
528
+            delete_option( 'wpinv_flush_permalinks' );
529
+        }
432 530
 
433
-		// Currently, UX Builder does not work particulaly well with SuperDuper.
434
-		// So we disable our widgets when editing a page with UX Builder.
435
-		if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
436
-			return;
437
-		}
438
-
439
-		$block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array();
440
-
441
-		if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
442
-			// don't initiate in these conditions.
443
-		}else{
444
-
445
-			// Only load allowed widgets.
446
-			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
447
-			$widgets = apply_filters(
448
-				'getpaid_widget_classes',
449
-				array(
450
-					'WPInv_Checkout_Widget',
451
-					'WPInv_History_Widget',
452
-					'WPInv_Receipt_Widget',
453
-					'WPInv_Subscriptions_Widget',
454
-					'WPInv_Buy_Item_Widget',
455
-					'WPInv_Messages_Widget',
456
-					'WPInv_GetPaid_Widget'
457
-				)
458
-			);
459
-
460
-			// For each widget...
461
-			foreach ( $widgets as $widget ) {
531
+    }
462 532
 
463
-				// Abort early if it is excluded for this page.
464
-				if ( in_array( $widget, $exclude ) ) {
465
-					continue;
466
-				}
533
+    /**
534
+     * Remove our pages from yoast sitemaps.
535
+     *
536
+     * @since 1.0.19
537
+     * @param int[] $excluded_posts_ids
538
+     */
539
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
467 540
 
468
-				// SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
469
-				if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
470
-					register_widget( $widget );
471
-				} else {
472
-					new $widget();
473
-				}
541
+        // Ensure that we have an array.
542
+        if ( ! is_array( $excluded_posts_ids ) ) {
543
+            $excluded_posts_ids = array();
544
+        }
474 545
 
475
-			}
546
+        // Prepare our pages.
547
+        $our_pages = array();
476 548
 
477
-		}
549
+        // Checkout page.
550
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
478 551
 
479
-	}
552
+        // Success page.
553
+        $our_pages[] = wpinv_get_option( 'success_page', false );
480 554
 
481
-	/**
482
-	 * Upgrades the database.
483
-	 *
484
-	 * @since 2.0.2
485
-	 */
486
-	public function maybe_upgrade_database() {
487
-
488
-		$wpi_version = get_option( 'wpinv_version', 0 );
489
-
490
-		if ( $wpi_version == WPINV_VERSION ) {
491
-			return;
492
-		}
493
-
494
-		$installer = new GetPaid_Installer();
495
-
496
-		if ( empty( $wpi_version ) ) {
497
-			return $installer->upgrade_db( 0 );
498
-		}
499
-
500
-		$upgrades  = array(
501
-			'0.0.5' => '004',
502
-			'1.0.3' => '102',
503
-			'2.0.0' => '118',
504
-			'2.0.8' => '207',
505
-		);
506
-
507
-		foreach ( $upgrades as $key => $method ) {
508
-
509
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
510
-				return $installer->upgrade_db( $method );
511
-			}
512
-
513
-		}
514
-
515
-	}
516
-
517
-	/**
518
-	 * Flushes the permalinks if needed.
519
-	 *
520
-	 * @since 2.0.8
521
-	 */
522
-	public function maybe_flush_permalinks() {
523
-
524
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
525
-
526
-		if ( ! empty( $flush ) ) {
527
-			flush_rewrite_rules();
528
-			delete_option( 'wpinv_flush_permalinks' );
529
-		}
530
-
531
-	}
532
-
533
-	/**
534
-	 * Remove our pages from yoast sitemaps.
535
-	 *
536
-	 * @since 1.0.19
537
-	 * @param int[] $excluded_posts_ids
538
-	 */
539
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
540
-
541
-		// Ensure that we have an array.
542
-		if ( ! is_array( $excluded_posts_ids ) ) {
543
-			$excluded_posts_ids = array();
544
-		}
545
-
546
-		// Prepare our pages.
547
-		$our_pages = array();
548
-
549
-		// Checkout page.
550
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
551
-
552
-		// Success page.
553
-		$our_pages[] = wpinv_get_option( 'success_page', false );
554
-
555
-		// Failure page.
556
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
555
+        // Failure page.
556
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
557 557
 
558
-		// History page.
559
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
558
+        // History page.
559
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
560 560
 
561
-		// Subscriptions page.
562
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
561
+        // Subscriptions page.
562
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
563 563
 
564
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
564
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
565 565
 
566
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
567
-		return array_unique( $excluded_posts_ids );
566
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
567
+        return array_unique( $excluded_posts_ids );
568 568
 
569
-	}
569
+    }
570 570
 
571
-	/**
572
-	 * Displays additional footer code.
573
-	 *
574
-	 * @since 2.0.0
575
-	 */
576
-	public function wp_footer() {
577
-		wpinv_get_template( 'frontend-footer.php' );
578
-	}
571
+    /**
572
+     * Displays additional footer code.
573
+     *
574
+     * @since 2.0.0
575
+     */
576
+    public function wp_footer() {
577
+        wpinv_get_template( 'frontend-footer.php' );
578
+    }
579 579
 
580
-	/**
581
-	 * Displays additional header code.
582
-	 *
583
-	 * @since 2.0.0
584
-	 */
585
-	public function wp_head() {
586
-		wpinv_get_template( 'frontend-head.php' );
587
-	}
580
+    /**
581
+     * Displays additional header code.
582
+     *
583
+     * @since 2.0.0
584
+     */
585
+    public function wp_head() {
586
+        wpinv_get_template( 'frontend-head.php' );
587
+    }
588 588
 
589
-	/**
590
-	 * Custom query vars.
591
-	 *
592
-	 */
593
-	public function custom_query_vars( $vars ) {
589
+    /**
590
+     * Custom query vars.
591
+     *
592
+     */
593
+    public function custom_query_vars( $vars ) {
594 594
         $vars[] = 'getpaid-ipn';
595 595
         return $vars;
596
-	}
596
+    }
597 597
 
598
-	/**
599
-	 * Add rewrite tags and rules.
600
-	 *
601
-	 */
602
-	public function add_rewrite_rule() {
598
+    /**
599
+     * Add rewrite tags and rules.
600
+     *
601
+     */
602
+    public function add_rewrite_rule() {
603 603
         $tag = 'getpaid-ipn';
604 604
         add_rewrite_tag( "%$tag%", '([^&]+)' );
605 605
         add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' );
606
-	}
606
+    }
607 607
 
608
-	/**
609
-	 * Processes non-query string ipns.
610
-	 *
611
-	 */
612
-	public function maybe_process_new_ipn( $query ) {
608
+    /**
609
+     * Processes non-query string ipns.
610
+     *
611
+     */
612
+    public function maybe_process_new_ipn( $query ) {
613 613
 
614 614
         if ( is_admin() || ! $query->is_main_query() ) {
615 615
             return;
616 616
         }
617 617
 
618
-		$gateway = get_query_var( 'getpaid-ipn' );
618
+        $gateway = get_query_var( 'getpaid-ipn' );
619 619
 
620 620
         if ( ! empty( $gateway ) ){
621 621
 
622
-			$gateway = sanitize_text_field( $gateway );
623
-			nocache_headers();
624
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
625
-			do_action( "wpinv_verify_{$gateway}_ipn" );
626
-			exit;
622
+            $gateway = sanitize_text_field( $gateway );
623
+            nocache_headers();
624
+            do_action( 'wpinv_verify_payment_ipn', $gateway );
625
+            do_action( "wpinv_verify_{$gateway}_ipn" );
626
+            exit;
627 627
 
628 628
         }
629 629
 
630
-	}
630
+    }
631 631
 
632 632
 }
Please login to merge, or discard this patch.
Spacing   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Main Invoicing class.
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param string $prop The prop to set.
57 57
 	 * @param mixed $value The value to retrieve.
58 58
 	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
59
+	public function set($prop, $value) {
60
+		$this->data[$prop] = $value;
61 61
 	}
62 62
 
63 63
 	/**
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 	 * @param string $prop The prop to set.
67 67
 	 * @return mixed The value.
68 68
 	 */
69
-	public function get( $prop ) {
69
+	public function get($prop) {
70 70
 
71
-		if ( isset( $this->data[ $prop ] ) ) {
72
-			return $this->data[ $prop ];
71
+		if (isset($this->data[$prop])) {
72
+			return $this->data[$prop];
73 73
 		}
74 74
 
75 75
 		return null;
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
 	public function set_properties() {
82 82
 
83 83
 		// Sessions.
84
-		$this->set( 'session', new WPInv_Session_Handler() );
85
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
84
+		$this->set('session', new WPInv_Session_Handler());
85
+		$GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility.
86 86
 		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87 87
 
88 88
 		// Init other objects.
89
-		$this->set( 'session', new WPInv_Session_Handler() );
90
-		$this->set( 'notes', new WPInv_Notes() );
91
-		$this->set( 'api', new WPInv_API() );
92
-		$this->set( 'post_types', new GetPaid_Post_Types() );
93
-		$this->set( 'template', new GetPaid_Template() );
94
-		$this->set( 'admin', new GetPaid_Admin() );
95
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
96
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
97
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
98
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
99
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
100
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
89
+		$this->set('session', new WPInv_Session_Handler());
90
+		$this->set('notes', new WPInv_Notes());
91
+		$this->set('api', new WPInv_API());
92
+		$this->set('post_types', new GetPaid_Post_Types());
93
+		$this->set('template', new GetPaid_Template());
94
+		$this->set('admin', new GetPaid_Admin());
95
+		$this->set('subscriptions', new WPInv_Subscriptions());
96
+		$this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails());
97
+		$this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails());
98
+		$this->set('daily_maintenace', new GetPaid_Daily_Maintenance());
99
+		$this->set('payment_forms', new GetPaid_Payment_Forms());
100
+		$this->set('maxmind', new GetPaid_MaxMind_Geolocation());
101 101
 
102 102
 	}
103 103
 
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 * Define plugin constants.
106 106
 	 */
107 107
 	public function define_constants() {
108
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
109
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
108
+		define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
109
+		define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
110 110
 		$this->version = WPINV_VERSION;
111 111
 	}
112 112
 
@@ -117,27 +117,27 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function init_hooks() {
119 119
 		/* Internationalize the text strings used. */
120
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
120
+		add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
121 121
 
122 122
 		// Init the plugin after WordPress inits.
123
-		add_action( 'init', array( $this, 'init' ), 1 );
124
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
125
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
126
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
127
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
128
-		add_action( 'wp_footer', array( $this, 'wp_footer' ) );
129
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
130
-		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
131
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
132
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
133
-
134
-		add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
135
-        add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
136
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
123
+		add_action('init', array($this, 'init'), 1);
124
+		add_action('init', array($this, 'maybe_process_ipn'), 10);
125
+		add_action('init', array($this, 'wpinv_actions'));
126
+		add_action('init', array($this, 'maybe_do_authenticated_action'), 100);
127
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11);
128
+		add_action('wp_footer', array($this, 'wp_footer'));
129
+		add_action('wp_head', array($this, 'wp_head'));
130
+		add_action('widgets_init', array($this, 'register_widgets'));
131
+		add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
132
+		add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
133
+
134
+		add_filter('query_vars', array($this, 'custom_query_vars'));
135
+        add_action('init', array($this, 'add_rewrite_rule'), 10, 0);
136
+		add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1);
137 137
 
138 138
 		// Fires after registering actions.
139
-		do_action( 'wpinv_actions', $this );
140
-		do_action( 'getpaid_actions', $this );
139
+		do_action('wpinv_actions', $this);
140
+		do_action('getpaid_actions', $this);
141 141
 
142 142
 	}
143 143
 
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 		/* Internationalize the text strings used. */
146 146
 		$this->load_textdomain();
147 147
 
148
-		do_action( 'wpinv_loaded' );
148
+		do_action('wpinv_loaded');
149 149
 
150 150
 		// Fix oxygen page builder conflict
151
-		if ( function_exists( 'ct_css_output' ) ) {
151
+		if (function_exists('ct_css_output')) {
152 152
 			wpinv_oxygen_fix_conflict();
153 153
 		}
154 154
 	}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		load_plugin_textdomain(
170 170
 			'invoicing',
171 171
 			false,
172
-			plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/'
172
+			plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/'
173 173
 		);
174 174
 
175 175
 	}
@@ -180,78 +180,78 @@  discard block
 block discarded – undo
180 180
 	public function includes() {
181 181
 
182 182
 		// Start with the settings.
183
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
183
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
184 184
 
185 185
 		// Packages/libraries.
186
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
187
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
186
+		require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
187
+		require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php');
188 188
 
189 189
 		// Load functions.
190
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
191
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
192
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
193
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
195
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
196
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
197
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
199
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
200
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
190
+		require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php');
191
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
192
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
193
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
194
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
195
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
196
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
197
+		require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php');
198
+		require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php');
199
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
200
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
201
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
202
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
203
+		require_once(WPINV_PLUGIN_DIR . 'includes/user-functions.php');
204
+		require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php');
205 205
 
206 206
 		// Register autoloader.
207 207
 		try {
208
-			spl_autoload_register( array( $this, 'autoload' ), true );
209
-		} catch ( Exception $e ) {
210
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
208
+			spl_autoload_register(array($this, 'autoload'), true);
209
+		} catch (Exception $e) {
210
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
211 211
 		}
212 212
 
213
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
216
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
217
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
218
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
219
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
220
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
221
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
222
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
234
-
235
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
213
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
214
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
215
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
216
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
217
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
218
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
219
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
220
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
221
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
222
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
223
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
224
+		require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
225
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
226
+		require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
227
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
228
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
229
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
230
+		require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
231
+		require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
232
+		require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
233
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
234
+
235
+		if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
236 236
 			GetPaid_Post_Types_Admin::init();
237 237
 
238
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
239
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
240
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
241
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
242
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
243
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
238
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
239
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
240
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
241
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
242
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
243
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php');
244 244
 			// load the user class only on the users.php page
245 245
 			global $pagenow;
246
-			if($pagenow=='users.php'){
246
+			if ($pagenow == 'users.php') {
247 247
 				new WPInv_Admin_Users();
248 248
 			}
249 249
 		}
250 250
 
251 251
 		// Register cli commands
252
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
253
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
254
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
252
+		if (defined('WP_CLI') && WP_CLI) {
253
+			require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
254
+			WP_CLI::add_command('invoicing', 'WPInv_CLI');
255 255
 		}
256 256
 
257 257
 	}
@@ -264,21 +264,21 @@  discard block
 block discarded – undo
264 264
 	 * @since       1.0.19
265 265
 	 * @return      void
266 266
 	 */
267
-	public function autoload( $class_name ) {
267
+	public function autoload($class_name) {
268 268
 
269 269
 		// Normalize the class name...
270
-		$class_name  = strtolower( $class_name );
270
+		$class_name = strtolower($class_name);
271 271
 
272 272
 		// ... and make sure it is our class.
273
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
273
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
274 274
 			return;
275 275
 		}
276 276
 
277 277
 		// Next, prepare the file name from the class.
278
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
278
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
279 279
 
280 280
 		// Base path of the classes.
281
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
281
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
282 282
 
283 283
 		// And an array of possible locations in order of importance.
284 284
 		$locations = array(
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 			"$plugin_path/includes/admin/meta-boxes",
294 294
 		);
295 295
 
296
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
296
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
297 297
 
298
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
299
-				include trailingslashit( $location ) . $file_name;
298
+			if (file_exists(trailingslashit($location) . $file_name)) {
299
+				include trailingslashit($location) . $file_name;
300 300
 				break;
301 301
 			}
302 302
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	public function init() {
311 311
 
312 312
 		// Fires before getpaid inits.
313
-		do_action( 'before_getpaid_init', $this );
313
+		do_action('before_getpaid_init', $this);
314 314
 
315 315
 		// Maybe upgrade.
316 316
 		$this->maybe_upgrade_database();
@@ -327,17 +327,17 @@  discard block
 block discarded – undo
327 327
 			)
328 328
 		);
329 329
 
330
-		foreach ( $gateways as $id => $class ) {
331
-			$this->gateways[ $id ] = new $class();
330
+		foreach ($gateways as $id => $class) {
331
+			$this->gateways[$id] = new $class();
332 332
 		}
333 333
 
334
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
334
+		if ('yes' != get_option('wpinv_renamed_gateways')) {
335 335
 			GetPaid_Installer::rename_gateways_label();
336
-			update_option( 'wpinv_renamed_gateways', 'yes' );
336
+			update_option('wpinv_renamed_gateways', 'yes');
337 337
 		}
338 338
 
339 339
 		// Fires after getpaid inits.
340
-		do_action( 'getpaid_init', $this );
340
+		do_action('getpaid_init', $this);
341 341
 
342 342
 	}
343 343
 
@@ -347,14 +347,14 @@  discard block
 block discarded – undo
347 347
 	public function maybe_process_ipn() {
348 348
 
349 349
 		// Ensure that this is an IPN request.
350
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
350
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
351 351
 			return;
352 352
 		}
353 353
 
354
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
354
+		$gateway = wpinv_clean($_GET['wpi-gateway']);
355 355
 
356
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
357
-		do_action( "wpinv_verify_{$gateway}_ipn" );
356
+		do_action('wpinv_verify_payment_ipn', $gateway);
357
+		do_action("wpinv_verify_{$gateway}_ipn");
358 358
 		exit;
359 359
 
360 360
 	}
@@ -362,33 +362,33 @@  discard block
 block discarded – undo
362 362
 	public function enqueue_scripts() {
363 363
 
364 364
 		// Fires before adding scripts.
365
-		do_action( 'getpaid_enqueue_scripts' );
365
+		do_action('getpaid_enqueue_scripts');
366 366
 
367 367
 		$localize                         = array();
368
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
368
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
369 369
 		$localize['thousands']            = wpinv_thousands_separator();
370 370
 		$localize['decimals']             = wpinv_decimal_separator();
371
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
372
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
371
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
372
+		$localize['txtComplete']          = __('Continue', 'invoicing');
373 373
 		$localize['UseTaxes']             = wpinv_use_taxes();
374
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
375
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
376
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
374
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
375
+		$localize['loading']              = __('Loading...', 'invoicing');
376
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
377 377
 
378
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
378
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
379 379
 
380
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
381
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ),  $version, true );
382
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
380
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
381
+		wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true);
382
+		wp_localize_script('wpinv-front-script', 'WPInv', $localize);
383 383
 	}
384 384
 
385 385
 	public function wpinv_actions() {
386
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
387
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
386
+		if (isset($_REQUEST['wpi_action'])) {
387
+			do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
388 388
 		}
389 389
 
390
-		if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
391
-			include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
390
+		if (defined('WP_ALL_IMPORT_ROOT_DIR')) {
391
+			include plugin_dir_path(__FILE__) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
392 392
 		}
393 393
 	}
394 394
 
@@ -400,24 +400,24 @@  discard block
 block discarded – undo
400 400
      */
401 401
     public function maybe_do_authenticated_action() {
402 402
 
403
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
403
+		if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
404 404
 
405
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
406
-			$data = wp_unslash( $_REQUEST );
407
-			if ( is_user_logged_in() ) {
408
-				do_action( "getpaid_authenticated_action_$key", $data );
405
+			$key  = sanitize_key($_REQUEST['getpaid-action']);
406
+			$data = wp_unslash($_REQUEST);
407
+			if (is_user_logged_in()) {
408
+				do_action("getpaid_authenticated_action_$key", $data);
409 409
 			}
410 410
 
411
-			do_action( "getpaid_unauthenticated_action_$key", $data );
411
+			do_action("getpaid_unauthenticated_action_$key", $data);
412 412
 
413 413
 		}
414 414
 
415 415
     }
416 416
 
417
-	public function pre_get_posts( $wp_query ) {
417
+	public function pre_get_posts($wp_query) {
418 418
 
419
-		if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
420
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
419
+		if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
420
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type']));
421 421
 		}
422 422
 
423 423
 		return $wp_query;
@@ -432,18 +432,18 @@  discard block
 block discarded – undo
432 432
 
433 433
 		// Currently, UX Builder does not work particulaly well with SuperDuper.
434 434
 		// So we disable our widgets when editing a page with UX Builder.
435
-		if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
435
+		if (function_exists('ux_builder_is_active') && ux_builder_is_active()) {
436 436
 			return;
437 437
 		}
438 438
 
439 439
 		$block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array();
440 440
 
441
-		if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
441
+		if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
442 442
 			// don't initiate in these conditions.
443
-		}else{
443
+		} else {
444 444
 
445 445
 			// Only load allowed widgets.
446
-			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
446
+			$exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array();
447 447
 			$widgets = apply_filters(
448 448
 				'getpaid_widget_classes',
449 449
 				array(
@@ -458,16 +458,16 @@  discard block
 block discarded – undo
458 458
 			);
459 459
 
460 460
 			// For each widget...
461
-			foreach ( $widgets as $widget ) {
461
+			foreach ($widgets as $widget) {
462 462
 
463 463
 				// Abort early if it is excluded for this page.
464
-				if ( in_array( $widget, $exclude ) ) {
464
+				if (in_array($widget, $exclude)) {
465 465
 					continue;
466 466
 				}
467 467
 
468 468
 				// SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
469
-				if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
470
-					register_widget( $widget );
469
+				if (is_subclass_of($widget, 'WP_Widget')) {
470
+					register_widget($widget);
471 471
 				} else {
472 472
 					new $widget();
473 473
 				}
@@ -485,29 +485,29 @@  discard block
 block discarded – undo
485 485
 	 */
486 486
 	public function maybe_upgrade_database() {
487 487
 
488
-		$wpi_version = get_option( 'wpinv_version', 0 );
488
+		$wpi_version = get_option('wpinv_version', 0);
489 489
 
490
-		if ( $wpi_version == WPINV_VERSION ) {
490
+		if ($wpi_version == WPINV_VERSION) {
491 491
 			return;
492 492
 		}
493 493
 
494 494
 		$installer = new GetPaid_Installer();
495 495
 
496
-		if ( empty( $wpi_version ) ) {
497
-			return $installer->upgrade_db( 0 );
496
+		if (empty($wpi_version)) {
497
+			return $installer->upgrade_db(0);
498 498
 		}
499 499
 
500
-		$upgrades  = array(
500
+		$upgrades = array(
501 501
 			'0.0.5' => '004',
502 502
 			'1.0.3' => '102',
503 503
 			'2.0.0' => '118',
504 504
 			'2.0.8' => '207',
505 505
 		);
506 506
 
507
-		foreach ( $upgrades as $key => $method ) {
507
+		foreach ($upgrades as $key => $method) {
508 508
 
509
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
510
-				return $installer->upgrade_db( $method );
509
+			if (version_compare($wpi_version, $key, '<')) {
510
+				return $installer->upgrade_db($method);
511 511
 			}
512 512
 
513 513
 		}
@@ -521,11 +521,11 @@  discard block
 block discarded – undo
521 521
 	 */
522 522
 	public function maybe_flush_permalinks() {
523 523
 
524
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
524
+		$flush = get_option('wpinv_flush_permalinks', 0);
525 525
 
526
-		if ( ! empty( $flush ) ) {
526
+		if (!empty($flush)) {
527 527
 			flush_rewrite_rules();
528
-			delete_option( 'wpinv_flush_permalinks' );
528
+			delete_option('wpinv_flush_permalinks');
529 529
 		}
530 530
 
531 531
 	}
@@ -536,10 +536,10 @@  discard block
 block discarded – undo
536 536
 	 * @since 1.0.19
537 537
 	 * @param int[] $excluded_posts_ids
538 538
 	 */
539
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
539
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
540 540
 
541 541
 		// Ensure that we have an array.
542
-		if ( ! is_array( $excluded_posts_ids ) ) {
542
+		if (!is_array($excluded_posts_ids)) {
543 543
 			$excluded_posts_ids = array();
544 544
 		}
545 545
 
@@ -547,24 +547,24 @@  discard block
 block discarded – undo
547 547
 		$our_pages = array();
548 548
 
549 549
 		// Checkout page.
550
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
550
+		$our_pages[] = wpinv_get_option('checkout_page', false);
551 551
 
552 552
 		// Success page.
553
-		$our_pages[] = wpinv_get_option( 'success_page', false );
553
+		$our_pages[] = wpinv_get_option('success_page', false);
554 554
 
555 555
 		// Failure page.
556
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
556
+		$our_pages[] = wpinv_get_option('failure_page', false);
557 557
 
558 558
 		// History page.
559
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
559
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
560 560
 
561 561
 		// Subscriptions page.
562
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
562
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
563 563
 
564
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
564
+		$our_pages   = array_map('intval', array_filter($our_pages));
565 565
 
566 566
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
567
-		return array_unique( $excluded_posts_ids );
567
+		return array_unique($excluded_posts_ids);
568 568
 
569 569
 	}
570 570
 
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 	 * @since 2.0.0
575 575
 	 */
576 576
 	public function wp_footer() {
577
-		wpinv_get_template( 'frontend-footer.php' );
577
+		wpinv_get_template('frontend-footer.php');
578 578
 	}
579 579
 
580 580
 	/**
@@ -583,14 +583,14 @@  discard block
 block discarded – undo
583 583
 	 * @since 2.0.0
584 584
 	 */
585 585
 	public function wp_head() {
586
-		wpinv_get_template( 'frontend-head.php' );
586
+		wpinv_get_template('frontend-head.php');
587 587
 	}
588 588
 
589 589
 	/**
590 590
 	 * Custom query vars.
591 591
 	 *
592 592
 	 */
593
-	public function custom_query_vars( $vars ) {
593
+	public function custom_query_vars($vars) {
594 594
         $vars[] = 'getpaid-ipn';
595 595
         return $vars;
596 596
 	}
@@ -601,28 +601,28 @@  discard block
 block discarded – undo
601 601
 	 */
602 602
 	public function add_rewrite_rule() {
603 603
         $tag = 'getpaid-ipn';
604
-        add_rewrite_tag( "%$tag%", '([^&]+)' );
605
-        add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' );
604
+        add_rewrite_tag("%$tag%", '([^&]+)');
605
+        add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top');
606 606
 	}
607 607
 
608 608
 	/**
609 609
 	 * Processes non-query string ipns.
610 610
 	 *
611 611
 	 */
612
-	public function maybe_process_new_ipn( $query ) {
612
+	public function maybe_process_new_ipn($query) {
613 613
 
614
-        if ( is_admin() || ! $query->is_main_query() ) {
614
+        if (is_admin() || !$query->is_main_query()) {
615 615
             return;
616 616
         }
617 617
 
618
-		$gateway = get_query_var( 'getpaid-ipn' );
618
+		$gateway = get_query_var('getpaid-ipn');
619 619
 
620
-        if ( ! empty( $gateway ) ){
620
+        if (!empty($gateway)) {
621 621
 
622
-			$gateway = sanitize_text_field( $gateway );
622
+			$gateway = sanitize_text_field($gateway);
623 623
 			nocache_headers();
624
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
625
-			do_action( "wpinv_verify_{$gateway}_ipn" );
624
+			do_action('wpinv_verify_payment_ipn', $gateway);
625
+			do_action("wpinv_verify_{$gateway}_ipn");
626 626
 			exit;
627 627
 
628 628
         }
Please login to merge, or discard this patch.
vendor/composer/autoload_static.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,35 +6,35 @@  discard block
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5
8 8
 {
9
-    public static $files = array (
9
+    public static $files = array(
10 10
         'e8d544c98e79f913e13eae1306ab635e' => __DIR__ . '/..' . '/ayecode/wp-ayecode-ui/ayecode-ui-loader.php',
11 11
         '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php',
12 12
         '42671a413efb740d7040437ff2a982cd' => __DIR__ . '/..' . '/ayecode/wp-super-duper/sd-functions.php',
13 13
     );
14 14
 
15
-    public static $prefixLengthsPsr4 = array (
15
+    public static $prefixLengthsPsr4 = array(
16 16
         'M' => 
17
-        array (
17
+        array(
18 18
             'MaxMind\\Db\\' => 11,
19 19
         ),
20 20
         'C' => 
21
-        array (
21
+        array(
22 22
             'Composer\\Installers\\' => 20,
23 23
         ),
24 24
     );
25 25
 
26
-    public static $prefixDirsPsr4 = array (
26
+    public static $prefixDirsPsr4 = array(
27 27
         'MaxMind\\Db\\' => 
28
-        array (
28
+        array(
29 29
             0 => __DIR__ . '/..' . '/maxmind-db/reader/src/MaxMind/Db',
30 30
         ),
31 31
         'Composer\\Installers\\' => 
32
-        array (
32
+        array(
33 33
             0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers',
34 34
         ),
35 35
     );
36 36
 
37
-    public static $classMap = array (
37
+    public static $classMap = array(
38 38
         'AyeCode_Connect_Helper' => __DIR__ . '/..' . '/ayecode/ayecode-connect-helper/ayecode-connect-helper.php',
39 39
         'AyeCode_Deactivation_Survey' => __DIR__ . '/..' . '/ayecode/wp-deactivation-survey/wp-deactivation-survey.php',
40 40
         'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
     public static function getInitializer(ClassLoader $loader)
45 45
     {
46
-        return \Closure::bind(function () use ($loader) {
46
+        return \Closure::bind(function() use ($loader) {
47 47
             $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4;
48 48
             $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4;
49 49
             $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap;
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2546 added lines, -2546 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'            => 0,
38
-		'status'               => 'wpi-pending',
39
-		'version'              => '',
40
-		'date_created'         => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'            => 0,
38
+        'status'               => 'wpi-pending',
39
+        'version'              => '',
40
+        'date_created'         => null,
41 41
         'date_modified'        => null,
42 42
         'due_date'             => null,
43 43
         'completed_date'       => null,
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         'state'                => null,
61 61
         'zip'                  => null,
62 62
         'company'              => null,
63
-		'company_id'           => null,
63
+        'company_id'           => null,
64 64
         'vat_number'           => null,
65 65
         'vat_rate'             => null,
66 66
         'address'              => null,
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
         'subtotal'             => 0,
69 69
         'total_discount'       => 0,
70 70
         'total_tax'            => 0,
71
-		'total_fees'           => 0,
72
-		'total'                => 0,
71
+        'total_fees'           => 0,
72
+        'total'                => 0,
73 73
         'fees'                 => array(),
74 74
         'discounts'            => array(),
75 75
         'taxes'                => array(),
@@ -81,22 +81,22 @@  discard block
 block discarded – undo
81 81
         'transaction_id'       => '',
82 82
         'currency'             => '',
83 83
         'disable_taxes'        => false,
84
-		'subscription_id'      => null,
85
-		'remote_subscription_id' => null,
86
-		'is_viewed'            => false,
87
-		'email_cc'             => '',
88
-		'template'             => 'quantity', // hours, amount only
89
-		'created_via'          => null,
84
+        'subscription_id'      => null,
85
+        'remote_subscription_id' => null,
86
+        'is_viewed'            => false,
87
+        'email_cc'             => '',
88
+        'template'             => 'quantity', // hours, amount only
89
+        'created_via'          => null,
90 90
     );
91 91
 
92 92
     /**
93
-	 * Stores meta in cache for future reads.
94
-	 *
95
-	 * A group must be set to to enable caching.
96
-	 *
97
-	 * @var string
98
-	 */
99
-	protected $cache_group = 'getpaid_invoices';
93
+     * Stores meta in cache for future reads.
94
+     *
95
+     * A group must be set to to enable caching.
96
+     *
97
+     * @var string
98
+     */
99
+    protected $cache_group = 'getpaid_invoices';
100 100
 
101 101
     /**
102 102
      * Stores a reference to the original WP_Post object
@@ -110,111 +110,111 @@  discard block
 block discarded – undo
110 110
      *
111 111
      * @var int
112 112
      */
113
-	protected $recurring_item = null;
113
+    protected $recurring_item = null;
114 114
 
115
-	/**
115
+    /**
116 116
      * Stores an array of item totals.
117
-	 *
118
-	 * e.g $totals['discount'] = array(
119
-	 * 		'initial'   => 10,
120
-	 * 		'recurring' => 10,
121
-	 * )
117
+     *
118
+     * e.g $totals['discount'] = array(
119
+     * 		'initial'   => 10,
120
+     * 		'recurring' => 10,
121
+     * )
122 122
      *
123 123
      * @var array
124 124
      */
125
-	protected $totals = array();
125
+    protected $totals = array();
126 126
 
127
-	/**
127
+    /**
128 128
      * Tax rate.
129
-	 *
129
+     *
130 130
      * @var float
131 131
      */
132
-	protected $tax_rate = 0;
132
+    protected $tax_rate = 0;
133 133
 
134
-	/**
135
-	 * Stores the status transition information.
136
-	 *
137
-	 * @since 1.0.19
138
-	 * @var bool|array
139
-	 */
140
-	protected $status_transition = false;
134
+    /**
135
+     * Stores the status transition information.
136
+     *
137
+     * @since 1.0.19
138
+     * @var bool|array
139
+     */
140
+    protected $status_transition = false;
141 141
 
142 142
     /**
143
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
144
-	 *
145
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
146
-	 */
143
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
144
+     *
145
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
146
+     */
147 147
     public function __construct( $invoice = 0 ) {
148 148
 
149 149
         parent::__construct( $invoice );
150 150
 
151
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
152
-			$this->set_id( (int) $invoice );
153
-		} elseif ( $invoice instanceof self ) {
154
-			$this->set_id( $invoice->get_id() );
155
-		} elseif ( ! empty( $invoice->ID ) ) {
156
-			$this->set_id( $invoice->ID );
157
-		} elseif ( is_array( $invoice ) ) {
158
-			$this->set_props( $invoice );
159
-
160
-			if ( isset( $invoice['ID'] ) ) {
161
-				$this->set_id( $invoice['ID'] );
162
-			}
163
-
164
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
165
-			$this->set_id( $invoice_id );
166
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
167
-			$this->set_id( $invoice_id );
168
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
169
-			$this->set_id( $invoice_id );
170
-		} else {
171
-			$this->set_object_read( true );
172
-		}
151
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
152
+            $this->set_id( (int) $invoice );
153
+        } elseif ( $invoice instanceof self ) {
154
+            $this->set_id( $invoice->get_id() );
155
+        } elseif ( ! empty( $invoice->ID ) ) {
156
+            $this->set_id( $invoice->ID );
157
+        } elseif ( is_array( $invoice ) ) {
158
+            $this->set_props( $invoice );
159
+
160
+            if ( isset( $invoice['ID'] ) ) {
161
+                $this->set_id( $invoice['ID'] );
162
+            }
163
+
164
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
165
+            $this->set_id( $invoice_id );
166
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
167
+            $this->set_id( $invoice_id );
168
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
169
+            $this->set_id( $invoice_id );
170
+        } else {
171
+            $this->set_object_read( true );
172
+        }
173 173
 
174 174
         // Load the datastore.
175
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
175
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
176 176
 
177
-		if ( $this->get_id() > 0 ) {
177
+        if ( $this->get_id() > 0 ) {
178 178
             $this->post = get_post( $this->get_id() );
179 179
             $this->ID   = $this->get_id();
180
-			$this->data_store->read( $this );
180
+            $this->data_store->read( $this );
181 181
         }
182 182
 
183 183
     }
184 184
 
185 185
     /**
186
-	 * Given an invoice key/number, it returns its id.
187
-	 *
188
-	 *
189
-	 * @static
190
-	 * @param string $value The invoice key or number
191
-	 * @param string $field Either key, transaction_id or number.
192
-	 * @since 1.0.15
193
-	 * @return int
194
-	 */
195
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
186
+     * Given an invoice key/number, it returns its id.
187
+     *
188
+     *
189
+     * @static
190
+     * @param string $value The invoice key or number
191
+     * @param string $field Either key, transaction_id or number.
192
+     * @since 1.0.15
193
+     * @return int
194
+     */
195
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
196 196
         global $wpdb;
197 197
 
198
-		// Trim the value.
199
-		$value = trim( $value );
198
+        // Trim the value.
199
+        $value = trim( $value );
200 200
 
201
-		if ( empty( $value ) ) {
202
-			return 0;
203
-		}
201
+        if ( empty( $value ) ) {
202
+            return 0;
203
+        }
204 204
 
205 205
         // Valid fields.
206 206
         $fields = array( 'key', 'number', 'transaction_id' );
207 207
 
208
-		// Ensure a field has been passed.
209
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
210
-			return 0;
211
-		}
208
+        // Ensure a field has been passed.
209
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
210
+            return 0;
211
+        }
212 212
 
213
-		// Maybe retrieve from the cache.
214
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
-		if ( false !== $invoice_id ) {
216
-			return $invoice_id;
217
-		}
213
+        // Maybe retrieve from the cache.
214
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
+        if ( false !== $invoice_id ) {
216
+            return $invoice_id;
217
+        }
218 218
 
219 219
         // Fetch from the db.
220 220
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
223 223
         );
224 224
 
225
-		// Update the cache with our data
226
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
225
+        // Update the cache with our data
226
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
227 227
 
228
-		return $invoice_id;
228
+        return $invoice_id;
229 229
     }
230 230
 
231 231
     /**
@@ -251,83 +251,83 @@  discard block
 block discarded – undo
251 251
     */
252 252
 
253 253
     /**
254
-	 * Get parent invoice ID.
255
-	 *
256
-	 * @since 1.0.19
257
-	 * @param  string $context View or edit context.
258
-	 * @return int
259
-	 */
260
-	public function get_parent_id( $context = 'view' ) {
261
-		return (int) $this->get_prop( 'parent_id', $context );
254
+     * Get parent invoice ID.
255
+     *
256
+     * @since 1.0.19
257
+     * @param  string $context View or edit context.
258
+     * @return int
259
+     */
260
+    public function get_parent_id( $context = 'view' ) {
261
+        return (int) $this->get_prop( 'parent_id', $context );
262 262
     }
263 263
 
264 264
     /**
265
-	 * Get parent invoice.
266
-	 *
267
-	 * @since 1.0.19
268
-	 * @return WPInv_Invoice
269
-	 */
265
+     * Get parent invoice.
266
+     *
267
+     * @since 1.0.19
268
+     * @return WPInv_Invoice
269
+     */
270 270
     public function get_parent_payment() {
271 271
         return new WPInv_Invoice( $this->get_parent_id() );
272 272
     }
273 273
 
274 274
     /**
275
-	 * Alias for self::get_parent_payment().
276
-	 *
277
-	 * @since 1.0.19
278
-	 * @return WPInv_Invoice
279
-	 */
275
+     * Alias for self::get_parent_payment().
276
+     *
277
+     * @since 1.0.19
278
+     * @return WPInv_Invoice
279
+     */
280 280
     public function get_parent() {
281 281
         return $this->get_parent_payment();
282 282
     }
283 283
 
284 284
     /**
285
-	 * Get invoice status.
286
-	 *
287
-	 * @since 1.0.19
288
-	 * @param  string $context View or edit context.
289
-	 * @return string
290
-	 */
291
-	public function get_status( $context = 'view' ) {
292
-		return $this->get_prop( 'status', $context );
293
-	}
285
+     * Get invoice status.
286
+     *
287
+     * @since 1.0.19
288
+     * @param  string $context View or edit context.
289
+     * @return string
290
+     */
291
+    public function get_status( $context = 'view' ) {
292
+        return $this->get_prop( 'status', $context );
293
+    }
294 294
 	
295
-	/**
296
-	 * Retrieves an array of possible invoice statuses.
297
-	 *
298
-	 * @since 1.0.19
299
-	 * @return array
300
-	 */
301
-	public function get_all_statuses() {
302
-		return wpinv_get_invoice_statuses( true, true, $this );
303
-    }
304
-
305
-    /**
306
-	 * Get invoice status nice name.
307
-	 *
308
-	 * @since 1.0.19
309
-	 * @return string
310
-	 */
295
+    /**
296
+     * Retrieves an array of possible invoice statuses.
297
+     *
298
+     * @since 1.0.19
299
+     * @return array
300
+     */
301
+    public function get_all_statuses() {
302
+        return wpinv_get_invoice_statuses( true, true, $this );
303
+    }
304
+
305
+    /**
306
+     * Get invoice status nice name.
307
+     *
308
+     * @since 1.0.19
309
+     * @return string
310
+     */
311 311
     public function get_status_nicename() {
312
-		$statuses = $this->get_all_statuses();
312
+        $statuses = $this->get_all_statuses();
313 313
 
314 314
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
315 315
 
316 316
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
317 317
     }
318 318
 
319
-	/**
320
-	 * Retrieves the invoice status class
321
-	 *
322
-	 * @since  1.0.19
323
-	 * @return string
324
-	 */
325
-	public function get_status_class() {
326
-		$statuses = getpaid_get_invoice_status_classes();
327
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
328
-	}
319
+    /**
320
+     * Retrieves the invoice status class
321
+     *
322
+     * @since  1.0.19
323
+     * @return string
324
+     */
325
+    public function get_status_class() {
326
+        $statuses = getpaid_get_invoice_status_classes();
327
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
328
+    }
329 329
 
330
-	/**
330
+    /**
331 331
      * Retrieves the invoice status label html
332 332
      *
333 333
      * @since  1.0.0
@@ -335,263 +335,263 @@  discard block
 block discarded – undo
335 335
      */
336 336
     public function get_status_label_html() {
337 337
 
338
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
339
-		$status       = sanitize_html_class( $this->get_status() );
340
-		$class        = esc_attr( $this->get_status_class() );
338
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
339
+        $status       = sanitize_html_class( $this->get_status() );
340
+        $class        = esc_attr( $this->get_status_class() );
341 341
 
342
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
343
-	}
342
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
343
+    }
344 344
 
345 345
     /**
346
-	 * Get plugin version when the invoice was created.
347
-	 *
348
-	 * @since 1.0.19
349
-	 * @param  string $context View or edit context.
350
-	 * @return string
351
-	 */
352
-	public function get_version( $context = 'view' ) {
353
-		return $this->get_prop( 'version', $context );
354
-	}
346
+     * Get plugin version when the invoice was created.
347
+     *
348
+     * @since 1.0.19
349
+     * @param  string $context View or edit context.
350
+     * @return string
351
+     */
352
+    public function get_version( $context = 'view' ) {
353
+        return $this->get_prop( 'version', $context );
354
+    }
355 355
 
356
-	/**
357
-	 * @deprecated
358
-	 */
359
-	public function get_invoice_date( $format = true ) {
360
-		$date      = getpaid_format_date( $this->get_date_completed() );
361
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
362
-		$formatted = getpaid_format_date( $date );
356
+    /**
357
+     * @deprecated
358
+     */
359
+    public function get_invoice_date( $format = true ) {
360
+        $date      = getpaid_format_date( $this->get_date_completed() );
361
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
362
+        $formatted = getpaid_format_date( $date );
363 363
 
364
-		if ( $format ) {
365
-			return $formatted;
366
-		}
364
+        if ( $format ) {
365
+            return $formatted;
366
+        }
367 367
 
368
-		return empty( $formatted ) ? '' : $date;
368
+        return empty( $formatted ) ? '' : $date;
369 369
 
370 370
     }
371 371
 
372 372
     /**
373
-	 * Get date when the invoice was created.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_date_created( $context = 'view' ) {
380
-		return $this->get_prop( 'date_created', $context );
381
-	}
373
+     * Get date when the invoice was created.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_date_created( $context = 'view' ) {
380
+        return $this->get_prop( 'date_created', $context );
381
+    }
382 382
 	
383
-	/**
384
-	 * Alias for self::get_date_created().
385
-	 *
386
-	 * @since 1.0.19
387
-	 * @param  string $context View or edit context.
388
-	 * @return string
389
-	 */
390
-	public function get_created_date( $context = 'view' ) {
391
-		return $this->get_date_created( $context );
392
-    }
393
-
394
-    /**
395
-	 * Get GMT date when the invoice was created.
396
-	 *
397
-	 * @since 1.0.19
398
-	 * @param  string $context View or edit context.
399
-	 * @return string
400
-	 */
401
-	public function get_date_created_gmt( $context = 'view' ) {
383
+    /**
384
+     * Alias for self::get_date_created().
385
+     *
386
+     * @since 1.0.19
387
+     * @param  string $context View or edit context.
388
+     * @return string
389
+     */
390
+    public function get_created_date( $context = 'view' ) {
391
+        return $this->get_date_created( $context );
392
+    }
393
+
394
+    /**
395
+     * Get GMT date when the invoice was created.
396
+     *
397
+     * @since 1.0.19
398
+     * @param  string $context View or edit context.
399
+     * @return string
400
+     */
401
+    public function get_date_created_gmt( $context = 'view' ) {
402 402
         $date = $this->get_date_created( $context );
403 403
 
404 404
         if ( $date ) {
405 405
             $date = get_gmt_from_date( $date );
406 406
         }
407
-		return $date;
407
+        return $date;
408 408
     }
409 409
 
410 410
     /**
411
-	 * Get date when the invoice was last modified.
412
-	 *
413
-	 * @since 1.0.19
414
-	 * @param  string $context View or edit context.
415
-	 * @return string
416
-	 */
417
-	public function get_date_modified( $context = 'view' ) {
418
-		return $this->get_prop( 'date_modified', $context );
419
-	}
411
+     * Get date when the invoice was last modified.
412
+     *
413
+     * @since 1.0.19
414
+     * @param  string $context View or edit context.
415
+     * @return string
416
+     */
417
+    public function get_date_modified( $context = 'view' ) {
418
+        return $this->get_prop( 'date_modified', $context );
419
+    }
420 420
 
421
-	/**
422
-	 * Alias for self::get_date_modified().
423
-	 *
424
-	 * @since 1.0.19
425
-	 * @param  string $context View or edit context.
426
-	 * @return string
427
-	 */
428
-	public function get_modified_date( $context = 'view' ) {
429
-		return $this->get_date_modified( $context );
421
+    /**
422
+     * Alias for self::get_date_modified().
423
+     *
424
+     * @since 1.0.19
425
+     * @param  string $context View or edit context.
426
+     * @return string
427
+     */
428
+    public function get_modified_date( $context = 'view' ) {
429
+        return $this->get_date_modified( $context );
430 430
     }
431 431
 
432 432
     /**
433
-	 * Get GMT date when the invoice was last modified.
434
-	 *
435
-	 * @since 1.0.19
436
-	 * @param  string $context View or edit context.
437
-	 * @return string
438
-	 */
439
-	public function get_date_modified_gmt( $context = 'view' ) {
433
+     * Get GMT date when the invoice was last modified.
434
+     *
435
+     * @since 1.0.19
436
+     * @param  string $context View or edit context.
437
+     * @return string
438
+     */
439
+    public function get_date_modified_gmt( $context = 'view' ) {
440 440
         $date = $this->get_date_modified( $context );
441 441
 
442 442
         if ( $date ) {
443 443
             $date = get_gmt_from_date( $date );
444 444
         }
445
-		return $date;
445
+        return $date;
446 446
     }
447 447
 
448 448
     /**
449
-	 * Get the invoice due date.
450
-	 *
451
-	 * @since 1.0.19
452
-	 * @param  string $context View or edit context.
453
-	 * @return string
454
-	 */
455
-	public function get_due_date( $context = 'view' ) {
456
-		return $this->get_prop( 'due_date', $context );
449
+     * Get the invoice due date.
450
+     *
451
+     * @since 1.0.19
452
+     * @param  string $context View or edit context.
453
+     * @return string
454
+     */
455
+    public function get_due_date( $context = 'view' ) {
456
+        return $this->get_prop( 'due_date', $context );
457 457
     }
458 458
 
459 459
     /**
460
-	 * Alias for self::get_due_date().
461
-	 *
462
-	 * @since 1.0.19
463
-	 * @param  string $context View or edit context.
464
-	 * @return string
465
-	 */
466
-	public function get_date_due( $context = 'view' ) {
467
-		return $this->get_due_date( $context );
460
+     * Alias for self::get_due_date().
461
+     *
462
+     * @since 1.0.19
463
+     * @param  string $context View or edit context.
464
+     * @return string
465
+     */
466
+    public function get_date_due( $context = 'view' ) {
467
+        return $this->get_due_date( $context );
468 468
     }
469 469
 
470 470
     /**
471
-	 * Get the invoice GMT due date.
472
-	 *
473
-	 * @since 1.0.19
474
-	 * @param  string $context View or edit context.
475
-	 * @return string
476
-	 */
477
-	public function get_due_date_gmt( $context = 'view' ) {
471
+     * Get the invoice GMT due date.
472
+     *
473
+     * @since 1.0.19
474
+     * @param  string $context View or edit context.
475
+     * @return string
476
+     */
477
+    public function get_due_date_gmt( $context = 'view' ) {
478 478
         $date = $this->get_due_date( $context );
479 479
 
480 480
         if ( $date ) {
481 481
             $date = get_gmt_from_date( $date );
482 482
         }
483
-		return $date;
483
+        return $date;
484 484
     }
485 485
 
486 486
     /**
487
-	 * Alias for self::get_due_date_gmt().
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  string $context View or edit context.
491
-	 * @return string
492
-	 */
493
-	public function get_gmt_date_due( $context = 'view' ) {
494
-		return $this->get_due_date_gmt( $context );
487
+     * Alias for self::get_due_date_gmt().
488
+     *
489
+     * @since 1.0.19
490
+     * @param  string $context View or edit context.
491
+     * @return string
492
+     */
493
+    public function get_gmt_date_due( $context = 'view' ) {
494
+        return $this->get_due_date_gmt( $context );
495 495
     }
496 496
 
497 497
     /**
498
-	 * Get date when the invoice was completed.
499
-	 *
500
-	 * @since 1.0.19
501
-	 * @param  string $context View or edit context.
502
-	 * @return string
503
-	 */
504
-	public function get_completed_date( $context = 'view' ) {
505
-		return $this->get_prop( 'completed_date', $context );
498
+     * Get date when the invoice was completed.
499
+     *
500
+     * @since 1.0.19
501
+     * @param  string $context View or edit context.
502
+     * @return string
503
+     */
504
+    public function get_completed_date( $context = 'view' ) {
505
+        return $this->get_prop( 'completed_date', $context );
506 506
     }
507 507
 
508 508
     /**
509
-	 * Alias for self::get_completed_date().
510
-	 *
511
-	 * @since 1.0.19
512
-	 * @param  string $context View or edit context.
513
-	 * @return string
514
-	 */
515
-	public function get_date_completed( $context = 'view' ) {
516
-		return $this->get_completed_date( $context );
509
+     * Alias for self::get_completed_date().
510
+     *
511
+     * @since 1.0.19
512
+     * @param  string $context View or edit context.
513
+     * @return string
514
+     */
515
+    public function get_date_completed( $context = 'view' ) {
516
+        return $this->get_completed_date( $context );
517 517
     }
518 518
 
519 519
     /**
520
-	 * Get GMT date when the invoice was was completed.
521
-	 *
522
-	 * @since 1.0.19
523
-	 * @param  string $context View or edit context.
524
-	 * @return string
525
-	 */
526
-	public function get_completed_date_gmt( $context = 'view' ) {
520
+     * Get GMT date when the invoice was was completed.
521
+     *
522
+     * @since 1.0.19
523
+     * @param  string $context View or edit context.
524
+     * @return string
525
+     */
526
+    public function get_completed_date_gmt( $context = 'view' ) {
527 527
         $date = $this->get_completed_date( $context );
528 528
 
529 529
         if ( $date ) {
530 530
             $date = get_gmt_from_date( $date );
531 531
         }
532
-		return $date;
532
+        return $date;
533 533
     }
534 534
 
535 535
     /**
536
-	 * Alias for self::get_completed_date_gmt().
537
-	 *
538
-	 * @since 1.0.19
539
-	 * @param  string $context View or edit context.
540
-	 * @return string
541
-	 */
542
-	public function get_gmt_completed_date( $context = 'view' ) {
543
-		return $this->get_completed_date_gmt( $context );
536
+     * Alias for self::get_completed_date_gmt().
537
+     *
538
+     * @since 1.0.19
539
+     * @param  string $context View or edit context.
540
+     * @return string
541
+     */
542
+    public function get_gmt_completed_date( $context = 'view' ) {
543
+        return $this->get_completed_date_gmt( $context );
544 544
     }
545 545
 
546 546
     /**
547
-	 * Get the invoice number.
548
-	 *
549
-	 * @since 1.0.19
550
-	 * @param  string $context View or edit context.
551
-	 * @return string
552
-	 */
553
-	public function get_number( $context = 'view' ) {
554
-		$number = $this->get_prop( 'number', $context );
547
+     * Get the invoice number.
548
+     *
549
+     * @since 1.0.19
550
+     * @param  string $context View or edit context.
551
+     * @return string
552
+     */
553
+    public function get_number( $context = 'view' ) {
554
+        $number = $this->get_prop( 'number', $context );
555 555
 
556
-		if ( empty( $number ) ) {
557
-			$number = $this->generate_number();
558
-			$this->set_number( $this->generate_number() );
559
-		}
556
+        if ( empty( $number ) ) {
557
+            $number = $this->generate_number();
558
+            $this->set_number( $this->generate_number() );
559
+        }
560 560
 
561
-		return $number;
561
+        return $number;
562 562
     }
563 563
 
564
-	/**
565
-	 * Set the invoice number.
566
-	 *
567
-	 * @since 1.0.19
568
-	 */
569
-	public function maybe_set_number() {
564
+    /**
565
+     * Set the invoice number.
566
+     *
567
+     * @since 1.0.19
568
+     */
569
+    public function maybe_set_number() {
570 570
         $number = $this->get_number();
571 571
 
572 572
         if ( empty( $number ) || $this->get_id() == $number ) {
573
-			$this->set_number( $this->generate_number() );
573
+            $this->set_number( $this->generate_number() );
574 574
         }
575 575
 
576
-	}
576
+    }
577 577
 
578 578
     /**
579
-	 * Get the invoice key.
580
-	 *
581
-	 * @since 1.0.19
582
-	 * @param  string $context View or edit context.
583
-	 * @return string
584
-	 */
585
-	public function get_key( $context = 'view' ) {
579
+     * Get the invoice key.
580
+     *
581
+     * @since 1.0.19
582
+     * @param  string $context View or edit context.
583
+     * @return string
584
+     */
585
+    public function get_key( $context = 'view' ) {
586 586
         return $this->get_prop( 'key', $context );
587
-	}
588
-
589
-	/**
590
-	 * Set the invoice key.
591
-	 *
592
-	 * @since 1.0.19
593
-	 */
594
-	public function maybe_set_key() {
587
+    }
588
+
589
+    /**
590
+     * Set the invoice key.
591
+     *
592
+     * @since 1.0.19
593
+     */
594
+    public function maybe_set_key() {
595 595
         $key = $this->get_key();
596 596
 
597 597
         if ( empty( $key ) ) {
@@ -602,140 +602,140 @@  discard block
 block discarded – undo
602 602
     }
603 603
 
604 604
     /**
605
-	 * Get the invoice type.
606
-	 *
607
-	 * @since 1.0.19
608
-	 * @param  string $context View or edit context.
609
-	 * @return string
610
-	 */
611
-	public function get_type( $context = 'view' ) {
605
+     * Get the invoice type.
606
+     *
607
+     * @since 1.0.19
608
+     * @param  string $context View or edit context.
609
+     * @return string
610
+     */
611
+    public function get_type( $context = 'view' ) {
612 612
         return $this->get_prop( 'type', $context );
613
-	}
614
-
615
-	/**
616
-	 * Returns the post type name.
617
-	 *
618
-	 * @since 1.0.19
619
-	 * @return string
620
-	 */
621
-	public function get_invoice_quote_type() {
613
+    }
614
+
615
+    /**
616
+     * Returns the post type name.
617
+     *
618
+     * @since 1.0.19
619
+     * @return string
620
+     */
621
+    public function get_invoice_quote_type() {
622 622
         return getpaid_get_post_type_label( $this->get_post_type(), false );
623 623
     }
624 624
 
625 625
     /**
626
-	 * Get the invoice post type label.
627
-	 *
628
-	 * @since 1.0.19
629
-	 * @param  string $context View or edit context.
630
-	 * @return string
631
-	 */
632
-	public function get_label( $context = 'view' ) {
626
+     * Get the invoice post type label.
627
+     *
628
+     * @since 1.0.19
629
+     * @param  string $context View or edit context.
630
+     * @return string
631
+     */
632
+    public function get_label( $context = 'view' ) {
633 633
         return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
634
-	}
635
-
636
-	/**
637
-	 * Get the invoice post type.
638
-	 *
639
-	 * @since 1.0.19
640
-	 * @param  string $context View or edit context.
641
-	 * @return string
642
-	 */
643
-	public function get_post_type( $context = 'view' ) {
634
+    }
635
+
636
+    /**
637
+     * Get the invoice post type.
638
+     *
639
+     * @since 1.0.19
640
+     * @param  string $context View or edit context.
641
+     * @return string
642
+     */
643
+    public function get_post_type( $context = 'view' ) {
644 644
         return $this->get_prop( 'post_type', $context );
645 645
     }
646 646
 
647 647
     /**
648
-	 * Get the invoice mode.
649
-	 *
650
-	 * @since 1.0.19
651
-	 * @param  string $context View or edit context.
652
-	 * @return string
653
-	 */
654
-	public function get_mode( $context = 'view' ) {
648
+     * Get the invoice mode.
649
+     *
650
+     * @since 1.0.19
651
+     * @param  string $context View or edit context.
652
+     * @return string
653
+     */
654
+    public function get_mode( $context = 'view' ) {
655 655
         return $this->get_prop( 'mode', $context );
656 656
     }
657 657
 
658 658
     /**
659
-	 * Get the invoice path.
660
-	 *
661
-	 * @since 1.0.19
662
-	 * @param  string $context View or edit context.
663
-	 * @return string
664
-	 */
665
-	public function get_path( $context = 'view' ) {
659
+     * Get the invoice path.
660
+     *
661
+     * @since 1.0.19
662
+     * @param  string $context View or edit context.
663
+     * @return string
664
+     */
665
+    public function get_path( $context = 'view' ) {
666 666
         $path   = $this->get_prop( 'path', $context );
667
-		$prefix = $this->get_type();
667
+        $prefix = $this->get_type();
668 668
 
669
-		if ( 0 !== strpos( $path, $prefix ) ) {
670
-			$path = sanitize_title(  $prefix . '-' . $this->get_id()  );
671
-			$this->set_path( $path );
672
-		}
669
+        if ( 0 !== strpos( $path, $prefix ) ) {
670
+            $path = sanitize_title(  $prefix . '-' . $this->get_id()  );
671
+            $this->set_path( $path );
672
+        }
673 673
 
674
-		return $path;
674
+        return $path;
675 675
     }
676 676
 
677 677
     /**
678
-	 * Get the invoice name/title.
679
-	 *
680
-	 * @since 1.0.19
681
-	 * @param  string $context View or edit context.
682
-	 * @return string
683
-	 */
684
-	public function get_name( $context = 'view' ) {
678
+     * Get the invoice name/title.
679
+     *
680
+     * @since 1.0.19
681
+     * @param  string $context View or edit context.
682
+     * @return string
683
+     */
684
+    public function get_name( $context = 'view' ) {
685 685
         return $this->get_prop( 'title', $context );
686 686
     }
687 687
 
688 688
     /**
689
-	 * Alias of self::get_name().
690
-	 *
691
-	 * @since 1.0.19
692
-	 * @param  string $context View or edit context.
693
-	 * @return string
694
-	 */
695
-	public function get_title( $context = 'view' ) {
696
-		return $this->get_name( $context );
689
+     * Alias of self::get_name().
690
+     *
691
+     * @since 1.0.19
692
+     * @param  string $context View or edit context.
693
+     * @return string
694
+     */
695
+    public function get_title( $context = 'view' ) {
696
+        return $this->get_name( $context );
697 697
     }
698 698
 
699 699
     /**
700
-	 * Get the invoice description.
701
-	 *
702
-	 * @since 1.0.19
703
-	 * @param  string $context View or edit context.
704
-	 * @return string
705
-	 */
706
-	public function get_description( $context = 'view' ) {
707
-		return $this->get_prop( 'description', $context );
700
+     * Get the invoice description.
701
+     *
702
+     * @since 1.0.19
703
+     * @param  string $context View or edit context.
704
+     * @return string
705
+     */
706
+    public function get_description( $context = 'view' ) {
707
+        return $this->get_prop( 'description', $context );
708 708
     }
709 709
 
710 710
     /**
711
-	 * Alias of self::get_description().
712
-	 *
713
-	 * @since 1.0.19
714
-	 * @param  string $context View or edit context.
715
-	 * @return string
716
-	 */
717
-	public function get_excerpt( $context = 'view' ) {
718
-		return $this->get_description( $context );
711
+     * Alias of self::get_description().
712
+     *
713
+     * @since 1.0.19
714
+     * @param  string $context View or edit context.
715
+     * @return string
716
+     */
717
+    public function get_excerpt( $context = 'view' ) {
718
+        return $this->get_description( $context );
719 719
     }
720 720
 
721 721
     /**
722
-	 * Alias of self::get_description().
723
-	 *
724
-	 * @since 1.0.19
725
-	 * @param  string $context View or edit context.
726
-	 * @return string
727
-	 */
728
-	public function get_summary( $context = 'view' ) {
729
-		return $this->get_description( $context );
722
+     * Alias of self::get_description().
723
+     *
724
+     * @since 1.0.19
725
+     * @param  string $context View or edit context.
726
+     * @return string
727
+     */
728
+    public function get_summary( $context = 'view' ) {
729
+        return $this->get_description( $context );
730 730
     }
731 731
 
732 732
     /**
733
-	 * Returns the user info.
734
-	 *
735
-	 * @since 1.0.19
733
+     * Returns the user info.
734
+     *
735
+     * @since 1.0.19
736 736
      * @param  string $context View or edit context.
737
-	 * @return array
738
-	 */
737
+     * @return array
738
+     */
739 739
     public function get_user_info( $context = 'view' ) {
740 740
 
741 741
         $user_info = array(
@@ -750,630 +750,630 @@  discard block
 block discarded – undo
750 750
             'state'      => $this->get_state( $context ),
751 751
             'zip'        => $this->get_zip( $context ),
752 752
             'company'    => $this->get_company( $context ),
753
-			'company_id' => $this->get_company_id( $context ),
753
+            'company_id' => $this->get_company_id( $context ),
754 754
             'vat_number' => $this->get_vat_number( $context ),
755 755
             'discount'   => $this->get_discount_code( $context ),
756
-		);
756
+        );
757 757
 
758
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
758
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
759 759
 
760 760
     }
761 761
 
762 762
     /**
763
-	 * Get the customer id.
764
-	 *
765
-	 * @since 1.0.19
766
-	 * @param  string $context View or edit context.
767
-	 * @return int
768
-	 */
769
-	public function get_author( $context = 'view' ) {
770
-		return (int) $this->get_prop( 'author', $context );
763
+     * Get the customer id.
764
+     *
765
+     * @since 1.0.19
766
+     * @param  string $context View or edit context.
767
+     * @return int
768
+     */
769
+    public function get_author( $context = 'view' ) {
770
+        return (int) $this->get_prop( 'author', $context );
771 771
     }
772 772
 
773 773
     /**
774
-	 * Alias of self::get_author().
775
-	 *
776
-	 * @since 1.0.19
777
-	 * @param  string $context View or edit context.
778
-	 * @return int
779
-	 */
780
-	public function get_user_id( $context = 'view' ) {
781
-		return $this->get_author( $context );
774
+     * Alias of self::get_author().
775
+     *
776
+     * @since 1.0.19
777
+     * @param  string $context View or edit context.
778
+     * @return int
779
+     */
780
+    public function get_user_id( $context = 'view' ) {
781
+        return $this->get_author( $context );
782 782
     }
783 783
 
784
-     /**
785
-	 * Alias of self::get_author().
786
-	 *
787
-	 * @since 1.0.19
788
-	 * @param  string $context View or edit context.
789
-	 * @return int
790
-	 */
791
-	public function get_customer_id( $context = 'view' ) {
792
-		return $this->get_author( $context );
784
+        /**
785
+         * Alias of self::get_author().
786
+         *
787
+         * @since 1.0.19
788
+         * @param  string $context View or edit context.
789
+         * @return int
790
+         */
791
+    public function get_customer_id( $context = 'view' ) {
792
+        return $this->get_author( $context );
793 793
     }
794 794
 
795 795
     /**
796
-	 * Get the customer's ip.
797
-	 *
798
-	 * @since 1.0.19
799
-	 * @param  string $context View or edit context.
800
-	 * @return string
801
-	 */
802
-	public function get_ip( $context = 'view' ) {
803
-		return $this->get_prop( 'user_ip', $context );
796
+     * Get the customer's ip.
797
+     *
798
+     * @since 1.0.19
799
+     * @param  string $context View or edit context.
800
+     * @return string
801
+     */
802
+    public function get_ip( $context = 'view' ) {
803
+        return $this->get_prop( 'user_ip', $context );
804 804
     }
805 805
 
806 806
     /**
807
-	 * Alias of self::get_ip().
808
-	 *
809
-	 * @since 1.0.19
810
-	 * @param  string $context View or edit context.
811
-	 * @return string
812
-	 */
813
-	public function get_user_ip( $context = 'view' ) {
814
-		return $this->get_ip( $context );
807
+     * Alias of self::get_ip().
808
+     *
809
+     * @since 1.0.19
810
+     * @param  string $context View or edit context.
811
+     * @return string
812
+     */
813
+    public function get_user_ip( $context = 'view' ) {
814
+        return $this->get_ip( $context );
815 815
     }
816 816
 
817
-     /**
818
-	 * Alias of self::get_ip().
819
-	 *
820
-	 * @since 1.0.19
821
-	 * @param  string $context View or edit context.
822
-	 * @return string
823
-	 */
824
-	public function get_customer_ip( $context = 'view' ) {
825
-		return $this->get_ip( $context );
817
+        /**
818
+         * Alias of self::get_ip().
819
+         *
820
+         * @since 1.0.19
821
+         * @param  string $context View or edit context.
822
+         * @return string
823
+         */
824
+    public function get_customer_ip( $context = 'view' ) {
825
+        return $this->get_ip( $context );
826 826
     }
827 827
 
828 828
     /**
829
-	 * Get the customer's first name.
830
-	 *
831
-	 * @since 1.0.19
832
-	 * @param  string $context View or edit context.
833
-	 * @return string
834
-	 */
835
-	public function get_first_name( $context = 'view' ) {
836
-		return $this->get_prop( 'first_name', $context );
829
+     * Get the customer's first name.
830
+     *
831
+     * @since 1.0.19
832
+     * @param  string $context View or edit context.
833
+     * @return string
834
+     */
835
+    public function get_first_name( $context = 'view' ) {
836
+        return $this->get_prop( 'first_name', $context );
837 837
     }
838 838
 
839 839
     /**
840
-	 * Alias of self::get_first_name().
841
-	 *
842
-	 * @since 1.0.19
843
-	 * @param  string $context View or edit context.
844
-	 * @return string
845
-	 */
846
-	public function get_user_first_name( $context = 'view' ) {
847
-		return $this->get_first_name( $context );
840
+     * Alias of self::get_first_name().
841
+     *
842
+     * @since 1.0.19
843
+     * @param  string $context View or edit context.
844
+     * @return string
845
+     */
846
+    public function get_user_first_name( $context = 'view' ) {
847
+        return $this->get_first_name( $context );
848 848
     }
849 849
 
850
-     /**
851
-	 * Alias of self::get_first_name().
852
-	 *
853
-	 * @since 1.0.19
854
-	 * @param  string $context View or edit context.
855
-	 * @return string
856
-	 */
857
-	public function get_customer_first_name( $context = 'view' ) {
858
-		return $this->get_first_name( $context );
850
+        /**
851
+         * Alias of self::get_first_name().
852
+         *
853
+         * @since 1.0.19
854
+         * @param  string $context View or edit context.
855
+         * @return string
856
+         */
857
+    public function get_customer_first_name( $context = 'view' ) {
858
+        return $this->get_first_name( $context );
859 859
     }
860 860
 
861 861
     /**
862
-	 * Get the customer's last name.
863
-	 *
864
-	 * @since 1.0.19
865
-	 * @param  string $context View or edit context.
866
-	 * @return string
867
-	 */
868
-	public function get_last_name( $context = 'view' ) {
869
-		return $this->get_prop( 'last_name', $context );
862
+     * Get the customer's last name.
863
+     *
864
+     * @since 1.0.19
865
+     * @param  string $context View or edit context.
866
+     * @return string
867
+     */
868
+    public function get_last_name( $context = 'view' ) {
869
+        return $this->get_prop( 'last_name', $context );
870 870
     }
871 871
 
872 872
     /**
873
-	 * Alias of self::get_last_name().
874
-	 *
875
-	 * @since 1.0.19
876
-	 * @param  string $context View or edit context.
877
-	 * @return string
878
-	 */
879
-	public function get_user_last_name( $context = 'view' ) {
880
-		return $this->get_last_name( $context );
873
+     * Alias of self::get_last_name().
874
+     *
875
+     * @since 1.0.19
876
+     * @param  string $context View or edit context.
877
+     * @return string
878
+     */
879
+    public function get_user_last_name( $context = 'view' ) {
880
+        return $this->get_last_name( $context );
881 881
     }
882 882
 
883 883
     /**
884
-	 * Alias of self::get_last_name().
885
-	 *
886
-	 * @since 1.0.19
887
-	 * @param  string $context View or edit context.
888
-	 * @return string
889
-	 */
890
-	public function get_customer_last_name( $context = 'view' ) {
891
-		return $this->get_last_name( $context );
884
+     * Alias of self::get_last_name().
885
+     *
886
+     * @since 1.0.19
887
+     * @param  string $context View or edit context.
888
+     * @return string
889
+     */
890
+    public function get_customer_last_name( $context = 'view' ) {
891
+        return $this->get_last_name( $context );
892 892
     }
893 893
 
894 894
     /**
895
-	 * Get the customer's full name.
896
-	 *
897
-	 * @since 1.0.19
898
-	 * @param  string $context View or edit context.
899
-	 * @return string
900
-	 */
901
-	public function get_full_name( $context = 'view' ) {
902
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
895
+     * Get the customer's full name.
896
+     *
897
+     * @since 1.0.19
898
+     * @param  string $context View or edit context.
899
+     * @return string
900
+     */
901
+    public function get_full_name( $context = 'view' ) {
902
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
903 903
     }
904 904
 
905 905
     /**
906
-	 * Alias of self::get_full_name().
907
-	 *
908
-	 * @since 1.0.19
909
-	 * @param  string $context View or edit context.
910
-	 * @return string
911
-	 */
912
-	public function get_user_full_name( $context = 'view' ) {
913
-		return $this->get_full_name( $context );
906
+     * Alias of self::get_full_name().
907
+     *
908
+     * @since 1.0.19
909
+     * @param  string $context View or edit context.
910
+     * @return string
911
+     */
912
+    public function get_user_full_name( $context = 'view' ) {
913
+        return $this->get_full_name( $context );
914 914
     }
915 915
 
916 916
     /**
917
-	 * Alias of self::get_full_name().
918
-	 *
919
-	 * @since 1.0.19
920
-	 * @param  string $context View or edit context.
921
-	 * @return string
922
-	 */
923
-	public function get_customer_full_name( $context = 'view' ) {
924
-		return $this->get_full_name( $context );
917
+     * Alias of self::get_full_name().
918
+     *
919
+     * @since 1.0.19
920
+     * @param  string $context View or edit context.
921
+     * @return string
922
+     */
923
+    public function get_customer_full_name( $context = 'view' ) {
924
+        return $this->get_full_name( $context );
925 925
     }
926 926
 
927 927
     /**
928
-	 * Get the customer's phone number.
929
-	 *
930
-	 * @since 1.0.19
931
-	 * @param  string $context View or edit context.
932
-	 * @return string
933
-	 */
934
-	public function get_phone( $context = 'view' ) {
935
-		return $this->get_prop( 'phone', $context );
928
+     * Get the customer's phone number.
929
+     *
930
+     * @since 1.0.19
931
+     * @param  string $context View or edit context.
932
+     * @return string
933
+     */
934
+    public function get_phone( $context = 'view' ) {
935
+        return $this->get_prop( 'phone', $context );
936 936
     }
937 937
 
938 938
     /**
939
-	 * Alias of self::get_phone().
940
-	 *
941
-	 * @since 1.0.19
942
-	 * @param  string $context View or edit context.
943
-	 * @return string
944
-	 */
945
-	public function get_phone_number( $context = 'view' ) {
946
-		return $this->get_phone( $context );
939
+     * Alias of self::get_phone().
940
+     *
941
+     * @since 1.0.19
942
+     * @param  string $context View or edit context.
943
+     * @return string
944
+     */
945
+    public function get_phone_number( $context = 'view' ) {
946
+        return $this->get_phone( $context );
947 947
     }
948 948
 
949 949
     /**
950
-	 * Alias of self::get_phone().
951
-	 *
952
-	 * @since 1.0.19
953
-	 * @param  string $context View or edit context.
954
-	 * @return string
955
-	 */
956
-	public function get_user_phone( $context = 'view' ) {
957
-		return $this->get_phone( $context );
958
-    }
959
-
950
+     * Alias of self::get_phone().
951
+     *
952
+     * @since 1.0.19
953
+     * @param  string $context View or edit context.
954
+     * @return string
955
+     */
956
+    public function get_user_phone( $context = 'view' ) {
957
+        return $this->get_phone( $context );
958
+    }
959
+
960
+    /**
961
+     * Alias of self::get_phone().
962
+     *
963
+     * @since 1.0.19
964
+     * @param  string $context View or edit context.
965
+     * @return string
966
+     */
967
+    public function get_customer_phone( $context = 'view' ) {
968
+        return $this->get_phone( $context );
969
+    }
970
+
971
+    /**
972
+     * Get the customer's email address.
973
+     *
974
+     * @since 1.0.19
975
+     * @param  string $context View or edit context.
976
+     * @return string
977
+     */
978
+    public function get_email( $context = 'view' ) {
979
+        return $this->get_prop( 'email', $context );
980
+    }
981
+
982
+    /**
983
+     * Alias of self::get_email().
984
+     *
985
+     * @since 1.0.19
986
+     * @param  string $context View or edit context.
987
+     * @return string
988
+     */
989
+    public function get_email_address( $context = 'view' ) {
990
+        return $this->get_email( $context );
991
+    }
992
+
993
+    /**
994
+     * Alias of self::get_email().
995
+     *
996
+     * @since 1.0.19
997
+     * @param  string $context View or edit context.
998
+     * @return string
999
+     */
1000
+    public function get_user_email( $context = 'view' ) {
1001
+        return $this->get_email( $context );
1002
+    }
1003
+
960 1004
     /**
961
-	 * Alias of self::get_phone().
962
-	 *
963
-	 * @since 1.0.19
964
-	 * @param  string $context View or edit context.
965
-	 * @return string
966
-	 */
967
-	public function get_customer_phone( $context = 'view' ) {
968
-		return $this->get_phone( $context );
1005
+     * Alias of self::get_email().
1006
+     *
1007
+     * @since 1.0.19
1008
+     * @param  string $context View or edit context.
1009
+     * @return string
1010
+     */
1011
+    public function get_customer_email( $context = 'view' ) {
1012
+        return $this->get_email( $context );
969 1013
     }
970 1014
 
971 1015
     /**
972
-	 * Get the customer's email address.
973
-	 *
974
-	 * @since 1.0.19
975
-	 * @param  string $context View or edit context.
976
-	 * @return string
977
-	 */
978
-	public function get_email( $context = 'view' ) {
979
-		return $this->get_prop( 'email', $context );
1016
+     * Get the customer's country.
1017
+     *
1018
+     * @since 1.0.19
1019
+     * @param  string $context View or edit context.
1020
+     * @return string
1021
+     */
1022
+    public function get_country( $context = 'view' ) {
1023
+        $country = $this->get_prop( 'country', $context );
1024
+        return empty( $country ) ? wpinv_get_default_country() : $country;
980 1025
     }
981 1026
 
982 1027
     /**
983
-	 * Alias of self::get_email().
984
-	 *
985
-	 * @since 1.0.19
986
-	 * @param  string $context View or edit context.
987
-	 * @return string
988
-	 */
989
-	public function get_email_address( $context = 'view' ) {
990
-		return $this->get_email( $context );
1028
+     * Alias of self::get_country().
1029
+     *
1030
+     * @since 1.0.19
1031
+     * @param  string $context View or edit context.
1032
+     * @return string
1033
+     */
1034
+    public function get_user_country( $context = 'view' ) {
1035
+        return $this->get_country( $context );
991 1036
     }
992 1037
 
993 1038
     /**
994
-	 * Alias of self::get_email().
995
-	 *
996
-	 * @since 1.0.19
997
-	 * @param  string $context View or edit context.
998
-	 * @return string
999
-	 */
1000
-	public function get_user_email( $context = 'view' ) {
1001
-		return $this->get_email( $context );
1039
+     * Alias of self::get_country().
1040
+     *
1041
+     * @since 1.0.19
1042
+     * @param  string $context View or edit context.
1043
+     * @return string
1044
+     */
1045
+    public function get_customer_country( $context = 'view' ) {
1046
+        return $this->get_country( $context );
1002 1047
     }
1003 1048
 
1004 1049
     /**
1005
-	 * Alias of self::get_email().
1006
-	 *
1007
-	 * @since 1.0.19
1008
-	 * @param  string $context View or edit context.
1009
-	 * @return string
1010
-	 */
1011
-	public function get_customer_email( $context = 'view' ) {
1012
-		return $this->get_email( $context );
1050
+     * Get the customer's state.
1051
+     *
1052
+     * @since 1.0.19
1053
+     * @param  string $context View or edit context.
1054
+     * @return string
1055
+     */
1056
+    public function get_state( $context = 'view' ) {
1057
+        $state = $this->get_prop( 'state', $context );
1058
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1013 1059
     }
1014 1060
 
1015 1061
     /**
1016
-	 * Get the customer's country.
1017
-	 *
1018
-	 * @since 1.0.19
1019
-	 * @param  string $context View or edit context.
1020
-	 * @return string
1021
-	 */
1022
-	public function get_country( $context = 'view' ) {
1023
-		$country = $this->get_prop( 'country', $context );
1024
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1062
+     * Alias of self::get_state().
1063
+     *
1064
+     * @since 1.0.19
1065
+     * @param  string $context View or edit context.
1066
+     * @return string
1067
+     */
1068
+    public function get_user_state( $context = 'view' ) {
1069
+        return $this->get_state( $context );
1025 1070
     }
1026 1071
 
1027 1072
     /**
1028
-	 * Alias of self::get_country().
1029
-	 *
1030
-	 * @since 1.0.19
1031
-	 * @param  string $context View or edit context.
1032
-	 * @return string
1033
-	 */
1034
-	public function get_user_country( $context = 'view' ) {
1035
-		return $this->get_country( $context );
1073
+     * Alias of self::get_state().
1074
+     *
1075
+     * @since 1.0.19
1076
+     * @param  string $context View or edit context.
1077
+     * @return string
1078
+     */
1079
+    public function get_customer_state( $context = 'view' ) {
1080
+        return $this->get_state( $context );
1036 1081
     }
1037 1082
 
1038 1083
     /**
1039
-	 * Alias of self::get_country().
1040
-	 *
1041
-	 * @since 1.0.19
1042
-	 * @param  string $context View or edit context.
1043
-	 * @return string
1044
-	 */
1045
-	public function get_customer_country( $context = 'view' ) {
1046
-		return $this->get_country( $context );
1084
+     * Get the customer's city.
1085
+     *
1086
+     * @since 1.0.19
1087
+     * @param  string $context View or edit context.
1088
+     * @return string
1089
+     */
1090
+    public function get_city( $context = 'view' ) {
1091
+        return $this->get_prop( 'city', $context );
1047 1092
     }
1048 1093
 
1049 1094
     /**
1050
-	 * Get the customer's state.
1051
-	 *
1052
-	 * @since 1.0.19
1053
-	 * @param  string $context View or edit context.
1054
-	 * @return string
1055
-	 */
1056
-	public function get_state( $context = 'view' ) {
1057
-		$state = $this->get_prop( 'state', $context );
1058
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1095
+     * Alias of self::get_city().
1096
+     *
1097
+     * @since 1.0.19
1098
+     * @param  string $context View or edit context.
1099
+     * @return string
1100
+     */
1101
+    public function get_user_city( $context = 'view' ) {
1102
+        return $this->get_city( $context );
1103
+    }
1104
+
1105
+    /**
1106
+     * Alias of self::get_city().
1107
+     *
1108
+     * @since 1.0.19
1109
+     * @param  string $context View or edit context.
1110
+     * @return string
1111
+     */
1112
+    public function get_customer_city( $context = 'view' ) {
1113
+        return $this->get_city( $context );
1114
+    }
1115
+
1116
+    /**
1117
+     * Get the customer's zip.
1118
+     *
1119
+     * @since 1.0.19
1120
+     * @param  string $context View or edit context.
1121
+     * @return string
1122
+     */
1123
+    public function get_zip( $context = 'view' ) {
1124
+        return $this->get_prop( 'zip', $context );
1125
+    }
1126
+
1127
+    /**
1128
+     * Alias of self::get_zip().
1129
+     *
1130
+     * @since 1.0.19
1131
+     * @param  string $context View or edit context.
1132
+     * @return string
1133
+     */
1134
+    public function get_user_zip( $context = 'view' ) {
1135
+        return $this->get_zip( $context );
1136
+    }
1137
+
1138
+    /**
1139
+     * Alias of self::get_zip().
1140
+     *
1141
+     * @since 1.0.19
1142
+     * @param  string $context View or edit context.
1143
+     * @return string
1144
+     */
1145
+    public function get_customer_zip( $context = 'view' ) {
1146
+        return $this->get_zip( $context );
1147
+    }
1148
+
1149
+    /**
1150
+     * Get the customer's company.
1151
+     *
1152
+     * @since 1.0.19
1153
+     * @param  string $context View or edit context.
1154
+     * @return string
1155
+     */
1156
+    public function get_company( $context = 'view' ) {
1157
+        return $this->get_prop( 'company', $context );
1158
+    }
1159
+
1160
+    /**
1161
+     * Alias of self::get_company().
1162
+     *
1163
+     * @since 1.0.19
1164
+     * @param  string $context View or edit context.
1165
+     * @return string
1166
+     */
1167
+    public function get_user_company( $context = 'view' ) {
1168
+        return $this->get_company( $context );
1169
+    }
1170
+
1171
+    /**
1172
+     * Alias of self::get_company().
1173
+     *
1174
+     * @since 1.0.19
1175
+     * @param  string $context View or edit context.
1176
+     * @return string
1177
+     */
1178
+    public function get_customer_company( $context = 'view' ) {
1179
+        return $this->get_company( $context );
1180
+    }
1181
+
1182
+    /**
1183
+     * Get the customer's company id.
1184
+     *
1185
+     * @since 1.0.19
1186
+     * @param  string $context View or edit context.
1187
+     * @return string
1188
+     */
1189
+    public function get_company_id( $context = 'view' ) {
1190
+        return $this->get_prop( 'company_id', $context );
1191
+    }
1192
+
1193
+    /**
1194
+     * Get the customer's vat number.
1195
+     *
1196
+     * @since 1.0.19
1197
+     * @param  string $context View or edit context.
1198
+     * @return string
1199
+     */
1200
+    public function get_vat_number( $context = 'view' ) {
1201
+        return $this->get_prop( 'vat_number', $context );
1059 1202
     }
1060 1203
 
1061 1204
     /**
1062
-	 * Alias of self::get_state().
1063
-	 *
1064
-	 * @since 1.0.19
1065
-	 * @param  string $context View or edit context.
1066
-	 * @return string
1067
-	 */
1068
-	public function get_user_state( $context = 'view' ) {
1069
-		return $this->get_state( $context );
1205
+     * Alias of self::get_vat_number().
1206
+     *
1207
+     * @since 1.0.19
1208
+     * @param  string $context View or edit context.
1209
+     * @return string
1210
+     */
1211
+    public function get_user_vat_number( $context = 'view' ) {
1212
+        return $this->get_vat_number( $context );
1070 1213
     }
1071 1214
 
1072 1215
     /**
1073
-	 * Alias of self::get_state().
1074
-	 *
1075
-	 * @since 1.0.19
1076
-	 * @param  string $context View or edit context.
1077
-	 * @return string
1078
-	 */
1079
-	public function get_customer_state( $context = 'view' ) {
1080
-		return $this->get_state( $context );
1216
+     * Alias of self::get_vat_number().
1217
+     *
1218
+     * @since 1.0.19
1219
+     * @param  string $context View or edit context.
1220
+     * @return string
1221
+     */
1222
+    public function get_customer_vat_number( $context = 'view' ) {
1223
+        return $this->get_vat_number( $context );
1081 1224
     }
1082 1225
 
1083 1226
     /**
1084
-	 * Get the customer's city.
1085
-	 *
1086
-	 * @since 1.0.19
1087
-	 * @param  string $context View or edit context.
1088
-	 * @return string
1089
-	 */
1090
-	public function get_city( $context = 'view' ) {
1091
-		return $this->get_prop( 'city', $context );
1227
+     * Get the customer's vat rate.
1228
+     *
1229
+     * @since 1.0.19
1230
+     * @param  string $context View or edit context.
1231
+     * @return string
1232
+     */
1233
+    public function get_vat_rate( $context = 'view' ) {
1234
+        return $this->get_prop( 'vat_rate', $context );
1092 1235
     }
1093 1236
 
1094 1237
     /**
1095
-	 * Alias of self::get_city().
1096
-	 *
1097
-	 * @since 1.0.19
1098
-	 * @param  string $context View or edit context.
1099
-	 * @return string
1100
-	 */
1101
-	public function get_user_city( $context = 'view' ) {
1102
-		return $this->get_city( $context );
1238
+     * Alias of self::get_vat_rate().
1239
+     *
1240
+     * @since 1.0.19
1241
+     * @param  string $context View or edit context.
1242
+     * @return string
1243
+     */
1244
+    public function get_user_vat_rate( $context = 'view' ) {
1245
+        return $this->get_vat_rate( $context );
1103 1246
     }
1104 1247
 
1105 1248
     /**
1106
-	 * Alias of self::get_city().
1107
-	 *
1108
-	 * @since 1.0.19
1109
-	 * @param  string $context View or edit context.
1110
-	 * @return string
1111
-	 */
1112
-	public function get_customer_city( $context = 'view' ) {
1113
-		return $this->get_city( $context );
1249
+     * Alias of self::get_vat_rate().
1250
+     *
1251
+     * @since 1.0.19
1252
+     * @param  string $context View or edit context.
1253
+     * @return string
1254
+     */
1255
+    public function get_customer_vat_rate( $context = 'view' ) {
1256
+        return $this->get_vat_rate( $context );
1114 1257
     }
1115 1258
 
1116 1259
     /**
1117
-	 * Get the customer's zip.
1118
-	 *
1119
-	 * @since 1.0.19
1120
-	 * @param  string $context View or edit context.
1121
-	 * @return string
1122
-	 */
1123
-	public function get_zip( $context = 'view' ) {
1124
-		return $this->get_prop( 'zip', $context );
1260
+     * Get the customer's address.
1261
+     *
1262
+     * @since 1.0.19
1263
+     * @param  string $context View or edit context.
1264
+     * @return string
1265
+     */
1266
+    public function get_address( $context = 'view' ) {
1267
+        return $this->get_prop( 'address', $context );
1125 1268
     }
1126 1269
 
1127 1270
     /**
1128
-	 * Alias of self::get_zip().
1129
-	 *
1130
-	 * @since 1.0.19
1131
-	 * @param  string $context View or edit context.
1132
-	 * @return string
1133
-	 */
1134
-	public function get_user_zip( $context = 'view' ) {
1135
-		return $this->get_zip( $context );
1271
+     * Alias of self::get_address().
1272
+     *
1273
+     * @since 1.0.19
1274
+     * @param  string $context View or edit context.
1275
+     * @return string
1276
+     */
1277
+    public function get_user_address( $context = 'view' ) {
1278
+        return $this->get_address( $context );
1136 1279
     }
1137 1280
 
1138 1281
     /**
1139
-	 * Alias of self::get_zip().
1140
-	 *
1141
-	 * @since 1.0.19
1142
-	 * @param  string $context View or edit context.
1143
-	 * @return string
1144
-	 */
1145
-	public function get_customer_zip( $context = 'view' ) {
1146
-		return $this->get_zip( $context );
1282
+     * Alias of self::get_address().
1283
+     *
1284
+     * @since 1.0.19
1285
+     * @param  string $context View or edit context.
1286
+     * @return string
1287
+     */
1288
+    public function get_customer_address( $context = 'view' ) {
1289
+        return $this->get_address( $context );
1147 1290
     }
1148 1291
 
1149 1292
     /**
1150
-	 * Get the customer's company.
1151
-	 *
1152
-	 * @since 1.0.19
1153
-	 * @param  string $context View or edit context.
1154
-	 * @return string
1155
-	 */
1156
-	public function get_company( $context = 'view' ) {
1157
-		return $this->get_prop( 'company', $context );
1293
+     * Get whether the customer has viewed the invoice or not.
1294
+     *
1295
+     * @since 1.0.19
1296
+     * @param  string $context View or edit context.
1297
+     * @return bool
1298
+     */
1299
+    public function get_is_viewed( $context = 'view' ) {
1300
+        return (bool) $this->get_prop( 'is_viewed', $context );
1158 1301
     }
1159 1302
 
1160 1303
     /**
1161
-	 * Alias of self::get_company().
1162
-	 *
1163
-	 * @since 1.0.19
1164
-	 * @param  string $context View or edit context.
1165
-	 * @return string
1166
-	 */
1167
-	public function get_user_company( $context = 'view' ) {
1168
-		return $this->get_company( $context );
1304
+     * Get other recipients for invoice communications.
1305
+     *
1306
+     * @since 1.0.19
1307
+     * @param  string $context View or edit context.
1308
+     * @return bool
1309
+     */
1310
+    public function get_email_cc( $context = 'view' ) {
1311
+        return $this->get_prop( 'email_cc', $context );
1169 1312
     }
1170 1313
 
1171 1314
     /**
1172
-	 * Alias of self::get_company().
1173
-	 *
1174
-	 * @since 1.0.19
1175
-	 * @param  string $context View or edit context.
1176
-	 * @return string
1177
-	 */
1178
-	public function get_customer_company( $context = 'view' ) {
1179
-		return $this->get_company( $context );
1315
+     * Get invoice template.
1316
+     *
1317
+     * @since 1.0.19
1318
+     * @param  string $context View or edit context.
1319
+     * @return bool
1320
+     */
1321
+    public function get_template( $context = 'view' ) {
1322
+        return $this->get_prop( 'template', $context );
1180 1323
     }
1181 1324
 
1182
-	/**
1183
-	 * Get the customer's company id.
1184
-	 *
1185
-	 * @since 1.0.19
1186
-	 * @param  string $context View or edit context.
1187
-	 * @return string
1188
-	 */
1189
-	public function get_company_id( $context = 'view' ) {
1190
-		return $this->get_prop( 'company_id', $context );
1325
+    /**
1326
+     * Get invoice source.
1327
+     *
1328
+     * @since 1.0.19
1329
+     * @param  string $context View or edit context.
1330
+     * @return bool
1331
+     */
1332
+    public function get_created_via( $context = 'view' ) {
1333
+        return $this->get_prop( 'created_via', $context );
1191 1334
     }
1192 1335
 
1193 1336
     /**
1194
-	 * Get the customer's vat number.
1195
-	 *
1196
-	 * @since 1.0.19
1197
-	 * @param  string $context View or edit context.
1198
-	 * @return string
1199
-	 */
1200
-	public function get_vat_number( $context = 'view' ) {
1201
-		return $this->get_prop( 'vat_number', $context );
1337
+     * Get whether the customer has confirmed their address.
1338
+     *
1339
+     * @since 1.0.19
1340
+     * @param  string $context View or edit context.
1341
+     * @return bool
1342
+     */
1343
+    public function get_address_confirmed( $context = 'view' ) {
1344
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1202 1345
     }
1203 1346
 
1204 1347
     /**
1205
-	 * Alias of self::get_vat_number().
1206
-	 *
1207
-	 * @since 1.0.19
1208
-	 * @param  string $context View or edit context.
1209
-	 * @return string
1210
-	 */
1211
-	public function get_user_vat_number( $context = 'view' ) {
1212
-		return $this->get_vat_number( $context );
1348
+     * Alias of self::get_address_confirmed().
1349
+     *
1350
+     * @since 1.0.19
1351
+     * @param  string $context View or edit context.
1352
+     * @return bool
1353
+     */
1354
+    public function get_user_address_confirmed( $context = 'view' ) {
1355
+        return $this->get_address_confirmed( $context );
1213 1356
     }
1214 1357
 
1215 1358
     /**
1216
-	 * Alias of self::get_vat_number().
1217
-	 *
1218
-	 * @since 1.0.19
1219
-	 * @param  string $context View or edit context.
1220
-	 * @return string
1221
-	 */
1222
-	public function get_customer_vat_number( $context = 'view' ) {
1223
-		return $this->get_vat_number( $context );
1359
+     * Alias of self::get_address().
1360
+     *
1361
+     * @since 1.0.19
1362
+     * @param  string $context View or edit context.
1363
+     * @return bool
1364
+     */
1365
+    public function get_customer_address_confirmed( $context = 'view' ) {
1366
+        return $this->get_address_confirmed( $context );
1224 1367
     }
1225 1368
 
1226
-    /**
1227
-	 * Get the customer's vat rate.
1228
-	 *
1229
-	 * @since 1.0.19
1230
-	 * @param  string $context View or edit context.
1231
-	 * @return string
1232
-	 */
1233
-	public function get_vat_rate( $context = 'view' ) {
1234
-		return $this->get_prop( 'vat_rate', $context );
1235
-    }
1236
-
1237
-    /**
1238
-	 * Alias of self::get_vat_rate().
1239
-	 *
1240
-	 * @since 1.0.19
1241
-	 * @param  string $context View or edit context.
1242
-	 * @return string
1243
-	 */
1244
-	public function get_user_vat_rate( $context = 'view' ) {
1245
-		return $this->get_vat_rate( $context );
1246
-    }
1247
-
1248
-    /**
1249
-	 * Alias of self::get_vat_rate().
1250
-	 *
1251
-	 * @since 1.0.19
1252
-	 * @param  string $context View or edit context.
1253
-	 * @return string
1254
-	 */
1255
-	public function get_customer_vat_rate( $context = 'view' ) {
1256
-		return $this->get_vat_rate( $context );
1257
-    }
1258
-
1259
-    /**
1260
-	 * Get the customer's address.
1261
-	 *
1262
-	 * @since 1.0.19
1263
-	 * @param  string $context View or edit context.
1264
-	 * @return string
1265
-	 */
1266
-	public function get_address( $context = 'view' ) {
1267
-		return $this->get_prop( 'address', $context );
1268
-    }
1269
-
1270
-    /**
1271
-	 * Alias of self::get_address().
1272
-	 *
1273
-	 * @since 1.0.19
1274
-	 * @param  string $context View or edit context.
1275
-	 * @return string
1276
-	 */
1277
-	public function get_user_address( $context = 'view' ) {
1278
-		return $this->get_address( $context );
1279
-    }
1280
-
1281
-    /**
1282
-	 * Alias of self::get_address().
1283
-	 *
1284
-	 * @since 1.0.19
1285
-	 * @param  string $context View or edit context.
1286
-	 * @return string
1287
-	 */
1288
-	public function get_customer_address( $context = 'view' ) {
1289
-		return $this->get_address( $context );
1290
-    }
1291
-
1292
-    /**
1293
-	 * Get whether the customer has viewed the invoice or not.
1294
-	 *
1295
-	 * @since 1.0.19
1296
-	 * @param  string $context View or edit context.
1297
-	 * @return bool
1298
-	 */
1299
-	public function get_is_viewed( $context = 'view' ) {
1300
-		return (bool) $this->get_prop( 'is_viewed', $context );
1301
-	}
1302
-
1303
-	/**
1304
-	 * Get other recipients for invoice communications.
1305
-	 *
1306
-	 * @since 1.0.19
1307
-	 * @param  string $context View or edit context.
1308
-	 * @return bool
1309
-	 */
1310
-	public function get_email_cc( $context = 'view' ) {
1311
-		return $this->get_prop( 'email_cc', $context );
1312
-	}
1313
-
1314
-	/**
1315
-	 * Get invoice template.
1316
-	 *
1317
-	 * @since 1.0.19
1318
-	 * @param  string $context View or edit context.
1319
-	 * @return bool
1320
-	 */
1321
-	public function get_template( $context = 'view' ) {
1322
-		return $this->get_prop( 'template', $context );
1323
-	}
1324
-
1325
-	/**
1326
-	 * Get invoice source.
1327
-	 *
1328
-	 * @since 1.0.19
1329
-	 * @param  string $context View or edit context.
1330
-	 * @return bool
1331
-	 */
1332
-	public function get_created_via( $context = 'view' ) {
1333
-		return $this->get_prop( 'created_via', $context );
1334
-	}
1335
-
1336
-	/**
1337
-	 * Get whether the customer has confirmed their address.
1338
-	 *
1339
-	 * @since 1.0.19
1340
-	 * @param  string $context View or edit context.
1341
-	 * @return bool
1342
-	 */
1343
-	public function get_address_confirmed( $context = 'view' ) {
1344
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1345
-    }
1346
-
1347
-    /**
1348
-	 * Alias of self::get_address_confirmed().
1349
-	 *
1350
-	 * @since 1.0.19
1351
-	 * @param  string $context View or edit context.
1352
-	 * @return bool
1353
-	 */
1354
-	public function get_user_address_confirmed( $context = 'view' ) {
1355
-		return $this->get_address_confirmed( $context );
1356
-    }
1357
-
1358
-    /**
1359
-	 * Alias of self::get_address().
1360
-	 *
1361
-	 * @since 1.0.19
1362
-	 * @param  string $context View or edit context.
1363
-	 * @return bool
1364
-	 */
1365
-	public function get_customer_address_confirmed( $context = 'view' ) {
1366
-		return $this->get_address_confirmed( $context );
1367
-    }
1368
-
1369
-    /**
1370
-	 * Get the invoice subtotal.
1371
-	 *
1372
-	 * @since 1.0.19
1373
-	 * @param  string $context View or edit context.
1374
-	 * @return float
1375
-	 */
1376
-	public function get_subtotal( $context = 'view' ) {
1369
+    /**
1370
+     * Get the invoice subtotal.
1371
+     *
1372
+     * @since 1.0.19
1373
+     * @param  string $context View or edit context.
1374
+     * @return float
1375
+     */
1376
+    public function get_subtotal( $context = 'view' ) {
1377 1377
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1378 1378
 
1379 1379
         // Backwards compatibility.
@@ -1385,192 +1385,192 @@  discard block
 block discarded – undo
1385 1385
     }
1386 1386
 
1387 1387
     /**
1388
-	 * Get the invoice discount total.
1389
-	 *
1390
-	 * @since 1.0.19
1391
-	 * @param  string $context View or edit context.
1392
-	 * @return float
1393
-	 */
1394
-	public function get_total_discount( $context = 'view' ) {
1395
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1388
+     * Get the invoice discount total.
1389
+     *
1390
+     * @since 1.0.19
1391
+     * @param  string $context View or edit context.
1392
+     * @return float
1393
+     */
1394
+    public function get_total_discount( $context = 'view' ) {
1395
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1396 1396
     }
1397 1397
 
1398 1398
     /**
1399
-	 * Get the invoice tax total.
1400
-	 *
1401
-	 * @since 1.0.19
1402
-	 * @param  string $context View or edit context.
1403
-	 * @return float
1404
-	 */
1405
-	public function get_total_tax( $context = 'view' ) {
1406
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1407
-	}
1399
+     * Get the invoice tax total.
1400
+     *
1401
+     * @since 1.0.19
1402
+     * @param  string $context View or edit context.
1403
+     * @return float
1404
+     */
1405
+    public function get_total_tax( $context = 'view' ) {
1406
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1407
+    }
1408 1408
 
1409
-	/**
1410
-	 * @deprecated
1411
-	 */
1412
-	public function get_final_tax( $currency = false ) {
1413
-		$tax = $this->get_total_tax();
1409
+    /**
1410
+     * @deprecated
1411
+     */
1412
+    public function get_final_tax( $currency = false ) {
1413
+        $tax = $this->get_total_tax();
1414 1414
 
1415 1415
         if ( $currency ) {
1416
-			return wpinv_price( $tax, $this->get_currency() );
1416
+            return wpinv_price( $tax, $this->get_currency() );
1417 1417
         }
1418 1418
 
1419 1419
         return $tax;
1420 1420
     }
1421 1421
 
1422 1422
     /**
1423
-	 * Get the invoice fees total.
1424
-	 *
1425
-	 * @since 1.0.19
1426
-	 * @param  string $context View or edit context.
1427
-	 * @return float
1428
-	 */
1429
-	public function get_total_fees( $context = 'view' ) {
1430
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1423
+     * Get the invoice fees total.
1424
+     *
1425
+     * @since 1.0.19
1426
+     * @param  string $context View or edit context.
1427
+     * @return float
1428
+     */
1429
+    public function get_total_fees( $context = 'view' ) {
1430
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1431 1431
     }
1432 1432
 
1433 1433
     /**
1434
-	 * Alias for self::get_total_fees().
1435
-	 *
1436
-	 * @since 1.0.19
1437
-	 * @param  string $context View or edit context.
1438
-	 * @return float
1439
-	 */
1440
-	public function get_fees_total( $context = 'view' ) {
1441
-		return $this->get_total_fees( $context );
1434
+     * Alias for self::get_total_fees().
1435
+     *
1436
+     * @since 1.0.19
1437
+     * @param  string $context View or edit context.
1438
+     * @return float
1439
+     */
1440
+    public function get_fees_total( $context = 'view' ) {
1441
+        return $this->get_total_fees( $context );
1442 1442
     }
1443 1443
 
1444 1444
     /**
1445
-	 * Get the invoice total.
1446
-	 *
1447
-	 * @since 1.0.19
1445
+     * Get the invoice total.
1446
+     *
1447
+     * @since 1.0.19
1448 1448
      * @return float
1449
-	 */
1450
-	public function get_total( $context = 'view' ) {
1451
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) );
1452
-	}
1453
-
1454
-	/**
1455
-	 * Retrieves the non-recurring total of items.
1456
-	 *
1457
-	 * @since 2.3.0
1458
-	 * @return float
1459
-	 */
1460
-	public function get_non_recurring_total() {
1461
-
1462
-		$subtotal = 0;
1463
-		foreach ( $this->get_items() as $item ) {
1464
-			if ( ! $item->is_recurring() ) {
1465
-				$subtotal += $item->get_sub_total();
1466
-			}
1467
-		}
1468
-
1469
-		foreach ( $this->get_fees() as $fee ) {
1470
-			if ( empty( $fee['recurring_fee'] ) ) {
1471
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1472
-			}
1473
-		}
1474
-
1475
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1449
+     */
1450
+    public function get_total( $context = 'view' ) {
1451
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) );
1452
+    }
1453
+
1454
+    /**
1455
+     * Retrieves the non-recurring total of items.
1456
+     *
1457
+     * @since 2.3.0
1458
+     * @return float
1459
+     */
1460
+    public function get_non_recurring_total() {
1461
+
1462
+        $subtotal = 0;
1463
+        foreach ( $this->get_items() as $item ) {
1464
+            if ( ! $item->is_recurring() ) {
1465
+                $subtotal += $item->get_sub_total();
1466
+            }
1467
+        }
1468
+
1469
+        foreach ( $this->get_fees() as $fee ) {
1470
+            if ( empty( $fee['recurring_fee'] ) ) {
1471
+                $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1472
+            }
1473
+        }
1474
+
1475
+        $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1476 1476
         return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1477 1477
 
1478 1478
     }
1479 1479
 
1480
-	/**
1481
-	 * Get the invoice totals.
1482
-	 *
1483
-	 * @since 1.0.19
1480
+    /**
1481
+     * Get the invoice totals.
1482
+     *
1483
+     * @since 1.0.19
1484 1484
      * @return array
1485
-	 */
1486
-	public function get_totals() {
1487
-		return $this->totals;
1485
+     */
1486
+    public function get_totals() {
1487
+        return $this->totals;
1488 1488
     }
1489 1489
 
1490 1490
     /**
1491
-	 * Get the initial invoice total.
1492
-	 *
1493
-	 * @since 1.0.19
1491
+     * Get the initial invoice total.
1492
+     *
1493
+     * @since 1.0.19
1494 1494
      * @param  string $context View or edit context.
1495 1495
      * @return float
1496
-	 */
1496
+     */
1497 1497
     public function get_initial_total() {
1498 1498
 
1499
-		if ( empty( $this->totals ) ) {
1500
-			$this->recalculate_total();
1501
-		}
1499
+        if ( empty( $this->totals ) ) {
1500
+            $this->recalculate_total();
1501
+        }
1502 1502
 
1503
-		$tax      = $this->totals['tax']['initial'];
1504
-		$fee      = $this->totals['fee']['initial'];
1505
-		$discount = $this->totals['discount']['initial'];
1506
-		$subtotal = $this->totals['subtotal']['initial'];
1507
-		$total    = $tax + $fee - $discount + $subtotal;
1503
+        $tax      = $this->totals['tax']['initial'];
1504
+        $fee      = $this->totals['fee']['initial'];
1505
+        $discount = $this->totals['discount']['initial'];
1506
+        $subtotal = $this->totals['subtotal']['initial'];
1507
+        $total    = $tax + $fee - $discount + $subtotal;
1508 1508
 
1509
-		if ( 0 > $total ) {
1510
-			$total = 0;
1511
-		}
1509
+        if ( 0 > $total ) {
1510
+            $total = 0;
1511
+        }
1512 1512
 
1513
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1513
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1514 1514
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1515
-	}
1515
+    }
1516 1516
 
1517
-	/**
1518
-	 * Get the recurring invoice total.
1519
-	 *
1520
-	 * @since 1.0.19
1517
+    /**
1518
+     * Get the recurring invoice total.
1519
+     *
1520
+     * @since 1.0.19
1521 1521
      * @param  string $context View or edit context.
1522 1522
      * @return float
1523
-	 */
1523
+     */
1524 1524
     public function get_recurring_total() {
1525 1525
 
1526
-		if ( empty( $this->totals ) ) {
1527
-			$this->recalculate_total();
1528
-		}
1526
+        if ( empty( $this->totals ) ) {
1527
+            $this->recalculate_total();
1528
+        }
1529 1529
 
1530
-		$tax      = $this->totals['tax']['recurring'];
1531
-		$fee      = $this->totals['fee']['recurring'];
1532
-		$discount = $this->totals['discount']['recurring'];
1533
-		$subtotal = $this->totals['subtotal']['recurring'];
1534
-		$total    = $tax + $fee - $discount + $subtotal;
1530
+        $tax      = $this->totals['tax']['recurring'];
1531
+        $fee      = $this->totals['fee']['recurring'];
1532
+        $discount = $this->totals['discount']['recurring'];
1533
+        $subtotal = $this->totals['subtotal']['recurring'];
1534
+        $total    = $tax + $fee - $discount + $subtotal;
1535 1535
 
1536
-		if ( 0 > $total ) {
1537
-			$total = 0;
1538
-		}
1536
+        if ( 0 > $total ) {
1537
+            $total = 0;
1538
+        }
1539 1539
 
1540
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1540
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1541 1541
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1542
-	}
1542
+    }
1543 1543
 
1544
-	/**
1545
-	 * Returns recurring payment details.
1546
-	 *
1547
-	 * @since 1.0.19
1544
+    /**
1545
+     * Returns recurring payment details.
1546
+     *
1547
+     * @since 1.0.19
1548 1548
      * @param  string $field Optionally provide a field to return.
1549
-	 * @param string $currency Whether to include the currency.
1549
+     * @param string $currency Whether to include the currency.
1550 1550
      * @return float|string
1551
-	 */
1551
+     */
1552 1552
     public function get_recurring_details( $field = '', $currency = false ) {
1553 1553
 
1554
-		// Maybe recalculate totals.
1555
-		if ( empty( $this->totals ) ) {
1556
-			$this->recalculate_total();
1557
-		}
1554
+        // Maybe recalculate totals.
1555
+        if ( empty( $this->totals ) ) {
1556
+            $this->recalculate_total();
1557
+        }
1558 1558
 
1559
-		// Prepare recurring totals.
1559
+        // Prepare recurring totals.
1560 1560
         $data = apply_filters(
1561
-			'wpinv_get_invoice_recurring_details',
1562
-			array(
1563
-				'cart_details' => $this->get_cart_details(),
1564
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1565
-				'discount'     => $this->totals['discount']['recurring'],
1566
-				'tax'          => $this->totals['tax']['recurring'],
1567
-				'fee'          => $this->totals['fee']['recurring'],
1568
-				'total'        => $this->get_recurring_total(),
1569
-			),
1570
-			$this,
1571
-			$field,
1572
-			$currency
1573
-		);
1561
+            'wpinv_get_invoice_recurring_details',
1562
+            array(
1563
+                'cart_details' => $this->get_cart_details(),
1564
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1565
+                'discount'     => $this->totals['discount']['recurring'],
1566
+                'tax'          => $this->totals['tax']['recurring'],
1567
+                'fee'          => $this->totals['fee']['recurring'],
1568
+                'total'        => $this->get_recurring_total(),
1569
+            ),
1570
+            $this,
1571
+            $field,
1572
+            $currency
1573
+        );
1574 1574
 
1575 1575
         if ( isset( $data[$field] ) ) {
1576 1576
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1580,166 +1580,166 @@  discard block
 block discarded – undo
1580 1580
     }
1581 1581
 
1582 1582
     /**
1583
-	 * Get the invoice fees.
1584
-	 *
1585
-	 * @since 1.0.19
1586
-	 * @param  string $context View or edit context.
1587
-	 * @return array
1588
-	 */
1589
-	public function get_fees( $context = 'view' ) {
1590
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1583
+     * Get the invoice fees.
1584
+     *
1585
+     * @since 1.0.19
1586
+     * @param  string $context View or edit context.
1587
+     * @return array
1588
+     */
1589
+    public function get_fees( $context = 'view' ) {
1590
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1591
+    }
1592
+
1593
+    /**
1594
+     * Get the invoice discounts.
1595
+     *
1596
+     * @since 1.0.19
1597
+     * @param  string $context View or edit context.
1598
+     * @return array
1599
+     */
1600
+    public function get_discounts( $context = 'view' ) {
1601
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1591 1602
     }
1592 1603
 
1593 1604
     /**
1594
-	 * Get the invoice discounts.
1595
-	 *
1596
-	 * @since 1.0.19
1597
-	 * @param  string $context View or edit context.
1598
-	 * @return array
1599
-	 */
1600
-	public function get_discounts( $context = 'view' ) {
1601
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1605
+     * Get the invoice taxes.
1606
+     *
1607
+     * @since 1.0.19
1608
+     * @param  string $context View or edit context.
1609
+     * @return array
1610
+     */
1611
+    public function get_taxes( $context = 'view' ) {
1612
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1602 1613
     }
1603 1614
 
1604 1615
     /**
1605
-	 * Get the invoice taxes.
1606
-	 *
1607
-	 * @since 1.0.19
1608
-	 * @param  string $context View or edit context.
1609
-	 * @return array
1610
-	 */
1611
-	public function get_taxes( $context = 'view' ) {
1612
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1616
+     * Get the invoice items.
1617
+     *
1618
+     * @since 1.0.19
1619
+     * @param  string $context View or edit context.
1620
+     * @return GetPaid_Form_Item[]
1621
+     */
1622
+    public function get_items( $context = 'view' ) {
1623
+        return $this->get_prop( 'items', $context );
1613 1624
     }
1614 1625
 
1615 1626
     /**
1616
-	 * Get the invoice items.
1617
-	 *
1618
-	 * @since 1.0.19
1619
-	 * @param  string $context View or edit context.
1620
-	 * @return GetPaid_Form_Item[]
1621
-	 */
1622
-	public function get_items( $context = 'view' ) {
1623
-        return $this->get_prop( 'items', $context );
1624
-	}
1625
-
1626
-	/**
1627
-	 * Get the invoice item ids.
1628
-	 *
1629
-	 * @since 1.0.19
1630
-	 * @return string
1631
-	 */
1632
-	public function get_item_ids() {
1633
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1627
+     * Get the invoice item ids.
1628
+     *
1629
+     * @since 1.0.19
1630
+     * @return string
1631
+     */
1632
+    public function get_item_ids() {
1633
+        return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1634 1634
     }
1635 1635
 
1636 1636
     /**
1637
-	 * Get the invoice's payment form.
1638
-	 *
1639
-	 * @since 1.0.19
1640
-	 * @param  string $context View or edit context.
1641
-	 * @return int
1642
-	 */
1643
-	public function get_payment_form( $context = 'view' ) {
1644
-		return intval( $this->get_prop( 'payment_form', $context ) );
1637
+     * Get the invoice's payment form.
1638
+     *
1639
+     * @since 1.0.19
1640
+     * @param  string $context View or edit context.
1641
+     * @return int
1642
+     */
1643
+    public function get_payment_form( $context = 'view' ) {
1644
+        return intval( $this->get_prop( 'payment_form', $context ) );
1645 1645
     }
1646 1646
 
1647 1647
     /**
1648
-	 * Get the invoice's submission id.
1649
-	 *
1650
-	 * @since 1.0.19
1651
-	 * @param  string $context View or edit context.
1652
-	 * @return string
1653
-	 */
1654
-	public function get_submission_id( $context = 'view' ) {
1655
-		return $this->get_prop( 'submission_id', $context );
1648
+     * Get the invoice's submission id.
1649
+     *
1650
+     * @since 1.0.19
1651
+     * @param  string $context View or edit context.
1652
+     * @return string
1653
+     */
1654
+    public function get_submission_id( $context = 'view' ) {
1655
+        return $this->get_prop( 'submission_id', $context );
1656 1656
     }
1657 1657
 
1658 1658
     /**
1659
-	 * Get the invoice's discount code.
1660
-	 *
1661
-	 * @since 1.0.19
1662
-	 * @param  string $context View or edit context.
1663
-	 * @return string
1664
-	 */
1665
-	public function get_discount_code( $context = 'view' ) {
1666
-		return $this->get_prop( 'discount_code', $context );
1659
+     * Get the invoice's discount code.
1660
+     *
1661
+     * @since 1.0.19
1662
+     * @param  string $context View or edit context.
1663
+     * @return string
1664
+     */
1665
+    public function get_discount_code( $context = 'view' ) {
1666
+        return $this->get_prop( 'discount_code', $context );
1667 1667
     }
1668 1668
 
1669 1669
     /**
1670
-	 * Get the invoice's gateway.
1671
-	 *
1672
-	 * @since 1.0.19
1673
-	 * @param  string $context View or edit context.
1674
-	 * @return string
1675
-	 */
1676
-	public function get_gateway( $context = 'view' ) {
1677
-		return $this->get_prop( 'gateway', $context );
1670
+     * Get the invoice's gateway.
1671
+     *
1672
+     * @since 1.0.19
1673
+     * @param  string $context View or edit context.
1674
+     * @return string
1675
+     */
1676
+    public function get_gateway( $context = 'view' ) {
1677
+        return $this->get_prop( 'gateway', $context );
1678 1678
     }
1679 1679
 
1680 1680
     /**
1681
-	 * Get the invoice's gateway display title.
1682
-	 *
1683
-	 * @since 1.0.19
1684
-	 * @return string
1685
-	 */
1681
+     * Get the invoice's gateway display title.
1682
+     *
1683
+     * @since 1.0.19
1684
+     * @return string
1685
+     */
1686 1686
     public function get_gateway_title() {
1687 1687
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1688 1688
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1689 1689
     }
1690 1690
 
1691 1691
     /**
1692
-	 * Get the invoice's transaction id.
1693
-	 *
1694
-	 * @since 1.0.19
1695
-	 * @param  string $context View or edit context.
1696
-	 * @return string
1697
-	 */
1698
-	public function get_transaction_id( $context = 'view' ) {
1699
-		return $this->get_prop( 'transaction_id', $context );
1692
+     * Get the invoice's transaction id.
1693
+     *
1694
+     * @since 1.0.19
1695
+     * @param  string $context View or edit context.
1696
+     * @return string
1697
+     */
1698
+    public function get_transaction_id( $context = 'view' ) {
1699
+        return $this->get_prop( 'transaction_id', $context );
1700 1700
     }
1701 1701
 
1702 1702
     /**
1703
-	 * Get the invoice's currency.
1704
-	 *
1705
-	 * @since 1.0.19
1706
-	 * @param  string $context View or edit context.
1707
-	 * @return string
1708
-	 */
1709
-	public function get_currency( $context = 'view' ) {
1703
+     * Get the invoice's currency.
1704
+     *
1705
+     * @since 1.0.19
1706
+     * @param  string $context View or edit context.
1707
+     * @return string
1708
+     */
1709
+    public function get_currency( $context = 'view' ) {
1710 1710
         $currency = $this->get_prop( 'currency', $context );
1711 1711
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1712 1712
     }
1713 1713
 
1714 1714
     /**
1715
-	 * Checks if we are charging taxes for this invoice.
1716
-	 *
1717
-	 * @since 1.0.19
1718
-	 * @param  string $context View or edit context.
1719
-	 * @return bool
1720
-	 */
1721
-	public function get_disable_taxes( $context = 'view' ) {
1715
+     * Checks if we are charging taxes for this invoice.
1716
+     *
1717
+     * @since 1.0.19
1718
+     * @param  string $context View or edit context.
1719
+     * @return bool
1720
+     */
1721
+    public function get_disable_taxes( $context = 'view' ) {
1722 1722
         return (bool) $this->get_prop( 'disable_taxes', $context );
1723 1723
     }
1724 1724
 
1725 1725
     /**
1726
-	 * Retrieves the subscription id for an invoice.
1727
-	 *
1728
-	 * @since 1.0.19
1729
-	 * @param  string $context View or edit context.
1730
-	 * @return int
1731
-	 */
1726
+     * Retrieves the subscription id for an invoice.
1727
+     *
1728
+     * @since 1.0.19
1729
+     * @param  string $context View or edit context.
1730
+     * @return int
1731
+     */
1732 1732
     public function get_subscription_id( $context = 'view' ) {
1733
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1734
-	}
1735
-
1736
-	/**
1737
-	 * Retrieves the remote subscription id for an invoice.
1738
-	 *
1739
-	 * @since 1.0.19
1740
-	 * @param  string $context View or edit context.
1741
-	 * @return int
1742
-	 */
1733
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1734
+    }
1735
+
1736
+    /**
1737
+     * Retrieves the remote subscription id for an invoice.
1738
+     *
1739
+     * @since 1.0.19
1740
+     * @param  string $context View or edit context.
1741
+     * @return int
1742
+     */
1743 1743
     public function get_remote_subscription_id( $context = 'view' ) {
1744 1744
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1745 1745
 
@@ -1752,12 +1752,12 @@  discard block
 block discarded – undo
1752 1752
     }
1753 1753
 
1754 1754
     /**
1755
-	 * Retrieves the payment meta for an invoice.
1756
-	 *
1757
-	 * @since 1.0.19
1758
-	 * @param  string $context View or edit context.
1759
-	 * @return array
1760
-	 */
1755
+     * Retrieves the payment meta for an invoice.
1756
+     *
1757
+     * @since 1.0.19
1758
+     * @param  string $context View or edit context.
1759
+     * @return array
1760
+     */
1761 1761
     public function get_payment_meta( $context = 'view' ) {
1762 1762
 
1763 1763
         return array(
@@ -1777,31 +1777,31 @@  discard block
 block discarded – undo
1777 1777
     }
1778 1778
 
1779 1779
     /**
1780
-	 * Retrieves the cart details for an invoice.
1781
-	 *
1782
-	 * @since 1.0.19
1783
-	 * @return array
1784
-	 */
1780
+     * Retrieves the cart details for an invoice.
1781
+     *
1782
+     * @since 1.0.19
1783
+     * @return array
1784
+     */
1785 1785
     public function get_cart_details() {
1786 1786
         $items        = $this->get_items();
1787 1787
         $cart_details = array();
1788 1788
 
1789 1789
         foreach ( $items as $item ) {
1790
-			$item->invoice_id = $this->get_id();
1790
+            $item->invoice_id = $this->get_id();
1791 1791
             $cart_details[]   = $item->prepare_data_for_saving();
1792 1792
         }
1793 1793
 
1794 1794
         return $cart_details;
1795
-	}
1795
+    }
1796 1796
 
1797
-	/**
1798
-	 * Retrieves the recurring item.
1799
-	 *
1800
-	 * @return null|GetPaid_Form_Item|int
1801
-	 */
1802
-	public function get_recurring( $object = false ) {
1797
+    /**
1798
+     * Retrieves the recurring item.
1799
+     *
1800
+     * @return null|GetPaid_Form_Item|int
1801
+     */
1802
+    public function get_recurring( $object = false ) {
1803 1803
 
1804
-		// Are we returning an object?
1804
+        // Are we returning an object?
1805 1805
         if ( $object ) {
1806 1806
             return $this->get_item( $this->recurring_item );
1807 1807
         }
@@ -1809,114 +1809,114 @@  discard block
 block discarded – undo
1809 1809
         return $this->recurring_item;
1810 1810
     }
1811 1811
 
1812
-	/**
1813
-	 * Retrieves the subscription name.
1814
-	 *
1815
-	 * @since 1.0.19
1816
-	 * @return string
1817
-	 */
1818
-	public function get_subscription_name() {
1812
+    /**
1813
+     * Retrieves the subscription name.
1814
+     *
1815
+     * @since 1.0.19
1816
+     * @return string
1817
+     */
1818
+    public function get_subscription_name() {
1819 1819
 
1820
-		// Retrieve the recurring name
1820
+        // Retrieve the recurring name
1821 1821
         $item = $this->get_recurring( true );
1822 1822
 
1823
-		// Abort if it does not exist.
1823
+        // Abort if it does not exist.
1824 1824
         if ( empty( $item ) ) {
1825 1825
             return '';
1826 1826
         }
1827 1827
 
1828
-		// Return the item name.
1828
+        // Return the item name.
1829 1829
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1830
-	}
1831
-
1832
-	/**
1833
-	 * Retrieves the view url.
1834
-	 *
1835
-	 * @since 1.0.19
1836
-	 * @return string
1837
-	 */
1838
-	public function get_view_url() {
1830
+    }
1831
+
1832
+    /**
1833
+     * Retrieves the view url.
1834
+     *
1835
+     * @since 1.0.19
1836
+     * @return string
1837
+     */
1838
+    public function get_view_url() {
1839 1839
         $invoice_url = get_permalink( $this->get_id() );
1840
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1840
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1841 1841
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1842
-	}
1842
+    }
1843 1843
 
1844
-	/**
1845
-	 * Retrieves the payment url.
1846
-	 *
1847
-	 * @since 1.0.19
1848
-	 * @return string
1849
-	 */
1850
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1844
+    /**
1845
+     * Retrieves the payment url.
1846
+     *
1847
+     * @since 1.0.19
1848
+     * @return string
1849
+     */
1850
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1851 1851
 
1852
-		// Retrieve the checkout url.
1852
+        // Retrieve the checkout url.
1853 1853
         $pay_url = wpinv_get_checkout_uri();
1854 1854
 
1855
-		// Maybe force ssl.
1855
+        // Maybe force ssl.
1856 1856
         if ( is_ssl() ) {
1857 1857
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1858 1858
         }
1859 1859
 
1860
-		// Add the invoice key.
1861
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1860
+        // Add the invoice key.
1861
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1862 1862
 
1863
-		// (Maybe?) add a secret
1863
+        // (Maybe?) add a secret
1864 1864
         if ( $secret ) {
1865 1865
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1866 1866
         }
1867 1867
 
1868 1868
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1869
-	}
1869
+    }
1870 1870
 	
1871
-	/**
1872
-	 * Retrieves the receipt url.
1873
-	 *
1874
-	 * @since 1.0.19
1875
-	 * @return string
1876
-	 */
1877
-	public function get_receipt_url() {
1878
-
1879
-		// Retrieve the checkout url.
1871
+    /**
1872
+     * Retrieves the receipt url.
1873
+     *
1874
+     * @since 1.0.19
1875
+     * @return string
1876
+     */
1877
+    public function get_receipt_url() {
1878
+
1879
+        // Retrieve the checkout url.
1880 1880
         $receipt_url = wpinv_get_success_page_uri();
1881 1881
 
1882
-		// Maybe force ssl.
1882
+        // Maybe force ssl.
1883 1883
         if ( is_ssl() ) {
1884 1884
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1885 1885
         }
1886 1886
 
1887
-		// Add the invoice key.
1888
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1887
+        // Add the invoice key.
1888
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1889 1889
 
1890 1890
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1891
-	}
1891
+    }
1892 1892
 	
1893
-	/**
1894
-	 * Retrieves the default status.
1895
-	 *
1896
-	 * @since 1.0.19
1897
-	 * @return string
1898
-	 */
1899
-	public function get_default_status() {
1900
-
1901
-		$type   = $this->get_type();
1902
-		$status = "wpi-$type-pending";
1903
-		return str_replace( '-invoice', '', $status );
1904
-
1905
-	}
1906
-
1907
-    /**
1908
-	 * Magic method for accessing invoice properties.
1909
-	 *
1910
-	 * @since 1.0.15
1911
-	 * @access public
1912
-	 *
1913
-	 * @param string $key Discount data to retrieve
1914
-	 * @param  string $context View or edit context.
1915
-	 * @return mixed Value of the given invoice property (if set).
1916
-	 */
1917
-	public function get( $key, $context = 'view' ) {
1893
+    /**
1894
+     * Retrieves the default status.
1895
+     *
1896
+     * @since 1.0.19
1897
+     * @return string
1898
+     */
1899
+    public function get_default_status() {
1900
+
1901
+        $type   = $this->get_type();
1902
+        $status = "wpi-$type-pending";
1903
+        return str_replace( '-invoice', '', $status );
1904
+
1905
+    }
1906
+
1907
+    /**
1908
+     * Magic method for accessing invoice properties.
1909
+     *
1910
+     * @since 1.0.15
1911
+     * @access public
1912
+     *
1913
+     * @param string $key Discount data to retrieve
1914
+     * @param  string $context View or edit context.
1915
+     * @return mixed Value of the given invoice property (if set).
1916
+     */
1917
+    public function get( $key, $context = 'view' ) {
1918 1918
         return $this->get_prop( $key, $context );
1919
-	}
1919
+    }
1920 1920
 
1921 1921
     /*
1922 1922
 	|--------------------------------------------------------------------------
@@ -1929,130 +1929,130 @@  discard block
 block discarded – undo
1929 1929
     */
1930 1930
 
1931 1931
     /**
1932
-	 * Magic method for setting invoice properties.
1933
-	 *
1934
-	 * @since 1.0.19
1935
-	 * @access public
1936
-	 *
1937
-	 * @param string $key Discount data to retrieve
1938
-	 * @param  mixed $value new value.
1939
-	 * @return mixed Value of the given invoice property (if set).
1940
-	 */
1941
-	public function set( $key, $value ) {
1932
+     * Magic method for setting invoice properties.
1933
+     *
1934
+     * @since 1.0.19
1935
+     * @access public
1936
+     *
1937
+     * @param string $key Discount data to retrieve
1938
+     * @param  mixed $value new value.
1939
+     * @return mixed Value of the given invoice property (if set).
1940
+     */
1941
+    public function set( $key, $value ) {
1942 1942
 
1943 1943
         $setter = "set_$key";
1944 1944
         if ( is_callable( array( $this, $setter ) ) ) {
1945 1945
             $this->{$setter}( $value );
1946 1946
         }
1947 1947
 
1948
-	}
1948
+    }
1949 1949
 
1950
-	/**
1951
-	 * Sets item status.
1952
-	 *
1953
-	 * @since 1.0.19
1954
-	 * @param string $new_status    New status.
1955
-	 * @param string $note          Optional note to add.
1956
-	 * @param bool   $manual_update Is this a manual status change?.
1957
-	 * @return array details of change.
1958
-	 */
1959
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1960
-		$old_status = $this->get_status();
1950
+    /**
1951
+     * Sets item status.
1952
+     *
1953
+     * @since 1.0.19
1954
+     * @param string $new_status    New status.
1955
+     * @param string $note          Optional note to add.
1956
+     * @param bool   $manual_update Is this a manual status change?.
1957
+     * @return array details of change.
1958
+     */
1959
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1960
+        $old_status = $this->get_status();
1961 1961
 
1962
-		$statuses = $this->get_all_statuses();
1962
+        $statuses = $this->get_all_statuses();
1963 1963
 
1964
-		if ( isset( $statuses[ 'draft' ] ) ) {
1965
-			unset( $statuses[ 'draft' ] );
1966
-		}
1964
+        if ( isset( $statuses[ 'draft' ] ) ) {
1965
+            unset( $statuses[ 'draft' ] );
1966
+        }
1967 1967
 
1968
-		$this->set_prop( 'status', $new_status );
1968
+        $this->set_prop( 'status', $new_status );
1969 1969
 
1970
-		// If setting the status, ensure it's set to a valid status.
1971
-		if ( true === $this->object_read ) {
1970
+        // If setting the status, ensure it's set to a valid status.
1971
+        if ( true === $this->object_read ) {
1972 1972
 
1973
-			// Only allow valid new status.
1974
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1975
-				$new_status = $this->get_default_status();
1976
-			}
1973
+            // Only allow valid new status.
1974
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1975
+                $new_status = $this->get_default_status();
1976
+            }
1977 1977
 
1978
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1979
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1980
-				$old_status = $this->get_default_status();
1981
-			}
1978
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1979
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1980
+                $old_status = $this->get_default_status();
1981
+            }
1982 1982
 
1983
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1984
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1985
-				$old_status = 'wpi-pending';
1986
-			}
1983
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1984
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1985
+                $old_status = 'wpi-pending';
1986
+            }
1987 1987
 
1988
-			if ( $old_status !== $new_status ) {
1989
-				$this->status_transition = array(
1990
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1991
-					'to'     => $new_status,
1992
-					'note'   => $note,
1993
-					'manual' => (bool) $manual_update,
1994
-				);
1988
+            if ( $old_status !== $new_status ) {
1989
+                $this->status_transition = array(
1990
+                    'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1991
+                    'to'     => $new_status,
1992
+                    'note'   => $note,
1993
+                    'manual' => (bool) $manual_update,
1994
+                );
1995 1995
 
1996
-				if ( $manual_update ) {
1997
-					do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1998
-				}
1996
+                if ( $manual_update ) {
1997
+                    do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1998
+                }
1999 1999
 
2000
-				$this->maybe_set_date_paid();
2000
+                $this->maybe_set_date_paid();
2001 2001
 
2002
-			}
2002
+            }
2003 2003
 
2004
-		}
2004
+        }
2005 2005
 
2006
-		return array(
2007
-			'from' => $old_status,
2008
-			'to'   => $new_status,
2009
-		);
2010
-	}
2006
+        return array(
2007
+            'from' => $old_status,
2008
+            'to'   => $new_status,
2009
+        );
2010
+    }
2011 2011
 
2012
-	/**
2013
-	 * Maybe set date paid.
2014
-	 *
2015
-	 * Sets the date paid variable when transitioning to the payment complete
2016
-	 * order status.
2017
-	 *
2018
-	 * @since 1.0.19
2019
-	 */
2020
-	public function maybe_set_date_paid() {
2012
+    /**
2013
+     * Maybe set date paid.
2014
+     *
2015
+     * Sets the date paid variable when transitioning to the payment complete
2016
+     * order status.
2017
+     *
2018
+     * @since 1.0.19
2019
+     */
2020
+    public function maybe_set_date_paid() {
2021 2021
 
2022
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2023
-			$this->set_date_completed( current_time( 'mysql' ) );
2024
-		}
2025
-	}
2022
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2023
+            $this->set_date_completed( current_time( 'mysql' ) );
2024
+        }
2025
+    }
2026 2026
 
2027 2027
     /**
2028
-	 * Set parent invoice ID.
2029
-	 *
2030
-	 * @since 1.0.19
2031
-	 */
2032
-	public function set_parent_id( $value ) {
2033
-		if ( $value && ( $value === $this->get_id() ) ) {
2034
-			return;
2035
-		}
2036
-		$this->set_prop( 'parent_id', absint( $value ) );
2028
+     * Set parent invoice ID.
2029
+     *
2030
+     * @since 1.0.19
2031
+     */
2032
+    public function set_parent_id( $value ) {
2033
+        if ( $value && ( $value === $this->get_id() ) ) {
2034
+            return;
2035
+        }
2036
+        $this->set_prop( 'parent_id', absint( $value ) );
2037 2037
     }
2038 2038
 
2039 2039
     /**
2040
-	 * Set plugin version when the invoice was created.
2041
-	 *
2042
-	 * @since 1.0.19
2043
-	 */
2044
-	public function set_version( $value ) {
2045
-		$this->set_prop( 'version', $value );
2040
+     * Set plugin version when the invoice was created.
2041
+     *
2042
+     * @since 1.0.19
2043
+     */
2044
+    public function set_version( $value ) {
2045
+        $this->set_prop( 'version', $value );
2046 2046
     }
2047
-
2048
-    /**
2049
-	 * Set date when the invoice was created.
2050
-	 *
2051
-	 * @since 1.0.19
2052
-	 * @param string $value Value to set.
2047
+
2048
+    /**
2049
+     * Set date when the invoice was created.
2050
+     *
2051
+     * @since 1.0.19
2052
+     * @param string $value Value to set.
2053 2053
      * @return bool Whether or not the date was set.
2054
-	 */
2055
-	public function set_date_created( $value ) {
2054
+     */
2055
+    public function set_date_created( $value ) {
2056 2056
         $date = strtotime( $value );
2057 2057
 
2058 2058
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2060,19 +2060,19 @@  discard block
 block discarded – undo
2060 2060
             return true;
2061 2061
         }
2062 2062
 
2063
-		$this->set_prop( 'date_created', '' );
2064
-		return false;
2063
+        $this->set_prop( 'date_created', '' );
2064
+        return false;
2065 2065
 
2066 2066
     }
2067 2067
 
2068 2068
     /**
2069
-	 * Set date invoice due date.
2070
-	 *
2071
-	 * @since 1.0.19
2072
-	 * @param string $value Value to set.
2069
+     * Set date invoice due date.
2070
+     *
2071
+     * @since 1.0.19
2072
+     * @param string $value Value to set.
2073 2073
      * @return bool Whether or not the date was set.
2074
-	 */
2075
-	public function set_due_date( $value ) {
2074
+     */
2075
+    public function set_due_date( $value ) {
2076 2076
         $date = strtotime( $value );
2077 2077
 
2078 2078
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2080,29 +2080,29 @@  discard block
 block discarded – undo
2080 2080
             return true;
2081 2081
         }
2082 2082
 
2083
-		$this->set_prop( 'due_date', '' );
2083
+        $this->set_prop( 'due_date', '' );
2084 2084
         return false;
2085 2085
 
2086 2086
     }
2087 2087
 
2088 2088
     /**
2089
-	 * Alias of self::set_due_date().
2090
-	 *
2091
-	 * @since 1.0.19
2092
-	 * @param  string $value New name.
2093
-	 */
2094
-	public function set_date_due( $value ) {
2095
-		$this->set_due_date( $value );
2089
+     * Alias of self::set_due_date().
2090
+     *
2091
+     * @since 1.0.19
2092
+     * @param  string $value New name.
2093
+     */
2094
+    public function set_date_due( $value ) {
2095
+        $this->set_due_date( $value );
2096 2096
     }
2097 2097
 
2098 2098
     /**
2099
-	 * Set date invoice was completed.
2100
-	 *
2101
-	 * @since 1.0.19
2102
-	 * @param string $value Value to set.
2099
+     * Set date invoice was completed.
2100
+     *
2101
+     * @since 1.0.19
2102
+     * @param string $value Value to set.
2103 2103
      * @return bool Whether or not the date was set.
2104
-	 */
2105
-	public function set_completed_date( $value ) {
2104
+     */
2105
+    public function set_completed_date( $value ) {
2106 2106
         $date = strtotime( $value );
2107 2107
 
2108 2108
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2110,29 +2110,29 @@  discard block
 block discarded – undo
2110 2110
             return true;
2111 2111
         }
2112 2112
 
2113
-		$this->set_prop( 'completed_date', '' );
2113
+        $this->set_prop( 'completed_date', '' );
2114 2114
         return false;
2115 2115
 
2116 2116
     }
2117 2117
 
2118 2118
     /**
2119
-	 * Alias of self::set_completed_date().
2120
-	 *
2121
-	 * @since 1.0.19
2122
-	 * @param  string $value New name.
2123
-	 */
2124
-	public function set_date_completed( $value ) {
2125
-		$this->set_completed_date( $value );
2119
+     * Alias of self::set_completed_date().
2120
+     *
2121
+     * @since 1.0.19
2122
+     * @param  string $value New name.
2123
+     */
2124
+    public function set_date_completed( $value ) {
2125
+        $this->set_completed_date( $value );
2126 2126
     }
2127 2127
 
2128 2128
     /**
2129
-	 * Set date when the invoice was last modified.
2130
-	 *
2131
-	 * @since 1.0.19
2132
-	 * @param string $value Value to set.
2129
+     * Set date when the invoice was last modified.
2130
+     *
2131
+     * @since 1.0.19
2132
+     * @param string $value Value to set.
2133 2133
      * @return bool Whether or not the date was set.
2134
-	 */
2135
-	public function set_date_modified( $value ) {
2134
+     */
2135
+    public function set_date_modified( $value ) {
2136 2136
         $date = strtotime( $value );
2137 2137
 
2138 2138
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2140,798 +2140,798 @@  discard block
 block discarded – undo
2140 2140
             return true;
2141 2141
         }
2142 2142
 
2143
-		$this->set_prop( 'date_modified', '' );
2143
+        $this->set_prop( 'date_modified', '' );
2144 2144
         return false;
2145 2145
 
2146 2146
     }
2147 2147
 
2148 2148
     /**
2149
-	 * Set the invoice number.
2150
-	 *
2151
-	 * @since 1.0.19
2152
-	 * @param  string $value New number.
2153
-	 */
2154
-	public function set_number( $value ) {
2149
+     * Set the invoice number.
2150
+     *
2151
+     * @since 1.0.19
2152
+     * @param  string $value New number.
2153
+     */
2154
+    public function set_number( $value ) {
2155 2155
         $number = sanitize_text_field( $value );
2156
-		$this->set_prop( 'number', $number );
2156
+        $this->set_prop( 'number', $number );
2157 2157
     }
2158 2158
 
2159 2159
     /**
2160
-	 * Set the invoice type.
2161
-	 *
2162
-	 * @since 1.0.19
2163
-	 * @param  string $value Type.
2164
-	 */
2165
-	public function set_type( $value ) {
2160
+     * Set the invoice type.
2161
+     *
2162
+     * @since 1.0.19
2163
+     * @param  string $value Type.
2164
+     */
2165
+    public function set_type( $value ) {
2166 2166
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2167
-		$this->set_prop( 'type', $type );
2168
-	}
2167
+        $this->set_prop( 'type', $type );
2168
+    }
2169 2169
 
2170 2170
     /**
2171
-	 * Set the invoice post type.
2172
-	 *
2173
-	 * @since 1.0.19
2174
-	 * @param  string $value Post type.
2175
-	 */
2176
-	public function set_post_type( $value ) {
2171
+     * Set the invoice post type.
2172
+     *
2173
+     * @since 1.0.19
2174
+     * @param  string $value Post type.
2175
+     */
2176
+    public function set_post_type( $value ) {
2177 2177
         if ( getpaid_is_invoice_post_type( $value ) ) {
2178
-			$this->set_type( $value );
2178
+            $this->set_type( $value );
2179 2179
             $this->set_prop( 'post_type', $value );
2180 2180
         }
2181 2181
     }
2182 2182
 
2183 2183
     /**
2184
-	 * Set the invoice key.
2185
-	 *
2186
-	 * @since 1.0.19
2187
-	 * @param  string $value New key.
2188
-	 */
2189
-	public function set_key( $value ) {
2184
+     * Set the invoice key.
2185
+     *
2186
+     * @since 1.0.19
2187
+     * @param  string $value New key.
2188
+     */
2189
+    public function set_key( $value ) {
2190 2190
         $key = sanitize_text_field( $value );
2191
-		$this->set_prop( 'key', $key );
2191
+        $this->set_prop( 'key', $key );
2192 2192
     }
2193 2193
 
2194 2194
     /**
2195
-	 * Set the invoice mode.
2196
-	 *
2197
-	 * @since 1.0.19
2198
-	 * @param  string $value mode.
2199
-	 */
2200
-	public function set_mode( $value ) {
2195
+     * Set the invoice mode.
2196
+     *
2197
+     * @since 1.0.19
2198
+     * @param  string $value mode.
2199
+     */
2200
+    public function set_mode( $value ) {
2201 2201
         if ( in_array( $value, array( 'live', 'test' ) ) ) {
2202 2202
             $this->set_prop( 'mode', $value );
2203 2203
         }
2204 2204
     }
2205 2205
 
2206 2206
     /**
2207
-	 * Set the invoice path.
2208
-	 *
2209
-	 * @since 1.0.19
2210
-	 * @param  string $value path.
2211
-	 */
2212
-	public function set_path( $value ) {
2207
+     * Set the invoice path.
2208
+     *
2209
+     * @since 1.0.19
2210
+     * @param  string $value path.
2211
+     */
2212
+    public function set_path( $value ) {
2213 2213
         $this->set_prop( 'path', $value );
2214 2214
     }
2215 2215
 
2216 2216
     /**
2217
-	 * Set the invoice name.
2218
-	 *
2219
-	 * @since 1.0.19
2220
-	 * @param  string $value New name.
2221
-	 */
2222
-	public function set_name( $value ) {
2217
+     * Set the invoice name.
2218
+     *
2219
+     * @since 1.0.19
2220
+     * @param  string $value New name.
2221
+     */
2222
+    public function set_name( $value ) {
2223 2223
         $name = sanitize_text_field( $value );
2224
-		$this->set_prop( 'name', $name );
2224
+        $this->set_prop( 'name', $name );
2225 2225
     }
2226 2226
 
2227 2227
     /**
2228
-	 * Alias of self::set_name().
2229
-	 *
2230
-	 * @since 1.0.19
2231
-	 * @param  string $value New name.
2232
-	 */
2233
-	public function set_title( $value ) {
2234
-		$this->set_name( $value );
2228
+     * Alias of self::set_name().
2229
+     *
2230
+     * @since 1.0.19
2231
+     * @param  string $value New name.
2232
+     */
2233
+    public function set_title( $value ) {
2234
+        $this->set_name( $value );
2235 2235
     }
2236 2236
 
2237 2237
     /**
2238
-	 * Set the invoice description.
2239
-	 *
2240
-	 * @since 1.0.19
2241
-	 * @param  string $value New description.
2242
-	 */
2243
-	public function set_description( $value ) {
2238
+     * Set the invoice description.
2239
+     *
2240
+     * @since 1.0.19
2241
+     * @param  string $value New description.
2242
+     */
2243
+    public function set_description( $value ) {
2244 2244
         $description = wp_kses_post( $value );
2245
-		$this->set_prop( 'description', $description );
2245
+        $this->set_prop( 'description', $description );
2246
+    }
2247
+
2248
+    /**
2249
+     * Alias of self::set_description().
2250
+     *
2251
+     * @since 1.0.19
2252
+     * @param  string $value New description.
2253
+     */
2254
+    public function set_excerpt( $value ) {
2255
+        $this->set_description( $value );
2256
+    }
2257
+
2258
+    /**
2259
+     * Alias of self::set_description().
2260
+     *
2261
+     * @since 1.0.19
2262
+     * @param  string $value New description.
2263
+     */
2264
+    public function set_summary( $value ) {
2265
+        $this->set_description( $value );
2266
+    }
2267
+
2268
+    /**
2269
+     * Set the receiver of the invoice.
2270
+     *
2271
+     * @since 1.0.19
2272
+     * @param  int $value New author.
2273
+     */
2274
+    public function set_author( $value ) {
2275
+        $user = get_user_by( 'id', (int) $value );
2276
+
2277
+        if ( $user && $user->ID ) {
2278
+            $this->set_prop( 'author', $user->ID );
2279
+            $this->set_prop( 'email', $user->user_email );
2280
+        }
2281
+
2282
+    }
2283
+
2284
+    /**
2285
+     * Alias of self::set_author().
2286
+     *
2287
+     * @since 1.0.19
2288
+     * @param  int $value New user id.
2289
+     */
2290
+    public function set_user_id( $value ) {
2291
+        $this->set_author( $value );
2292
+    }
2293
+
2294
+    /**
2295
+     * Alias of self::set_author().
2296
+     *
2297
+     * @since 1.0.19
2298
+     * @param  int $value New user id.
2299
+     */
2300
+    public function set_customer_id( $value ) {
2301
+        $this->set_author( $value );
2302
+    }
2303
+
2304
+    /**
2305
+     * Set the customer's ip.
2306
+     *
2307
+     * @since 1.0.19
2308
+     * @param  string $value ip address.
2309
+     */
2310
+    public function set_ip( $value ) {
2311
+        $this->set_prop( 'ip', $value );
2312
+    }
2313
+
2314
+    /**
2315
+     * Alias of self::set_ip().
2316
+     *
2317
+     * @since 1.0.19
2318
+     * @param  string $value ip address.
2319
+     */
2320
+    public function set_user_ip( $value ) {
2321
+        $this->set_ip( $value );
2322
+    }
2323
+
2324
+    /**
2325
+     * Set the customer's first name.
2326
+     *
2327
+     * @since 1.0.19
2328
+     * @param  string $value first name.
2329
+     */
2330
+    public function set_first_name( $value ) {
2331
+        $this->set_prop( 'first_name', $value );
2332
+    }
2333
+
2334
+    /**
2335
+     * Alias of self::set_first_name().
2336
+     *
2337
+     * @since 1.0.19
2338
+     * @param  string $value first name.
2339
+     */
2340
+    public function set_user_first_name( $value ) {
2341
+        $this->set_first_name( $value );
2342
+    }
2343
+
2344
+    /**
2345
+     * Alias of self::set_first_name().
2346
+     *
2347
+     * @since 1.0.19
2348
+     * @param  string $value first name.
2349
+     */
2350
+    public function set_customer_first_name( $value ) {
2351
+        $this->set_first_name( $value );
2352
+    }
2353
+
2354
+    /**
2355
+     * Set the customer's last name.
2356
+     *
2357
+     * @since 1.0.19
2358
+     * @param  string $value last name.
2359
+     */
2360
+    public function set_last_name( $value ) {
2361
+        $this->set_prop( 'last_name', $value );
2246 2362
     }
2247 2363
 
2248 2364
     /**
2249
-	 * Alias of self::set_description().
2250
-	 *
2251
-	 * @since 1.0.19
2252
-	 * @param  string $value New description.
2253
-	 */
2254
-	public function set_excerpt( $value ) {
2255
-		$this->set_description( $value );
2365
+     * Alias of self::set_last_name().
2366
+     *
2367
+     * @since 1.0.19
2368
+     * @param  string $value last name.
2369
+     */
2370
+    public function set_user_last_name( $value ) {
2371
+        $this->set_last_name( $value );
2372
+    }
2373
+
2374
+    /**
2375
+     * Alias of self::set_last_name().
2376
+     *
2377
+     * @since 1.0.19
2378
+     * @param  string $value last name.
2379
+     */
2380
+    public function set_customer_last_name( $value ) {
2381
+        $this->set_last_name( $value );
2382
+    }
2383
+
2384
+    /**
2385
+     * Set the customer's phone number.
2386
+     *
2387
+     * @since 1.0.19
2388
+     * @param  string $value phone.
2389
+     */
2390
+    public function set_phone( $value ) {
2391
+        $this->set_prop( 'phone', $value );
2256 2392
     }
2257 2393
 
2258 2394
     /**
2259
-	 * Alias of self::set_description().
2260
-	 *
2261
-	 * @since 1.0.19
2262
-	 * @param  string $value New description.
2263
-	 */
2264
-	public function set_summary( $value ) {
2265
-		$this->set_description( $value );
2395
+     * Alias of self::set_phone().
2396
+     *
2397
+     * @since 1.0.19
2398
+     * @param  string $value phone.
2399
+     */
2400
+    public function set_user_phone( $value ) {
2401
+        $this->set_phone( $value );
2266 2402
     }
2267 2403
 
2268 2404
     /**
2269
-	 * Set the receiver of the invoice.
2270
-	 *
2271
-	 * @since 1.0.19
2272
-	 * @param  int $value New author.
2273
-	 */
2274
-	public function set_author( $value ) {
2275
-		$user = get_user_by( 'id', (int) $value );
2405
+     * Alias of self::set_phone().
2406
+     *
2407
+     * @since 1.0.19
2408
+     * @param  string $value phone.
2409
+     */
2410
+    public function set_customer_phone( $value ) {
2411
+        $this->set_phone( $value );
2412
+    }
2276 2413
 
2277
-		if ( $user && $user->ID ) {
2278
-			$this->set_prop( 'author', $user->ID );
2279
-			$this->set_prop( 'email', $user->user_email );
2280
-		}
2414
+    /**
2415
+     * Alias of self::set_phone().
2416
+     *
2417
+     * @since 1.0.19
2418
+     * @param  string $value phone.
2419
+     */
2420
+    public function set_phone_number( $value ) {
2421
+        $this->set_phone( $value );
2422
+    }
2281 2423
 
2424
+    /**
2425
+     * Set the customer's email address.
2426
+     *
2427
+     * @since 1.0.19
2428
+     * @param  string $value email address.
2429
+     */
2430
+    public function set_email( $value ) {
2431
+        $this->set_prop( 'email', $value );
2282 2432
     }
2283 2433
 
2284 2434
     /**
2285
-	 * Alias of self::set_author().
2286
-	 *
2287
-	 * @since 1.0.19
2288
-	 * @param  int $value New user id.
2289
-	 */
2290
-	public function set_user_id( $value ) {
2291
-		$this->set_author( $value );
2435
+     * Alias of self::set_email().
2436
+     *
2437
+     * @since 1.0.19
2438
+     * @param  string $value email address.
2439
+     */
2440
+    public function set_user_email( $value ) {
2441
+        $this->set_email( $value );
2292 2442
     }
2293 2443
 
2294 2444
     /**
2295
-	 * Alias of self::set_author().
2296
-	 *
2297
-	 * @since 1.0.19
2298
-	 * @param  int $value New user id.
2299
-	 */
2300
-	public function set_customer_id( $value ) {
2301
-		$this->set_author( $value );
2445
+     * Alias of self::set_email().
2446
+     *
2447
+     * @since 1.0.19
2448
+     * @param  string $value email address.
2449
+     */
2450
+    public function set_email_address( $value ) {
2451
+        $this->set_email( $value );
2302 2452
     }
2303 2453
 
2304 2454
     /**
2305
-	 * Set the customer's ip.
2306
-	 *
2307
-	 * @since 1.0.19
2308
-	 * @param  string $value ip address.
2309
-	 */
2310
-	public function set_ip( $value ) {
2311
-		$this->set_prop( 'ip', $value );
2455
+     * Alias of self::set_email().
2456
+     *
2457
+     * @since 1.0.19
2458
+     * @param  string $value email address.
2459
+     */
2460
+    public function set_customer_email( $value ) {
2461
+        $this->set_email( $value );
2312 2462
     }
2313 2463
 
2314 2464
     /**
2315
-	 * Alias of self::set_ip().
2316
-	 *
2317
-	 * @since 1.0.19
2318
-	 * @param  string $value ip address.
2319
-	 */
2320
-	public function set_user_ip( $value ) {
2321
-		$this->set_ip( $value );
2465
+     * Set the customer's country.
2466
+     *
2467
+     * @since 1.0.19
2468
+     * @param  string $value country.
2469
+     */
2470
+    public function set_country( $value ) {
2471
+        $this->set_prop( 'country', $value );
2322 2472
     }
2323 2473
 
2324 2474
     /**
2325
-	 * Set the customer's first name.
2326
-	 *
2327
-	 * @since 1.0.19
2328
-	 * @param  string $value first name.
2329
-	 */
2330
-	public function set_first_name( $value ) {
2331
-		$this->set_prop( 'first_name', $value );
2475
+     * Alias of self::set_country().
2476
+     *
2477
+     * @since 1.0.19
2478
+     * @param  string $value country.
2479
+     */
2480
+    public function set_user_country( $value ) {
2481
+        $this->set_country( $value );
2332 2482
     }
2333 2483
 
2334 2484
     /**
2335
-	 * Alias of self::set_first_name().
2336
-	 *
2337
-	 * @since 1.0.19
2338
-	 * @param  string $value first name.
2339
-	 */
2340
-	public function set_user_first_name( $value ) {
2341
-		$this->set_first_name( $value );
2485
+     * Alias of self::set_country().
2486
+     *
2487
+     * @since 1.0.19
2488
+     * @param  string $value country.
2489
+     */
2490
+    public function set_customer_country( $value ) {
2491
+        $this->set_country( $value );
2342 2492
     }
2343 2493
 
2344 2494
     /**
2345
-	 * Alias of self::set_first_name().
2346
-	 *
2347
-	 * @since 1.0.19
2348
-	 * @param  string $value first name.
2349
-	 */
2350
-	public function set_customer_first_name( $value ) {
2351
-		$this->set_first_name( $value );
2495
+     * Set the customer's state.
2496
+     *
2497
+     * @since 1.0.19
2498
+     * @param  string $value state.
2499
+     */
2500
+    public function set_state( $value ) {
2501
+        $this->set_prop( 'state', $value );
2352 2502
     }
2353 2503
 
2354 2504
     /**
2355
-	 * Set the customer's last name.
2356
-	 *
2357
-	 * @since 1.0.19
2358
-	 * @param  string $value last name.
2359
-	 */
2360
-	public function set_last_name( $value ) {
2361
-		$this->set_prop( 'last_name', $value );
2505
+     * Alias of self::set_state().
2506
+     *
2507
+     * @since 1.0.19
2508
+     * @param  string $value state.
2509
+     */
2510
+    public function set_user_state( $value ) {
2511
+        $this->set_state( $value );
2362 2512
     }
2363 2513
 
2364 2514
     /**
2365
-	 * Alias of self::set_last_name().
2366
-	 *
2367
-	 * @since 1.0.19
2368
-	 * @param  string $value last name.
2369
-	 */
2370
-	public function set_user_last_name( $value ) {
2371
-		$this->set_last_name( $value );
2515
+     * Alias of self::set_state().
2516
+     *
2517
+     * @since 1.0.19
2518
+     * @param  string $value state.
2519
+     */
2520
+    public function set_customer_state( $value ) {
2521
+        $this->set_state( $value );
2372 2522
     }
2373 2523
 
2374 2524
     /**
2375
-	 * Alias of self::set_last_name().
2376
-	 *
2377
-	 * @since 1.0.19
2378
-	 * @param  string $value last name.
2379
-	 */
2380
-	public function set_customer_last_name( $value ) {
2381
-		$this->set_last_name( $value );
2525
+     * Set the customer's city.
2526
+     *
2527
+     * @since 1.0.19
2528
+     * @param  string $value city.
2529
+     */
2530
+    public function set_city( $value ) {
2531
+        $this->set_prop( 'city', $value );
2382 2532
     }
2383 2533
 
2384 2534
     /**
2385
-	 * Set the customer's phone number.
2386
-	 *
2387
-	 * @since 1.0.19
2388
-	 * @param  string $value phone.
2389
-	 */
2390
-	public function set_phone( $value ) {
2391
-		$this->set_prop( 'phone', $value );
2535
+     * Alias of self::set_city().
2536
+     *
2537
+     * @since 1.0.19
2538
+     * @param  string $value city.
2539
+     */
2540
+    public function set_user_city( $value ) {
2541
+        $this->set_city( $value );
2392 2542
     }
2393 2543
 
2394 2544
     /**
2395
-	 * Alias of self::set_phone().
2396
-	 *
2397
-	 * @since 1.0.19
2398
-	 * @param  string $value phone.
2399
-	 */
2400
-	public function set_user_phone( $value ) {
2401
-		$this->set_phone( $value );
2545
+     * Alias of self::set_city().
2546
+     *
2547
+     * @since 1.0.19
2548
+     * @param  string $value city.
2549
+     */
2550
+    public function set_customer_city( $value ) {
2551
+        $this->set_city( $value );
2402 2552
     }
2403 2553
 
2404 2554
     /**
2405
-	 * Alias of self::set_phone().
2406
-	 *
2407
-	 * @since 1.0.19
2408
-	 * @param  string $value phone.
2409
-	 */
2410
-	public function set_customer_phone( $value ) {
2411
-		$this->set_phone( $value );
2555
+     * Set the customer's zip code.
2556
+     *
2557
+     * @since 1.0.19
2558
+     * @param  string $value zip.
2559
+     */
2560
+    public function set_zip( $value ) {
2561
+        $this->set_prop( 'zip', $value );
2412 2562
     }
2413 2563
 
2414 2564
     /**
2415
-	 * Alias of self::set_phone().
2416
-	 *
2417
-	 * @since 1.0.19
2418
-	 * @param  string $value phone.
2419
-	 */
2420
-	public function set_phone_number( $value ) {
2421
-		$this->set_phone( $value );
2565
+     * Alias of self::set_zip().
2566
+     *
2567
+     * @since 1.0.19
2568
+     * @param  string $value zip.
2569
+     */
2570
+    public function set_user_zip( $value ) {
2571
+        $this->set_zip( $value );
2422 2572
     }
2423 2573
 
2424 2574
     /**
2425
-	 * Set the customer's email address.
2426
-	 *
2427
-	 * @since 1.0.19
2428
-	 * @param  string $value email address.
2429
-	 */
2430
-	public function set_email( $value ) {
2431
-		$this->set_prop( 'email', $value );
2575
+     * Alias of self::set_zip().
2576
+     *
2577
+     * @since 1.0.19
2578
+     * @param  string $value zip.
2579
+     */
2580
+    public function set_customer_zip( $value ) {
2581
+        $this->set_zip( $value );
2432 2582
     }
2433 2583
 
2434 2584
     /**
2435
-	 * Alias of self::set_email().
2436
-	 *
2437
-	 * @since 1.0.19
2438
-	 * @param  string $value email address.
2439
-	 */
2440
-	public function set_user_email( $value ) {
2441
-		$this->set_email( $value );
2585
+     * Set the customer's company.
2586
+     *
2587
+     * @since 1.0.19
2588
+     * @param  string $value company.
2589
+     */
2590
+    public function set_company( $value ) {
2591
+        $this->set_prop( 'company', $value );
2442 2592
     }
2443 2593
 
2444 2594
     /**
2445
-	 * Alias of self::set_email().
2446
-	 *
2447
-	 * @since 1.0.19
2448
-	 * @param  string $value email address.
2449
-	 */
2450
-	public function set_email_address( $value ) {
2451
-		$this->set_email( $value );
2595
+     * Alias of self::set_company().
2596
+     *
2597
+     * @since 1.0.19
2598
+     * @param  string $value company.
2599
+     */
2600
+    public function set_user_company( $value ) {
2601
+        $this->set_company( $value );
2452 2602
     }
2453 2603
 
2454 2604
     /**
2455
-	 * Alias of self::set_email().
2456
-	 *
2457
-	 * @since 1.0.19
2458
-	 * @param  string $value email address.
2459
-	 */
2460
-	public function set_customer_email( $value ) {
2461
-		$this->set_email( $value );
2605
+     * Alias of self::set_company().
2606
+     *
2607
+     * @since 1.0.19
2608
+     * @param  string $value company.
2609
+     */
2610
+    public function set_customer_company( $value ) {
2611
+        $this->set_company( $value );
2462 2612
     }
2463 2613
 
2464 2614
     /**
2465
-	 * Set the customer's country.
2466
-	 *
2467
-	 * @since 1.0.19
2468
-	 * @param  string $value country.
2469
-	 */
2470
-	public function set_country( $value ) {
2471
-		$this->set_prop( 'country', $value );
2615
+     * Set the customer's company id.
2616
+     *
2617
+     * @since 1.0.19
2618
+     * @param  string $value company id.
2619
+     */
2620
+    public function set_company_id( $value ) {
2621
+        $this->set_prop( 'company_id', $value );
2472 2622
     }
2473 2623
 
2474 2624
     /**
2475
-	 * Alias of self::set_country().
2476
-	 *
2477
-	 * @since 1.0.19
2478
-	 * @param  string $value country.
2479
-	 */
2480
-	public function set_user_country( $value ) {
2481
-		$this->set_country( $value );
2625
+     * Set the customer's var number.
2626
+     *
2627
+     * @since 1.0.19
2628
+     * @param  string $value var number.
2629
+     */
2630
+    public function set_vat_number( $value ) {
2631
+        $this->set_prop( 'vat_number', $value );
2482 2632
     }
2483 2633
 
2484 2634
     /**
2485
-	 * Alias of self::set_country().
2486
-	 *
2487
-	 * @since 1.0.19
2488
-	 * @param  string $value country.
2489
-	 */
2490
-	public function set_customer_country( $value ) {
2491
-		$this->set_country( $value );
2635
+     * Alias of self::set_vat_number().
2636
+     *
2637
+     * @since 1.0.19
2638
+     * @param  string $value var number.
2639
+     */
2640
+    public function set_user_vat_number( $value ) {
2641
+        $this->set_vat_number( $value );
2492 2642
     }
2493 2643
 
2494 2644
     /**
2495
-	 * Set the customer's state.
2496
-	 *
2497
-	 * @since 1.0.19
2498
-	 * @param  string $value state.
2499
-	 */
2500
-	public function set_state( $value ) {
2501
-		$this->set_prop( 'state', $value );
2645
+     * Alias of self::set_vat_number().
2646
+     *
2647
+     * @since 1.0.19
2648
+     * @param  string $value var number.
2649
+     */
2650
+    public function set_customer_vat_number( $value ) {
2651
+        $this->set_vat_number( $value );
2502 2652
     }
2503 2653
 
2504 2654
     /**
2505
-	 * Alias of self::set_state().
2506
-	 *
2507
-	 * @since 1.0.19
2508
-	 * @param  string $value state.
2509
-	 */
2510
-	public function set_user_state( $value ) {
2511
-		$this->set_state( $value );
2655
+     * Set the customer's vat rate.
2656
+     *
2657
+     * @since 1.0.19
2658
+     * @param  string $value var rate.
2659
+     */
2660
+    public function set_vat_rate( $value ) {
2661
+        $this->set_prop( 'vat_rate', $value );
2512 2662
     }
2513 2663
 
2514 2664
     /**
2515
-	 * Alias of self::set_state().
2516
-	 *
2517
-	 * @since 1.0.19
2518
-	 * @param  string $value state.
2519
-	 */
2520
-	public function set_customer_state( $value ) {
2521
-		$this->set_state( $value );
2665
+     * Alias of self::set_vat_rate().
2666
+     *
2667
+     * @since 1.0.19
2668
+     * @param  string $value var number.
2669
+     */
2670
+    public function set_user_vat_rate( $value ) {
2671
+        $this->set_vat_rate( $value );
2522 2672
     }
2523 2673
 
2524 2674
     /**
2525
-	 * Set the customer's city.
2526
-	 *
2527
-	 * @since 1.0.19
2528
-	 * @param  string $value city.
2529
-	 */
2530
-	public function set_city( $value ) {
2531
-		$this->set_prop( 'city', $value );
2675
+     * Alias of self::set_vat_rate().
2676
+     *
2677
+     * @since 1.0.19
2678
+     * @param  string $value var number.
2679
+     */
2680
+    public function set_customer_vat_rate( $value ) {
2681
+        $this->set_vat_rate( $value );
2532 2682
     }
2533 2683
 
2534 2684
     /**
2535
-	 * Alias of self::set_city().
2536
-	 *
2537
-	 * @since 1.0.19
2538
-	 * @param  string $value city.
2539
-	 */
2540
-	public function set_user_city( $value ) {
2541
-		$this->set_city( $value );
2685
+     * Set the customer's address.
2686
+     *
2687
+     * @since 1.0.19
2688
+     * @param  string $value address.
2689
+     */
2690
+    public function set_address( $value ) {
2691
+        $this->set_prop( 'address', $value );
2542 2692
     }
2543 2693
 
2544 2694
     /**
2545
-	 * Alias of self::set_city().
2546
-	 *
2547
-	 * @since 1.0.19
2548
-	 * @param  string $value city.
2549
-	 */
2550
-	public function set_customer_city( $value ) {
2551
-		$this->set_city( $value );
2695
+     * Alias of self::set_address().
2696
+     *
2697
+     * @since 1.0.19
2698
+     * @param  string $value address.
2699
+     */
2700
+    public function set_user_address( $value ) {
2701
+        $this->set_address( $value );
2552 2702
     }
2553 2703
 
2554 2704
     /**
2555
-	 * Set the customer's zip code.
2556
-	 *
2557
-	 * @since 1.0.19
2558
-	 * @param  string $value zip.
2559
-	 */
2560
-	public function set_zip( $value ) {
2561
-		$this->set_prop( 'zip', $value );
2705
+     * Alias of self::set_address().
2706
+     *
2707
+     * @since 1.0.19
2708
+     * @param  string $value address.
2709
+     */
2710
+    public function set_customer_address( $value ) {
2711
+        $this->set_address( $value );
2562 2712
     }
2563 2713
 
2564 2714
     /**
2565
-	 * Alias of self::set_zip().
2566
-	 *
2567
-	 * @since 1.0.19
2568
-	 * @param  string $value zip.
2569
-	 */
2570
-	public function set_user_zip( $value ) {
2571
-		$this->set_zip( $value );
2715
+     * Set whether the customer has viewed the invoice or not.
2716
+     *
2717
+     * @since 1.0.19
2718
+     * @param  int|bool $value confirmed.
2719
+     */
2720
+    public function set_is_viewed( $value ) {
2721
+        $this->set_prop( 'is_viewed', $value );
2572 2722
     }
2573 2723
 
2574 2724
     /**
2575
-	 * Alias of self::set_zip().
2576
-	 *
2577
-	 * @since 1.0.19
2578
-	 * @param  string $value zip.
2579
-	 */
2580
-	public function set_customer_zip( $value ) {
2581
-		$this->set_zip( $value );
2725
+     * Set extra email recipients.
2726
+     *
2727
+     * @since 1.0.19
2728
+     * @param  string $value email recipients.
2729
+     */
2730
+    public function set_email_cc( $value ) {
2731
+        $this->set_prop( 'email_cc', $value );
2582 2732
     }
2583 2733
 
2584 2734
     /**
2585
-	 * Set the customer's company.
2586
-	 *
2587
-	 * @since 1.0.19
2588
-	 * @param  string $value company.
2589
-	 */
2590
-	public function set_company( $value ) {
2591
-		$this->set_prop( 'company', $value );
2735
+     * Set the invoice template.
2736
+     *
2737
+     * @since 1.0.19
2738
+     * @param  string $value template.
2739
+     */
2740
+    public function set_template( $value ) {
2741
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2742
+            $this->set_prop( 'template', $value );
2743
+        }
2592 2744
     }
2593 2745
 
2594 2746
     /**
2595
-	 * Alias of self::set_company().
2596
-	 *
2597
-	 * @since 1.0.19
2598
-	 * @param  string $value company.
2599
-	 */
2600
-	public function set_user_company( $value ) {
2601
-		$this->set_company( $value );
2747
+     * Set the invoice source.
2748
+     *
2749
+     * @since 1.0.19
2750
+     * @param  string $value source.
2751
+     * @deprecated
2752
+     */
2753
+    public function created_via( $value ) {
2754
+        $this->set_created_via( sanitize_text_field( $value ) );
2602 2755
     }
2603 2756
 
2604 2757
     /**
2605
-	 * Alias of self::set_company().
2606
-	 *
2607
-	 * @since 1.0.19
2608
-	 * @param  string $value company.
2609
-	 */
2610
-	public function set_customer_company( $value ) {
2611
-		$this->set_company( $value );
2758
+     * Set the invoice source.
2759
+     *
2760
+     * @since 1.0.19
2761
+     * @param  string $value source.
2762
+     */
2763
+    public function set_created_via( $value ) {
2764
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2612 2765
     }
2613 2766
 
2614
-	/**
2615
-	 * Set the customer's company id.
2616
-	 *
2617
-	 * @since 1.0.19
2618
-	 * @param  string $value company id.
2619
-	 */
2620
-	public function set_company_id( $value ) {
2621
-		$this->set_prop( 'company_id', $value );
2767
+    /**
2768
+     * Set the customer's address confirmed status.
2769
+     *
2770
+     * @since 1.0.19
2771
+     * @param  int|bool $value confirmed.
2772
+     */
2773
+    public function set_address_confirmed( $value ) {
2774
+        $this->set_prop( 'address_confirmed', $value );
2622 2775
     }
2623 2776
 
2624 2777
     /**
2625
-	 * Set the customer's var number.
2626
-	 *
2627
-	 * @since 1.0.19
2628
-	 * @param  string $value var number.
2629
-	 */
2630
-	public function set_vat_number( $value ) {
2631
-		$this->set_prop( 'vat_number', $value );
2778
+     * Alias of self::set_address_confirmed().
2779
+     *
2780
+     * @since 1.0.19
2781
+     * @param  int|bool $value confirmed.
2782
+     */
2783
+    public function set_user_address_confirmed( $value ) {
2784
+        $this->set_address_confirmed( $value );
2632 2785
     }
2633 2786
 
2634 2787
     /**
2635
-	 * Alias of self::set_vat_number().
2636
-	 *
2637
-	 * @since 1.0.19
2638
-	 * @param  string $value var number.
2639
-	 */
2640
-	public function set_user_vat_number( $value ) {
2641
-		$this->set_vat_number( $value );
2788
+     * Alias of self::set_address_confirmed().
2789
+     *
2790
+     * @since 1.0.19
2791
+     * @param  int|bool $value confirmed.
2792
+     */
2793
+    public function set_customer_address_confirmed( $value ) {
2794
+        $this->set_address_confirmed( $value );
2642 2795
     }
2643 2796
 
2644 2797
     /**
2645
-	 * Alias of self::set_vat_number().
2646
-	 *
2647
-	 * @since 1.0.19
2648
-	 * @param  string $value var number.
2649
-	 */
2650
-	public function set_customer_vat_number( $value ) {
2651
-		$this->set_vat_number( $value );
2798
+     * Set the invoice sub total.
2799
+     *
2800
+     * @since 1.0.19
2801
+     * @param  float $value sub total.
2802
+     */
2803
+    public function set_subtotal( $value ) {
2804
+        $this->set_prop( 'subtotal', max( 0, $value ) );
2652 2805
     }
2653 2806
 
2654 2807
     /**
2655
-	 * Set the customer's vat rate.
2656
-	 *
2657
-	 * @since 1.0.19
2658
-	 * @param  string $value var rate.
2659
-	 */
2660
-	public function set_vat_rate( $value ) {
2661
-		$this->set_prop( 'vat_rate', $value );
2808
+     * Set the invoice total.
2809
+     *
2810
+     * @since 1.0.19
2811
+     * @param  float $value sub total.
2812
+     */
2813
+    public function set_total( $value ) {
2814
+        $this->set_prop( 'total', max( 0, $value ) );
2662 2815
     }
2663 2816
 
2664
-    /**
2665
-	 * Alias of self::set_vat_rate().
2666
-	 *
2667
-	 * @since 1.0.19
2668
-	 * @param  string $value var number.
2669
-	 */
2670
-	public function set_user_vat_rate( $value ) {
2671
-		$this->set_vat_rate( $value );
2672
-    }
2673
-
2674
-    /**
2675
-	 * Alias of self::set_vat_rate().
2676
-	 *
2677
-	 * @since 1.0.19
2678
-	 * @param  string $value var number.
2679
-	 */
2680
-	public function set_customer_vat_rate( $value ) {
2681
-		$this->set_vat_rate( $value );
2682
-    }
2683
-
2684
-    /**
2685
-	 * Set the customer's address.
2686
-	 *
2687
-	 * @since 1.0.19
2688
-	 * @param  string $value address.
2689
-	 */
2690
-	public function set_address( $value ) {
2691
-		$this->set_prop( 'address', $value );
2692
-    }
2693
-
2694
-    /**
2695
-	 * Alias of self::set_address().
2696
-	 *
2697
-	 * @since 1.0.19
2698
-	 * @param  string $value address.
2699
-	 */
2700
-	public function set_user_address( $value ) {
2701
-		$this->set_address( $value );
2702
-    }
2703
-
2704
-    /**
2705
-	 * Alias of self::set_address().
2706
-	 *
2707
-	 * @since 1.0.19
2708
-	 * @param  string $value address.
2709
-	 */
2710
-	public function set_customer_address( $value ) {
2711
-		$this->set_address( $value );
2712
-    }
2713
-
2714
-    /**
2715
-	 * Set whether the customer has viewed the invoice or not.
2716
-	 *
2717
-	 * @since 1.0.19
2718
-	 * @param  int|bool $value confirmed.
2719
-	 */
2720
-	public function set_is_viewed( $value ) {
2721
-		$this->set_prop( 'is_viewed', $value );
2722
-	}
2723
-
2724
-	/**
2725
-	 * Set extra email recipients.
2726
-	 *
2727
-	 * @since 1.0.19
2728
-	 * @param  string $value email recipients.
2729
-	 */
2730
-	public function set_email_cc( $value ) {
2731
-		$this->set_prop( 'email_cc', $value );
2732
-	}
2733
-
2734
-	/**
2735
-	 * Set the invoice template.
2736
-	 *
2737
-	 * @since 1.0.19
2738
-	 * @param  string $value template.
2739
-	 */
2740
-	public function set_template( $value ) {
2741
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2742
-			$this->set_prop( 'template', $value );
2743
-		}
2744
-	}
2745
-
2746
-	/**
2747
-	 * Set the invoice source.
2748
-	 *
2749
-	 * @since 1.0.19
2750
-	 * @param  string $value source.
2751
-	 * @deprecated
2752
-	 */
2753
-	public function created_via( $value ) {
2754
-		$this->set_created_via( sanitize_text_field( $value ) );
2755
-	}
2756
-
2757
-	/**
2758
-	 * Set the invoice source.
2759
-	 *
2760
-	 * @since 1.0.19
2761
-	 * @param  string $value source.
2762
-	 */
2763
-	public function set_created_via( $value ) {
2764
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2765
-	}
2766
-
2767
-	/**
2768
-	 * Set the customer's address confirmed status.
2769
-	 *
2770
-	 * @since 1.0.19
2771
-	 * @param  int|bool $value confirmed.
2772
-	 */
2773
-	public function set_address_confirmed( $value ) {
2774
-		$this->set_prop( 'address_confirmed', $value );
2775
-    }
2776
-
2777
-    /**
2778
-	 * Alias of self::set_address_confirmed().
2779
-	 *
2780
-	 * @since 1.0.19
2781
-	 * @param  int|bool $value confirmed.
2782
-	 */
2783
-	public function set_user_address_confirmed( $value ) {
2784
-		$this->set_address_confirmed( $value );
2785
-    }
2786
-
2787
-    /**
2788
-	 * Alias of self::set_address_confirmed().
2789
-	 *
2790
-	 * @since 1.0.19
2791
-	 * @param  int|bool $value confirmed.
2792
-	 */
2793
-	public function set_customer_address_confirmed( $value ) {
2794
-		$this->set_address_confirmed( $value );
2795
-    }
2796
-
2797
-    /**
2798
-	 * Set the invoice sub total.
2799
-	 *
2800
-	 * @since 1.0.19
2801
-	 * @param  float $value sub total.
2802
-	 */
2803
-	public function set_subtotal( $value ) {
2804
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2805
-	}
2806
-
2807
-	/**
2808
-	 * Set the invoice total.
2809
-	 *
2810
-	 * @since 1.0.19
2811
-	 * @param  float $value sub total.
2812
-	 */
2813
-	public function set_total( $value ) {
2814
-		$this->set_prop( 'total', max( 0, $value ) );
2815
-    }
2816
-
2817
-    /**
2818
-	 * Set the invoice discount amount.
2819
-	 *
2820
-	 * @since 1.0.19
2821
-	 * @param  float $value discount total.
2822
-	 */
2823
-	public function set_total_discount( $value ) {
2824
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2817
+    /**
2818
+     * Set the invoice discount amount.
2819
+     *
2820
+     * @since 1.0.19
2821
+     * @param  float $value discount total.
2822
+     */
2823
+    public function set_total_discount( $value ) {
2824
+        $this->set_prop( 'total_discount', max( 0, $value ) );
2825 2825
     }
2826 2826
 
2827 2827
     /**
2828
-	 * Alias of self::set_total_discount().
2829
-	 *
2830
-	 * @since 1.0.19
2831
-	 * @param  float $value discount total.
2832
-	 */
2833
-	public function set_discount( $value ) {
2834
-		$this->set_total_discount( $value );
2828
+     * Alias of self::set_total_discount().
2829
+     *
2830
+     * @since 1.0.19
2831
+     * @param  float $value discount total.
2832
+     */
2833
+    public function set_discount( $value ) {
2834
+        $this->set_total_discount( $value );
2835 2835
     }
2836 2836
 
2837 2837
     /**
2838
-	 * Set the invoice tax amount.
2839
-	 *
2840
-	 * @since 1.0.19
2841
-	 * @param  float $value tax total.
2842
-	 */
2843
-	public function set_total_tax( $value ) {
2844
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2838
+     * Set the invoice tax amount.
2839
+     *
2840
+     * @since 1.0.19
2841
+     * @param  float $value tax total.
2842
+     */
2843
+    public function set_total_tax( $value ) {
2844
+        $this->set_prop( 'total_tax', max( 0, $value ) );
2845 2845
     }
2846 2846
 
2847 2847
     /**
2848
-	 * Alias of self::set_total_tax().
2849
-	 *
2850
-	 * @since 1.0.19
2851
-	 * @param  float $value tax total.
2852
-	 */
2853
-	public function set_tax_total( $value ) {
2854
-		$this->set_total_tax( $value );
2848
+     * Alias of self::set_total_tax().
2849
+     *
2850
+     * @since 1.0.19
2851
+     * @param  float $value tax total.
2852
+     */
2853
+    public function set_tax_total( $value ) {
2854
+        $this->set_total_tax( $value );
2855 2855
     }
2856 2856
 
2857 2857
     /**
2858
-	 * Set the invoice fees amount.
2859
-	 *
2860
-	 * @since 1.0.19
2861
-	 * @param  float $value fees total.
2862
-	 */
2863
-	public function set_total_fees( $value ) {
2864
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2858
+     * Set the invoice fees amount.
2859
+     *
2860
+     * @since 1.0.19
2861
+     * @param  float $value fees total.
2862
+     */
2863
+    public function set_total_fees( $value ) {
2864
+        $this->set_prop( 'total_fees', max( 0, $value ) );
2865 2865
     }
2866 2866
 
2867 2867
     /**
2868
-	 * Alias of self::set_total_fees().
2869
-	 *
2870
-	 * @since 1.0.19
2871
-	 * @param  float $value fees total.
2872
-	 */
2873
-	public function set_fees_total( $value ) {
2874
-		$this->set_total_fees( $value );
2868
+     * Alias of self::set_total_fees().
2869
+     *
2870
+     * @since 1.0.19
2871
+     * @param  float $value fees total.
2872
+     */
2873
+    public function set_fees_total( $value ) {
2874
+        $this->set_total_fees( $value );
2875 2875
     }
2876 2876
 
2877 2877
     /**
2878
-	 * Set the invoice fees.
2879
-	 *
2880
-	 * @since 1.0.19
2881
-	 * @param  array $value fees.
2882
-	 */
2883
-	public function set_fees( $value ) {
2878
+     * Set the invoice fees.
2879
+     *
2880
+     * @since 1.0.19
2881
+     * @param  array $value fees.
2882
+     */
2883
+    public function set_fees( $value ) {
2884 2884
 
2885
-		if ( ! is_array( $value ) ) {
2886
-			$value = array();
2887
-		}
2885
+        if ( ! is_array( $value ) ) {
2886
+            $value = array();
2887
+        }
2888 2888
 
2889
-		$this->set_prop( 'fees', $value );
2889
+        $this->set_prop( 'fees', $value );
2890 2890
 
2891 2891
     }
2892 2892
 
2893 2893
     /**
2894
-	 * Set the invoice taxes.
2895
-	 *
2896
-	 * @since 1.0.19
2897
-	 * @param  array $value taxes.
2898
-	 */
2899
-	public function set_taxes( $value ) {
2894
+     * Set the invoice taxes.
2895
+     *
2896
+     * @since 1.0.19
2897
+     * @param  array $value taxes.
2898
+     */
2899
+    public function set_taxes( $value ) {
2900 2900
 
2901
-		if ( ! is_array( $value ) ) {
2902
-			$value = array();
2903
-		}
2901
+        if ( ! is_array( $value ) ) {
2902
+            $value = array();
2903
+        }
2904 2904
 
2905
-		$this->set_prop( 'taxes', $value );
2905
+        $this->set_prop( 'taxes', $value );
2906 2906
 
2907 2907
     }
2908 2908
 
2909 2909
     /**
2910
-	 * Set the invoice discounts.
2911
-	 *
2912
-	 * @since 1.0.19
2913
-	 * @param  array $value discounts.
2914
-	 */
2915
-	public function set_discounts( $value ) {
2910
+     * Set the invoice discounts.
2911
+     *
2912
+     * @since 1.0.19
2913
+     * @param  array $value discounts.
2914
+     */
2915
+    public function set_discounts( $value ) {
2916 2916
 
2917
-		if ( ! is_array( $value ) ) {
2918
-			$value = array();
2919
-		}
2917
+        if ( ! is_array( $value ) ) {
2918
+            $value = array();
2919
+        }
2920 2920
 
2921
-		$this->set_prop( 'discounts', $value );
2921
+        $this->set_prop( 'discounts', $value );
2922 2922
     }
2923 2923
 
2924 2924
     /**
2925
-	 * Set the invoice items.
2926
-	 *
2927
-	 * @since 1.0.19
2928
-	 * @param  GetPaid_Form_Item[] $value items.
2929
-	 */
2930
-	public function set_items( $value ) {
2925
+     * Set the invoice items.
2926
+     *
2927
+     * @since 1.0.19
2928
+     * @param  GetPaid_Form_Item[] $value items.
2929
+     */
2930
+    public function set_items( $value ) {
2931 2931
 
2932 2932
         // Remove existing items.
2933 2933
         $this->set_prop( 'items', array() );
2934
-		$this->recurring_item = null;
2934
+        $this->recurring_item = null;
2935 2935
 
2936 2936
         // Ensure that we have an array.
2937 2937
         if ( ! is_array( $value ) ) {
@@ -2945,95 +2945,95 @@  discard block
 block discarded – undo
2945 2945
     }
2946 2946
 
2947 2947
     /**
2948
-	 * Set the payment form.
2949
-	 *
2950
-	 * @since 1.0.19
2951
-	 * @param  int $value payment form.
2952
-	 */
2953
-	public function set_payment_form( $value ) {
2954
-		$this->set_prop( 'payment_form', $value );
2948
+     * Set the payment form.
2949
+     *
2950
+     * @since 1.0.19
2951
+     * @param  int $value payment form.
2952
+     */
2953
+    public function set_payment_form( $value ) {
2954
+        $this->set_prop( 'payment_form', $value );
2955 2955
     }
2956 2956
 
2957 2957
     /**
2958
-	 * Set the submission id.
2959
-	 *
2960
-	 * @since 1.0.19
2961
-	 * @param  string $value submission id.
2962
-	 */
2963
-	public function set_submission_id( $value ) {
2964
-		$this->set_prop( 'submission_id', $value );
2958
+     * Set the submission id.
2959
+     *
2960
+     * @since 1.0.19
2961
+     * @param  string $value submission id.
2962
+     */
2963
+    public function set_submission_id( $value ) {
2964
+        $this->set_prop( 'submission_id', $value );
2965 2965
     }
2966 2966
 
2967 2967
     /**
2968
-	 * Set the discount code.
2969
-	 *
2970
-	 * @since 1.0.19
2971
-	 * @param  string $value discount code.
2972
-	 */
2973
-	public function set_discount_code( $value ) {
2974
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
2968
+     * Set the discount code.
2969
+     *
2970
+     * @since 1.0.19
2971
+     * @param  string $value discount code.
2972
+     */
2973
+    public function set_discount_code( $value ) {
2974
+        $this->set_prop( 'discount_code', sanitize_text_field( $value ) );
2975 2975
     }
2976 2976
 
2977 2977
     /**
2978
-	 * Set the gateway.
2979
-	 *
2980
-	 * @since 1.0.19
2981
-	 * @param  string $value gateway.
2982
-	 */
2983
-	public function set_gateway( $value ) {
2984
-		$this->set_prop( 'gateway', $value );
2978
+     * Set the gateway.
2979
+     *
2980
+     * @since 1.0.19
2981
+     * @param  string $value gateway.
2982
+     */
2983
+    public function set_gateway( $value ) {
2984
+        $this->set_prop( 'gateway', $value );
2985 2985
     }
2986 2986
 
2987 2987
     /**
2988
-	 * Set the transaction id.
2989
-	 *
2990
-	 * @since 1.0.19
2991
-	 * @param  string $value transaction id.
2992
-	 */
2993
-	public function set_transaction_id( $value ) {
2994
-		if ( ! empty( $value ) ) {
2995
-			$this->set_prop( 'transaction_id', $value );
2996
-		}
2988
+     * Set the transaction id.
2989
+     *
2990
+     * @since 1.0.19
2991
+     * @param  string $value transaction id.
2992
+     */
2993
+    public function set_transaction_id( $value ) {
2994
+        if ( ! empty( $value ) ) {
2995
+            $this->set_prop( 'transaction_id', $value );
2996
+        }
2997 2997
     }
2998 2998
 
2999 2999
     /**
3000
-	 * Set the currency id.
3001
-	 *
3002
-	 * @since 1.0.19
3003
-	 * @param  string $value currency id.
3004
-	 */
3005
-	public function set_currency( $value ) {
3006
-		$this->set_prop( 'currency', $value );
3000
+     * Set the currency id.
3001
+     *
3002
+     * @since 1.0.19
3003
+     * @param  string $value currency id.
3004
+     */
3005
+    public function set_currency( $value ) {
3006
+        $this->set_prop( 'currency', $value );
3007 3007
     }
3008 3008
 
3009
-	/**
3010
-	 * Set whether to disable taxes.
3011
-	 *
3012
-	 * @since 1.0.19
3013
-	 * @param  bool $value value.
3014
-	 */
3015
-	public function set_disable_taxes( $value ) {
3016
-		$this->set_prop( 'disable_taxes', (bool) $value );
3017
-	}
3009
+    /**
3010
+     * Set whether to disable taxes.
3011
+     *
3012
+     * @since 1.0.19
3013
+     * @param  bool $value value.
3014
+     */
3015
+    public function set_disable_taxes( $value ) {
3016
+        $this->set_prop( 'disable_taxes', (bool) $value );
3017
+    }
3018 3018
 
3019 3019
     /**
3020
-	 * Set the subscription id.
3021
-	 *
3022
-	 * @since 1.0.19
3023
-	 * @param  string $value subscription id.
3024
-	 */
3025
-	public function set_subscription_id( $value ) {
3026
-		$this->set_prop( 'subscription_id', $value );
3027
-	}
3020
+     * Set the subscription id.
3021
+     *
3022
+     * @since 1.0.19
3023
+     * @param  string $value subscription id.
3024
+     */
3025
+    public function set_subscription_id( $value ) {
3026
+        $this->set_prop( 'subscription_id', $value );
3027
+    }
3028 3028
 	
3029
-	/**
3030
-	 * Set the remote subscription id.
3031
-	 *
3032
-	 * @since 1.0.19
3033
-	 * @param  string $value subscription id.
3034
-	 */
3035
-	public function set_remote_subscription_id( $value ) {
3036
-		$this->set_prop( 'remote_subscription_id', $value );
3029
+    /**
3030
+     * Set the remote subscription id.
3031
+     *
3032
+     * @since 1.0.19
3033
+     * @param  string $value subscription id.
3034
+     */
3035
+    public function set_remote_subscription_id( $value ) {
3036
+        $this->set_prop( 'remote_subscription_id', $value );
3037 3037
     }
3038 3038
 
3039 3039
     /*
@@ -3072,24 +3072,24 @@  discard block
 block discarded – undo
3072 3072
      */
3073 3073
     public function is_taxable() {
3074 3074
         return ! $this->get_disable_taxes();
3075
-	}
3075
+    }
3076 3076
 
3077
-	/**
3078
-	 * @deprecated
3079
-	 */
3080
-	public function has_vat() {
3077
+    /**
3078
+     * @deprecated
3079
+     */
3080
+    public function has_vat() {
3081 3081
         return $this->is_taxable();
3082
-	}
3082
+    }
3083 3083
 
3084
-	/**
3085
-	 * Checks to see if the invoice requires payment.
3086
-	 */
3087
-	public function is_free() {
3084
+    /**
3085
+     * Checks to see if the invoice requires payment.
3086
+     */
3087
+    public function is_free() {
3088 3088
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3089 3089
 
3090
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3091
-			$is_free = false;
3092
-		}
3090
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3091
+            $is_free = false;
3092
+        }
3093 3093
 
3094 3094
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3095 3095
     }
@@ -3100,46 +3100,46 @@  discard block
 block discarded – undo
3100 3100
     public function is_paid() {
3101 3101
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3102 3102
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3103
-	}
3103
+    }
3104 3104
 
3105
-	/**
3105
+    /**
3106 3106
      * Checks if the invoice needs payment.
3107 3107
      */
3108
-	public function needs_payment() {
3109
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3108
+    public function needs_payment() {
3109
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3110 3110
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3111 3111
     }
3112 3112
   
3113
-	/**
3113
+    /**
3114 3114
      * Checks if the invoice is refunded.
3115 3115
      */
3116
-	public function is_refunded() {
3116
+    public function is_refunded() {
3117 3117
         $is_refunded = $this->has_status( 'wpi-refunded' );
3118 3118
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3119
-	}
3119
+    }
3120 3120
 
3121
-	/**
3121
+    /**
3122 3122
      * Checks if the invoice is held.
3123 3123
      */
3124
-	public function is_held() {
3124
+    public function is_held() {
3125 3125
         $is_held = $this->has_status( 'wpi-onhold' );
3126 3126
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3127
-	}
3127
+    }
3128 3128
 
3129
-	/**
3129
+    /**
3130 3130
      * Checks if the invoice is due.
3131 3131
      */
3132
-	public function is_due() {
3133
-		$due_date = $this->get_due_date();
3134
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3135
-	}
3132
+    public function is_due() {
3133
+        $due_date = $this->get_due_date();
3134
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3135
+    }
3136 3136
 
3137
-	/**
3137
+    /**
3138 3138
      * Checks if the invoice is draft.
3139 3139
      */
3140
-	public function is_draft() {
3140
+    public function is_draft() {
3141 3141
         return $this->has_status( 'draft, auto-draft' );
3142
-	}
3142
+    }
3143 3143
 
3144 3144
     /**
3145 3145
      * Checks if the invoice has a given status.
@@ -3147,9 +3147,9 @@  discard block
 block discarded – undo
3147 3147
     public function has_status( $status ) {
3148 3148
         $status = wpinv_parse_list( $status );
3149 3149
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3150
-	}
3150
+    }
3151 3151
 
3152
-	/**
3152
+    /**
3153 3153
      * Checks if the invoice is of a given type.
3154 3154
      */
3155 3155
     public function is_type( $type ) {
@@ -3172,25 +3172,25 @@  discard block
 block discarded – undo
3172 3172
      */
3173 3173
     public function has_free_trial() {
3174 3174
         return $this->is_recurring() && 0 == $this->get_initial_total();
3175
-	}
3175
+    }
3176 3176
 
3177
-	/**
3177
+    /**
3178 3178
      * @deprecated
3179 3179
      */
3180 3180
     public function is_free_trial() {
3181 3181
         $this->has_free_trial();
3182 3182
     }
3183 3183
 
3184
-	/**
3184
+    /**
3185 3185
      * Check if the initial payment if 0.
3186 3186
      *
3187 3187
      */
3188
-	public function is_initial_free() {
3188
+    public function is_initial_free() {
3189 3189
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3190 3190
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3191 3191
     }
3192 3192
 	
3193
-	/**
3193
+    /**
3194 3194
      * Check if the recurring item has a free trial.
3195 3195
      *
3196 3196
      */
@@ -3203,21 +3203,21 @@  discard block
 block discarded – undo
3203 3203
 
3204 3204
         $item = $this->get_recurring( true );
3205 3205
         return $item->has_free_trial();
3206
-	}
3206
+    }
3207 3207
 
3208
-	/**
3208
+    /**
3209 3209
      * Check if the free trial is a result of a discount.
3210 3210
      */
3211 3211
     public function is_free_trial_from_discount() {
3212
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3213
-	}
3212
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3213
+    }
3214 3214
 	
3215
-	/**
3215
+    /**
3216 3216
      * @deprecated
3217 3217
      */
3218 3218
     public function discount_first_payment_only() {
3219 3219
 
3220
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3220
+        $discount = wpinv_get_discount_obj( $this->get_discount_code() );
3221 3221
         if ( ! $discount->exists() || ! $this->is_recurring() ) {
3222 3222
             return true;
3223 3223
         }
@@ -3242,147 +3242,147 @@  discard block
 block discarded – undo
3242 3242
      */
3243 3243
     public function add_item( $item ) {
3244 3244
 
3245
-		if ( is_array( $item ) ) {
3246
-			$item = $this->process_array_item( $item );
3247
-		}
3245
+        if ( is_array( $item ) ) {
3246
+            $item = $this->process_array_item( $item );
3247
+        }
3248 3248
 
3249
-		if ( is_numeric( $item ) ) {
3250
-			$item = new GetPaid_Form_Item( $item );
3251
-		}
3249
+        if ( is_numeric( $item ) ) {
3250
+            $item = new GetPaid_Form_Item( $item );
3251
+        }
3252 3252
 
3253 3253
         // Make sure that it is available for purchase.
3254
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3255
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3254
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3255
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3256 3256
         }
3257 3257
 
3258 3258
         // Do we have a recurring item?
3259
-		if ( $item->is_recurring() ) {
3260
-			$this->recurring_item = $item->get_id();
3259
+        if ( $item->is_recurring() ) {
3260
+            $this->recurring_item = $item->get_id();
3261 3261
         }
3262 3262
 
3263 3263
         // Invoice id.
3264 3264
         $item->invoice_id = (int) $this->get_id();
3265 3265
 
3266
-		// Remove duplicates.
3267
-		$this->remove_item( $item->get_id() );
3266
+        // Remove duplicates.
3267
+        $this->remove_item( $item->get_id() );
3268 3268
 
3269
-		if ( 0 == $item->get_quantity() ) {
3270
-			return;
3271
-		}
3269
+        if ( 0 == $item->get_quantity() ) {
3270
+            return;
3271
+        }
3272 3272
 
3273
-		// Retrieve all items.
3273
+        // Retrieve all items.
3274 3274
         $items   = $this->get_items();
3275 3275
 
3276
-		// Add new item.
3276
+        // Add new item.
3277 3277
         $items[] = $item;
3278 3278
 
3279 3279
         $this->set_prop( 'items', $items );
3280 3280
 
3281
-		return true;
3282
-	}
3281
+        return true;
3282
+    }
3283 3283
 
3284
-	/**
3285
-	 * Converts an array to an item.
3286
-	 *
3287
-	 * @since 1.0.19
3288
-	 * @return GetPaid_Form_Item
3289
-	 */
3290
-	protected function process_array_item( $array ) {
3284
+    /**
3285
+     * Converts an array to an item.
3286
+     *
3287
+     * @since 1.0.19
3288
+     * @return GetPaid_Form_Item
3289
+     */
3290
+    protected function process_array_item( $array ) {
3291 3291
 
3292
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3293
-		$item    = new GetPaid_Form_Item( $item_id );
3292
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3293
+        $item    = new GetPaid_Form_Item( $item_id );
3294 3294
 
3295
-		// Set item data.
3296
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3297
-			if ( isset( $array[ "item_$key" ] ) ) {
3298
-				$method = "set_$key";
3299
-				$item->$method( $array[ "item_$key" ] );
3300
-			}
3301
-		}
3295
+        // Set item data.
3296
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3297
+            if ( isset( $array[ "item_$key" ] ) ) {
3298
+                $method = "set_$key";
3299
+                $item->$method( $array[ "item_$key" ] );
3300
+            }
3301
+        }
3302 3302
 
3303
-		if ( isset( $array['quantity'] ) ) {
3304
-			$item->set_quantity( $array['quantity'] );
3305
-		}
3303
+        if ( isset( $array['quantity'] ) ) {
3304
+            $item->set_quantity( $array['quantity'] );
3305
+        }
3306 3306
 
3307
-		// Set item meta.
3308
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3309
-			$item->set_item_meta( $array['meta'] );
3310
-		}
3307
+        // Set item meta.
3308
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3309
+            $item->set_item_meta( $array['meta'] );
3310
+        }
3311 3311
 
3312
-		return $item;
3312
+        return $item;
3313 3313
 
3314
-	}
3314
+    }
3315 3315
 
3316 3316
     /**
3317
-	 * Retrieves a specific item.
3318
-	 *
3319
-	 * @since 1.0.19
3320
-	 * @return GetPaid_Form_Item|null
3321
-	 */
3322
-	public function get_item( $item_id ) {
3317
+     * Retrieves a specific item.
3318
+     *
3319
+     * @since 1.0.19
3320
+     * @return GetPaid_Form_Item|null
3321
+     */
3322
+    public function get_item( $item_id ) {
3323 3323
 
3324
-		foreach ( $this->get_items() as $item ) {
3325
-			if ( (int) $item_id == $item->get_id() ) {
3326
-				return $item;
3327
-			}
3328
-		}
3324
+        foreach ( $this->get_items() as $item ) {
3325
+            if ( (int) $item_id == $item->get_id() ) {
3326
+                return $item;
3327
+            }
3328
+        }
3329 3329
 
3330
-		return null;
3330
+        return null;
3331 3331
     }
3332 3332
 
3333 3333
     /**
3334
-	 * Removes a specific item.
3335
-	 *
3336
-	 * @since 1.0.19
3337
-	 */
3338
-	public function remove_item( $item_id ) {
3339
-		$items   = $this->get_items();
3340
-		$item_id = (int) $item_id;
3334
+     * Removes a specific item.
3335
+     *
3336
+     * @since 1.0.19
3337
+     */
3338
+    public function remove_item( $item_id ) {
3339
+        $items   = $this->get_items();
3340
+        $item_id = (int) $item_id;
3341 3341
 
3342
-		foreach ( $items as $index => $item ) {
3343
-			if ( (int) $item_id == $item->get_id() ) {
3344
-				unset( $items[ $index ] );
3345
-				$this->set_prop( 'items', $items );
3342
+        foreach ( $items as $index => $item ) {
3343
+            if ( (int) $item_id == $item->get_id() ) {
3344
+                unset( $items[ $index ] );
3345
+                $this->set_prop( 'items', $items );
3346 3346
 
3347
-				if ( $item_id == $this->recurring_item ) {
3348
-					$this->recurring_item = null;
3349
-				}
3347
+                if ( $item_id == $this->recurring_item ) {
3348
+                    $this->recurring_item = null;
3349
+                }
3350 3350
 
3351
-			}
3352
-		}
3351
+            }
3352
+        }
3353 3353
 
3354 3354
     }
3355 3355
 
3356 3356
     /**
3357
-	 * Adds a fee to the invoice.
3358
-	 *
3359
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3360
-	 * @since 1.0.19
3361
-	 */
3357
+     * Adds a fee to the invoice.
3358
+     *
3359
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3360
+     * @since 1.0.19
3361
+     */
3362 3362
     public function add_fee( $fee ) {
3363 3363
 
3364
-		$fees                 = $this->get_fees();
3365
-		$fees[ $fee['name'] ] = $fee;
3366
-		$this->set_prop( 'fees', $fees );
3364
+        $fees                 = $this->get_fees();
3365
+        $fees[ $fee['name'] ] = $fee;
3366
+        $this->set_prop( 'fees', $fees );
3367 3367
 
3368 3368
     }
3369 3369
 
3370 3370
     /**
3371
-	 * Retrieves a specific fee.
3372
-	 *
3373
-	 * @since 1.0.19
3374
-	 */
3375
-	public function get_fee( $fee ) {
3371
+     * Retrieves a specific fee.
3372
+     *
3373
+     * @since 1.0.19
3374
+     */
3375
+    public function get_fee( $fee ) {
3376 3376
         $fees = $this->get_fees();
3377
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3377
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3378 3378
     }
3379 3379
 
3380 3380
     /**
3381
-	 * Removes a specific fee.
3382
-	 *
3383
-	 * @since 1.0.19
3384
-	 */
3385
-	public function remove_fee( $fee ) {
3381
+     * Removes a specific fee.
3382
+     *
3383
+     * @since 1.0.19
3384
+     */
3385
+    public function remove_fee( $fee ) {
3386 3386
         $fees = $this->get_fees();
3387 3387
         if ( isset( $fees[ $fee ] ) ) {
3388 3388
             unset( $fees[ $fee ] );
@@ -3390,55 +3390,55 @@  discard block
 block discarded – undo
3390 3390
         }
3391 3391
     }
3392 3392
 
3393
-	/**
3394
-	 * Adds a discount to the invoice.
3395
-	 *
3396
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3397
-	 * @since 1.0.19
3398
-	 */
3399
-	public function add_discount( $discount ) {
3393
+    /**
3394
+     * Adds a discount to the invoice.
3395
+     *
3396
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3397
+     * @since 1.0.19
3398
+     */
3399
+    public function add_discount( $discount ) {
3400 3400
 
3401
-		$discounts = $this->get_discounts();
3402
-		$discounts[ $discount['name'] ] = $discount;
3403
-		$this->set_prop( 'discounts', $discounts );
3401
+        $discounts = $this->get_discounts();
3402
+        $discounts[ $discount['name'] ] = $discount;
3403
+        $this->set_prop( 'discounts', $discounts );
3404 3404
 
3405
-	}
3405
+    }
3406 3406
 
3407 3407
     /**
3408
-	 * Retrieves a specific discount.
3409
-	 *
3410
-	 * @since 1.0.19
3411
-	 * @return float
3412
-	 */
3413
-	public function get_discount( $discount = false ) {
3408
+     * Retrieves a specific discount.
3409
+     *
3410
+     * @since 1.0.19
3411
+     * @return float
3412
+     */
3413
+    public function get_discount( $discount = false ) {
3414 3414
 
3415
-		// Backwards compatibilty.
3416
-		if ( empty( $discount ) ) {
3417
-			return $this->get_total_discount();
3418
-		}
3415
+        // Backwards compatibilty.
3416
+        if ( empty( $discount ) ) {
3417
+            return $this->get_total_discount();
3418
+        }
3419 3419
 
3420 3420
         $discounts = $this->get_discounts();
3421
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3421
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3422 3422
     }
3423 3423
 
3424 3424
     /**
3425
-	 * Removes a specific discount.
3426
-	 *
3427
-	 * @since 1.0.19
3428
-	 */
3429
-	public function remove_discount( $discount ) {
3425
+     * Removes a specific discount.
3426
+     *
3427
+     * @since 1.0.19
3428
+     */
3429
+    public function remove_discount( $discount ) {
3430 3430
         $discounts = $this->get_discounts();
3431 3431
         if ( isset( $discounts[ $discount ] ) ) {
3432 3432
             unset( $discounts[ $discount ] );
3433 3433
             $this->set_prop( 'discounts', $discounts );
3434 3434
         }
3435 3435
 
3436
-		if ( 'discount_code' == $discount ) {
3437
-			foreach ( $this->get_items() as $item ) {
3438
-				$item->item_discount           = 0;
3439
-				$item->recurring_item_discount = 0;
3440
-			}
3441
-		}
3436
+        if ( 'discount_code' == $discount ) {
3437
+            foreach ( $this->get_items() as $item ) {
3438
+                $item->item_discount           = 0;
3439
+                $item->recurring_item_discount = 0;
3440
+            }
3441
+        }
3442 3442
 
3443 3443
     }
3444 3444
 
@@ -3451,34 +3451,34 @@  discard block
 block discarded – undo
3451 3451
         if ( $this->is_taxable() ) {
3452 3452
 
3453 3453
             $taxes                 = $this->get_taxes();
3454
-			$taxes[ $tax['name'] ] = $tax;
3455
-			$this->set_prop( 'taxes', $tax );
3454
+            $taxes[ $tax['name'] ] = $tax;
3455
+            $this->set_prop( 'taxes', $tax );
3456 3456
 
3457 3457
         }
3458 3458
     }
3459 3459
 
3460 3460
     /**
3461
-	 * Retrieves a specific tax.
3462
-	 *
3463
-	 * @since 1.0.19
3464
-	 */
3465
-	public function get_tax( $tax = null ) {
3461
+     * Retrieves a specific tax.
3462
+     *
3463
+     * @since 1.0.19
3464
+     */
3465
+    public function get_tax( $tax = null ) {
3466 3466
 
3467
-		// Backwards compatility.
3468
-		if ( empty( $tax ) ) {
3469
-			return $this->get_total_tax();
3470
-		}
3467
+        // Backwards compatility.
3468
+        if ( empty( $tax ) ) {
3469
+            return $this->get_total_tax();
3470
+        }
3471 3471
 
3472 3472
         $taxes = $this->get_taxes();
3473
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3473
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3474 3474
     }
3475 3475
 
3476 3476
     /**
3477
-	 * Removes a specific tax.
3478
-	 *
3479
-	 * @since 1.0.19
3480
-	 */
3481
-	public function remove_tax( $tax ) {
3477
+     * Removes a specific tax.
3478
+     *
3479
+     * @since 1.0.19
3480
+     */
3481
+    public function remove_tax( $tax ) {
3482 3482
         $taxes = $this->get_taxes();
3483 3483
         if ( isset( $taxes[ $tax ] ) ) {
3484 3484
             unset( $taxes[ $tax ] );
@@ -3487,185 +3487,185 @@  discard block
 block discarded – undo
3487 3487
     }
3488 3488
 
3489 3489
     /**
3490
-	 * Recalculates the invoice subtotal.
3491
-	 *
3492
-	 * @since 1.0.19
3493
-	 * @return float The recalculated subtotal
3494
-	 */
3495
-	public function recalculate_subtotal() {
3490
+     * Recalculates the invoice subtotal.
3491
+     *
3492
+     * @since 1.0.19
3493
+     * @return float The recalculated subtotal
3494
+     */
3495
+    public function recalculate_subtotal() {
3496 3496
         $items     = $this->get_items();
3497
-		$subtotal  = 0;
3498
-		$recurring = 0;
3497
+        $subtotal  = 0;
3498
+        $recurring = 0;
3499 3499
 
3500 3500
         foreach ( $items as $item ) {
3501
-			$subtotal  += $item->get_sub_total( 'edit' );
3502
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3501
+            $subtotal  += $item->get_sub_total( 'edit' );
3502
+            $recurring += $item->get_recurring_sub_total( 'edit' );
3503 3503
         }
3504 3504
 
3505
-		if ( wpinv_prices_include_tax() ) {
3506
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3507
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3508
-		}
3505
+        if ( wpinv_prices_include_tax() ) {
3506
+            $subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3507
+            $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3508
+        }
3509 3509
 
3510
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3511
-		$this->set_subtotal( $current );
3510
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3511
+        $this->set_subtotal( $current );
3512 3512
 
3513
-		$this->totals['subtotal'] = array(
3514
-			'initial'   => $subtotal,
3515
-			'recurring' => $recurring,
3516
-		);
3513
+        $this->totals['subtotal'] = array(
3514
+            'initial'   => $subtotal,
3515
+            'recurring' => $recurring,
3516
+        );
3517 3517
 
3518 3518
         return $current;
3519 3519
     }
3520 3520
 
3521 3521
     /**
3522
-	 * Recalculates the invoice discount total.
3523
-	 *
3524
-	 * @since 1.0.19
3525
-	 * @return float The recalculated discount
3526
-	 */
3527
-	public function recalculate_total_discount() {
3522
+     * Recalculates the invoice discount total.
3523
+     *
3524
+     * @since 1.0.19
3525
+     * @return float The recalculated discount
3526
+     */
3527
+    public function recalculate_total_discount() {
3528 3528
         $discounts = $this->get_discounts();
3529
-		$discount  = 0;
3530
-		$recurring = 0;
3529
+        $discount  = 0;
3530
+        $recurring = 0;
3531 3531
 
3532 3532
         foreach ( $discounts as $data ) {
3533
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3534
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3535
-		}
3533
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3534
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3535
+        }
3536 3536
 
3537
-		$current = $this->is_renewal() ? $recurring : $discount;
3537
+        $current = $this->is_renewal() ? $recurring : $discount;
3538 3538
 
3539
-		$this->set_total_discount( $current );
3539
+        $this->set_total_discount( $current );
3540 3540
 
3541
-		$this->totals['discount'] = array(
3542
-			'initial'   => $discount,
3543
-			'recurring' => $recurring,
3544
-		);
3541
+        $this->totals['discount'] = array(
3542
+            'initial'   => $discount,
3543
+            'recurring' => $recurring,
3544
+        );
3545 3545
 
3546
-		return $current;
3546
+        return $current;
3547 3547
 
3548 3548
     }
3549 3549
 
3550 3550
     /**
3551
-	 * Recalculates the invoice tax total.
3552
-	 *
3553
-	 * @since 1.0.19
3554
-	 * @return float The recalculated tax
3555
-	 */
3556
-	public function recalculate_total_tax() {
3551
+     * Recalculates the invoice tax total.
3552
+     *
3553
+     * @since 1.0.19
3554
+     * @return float The recalculated tax
3555
+     */
3556
+    public function recalculate_total_tax() {
3557 3557
 
3558
-		// Maybe disable taxes.
3559
-		$vat_number = $this->get_vat_number();
3560
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3558
+        // Maybe disable taxes.
3559
+        $vat_number = $this->get_vat_number();
3560
+        $skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3561 3561
 
3562
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3563
-			$skip_tax = false;
3564
-		}
3562
+        if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3563
+            $skip_tax = false;
3564
+        }
3565 3565
 
3566
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3566
+        if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3567 3567
 
3568
-			$this->totals['tax'] = array(
3569
-				'initial'   => 0,
3570
-				'recurring' => 0,
3571
-			);
3568
+            $this->totals['tax'] = array(
3569
+                'initial'   => 0,
3570
+                'recurring' => 0,
3571
+            );
3572 3572
 
3573
-			$this->tax_rate = 0;
3573
+            $this->tax_rate = 0;
3574 3574
 
3575
-			$this->set_taxes( array() );
3576
-			$current = 0;
3577
-		} else {
3575
+            $this->set_taxes( array() );
3576
+            $current = 0;
3577
+        } else {
3578 3578
 
3579
-			$item_taxes = array();
3579
+            $item_taxes = array();
3580 3580
 
3581
-			foreach ( $this->get_items() as $item ) {
3582
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3583
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3584
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3585
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3586
-				foreach ( $taxes as $name => $amount ) {
3587
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3588
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3581
+            foreach ( $this->get_items() as $item ) {
3582
+                $rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3583
+                $rates    = getpaid_filter_item_tax_rates( $item, $rates );
3584
+                $taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3585
+                $r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3586
+                foreach ( $taxes as $name => $amount ) {
3587
+                    $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3588
+                    $tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3589 3589
 
3590
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3591
-						$item_taxes[ $name ] = $tax;
3592
-						continue;
3593
-					}
3590
+                    if ( ! isset( $item_taxes[ $name ] ) ) {
3591
+                        $item_taxes[ $name ] = $tax;
3592
+                        continue;
3593
+                    }
3594 3594
 
3595
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3596
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3595
+                    $item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3596
+                    $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3597 3597
 
3598
-				}
3598
+                }
3599 3599
 
3600
-			}
3600
+            }
3601 3601
 
3602
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3603
-			$this->set_taxes( $item_taxes );
3602
+            $item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3603
+            $this->set_taxes( $item_taxes );
3604 3604
 
3605
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3606
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3605
+            $initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3606
+            $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3607 3607
 
3608
-			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3608
+            $current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3609 3609
 
3610
-			$this->totals['tax'] = array(
3611
-				'initial'   => $initial_tax,
3612
-				'recurring' => $recurring_tax,
3613
-			);
3610
+            $this->totals['tax'] = array(
3611
+                'initial'   => $initial_tax,
3612
+                'recurring' => $recurring_tax,
3613
+            );
3614 3614
 
3615
-		}
3615
+        }
3616 3616
 
3617
-		$this->set_total_tax( $current );
3617
+        $this->set_total_tax( $current );
3618 3618
 
3619
-		return $current;
3619
+        return $current;
3620 3620
 
3621 3621
     }
3622 3622
 
3623 3623
     /**
3624
-	 * Recalculates the invoice fees total.
3625
-	 *
3626
-	 * @since 1.0.19
3627
-	 * @return float The recalculated fee
3628
-	 */
3629
-	public function recalculate_total_fees() {
3630
-		$fees      = $this->get_fees();
3631
-		$fee       = 0;
3632
-		$recurring = 0;
3624
+     * Recalculates the invoice fees total.
3625
+     *
3626
+     * @since 1.0.19
3627
+     * @return float The recalculated fee
3628
+     */
3629
+    public function recalculate_total_fees() {
3630
+        $fees      = $this->get_fees();
3631
+        $fee       = 0;
3632
+        $recurring = 0;
3633 3633
 
3634 3634
         foreach ( $fees as $data ) {
3635
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3636
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3637
-		}
3635
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3636
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3637
+        }
3638 3638
 
3639
-		$current = $this->is_renewal() ? $recurring : $fee;
3640
-		$this->set_total_fees( $current );
3639
+        $current = $this->is_renewal() ? $recurring : $fee;
3640
+        $this->set_total_fees( $current );
3641 3641
 
3642
-		$this->totals['fee'] = array(
3643
-			'initial'   => $fee,
3644
-			'recurring' => $recurring,
3645
-		);
3642
+        $this->totals['fee'] = array(
3643
+            'initial'   => $fee,
3644
+            'recurring' => $recurring,
3645
+        );
3646 3646
 
3647 3647
         $this->set_total_fees( $fee );
3648 3648
         return $current;
3649 3649
     }
3650 3650
 
3651 3651
     /**
3652
-	 * Recalculates the invoice total.
3653
-	 *
3654
-	 * @since 1.0.19
3652
+     * Recalculates the invoice total.
3653
+     *
3654
+     * @since 1.0.19
3655 3655
      * @return float The invoice total
3656
-	 */
3657
-	public function recalculate_total() {
3656
+     */
3657
+    public function recalculate_total() {
3658 3658
         $this->recalculate_total_fees();
3659 3659
         $this->recalculate_total_discount();
3660
-		$this->recalculate_total_tax();
3661
-		$this->recalculate_subtotal();
3662
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3663
-		return $this->get_total();
3664
-	}
3665
-
3666
-	/**
3667
-	 * @deprecated
3668
-	 */
3660
+        $this->recalculate_total_tax();
3661
+        $this->recalculate_subtotal();
3662
+        $this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3663
+        return $this->get_total();
3664
+    }
3665
+
3666
+    /**
3667
+     * @deprecated
3668
+     */
3669 3669
     public function recalculate_totals() {
3670 3670
         $this->recalculate_total();
3671 3671
         $this->save( true );
@@ -3679,22 +3679,22 @@  discard block
 block discarded – undo
3679 3679
         return $this->get_data();
3680 3680
     }
3681 3681
 
3682
-	/**
3682
+    /**
3683 3683
      * Adds a system note to an invoice.
3684 3684
      *
3685 3685
      * @param string $note The note being added.
3686
-	 * @return int|false The new note's ID on success, false on failure.
3686
+     * @return int|false The new note's ID on success, false on failure.
3687 3687
      *
3688 3688
      */
3689 3689
     public function add_system_note( $note ) {
3690
-		return $this->add_note( $note, false, false, true );
3691
-	}
3690
+        return $this->add_note( $note, false, false, true );
3691
+    }
3692 3692
 
3693 3693
     /**
3694 3694
      * Adds a note to an invoice.
3695 3695
      *
3696 3696
      * @param string $note The note being added.
3697
-	 * @return int|false The new note's ID on success, false on failure.
3697
+     * @return int|false The new note's ID on success, false on failure.
3698 3698
      *
3699 3699
      */
3700 3700
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3704,21 +3704,21 @@  discard block
 block discarded – undo
3704 3704
             return false;
3705 3705
         }
3706 3706
 
3707
-		$author       = 'System';
3708
-		$author_email = '[email protected]';
3707
+        $author       = 'System';
3708
+        $author_email = '[email protected]';
3709 3709
 
3710
-		// If this is an admin comment or it has been added by the user.
3711
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3712
-			$user         = get_user_by( 'id', get_current_user_id() );
3710
+        // If this is an admin comment or it has been added by the user.
3711
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3712
+            $user         = get_user_by( 'id', get_current_user_id() );
3713 3713
             $author       = $user->display_name;
3714 3714
             $author_email = $user->user_email;
3715
-		}
3715
+        }
3716 3716
 
3717
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3717
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3718 3718
 
3719
-	}
3719
+    }
3720 3720
 
3721
-	/**
3721
+    /**
3722 3722
      * Generates a unique key for the invoice.
3723 3723
      */
3724 3724
     public function generate_key( $string = '' ) {
@@ -3738,113 +3738,113 @@  discard block
 block discarded – undo
3738 3738
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3739 3739
         }
3740 3740
 
3741
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3742
-
3743
-	}
3744
-
3745
-	/**
3746
-	 * Handle the status transition.
3747
-	 */
3748
-	protected function status_transition() {
3749
-		$status_transition = $this->status_transition;
3750
-
3751
-		// Reset status transition variable.
3752
-		$this->status_transition = false;
3741
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3753 3742
 
3754
-		if ( $status_transition ) {
3755
-			try {
3756
-
3757
-				// Fire a hook for the status change.
3758
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3759
-
3760
-				// @deprecated this is deprecated and will be removed in the future.
3761
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3762
-
3763
-				if ( ! empty( $status_transition['from'] ) ) {
3764
-
3765
-					/* translators: 1: old invoice status 2: new invoice status */
3766
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3767
-
3768
-					// Fire another hook.
3769
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3770
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3771
-
3772
-					// @deprecated this is deprecated and will be removed in the future.
3773
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3774
-
3775
-					// Note the transition occurred.
3776
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3777
-
3778
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3779
-					if (
3780
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3781
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3782
-					) {
3783
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3784
-					}
3785
-
3786
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3787
-					if (
3788
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3789
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3790
-					) {
3791
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3792
-					}
3793
-				} else {
3794
-					/* translators: %s: new invoice status */
3795
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3796
-
3797
-					// Note the transition occurred.
3798
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3743
+    }
3799 3744
 
3800
-				}
3801
-			} catch ( Exception $e ) {
3802
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3803
-			}
3804
-		}
3805
-	}
3745
+    /**
3746
+     * Handle the status transition.
3747
+     */
3748
+    protected function status_transition() {
3749
+        $status_transition = $this->status_transition;
3750
+
3751
+        // Reset status transition variable.
3752
+        $this->status_transition = false;
3753
+
3754
+        if ( $status_transition ) {
3755
+            try {
3756
+
3757
+                // Fire a hook for the status change.
3758
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3759
+
3760
+                // @deprecated this is deprecated and will be removed in the future.
3761
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3762
+
3763
+                if ( ! empty( $status_transition['from'] ) ) {
3764
+
3765
+                    /* translators: 1: old invoice status 2: new invoice status */
3766
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3767
+
3768
+                    // Fire another hook.
3769
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3770
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3771
+
3772
+                    // @deprecated this is deprecated and will be removed in the future.
3773
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3774
+
3775
+                    // Note the transition occurred.
3776
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3777
+
3778
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3779
+                    if (
3780
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3781
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3782
+                    ) {
3783
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3784
+                    }
3785
+
3786
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3787
+                    if (
3788
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3789
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3790
+                    ) {
3791
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3792
+                    }
3793
+                } else {
3794
+                    /* translators: %s: new invoice status */
3795
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3796
+
3797
+                    // Note the transition occurred.
3798
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3799
+
3800
+                }
3801
+            } catch ( Exception $e ) {
3802
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3803
+            }
3804
+        }
3805
+    }
3806 3806
 
3807
-	/**
3808
-	 * Updates an invoice status.
3809
-	 */
3810
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3807
+    /**
3808
+     * Updates an invoice status.
3809
+     */
3810
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3811 3811
 
3812
-		// Fires before updating a status.
3813
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3812
+        // Fires before updating a status.
3813
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3814 3814
 
3815
-		// Update the status.
3816
-		$this->set_status( $new_status, $note, $manual );
3815
+        // Update the status.
3816
+        $this->set_status( $new_status, $note, $manual );
3817 3817
 
3818
-		// Save the order.
3819
-		return $this->save();
3818
+        // Save the order.
3819
+        return $this->save();
3820 3820
 
3821
-	}
3821
+    }
3822 3822
 
3823
-	/**
3824
-	 * @deprecated
3825
-	 */
3826
-	public function refresh_item_ids() {
3823
+    /**
3824
+     * @deprecated
3825
+     */
3826
+    public function refresh_item_ids() {
3827 3827
         $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3828 3828
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3829
-	}
3829
+    }
3830 3830
 
3831
-	/**
3832
-	 * @deprecated
3833
-	 */
3834
-	public function update_items( $temp = false ) {
3831
+    /**
3832
+     * @deprecated
3833
+     */
3834
+    public function update_items( $temp = false ) {
3835 3835
 
3836
-		$this->set_items( $this->get_items() );
3836
+        $this->set_items( $this->get_items() );
3837 3837
 
3838
-		if ( ! $temp ) {
3839
-			$this->save();
3840
-		}
3838
+        if ( ! $temp ) {
3839
+            $this->save();
3840
+        }
3841 3841
 
3842 3842
         return $this;
3843
-	}
3843
+    }
3844 3844
 
3845
-	/**
3846
-	 * @deprecated
3847
-	 */
3845
+    /**
3846
+     * @deprecated
3847
+     */
3848 3848
     public function validate_discount() {
3849 3849
 
3850 3850
         $discount_code = $this->get_discount_code();
@@ -3860,93 +3860,93 @@  discard block
 block discarded – undo
3860 3860
 
3861 3861
     }
3862 3862
 
3863
-	/**
3864
-	 * Refunds an invoice.
3865
-	 */
3863
+    /**
3864
+     * Refunds an invoice.
3865
+     */
3866 3866
     public function refund() {
3867
-		$this->set_status( 'wpi-refunded' );
3867
+        $this->set_status( 'wpi-refunded' );
3868 3868
         $this->save();
3869
-	}
3869
+    }
3870 3870
 
3871
-	/**
3872
-	 * Marks an invoice as paid.
3873
-	 * 
3874
-	 * @param string $transaction_id
3875
-	 */
3871
+    /**
3872
+     * Marks an invoice as paid.
3873
+     * 
3874
+     * @param string $transaction_id
3875
+     */
3876 3876
     public function mark_paid( $transaction_id = null, $note = '' ) {
3877 3877
 
3878
-		// Set the transaction id.
3879
-		if ( empty( $transaction_id ) ) {
3880
-			$transaction_id = $this->generate_key('trans_');
3881
-		}
3878
+        // Set the transaction id.
3879
+        if ( empty( $transaction_id ) ) {
3880
+            $transaction_id = $this->generate_key('trans_');
3881
+        }
3882 3882
 
3883
-		if ( ! $this->get_transaction_id() ) {
3884
-			$this->set_transaction_id( $transaction_id );
3885
-		}
3883
+        if ( ! $this->get_transaction_id() ) {
3884
+            $this->set_transaction_id( $transaction_id );
3885
+        }
3886 3886
 
3887
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3888
-			return $this->save();
3889
-		}
3887
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3888
+            return $this->save();
3889
+        }
3890 3890
 
3891
-		// Set the completed date.
3892
-		$this->set_date_completed( current_time( 'mysql' ) );
3891
+        // Set the completed date.
3892
+        $this->set_date_completed( current_time( 'mysql' ) );
3893 3893
 
3894
-		// Set the new status.
3895
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3896
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
3894
+        // Set the new status.
3895
+        $gateway = sanitize_text_field( $this->get_gateway_title() );
3896
+        if ( $this->is_renewal() || ! $this->is_parent() ) {
3897 3897
 
3898
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3899
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3898
+            $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3899
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3900 3900
 
3901
-			if ( 'none' == $this->get_gateway() ) {
3902
-				$_note = $note;
3903
-			}
3901
+            if ( 'none' == $this->get_gateway() ) {
3902
+                $_note = $note;
3903
+            }
3904 3904
 
3905
-			$this->set_status( 'wpi-renewal', $_note );
3905
+            $this->set_status( 'wpi-renewal', $_note );
3906 3906
 
3907
-		} else {
3907
+        } else {
3908 3908
 
3909
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3910
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3909
+            $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3910
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3911 3911
 
3912
-			if ( 'none' == $this->get_gateway() ) {
3913
-				$_note = $note;
3914
-			}
3912
+            if ( 'none' == $this->get_gateway() ) {
3913
+                $_note = $note;
3914
+            }
3915 3915
 
3916
-			$this->set_status( 'publish', $_note );
3916
+            $this->set_status( 'publish', $_note );
3917 3917
 
3918
-		}
3918
+        }
3919 3919
 
3920
-		// Set checkout mode.
3921
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3922
-		$this->set_mode( $mode );
3920
+        // Set checkout mode.
3921
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3922
+        $this->set_mode( $mode );
3923 3923
 
3924
-		// Save the invoice.
3924
+        // Save the invoice.
3925 3925
         $this->save();
3926
-	}
3927
-
3928
-	/**
3929
-	 * Save data to the database.
3930
-	 *
3931
-	 * @since 1.0.19
3932
-	 * @return int invoice ID
3933
-	 */
3934
-	public function save() {
3935
-		$this->maybe_set_date_paid();
3936
-		$this->maybe_set_key();
3937
-		parent::save();
3938
-		$this->clear_cache();
3939
-		$this->status_transition();
3940
-		return $this->get_id();
3941
-	}
3942
-
3943
-	/**
3926
+    }
3927
+
3928
+    /**
3929
+     * Save data to the database.
3930
+     *
3931
+     * @since 1.0.19
3932
+     * @return int invoice ID
3933
+     */
3934
+    public function save() {
3935
+        $this->maybe_set_date_paid();
3936
+        $this->maybe_set_key();
3937
+        parent::save();
3938
+        $this->clear_cache();
3939
+        $this->status_transition();
3940
+        return $this->get_id();
3941
+    }
3942
+
3943
+    /**
3944 3944
      * Clears the subscription's cache.
3945 3945
      */
3946 3946
     public function clear_cache() {
3947
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3948
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3949
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3950
-	}
3947
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3948
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3949
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3950
+    }
3951 3951
 
3952 3952
 }
Please login to merge, or discard this patch.
Spacing   +790 added lines, -790 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Invoice class.
@@ -144,40 +144,40 @@  discard block
 block discarded – undo
144 144
 	 *
145 145
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
146 146
 	 */
147
-    public function __construct( $invoice = 0 ) {
147
+    public function __construct($invoice = 0) {
148 148
 
149
-        parent::__construct( $invoice );
149
+        parent::__construct($invoice);
150 150
 
151
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
152
-			$this->set_id( (int) $invoice );
153
-		} elseif ( $invoice instanceof self ) {
154
-			$this->set_id( $invoice->get_id() );
155
-		} elseif ( ! empty( $invoice->ID ) ) {
156
-			$this->set_id( $invoice->ID );
157
-		} elseif ( is_array( $invoice ) ) {
158
-			$this->set_props( $invoice );
151
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) {
152
+			$this->set_id((int) $invoice);
153
+		} elseif ($invoice instanceof self) {
154
+			$this->set_id($invoice->get_id());
155
+		} elseif (!empty($invoice->ID)) {
156
+			$this->set_id($invoice->ID);
157
+		} elseif (is_array($invoice)) {
158
+			$this->set_props($invoice);
159 159
 
160
-			if ( isset( $invoice['ID'] ) ) {
161
-				$this->set_id( $invoice['ID'] );
160
+			if (isset($invoice['ID'])) {
161
+				$this->set_id($invoice['ID']);
162 162
 			}
163 163
 
164
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
165
-			$this->set_id( $invoice_id );
166
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
167
-			$this->set_id( $invoice_id );
168
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
169
-			$this->set_id( $invoice_id );
164
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
165
+			$this->set_id($invoice_id);
166
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
167
+			$this->set_id($invoice_id);
168
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
169
+			$this->set_id($invoice_id);
170 170
 		} else {
171
-			$this->set_object_read( true );
171
+			$this->set_object_read(true);
172 172
 		}
173 173
 
174 174
         // Load the datastore.
175
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
175
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
176 176
 
177
-		if ( $this->get_id() > 0 ) {
178
-            $this->post = get_post( $this->get_id() );
177
+		if ($this->get_id() > 0) {
178
+            $this->post = get_post($this->get_id());
179 179
             $this->ID   = $this->get_id();
180
-			$this->data_store->read( $this );
180
+			$this->data_store->read($this);
181 181
         }
182 182
 
183 183
     }
@@ -192,38 +192,38 @@  discard block
 block discarded – undo
192 192
 	 * @since 1.0.15
193 193
 	 * @return int
194 194
 	 */
195
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
195
+	public static function get_invoice_id_by_field($value, $field = 'key') {
196 196
         global $wpdb;
197 197
 
198 198
 		// Trim the value.
199
-		$value = trim( $value );
199
+		$value = trim($value);
200 200
 
201
-		if ( empty( $value ) ) {
201
+		if (empty($value)) {
202 202
 			return 0;
203 203
 		}
204 204
 
205 205
         // Valid fields.
206
-        $fields = array( 'key', 'number', 'transaction_id' );
206
+        $fields = array('key', 'number', 'transaction_id');
207 207
 
208 208
 		// Ensure a field has been passed.
209
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
209
+		if (empty($field) || !in_array($field, $fields)) {
210 210
 			return 0;
211 211
 		}
212 212
 
213 213
 		// Maybe retrieve from the cache.
214
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
-		if ( false !== $invoice_id ) {
214
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
215
+		if (false !== $invoice_id) {
216 216
 			return $invoice_id;
217 217
 		}
218 218
 
219 219
         // Fetch from the db.
220 220
         $table       = $wpdb->prefix . 'getpaid_invoices';
221 221
         $invoice_id  = (int) $wpdb->get_var(
222
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
222
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
223 223
         );
224 224
 
225 225
 		// Update the cache with our data
226
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
226
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
227 227
 
228 228
 		return $invoice_id;
229 229
     }
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
     /**
232 232
      * Checks if an invoice key is set.
233 233
      */
234
-    public function _isset( $key ) {
235
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
234
+    public function _isset($key) {
235
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
236 236
     }
237 237
 
238 238
     /*
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 	 * @param  string $context View or edit context.
258 258
 	 * @return int
259 259
 	 */
260
-	public function get_parent_id( $context = 'view' ) {
261
-		return (int) $this->get_prop( 'parent_id', $context );
260
+	public function get_parent_id($context = 'view') {
261
+		return (int) $this->get_prop('parent_id', $context);
262 262
     }
263 263
 
264 264
     /**
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 * @return WPInv_Invoice
269 269
 	 */
270 270
     public function get_parent_payment() {
271
-        return new WPInv_Invoice( $this->get_parent_id() );
271
+        return new WPInv_Invoice($this->get_parent_id());
272 272
     }
273 273
 
274 274
     /**
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 	 * @param  string $context View or edit context.
289 289
 	 * @return string
290 290
 	 */
291
-	public function get_status( $context = 'view' ) {
292
-		return $this->get_prop( 'status', $context );
291
+	public function get_status($context = 'view') {
292
+		return $this->get_prop('status', $context);
293 293
 	}
294 294
 	
295 295
 	/**
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @return array
300 300
 	 */
301 301
 	public function get_all_statuses() {
302
-		return wpinv_get_invoice_statuses( true, true, $this );
302
+		return wpinv_get_invoice_statuses(true, true, $this);
303 303
     }
304 304
 
305 305
     /**
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
     public function get_status_nicename() {
312 312
 		$statuses = $this->get_all_statuses();
313 313
 
314
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
314
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
315 315
 
316
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
316
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
317 317
     }
318 318
 
319 319
 	/**
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 */
325 325
 	public function get_status_class() {
326 326
 		$statuses = getpaid_get_invoice_status_classes();
327
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
327
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark';
328 328
 	}
329 329
 
330 330
 	/**
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
      */
336 336
     public function get_status_label_html() {
337 337
 
338
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
339
-		$status       = sanitize_html_class( $this->get_status() );
340
-		$class        = esc_attr( $this->get_status_class() );
338
+		$status_label = sanitize_text_field($this->get_status_nicename());
339
+		$status       = sanitize_html_class($this->get_status());
340
+		$class        = esc_attr($this->get_status_class());
341 341
 
342 342
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
343 343
 	}
@@ -349,23 +349,23 @@  discard block
 block discarded – undo
349 349
 	 * @param  string $context View or edit context.
350 350
 	 * @return string
351 351
 	 */
352
-	public function get_version( $context = 'view' ) {
353
-		return $this->get_prop( 'version', $context );
352
+	public function get_version($context = 'view') {
353
+		return $this->get_prop('version', $context);
354 354
 	}
355 355
 
356 356
 	/**
357 357
 	 * @deprecated
358 358
 	 */
359
-	public function get_invoice_date( $format = true ) {
360
-		$date      = getpaid_format_date( $this->get_date_completed() );
361
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
362
-		$formatted = getpaid_format_date( $date );
359
+	public function get_invoice_date($format = true) {
360
+		$date      = getpaid_format_date($this->get_date_completed());
361
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
362
+		$formatted = getpaid_format_date($date);
363 363
 
364
-		if ( $format ) {
364
+		if ($format) {
365 365
 			return $formatted;
366 366
 		}
367 367
 
368
-		return empty( $formatted ) ? '' : $date;
368
+		return empty($formatted) ? '' : $date;
369 369
 
370 370
     }
371 371
 
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_date_created( $context = 'view' ) {
380
-		return $this->get_prop( 'date_created', $context );
379
+	public function get_date_created($context = 'view') {
380
+		return $this->get_prop('date_created', $context);
381 381
 	}
382 382
 	
383 383
 	/**
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 	 * @param  string $context View or edit context.
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_created_date( $context = 'view' ) {
391
-		return $this->get_date_created( $context );
390
+	public function get_created_date($context = 'view') {
391
+		return $this->get_date_created($context);
392 392
     }
393 393
 
394 394
     /**
@@ -398,11 +398,11 @@  discard block
 block discarded – undo
398 398
 	 * @param  string $context View or edit context.
399 399
 	 * @return string
400 400
 	 */
401
-	public function get_date_created_gmt( $context = 'view' ) {
402
-        $date = $this->get_date_created( $context );
401
+	public function get_date_created_gmt($context = 'view') {
402
+        $date = $this->get_date_created($context);
403 403
 
404
-        if ( $date ) {
405
-            $date = get_gmt_from_date( $date );
404
+        if ($date) {
405
+            $date = get_gmt_from_date($date);
406 406
         }
407 407
 		return $date;
408 408
     }
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
 	 * @param  string $context View or edit context.
415 415
 	 * @return string
416 416
 	 */
417
-	public function get_date_modified( $context = 'view' ) {
418
-		return $this->get_prop( 'date_modified', $context );
417
+	public function get_date_modified($context = 'view') {
418
+		return $this->get_prop('date_modified', $context);
419 419
 	}
420 420
 
421 421
 	/**
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
 	 * @param  string $context View or edit context.
426 426
 	 * @return string
427 427
 	 */
428
-	public function get_modified_date( $context = 'view' ) {
429
-		return $this->get_date_modified( $context );
428
+	public function get_modified_date($context = 'view') {
429
+		return $this->get_date_modified($context);
430 430
     }
431 431
 
432 432
     /**
@@ -436,11 +436,11 @@  discard block
 block discarded – undo
436 436
 	 * @param  string $context View or edit context.
437 437
 	 * @return string
438 438
 	 */
439
-	public function get_date_modified_gmt( $context = 'view' ) {
440
-        $date = $this->get_date_modified( $context );
439
+	public function get_date_modified_gmt($context = 'view') {
440
+        $date = $this->get_date_modified($context);
441 441
 
442
-        if ( $date ) {
443
-            $date = get_gmt_from_date( $date );
442
+        if ($date) {
443
+            $date = get_gmt_from_date($date);
444 444
         }
445 445
 		return $date;
446 446
     }
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
 	 * @param  string $context View or edit context.
453 453
 	 * @return string
454 454
 	 */
455
-	public function get_due_date( $context = 'view' ) {
456
-		return $this->get_prop( 'due_date', $context );
455
+	public function get_due_date($context = 'view') {
456
+		return $this->get_prop('due_date', $context);
457 457
     }
458 458
 
459 459
     /**
@@ -463,8 +463,8 @@  discard block
 block discarded – undo
463 463
 	 * @param  string $context View or edit context.
464 464
 	 * @return string
465 465
 	 */
466
-	public function get_date_due( $context = 'view' ) {
467
-		return $this->get_due_date( $context );
466
+	public function get_date_due($context = 'view') {
467
+		return $this->get_due_date($context);
468 468
     }
469 469
 
470 470
     /**
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 	 * @param  string $context View or edit context.
475 475
 	 * @return string
476 476
 	 */
477
-	public function get_due_date_gmt( $context = 'view' ) {
478
-        $date = $this->get_due_date( $context );
477
+	public function get_due_date_gmt($context = 'view') {
478
+        $date = $this->get_due_date($context);
479 479
 
480
-        if ( $date ) {
481
-            $date = get_gmt_from_date( $date );
480
+        if ($date) {
481
+            $date = get_gmt_from_date($date);
482 482
         }
483 483
 		return $date;
484 484
     }
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 	 * @param  string $context View or edit context.
491 491
 	 * @return string
492 492
 	 */
493
-	public function get_gmt_date_due( $context = 'view' ) {
494
-		return $this->get_due_date_gmt( $context );
493
+	public function get_gmt_date_due($context = 'view') {
494
+		return $this->get_due_date_gmt($context);
495 495
     }
496 496
 
497 497
     /**
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	 * @param  string $context View or edit context.
502 502
 	 * @return string
503 503
 	 */
504
-	public function get_completed_date( $context = 'view' ) {
505
-		return $this->get_prop( 'completed_date', $context );
504
+	public function get_completed_date($context = 'view') {
505
+		return $this->get_prop('completed_date', $context);
506 506
     }
507 507
 
508 508
     /**
@@ -512,8 +512,8 @@  discard block
 block discarded – undo
512 512
 	 * @param  string $context View or edit context.
513 513
 	 * @return string
514 514
 	 */
515
-	public function get_date_completed( $context = 'view' ) {
516
-		return $this->get_completed_date( $context );
515
+	public function get_date_completed($context = 'view') {
516
+		return $this->get_completed_date($context);
517 517
     }
518 518
 
519 519
     /**
@@ -523,11 +523,11 @@  discard block
 block discarded – undo
523 523
 	 * @param  string $context View or edit context.
524 524
 	 * @return string
525 525
 	 */
526
-	public function get_completed_date_gmt( $context = 'view' ) {
527
-        $date = $this->get_completed_date( $context );
526
+	public function get_completed_date_gmt($context = 'view') {
527
+        $date = $this->get_completed_date($context);
528 528
 
529
-        if ( $date ) {
530
-            $date = get_gmt_from_date( $date );
529
+        if ($date) {
530
+            $date = get_gmt_from_date($date);
531 531
         }
532 532
 		return $date;
533 533
     }
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
 	 * @param  string $context View or edit context.
540 540
 	 * @return string
541 541
 	 */
542
-	public function get_gmt_completed_date( $context = 'view' ) {
543
-		return $this->get_completed_date_gmt( $context );
542
+	public function get_gmt_completed_date($context = 'view') {
543
+		return $this->get_completed_date_gmt($context);
544 544
     }
545 545
 
546 546
     /**
@@ -550,12 +550,12 @@  discard block
 block discarded – undo
550 550
 	 * @param  string $context View or edit context.
551 551
 	 * @return string
552 552
 	 */
553
-	public function get_number( $context = 'view' ) {
554
-		$number = $this->get_prop( 'number', $context );
553
+	public function get_number($context = 'view') {
554
+		$number = $this->get_prop('number', $context);
555 555
 
556
-		if ( empty( $number ) ) {
556
+		if (empty($number)) {
557 557
 			$number = $this->generate_number();
558
-			$this->set_number( $this->generate_number() );
558
+			$this->set_number($this->generate_number());
559 559
 		}
560 560
 
561 561
 		return $number;
@@ -569,8 +569,8 @@  discard block
 block discarded – undo
569 569
 	public function maybe_set_number() {
570 570
         $number = $this->get_number();
571 571
 
572
-        if ( empty( $number ) || $this->get_id() == $number ) {
573
-			$this->set_number( $this->generate_number() );
572
+        if (empty($number) || $this->get_id() == $number) {
573
+			$this->set_number($this->generate_number());
574 574
         }
575 575
 
576 576
 	}
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 	 * @param  string $context View or edit context.
583 583
 	 * @return string
584 584
 	 */
585
-	public function get_key( $context = 'view' ) {
586
-        return $this->get_prop( 'key', $context );
585
+	public function get_key($context = 'view') {
586
+        return $this->get_prop('key', $context);
587 587
 	}
588 588
 
589 589
 	/**
@@ -594,9 +594,9 @@  discard block
 block discarded – undo
594 594
 	public function maybe_set_key() {
595 595
         $key = $this->get_key();
596 596
 
597
-        if ( empty( $key ) ) {
598
-            $key = $this->generate_key( $this->get_type() . '_' );
599
-            $this->set_key( $key );
597
+        if (empty($key)) {
598
+            $key = $this->generate_key($this->get_type() . '_');
599
+            $this->set_key($key);
600 600
         }
601 601
 
602 602
     }
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
 	 * @param  string $context View or edit context.
609 609
 	 * @return string
610 610
 	 */
611
-	public function get_type( $context = 'view' ) {
612
-        return $this->get_prop( 'type', $context );
611
+	public function get_type($context = 'view') {
612
+        return $this->get_prop('type', $context);
613 613
 	}
614 614
 
615 615
 	/**
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	 * @return string
620 620
 	 */
621 621
 	public function get_invoice_quote_type() {
622
-        return getpaid_get_post_type_label( $this->get_post_type(), false );
622
+        return getpaid_get_post_type_label($this->get_post_type(), false);
623 623
     }
624 624
 
625 625
     /**
@@ -629,8 +629,8 @@  discard block
 block discarded – undo
629 629
 	 * @param  string $context View or edit context.
630 630
 	 * @return string
631 631
 	 */
632
-	public function get_label( $context = 'view' ) {
633
-        return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
632
+	public function get_label($context = 'view') {
633
+        return getpaid_get_post_type_label($this->get_post_type($context), false);
634 634
 	}
635 635
 
636 636
 	/**
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
 	 * @param  string $context View or edit context.
641 641
 	 * @return string
642 642
 	 */
643
-	public function get_post_type( $context = 'view' ) {
644
-        return $this->get_prop( 'post_type', $context );
643
+	public function get_post_type($context = 'view') {
644
+        return $this->get_prop('post_type', $context);
645 645
     }
646 646
 
647 647
     /**
@@ -651,8 +651,8 @@  discard block
 block discarded – undo
651 651
 	 * @param  string $context View or edit context.
652 652
 	 * @return string
653 653
 	 */
654
-	public function get_mode( $context = 'view' ) {
655
-        return $this->get_prop( 'mode', $context );
654
+	public function get_mode($context = 'view') {
655
+        return $this->get_prop('mode', $context);
656 656
     }
657 657
 
658 658
     /**
@@ -662,13 +662,13 @@  discard block
 block discarded – undo
662 662
 	 * @param  string $context View or edit context.
663 663
 	 * @return string
664 664
 	 */
665
-	public function get_path( $context = 'view' ) {
666
-        $path   = $this->get_prop( 'path', $context );
665
+	public function get_path($context = 'view') {
666
+        $path = $this->get_prop('path', $context);
667 667
 		$prefix = $this->get_type();
668 668
 
669
-		if ( 0 !== strpos( $path, $prefix ) ) {
670
-			$path = sanitize_title(  $prefix . '-' . $this->get_id()  );
671
-			$this->set_path( $path );
669
+		if (0 !== strpos($path, $prefix)) {
670
+			$path = sanitize_title($prefix . '-' . $this->get_id());
671
+			$this->set_path($path);
672 672
 		}
673 673
 
674 674
 		return $path;
@@ -681,8 +681,8 @@  discard block
 block discarded – undo
681 681
 	 * @param  string $context View or edit context.
682 682
 	 * @return string
683 683
 	 */
684
-	public function get_name( $context = 'view' ) {
685
-        return $this->get_prop( 'title', $context );
684
+	public function get_name($context = 'view') {
685
+        return $this->get_prop('title', $context);
686 686
     }
687 687
 
688 688
     /**
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
 	 * @param  string $context View or edit context.
693 693
 	 * @return string
694 694
 	 */
695
-	public function get_title( $context = 'view' ) {
696
-		return $this->get_name( $context );
695
+	public function get_title($context = 'view') {
696
+		return $this->get_name($context);
697 697
     }
698 698
 
699 699
     /**
@@ -703,8 +703,8 @@  discard block
 block discarded – undo
703 703
 	 * @param  string $context View or edit context.
704 704
 	 * @return string
705 705
 	 */
706
-	public function get_description( $context = 'view' ) {
707
-		return $this->get_prop( 'description', $context );
706
+	public function get_description($context = 'view') {
707
+		return $this->get_prop('description', $context);
708 708
     }
709 709
 
710 710
     /**
@@ -714,8 +714,8 @@  discard block
 block discarded – undo
714 714
 	 * @param  string $context View or edit context.
715 715
 	 * @return string
716 716
 	 */
717
-	public function get_excerpt( $context = 'view' ) {
718
-		return $this->get_description( $context );
717
+	public function get_excerpt($context = 'view') {
718
+		return $this->get_description($context);
719 719
     }
720 720
 
721 721
     /**
@@ -725,8 +725,8 @@  discard block
 block discarded – undo
725 725
 	 * @param  string $context View or edit context.
726 726
 	 * @return string
727 727
 	 */
728
-	public function get_summary( $context = 'view' ) {
729
-		return $this->get_description( $context );
728
+	public function get_summary($context = 'view') {
729
+		return $this->get_description($context);
730 730
     }
731 731
 
732 732
     /**
@@ -736,26 +736,26 @@  discard block
 block discarded – undo
736 736
      * @param  string $context View or edit context.
737 737
 	 * @return array
738 738
 	 */
739
-    public function get_user_info( $context = 'view' ) {
739
+    public function get_user_info($context = 'view') {
740 740
 
741 741
         $user_info = array(
742
-            'user_id'    => $this->get_user_id( $context ),
743
-            'email'      => $this->get_email( $context ),
744
-            'first_name' => $this->get_first_name( $context ),
745
-            'last_name'  => $this->get_last_name( $context ),
746
-            'address'    => $this->get_address( $context ),
747
-            'phone'      => $this->get_phone( $context ),
748
-            'city'       => $this->get_city( $context ),
749
-            'country'    => $this->get_country( $context ),
750
-            'state'      => $this->get_state( $context ),
751
-            'zip'        => $this->get_zip( $context ),
752
-            'company'    => $this->get_company( $context ),
753
-			'company_id' => $this->get_company_id( $context ),
754
-            'vat_number' => $this->get_vat_number( $context ),
755
-            'discount'   => $this->get_discount_code( $context ),
742
+            'user_id'    => $this->get_user_id($context),
743
+            'email'      => $this->get_email($context),
744
+            'first_name' => $this->get_first_name($context),
745
+            'last_name'  => $this->get_last_name($context),
746
+            'address'    => $this->get_address($context),
747
+            'phone'      => $this->get_phone($context),
748
+            'city'       => $this->get_city($context),
749
+            'country'    => $this->get_country($context),
750
+            'state'      => $this->get_state($context),
751
+            'zip'        => $this->get_zip($context),
752
+            'company'    => $this->get_company($context),
753
+			'company_id' => $this->get_company_id($context),
754
+            'vat_number' => $this->get_vat_number($context),
755
+            'discount'   => $this->get_discount_code($context),
756 756
 		);
757 757
 
758
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
758
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
759 759
 
760 760
     }
761 761
 
@@ -766,8 +766,8 @@  discard block
 block discarded – undo
766 766
 	 * @param  string $context View or edit context.
767 767
 	 * @return int
768 768
 	 */
769
-	public function get_author( $context = 'view' ) {
770
-		return (int) $this->get_prop( 'author', $context );
769
+	public function get_author($context = 'view') {
770
+		return (int) $this->get_prop('author', $context);
771 771
     }
772 772
 
773 773
     /**
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 	 * @param  string $context View or edit context.
778 778
 	 * @return int
779 779
 	 */
780
-	public function get_user_id( $context = 'view' ) {
781
-		return $this->get_author( $context );
780
+	public function get_user_id($context = 'view') {
781
+		return $this->get_author($context);
782 782
     }
783 783
 
784 784
      /**
@@ -788,8 +788,8 @@  discard block
 block discarded – undo
788 788
 	 * @param  string $context View or edit context.
789 789
 	 * @return int
790 790
 	 */
791
-	public function get_customer_id( $context = 'view' ) {
792
-		return $this->get_author( $context );
791
+	public function get_customer_id($context = 'view') {
792
+		return $this->get_author($context);
793 793
     }
794 794
 
795 795
     /**
@@ -799,8 +799,8 @@  discard block
 block discarded – undo
799 799
 	 * @param  string $context View or edit context.
800 800
 	 * @return string
801 801
 	 */
802
-	public function get_ip( $context = 'view' ) {
803
-		return $this->get_prop( 'user_ip', $context );
802
+	public function get_ip($context = 'view') {
803
+		return $this->get_prop('user_ip', $context);
804 804
     }
805 805
 
806 806
     /**
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
 	 * @param  string $context View or edit context.
811 811
 	 * @return string
812 812
 	 */
813
-	public function get_user_ip( $context = 'view' ) {
814
-		return $this->get_ip( $context );
813
+	public function get_user_ip($context = 'view') {
814
+		return $this->get_ip($context);
815 815
     }
816 816
 
817 817
      /**
@@ -821,8 +821,8 @@  discard block
 block discarded – undo
821 821
 	 * @param  string $context View or edit context.
822 822
 	 * @return string
823 823
 	 */
824
-	public function get_customer_ip( $context = 'view' ) {
825
-		return $this->get_ip( $context );
824
+	public function get_customer_ip($context = 'view') {
825
+		return $this->get_ip($context);
826 826
     }
827 827
 
828 828
     /**
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
 	 * @param  string $context View or edit context.
833 833
 	 * @return string
834 834
 	 */
835
-	public function get_first_name( $context = 'view' ) {
836
-		return $this->get_prop( 'first_name', $context );
835
+	public function get_first_name($context = 'view') {
836
+		return $this->get_prop('first_name', $context);
837 837
     }
838 838
 
839 839
     /**
@@ -843,8 +843,8 @@  discard block
 block discarded – undo
843 843
 	 * @param  string $context View or edit context.
844 844
 	 * @return string
845 845
 	 */
846
-	public function get_user_first_name( $context = 'view' ) {
847
-		return $this->get_first_name( $context );
846
+	public function get_user_first_name($context = 'view') {
847
+		return $this->get_first_name($context);
848 848
     }
849 849
 
850 850
      /**
@@ -854,8 +854,8 @@  discard block
 block discarded – undo
854 854
 	 * @param  string $context View or edit context.
855 855
 	 * @return string
856 856
 	 */
857
-	public function get_customer_first_name( $context = 'view' ) {
858
-		return $this->get_first_name( $context );
857
+	public function get_customer_first_name($context = 'view') {
858
+		return $this->get_first_name($context);
859 859
     }
860 860
 
861 861
     /**
@@ -865,8 +865,8 @@  discard block
 block discarded – undo
865 865
 	 * @param  string $context View or edit context.
866 866
 	 * @return string
867 867
 	 */
868
-	public function get_last_name( $context = 'view' ) {
869
-		return $this->get_prop( 'last_name', $context );
868
+	public function get_last_name($context = 'view') {
869
+		return $this->get_prop('last_name', $context);
870 870
     }
871 871
 
872 872
     /**
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
 	 * @param  string $context View or edit context.
877 877
 	 * @return string
878 878
 	 */
879
-	public function get_user_last_name( $context = 'view' ) {
880
-		return $this->get_last_name( $context );
879
+	public function get_user_last_name($context = 'view') {
880
+		return $this->get_last_name($context);
881 881
     }
882 882
 
883 883
     /**
@@ -887,8 +887,8 @@  discard block
 block discarded – undo
887 887
 	 * @param  string $context View or edit context.
888 888
 	 * @return string
889 889
 	 */
890
-	public function get_customer_last_name( $context = 'view' ) {
891
-		return $this->get_last_name( $context );
890
+	public function get_customer_last_name($context = 'view') {
891
+		return $this->get_last_name($context);
892 892
     }
893 893
 
894 894
     /**
@@ -898,8 +898,8 @@  discard block
 block discarded – undo
898 898
 	 * @param  string $context View or edit context.
899 899
 	 * @return string
900 900
 	 */
901
-	public function get_full_name( $context = 'view' ) {
902
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
901
+	public function get_full_name($context = 'view') {
902
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
903 903
     }
904 904
 
905 905
     /**
@@ -909,8 +909,8 @@  discard block
 block discarded – undo
909 909
 	 * @param  string $context View or edit context.
910 910
 	 * @return string
911 911
 	 */
912
-	public function get_user_full_name( $context = 'view' ) {
913
-		return $this->get_full_name( $context );
912
+	public function get_user_full_name($context = 'view') {
913
+		return $this->get_full_name($context);
914 914
     }
915 915
 
916 916
     /**
@@ -920,8 +920,8 @@  discard block
 block discarded – undo
920 920
 	 * @param  string $context View or edit context.
921 921
 	 * @return string
922 922
 	 */
923
-	public function get_customer_full_name( $context = 'view' ) {
924
-		return $this->get_full_name( $context );
923
+	public function get_customer_full_name($context = 'view') {
924
+		return $this->get_full_name($context);
925 925
     }
926 926
 
927 927
     /**
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 	 * @param  string $context View or edit context.
932 932
 	 * @return string
933 933
 	 */
934
-	public function get_phone( $context = 'view' ) {
935
-		return $this->get_prop( 'phone', $context );
934
+	public function get_phone($context = 'view') {
935
+		return $this->get_prop('phone', $context);
936 936
     }
937 937
 
938 938
     /**
@@ -942,8 +942,8 @@  discard block
 block discarded – undo
942 942
 	 * @param  string $context View or edit context.
943 943
 	 * @return string
944 944
 	 */
945
-	public function get_phone_number( $context = 'view' ) {
946
-		return $this->get_phone( $context );
945
+	public function get_phone_number($context = 'view') {
946
+		return $this->get_phone($context);
947 947
     }
948 948
 
949 949
     /**
@@ -953,8 +953,8 @@  discard block
 block discarded – undo
953 953
 	 * @param  string $context View or edit context.
954 954
 	 * @return string
955 955
 	 */
956
-	public function get_user_phone( $context = 'view' ) {
957
-		return $this->get_phone( $context );
956
+	public function get_user_phone($context = 'view') {
957
+		return $this->get_phone($context);
958 958
     }
959 959
 
960 960
     /**
@@ -964,8 +964,8 @@  discard block
 block discarded – undo
964 964
 	 * @param  string $context View or edit context.
965 965
 	 * @return string
966 966
 	 */
967
-	public function get_customer_phone( $context = 'view' ) {
968
-		return $this->get_phone( $context );
967
+	public function get_customer_phone($context = 'view') {
968
+		return $this->get_phone($context);
969 969
     }
970 970
 
971 971
     /**
@@ -975,8 +975,8 @@  discard block
 block discarded – undo
975 975
 	 * @param  string $context View or edit context.
976 976
 	 * @return string
977 977
 	 */
978
-	public function get_email( $context = 'view' ) {
979
-		return $this->get_prop( 'email', $context );
978
+	public function get_email($context = 'view') {
979
+		return $this->get_prop('email', $context);
980 980
     }
981 981
 
982 982
     /**
@@ -986,8 +986,8 @@  discard block
 block discarded – undo
986 986
 	 * @param  string $context View or edit context.
987 987
 	 * @return string
988 988
 	 */
989
-	public function get_email_address( $context = 'view' ) {
990
-		return $this->get_email( $context );
989
+	public function get_email_address($context = 'view') {
990
+		return $this->get_email($context);
991 991
     }
992 992
 
993 993
     /**
@@ -997,8 +997,8 @@  discard block
 block discarded – undo
997 997
 	 * @param  string $context View or edit context.
998 998
 	 * @return string
999 999
 	 */
1000
-	public function get_user_email( $context = 'view' ) {
1001
-		return $this->get_email( $context );
1000
+	public function get_user_email($context = 'view') {
1001
+		return $this->get_email($context);
1002 1002
     }
1003 1003
 
1004 1004
     /**
@@ -1008,8 +1008,8 @@  discard block
 block discarded – undo
1008 1008
 	 * @param  string $context View or edit context.
1009 1009
 	 * @return string
1010 1010
 	 */
1011
-	public function get_customer_email( $context = 'view' ) {
1012
-		return $this->get_email( $context );
1011
+	public function get_customer_email($context = 'view') {
1012
+		return $this->get_email($context);
1013 1013
     }
1014 1014
 
1015 1015
     /**
@@ -1019,9 +1019,9 @@  discard block
 block discarded – undo
1019 1019
 	 * @param  string $context View or edit context.
1020 1020
 	 * @return string
1021 1021
 	 */
1022
-	public function get_country( $context = 'view' ) {
1023
-		$country = $this->get_prop( 'country', $context );
1024
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1022
+	public function get_country($context = 'view') {
1023
+		$country = $this->get_prop('country', $context);
1024
+		return empty($country) ? wpinv_get_default_country() : $country;
1025 1025
     }
1026 1026
 
1027 1027
     /**
@@ -1031,8 +1031,8 @@  discard block
 block discarded – undo
1031 1031
 	 * @param  string $context View or edit context.
1032 1032
 	 * @return string
1033 1033
 	 */
1034
-	public function get_user_country( $context = 'view' ) {
1035
-		return $this->get_country( $context );
1034
+	public function get_user_country($context = 'view') {
1035
+		return $this->get_country($context);
1036 1036
     }
1037 1037
 
1038 1038
     /**
@@ -1042,8 +1042,8 @@  discard block
 block discarded – undo
1042 1042
 	 * @param  string $context View or edit context.
1043 1043
 	 * @return string
1044 1044
 	 */
1045
-	public function get_customer_country( $context = 'view' ) {
1046
-		return $this->get_country( $context );
1045
+	public function get_customer_country($context = 'view') {
1046
+		return $this->get_country($context);
1047 1047
     }
1048 1048
 
1049 1049
     /**
@@ -1053,9 +1053,9 @@  discard block
 block discarded – undo
1053 1053
 	 * @param  string $context View or edit context.
1054 1054
 	 * @return string
1055 1055
 	 */
1056
-	public function get_state( $context = 'view' ) {
1057
-		$state = $this->get_prop( 'state', $context );
1058
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1056
+	public function get_state($context = 'view') {
1057
+		$state = $this->get_prop('state', $context);
1058
+		return empty($state) ? wpinv_get_default_state() : $state;
1059 1059
     }
1060 1060
 
1061 1061
     /**
@@ -1065,8 +1065,8 @@  discard block
 block discarded – undo
1065 1065
 	 * @param  string $context View or edit context.
1066 1066
 	 * @return string
1067 1067
 	 */
1068
-	public function get_user_state( $context = 'view' ) {
1069
-		return $this->get_state( $context );
1068
+	public function get_user_state($context = 'view') {
1069
+		return $this->get_state($context);
1070 1070
     }
1071 1071
 
1072 1072
     /**
@@ -1076,8 +1076,8 @@  discard block
 block discarded – undo
1076 1076
 	 * @param  string $context View or edit context.
1077 1077
 	 * @return string
1078 1078
 	 */
1079
-	public function get_customer_state( $context = 'view' ) {
1080
-		return $this->get_state( $context );
1079
+	public function get_customer_state($context = 'view') {
1080
+		return $this->get_state($context);
1081 1081
     }
1082 1082
 
1083 1083
     /**
@@ -1087,8 +1087,8 @@  discard block
 block discarded – undo
1087 1087
 	 * @param  string $context View or edit context.
1088 1088
 	 * @return string
1089 1089
 	 */
1090
-	public function get_city( $context = 'view' ) {
1091
-		return $this->get_prop( 'city', $context );
1090
+	public function get_city($context = 'view') {
1091
+		return $this->get_prop('city', $context);
1092 1092
     }
1093 1093
 
1094 1094
     /**
@@ -1098,8 +1098,8 @@  discard block
 block discarded – undo
1098 1098
 	 * @param  string $context View or edit context.
1099 1099
 	 * @return string
1100 1100
 	 */
1101
-	public function get_user_city( $context = 'view' ) {
1102
-		return $this->get_city( $context );
1101
+	public function get_user_city($context = 'view') {
1102
+		return $this->get_city($context);
1103 1103
     }
1104 1104
 
1105 1105
     /**
@@ -1109,8 +1109,8 @@  discard block
 block discarded – undo
1109 1109
 	 * @param  string $context View or edit context.
1110 1110
 	 * @return string
1111 1111
 	 */
1112
-	public function get_customer_city( $context = 'view' ) {
1113
-		return $this->get_city( $context );
1112
+	public function get_customer_city($context = 'view') {
1113
+		return $this->get_city($context);
1114 1114
     }
1115 1115
 
1116 1116
     /**
@@ -1120,8 +1120,8 @@  discard block
 block discarded – undo
1120 1120
 	 * @param  string $context View or edit context.
1121 1121
 	 * @return string
1122 1122
 	 */
1123
-	public function get_zip( $context = 'view' ) {
1124
-		return $this->get_prop( 'zip', $context );
1123
+	public function get_zip($context = 'view') {
1124
+		return $this->get_prop('zip', $context);
1125 1125
     }
1126 1126
 
1127 1127
     /**
@@ -1131,8 +1131,8 @@  discard block
 block discarded – undo
1131 1131
 	 * @param  string $context View or edit context.
1132 1132
 	 * @return string
1133 1133
 	 */
1134
-	public function get_user_zip( $context = 'view' ) {
1135
-		return $this->get_zip( $context );
1134
+	public function get_user_zip($context = 'view') {
1135
+		return $this->get_zip($context);
1136 1136
     }
1137 1137
 
1138 1138
     /**
@@ -1142,8 +1142,8 @@  discard block
 block discarded – undo
1142 1142
 	 * @param  string $context View or edit context.
1143 1143
 	 * @return string
1144 1144
 	 */
1145
-	public function get_customer_zip( $context = 'view' ) {
1146
-		return $this->get_zip( $context );
1145
+	public function get_customer_zip($context = 'view') {
1146
+		return $this->get_zip($context);
1147 1147
     }
1148 1148
 
1149 1149
     /**
@@ -1153,8 +1153,8 @@  discard block
 block discarded – undo
1153 1153
 	 * @param  string $context View or edit context.
1154 1154
 	 * @return string
1155 1155
 	 */
1156
-	public function get_company( $context = 'view' ) {
1157
-		return $this->get_prop( 'company', $context );
1156
+	public function get_company($context = 'view') {
1157
+		return $this->get_prop('company', $context);
1158 1158
     }
1159 1159
 
1160 1160
     /**
@@ -1164,8 +1164,8 @@  discard block
 block discarded – undo
1164 1164
 	 * @param  string $context View or edit context.
1165 1165
 	 * @return string
1166 1166
 	 */
1167
-	public function get_user_company( $context = 'view' ) {
1168
-		return $this->get_company( $context );
1167
+	public function get_user_company($context = 'view') {
1168
+		return $this->get_company($context);
1169 1169
     }
1170 1170
 
1171 1171
     /**
@@ -1175,8 +1175,8 @@  discard block
 block discarded – undo
1175 1175
 	 * @param  string $context View or edit context.
1176 1176
 	 * @return string
1177 1177
 	 */
1178
-	public function get_customer_company( $context = 'view' ) {
1179
-		return $this->get_company( $context );
1178
+	public function get_customer_company($context = 'view') {
1179
+		return $this->get_company($context);
1180 1180
     }
1181 1181
 
1182 1182
 	/**
@@ -1186,8 +1186,8 @@  discard block
 block discarded – undo
1186 1186
 	 * @param  string $context View or edit context.
1187 1187
 	 * @return string
1188 1188
 	 */
1189
-	public function get_company_id( $context = 'view' ) {
1190
-		return $this->get_prop( 'company_id', $context );
1189
+	public function get_company_id($context = 'view') {
1190
+		return $this->get_prop('company_id', $context);
1191 1191
     }
1192 1192
 
1193 1193
     /**
@@ -1197,8 +1197,8 @@  discard block
 block discarded – undo
1197 1197
 	 * @param  string $context View or edit context.
1198 1198
 	 * @return string
1199 1199
 	 */
1200
-	public function get_vat_number( $context = 'view' ) {
1201
-		return $this->get_prop( 'vat_number', $context );
1200
+	public function get_vat_number($context = 'view') {
1201
+		return $this->get_prop('vat_number', $context);
1202 1202
     }
1203 1203
 
1204 1204
     /**
@@ -1208,8 +1208,8 @@  discard block
 block discarded – undo
1208 1208
 	 * @param  string $context View or edit context.
1209 1209
 	 * @return string
1210 1210
 	 */
1211
-	public function get_user_vat_number( $context = 'view' ) {
1212
-		return $this->get_vat_number( $context );
1211
+	public function get_user_vat_number($context = 'view') {
1212
+		return $this->get_vat_number($context);
1213 1213
     }
1214 1214
 
1215 1215
     /**
@@ -1219,8 +1219,8 @@  discard block
 block discarded – undo
1219 1219
 	 * @param  string $context View or edit context.
1220 1220
 	 * @return string
1221 1221
 	 */
1222
-	public function get_customer_vat_number( $context = 'view' ) {
1223
-		return $this->get_vat_number( $context );
1222
+	public function get_customer_vat_number($context = 'view') {
1223
+		return $this->get_vat_number($context);
1224 1224
     }
1225 1225
 
1226 1226
     /**
@@ -1230,8 +1230,8 @@  discard block
 block discarded – undo
1230 1230
 	 * @param  string $context View or edit context.
1231 1231
 	 * @return string
1232 1232
 	 */
1233
-	public function get_vat_rate( $context = 'view' ) {
1234
-		return $this->get_prop( 'vat_rate', $context );
1233
+	public function get_vat_rate($context = 'view') {
1234
+		return $this->get_prop('vat_rate', $context);
1235 1235
     }
1236 1236
 
1237 1237
     /**
@@ -1241,8 +1241,8 @@  discard block
 block discarded – undo
1241 1241
 	 * @param  string $context View or edit context.
1242 1242
 	 * @return string
1243 1243
 	 */
1244
-	public function get_user_vat_rate( $context = 'view' ) {
1245
-		return $this->get_vat_rate( $context );
1244
+	public function get_user_vat_rate($context = 'view') {
1245
+		return $this->get_vat_rate($context);
1246 1246
     }
1247 1247
 
1248 1248
     /**
@@ -1252,8 +1252,8 @@  discard block
 block discarded – undo
1252 1252
 	 * @param  string $context View or edit context.
1253 1253
 	 * @return string
1254 1254
 	 */
1255
-	public function get_customer_vat_rate( $context = 'view' ) {
1256
-		return $this->get_vat_rate( $context );
1255
+	public function get_customer_vat_rate($context = 'view') {
1256
+		return $this->get_vat_rate($context);
1257 1257
     }
1258 1258
 
1259 1259
     /**
@@ -1263,8 +1263,8 @@  discard block
 block discarded – undo
1263 1263
 	 * @param  string $context View or edit context.
1264 1264
 	 * @return string
1265 1265
 	 */
1266
-	public function get_address( $context = 'view' ) {
1267
-		return $this->get_prop( 'address', $context );
1266
+	public function get_address($context = 'view') {
1267
+		return $this->get_prop('address', $context);
1268 1268
     }
1269 1269
 
1270 1270
     /**
@@ -1274,8 +1274,8 @@  discard block
 block discarded – undo
1274 1274
 	 * @param  string $context View or edit context.
1275 1275
 	 * @return string
1276 1276
 	 */
1277
-	public function get_user_address( $context = 'view' ) {
1278
-		return $this->get_address( $context );
1277
+	public function get_user_address($context = 'view') {
1278
+		return $this->get_address($context);
1279 1279
     }
1280 1280
 
1281 1281
     /**
@@ -1285,8 +1285,8 @@  discard block
 block discarded – undo
1285 1285
 	 * @param  string $context View or edit context.
1286 1286
 	 * @return string
1287 1287
 	 */
1288
-	public function get_customer_address( $context = 'view' ) {
1289
-		return $this->get_address( $context );
1288
+	public function get_customer_address($context = 'view') {
1289
+		return $this->get_address($context);
1290 1290
     }
1291 1291
 
1292 1292
     /**
@@ -1296,8 +1296,8 @@  discard block
 block discarded – undo
1296 1296
 	 * @param  string $context View or edit context.
1297 1297
 	 * @return bool
1298 1298
 	 */
1299
-	public function get_is_viewed( $context = 'view' ) {
1300
-		return (bool) $this->get_prop( 'is_viewed', $context );
1299
+	public function get_is_viewed($context = 'view') {
1300
+		return (bool) $this->get_prop('is_viewed', $context);
1301 1301
 	}
1302 1302
 
1303 1303
 	/**
@@ -1307,8 +1307,8 @@  discard block
 block discarded – undo
1307 1307
 	 * @param  string $context View or edit context.
1308 1308
 	 * @return bool
1309 1309
 	 */
1310
-	public function get_email_cc( $context = 'view' ) {
1311
-		return $this->get_prop( 'email_cc', $context );
1310
+	public function get_email_cc($context = 'view') {
1311
+		return $this->get_prop('email_cc', $context);
1312 1312
 	}
1313 1313
 
1314 1314
 	/**
@@ -1318,8 +1318,8 @@  discard block
 block discarded – undo
1318 1318
 	 * @param  string $context View or edit context.
1319 1319
 	 * @return bool
1320 1320
 	 */
1321
-	public function get_template( $context = 'view' ) {
1322
-		return $this->get_prop( 'template', $context );
1321
+	public function get_template($context = 'view') {
1322
+		return $this->get_prop('template', $context);
1323 1323
 	}
1324 1324
 
1325 1325
 	/**
@@ -1329,8 +1329,8 @@  discard block
 block discarded – undo
1329 1329
 	 * @param  string $context View or edit context.
1330 1330
 	 * @return bool
1331 1331
 	 */
1332
-	public function get_created_via( $context = 'view' ) {
1333
-		return $this->get_prop( 'created_via', $context );
1332
+	public function get_created_via($context = 'view') {
1333
+		return $this->get_prop('created_via', $context);
1334 1334
 	}
1335 1335
 
1336 1336
 	/**
@@ -1340,8 +1340,8 @@  discard block
 block discarded – undo
1340 1340
 	 * @param  string $context View or edit context.
1341 1341
 	 * @return bool
1342 1342
 	 */
1343
-	public function get_address_confirmed( $context = 'view' ) {
1344
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1343
+	public function get_address_confirmed($context = 'view') {
1344
+		return (bool) $this->get_prop('address_confirmed', $context);
1345 1345
     }
1346 1346
 
1347 1347
     /**
@@ -1351,8 +1351,8 @@  discard block
 block discarded – undo
1351 1351
 	 * @param  string $context View or edit context.
1352 1352
 	 * @return bool
1353 1353
 	 */
1354
-	public function get_user_address_confirmed( $context = 'view' ) {
1355
-		return $this->get_address_confirmed( $context );
1354
+	public function get_user_address_confirmed($context = 'view') {
1355
+		return $this->get_address_confirmed($context);
1356 1356
     }
1357 1357
 
1358 1358
     /**
@@ -1362,8 +1362,8 @@  discard block
 block discarded – undo
1362 1362
 	 * @param  string $context View or edit context.
1363 1363
 	 * @return bool
1364 1364
 	 */
1365
-	public function get_customer_address_confirmed( $context = 'view' ) {
1366
-		return $this->get_address_confirmed( $context );
1365
+	public function get_customer_address_confirmed($context = 'view') {
1366
+		return $this->get_address_confirmed($context);
1367 1367
     }
1368 1368
 
1369 1369
     /**
@@ -1373,12 +1373,12 @@  discard block
 block discarded – undo
1373 1373
 	 * @param  string $context View or edit context.
1374 1374
 	 * @return float
1375 1375
 	 */
1376
-	public function get_subtotal( $context = 'view' ) {
1377
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1376
+	public function get_subtotal($context = 'view') {
1377
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1378 1378
 
1379 1379
         // Backwards compatibility.
1380
-        if ( is_bool( $context ) && $context ) {
1381
-            return wpinv_price( $subtotal, $this->get_currency() );
1380
+        if (is_bool($context) && $context) {
1381
+            return wpinv_price($subtotal, $this->get_currency());
1382 1382
         }
1383 1383
 
1384 1384
         return $subtotal;
@@ -1391,8 +1391,8 @@  discard block
 block discarded – undo
1391 1391
 	 * @param  string $context View or edit context.
1392 1392
 	 * @return float
1393 1393
 	 */
1394
-	public function get_total_discount( $context = 'view' ) {
1395
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1394
+	public function get_total_discount($context = 'view') {
1395
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context)));
1396 1396
     }
1397 1397
 
1398 1398
     /**
@@ -1402,18 +1402,18 @@  discard block
 block discarded – undo
1402 1402
 	 * @param  string $context View or edit context.
1403 1403
 	 * @return float
1404 1404
 	 */
1405
-	public function get_total_tax( $context = 'view' ) {
1406
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1405
+	public function get_total_tax($context = 'view') {
1406
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context)));
1407 1407
 	}
1408 1408
 
1409 1409
 	/**
1410 1410
 	 * @deprecated
1411 1411
 	 */
1412
-	public function get_final_tax( $currency = false ) {
1412
+	public function get_final_tax($currency = false) {
1413 1413
 		$tax = $this->get_total_tax();
1414 1414
 
1415
-        if ( $currency ) {
1416
-			return wpinv_price( $tax, $this->get_currency() );
1415
+        if ($currency) {
1416
+			return wpinv_price($tax, $this->get_currency());
1417 1417
         }
1418 1418
 
1419 1419
         return $tax;
@@ -1426,8 +1426,8 @@  discard block
 block discarded – undo
1426 1426
 	 * @param  string $context View or edit context.
1427 1427
 	 * @return float
1428 1428
 	 */
1429
-	public function get_total_fees( $context = 'view' ) {
1430
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1429
+	public function get_total_fees($context = 'view') {
1430
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context)));
1431 1431
     }
1432 1432
 
1433 1433
     /**
@@ -1437,8 +1437,8 @@  discard block
 block discarded – undo
1437 1437
 	 * @param  string $context View or edit context.
1438 1438
 	 * @return float
1439 1439
 	 */
1440
-	public function get_fees_total( $context = 'view' ) {
1441
-		return $this->get_total_fees( $context );
1440
+	public function get_fees_total($context = 'view') {
1441
+		return $this->get_total_fees($context);
1442 1442
     }
1443 1443
 
1444 1444
     /**
@@ -1447,8 +1447,8 @@  discard block
 block discarded – undo
1447 1447
 	 * @since 1.0.19
1448 1448
      * @return float
1449 1449
 	 */
1450
-	public function get_total( $context = 'view' ) {
1451
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) );
1450
+	public function get_total($context = 'view') {
1451
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total', $context)));
1452 1452
 	}
1453 1453
 
1454 1454
 	/**
@@ -1460,20 +1460,20 @@  discard block
 block discarded – undo
1460 1460
 	public function get_non_recurring_total() {
1461 1461
 
1462 1462
 		$subtotal = 0;
1463
-		foreach ( $this->get_items() as $item ) {
1464
-			if ( ! $item->is_recurring() ) {
1463
+		foreach ($this->get_items() as $item) {
1464
+			if (!$item->is_recurring()) {
1465 1465
 				$subtotal += $item->get_sub_total();
1466 1466
 			}
1467 1467
 		}
1468 1468
 
1469
-		foreach ( $this->get_fees() as $fee ) {
1470
-			if ( empty( $fee['recurring_fee'] ) ) {
1471
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1469
+		foreach ($this->get_fees() as $fee) {
1470
+			if (empty($fee['recurring_fee'])) {
1471
+				$subtotal += wpinv_sanitize_amount($fee['initial_fee']);
1472 1472
 			}
1473 1473
 		}
1474 1474
 
1475
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1476
-        return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1475
+		$subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal));
1476
+        return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this);
1477 1477
 
1478 1478
     }
1479 1479
 
@@ -1496,7 +1496,7 @@  discard block
 block discarded – undo
1496 1496
 	 */
1497 1497
     public function get_initial_total() {
1498 1498
 
1499
-		if ( empty( $this->totals ) ) {
1499
+		if (empty($this->totals)) {
1500 1500
 			$this->recalculate_total();
1501 1501
 		}
1502 1502
 
@@ -1506,12 +1506,12 @@  discard block
 block discarded – undo
1506 1506
 		$subtotal = $this->totals['subtotal']['initial'];
1507 1507
 		$total    = $tax + $fee - $discount + $subtotal;
1508 1508
 
1509
-		if ( 0 > $total ) {
1509
+		if (0 > $total) {
1510 1510
 			$total = 0;
1511 1511
 		}
1512 1512
 
1513
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1514
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1513
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1514
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1515 1515
 	}
1516 1516
 
1517 1517
 	/**
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 	 */
1524 1524
     public function get_recurring_total() {
1525 1525
 
1526
-		if ( empty( $this->totals ) ) {
1526
+		if (empty($this->totals)) {
1527 1527
 			$this->recalculate_total();
1528 1528
 		}
1529 1529
 
@@ -1533,12 +1533,12 @@  discard block
 block discarded – undo
1533 1533
 		$subtotal = $this->totals['subtotal']['recurring'];
1534 1534
 		$total    = $tax + $fee - $discount + $subtotal;
1535 1535
 
1536
-		if ( 0 > $total ) {
1536
+		if (0 > $total) {
1537 1537
 			$total = 0;
1538 1538
 		}
1539 1539
 
1540
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1541
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1540
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1541
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1542 1542
 	}
1543 1543
 
1544 1544
 	/**
@@ -1549,10 +1549,10 @@  discard block
 block discarded – undo
1549 1549
 	 * @param string $currency Whether to include the currency.
1550 1550
      * @return float|string
1551 1551
 	 */
1552
-    public function get_recurring_details( $field = '', $currency = false ) {
1552
+    public function get_recurring_details($field = '', $currency = false) {
1553 1553
 
1554 1554
 		// Maybe recalculate totals.
1555
-		if ( empty( $this->totals ) ) {
1555
+		if (empty($this->totals)) {
1556 1556
 			$this->recalculate_total();
1557 1557
 		}
1558 1558
 
@@ -1572,8 +1572,8 @@  discard block
 block discarded – undo
1572 1572
 			$currency
1573 1573
 		);
1574 1574
 
1575
-        if ( isset( $data[$field] ) ) {
1576
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1575
+        if (isset($data[$field])) {
1576
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1577 1577
         }
1578 1578
 
1579 1579
         return $data;
@@ -1586,8 +1586,8 @@  discard block
 block discarded – undo
1586 1586
 	 * @param  string $context View or edit context.
1587 1587
 	 * @return array
1588 1588
 	 */
1589
-	public function get_fees( $context = 'view' ) {
1590
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1589
+	public function get_fees($context = 'view') {
1590
+		return wpinv_parse_list($this->get_prop('fees', $context));
1591 1591
     }
1592 1592
 
1593 1593
     /**
@@ -1597,8 +1597,8 @@  discard block
 block discarded – undo
1597 1597
 	 * @param  string $context View or edit context.
1598 1598
 	 * @return array
1599 1599
 	 */
1600
-	public function get_discounts( $context = 'view' ) {
1601
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1600
+	public function get_discounts($context = 'view') {
1601
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1602 1602
     }
1603 1603
 
1604 1604
     /**
@@ -1608,8 +1608,8 @@  discard block
 block discarded – undo
1608 1608
 	 * @param  string $context View or edit context.
1609 1609
 	 * @return array
1610 1610
 	 */
1611
-	public function get_taxes( $context = 'view' ) {
1612
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1611
+	public function get_taxes($context = 'view') {
1612
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1613 1613
     }
1614 1614
 
1615 1615
     /**
@@ -1619,8 +1619,8 @@  discard block
 block discarded – undo
1619 1619
 	 * @param  string $context View or edit context.
1620 1620
 	 * @return GetPaid_Form_Item[]
1621 1621
 	 */
1622
-	public function get_items( $context = 'view' ) {
1623
-        return $this->get_prop( 'items', $context );
1622
+	public function get_items($context = 'view') {
1623
+        return $this->get_prop('items', $context);
1624 1624
 	}
1625 1625
 
1626 1626
 	/**
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
 	 * @return string
1631 1631
 	 */
1632 1632
 	public function get_item_ids() {
1633
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1633
+		return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id'));
1634 1634
     }
1635 1635
 
1636 1636
     /**
@@ -1640,8 +1640,8 @@  discard block
 block discarded – undo
1640 1640
 	 * @param  string $context View or edit context.
1641 1641
 	 * @return int
1642 1642
 	 */
1643
-	public function get_payment_form( $context = 'view' ) {
1644
-		return intval( $this->get_prop( 'payment_form', $context ) );
1643
+	public function get_payment_form($context = 'view') {
1644
+		return intval($this->get_prop('payment_form', $context));
1645 1645
     }
1646 1646
 
1647 1647
     /**
@@ -1651,8 +1651,8 @@  discard block
 block discarded – undo
1651 1651
 	 * @param  string $context View or edit context.
1652 1652
 	 * @return string
1653 1653
 	 */
1654
-	public function get_submission_id( $context = 'view' ) {
1655
-		return $this->get_prop( 'submission_id', $context );
1654
+	public function get_submission_id($context = 'view') {
1655
+		return $this->get_prop('submission_id', $context);
1656 1656
     }
1657 1657
 
1658 1658
     /**
@@ -1662,8 +1662,8 @@  discard block
 block discarded – undo
1662 1662
 	 * @param  string $context View or edit context.
1663 1663
 	 * @return string
1664 1664
 	 */
1665
-	public function get_discount_code( $context = 'view' ) {
1666
-		return $this->get_prop( 'discount_code', $context );
1665
+	public function get_discount_code($context = 'view') {
1666
+		return $this->get_prop('discount_code', $context);
1667 1667
     }
1668 1668
 
1669 1669
     /**
@@ -1673,8 +1673,8 @@  discard block
 block discarded – undo
1673 1673
 	 * @param  string $context View or edit context.
1674 1674
 	 * @return string
1675 1675
 	 */
1676
-	public function get_gateway( $context = 'view' ) {
1677
-		return $this->get_prop( 'gateway', $context );
1676
+	public function get_gateway($context = 'view') {
1677
+		return $this->get_prop('gateway', $context);
1678 1678
     }
1679 1679
 
1680 1680
     /**
@@ -1684,8 +1684,8 @@  discard block
 block discarded – undo
1684 1684
 	 * @return string
1685 1685
 	 */
1686 1686
     public function get_gateway_title() {
1687
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1688
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1687
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1688
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1689 1689
     }
1690 1690
 
1691 1691
     /**
@@ -1695,8 +1695,8 @@  discard block
 block discarded – undo
1695 1695
 	 * @param  string $context View or edit context.
1696 1696
 	 * @return string
1697 1697
 	 */
1698
-	public function get_transaction_id( $context = 'view' ) {
1699
-		return $this->get_prop( 'transaction_id', $context );
1698
+	public function get_transaction_id($context = 'view') {
1699
+		return $this->get_prop('transaction_id', $context);
1700 1700
     }
1701 1701
 
1702 1702
     /**
@@ -1706,9 +1706,9 @@  discard block
 block discarded – undo
1706 1706
 	 * @param  string $context View or edit context.
1707 1707
 	 * @return string
1708 1708
 	 */
1709
-	public function get_currency( $context = 'view' ) {
1710
-        $currency = $this->get_prop( 'currency', $context );
1711
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1709
+	public function get_currency($context = 'view') {
1710
+        $currency = $this->get_prop('currency', $context);
1711
+        return empty($currency) ? wpinv_get_currency() : $currency;
1712 1712
     }
1713 1713
 
1714 1714
     /**
@@ -1718,8 +1718,8 @@  discard block
 block discarded – undo
1718 1718
 	 * @param  string $context View or edit context.
1719 1719
 	 * @return bool
1720 1720
 	 */
1721
-	public function get_disable_taxes( $context = 'view' ) {
1722
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1721
+	public function get_disable_taxes($context = 'view') {
1722
+        return (bool) $this->get_prop('disable_taxes', $context);
1723 1723
     }
1724 1724
 
1725 1725
     /**
@@ -1729,8 +1729,8 @@  discard block
 block discarded – undo
1729 1729
 	 * @param  string $context View or edit context.
1730 1730
 	 * @return int
1731 1731
 	 */
1732
-    public function get_subscription_id( $context = 'view' ) {
1733
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1732
+    public function get_subscription_id($context = 'view') {
1733
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1734 1734
 	}
1735 1735
 
1736 1736
 	/**
@@ -1740,12 +1740,12 @@  discard block
 block discarded – undo
1740 1740
 	 * @param  string $context View or edit context.
1741 1741
 	 * @return int
1742 1742
 	 */
1743
-    public function get_remote_subscription_id( $context = 'view' ) {
1744
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1743
+    public function get_remote_subscription_id($context = 'view') {
1744
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1745 1745
 
1746
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1746
+        if (empty($subscription_id) && $this->is_renewal()) {
1747 1747
             $parent = $this->get_parent();
1748
-            return $parent->get_remote_subscription_id( $context );
1748
+            return $parent->get_remote_subscription_id($context);
1749 1749
         }
1750 1750
 
1751 1751
         return $subscription_id;
@@ -1758,20 +1758,20 @@  discard block
 block discarded – undo
1758 1758
 	 * @param  string $context View or edit context.
1759 1759
 	 * @return array
1760 1760
 	 */
1761
-    public function get_payment_meta( $context = 'view' ) {
1761
+    public function get_payment_meta($context = 'view') {
1762 1762
 
1763 1763
         return array(
1764
-            'price'        => $this->get_total( $context ),
1765
-            'date'         => $this->get_date_created( $context ),
1766
-            'user_email'   => $this->get_email( $context ),
1767
-            'invoice_key'  => $this->get_key( $context ),
1768
-            'currency'     => $this->get_currency( $context ),
1769
-            'items'        => $this->get_items( $context ),
1770
-            'user_info'    => $this->get_user_info( $context ),
1764
+            'price'        => $this->get_total($context),
1765
+            'date'         => $this->get_date_created($context),
1766
+            'user_email'   => $this->get_email($context),
1767
+            'invoice_key'  => $this->get_key($context),
1768
+            'currency'     => $this->get_currency($context),
1769
+            'items'        => $this->get_items($context),
1770
+            'user_info'    => $this->get_user_info($context),
1771 1771
             'cart_details' => $this->get_cart_details(),
1772
-            'status'       => $this->get_status( $context ),
1773
-            'fees'         => $this->get_fees( $context ),
1774
-            'taxes'        => $this->get_taxes( $context ),
1772
+            'status'       => $this->get_status($context),
1773
+            'fees'         => $this->get_fees($context),
1774
+            'taxes'        => $this->get_taxes($context),
1775 1775
         );
1776 1776
 
1777 1777
     }
@@ -1786,9 +1786,9 @@  discard block
 block discarded – undo
1786 1786
         $items        = $this->get_items();
1787 1787
         $cart_details = array();
1788 1788
 
1789
-        foreach ( $items as $item ) {
1789
+        foreach ($items as $item) {
1790 1790
 			$item->invoice_id = $this->get_id();
1791
-            $cart_details[]   = $item->prepare_data_for_saving();
1791
+            $cart_details[] = $item->prepare_data_for_saving();
1792 1792
         }
1793 1793
 
1794 1794
         return $cart_details;
@@ -1799,11 +1799,11 @@  discard block
 block discarded – undo
1799 1799
 	 *
1800 1800
 	 * @return null|GetPaid_Form_Item|int
1801 1801
 	 */
1802
-	public function get_recurring( $object = false ) {
1802
+	public function get_recurring($object = false) {
1803 1803
 
1804 1804
 		// Are we returning an object?
1805
-        if ( $object ) {
1806
-            return $this->get_item( $this->recurring_item );
1805
+        if ($object) {
1806
+            return $this->get_item($this->recurring_item);
1807 1807
         }
1808 1808
 
1809 1809
         return $this->recurring_item;
@@ -1818,15 +1818,15 @@  discard block
 block discarded – undo
1818 1818
 	public function get_subscription_name() {
1819 1819
 
1820 1820
 		// Retrieve the recurring name
1821
-        $item = $this->get_recurring( true );
1821
+        $item = $this->get_recurring(true);
1822 1822
 
1823 1823
 		// Abort if it does not exist.
1824
-        if ( empty( $item ) ) {
1824
+        if (empty($item)) {
1825 1825
             return '';
1826 1826
         }
1827 1827
 
1828 1828
 		// Return the item name.
1829
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1829
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1830 1830
 	}
1831 1831
 
1832 1832
 	/**
@@ -1836,9 +1836,9 @@  discard block
 block discarded – undo
1836 1836
 	 * @return string
1837 1837
 	 */
1838 1838
 	public function get_view_url() {
1839
-        $invoice_url = get_permalink( $this->get_id() );
1840
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1841
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1839
+        $invoice_url = get_permalink($this->get_id());
1840
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1841
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1842 1842
 	}
1843 1843
 
1844 1844
 	/**
@@ -1847,25 +1847,25 @@  discard block
 block discarded – undo
1847 1847
 	 * @since 1.0.19
1848 1848
 	 * @return string
1849 1849
 	 */
1850
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1850
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1851 1851
 
1852 1852
 		// Retrieve the checkout url.
1853 1853
         $pay_url = wpinv_get_checkout_uri();
1854 1854
 
1855 1855
 		// Maybe force ssl.
1856
-        if ( is_ssl() ) {
1857
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1856
+        if (is_ssl()) {
1857
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1858 1858
         }
1859 1859
 
1860 1860
 		// Add the invoice key.
1861
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1861
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1862 1862
 
1863 1863
 		// (Maybe?) add a secret
1864
-        if ( $secret ) {
1865
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1864
+        if ($secret) {
1865
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1866 1866
         }
1867 1867
 
1868
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1868
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1869 1869
 	}
1870 1870
 	
1871 1871
 	/**
@@ -1880,14 +1880,14 @@  discard block
 block discarded – undo
1880 1880
         $receipt_url = wpinv_get_success_page_uri();
1881 1881
 
1882 1882
 		// Maybe force ssl.
1883
-        if ( is_ssl() ) {
1884
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1883
+        if (is_ssl()) {
1884
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1885 1885
         }
1886 1886
 
1887 1887
 		// Add the invoice key.
1888
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1888
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1889 1889
 
1890
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1890
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1891 1891
 	}
1892 1892
 	
1893 1893
 	/**
@@ -1900,7 +1900,7 @@  discard block
 block discarded – undo
1900 1900
 
1901 1901
 		$type   = $this->get_type();
1902 1902
 		$status = "wpi-$type-pending";
1903
-		return str_replace( '-invoice', '', $status );
1903
+		return str_replace('-invoice', '', $status);
1904 1904
 
1905 1905
 	}
1906 1906
 
@@ -1914,8 +1914,8 @@  discard block
 block discarded – undo
1914 1914
 	 * @param  string $context View or edit context.
1915 1915
 	 * @return mixed Value of the given invoice property (if set).
1916 1916
 	 */
1917
-	public function get( $key, $context = 'view' ) {
1918
-        return $this->get_prop( $key, $context );
1917
+	public function get($key, $context = 'view') {
1918
+        return $this->get_prop($key, $context);
1919 1919
 	}
1920 1920
 
1921 1921
     /*
@@ -1938,11 +1938,11 @@  discard block
 block discarded – undo
1938 1938
 	 * @param  mixed $value new value.
1939 1939
 	 * @return mixed Value of the given invoice property (if set).
1940 1940
 	 */
1941
-	public function set( $key, $value ) {
1941
+	public function set($key, $value) {
1942 1942
 
1943 1943
         $setter = "set_$key";
1944
-        if ( is_callable( array( $this, $setter ) ) ) {
1945
-            $this->{$setter}( $value );
1944
+        if (is_callable(array($this, $setter))) {
1945
+            $this->{$setter}($value);
1946 1946
         }
1947 1947
 
1948 1948
 	}
@@ -1956,45 +1956,45 @@  discard block
 block discarded – undo
1956 1956
 	 * @param bool   $manual_update Is this a manual status change?.
1957 1957
 	 * @return array details of change.
1958 1958
 	 */
1959
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1959
+	public function set_status($new_status, $note = '', $manual_update = false) {
1960 1960
 		$old_status = $this->get_status();
1961 1961
 
1962 1962
 		$statuses = $this->get_all_statuses();
1963 1963
 
1964
-		if ( isset( $statuses[ 'draft' ] ) ) {
1965
-			unset( $statuses[ 'draft' ] );
1964
+		if (isset($statuses['draft'])) {
1965
+			unset($statuses['draft']);
1966 1966
 		}
1967 1967
 
1968
-		$this->set_prop( 'status', $new_status );
1968
+		$this->set_prop('status', $new_status);
1969 1969
 
1970 1970
 		// If setting the status, ensure it's set to a valid status.
1971
-		if ( true === $this->object_read ) {
1971
+		if (true === $this->object_read) {
1972 1972
 
1973 1973
 			// Only allow valid new status.
1974
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1974
+			if (!array_key_exists($new_status, $statuses)) {
1975 1975
 				$new_status = $this->get_default_status();
1976 1976
 			}
1977 1977
 
1978 1978
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1979
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1979
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1980 1980
 				$old_status = $this->get_default_status();
1981 1981
 			}
1982 1982
 
1983 1983
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1984
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1984
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
1985 1985
 				$old_status = 'wpi-pending';
1986 1986
 			}
1987 1987
 
1988
-			if ( $old_status !== $new_status ) {
1988
+			if ($old_status !== $new_status) {
1989 1989
 				$this->status_transition = array(
1990
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1990
+					'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1991 1991
 					'to'     => $new_status,
1992 1992
 					'note'   => $note,
1993 1993
 					'manual' => (bool) $manual_update,
1994 1994
 				);
1995 1995
 
1996
-				if ( $manual_update ) {
1997
-					do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1996
+				if ($manual_update) {
1997
+					do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1998 1998
 				}
1999 1999
 
2000 2000
 				$this->maybe_set_date_paid();
@@ -2019,8 +2019,8 @@  discard block
 block discarded – undo
2019 2019
 	 */
2020 2020
 	public function maybe_set_date_paid() {
2021 2021
 
2022
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2023
-			$this->set_date_completed( current_time( 'mysql' ) );
2022
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
2023
+			$this->set_date_completed(current_time('mysql'));
2024 2024
 		}
2025 2025
 	}
2026 2026
 
@@ -2029,11 +2029,11 @@  discard block
 block discarded – undo
2029 2029
 	 *
2030 2030
 	 * @since 1.0.19
2031 2031
 	 */
2032
-	public function set_parent_id( $value ) {
2033
-		if ( $value && ( $value === $this->get_id() ) ) {
2032
+	public function set_parent_id($value) {
2033
+		if ($value && ($value === $this->get_id())) {
2034 2034
 			return;
2035 2035
 		}
2036
-		$this->set_prop( 'parent_id', absint( $value ) );
2036
+		$this->set_prop('parent_id', absint($value));
2037 2037
     }
2038 2038
 
2039 2039
     /**
@@ -2041,8 +2041,8 @@  discard block
 block discarded – undo
2041 2041
 	 *
2042 2042
 	 * @since 1.0.19
2043 2043
 	 */
2044
-	public function set_version( $value ) {
2045
-		$this->set_prop( 'version', $value );
2044
+	public function set_version($value) {
2045
+		$this->set_prop('version', $value);
2046 2046
     }
2047 2047
 
2048 2048
     /**
@@ -2052,15 +2052,15 @@  discard block
 block discarded – undo
2052 2052
 	 * @param string $value Value to set.
2053 2053
      * @return bool Whether or not the date was set.
2054 2054
 	 */
2055
-	public function set_date_created( $value ) {
2056
-        $date = strtotime( $value );
2055
+	public function set_date_created($value) {
2056
+        $date = strtotime($value);
2057 2057
 
2058
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2059
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
2058
+        if ($date && $value !== '0000-00-00 00:00:00') {
2059
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
2060 2060
             return true;
2061 2061
         }
2062 2062
 
2063
-		$this->set_prop( 'date_created', '' );
2063
+		$this->set_prop('date_created', '');
2064 2064
 		return false;
2065 2065
 
2066 2066
     }
@@ -2072,15 +2072,15 @@  discard block
 block discarded – undo
2072 2072
 	 * @param string $value Value to set.
2073 2073
      * @return bool Whether or not the date was set.
2074 2074
 	 */
2075
-	public function set_due_date( $value ) {
2076
-        $date = strtotime( $value );
2075
+	public function set_due_date($value) {
2076
+        $date = strtotime($value);
2077 2077
 
2078
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2079
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
2078
+        if ($date && $value !== '0000-00-00 00:00:00') {
2079
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
2080 2080
             return true;
2081 2081
         }
2082 2082
 
2083
-		$this->set_prop( 'due_date', '' );
2083
+		$this->set_prop('due_date', '');
2084 2084
         return false;
2085 2085
 
2086 2086
     }
@@ -2091,8 +2091,8 @@  discard block
 block discarded – undo
2091 2091
 	 * @since 1.0.19
2092 2092
 	 * @param  string $value New name.
2093 2093
 	 */
2094
-	public function set_date_due( $value ) {
2095
-		$this->set_due_date( $value );
2094
+	public function set_date_due($value) {
2095
+		$this->set_due_date($value);
2096 2096
     }
2097 2097
 
2098 2098
     /**
@@ -2102,15 +2102,15 @@  discard block
 block discarded – undo
2102 2102
 	 * @param string $value Value to set.
2103 2103
      * @return bool Whether or not the date was set.
2104 2104
 	 */
2105
-	public function set_completed_date( $value ) {
2106
-        $date = strtotime( $value );
2105
+	public function set_completed_date($value) {
2106
+        $date = strtotime($value);
2107 2107
 
2108
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
2109
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2108
+        if ($date && $value !== '0000-00-00 00:00:00') {
2109
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2110 2110
             return true;
2111 2111
         }
2112 2112
 
2113
-		$this->set_prop( 'completed_date', '' );
2113
+		$this->set_prop('completed_date', '');
2114 2114
         return false;
2115 2115
 
2116 2116
     }
@@ -2121,8 +2121,8 @@  discard block
 block discarded – undo
2121 2121
 	 * @since 1.0.19
2122 2122
 	 * @param  string $value New name.
2123 2123
 	 */
2124
-	public function set_date_completed( $value ) {
2125
-		$this->set_completed_date( $value );
2124
+	public function set_date_completed($value) {
2125
+		$this->set_completed_date($value);
2126 2126
     }
2127 2127
 
2128 2128
     /**
@@ -2132,15 +2132,15 @@  discard block
 block discarded – undo
2132 2132
 	 * @param string $value Value to set.
2133 2133
      * @return bool Whether or not the date was set.
2134 2134
 	 */
2135
-	public function set_date_modified( $value ) {
2136
-        $date = strtotime( $value );
2135
+	public function set_date_modified($value) {
2136
+        $date = strtotime($value);
2137 2137
 
2138
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2139
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2138
+        if ($date && $value !== '0000-00-00 00:00:00') {
2139
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2140 2140
             return true;
2141 2141
         }
2142 2142
 
2143
-		$this->set_prop( 'date_modified', '' );
2143
+		$this->set_prop('date_modified', '');
2144 2144
         return false;
2145 2145
 
2146 2146
     }
@@ -2151,9 +2151,9 @@  discard block
 block discarded – undo
2151 2151
 	 * @since 1.0.19
2152 2152
 	 * @param  string $value New number.
2153 2153
 	 */
2154
-	public function set_number( $value ) {
2155
-        $number = sanitize_text_field( $value );
2156
-		$this->set_prop( 'number', $number );
2154
+	public function set_number($value) {
2155
+        $number = sanitize_text_field($value);
2156
+		$this->set_prop('number', $number);
2157 2157
     }
2158 2158
 
2159 2159
     /**
@@ -2162,9 +2162,9 @@  discard block
 block discarded – undo
2162 2162
 	 * @since 1.0.19
2163 2163
 	 * @param  string $value Type.
2164 2164
 	 */
2165
-	public function set_type( $value ) {
2166
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2167
-		$this->set_prop( 'type', $type );
2165
+	public function set_type($value) {
2166
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2167
+		$this->set_prop('type', $type);
2168 2168
 	}
2169 2169
 
2170 2170
     /**
@@ -2173,10 +2173,10 @@  discard block
 block discarded – undo
2173 2173
 	 * @since 1.0.19
2174 2174
 	 * @param  string $value Post type.
2175 2175
 	 */
2176
-	public function set_post_type( $value ) {
2177
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2178
-			$this->set_type( $value );
2179
-            $this->set_prop( 'post_type', $value );
2176
+	public function set_post_type($value) {
2177
+        if (getpaid_is_invoice_post_type($value)) {
2178
+			$this->set_type($value);
2179
+            $this->set_prop('post_type', $value);
2180 2180
         }
2181 2181
     }
2182 2182
 
@@ -2186,9 +2186,9 @@  discard block
 block discarded – undo
2186 2186
 	 * @since 1.0.19
2187 2187
 	 * @param  string $value New key.
2188 2188
 	 */
2189
-	public function set_key( $value ) {
2190
-        $key = sanitize_text_field( $value );
2191
-		$this->set_prop( 'key', $key );
2189
+	public function set_key($value) {
2190
+        $key = sanitize_text_field($value);
2191
+		$this->set_prop('key', $key);
2192 2192
     }
2193 2193
 
2194 2194
     /**
@@ -2197,9 +2197,9 @@  discard block
 block discarded – undo
2197 2197
 	 * @since 1.0.19
2198 2198
 	 * @param  string $value mode.
2199 2199
 	 */
2200
-	public function set_mode( $value ) {
2201
-        if ( in_array( $value, array( 'live', 'test' ) ) ) {
2202
-            $this->set_prop( 'mode', $value );
2200
+	public function set_mode($value) {
2201
+        if (in_array($value, array('live', 'test'))) {
2202
+            $this->set_prop('mode', $value);
2203 2203
         }
2204 2204
     }
2205 2205
 
@@ -2209,8 +2209,8 @@  discard block
 block discarded – undo
2209 2209
 	 * @since 1.0.19
2210 2210
 	 * @param  string $value path.
2211 2211
 	 */
2212
-	public function set_path( $value ) {
2213
-        $this->set_prop( 'path', $value );
2212
+	public function set_path($value) {
2213
+        $this->set_prop('path', $value);
2214 2214
     }
2215 2215
 
2216 2216
     /**
@@ -2219,9 +2219,9 @@  discard block
 block discarded – undo
2219 2219
 	 * @since 1.0.19
2220 2220
 	 * @param  string $value New name.
2221 2221
 	 */
2222
-	public function set_name( $value ) {
2223
-        $name = sanitize_text_field( $value );
2224
-		$this->set_prop( 'name', $name );
2222
+	public function set_name($value) {
2223
+        $name = sanitize_text_field($value);
2224
+		$this->set_prop('name', $name);
2225 2225
     }
2226 2226
 
2227 2227
     /**
@@ -2230,8 +2230,8 @@  discard block
 block discarded – undo
2230 2230
 	 * @since 1.0.19
2231 2231
 	 * @param  string $value New name.
2232 2232
 	 */
2233
-	public function set_title( $value ) {
2234
-		$this->set_name( $value );
2233
+	public function set_title($value) {
2234
+		$this->set_name($value);
2235 2235
     }
2236 2236
 
2237 2237
     /**
@@ -2240,9 +2240,9 @@  discard block
 block discarded – undo
2240 2240
 	 * @since 1.0.19
2241 2241
 	 * @param  string $value New description.
2242 2242
 	 */
2243
-	public function set_description( $value ) {
2244
-        $description = wp_kses_post( $value );
2245
-		$this->set_prop( 'description', $description );
2243
+	public function set_description($value) {
2244
+        $description = wp_kses_post($value);
2245
+		$this->set_prop('description', $description);
2246 2246
     }
2247 2247
 
2248 2248
     /**
@@ -2251,8 +2251,8 @@  discard block
 block discarded – undo
2251 2251
 	 * @since 1.0.19
2252 2252
 	 * @param  string $value New description.
2253 2253
 	 */
2254
-	public function set_excerpt( $value ) {
2255
-		$this->set_description( $value );
2254
+	public function set_excerpt($value) {
2255
+		$this->set_description($value);
2256 2256
     }
2257 2257
 
2258 2258
     /**
@@ -2261,8 +2261,8 @@  discard block
 block discarded – undo
2261 2261
 	 * @since 1.0.19
2262 2262
 	 * @param  string $value New description.
2263 2263
 	 */
2264
-	public function set_summary( $value ) {
2265
-		$this->set_description( $value );
2264
+	public function set_summary($value) {
2265
+		$this->set_description($value);
2266 2266
     }
2267 2267
 
2268 2268
     /**
@@ -2271,12 +2271,12 @@  discard block
 block discarded – undo
2271 2271
 	 * @since 1.0.19
2272 2272
 	 * @param  int $value New author.
2273 2273
 	 */
2274
-	public function set_author( $value ) {
2275
-		$user = get_user_by( 'id', (int) $value );
2274
+	public function set_author($value) {
2275
+		$user = get_user_by('id', (int) $value);
2276 2276
 
2277
-		if ( $user && $user->ID ) {
2278
-			$this->set_prop( 'author', $user->ID );
2279
-			$this->set_prop( 'email', $user->user_email );
2277
+		if ($user && $user->ID) {
2278
+			$this->set_prop('author', $user->ID);
2279
+			$this->set_prop('email', $user->user_email);
2280 2280
 		}
2281 2281
 
2282 2282
     }
@@ -2287,8 +2287,8 @@  discard block
 block discarded – undo
2287 2287
 	 * @since 1.0.19
2288 2288
 	 * @param  int $value New user id.
2289 2289
 	 */
2290
-	public function set_user_id( $value ) {
2291
-		$this->set_author( $value );
2290
+	public function set_user_id($value) {
2291
+		$this->set_author($value);
2292 2292
     }
2293 2293
 
2294 2294
     /**
@@ -2297,8 +2297,8 @@  discard block
 block discarded – undo
2297 2297
 	 * @since 1.0.19
2298 2298
 	 * @param  int $value New user id.
2299 2299
 	 */
2300
-	public function set_customer_id( $value ) {
2301
-		$this->set_author( $value );
2300
+	public function set_customer_id($value) {
2301
+		$this->set_author($value);
2302 2302
     }
2303 2303
 
2304 2304
     /**
@@ -2307,8 +2307,8 @@  discard block
 block discarded – undo
2307 2307
 	 * @since 1.0.19
2308 2308
 	 * @param  string $value ip address.
2309 2309
 	 */
2310
-	public function set_ip( $value ) {
2311
-		$this->set_prop( 'ip', $value );
2310
+	public function set_ip($value) {
2311
+		$this->set_prop('ip', $value);
2312 2312
     }
2313 2313
 
2314 2314
     /**
@@ -2317,8 +2317,8 @@  discard block
 block discarded – undo
2317 2317
 	 * @since 1.0.19
2318 2318
 	 * @param  string $value ip address.
2319 2319
 	 */
2320
-	public function set_user_ip( $value ) {
2321
-		$this->set_ip( $value );
2320
+	public function set_user_ip($value) {
2321
+		$this->set_ip($value);
2322 2322
     }
2323 2323
 
2324 2324
     /**
@@ -2327,8 +2327,8 @@  discard block
 block discarded – undo
2327 2327
 	 * @since 1.0.19
2328 2328
 	 * @param  string $value first name.
2329 2329
 	 */
2330
-	public function set_first_name( $value ) {
2331
-		$this->set_prop( 'first_name', $value );
2330
+	public function set_first_name($value) {
2331
+		$this->set_prop('first_name', $value);
2332 2332
     }
2333 2333
 
2334 2334
     /**
@@ -2337,8 +2337,8 @@  discard block
 block discarded – undo
2337 2337
 	 * @since 1.0.19
2338 2338
 	 * @param  string $value first name.
2339 2339
 	 */
2340
-	public function set_user_first_name( $value ) {
2341
-		$this->set_first_name( $value );
2340
+	public function set_user_first_name($value) {
2341
+		$this->set_first_name($value);
2342 2342
     }
2343 2343
 
2344 2344
     /**
@@ -2347,8 +2347,8 @@  discard block
 block discarded – undo
2347 2347
 	 * @since 1.0.19
2348 2348
 	 * @param  string $value first name.
2349 2349
 	 */
2350
-	public function set_customer_first_name( $value ) {
2351
-		$this->set_first_name( $value );
2350
+	public function set_customer_first_name($value) {
2351
+		$this->set_first_name($value);
2352 2352
     }
2353 2353
 
2354 2354
     /**
@@ -2357,8 +2357,8 @@  discard block
 block discarded – undo
2357 2357
 	 * @since 1.0.19
2358 2358
 	 * @param  string $value last name.
2359 2359
 	 */
2360
-	public function set_last_name( $value ) {
2361
-		$this->set_prop( 'last_name', $value );
2360
+	public function set_last_name($value) {
2361
+		$this->set_prop('last_name', $value);
2362 2362
     }
2363 2363
 
2364 2364
     /**
@@ -2367,8 +2367,8 @@  discard block
 block discarded – undo
2367 2367
 	 * @since 1.0.19
2368 2368
 	 * @param  string $value last name.
2369 2369
 	 */
2370
-	public function set_user_last_name( $value ) {
2371
-		$this->set_last_name( $value );
2370
+	public function set_user_last_name($value) {
2371
+		$this->set_last_name($value);
2372 2372
     }
2373 2373
 
2374 2374
     /**
@@ -2377,8 +2377,8 @@  discard block
 block discarded – undo
2377 2377
 	 * @since 1.0.19
2378 2378
 	 * @param  string $value last name.
2379 2379
 	 */
2380
-	public function set_customer_last_name( $value ) {
2381
-		$this->set_last_name( $value );
2380
+	public function set_customer_last_name($value) {
2381
+		$this->set_last_name($value);
2382 2382
     }
2383 2383
 
2384 2384
     /**
@@ -2387,8 +2387,8 @@  discard block
 block discarded – undo
2387 2387
 	 * @since 1.0.19
2388 2388
 	 * @param  string $value phone.
2389 2389
 	 */
2390
-	public function set_phone( $value ) {
2391
-		$this->set_prop( 'phone', $value );
2390
+	public function set_phone($value) {
2391
+		$this->set_prop('phone', $value);
2392 2392
     }
2393 2393
 
2394 2394
     /**
@@ -2397,8 +2397,8 @@  discard block
 block discarded – undo
2397 2397
 	 * @since 1.0.19
2398 2398
 	 * @param  string $value phone.
2399 2399
 	 */
2400
-	public function set_user_phone( $value ) {
2401
-		$this->set_phone( $value );
2400
+	public function set_user_phone($value) {
2401
+		$this->set_phone($value);
2402 2402
     }
2403 2403
 
2404 2404
     /**
@@ -2407,8 +2407,8 @@  discard block
 block discarded – undo
2407 2407
 	 * @since 1.0.19
2408 2408
 	 * @param  string $value phone.
2409 2409
 	 */
2410
-	public function set_customer_phone( $value ) {
2411
-		$this->set_phone( $value );
2410
+	public function set_customer_phone($value) {
2411
+		$this->set_phone($value);
2412 2412
     }
2413 2413
 
2414 2414
     /**
@@ -2417,8 +2417,8 @@  discard block
 block discarded – undo
2417 2417
 	 * @since 1.0.19
2418 2418
 	 * @param  string $value phone.
2419 2419
 	 */
2420
-	public function set_phone_number( $value ) {
2421
-		$this->set_phone( $value );
2420
+	public function set_phone_number($value) {
2421
+		$this->set_phone($value);
2422 2422
     }
2423 2423
 
2424 2424
     /**
@@ -2427,8 +2427,8 @@  discard block
 block discarded – undo
2427 2427
 	 * @since 1.0.19
2428 2428
 	 * @param  string $value email address.
2429 2429
 	 */
2430
-	public function set_email( $value ) {
2431
-		$this->set_prop( 'email', $value );
2430
+	public function set_email($value) {
2431
+		$this->set_prop('email', $value);
2432 2432
     }
2433 2433
 
2434 2434
     /**
@@ -2437,8 +2437,8 @@  discard block
 block discarded – undo
2437 2437
 	 * @since 1.0.19
2438 2438
 	 * @param  string $value email address.
2439 2439
 	 */
2440
-	public function set_user_email( $value ) {
2441
-		$this->set_email( $value );
2440
+	public function set_user_email($value) {
2441
+		$this->set_email($value);
2442 2442
     }
2443 2443
 
2444 2444
     /**
@@ -2447,8 +2447,8 @@  discard block
 block discarded – undo
2447 2447
 	 * @since 1.0.19
2448 2448
 	 * @param  string $value email address.
2449 2449
 	 */
2450
-	public function set_email_address( $value ) {
2451
-		$this->set_email( $value );
2450
+	public function set_email_address($value) {
2451
+		$this->set_email($value);
2452 2452
     }
2453 2453
 
2454 2454
     /**
@@ -2457,8 +2457,8 @@  discard block
 block discarded – undo
2457 2457
 	 * @since 1.0.19
2458 2458
 	 * @param  string $value email address.
2459 2459
 	 */
2460
-	public function set_customer_email( $value ) {
2461
-		$this->set_email( $value );
2460
+	public function set_customer_email($value) {
2461
+		$this->set_email($value);
2462 2462
     }
2463 2463
 
2464 2464
     /**
@@ -2467,8 +2467,8 @@  discard block
 block discarded – undo
2467 2467
 	 * @since 1.0.19
2468 2468
 	 * @param  string $value country.
2469 2469
 	 */
2470
-	public function set_country( $value ) {
2471
-		$this->set_prop( 'country', $value );
2470
+	public function set_country($value) {
2471
+		$this->set_prop('country', $value);
2472 2472
     }
2473 2473
 
2474 2474
     /**
@@ -2477,8 +2477,8 @@  discard block
 block discarded – undo
2477 2477
 	 * @since 1.0.19
2478 2478
 	 * @param  string $value country.
2479 2479
 	 */
2480
-	public function set_user_country( $value ) {
2481
-		$this->set_country( $value );
2480
+	public function set_user_country($value) {
2481
+		$this->set_country($value);
2482 2482
     }
2483 2483
 
2484 2484
     /**
@@ -2487,8 +2487,8 @@  discard block
 block discarded – undo
2487 2487
 	 * @since 1.0.19
2488 2488
 	 * @param  string $value country.
2489 2489
 	 */
2490
-	public function set_customer_country( $value ) {
2491
-		$this->set_country( $value );
2490
+	public function set_customer_country($value) {
2491
+		$this->set_country($value);
2492 2492
     }
2493 2493
 
2494 2494
     /**
@@ -2497,8 +2497,8 @@  discard block
 block discarded – undo
2497 2497
 	 * @since 1.0.19
2498 2498
 	 * @param  string $value state.
2499 2499
 	 */
2500
-	public function set_state( $value ) {
2501
-		$this->set_prop( 'state', $value );
2500
+	public function set_state($value) {
2501
+		$this->set_prop('state', $value);
2502 2502
     }
2503 2503
 
2504 2504
     /**
@@ -2507,8 +2507,8 @@  discard block
 block discarded – undo
2507 2507
 	 * @since 1.0.19
2508 2508
 	 * @param  string $value state.
2509 2509
 	 */
2510
-	public function set_user_state( $value ) {
2511
-		$this->set_state( $value );
2510
+	public function set_user_state($value) {
2511
+		$this->set_state($value);
2512 2512
     }
2513 2513
 
2514 2514
     /**
@@ -2517,8 +2517,8 @@  discard block
 block discarded – undo
2517 2517
 	 * @since 1.0.19
2518 2518
 	 * @param  string $value state.
2519 2519
 	 */
2520
-	public function set_customer_state( $value ) {
2521
-		$this->set_state( $value );
2520
+	public function set_customer_state($value) {
2521
+		$this->set_state($value);
2522 2522
     }
2523 2523
 
2524 2524
     /**
@@ -2527,8 +2527,8 @@  discard block
 block discarded – undo
2527 2527
 	 * @since 1.0.19
2528 2528
 	 * @param  string $value city.
2529 2529
 	 */
2530
-	public function set_city( $value ) {
2531
-		$this->set_prop( 'city', $value );
2530
+	public function set_city($value) {
2531
+		$this->set_prop('city', $value);
2532 2532
     }
2533 2533
 
2534 2534
     /**
@@ -2537,8 +2537,8 @@  discard block
 block discarded – undo
2537 2537
 	 * @since 1.0.19
2538 2538
 	 * @param  string $value city.
2539 2539
 	 */
2540
-	public function set_user_city( $value ) {
2541
-		$this->set_city( $value );
2540
+	public function set_user_city($value) {
2541
+		$this->set_city($value);
2542 2542
     }
2543 2543
 
2544 2544
     /**
@@ -2547,8 +2547,8 @@  discard block
 block discarded – undo
2547 2547
 	 * @since 1.0.19
2548 2548
 	 * @param  string $value city.
2549 2549
 	 */
2550
-	public function set_customer_city( $value ) {
2551
-		$this->set_city( $value );
2550
+	public function set_customer_city($value) {
2551
+		$this->set_city($value);
2552 2552
     }
2553 2553
 
2554 2554
     /**
@@ -2557,8 +2557,8 @@  discard block
 block discarded – undo
2557 2557
 	 * @since 1.0.19
2558 2558
 	 * @param  string $value zip.
2559 2559
 	 */
2560
-	public function set_zip( $value ) {
2561
-		$this->set_prop( 'zip', $value );
2560
+	public function set_zip($value) {
2561
+		$this->set_prop('zip', $value);
2562 2562
     }
2563 2563
 
2564 2564
     /**
@@ -2567,8 +2567,8 @@  discard block
 block discarded – undo
2567 2567
 	 * @since 1.0.19
2568 2568
 	 * @param  string $value zip.
2569 2569
 	 */
2570
-	public function set_user_zip( $value ) {
2571
-		$this->set_zip( $value );
2570
+	public function set_user_zip($value) {
2571
+		$this->set_zip($value);
2572 2572
     }
2573 2573
 
2574 2574
     /**
@@ -2577,8 +2577,8 @@  discard block
 block discarded – undo
2577 2577
 	 * @since 1.0.19
2578 2578
 	 * @param  string $value zip.
2579 2579
 	 */
2580
-	public function set_customer_zip( $value ) {
2581
-		$this->set_zip( $value );
2580
+	public function set_customer_zip($value) {
2581
+		$this->set_zip($value);
2582 2582
     }
2583 2583
 
2584 2584
     /**
@@ -2587,8 +2587,8 @@  discard block
 block discarded – undo
2587 2587
 	 * @since 1.0.19
2588 2588
 	 * @param  string $value company.
2589 2589
 	 */
2590
-	public function set_company( $value ) {
2591
-		$this->set_prop( 'company', $value );
2590
+	public function set_company($value) {
2591
+		$this->set_prop('company', $value);
2592 2592
     }
2593 2593
 
2594 2594
     /**
@@ -2597,8 +2597,8 @@  discard block
 block discarded – undo
2597 2597
 	 * @since 1.0.19
2598 2598
 	 * @param  string $value company.
2599 2599
 	 */
2600
-	public function set_user_company( $value ) {
2601
-		$this->set_company( $value );
2600
+	public function set_user_company($value) {
2601
+		$this->set_company($value);
2602 2602
     }
2603 2603
 
2604 2604
     /**
@@ -2607,8 +2607,8 @@  discard block
 block discarded – undo
2607 2607
 	 * @since 1.0.19
2608 2608
 	 * @param  string $value company.
2609 2609
 	 */
2610
-	public function set_customer_company( $value ) {
2611
-		$this->set_company( $value );
2610
+	public function set_customer_company($value) {
2611
+		$this->set_company($value);
2612 2612
     }
2613 2613
 
2614 2614
 	/**
@@ -2617,8 +2617,8 @@  discard block
 block discarded – undo
2617 2617
 	 * @since 1.0.19
2618 2618
 	 * @param  string $value company id.
2619 2619
 	 */
2620
-	public function set_company_id( $value ) {
2621
-		$this->set_prop( 'company_id', $value );
2620
+	public function set_company_id($value) {
2621
+		$this->set_prop('company_id', $value);
2622 2622
     }
2623 2623
 
2624 2624
     /**
@@ -2627,8 +2627,8 @@  discard block
 block discarded – undo
2627 2627
 	 * @since 1.0.19
2628 2628
 	 * @param  string $value var number.
2629 2629
 	 */
2630
-	public function set_vat_number( $value ) {
2631
-		$this->set_prop( 'vat_number', $value );
2630
+	public function set_vat_number($value) {
2631
+		$this->set_prop('vat_number', $value);
2632 2632
     }
2633 2633
 
2634 2634
     /**
@@ -2637,8 +2637,8 @@  discard block
 block discarded – undo
2637 2637
 	 * @since 1.0.19
2638 2638
 	 * @param  string $value var number.
2639 2639
 	 */
2640
-	public function set_user_vat_number( $value ) {
2641
-		$this->set_vat_number( $value );
2640
+	public function set_user_vat_number($value) {
2641
+		$this->set_vat_number($value);
2642 2642
     }
2643 2643
 
2644 2644
     /**
@@ -2647,8 +2647,8 @@  discard block
 block discarded – undo
2647 2647
 	 * @since 1.0.19
2648 2648
 	 * @param  string $value var number.
2649 2649
 	 */
2650
-	public function set_customer_vat_number( $value ) {
2651
-		$this->set_vat_number( $value );
2650
+	public function set_customer_vat_number($value) {
2651
+		$this->set_vat_number($value);
2652 2652
     }
2653 2653
 
2654 2654
     /**
@@ -2657,8 +2657,8 @@  discard block
 block discarded – undo
2657 2657
 	 * @since 1.0.19
2658 2658
 	 * @param  string $value var rate.
2659 2659
 	 */
2660
-	public function set_vat_rate( $value ) {
2661
-		$this->set_prop( 'vat_rate', $value );
2660
+	public function set_vat_rate($value) {
2661
+		$this->set_prop('vat_rate', $value);
2662 2662
     }
2663 2663
 
2664 2664
     /**
@@ -2667,8 +2667,8 @@  discard block
 block discarded – undo
2667 2667
 	 * @since 1.0.19
2668 2668
 	 * @param  string $value var number.
2669 2669
 	 */
2670
-	public function set_user_vat_rate( $value ) {
2671
-		$this->set_vat_rate( $value );
2670
+	public function set_user_vat_rate($value) {
2671
+		$this->set_vat_rate($value);
2672 2672
     }
2673 2673
 
2674 2674
     /**
@@ -2677,8 +2677,8 @@  discard block
 block discarded – undo
2677 2677
 	 * @since 1.0.19
2678 2678
 	 * @param  string $value var number.
2679 2679
 	 */
2680
-	public function set_customer_vat_rate( $value ) {
2681
-		$this->set_vat_rate( $value );
2680
+	public function set_customer_vat_rate($value) {
2681
+		$this->set_vat_rate($value);
2682 2682
     }
2683 2683
 
2684 2684
     /**
@@ -2687,8 +2687,8 @@  discard block
 block discarded – undo
2687 2687
 	 * @since 1.0.19
2688 2688
 	 * @param  string $value address.
2689 2689
 	 */
2690
-	public function set_address( $value ) {
2691
-		$this->set_prop( 'address', $value );
2690
+	public function set_address($value) {
2691
+		$this->set_prop('address', $value);
2692 2692
     }
2693 2693
 
2694 2694
     /**
@@ -2697,8 +2697,8 @@  discard block
 block discarded – undo
2697 2697
 	 * @since 1.0.19
2698 2698
 	 * @param  string $value address.
2699 2699
 	 */
2700
-	public function set_user_address( $value ) {
2701
-		$this->set_address( $value );
2700
+	public function set_user_address($value) {
2701
+		$this->set_address($value);
2702 2702
     }
2703 2703
 
2704 2704
     /**
@@ -2707,8 +2707,8 @@  discard block
 block discarded – undo
2707 2707
 	 * @since 1.0.19
2708 2708
 	 * @param  string $value address.
2709 2709
 	 */
2710
-	public function set_customer_address( $value ) {
2711
-		$this->set_address( $value );
2710
+	public function set_customer_address($value) {
2711
+		$this->set_address($value);
2712 2712
     }
2713 2713
 
2714 2714
     /**
@@ -2717,8 +2717,8 @@  discard block
 block discarded – undo
2717 2717
 	 * @since 1.0.19
2718 2718
 	 * @param  int|bool $value confirmed.
2719 2719
 	 */
2720
-	public function set_is_viewed( $value ) {
2721
-		$this->set_prop( 'is_viewed', $value );
2720
+	public function set_is_viewed($value) {
2721
+		$this->set_prop('is_viewed', $value);
2722 2722
 	}
2723 2723
 
2724 2724
 	/**
@@ -2727,8 +2727,8 @@  discard block
 block discarded – undo
2727 2727
 	 * @since 1.0.19
2728 2728
 	 * @param  string $value email recipients.
2729 2729
 	 */
2730
-	public function set_email_cc( $value ) {
2731
-		$this->set_prop( 'email_cc', $value );
2730
+	public function set_email_cc($value) {
2731
+		$this->set_prop('email_cc', $value);
2732 2732
 	}
2733 2733
 
2734 2734
 	/**
@@ -2737,9 +2737,9 @@  discard block
 block discarded – undo
2737 2737
 	 * @since 1.0.19
2738 2738
 	 * @param  string $value template.
2739 2739
 	 */
2740
-	public function set_template( $value ) {
2741
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2742
-			$this->set_prop( 'template', $value );
2740
+	public function set_template($value) {
2741
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2742
+			$this->set_prop('template', $value);
2743 2743
 		}
2744 2744
 	}
2745 2745
 
@@ -2750,8 +2750,8 @@  discard block
 block discarded – undo
2750 2750
 	 * @param  string $value source.
2751 2751
 	 * @deprecated
2752 2752
 	 */
2753
-	public function created_via( $value ) {
2754
-		$this->set_created_via( sanitize_text_field( $value ) );
2753
+	public function created_via($value) {
2754
+		$this->set_created_via(sanitize_text_field($value));
2755 2755
 	}
2756 2756
 
2757 2757
 	/**
@@ -2760,8 +2760,8 @@  discard block
 block discarded – undo
2760 2760
 	 * @since 1.0.19
2761 2761
 	 * @param  string $value source.
2762 2762
 	 */
2763
-	public function set_created_via( $value ) {
2764
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2763
+	public function set_created_via($value) {
2764
+		$this->set_prop('created_via', sanitize_text_field($value));
2765 2765
 	}
2766 2766
 
2767 2767
 	/**
@@ -2770,8 +2770,8 @@  discard block
 block discarded – undo
2770 2770
 	 * @since 1.0.19
2771 2771
 	 * @param  int|bool $value confirmed.
2772 2772
 	 */
2773
-	public function set_address_confirmed( $value ) {
2774
-		$this->set_prop( 'address_confirmed', $value );
2773
+	public function set_address_confirmed($value) {
2774
+		$this->set_prop('address_confirmed', $value);
2775 2775
     }
2776 2776
 
2777 2777
     /**
@@ -2780,8 +2780,8 @@  discard block
 block discarded – undo
2780 2780
 	 * @since 1.0.19
2781 2781
 	 * @param  int|bool $value confirmed.
2782 2782
 	 */
2783
-	public function set_user_address_confirmed( $value ) {
2784
-		$this->set_address_confirmed( $value );
2783
+	public function set_user_address_confirmed($value) {
2784
+		$this->set_address_confirmed($value);
2785 2785
     }
2786 2786
 
2787 2787
     /**
@@ -2790,8 +2790,8 @@  discard block
 block discarded – undo
2790 2790
 	 * @since 1.0.19
2791 2791
 	 * @param  int|bool $value confirmed.
2792 2792
 	 */
2793
-	public function set_customer_address_confirmed( $value ) {
2794
-		$this->set_address_confirmed( $value );
2793
+	public function set_customer_address_confirmed($value) {
2794
+		$this->set_address_confirmed($value);
2795 2795
     }
2796 2796
 
2797 2797
     /**
@@ -2800,8 +2800,8 @@  discard block
 block discarded – undo
2800 2800
 	 * @since 1.0.19
2801 2801
 	 * @param  float $value sub total.
2802 2802
 	 */
2803
-	public function set_subtotal( $value ) {
2804
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2803
+	public function set_subtotal($value) {
2804
+		$this->set_prop('subtotal', max(0, $value));
2805 2805
 	}
2806 2806
 
2807 2807
 	/**
@@ -2810,8 +2810,8 @@  discard block
 block discarded – undo
2810 2810
 	 * @since 1.0.19
2811 2811
 	 * @param  float $value sub total.
2812 2812
 	 */
2813
-	public function set_total( $value ) {
2814
-		$this->set_prop( 'total', max( 0, $value ) );
2813
+	public function set_total($value) {
2814
+		$this->set_prop('total', max(0, $value));
2815 2815
     }
2816 2816
 
2817 2817
     /**
@@ -2820,8 +2820,8 @@  discard block
 block discarded – undo
2820 2820
 	 * @since 1.0.19
2821 2821
 	 * @param  float $value discount total.
2822 2822
 	 */
2823
-	public function set_total_discount( $value ) {
2824
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2823
+	public function set_total_discount($value) {
2824
+		$this->set_prop('total_discount', max(0, $value));
2825 2825
     }
2826 2826
 
2827 2827
     /**
@@ -2830,8 +2830,8 @@  discard block
 block discarded – undo
2830 2830
 	 * @since 1.0.19
2831 2831
 	 * @param  float $value discount total.
2832 2832
 	 */
2833
-	public function set_discount( $value ) {
2834
-		$this->set_total_discount( $value );
2833
+	public function set_discount($value) {
2834
+		$this->set_total_discount($value);
2835 2835
     }
2836 2836
 
2837 2837
     /**
@@ -2840,8 +2840,8 @@  discard block
 block discarded – undo
2840 2840
 	 * @since 1.0.19
2841 2841
 	 * @param  float $value tax total.
2842 2842
 	 */
2843
-	public function set_total_tax( $value ) {
2844
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2843
+	public function set_total_tax($value) {
2844
+		$this->set_prop('total_tax', max(0, $value));
2845 2845
     }
2846 2846
 
2847 2847
     /**
@@ -2850,8 +2850,8 @@  discard block
 block discarded – undo
2850 2850
 	 * @since 1.0.19
2851 2851
 	 * @param  float $value tax total.
2852 2852
 	 */
2853
-	public function set_tax_total( $value ) {
2854
-		$this->set_total_tax( $value );
2853
+	public function set_tax_total($value) {
2854
+		$this->set_total_tax($value);
2855 2855
     }
2856 2856
 
2857 2857
     /**
@@ -2860,8 +2860,8 @@  discard block
 block discarded – undo
2860 2860
 	 * @since 1.0.19
2861 2861
 	 * @param  float $value fees total.
2862 2862
 	 */
2863
-	public function set_total_fees( $value ) {
2864
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2863
+	public function set_total_fees($value) {
2864
+		$this->set_prop('total_fees', max(0, $value));
2865 2865
     }
2866 2866
 
2867 2867
     /**
@@ -2870,8 +2870,8 @@  discard block
 block discarded – undo
2870 2870
 	 * @since 1.0.19
2871 2871
 	 * @param  float $value fees total.
2872 2872
 	 */
2873
-	public function set_fees_total( $value ) {
2874
-		$this->set_total_fees( $value );
2873
+	public function set_fees_total($value) {
2874
+		$this->set_total_fees($value);
2875 2875
     }
2876 2876
 
2877 2877
     /**
@@ -2880,13 +2880,13 @@  discard block
 block discarded – undo
2880 2880
 	 * @since 1.0.19
2881 2881
 	 * @param  array $value fees.
2882 2882
 	 */
2883
-	public function set_fees( $value ) {
2883
+	public function set_fees($value) {
2884 2884
 
2885
-		if ( ! is_array( $value ) ) {
2885
+		if (!is_array($value)) {
2886 2886
 			$value = array();
2887 2887
 		}
2888 2888
 
2889
-		$this->set_prop( 'fees', $value );
2889
+		$this->set_prop('fees', $value);
2890 2890
 
2891 2891
     }
2892 2892
 
@@ -2896,13 +2896,13 @@  discard block
 block discarded – undo
2896 2896
 	 * @since 1.0.19
2897 2897
 	 * @param  array $value taxes.
2898 2898
 	 */
2899
-	public function set_taxes( $value ) {
2899
+	public function set_taxes($value) {
2900 2900
 
2901
-		if ( ! is_array( $value ) ) {
2901
+		if (!is_array($value)) {
2902 2902
 			$value = array();
2903 2903
 		}
2904 2904
 
2905
-		$this->set_prop( 'taxes', $value );
2905
+		$this->set_prop('taxes', $value);
2906 2906
 
2907 2907
     }
2908 2908
 
@@ -2912,13 +2912,13 @@  discard block
 block discarded – undo
2912 2912
 	 * @since 1.0.19
2913 2913
 	 * @param  array $value discounts.
2914 2914
 	 */
2915
-	public function set_discounts( $value ) {
2915
+	public function set_discounts($value) {
2916 2916
 
2917
-		if ( ! is_array( $value ) ) {
2917
+		if (!is_array($value)) {
2918 2918
 			$value = array();
2919 2919
 		}
2920 2920
 
2921
-		$this->set_prop( 'discounts', $value );
2921
+		$this->set_prop('discounts', $value);
2922 2922
     }
2923 2923
 
2924 2924
     /**
@@ -2927,19 +2927,19 @@  discard block
 block discarded – undo
2927 2927
 	 * @since 1.0.19
2928 2928
 	 * @param  GetPaid_Form_Item[] $value items.
2929 2929
 	 */
2930
-	public function set_items( $value ) {
2930
+	public function set_items($value) {
2931 2931
 
2932 2932
         // Remove existing items.
2933
-        $this->set_prop( 'items', array() );
2933
+        $this->set_prop('items', array());
2934 2934
 		$this->recurring_item = null;
2935 2935
 
2936 2936
         // Ensure that we have an array.
2937
-        if ( ! is_array( $value ) ) {
2937
+        if (!is_array($value)) {
2938 2938
             return;
2939 2939
         }
2940 2940
 
2941
-        foreach ( $value as $item ) {
2942
-            $this->add_item( $item );
2941
+        foreach ($value as $item) {
2942
+            $this->add_item($item);
2943 2943
         }
2944 2944
 
2945 2945
     }
@@ -2950,8 +2950,8 @@  discard block
 block discarded – undo
2950 2950
 	 * @since 1.0.19
2951 2951
 	 * @param  int $value payment form.
2952 2952
 	 */
2953
-	public function set_payment_form( $value ) {
2954
-		$this->set_prop( 'payment_form', $value );
2953
+	public function set_payment_form($value) {
2954
+		$this->set_prop('payment_form', $value);
2955 2955
     }
2956 2956
 
2957 2957
     /**
@@ -2960,8 +2960,8 @@  discard block
 block discarded – undo
2960 2960
 	 * @since 1.0.19
2961 2961
 	 * @param  string $value submission id.
2962 2962
 	 */
2963
-	public function set_submission_id( $value ) {
2964
-		$this->set_prop( 'submission_id', $value );
2963
+	public function set_submission_id($value) {
2964
+		$this->set_prop('submission_id', $value);
2965 2965
     }
2966 2966
 
2967 2967
     /**
@@ -2970,8 +2970,8 @@  discard block
 block discarded – undo
2970 2970
 	 * @since 1.0.19
2971 2971
 	 * @param  string $value discount code.
2972 2972
 	 */
2973
-	public function set_discount_code( $value ) {
2974
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
2973
+	public function set_discount_code($value) {
2974
+		$this->set_prop('discount_code', sanitize_text_field($value));
2975 2975
     }
2976 2976
 
2977 2977
     /**
@@ -2980,8 +2980,8 @@  discard block
 block discarded – undo
2980 2980
 	 * @since 1.0.19
2981 2981
 	 * @param  string $value gateway.
2982 2982
 	 */
2983
-	public function set_gateway( $value ) {
2984
-		$this->set_prop( 'gateway', $value );
2983
+	public function set_gateway($value) {
2984
+		$this->set_prop('gateway', $value);
2985 2985
     }
2986 2986
 
2987 2987
     /**
@@ -2990,9 +2990,9 @@  discard block
 block discarded – undo
2990 2990
 	 * @since 1.0.19
2991 2991
 	 * @param  string $value transaction id.
2992 2992
 	 */
2993
-	public function set_transaction_id( $value ) {
2994
-		if ( ! empty( $value ) ) {
2995
-			$this->set_prop( 'transaction_id', $value );
2993
+	public function set_transaction_id($value) {
2994
+		if (!empty($value)) {
2995
+			$this->set_prop('transaction_id', $value);
2996 2996
 		}
2997 2997
     }
2998 2998
 
@@ -3002,8 +3002,8 @@  discard block
 block discarded – undo
3002 3002
 	 * @since 1.0.19
3003 3003
 	 * @param  string $value currency id.
3004 3004
 	 */
3005
-	public function set_currency( $value ) {
3006
-		$this->set_prop( 'currency', $value );
3005
+	public function set_currency($value) {
3006
+		$this->set_prop('currency', $value);
3007 3007
     }
3008 3008
 
3009 3009
 	/**
@@ -3012,8 +3012,8 @@  discard block
 block discarded – undo
3012 3012
 	 * @since 1.0.19
3013 3013
 	 * @param  bool $value value.
3014 3014
 	 */
3015
-	public function set_disable_taxes( $value ) {
3016
-		$this->set_prop( 'disable_taxes', (bool) $value );
3015
+	public function set_disable_taxes($value) {
3016
+		$this->set_prop('disable_taxes', (bool) $value);
3017 3017
 	}
3018 3018
 
3019 3019
     /**
@@ -3022,8 +3022,8 @@  discard block
 block discarded – undo
3022 3022
 	 * @since 1.0.19
3023 3023
 	 * @param  string $value subscription id.
3024 3024
 	 */
3025
-	public function set_subscription_id( $value ) {
3026
-		$this->set_prop( 'subscription_id', $value );
3025
+	public function set_subscription_id($value) {
3026
+		$this->set_prop('subscription_id', $value);
3027 3027
 	}
3028 3028
 	
3029 3029
 	/**
@@ -3032,8 +3032,8 @@  discard block
 block discarded – undo
3032 3032
 	 * @since 1.0.19
3033 3033
 	 * @param  string $value subscription id.
3034 3034
 	 */
3035
-	public function set_remote_subscription_id( $value ) {
3036
-		$this->set_prop( 'remote_subscription_id', $value );
3035
+	public function set_remote_subscription_id($value) {
3036
+		$this->set_prop('remote_subscription_id', $value);
3037 3037
     }
3038 3038
 
3039 3039
     /*
@@ -3050,28 +3050,28 @@  discard block
 block discarded – undo
3050 3050
      */
3051 3051
     public function is_parent() {
3052 3052
         $parent = $this->get_parent_id();
3053
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
3053
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
3054 3054
     }
3055 3055
 
3056 3056
     /**
3057 3057
      * Checks if this is a renewal invoice.
3058 3058
      */
3059 3059
     public function is_renewal() {
3060
-        return $this->is_recurring() && ! $this->is_parent();
3060
+        return $this->is_recurring() && !$this->is_parent();
3061 3061
     }
3062 3062
 
3063 3063
     /**
3064 3064
      * Checks if this is a recurring invoice.
3065 3065
      */
3066 3066
     public function is_recurring() {
3067
-        return ! empty( $this->recurring_item );
3067
+        return !empty($this->recurring_item);
3068 3068
     }
3069 3069
 
3070 3070
     /**
3071 3071
      * Checks if this is a taxable invoice.
3072 3072
      */
3073 3073
     public function is_taxable() {
3074
-        return ! $this->get_disable_taxes();
3074
+        return !$this->get_disable_taxes();
3075 3075
 	}
3076 3076
 
3077 3077
 	/**
@@ -3085,45 +3085,45 @@  discard block
 block discarded – undo
3085 3085
 	 * Checks to see if the invoice requires payment.
3086 3086
 	 */
3087 3087
 	public function is_free() {
3088
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3088
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
3089 3089
 
3090
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3090
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
3091 3091
 			$is_free = false;
3092 3092
 		}
3093 3093
 
3094
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3094
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
3095 3095
     }
3096 3096
 
3097 3097
     /**
3098 3098
      * Checks if the invoice is paid.
3099 3099
      */
3100 3100
     public function is_paid() {
3101
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3102
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3101
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
3102
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
3103 3103
 	}
3104 3104
 
3105 3105
 	/**
3106 3106
      * Checks if the invoice needs payment.
3107 3107
      */
3108 3108
 	public function needs_payment() {
3109
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3110
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3109
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
3110
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
3111 3111
     }
3112 3112
   
3113 3113
 	/**
3114 3114
      * Checks if the invoice is refunded.
3115 3115
      */
3116 3116
 	public function is_refunded() {
3117
-        $is_refunded = $this->has_status( 'wpi-refunded' );
3118
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3117
+        $is_refunded = $this->has_status('wpi-refunded');
3118
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
3119 3119
 	}
3120 3120
 
3121 3121
 	/**
3122 3122
      * Checks if the invoice is held.
3123 3123
      */
3124 3124
 	public function is_held() {
3125
-        $is_held = $this->has_status( 'wpi-onhold' );
3126
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3125
+        $is_held = $this->has_status('wpi-onhold');
3126
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3127 3127
 	}
3128 3128
 
3129 3129
 	/**
@@ -3131,30 +3131,30 @@  discard block
 block discarded – undo
3131 3131
      */
3132 3132
 	public function is_due() {
3133 3133
 		$due_date = $this->get_due_date();
3134
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3134
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3135 3135
 	}
3136 3136
 
3137 3137
 	/**
3138 3138
      * Checks if the invoice is draft.
3139 3139
      */
3140 3140
 	public function is_draft() {
3141
-        return $this->has_status( 'draft, auto-draft' );
3141
+        return $this->has_status('draft, auto-draft');
3142 3142
 	}
3143 3143
 
3144 3144
     /**
3145 3145
      * Checks if the invoice has a given status.
3146 3146
      */
3147
-    public function has_status( $status ) {
3148
-        $status = wpinv_parse_list( $status );
3149
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3147
+    public function has_status($status) {
3148
+        $status = wpinv_parse_list($status);
3149
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3150 3150
 	}
3151 3151
 
3152 3152
 	/**
3153 3153
      * Checks if the invoice is of a given type.
3154 3154
      */
3155
-    public function is_type( $type ) {
3156
-        $type = wpinv_parse_list( $type );
3157
-        return in_array( $this->get_type(), $type );
3155
+    public function is_type($type) {
3156
+        $type = wpinv_parse_list($type);
3157
+        return in_array($this->get_type(), $type);
3158 3158
     }
3159 3159
 
3160 3160
     /**
@@ -3186,8 +3186,8 @@  discard block
 block discarded – undo
3186 3186
      *
3187 3187
      */
3188 3188
 	public function is_initial_free() {
3189
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3190
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3189
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3190
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3191 3191
     }
3192 3192
 	
3193 3193
 	/**
@@ -3197,11 +3197,11 @@  discard block
 block discarded – undo
3197 3197
     public function item_has_free_trial() {
3198 3198
 
3199 3199
         // Ensure we have a recurring item.
3200
-        if ( ! $this->is_recurring() ) {
3200
+        if (!$this->is_recurring()) {
3201 3201
             return false;
3202 3202
         }
3203 3203
 
3204
-        $item = $this->get_recurring( true );
3204
+        $item = $this->get_recurring(true);
3205 3205
         return $item->has_free_trial();
3206 3206
 	}
3207 3207
 
@@ -3209,7 +3209,7 @@  discard block
 block discarded – undo
3209 3209
      * Check if the free trial is a result of a discount.
3210 3210
      */
3211 3211
     public function is_free_trial_from_discount() {
3212
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3212
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3213 3213
 	}
3214 3214
 	
3215 3215
 	/**
@@ -3217,12 +3217,12 @@  discard block
 block discarded – undo
3217 3217
      */
3218 3218
     public function discount_first_payment_only() {
3219 3219
 
3220
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3221
-        if ( ! $discount->exists() || ! $this->is_recurring() ) {
3220
+		$discount = wpinv_get_discount_obj($this->get_discount_code());
3221
+        if (!$discount->exists() || !$this->is_recurring()) {
3222 3222
             return true;
3223 3223
         }
3224 3224
 
3225
-        return ! $discount->get_is_recurring();
3225
+        return !$discount->get_is_recurring();
3226 3226
     }
3227 3227
 
3228 3228
     /*
@@ -3240,23 +3240,23 @@  discard block
 block discarded – undo
3240 3240
      * @param GetPaid_Form_Item|array $item
3241 3241
      * @return WP_Error|Bool
3242 3242
      */
3243
-    public function add_item( $item ) {
3243
+    public function add_item($item) {
3244 3244
 
3245
-		if ( is_array( $item ) ) {
3246
-			$item = $this->process_array_item( $item );
3245
+		if (is_array($item)) {
3246
+			$item = $this->process_array_item($item);
3247 3247
 		}
3248 3248
 
3249
-		if ( is_numeric( $item ) ) {
3250
-			$item = new GetPaid_Form_Item( $item );
3249
+		if (is_numeric($item)) {
3250
+			$item = new GetPaid_Form_Item($item);
3251 3251
 		}
3252 3252
 
3253 3253
         // Make sure that it is available for purchase.
3254
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3255
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3254
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3255
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3256 3256
         }
3257 3257
 
3258 3258
         // Do we have a recurring item?
3259
-		if ( $item->is_recurring() ) {
3259
+		if ($item->is_recurring()) {
3260 3260
 			$this->recurring_item = $item->get_id();
3261 3261
         }
3262 3262
 
@@ -3264,9 +3264,9 @@  discard block
 block discarded – undo
3264 3264
         $item->invoice_id = (int) $this->get_id();
3265 3265
 
3266 3266
 		// Remove duplicates.
3267
-		$this->remove_item( $item->get_id() );
3267
+		$this->remove_item($item->get_id());
3268 3268
 
3269
-		if ( 0 == $item->get_quantity() ) {
3269
+		if (0 == $item->get_quantity()) {
3270 3270
 			return;
3271 3271
 		}
3272 3272
 
@@ -3276,7 +3276,7 @@  discard block
 block discarded – undo
3276 3276
 		// Add new item.
3277 3277
         $items[] = $item;
3278 3278
 
3279
-        $this->set_prop( 'items', $items );
3279
+        $this->set_prop('items', $items);
3280 3280
 
3281 3281
 		return true;
3282 3282
 	}
@@ -3287,26 +3287,26 @@  discard block
 block discarded – undo
3287 3287
 	 * @since 1.0.19
3288 3288
 	 * @return GetPaid_Form_Item
3289 3289
 	 */
3290
-	protected function process_array_item( $array ) {
3290
+	protected function process_array_item($array) {
3291 3291
 
3292
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3293
-		$item    = new GetPaid_Form_Item( $item_id );
3292
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3293
+		$item    = new GetPaid_Form_Item($item_id);
3294 3294
 
3295 3295
 		// Set item data.
3296
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3297
-			if ( isset( $array[ "item_$key" ] ) ) {
3296
+		foreach (array('name', 'price', 'description') as $key) {
3297
+			if (isset($array["item_$key"])) {
3298 3298
 				$method = "set_$key";
3299
-				$item->$method( $array[ "item_$key" ] );
3299
+				$item->$method($array["item_$key"]);
3300 3300
 			}
3301 3301
 		}
3302 3302
 
3303
-		if ( isset( $array['quantity'] ) ) {
3304
-			$item->set_quantity( $array['quantity'] );
3303
+		if (isset($array['quantity'])) {
3304
+			$item->set_quantity($array['quantity']);
3305 3305
 		}
3306 3306
 
3307 3307
 		// Set item meta.
3308
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3309
-			$item->set_item_meta( $array['meta'] );
3308
+		if (isset($array['meta']) && is_array($array['meta'])) {
3309
+			$item->set_item_meta($array['meta']);
3310 3310
 		}
3311 3311
 
3312 3312
 		return $item;
@@ -3319,10 +3319,10 @@  discard block
 block discarded – undo
3319 3319
 	 * @since 1.0.19
3320 3320
 	 * @return GetPaid_Form_Item|null
3321 3321
 	 */
3322
-	public function get_item( $item_id ) {
3322
+	public function get_item($item_id) {
3323 3323
 
3324
-		foreach ( $this->get_items() as $item ) {
3325
-			if ( (int) $item_id == $item->get_id() ) {
3324
+		foreach ($this->get_items() as $item) {
3325
+			if ((int) $item_id == $item->get_id()) {
3326 3326
 				return $item;
3327 3327
 			}
3328 3328
 		}
@@ -3335,16 +3335,16 @@  discard block
 block discarded – undo
3335 3335
 	 *
3336 3336
 	 * @since 1.0.19
3337 3337
 	 */
3338
-	public function remove_item( $item_id ) {
3338
+	public function remove_item($item_id) {
3339 3339
 		$items   = $this->get_items();
3340 3340
 		$item_id = (int) $item_id;
3341 3341
 
3342
-		foreach ( $items as $index => $item ) {
3343
-			if ( (int) $item_id == $item->get_id() ) {
3344
-				unset( $items[ $index ] );
3345
-				$this->set_prop( 'items', $items );
3342
+		foreach ($items as $index => $item) {
3343
+			if ((int) $item_id == $item->get_id()) {
3344
+				unset($items[$index]);
3345
+				$this->set_prop('items', $items);
3346 3346
 
3347
-				if ( $item_id == $this->recurring_item ) {
3347
+				if ($item_id == $this->recurring_item) {
3348 3348
 					$this->recurring_item = null;
3349 3349
 				}
3350 3350
 
@@ -3359,11 +3359,11 @@  discard block
 block discarded – undo
3359 3359
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3360 3360
 	 * @since 1.0.19
3361 3361
 	 */
3362
-    public function add_fee( $fee ) {
3362
+    public function add_fee($fee) {
3363 3363
 
3364 3364
 		$fees                 = $this->get_fees();
3365
-		$fees[ $fee['name'] ] = $fee;
3366
-		$this->set_prop( 'fees', $fees );
3365
+		$fees[$fee['name']] = $fee;
3366
+		$this->set_prop('fees', $fees);
3367 3367
 
3368 3368
     }
3369 3369
 
@@ -3372,9 +3372,9 @@  discard block
 block discarded – undo
3372 3372
 	 *
3373 3373
 	 * @since 1.0.19
3374 3374
 	 */
3375
-	public function get_fee( $fee ) {
3375
+	public function get_fee($fee) {
3376 3376
         $fees = $this->get_fees();
3377
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3377
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3378 3378
     }
3379 3379
 
3380 3380
     /**
@@ -3382,11 +3382,11 @@  discard block
 block discarded – undo
3382 3382
 	 *
3383 3383
 	 * @since 1.0.19
3384 3384
 	 */
3385
-	public function remove_fee( $fee ) {
3385
+	public function remove_fee($fee) {
3386 3386
         $fees = $this->get_fees();
3387
-        if ( isset( $fees[ $fee ] ) ) {
3388
-            unset( $fees[ $fee ] );
3389
-            $this->set_prop( 'fees', $fees );
3387
+        if (isset($fees[$fee])) {
3388
+            unset($fees[$fee]);
3389
+            $this->set_prop('fees', $fees);
3390 3390
         }
3391 3391
     }
3392 3392
 
@@ -3396,11 +3396,11 @@  discard block
 block discarded – undo
3396 3396
 	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3397 3397
 	 * @since 1.0.19
3398 3398
 	 */
3399
-	public function add_discount( $discount ) {
3399
+	public function add_discount($discount) {
3400 3400
 
3401 3401
 		$discounts = $this->get_discounts();
3402
-		$discounts[ $discount['name'] ] = $discount;
3403
-		$this->set_prop( 'discounts', $discounts );
3402
+		$discounts[$discount['name']] = $discount;
3403
+		$this->set_prop('discounts', $discounts);
3404 3404
 
3405 3405
 	}
3406 3406
 
@@ -3410,15 +3410,15 @@  discard block
 block discarded – undo
3410 3410
 	 * @since 1.0.19
3411 3411
 	 * @return float
3412 3412
 	 */
3413
-	public function get_discount( $discount = false ) {
3413
+	public function get_discount($discount = false) {
3414 3414
 
3415 3415
 		// Backwards compatibilty.
3416
-		if ( empty( $discount ) ) {
3416
+		if (empty($discount)) {
3417 3417
 			return $this->get_total_discount();
3418 3418
 		}
3419 3419
 
3420 3420
         $discounts = $this->get_discounts();
3421
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3421
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3422 3422
     }
3423 3423
 
3424 3424
     /**
@@ -3426,15 +3426,15 @@  discard block
 block discarded – undo
3426 3426
 	 *
3427 3427
 	 * @since 1.0.19
3428 3428
 	 */
3429
-	public function remove_discount( $discount ) {
3429
+	public function remove_discount($discount) {
3430 3430
         $discounts = $this->get_discounts();
3431
-        if ( isset( $discounts[ $discount ] ) ) {
3432
-            unset( $discounts[ $discount ] );
3433
-            $this->set_prop( 'discounts', $discounts );
3431
+        if (isset($discounts[$discount])) {
3432
+            unset($discounts[$discount]);
3433
+            $this->set_prop('discounts', $discounts);
3434 3434
         }
3435 3435
 
3436
-		if ( 'discount_code' == $discount ) {
3437
-			foreach ( $this->get_items() as $item ) {
3436
+		if ('discount_code' == $discount) {
3437
+			foreach ($this->get_items() as $item) {
3438 3438
 				$item->item_discount           = 0;
3439 3439
 				$item->recurring_item_discount = 0;
3440 3440
 			}
@@ -3447,12 +3447,12 @@  discard block
 block discarded – undo
3447 3447
      *
3448 3448
      * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
3449 3449
      */
3450
-    public function add_tax( $tax ) {
3451
-        if ( $this->is_taxable() ) {
3450
+    public function add_tax($tax) {
3451
+        if ($this->is_taxable()) {
3452 3452
 
3453
-            $taxes                 = $this->get_taxes();
3454
-			$taxes[ $tax['name'] ] = $tax;
3455
-			$this->set_prop( 'taxes', $tax );
3453
+            $taxes = $this->get_taxes();
3454
+			$taxes[$tax['name']] = $tax;
3455
+			$this->set_prop('taxes', $tax);
3456 3456
 
3457 3457
         }
3458 3458
     }
@@ -3462,15 +3462,15 @@  discard block
 block discarded – undo
3462 3462
 	 *
3463 3463
 	 * @since 1.0.19
3464 3464
 	 */
3465
-	public function get_tax( $tax = null ) {
3465
+	public function get_tax($tax = null) {
3466 3466
 
3467 3467
 		// Backwards compatility.
3468
-		if ( empty( $tax ) ) {
3468
+		if (empty($tax)) {
3469 3469
 			return $this->get_total_tax();
3470 3470
 		}
3471 3471
 
3472 3472
         $taxes = $this->get_taxes();
3473
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3473
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3474 3474
     }
3475 3475
 
3476 3476
     /**
@@ -3478,11 +3478,11 @@  discard block
 block discarded – undo
3478 3478
 	 *
3479 3479
 	 * @since 1.0.19
3480 3480
 	 */
3481
-	public function remove_tax( $tax ) {
3481
+	public function remove_tax($tax) {
3482 3482
         $taxes = $this->get_taxes();
3483
-        if ( isset( $taxes[ $tax ] ) ) {
3484
-            unset( $taxes[ $tax ] );
3485
-            $this->set_prop( 'taxes', $taxes );
3483
+        if (isset($taxes[$tax])) {
3484
+            unset($taxes[$tax]);
3485
+            $this->set_prop('taxes', $taxes);
3486 3486
         }
3487 3487
     }
3488 3488
 
@@ -3493,22 +3493,22 @@  discard block
 block discarded – undo
3493 3493
 	 * @return float The recalculated subtotal
3494 3494
 	 */
3495 3495
 	public function recalculate_subtotal() {
3496
-        $items     = $this->get_items();
3496
+        $items = $this->get_items();
3497 3497
 		$subtotal  = 0;
3498 3498
 		$recurring = 0;
3499 3499
 
3500
-        foreach ( $items as $item ) {
3501
-			$subtotal  += $item->get_sub_total( 'edit' );
3502
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3500
+        foreach ($items as $item) {
3501
+			$subtotal  += $item->get_sub_total('edit');
3502
+			$recurring += $item->get_recurring_sub_total('edit');
3503 3503
         }
3504 3504
 
3505
-		if ( wpinv_prices_include_tax() ) {
3506
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3507
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3505
+		if (wpinv_prices_include_tax()) {
3506
+			$subtotal  = max(0, $subtotal - $this->totals['tax']['initial']);
3507
+			$recurring = max(0, $recurring - $this->totals['tax']['recurring']);
3508 3508
 		}
3509 3509
 
3510 3510
 		$current = $this->is_renewal() ? $recurring : $subtotal;
3511
-		$this->set_subtotal( $current );
3511
+		$this->set_subtotal($current);
3512 3512
 
3513 3513
 		$this->totals['subtotal'] = array(
3514 3514
 			'initial'   => $subtotal,
@@ -3529,14 +3529,14 @@  discard block
 block discarded – undo
3529 3529
 		$discount  = 0;
3530 3530
 		$recurring = 0;
3531 3531
 
3532
-        foreach ( $discounts as $data ) {
3533
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3534
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3532
+        foreach ($discounts as $data) {
3533
+			$discount  += wpinv_sanitize_amount($data['initial_discount']);
3534
+			$recurring += wpinv_sanitize_amount($data['recurring_discount']);
3535 3535
 		}
3536 3536
 
3537 3537
 		$current = $this->is_renewal() ? $recurring : $discount;
3538 3538
 
3539
-		$this->set_total_discount( $current );
3539
+		$this->set_total_discount($current);
3540 3540
 
3541 3541
 		$this->totals['discount'] = array(
3542 3542
 			'initial'   => $discount,
@@ -3557,13 +3557,13 @@  discard block
 block discarded – undo
3557 3557
 
3558 3558
 		// Maybe disable taxes.
3559 3559
 		$vat_number = $this->get_vat_number();
3560
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3560
+		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number);
3561 3561
 
3562
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3562
+		if (wpinv_is_base_country($this->get_country()) && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) {
3563 3563
 			$skip_tax = false;
3564 3564
 		}
3565 3565
 
3566
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3566
+		if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) {
3567 3567
 
3568 3568
 			$this->totals['tax'] = array(
3569 3569
 				'initial'   => 0,
@@ -3572,38 +3572,38 @@  discard block
 block discarded – undo
3572 3572
 
3573 3573
 			$this->tax_rate = 0;
3574 3574
 
3575
-			$this->set_taxes( array() );
3575
+			$this->set_taxes(array());
3576 3576
 			$current = 0;
3577 3577
 		} else {
3578 3578
 
3579 3579
 			$item_taxes = array();
3580 3580
 
3581
-			foreach ( $this->get_items() as $item ) {
3582
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3583
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3584
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3585
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3586
-				foreach ( $taxes as $name => $amount ) {
3587
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3588
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3589
-
3590
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3591
-						$item_taxes[ $name ] = $tax;
3581
+			foreach ($this->get_items() as $item) {
3582
+				$rates    = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state());
3583
+				$rates    = getpaid_filter_item_tax_rates($item, $rates);
3584
+				$taxes    = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates);
3585
+				$r_taxes  = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates);
3586
+				foreach ($taxes as $name => $amount) {
3587
+					$recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0;
3588
+					$tax       = getpaid_prepare_item_tax($item, $name, $amount, $recurring);
3589
+
3590
+					if (!isset($item_taxes[$name])) {
3591
+						$item_taxes[$name] = $tax;
3592 3592
 						continue;
3593 3593
 					}
3594 3594
 
3595
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3596
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3595
+					$item_taxes[$name]['initial_tax']   += $tax['initial_tax'];
3596
+					$item_taxes[$name]['recurring_tax'] += $tax['recurring_tax'];
3597 3597
 
3598 3598
 				}
3599 3599
 
3600 3600
 			}
3601 3601
 
3602
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3603
-			$this->set_taxes( $item_taxes );
3602
+			$item_taxes = array_replace($this->get_taxes(), $item_taxes);
3603
+			$this->set_taxes($item_taxes);
3604 3604
 
3605
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3606
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3605
+			$initial_tax   = array_sum(wp_list_pluck($item_taxes, 'initial_tax'));
3606
+			$recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax'));
3607 3607
 
3608 3608
 			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3609 3609
 
@@ -3614,7 +3614,7 @@  discard block
 block discarded – undo
3614 3614
 
3615 3615
 		}
3616 3616
 
3617
-		$this->set_total_tax( $current );
3617
+		$this->set_total_tax($current);
3618 3618
 
3619 3619
 		return $current;
3620 3620
 
@@ -3631,20 +3631,20 @@  discard block
 block discarded – undo
3631 3631
 		$fee       = 0;
3632 3632
 		$recurring = 0;
3633 3633
 
3634
-        foreach ( $fees as $data ) {
3635
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3636
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3634
+        foreach ($fees as $data) {
3635
+			$fee       += wpinv_sanitize_amount($data['initial_fee']);
3636
+			$recurring += wpinv_sanitize_amount($data['recurring_fee']);
3637 3637
 		}
3638 3638
 
3639 3639
 		$current = $this->is_renewal() ? $recurring : $fee;
3640
-		$this->set_total_fees( $current );
3640
+		$this->set_total_fees($current);
3641 3641
 
3642 3642
 		$this->totals['fee'] = array(
3643 3643
 			'initial'   => $fee,
3644 3644
 			'recurring' => $recurring,
3645 3645
 		);
3646 3646
 
3647
-        $this->set_total_fees( $fee );
3647
+        $this->set_total_fees($fee);
3648 3648
         return $current;
3649 3649
     }
3650 3650
 
@@ -3659,7 +3659,7 @@  discard block
 block discarded – undo
3659 3659
         $this->recalculate_total_discount();
3660 3660
 		$this->recalculate_total_tax();
3661 3661
 		$this->recalculate_subtotal();
3662
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3662
+		$this->set_total($this->get_total_tax('edit') + $this->get_total_fees('edit') + $this->get_subtotal('edit') - $this->get_total_discount('edit'));
3663 3663
 		return $this->get_total();
3664 3664
 	}
3665 3665
 
@@ -3668,7 +3668,7 @@  discard block
 block discarded – undo
3668 3668
 	 */
3669 3669
     public function recalculate_totals() {
3670 3670
         $this->recalculate_total();
3671
-        $this->save( true );
3671
+        $this->save(true);
3672 3672
         return $this;
3673 3673
     }
3674 3674
 
@@ -3686,8 +3686,8 @@  discard block
 block discarded – undo
3686 3686
 	 * @return int|false The new note's ID on success, false on failure.
3687 3687
      *
3688 3688
      */
3689
-    public function add_system_note( $note ) {
3690
-		return $this->add_note( $note, false, false, true );
3689
+    public function add_system_note($note) {
3690
+		return $this->add_note($note, false, false, true);
3691 3691
 	}
3692 3692
 
3693 3693
     /**
@@ -3697,10 +3697,10 @@  discard block
 block discarded – undo
3697 3697
 	 * @return int|false The new note's ID on success, false on failure.
3698 3698
      *
3699 3699
      */
3700
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3700
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3701 3701
 
3702 3702
         // Bail if no note specified or this invoice is not yet saved.
3703
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3703
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3704 3704
             return false;
3705 3705
         }
3706 3706
 
@@ -3708,23 +3708,23 @@  discard block
 block discarded – undo
3708 3708
 		$author_email = '[email protected]';
3709 3709
 
3710 3710
 		// If this is an admin comment or it has been added by the user.
3711
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3712
-			$user         = get_user_by( 'id', get_current_user_id() );
3711
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3712
+			$user = get_user_by('id', get_current_user_id());
3713 3713
             $author       = $user->display_name;
3714 3714
             $author_email = $user->user_email;
3715 3715
 		}
3716 3716
 
3717
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3717
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3718 3718
 
3719 3719
 	}
3720 3720
 
3721 3721
 	/**
3722 3722
      * Generates a unique key for the invoice.
3723 3723
      */
3724
-    public function generate_key( $string = '' ) {
3725
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3724
+    public function generate_key($string = '') {
3725
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3726 3726
         return strtolower(
3727
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3727
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3728 3728
         );
3729 3729
     }
3730 3730
 
@@ -3734,11 +3734,11 @@  discard block
 block discarded – undo
3734 3734
     public function generate_number() {
3735 3735
         $number = $this->get_id();
3736 3736
 
3737
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3738
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3737
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3738
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3739 3739
         }
3740 3740
 
3741
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3741
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3742 3742
 
3743 3743
 	}
3744 3744
 
@@ -3751,55 +3751,55 @@  discard block
 block discarded – undo
3751 3751
 		// Reset status transition variable.
3752 3752
 		$this->status_transition = false;
3753 3753
 
3754
-		if ( $status_transition ) {
3754
+		if ($status_transition) {
3755 3755
 			try {
3756 3756
 
3757 3757
 				// Fire a hook for the status change.
3758
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3758
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3759 3759
 
3760 3760
 				// @deprecated this is deprecated and will be removed in the future.
3761
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3761
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3762 3762
 
3763
-				if ( ! empty( $status_transition['from'] ) ) {
3763
+				if (!empty($status_transition['from'])) {
3764 3764
 
3765 3765
 					/* translators: 1: old invoice status 2: new invoice status */
3766
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3766
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this));
3767 3767
 
3768 3768
 					// Fire another hook.
3769
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3770
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3769
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3770
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3771 3771
 
3772 3772
 					// @deprecated this is deprecated and will be removed in the future.
3773
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3773
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3774 3774
 
3775 3775
 					// Note the transition occurred.
3776
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3776
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']);
3777 3777
 
3778 3778
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3779 3779
 					if (
3780
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3781
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3780
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3781
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3782 3782
 					) {
3783
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3783
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3784 3784
 					}
3785 3785
 
3786 3786
 					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3787 3787
 					if (
3788
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3789
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3788
+						in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3789
+						&& in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3790 3790
 					) {
3791
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3791
+						do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition);
3792 3792
 					}
3793 3793
 				} else {
3794 3794
 					/* translators: %s: new invoice status */
3795
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3795
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this));
3796 3796
 
3797 3797
 					// Note the transition occurred.
3798
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3798
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3799 3799
 
3800 3800
 				}
3801
-			} catch ( Exception $e ) {
3802
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3801
+			} catch (Exception $e) {
3802
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3803 3803
 			}
3804 3804
 		}
3805 3805
 	}
@@ -3807,13 +3807,13 @@  discard block
 block discarded – undo
3807 3807
 	/**
3808 3808
 	 * Updates an invoice status.
3809 3809
 	 */
3810
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3810
+	public function update_status($new_status = false, $note = '', $manual = false) {
3811 3811
 
3812 3812
 		// Fires before updating a status.
3813
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3813
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3814 3814
 
3815 3815
 		// Update the status.
3816
-		$this->set_status( $new_status, $note, $manual );
3816
+		$this->set_status($new_status, $note, $manual);
3817 3817
 
3818 3818
 		// Save the order.
3819 3819
 		return $this->save();
@@ -3824,18 +3824,18 @@  discard block
 block discarded – undo
3824 3824
 	 * @deprecated
3825 3825
 	 */
3826 3826
 	public function refresh_item_ids() {
3827
-        $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3828
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3827
+        $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id')));
3828
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3829 3829
 	}
3830 3830
 
3831 3831
 	/**
3832 3832
 	 * @deprecated
3833 3833
 	 */
3834
-	public function update_items( $temp = false ) {
3834
+	public function update_items($temp = false) {
3835 3835
 
3836
-		$this->set_items( $this->get_items() );
3836
+		$this->set_items($this->get_items());
3837 3837
 
3838
-		if ( ! $temp ) {
3838
+		if (!$temp) {
3839 3839
 			$this->save();
3840 3840
 		}
3841 3841
 
@@ -3849,11 +3849,11 @@  discard block
 block discarded – undo
3849 3849
 
3850 3850
         $discount_code = $this->get_discount_code();
3851 3851
 
3852
-        if ( empty( $discount_code ) ) {
3852
+        if (empty($discount_code)) {
3853 3853
             return false;
3854 3854
         }
3855 3855
 
3856
-        $discount = wpinv_get_discount_obj( $discount_code );
3856
+        $discount = wpinv_get_discount_obj($discount_code);
3857 3857
 
3858 3858
         // Ensure it is active.
3859 3859
         return $discount->exists();
@@ -3864,7 +3864,7 @@  discard block
 block discarded – undo
3864 3864
 	 * Refunds an invoice.
3865 3865
 	 */
3866 3866
     public function refund() {
3867
-		$this->set_status( 'wpi-refunded' );
3867
+		$this->set_status('wpi-refunded');
3868 3868
         $this->save();
3869 3869
 	}
3870 3870
 
@@ -3873,53 +3873,53 @@  discard block
 block discarded – undo
3873 3873
 	 * 
3874 3874
 	 * @param string $transaction_id
3875 3875
 	 */
3876
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3876
+    public function mark_paid($transaction_id = null, $note = '') {
3877 3877
 
3878 3878
 		// Set the transaction id.
3879
-		if ( empty( $transaction_id ) ) {
3879
+		if (empty($transaction_id)) {
3880 3880
 			$transaction_id = $this->generate_key('trans_');
3881 3881
 		}
3882 3882
 
3883
-		if ( ! $this->get_transaction_id() ) {
3884
-			$this->set_transaction_id( $transaction_id );
3883
+		if (!$this->get_transaction_id()) {
3884
+			$this->set_transaction_id($transaction_id);
3885 3885
 		}
3886 3886
 
3887
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3887
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3888 3888
 			return $this->save();
3889 3889
 		}
3890 3890
 
3891 3891
 		// Set the completed date.
3892
-		$this->set_date_completed( current_time( 'mysql' ) );
3892
+		$this->set_date_completed(current_time('mysql'));
3893 3893
 
3894 3894
 		// Set the new status.
3895
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3896
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
3895
+		$gateway = sanitize_text_field($this->get_gateway_title());
3896
+		if ($this->is_renewal() || !$this->is_parent()) {
3897 3897
 
3898
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3899
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3898
+			$_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway);
3899
+			$_note = $_note . empty($note) ? '' : " ($note)";
3900 3900
 
3901
-			if ( 'none' == $this->get_gateway() ) {
3901
+			if ('none' == $this->get_gateway()) {
3902 3902
 				$_note = $note;
3903 3903
 			}
3904 3904
 
3905
-			$this->set_status( 'wpi-renewal', $_note );
3905
+			$this->set_status('wpi-renewal', $_note);
3906 3906
 
3907 3907
 		} else {
3908 3908
 
3909
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3910
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3909
+			$_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway);
3910
+			$_note = $_note . empty($note) ? '' : " ($note)";
3911 3911
 
3912
-			if ( 'none' == $this->get_gateway() ) {
3912
+			if ('none' == $this->get_gateway()) {
3913 3913
 				$_note = $note;
3914 3914
 			}
3915 3915
 
3916
-			$this->set_status( 'publish', $_note );
3916
+			$this->set_status('publish', $_note);
3917 3917
 
3918 3918
 		}
3919 3919
 
3920 3920
 		// Set checkout mode.
3921
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3922
-		$this->set_mode( $mode );
3921
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3922
+		$this->set_mode($mode);
3923 3923
 
3924 3924
 		// Save the invoice.
3925 3925
         $this->save();
@@ -3944,9 +3944,9 @@  discard block
 block discarded – undo
3944 3944
      * Clears the subscription's cache.
3945 3945
      */
3946 3946
     public function clear_cache() {
3947
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3948
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3949
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3947
+		wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
3948
+		wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
3949
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
3950 3950
 	}
3951 3951
 
3952 3952
 }
Please login to merge, or discard this patch.