返回介绍

wp_load_alloptions()

发布于 2017-09-11 12:22:39 字数 3011 浏览 1024 评论 0 收藏 0

wp_load_alloptions()

Loads and caches all autoloaded options, if available or all options.


description


返回值

(array) List of all options.


源代码

File: wp-includes/option.php

function wp_load_alloptions() {
	global $wpdb;

	if ( ! wp_installing() || ! is_multisite() )
		$alloptions = wp_cache_get( 'alloptions', 'options' );
	else
		$alloptions = false;

	if ( !$alloptions ) {
		$suppress = $wpdb->suppress_errors();
		if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) )
			$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
		$wpdb->suppress_errors($suppress);
		$alloptions = array();
		foreach ( (array) $alloptions_db as $o ) {
			$alloptions[$o->option_name] = $o->option_value;
		}
		if ( ! wp_installing() || ! is_multisite() )
			wp_cache_add( 'alloptions', $alloptions, 'options' );
	}

	return $alloptions;
}

更新日志

Versiondescription
2.2.0Introduced.

相关函数

Uses

  • wp-includes/load.php: wp_installing()
  • wp-includes/cache.php: wp_cache_get()
  • wp-includes/cache.php: wp_cache_add()
  • wp-includes/load.php: is_multisite()
  • wp-includes/wp-db.php: wpdb::get_results()
  • wp-includes/wp-db.php: wpdb::suppress_errors()
  • Show 1 more use Hide more uses

Used By

  • wp-includes/formatting.php: _wp_specialchars()
  • wp-includes/deprecated.php: get_alloptions()
  • wp-includes/functions.php: is_blog_installed()
  • wp-includes/option.php: get_transient()
  • wp-includes/option.php: update_option()
  • wp-includes/option.php: add_option()
  • wp-includes/option.php: delete_option()
  • wp-includes/option.php: get_option()
  • Show 3 more used by Hide more used by

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note Contributed by Codex

    Example

    
    $all_options = wp_load_alloptions();
    $my_options  = array();
    
    foreach ( $all_options as $name => $value ) {
    	if ( stristr( $name, '_transient' ) ) {
    		$my_options[ $name ] = $value;
    	}
    }
    
    print_r( $my_options );
    

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

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

发布评论

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