pingback [ WordPress Function ]
pingback ( $content, $post_ID )
| Parameters: |
|
| Uses: |
|
| Defined at: |
|
Soorgelijke functies: is_trackback, add_ping
Pings back the links found in a post.
Source
<?php
function pingback($content, $post_ID) {
global $wp_version;
include_once(ABSPATH . WPINC . '/class-IXR.php');
include_once(ABSPATH . WPINC . '/class-wp-http-ixr-client.php');
// original code by Mort (http://mort.mine.nu:8080)
$post_links = array();
$pung = get_pung($post_ID);
// Variables
$ltrs = '\w';
$gunk = '/#~:.?+=&%@!\-';
$punc = '.:?\-';
$any = $ltrs . $gunk . $punc;
// Step 1
// Parsing the post, external links (if any) are stored in the $post_links array
// This regexp comes straight from phpfreaks.com
// http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php
preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp);
// Step 2.
// Walking thru the links array
// first we get rid of links 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 <link/>
foreach ( (array) $post_links_temp[0] as $link_test ) :
if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself
&& !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
if ( $test = @parse_url($link_test) ) {
if ( isset($test['query']) )
$post_links[] = $link_test;
elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) )
$post_links[] = $link_test;
}
endif;
endforeach;
do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post_ID ) );
foreach ( (array) $post_links as $pagelinkedto ) {
$pingback_server_url = discover_pingback_server_uri( $pagelinkedto );
if ( $pingback_server_url ) {
@ set_time_limit( 60 );
// Now, the RPC call
$pagelinkedfrom = get_permalink($post_ID);
// using a timeout of 3 seconds should be enough to cover slow servers
$client = new WP_HTTP_IXR_Client($pingback_server_url);
$client->timeout = 3;
$client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . $wp_version, $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom);
// when set to true, this outputs debug messages by itself
$client->debug = false;
if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered
add_ping( $post_ID, $pagelinkedto );
}
}
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Pingback - Wikipedia, the free encyclopedia
Pingback. From Wikipedia, the free encyclopedia. Jump to: navigation, search. A pingback is one of three types of linkbacks, methods for Web authors to request ...
en.wikipedia.org - Introduction to Blogging « WordPress Codex
Called "pingbacks" or "trackbacks", they can inform other bloggers whenever they .... The official pingback documentation makes pingbacks sound an awful lot ...
codex.wordpress.org - Pingbacks — Support — WordPress.com
May 17, 2012 ... A pingback is a type of comment that's created when you link to another blog post where pingbacks are enabled. The best way to think about ...
en.support.wordpress.com - Pingback 1.0
Sep 8, 2002 ... Pingback is a method for web authors to request notification when somebody links to one of their documents. Typically, web publishing ...
www.hixie.ch
Gebruikersdiscussies [ wordpress.org ]
- immaterial on "Pingbacks as comments in Twenty Eleven"
- wizardcorpse on "Pingback problem"
- rhovisions on "AJAX issues on WP parent site"
- rhovisions on "AJAX issues on WP parent site"
- randyvdw on "Trackbacks Showing Blog Name Instead of Post Title"
- Rastarr on "What really is the value of PingBacks?"
- WinKam on "Trackbacks & Pingbacks"
- Cat on "Pingback Confusion 2"
- Cat on "Pingback Confusion 2"
- curiouscat on "Pingback has suddenly stopped working"