[wp-trac] [WordPress Trac] #48481: don't apply wp_initialize_site_args filter until after wp-admin-includes/update.php is loaded

WordPress Trac noreply at wordpress.org
Fri Nov 1 17:46:04 UTC 2019


#48481: don't apply wp_initialize_site_args filter until after wp-admin-
includes/update.php is loaded
--------------------------------+-----------------------------
 Reporter:  pbiron              |      Owner:  (none)
     Type:  enhancement         |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Networks and Sites  |    Version:
 Severity:  normal              |   Keywords:
  Focuses:  multisite           |
--------------------------------+-----------------------------
 A recent [https://wordpress.slack.com/archives/C03BVB47S/p1572621303020200
 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`:

 {{{#!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

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48481>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list