On this page
wp_load_alloptions( bool $force_cache = false ): array
Loads and caches all autoloaded options, if available or all options.
Parameters
$force_cachebool Optional-
Whether to force an update of the local cache from the persistent cache.
Default:
false
Return
array List of all options.
Source
File: wp-includes/option.php. View all references
function wp_load_alloptions( $force_cache = false ) {
global $wpdb;
if ( ! wp_installing() || ! is_multisite() ) {
$alloptions = wp_cache_get( 'alloptions', 'options', $force_cache );
} else {
$alloptions = false;
}
if ( ! $alloptions ) {
$suppress = $wpdb->suppress_errors();
$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" );
if ( ! $alloptions_db ) {
$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() ) {
/**
* Filters all options before caching them.
*
* @since 4.9.0
*
* @param array $alloptions Array with all options.
*/
$alloptions = apply_filters( 'pre_cache_alloptions', $alloptions );
wp_cache_add( 'alloptions', $alloptions, 'options' );
}
}
/**
* Filters all options after retrieving them.
*
* @since 4.9.0
*
* @param array $alloptions Array with all options.
*/
return apply_filters( 'alloptions', $alloptions );
}
Hooks
- apply_filters( 'alloptions',
array $alloptions ) -
Filters all options after retrieving them.
- apply_filters( 'pre_cache_alloptions',
array $alloptions ) -
Filters all options before caching them.
Related
Uses
| Uses | Description |
|---|---|
| wp_installing() wp-includes/load.php | Check or set whether WordPress is in “installation” mode. |
| wp_cache_add() wp-includes/cache.php | Adds data to the cache, if the cache key doesn’t already exist. |
| wpdb::suppress_errors() wp-includes/class-wpdb.php | Enables or disables suppressing of database errors. |
| wp_cache_get() wp-includes/cache.php | Retrieves the cache contents from the cache by key and group. |
| is_multisite() wp-includes/load.php | If Multisite is enabled. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| wpdb::get_results() wp-includes/class-wpdb.php | Retrieves an entire SQL result set from the database (i.e., many rows). |
Used By
| Used By | Description |
|---|---|
| WP_Site_Health::should_suggest_persistent_object_cache() wp-admin/includes/class-wp-site-health.php | Determines whether to suggest using a persistent object cache. |
| _wp_specialchars() wp-includes/formatting.php | Converts a number of special characters into their HTML entities. |
| get_alloptions() wp-includes/deprecated.php | Retrieve all autoload options, or all options if no autoloaded ones exist. |
| is_blog_installed() wp-includes/functions.php | Determines whether WordPress is already installed. |
| get_transient() wp-includes/option.php | Retrieves the value of a transient. |
| update_option() wp-includes/option.php | Updates the value of an option that was already added. |
| add_option() wp-includes/option.php | Adds a new option. |
| delete_option() wp-includes/option.php | Removes option by name. Prevents removal of protected WordPress options. |
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_load_alloptions