Make WordPress Core


Ignore:
Timestamp:
02/07/2023 12:47:30 PM (2 years ago)
Author:
spacedmonkey
Message:

Options, Meta APIs: Add a filter to allow the shortcut return to wp_load_alloptions function.

Add a new filter pre_wp_load_alloptions in the wp_load_alloptions function to short circuit the return value.

Props pbearne, spacedmonkey, joyously, SergeyBiryukov, mukesh27, costdev.
Fixes #56045.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/option.php

    r55033 r55256  
    301301function wp_load_alloptions( $force_cache = false ) {
    302302    global $wpdb;
     303
     304    /**
     305     * Filters the array of alloptions before it is populated.
     306     *
     307     * Returning an array from the filter will effectively short circuit
     308     * wp_load_alloptions(), returning that value instead.
     309     *
     310     * @since 6.2.0
     311     *
     312     * @param array|null $alloptions  An array of alloptions. Default null.
     313     * @param bool       $force_cache Whether to force an update of the local cache from the persistent cache. Default false.
     314     */
     315    $alloptions = apply_filters( 'pre_wp_load_alloptions', null, $force_cache );
     316    if ( is_array( $alloptions ) ) {
     317        return $alloptions;
     318    }
    303319
    304320    if ( ! wp_installing() || ! is_multisite() ) {
Note: See TracChangeset for help on using the changeset viewer.