Skip to content

Commit b5b2fb9

Browse files
authored
Merge pull request #302 from SID177/fix/GH-291
Fix PHP 8.1 compatibility issues and phpcs
2 parents 5e57091 + d0e45eb commit b5b2fb9

File tree

3 files changed

+50
-36
lines changed

3 files changed

+50
-36
lines changed

admin/class-nginx-helper-admin.php

+17-9
Original file line numberDiff line numberDiff line change
@@ -679,12 +679,20 @@ public function purge_all() {
679679

680680
global $nginx_purger, $wp;
681681

682-
$method = filter_input( INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_STRING );
682+
$method = null;
683+
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
684+
$method = wp_strip_all_tags( $_SERVER['REQUEST_METHOD'] );
685+
}
683686

687+
$action = '';
684688
if ( 'POST' === $method ) {
685-
$action = filter_input( INPUT_POST, 'nginx_helper_action', FILTER_SANITIZE_STRING );
689+
if ( isset( $_POST['nginx_helper_action'] ) ) {
690+
$action = wp_strip_all_tags( $_POST['nginx_helper_action'] );
691+
}
686692
} else {
687-
$action = filter_input( INPUT_GET, 'nginx_helper_action', FILTER_SANITIZE_STRING );
693+
if ( isset( $_GET['nginx_helper_action'] ) ) {
694+
$action = wp_strip_all_tags( $_GET['nginx_helper_action'] );
695+
}
688696
}
689697

690698
if ( empty( $action ) ) {
@@ -725,12 +733,12 @@ public function purge_all() {
725733

726734
if ( 'purge' === $action ) {
727735

728-
/**
729-
* Fire an action after the entire cache has been purged whatever caching type is used.
730-
*
731-
* @since 2.2.2
732-
*/
733-
do_action( 'rt_nginx_helper_after_purge_all' );
736+
/**
737+
* Fire an action after the entire cache has been purged whatever caching type is used.
738+
*
739+
* @since 2.2.2
740+
*/
741+
do_action( 'rt_nginx_helper_after_purge_all' );
734742

735743
}
736744

admin/partials/nginx-helper-admin-display.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<div id="post-body-content">
2626
<?php
2727
/* Show settinhs tabs */
28-
$current_tab = filter_input( INPUT_GET, 'tab', FILTER_SANITIZE_STRING );
28+
$current_tab = ( isset( $_GET['tab'] ) ? wp_strip_all_tags( $_GET['tab'] ) : '' );
2929
$current_setting_tab = ( ! empty( $current_tab ) ) ? $current_tab : 'general';
3030

3131
echo '<h2 class="nav-tab-wrapper">';

admin/partials/nginx-helper-general-options.php

+32-26
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,39 @@
1515
$error_log_filesize = false;
1616

1717
$args = array(
18-
'enable_purge' => FILTER_SANITIZE_STRING,
19-
'enable_stamp' => FILTER_SANITIZE_STRING,
20-
'purge_method' => FILTER_SANITIZE_STRING,
21-
'is_submit' => FILTER_SANITIZE_STRING,
22-
'redis_hostname' => FILTER_SANITIZE_STRING,
23-
'redis_port' => FILTER_SANITIZE_STRING,
24-
'redis_prefix' => FILTER_SANITIZE_STRING,
25-
'purge_homepage_on_edit' => FILTER_SANITIZE_STRING,
26-
'purge_homepage_on_del' => FILTER_SANITIZE_STRING,
27-
'purge_url' => FILTER_SANITIZE_STRING,
28-
'log_level' => FILTER_SANITIZE_STRING,
29-
'log_filesize' => FILTER_SANITIZE_STRING,
30-
'smart_http_expire_save' => FILTER_SANITIZE_STRING,
31-
'cache_method' => FILTER_SANITIZE_STRING,
32-
'enable_map' => FILTER_SANITIZE_STRING,
33-
'enable_log' => FILTER_SANITIZE_STRING,
34-
'purge_archive_on_edit' => FILTER_SANITIZE_STRING,
35-
'purge_archive_on_del' => FILTER_SANITIZE_STRING,
36-
'purge_archive_on_new_comment' => FILTER_SANITIZE_STRING,
37-
'purge_archive_on_deleted_comment' => FILTER_SANITIZE_STRING,
38-
'purge_page_on_mod' => FILTER_SANITIZE_STRING,
39-
'purge_page_on_new_comment' => FILTER_SANITIZE_STRING,
40-
'purge_page_on_deleted_comment' => FILTER_SANITIZE_STRING,
41-
'smart_http_expire_form_nonce' => FILTER_SANITIZE_STRING,
18+
'enable_purge',
19+
'enable_stamp',
20+
'purge_method',
21+
'is_submit',
22+
'redis_hostname',
23+
'redis_port',
24+
'redis_prefix',
25+
'purge_homepage_on_edit',
26+
'purge_homepage_on_del',
27+
'purge_url',
28+
'log_level',
29+
'log_filesize',
30+
'smart_http_expire_save',
31+
'cache_method',
32+
'enable_map',
33+
'enable_log',
34+
'purge_archive_on_edit',
35+
'purge_archive_on_del',
36+
'purge_archive_on_new_comment',
37+
'purge_archive_on_deleted_comment',
38+
'purge_page_on_mod',
39+
'purge_page_on_new_comment',
40+
'purge_page_on_deleted_comment',
41+
'smart_http_expire_form_nonce',
4242
);
4343

44-
$all_inputs = filter_input_array( INPUT_POST, $args );
44+
$all_inputs = array();
45+
46+
foreach ( $args as $val ) {
47+
if ( isset( $_POST[ $val ] ) ) {
48+
$all_inputs[ $val ] = wp_strip_all_tags( $_POST[ $val ] );
49+
}
50+
}
4551

4652
if ( isset( $all_inputs['smart_http_expire_save'] ) && wp_verify_nonce( $all_inputs['smart_http_expire_form_nonce'], 'smart-http-expire-form-nonce' ) ) {
4753
unset( $all_inputs['smart_http_expire_save'] );
@@ -720,7 +726,7 @@
720726
</table>
721727
</div> <!-- End of .inside -->
722728
</div>
723-
<input type="hidden" name="smart_http_expire_form_nonce" value="<?php echo wp_create_nonce('smart-http-expire-form-nonce'); ?>"/>
729+
<input type="hidden" name="smart_http_expire_form_nonce" value="<?php echo esc_attr( wp_create_nonce( 'smart-http-expire-form-nonce' ) ); ?>" />
724730
<?php
725731
submit_button( __( 'Save All Changes', 'nginx-helper' ), 'primary large', 'smart_http_expire_save', true );
726732
?>

0 commit comments

Comments
 (0)