Passed
Push — master ( 4537f3...b8a531 )
by Brian
04:39
created
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +80 added lines, -80 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,7 +77,7 @@  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
             <?php
82 82
                 $table = new WPInv_Customers_Table();
83 83
                 $table->prepare_items();
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
     public function add_settings_menu() {
94 94
         add_submenu_page(
95 95
             'wpinv',
96
-            __( 'Invoice Settings', 'invoicing' ),
97
-            __( 'Settings', 'invoicing' ),
98
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
96
+            __('Invoice Settings', 'invoicing'),
97
+            __('Settings', 'invoicing'),
98
+            apply_filters('invoicing_capability', wpinv_get_capability()),
99 99
             'wpinv-settings',
100
-            array( $this, 'options_page' )
100
+            array($this, 'options_page')
101 101
         );
102 102
     }
103 103
 
104
-    public function add_addons_menu(){
105
-        if ( !apply_filters( 'wpi_show_addons_page', true ) ) {
104
+    public function add_addons_menu() {
105
+        if (!apply_filters('wpi_show_addons_page', true)) {
106 106
             return;
107 107
         }
108 108
 
@@ -112,78 +112,78 @@  discard block
 block discarded – undo
112 112
             __('Extensions', 'invoicing'),
113 113
             'manage_options',
114 114
             'wpi-addons',
115
-            array( $this, 'addons_page' )
115
+            array($this, 'addons_page')
116 116
         );
117 117
     }
118 118
 
119
-    public function addons_page(){
119
+    public function addons_page() {
120 120
         $addon_obj = new WPInv_Admin_Addons();
121 121
         $addon_obj->output();
122 122
     }
123 123
 
124 124
     function options_page() {
125
-        $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
125
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
126 126
 
127
-        if ( $page !== 'wpinv-settings' ) {
127
+        if ($page !== 'wpinv-settings') {
128 128
             return;
129 129
         }
130 130
 
131 131
         $settings_tabs = wpinv_get_settings_tabs();
132 132
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
133
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
134
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
133
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
134
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
135 135
         $key           = 'main';
136 136
 
137
-        if ( is_array( $sections ) ) {
138
-            $key = key( $sections );
137
+        if (is_array($sections)) {
138
+            $key = key($sections);
139 139
         }
140 140
 
141
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
142
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
141
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
142
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
143 143
         ob_start();
144 144
         ?>
145 145
         <div class="wrap">
146 146
             <h1 class="nav-tab-wrapper">
147 147
                 <?php
148
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
149
-                    $tab_url = add_query_arg( array(
148
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
149
+                    $tab_url = add_query_arg(array(
150 150
                         'settings-updated' => false,
151 151
                         'tab' => $tab_id,
152
-                    ) );
152
+                    ));
153 153
 
154 154
                     // Remove the section from the tabs so we always end up at the main section
155
-                    $tab_url = remove_query_arg( 'section', $tab_url );
156
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
155
+                    $tab_url = remove_query_arg('section', $tab_url);
156
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
157 157
 
158 158
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
159 159
 
160
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
161
-                    echo esc_html( $tab_name );
160
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
161
+                    echo esc_html($tab_name);
162 162
                     echo '</a>';
163 163
                 }
164 164
                 ?>
165 165
             </h1>
166 166
             <?php
167
-            $number_of_sections = count( $sections );
167
+            $number_of_sections = count($sections);
168 168
             $number = 0;
169
-            if ( $number_of_sections > 1 ) {
169
+            if ($number_of_sections > 1) {
170 170
                 echo '<div><ul class="subsubsub">';
171
-                foreach( $sections as $section_id => $section_name ) {
171
+                foreach ($sections as $section_id => $section_name) {
172 172
                     echo '<li>';
173 173
                     $number++;
174
-                    $tab_url = add_query_arg( array(
174
+                    $tab_url = add_query_arg(array(
175 175
                         'settings-updated' => false,
176 176
                         'tab' => $active_tab,
177 177
                         'section' => $section_id
178
-                    ) );
179
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
178
+                    ));
179
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
180 180
                     $class = '';
181
-                    if ( $section == $section_id ) {
181
+                    if ($section == $section_id) {
182 182
                         $class = 'current';
183 183
                     }
184
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
184
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
185 185
 
186
-                    if ( $number != $number_of_sections ) {
186
+                    if ($number != $number_of_sections) {
187 187
                         echo ' | ';
188 188
                     }
189 189
                     echo '</li>';
@@ -195,20 +195,20 @@  discard block
 block discarded – undo
195 195
                 <form method="post" action="options.php">
196 196
                     <table class="form-table">
197 197
                         <?php
198
-                        settings_fields( 'wpinv_settings' );
198
+                        settings_fields('wpinv_settings');
199 199
 
200
-                        if ( 'main' === $section ) {
201
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
200
+                        if ('main' === $section) {
201
+                            do_action('wpinv_settings_tab_top', $active_tab);
202 202
                         }
203 203
 
204
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
205
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
206
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
207
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
204
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
205
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
206
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
207
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
208 208
 
209 209
                         // For backwards compatibility
210
-                        if ( 'main' === $section ) {
211
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
210
+                        if ('main' === $section) {
211
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
212 212
                         }
213 213
                         ?>
214 214
                     </table>
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     }
223 223
 
224 224
     public function remove_admin_submenus() {
225
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
225
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
226 226
     }
227 227
 
228 228
     /**
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
 
233 233
         add_meta_box(
234 234
             'wpinv_endpoints_nav_link',
235
-            __( 'GetPaid endpoints', 'invoicing' ),
236
-            array( $this, 'nav_menu_links' ),
235
+            __('GetPaid endpoints', 'invoicing'),
236
+            array($this, 'nav_menu_links'),
237 237
             'nav-menus',
238 238
             'side',
239 239
             'low'
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
         $endpoints = $this->get_menu_items();
249 249
         ?>
250 250
         <div id="invoicing-endpoints" class="posttypediv">
251
-            <?php if ( ! empty( $endpoints['pages'] ) ) : ?>
251
+            <?php if (!empty($endpoints['pages'])) : ?>
252 252
                 <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
253 253
                     <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
254 254
                         <?php
255
-                            $walker = new Walker_Nav_Menu_Checklist( array() );
256
-                            echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) );
255
+                            $walker = new Walker_Nav_Menu_Checklist(array());
256
+                            echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
257 257
                         ?>
258 258
                     </ul>
259 259
                 </div>
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
             <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints">
263 263
                 <span class="list-controls hide-if-no-js">
264 264
                     <input type="checkbox" id="invoicing-endpoints-tab" class="select-all">
265
-                    <label for="invoicing-endpoints-tab"><?php _e( 'Select all', 'invoicing' ); ?></label>
265
+                    <label for="invoicing-endpoints-tab"><?php _e('Select all', 'invoicing'); ?></label>
266 266
                 </span>
267 267
 
268 268
                 <span class="add-to-menu">
269
-                    <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">
269
+                    <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">
270 270
                     <span class="spinner"></span>
271 271
                 </span>
272 272
             </p>
@@ -279,35 +279,35 @@  discard block
 block discarded – undo
279 279
      *
280 280
      * @return array.
281 281
      */
282
-    public function get_menu_items(){
282
+    public function get_menu_items() {
283 283
         $items = array();
284 284
 
285 285
         $pages = array(
286 286
             array(
287
-                'id'    => wpinv_get_option( 'invoice_history_page' ),
288
-                'label' => __( 'My Invoices', 'invoicing' ),
287
+                'id'    => wpinv_get_option('invoice_history_page'),
288
+                'label' => __('My Invoices', 'invoicing'),
289 289
             ),
290 290
             array(
291
-                'id'    => wpinv_get_option( 'invoice_subscription_page' ),
292
-                'label' => __( 'My Subscriptions', 'invoicing' ),
291
+                'id'    => wpinv_get_option('invoice_subscription_page'),
292
+                'label' => __('My Subscriptions', 'invoicing'),
293 293
             )
294 294
         );
295 295
 
296
-        foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) {
296
+        foreach (apply_filters('getpaid_menu_pages', $pages) as $page) {
297 297
 
298
-            if ( (int) $page['id'] > 0 ) {
298
+            if ((int) $page['id'] > 0) {
299 299
 
300 300
                 $item                   = new stdClass();
301 301
                 $item->object_id        = (int) $page['id'];
302 302
                 $item->db_id            = 0;
303
-                $item->object           =  'page';
303
+                $item->object           = 'page';
304 304
                 $item->menu_item_parent = 0;
305 305
                 $item->type             = 'post_type';
306
-                $item->title            = sanitize_text_field( $page['label'] );
307
-                $item->url              = get_permalink( (int) $page['id'] );
306
+                $item->title            = sanitize_text_field($page['label']);
307
+                $item->url              = get_permalink((int) $page['id']);
308 308
                 $item->target           = '';
309 309
                 $item->attr_title       = '';
310
-                $item->classes          = array( 'wpinv-menu-item' );
310
+                $item->classes          = array('wpinv-menu-item');
311 311
                 $item->xfn              = '';
312 312
 
313 313
                 $items['pages'][]       = $item;
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
         }
318 318
 
319
-        return apply_filters( 'wpinv_menu_items', $items );
319
+        return apply_filters('wpinv_menu_items', $items);
320 320
     }
321 321
 
322 322
 }
Please login to merge, or discard this patch.