core_update_footer()

最后更新于:2021-11-25 22:16:22

core_update_footer( string$msg=”)

参数

$msg

(string) (Optional)

Default value: ”

响应

(string)

源文件

文件: gc-admin/includes/update.php

function core_update_footer( $msg = '' ) {
	if ( ! current_user_can( 'update_core' ) ) {
		/* translators: %s: GeChiUI version. */
		return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
	}

	$cur = get_preferred_from_update_core();
	if ( ! is_object( $cur ) ) {
		$cur = new stdClass;
	}

	if ( ! isset( $cur->current ) ) {
		$cur->current = '';
	}

	if ( ! isset( $cur->response ) ) {
		$cur->response = '';
	}

	// Include an unmodified $gc_version.
	require ABSPATH . GCINC . '/version.php';

	$is_development_version = preg_match( '/alpha|beta|RC/', $gc_version );

	if ( $is_development_version ) {
		return sprintf(
			/* translators: 1: GeChiUI version number, 2: URL to GeChiUI Updates screen. */
			__( 'You are using a development version (%1$s). Cool! Please <a href="https://docs.gechiui.com/functions/core_update_footer/%2$s">stay updated</a>.' ),
			get_bloginfo( 'version', 'display' ),
			network_admin_url( 'update-core.php' )
		);
	}

	switch ( $cur->response ) {
		case 'upgrade':
			return sprintf(
				'<strong><a href="https://docs.gechiui.com/functions/core_update_footer/%s">%s</a></strong>',
				network_admin_url( 'update-core.php' ),
				/* translators: %s: GeChiUI version. */
				sprintf( __( 'Get Version %s' ), $cur->current )
			);

		case 'latest':
		default:
			/* translators: %s: GeChiUI version. */
			return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
	}
}
// Improve Admin footer update notice.
if (!function_exists('smarter_update_footer')){
	function smarter_update_footer( $msg = '' ) {
		if ( !current_user_can('update_core') )
			return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );

		$cur = get_preferred_from_update_core();
		if ( ! is_object( $cur ) )
			$cur = new stdClass;

		if ( ! isset( $cur->current ) )
			$cur->current = '';

		if ( ! isset( $cur->url ) )
			$cur->url = '';

		if ( ! isset( $cur->response ) )
			$cur->response = '';

		switch ( $cur->response ) {
		case 'development' :
			return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="https://docs.gechiui.com/functions/core_update_footer/%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) );

		case 'upgrade' :
			return '<strong>'.sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ).' - <a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>';

		case 'latest' :
		default :
			return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
		}
	}
	add_filter( 'update_footer', 'smarter_update_footer', 9999);
}