Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#48481 new enhancement

don't apply wp_initialize_site_args filter until after wp-admin-includes/update.php is loaded

Reported by: pbiron's profile pbiron Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: has-patch
Focuses: multisite Cc:

Description

A recent slack thread discussed the desire to have sub-domain installs default the siteurl and home options to https (at least on a given install). in that thread it was suggested that one could hook into wp_initialize_site_args to accomplish that.

It would be great if one could hook into wp_initialize_site_args in a custom WP_CONTENT_DIR . '/install.php'. Unfortunately, that isn't loaded until after wp_initialize_site_args is applied.

Therefore, I suggest that wp_initialize_site() should apply wp_initialize_site_args only after wp-admin-includes/update.php has been loaded (that file in turn loads WP_CONTENT_DIR . '/install.php').

Doing that would allow a site owner that new all of the sub-domain sites they were going to add would support https to add something like the following to their WP_CONTENT_DIR . '/install.php:

add_filter( 'wp_initialize_site_args', 'mysite_https_siteurl_and_home' ), 10, 3 );
function mysite_https_siteurl_and_home( $args, $site, $network ) {
        if ( is_subdomain_install() ) {
                $args['options'] = array_merge(
                        array(
                                'home'    => untrailingslashit( 'https://' . $site->domain . $site->path ),
                                'siteurl' => untrailingslashit( 'https://' . $site->domain . $site->path ),
                        ),
                        $args['options']
                );
        }

        return $args;
}

Related: #14172, #27499

Attachments (1)

48481.diff (1.7 KB) - added by pbiron 5 years ago.

Download all attachments as: .zip

Change History (4)

@pbiron
5 years ago

#1 @pbiron
5 years ago

  • Keywords has-patch added

This ticket was mentioned in Slack in #core-multisite by pbiron. View the logs.


5 years ago

#3 @Seags
5 years ago

I don't really use WP_CONTENT_DIR . '/install.php but I could imagine it being useful for default behaviour you wish to invoke such as this.

Note: See TracTickets for help on using tickets.