Make WordPress Core


Ignore:
Timestamp:
09/13/2022 07:27:19 PM (2 years ago)
Author:
davidbaumwald
Message:

Options, Meta APIs: Add a new pre-option filter.

Although a pre_option_{$option} filter already exists, this change adds a more general pre_option filter that will run on every get_option call. This brings the control flow into similar flow as update_option.

Props flixos90, NathanAtmoz, desrosj, spacedmonkey, pbearne.
Fixes #37930.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/option/option.php

    r53865 r54145  
    298298        );
    299299    }
     300
     301    /**
     302     * @ticket 37930
     303     *
     304     * @covers ::get_option
     305     */
     306    public function test_filter_pre_option_all_filter_is_called() {
     307        $filter = new MockAction();
     308
     309        add_filter( 'pre_option', array( $filter, 'filter' ) );
     310
     311        get_option( 'ignored' );
     312
     313        $this->assertSame( 1, $filter->get_call_count() );
     314    }
    300315}
Note: See TracChangeset for help on using the changeset viewer.