Make WordPress Core


Ignore:
Timestamp:
05/01/2024 05:59:05 PM (11 months ago)
Author:
swissspidy
Message:

General: Remove any usage of wp_reset_vars().

The way wp_reset_vars() sets global variables based on $_POST and $_GET values makes code hard to understand and maintain. It also makes it easy to forget to sanitize input.

This change removes the few places where wp_reset_vars() is used in the admin to explicitly use $_REQUEST and sanitize any input.

Props swissspidy, audrasjb, davideferre, killua99, weijland, voldemortensen.
Fixes #38073.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/themes.php

    r56800 r58069  
    216216    $themes = wp_prepare_themes_for_js( array( wp_get_theme() ) );
    217217}
    218 wp_reset_vars( array( 'theme', 'search' ) );
     218
     219$theme  = ! empty( $_REQUEST['theme'] ) ? sanitize_text_field( $_REQUEST['theme'] ) : '';
     220$search = ! empty( $_REQUEST['search'] ) ? sanitize_text_field( $_REQUEST['search'] ) : '';
    219221
    220222wp_localize_script(
Note: See TracChangeset for help on using the changeset viewer.