Passed
Push — master ( 5b03f5...e1a3e9 )
by Brian
04:57
created
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +81 added lines, -81 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,25 +13,25 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
17
-        add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 );
18
-        add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 );
19
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 );
20
-        add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 );
21
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
22
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
17
+        add_action('admin_menu', array($this, 'add_customers_menu'), 18);
18
+        add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40);
19
+        add_action('admin_menu', array($this, 'add_addons_menu'), 100);
20
+        add_action('admin_menu', array($this, 'add_settings_menu'), 60);
21
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
22
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
23 23
     }
24 24
 
25 25
     public function admin_menu() {
26 26
 
27
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
27
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
28 28
         add_menu_page(
29
-            __( 'GetPaid', 'invoicing' ),
30
-            __( 'GetPaid', 'invoicing' ),
29
+            __('GetPaid', 'invoicing'),
30
+            __('GetPaid', 'invoicing'),
31 31
             $capability,
32 32
             'wpinv',
33 33
             null,
34
-            'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ),
34
+            'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')),
35 35
             '54.123460'
36 36
         );
37 37
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
     public function add_customers_menu() {
44 44
         add_submenu_page(
45 45
             'wpinv',
46
-            __( 'Customers', 'invoicing' ),
47
-            __( 'Customers', 'invoicing' ),
46
+            __('Customers', 'invoicing'),
47
+            __('Customers', 'invoicing'),
48 48
             wpinv_get_capability(),
49 49
             'wpinv-customers',
50
-            array( $this, 'customers_page' )
50
+            array($this, 'customers_page')
51 51
         );
52 52
     }
53 53
 
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
     public function add_subscriptions_menu() {
58 58
         add_submenu_page(
59 59
             'wpinv',
60
-            __( 'Subscriptions', 'invoicing' ),
61
-            __( 'Subscriptions', 'invoicing' ),
60
+            __('Subscriptions', 'invoicing'),
61
+            __('Subscriptions', 'invoicing'),
62 62
             wpinv_get_capability(),
63 63
             'wpinv-subscriptions',
64 64
             'wpinv_subscriptions_page'
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * Displays the customers page.
70 70
      */
71 71
     public function customers_page() {
72
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' );
72
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php');
73 73
         ?>
74 74
         <div class="wrap wpi-customers-wrap">
75 75
             <style>
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
                     width: 30%;
78 78
                 }
79 79
             </style>
80
-            <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?></h1>
80
+            <h1><?php echo esc_html(__('Customers', 'invoicing')); ?></h1>
81 81
             <form method="post">
82 82
             <?php
83 83
                 $table = new WPInv_Customers_Table();
84 84
                 $table->prepare_items();
85
-                $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' );
85
+                $table->search_box(__('Search Customers', 'invoicing'), 'search-customers');
86 86
                 $table->display();
87 87
             ?>
88 88
             </form>
@@ -96,16 +96,16 @@  discard block
 block discarded – undo
96 96
     public function add_settings_menu() {
97 97
         add_submenu_page(
98 98
             'wpinv',
99
-            __( 'Invoice Settings', 'invoicing' ),
100
-            __( 'Settings', 'invoicing' ),
101
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
99
+            __('Invoice Settings', 'invoicing'),
100
+            __('Settings', 'invoicing'),
101
+            apply_filters('invoicing_capability', wpinv_get_capability()),
102 102
             'wpinv-settings',
103
-            array( $this, 'options_page' )
103
+            array($this, 'options_page')
104 104
         );
105 105
     }
106 106
 
107
-    public function add_addons_menu(){
108
-        if ( !apply_filters( 'wpi_show_addons_page', true ) ) {
107
+    public function add_addons_menu() {
108
+        if (!apply_filters('wpi_show_addons_page', true)) {
109 109
             return;
110 110
         }
111 111
 
@@ -115,78 +115,78 @@  discard block
 block discarded – undo
115 115
             __('Extensions', 'invoicing'),
116 116
             'manage_options',
117 117
             'wpi-addons',
118
-            array( $this, 'addons_page' )
118
+            array($this, 'addons_page')
119 119
         );
120 120
     }
121 121
 
122
-    public function addons_page(){
122
+    public function addons_page() {
123 123
         $addon_obj = new WPInv_Admin_Addons();
124 124
         $addon_obj->output();
125 125
     }
126 126
 
127 127
     function options_page() {
128
-        $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
128
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
129 129
 
130
-        if ( $page !== 'wpinv-settings' ) {
130
+        if ($page !== 'wpinv-settings') {
131 131
             return;
132 132
         }
133 133
 
134 134
         $settings_tabs = wpinv_get_settings_tabs();
135 135
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
136
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
137
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
136
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
137
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
138 138
         $key           = 'main';
139 139
 
140
-        if ( is_array( $sections ) ) {
141
-            $key = key( $sections );
140
+        if (is_array($sections)) {
141
+            $key = key($sections);
142 142
         }
143 143
 
144
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
145
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
144
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
145
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
146 146
         ob_start();
147 147
         ?>
148 148
         <div class="wrap">
149 149
             <h1 class="nav-tab-wrapper">
150 150
                 <?php
151
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
152
-                    $tab_url = add_query_arg( array(
151
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
152
+                    $tab_url = add_query_arg(array(
153 153
                         'settings-updated' => false,
154 154
                         'tab' => $tab_id,
155
-                    ) );
155
+                    ));
156 156
 
157 157
                     // Remove the section from the tabs so we always end up at the main section
158
-                    $tab_url = remove_query_arg( 'section', $tab_url );
159
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
158
+                    $tab_url = remove_query_arg('section', $tab_url);
159
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
160 160
 
161 161
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
162 162
 
163
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
164
-                    echo esc_html( $tab_name );
163
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
164
+                    echo esc_html($tab_name);
165 165
                     echo '</a>';
166 166
                 }
167 167
                 ?>
168 168
             </h1>
169 169
             <?php
170
-            $number_of_sections = count( $sections );
170
+            $number_of_sections = count($sections);
171 171
             $number = 0;
172
-            if ( $number_of_sections > 1 ) {
172
+            if ($number_of_sections > 1) {
173 173
                 echo '<div><ul class="subsubsub">';
174
-                foreach( $sections as $section_id => $section_name ) {
174
+                foreach ($sections as $section_id => $section_name) {
175 175
                     echo '<li>';
176 176
                     $number++;
177
-                    $tab_url = add_query_arg( array(
177
+                    $tab_url = add_query_arg(array(
178 178
                         'settings-updated' => false,
179 179
                         'tab' => $active_tab,
180 180
                         'section' => $section_id
181
-                    ) );
182
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
181
+                    ));
182
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
183 183
                     $class = '';
184
-                    if ( $section == $section_id ) {
184
+                    if ($section == $section_id) {
185 185
                         $class = 'current';
186 186
                     }
187
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
187
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
188 188
 
189
-                    if ( $number != $number_of_sections ) {
189
+                    if ($number != $number_of_sections) {
190 190
                         echo ' | ';
191 191
                     }
192 192
                     echo '</li>';
@@ -198,20 +198,20 @@  discard block
 block discarded – undo
198 198
                 <form method="post" action="options.php">
199 199
                     <table class="form-table">
200 200
                         <?php
201
-                        settings_fields( 'wpinv_settings' );
201
+                        settings_fields('wpinv_settings');
202 202
 
203
-                        if ( 'main' === $section ) {
204
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
203
+                        if ('main' === $section) {
204
+                            do_action('wpinv_settings_tab_top', $active_tab);
205 205
                         }
206 206
 
207
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
208
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
209
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
210
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
207
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
208
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
209
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
210
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
211 211
 
212 212
                         // For backwards compatibility
213
-                        if ( 'main' === $section ) {
214
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
213
+                        if ('main' === $section) {
214
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
215 215
                         }
216 216
                         ?>
217 217
                     </table>
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     }
226 226
 
227 227
     public function remove_admin_submenus() {
228
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
228
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
229 229
     }
230 230
 
231 231
     /**
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 
236 236
         add_meta_box(
237 237
             'wpinv_endpoints_nav_link',
238
-            __( 'GetPaid endpoints', 'invoicing' ),
239
-            array( $this, 'nav_menu_links' ),
238
+            __('GetPaid endpoints', 'invoicing'),
239
+            array($this, 'nav_menu_links'),
240 240
             'nav-menus',
241 241
             'side',
242 242
             'low'
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
         $endpoints = $this->get_menu_items();
252 252
         ?>
253 253
         <div id="invoicing-endpoints" class="posttypediv">
254
-            <?php if ( ! empty( $endpoints['pages'] ) ) : ?>
254
+            <?php if (!empty($endpoints['pages'])) : ?>
255 255
                 <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
256 256
                     <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
257 257
                         <?php
258
-                            $walker = new Walker_Nav_Menu_Checklist( array() );
259
-                            echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) );
258
+                            $walker = new Walker_Nav_Menu_Checklist(array());
259
+                            echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
260 260
                         ?>
261 261
                     </ul>
262 262
                 </div>
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
             <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints">
266 266
                 <span class="list-controls hide-if-no-js">
267 267
                     <input type="checkbox" id="invoicing-endpoints-tab" class="select-all">
268
-                    <label for="invoicing-endpoints-tab"><?php _e( 'Select all', 'invoicing' ); ?></label>
268
+                    <label for="invoicing-endpoints-tab"><?php _e('Select all', 'invoicing'); ?></label>
269 269
                 </span>
270 270
 
271 271
                 <span class="add-to-menu">
272
-                    <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">
272
+                    <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">
273 273
                     <span class="spinner"></span>
274 274
                 </span>
275 275
             </p>
@@ -282,35 +282,35 @@  discard block
 block discarded – undo
282 282
      *
283 283
      * @return array.
284 284
      */
285
-    public function get_menu_items(){
285
+    public function get_menu_items() {
286 286
         $items = array();
287 287
 
288 288
         $pages = array(
289 289
             array(
290
-                'id'    => wpinv_get_option( 'invoice_history_page' ),
291
-                'label' => __( 'My Invoices', 'invoicing' ),
290
+                'id'    => wpinv_get_option('invoice_history_page'),
291
+                'label' => __('My Invoices', 'invoicing'),
292 292
             ),
293 293
             array(
294
-                'id'    => wpinv_get_option( 'invoice_subscription_page' ),
295
-                'label' => __( 'My Subscriptions', 'invoicing' ),
294
+                'id'    => wpinv_get_option('invoice_subscription_page'),
295
+                'label' => __('My Subscriptions', 'invoicing'),
296 296
             )
297 297
         );
298 298
 
299
-        foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) {
299
+        foreach (apply_filters('getpaid_menu_pages', $pages) as $page) {
300 300
 
301
-            if ( (int) $page['id'] > 0 ) {
301
+            if ((int) $page['id'] > 0) {
302 302
 
303 303
                 $item                   = new stdClass();
304 304
                 $item->object_id        = (int) $page['id'];
305 305
                 $item->db_id            = 0;
306
-                $item->object           =  'page';
306
+                $item->object           = 'page';
307 307
                 $item->menu_item_parent = 0;
308 308
                 $item->type             = 'post_type';
309
-                $item->title            = sanitize_text_field( $page['label'] );
310
-                $item->url              = get_permalink( (int) $page['id'] );
309
+                $item->title            = sanitize_text_field($page['label']);
310
+                $item->url              = get_permalink((int) $page['id']);
311 311
                 $item->target           = '';
312 312
                 $item->attr_title       = '';
313
-                $item->classes          = array( 'wpinv-menu-item' );
313
+                $item->classes          = array('wpinv-menu-item');
314 314
                 $item->xfn              = '';
315 315
 
316 316
                 $items['pages'][]       = $item;
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 
320 320
         }
321 321
 
322
-        return apply_filters( 'wpinv_menu_items', $items );
322
+        return apply_filters('wpinv_menu_items', $items);
323 323
     }
324 324
 
325 325
 }
Please login to merge, or discard this patch.
includes/admin/class-wpinv-customers-table.php 2 patches
Indentation   +351 added lines, -351 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 // Load WP_List_Table if not loaded
11 11
 if ( ! class_exists( 'WP_List_Table' ) ) {
12
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
15 15
 /**
@@ -21,354 +21,354 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class WPInv_Customers_Table extends WP_List_Table {
23 23
 
24
-	/**
25
-	 * @var int Number of items per page
26
-	 * @since 1.0.19
27
-	 */
28
-	public $per_page = 10;
29
-
30
-	/**
31
-	 * @var int Number of items
32
-	 * @since 1.0.19
33
-	 */
34
-	public $total = 0;
35
-
36
-	/**
37
-	 * Get things started
38
-	 *
39
-	 * @since 1.0.19
40
-	 * @see WP_List_Table::__construct()
41
-	 */
42
-	public function __construct() {
43
-
44
-		// Set parent defaults
45
-		parent::__construct( array(
46
-			'singular' => 'id',
47
-			'plural'   => 'ids',
48
-			'ajax'     => false,
49
-		) );
50
-
51
-	}
52
-
53
-	/**
54
-	 * Gets the name of the primary column.
55
-	 *
56
-	 * @since 1.0.19
57
-	 * @access protected
58
-	 *
59
-	 * @return string Name of the primary column.
60
-	 */
61
-	protected function get_primary_column_name() {
62
-		return 'name';
63
-	}
64
-
65
-	/**
66
-	 * This function renders most of the columns in the list table.
67
-	 *
68
-	 * @since 1.0.19
69
-	 *
70
-	 * @param WP_User $item
71
-	 * @param string $column_name The name of the column
72
-	 *
73
-	 * @return string Column Name
74
-	 */
75
-	public function column_default( $item, $column_name ) {
76
-		$value = sanitize_text_field( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) );
77
-		return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item );
78
-	}
79
-
80
-	/**
81
-	 * Displays the country column.
82
-	 *
83
-	 * @since 1.0.19
84
-	 *
85
-	 * @param WP_User $user
86
-	 *
87
-	 * @return string Column Name
88
-	 */
89
-	public function column_country( $user ) {
90
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
91
-		if ( $country ) {
92
-			$country = wpinv_country_name( $country );
93
-		}
94
-		return sanitize_text_field( $country );
95
-	}
96
-
97
-	/**
98
-	 * Displays the state column.
99
-	 *
100
-	 * @since 1.0.19
101
-	 *
102
-	 * @param WP_User $user
103
-	 *
104
-	 * @return string Column Name
105
-	 */
106
-	public function column_state( $user ) {
107
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
108
-		$state   = $user->_wpinv_state;
109
-		if ( $state ) {
110
-			$state = wpinv_state_name( $state, $country );
111
-		}
112
-
113
-		return sanitize_text_field( $state );
114
-	}
115
-
116
-	/**
117
-	 * Displays the signup column.
118
-	 *
119
-	 * @since 1.0.19
120
-	 *
121
-	 * @param WP_User $user
122
-	 *
123
-	 * @return string Column Name
124
-	 */
125
-	public function column_signup( $user ) {
126
-		return getpaid_format_date_value( $user->user_registered );
127
-	}
128
-
129
-	/**
130
-	 * Displays the total spent column.
131
-	 *
132
-	 * @since 1.0.19
133
-	 *
134
-	 * @param WP_User $user
135
-	 *
136
-	 * @return string Column Name
137
-	 */
138
-	public function column_total( $user ) {
139
-
140
-		$args = array(
141
-			'data'             => array(
142
-
143
-				'total'        => array(
144
-					'type'     => 'invoice_data',
145
-					'function' => 'SUM',
146
-					'name'     => 'total_sales',
147
-				)
148
-
149
-			),
150
-			'where'            => array(
151
-
152
-				'author'       => array(
153
-					'type'     => 'post_data',
154
-					'value'    => absint( $user->ID ),
155
-					'key'      => 'posts.post_author',
156
-					'operator' => '=',
157
-				),
158
-
159
-			),
160
-			'query_type'     => 'get_var',
161
-			'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ),
162
-		);
163
-
164
-		return wpinv_price( (float) GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
165
-
166
-	}
167
-
168
-	/**
169
-	 * Displays the total spent column.
170
-	 *
171
-	 * @since 1.0.19
172
-	 *
173
-	 * @param WP_User $user
174
-	 *
175
-	 * @return string Column Name
176
-	 */
177
-	public function column_invoices( $user ) {
178
-
179
-		$args = array(
180
-			'data'             => array(
181
-
182
-				'ID'           => array(
183
-					'type'     => 'post_data',
184
-					'function' => 'COUNT',
185
-					'name'     => 'count',
186
-					'distinct' => true,
187
-				),
188
-
189
-			),
190
-			'where'            => array(
191
-
192
-				'author'       => array(
193
-					'type'     => 'post_data',
194
-					'value'    => absint( $user->ID ),
195
-					'key'      => 'posts.post_author',
196
-					'operator' => '=',
197
-				),
198
-
199
-			),
200
-			'query_type'     => 'get_var',
201
-			'invoice_status' => array_keys( wpinv_get_invoice_statuses() ),
202
-		);
203
-
204
-		return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
205
-
206
-	}
207
-
208
-	/**
209
-	 * Generates content for a single row of the table
210
-	 * @since 1.0.19
211
-	 *
212
-	 * @param int $item The user id.
213
-	 */
214
-	public function single_row( $item ) {
215
-		$item = get_user_by( 'id', $item );
216
-
217
-		if ( empty( $item ) ) {
218
-			return;
219
-		}
220
-
221
-		echo '<tr>';
222
-		$this->single_row_columns( $item );
223
-		echo '</tr>';
224
-	}
225
-
226
-	/**
227
-	 * Displays the customers name
228
-	 *
229
-	 * @param  WP_User $customer customer.
230
-	 * @return string
231
-	 */
232
-	public function column_name( $customer ) {
233
-
234
-		// Customer view URL.
235
-		$view_url    = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) );
236
-		$row_actions = $this->row_actions(
237
-			array(
238
-				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>',
239
-			)
240
-		);
241
-
242
-		// Get user's address.
243
-		$address = wpinv_get_user_address( $customer->ID );
244
-
245
-		// Customer email address.
246
-		$email       = sanitize_email( $customer->user_email );
247
-
248
-		// Customer's avatar.
249
-		$avatar = esc_url( get_avatar_url( $email ) );
250
-		$avatar = "<img src='$avatar' height='32' width='32'/>";
251
-
252
-		// Customer's name.
253
-		$name   = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" );
254
-
255
-		if ( ! empty( $name ) ) {
256
-			$name = "<div style='overflow: hidden;height: 18px;'>$name</div>";
257
-		}
258
-
259
-		$email = "<div class='row-title'><a href='$view_url'>$email</a></div>";
260
-
261
-		return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>";
262
-
263
-	}
264
-
265
-	/**
266
-	 * Retrieve the table columns
267
-	 *
268
-	 * @since 1.0.19
269
-	 * @return array $columns Array of all the list table columns
270
-	 */
271
-	public function get_columns() {
272
-
273
-		$columns = array(
274
-			'name'     => __( 'Name', 'invoicing' ),
275
-			'country'  => __( 'Country', 'invoicing' ),
276
-			'state'    => __( 'State', 'invoicing' ),
277
-			'city'     => __( 'City', 'invoicing' ),
278
-			'zip'      => __( 'ZIP', 'invoicing' ),
279
-			'address'  => __( 'Address', 'invoicing' ),
280
-			'phone'    => __( 'Phone', 'invoicing' ),
281
-			'company'  => __( 'Company', 'invoicing' ),
282
-			'invoices' => __( 'Invoices', 'invoicing' ),
283
-			'total'    => __( 'Total Spend', 'invoicing' ),
284
-			'signup'   => __( 'Date created', 'invoicing' ),
285
-		);
286
-		return apply_filters( 'wpinv_customers_table_columns', $columns );
287
-
288
-	}
289
-
290
-	/**
291
-	 * Retrieve the current page number
292
-	 *
293
-	 * @since 1.0.19
294
-	 * @return int Current page number
295
-	 */
296
-	public function get_paged() {
297
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
298
-	}
299
-
300
-	/**
301
-	 * Returns bulk actions.
302
-	 *
303
-	 * @since 1.0.19
304
-	 * @return void
305
-	 */
306
-	public function bulk_actions( $which = '' ) {
307
-		return array();
308
-	}
309
-
310
-	/**
311
-	 *  Prepares the display query
312
-	 */
313
-	public function prepare_query() {
314
-		global $wpdb;
315
-
316
-		$post_types = '';
317
-
318
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
319
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
320
-		}
321
-
322
-		$post_types = rtrim( $post_types, ' OR' );
323
-
324
-		// Maybe search.
325
-		if ( ! empty( $_POST['s'] ) ) {
326
-			$users = get_users(
327
-				array(
328
-					'search'         => sanitize_text_field( urldecode( $_POST['s'] ) ),
329
-					'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
330
-					'fields'         => 'ID',
331
-				)
332
-			);
333
-
334
-			$users      = implode( ', ', $users );
335
-			$post_types = "($post_types) AND ( post_author IN ( $users ) )";
336
-		}
337
-
338
-		// Users with invoices.
339
-    	$customers = $wpdb->get_col(
340
-			$wpdb->prepare(
341
-				"SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types LIMIT %d,%d",
342
-				$this->get_paged() * 10 - 10,
343
-				$this->per_page
344
-			)
345
-		);
346
-
347
-		$this->items = $customers;
348
-		$this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" );
349
-
350
-	}
351
-
352
-	/**
353
-	 * Setup the final data for the table
354
-	 *
355
-	 * @since 1.0.19
356
-	 * @return void
357
-	 */
358
-	public function prepare_items() {
359
-		$columns               = $this->get_columns();
360
-		$hidden                = array(); // No hidden columns
361
-		$sortable              = $this->get_sortable_columns();
362
-		$this->_column_headers = array( $columns, $hidden, $sortable );
363
-		$this->prepare_query();
364
-
365
-		$this->set_pagination_args(
366
-			array(
367
-			'total_items' => $this->total,
368
-			'per_page'    => $this->per_page,
369
-			'total_pages' => ceil( $this->total / $this->per_page )
370
-			)
371
-		);
372
-
373
-	}
24
+    /**
25
+     * @var int Number of items per page
26
+     * @since 1.0.19
27
+     */
28
+    public $per_page = 10;
29
+
30
+    /**
31
+     * @var int Number of items
32
+     * @since 1.0.19
33
+     */
34
+    public $total = 0;
35
+
36
+    /**
37
+     * Get things started
38
+     *
39
+     * @since 1.0.19
40
+     * @see WP_List_Table::__construct()
41
+     */
42
+    public function __construct() {
43
+
44
+        // Set parent defaults
45
+        parent::__construct( array(
46
+            'singular' => 'id',
47
+            'plural'   => 'ids',
48
+            'ajax'     => false,
49
+        ) );
50
+
51
+    }
52
+
53
+    /**
54
+     * Gets the name of the primary column.
55
+     *
56
+     * @since 1.0.19
57
+     * @access protected
58
+     *
59
+     * @return string Name of the primary column.
60
+     */
61
+    protected function get_primary_column_name() {
62
+        return 'name';
63
+    }
64
+
65
+    /**
66
+     * This function renders most of the columns in the list table.
67
+     *
68
+     * @since 1.0.19
69
+     *
70
+     * @param WP_User $item
71
+     * @param string $column_name The name of the column
72
+     *
73
+     * @return string Column Name
74
+     */
75
+    public function column_default( $item, $column_name ) {
76
+        $value = sanitize_text_field( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) );
77
+        return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item );
78
+    }
79
+
80
+    /**
81
+     * Displays the country column.
82
+     *
83
+     * @since 1.0.19
84
+     *
85
+     * @param WP_User $user
86
+     *
87
+     * @return string Column Name
88
+     */
89
+    public function column_country( $user ) {
90
+        $country = wpinv_sanitize_country( $user->_wpinv_country );
91
+        if ( $country ) {
92
+            $country = wpinv_country_name( $country );
93
+        }
94
+        return sanitize_text_field( $country );
95
+    }
96
+
97
+    /**
98
+     * Displays the state column.
99
+     *
100
+     * @since 1.0.19
101
+     *
102
+     * @param WP_User $user
103
+     *
104
+     * @return string Column Name
105
+     */
106
+    public function column_state( $user ) {
107
+        $country = wpinv_sanitize_country( $user->_wpinv_country );
108
+        $state   = $user->_wpinv_state;
109
+        if ( $state ) {
110
+            $state = wpinv_state_name( $state, $country );
111
+        }
112
+
113
+        return sanitize_text_field( $state );
114
+    }
115
+
116
+    /**
117
+     * Displays the signup column.
118
+     *
119
+     * @since 1.0.19
120
+     *
121
+     * @param WP_User $user
122
+     *
123
+     * @return string Column Name
124
+     */
125
+    public function column_signup( $user ) {
126
+        return getpaid_format_date_value( $user->user_registered );
127
+    }
128
+
129
+    /**
130
+     * Displays the total spent column.
131
+     *
132
+     * @since 1.0.19
133
+     *
134
+     * @param WP_User $user
135
+     *
136
+     * @return string Column Name
137
+     */
138
+    public function column_total( $user ) {
139
+
140
+        $args = array(
141
+            'data'             => array(
142
+
143
+                'total'        => array(
144
+                    'type'     => 'invoice_data',
145
+                    'function' => 'SUM',
146
+                    'name'     => 'total_sales',
147
+                )
148
+
149
+            ),
150
+            'where'            => array(
151
+
152
+                'author'       => array(
153
+                    'type'     => 'post_data',
154
+                    'value'    => absint( $user->ID ),
155
+                    'key'      => 'posts.post_author',
156
+                    'operator' => '=',
157
+                ),
158
+
159
+            ),
160
+            'query_type'     => 'get_var',
161
+            'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ),
162
+        );
163
+
164
+        return wpinv_price( (float) GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
165
+
166
+    }
167
+
168
+    /**
169
+     * Displays the total spent column.
170
+     *
171
+     * @since 1.0.19
172
+     *
173
+     * @param WP_User $user
174
+     *
175
+     * @return string Column Name
176
+     */
177
+    public function column_invoices( $user ) {
178
+
179
+        $args = array(
180
+            'data'             => array(
181
+
182
+                'ID'           => array(
183
+                    'type'     => 'post_data',
184
+                    'function' => 'COUNT',
185
+                    'name'     => 'count',
186
+                    'distinct' => true,
187
+                ),
188
+
189
+            ),
190
+            'where'            => array(
191
+
192
+                'author'       => array(
193
+                    'type'     => 'post_data',
194
+                    'value'    => absint( $user->ID ),
195
+                    'key'      => 'posts.post_author',
196
+                    'operator' => '=',
197
+                ),
198
+
199
+            ),
200
+            'query_type'     => 'get_var',
201
+            'invoice_status' => array_keys( wpinv_get_invoice_statuses() ),
202
+        );
203
+
204
+        return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
205
+
206
+    }
207
+
208
+    /**
209
+     * Generates content for a single row of the table
210
+     * @since 1.0.19
211
+     *
212
+     * @param int $item The user id.
213
+     */
214
+    public function single_row( $item ) {
215
+        $item = get_user_by( 'id', $item );
216
+
217
+        if ( empty( $item ) ) {
218
+            return;
219
+        }
220
+
221
+        echo '<tr>';
222
+        $this->single_row_columns( $item );
223
+        echo '</tr>';
224
+    }
225
+
226
+    /**
227
+     * Displays the customers name
228
+     *
229
+     * @param  WP_User $customer customer.
230
+     * @return string
231
+     */
232
+    public function column_name( $customer ) {
233
+
234
+        // Customer view URL.
235
+        $view_url    = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) );
236
+        $row_actions = $this->row_actions(
237
+            array(
238
+                'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>',
239
+            )
240
+        );
241
+
242
+        // Get user's address.
243
+        $address = wpinv_get_user_address( $customer->ID );
244
+
245
+        // Customer email address.
246
+        $email       = sanitize_email( $customer->user_email );
247
+
248
+        // Customer's avatar.
249
+        $avatar = esc_url( get_avatar_url( $email ) );
250
+        $avatar = "<img src='$avatar' height='32' width='32'/>";
251
+
252
+        // Customer's name.
253
+        $name   = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" );
254
+
255
+        if ( ! empty( $name ) ) {
256
+            $name = "<div style='overflow: hidden;height: 18px;'>$name</div>";
257
+        }
258
+
259
+        $email = "<div class='row-title'><a href='$view_url'>$email</a></div>";
260
+
261
+        return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>";
262
+
263
+    }
264
+
265
+    /**
266
+     * Retrieve the table columns
267
+     *
268
+     * @since 1.0.19
269
+     * @return array $columns Array of all the list table columns
270
+     */
271
+    public function get_columns() {
272
+
273
+        $columns = array(
274
+            'name'     => __( 'Name', 'invoicing' ),
275
+            'country'  => __( 'Country', 'invoicing' ),
276
+            'state'    => __( 'State', 'invoicing' ),
277
+            'city'     => __( 'City', 'invoicing' ),
278
+            'zip'      => __( 'ZIP', 'invoicing' ),
279
+            'address'  => __( 'Address', 'invoicing' ),
280
+            'phone'    => __( 'Phone', 'invoicing' ),
281
+            'company'  => __( 'Company', 'invoicing' ),
282
+            'invoices' => __( 'Invoices', 'invoicing' ),
283
+            'total'    => __( 'Total Spend', 'invoicing' ),
284
+            'signup'   => __( 'Date created', 'invoicing' ),
285
+        );
286
+        return apply_filters( 'wpinv_customers_table_columns', $columns );
287
+
288
+    }
289
+
290
+    /**
291
+     * Retrieve the current page number
292
+     *
293
+     * @since 1.0.19
294
+     * @return int Current page number
295
+     */
296
+    public function get_paged() {
297
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
298
+    }
299
+
300
+    /**
301
+     * Returns bulk actions.
302
+     *
303
+     * @since 1.0.19
304
+     * @return void
305
+     */
306
+    public function bulk_actions( $which = '' ) {
307
+        return array();
308
+    }
309
+
310
+    /**
311
+     *  Prepares the display query
312
+     */
313
+    public function prepare_query() {
314
+        global $wpdb;
315
+
316
+        $post_types = '';
317
+
318
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
319
+            $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
320
+        }
321
+
322
+        $post_types = rtrim( $post_types, ' OR' );
323
+
324
+        // Maybe search.
325
+        if ( ! empty( $_POST['s'] ) ) {
326
+            $users = get_users(
327
+                array(
328
+                    'search'         => sanitize_text_field( urldecode( $_POST['s'] ) ),
329
+                    'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
330
+                    'fields'         => 'ID',
331
+                )
332
+            );
333
+
334
+            $users      = implode( ', ', $users );
335
+            $post_types = "($post_types) AND ( post_author IN ( $users ) )";
336
+        }
337
+
338
+        // Users with invoices.
339
+        $customers = $wpdb->get_col(
340
+            $wpdb->prepare(
341
+                "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types LIMIT %d,%d",
342
+                $this->get_paged() * 10 - 10,
343
+                $this->per_page
344
+            )
345
+        );
346
+
347
+        $this->items = $customers;
348
+        $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" );
349
+
350
+    }
351
+
352
+    /**
353
+     * Setup the final data for the table
354
+     *
355
+     * @since 1.0.19
356
+     * @return void
357
+     */
358
+    public function prepare_items() {
359
+        $columns               = $this->get_columns();
360
+        $hidden                = array(); // No hidden columns
361
+        $sortable              = $this->get_sortable_columns();
362
+        $this->_column_headers = array( $columns, $hidden, $sortable );
363
+        $this->prepare_query();
364
+
365
+        $this->set_pagination_args(
366
+            array(
367
+            'total_items' => $this->total,
368
+            'per_page'    => $this->per_page,
369
+            'total_pages' => ceil( $this->total / $this->per_page )
370
+            )
371
+        );
372
+
373
+    }
374 374
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 // Exit if accessed directly
8
-if ( ! defined( 'ABSPATH' ) ) exit;
8
+if (!defined('ABSPATH')) exit;
9 9
 
10 10
 // Load WP_List_Table if not loaded
11
-if ( ! class_exists( 'WP_List_Table' ) ) {
11
+if (!class_exists('WP_List_Table')) {
12 12
 	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 	public function __construct() {
43 43
 
44 44
 		// Set parent defaults
45
-		parent::__construct( array(
45
+		parent::__construct(array(
46 46
 			'singular' => 'id',
47 47
 			'plural'   => 'ids',
48 48
 			'ajax'     => false,
49
-		) );
49
+		));
50 50
 
51 51
 	}
52 52
 
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @return string Column Name
74 74
 	 */
75
-	public function column_default( $item, $column_name ) {
76
-		$value = sanitize_text_field( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) );
77
-		return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item );
75
+	public function column_default($item, $column_name) {
76
+		$value = sanitize_text_field(get_user_meta($item->ID, '_wpinv_' . $column_name, true));
77
+		return apply_filters('wpinv_customers_table_column' . $column_name, $value, $item);
78 78
 	}
79 79
 
80 80
 	/**
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return string Column Name
88 88
 	 */
89
-	public function column_country( $user ) {
90
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
91
-		if ( $country ) {
92
-			$country = wpinv_country_name( $country );
89
+	public function column_country($user) {
90
+		$country = wpinv_sanitize_country($user->_wpinv_country);
91
+		if ($country) {
92
+			$country = wpinv_country_name($country);
93 93
 		}
94
-		return sanitize_text_field( $country );
94
+		return sanitize_text_field($country);
95 95
 	}
96 96
 
97 97
 	/**
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @return string Column Name
105 105
 	 */
106
-	public function column_state( $user ) {
107
-		$country = wpinv_sanitize_country( $user->_wpinv_country );
106
+	public function column_state($user) {
107
+		$country = wpinv_sanitize_country($user->_wpinv_country);
108 108
 		$state   = $user->_wpinv_state;
109
-		if ( $state ) {
110
-			$state = wpinv_state_name( $state, $country );
109
+		if ($state) {
110
+			$state = wpinv_state_name($state, $country);
111 111
 		}
112 112
 
113
-		return sanitize_text_field( $state );
113
+		return sanitize_text_field($state);
114 114
 	}
115 115
 
116 116
 	/**
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return string Column Name
124 124
 	 */
125
-	public function column_signup( $user ) {
126
-		return getpaid_format_date_value( $user->user_registered );
125
+	public function column_signup($user) {
126
+		return getpaid_format_date_value($user->user_registered);
127 127
 	}
128 128
 
129 129
 	/**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @return string Column Name
137 137
 	 */
138
-	public function column_total( $user ) {
138
+	public function column_total($user) {
139 139
 
140 140
 		$args = array(
141 141
 			'data'             => array(
@@ -151,17 +151,17 @@  discard block
 block discarded – undo
151 151
 
152 152
 				'author'       => array(
153 153
 					'type'     => 'post_data',
154
-					'value'    => absint( $user->ID ),
154
+					'value'    => absint($user->ID),
155 155
 					'key'      => 'posts.post_author',
156 156
 					'operator' => '=',
157 157
 				),
158 158
 
159 159
 			),
160 160
 			'query_type'     => 'get_var',
161
-			'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ),
161
+			'invoice_status' => array('wpi-renewal', 'wpi-processing', 'publish'),
162 162
 		);
163 163
 
164
-		return wpinv_price( (float) GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
164
+		return wpinv_price((float) GetPaid_Reports_Helper::get_invoice_report_data($args));
165 165
 
166 166
 	}
167 167
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 *
175 175
 	 * @return string Column Name
176 176
 	 */
177
-	public function column_invoices( $user ) {
177
+	public function column_invoices($user) {
178 178
 
179 179
 		$args = array(
180 180
 			'data'             => array(
@@ -191,17 +191,17 @@  discard block
 block discarded – undo
191 191
 
192 192
 				'author'       => array(
193 193
 					'type'     => 'post_data',
194
-					'value'    => absint( $user->ID ),
194
+					'value'    => absint($user->ID),
195 195
 					'key'      => 'posts.post_author',
196 196
 					'operator' => '=',
197 197
 				),
198 198
 
199 199
 			),
200 200
 			'query_type'     => 'get_var',
201
-			'invoice_status' => array_keys( wpinv_get_invoice_statuses() ),
201
+			'invoice_status' => array_keys(wpinv_get_invoice_statuses()),
202 202
 		);
203 203
 
204
-		return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
204
+		return absint(GetPaid_Reports_Helper::get_invoice_report_data($args));
205 205
 
206 206
 	}
207 207
 
@@ -211,15 +211,15 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @param int $item The user id.
213 213
 	 */
214
-	public function single_row( $item ) {
215
-		$item = get_user_by( 'id', $item );
214
+	public function single_row($item) {
215
+		$item = get_user_by('id', $item);
216 216
 
217
-		if ( empty( $item ) ) {
217
+		if (empty($item)) {
218 218
 			return;
219 219
 		}
220 220
 
221 221
 		echo '<tr>';
222
-		$this->single_row_columns( $item );
222
+		$this->single_row_columns($item);
223 223
 		echo '</tr>';
224 224
 	}
225 225
 
@@ -229,30 +229,30 @@  discard block
 block discarded – undo
229 229
 	 * @param  WP_User $customer customer.
230 230
 	 * @return string
231 231
 	 */
232
-	public function column_name( $customer ) {
232
+	public function column_name($customer) {
233 233
 
234 234
 		// Customer view URL.
235
-		$view_url    = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) );
235
+		$view_url    = esc_url(add_query_arg('user_id', $customer->ID, admin_url('user-edit.php')));
236 236
 		$row_actions = $this->row_actions(
237 237
 			array(
238
-				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>',
238
+				'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>',
239 239
 			)
240 240
 		);
241 241
 
242 242
 		// Get user's address.
243
-		$address = wpinv_get_user_address( $customer->ID );
243
+		$address = wpinv_get_user_address($customer->ID);
244 244
 
245 245
 		// Customer email address.
246
-		$email       = sanitize_email( $customer->user_email );
246
+		$email = sanitize_email($customer->user_email);
247 247
 
248 248
 		// Customer's avatar.
249
-		$avatar = esc_url( get_avatar_url( $email ) );
249
+		$avatar = esc_url(get_avatar_url($email));
250 250
 		$avatar = "<img src='$avatar' height='32' width='32'/>";
251 251
 
252 252
 		// Customer's name.
253
-		$name   = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" );
253
+		$name   = sanitize_text_field("{$address['first_name']} {$address['last_name']}");
254 254
 
255
-		if ( ! empty( $name ) ) {
255
+		if (!empty($name)) {
256 256
 			$name = "<div style='overflow: hidden;height: 18px;'>$name</div>";
257 257
 		}
258 258
 
@@ -271,19 +271,19 @@  discard block
 block discarded – undo
271 271
 	public function get_columns() {
272 272
 
273 273
 		$columns = array(
274
-			'name'     => __( 'Name', 'invoicing' ),
275
-			'country'  => __( 'Country', 'invoicing' ),
276
-			'state'    => __( 'State', 'invoicing' ),
277
-			'city'     => __( 'City', 'invoicing' ),
278
-			'zip'      => __( 'ZIP', 'invoicing' ),
279
-			'address'  => __( 'Address', 'invoicing' ),
280
-			'phone'    => __( 'Phone', 'invoicing' ),
281
-			'company'  => __( 'Company', 'invoicing' ),
282
-			'invoices' => __( 'Invoices', 'invoicing' ),
283
-			'total'    => __( 'Total Spend', 'invoicing' ),
284
-			'signup'   => __( 'Date created', 'invoicing' ),
274
+			'name'     => __('Name', 'invoicing'),
275
+			'country'  => __('Country', 'invoicing'),
276
+			'state'    => __('State', 'invoicing'),
277
+			'city'     => __('City', 'invoicing'),
278
+			'zip'      => __('ZIP', 'invoicing'),
279
+			'address'  => __('Address', 'invoicing'),
280
+			'phone'    => __('Phone', 'invoicing'),
281
+			'company'  => __('Company', 'invoicing'),
282
+			'invoices' => __('Invoices', 'invoicing'),
283
+			'total'    => __('Total Spend', 'invoicing'),
284
+			'signup'   => __('Date created', 'invoicing'),
285 285
 		);
286
-		return apply_filters( 'wpinv_customers_table_columns', $columns );
286
+		return apply_filters('wpinv_customers_table_columns', $columns);
287 287
 
288 288
 	}
289 289
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	 * @return int Current page number
295 295
 	 */
296 296
 	public function get_paged() {
297
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
297
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
298 298
 	}
299 299
 
300 300
 	/**
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	 * @since 1.0.19
304 304
 	 * @return void
305 305
 	 */
306
-	public function bulk_actions( $which = '' ) {
306
+	public function bulk_actions($which = '') {
307 307
 		return array();
308 308
 	}
309 309
 
@@ -315,23 +315,23 @@  discard block
 block discarded – undo
315 315
 
316 316
 		$post_types = '';
317 317
 
318
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
319
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
318
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
319
+			$post_types .= $wpdb->prepare("post_type=%s OR ", $post_type);
320 320
 		}
321 321
 
322
-		$post_types = rtrim( $post_types, ' OR' );
322
+		$post_types = rtrim($post_types, ' OR');
323 323
 
324 324
 		// Maybe search.
325
-		if ( ! empty( $_POST['s'] ) ) {
325
+		if (!empty($_POST['s'])) {
326 326
 			$users = get_users(
327 327
 				array(
328
-					'search'         => sanitize_text_field( urldecode( $_POST['s'] ) ),
329
-					'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
328
+					'search'         => sanitize_text_field(urldecode($_POST['s'])),
329
+					'search_columns' => array('user_login', 'user_email', 'display_name'),
330 330
 					'fields'         => 'ID',
331 331
 				)
332 332
 			);
333 333
 
334
-			$users      = implode( ', ', $users );
334
+			$users      = implode(', ', $users);
335 335
 			$post_types = "($post_types) AND ( post_author IN ( $users ) )";
336 336
 		}
337 337
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 		);
346 346
 
347 347
 		$this->items = $customers;
348
-		$this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" );
348
+		$this->total = (int) $wpdb->get_var("SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types");
349 349
 
350 350
 	}
351 351
 
@@ -359,14 +359,14 @@  discard block
 block discarded – undo
359 359
 		$columns               = $this->get_columns();
360 360
 		$hidden                = array(); // No hidden columns
361 361
 		$sortable              = $this->get_sortable_columns();
362
-		$this->_column_headers = array( $columns, $hidden, $sortable );
362
+		$this->_column_headers = array($columns, $hidden, $sortable);
363 363
 		$this->prepare_query();
364 364
 
365 365
 		$this->set_pagination_args(
366 366
 			array(
367 367
 			'total_items' => $this->total,
368 368
 			'per_page'    => $this->per_page,
369
-			'total_pages' => ceil( $this->total / $this->per_page )
369
+			'total_pages' => ceil($this->total / $this->per_page)
370 370
 			)
371 371
 		);
372 372
 
Please login to merge, or discard this patch.