@@ -22,9 +22,9 @@ function wp_super_cache_blogs_field( $name, $blog_id ) {
2222
2323 $ blog_id = (int ) $ blog_id ;
2424
25- if ( isset ( $ _GET ['id ' ], $ _GET ['action ' ], $ _GET ['_wpnonce ' ] )
26- && $ blog_id === filter_input ( INPUT_GET , 'id ' , FILTER_VALIDATE_INT )
27- && wp_verify_nonce ( $ _GET ['_wpnonce ' ], 'wp-cache ' . $ blog_id )
25+ if ( isset ( $ _GET ['id ' ], $ _GET ['action ' ], $ _GET ['_wpnonce ' ] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
26+ && filter_input ( INPUT_GET , 'id ' , FILTER_VALIDATE_INT ) === $ blog_id
27+ && wp_verify_nonce ( sanitize_text_field ( wp_unslash ( $ _GET ['_wpnonce ' ] ) ) , 'wp-cache ' . $ blog_id ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
2828 ) {
2929 if ( 'disable_cache ' === filter_input ( INPUT_GET , 'action ' ) ) {
3030 add_blog_option ( $ blog_id , 'wp_super_cache_disabled ' , 1 );
@@ -33,11 +33,14 @@ function wp_super_cache_blogs_field( $name, $blog_id ) {
3333 }
3434 }
3535
36- if ( 1 === (int ) get_blog_option ( $ blog_id , 'wp_super_cache_disabled ' ) ) {
37- echo '<a href=" ' . wp_nonce_url ( add_query_arg ( array ( 'action ' => 'enable_cache ' , 'id ' => $ blog_id ) ), 'wp-cache ' . $ blog_id ) . '"> ' . __ ( 'Enable ' , 'wp-super-cache ' ) . '</a> ' ;
38- } else {
39- echo '<a href=" ' . wp_nonce_url ( add_query_arg ( array ( 'action ' => 'disable_cache ' , 'id ' => $ blog_id ) ), 'wp-cache ' . $ blog_id ) . '"> ' . __ ( 'Disable ' , 'wp-super-cache ' ) . '</a> ' ;
40- }
36+ $ cache_disabled = 1 === (int ) get_blog_option ( $ blog_id , 'wp_super_cache_disabled ' );
37+ $ action_text = $ cache_disabled ? __ ( 'Enable ' , 'wp-super-cache ' ) : __ ( 'Disable ' , 'wp-super-cache ' );
38+ $ action_args = array (
39+ 'action ' => $ cache_disabled ? 'enable_cache ' : 'disable_cache ' ,
40+ 'id ' => $ blog_id ,
41+ '_wpnonce ' => wp_create_nonce ( 'wp-cache ' . $ blog_id ),
42+ );
43+ printf ( '<a href="%s">%s</a> ' , esc_url ( add_query_arg ( $ action_args ) ), esc_html ( $ action_text ) );
4144}
4245
4346function wp_super_cache_multisite_notice () {
0 commit comments