wppaste
WordPress

wp_load_alloptions( bool $force_cache = false ): array

Since
2.2.0, 5.3.1
Source
wp-includes/option.php:600
Loads and caches all autoloaded options, if available or all options.

Parameters

$force_cachebooloptional
Whether to force an update of the local cache from the persistent cache. Default false.Default: false

Return

array
List of all options.

Hooks fired · 3

3 hooks fire while wp_load_alloptions() runs, in this order:

  1. apply_filters( pre_wp_load_alloptions )filterline 614 (+14 into the body)

    Filters the array of alloptions before it is populated.

  2. apply_filters( pre_cache_alloptions )filterline 647 (+47 into the body)

    Filters all options before caching them.

  3. apply_filters( alloptions )filterline 660 (+60 into the body)

    Filters all options after retrieving them.

Uses · 7

Used by · 12

Source

function wp_load_alloptions( $force_cache = false ) {	global $wpdb; 	/**	 * Filters the array of alloptions before it is populated.	 *	 * Returning an array from the filter will effectively short circuit	 * wp_load_alloptions(), returning that value instead.	 *	 * @since 6.2.0	 *	 * @param array|null $alloptions  An array of alloptions. Default null.	 * @param bool       $force_cache Whether to force an update of the local cache from the persistent cache. Default false.	 */	$alloptions = apply_filters( 'pre_wp_load_alloptions', null, $force_cache );	if ( is_array( $alloptions ) ) {		return $alloptions;	} 	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 IN ( '" . implode( "', '", esc_sql( wp_autoload_values_to_autoload() ) ) . "' )" ); 		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 );}

History

Introduced in 2.2.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.3.1
The $force_cache parameter was added.from the docblock
2.2.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/option.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.