mirror of
https://github.com/WordPress/WordPress.git
synced 2026-06-19 07:37:07 +00:00
REVERT r62231: Disable pings/trackbacks for local, development, and staging environments
Commits to trunk have been paused for 7.0. See: https://make.wordpress.org/core/2026/04/02/the-path-forward-for-wordpress-7-0/ Props arcangelini, cagrimmett, ramonopoly, tyxla, ocean90, khushipatel15. Follow-up to [64837]. See #64837. Built from https://develop.svn.wordpress.org/trunk@62233 git-svn-id: http://core.svn.wordpress.org/trunk@61513 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -3163,84 +3163,6 @@ function generic_ping( $post_id = 0 ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether pings should be disabled for the current environment.
|
||||
*
|
||||
* By default, all pings (outgoing pingbacks, trackbacks, and ping service
|
||||
* notifications, as well as incoming pingbacks and trackbacks) are disabled
|
||||
* for non-production environments ('local', 'development', 'staging').
|
||||
*
|
||||
* @since 7.1.0
|
||||
*
|
||||
* @return bool True if pings should be disabled, false otherwise.
|
||||
*/
|
||||
function wp_should_disable_pings_for_environment() {
|
||||
$environment_type = wp_get_environment_type();
|
||||
$should_disable = 'production' !== $environment_type;
|
||||
|
||||
/**
|
||||
* Filters whether pings should be disabled for the current environment.
|
||||
*
|
||||
* Returning false re-enables pings in non-production environments.
|
||||
* Returning true disables pings even in production.
|
||||
*
|
||||
* @since 7.1.0
|
||||
*
|
||||
* @param bool $should_disable Whether pings should be disabled. Default true
|
||||
* for non-production environments, false for production.
|
||||
* @param string $environment_type The current environment type as returned by
|
||||
* wp_get_environment_type().
|
||||
*/
|
||||
return apply_filters( 'wp_should_disable_pings_for_environment', $should_disable, $environment_type );
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes outgoing ping callbacks in non-production environments.
|
||||
*
|
||||
* Hooked to `do_all_pings` at priority 1 so it runs before the default
|
||||
* priority 10 callbacks. Does not remove `do_all_enclosures`.
|
||||
*
|
||||
* @since 7.1.0
|
||||
*/
|
||||
function wp_maybe_disable_outgoing_pings_for_environment() {
|
||||
if ( wp_should_disable_pings_for_environment() ) {
|
||||
remove_action( 'do_all_pings', 'do_all_pingbacks' );
|
||||
remove_action( 'do_all_pings', 'do_all_trackbacks' );
|
||||
remove_action( 'do_all_pings', 'generic_ping' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rejects incoming trackbacks in non-production environments.
|
||||
*
|
||||
* Hooked to `pre_trackback_post` which fires in `wp-trackback.php` before the
|
||||
* trackback is processed. Calls `trackback_response()` which sends an XML error
|
||||
* response and terminates the request.
|
||||
*
|
||||
* @since 7.1.0
|
||||
*/
|
||||
function wp_maybe_disable_trackback_for_environment() {
|
||||
if ( wp_should_disable_pings_for_environment() ) {
|
||||
trackback_response( 1, __( 'Trackbacks are disabled in non-production environments.' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the pingback XML-RPC method in non-production environments.
|
||||
*
|
||||
* @since 7.1.0
|
||||
*
|
||||
* @param string[] $methods An array of XML-RPC methods, keyed by their methodName.
|
||||
* @return string[] Modified array of XML-RPC methods.
|
||||
*/
|
||||
function wp_maybe_disable_xmlrpc_pingback_for_environment( $methods ) {
|
||||
if ( wp_should_disable_pings_for_environment() ) {
|
||||
unset( $methods['pingback.ping'] );
|
||||
}
|
||||
|
||||
return $methods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pings back the links found in a post.
|
||||
*
|
||||
|
||||
@@ -421,12 +421,6 @@ add_action( 'do_all_pings', 'do_all_pingbacks', 10, 0 );
|
||||
add_action( 'do_all_pings', 'do_all_enclosures', 10, 0 );
|
||||
add_action( 'do_all_pings', 'do_all_trackbacks', 10, 0 );
|
||||
add_action( 'do_all_pings', 'generic_ping', 10, 0 );
|
||||
|
||||
// Disable pings (pingbacks, trackbacks, and ping service notifications) in non-production environments.
|
||||
add_action( 'do_all_pings', 'wp_maybe_disable_outgoing_pings_for_environment', 1, 0 );
|
||||
add_action( 'pre_trackback_post', 'wp_maybe_disable_trackback_for_environment', 10, 0 );
|
||||
add_filter( 'xmlrpc_methods', 'wp_maybe_disable_xmlrpc_pingback_for_environment' );
|
||||
|
||||
add_action( 'do_robots', 'do_robots' );
|
||||
add_action( 'do_favicon', 'do_favicon' );
|
||||
add_action( 'wp_before_include_template', 'wp_start_template_enhancement_output_buffer', 1000 ); // Late priority to let `wp_template_enhancement_output_buffer` filters and `wp_finalized_template_enhancement_output_buffer` actions be registered.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '7.1-alpha-62232';
|
||||
$wp_version = '7.1-alpha-62233';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
Reference in New Issue
Block a user