From 1c1aadbe54013adc441ceda3766d62b8d828c6c3 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 19 Oct 2020 21:16:02 +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. Built from https://develop.svn.wordpress.org/trunk@49211 git-svn-id: http://core.svn.wordpress.org/trunk@48973 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment.php | 37 +++++++++++++++++++++++++-------- wp-includes/default-filters.php | 4 ++++ wp-includes/version.php | 2 +- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 71471eed12..49611147f5 100644 --- a/wp-includes/comment.php +++ b/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/wp-includes/default-filters.php b/wp-includes/default-filters.php index dbc4fefb09..32727445dc 100644 --- a/wp-includes/default-filters.php +++ b/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 ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 435a2cec24..31fb03ce42 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-49210'; +$wp_version = '5.6-alpha-49211'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.