From 052ac0838560739e9e42934a8e0f9b0ab806434a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 19 Oct 2020 21:14:06 +0000 Subject: [PATCH] Pings/Trackbacks: Split `do_all_pings()` into several functions: * `do_all_pingbacks()` * `do_all_enclosures()` * `do_all_trackbacks()` This allows for the specific removal/replacement of one of more services. Props dshanske, garrett-eclipse, Mista-Flo, azaozz, hellofromTonya. Fixes #36576. git-svn-id: https://develop.svn.wordpress.org/trunk@49211 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment.php | 37 ++++++++++++++++++++++------- src/wp-includes/default-filters.php | 4 ++++ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 71471eed12..49611147f5 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -2800,13 +2800,23 @@ function discover_pingback_server_uri( $url, $deprecated = '' ) { * Perform all pingbacks, enclosures, trackbacks, and send to pingback services. * * @since 2.1.0 - * - * @global wpdb $wpdb WordPress database abstraction object. + * @since 5.6.0 Introduced `do_all_pings` action hook for individual services. */ function do_all_pings() { - global $wpdb; + /** + * Fires immediately after the `do_pings` event to hook services individually. + * + * @since 5.6.0 + */ + do_action( 'do_all_pings' ); +} - // Do pingbacks. +/** + * Perform all pingbacks. + * + * @since 5.6.0 + */ +function do_all_pingbacks() { $pings = get_posts( array( 'post_type' => get_post_types(), @@ -2821,8 +2831,14 @@ function do_all_pings() { delete_post_meta( $ping, '_pingme' ); pingback( null, $ping ); } +} - // Do enclosures. +/** + * Perform all enclosures. + * + * @since 5.6.0 + */ +function do_all_enclosures() { $enclosures = get_posts( array( 'post_type' => get_post_types(), @@ -2837,8 +2853,14 @@ function do_all_pings() { delete_post_meta( $enclosure, '_encloseme' ); do_enclose( null, $enclosure ); } +} - // Do trackbacks. +/** + * Perform all trackbacks. + * + * @since 5.6.0 + */ +function do_all_trackbacks() { $trackbacks = get_posts( array( 'post_type' => get_post_types(), @@ -2853,9 +2875,6 @@ function do_all_pings() { delete_post_meta( $trackback, '_trackbackme' ); do_trackbacks( $trackback ); } - - // Do Update Services/Generic Pings. - generic_ping(); } /** diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index dbc4fefb09..32727445dc 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -342,6 +342,10 @@ add_action( 'do_feed_rss', 'do_feed_rss', 10, 0 ); add_action( 'do_feed_rss2', 'do_feed_rss2', 10, 1 ); add_action( 'do_feed_atom', 'do_feed_atom', 10, 1 ); add_action( 'do_pings', 'do_all_pings', 10, 0 ); +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 ); add_action( 'do_robots', 'do_robots' ); add_action( 'do_favicon', 'do_favicon' ); add_action( 'set_comment_cookies', 'wp_set_comment_cookies', 10, 3 );