Passed
Push — master ( 63ad62...113528 )
by Brian
05:30
created
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_head', array( $this, 'set_admin_menu_class' ) );
17
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
18
-        add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 );
19
-        add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 );
20
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 );
21
-        add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 );
22
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
23
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_head', array($this, 'set_admin_menu_class'));
17
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
18
+        add_action('admin_menu', array($this, 'add_customers_menu'), 18);
19
+        add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40);
20
+        add_action('admin_menu', array($this, 'add_addons_menu'), 100);
21
+        add_action('admin_menu', array($this, 'add_settings_menu'), 60);
22
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
23
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
24 24
     }
25 25
 
26 26
     /**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	public function set_admin_menu_class() {
30 30
 		global $current_screen, $parent_file, $submenu_file;
31 31
 
32
-        if ( ! empty( $current_screen->id ) && in_array( $current_screen->id , array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) {
32
+        if (!empty($current_screen->id) && in_array($current_screen->id, array('wpi_discount', 'wpi_payment_form', 'wpi_invoice'))) {
33 33
 			$parent_file = 'wpinv';
34 34
 			$submenu_file = 'edit.php?post_type=' . $current_screen->id;
35 35
         }
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function admin_menu() {
40 40
 
41
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
41
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
42 42
         add_menu_page(
43
-            __( 'GetPaid', 'invoicing' ),
44
-            __( 'GetPaid', 'invoicing' ),
43
+            __('GetPaid', 'invoicing'),
44
+            __('GetPaid', 'invoicing'),
45 45
             $capability,
46 46
             'wpinv',
47 47
             null,
48
-            'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ),
48
+            'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')),
49 49
             '54.123460'
50 50
         );
51 51
 
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
     public function add_customers_menu() {
58 58
         add_submenu_page(
59 59
             'wpinv',
60
-            __( 'Customers', 'invoicing' ),
61
-            __( 'Customers', 'invoicing' ),
60
+            __('Customers', 'invoicing'),
61
+            __('Customers', 'invoicing'),
62 62
             wpinv_get_capability(),
63 63
             'wpinv-customers',
64
-            array( $this, 'customers_page' )
64
+            array($this, 'customers_page')
65 65
         );
66 66
     }
67 67
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
     public function add_subscriptions_menu() {
72 72
         add_submenu_page(
73 73
             'wpinv',
74
-            __( 'Subscriptions', 'invoicing' ),
75
-            __( 'Subscriptions', 'invoicing' ),
74
+            __('Subscriptions', 'invoicing'),
75
+            __('Subscriptions', 'invoicing'),
76 76
             wpinv_get_capability(),
77 77
             'wpinv-subscriptions',
78 78
             'wpinv_subscriptions_page'
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      * Displays the customers page.
84 84
      */
85 85
     public function customers_page() {
86
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' );
86
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php');
87 87
         ?>
88 88
         <div class="wrap wpi-customers-wrap">
89 89
             <style>
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
                     width: 30%;
92 92
                 }
93 93
             </style>
94
-            <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?>&nbsp;<a href="<?php echo wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'download_customers' ), 'getpaid-nonce', 'getpaid-nonce' ); ?>" class="page-title-action"><?php _e( 'Export', 'invoicing' ); ?></a></h1>
94
+            <h1><?php echo esc_html(__('Customers', 'invoicing')); ?>&nbsp;<a href="<?php echo wp_nonce_url(add_query_arg('getpaid-admin-action', 'download_customers'), 'getpaid-nonce', 'getpaid-nonce'); ?>" class="page-title-action"><?php _e('Export', 'invoicing'); ?></a></h1>
95 95
             <form method="post">
96 96
             <?php
97 97
                 $table = new WPInv_Customers_Table();
98 98
                 $table->prepare_items();
99
-                $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' );
99
+                $table->search_box(__('Search Customers', 'invoicing'), 'search-customers');
100 100
                 $table->display();
101 101
             ?>
102 102
             </form>
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
     public function add_settings_menu() {
111 111
         add_submenu_page(
112 112
             'wpinv',
113
-            __( 'Invoice Settings', 'invoicing' ),
114
-            __( 'Settings', 'invoicing' ),
115
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
113
+            __('Invoice Settings', 'invoicing'),
114
+            __('Settings', 'invoicing'),
115
+            apply_filters('invoicing_capability', wpinv_get_capability()),
116 116
             'wpinv-settings',
117
-            array( $this, 'options_page' )
117
+            array($this, 'options_page')
118 118
         );
119 119
     }
120 120
 
121
-    public function add_addons_menu(){
122
-        if ( !apply_filters( 'wpi_show_addons_page', true ) ) {
121
+    public function add_addons_menu() {
122
+        if (!apply_filters('wpi_show_addons_page', true)) {
123 123
             return;
124 124
         }
125 125
 
@@ -129,80 +129,80 @@  discard block
 block discarded – undo
129 129
             __('Extensions', 'invoicing'),
130 130
             'manage_options',
131 131
             'wpi-addons',
132
-            array( $this, 'addons_page' )
132
+            array($this, 'addons_page')
133 133
         );
134 134
     }
135 135
 
136
-    public function addons_page(){
136
+    public function addons_page() {
137 137
         $addon_obj = new WPInv_Admin_Addons();
138 138
         $addon_obj->output();
139 139
     }
140 140
 
141 141
     function options_page() {
142
-        $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
142
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
143 143
 
144
-        if ( $page !== 'wpinv-settings' ) {
144
+        if ($page !== 'wpinv-settings') {
145 145
             return;
146 146
         }
147 147
 
148 148
         $settings_tabs = wpinv_get_settings_tabs();
149 149
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
150
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? esc_html( $_GET['tab'] ) : 'general';
151
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
150
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? esc_html($_GET['tab']) : 'general';
151
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
152 152
         $key           = 'main';
153 153
 
154
-        if ( is_array( $sections ) ) {
155
-            $key = key( $sections );
154
+        if (is_array($sections)) {
155
+            $key = key($sections);
156 156
         }
157 157
 
158 158
         add_thickbox();
159 159
 
160
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
161
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
160
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
161
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
162 162
         ob_start();
163 163
         ?>
164 164
         <div class="wrap">
165 165
             <h1 class="nav-tab-wrapper">
166 166
                 <?php
167
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
168
-                    $tab_url = add_query_arg( array(
167
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
168
+                    $tab_url = add_query_arg(array(
169 169
                         'settings-updated' => false,
170 170
                         'tab' => $tab_id,
171
-                    ) );
171
+                    ));
172 172
 
173 173
                     // Remove the section from the tabs so we always end up at the main section
174
-                    $tab_url = remove_query_arg( 'section', $tab_url );
175
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
174
+                    $tab_url = remove_query_arg('section', $tab_url);
175
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
176 176
 
177 177
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
178 178
 
179
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
180
-                    echo esc_html( $tab_name );
179
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
180
+                    echo esc_html($tab_name);
181 181
                     echo '</a>';
182 182
                 }
183 183
                 ?>
184 184
             </h1>
185 185
             <?php
186
-            $number_of_sections = count( $sections );
186
+            $number_of_sections = count($sections);
187 187
             $number = 0;
188
-            if ( $number_of_sections > 1 ) {
188
+            if ($number_of_sections > 1) {
189 189
                 echo '<div><ul class="subsubsub">';
190
-                foreach( $sections as $section_id => $section_name ) {
190
+                foreach ($sections as $section_id => $section_name) {
191 191
                     echo '<li>';
192 192
                     $number++;
193
-                    $tab_url = add_query_arg( array(
193
+                    $tab_url = add_query_arg(array(
194 194
                         'settings-updated' => false,
195 195
                         'tab' => $active_tab,
196 196
                         'section' => $section_id
197
-                    ) );
198
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
197
+                    ));
198
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
199 199
                     $class = '';
200
-                    if ( $section == $section_id ) {
200
+                    if ($section == $section_id) {
201 201
                         $class = 'current';
202 202
                     }
203
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
203
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
204 204
 
205
-                    if ( $number != $number_of_sections ) {
205
+                    if ($number != $number_of_sections) {
206 206
                         echo ' | ';
207 207
                     }
208 208
                     echo '</li>';
@@ -214,20 +214,20 @@  discard block
 block discarded – undo
214 214
                 <form method="post" action="options.php">
215 215
                     <table class="form-table">
216 216
                         <?php
217
-                        settings_fields( 'wpinv_settings' );
217
+                        settings_fields('wpinv_settings');
218 218
 
219
-                        if ( 'main' === $section ) {
220
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
219
+                        if ('main' === $section) {
220
+                            do_action('wpinv_settings_tab_top', $active_tab);
221 221
                         }
222 222
 
223
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
224
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
225
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
226
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
223
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
224
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
225
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
226
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
227 227
 
228 228
                         // For backwards compatibility
229
-                        if ( 'main' === $section ) {
230
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
229
+                        if ('main' === $section) {
230
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
231 231
                         }
232 232
                         ?>
233 233
                     </table>
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
     }
242 242
 
243 243
     public function remove_admin_submenus() {
244
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
244
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
245 245
     }
246 246
 
247 247
     /**
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 
252 252
         add_meta_box(
253 253
             'wpinv_endpoints_nav_link',
254
-            __( 'GetPaid endpoints', 'invoicing' ),
255
-            array( $this, 'nav_menu_links' ),
254
+            __('GetPaid endpoints', 'invoicing'),
255
+            array($this, 'nav_menu_links'),
256 256
             'nav-menus',
257 257
             'side',
258 258
             'low'
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
         $endpoints = $this->get_menu_items();
268 268
         ?>
269 269
         <div id="invoicing-endpoints" class="posttypediv">
270
-            <?php if ( ! empty( $endpoints['pages'] ) ) : ?>
270
+            <?php if (!empty($endpoints['pages'])) : ?>
271 271
                 <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
272 272
                     <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
273 273
                         <?php
274
-                            $walker = new Walker_Nav_Menu_Checklist( array() );
275
-                            echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) );
274
+                            $walker = new Walker_Nav_Menu_Checklist(array());
275
+                            echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
276 276
                         ?>
277 277
                     </ul>
278 278
                 </div>
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
             <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints">
282 282
                 <span class="list-controls hide-if-no-js">
283 283
                     <input type="checkbox" id="invoicing-endpoints-tab" class="select-all">
284
-                    <label for="invoicing-endpoints-tab"><?php _e( 'Select all', 'invoicing' ); ?></label>
284
+                    <label for="invoicing-endpoints-tab"><?php _e('Select all', 'invoicing'); ?></label>
285 285
                 </span>
286 286
 
287 287
                 <span class="add-to-menu">
288
-                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
288
+                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
289 289
                     <span class="spinner"></span>
290 290
                 </span>
291 291
             </p>
@@ -298,35 +298,35 @@  discard block
 block discarded – undo
298 298
      *
299 299
      * @return array.
300 300
      */
301
-    public function get_menu_items(){
301
+    public function get_menu_items() {
302 302
         $items = array();
303 303
 
304 304
         $pages = array(
305 305
             array(
306
-                'id'    => wpinv_get_option( 'invoice_history_page' ),
307
-                'label' => __( 'My Invoices', 'invoicing' ),
306
+                'id'    => wpinv_get_option('invoice_history_page'),
307
+                'label' => __('My Invoices', 'invoicing'),
308 308
             ),
309 309
             array(
310
-                'id'    => wpinv_get_option( 'invoice_subscription_page' ),
311
-                'label' => __( 'My Subscriptions', 'invoicing' ),
310
+                'id'    => wpinv_get_option('invoice_subscription_page'),
311
+                'label' => __('My Subscriptions', 'invoicing'),
312 312
             )
313 313
         );
314 314
 
315
-        foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) {
315
+        foreach (apply_filters('getpaid_menu_pages', $pages) as $page) {
316 316
 
317
-            if ( (int) $page['id'] > 0 ) {
317
+            if ((int) $page['id'] > 0) {
318 318
 
319 319
                 $item                   = new stdClass();
320 320
                 $item->object_id        = (int) $page['id'];
321 321
                 $item->db_id            = 0;
322
-                $item->object           =  'page';
322
+                $item->object           = 'page';
323 323
                 $item->menu_item_parent = 0;
324 324
                 $item->type             = 'post_type';
325
-                $item->title            = esc_html( $page['label'] );
326
-                $item->url              = get_permalink( (int) $page['id'] );
325
+                $item->title            = esc_html($page['label']);
326
+                $item->url              = get_permalink((int) $page['id']);
327 327
                 $item->target           = '';
328 328
                 $item->attr_title       = '';
329
-                $item->classes          = array( 'wpinv-menu-item' );
329
+                $item->classes          = array('wpinv-menu-item');
330 330
                 $item->xfn              = '';
331 331
 
332 332
                 $items['pages'][]       = $item;
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 
336 336
         }
337 337
 
338
-        return apply_filters( 'wpinv_menu_items', $items );
338
+        return apply_filters('wpinv_menu_items', $items);
339 339
     }
340 340
 
341 341
 }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +575 added lines, -575 removed lines patch added patch discarded remove patch
@@ -14,90 +14,90 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29 29
 	
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct(){
38
+     * Class constructor.
39
+     */
40
+    public function __construct(){
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect') );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
66
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
67 67
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
75
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
76
-		do_action( 'getpaid_init_admin_hooks', $this );
77
-
78
-		// Setup/welcome
79
-		if ( ! empty( $_GET['page'] ) ) {
80
-			switch ( $_GET['page'] ) {
81
-				case 'gp-setup' :
82
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
83
-					break;
84
-			}
85
-		}
68
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
69
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
70
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
71
+        add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
72
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
73
+        add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
74
+        add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
75
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
76
+        do_action( 'getpaid_init_admin_hooks', $this );
77
+
78
+        // Setup/welcome
79
+        if ( ! empty( $_GET['page'] ) ) {
80
+            switch ( $_GET['page'] ) {
81
+                case 'gp-setup' :
82
+                    include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
83
+                    break;
84
+            }
85
+        }
86 86
 
87 87
     }
88 88
 
89 89
     /**
90
-	 * Register admin scripts
91
-	 *
92
-	 */
93
-	public function enqeue_scripts() {
90
+     * Register admin scripts
91
+     *
92
+     */
93
+    public function enqeue_scripts() {
94 94
         global $current_screen, $pagenow;
95 95
 
96
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
97
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
96
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
97
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
98 98
 
99 99
         if ( ! empty( $current_screen->post_type ) ) {
100
-			$page = $current_screen->post_type;
100
+            $page = $current_screen->post_type;
101 101
         }
102 102
 
103 103
         // General styles.
@@ -118,54 +118,54 @@  discard block
 block discarded – undo
118 118
         }
119 119
 
120 120
         // Payment form scripts.
121
-		if ( 'wpi_payment_form' == $page && $editing ) {
121
+        if ( 'wpi_payment_form' == $page && $editing ) {
122 122
             $this->load_payment_form_scripts();
123 123
         }
124 124
 
125
-		if ( $page == 'wpinv-subscriptions' ) {
126
-			wp_enqueue_script( 'postbox' );
127
-		}
125
+        if ( $page == 'wpinv-subscriptions' ) {
126
+            wp_enqueue_script( 'postbox' );
127
+        }
128 128
 
129 129
     }
130 130
 
131 131
     /**
132
-	 * Returns admin js translations.
133
-	 *
134
-	 */
135
-	protected function get_admin_i18() {
132
+     * Returns admin js translations.
133
+     *
134
+     */
135
+    protected function get_admin_i18() {
136 136
         global $post;
137 137
 
138
-		$date_range = array(
139
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
140
-		);
138
+        $date_range = array(
139
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
140
+        );
141 141
 
142
-		if ( $date_range['period'] == 'custom' ) {
142
+        if ( $date_range['period'] == 'custom' ) {
143 143
 			
144
-			if ( isset( $_GET['from'] ) ) {
145
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
146
-			}
144
+            if ( isset( $_GET['from'] ) ) {
145
+                $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
146
+            }
147 147
 
148
-			if ( isset( $_GET['to'] ) ) {
149
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
150
-			}
148
+            if ( isset( $_GET['to'] ) ) {
149
+                $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
150
+            }
151 151
 
152
-		}
152
+        }
153 153
 
154 154
         $i18n = array(
155 155
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
156 156
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
157
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
158
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
159
-			'rest_root'                 => esc_url_raw( rest_url() ),
160
-			'date_range'                => $date_range,
157
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
158
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
159
+            'rest_root'                 => esc_url_raw( rest_url() ),
160
+            'date_range'                => $date_range,
161 161
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
162 162
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
163 163
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
164 164
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
165 165
             'tax'                       => wpinv_tax_amount(),
166 166
             'discount'                  => 0,
167
-			'currency_symbol'           => wpinv_currency_symbol(),
168
-			'currency'                  => wpinv_get_currency(),
167
+            'currency_symbol'           => wpinv_currency_symbol(),
168
+            'currency'                  => wpinv_get_currency(),
169 169
             'currency_pos'              => wpinv_currency_position(),
170 170
             'thousand_sep'              => wpinv_thousands_separator(),
171 171
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -185,118 +185,118 @@  discard block
 block discarded – undo
185 185
             'item_description'          => __( 'Item Description', 'invoicing' ),
186 186
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
187 187
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
188
-			'searching'                 => __( 'Searching', 'invoicing' ),
189
-			'loading'                   => __( 'Loading...', 'invoicing' ),
190
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
191
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
188
+            'searching'                 => __( 'Searching', 'invoicing' ),
189
+            'loading'                   => __( 'Loading...', 'invoicing' ),
190
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
191
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
192 192
         );
193 193
 
194
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
194
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
195 195
 
196
-			$invoice              = new WPInv_Invoice( $post );
197
-			$i18n['save_invoice'] = sprintf(
198
-				__( 'Save %s', 'invoicing' ),
199
-				ucfirst( $invoice->get_invoice_quote_type() )
200
-			);
196
+            $invoice              = new WPInv_Invoice( $post );
197
+            $i18n['save_invoice'] = sprintf(
198
+                __( 'Save %s', 'invoicing' ),
199
+                ucfirst( $invoice->get_invoice_quote_type() )
200
+            );
201 201
 
202
-			$i18n['invoice_description'] = sprintf(
203
-				__( '%s Description', 'invoicing' ),
204
-				ucfirst( $invoice->get_invoice_quote_type() )
205
-			);
202
+            $i18n['invoice_description'] = sprintf(
203
+                __( '%s Description', 'invoicing' ),
204
+                ucfirst( $invoice->get_invoice_quote_type() )
205
+            );
206 206
 
207
-		}
208
-		return $i18n;
209
-	}
207
+        }
208
+        return $i18n;
209
+    }
210 210
 
211
-	/**
212
-	 * Change the admin footer text on GetPaid admin pages.
213
-	 *
214
-	 * @since  2.0.0
215
-	 * @param  string $footer_text
216
-	 * @return string
217
-	 */
218
-	public function admin_footer_text( $footer_text ) {
219
-		global $current_screen;
211
+    /**
212
+     * Change the admin footer text on GetPaid admin pages.
213
+     *
214
+     * @since  2.0.0
215
+     * @param  string $footer_text
216
+     * @return string
217
+     */
218
+    public function admin_footer_text( $footer_text ) {
219
+        global $current_screen;
220 220
 
221
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
221
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
222 222
 
223 223
         if ( ! empty( $current_screen->post_type ) ) {
224
-			$page = $current_screen->post_type;
224
+            $page = $current_screen->post_type;
225 225
         }
226 226
 
227 227
         // General styles.
228 228
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
229 229
 
230
-			// Change the footer text
231
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
232
-
233
-				$rating_url  = esc_url(
234
-					wp_nonce_url(
235
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
236
-						'getpaid-nonce',
237
-						'getpaid-nonce'
238
-						)
239
-				);
240
-
241
-				$footer_text = sprintf(
242
-					/* translators: %s: five stars */
243
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
244
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
245
-				);
246
-
247
-			} else {
248
-
249
-				$footer_text = sprintf(
250
-					/* translators: %s: GetPaid */
251
-					__( 'Thank you for using %s!', 'invoicing' ),
252
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
253
-				);
254
-
255
-			}
256
-
257
-		}
258
-
259
-		return $footer_text;
260
-	}
261
-
262
-	/**
263
-	 * Redirects to wp.org to rate the plugin.
264
-	 *
265
-	 * @since  2.0.0
266
-	 */
267
-	public function redirect_to_wordpress_rating_page() {
268
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
269
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
270
-		exit;
271
-	}
272
-
273
-    /**
274
-	 * Loads payment form js.
275
-	 *
276
-	 */
277
-	protected function load_payment_form_scripts() {
230
+            // Change the footer text
231
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
232
+
233
+                $rating_url  = esc_url(
234
+                    wp_nonce_url(
235
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
236
+                        'getpaid-nonce',
237
+                        'getpaid-nonce'
238
+                        )
239
+                );
240
+
241
+                $footer_text = sprintf(
242
+                    /* translators: %s: five stars */
243
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
244
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
245
+                );
246
+
247
+            } else {
248
+
249
+                $footer_text = sprintf(
250
+                    /* translators: %s: GetPaid */
251
+                    __( 'Thank you for using %s!', 'invoicing' ),
252
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
253
+                );
254
+
255
+            }
256
+
257
+        }
258
+
259
+        return $footer_text;
260
+    }
261
+
262
+    /**
263
+     * Redirects to wp.org to rate the plugin.
264
+     *
265
+     * @since  2.0.0
266
+     */
267
+    public function redirect_to_wordpress_rating_page() {
268
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
269
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
270
+        exit;
271
+    }
272
+
273
+    /**
274
+     * Loads payment form js.
275
+     *
276
+     */
277
+    protected function load_payment_form_scripts() {
278 278
         global $post;
279 279
 
280 280
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
281
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
282
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
281
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
282
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
283 283
 
284
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
285
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
284
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
285
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
286 286
 
287
-		wp_localize_script(
287
+        wp_localize_script(
288 288
             'wpinv-admin-payment-form-script',
289 289
             'wpinvPaymentFormAdmin',
290 290
             array(
291
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
292
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
293
-				'currency'      => wpinv_currency_symbol(),
294
-				'position'      => wpinv_currency_position(),
295
-				'decimals'      => (int) wpinv_decimals(),
296
-				'thousands_sep' => wpinv_thousands_separator(),
297
-				'decimals_sep'  => wpinv_decimal_separator(),
298
-				'form_items'    => gepaid_get_form_items( $post->ID ),
299
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
291
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
292
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
293
+                'currency'      => wpinv_currency_symbol(),
294
+                'position'      => wpinv_currency_position(),
295
+                'decimals'      => (int) wpinv_decimals(),
296
+                'thousands_sep' => wpinv_thousands_separator(),
297
+                'decimals_sep'  => wpinv_decimal_separator(),
298
+                'form_items'    => gepaid_get_form_items( $post->ID ),
299
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
300 300
             )
301 301
         );
302 302
 
@@ -305,20 +305,20 @@  discard block
 block discarded – undo
305 305
     }
306 306
 
307 307
     /**
308
-	 * Add our classes to admin pages.
308
+     * Add our classes to admin pages.
309 309
      *
310 310
      * @param string $classes
311 311
      * @return string
312
-	 *
313
-	 */
312
+     *
313
+     */
314 314
     public function admin_body_class( $classes ) {
315
-		global $pagenow, $post, $current_screen;
315
+        global $pagenow, $post, $current_screen;
316 316
 
317 317
 
318 318
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
319 319
 
320 320
         if ( ! empty( $current_screen->post_type ) ) {
321
-			$page = $current_screen->post_type;
321
+            $page = $current_screen->post_type;
322 322
         }
323 323
 
324 324
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -327,68 +327,68 @@  discard block
 block discarded – undo
327 327
 
328 328
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
329 329
             $classes .= ' wpinv-cpt wpinv';
330
-		}
330
+        }
331 331
 		
332
-		if ( getpaid_is_invoice_post_type( $page ) ) {
332
+        if ( getpaid_is_invoice_post_type( $page ) ) {
333 333
             $classes .= ' getpaid-is-invoice-cpt';
334 334
         }
335 335
 
336
-		return $classes;
336
+        return $classes;
337 337
     }
338 338
 
339 339
     /**
340
-	 * Maybe show the AyeCode Connect Notice.
341
-	 */
342
-	public function init_ayecode_connect_helper(){
340
+     * Maybe show the AyeCode Connect Notice.
341
+     */
342
+    public function init_ayecode_connect_helper(){
343 343
 
344
-		// Register with the deactivation survey class.
345
-		AyeCode_Deactivation_Survey::instance(array(
346
-			'slug'		        => 'invoicing',
347
-			'version'	        => WPINV_VERSION,
348
-			'support_url'       => 'https://wpgetpaid.com/support/',
349
-			'documentation_url' => 'https://docs.wpgetpaid.com/',
350
-			'activated'         => (int) get_option( 'gepaid_installed_on' ),
351
-		));
344
+        // Register with the deactivation survey class.
345
+        AyeCode_Deactivation_Survey::instance(array(
346
+            'slug'		        => 'invoicing',
347
+            'version'	        => WPINV_VERSION,
348
+            'support_url'       => 'https://wpgetpaid.com/support/',
349
+            'documentation_url' => 'https://docs.wpgetpaid.com/',
350
+            'activated'         => (int) get_option( 'gepaid_installed_on' ),
351
+        ));
352 352
 
353 353
         new AyeCode_Connect_Helper(
354 354
             array(
355
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
356
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
357
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
358
-				'connect_button'    => __("Connect Site","invoicing"),
359
-				'connecting_button'    => __("Connecting...","invoicing"),
360
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
361
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
355
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
356
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
357
+                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
358
+                'connect_button'    => __("Connect Site","invoicing"),
359
+                'connecting_button'    => __("Connecting...","invoicing"),
360
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
361
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
362 362
             ),
363 363
             array( 'wpi-addons' )
364 364
         );
365 365
 
366 366
     }
367 367
 
368
-	/**
369
-	 * Redirect users to settings on activation.
370
-	 *
371
-	 * @return void
372
-	 */
373
-	public function activation_redirect() {
368
+    /**
369
+     * Redirect users to settings on activation.
370
+     *
371
+     * @return void
372
+     */
373
+    public function activation_redirect() {
374 374
 
375
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
375
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
376 376
 
377
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
378
-			return;
379
-		}
377
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
378
+            return;
379
+        }
380 380
 
381
-		// Bail if activating from network, or bulk
382
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
383
-			return;
384
-		}
381
+        // Bail if activating from network, or bulk
382
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
383
+            return;
384
+        }
385 385
 
386
-	    update_option( 'wpinv_redirected_to_settings', 1 );
386
+        update_option( 'wpinv_redirected_to_settings', 1 );
387 387
 
388 388
         wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
389 389
         exit;
390 390
 
391
-	}
391
+    }
392 392
 
393 393
     /**
394 394
      * Fires an admin action after verifying that a user can fire them.
@@ -402,498 +402,498 @@  discard block
 block discarded – undo
402 402
 
403 403
     }
404 404
 
405
-	/**
405
+    /**
406 406
      * Sends a payment reminder to a customer.
407
-	 * 
408
-	 * @param array $args
407
+     * 
408
+     * @param array $args
409 409
      */
410 410
     public function duplicate_payment_form( $args ) {
411 411
 
412
-		if ( empty( $args['form_id'] ) ) {
413
-			return;
414
-		}
415
-
416
-		$form = new GetPaid_Payment_Form( $args['form_id'] );
412
+        if ( empty( $args['form_id'] ) ) {
413
+            return;
414
+        }
417 415
 
418
-		if ( ! $form->exists() ) {
419
-			return;
420
-		}
416
+        $form = new GetPaid_Payment_Form( $args['form_id'] );
421 417
 
422
-		$new_form = new GetPaid_Payment_Form();
423
-		$new_form->set_author( $form->get_author( 'edit' ) );
424
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
425
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
426
-		$new_form->set_items( $form->get_items( 'edit' ) );
427
-		$new_form->save();
418
+        if ( ! $form->exists() ) {
419
+            return;
420
+        }
428 421
 
429
-		if ( $new_form->exists() ) {
430
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
431
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
432
-		} else {
433
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
434
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
435
-		}
422
+        $new_form = new GetPaid_Payment_Form();
423
+        $new_form->set_author( $form->get_author( 'edit' ) );
424
+        $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
425
+        $new_form->set_elements( $form->get_elements( 'edit' ) );
426
+        $new_form->set_items( $form->get_items( 'edit' ) );
427
+        $new_form->save();
428
+
429
+        if ( $new_form->exists() ) {
430
+            $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
431
+            $url = get_edit_post_link( $new_form->get_id(), 'edit' );
432
+        } else {
433
+            $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
434
+            $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
435
+        }
436 436
 
437
-		wp_redirect( $url );
438
-		exit;
439
-	}
437
+        wp_redirect( $url );
438
+        exit;
439
+    }
440 440
 
441
-	/**
441
+    /**
442 442
      * Sends a payment reminder to a customer.
443
-	 * 
444
-	 * @param array $args
443
+     * 
444
+     * @param array $args
445 445
      */
446 446
     public function send_customer_invoice( $args ) {
447
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
447
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
448 448
 
449
-		if ( $sent ) {
450
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
451
-		} else {
452
-			$this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
453
-		}
449
+        if ( $sent ) {
450
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
451
+        } else {
452
+            $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
453
+        }
454 454
 
455
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
456
-		exit;
457
-	}
455
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
456
+        exit;
457
+    }
458 458
 
459
-	/**
459
+    /**
460 460
      * Sends a payment reminder to a customer.
461
-	 * 
462
-	 * @param array $args
461
+     * 
462
+     * @param array $args
463 463
      */
464 464
     public function send_customer_payment_reminder( $args ) {
465
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
465
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
466 466
 
467
-		if ( $sent ) {
468
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
469
-		} else {
470
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
471
-		}
467
+        if ( $sent ) {
468
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
469
+        } else {
470
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
471
+        }
472 472
 
473
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
474
-		exit;
475
-	}
473
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
474
+        exit;
475
+    }
476 476
 
477
-	/**
477
+    /**
478 478
      * Resets tax rates.
479
-	 * 
479
+     * 
480 480
      */
481 481
     public function admin_reset_tax_rates() {
482 482
 
483
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
484
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
485
-		exit;
483
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
484
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
485
+        exit;
486 486
 
487
-	}
487
+    }
488 488
 
489
-	/**
489
+    /**
490 490
      * Resets admin pages.
491
-	 * 
491
+     * 
492 492
      */
493 493
     public function admin_create_missing_pages() {
494
-		$installer = new GetPaid_Installer();
495
-		$installer->create_pages();
496
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
497
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
498
-		exit;
499
-	}
500
-
501
-	/**
494
+        $installer = new GetPaid_Installer();
495
+        $installer->create_pages();
496
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
497
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
498
+        exit;
499
+    }
500
+
501
+    /**
502 502
      * Creates an missing admin tables.
503
-	 * 
503
+     * 
504 504
      */
505 505
     public function admin_create_missing_tables() {
506
-		global $wpdb;
507
-		$installer = new GetPaid_Installer();
506
+        global $wpdb;
507
+        $installer = new GetPaid_Installer();
508 508
 
509
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
510
-			$installer->create_subscriptions_table();
509
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
510
+            $installer->create_subscriptions_table();
511 511
 
512
-			if ( $wpdb->last_error !== '' ) {
513
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
514
-			}
515
-		}
512
+            if ( $wpdb->last_error !== '' ) {
513
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
514
+            }
515
+        }
516 516
 
517
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
518
-			$installer->create_invoices_table();
517
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
518
+            $installer->create_invoices_table();
519 519
 
520
-			if ( $wpdb->last_error !== '' ) {
521
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
522
-			}
523
-		}
520
+            if ( $wpdb->last_error !== '' ) {
521
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
522
+            }
523
+        }
524 524
 
525
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
526
-			$installer->create_invoice_items_table();
525
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
526
+            $installer->create_invoice_items_table();
527 527
 
528
-			if ( $wpdb->last_error !== '' ) {
529
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
530
-			}
531
-		}
528
+            if ( $wpdb->last_error !== '' ) {
529
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
530
+            }
531
+        }
532 532
 
533
-		if ( ! $this->has_notices() ) {
534
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
535
-		}
533
+        if ( ! $this->has_notices() ) {
534
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
535
+        }
536 536
 
537
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
538
-		exit;
539
-	}
537
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
538
+        exit;
539
+    }
540 540
 
541
-	/**
541
+    /**
542 542
      * Migrates old invoices to the new database tables.
543
-	 * 
543
+     * 
544 544
      */
545 545
     public function admin_migrate_old_invoices() {
546 546
 
547
-		// Migrate the invoices.
548
-		$installer = new GetPaid_Installer();
549
-		$installer->migrate_old_invoices();
547
+        // Migrate the invoices.
548
+        $installer = new GetPaid_Installer();
549
+        $installer->migrate_old_invoices();
550 550
 
551
-		// Show an admin message.
552
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
551
+        // Show an admin message.
552
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
553 553
 
554
-		// Redirect the admin.
555
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
556
-		exit;
554
+        // Redirect the admin.
555
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
556
+        exit;
557 557
 
558
-	}
558
+    }
559 559
 
560
-	/**
560
+    /**
561 561
      * Download customers.
562
-	 * 
562
+     * 
563 563
      */
564 564
     public function admin_download_customers() {
565
-		global $wpdb;
565
+        global $wpdb;
566 566
 
567
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
567
+        $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
568 568
 
569
-		header( "Content-Type:text/csv" );
570
-		header( "Content-Disposition:attachment;filename=customers.csv" );
569
+        header( "Content-Type:text/csv" );
570
+        header( "Content-Disposition:attachment;filename=customers.csv" );
571 571
 
572
-		$post_types = '';
572
+        $post_types = '';
573 573
 
574
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
575
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
576
-		}
574
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
575
+            $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
576
+        }
577 577
 
578
-		$post_types = rtrim( $post_types, ' OR' );
578
+        $post_types = rtrim( $post_types, ' OR' );
579 579
 
580
-		$customers = $wpdb->get_col(
581
-			$wpdb->prepare(
582
-				"SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
583
-			)
584
-		);
580
+        $customers = $wpdb->get_col(
581
+            $wpdb->prepare(
582
+                "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
583
+            )
584
+        );
585 585
 
586
-		$columns = array(
587
-			'name'     => __( 'Name', 'invoicing' ),
588
-			'email'    => __( 'Email', 'invoicing' ),
589
-			'country'  => __( 'Country', 'invoicing' ),
590
-			'state'    => __( 'State', 'invoicing' ),
591
-			'city'     => __( 'City', 'invoicing' ),
592
-			'zip'      => __( 'ZIP', 'invoicing' ),
593
-			'address'  => __( 'Address', 'invoicing' ),
594
-			'phone'    => __( 'Phone', 'invoicing' ),
595
-			'company'  => __( 'Company', 'invoicing' ),
596
-			'company_id'  => __( 'Company ID', 'invoicing' ),
597
-			'invoices' => __( 'Invoices', 'invoicing' ),
598
-			'total_raw' => __( 'Total Spend', 'invoicing' ),
599
-			'signup'   => __( 'Date created', 'invoicing' ),
600
-		);
586
+        $columns = array(
587
+            'name'     => __( 'Name', 'invoicing' ),
588
+            'email'    => __( 'Email', 'invoicing' ),
589
+            'country'  => __( 'Country', 'invoicing' ),
590
+            'state'    => __( 'State', 'invoicing' ),
591
+            'city'     => __( 'City', 'invoicing' ),
592
+            'zip'      => __( 'ZIP', 'invoicing' ),
593
+            'address'  => __( 'Address', 'invoicing' ),
594
+            'phone'    => __( 'Phone', 'invoicing' ),
595
+            'company'  => __( 'Company', 'invoicing' ),
596
+            'company_id'  => __( 'Company ID', 'invoicing' ),
597
+            'invoices' => __( 'Invoices', 'invoicing' ),
598
+            'total_raw' => __( 'Total Spend', 'invoicing' ),
599
+            'signup'   => __( 'Date created', 'invoicing' ),
600
+        );
601 601
 
602
-		// Output the csv column headers.
603
-		fputcsv( $output, array_values( $columns ) );
602
+        // Output the csv column headers.
603
+        fputcsv( $output, array_values( $columns ) );
604 604
 
605
-		// Loop through
606
-		$table = new WPInv_Customers_Table();
607
-		foreach ( $customers as $customer_id ) {
605
+        // Loop through
606
+        $table = new WPInv_Customers_Table();
607
+        foreach ( $customers as $customer_id ) {
608 608
 
609
-			$user = get_user_by( 'id', $customer_id );
610
-			$row  = array();
611
-			if ( empty( $user ) ) {
612
-				continue;
613
-			}
609
+            $user = get_user_by( 'id', $customer_id );
610
+            $row  = array();
611
+            if ( empty( $user ) ) {
612
+                continue;
613
+            }
614 614
 
615
-			foreach ( array_keys( $columns ) as $column ) {
615
+            foreach ( array_keys( $columns ) as $column ) {
616 616
 
617
-				$method = 'column_' . $column;
617
+                $method = 'column_' . $column;
618 618
 
619
-				if ( 'name' == $column ) {
620
-					$value = esc_html( $user->display_name );
621
-				} else if( 'email' == $column ) {
622
-					$value = sanitize_email( $user->user_email );
623
-				} else if ( is_callable( array( $table, $method ) ) ) {
624
-					$value = strip_tags( $table->$method( $user ) );
625
-				}
619
+                if ( 'name' == $column ) {
620
+                    $value = esc_html( $user->display_name );
621
+                } else if( 'email' == $column ) {
622
+                    $value = sanitize_email( $user->user_email );
623
+                } else if ( is_callable( array( $table, $method ) ) ) {
624
+                    $value = strip_tags( $table->$method( $user ) );
625
+                }
626 626
 
627
-				if ( empty( $value ) ) {
628
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
629
-				}
627
+                if ( empty( $value ) ) {
628
+                    $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
629
+                }
630 630
 
631
-				$row[] = $value;
631
+                $row[] = $value;
632 632
 
633
-			}
633
+            }
634 634
 
635
-			fputcsv( $output, $row );
636
-		}
635
+            fputcsv( $output, $row );
636
+        }
637 637
 
638
-		fclose( $output );
639
-		exit;
638
+        fclose( $output );
639
+        exit;
640 640
 
641
-	}
641
+    }
642 642
 
643
-	/**
643
+    /**
644 644
      * Installs a plugin.
645
-	 *
646
-	 * @param array $data
645
+     *
646
+     * @param array $data
647 647
      */
648 648
     public function admin_install_plugin( $data ) {
649 649
 
650
-		if ( ! empty( $data['plugins'] ) ) {
651
-			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
652
-			wp_cache_flush();
650
+        if ( ! empty( $data['plugins'] ) ) {
651
+            include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
652
+            wp_cache_flush();
653 653
 
654
-			foreach ( $data['plugins'] as $slug => $file ) {
655
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
656
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
657
-				$installed  = $upgrader->install( $plugin_zip );
654
+            foreach ( $data['plugins'] as $slug => $file ) {
655
+                $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
656
+                $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
657
+                $installed  = $upgrader->install( $plugin_zip );
658 658
 
659
-				if ( ! is_wp_error( $installed ) && $installed ) {
660
-					activate_plugin( $file, '', false, true );
661
-				} else {
662
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
663
-				}
659
+                if ( ! is_wp_error( $installed ) && $installed ) {
660
+                    activate_plugin( $file, '', false, true );
661
+                } else {
662
+                    wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
663
+                }
664 664
 
665
-			}
665
+            }
666 666
 
667
-		}
667
+        }
668 668
 
669
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
670
-		wp_safe_redirect( $redirect );
671
-		exit;
669
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
670
+        wp_safe_redirect( $redirect );
671
+        exit;
672 672
 
673
-	}
673
+    }
674 674
 
675
-	/**
675
+    /**
676 676
      * Connects a gateway.
677
-	 *
678
-	 * @param array $data
677
+     *
678
+     * @param array $data
679 679
      */
680 680
     public function admin_connect_gateway( $data ) {
681 681
 
682
-		if ( ! empty( $data['plugin'] ) ) {
682
+        if ( ! empty( $data['plugin'] ) ) {
683 683
 
684
-			$gateway     = sanitize_key( $data['plugin'] );
685
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
684
+            $gateway     = sanitize_key( $data['plugin'] );
685
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
686 686
 
687
-			if ( ! empty( $connect_url ) ) {
688
-				wp_redirect( $connect_url );
689
-				exit;
690
-			}
687
+            if ( ! empty( $connect_url ) ) {
688
+                wp_redirect( $connect_url );
689
+                exit;
690
+            }
691 691
 
692
-			if ( 'stripe' == $data['plugin'] ) {
693
-				require_once ABSPATH . 'wp-admin/includes/plugin.php';
694
-				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
695
-				wp_cache_flush();
692
+            if ( 'stripe' == $data['plugin'] ) {
693
+                require_once ABSPATH . 'wp-admin/includes/plugin.php';
694
+                include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
695
+                wp_cache_flush();
696 696
 
697
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
698
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
699
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
700
-					$upgrader->install( $plugin_zip );
701
-				}
697
+                if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
698
+                    $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
699
+                    $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
700
+                    $upgrader->install( $plugin_zip );
701
+                }
702 702
 
703
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
704
-			}
703
+                activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
704
+            }
705 705
 
706
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
707
-			if ( ! empty( $connect_url ) ) {
708
-				wp_redirect( $connect_url );
709
-				exit;
710
-			}
706
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
707
+            if ( ! empty( $connect_url ) ) {
708
+                wp_redirect( $connect_url );
709
+                exit;
710
+            }
711 711
 
712
-		}
712
+        }
713 713
 
714
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
715
-		wp_safe_redirect( $redirect );
716
-		exit;
714
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
715
+        wp_safe_redirect( $redirect );
716
+        exit;
717 717
 
718
-	}
718
+    }
719 719
 
720
-	/**
720
+    /**
721 721
      * Recalculates discounts.
722
-	 * 
722
+     * 
723 723
      */
724 724
     public function admin_recalculate_discounts() {
725
-		global $wpdb;
725
+        global $wpdb;
726 726
 
727
-		// Fetch all invoices that have discount codes.
728
-		$table    = $wpdb->prefix . 'getpaid_invoices';
729
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
727
+        // Fetch all invoices that have discount codes.
728
+        $table    = $wpdb->prefix . 'getpaid_invoices';
729
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
730 730
 
731
-		foreach ( $invoices as $invoice ) {
731
+        foreach ( $invoices as $invoice ) {
732 732
 
733
-			$invoice = new WPInv_Invoice( $invoice );
733
+            $invoice = new WPInv_Invoice( $invoice );
734 734
 
735
-			if ( ! $invoice->exists() ) {
736
-				continue;
737
-			}
735
+            if ( ! $invoice->exists() ) {
736
+                continue;
737
+            }
738 738
 
739
-			// Abort if the discount does not exist or does not apply here.
740
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
741
-			if ( ! $discount->exists() ) {
742
-				continue;
743
-			}
739
+            // Abort if the discount does not exist or does not apply here.
740
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
741
+            if ( ! $discount->exists() ) {
742
+                continue;
743
+            }
744 744
 
745
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
746
-			$invoice->recalculate_total();
745
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
746
+            $invoice->recalculate_total();
747 747
 
748
-			if ( $invoice->get_total_discount() > 0 ) {
749
-				$invoice->save();
750
-			}
748
+            if ( $invoice->get_total_discount() > 0 ) {
749
+                $invoice->save();
750
+            }
751 751
 
752
-		}
752
+        }
753 753
 
754
-		// Show an admin message.
755
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
754
+        // Show an admin message.
755
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
756 756
 
757
-		// Redirect the admin.
758
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
759
-		exit;
757
+        // Redirect the admin.
758
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
759
+        exit;
760 760
 
761
-	}
761
+    }
762 762
 
763 763
     /**
764
-	 * Returns an array of admin notices.
765
-	 *
766
-	 * @since       1.0.19
764
+     * Returns an array of admin notices.
765
+     *
766
+     * @since       1.0.19
767 767
      * @return array
768
-	 */
769
-	public function get_notices() {
770
-		$notices = get_option( 'wpinv_admin_notices' );
768
+     */
769
+    public function get_notices() {
770
+        $notices = get_option( 'wpinv_admin_notices' );
771 771
         return is_array( $notices ) ? $notices : array();
772
-	}
772
+    }
773 773
 
774
-	/**
775
-	 * Checks if we have any admin notices.
776
-	 *
777
-	 * @since       2.0.4
774
+    /**
775
+     * Checks if we have any admin notices.
776
+     *
777
+     * @since       2.0.4
778 778
      * @return array
779
-	 */
780
-	public function has_notices() {
781
-		return count( $this->get_notices() ) > 0;
782
-	}
783
-
784
-	/**
785
-	 * Clears all admin notices
786
-	 *
787
-	 * @access      public
788
-	 * @since       1.0.19
789
-	 */
790
-	public function clear_notices() {
791
-		delete_option( 'wpinv_admin_notices' );
792
-	}
793
-
794
-	/**
795
-	 * Saves a new admin notice
796
-	 *
797
-	 * @access      public
798
-	 * @since       1.0.19
799
-	 */
800
-	public function save_notice( $type, $message ) {
801
-		$notices = $this->get_notices();
802
-
803
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
804
-			$notices[ $type ] = array();
805
-		}
806
-
807
-		$notices[ $type ][] = $message;
808
-
809
-		update_option( 'wpinv_admin_notices', $notices );
810
-	}
811
-
812
-	/**
813
-	 * Displays a success notice
814
-	 *
815
-	 * @param       string $msg The message to qeue.
816
-	 * @access      public
817
-	 * @since       1.0.19
818
-	 */
819
-	public function show_success( $msg ) {
820
-		$this->save_notice( 'success', $msg );
821
-	}
822
-
823
-	/**
824
-	 * Displays a error notice
825
-	 *
826
-	 * @access      public
827
-	 * @param       string $msg The message to qeue.
828
-	 * @since       1.0.19
829
-	 */
830
-	public function show_error( $msg ) {
831
-		$this->save_notice( 'error', $msg );
832
-	}
833
-
834
-	/**
835
-	 * Displays a warning notice
836
-	 *
837
-	 * @access      public
838
-	 * @param       string $msg The message to qeue.
839
-	 * @since       1.0.19
840
-	 */
841
-	public function show_warning( $msg ) {
842
-		$this->save_notice( 'warning', $msg );
843
-	}
844
-
845
-	/**
846
-	 * Displays a info notice
847
-	 *
848
-	 * @access      public
849
-	 * @param       string $msg The message to qeue.
850
-	 * @since       1.0.19
851
-	 */
852
-	public function show_info( $msg ) {
853
-		$this->save_notice( 'info', $msg );
854
-	}
855
-
856
-	/**
857
-	 * Show notices
858
-	 *
859
-	 * @access      public
860
-	 * @since       1.0.19
861
-	 */
862
-	public function show_notices() {
779
+     */
780
+    public function has_notices() {
781
+        return count( $this->get_notices() ) > 0;
782
+    }
783
+
784
+    /**
785
+     * Clears all admin notices
786
+     *
787
+     * @access      public
788
+     * @since       1.0.19
789
+     */
790
+    public function clear_notices() {
791
+        delete_option( 'wpinv_admin_notices' );
792
+    }
793
+
794
+    /**
795
+     * Saves a new admin notice
796
+     *
797
+     * @access      public
798
+     * @since       1.0.19
799
+     */
800
+    public function save_notice( $type, $message ) {
801
+        $notices = $this->get_notices();
802
+
803
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
804
+            $notices[ $type ] = array();
805
+        }
806
+
807
+        $notices[ $type ][] = $message;
808
+
809
+        update_option( 'wpinv_admin_notices', $notices );
810
+    }
811
+
812
+    /**
813
+     * Displays a success notice
814
+     *
815
+     * @param       string $msg The message to qeue.
816
+     * @access      public
817
+     * @since       1.0.19
818
+     */
819
+    public function show_success( $msg ) {
820
+        $this->save_notice( 'success', $msg );
821
+    }
822
+
823
+    /**
824
+     * Displays a error notice
825
+     *
826
+     * @access      public
827
+     * @param       string $msg The message to qeue.
828
+     * @since       1.0.19
829
+     */
830
+    public function show_error( $msg ) {
831
+        $this->save_notice( 'error', $msg );
832
+    }
833
+
834
+    /**
835
+     * Displays a warning notice
836
+     *
837
+     * @access      public
838
+     * @param       string $msg The message to qeue.
839
+     * @since       1.0.19
840
+     */
841
+    public function show_warning( $msg ) {
842
+        $this->save_notice( 'warning', $msg );
843
+    }
844
+
845
+    /**
846
+     * Displays a info notice
847
+     *
848
+     * @access      public
849
+     * @param       string $msg The message to qeue.
850
+     * @since       1.0.19
851
+     */
852
+    public function show_info( $msg ) {
853
+        $this->save_notice( 'info', $msg );
854
+    }
855
+
856
+    /**
857
+     * Show notices
858
+     *
859
+     * @access      public
860
+     * @since       1.0.19
861
+     */
862
+    public function show_notices() {
863 863
 
864 864
         $notices = $this->get_notices();
865 865
         $this->clear_notices();
866 866
 
867
-		foreach ( $notices as $type => $messages ) {
867
+        foreach ( $notices as $type => $messages ) {
868 868
 
869
-			if ( ! is_array( $messages ) ) {
870
-				continue;
871
-			}
869
+            if ( ! is_array( $messages ) ) {
870
+                continue;
871
+            }
872 872
 
873 873
             $type  = sanitize_key( $type );
874
-			foreach ( $messages as $message ) {
874
+            foreach ( $messages as $message ) {
875 875
                 $message = wp_kses_post( $message );
876
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
876
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
877 877
             }
878 878
 
879 879
         }
880 880
 
881
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
882
-
883
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
884
-				$url     = wp_nonce_url(
885
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
886
-					'getpaid-nonce',
887
-					'getpaid-nonce'
888
-				);
889
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
890
-				$message2 = __( 'Generate Pages', 'invoicing' );
891
-				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
892
-				break;
893
-			}
881
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
882
+
883
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
884
+                $url     = wp_nonce_url(
885
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
886
+                    'getpaid-nonce',
887
+                    'getpaid-nonce'
888
+                );
889
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
890
+                $message2 = __( 'Generate Pages', 'invoicing' );
891
+                echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
892
+                break;
893
+            }
894 894
 
895
-		}
895
+        }
896 896
 
897
-	}
897
+    }
898 898
 
899 899
 }
Please login to merge, or discard this patch.
Spacing   +270 added lines, -270 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
  * The main admin class.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
40
+	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,32 +54,32 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
67
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
75
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
76
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page'));
64
+		add_action('getpaid_authenticated_admin_action_duplicate_form', array($this, 'duplicate_payment_form'));
65
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
66
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
67
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
68
+		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages'));
69
+		add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables'));
70
+		add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices'));
71
+		add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers'));
72
+		add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts'));
73
+		add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin'));
74
+		add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway'));
75
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
76
+		do_action('getpaid_init_admin_hooks', $this);
77 77
 
78 78
 		// Setup/welcome
79
-		if ( ! empty( $_GET['page'] ) ) {
80
-			switch ( $_GET['page'] ) {
79
+		if (!empty($_GET['page'])) {
80
+			switch ($_GET['page']) {
81 81
 				case 'gp-setup' :
82
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
82
+					include_once(dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php');
83 83
 					break;
84 84
 			}
85 85
 		}
@@ -93,37 +93,37 @@  discard block
 block discarded – undo
93 93
 	public function enqeue_scripts() {
94 94
         global $current_screen, $pagenow;
95 95
 
96
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
96
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
97 97
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
98 98
 
99
-        if ( ! empty( $current_screen->post_type ) ) {
99
+        if (!empty($current_screen->post_type)) {
100 100
 			$page = $current_screen->post_type;
101 101
         }
102 102
 
103 103
         // General styles.
104
-        if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page ) {
104
+        if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page) {
105 105
 
106 106
             // Styles.
107
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
108
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
109
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
107
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
108
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
109
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
110 110
 
111 111
             // Scripts.
112
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
112
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
113 113
 
114
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
115
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ),  $version );
116
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
114
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
115
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version);
116
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
117 117
 
118 118
         }
119 119
 
120 120
         // Payment form scripts.
121
-		if ( 'wpi_payment_form' == $page && $editing ) {
121
+		if ('wpi_payment_form' == $page && $editing) {
122 122
             $this->load_payment_form_scripts();
123 123
         }
124 124
 
125
-		if ( $page == 'wpinv-subscriptions' ) {
126
-			wp_enqueue_script( 'postbox' );
125
+		if ($page == 'wpinv-subscriptions') {
126
+			wp_enqueue_script('postbox');
127 127
 		}
128 128
 
129 129
     }
@@ -136,32 +136,32 @@  discard block
 block discarded – undo
136 136
         global $post;
137 137
 
138 138
 		$date_range = array(
139
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
139
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'
140 140
 		);
141 141
 
142
-		if ( $date_range['period'] == 'custom' ) {
142
+		if ($date_range['period'] == 'custom') {
143 143
 			
144
-			if ( isset( $_GET['from'] ) ) {
145
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
144
+			if (isset($_GET['from'])) {
145
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
146 146
 			}
147 147
 
148
-			if ( isset( $_GET['to'] ) ) {
149
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
148
+			if (isset($_GET['to'])) {
149
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
150 150
 			}
151 151
 
152 152
 		}
153 153
 
154 154
         $i18n = array(
155
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
156
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
157
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
158
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
159
-			'rest_root'                 => esc_url_raw( rest_url() ),
155
+            'ajax_url'                  => admin_url('admin-ajax.php'),
156
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
157
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
158
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
159
+			'rest_root'                 => esc_url_raw(rest_url()),
160 160
 			'date_range'                => $date_range,
161
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
162
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
163
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
164
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
161
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
162
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
163
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
164
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
165 165
             'tax'                       => wpinv_tax_amount(),
166 166
             'discount'                  => 0,
167 167
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -170,38 +170,38 @@  discard block
 block discarded – undo
170 170
             'thousand_sep'              => wpinv_thousands_separator(),
171 171
             'decimal_sep'               => wpinv_decimal_separator(),
172 172
             'decimals'                  => wpinv_decimals(),
173
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
174
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
175
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
176
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
177
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
178
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
179
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
180
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
181
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
182
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
183
-            'action_edit'               => __( 'Edit', 'invoicing' ),
184
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
185
-            'item_description'          => __( 'Item Description', 'invoicing' ),
186
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
187
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
188
-			'searching'                 => __( 'Searching', 'invoicing' ),
189
-			'loading'                   => __( 'Loading...', 'invoicing' ),
190
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
191
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
173
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
174
+            'status_publish'            => wpinv_status_nicename('publish'),
175
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
176
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
177
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
178
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
179
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
180
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
181
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
182
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
183
+            'action_edit'               => __('Edit', 'invoicing'),
184
+            'action_cancel'             => __('Cancel', 'invoicing'),
185
+            'item_description'          => __('Item Description', 'invoicing'),
186
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
187
+            'discount_description'      => __('Discount Description', 'invoicing'),
188
+			'searching'                 => __('Searching', 'invoicing'),
189
+			'loading'                   => __('Loading...', 'invoicing'),
190
+			'search_customers'          => __('Enter customer name or email', 'invoicing'),
191
+			'search_items'              => __('Enter item name', 'invoicing'),
192 192
         );
193 193
 
194
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
194
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
195 195
 
196
-			$invoice              = new WPInv_Invoice( $post );
196
+			$invoice              = new WPInv_Invoice($post);
197 197
 			$i18n['save_invoice'] = sprintf(
198
-				__( 'Save %s', 'invoicing' ),
199
-				ucfirst( $invoice->get_invoice_quote_type() )
198
+				__('Save %s', 'invoicing'),
199
+				ucfirst($invoice->get_invoice_quote_type())
200 200
 			);
201 201
 
202 202
 			$i18n['invoice_description'] = sprintf(
203
-				__( '%s Description', 'invoicing' ),
204
-				ucfirst( $invoice->get_invoice_quote_type() )
203
+				__('%s Description', 'invoicing'),
204
+				ucfirst($invoice->get_invoice_quote_type())
205 205
 			);
206 206
 
207 207
 		}
@@ -215,24 +215,24 @@  discard block
 block discarded – undo
215 215
 	 * @param  string $footer_text
216 216
 	 * @return string
217 217
 	 */
218
-	public function admin_footer_text( $footer_text ) {
218
+	public function admin_footer_text($footer_text) {
219 219
 		global $current_screen;
220 220
 
221
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
221
+		$page = isset($_GET['page']) ? $_GET['page'] : '';
222 222
 
223
-        if ( ! empty( $current_screen->post_type ) ) {
223
+        if (!empty($current_screen->post_type)) {
224 224
 			$page = $current_screen->post_type;
225 225
         }
226 226
 
227 227
         // General styles.
228
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
228
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
229 229
 
230 230
 			// Change the footer text
231
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
231
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
232 232
 
233
-				$rating_url  = esc_url(
233
+				$rating_url = esc_url(
234 234
 					wp_nonce_url(
235
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
235
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
236 236
 						'getpaid-nonce',
237 237
 						'getpaid-nonce'
238 238
 						)
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
 				$footer_text = sprintf(
242 242
 					/* translators: %s: five stars */
243
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
243
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
244 244
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
245 245
 				);
246 246
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
 				$footer_text = sprintf(
250 250
 					/* translators: %s: GetPaid */
251
-					__( 'Thank you for using %s!', 'invoicing' ),
251
+					__('Thank you for using %s!', 'invoicing'),
252 252
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
253 253
 				);
254 254
 
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 	 * @since  2.0.0
266 266
 	 */
267 267
 	public function redirect_to_wordpress_rating_page() {
268
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
269
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
268
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
269
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
270 270
 		exit;
271 271
 	}
272 272
 
@@ -277,30 +277,30 @@  discard block
 block discarded – undo
277 277
 	protected function load_payment_form_scripts() {
278 278
         global $post;
279 279
 
280
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
281
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
282
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
280
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION);
281
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
282
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
283 283
 
284
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
285
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
284
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
285
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
286 286
 
287 287
 		wp_localize_script(
288 288
             'wpinv-admin-payment-form-script',
289 289
             'wpinvPaymentFormAdmin',
290 290
             array(
291
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
292
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
291
+				'elements'      => wpinv_get_data('payment-form-elements'),
292
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
293 293
 				'currency'      => wpinv_currency_symbol(),
294 294
 				'position'      => wpinv_currency_position(),
295 295
 				'decimals'      => (int) wpinv_decimals(),
296 296
 				'thousands_sep' => wpinv_thousands_separator(),
297 297
 				'decimals_sep'  => wpinv_decimal_separator(),
298
-				'form_items'    => gepaid_get_form_items( $post->ID ),
298
+				'form_items'    => gepaid_get_form_items($post->ID),
299 299
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
300 300
             )
301 301
         );
302 302
 
303
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
303
+        wp_enqueue_script('wpinv-admin-payment-form-script');
304 304
 
305 305
     }
306 306
 
@@ -311,25 +311,25 @@  discard block
 block discarded – undo
311 311
      * @return string
312 312
 	 *
313 313
 	 */
314
-    public function admin_body_class( $classes ) {
314
+    public function admin_body_class($classes) {
315 315
 		global $pagenow, $post, $current_screen;
316 316
 
317 317
 
318
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
318
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
319 319
 
320
-        if ( ! empty( $current_screen->post_type ) ) {
320
+        if (!empty($current_screen->post_type)) {
321 321
 			$page = $current_screen->post_type;
322 322
         }
323 323
 
324
-        if ( false !== stripos( $page, 'wpi' ) ) {
325
-            $classes .= ' wpi-' . sanitize_key( $page );
324
+        if (false !== stripos($page, 'wpi')) {
325
+            $classes .= ' wpi-' . sanitize_key($page);
326 326
         }
327 327
 
328
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
328
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
329 329
             $classes .= ' wpinv-cpt wpinv';
330 330
 		}
331 331
 		
332
-		if ( getpaid_is_invoice_post_type( $page ) ) {
332
+		if (getpaid_is_invoice_post_type($page)) {
333 333
             $classes .= ' getpaid-is-invoice-cpt';
334 334
         }
335 335
 
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
     /**
340 340
 	 * Maybe show the AyeCode Connect Notice.
341 341
 	 */
342
-	public function init_ayecode_connect_helper(){
342
+	public function init_ayecode_connect_helper() {
343 343
 
344 344
 		// Register with the deactivation survey class.
345 345
 		AyeCode_Deactivation_Survey::instance(array(
@@ -347,20 +347,20 @@  discard block
 block discarded – undo
347 347
 			'version'	        => WPINV_VERSION,
348 348
 			'support_url'       => 'https://wpgetpaid.com/support/',
349 349
 			'documentation_url' => 'https://docs.wpgetpaid.com/',
350
-			'activated'         => (int) get_option( 'gepaid_installed_on' ),
350
+			'activated'         => (int) get_option('gepaid_installed_on'),
351 351
 		));
352 352
 
353 353
         new AyeCode_Connect_Helper(
354 354
             array(
355
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
356
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
357
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
358
-				'connect_button'    => __("Connect Site","invoicing"),
359
-				'connecting_button'    => __("Connecting...","invoicing"),
360
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
361
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
355
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
356
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
357
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
358
+				'connect_button'    => __("Connect Site", "invoicing"),
359
+				'connecting_button'    => __("Connecting...", "invoicing"),
360
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
361
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
362 362
             ),
363
-            array( 'wpi-addons' )
363
+            array('wpi-addons')
364 364
         );
365 365
 
366 366
     }
@@ -372,20 +372,20 @@  discard block
 block discarded – undo
372 372
 	 */
373 373
 	public function activation_redirect() {
374 374
 
375
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
375
+		$redirected = get_option('wpinv_redirected_to_settings');
376 376
 
377
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
377
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
378 378
 			return;
379 379
 		}
380 380
 
381 381
 		// Bail if activating from network, or bulk
382
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
382
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
383 383
 			return;
384 384
 		}
385 385
 
386
-	    update_option( 'wpinv_redirected_to_settings', 1 );
386
+	    update_option('wpinv_redirected_to_settings', 1);
387 387
 
388
-        wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
388
+        wp_safe_redirect(admin_url('index.php?page=gp-setup'));
389 389
         exit;
390 390
 
391 391
 	}
@@ -395,9 +395,9 @@  discard block
 block discarded – undo
395 395
      */
396 396
     public function maybe_do_admin_action() {
397 397
 
398
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
399
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
400
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
398
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
399
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
400
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
401 401
         }
402 402
 
403 403
     }
@@ -407,34 +407,34 @@  discard block
 block discarded – undo
407 407
 	 * 
408 408
 	 * @param array $args
409 409
      */
410
-    public function duplicate_payment_form( $args ) {
410
+    public function duplicate_payment_form($args) {
411 411
 
412
-		if ( empty( $args['form_id'] ) ) {
412
+		if (empty($args['form_id'])) {
413 413
 			return;
414 414
 		}
415 415
 
416
-		$form = new GetPaid_Payment_Form( $args['form_id'] );
416
+		$form = new GetPaid_Payment_Form($args['form_id']);
417 417
 
418
-		if ( ! $form->exists() ) {
418
+		if (!$form->exists()) {
419 419
 			return;
420 420
 		}
421 421
 
422 422
 		$new_form = new GetPaid_Payment_Form();
423
-		$new_form->set_author( $form->get_author( 'edit' ) );
424
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
425
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
426
-		$new_form->set_items( $form->get_items( 'edit' ) );
423
+		$new_form->set_author($form->get_author('edit'));
424
+		$new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing'));
425
+		$new_form->set_elements($form->get_elements('edit'));
426
+		$new_form->set_items($form->get_items('edit'));
427 427
 		$new_form->save();
428 428
 
429
-		if ( $new_form->exists() ) {
430
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
431
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
429
+		if ($new_form->exists()) {
430
+			$this->show_success(__('Form duplicated successfully', 'invoicing'));
431
+			$url = get_edit_post_link($new_form->get_id(), 'edit');
432 432
 		} else {
433
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
434
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
433
+			$this->show_error(__('Unable to duplicate form', 'invoicing'));
434
+			$url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce'));
435 435
 		}
436 436
 
437
-		wp_redirect( $url );
437
+		wp_redirect($url);
438 438
 		exit;
439 439
 	}
440 440
 
@@ -443,16 +443,16 @@  discard block
 block discarded – undo
443 443
 	 * 
444 444
 	 * @param array $args
445 445
      */
446
-    public function send_customer_invoice( $args ) {
447
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
446
+    public function send_customer_invoice($args) {
447
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true);
448 448
 
449
-		if ( $sent ) {
450
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
449
+		if ($sent) {
450
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
451 451
 		} else {
452
-			$this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
452
+			$this->show_error(__('Could not send the invoice to the customer', 'invoicing'));
453 453
 		}
454 454
 
455
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
455
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
456 456
 		exit;
457 457
 	}
458 458
 
@@ -461,16 +461,16 @@  discard block
 block discarded – undo
461 461
 	 * 
462 462
 	 * @param array $args
463 463
      */
464
-    public function send_customer_payment_reminder( $args ) {
465
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
464
+    public function send_customer_payment_reminder($args) {
465
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
466 466
 
467
-		if ( $sent ) {
468
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
467
+		if ($sent) {
468
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
469 469
 		} else {
470
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
470
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
471 471
 		}
472 472
 
473
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
473
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
474 474
 		exit;
475 475
 	}
476 476
 
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
      */
481 481
     public function admin_reset_tax_rates() {
482 482
 
483
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
484
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
483
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
484
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
485 485
 		exit;
486 486
 
487 487
 	}
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
     public function admin_create_missing_pages() {
494 494
 		$installer = new GetPaid_Installer();
495 495
 		$installer->create_pages();
496
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
497
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
496
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
497
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
498 498
 		exit;
499 499
 	}
500 500
 
@@ -506,35 +506,35 @@  discard block
 block discarded – undo
506 506
 		global $wpdb;
507 507
 		$installer = new GetPaid_Installer();
508 508
 
509
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
509
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') {
510 510
 			$installer->create_subscriptions_table();
511 511
 
512
-			if ( $wpdb->last_error !== '' ) {
513
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
512
+			if ($wpdb->last_error !== '') {
513
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
514 514
 			}
515 515
 		}
516 516
 
517
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
517
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') {
518 518
 			$installer->create_invoices_table();
519 519
 
520
-			if ( $wpdb->last_error !== '' ) {
521
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
520
+			if ($wpdb->last_error !== '') {
521
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
522 522
 			}
523 523
 		}
524 524
 
525
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
525
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') {
526 526
 			$installer->create_invoice_items_table();
527 527
 
528
-			if ( $wpdb->last_error !== '' ) {
529
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
528
+			if ($wpdb->last_error !== '') {
529
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
530 530
 			}
531 531
 		}
532 532
 
533
-		if ( ! $this->has_notices() ) {
534
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
533
+		if (!$this->has_notices()) {
534
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
535 535
 		}
536 536
 
537
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
537
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
538 538
 		exit;
539 539
 	}
540 540
 
@@ -549,10 +549,10 @@  discard block
 block discarded – undo
549 549
 		$installer->migrate_old_invoices();
550 550
 
551 551
 		// Show an admin message.
552
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
552
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
553 553
 
554 554
 		// Redirect the admin.
555
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
555
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
556 556
 		exit;
557 557
 
558 558
 	}
@@ -564,18 +564,18 @@  discard block
 block discarded – undo
564 564
     public function admin_download_customers() {
565 565
 		global $wpdb;
566 566
 
567
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
567
+		$output = fopen('php://output', 'w') or die(__('Unsupported server', 'invoicing'));
568 568
 
569
-		header( "Content-Type:text/csv" );
570
-		header( "Content-Disposition:attachment;filename=customers.csv" );
569
+		header("Content-Type:text/csv");
570
+		header("Content-Disposition:attachment;filename=customers.csv");
571 571
 
572 572
 		$post_types = '';
573 573
 
574
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
575
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
574
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
575
+			$post_types .= $wpdb->prepare("post_type=%s OR ", $post_type);
576 576
 		}
577 577
 
578
-		$post_types = rtrim( $post_types, ' OR' );
578
+		$post_types = rtrim($post_types, ' OR');
579 579
 
580 580
 		$customers = $wpdb->get_col(
581 581
 			$wpdb->prepare(
@@ -584,58 +584,58 @@  discard block
 block discarded – undo
584 584
 		);
585 585
 
586 586
 		$columns = array(
587
-			'name'     => __( 'Name', 'invoicing' ),
588
-			'email'    => __( 'Email', 'invoicing' ),
589
-			'country'  => __( 'Country', 'invoicing' ),
590
-			'state'    => __( 'State', 'invoicing' ),
591
-			'city'     => __( 'City', 'invoicing' ),
592
-			'zip'      => __( 'ZIP', 'invoicing' ),
593
-			'address'  => __( 'Address', 'invoicing' ),
594
-			'phone'    => __( 'Phone', 'invoicing' ),
595
-			'company'  => __( 'Company', 'invoicing' ),
596
-			'company_id'  => __( 'Company ID', 'invoicing' ),
597
-			'invoices' => __( 'Invoices', 'invoicing' ),
598
-			'total_raw' => __( 'Total Spend', 'invoicing' ),
599
-			'signup'   => __( 'Date created', 'invoicing' ),
587
+			'name'     => __('Name', 'invoicing'),
588
+			'email'    => __('Email', 'invoicing'),
589
+			'country'  => __('Country', 'invoicing'),
590
+			'state'    => __('State', 'invoicing'),
591
+			'city'     => __('City', 'invoicing'),
592
+			'zip'      => __('ZIP', 'invoicing'),
593
+			'address'  => __('Address', 'invoicing'),
594
+			'phone'    => __('Phone', 'invoicing'),
595
+			'company'  => __('Company', 'invoicing'),
596
+			'company_id'  => __('Company ID', 'invoicing'),
597
+			'invoices' => __('Invoices', 'invoicing'),
598
+			'total_raw' => __('Total Spend', 'invoicing'),
599
+			'signup'   => __('Date created', 'invoicing'),
600 600
 		);
601 601
 
602 602
 		// Output the csv column headers.
603
-		fputcsv( $output, array_values( $columns ) );
603
+		fputcsv($output, array_values($columns));
604 604
 
605 605
 		// Loop through
606 606
 		$table = new WPInv_Customers_Table();
607
-		foreach ( $customers as $customer_id ) {
607
+		foreach ($customers as $customer_id) {
608 608
 
609
-			$user = get_user_by( 'id', $customer_id );
609
+			$user = get_user_by('id', $customer_id);
610 610
 			$row  = array();
611
-			if ( empty( $user ) ) {
611
+			if (empty($user)) {
612 612
 				continue;
613 613
 			}
614 614
 
615
-			foreach ( array_keys( $columns ) as $column ) {
615
+			foreach (array_keys($columns) as $column) {
616 616
 
617 617
 				$method = 'column_' . $column;
618 618
 
619
-				if ( 'name' == $column ) {
620
-					$value = esc_html( $user->display_name );
621
-				} else if( 'email' == $column ) {
622
-					$value = sanitize_email( $user->user_email );
623
-				} else if ( is_callable( array( $table, $method ) ) ) {
624
-					$value = strip_tags( $table->$method( $user ) );
619
+				if ('name' == $column) {
620
+					$value = esc_html($user->display_name);
621
+				} else if ('email' == $column) {
622
+					$value = sanitize_email($user->user_email);
623
+				} else if (is_callable(array($table, $method))) {
624
+					$value = strip_tags($table->$method($user));
625 625
 				}
626 626
 
627
-				if ( empty( $value ) ) {
628
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
627
+				if (empty($value)) {
628
+					$value = esc_html(get_user_meta($user->ID, '_wpinv_' . $column, true));
629 629
 				}
630 630
 
631 631
 				$row[] = $value;
632 632
 
633 633
 			}
634 634
 
635
-			fputcsv( $output, $row );
635
+			fputcsv($output, $row);
636 636
 		}
637 637
 
638
-		fclose( $output );
638
+		fclose($output);
639 639
 		exit;
640 640
 
641 641
 	}
@@ -645,29 +645,29 @@  discard block
 block discarded – undo
645 645
 	 *
646 646
 	 * @param array $data
647 647
      */
648
-    public function admin_install_plugin( $data ) {
648
+    public function admin_install_plugin($data) {
649 649
 
650
-		if ( ! empty( $data['plugins'] ) ) {
650
+		if (!empty($data['plugins'])) {
651 651
 			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
652 652
 			wp_cache_flush();
653 653
 
654
-			foreach ( $data['plugins'] as $slug => $file ) {
655
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
656
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
657
-				$installed  = $upgrader->install( $plugin_zip );
654
+			foreach ($data['plugins'] as $slug => $file) {
655
+				$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip');
656
+				$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
657
+				$installed  = $upgrader->install($plugin_zip);
658 658
 
659
-				if ( ! is_wp_error( $installed ) && $installed ) {
660
-					activate_plugin( $file, '', false, true );
659
+				if (!is_wp_error($installed) && $installed) {
660
+					activate_plugin($file, '', false, true);
661 661
 				} else {
662
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
662
+					wpinv_error_log($upgrader->skin->get_upgrade_messages(), false);
663 663
 				}
664 664
 
665 665
 			}
666 666
 
667 667
 		}
668 668
 
669
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
670
-		wp_safe_redirect( $redirect );
669
+		$redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php');
670
+		wp_safe_redirect($redirect);
671 671
 		exit;
672 672
 
673 673
 	}
@@ -677,42 +677,42 @@  discard block
 block discarded – undo
677 677
 	 *
678 678
 	 * @param array $data
679 679
      */
680
-    public function admin_connect_gateway( $data ) {
680
+    public function admin_connect_gateway($data) {
681 681
 
682
-		if ( ! empty( $data['plugin'] ) ) {
682
+		if (!empty($data['plugin'])) {
683 683
 
684
-			$gateway     = sanitize_key( $data['plugin'] );
685
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
684
+			$gateway     = sanitize_key($data['plugin']);
685
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
686 686
 
687
-			if ( ! empty( $connect_url ) ) {
688
-				wp_redirect( $connect_url );
687
+			if (!empty($connect_url)) {
688
+				wp_redirect($connect_url);
689 689
 				exit;
690 690
 			}
691 691
 
692
-			if ( 'stripe' == $data['plugin'] ) {
692
+			if ('stripe' == $data['plugin']) {
693 693
 				require_once ABSPATH . 'wp-admin/includes/plugin.php';
694 694
 				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
695 695
 				wp_cache_flush();
696 696
 
697
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
698
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
699
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
700
-					$upgrader->install( $plugin_zip );
697
+				if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) {
698
+					$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip');
699
+					$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
700
+					$upgrader->install($plugin_zip);
701 701
 				}
702 702
 
703
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
703
+				activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true);
704 704
 			}
705 705
 
706
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
707
-			if ( ! empty( $connect_url ) ) {
708
-				wp_redirect( $connect_url );
706
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
707
+			if (!empty($connect_url)) {
708
+				wp_redirect($connect_url);
709 709
 				exit;
710 710
 			}
711 711
 
712 712
 		}
713 713
 
714
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
715
-		wp_safe_redirect( $redirect );
714
+		$redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways');
715
+		wp_safe_redirect($redirect);
716 716
 		exit;
717 717
 
718 718
 	}
@@ -726,36 +726,36 @@  discard block
 block discarded – undo
726 726
 
727 727
 		// Fetch all invoices that have discount codes.
728 728
 		$table    = $wpdb->prefix . 'getpaid_invoices';
729
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
729
+		$invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''");
730 730
 
731
-		foreach ( $invoices as $invoice ) {
731
+		foreach ($invoices as $invoice) {
732 732
 
733
-			$invoice = new WPInv_Invoice( $invoice );
733
+			$invoice = new WPInv_Invoice($invoice);
734 734
 
735
-			if ( ! $invoice->exists() ) {
735
+			if (!$invoice->exists()) {
736 736
 				continue;
737 737
 			}
738 738
 
739 739
 			// Abort if the discount does not exist or does not apply here.
740
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
741
-			if ( ! $discount->exists() ) {
740
+			$discount = new WPInv_Discount($invoice->get_discount_code());
741
+			if (!$discount->exists()) {
742 742
 				continue;
743 743
 			}
744 744
 
745
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
745
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
746 746
 			$invoice->recalculate_total();
747 747
 
748
-			if ( $invoice->get_total_discount() > 0 ) {
748
+			if ($invoice->get_total_discount() > 0) {
749 749
 				$invoice->save();
750 750
 			}
751 751
 
752 752
 		}
753 753
 
754 754
 		// Show an admin message.
755
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
755
+		$this->show_success(__('Discounts have been recalculated.', 'invoicing'));
756 756
 
757 757
 		// Redirect the admin.
758
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
758
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
759 759
 		exit;
760 760
 
761 761
 	}
@@ -767,8 +767,8 @@  discard block
 block discarded – undo
767 767
      * @return array
768 768
 	 */
769 769
 	public function get_notices() {
770
-		$notices = get_option( 'wpinv_admin_notices' );
771
-        return is_array( $notices ) ? $notices : array();
770
+		$notices = get_option('wpinv_admin_notices');
771
+        return is_array($notices) ? $notices : array();
772 772
 	}
773 773
 
774 774
 	/**
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
      * @return array
779 779
 	 */
780 780
 	public function has_notices() {
781
-		return count( $this->get_notices() ) > 0;
781
+		return count($this->get_notices()) > 0;
782 782
 	}
783 783
 
784 784
 	/**
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 	 * @since       1.0.19
789 789
 	 */
790 790
 	public function clear_notices() {
791
-		delete_option( 'wpinv_admin_notices' );
791
+		delete_option('wpinv_admin_notices');
792 792
 	}
793 793
 
794 794
 	/**
@@ -797,16 +797,16 @@  discard block
 block discarded – undo
797 797
 	 * @access      public
798 798
 	 * @since       1.0.19
799 799
 	 */
800
-	public function save_notice( $type, $message ) {
800
+	public function save_notice($type, $message) {
801 801
 		$notices = $this->get_notices();
802 802
 
803
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
804
-			$notices[ $type ] = array();
803
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
804
+			$notices[$type] = array();
805 805
 		}
806 806
 
807
-		$notices[ $type ][] = $message;
807
+		$notices[$type][] = $message;
808 808
 
809
-		update_option( 'wpinv_admin_notices', $notices );
809
+		update_option('wpinv_admin_notices', $notices);
810 810
 	}
811 811
 
812 812
 	/**
@@ -816,8 +816,8 @@  discard block
 block discarded – undo
816 816
 	 * @access      public
817 817
 	 * @since       1.0.19
818 818
 	 */
819
-	public function show_success( $msg ) {
820
-		$this->save_notice( 'success', $msg );
819
+	public function show_success($msg) {
820
+		$this->save_notice('success', $msg);
821 821
 	}
822 822
 
823 823
 	/**
@@ -827,8 +827,8 @@  discard block
 block discarded – undo
827 827
 	 * @param       string $msg The message to qeue.
828 828
 	 * @since       1.0.19
829 829
 	 */
830
-	public function show_error( $msg ) {
831
-		$this->save_notice( 'error', $msg );
830
+	public function show_error($msg) {
831
+		$this->save_notice('error', $msg);
832 832
 	}
833 833
 
834 834
 	/**
@@ -838,8 +838,8 @@  discard block
 block discarded – undo
838 838
 	 * @param       string $msg The message to qeue.
839 839
 	 * @since       1.0.19
840 840
 	 */
841
-	public function show_warning( $msg ) {
842
-		$this->save_notice( 'warning', $msg );
841
+	public function show_warning($msg) {
842
+		$this->save_notice('warning', $msg);
843 843
 	}
844 844
 
845 845
 	/**
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	 * @param       string $msg The message to qeue.
850 850
 	 * @since       1.0.19
851 851
 	 */
852
-	public function show_info( $msg ) {
853
-		$this->save_notice( 'info', $msg );
852
+	public function show_info($msg) {
853
+		$this->save_notice('info', $msg);
854 854
 	}
855 855
 
856 856
 	/**
@@ -864,30 +864,30 @@  discard block
 block discarded – undo
864 864
         $notices = $this->get_notices();
865 865
         $this->clear_notices();
866 866
 
867
-		foreach ( $notices as $type => $messages ) {
867
+		foreach ($notices as $type => $messages) {
868 868
 
869
-			if ( ! is_array( $messages ) ) {
869
+			if (!is_array($messages)) {
870 870
 				continue;
871 871
 			}
872 872
 
873
-            $type  = sanitize_key( $type );
874
-			foreach ( $messages as $message ) {
875
-                $message = wp_kses_post( $message );
873
+            $type = sanitize_key($type);
874
+			foreach ($messages as $message) {
875
+                $message = wp_kses_post($message);
876 876
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
877 877
             }
878 878
 
879 879
         }
880 880
 
881
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
881
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
882 882
 
883
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
884
-				$url     = wp_nonce_url(
885
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
883
+			if (!is_numeric(wpinv_get_option($page, false))) {
884
+				$url = wp_nonce_url(
885
+					add_query_arg('getpaid-admin-action', 'create_missing_pages'),
886 886
 					'getpaid-nonce',
887 887
 					'getpaid-nonce'
888 888
 				);
889
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
890
-				$message2 = __( 'Generate Pages', 'invoicing' );
889
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
890
+				$message2 = __('Generate Pages', 'invoicing');
891 891
 				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
892 892
 				break;
893 893
 			}
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-info.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,20 +21,20 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         ?>
30 30
 
31 31
         <div class='bsui' style='padding-top: 10px;'>
32
-            <?php do_action( 'wpinv_item_before_info_metabox', $item ); ?>
32
+            <?php do_action('wpinv_item_before_info_metabox', $item); ?>
33 33
 
34 34
             <div class="wpinv_item_type form-group row">
35 35
                 <label for="wpinv_item_type" class="col-sm-12 col-form-label">
36
-                    <?php _e( 'Item Type', 'invoicing' );?>
37
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo strip_tags( self::get_tooltip( $post ) ); ?>"></span>
36
+                    <?php _e('Item Type', 'invoicing'); ?>
37
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo strip_tags(self::get_tooltip($post)); ?>"></span>
38 38
                 </label>
39 39
 
40 40
                 <div class="col-sm-12">
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
                             array(
45 45
                                 'id'               => 'wpinv_item_type',
46 46
                                 'name'             => 'wpinv_item_type',
47
-                                'placeholder'      => __( 'Select item type', 'invoicing' ),
48
-                                'value'            => $item->get_type( 'edit' ),
47
+                                'placeholder'      => __('Select item type', 'invoicing'),
48
+                                'value'            => $item->get_type('edit'),
49 49
                                 'select2'          => true,
50 50
                                 'data-allow-clear' => 'false',
51 51
                                 'no_wrap'          => true,
@@ -59,42 +59,42 @@  discard block
 block discarded – undo
59 59
 
60 60
             <div class="wpinv_item_shortcode form-group row">
61 61
                 <label for="wpinv_item_shortcode" class="col-sm-12 col-form-label">
62
-                    <?php _e( 'Payment Form Shortcode', 'invoicing' );?>
63
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span>
62
+                    <?php _e('Payment Form Shortcode', 'invoicing'); ?>
63
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span>
64 64
                 </label>
65 65
 
66 66
                 <div class="col-sm-12">
67
-                    <input  onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?>]" style="width: 100%;" readonly/>
67
+                    <input  onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?>]" style="width: 100%;" readonly/>
68 68
                 </div>
69 69
             </div>
70 70
 
71 71
             <div class="wpinv_item_buy_shortcode form-group row">
72 72
                 <label for="wpinv_item_button_shortcode" class="col-sm-12 col-form-label">
73
-                    <?php _e( 'Payment Button Shortcode', 'invoicing' );?>
74
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span>
73
+                    <?php _e('Payment Button Shortcode', 'invoicing'); ?>
74
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span>
75 75
                 </label>
76 76
 
77 77
                 <div class="col-sm-12">
78
-                    <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?> button='Buy Now']" style="width: 100%;" readonly/>
78
+                    <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?> button='Buy Now']" style="width: 100%;" readonly/>
79 79
                     <small class="form-text text-muted">
80
-                        <?php _e( 'Or use the following URL in a link:', 'invoicing' );?>
81
-                        <code>#getpaid-item-<?php echo intval( $item->get_id() ); ?>|0</code>
80
+                        <?php _e('Or use the following URL in a link:', 'invoicing'); ?>
81
+                        <code>#getpaid-item-<?php echo intval($item->get_id()); ?>|0</code>
82 82
                     </small>
83 83
                 </div>
84 84
             </div>
85 85
 
86 86
             <div class="wpinv_item_custom_id form-group">
87
-                <?php _e( 'Custom ID', 'invoicing' );?> &mdash; <?php echo esc_html( $item->get_custom_id() ) ?>
87
+                <?php _e('Custom ID', 'invoicing'); ?> &mdash; <?php echo esc_html($item->get_custom_id()) ?>
88 88
             </div>
89 89
 
90
-            <?php do_action( 'wpinv_meta_values_metabox_before', $post ); ?>
91
-            <?php foreach ( apply_filters( 'wpinv_show_meta_values_for_keys', array() ) as $meta_key ) : ?>
90
+            <?php do_action('wpinv_meta_values_metabox_before', $post); ?>
91
+            <?php foreach (apply_filters('wpinv_show_meta_values_for_keys', array()) as $meta_key) : ?>
92 92
                 <div class="wpinv_item_custom_id form-group">
93
-                    <?php echo esc_html( $meta_key );?> &mdash; <?php echo esc_html( get_post_meta( $item->get_id(), '_wpinv_' . $meta_key, true ) ); ?>
93
+                    <?php echo esc_html($meta_key); ?> &mdash; <?php echo esc_html(get_post_meta($item->get_id(), '_wpinv_' . $meta_key, true)); ?>
94 94
                 </div>
95 95
             <?php endforeach; ?>
96
-            <?php do_action( 'wpinv_meta_values_metabox_after', $post ); ?>
97
-            <?php do_action( 'wpinv_item_info_metabox', $item ); ?>
96
+            <?php do_action('wpinv_meta_values_metabox_after', $post); ?>
97
+            <?php do_action('wpinv_item_info_metabox', $item); ?>
98 98
         </div>
99 99
         <?php
100 100
 
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
 	 * Returns item type tolltip.
105 105
 	 *
106 106
 	 */
107
-    public static function get_tooltip( $post ) {
107
+    public static function get_tooltip($post) {
108 108
 
109 109
         ob_start();
110 110
         ?>
111 111
 
112
-        <?php _e( 'Standard: Standard item type', 'invoicing' );?>
113
-        <?php _e( 'Fee: Like Registration Fee, Sign up Fee etc', 'invoicing' );?>
112
+        <?php _e('Standard: Standard item type', 'invoicing'); ?>
113
+        <?php _e('Fee: Like Registration Fee, Sign up Fee etc', 'invoicing'); ?>
114 114
 
115 115
         <?php
116
-        do_action( 'wpinv_item_info_metabox_after', $post );
116
+        do_action('wpinv_item_info_metabox_after', $post);
117 117
 
118 118
         return ob_get_clean();
119 119
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 1 patch
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice  = new WPInv_Invoice( $post );
28
-        $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id();
29
-        $customer = new WP_User( $customer );
30
-        $display  = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email );
31
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
27
+        $invoice  = new WPInv_Invoice($post);
28
+        $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id();
29
+        $customer = new WP_User($customer);
30
+        $display  = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email);
31
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
32 32
 
33 33
         ?>
34 34
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
                         <div class="col-12 col-sm-6">
44 44
                             <div id="getpaid-invoice-user-id-wrapper" class="form-group">
45 45
                                 <div>
46
-                                    <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label>
46
+                                    <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label>
47 47
                                 </div>
48 48
                                 <div>
49
-                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>">
50
-                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html( $display ); ?> </option>)
49
+                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>">
50
+                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html($display); ?> </option>)
51 51
                                     </select>
52 52
                                 </div>
53 53
                             </div>
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                                             'type'        => 'text',
61 61
                                             'id'          => 'getpaid-invoice-new-user-email',
62 62
                                             'name'        => 'wpinv_email',
63
-                                            'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
63
+                                            'label'       => __('Email', 'invoicing') . '<span class="required">*</span>',
64 64
                                             'label_type'  => 'vertical',
65 65
                                             'placeholder' => '[email protected]',
66 66
                                             'class'       => 'form-control-sm',
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
                             </div>
71 71
                         </div>
72 72
                         <div class="col-12 col-sm-6 form-group mt-sm-4">
73
-                            <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
73
+                            <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
74 74
                                 <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)">
75 75
                                     <i aria-hidden="true" class="fa fa-refresh"></i>
76
-                                    <?php _e( 'Fill User Details', 'invoicing' );?>
76
+                                    <?php _e('Fill User Details', 'invoicing'); ?>
77 77
                                 </a>
78 78
                                 <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)">
79 79
                                     <i aria-hidden="true" class="fa fa-plus"></i>
80
-                                    <?php _e( 'Add New User', 'invoicing' );?>
80
+                                    <?php _e('Add New User', 'invoicing'); ?>
81 81
                                 </a>
82 82
                                 <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)">
83 83
                                     <i aria-hidden="true" class="fa fa-close"></i>
84
-                                    <?php _e( 'Cancel', 'invoicing' );?>
84
+                                    <?php _e('Cancel', 'invoicing'); ?>
85 85
                                 </a>
86 86
                             <?php endif; ?>
87 87
                         </div>
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
                                         'type'        => 'text',
95 95
                                         'id'          => 'wpinv_first_name',
96 96
                                         'name'        => 'wpinv_first_name',
97
-                                        'label'       => __( 'First Name', 'invoicing' ),
97
+                                        'label'       => __('First Name', 'invoicing'),
98 98
                                         'label_type'  => 'vertical',
99 99
                                         'placeholder' => '',
100 100
                                         'class'       => 'form-control-sm',
101
-                                        'value'       => $invoice->get_first_name( 'edit' ),
101
+                                        'value'       => $invoice->get_first_name('edit'),
102 102
                                     )
103 103
                                 );
104 104
                             ?>
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
                                         'type'        => 'text',
111 111
                                         'id'          => 'wpinv_last_name',
112 112
                                         'name'        => 'wpinv_last_name',
113
-                                        'label'       => __( 'Last Name', 'invoicing' ),
113
+                                        'label'       => __('Last Name', 'invoicing'),
114 114
                                         'label_type'  => 'vertical',
115 115
                                         'placeholder' => '',
116 116
                                         'class'       => 'form-control-sm',
117
-                                        'value'       => $invoice->get_last_name( 'edit' ),
117
+                                        'value'       => $invoice->get_last_name('edit'),
118 118
                                     )
119 119
                                 );
120 120
                             ?>
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
                                         'type'        => 'text',
130 130
                                         'id'          => 'wpinv_company',
131 131
                                         'name'        => 'wpinv_company',
132
-                                        'label'       => __( 'Company', 'invoicing' ),
132
+                                        'label'       => __('Company', 'invoicing'),
133 133
                                         'label_type'  => 'vertical',
134 134
                                         'placeholder' => '',
135 135
                                         'class'       => 'form-control-sm',
136
-                                        'value'       => $invoice->get_company( 'edit' ),
136
+                                        'value'       => $invoice->get_company('edit'),
137 137
                                     )
138 138
                                 );
139 139
                             ?>
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
                                         'type'        => 'text',
146 146
                                         'id'          => 'wpinv_vat_number',
147 147
                                         'name'        => 'wpinv_vat_number',
148
-                                        'label'       => __( 'Vat Number', 'invoicing' ),
148
+                                        'label'       => __('Vat Number', 'invoicing'),
149 149
                                         'label_type'  => 'vertical',
150 150
                                         'placeholder' => '',
151 151
                                         'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
152
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
152
+                                        'value'       => $invoice->get_vat_number('edit'),
153 153
                                     )
154 154
                                 );
155 155
                             ?>
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
                                         'type'        => 'text',
165 165
                                         'id'          => 'wpinv_address',
166 166
                                         'name'        => 'wpinv_address',
167
-                                        'label'       => __( 'Address', 'invoicing' ),
167
+                                        'label'       => __('Address', 'invoicing'),
168 168
                                         'label_type'  => 'vertical',
169 169
                                         'placeholder' => '',
170 170
                                         'class'       => 'form-control-sm',
171
-                                        'value'       => $invoice->get_address( 'edit' ),
171
+                                        'value'       => $invoice->get_address('edit'),
172 172
                                     )
173 173
                                 );
174 174
                             ?>
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
                                         'type'        => 'text',
181 181
                                         'id'          => 'wpinv_city',
182 182
                                         'name'        => 'wpinv_city',
183
-                                        'label'       => __( 'City', 'invoicing' ),
183
+                                        'label'       => __('City', 'invoicing'),
184 184
                                         'label_type'  => 'vertical',
185 185
                                         'placeholder' => '',
186 186
                                         'class'       => 'form-control-sm',
187
-                                        'value'       => $invoice->get_city( 'edit' ),
187
+                                        'value'       => $invoice->get_city('edit'),
188 188
                                     )
189 189
                                 );
190 190
                             ?>
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
                                     array(
199 199
                                         'id'          => 'wpinv_country',
200 200
                                         'name'        => 'wpinv_country',
201
-                                        'label'       => __( 'Country', 'invoicing' ),
201
+                                        'label'       => __('Country', 'invoicing'),
202 202
                                         'label_type'  => 'vertical',
203
-                                        'placeholder' => __( 'Choose a country', 'invoicing' ),
203
+                                        'placeholder' => __('Choose a country', 'invoicing'),
204 204
                                         'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
205
-                                        'value'       => $invoice->get_country( 'edit' ),
205
+                                        'value'       => $invoice->get_country('edit'),
206 206
                                         'options'     => wpinv_get_country_list(),
207 207
                                         'data-allow-clear' => 'false',
208 208
                                         'select2'          => true,
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
                         <div class="col-12 col-sm-6">
214 214
                             <?php
215 215
 
216
-                                $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
216
+                                $states = wpinv_get_country_states($invoice->get_country('edit'));
217 217
 
218
-                                if ( empty( $states ) ) {
218
+                                if (empty($states)) {
219 219
 
220 220
                                     echo aui()->input(
221 221
                                         array(
222 222
                                             'type'        => 'text',
223 223
                                             'id'          => 'wpinv_state',
224 224
                                             'name'        => 'wpinv_state',
225
-                                            'label'       => __( 'State', 'invoicing' ),
225
+                                            'label'       => __('State', 'invoicing'),
226 226
                                             'label_type'  => 'vertical',
227 227
                                             'placeholder' => '',
228 228
                                             'class'       => 'form-control-sm',
229
-                                            'value'       => $invoice->get_state( 'edit' ),
229
+                                            'value'       => $invoice->get_state('edit'),
230 230
                                         )
231 231
                                     );
232 232
 
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
                                         array(
237 237
                                             'id'          => 'wpinv_state',
238 238
                                             'name'        => 'wpinv_state',
239
-                                            'label'       => __( 'State', 'invoicing' ),
239
+                                            'label'       => __('State', 'invoicing'),
240 240
                                             'label_type'  => 'vertical',
241
-                                            'placeholder' => __( 'Select a state', 'invoicing' ),
241
+                                            'placeholder' => __('Select a state', 'invoicing'),
242 242
                                             'class'       => 'form-control-sm',
243
-                                            'value'       => $invoice->get_state( 'edit' ),
243
+                                            'value'       => $invoice->get_state('edit'),
244 244
                                             'options'     => $states,
245 245
                                             'data-allow-clear' => 'false',
246 246
                                             'select2'          => true,
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
                                         'type'        => 'text',
262 262
                                         'id'          => 'wpinv_zip',
263 263
                                         'name'        => 'wpinv_zip',
264
-                                        'label'       => __( 'Zip / Postal Code', 'invoicing' ),
264
+                                        'label'       => __('Zip / Postal Code', 'invoicing'),
265 265
                                         'label_type'  => 'vertical',
266 266
                                         'placeholder' => '',
267 267
                                         'class'       => 'form-control-sm',
268
-                                        'value'       => $invoice->get_zip( 'edit' ),
268
+                                        'value'       => $invoice->get_zip('edit'),
269 269
                                     )
270 270
                                 );
271 271
                             ?>
@@ -277,19 +277,19 @@  discard block
 block discarded – undo
277 277
                                         'type'        => 'text',
278 278
                                         'id'          => 'wpinv_phone',
279 279
                                         'name'        => 'wpinv_phone',
280
-                                        'label'       => __( 'Phone', 'invoicing' ),
280
+                                        'label'       => __('Phone', 'invoicing'),
281 281
                                         'label_type'  => 'vertical',
282 282
                                         'placeholder' => '',
283 283
                                         'class'       => 'form-control-sm',
284
-                                        'value'       => $invoice->get_phone( 'edit' ),
284
+                                        'value'       => $invoice->get_phone('edit'),
285 285
                                     )
286 286
                                 );
287 287
                             ?>
288 288
                         </div>
289 289
                     </div>
290 290
 
291
-                    <?php if ( ! apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) : ?>
292
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
291
+                    <?php if (!apply_filters('getpaid_use_new_invoice_items_metabox', false)) : ?>
292
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
293 293
 
294 294
                         <div class="row">
295 295
                             <div class="col-12 col-sm-6">
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
                                         array(
299 299
                                             'id'          => 'wpinv_template',
300 300
                                             'name'        => 'wpinv_template',
301
-                                            'label'       => __( 'Template', 'invoicing' ),
301
+                                            'label'       => __('Template', 'invoicing'),
302 302
                                             'label_type'  => 'vertical',
303
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
303
+                                            'placeholder' => __('Choose a template', 'invoicing'),
304 304
                                             'class'       => 'form-control-sm',
305
-                                            'value'       => $invoice->get_template( 'edit' ),
305
+                                            'value'       => $invoice->get_template('edit'),
306 306
                                             'options'     => array(
307
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
308
-                                                'hours'    => __( 'Hours', 'invoicing' ),
307
+                                                'quantity' => __('Quantity', 'invoicing'),
308
+                                                'hours'    => __('Hours', 'invoicing'),
309 309
                                                 //'amount'   => __( 'Amount Only', 'invoicing' ),
310 310
                                             ),
311 311
                                             'data-allow-clear' => 'false',
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
                                         array(
323 323
                                             'id'          => 'wpinv_currency',
324 324
                                             'name'        => 'wpinv_currency',
325
-                                            'label'       => __( 'Currency', 'invoicing' ),
325
+                                            'label'       => __('Currency', 'invoicing'),
326 326
                                             'label_type'  => 'vertical',
327
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
327
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
328 328
                                             'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
329
-                                            'value'       => $invoice->get_currency( 'edit' ),
329
+                                            'value'       => $invoice->get_currency('edit'),
330 330
                                             'required'    => false,
331 331
                                             'data-allow-clear' => 'false',
332 332
                                             'select2'          => true,
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
                             </div>
339 339
                         </div>
340 340
 
341
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
341
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
342 342
                     <?php endif; ?>
343 343
 
344 344
                     <div class="row">
@@ -349,18 +349,18 @@  discard block
 block discarded – undo
349 349
                                         'type'        => 'text',
350 350
                                         'id'          => 'wpinv_company_id',
351 351
                                         'name'        => 'wpinv_company_id',
352
-                                        'label'       => __( 'Company ID', 'invoicing' ),
352
+                                        'label'       => __('Company ID', 'invoicing'),
353 353
                                         'label_type'  => 'vertical',
354 354
                                         'placeholder' => '',
355 355
                                         'class'       => 'form-control-sm',
356
-                                        'value'       => $invoice->get_company_id( 'edit' ),
356
+                                        'value'       => $invoice->get_company_id('edit'),
357 357
                                     )
358 358
                                 );
359 359
                             ?>
360 360
                         </div>
361 361
                     </div>
362 362
 
363
-                    <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?>
363
+                    <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?>
364 364
             </div>
365 365
         <?php
366 366
     }
@@ -370,51 +370,51 @@  discard block
 block discarded – undo
370 370
 	 *
371 371
 	 * @param int $post_id
372 372
 	 */
373
-	public static function save( $post_id ) {
373
+	public static function save($post_id) {
374 374
 
375 375
         // Prepare the invoice.
376
-        $invoice = new WPInv_Invoice( $post_id );
376
+        $invoice = new WPInv_Invoice($post_id);
377 377
 
378 378
         // Load new data.
379 379
         $invoice->set_props(
380 380
 			array(
381
-                'template'             => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
382
-                'email_cc'             => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
383
-                'disable_taxes'        => isset( $_POST['disable_taxes'] ),
384
-                'currency'             => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null,
385
-                'gateway'              => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null,
386
-                'address'              => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null,
387
-                'vat_number'           => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null,
388
-                'company'              => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null,
389
-                'company_id'           => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null,
390
-                'zip'                  => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null,
391
-                'state'                => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null,
392
-                'city'                 => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null,
393
-                'country'              => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null,
394
-                'phone'                => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null,
395
-                'first_name'           => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null,
396
-                'last_name'            => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null,
397
-                'author'               => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null,
398
-                'date_created'         => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null,
399
-                'date_completed'       => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null,
400
-                'due_date'             => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
401
-                'number'               => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
402
-                'status'               => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
381
+                'template'             => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null,
382
+                'email_cc'             => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null,
383
+                'disable_taxes'        => isset($_POST['disable_taxes']),
384
+                'currency'             => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null,
385
+                'gateway'              => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null,
386
+                'address'              => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null,
387
+                'vat_number'           => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null,
388
+                'company'              => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null,
389
+                'company_id'           => isset($_POST['wpinv_company_id']) ? wpinv_clean($_POST['wpinv_company_id']) : null,
390
+                'zip'                  => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null,
391
+                'state'                => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null,
392
+                'city'                 => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null,
393
+                'country'              => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null,
394
+                'phone'                => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null,
395
+                'first_name'           => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null,
396
+                'last_name'            => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null,
397
+                'author'               => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null,
398
+                'date_created'         => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null,
399
+                'date_completed'       => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null,
400
+                'due_date'             => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null,
401
+                'number'               => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null,
402
+                'status'               => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null,
403 403
 			)
404 404
         );
405 405
 
406 406
         // Discount code.
407
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
407
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
408 408
 
409
-            if ( isset( $_POST['wpinv_discount_code'] ) ) {
410
-                $invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) );
409
+            if (isset($_POST['wpinv_discount_code'])) {
410
+                $invoice->set_discount_code(wpinv_clean($_POST['wpinv_discount_code']));
411 411
             }
412 412
 
413
-            $discount = new WPInv_Discount( $invoice->get_discount_code() );
414
-            if ( $discount->exists() ) {
415
-                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
413
+            $discount = new WPInv_Discount($invoice->get_discount_code());
414
+            if ($discount->exists()) {
415
+                $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
416 416
             } else {
417
-                $invoice->remove_discount( 'discount_code' );
417
+                $invoice->remove_discount('discount_code');
418 418
             }
419 419
 
420 420
             // Recalculate totals.
@@ -423,17 +423,17 @@  discard block
 block discarded – undo
423 423
         }
424 424
 
425 425
         // If we're creating a new user...
426
-        if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) {
426
+        if (!empty($_POST['wpinv_new_user']) && is_email(stripslashes($_POST['wpinv_email']))) {
427 427
 
428 428
             // Attempt to create the user.
429
-            $user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ) );
429
+            $user = wpinv_create_user(sanitize_email(stripslashes($_POST['wpinv_email'])));
430 430
 
431 431
 
432 432
             // If successful, update the invoice author.
433
-            if ( is_numeric( $user ) ) {
434
-                $invoice->set_author( $user );
433
+            if (is_numeric($user)) {
434
+                $invoice->set_author($user);
435 435
             } else {
436
-                wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
436
+                wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__);
437 437
             }
438 438
         }
439 439
 
@@ -447,24 +447,24 @@  discard block
 block discarded – undo
447 447
         $GLOBALS['wpinv_skip_invoice_notification'] = false;
448 448
 
449 449
         // (Maybe) send new user notification.
450
-        $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
451
-        if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
452
-            wp_send_new_user_notifications( $user, 'user' );
450
+        $should_send_notification = wpinv_get_option('disable_new_user_emails');
451
+        if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) {
452
+            wp_send_new_user_notifications($user, 'user');
453 453
         }
454 454
 
455
-        if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) {
455
+        if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) {
456 456
 
457
-            $sent = getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true );
457
+            $sent = getpaid()->get('invoice_emails')->user_invoice($invoice, true);
458 458
 
459
-            if ( $sent ) {
460
-                getpaid_admin()->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
459
+            if ($sent) {
460
+                getpaid_admin()->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
461 461
             } else {
462
-                getpaid_admin()->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
462
+                getpaid_admin()->show_error(__('Could not send the invoice to the customer', 'invoicing'));
463 463
             }
464 464
 
465 465
         }
466 466
 
467 467
         // Fires after an invoice is saved.
468
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
468
+		do_action('wpinv_invoice_metabox_saved', $invoice);
469 469
 	}
470 470
 }
Please login to merge, or discard this patch.
admin/meta-boxes/class-getpaid-meta-box-invoice-shipping-address.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit; // Exit if accessed directly
10
+    exit; // Exit if accessed directly
11 11
 }
12 12
 
13 13
 /**
@@ -15,22 +15,22 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class GetPaid_Meta_Box_Invoice_Shipping_Address {
17 17
 
18
-	/**
19
-	 * Output the metabox.
20
-	 *
21
-	 * @param WP_Post $post
22
-	 */
23
-	public static function output( $post ) {
18
+    /**
19
+     * Output the metabox.
20
+     *
21
+     * @param WP_Post $post
22
+     */
23
+    public static function output( $post ) {
24 24
 
25
-		// Retrieve shipping address.
26
-		$shipping_address = get_post_meta( $post->ID, 'shipping_address', true );
25
+        // Retrieve shipping address.
26
+        $shipping_address = get_post_meta( $post->ID, 'shipping_address', true );
27 27
 
28
-		// Abort if it is invalid.
29
-		if ( ! is_array( $shipping_address ) ) {
30
-			return;
31
-		}
28
+        // Abort if it is invalid.
29
+        if ( ! is_array( $shipping_address ) ) {
30
+            return;
31
+        }
32 32
 
33
-		?>
33
+        ?>
34 34
 
35 35
 		<div class="bsui">
36 36
 
@@ -55,31 +55,31 @@  discard block
 block discarded – undo
55 55
 
56 56
 		<?php
57 57
 
58
-	}
58
+    }
59 59
 
60
-	/**
61
-	 * Prepares a value.
62
-	 *
63
-	 * @param array $address
64
-	 * @param string $key
65
-	 * @return string
66
-	 */
67
-	public static function prepare_for_display( $address, $key ) {
60
+    /**
61
+     * Prepares a value.
62
+     *
63
+     * @param array $address
64
+     * @param string $key
65
+     * @return string
66
+     */
67
+    public static function prepare_for_display( $address, $key ) {
68 68
 
69
-		// Prepare the value.
70
-		$value = $address[ $key ];
69
+        // Prepare the value.
70
+        $value = $address[ $key ];
71 71
 
72
-		if ( $key == 'country' ) {
73
-			$value = wpinv_country_name( $value );
74
-		}
72
+        if ( $key == 'country' ) {
73
+            $value = wpinv_country_name( $value );
74
+        }
75 75
 
76
-		if ( $key == 'state' ) {
77
-			$country = isset( $address[ 'country' ] ) ? $address[ 'country' ] : wpinv_get_default_country();
78
-			$value = wpinv_state_name( $value, $country );
79
-		}
76
+        if ( $key == 'state' ) {
77
+            $country = isset( $address[ 'country' ] ) ? $address[ 'country' ] : wpinv_get_default_country();
78
+            $value = wpinv_state_name( $value, $country );
79
+        }
80 80
 
81
-		return esc_html( $value );
81
+        return esc_html( $value );
82 82
 
83
-	}
83
+    }
84 84
 
85 85
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit; // Exit if accessed directly
11 11
 }
12 12
 
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param WP_Post $post
22 22
 	 */
23
-	public static function output( $post ) {
23
+	public static function output($post) {
24 24
 
25 25
 		// Retrieve shipping address.
26
-		$shipping_address = get_post_meta( $post->ID, 'shipping_address', true );
26
+		$shipping_address = get_post_meta($post->ID, 'shipping_address', true);
27 27
 
28 28
 		// Abort if it is invalid.
29
-		if ( ! is_array( $shipping_address ) ) {
29
+		if (!is_array($shipping_address)) {
30 30
 			return;
31 31
 		}
32 32
 
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 
35 35
 		<div class="bsui">
36 36
 
37
-			<?php foreach ( getpaid_user_address_fields() as $key => $label ) : ?>
37
+			<?php foreach (getpaid_user_address_fields() as $key => $label) : ?>
38 38
 
39
-					<?php if ( ! empty( $shipping_address[ $key ] ) ) : ?>
39
+					<?php if (!empty($shipping_address[$key])) : ?>
40 40
 
41 41
 						<div class="form-group form-row">
42 42
 							<div class="col">
43
-								<span style="font-weight: 600"><?php echo esc_html( $label ); ?>:</span>
43
+								<span style="font-weight: 600"><?php echo esc_html($label); ?>:</span>
44 44
 							</div>
45 45
 							<div class="col">
46
-								<?php echo self::prepare_for_display( $shipping_address, $key ); ?>
46
+								<?php echo self::prepare_for_display($shipping_address, $key); ?>
47 47
 							</div>
48 48
 						</div>
49 49
 
@@ -64,21 +64,21 @@  discard block
 block discarded – undo
64 64
 	 * @param string $key
65 65
 	 * @return string
66 66
 	 */
67
-	public static function prepare_for_display( $address, $key ) {
67
+	public static function prepare_for_display($address, $key) {
68 68
 
69 69
 		// Prepare the value.
70
-		$value = $address[ $key ];
70
+		$value = $address[$key];
71 71
 
72
-		if ( $key == 'country' ) {
73
-			$value = wpinv_country_name( $value );
72
+		if ($key == 'country') {
73
+			$value = wpinv_country_name($value);
74 74
 		}
75 75
 
76
-		if ( $key == 'state' ) {
77
-			$country = isset( $address[ 'country' ] ) ? $address[ 'country' ] : wpinv_get_default_country();
78
-			$value = wpinv_state_name( $value, $country );
76
+		if ($key == 'state') {
77
+			$country = isset($address['country']) ? $address['country'] : wpinv_get_default_country();
78
+			$value = wpinv_state_name($value, $country);
79 79
 		}
80 80
 
81
-		return esc_html( $value );
81
+		return esc_html($value);
82 82
 
83 83
 	}
84 84
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-items.php 1 patch
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -16,82 +16,82 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class GetPaid_Meta_Box_Invoice_Items {
18 18
 
19
-    public static function get_columns( $invoice ) {
19
+    public static function get_columns($invoice) {
20 20
         $use_taxes          = $invoice->is_taxable() && wpinv_use_taxes();
21 21
         $columns            = array(
22
-            'id'     => __( 'ID', 'invoicing' ),
23
-            'title'  => __( 'Item', 'invoicing' ),
22
+            'id'     => __('ID', 'invoicing'),
23
+            'title'  => __('Item', 'invoicing'),
24 24
             'price'  => sprintf(
25 25
                 '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span>
26 26
                 <span class="getpaid-hide-if-hours hide-if-amount">%s</span>
27 27
                 <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>',
28
-                __( 'Amount', 'invoicing' ),
29
-                __( 'Price', 'invoicing' ),
30
-                __( 'Rate', 'invoicing' )
28
+                __('Amount', 'invoicing'),
29
+                __('Price', 'invoicing'),
30
+                __('Rate', 'invoicing')
31 31
             ),
32 32
             'qty'    => sprintf(
33 33
                 '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>',
34
-                __( 'Quantity', 'invoicing' ),
35
-                __( 'Hours', 'invoicing' )
34
+                __('Quantity', 'invoicing'),
35
+                __('Hours', 'invoicing')
36 36
             ),
37
-            'total'  => __( 'Total', 'invoicing' ),
38
-            'tax'    => __( 'Tax (%)', 'invoicing' ),
37
+            'total'  => __('Total', 'invoicing'),
38
+            'tax'    => __('Tax (%)', 'invoicing'),
39 39
             'action' => '',
40 40
         );
41 41
 
42
-        if ( ! $use_taxes ) {
43
-            unset( $columns['tax'] );
42
+        if (!$use_taxes) {
43
+            unset($columns['tax']);
44 44
         }
45 45
 
46 46
         return $columns;
47 47
     }
48 48
 
49
-    public static function output( $post, $invoice = false ) {
49
+    public static function output($post, $invoice = false) {
50 50
 
51
-        if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) {
52
-            return self::output2( $post );
51
+        if (apply_filters('getpaid_use_new_invoice_items_metabox', false)) {
52
+            return self::output2($post);
53 53
         }
54 54
 
55
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
56
-        $invoice            = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id );
55
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
56
+        $invoice            = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id);
57 57
         $use_taxes          = $invoice->is_taxable() && wpinv_use_taxes();
58
-        $item_types         = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
59
-        $columns            = self::get_columns( $invoice );
60
-        $cols               = count( $columns );
58
+        $item_types         = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
59
+        $columns            = self::get_columns($invoice);
60
+        $cols               = count($columns);
61 61
         $class              = '';
62 62
 
63
-        unset( $item_types['adv'] );
64
-        unset( $item_types['package'] );
63
+        unset($item_types['adv']);
64
+        unset($item_types['package']);
65 65
 
66
-        if ( $invoice->is_paid() ) {
66
+        if ($invoice->is_paid()) {
67 67
             $class .= ' wpinv-paid';
68 68
         }
69 69
 
70
-        if ( $invoice->is_refunded() ) {
70
+        if ($invoice->is_refunded()) {
71 71
             $class .= ' wpinv-refunded';
72 72
         }
73 73
 
74
-        if ( $invoice->is_recurring() ) {
74
+        if ($invoice->is_recurring()) {
75 75
             $class .= ' wpi-recurring';
76 76
         }
77 77
 
78 78
     ?>
79 79
 
80
-        <div class="wpinv-items-wrap<?php echo $class; ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>">
80
+        <div class="wpinv-items-wrap<?php echo $class; ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>">
81 81
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
82 82
 
83 83
                 <thead>
84 84
                     <tr>
85
-                        <?php foreach ( $columns as $key => $label ) : ?>
86
-                            <th class="<?php echo esc_attr( $key ); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post( $label ); ?></th>
85
+                        <?php foreach ($columns as $key => $label) : ?>
86
+                            <th class="<?php echo esc_attr($key); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post($label); ?></th>
87 87
                         <?php endforeach; ?>
88 88
                     </tr>
89 89
                 </thead>
90 90
 
91 91
                 <tbody class="wpinv-line-items">
92 92
                     <?php
93
-                        foreach ( $invoice->get_items() as $int => $item ) {
94
-                            self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' );
93
+                        foreach ($invoice->get_items() as $int => $item) {
94
+                            self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd');
95 95
                         }
96 96
                     ?>
97 97
                 </tbody>
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                                             <div class="wp-clearfix">
109 109
                                                 <label class="wpi-item-name">
110 110
                                                     <span class="input-text-wrap">
111
-                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' );?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
111
+                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
112 112
                                                     </span>
113 113
                                                 </label>
114 114
                                             </div>
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
                                             <div class="wp-clearfix">
117 117
                                                 <label class="wpi-item-price">
118 118
                                                     <span class="input-text-wrap">
119
-                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' );?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
120
-                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' );?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
119
+                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
120
+                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
121 121
                                                     </span>
122 122
                                                 </label>
123 123
                                             </div>
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                                             <div class="wp-clearfix">
126 126
                                                 <label class="wpi-item-name">
127 127
                                                     <span class="input-text-wrap">
128
-                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' );?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
128
+                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
129 129
                                                     </span>
130 130
                                                 </label>
131 131
                                             </div>
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                                             <div class="wp-clearfix">
134 134
                                                 <label class="wpi-item-type">
135 135
                                                     <span class="input-text-wrap">
136
-                                                        <?php echo wpinv_html_select( array(
136
+                                                        <?php echo wpinv_html_select(array(
137 137
                                                             'options'          => $item_types,
138 138
                                                             'name'             => '_wpinv_quick[type]',
139 139
                                                             'id'               => '_wpinv_quick_type',
@@ -141,19 +141,19 @@  discard block
 block discarded – undo
141 141
                                                             'show_option_all'  => false,
142 142
                                                             'show_option_none' => false,
143 143
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
144
-                                                        ) ); ?>
144
+                                                        )); ?>
145 145
                                                     </span>
146 146
                                                 </label>
147 147
                                             </div>
148 148
 
149
-                                            <?php if ( $use_taxes ) : ?>
149
+                                            <?php if ($use_taxes) : ?>
150 150
                                                 <div class="wp-clearfix">
151 151
                                                     <label class="wpi-vat-rule">
152 152
                                                         <span class="input-text-wrap">
153 153
                                                             <?php
154
-                                                                echo wpinv_html_select( array(
154
+                                                                echo wpinv_html_select(array(
155 155
                                                                     'options'          => array_merge(
156
-                                                                        array( '' => __( 'Select VAT Rule', 'invoicing' ) ),
156
+                                                                        array('' => __('Select VAT Rule', 'invoicing')),
157 157
                                                                         getpaid_get_tax_rules()
158 158
                                                                     ),
159 159
                                                                     'name'             => '_wpinv_quick[vat_rule]',
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
                                                                     'show_option_all'  => false,
162 162
                                                                     'show_option_none' => false,
163 163
                                                                     'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
164
-                                                                ) );
164
+                                                                ));
165 165
                                                             ?>
166 166
                                                         </span>
167 167
                                                     </label>
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
                                                     <label class="wpi-vat-class">
171 171
                                                         <span class="input-text-wrap">
172 172
                                                             <?php
173
-                                                                echo wpinv_html_select( array(
173
+                                                                echo wpinv_html_select(array(
174 174
                                                                     'options'          => array_merge(
175
-                                                                        array( '' => __( 'Select VAT Class', 'invoicing' ) ),
175
+                                                                        array('' => __('Select VAT Class', 'invoicing')),
176 176
                                                                         getpaid_get_tax_classes()
177 177
                                                                     ),
178 178
                                                                     'name'             => '_wpinv_quick[vat_class]',
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
                                                                     'show_option_all'  => false,
181 181
                                                                     'show_option_none' => false,
182 182
                                                                     'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
183
-                                                                ) );
183
+                                                                ));
184 184
                                                             ?>
185 185
                                                         </span>
186 186
                                                     </label>
@@ -201,29 +201,29 @@  discard block
 block discarded – undo
201 201
                         </td>
202 202
                     </tr>
203 203
                     <tr class="totals">
204
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
204
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
205 205
                         <td colspan="4">
206 206
                             <table cellspacing="0" cellpadding="0">
207 207
                                 <tr class="subtotal">
208
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
209
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() );?></td>
208
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
209
+                                    <td class="total"><?php echo wpinv_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td>
210 210
                                     <td class="action"></td>
211 211
                                 </tr>
212 212
                                 <tr class="discount">
213
-                                    <td class="name"><?php _e( 'Discount:', 'invoicing' ) ; ?></td>
214
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() );?></td>
213
+                                    <td class="name"><?php _e('Discount:', 'invoicing'); ?></td>
214
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td>
215 215
                                     <td class="action"></td>
216 216
                                 </tr>
217
-                                <?php if ( $use_taxes ) : ?>
217
+                                <?php if ($use_taxes) : ?>
218 218
                                 <tr class="tax">
219
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
220
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() );?></td>
219
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
220
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td>
221 221
                                     <td class="action"></td>
222 222
                                 </tr>
223 223
                                 <?php endif; ?>
224 224
                                 <tr class="total">
225
-                                    <td class="name"><?php _e( 'Total:', 'invoicing' );?></td>
226
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );?></td>
225
+                                    <td class="name"><?php _e('Total:', 'invoicing'); ?></td>
226
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total(), $invoice->get_currency()); ?></td>
227 227
                                     <td class="action"></td>
228 228
                                 </tr>
229 229
                             </table>
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             </table>
235 235
             <div class="wpinv-actions">
236 236
                 <?php
237
-                    if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
237
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
238 238
                         echo wpinv_item_dropdown(
239 239
                             array(
240 240
                                 'name'             => 'wpinv_invoice_item',
@@ -244,61 +244,61 @@  discard block
 block discarded – undo
244 244
                             )
245 245
                         );
246 246
 
247
-                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), $invoice->get_label() ) . '</button>';
248
-                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>';
249
-                        echo "&nbsp;" . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>';
247
+                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), $invoice->get_label()) . '</button>';
248
+                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>';
249
+                        echo "&nbsp;" . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>';
250 250
 
251 251
                     }
252 252
                 ?>
253
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
253
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
254 254
             </div>
255 255
         </div>
256 256
         <?php
257 257
     }
258 258
 
259
-    public static function output_row( $columns, $item, $invoice, $class='even' ) {
259
+    public static function output_row($columns, $item, $invoice, $class = 'even') {
260 260
 
261 261
     ?>
262
-        <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>">
263
-            <?php foreach ( array_keys( $columns ) as $column ) : ?>
264
-                <td class="<?php echo esc_attr( $column ); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>">
262
+        <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>">
263
+            <?php foreach (array_keys($columns) as $column) : ?>
264
+                <td class="<?php echo esc_attr($column); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>">
265 265
                     <?php
266
-                        switch ( $column ) {
266
+                        switch ($column) {
267 267
                             case 'id':
268 268
                                 echo (int) $item->get_id();
269 269
                                 break;
270 270
                             case 'title':
271 271
                                 printf(
272 272
                                     '<a href="%s" target="_blank">%s</a>',
273
-                                    get_edit_post_link( $item->get_id() ),
274
-                                    esc_html( $item->get_raw_name() )
273
+                                    get_edit_post_link($item->get_id()),
274
+                                    esc_html($item->get_raw_name())
275 275
                                 );
276 276
 
277
-                                $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice );
278
-                                if ( $summary !== '' ) {
277
+                                $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice);
278
+                                if ($summary !== '') {
279 279
                                     printf(
280 280
                                         '<span class="meta">%s</span>',
281
-                                        wpautop( wp_kses_post( $summary ) )
281
+                                        wpautop(wp_kses_post($summary))
282 282
                                     );
283 283
                                 }
284 284
 
285 285
                                 printf(
286 286
                                     '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />',
287
-                                    esc_attr( $item->get_raw_name() ),
287
+                                    esc_attr($item->get_raw_name()),
288 288
                                     (int) $item->get_id()
289 289
                                 );
290 290
 
291 291
                                 printf(
292 292
                                     '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>',
293 293
                                     (int) $item->get_id(),
294
-                                    esc_attr( $item->get_description() )
294
+                                    esc_attr($item->get_description())
295 295
                                 );
296 296
 
297 297
                                 break;
298 298
                             case 'price':
299 299
                                 printf(
300 300
                                     '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />',
301
-                                    esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ),
301
+                                    esc_attr(getpaid_unstandardize_amount($item->get_price())),
302 302
                                     (int) $item->get_id()
303 303
                                 );
304 304
 
@@ -306,26 +306,26 @@  discard block
 block discarded – undo
306 306
                             case 'qty':
307 307
                                 printf(
308 308
                                     '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />',
309
-                                    floatval( $item->get_quantity() ),
309
+                                    floatval($item->get_quantity()),
310 310
                                     (int) $item->get_id()
311 311
                                 );
312 312
 
313 313
                                 break;
314 314
                             case 'total':
315
-                                echo wpinv_price( $item->get_sub_total(), $invoice->get_currency() );
315
+                                echo wpinv_price($item->get_sub_total(), $invoice->get_currency());
316 316
 
317 317
                                 break;
318 318
                             case 'tax':
319
-                                echo wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%';
319
+                                echo wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%';
320 320
 
321 321
                                 break;
322 322
                             case 'action':
323
-                                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
323
+                                if (!$invoice->is_paid() && !$invoice->is_refunded()) {
324 324
                                     echo '<i class="fa fa-trash wpinv-item-remove"></i>';
325 325
                                 }
326 326
                                 break;
327 327
                         }
328
-                        do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice );
328
+                        do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice);
329 329
                     ?>
330 330
                 </td>
331 331
             <?php endforeach; ?>
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
 	 *
339 339
 	 * @param WP_Post $post
340 340
 	 */
341
-    public static function output2( $post ) {
341
+    public static function output2($post) {
342 342
 
343 343
         // Prepare the invoice.
344
-        $invoice = new WPInv_Invoice( $post );
344
+        $invoice = new WPInv_Invoice($post);
345 345
 
346 346
         // Invoice items.
347 347
         $items = $invoice->get_items();
@@ -349,28 +349,28 @@  discard block
 block discarded – undo
349 349
         $totals = array(
350 350
 
351 351
             'subtotal'  => array(
352
-                'label' => __( 'Items Subtotal', 'invoicing' ),
353
-                'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
352
+                'label' => __('Items Subtotal', 'invoicing'),
353
+                'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
354 354
             ),
355 355
 
356 356
             'discount'  => array(
357
-                'label' => __( 'Total Discount', 'invoicing' ),
358
-                'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
357
+                'label' => __('Total Discount', 'invoicing'),
358
+                'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
359 359
             ),
360 360
 
361 361
             'tax'       => array(
362
-                'label' => __( 'Total Tax', 'invoicing' ),
363
-                'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
362
+                'label' => __('Total Tax', 'invoicing'),
363
+                'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
364 364
             ),
365 365
 
366 366
             'total'     => array(
367
-                'label' => __( 'Invoice Total', 'invoicing' ),
368
-                'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
367
+                'label' => __('Invoice Total', 'invoicing'),
368
+                'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
369 369
             )
370 370
         );
371 371
 
372
-        if ( ! wpinv_use_taxes() ) {
373
-            unset( $totals['tax'] );
372
+        if (!wpinv_use_taxes()) {
373
+            unset($totals['tax']);
374 374
         }
375 375
 
376 376
         $item_args = array(
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             'orderby'        => 'title',
379 379
             'order'          => 'ASC',
380 380
             'posts_per_page' => -1,
381
-            'post_status'    => array( 'publish' ),
381
+            'post_status'    => array('publish'),
382 382
             'meta_query'     => array(
383 383
                 array(
384 384
                     'key'       => '_wpinv_type',
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
             }
403 403
         </style>
404 404
 
405
-                <div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;">
405
+                <div class="bsui getpaid-invoice-items-inner <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;">
406 406
 
407
-                    <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
408
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
407
+                    <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
408
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
409 409
 
410 410
                         <div class="row">
411 411
                             <div class="col-12 col-sm-6">
@@ -414,15 +414,15 @@  discard block
 block discarded – undo
414 414
                                         array(
415 415
                                             'id'          => 'wpinv_template',
416 416
                                             'name'        => 'wpinv_template',
417
-                                            'label'       => __( 'Template', 'invoicing' ),
417
+                                            'label'       => __('Template', 'invoicing'),
418 418
                                             'label_type'  => 'vertical',
419
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
419
+                                            'placeholder' => __('Choose a template', 'invoicing'),
420 420
                                             'class'       => 'form-control-sm',
421
-                                            'value'       => $invoice->get_template( 'edit' ),
421
+                                            'value'       => $invoice->get_template('edit'),
422 422
                                             'options'     => array(
423
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
424
-                                                'hours'    => __( 'Hours', 'invoicing' ),
425
-                                                'amount'   => __( 'Amount Only', 'invoicing' ),
423
+                                                'quantity' => __('Quantity', 'invoicing'),
424
+                                                'hours'    => __('Hours', 'invoicing'),
425
+                                                'amount'   => __('Amount Only', 'invoicing'),
426 426
                                             ),
427 427
                                             'data-allow-clear' => 'false',
428 428
                                             'select2'          => true,
@@ -438,11 +438,11 @@  discard block
 block discarded – undo
438 438
                                         array(
439 439
                                             'id'          => 'wpinv_currency',
440 440
                                             'name'        => 'wpinv_currency',
441
-                                            'label'       => __( 'Currency', 'invoicing' ),
441
+                                            'label'       => __('Currency', 'invoicing'),
442 442
                                             'label_type'  => 'vertical',
443
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
443
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
444 444
                                             'class'       => 'form-control-sm',
445
-                                            'value'       => $invoice->get_currency( 'edit' ),
445
+                                            'value'       => $invoice->get_currency('edit'),
446 446
                                             'required'    => false,
447 447
                                             'data-allow-clear' => 'false',
448 448
                                             'select2'          => true,
@@ -454,24 +454,24 @@  discard block
 block discarded – undo
454 454
                             </div>
455 455
                         </div>
456 456
 
457
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
457
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
458 458
                     <?php endif; ?>
459 459
 
460 460
                     <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items">
461 461
                         <thead>
462 462
                             <tr>
463
-                                <th class="getpaid-item" colspan="2"><?php _e( 'Item', 'invoicing' ) ?></th>
463
+                                <th class="getpaid-item" colspan="2"><?php _e('Item', 'invoicing') ?></th>
464 464
                                 <th class="getpaid-quantity hide-if-amount text-right">
465
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
466
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
465
+                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
466
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
467 467
                                 </th>
468 468
                                 <th class="getpaid-price hide-if-amount text-right">
469
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Price', 'invoicing' ) ?></span>
470
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Rate', 'invoicing' ) ?></span>
469
+                                    <span class="getpaid-hide-if-hours"><?php _e('Price', 'invoicing') ?></span>
470
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Rate', 'invoicing') ?></span>
471 471
                                 </th>
472 472
                                 <th class="getpaid-item-subtotal text-right">
473
-                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e( 'Amount', 'invoicing' ) ?></span>
474
-                                    <span class="hide-if-amount"><?php _e( 'Total', 'invoicing' ) ?></span>
473
+                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e('Amount', 'invoicing') ?></span>
474
+                                    <span class="hide-if-amount"><?php _e('Total', 'invoicing') ?></span>
475 475
                                 </th>
476 476
                                 <th class="getpaid-item-actions hide-if-not-editable" width="70px">&nbsp;</th>
477 477
                             </tr>
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 		                <tbody class="getpaid_invoice_line_items">
480 480
                             <tr class="hide-if-has-items hide-if-not-editable">
481 481
                                 <td colspan="2" class="pt-4 pb-4">
482
-                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Items', 'invoicing' ) ?></button>
483
-                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button>
482
+                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Items', 'invoicing') ?></button>
483
+                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e('Create New Item', 'invoicing') ?></button>
484 484
                                 </td>
485 485
                                 <td class="hide-if-amount">&nbsp;</th>
486 486
                                 <td class="hide-if-amount">&nbsp;</th>
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
                             <div class="col-12 col-sm-6 offset-sm-6">
513 513
                                 <table class="getpaid-invoice-totals text-right w-100">
514 514
                                     <tbody>
515
-                                        <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?>
516
-                                            <tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>">
517
-                                                <td class="label"><?php echo esc_html( $data['label'] ) ?>:</td>
515
+                                        <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?>
516
+                                            <tr class="getpaid-totals-<?php echo sanitize_html_class($key); ?>">
517
+                                                <td class="label"><?php echo esc_html($data['label']) ?>:</td>
518 518
                                                 <td width="1%"></td>
519
-                                                <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td>
519
+                                                <td class="value"><?php echo wp_kses_post($data['value']) ?></td>
520 520
                                             </tr>
521 521
                                         <?php endforeach; ?>
522 522
                                     </tbody>
@@ -529,18 +529,18 @@  discard block
 block discarded – undo
529 529
                     <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable">
530 530
                         <div class="row">
531 531
                             <div class="text-left col-12 col-sm-8">
532
-                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Item', 'invoicing' ) ?></button>
533
-                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button>
534
-                                <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?>
532
+                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Item', 'invoicing') ?></button>
533
+                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e('Create New Item', 'invoicing') ?></button>
534
+                                <?php do_action('getpaid-invoice-items-actions', $invoice); ?>
535 535
                             </div>
536 536
                             <div class="text-right col-12 col-sm-4">
537
-                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e( 'Recalculate Totals', 'invoicing' ) ?></button>
537
+                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e('Recalculate Totals', 'invoicing') ?></button>
538 538
                             </div>
539 539
                         </div>
540 540
                     </div>
541 541
 
542 542
                     <div class="getpaid-invoice-item-actions hide-if-editable">
543
-                        <p class="description m-2 text-right text-muted"><?php _e( 'This invoice is no longer editable', 'invoicing' ); ?></p>
543
+                        <p class="description m-2 text-right text-muted"><?php _e('This invoice is no longer editable', 'invoicing'); ?></p>
544 544
                     </div>
545 545
 
546 546
                     <!-- Add items to an invoice -->
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
                         <div class="modal-dialog modal-dialog-centered" role="document">
549 549
                             <div class="modal-content">
550 550
                                 <div class="modal-header">
551
-                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e( "Add Item(s)", 'invoicing' ); ?></h5>
552
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
551
+                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e("Add Item(s)", 'invoicing'); ?></h5>
552
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
553 553
                                         <span aria-hidden="true">&times;</span>
554 554
                                     </button>
555 555
                                 </div>
@@ -557,10 +557,10 @@  discard block
 block discarded – undo
557 557
                                     <table class="widefat">
558 558
                                         <thead>
559 559
                                             <tr>
560
-                                                <th class="pl-0 text-left"><?php _e( 'Item', 'invoicing' ) ?></th>
560
+                                                <th class="pl-0 text-left"><?php _e('Item', 'invoicing') ?></th>
561 561
                                                 <th class="pr-0 text-right hide-if-amount">
562
-                                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
563
-                                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
562
+                                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
563
+                                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
564 564
                                                 </th>
565 565
                                             </tr>
566 566
                                         </thead>
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
 								            <tr>
569 569
 									            <td class="pl-0 text-left">
570 570
                                                     <select class="regular-text getpaid-add-invoice-item-select">
571
-                                                        <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option>
572
-                                                        <?php foreach ( get_posts( $item_args ) as $item ) : ?>
573
-                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags( $item->post_title ); ?></option>
571
+                                                        <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option>
572
+                                                        <?php foreach (get_posts($item_args) as $item) : ?>
573
+                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags($item->post_title); ?></option>
574 574
                                                         <?php endforeach; ?>
575 575
                                                     </select>
576 576
                                                 </td>
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 						            </table>
583 583
                                 </div>
584 584
                                 <div class="modal-footer">
585
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
586
-                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e( 'Add', 'invoicing' ); ?></button>
585
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
586
+                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e('Add', 'invoicing'); ?></button>
587 587
                                 </div>
588 588
                             </div>
589 589
                         </div>
@@ -594,8 +594,8 @@  discard block
 block discarded – undo
594 594
                         <div class="modal-dialog modal-dialog-centered" role="document">
595 595
                             <div class="modal-content">
596 596
                                 <div class="modal-header">
597
-                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php _e( "Create Item", 'invoicing' ); ?></h5>
598
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
597
+                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php _e("Create Item", 'invoicing'); ?></h5>
598
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
599 599
                                         <span aria-hidden="true">&times;</span>
600 600
                                     </button>
601 601
                                 </div>
@@ -603,27 +603,27 @@  discard block
 block discarded – undo
603 603
                                     <div class="getpaid-create-item-div">
604 604
                                         <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id">
605 605
                                         <label class="form-group w-100">
606
-                                            <span><?php _e( 'Name', 'invoicing' ); ?></span>
607
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
606
+                                            <span><?php _e('Name', 'invoicing'); ?></span>
607
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
608 608
                                         </label>
609 609
                                         <label class="form-group w-100">
610
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span>
611
-                                            <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span>
612
-                                            <input type="text" name="price" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
610
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span>
611
+                                            <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span>
612
+                                            <input type="text" name="price" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
613 613
                                         </label>
614 614
                                         <label class="form-group w-100 hide-if-amount">
615
-                                            <span><?php _e( 'Quantity', 'invoicing' ); ?></span>
615
+                                            <span><?php _e('Quantity', 'invoicing'); ?></span>
616 616
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
617 617
                                         </label>
618 618
                                         <label class="form-group w-100">
619
-                                            <span><?php _e( 'Item Description', 'invoicing' ); ?></span>
620
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
619
+                                            <span><?php _e('Item Description', 'invoicing'); ?></span>
620
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
621 621
                                         </label>
622 622
                                     </div>
623 623
                                 </div>
624 624
                                 <div class="modal-footer">
625
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
626
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Create', 'invoicing' ); ?></button>
625
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
626
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Create', 'invoicing'); ?></button>
627 627
                                 </div>
628 628
                             </div>
629 629
                         </div>
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
                         <div class="modal-dialog modal-dialog-centered" role="document">
635 635
                             <div class="modal-content">
636 636
                                 <div class="modal-header">
637
-                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e( "Edit Item", 'invoicing' ); ?></h5>
638
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
637
+                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e("Edit Item", 'invoicing'); ?></h5>
638
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
639 639
                                         <span aria-hidden="true">&times;</span>
640 640
                                     </button>
641 641
                                 </div>
@@ -643,27 +643,27 @@  discard block
 block discarded – undo
643 643
                                     <div class="getpaid-edit-item-div">
644 644
                                         <input type="hidden" name="id" class="form-control form-control-sm item-id">
645 645
                                         <label class="form-group w-100">
646
-                                            <span><?php _e( 'Name', 'invoicing' ); ?></span>
647
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
646
+                                            <span><?php _e('Name', 'invoicing'); ?></span>
647
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
648 648
                                         </label>
649 649
                                         <label class="form-group w-100">
650
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span>
651
-                                            <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span>
652
-                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
650
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span>
651
+                                            <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span>
652
+                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
653 653
                                         </label>
654 654
                                         <label class="form-group w-100 hide-if-amount">
655
-                                            <span><?php _e( 'Quantity', 'invoicing' ); ?></span>
655
+                                            <span><?php _e('Quantity', 'invoicing'); ?></span>
656 656
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
657 657
                                         </label>
658 658
                                         <label class="form-group w-100">
659
-                                            <span><?php _e( 'Item Description', 'invoicing' ); ?></span>
660
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
659
+                                            <span><?php _e('Item Description', 'invoicing'); ?></span>
660
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
661 661
                                         </label>
662 662
                                     </div>
663 663
                                 </div>
664 664
                                 <div class="modal-footer">
665
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
666
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Save', 'invoicing' ); ?></button>
665
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
666
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Save', 'invoicing'); ?></button>
667 667
                                 </div>
668 668
                             </div>
669 669
                         </div>
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-resend-invoice.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if (!defined('ABSPATH')) {
9 9
 	exit; // Exit if accessed directly
10 10
 }
11 11
 
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @param WP_Post $post
21 21
 	 */
22
-    public static function output( $post ) {
22
+    public static function output($post) {
23 23
 
24 24
         // Fetch the invoice.
25
-        $invoice = new WPInv_Invoice( $post );
25
+        $invoice = new WPInv_Invoice($post);
26 26
 
27
-        do_action( 'wpinv_metabox_resend_invoice_before', $invoice );
27
+        do_action('wpinv_metabox_resend_invoice_before', $invoice);
28 28
 
29 29
         $invoice_actions = array(
30 30
             'resend-email' => array(
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
                     'getpaid-nonce',
39 39
                     'getpaid-nonce'
40 40
                 ),
41
-                'label' => __( 'Resend Invoice', 'invoicing' ),
41
+                'label' => __('Resend Invoice', 'invoicing'),
42 42
             )
43 43
         );
44 44
 
45
-        if ( $invoice->needs_payment() ) {
45
+        if ($invoice->needs_payment()) {
46 46
 
47 47
             $invoice_actions['send-reminder'] = array(
48 48
                 'url' => wp_nonce_url(
@@ -55,29 +55,29 @@  discard block
 block discarded – undo
55 55
                     'getpaid-nonce',
56 56
                     'getpaid-nonce'
57 57
                 ),
58
-                'label' => __( 'Send Reminder', 'invoicing' ),
58
+                'label' => __('Send Reminder', 'invoicing'),
59 59
             );
60 60
 
61 61
         }
62 62
 
63
-        $invoice_actions = apply_filters( 'getpaid_edit_invoice_actions', $invoice_actions, $invoice );
63
+        $invoice_actions = apply_filters('getpaid_edit_invoice_actions', $invoice_actions, $invoice);
64 64
 
65
-        foreach ( $invoice_actions as $key => $action ) {
65
+        foreach ($invoice_actions as $key => $action) {
66 66
 
67
-            if ( 'resend-email' === $key ) {
68
-                echo wpautop( __( "This will send a copy of the invoice to the customer's email address.", 'invoicing' ) );
67
+            if ('resend-email' === $key) {
68
+                echo wpautop(__("This will send a copy of the invoice to the customer's email address.", 'invoicing'));
69 69
             }
70 70
 
71 71
             printf(
72 72
                 '<p class="wpi-meta-row wpi-%s"><a href="%s" class="button button-secondary">%s</a>',
73
-                esc_attr( $key ),
74
-                esc_url( $action['url'] ),
75
-                esc_html( $action['label'] )
73
+                esc_attr($key),
74
+                esc_url($action['url']),
75
+                esc_html($action['label'])
76 76
             );
77 77
 
78 78
         }
79 79
 
80
-        do_action( 'wpinv_metabox_resend_invoice_after', $invoice );
80
+        do_action('wpinv_metabox_resend_invoice_after', $invoice);
81 81
 
82 82
     }
83 83
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-payment-form.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Payment_Form {
@@ -11,23 +11,23 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @param WP_Post $post
13 13
      */
14
-    public static function output_details( $post ) {
15
-        $details = get_post_meta( $post->ID, 'payment_form_data', true );
14
+    public static function output_details($post) {
15
+        $details = get_post_meta($post->ID, 'payment_form_data', true);
16 16
 
17
-        if ( ! is_array( $details ) ) {
17
+        if (!is_array($details)) {
18 18
             return;
19 19
         }
20 20
 
21 21
         echo '<div class="bsui"> <div class="form-row">';
22 22
 
23
-        foreach ( $details as $key => $value ) {
24
-            $key = esc_html( $key );
23
+        foreach ($details as $key => $value) {
24
+            $key = esc_html($key);
25 25
 
26
-            if ( is_array( $value ) ) {
27
-                $value = implode( ',', $value );
26
+            if (is_array($value)) {
27
+                $value = implode(',', $value);
28 28
             }
29 29
 
30
-            $value = esc_html( $value );
30
+            $value = esc_html($value);
31 31
             echo "<div class='col-6 form-group'><strong>$key:</strong></div><div class='col-6 form-group'>$value</div>";
32 32
         }
33 33
 
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @param WP_Post $post
42 42
      */
43
-    public static function output_shortcode( $post ) {
43
+    public static function output_shortcode($post) {
44 44
 
45
-        if ( ! is_numeric( $post ) ) {
45
+        if (!is_numeric($post)) {
46 46
             $post = $post->ID;
47 47
         }
48 48
 
49
-        if ( $post == wpinv_get_default_payment_form() ) {
49
+        if ($post == wpinv_get_default_payment_form()) {
50 50
             echo '&mdash;';
51 51
             return;
52 52
         }
Please login to merge, or discard this patch.
includes/admin/class-wpinv-subscriptions-list-table.php 2 patches
Indentation   +402 added lines, -402 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 if ( ! defined( 'ABSPATH' ) ) exit;
7 7
 
8 8
 if ( ! class_exists( 'WP_List_Table' ) ) {
9
-	include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
9
+    include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
10 10
 }
11 11
 
12 12
 /**
@@ -14,406 +14,406 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class WPInv_Subscriptions_List_Table extends WP_List_Table {
16 16
 
17
-	/**
18
-	 * URL of this page
19
-	 *
20
-	 * @var   string
21
-	 * @since 1.0.19
22
-	 */
23
-	public $base_url;
24
-
25
-	/**
26
-	 * Query
27
-	 *
28
-	 * @var   GetPaid_Subscriptions_Query
29
-	 * @since 1.0.19
30
-	 */
31
-	public $query;
32
-
33
-	/**
34
-	 * Total subscriptions
35
-	 *
36
-	 * @var   string
37
-	 * @since 1.0.0
38
-	 */
39
-	public $total_count;
40
-
41
-	/**
42
-	 * Current status subscriptions
43
-	 *
44
-	 * @var   string
45
-	 * @since 1.0.0
46
-	 */
47
-	public $current_total_count;
48
-
49
-	/**
50
-	 * Status counts
51
-	 *
52
-	 * @var   array
53
-	 * @since 1.0.19
54
-	 */
55
-	public $status_counts;
56
-
57
-	/**
58
-	 * Number of results to show per page
59
-	 *
60
-	 * @var   int
61
-	 * @since 1.0.0
62
-	 */
63
-	public $per_page = 10;
64
-
65
-	/**
66
-	 *  Constructor function.
67
-	 */
68
-	public function __construct() {
69
-
70
-		parent::__construct(
71
-			array(
72
-				'singular' => 'subscription',
73
-				'plural'   => 'subscriptions',
74
-			)
75
-		);
76
-
77
-		$this->process_bulk_action();
78
-
79
-		$this->prepare_query();
80
-
81
-		$this->base_url = remove_query_arg( 'status' );
82
-
83
-	}
84
-
85
-	/**
86
-	 *  Prepares the display query
87
-	 */
88
-	public function prepare_query() {
89
-
90
-		// Prepare query args.
91
-		$query = array(
92
-			'number'  => $this->per_page,
93
-			'paged'   => $this->get_paged(),
94
-			'status'  => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all',
95
-			'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id',
96
-			'order'   => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC',
97
-		);
98
-
99
-		// Prepare class properties.
100
-		$this->query               = new GetPaid_Subscriptions_Query( $query );
101
-		$this->total_count         = $this->query->get_total();
102
-		$this->current_total_count = $this->query->get_total();
103
-		$this->items               = $this->query->get_results();
104
-		$this->status_counts       = getpaid_get_subscription_status_counts( $query );
105
-
106
-		if ( 'all' != $query['status'] ) {
107
-			unset( $query['status'] );
108
-			$this->total_count   = getpaid_get_subscriptions( $query, 'count' );
109
-		}
110
-
111
-	}
112
-
113
-	/**
114
-	 * Gets the list of views available on this table.
115
-	 *
116
-	 * The format is an associative array:
117
-	 * - `'id' => 'link'`
118
-	 *
119
-	 * @since 1.0.0
120
-	 *
121
-	 * @return array
122
-	 */
123
-	public function get_views() {
124
-
125
-		$current  = isset( $_GET['status'] ) ? $_GET['status'] : 'all';
126
-		$views    = array(
127
-
128
-			'all' => sprintf(
129
-				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
130
-				esc_url( add_query_arg( 'status', false, $this->base_url ) ),
131
-				$current === 'all' ? ' class="current"' : '',
132
-				__('All','invoicing' ),
133
-				$this->total_count
134
-			)
135
-
136
-		);
137
-
138
-		foreach ( array_filter( $this->status_counts ) as $status => $count ) {
139
-
140
-			$views[ $status ] = sprintf(
141
-				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
142
-				esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
143
-				$current === $status ? ' class="current"' : '',
144
-				esc_html( getpaid_get_subscription_status_label( $status ) ),
145
-				$count
146
-			);
147
-
148
-		}
149
-
150
-		return $views;
151
-
152
-	}
153
-
154
-	/**
155
-	 * Render most columns
156
-	 *
157
-	 * @access      private
158
-	 * @since       1.0.0
159
-	 * @return      string
160
-	 */
161
-	public function column_default( $item, $column_name ) {
162
-		return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
163
-	}
164
-
165
-	/**
166
-	 * This is how checkbox column renders.
167
-	 *
168
-	 * @param WPInv_Subscription $item
169
-	 * @return string
170
-	 */
171
-	public function column_cb( $item ) {
172
-		return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
173
-	}
174
-
175
-	/**
176
-	 * Status column
177
-	 *
178
-	 * @param WPInv_Subscription $item
179
-	 * @since       1.0.0
180
-	 * @return      string
181
-	 */
182
-	public function column_status( $item ) {
183
-		return $item->get_status_label_html();
184
-	}
185
-
186
-	/**
187
-	 * Subscription column
188
-	 *
189
-	 * @param WPInv_Subscription $item
190
-	 * @since       1.0.0
191
-	 * @return      string
192
-	 */
193
-	public function column_subscription( $item ) {
194
-
195
-		$username = __( '(Missing User)', 'invoicing' );
196
-
197
-		$user = get_userdata( $item->get_customer_id() );
198
-		if ( $user ) {
199
-
200
-			$username = sprintf(
201
-				'<a href="user-edit.php?user_id=%s">%s</a>',
202
-				absint( $user->ID ),
203
-				! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
204
-			);
205
-
206
-		}
207
-
208
-		// translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
209
-		$column_content = sprintf(
210
-			_x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
211
-			'<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
212
-			'<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>',
213
-			$username
214
-		);
215
-
216
-		$row_actions = array();
217
-
218
-		// View subscription.
219
-		$view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ));
220
-		$row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
221
-
222
-		// View invoice.
223
-		$invoice = get_post( $item->get_parent_invoice_id() );
224
-
225
-		if ( ! empty( $invoice ) ) {
226
-			$invoice_url            = get_edit_post_link( $invoice );
227
-			$row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
228
-		}
229
-
230
-		$delete_url            = esc_url(
231
-			wp_nonce_url(
232
-				add_query_arg(
233
-					array(
234
-						'getpaid-admin-action' => 'subscription_manual_delete',
235
-						'id'                   => $item->get_id(),
236
-					)
237
-				),
238
-				'getpaid-nonce',
239
-				'getpaid-nonce'
240
-			)
241
-		);
242
-		$row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>';
243
-
244
-		$row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
245
-
246
-		return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
247
-	}
248
-
249
-	/**
250
-	 * Renewal date column
251
-	 *
252
-	 * @param WPInv_Subscription $item
253
-	 * @since       1.0.0
254
-	 * @return      string
255
-	 */
256
-	public function column_renewal_date( $item ) {
257
-		return getpaid_format_date_value( $item->get_expiration() );
258
-	}
259
-
260
-	/**
261
-	 * Start date column
262
-	 *
263
-	 * @param WPInv_Subscription $item
264
-	 * @since       1.0.0
265
-	 * @return      string
266
-	 */
267
-	public function column_start_date( $item ) {
268
-		return getpaid_format_date_value( $item->get_date_created() );
269
-	}
270
-
271
-	/**
272
-	 * Amount column
273
-	 *
274
-	 * @param WPInv_Subscription $item
275
-	 * @since       1.0.19
276
-	 * @return      string
277
-	 */
278
-	public static function column_amount( $item ) {
279
-		$amount = getpaid_get_formatted_subscription_amount( $item );
280
-		return "<span class='text-muted form-text mt-2 mb-2'>$amount</span>";
281
-	}
282
-
283
-	/**
284
-	 * Billing Times column
285
-	 *
286
-	 * @param WPInv_Subscription $item
287
-	 * @since       1.0.0
288
-	 * @return      string
289
-	 */
290
-	public function column_renewals( $item ) {
291
-		$max_bills = $item->get_bill_times();
292
-		return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
293
-	}
294
-
295
-	/**
296
-	 * Product ID column
297
-	 *
298
-	 * @param WPInv_Subscription $item
299
-	 * @since       1.0.0
300
-	 * @return      string
301
-	 */
302
-	public function column_item( $item ) {
303
-		$subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() );
304
-
305
-		if ( empty( $subscription_group ) ) {
306
-			return $this->generate_item_markup( $item->get_product_id() );
307
-		}
308
-
309
-		$markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
310
-		return implode( ' | ', $markup );
311
-
312
-	}
313
-
314
-	/**
315
-	 * Generates the items markup.
316
-	 *
317
-	 * @param int $item_id
318
-	 * @since       1.0.0
319
-	 * @return      string
320
-	 */
321
-	public static function generate_item_markup( $item_id ) {
322
-		$item = get_post( $item_id );
323
-
324
-		if ( ! empty( $item ) ) {
325
-			$link = get_edit_post_link( $item );
326
-			$link = esc_url( $link );
327
-			$name = esc_html( get_the_title( $item ) );
328
-			return wpinv_current_user_can_manage_invoicing() ? "<a href='$link'>$name</a>" : $name;
329
-		} else {
330
-			return sprintf( __( 'Item #%s', 'invoicing' ), $item_id );
331
-		}
332
-
333
-	}
334
-
335
-	/**
336
-	 * Retrieve the current page number
337
-	 *
338
-	 * @return      int
339
-	 */
340
-	public function get_paged() {
341
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
342
-	}
343
-
344
-	/**
345
-	 * Setup the final data for the table
346
-	 *
347
-	 */
348
-	public function prepare_items() {
349
-
350
-		$columns  = $this->get_columns();
351
-		$hidden   = array();
352
-		$sortable = $this->get_sortable_columns();
353
-
354
-		$this->_column_headers = array( $columns, $hidden, $sortable );
355
-
356
-		$this->set_pagination_args(
357
-			array(
358
-			'total_items' => $this->current_total_count,
359
-			'per_page'    => $this->per_page,
360
-			'total_pages' => ceil( $this->current_total_count / $this->per_page )
361
-			)
362
-		);
363
-	}
364
-
365
-	/**
366
-	 * Table columns
367
-	 *
368
-	 * @return array
369
-	 */
370
-	public function get_columns(){
371
-		$columns = array(
372
-			'cb'                => '<input type="checkbox" />',
373
-			'subscription'      => __( 'Subscription', 'invoicing' ),
374
-			'start_date'        => __( 'Start Date', 'invoicing' ),
375
-			'renewal_date'      => __( 'Next Payment', 'invoicing' ),
376
-			'renewals'          => __( 'Payments', 'invoicing' ),
377
-			'item'              => __( 'Items', 'invoicing' ),
378
-			'status'            => __( 'Status', 'invoicing' ),
379
-		);
380
-
381
-		return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
382
-	}
383
-
384
-	/**
385
-	 * Sortable table columns.
386
-	 *
387
-	 * @return array
388
-	 */
389
-	public function get_sortable_columns() {
390
-		$sortable = array(
391
-			'subscription' => array( 'id', true ),
392
-			'start_date'   => array( 'created', true ),
393
-			'renewal_date' => array( 'expiration', true ),
394
-			'renewals'     => array( 'bill_times', true ),
395
-			'item'         => array( 'product_id', true ),
396
-			'status'       => array( 'status', true ),
397
-		);
398
-
399
-		return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
400
-	}
401
-
402
-	/**
403
-	 * Whether the table has items to display or not
404
-	 *
405
-	 * @return bool
406
-	 */
407
-	public function has_items() {
408
-		return ! empty( $this->current_total_count );
409
-	}
410
-
411
-	/**
412
-	 * Processes bulk actions.
413
-	 *
414
-	 */
415
-	public function process_bulk_action() {
416
-
417
-	}
17
+    /**
18
+     * URL of this page
19
+     *
20
+     * @var   string
21
+     * @since 1.0.19
22
+     */
23
+    public $base_url;
24
+
25
+    /**
26
+     * Query
27
+     *
28
+     * @var   GetPaid_Subscriptions_Query
29
+     * @since 1.0.19
30
+     */
31
+    public $query;
32
+
33
+    /**
34
+     * Total subscriptions
35
+     *
36
+     * @var   string
37
+     * @since 1.0.0
38
+     */
39
+    public $total_count;
40
+
41
+    /**
42
+     * Current status subscriptions
43
+     *
44
+     * @var   string
45
+     * @since 1.0.0
46
+     */
47
+    public $current_total_count;
48
+
49
+    /**
50
+     * Status counts
51
+     *
52
+     * @var   array
53
+     * @since 1.0.19
54
+     */
55
+    public $status_counts;
56
+
57
+    /**
58
+     * Number of results to show per page
59
+     *
60
+     * @var   int
61
+     * @since 1.0.0
62
+     */
63
+    public $per_page = 10;
64
+
65
+    /**
66
+     *  Constructor function.
67
+     */
68
+    public function __construct() {
69
+
70
+        parent::__construct(
71
+            array(
72
+                'singular' => 'subscription',
73
+                'plural'   => 'subscriptions',
74
+            )
75
+        );
76
+
77
+        $this->process_bulk_action();
78
+
79
+        $this->prepare_query();
80
+
81
+        $this->base_url = remove_query_arg( 'status' );
82
+
83
+    }
84
+
85
+    /**
86
+     *  Prepares the display query
87
+     */
88
+    public function prepare_query() {
89
+
90
+        // Prepare query args.
91
+        $query = array(
92
+            'number'  => $this->per_page,
93
+            'paged'   => $this->get_paged(),
94
+            'status'  => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all',
95
+            'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id',
96
+            'order'   => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC',
97
+        );
98
+
99
+        // Prepare class properties.
100
+        $this->query               = new GetPaid_Subscriptions_Query( $query );
101
+        $this->total_count         = $this->query->get_total();
102
+        $this->current_total_count = $this->query->get_total();
103
+        $this->items               = $this->query->get_results();
104
+        $this->status_counts       = getpaid_get_subscription_status_counts( $query );
105
+
106
+        if ( 'all' != $query['status'] ) {
107
+            unset( $query['status'] );
108
+            $this->total_count   = getpaid_get_subscriptions( $query, 'count' );
109
+        }
110
+
111
+    }
112
+
113
+    /**
114
+     * Gets the list of views available on this table.
115
+     *
116
+     * The format is an associative array:
117
+     * - `'id' => 'link'`
118
+     *
119
+     * @since 1.0.0
120
+     *
121
+     * @return array
122
+     */
123
+    public function get_views() {
124
+
125
+        $current  = isset( $_GET['status'] ) ? $_GET['status'] : 'all';
126
+        $views    = array(
127
+
128
+            'all' => sprintf(
129
+                '<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
130
+                esc_url( add_query_arg( 'status', false, $this->base_url ) ),
131
+                $current === 'all' ? ' class="current"' : '',
132
+                __('All','invoicing' ),
133
+                $this->total_count
134
+            )
135
+
136
+        );
137
+
138
+        foreach ( array_filter( $this->status_counts ) as $status => $count ) {
139
+
140
+            $views[ $status ] = sprintf(
141
+                '<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
142
+                esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
143
+                $current === $status ? ' class="current"' : '',
144
+                esc_html( getpaid_get_subscription_status_label( $status ) ),
145
+                $count
146
+            );
147
+
148
+        }
149
+
150
+        return $views;
151
+
152
+    }
153
+
154
+    /**
155
+     * Render most columns
156
+     *
157
+     * @access      private
158
+     * @since       1.0.0
159
+     * @return      string
160
+     */
161
+    public function column_default( $item, $column_name ) {
162
+        return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
163
+    }
164
+
165
+    /**
166
+     * This is how checkbox column renders.
167
+     *
168
+     * @param WPInv_Subscription $item
169
+     * @return string
170
+     */
171
+    public function column_cb( $item ) {
172
+        return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
173
+    }
174
+
175
+    /**
176
+     * Status column
177
+     *
178
+     * @param WPInv_Subscription $item
179
+     * @since       1.0.0
180
+     * @return      string
181
+     */
182
+    public function column_status( $item ) {
183
+        return $item->get_status_label_html();
184
+    }
185
+
186
+    /**
187
+     * Subscription column
188
+     *
189
+     * @param WPInv_Subscription $item
190
+     * @since       1.0.0
191
+     * @return      string
192
+     */
193
+    public function column_subscription( $item ) {
194
+
195
+        $username = __( '(Missing User)', 'invoicing' );
196
+
197
+        $user = get_userdata( $item->get_customer_id() );
198
+        if ( $user ) {
199
+
200
+            $username = sprintf(
201
+                '<a href="user-edit.php?user_id=%s">%s</a>',
202
+                absint( $user->ID ),
203
+                ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
204
+            );
205
+
206
+        }
207
+
208
+        // translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
209
+        $column_content = sprintf(
210
+            _x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
211
+            '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
212
+            '<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>',
213
+            $username
214
+        );
215
+
216
+        $row_actions = array();
217
+
218
+        // View subscription.
219
+        $view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ));
220
+        $row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
221
+
222
+        // View invoice.
223
+        $invoice = get_post( $item->get_parent_invoice_id() );
224
+
225
+        if ( ! empty( $invoice ) ) {
226
+            $invoice_url            = get_edit_post_link( $invoice );
227
+            $row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
228
+        }
229
+
230
+        $delete_url            = esc_url(
231
+            wp_nonce_url(
232
+                add_query_arg(
233
+                    array(
234
+                        'getpaid-admin-action' => 'subscription_manual_delete',
235
+                        'id'                   => $item->get_id(),
236
+                    )
237
+                ),
238
+                'getpaid-nonce',
239
+                'getpaid-nonce'
240
+            )
241
+        );
242
+        $row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>';
243
+
244
+        $row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
245
+
246
+        return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
247
+    }
248
+
249
+    /**
250
+     * Renewal date column
251
+     *
252
+     * @param WPInv_Subscription $item
253
+     * @since       1.0.0
254
+     * @return      string
255
+     */
256
+    public function column_renewal_date( $item ) {
257
+        return getpaid_format_date_value( $item->get_expiration() );
258
+    }
259
+
260
+    /**
261
+     * Start date column
262
+     *
263
+     * @param WPInv_Subscription $item
264
+     * @since       1.0.0
265
+     * @return      string
266
+     */
267
+    public function column_start_date( $item ) {
268
+        return getpaid_format_date_value( $item->get_date_created() );
269
+    }
270
+
271
+    /**
272
+     * Amount column
273
+     *
274
+     * @param WPInv_Subscription $item
275
+     * @since       1.0.19
276
+     * @return      string
277
+     */
278
+    public static function column_amount( $item ) {
279
+        $amount = getpaid_get_formatted_subscription_amount( $item );
280
+        return "<span class='text-muted form-text mt-2 mb-2'>$amount</span>";
281
+    }
282
+
283
+    /**
284
+     * Billing Times column
285
+     *
286
+     * @param WPInv_Subscription $item
287
+     * @since       1.0.0
288
+     * @return      string
289
+     */
290
+    public function column_renewals( $item ) {
291
+        $max_bills = $item->get_bill_times();
292
+        return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
293
+    }
294
+
295
+    /**
296
+     * Product ID column
297
+     *
298
+     * @param WPInv_Subscription $item
299
+     * @since       1.0.0
300
+     * @return      string
301
+     */
302
+    public function column_item( $item ) {
303
+        $subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() );
304
+
305
+        if ( empty( $subscription_group ) ) {
306
+            return $this->generate_item_markup( $item->get_product_id() );
307
+        }
308
+
309
+        $markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
310
+        return implode( ' | ', $markup );
311
+
312
+    }
313
+
314
+    /**
315
+     * Generates the items markup.
316
+     *
317
+     * @param int $item_id
318
+     * @since       1.0.0
319
+     * @return      string
320
+     */
321
+    public static function generate_item_markup( $item_id ) {
322
+        $item = get_post( $item_id );
323
+
324
+        if ( ! empty( $item ) ) {
325
+            $link = get_edit_post_link( $item );
326
+            $link = esc_url( $link );
327
+            $name = esc_html( get_the_title( $item ) );
328
+            return wpinv_current_user_can_manage_invoicing() ? "<a href='$link'>$name</a>" : $name;
329
+        } else {
330
+            return sprintf( __( 'Item #%s', 'invoicing' ), $item_id );
331
+        }
332
+
333
+    }
334
+
335
+    /**
336
+     * Retrieve the current page number
337
+     *
338
+     * @return      int
339
+     */
340
+    public function get_paged() {
341
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
342
+    }
343
+
344
+    /**
345
+     * Setup the final data for the table
346
+     *
347
+     */
348
+    public function prepare_items() {
349
+
350
+        $columns  = $this->get_columns();
351
+        $hidden   = array();
352
+        $sortable = $this->get_sortable_columns();
353
+
354
+        $this->_column_headers = array( $columns, $hidden, $sortable );
355
+
356
+        $this->set_pagination_args(
357
+            array(
358
+            'total_items' => $this->current_total_count,
359
+            'per_page'    => $this->per_page,
360
+            'total_pages' => ceil( $this->current_total_count / $this->per_page )
361
+            )
362
+        );
363
+    }
364
+
365
+    /**
366
+     * Table columns
367
+     *
368
+     * @return array
369
+     */
370
+    public function get_columns(){
371
+        $columns = array(
372
+            'cb'                => '<input type="checkbox" />',
373
+            'subscription'      => __( 'Subscription', 'invoicing' ),
374
+            'start_date'        => __( 'Start Date', 'invoicing' ),
375
+            'renewal_date'      => __( 'Next Payment', 'invoicing' ),
376
+            'renewals'          => __( 'Payments', 'invoicing' ),
377
+            'item'              => __( 'Items', 'invoicing' ),
378
+            'status'            => __( 'Status', 'invoicing' ),
379
+        );
380
+
381
+        return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
382
+    }
383
+
384
+    /**
385
+     * Sortable table columns.
386
+     *
387
+     * @return array
388
+     */
389
+    public function get_sortable_columns() {
390
+        $sortable = array(
391
+            'subscription' => array( 'id', true ),
392
+            'start_date'   => array( 'created', true ),
393
+            'renewal_date' => array( 'expiration', true ),
394
+            'renewals'     => array( 'bill_times', true ),
395
+            'item'         => array( 'product_id', true ),
396
+            'status'       => array( 'status', true ),
397
+        );
398
+
399
+        return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
400
+    }
401
+
402
+    /**
403
+     * Whether the table has items to display or not
404
+     *
405
+     * @return bool
406
+     */
407
+    public function has_items() {
408
+        return ! empty( $this->current_total_count );
409
+    }
410
+
411
+    /**
412
+     * Processes bulk actions.
413
+     *
414
+     */
415
+    public function process_bulk_action() {
416
+
417
+    }
418 418
 
419 419
 }
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
  * Displays a list of all subscriptions rules
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) exit;
6
+if (!defined('ABSPATH')) exit;
7 7
 
8
-if ( ! class_exists( 'WP_List_Table' ) ) {
8
+if (!class_exists('WP_List_Table')) {
9 9
 	include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
10 10
 }
11 11
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		$this->prepare_query();
80 80
 
81
-		$this->base_url = remove_query_arg( 'status' );
81
+		$this->base_url = remove_query_arg('status');
82 82
 
83 83
 	}
84 84
 
@@ -91,21 +91,21 @@  discard block
 block discarded – undo
91 91
 		$query = array(
92 92
 			'number'  => $this->per_page,
93 93
 			'paged'   => $this->get_paged(),
94
-			'status'  => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all',
95
-			'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id',
96
-			'order'   => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC',
94
+			'status'  => (isset($_GET['status']) && array_key_exists($_GET['status'], getpaid_get_subscription_statuses())) ? $_GET['status'] : 'all',
95
+			'orderby' => (isset($_GET['orderby'])) ? $_GET['orderby'] : 'id',
96
+			'order'   => (isset($_GET['order'])) ? $_GET['order'] : 'DESC',
97 97
 		);
98 98
 
99 99
 		// Prepare class properties.
100
-		$this->query               = new GetPaid_Subscriptions_Query( $query );
100
+		$this->query               = new GetPaid_Subscriptions_Query($query);
101 101
 		$this->total_count         = $this->query->get_total();
102 102
 		$this->current_total_count = $this->query->get_total();
103 103
 		$this->items               = $this->query->get_results();
104
-		$this->status_counts       = getpaid_get_subscription_status_counts( $query );
104
+		$this->status_counts       = getpaid_get_subscription_status_counts($query);
105 105
 
106
-		if ( 'all' != $query['status'] ) {
107
-			unset( $query['status'] );
108
-			$this->total_count   = getpaid_get_subscriptions( $query, 'count' );
106
+		if ('all' != $query['status']) {
107
+			unset($query['status']);
108
+			$this->total_count = getpaid_get_subscriptions($query, 'count');
109 109
 		}
110 110
 
111 111
 	}
@@ -122,26 +122,26 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function get_views() {
124 124
 
125
-		$current  = isset( $_GET['status'] ) ? $_GET['status'] : 'all';
125
+		$current  = isset($_GET['status']) ? $_GET['status'] : 'all';
126 126
 		$views    = array(
127 127
 
128 128
 			'all' => sprintf(
129 129
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
130
-				esc_url( add_query_arg( 'status', false, $this->base_url ) ),
130
+				esc_url(add_query_arg('status', false, $this->base_url)),
131 131
 				$current === 'all' ? ' class="current"' : '',
132
-				__('All','invoicing' ),
132
+				__('All', 'invoicing'),
133 133
 				$this->total_count
134 134
 			)
135 135
 
136 136
 		);
137 137
 
138
-		foreach ( array_filter( $this->status_counts ) as $status => $count ) {
138
+		foreach (array_filter($this->status_counts) as $status => $count) {
139 139
 
140
-			$views[ $status ] = sprintf(
140
+			$views[$status] = sprintf(
141 141
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
142
-				esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
142
+				esc_url(add_query_arg('status', urlencode($status), $this->base_url)),
143 143
 				$current === $status ? ' class="current"' : '',
144
-				esc_html( getpaid_get_subscription_status_label( $status ) ),
144
+				esc_html(getpaid_get_subscription_status_label($status)),
145 145
 				$count
146 146
 			);
147 147
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @since       1.0.0
159 159
 	 * @return      string
160 160
 	 */
161
-	public function column_default( $item, $column_name ) {
162
-		return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
161
+	public function column_default($item, $column_name) {
162
+		return apply_filters("getpaid_subscriptions_table_column_$column_name", $item->$column_name);
163 163
 	}
164 164
 
165 165
 	/**
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 * @param WPInv_Subscription $item
169 169
 	 * @return string
170 170
 	 */
171
-	public function column_cb( $item ) {
172
-		return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
171
+	public function column_cb($item) {
172
+		return sprintf('<input type="checkbox" name="id[]" value="%s" />', esc_html($item->get_id()));
173 173
 	}
174 174
 
175 175
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @since       1.0.0
180 180
 	 * @return      string
181 181
 	 */
182
-	public function column_status( $item ) {
182
+	public function column_status($item) {
183 183
 		return $item->get_status_label_html();
184 184
 	}
185 185
 
@@ -190,44 +190,44 @@  discard block
 block discarded – undo
190 190
 	 * @since       1.0.0
191 191
 	 * @return      string
192 192
 	 */
193
-	public function column_subscription( $item ) {
193
+	public function column_subscription($item) {
194 194
 
195
-		$username = __( '(Missing User)', 'invoicing' );
195
+		$username = __('(Missing User)', 'invoicing');
196 196
 
197
-		$user = get_userdata( $item->get_customer_id() );
198
-		if ( $user ) {
197
+		$user = get_userdata($item->get_customer_id());
198
+		if ($user) {
199 199
 
200 200
 			$username = sprintf(
201 201
 				'<a href="user-edit.php?user_id=%s">%s</a>',
202
-				absint( $user->ID ),
203
-				! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
202
+				absint($user->ID),
203
+				!empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email)
204 204
 			);
205 205
 
206 206
 		}
207 207
 
208 208
 		// translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
209 209
 		$column_content = sprintf(
210
-			_x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
211
-			'<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
212
-			'<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>',
210
+			_x('%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing'),
211
+			'<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($item->get_id()))) . '">',
212
+			'<strong>' . esc_attr($item->get_id()) . '</strong>', '</a>',
213 213
 			$username
214 214
 		);
215 215
 
216 216
 		$row_actions = array();
217 217
 
218 218
 		// View subscription.
219
-		$view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ));
220
-		$row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
219
+		$view_url    = esc_url(add_query_arg('id', $item->get_id(), admin_url('admin.php?page=wpinv-subscriptions')));
220
+		$row_actions['view'] = '<a href="' . $view_url . '">' . __('View Subscription', 'invoicing') . '</a>';
221 221
 
222 222
 		// View invoice.
223
-		$invoice = get_post( $item->get_parent_invoice_id() );
223
+		$invoice = get_post($item->get_parent_invoice_id());
224 224
 
225
-		if ( ! empty( $invoice ) ) {
226
-			$invoice_url            = get_edit_post_link( $invoice );
227
-			$row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
225
+		if (!empty($invoice)) {
226
+			$invoice_url            = get_edit_post_link($invoice);
227
+			$row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __('View Invoice', 'invoicing') . '</a>';
228 228
 		}
229 229
 
230
-		$delete_url            = esc_url(
230
+		$delete_url = esc_url(
231 231
 			wp_nonce_url(
232 232
 				add_query_arg(
233 233
 					array(
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
 				'getpaid-nonce'
240 240
 			)
241 241
 		);
242
-		$row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>';
242
+		$row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __('Delete Subscription', 'invoicing') . '</a>';
243 243
 
244
-		$row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
244
+		$row_actions = $this->row_actions(apply_filters('getpaid_subscription_table_row_actions', $row_actions, $item));
245 245
 
246
-		return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
246
+		return "<strong>$column_content</strong>" . $this->column_amount($item) . $row_actions;
247 247
 	}
248 248
 
249 249
 	/**
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 	 * @since       1.0.0
254 254
 	 * @return      string
255 255
 	 */
256
-	public function column_renewal_date( $item ) {
257
-		return getpaid_format_date_value( $item->get_expiration() );
256
+	public function column_renewal_date($item) {
257
+		return getpaid_format_date_value($item->get_expiration());
258 258
 	}
259 259
 
260 260
 	/**
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 	 * @since       1.0.0
265 265
 	 * @return      string
266 266
 	 */
267
-	public function column_start_date( $item ) {
268
-		return getpaid_format_date_value( $item->get_date_created() );
267
+	public function column_start_date($item) {
268
+		return getpaid_format_date_value($item->get_date_created());
269 269
 	}
270 270
 
271 271
 	/**
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
 	 * @since       1.0.19
276 276
 	 * @return      string
277 277
 	 */
278
-	public static function column_amount( $item ) {
279
-		$amount = getpaid_get_formatted_subscription_amount( $item );
278
+	public static function column_amount($item) {
279
+		$amount = getpaid_get_formatted_subscription_amount($item);
280 280
 		return "<span class='text-muted form-text mt-2 mb-2'>$amount</span>";
281 281
 	}
282 282
 
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 	 * @since       1.0.0
288 288
 	 * @return      string
289 289
 	 */
290
-	public function column_renewals( $item ) {
290
+	public function column_renewals($item) {
291 291
 		$max_bills = $item->get_bill_times();
292
-		return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
292
+		return $item->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
293 293
 	}
294 294
 
295 295
 	/**
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 	 * @since       1.0.0
300 300
 	 * @return      string
301 301
 	 */
302
-	public function column_item( $item ) {
303
-		$subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() );
302
+	public function column_item($item) {
303
+		$subscription_group = getpaid_get_invoice_subscription_group($item->get_parent_invoice_id(), $item->get_id());
304 304
 
305
-		if ( empty( $subscription_group ) ) {
306
-			return $this->generate_item_markup( $item->get_product_id() );
305
+		if (empty($subscription_group)) {
306
+			return $this->generate_item_markup($item->get_product_id());
307 307
 		}
308 308
 
309
-		$markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
310
-		return implode( ' | ', $markup );
309
+		$markup = array_map(array($this, 'generate_item_markup'), array_keys($subscription_group['items']));
310
+		return implode(' | ', $markup);
311 311
 
312 312
 	}
313 313
 
@@ -318,16 +318,16 @@  discard block
 block discarded – undo
318 318
 	 * @since       1.0.0
319 319
 	 * @return      string
320 320
 	 */
321
-	public static function generate_item_markup( $item_id ) {
322
-		$item = get_post( $item_id );
321
+	public static function generate_item_markup($item_id) {
322
+		$item = get_post($item_id);
323 323
 
324
-		if ( ! empty( $item ) ) {
325
-			$link = get_edit_post_link( $item );
326
-			$link = esc_url( $link );
327
-			$name = esc_html( get_the_title( $item ) );
324
+		if (!empty($item)) {
325
+			$link = get_edit_post_link($item);
326
+			$link = esc_url($link);
327
+			$name = esc_html(get_the_title($item));
328 328
 			return wpinv_current_user_can_manage_invoicing() ? "<a href='$link'>$name</a>" : $name;
329 329
 		} else {
330
-			return sprintf( __( 'Item #%s', 'invoicing' ), $item_id );
330
+			return sprintf(__('Item #%s', 'invoicing'), $item_id);
331 331
 		}
332 332
 
333 333
 	}
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 	 * @return      int
339 339
 	 */
340 340
 	public function get_paged() {
341
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
341
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
342 342
 	}
343 343
 
344 344
 	/**
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
 		$hidden   = array();
352 352
 		$sortable = $this->get_sortable_columns();
353 353
 
354
-		$this->_column_headers = array( $columns, $hidden, $sortable );
354
+		$this->_column_headers = array($columns, $hidden, $sortable);
355 355
 
356 356
 		$this->set_pagination_args(
357 357
 			array(
358 358
 			'total_items' => $this->current_total_count,
359 359
 			'per_page'    => $this->per_page,
360
-			'total_pages' => ceil( $this->current_total_count / $this->per_page )
360
+			'total_pages' => ceil($this->current_total_count / $this->per_page)
361 361
 			)
362 362
 		);
363 363
 	}
@@ -367,18 +367,18 @@  discard block
 block discarded – undo
367 367
 	 *
368 368
 	 * @return array
369 369
 	 */
370
-	public function get_columns(){
370
+	public function get_columns() {
371 371
 		$columns = array(
372 372
 			'cb'                => '<input type="checkbox" />',
373
-			'subscription'      => __( 'Subscription', 'invoicing' ),
374
-			'start_date'        => __( 'Start Date', 'invoicing' ),
375
-			'renewal_date'      => __( 'Next Payment', 'invoicing' ),
376
-			'renewals'          => __( 'Payments', 'invoicing' ),
377
-			'item'              => __( 'Items', 'invoicing' ),
378
-			'status'            => __( 'Status', 'invoicing' ),
373
+			'subscription'      => __('Subscription', 'invoicing'),
374
+			'start_date'        => __('Start Date', 'invoicing'),
375
+			'renewal_date'      => __('Next Payment', 'invoicing'),
376
+			'renewals'          => __('Payments', 'invoicing'),
377
+			'item'              => __('Items', 'invoicing'),
378
+			'status'            => __('Status', 'invoicing'),
379 379
 		);
380 380
 
381
-		return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
381
+		return apply_filters('manage_getpaid_subscriptions_table_columns', $columns);
382 382
 	}
383 383
 
384 384
 	/**
@@ -388,15 +388,15 @@  discard block
 block discarded – undo
388 388
 	 */
389 389
 	public function get_sortable_columns() {
390 390
 		$sortable = array(
391
-			'subscription' => array( 'id', true ),
392
-			'start_date'   => array( 'created', true ),
393
-			'renewal_date' => array( 'expiration', true ),
394
-			'renewals'     => array( 'bill_times', true ),
395
-			'item'         => array( 'product_id', true ),
396
-			'status'       => array( 'status', true ),
391
+			'subscription' => array('id', true),
392
+			'start_date'   => array('created', true),
393
+			'renewal_date' => array('expiration', true),
394
+			'renewals'     => array('bill_times', true),
395
+			'item'         => array('product_id', true),
396
+			'status'       => array('status', true),
397 397
 		);
398 398
 
399
-		return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
399
+		return apply_filters('manage_getpaid_subscriptions_sortable_table_columns', $sortable);
400 400
 	}
401 401
 
402 402
 	/**
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 * @return bool
406 406
 	 */
407 407
 	public function has_items() {
408
-		return ! empty( $this->current_total_count );
408
+		return !empty($this->current_total_count);
409 409
 	}
410 410
 
411 411
 	/**
Please login to merge, or discard this patch.