返回介绍

get_site_transient()

发布于 2017-09-11 00:12:49 字数 6597 浏览 1070 评论 0 收藏 0

get_site_transient( string $transient )

Get the value of a site transient.


description

If the transient does not exist, does not have a value, or has expired, then the return value will be false.


参数

$transient

(string) (Required) Transient name. Expected to not be SQL-escaped.


返回值

(mixed) Value of transient.


源代码

File: wp-includes/option.php

function get_site_transient( $transient ) {

	/**
	 * Filters the value of an existing site transient.
	 *
	 * The dynamic portion of the hook name, `$transient`, refers to the transient name.
	 *
	 * Passing a truthy value to the filter will effectively short-circuit retrieval,
	 * returning the passed value instead.
	 *
	 * @since 2.9.0
	 * @since 4.4.0 The `$transient` parameter was added.
	 *
	 * @param mixed  $pre_site_transient The default value to return if the site transient does not exist.
	 *                                   Any value other than false will short-circuit the retrieval
	 *                                   of the transient, and return the returned value.
	 * @param string $transient          Transient name.
	 */
	$pre = apply_filters( "pre_site_transient_{$transient}", false, $transient );

	if ( false !== $pre )
		return $pre;

	if ( wp_using_ext_object_cache() ) {
		$value = wp_cache_get( $transient, 'site-transient' );
	} else {
		// Core transients that do not have a timeout. Listed here so querying timeouts can be avoided.
		$no_timeout = array('update_core', 'update_plugins', 'update_themes');
		$transient_option = '_site_transient_' . $transient;
		if ( ! in_array( $transient, $no_timeout ) ) {
			$transient_timeout = '_site_transient_timeout_' . $transient;
			$timeout = get_site_option( $transient_timeout );
			if ( false !== $timeout && $timeout < time() ) {
				delete_site_option( $transient_option  );
				delete_site_option( $transient_timeout );
				$value = false;
			}
		}

		if ( ! isset( $value ) )
			$value = get_site_option( $transient_option );
	}

	/**
	 * Filters the value of an existing site transient.
	 *
	 * The dynamic portion of the hook name, `$transient`, refers to the transient name.
	 *
	 * @since 2.9.0
	 * @since 4.4.0 The `$transient` parameter was added.
	 *
	 * @param mixed  $value     Value of site transient.
	 * @param string $transient Transient name.
	 */
	return apply_filters( "site_transient_{$transient}", $value, $transient );
}

更新日志

Versiondescription
2.9.0Introduced.

相关函数

Uses

  • wp-includes/cache.php: wp_cache_get()
  • wp-includes/load.php: wp_using_ext_object_cache()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/option.php: site_transient_{$transient}
  • wp-includes/option.php: delete_site_option()
  • wp-includes/option.php: pre_site_transient_{$transient}
  • wp-includes/option.php: get_site_option()
  • Show 2 more uses Hide more uses

Used By

  • wp-admin/includes/class-wp-community-events.php: WP_Community_Events::get_cached_events()
  • wp-admin/includes/ajax-actions.php: wp_ajax_update_theme()
  • wp-admin/includes/class-wp-plugin-install-list-table.php: WP_Plugin_Install_List_Table::get_installed_plugin_slugs()
  • wp-admin/includes/translation-install.php: wp_get_available_translations()
  • wp-admin/includes/class-wp-automatic-updater.php: WP_Automatic_Updater::run()
  • wp-admin/includes/class-plugin-upgrader.php: Plugin_Upgrader::bulk_upgrade()
  • wp-admin/includes/class-theme-upgrader.php: Theme_Upgrader::upgrade()
  • wp-admin/includes/class-theme-upgrader.php: Theme_Upgrader::bulk_upgrade()
  • wp-admin/includes/class-plugin-upgrader.php: Plugin_Upgrader::upgrade()
  • wp-admin/includes/theme.php: wp_prepare_themes_for_js()
  • wp-admin/includes/theme.php: get_theme_update_available()
  • wp-admin/includes/theme.php: get_theme_feature_list()
  • wp-admin/includes/class-wp-plugins-list-table.php: WP_Plugins_List_Table::prepare_items()
  • wp-admin/includes/class-wp-ms-themes-list-table.php: WP_MS_Themes_List_Table::prepare_items()
  • wp-admin/includes/update.php: get_core_updates()
  • wp-admin/includes/update.php: find_core_auto_update()
  • wp-admin/includes/update.php: find_core_update()
  • wp-admin/includes/update.php: get_plugin_updates()
  • wp-admin/includes/update.php: wp_plugin_update_rows()
  • wp-admin/includes/update.php: wp_plugin_update_row()
  • wp-admin/includes/update.php: get_theme_updates()
  • wp-admin/includes/update.php: wp_theme_update_rows()
  • wp-admin/includes/update.php: wp_theme_update_row()
  • wp-admin/includes/dashboard.php: wp_check_browser_version()
  • wp-admin/includes/plugin-install.php: install_popular_tags()
  • wp-admin/includes/plugin-install.php: install_plugin_install_status()
  • wp-admin/includes/plugin.php: delete_plugins()
  • wp-admin/includes/import.php: wp_get_popular_importers()
  • wp-admin/includes/credits.php: wp_credits()
  • wp-includes/theme.php: get_theme_roots()
  • wp-includes/theme.php: search_theme_directories()
  • wp-includes/update.php: _maybe_update_plugins()
  • wp-includes/update.php: _maybe_update_themes()
  • wp-includes/update.php: wp_version_check()
  • wp-includes/update.php: wp_update_plugins()
  • wp-includes/update.php: wp_update_themes()
  • wp-includes/update.php: wp_get_translation_updates()
  • wp-includes/update.php: wp_get_update_data()
  • wp-includes/update.php: _maybe_update_core()
  • Show 34 more used by Hide more used by

User Contributed Notes

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

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

发布评论

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