Make WordPress Core

Changeset 62233


Ignore:
Timestamp:
04/14/2026 11:37:02 AM (11 hours ago)
Author:
ramonopoly
Message:

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.

Location:
trunk
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r62231 r62233  
    31653165
    31663166/**
    3167  * Determines whether pings should be disabled for the current environment.
    3168  *
    3169  * By default, all pings (outgoing pingbacks, trackbacks, and ping service
    3170  * notifications, as well as incoming pingbacks and trackbacks) are disabled
    3171  * for non-production environments ('local', 'development', 'staging').
    3172  *
    3173  * @since 7.1.0
    3174  *
    3175  * @return bool True if pings should be disabled, false otherwise.
    3176  */
    3177 function wp_should_disable_pings_for_environment() {
    3178     $environment_type = wp_get_environment_type();
    3179     $should_disable   = 'production' !== $environment_type;
    3180 
    3181     /**
    3182      * Filters whether pings should be disabled for the current environment.
    3183      *
    3184      * Returning false re-enables pings in non-production environments.
    3185      * Returning true disables pings even in production.
    3186      *
    3187      * @since 7.1.0
    3188      *
    3189      * @param bool   $should_disable  Whether pings should be disabled. Default true
    3190      *                                for non-production environments, false for production.
    3191      * @param string $environment_type The current environment type as returned by
    3192      *                                 wp_get_environment_type().
    3193      */
    3194     return apply_filters( 'wp_should_disable_pings_for_environment', $should_disable, $environment_type );
    3195 }
    3196 
    3197 /**
    3198  * Removes outgoing ping callbacks in non-production environments.
    3199  *
    3200  * Hooked to `do_all_pings` at priority 1 so it runs before the default
    3201  * priority 10 callbacks. Does not remove `do_all_enclosures`.
    3202  *
    3203  * @since 7.1.0
    3204  */
    3205 function wp_maybe_disable_outgoing_pings_for_environment() {
    3206     if ( wp_should_disable_pings_for_environment() ) {
    3207         remove_action( 'do_all_pings', 'do_all_pingbacks' );
    3208         remove_action( 'do_all_pings', 'do_all_trackbacks' );
    3209         remove_action( 'do_all_pings', 'generic_ping' );
    3210     }
    3211 }
    3212 
    3213 /**
    3214  * Rejects incoming trackbacks in non-production environments.
    3215  *
    3216  * Hooked to `pre_trackback_post` which fires in `wp-trackback.php` before the
    3217  * trackback is processed. Calls `trackback_response()` which sends an XML error
    3218  * response and terminates the request.
    3219  *
    3220  * @since 7.1.0
    3221  */
    3222 function wp_maybe_disable_trackback_for_environment() {
    3223     if ( wp_should_disable_pings_for_environment() ) {
    3224         trackback_response( 1, __( 'Trackbacks are disabled in non-production environments.' ) );
    3225     }
    3226 }
    3227 
    3228 /**
    3229  * Removes the pingback XML-RPC method in non-production environments.
    3230  *
    3231  * @since 7.1.0
    3232  *
    3233  * @param string[] $methods An array of XML-RPC methods, keyed by their methodName.
    3234  * @return string[] Modified array of XML-RPC methods.
    3235  */
    3236 function wp_maybe_disable_xmlrpc_pingback_for_environment( $methods ) {
    3237     if ( wp_should_disable_pings_for_environment() ) {
    3238         unset( $methods['pingback.ping'] );
    3239     }
    3240 
    3241     return $methods;
    3242 }
    3243 
    3244 /**
    32453167 * Pings back the links found in a post.
    32463168 *
  • trunk/src/wp-includes/default-filters.php

    r62231 r62233  
    422422add_action( 'do_all_pings', 'do_all_trackbacks', 10, 0 );
    423423add_action( 'do_all_pings', 'generic_ping', 10, 0 );
    424 
    425 // Disable pings (pingbacks, trackbacks, and ping service notifications) in non-production environments.
    426 add_action( 'do_all_pings', 'wp_maybe_disable_outgoing_pings_for_environment', 1, 0 );
    427 add_action( 'pre_trackback_post', 'wp_maybe_disable_trackback_for_environment', 10, 0 );
    428 add_filter( 'xmlrpc_methods', 'wp_maybe_disable_xmlrpc_pingback_for_environment' );
    429 
    430424add_action( 'do_robots', 'do_robots' );
    431425add_action( 'do_favicon', 'do_favicon' );
Note: See TracChangeset for help on using the changeset viewer.