diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 882166a3..2baf6069 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -12,7 +12,7 @@ jobs: php-tests: strategy: matrix: - php: [8.0] + php: [8.2] wordpress: ["latest"] uses: alleyinteractive/.github/.github/workflows/php-tests.yml@main with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 41fb1258..f8805c70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ This library adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/en/1.0.0/). +## Unreleased + +### Added + +- New filter `ai_logger_unrestricted_logging` to allow unrestricted logging + without checking if the log was recently seen. + ## 2.3.2 - Add return types to logger to appease `psr/log` v3. diff --git a/inc/handler/class-post-handler.php b/inc/handler/class-post-handler.php index 982b2ce2..87ff1db6 100644 --- a/inc/handler/class-post-handler.php +++ b/inc/handler/class-post-handler.php @@ -229,6 +229,16 @@ protected function insert_permitted( string $transient_key, array $log ): bool { return false; } + /** + * Allow unrestricted logging if filtered. + * + * @param bool $unrestricted_logging Whether to allow unrestricted logging. + * @param array $log Log arguments. + */ + if ( \apply_filters( 'ai_logger_unrestricted_logging', false, $log ) ) { + return true; + } + /** * The throttling transient has expired if get_transient returns false, * and a new insert should be permitted. @@ -237,9 +247,8 @@ protected function insert_permitted( string $transient_key, array $log ): bool { } /** - * Assign the terms associated with the new post, currently - * used to apply a Log Level (info, warning, error) and the - * custom context to a log + * Assign the terms associated with the new post, currently used to apply a + * Log Level (info, warning, error) and the custom context to a log * * @param int $new_post_id Post ID. * @param string $term Term name.