WP_Theme_Install_List_Table::single_row( object $theme )

Prints a theme from the ClassicPress.net API.


Parameters

$theme

(object) (Required) An object that contains theme data returned by the ClassicPress.net API.

  • 'name'
    (string) Theme name, e.g. 'Twenty Seventeen'.
  • 'slug'
    (string) Theme slug, e.g. 'twentyseventeen'.
  • 'version'
    (string) Theme version, e.g. '1.1'.
  • 'author'
    (string) Theme author username, e.g. 'melchoyce'.
  • 'preview_url'
    (string) Preview URL, e.g. <a href="http://2017.wordpress.net/">http://2017.wordpress.net/</a>.
  • 'screenshot_url'
    (string) Screenshot URL, e.g. <a href="https://wordpress.org/themes/twentyseventeen/">https://wordpress.org/themes/twentyseventeen/</a>.
  • 'rating'
    (float) Rating score.
  • 'num_ratings'
    (int) The number of ratings.
  • 'homepage'
    (string) Theme homepage, e.g. <a href="https://wordpress.org/themes/twentyseventeen/">https://wordpress.org/themes/twentyseventeen/</a>.
  • 'description'
    (string) Theme description.
  • 'download_link'
    (string) Theme ZIP download URL.


Source

File: wp-admin/includes/class-wp-theme-install-list-table.php

	public function single_row( $theme ) {
		global $themes_allowedtags;

		if ( empty( $theme ) )
			return;

		$name   = wp_kses( $theme->name,   $themes_allowedtags );
		$author = wp_kses( $theme->author, $themes_allowedtags );

		$preview_title = sprintf( __('Preview &#8220;%s&#8221;'), $name );
		$preview_url   = add_query_arg( array(
			'tab'   => 'theme-information',
			'theme' => $theme->slug,
		), self_admin_url( 'theme-install.php' ) );

		$actions = array();

		$install_url = add_query_arg( array(
			'action' => 'install-theme',
			'theme'  => $theme->slug,
		), self_admin_url( 'update.php' ) );

		$update_url = add_query_arg( array(
			'action' => 'upgrade-theme',
			'theme'  => $theme->slug,
		), self_admin_url( 'update.php' ) );

		$status = $this->_get_theme_status( $theme );

		switch ( $status ) {
			case 'update_available':
				$actions[] = '<a class="install-now" href="' . esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ) . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ) . '">' . __( 'Update' ) . '</a>';
				break;
			case 'newer_installed':
			case 'latest_installed':
				$actions[] = '<span class="install-now" title="' . esc_attr__( 'This theme is already installed and is up to date' ) . '">' . _x( 'Installed', 'theme' ) . '</span>';
				break;
			case 'install':
			default:
				$actions[] = '<a class="install-now" href="' . esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ) . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>';
				break;
		}

		$actions[] = '<a class="install-theme-preview" href="' . esc_url( $preview_url ) . '" title="' . esc_attr( sprintf( __( 'Preview %s' ), $name ) ) . '">' . __( 'Preview' ) . '</a>';

		/**
		 * Filters the install action links for a theme in the Install Themes list table.
		 *
		 * @since WP-3.4.0
		 *
		 * @param array    $actions An array of theme action hyperlinks. Defaults are
		 *                          links to Install Now, Preview, and Details.
		 * @param WP_Theme $theme   Theme object.
		 */
		$actions = apply_filters( 'theme_install_actions', $actions, $theme );

		?>
		<a class="screenshot install-theme-preview" href="<?php echo esc_url( $preview_url ); ?>" title="<?php echo esc_attr( $preview_title ); ?>">
			<img src="<?php echo esc_url( $theme->screenshot_url ); ?>" width="150" alt="" />
		</a>

		<h3><?php echo $name; ?></h3>
		<div class="theme-author"><?php printf( __( 'By %s' ), $author ); ?></div>

		<div class="action-links">
			<ul>
				<?php foreach ( $actions as $action ): ?>
					<li><?php echo $action; ?></li>
				<?php endforeach; ?>
				<li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e('Details') ?></a></li>
			</ul>
		</div>

		<?php
		$this->install_theme_info( $theme );
	}


Changelog

Changelog
Version Description
WP-3.1.0 Introduced.