apply_filters( ‘pre_cache_alloptions’, array $alloptions )

Filters all options before caching them.

Parameters

$alloptionsarray
Array with all options.

Source

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

Changelog

VersionDescription
4.9.0Introduced.

User Contributed Notes

  1. Skip to note 3 content

    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.