Make WordPress Core

Ticket #28521: 28521.diff

File 28521.diff, 5.5 KB (added by wonderboymusic, 10 years ago)
  • src/wp-includes/comment.php

     
    11511151         * @param int $seconds Comment cookie lifetime. Default 30000000.
    11521152         */
    11531153        $comment_cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
    1154         $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
     1154        $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ) || force_ssl();
    11551155        setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
    11561156        setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
    11571157        setcookie( 'comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure );
  • src/wp-includes/default-constants.php

     
    263263        if ( defined( 'FORCE_SSL_LOGIN' ) && FORCE_SSL_LOGIN ) {
    264264                force_ssl_admin( true );
    265265        }
     266
     267        if ( ! defined( 'FORCE_SSL' ) ) {
     268                define( 'FORCE_SSL', false );
     269        }
    266270}
    267271
    268272/**
  • src/wp-includes/default-filters.php

     
    399399add_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
    400400add_action( 'in_admin_header', 'wp_admin_bar_render', 0 );
    401401
     402if ( force_ssl() ) {
     403        $hooks = array( 'the_content', 'the_excerpt', 'comment_text' );
     404        foreach ( $hooks as $hook ) {
     405                add_filter( $hook, 'wp_ssl_urls' );
     406        }
     407}
     408
    402409unset( $filter, $action );
  • src/wp-includes/functions.php

     
    36723672 * @return bool True if SSL, false if not used.
    36733673 */
    36743674function is_ssl() {
     3675        if ( force_ssl() ) {
     3676                return true;
     3677        }
     3678
    36753679        if ( isset($_SERVER['HTTPS']) ) {
    36763680                if ( 'on' == strtolower($_SERVER['HTTPS']) )
    36773681                        return true;
     
    37183722}
    37193723
    37203724/**
     3725 * Determine whether to force SSL
     3726 *
     3727 * @since 4.2.0
     3728 *
     3729 * @return bool True if forced SSL, false if not used.
     3730 */
     3731function force_ssl() {
     3732        return defined( 'FORCE_SSL' ) && FORCE_SSL;
     3733}
     3734
     3735/**
     3736 * Determine whether to force SSL
     3737 *
     3738 * @since 4.2.0
     3739 *
     3740 * @param string $content
     3741 *
     3742 * @return string The filtered content.
     3743 */
     3744function wp_ssl_urls( $content ) {
     3745        $search = array(
     3746                home_url( '', 'http' ),
     3747                site_url( '', 'http' )
     3748        );
     3749        $replace = array(
     3750                home_url( '', 'https' ),
     3751                site_url( '', 'https' )
     3752        );
     3753        return str_replace( $search, $replace, $content );
     3754}
     3755
     3756/**
    37213757 * Guess the URL for the site.
    37223758 *
    37233759 * Will remove wp-admin links to retrieve only return URLs not in the wp-admin
  • src/wp-includes/option.php

     
    749749        }
    750750
    751751        // The cookie is not set in the current browser or the saved value is newer.
    752         $secure = ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) );
     752        $secure = ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) ) || force_ssl();
    753753        setcookie( 'wp-settings-' . $user_id, $settings, time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure );
    754754        setcookie( 'wp-settings-time-' . $user_id, time(), time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure );
    755755        $_COOKIE['wp-settings-' . $user_id] = $settings;
  • src/wp-includes/pluggable.php

     
    873873         */
    874874        $secure_logged_in_cookie = apply_filters( 'secure_logged_in_cookie', $secure_logged_in_cookie, $user_id, $secure );
    875875
    876         if ( $secure ) {
     876        if ( $secure || force_ssl() ) {
    877877                $auth_cookie_name = SECURE_AUTH_COOKIE;
    878878                $scheme = 'secure_auth';
    879879        } else {
  • src/wp-login.php

     
    434434}
    435435
    436436//Set a cookie now to see if they are supported by the browser.
    437 $secure = ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) && 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
     437$secure = ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) && 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ) || force_ssl();
    438438setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure );
    439439if ( SITECOOKIEPATH != COOKIEPATH )
    440440        setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure );
     
    476476         * @param int $expires The expiry time, as passed to setcookie().
    477477         */
    478478        $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
    479         $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
     479        $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ) || force_ssl();
    480480        setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
    481481
    482482        wp_safe_redirect( wp_get_referer() );