mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
User Settings: allow dashes in get|set_user_setting() in PHP and get|setUserSetting() in JS.
Add unit tests - there were none. Mock `set_user_setting()` since it won't run due to `headers_sent()` being `true`. Fixes #22781. git-svn-id: https://develop.svn.wordpress.org/trunk@33840 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -900,7 +900,7 @@ function get_all_user_settings() {
|
||||
$user_settings = array();
|
||||
|
||||
if ( isset( $_COOKIE['wp-settings-' . $user_id] ) ) {
|
||||
$cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user_id] );
|
||||
$cookie = preg_replace( '/[^A-Za-z0-9=&_-]/', '', $_COOKIE['wp-settings-' . $user_id] );
|
||||
|
||||
if ( strpos( $cookie, '=' ) ) { // '=' cannot be 1st char
|
||||
parse_str( $cookie, $user_settings );
|
||||
@@ -940,8 +940,8 @@ function wp_set_all_user_settings( $user_settings ) {
|
||||
|
||||
$settings = '';
|
||||
foreach ( $user_settings as $name => $value ) {
|
||||
$_name = preg_replace( '/[^A-Za-z0-9_]+/', '', $name );
|
||||
$_value = preg_replace( '/[^A-Za-z0-9_]+/', '', $value );
|
||||
$_name = preg_replace( '/[^A-Za-z0-9_-]+/', '', $name );
|
||||
$_value = preg_replace( '/[^A-Za-z0-9_-]+/', '', $value );
|
||||
|
||||
if ( ! empty( $_name ) ) {
|
||||
$settings .= $_name . '=' . $_value . '&';
|
||||
|
||||
Reference in New Issue
Block a user