@@ -22,22 +22,29 @@ 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+ $ get_id = filter_input ( INPUT_GET , 'id ' , FILTER_VALIDATE_INT );
26+ $ get_action = filter_input ( INPUT_GET , 'action ' , FILTER_SANITIZE_FULL_SPECIAL_CHARS );
27+ $ get_nonce = filter_input ( INPUT_GET , '_wpnonce ' , FILTER_SANITIZE_FULL_SPECIAL_CHARS );
28+
29+ if ( $ get_id === $ blog_id
30+ && $ get_nonce
31+ && wp_verify_nonce ( $ get_nonce , 'wp-cache ' . $ blog_id )
2832 ) {
29- if ( 'disable_cache ' === filter_input ( INPUT_GET , ' action ' ) ) {
33+ if ( 'disable_cache ' === $ get_action ) {
3034 add_blog_option ( $ blog_id , 'wp_super_cache_disabled ' , 1 );
31- } elseif ( 'enable_cache ' === filter_input ( INPUT_GET , ' action ' ) ) {
35+ } elseif ( 'enable_cache ' === $ get_action ) {
3236 delete_blog_option ( $ blog_id , 'wp_super_cache_disabled ' );
3337 }
3438 }
3539
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- }
40+ $ cache_disabled = 1 === (int ) get_blog_option ( $ blog_id , 'wp_super_cache_disabled ' );
41+ $ action_text = $ cache_disabled ? __ ( 'Enable ' , 'wp-super-cache ' ) : __ ( 'Disable ' , 'wp-super-cache ' );
42+ $ action_args = array (
43+ 'action ' => $ cache_disabled ? 'enable_cache ' : 'disable_cache ' ,
44+ 'id ' => $ blog_id ,
45+ '_wpnonce ' => wp_create_nonce ( 'wp-cache ' . $ blog_id ),
46+ );
47+ printf ( '<a href="%s">%s</a> ' , esc_url ( add_query_arg ( $ action_args ) ), esc_html ( $ action_text ) );
4148}
4249
4350function wp_super_cache_multisite_notice () {
0 commit comments