Make WordPress Core

Changeset 60147


Ignore:
Timestamp:
04/08/2025 06:02:14 PM (3 weeks ago)
Author:
SergeyBiryukov
Message:

General: Correct force_ssl_content() to always return a boolean value.

This aims to bring parity with force_ssl_admin().

Includes:

  • Allowing force_ssl_content() to properly accept false as a value.
  • Correcting an erroneous ! $force conditional that should have been reversed.
  • Adding unit tests to confirm valid behavior.

Follow-up to mu:1979, [11903], [12603], [47808], [59830].

Props justlevine for initial patch.
See #52217.

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-functions.php

    r60129 r60147  
    24212421 * @since 2.8.5
    24222422 *
    2423  * @param bool $force
     2423 * @param bool|null $force Optional. Whether to force SSL in admin screens. Default null.
    24242424 * @return bool True if forced, false if not forced.
    24252425 */
    2426 function force_ssl_content( $force = '' ) {
     2426function force_ssl_content( $force = null ) {
    24272427    static $forced_content = false;
    24282428
    2429     if ( ! $force ) {
     2429    if ( ! is_null( $force ) ) {
    24302430        $old_forced     = $forced_content;
    2431         $forced_content = $force;
     2431        $forced_content = (bool) $force;
    24322432        return $old_forced;
    24332433    }
Note: See TracChangeset for help on using the changeset viewer.