Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



wp_theme_update_row ›

Odn/a
Przestarzałyn/a
wp_theme_update_row ( $theme_key, $theme )
Parametry: (2)
  • (string) $theme_key Theme stylesheet.
    Wymagane: Tak
  • (WP_Theme) $theme Theme object.
    Wymagane: Tak
Powrót:
  • (false|void)
Zdefiniowane na:
Codex:

Displays update information for a theme.



Źródło

function wp_theme_update_row( $theme_key, $theme ) {
	$current = get_site_transient( 'update_themes' );

	if ( ! isset( $current->response[ $theme_key ] ) ) {
		return false;
	}

	$response = $current->response[ $theme_key ];

	$details_url = add_query_arg(
		array(
			'TB_iframe' => 'true',
			'width'     => 1024,
			'height'    => 800,
		),
		$current->response[ $theme_key ]['url']
	);

	/** @var WP_MS_Themes_List_Table $wp_list_table */
	$wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' );

	$active = $theme->is_allowed( 'network' ) ? ' active' : '';

	printf(
		'<tr class="plugin-update-tr%s" id="%s" data-slug="%s">' .
		'<td colspan="%s" class="plugin-update colspanchange">' .
		'<div class="update-message notice inline notice-warning notice-alt"><p>',
		$active,
		esc_attr( $theme->get_stylesheet() . '-update' ),
		esc_attr( $theme->get_stylesheet() ),
		$wp_list_table->get_column_count()
	);

	if ( ! current_user_can( 'update_themes' ) ) {
		printf(
			/* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
			__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ),
			$theme['Name'],
			esc_url( $details_url ),
			sprintf(
				'class="thickbox open-plugin-details-modal" aria-label="%s"',
				/* translators: 1: Theme name, 2: Version number. */
				esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
			),
			$response['new_version']
		);
	} elseif ( empty( $response['package'] ) ) {
		printf(
			/* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
			__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ),
			$theme['Name'],
			esc_url( $details_url ),
			sprintf(
				'class="thickbox open-plugin-details-modal" aria-label="%s"',
				/* translators: 1: Theme name, 2: Version number. */
				esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
			),
			$response['new_version']
		);
	} else {
		printf(
			/* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */
			__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ),
			$theme['Name'],
			esc_url( $details_url ),
			sprintf(
				'class="thickbox open-plugin-details-modal" aria-label="%s"',
				/* translators: 1: Theme name, 2: Version number. */
				esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
			),
			$response['new_version'],
			wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ),
			sprintf(
				'class="update-link" aria-label="%s"',
				/* translators: %s: Theme name. */
				esc_attr( sprintf( __( 'Update %s now' ), $theme['Name'] ) )
			)
		);
	}

	/**
	 * Fires at the end of the update message container in each
	 * row of the themes list table.
	 *
	 * The dynamic portion of the hook name, `$theme_key`, refers to
	 * the theme slug as found in the WordPress.org themes repository.
	 *
	 * @since 3.1.0
	 *
	 * @param WP_Theme $theme    The WP_Theme object.
	 * @param array    $response {
	 *     An array of metadata about the available theme update.
	 *
	 *     @type string $new_version New theme version.
	 *     @type string $url         Theme URL.
	 *     @type string $package     Theme update package URL.
	 * }
	 */
	do_action( "in_theme_update_message-{$theme_key}", $theme, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores

	echo '</p></div></td></tr>';
}