Passed
Push — master ( 1ba24c...55ab8f )
by Stiofan
33s
created
includes/wpinv-post-types.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -7,44 +7,44 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14
-add_action( 'init', 'wpinv_register_post_types', 1 );
14
+add_action('init', 'wpinv_register_post_types', 1);
15 15
 function wpinv_register_post_types() {    
16 16
     $labels = array(
17
-        'name'               => _x( 'Invoices', 'post type general name', 'invoicing' ),
18
-        'singular_name'      => _x( 'Invoice', 'post type singular name', 'invoicing' ),
19
-        'menu_name'          => _x( 'Invoices', 'admin menu', 'invoicing' ),
20
-        'name_admin_bar'     => _x( 'Invoice', 'add new on admin bar', 'invoicing' ),
21
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
22
-        'add_new_item'       => __( 'Add New Invoice', 'invoicing' ),
23
-        'new_item'           => __( 'New Invoice', 'invoicing' ),
24
-        'edit_item'          => __( 'Edit Invoice', 'invoicing' ),
25
-        'view_item'          => __( 'View Invoice', 'invoicing' ),
26
-        'all_items'          => __( 'Invoices', 'invoicing' ),
27
-        'search_items'       => __( 'Search Invoices', 'invoicing' ),
28
-        'parent_item_colon'  => __( 'Parent Invoices:', 'invoicing' ),
29
-        'not_found'          => __( 'No invoices found.', 'invoicing' ),
30
-        'not_found_in_trash' => __( 'No invoices found in trash.', 'invoicing' )
17
+        'name'               => _x('Invoices', 'post type general name', 'invoicing'),
18
+        'singular_name'      => _x('Invoice', 'post type singular name', 'invoicing'),
19
+        'menu_name'          => _x('Invoices', 'admin menu', 'invoicing'),
20
+        'name_admin_bar'     => _x('Invoice', 'add new on admin bar', 'invoicing'),
21
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
22
+        'add_new_item'       => __('Add New Invoice', 'invoicing'),
23
+        'new_item'           => __('New Invoice', 'invoicing'),
24
+        'edit_item'          => __('Edit Invoice', 'invoicing'),
25
+        'view_item'          => __('View Invoice', 'invoicing'),
26
+        'all_items'          => __('Invoices', 'invoicing'),
27
+        'search_items'       => __('Search Invoices', 'invoicing'),
28
+        'parent_item_colon'  => __('Parent Invoices:', 'invoicing'),
29
+        'not_found'          => __('No invoices found.', 'invoicing'),
30
+        'not_found_in_trash' => __('No invoices found in trash.', 'invoicing')
31 31
     );
32
-    $labels = apply_filters( 'wpinv_labels', $labels );
32
+    $labels = apply_filters('wpinv_labels', $labels);
33 33
     
34 34
     $menu_icon = WPINV_PLUGIN_URL . '/assets/images/favicon.ico';
35
-    $menu_icon = apply_filters( 'wpinv_menu_icon_invoice', $menu_icon );
35
+    $menu_icon = apply_filters('wpinv_menu_icon_invoice', $menu_icon);
36 36
 
37 37
     $cap_type = 'wpi_invoice';
38 38
     $args = array(
39 39
         'labels'             => $labels,
40
-        'description'        => __( 'This is where invoices are stored.', 'invoicing' ),
40
+        'description'        => __('This is where invoices are stored.', 'invoicing'),
41 41
         'public'             => true,
42 42
         'can_export'         => true,
43 43
         '_builtin'           => false,
44 44
         'publicly_queryable' => true,
45 45
         'exclude_from_search'=> true,
46 46
         'show_ui'            => true,
47
-        'show_in_menu'       => current_user_can( 'manage_invoicing' ) ? 'wpinv' : true,
47
+        'show_in_menu'       => current_user_can('manage_invoicing') ? 'wpinv' : true,
48 48
         'show_in_nav_menus'  => false,
49 49
         'query_var'          => false,
50 50
         'rewrite'            => true,
@@ -69,39 +69,39 @@  discard block
 block discarded – undo
69 69
         'has_archive'        => false,
70 70
         'hierarchical'       => false,
71 71
         'menu_position'      => null,
72
-        'supports'           => array( 'title', 'author' ),
72
+        'supports'           => array('title', 'author'),
73 73
         'menu_icon'          => 'dashicons-media-spreadsheet',
74 74
     );
75 75
             
76
-    $args = apply_filters( 'wpinv_register_post_type_invoice', $args );
76
+    $args = apply_filters('wpinv_register_post_type_invoice', $args);
77 77
     
78
-    register_post_type( 'wpi_invoice', $args );
78
+    register_post_type('wpi_invoice', $args);
79 79
     
80 80
     $items_labels = array(
81
-        'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
82
-        'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
83
-        'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
84
-        'add_new'            => _x( 'Add New', 'wpi_item', 'invoicing' ),
85
-        'add_new_item'       => __( 'Add New Item', 'invoicing' ),
86
-        'new_item'           => __( 'New Item', 'invoicing' ),
87
-        'edit_item'          => __( 'Edit Item', 'invoicing' ),
88
-        'view_item'          => __( 'View Item', 'invoicing' ),
89
-        'all_items'          => __( 'Items', 'invoicing' ),
90
-        'search_items'       => __( 'Search Items', 'invoicing' ),
81
+        'name'               => _x('Items', 'post type general name', 'invoicing'),
82
+        'singular_name'      => _x('Item', 'post type singular name', 'invoicing'),
83
+        'menu_name'          => _x('Items', 'admin menu', 'invoicing'),
84
+        'add_new'            => _x('Add New', 'wpi_item', 'invoicing'),
85
+        'add_new_item'       => __('Add New Item', 'invoicing'),
86
+        'new_item'           => __('New Item', 'invoicing'),
87
+        'edit_item'          => __('Edit Item', 'invoicing'),
88
+        'view_item'          => __('View Item', 'invoicing'),
89
+        'all_items'          => __('Items', 'invoicing'),
90
+        'search_items'       => __('Search Items', 'invoicing'),
91 91
         'parent_item_colon'  => '',
92
-        'not_found'          => __( 'No items found.', 'invoicing' ),
93
-        'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
92
+        'not_found'          => __('No items found.', 'invoicing'),
93
+        'not_found_in_trash' => __('No items found in trash.', 'invoicing')
94 94
     );
95
-    $items_labels = apply_filters( 'wpinv_items_labels', $items_labels );
95
+    $items_labels = apply_filters('wpinv_items_labels', $items_labels);
96 96
 
97 97
     $cap_type = 'wpi_item';
98 98
     $invoice_item_args = array(
99 99
         'labels'                => $items_labels,
100 100
         'public'                => false,
101 101
         'show_ui'               => true,
102
-        'show_in_menu'          => current_user_can( 'manage_invoicing' ) ? 'wpinv' : false,
102
+        'show_in_menu'          => current_user_can('manage_invoicing') ? 'wpinv' : false,
103 103
         'show_in_nav_menus'     => false,
104
-        'supports'              => array( 'title', 'excerpt' ),
104
+        'supports'              => array('title', 'excerpt'),
105 105
         'register_meta_box_cb'  => 'wpinv_register_item_meta_boxes',
106 106
         'rewrite'               => false,
107 107
         'query_var'             => false,
@@ -125,40 +125,40 @@  discard block
 block discarded – undo
125 125
         ),
126 126
         'can_export'            => true,
127 127
     );
128
-    $invoice_item_args = apply_filters( 'wpinv_register_post_type_invoice_item', $invoice_item_args );
128
+    $invoice_item_args = apply_filters('wpinv_register_post_type_invoice_item', $invoice_item_args);
129 129
 
130
-    register_post_type( 'wpi_item', $invoice_item_args );
130
+    register_post_type('wpi_item', $invoice_item_args);
131 131
     
132 132
     $labels = array(
133
-        'name'               => _x( 'Discounts', 'post type general name', 'invoicing' ),
134
-        'singular_name'      => _x( 'Discount', 'post type singular name', 'invoicing' ),
135
-        'menu_name'          => _x( 'Discounts', 'admin menu', 'invoicing' ),
136
-        'name_admin_bar'     => _x( 'Discount', 'add new on admin bar', 'invoicing' ),
137
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
138
-        'add_new_item'       => __( 'Add New Discount', 'invoicing' ),
139
-        'new_item'           => __( 'New Discount', 'invoicing' ),
140
-        'edit_item'          => __( 'Edit Discount', 'invoicing' ),
141
-        'view_item'          => __( 'View Discount', 'invoicing' ),
142
-        'all_items'          => __( 'Discounts', 'invoicing' ),
143
-        'search_items'       => __( 'Search Discounts', 'invoicing' ),
144
-        'parent_item_colon'  => __( 'Parent Discounts:', 'invoicing' ),
145
-        'not_found'          => __( 'No discounts found.', 'invoicing' ),
146
-        'not_found_in_trash' => __( 'No discounts found in trash.', 'invoicing' )
133
+        'name'               => _x('Discounts', 'post type general name', 'invoicing'),
134
+        'singular_name'      => _x('Discount', 'post type singular name', 'invoicing'),
135
+        'menu_name'          => _x('Discounts', 'admin menu', 'invoicing'),
136
+        'name_admin_bar'     => _x('Discount', 'add new on admin bar', 'invoicing'),
137
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
138
+        'add_new_item'       => __('Add New Discount', 'invoicing'),
139
+        'new_item'           => __('New Discount', 'invoicing'),
140
+        'edit_item'          => __('Edit Discount', 'invoicing'),
141
+        'view_item'          => __('View Discount', 'invoicing'),
142
+        'all_items'          => __('Discounts', 'invoicing'),
143
+        'search_items'       => __('Search Discounts', 'invoicing'),
144
+        'parent_item_colon'  => __('Parent Discounts:', 'invoicing'),
145
+        'not_found'          => __('No discounts found.', 'invoicing'),
146
+        'not_found_in_trash' => __('No discounts found in trash.', 'invoicing')
147 147
     );
148
-    $labels = apply_filters( 'wpinv_discounts_labels', $labels );
148
+    $labels = apply_filters('wpinv_discounts_labels', $labels);
149 149
 
150 150
     $cap_type = 'wpi_discount';
151 151
     
152 152
     $args = array(
153 153
         'labels'             => $labels,
154
-        'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
154
+        'description'        => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'),
155 155
         'public'             => false,
156 156
         'can_export'         => true,
157 157
         '_builtin'           => false,
158 158
         'publicly_queryable' => false,
159 159
         'exclude_from_search'=> true,
160 160
         'show_ui'            => true,
161
-        'show_in_menu'       => current_user_can( 'manage_invoicing' ) ? 'wpinv' : false,
161
+        'show_in_menu'       => current_user_can('manage_invoicing') ? 'wpinv' : false,
162 162
         'query_var'          => false,
163 163
         'rewrite'            => false,
164 164
         'capability_type'    => $cap_type,
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         ),
182 182
         'has_archive'        => false,
183 183
         'hierarchical'       => false,
184
-        'supports'           => array( 'title', 'excerpt' ),
184
+        'supports'           => array('title', 'excerpt'),
185 185
         'register_meta_box_cb'  => 'wpinv_register_discount_meta_boxes',
186 186
         'show_in_nav_menus'  => false,
187 187
         'show_in_admin_bar'  => true,
@@ -189,107 +189,107 @@  discard block
 block discarded – undo
189 189
         'menu_position'      => null,
190 190
     );
191 191
             
192
-    $args = apply_filters( 'wpinv_register_post_type_discount', $args );
192
+    $args = apply_filters('wpinv_register_post_type_discount', $args);
193 193
     
194
-    register_post_type( 'wpi_discount', $args );
194
+    register_post_type('wpi_discount', $args);
195 195
 }
196 196
 
197 197
 function wpinv_get_default_labels() {
198 198
     $defaults = array(
199
-       'singular' => __( 'Invoice', 'invoicing' ),
200
-       'plural'   => __( 'Invoices', 'invoicing' )
199
+       'singular' => __('Invoice', 'invoicing'),
200
+       'plural'   => __('Invoices', 'invoicing')
201 201
     );
202 202
     
203
-    return apply_filters( 'wpinv_default_invoices_name', $defaults );
203
+    return apply_filters('wpinv_default_invoices_name', $defaults);
204 204
 }
205 205
 
206
-function wpinv_get_label_singular( $lowercase = false ) {
206
+function wpinv_get_label_singular($lowercase = false) {
207 207
     $defaults = wpinv_get_default_labels();
208 208
     
209
-    return ($lowercase) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
209
+    return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
210 210
 }
211 211
 
212
-function wpinv_get_label_plural( $lowercase = false ) {
212
+function wpinv_get_label_plural($lowercase = false) {
213 213
     $defaults = wpinv_get_default_labels();
214 214
     
215
-    return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
215
+    return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
216 216
 }
217 217
 
218
-function wpinv_change_default_title( $title ) {
219
-     if ( !is_admin() ) {
218
+function wpinv_change_default_title($title) {
219
+     if (!is_admin()) {
220 220
         $label = wpinv_get_label_singular();
221
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
221
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
222 222
         return $title;
223 223
      }
224 224
 
225 225
      $screen = get_current_screen();
226 226
 
227
-     if ( 'wpi_invoice' == $screen->post_type ) {
227
+     if ('wpi_invoice' == $screen->post_type) {
228 228
         $label = wpinv_get_label_singular();
229
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
229
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
230 230
      }
231 231
 
232 232
      return $title;
233 233
 }
234
-add_filter( 'enter_title_here', 'wpinv_change_default_title' );
234
+add_filter('enter_title_here', 'wpinv_change_default_title');
235 235
 
236 236
 function wpinv_register_post_status() {
237
-    register_post_status( 'wpi-pending', array(
238
-        'label'                     => _x( 'Pending', 'Invoice status', 'invoicing' ),
237
+    register_post_status('wpi-pending', array(
238
+        'label'                     => _x('Pending', 'Invoice status', 'invoicing'),
239 239
         'public'                    => true,
240 240
         'exclude_from_search'       => true,
241 241
         'show_in_admin_all_list'    => true,
242 242
         'show_in_admin_status_list' => true,
243
-        'label_count'               => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing' )
244
-    ) );
245
-    register_post_status( 'wpi-processing', array(
246
-        'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
243
+        'label_count'               => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing')
244
+    ));
245
+    register_post_status('wpi-processing', array(
246
+        'label'                     => _x('Processing', 'Invoice status', 'invoicing'),
247 247
         'public'                    => true,
248 248
         'exclude_from_search'       => true,
249 249
         'show_in_admin_all_list'    => true,
250 250
         'show_in_admin_status_list' => true,
251
-        'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
252
-    ) );
253
-    register_post_status( 'wpi-onhold', array(
254
-        'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
251
+        'label_count'               => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing')
252
+    ));
253
+    register_post_status('wpi-onhold', array(
254
+        'label'                     => _x('On Hold', 'Invoice status', 'invoicing'),
255 255
         'public'                    => true,
256 256
         'exclude_from_search'       => true,
257 257
         'show_in_admin_all_list'    => true,
258 258
         'show_in_admin_status_list' => true,
259
-        'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
260
-    ) );
261
-    register_post_status( 'wpi-cancelled', array(
262
-        'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
259
+        'label_count'               => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing')
260
+    ));
261
+    register_post_status('wpi-cancelled', array(
262
+        'label'                     => _x('Cancelled', 'Invoice status', 'invoicing'),
263 263
         'public'                    => true,
264 264
         'exclude_from_search'       => true,
265 265
         'show_in_admin_all_list'    => true,
266 266
         'show_in_admin_status_list' => true,
267
-        'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
268
-    ) );
269
-    register_post_status( 'wpi-refunded', array(
270
-        'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
267
+        'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing')
268
+    ));
269
+    register_post_status('wpi-refunded', array(
270
+        'label'                     => _x('Refunded', 'Invoice status', 'invoicing'),
271 271
         'public'                    => true,
272 272
         'exclude_from_search'       => true,
273 273
         'show_in_admin_all_list'    => true,
274 274
         'show_in_admin_status_list' => true,
275
-        'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
276
-    ) );
277
-    register_post_status( 'wpi-failed', array(
278
-        'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
275
+        'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing')
276
+    ));
277
+    register_post_status('wpi-failed', array(
278
+        'label'                     => _x('Failed', 'Invoice status', 'invoicing'),
279 279
         'public'                    => true,
280 280
         'exclude_from_search'       => true,
281 281
         'show_in_admin_all_list'    => true,
282 282
         'show_in_admin_status_list' => true,
283
-        'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
284
-    ) );
285
-    register_post_status( 'wpi-renewal', array(
286
-        'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
283
+        'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing')
284
+    ));
285
+    register_post_status('wpi-renewal', array(
286
+        'label'                     => _x('Renewal', 'Invoice status', 'invoicing'),
287 287
         'public'                    => true,
288 288
         'exclude_from_search'       => true,
289 289
         'show_in_admin_all_list'    => true,
290 290
         'show_in_admin_status_list' => true,
291
-        'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
292
-    ) );
291
+        'label_count'               => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing')
292
+    ));
293 293
 }
294
-add_action( 'init', 'wpinv_register_post_status', 10 );
294
+add_action('init', 'wpinv_register_post_status', 10);
295 295
 
Please login to merge, or discard this patch.