WP_MS_Themes_List_Table::prepare_items() –

You appear to be a bot. Output may be restricted

Description

Usage

WP_MS_Themes_List_Table::prepare_items();

Parameters

Returns

void

Source

File name: wordpress/wp-admin/includes/class-wp-ms-themes-list-table.php
Lines:

1 to 100 of 161
  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 = (object) array_merge( $filter_payload, array_intersect_key( $theme_data, $filter_payload ) );

      $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, $filter_payload );

      if ( ! is_null( $auto_update_forced ) ) {
        $theme->auto_update_forced = $auto_update_forced;
      }

      if ( $this->show_autoupdates ) {
        $enabled = in_array( $key, $auto_updates, true ) && $theme->update_supported;
        if ( isset( $theme->auto_update_forced ) ) {
          $enabled = (bool) $theme->auto_update_forced;
        }

        if ( $enabled ) {
          $themes['auto-update-enabled'][ $key ] = $theme;
        } else {
          $themes['auto-update-disabled'][ $key ] = $theme;
 

 View on GitHub View on Trac