Make WordPress Core

Changeset 59818


Ignore:
Timestamp:
02/12/2025 11:44:00 PM (5 weeks ago)
Author:
flixos90
Message:

Pings/Trackbacks: Add return value to pingback().

This facilitates debugging and better response / error handling, among other things.

Props audrasjb, coquardcyr, dshanske, ironprogrammer, NathanAtmoz, pbearne, shulard, soulseekah.
Fixes #38197.

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r59657 r59818  
    28912891    $pingback_link_offset_dquote = strpos( $contents, $pingback_str_dquote );
    28922892    $pingback_link_offset_squote = strpos( $contents, $pingback_str_squote );
     2893
    28932894    if ( $pingback_link_offset_dquote || $pingback_link_offset_squote ) {
    28942895        $quote                   = ( $pingback_link_offset_dquote ) ? '"' : '\'';
     
    30803081 * @since 0.71
    30813082 * @since 4.7.0 `$post` can be a WP_Post object.
     3083 * @since 6.8.0 Returns an array of pingback statuses indexed by link.
    30823084 *
    30833085 * @param string      $content Post content to check for links. If empty will retrieve from post.
    30843086 * @param int|WP_Post $post    Post ID or object.
     3087 * @return array<string, bool> An array of pingback statuses indexed by link.
    30853088 */
    30863089function pingback( $content, $post ) {
     
    30943097
    30953098    if ( ! $post ) {
    3096         return;
     3099        return array();
    30973100    }
    30983101
     
    31093112    $post_links_temp = wp_extract_urls( $content );
    31103113
     3114    $ping_status = array();
    31113115    /*
    31123116     * Step 2.
     
    31803184            $client->debug = false;
    31813185
    3182             if ( $client->query( 'pingback.ping', $pagelinkedfrom, $pagelinkedto ) || ( isset( $client->error->code ) && 48 == $client->error->code ) ) { // Already registered.
     3186            $status = $client->query( 'pingback.ping', $pagelinkedfrom, $pagelinkedto );
     3187
     3188            if ( $status // Ping registered.
     3189                || ( isset( $client->error->code ) && 48 === $client->error->code ) // Already registered.
     3190            ) {
    31833191                add_ping( $post, $pagelinkedto );
    31843192            }
    3185         }
    3186     }
     3193            $ping_status[ $pagelinkedto ] = $status;
     3194        }
     3195    }
     3196
     3197    return $ping_status;
    31873198}
    31883199
Note: See TracChangeset for help on using the changeset viewer.