Syntax Syntax
Source Source
File: wp-admin/includes/class-wp-ms-themes-list-table.php
return current_user_can( 'manage_network_themes' ); } } /** * @global string $status * @global array $totals * @global int $page * @global string $orderby * @global string $order * @global string $s */ public function prepare_items() { global $status, $totals, $page, $orderby, $order, $s; wp_reset_vars( array( 'orderby', 'order', 's' ) ); $themes = array( /** * Filters the full array of WP_Theme objects to list in the Multisite * themes list table. * * @since 3.1.0 * * @param WP_Theme[] $all Array of WP_Theme objects to display in the list table. */ 'all' => apply_filters( 'all_themes', wp_get_themes() ), 'search' => array(), 'enabled' => array(), 'disabled' => array(), 'upgrade' => array(), 'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ), ); if ( $this->show_autoupdates ) { $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); $themes['auto-update-enabled'] = array(); $themes['auto-update-disabled'] = array(); } if ( $this->is_site_themes ) { $themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' ); $allowed_where = 'site'; } else { $themes_per_page = $this->get_items_per_page( 'themes_network_per_page' ); $allowed_where = 'network'; } $current = get_site_transient( 'update_themes' ); $maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && $current; foreach ( (array) $themes['all'] as $key => $theme ) { if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) { unset( $themes['all'][ $key ] ); continue; } if ( $maybe_update && isset( $current->response[ $key ] ) ) { $themes['all'][ $key ]->update = true; $themes['upgrade'][ $key ] = $themes['all'][ $key ]; } $filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled'; $themes[ $filter ][ $key ] = $themes['all'][ $key ]; $theme_data = array( 'update_supported' => isset( $theme->update_supported ) ? $theme->update_supported : true, ); // Extra info if known. array_merge() ensures $theme_data has precedence if keys collide. if ( isset( $current->response[ $key ] ) ) { $theme_data = array_merge( (array) $current->response[ $key ], $theme_data ); } elseif ( isset( $current->no_update[ $key ] ) ) { $theme_data = array_merge( (array) $current->no_update[ $key ], $theme_data ); } else { $theme_data['update_supported'] = false; } $theme->update_supported = $theme_data['update_supported']; /* * Create the expected payload for the auto_update_theme filter, this is the same data * as contained within $updates or $no_updates but used when the Theme is not known. */ $filter_payload = array( 'theme' => $key, 'new_version' => '', 'url' => '', 'package' => '', 'requires' => '', 'requires_php' => '', ); $filter_payload = array_merge( $filter_payload, array_intersect_key( $theme_data, $filter_payload ) ); $type = 'theme'; /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ $auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $filter_payload ); if ( ! is_null( $auto_update_forced ) ) { $theme->auto_update_forced = $auto_update_forced; }