Passed
Push — master ( 57b45a...7abbad )
by Brian
09:13
created
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +82 added lines, -82 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,78 +129,78 @@  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 142
 
143
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
143
+        if (!wpinv_current_user_can_manage_invoicing()) {
144 144
             return;
145 145
         }
146 146
 
147 147
         $settings_tabs = wpinv_get_settings_tabs();
148 148
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
149
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? esc_html( $_GET['tab'] ) : 'general';
150
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
149
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? esc_html($_GET['tab']) : 'general';
150
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
151 151
         $key           = 'main';
152 152
 
153
-        if ( is_array( $sections ) ) {
154
-            $key = key( $sections );
153
+        if (is_array($sections)) {
154
+            $key = key($sections);
155 155
         }
156 156
 
157 157
         add_thickbox();
158 158
 
159
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
160
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
159
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
160
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
161 161
         ?>
162 162
         <div class="wrap">
163 163
             <h1 class="nav-tab-wrapper">
164 164
                 <?php
165
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
166
-                    $tab_url = add_query_arg( array(
165
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
166
+                    $tab_url = add_query_arg(array(
167 167
                         'settings-updated' => false,
168 168
                         'tab' => $tab_id,
169
-                    ), 'admin.php?page=wpinv-settings' );
169
+                    ), 'admin.php?page=wpinv-settings');
170 170
 
171 171
                     // Remove the section from the tabs so we always end up at the main section
172
-                    $tab_url = remove_query_arg( 'section', $tab_url );
173
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
172
+                    $tab_url = remove_query_arg('section', $tab_url);
173
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
174 174
 
175 175
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
176 176
 
177
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
178
-                    echo esc_html( $tab_name );
177
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
178
+                    echo esc_html($tab_name);
179 179
                     echo '</a>';
180 180
                 }
181 181
                 ?>
182 182
             </h1>
183 183
             <?php
184
-            $number_of_sections = count( $sections );
184
+            $number_of_sections = count($sections);
185 185
             $number = 0;
186
-            if ( $number_of_sections > 1 ) {
186
+            if ($number_of_sections > 1) {
187 187
                 echo '<div><ul class="subsubsub">';
188
-                foreach( $sections as $section_id => $section_name ) {
188
+                foreach ($sections as $section_id => $section_name) {
189 189
                     echo '<li>';
190 190
                     $number++;
191
-                    $tab_url = add_query_arg( array(
191
+                    $tab_url = add_query_arg(array(
192 192
                         'settings-updated' => false,
193 193
                         'tab' => $active_tab,
194 194
                         'section' => $section_id
195
-                    ), admin_url( 'admin.php?page=wpinv-settings' ) );
196
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
195
+                    ), admin_url('admin.php?page=wpinv-settings'));
196
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
197 197
                     $class = '';
198
-                    if ( $section == $section_id ) {
198
+                    if ($section == $section_id) {
199 199
                         $class = 'current';
200 200
                     }
201
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
201
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
202 202
 
203
-                    if ( $number != $number_of_sections ) {
203
+                    if ($number != $number_of_sections) {
204 204
                         echo ' | ';
205 205
                     }
206 206
                     echo '</li>';
@@ -212,20 +212,20 @@  discard block
 block discarded – undo
212 212
                 <form method="post" action="options.php">
213 213
                     <table class="form-table">
214 214
                         <?php
215
-                        settings_fields( 'wpinv_settings' );
215
+                        settings_fields('wpinv_settings');
216 216
 
217
-                        if ( 'main' === $section ) {
218
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
217
+                        if ('main' === $section) {
218
+                            do_action('wpinv_settings_tab_top', $active_tab);
219 219
                         }
220 220
 
221
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
222
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
223
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
224
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
221
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
222
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
223
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
224
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
225 225
 
226 226
                         // For backwards compatibility
227
-                        if ( 'main' === $section ) {
228
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
227
+                        if ('main' === $section) {
228
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
229 229
                         }
230 230
                         ?>
231 231
                     </table>
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
     }
238 238
 
239 239
     public function remove_admin_submenus() {
240
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
240
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
241 241
     }
242 242
 
243 243
     /**
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 
248 248
         add_meta_box(
249 249
             'wpinv_endpoints_nav_link',
250
-            __( 'GetPaid endpoints', 'invoicing' ),
251
-            array( $this, 'nav_menu_links' ),
250
+            __('GetPaid endpoints', 'invoicing'),
251
+            array($this, 'nav_menu_links'),
252 252
             'nav-menus',
253 253
             'side',
254 254
             'low'
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
         $endpoints = $this->get_menu_items();
264 264
         ?>
265 265
         <div id="invoicing-endpoints" class="posttypediv">
266
-            <?php if ( ! empty( $endpoints['pages'] ) ) : ?>
266
+            <?php if (!empty($endpoints['pages'])) : ?>
267 267
                 <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
268 268
                     <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
269 269
                         <?php
270
-                            $walker = new Walker_Nav_Menu_Checklist( array() );
271
-                            echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) );
270
+                            $walker = new Walker_Nav_Menu_Checklist(array());
271
+                            echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
272 272
                         ?>
273 273
                     </ul>
274 274
                 </div>
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
             <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints">
278 278
                 <span class="list-controls hide-if-no-js">
279 279
                     <input type="checkbox" id="invoicing-endpoints-tab" class="select-all">
280
-                    <label for="invoicing-endpoints-tab"><?php _e( 'Select all', 'invoicing' ); ?></label>
280
+                    <label for="invoicing-endpoints-tab"><?php _e('Select all', 'invoicing'); ?></label>
281 281
                 </span>
282 282
 
283 283
                 <span class="add-to-menu">
284
-                    <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">
284
+                    <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">
285 285
                     <span class="spinner"></span>
286 286
                 </span>
287 287
             </p>
@@ -294,35 +294,35 @@  discard block
 block discarded – undo
294 294
      *
295 295
      * @return array.
296 296
      */
297
-    public function get_menu_items(){
297
+    public function get_menu_items() {
298 298
         $items = array();
299 299
 
300 300
         $pages = array(
301 301
             array(
302
-                'id'    => wpinv_get_option( 'invoice_history_page' ),
303
-                'label' => __( 'My Invoices', 'invoicing' ),
302
+                'id'    => wpinv_get_option('invoice_history_page'),
303
+                'label' => __('My Invoices', 'invoicing'),
304 304
             ),
305 305
             array(
306
-                'id'    => wpinv_get_option( 'invoice_subscription_page' ),
307
-                'label' => __( 'My Subscriptions', 'invoicing' ),
306
+                'id'    => wpinv_get_option('invoice_subscription_page'),
307
+                'label' => __('My Subscriptions', 'invoicing'),
308 308
             )
309 309
         );
310 310
 
311
-        foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) {
311
+        foreach (apply_filters('getpaid_menu_pages', $pages) as $page) {
312 312
 
313
-            if ( (int) $page['id'] > 0 ) {
313
+            if ((int) $page['id'] > 0) {
314 314
 
315 315
                 $item                   = new stdClass();
316 316
                 $item->object_id        = (int) $page['id'];
317 317
                 $item->db_id            = 0;
318
-                $item->object           =  'page';
318
+                $item->object           = 'page';
319 319
                 $item->menu_item_parent = 0;
320 320
                 $item->type             = 'post_type';
321
-                $item->title            = esc_html( $page['label'] );
322
-                $item->url              = get_permalink( (int) $page['id'] );
321
+                $item->title            = esc_html($page['label']);
322
+                $item->url              = get_permalink((int) $page['id']);
323 323
                 $item->target           = '';
324 324
                 $item->attr_title       = '';
325
-                $item->classes          = array( 'wpinv-menu-item' );
325
+                $item->classes          = array('wpinv-menu-item');
326 326
                 $item->xfn              = '';
327 327
 
328 328
                 $items['pages'][]       = $item;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 
332 332
         }
333 333
 
334
-        return apply_filters( 'wpinv_menu_items', $items );
334
+        return apply_filters('wpinv_menu_items', $items);
335 335
     }
336 336
 
337 337
 }
Please login to merge, or discard this patch.