Skip to content

Commit f5961fc

Browse files
committed
Address PR review feedback
1 parent beec383 commit f5961fc

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

src/wp-includes/comment.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3170,7 +3170,7 @@ function generic_ping( $post_id = 0 ) {
31703170
* notifications, as well as incoming pingbacks and trackbacks) are disabled
31713171
* for non-production environments ('local', 'development', 'staging').
31723172
*
3173-
* @since 6.9.0
3173+
* @since 7.1.0
31743174
*
31753175
* @return bool True if pings should be disabled, false otherwise.
31763176
*/
@@ -3184,7 +3184,7 @@ function wp_should_disable_pings_for_environment() {
31843184
* Returning false re-enables pings in non-production environments.
31853185
* Returning true disables pings even in production.
31863186
*
3187-
* @since 6.9.0
3187+
* @since 7.1.0
31883188
*
31893189
* @param bool $should_disable Whether pings should be disabled. Default true
31903190
* for non-production environments, false for production.
@@ -3200,7 +3200,7 @@ function wp_should_disable_pings_for_environment() {
32003200
* Hooked to `do_all_pings` at priority 1 so it runs before the default
32013201
* priority 10 callbacks. Does not remove `do_all_enclosures`.
32023202
*
3203-
* @since 6.9.0
3203+
* @since 7.1.0
32043204
* @access private
32053205
*/
32063206
function wp_disable_outgoing_pings_for_environment() {
@@ -3218,22 +3218,19 @@ function wp_disable_outgoing_pings_for_environment() {
32183218
* trackback is processed. Calls `trackback_response()` which sends an XML error
32193219
* response and terminates the request.
32203220
*
3221-
* @since 6.9.0
3221+
* @since 7.1.0
32223222
* @access private
3223-
*
3224-
* @param int $post_id Post ID related to the trackback.
3225-
* @param string $trackback_url Trackback URL.
32263223
*/
3227-
function wp_disable_trackback_for_environment( $post_id, $trackback_url ) {
3224+
function wp_disable_trackback_for_environment() {
32283225
if ( wp_should_disable_pings_for_environment() ) {
3229-
trackback_response( 1, __( 'Sorry, trackbacks are closed for this item.' ) );
3226+
trackback_response( 1, __( 'Trackbacks are disabled in non-production environments.' ) );
32303227
}
32313228
}
32323229

32333230
/**
32343231
* Removes the pingback XML-RPC method in non-production environments.
32353232
*
3236-
* @since 6.9.0
3233+
* @since 7.1.0
32373234
* @access private
32383235
*
32393236
* @param string[] $methods An array of XML-RPC methods, keyed by their methodName.

src/wp-includes/default-filters.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@
424424

425425
// Disable pings (pingbacks, trackbacks, and ping service notifications) in non-production environments.
426426
add_action( 'do_all_pings', 'wp_disable_outgoing_pings_for_environment', 1, 0 );
427-
add_action( 'pre_trackback_post', 'wp_disable_trackback_for_environment', 10, 2 );
427+
add_action( 'pre_trackback_post', 'wp_disable_trackback_for_environment', 10, 0 );
428428
add_filter( 'xmlrpc_methods', 'wp_disable_xmlrpc_pingback_for_environment' );
429429

430430
add_action( 'do_robots', 'do_robots' );

tests/phpunit/tests/comment/disablePingsForEnvironment.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ public function test_outgoing_pings_preserved_in_production() {
174174

175175
wp_disable_outgoing_pings_for_environment();
176176

177-
$this->assertSame( 10, has_action( 'do_all_pings', 'do_all_pingbacks' ) );
178-
$this->assertSame( 10, has_action( 'do_all_pings', 'do_all_trackbacks' ) );
179-
$this->assertSame( 10, has_action( 'do_all_pings', 'generic_ping' ) );
177+
$this->assertSame( 10, has_action( 'do_all_pings', 'do_all_pingbacks' ), 'do_all_pingbacks should still be hooked.' );
178+
$this->assertSame( 10, has_action( 'do_all_pings', 'do_all_trackbacks' ), 'do_all_trackbacks should still be hooked.' );
179+
$this->assertSame( 10, has_action( 'do_all_pings', 'generic_ping' ), 'generic_ping should still be hooked.' );
180180
}
181181

182182
/**
183183
* @ticket 64837
184184
*/
185-
public function test_trackback_hook_registered_in_non_production() {
185+
public function test_trackback_hook_is_registered() {
186186
$this->assertSame( 10, has_action( 'pre_trackback_post', 'wp_disable_trackback_for_environment' ) );
187187
}
188188

0 commit comments

Comments
 (0)