Passed
Push — master ( a53575...4537f3 )
by Brian
03:58
created
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +95 added lines, -95 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,25 +222,25 @@  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
-    public function add_nav_menu_meta_boxes(){
228
+    public function add_nav_menu_meta_boxes() {
229 229
         add_meta_box(
230 230
             'wpinv_endpoints_nav_link',
231
-            __( 'GetPaid endpoints', 'invoicing' ),
232
-            array( $this, 'nav_menu_links' ),
231
+            __('GetPaid endpoints', 'invoicing'),
232
+            array($this, 'nav_menu_links'),
233 233
             'nav-menus',
234 234
             'side',
235 235
             'low'
236 236
         );
237 237
     }
238 238
 
239
-    public function nav_menu_links(){
239
+    public function nav_menu_links() {
240 240
         $endpoints = $this->get_menu_items();
241 241
         ?>
242 242
         <div id="invoicing-endpoints" class="posttypediv">
243
-        <?php if(!empty($endpoints['pages'])){ ?>
243
+        <?php if (!empty($endpoints['pages'])) { ?>
244 244
             <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
245 245
                 <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
246 246
                     <?php
@@ -252,29 +252,29 @@  discard block
 block discarded – undo
252 252
         <?php } ?>
253 253
         <p class="button-controls">
254 254
         <span class="list-controls">
255
-            <a href="<?php echo admin_url( 'nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints' ); ?>" class="select-all"><?php _e( 'Select all', 'invoicing' ); ?></a>
255
+            <a href="<?php echo admin_url('nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints'); ?>" class="select-all"><?php _e('Select all', 'invoicing'); ?></a>
256 256
         </span>
257 257
             <span class="add-to-menu">
258
-            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
258
+            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
259 259
             <span class="spinner"></span>
260 260
         </span>
261 261
         </p>
262 262
         <?php
263 263
     }
264 264
 
265
-    public function get_menu_items(){
265
+    public function get_menu_items() {
266 266
         $items = array();
267 267
 
268
-        $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' );
269
-        if($wpinv_history_page_id > 0){
268
+        $wpinv_history_page_id = (int) wpinv_get_option('invoice_history_page');
269
+        if ($wpinv_history_page_id > 0) {
270 270
             $item = new stdClass();
271 271
             $item->object_id = $wpinv_history_page_id;
272 272
             $item->db_id = 0;
273
-            $item->object =  'page';
273
+            $item->object = 'page';
274 274
             $item->menu_item_parent = 0;
275 275
             $item->type = 'post_type';
276
-            $item->title = __('Invoice History Page','invoicing');
277
-            $item->url = get_permalink( $wpinv_history_page_id );
276
+            $item->title = __('Invoice History Page', 'invoicing');
277
+            $item->url = get_permalink($wpinv_history_page_id);
278 278
             $item->target = '';
279 279
             $item->attr_title = '';
280 280
             $item->classes = array('wpinv-menu-item');
@@ -283,16 +283,16 @@  discard block
 block discarded – undo
283 283
             $items['pages'][] = $item;
284 284
         }
285 285
 
286
-        $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' );
287
-        if($wpinv_sub_history_page_id > 0){
286
+        $wpinv_sub_history_page_id = (int) wpinv_get_option('invoice_subscription_page');
287
+        if ($wpinv_sub_history_page_id > 0) {
288 288
             $item = new stdClass();
289 289
             $item->object_id = $wpinv_sub_history_page_id;
290 290
             $item->db_id = 0;
291
-            $item->object =  'page';
291
+            $item->object = 'page';
292 292
             $item->menu_item_parent = 0;
293 293
             $item->type = 'post_type';
294
-            $item->title = __('Invoice Subscriptions Page','invoicing');
295
-            $item->url = get_permalink( $wpinv_sub_history_page_id );
294
+            $item->title = __('Invoice Subscriptions Page', 'invoicing');
295
+            $item->url = get_permalink($wpinv_sub_history_page_id);
296 296
             $item->target = '';
297 297
             $item->attr_title = '';
298 298
             $item->classes = array('wpinv-menu-item');
@@ -301,16 +301,16 @@  discard block
 block discarded – undo
301 301
             $items['pages'][] = $item;
302 302
         }
303 303
 
304
-        $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' );
305
-        if($wpinv_checkout_page_id > 0){
304
+        $wpinv_checkout_page_id = (int) wpinv_get_option('checkout_page');
305
+        if ($wpinv_checkout_page_id > 0) {
306 306
             $item = new stdClass();
307 307
             $item->object_id = $wpinv_checkout_page_id;
308 308
             $item->db_id = 0;
309
-            $item->object =  'page';
309
+            $item->object = 'page';
310 310
             $item->menu_item_parent = 0;
311 311
             $item->type = 'post_type';
312
-            $item->title = __('Checkout Page','invoicing');
313
-            $item->url = get_permalink( $wpinv_checkout_page_id );
312
+            $item->title = __('Checkout Page', 'invoicing');
313
+            $item->url = get_permalink($wpinv_checkout_page_id);
314 314
             $item->target = '';
315 315
             $item->attr_title = '';
316 316
             $item->classes = array('wpinv-menu-item');
@@ -319,16 +319,16 @@  discard block
 block discarded – undo
319 319
             $items['pages'][] = $item;
320 320
         }
321 321
 
322
-        $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' );
323
-        if($wpinv_success_page_id > 0){
322
+        $wpinv_success_page_id = (int) wpinv_get_option('success_page');
323
+        if ($wpinv_success_page_id > 0) {
324 324
             $item = new stdClass();
325 325
             $item->object_id = $wpinv_success_page_id;
326 326
             $item->db_id = 0;
327
-            $item->object =  'page';
327
+            $item->object = 'page';
328 328
             $item->menu_item_parent = 0;
329 329
             $item->type = 'post_type';
330
-            $item->title = __('Success Page','invoicing');
331
-            $item->url = get_permalink( $wpinv_success_page_id );
330
+            $item->title = __('Success Page', 'invoicing');
331
+            $item->url = get_permalink($wpinv_success_page_id);
332 332
             $item->target = '';
333 333
             $item->attr_title = '';
334 334
             $item->classes = array('wpinv-menu-item');
@@ -337,16 +337,16 @@  discard block
 block discarded – undo
337 337
             $items['pages'][] = $item;
338 338
         }
339 339
 
340
-        $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' );
341
-        if($wpinv_failure_page_id > 0){
340
+        $wpinv_failure_page_id = (int) wpinv_get_option('failure_page');
341
+        if ($wpinv_failure_page_id > 0) {
342 342
             $item = new stdClass();
343 343
             $item->object_id = $wpinv_failure_page_id;
344 344
             $item->db_id = 0;
345
-            $item->object =  'page';
345
+            $item->object = 'page';
346 346
             $item->menu_item_parent = 0;
347 347
             $item->type = 'post_type';
348
-            $item->title = __('Failed Transaction Page','invoicing');
349
-            $item->url = get_permalink( $wpinv_failure_page_id );
348
+            $item->title = __('Failed Transaction Page', 'invoicing');
349
+            $item->url = get_permalink($wpinv_failure_page_id);
350 350
             $item->target = '';
351 351
             $item->attr_title = '';
352 352
             $item->classes = array('wpinv-menu-item');
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
             $items['pages'][] = $item;
356 356
         }
357 357
 
358
-        return apply_filters( 'wpinv_menu_items', $items );
358
+        return apply_filters('wpinv_menu_items', $items);
359 359
     }
360 360
 
361 361
 }
Please login to merge, or discard this patch.