返回介绍

wp_theme_update_row()

发布于 2017-09-11 12:59:29 字数 5571 浏览 876 评论 0 收藏 0

wp_theme_update_row( string $theme_key,  WP_Theme $theme )

Displays update information for a theme.


description


参数

$theme_key

(string) (Required) Theme stylesheet.

$theme

(WP_Theme) (Required) Theme object.


返回值

(false|void)


源代码

File: wp-admin/includes/update.php

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' : '';

	echo '<tr class="plugin-update-tr' . $active . '" id="' . esc_attr( $theme->get_stylesheet() . '-update' ) . '" data-slug="' . esc_attr( $theme->get_stylesheet() ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>';
	if ( ! current_user_can( 'update_themes' ) ) {
		/* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */
		printf( __( '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'] ) ) {
		/* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */
		printf( __( '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 {
		/* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */
		printf( __( '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 );

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

Collapse full 源代码 code View on Trac


相关函数

Uses

  • wp-admin/includes/class-wp-list-table.php: WP_List_Table::get_column_count()
  • wp-admin/includes/update.php: in_theme_update_message-{$theme_key}
  • wp-admin/includes/list-table.php: _get_list_table()
  • wp-includes/capabilities.php: current_user_can()
  • wp-includes/l10n.php: __()
  • wp-includes/formatting.php: esc_attr()
  • wp-includes/formatting.php: esc_url()
  • wp-includes/functions.php: wp_nonce_url()
  • wp-includes/functions.php: add_query_arg()
  • wp-includes/link-template.php: self_admin_url()
  • wp-includes/plugin.php: do_action()
  • wp-includes/option.php: get_site_transient()
  • Show 7 more uses Hide more uses

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文