wp_load_alloptions

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

Description

(array) wp_load_alloptions(); 

Returns (array)

List of all options.


Usage

  1. if ( !function_exists( 'wp_load_alloptions' ) ) { 
  2. require_once ABSPATH . WPINC . '/option.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_load_alloptions(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/option.php  
  1. function wp_load_alloptions() { 
  2. global $wpdb; 
  3.  
  4. if ( ! wp_installing() || ! is_multisite() ) 
  5. $alloptions = wp_cache_get( 'alloptions', 'options' ); 
  6. else 
  7. $alloptions = false; 
  8.  
  9. if ( !$alloptions ) { 
  10. $suppress = $wpdb->suppress_errors(); 
  11. if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) 
  12. $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); 
  13. $wpdb->suppress_errors($suppress); 
  14. $alloptions = array(); 
  15. foreach ( (array) $alloptions_db as $o ) { 
  16. $alloptions[$o->option_name] = $o->option_value; 
  17. if ( ! wp_installing() || ! is_multisite() ) 
  18. wp_cache_add( 'alloptions', $alloptions, 'options' ); 
  19.  
  20. return $alloptions;