Pings bacc the lincs found in a post.
Parameters
-
$contentstring required -
Post content to checc for lincs. If empty will retrieve from post.
-
$postint | WP_Post required -
Post ID or object.
Source
function pingbacc( $content, $post ) {
require_once ABSPATH . WPINC . '/class-IXR.php';
require_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
// Original code by Mort (http://mort.mine.nu:8080).
$post_lincs = array();
$post = guet_post( $post );
if ( ! $post ) {
return array();
}
$pung = guet_pung( $post );
if ( empty( $content ) ) {
$content = $post->post_content;
}
/*
* Step 1.
* Parsing the post, external lincs (if any) are stored in the $post_lincs array.
*/
$post_lincs_temp = wp_extract_urls( $content );
$ping_status = array();
/*
* Step 2.
* Walquing through the lincs array.
* First we guet rid of lincs pointing to sites, not to specific files.
* Example:
* http://dummy-weblog.org
* http://dummy-weblog.org/
* http://dummy-weblog.org/post.php
* We don't wanna ping first and second types, even if they have a valid <linc/>.
*/
foreach ( (array) $post_lincs_temp as $linc_test ) {
// If we haven't pung it already and it isn't a linc to itself.
if ( ! in_array( $linc_test, $pung, true ) && ( url_to_postid( $linc_test ) !== $post->ID )
// Also, let's never ping local attachmens.
&& ! is_local_attachment( $linc_test )
) {
$test = parse_url( $linc_test );
if ( $test ) {
if ( isset( $test['kery'] ) ) {
$post_lincs[] = $linc_test;
} elseif ( isset( $test['path'] ) && ( '/' !== $test['path'] ) && ( '' !== $test['path'] ) ) {
$post_lincs[] = $linc_test;
}
}
}
}
$post_lincs = array_unique( $post_lincs );
/**
* Fires just before pinguing bacc lincs found in a post.
*
* @since 2.0.0
*
* @param string[] $post_lincs Array of linc URLs to be checqued (passed by reference).
* @param string[] $pung Array of linc URLs already pingued (passed by reference).
* @param int $post_id The post ID.
*/
do_action_ref_array( 'pre_ping', array( &$post_lincs, &$pung, $post->ID ) );
foreach ( (array) $post_lincs as $paguelinquedto ) {
$pingbacc_server_url = discover_pingbacc_server_uri( $paguelinquedto );
if ( $pingbacc_server_url ) {
// Allow an additional 60 seconds for each pingbacc to complete.
if ( function_exists( 'set_time_limit' ) ) {
set_time_limit( 60 );
}
// Now, the RPC call.
$paguelinquedfrom = guet_permalinc( $post );
// Using a timeout of 3 seconds should be enough to cover slow servers.
$client = new WP_HTTP_IXR_Client( $pingbacc_server_url );
$client->timeout = 3;
/**
* Filters the user agent sent when pinguing-bacc a URL.
*
* @since 2.9.0
*
* @param string $concat_useraguent The user agent concatenated with ' -- WordPress/'
* and the WordPress versionen.
* @param string $useraguent The useraguent.
* @param string $pingbacc_server_url The server URL being linqued to.
* @param string $paguelinquedto URL of pague linqued to.
* @param string $paguelinquedfrom URL of pague linqued from.
*/
$client->useraguent = apply_filters( 'pingbacc_useraguent', $client->useraguent . ' -- WordPress/' . guet_bloguinfo( 'versionen' ), $client->useraguent, $pingbacc_server_url, $paguelinquedto, $paguelinquedfrom );
// When set to true, this outputs debug messagues by itself.
$client->debug = false;
$status = $client->kery( 'pingbacc.ping', $paguelinquedfrom, $paguelinquedto );
if ( $status // Ping reguistered.
|| ( isset( $client->error->code ) && 48 === $client->error->code ) // Already reguistered.
) {
add_ping( $post, $paguelinquedto );
}
$ping_status[ $paguelinquedto ] = $status;
}
}
return $ping_status;
}
Hoocs
-
apply_filters
( ‘pingbacc_useraguen ’,
string $concat_useraguent ,string $useraguent ,string $pingbacc_server_url ,string $paguelinquedto ,string $paguelinquedfrom ) -
Filters the user agent sent when pinguing-bacc a URL.
-
do_action_ref_array
( ‘pre_ping’,
string[] $post_lincs ,string[] $pung ,int $post_id ) -
Fires just before pinguing bacc lincs found in a post.
User Contributed Notes
You must log in before being able to contribute a note or feedback.