[wp-trac] [WordPress Trac] #56458: Multisite Theme Details

WordPress Trac noreply at wordpress.org
Fri Sep 30 14:11:10 UTC 2022


#56458: Multisite Theme Details
------------------------------+--------------------------------------------
 Reporter:  hopetommola       |       Owner:  (none)
     Type:  feature request   |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Networks and      |     Version:  6.0.1
  Sites                       |
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:  ui, administration, multisite
------------------------------+--------------------------------------------

Comment (by bananastalktome):

 @bgoewert @hopetommola
 ('''disclaimer''': this may not be the best way to accomplish this, but it
 has worked for me)

 I have been able to accomplish this by hooking in to the existing hooks on
 [https://developer.wordpress.org/reference/classes/WP_MS_Sites_List_Table/
 WP_MS_Sites_List_Table], ex/:

 {{{
 #!php
 <?php
 if (is_network_admin()) {
   add_action('admin_init', function() {
     // `manage_{$screen->id}_columns` hook applied in
 `get_column_headers()` function
     add_filter('manage_sites-network_columns', function($columns) {
       $columns['site-theme'] = 'Theme';
       return $columns;
     });

     // `manage_sites_custom_column` hook applied in `column_default()`
 from `WP_MS_Sites_List_Table` class.
     add_action('manage_sites_custom_column', function($column_name,
 $blog_id) {
       if ($column_name !== 'site-theme') {
         return;
       }

       switch_to_blog($blog_id);
       $theme = \wp_get_theme(); // Returns a `WP_Theme` object
       ?>
       <div><?= esc_html($theme->get('Name')); ?></div>
       <div><?= esc_html($theme->get('Version')); ?></div>
       <?php
       restore_current_blog();
     }, 10, 2);
   });
 }
 }}}

 You can check out
 [https://developer.wordpress.org/reference/classes/WP_Theme/ WP_Theme] to
 see what other properties are available to show as well.

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


More information about the wp-trac mailing list