apply_filters( 'pre_cache_alloptions', array $alloptions )

Filters all options before caching them.


Parameters

$alloptions array
Array with all options.

Top ↑

Source

File: wp-includes/option.php. View all references

$alloptions = apply_filters( 'pre_cache_alloptions', $alloptions );


Top ↑

Changelog

Changelog
Version Description
4.9.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Nawawi Jamili

    Optimize alloptions: remove option if size more than 1MB.

    add_action( 'pre_cache_alloptions', function( $alloptions ) {
    	foreach ( $alloptions as $key => $value ) {
    		$size = strlen( maybe_serialize( $value ) );
    		if ( $size > 1000000 ) {
    			unset( $alloptions[$key] );
    		}
    	}
    	return $alloptions;
    } );

You must log in before being able to contribute a note or feedback.