OSDN Git Service

Adding site and network enabled columns to wp theme list
authorMatt Boynes <mboynes@alleyinteractive.com>
Sat, 28 Dec 2013 06:28:54 +0000 (01:28 -0500)
committerMatt Boynes <mboynes@alleyinteractive.com>
Sat, 28 Dec 2013 06:28:54 +0000 (01:28 -0500)
php/commands/theme.php

index 7975acb..2d41280 100644 (file)
@@ -19,6 +19,10 @@ class Theme_Command extends \WP_CLI\CommandWithUpgrade {
        );
 
        function __construct() {
+               if ( is_multisite() ) {
+                       $this->obj_fields[] = 'site_enabled';
+                       $this->obj_fields[] = 'network_enabled';
+               }
                parent::__construct();
 
                $this->fetcher = new \WP_CLI\Fetchers\Theme;
@@ -193,6 +197,16 @@ class Theme_Command extends \WP_CLI\CommandWithUpgrade {
        protected function get_item_list() {
                $items = array();
 
+               if ( is_multisite() ) {
+                       $site_enabled = get_option( 'allowedthemes' );
+                       if ( empty( $site_enabled ) )
+                               $site_enabled = array();
+
+                       $network_enabled = get_site_option( 'allowedthemes' );
+                       if ( empty( $network_enabled ) )
+                               $network_enabled = array();
+               }
+
                foreach ( wp_get_themes() as $key => $theme ) {
                        $file = $theme->get_stylesheet_directory();
                        $update_info = $this->get_update_info( $theme->get_stylesheet() );
@@ -206,6 +220,11 @@ class Theme_Command extends \WP_CLI\CommandWithUpgrade {
                                'version' => $theme->get('Version'),
                                'update_id' => $theme->get_stylesheet(),
                        );
+
+                       if ( is_multisite() ) {
+                               $items[ $file ]['site_enabled'] = ! empty( $site_enabled[ $key ] ) ? 'enabled' : 'disabled';
+                               $items[ $file ]['network_enabled'] = ! empty( $network_enabled[ $key ] ) ? 'enabled' : 'disabled';
+                       }
                }
 
                return $items;