Subject: [PATCH] Updated for WordPress 6.6.0
---
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php
|
a
|
b
|
|
| 1083 | 1083 | $option = trim( $option ); |
| 1084 | 1084 | } |
| 1085 | 1085 | |
| | 1086 | /** |
| | 1087 | * Filters the option name before the option gets deleted. |
| | 1088 | * |
| | 1089 | * Returning an empty string short circuits the function. |
| | 1090 | * |
| | 1091 | * @since 6.6.0 |
| | 1092 | * |
| | 1093 | * @param string $option Option name. |
| | 1094 | */ |
| | 1095 | $option = trim( apply_filters( 'pre_delete_option', $option ) ); |
| | 1096 | |
| 1086 | 1097 | if ( empty( $option ) ) { |
| 1087 | 1098 | return false; |
| 1088 | 1099 | } |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/tests/phpunit/tests/option/option.php b/tests/phpunit/tests/option/option.php
|
a
|
b
|
|
| 478 | 478 | delete_option( 'foo' ); |
| 479 | 479 | $this->assertFalse( get_option( 'foo' ) ); |
| 480 | 480 | } |
| | 481 | |
| | 482 | /** |
| | 483 | * @ticket 44042 |
| | 484 | */ |
| | 485 | function test_pre_delete_option_filter() { |
| | 486 | add_filter( 'pre_delete_option', function( $option ) { |
| | 487 | if ( 'test_option_test' === $option ) { |
| | 488 | $option = 'test_option'; |
| | 489 | } |
| | 490 | |
| | 491 | return $option; |
| | 492 | } ); |
| | 493 | |
| | 494 | add_option( 'test_option', '1' ); |
| | 495 | delete_option( 'test_option_test' ); |
| | 496 | |
| | 497 | $this->assertEquals( false, get_option( 'test_option' ) ); |
| | 498 | |
| | 499 | } |
| | 500 | |
| | 501 | /** |
| | 502 | * Returning an empty string in `pre_delete_option` short circuits `delete_option()`. |
| | 503 | * |
| | 504 | * @ticket 44042 |
| | 505 | */ |
| | 506 | function test_pre_delete_option_short_circuit() { |
| | 507 | add_filter( 'pre_delete_option', function( $option ) { |
| | 508 | if ( 'test_option' === $option ) { |
| | 509 | return ''; |
| | 510 | } |
| | 511 | } ); |
| | 512 | |
| | 513 | add_option( 'test_option', '5' ); |
| | 514 | delete_option( 'test_option' ); |
| | 515 | |
| | 516 | $this->assertEquals( '5', get_option( 'test_option' ) ); |
| | 517 | } |
| 481 | 518 | } |