Skip to content

Commit 85c783f

Browse files
committed
PHPCS: Ignore nonce sniffs in some admin files.
1 parent 8e9a754 commit 85c783f

File tree

2 files changed

+66
-13
lines changed

2 files changed

+66
-13
lines changed

wp-multi-network/includes/classes/class-wp-ms-networks-admin.php

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,11 @@ public function fix_menu_highlight_for_move_page() {
140140
global $plugin_page, $submenu_file;
141141

142142
if ( 'networks' === $plugin_page ) {
143+
// phpcs:disable WordPress.Security.NonceVerification.Recommended
143144
$action = ! empty( $_GET['action'] )
144145
? sanitize_key( $_GET['action'] )
145146
: '';
147+
// phpcs:enable
146148

147149
if ( 'move' === $action ) {
148150
$submenu_file = 'sites.php'; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited
@@ -166,8 +168,8 @@ public function enqueue_scripts( $page = '' ) {
166168
}
167169

168170
// Determine if we should load source or minified assets based on WP_SCRIPT_DEBUG.
169-
$suffix = ( defined( 'WP_SCRIPT_DEBUG' ) && WP_SCRIPT_DEBUG ) ? '' : '.min';
170-
$asset_version = ( defined( 'WP_SCRIPT_DEBUG' ) && WP_SCRIPT_DEBUG ) ? time() : wpmn()->asset_version;
171+
$suffix = ( defined( 'WP_SCRIPT_DEBUG' ) && WP_SCRIPT_DEBUG ) ? '' : '.min';
172+
$asset_version = ( defined( 'WP_SCRIPT_DEBUG' ) && WP_SCRIPT_DEBUG ) ? time() : wpmn()->asset_version;
171173

172174
wp_register_style( 'wp-multi-network', wpmn()->plugin_url . 'assets/css/wp-multi-network' . $suffix . '.css', array(), $asset_version );
173175
wp_register_script( 'wp-multi-network', wpmn()->plugin_url . 'assets/js/wp-multi-network' . $suffix . '.js', array( 'jquery', 'post' ), $asset_version, true );
@@ -206,6 +208,9 @@ public function set_feedback_strings() {
206208
/**
207209
* Prints feedback notices for network admin actions as necessary.
208210
*
211+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
212+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
213+
*
209214
* @since 1.3.0
210215
* @return void
211216
*/
@@ -215,30 +220,29 @@ public function network_admin_notices() {
215220

216221
foreach ( $this->feedback_strings as $slug => $messages ) {
217222

218-
// Skip if not known feedback
223+
// Skip if not known feedback.
219224
if ( ! isset( $_GET[ $slug ] ) || ! is_scalar( $_GET[ $slug ] ) ) {
220225
continue;
221226
}
222227

223-
// Pass/Fail
228+
// Pass/Fail.
224229
$passed = sanitize_key( $_GET[ $slug ] );
225230

226-
// Pass
227231
if ( '1' === $passed ) {
232+
// Pass.
228233
$message = $messages['1'];
229234
$type = 'updated';
230-
231-
// Fail
232235
} else {
236+
// Fail.
233237
$message = $messages['0'];
234238
$type = 'error';
235239
}
236240

237-
// Done
241+
// Done.
238242
break;
239243
}
240244

241-
// Bail if no message or type
245+
// Bail if no message or type.
242246
if ( empty( $message ) || empty( $type ) ) {
243247
return;
244248
}
@@ -257,6 +261,9 @@ public function network_admin_notices() {
257261
/**
258262
* Routes the current request to the correct page.
259263
*
264+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
265+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
266+
*
260267
* @since 2.0.0
261268
* @return void
262269
*/
@@ -324,6 +331,9 @@ public function route_pages() {
324331
/**
325332
* Handles network management form submissions.
326333
*
334+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
335+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
336+
*
327337
* @since 2.0.0
328338
* @return void
329339
*/
@@ -388,6 +398,9 @@ public function route_save_handlers() {
388398
/**
389399
* Renders the new network creation dashboard page.
390400
*
401+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
402+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
403+
*
391404
* @since 2.0.0
392405
* @return void
393406
*/
@@ -468,6 +481,9 @@ public function page_edit_network() {
468481
/**
469482
* Renders the network listing dashboard page.
470483
*
484+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
485+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
486+
*
471487
* @since 2.0.0
472488
*
473489
* @uses WP_MS_Networks_List_Table List_Table iterator for networks
@@ -523,6 +539,9 @@ private function page_all_networks() {
523539
/**
524540
* Renders the dashboard screen for moving sites -- accessed from the "Sites" screen.
525541
*
542+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
543+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
544+
*
526545
* @since 2.0.0
527546
* @return void
528547
*/
@@ -564,8 +583,17 @@ private function page_move_site() {
564583
);
565584

566585
// URLs to escape.
567-
$add_network_url = $this->admin_url( array( 'page' => 'add-new-network' ) );
568-
$form_action_url = $this->admin_url( array( 'action' => 'move', 'blog_id' => $site_id ) );
586+
$add_network_url = $this->admin_url(
587+
array(
588+
'page' => 'add-new-network',
589+
)
590+
);
591+
$form_action_url = $this->admin_url(
592+
array(
593+
'action' => 'move',
594+
'blog_id' => $site_id,
595+
)
596+
);
569597
?>
570598

571599
<div class="wrap">
@@ -605,6 +633,9 @@ private function page_move_site() {
605633
/**
606634
* Renders the delete network page.
607635
*
636+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
637+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
638+
*
608639
* @since 2.0.0
609640
* @return void
610641
*/
@@ -703,12 +734,15 @@ private function page_delete_network() {
703734
/**
704735
* Renders the delete multiple networks page.
705736
*
737+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
738+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
739+
*
706740
* @since 2.0.0
707741
* @return void
708742
*/
709743
private function page_delete_networks() {
710744

711-
$network_id = get_main_network_id();
745+
$network_id = get_main_network_id();
712746

713747
$all_networks = ! empty( $_POST['all_networks'] ) && is_array( $_POST['all_networks'] )
714748
? wp_parse_id_list( (array) $_POST['all_networks'] )
@@ -920,6 +954,9 @@ public function page_my_networks() {
920954
/**
921955
* Handles the request to add a new network.
922956
*
957+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
958+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
959+
*
923960
* @since 2.0.0
924961
* @return void
925962
*/
@@ -1027,6 +1064,9 @@ private function handle_add_network() {
10271064
/**
10281065
* Handles the request to update a network.
10291066
*
1067+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
1068+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
1069+
*
10301070
* @since 2.0.0
10311071
* @return void
10321072
*/
@@ -1098,13 +1138,16 @@ private function handle_update_network() {
10981138
/**
10991139
* Handles the request to move a site to another network.
11001140
*
1141+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
1142+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
1143+
*
11011144
* @since 2.0.0
11021145
* @return void
11031146
*/
11041147
private function handle_move_site() {
11051148

11061149
// Sanitize values.
1107-
$site_id = ! empty( $_GET['blog_id'] ) && is_numeric( $_GET['blog_id'] )
1150+
$site_id = ! empty( $_GET['blog_id'] ) && is_numeric( $_GET['blog_id'] )
11081151
? (int) $_GET['blog_id']
11091152
: 0;
11101153

@@ -1164,6 +1207,8 @@ private function handle_move_site() {
11641207
/**
11651208
* Handles the request to reassign sites to another network.
11661209
*
1210+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
1211+
*
11671212
* @since 2.0.0
11681213
* @return void
11691214
*/
@@ -1236,6 +1281,9 @@ private function handle_reassign_sites() {
12361281
/**
12371282
* Handles the request to delete a network.
12381283
*
1284+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
1285+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
1286+
*
12391287
* @since 2.0.0
12401288
* @return void
12411289
*/
@@ -1267,6 +1315,8 @@ private function handle_delete_network() {
12671315
/**
12681316
* Handles the request to delete multiple networks.
12691317
*
1318+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
1319+
*
12701320
* @since 2.0.0
12711321
* @return void
12721322
*/

wp-multi-network/includes/classes/class-wp-ms-networks-list-table.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public function ajax_user_can() {
4646
/**
4747
* Prepares the list table items.
4848
*
49+
* @phpcs:disable WordPress.Security.NonceVerification.Missing
50+
* @phpcs:disable WordPress.Security.NonceVerification.Recommended
51+
*
4952
* @since 1.3.0
5053
* @return void
5154
*/

0 commit comments

Comments
 (0)