WordPress.org

Make WordPress Core

Opened 2 months ago

Last modified 2 days ago

#41937 new enhancement

Change name of "wp-settings-" and "wp-settings-time-" cookie

Reported by: Neustradamus Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Users Keywords: good-first-bug has-patch
Focuses: Cc:

Description

There is no option to change the cookie names of:

  • wp-settings-time-
  • wp-settings-

Can you add options?
It will be nice to add in wp-config.php like other cookies?

Thanks in advance.

Attachments (1)

41937.patch (5.6 KB) - added by petertoi 7 weeks ago.
Convert strings for wp-settings- and wp-settings-time- to constants

Download all attachments as: .zip

Change History (9)

#1 @SergeyBiryukov
2 months ago

  • Component changed from General to Users
  • Keywords cookie removed
  • Severity changed from major to normal
  • Type changed from defect (bug) to enhancement

#2 @johnbillion
2 months ago

  • Keywords needs-patch good-first-bug added
  • Version trunk deleted

#3 @birgire
2 months ago

The related core (PHP) functions are:

but it's more complicated than that, because it's hardcoded in the Javascript function setUserSetting(), where:

...
settings = wpCookies.getHash( 'wp-settings-' + uid ),
...
wpCookies.setHash( 'wp-settings-' + uid, settings, 31536000, path, '', secure );
wpCookies.set( 'wp-settings-time-' + uid, userSettings.time, 31536000, path, '', secure );
...

in /wp-includes/js/utils.js:

https://core.trac.wordpress.org/browser/tags/4.8.2/src/wp-includes/js/utils.js#L151-L184

There's also the getAllUserSettings() Javascript function that contains:

return wpCookies.getHash( 'wp-settings-' + userSettings.uid ) || {};

Last edited 2 months ago by birgire (previous) (diff)

@petertoi
7 weeks ago

Convert strings for wp-settings- and wp-settings-time- to constants

#4 @petertoi
7 weeks ago

This patch takes adds constants to replace usages of 'wp-settings-' and 'wp-settings-time-' in PHP and updates the localization of utils.js with variables to use these constants in JS. Let me know if this needs any modification, happy to make any changes.

Prepared this patch at WordCamp Toronto 2017 with assistance from @pbearne.

Last edited 7 weeks ago by petertoi (previous) (diff)

#5 @petertoi
7 weeks ago

As a side note, what's the standard approach to updating WordPress code style on patches? Is code style applied only to modified code or should it be applied to related blocks (ex: adding curly brackets to all the constants in constants.php instead just those we've added)?

#6 @petertoi
6 weeks ago

  • Keywords has-patch added; needs-patch removed

#7 follow-up: @Neustradamus
2 days ago

Thanks for your works! :)

It has been added in 4.9 release?

#8 in reply to: ↑ 7 @petertoi
2 days ago

Replying to Neustradamus:

It has been added in 4.9 release?

No, it hasn't been reviewed yet. And may need tests too. Now that 4.9 is out the door there's a good window to bring this up in the #core Slack channel and see what folks think is required to get it in a future release.

Note: See TracTickets for help on using tickets.