[wp-trac] [WordPress Trac] #61029: Multisite state 'Delete' can only have a value of 1or 0. Not 2. So why is 2 mentioned in the code?

WordPress Trac noreply at wordpress.org
Thu Apr 18 01:46:58 UTC 2024


#61029: Multisite state 'Delete' can only have a value of 1or 0. Not 2. So why is 2
mentioned in the code?
--------------------------------+------------------------------
 Reporter:  ignatiusjeroe       |       Owner:  (none)
     Type:  defect (bug)        |      Status:  new
 Priority:  normal              |   Milestone:  Awaiting Review
Component:  Networks and Sites  |     Version:
 Severity:  normal              |  Resolution:
 Keywords:                      |     Focuses:  multisite
--------------------------------+------------------------------

Comment (by costdev):

 > The drop-in in the if-statement is rendered unusable cause the if-
 statement will fail every time.

 Note that the return value of
 [https://developer.wordpress.org/reference/functions/get_site/#return
 get_site()] is filterable using the
 [https://developer.wordpress.org/reference/hooks/get_site/ get_site] hook.

 For example, the following can be used to set `$deleted` to `'2'` to
 differentiate between `'1'` a site that is no longer available, and `'2'`
 a site that has not been activated yet (i.e. it was never available). That
 branch will be hit, and either load `WP_CONTENT_DIR . '/blog-
 inactive.php'` if available, or output the default message.

 {{{#!php
 add_filter(
   'get_site',
   static function ( $_site ) {
     $_site->deleted = '2';
     return $_site;
   }
 );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61029#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list