diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php
index 861ad6b..44a72a9 100644
a
|
b
|
function do_all_pings() { |
2308 | 2308 | * Perform trackbacks. |
2309 | 2309 | * |
2310 | 2310 | * @since 1.5.0 |
| 2311 | * @since 4.7.0 |
2311 | 2312 | * |
2312 | 2313 | * @global wpdb $wpdb WordPress database abstraction object. |
2313 | 2314 | * |
2314 | | * @param int $post_id Post ID to do trackbacks on. |
| 2315 | * @param int|WP_Post $post Post Object or ID to do trackbacks on. |
2315 | 2316 | */ |
2316 | | function do_trackbacks($post_id) { |
| 2317 | function do_trackbacks( $post ) { |
2317 | 2318 | global $wpdb; |
| 2319 | $post = get_post( $post ); |
| 2320 | if ( ! $post ) { |
| 2321 | return false; |
| 2322 | } |
2318 | 2323 | |
2319 | | $post = get_post( $post_id ); |
2320 | | $to_ping = get_to_ping($post_id); |
2321 | | $pinged = get_pung($post_id); |
| 2324 | $to_ping = get_to_ping( $post ); |
| 2325 | $pinged = get_pung( $post ); |
2322 | 2326 | if ( empty($to_ping) ) { |
2323 | | $wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post_id) ); |
| 2327 | $wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post->ID) ); |
2324 | 2328 | return; |
2325 | 2329 | } |
2326 | 2330 | |
… |
… |
function do_trackbacks($post_id) { |
2343 | 2347 | foreach ( (array) $to_ping as $tb_ping ) { |
2344 | 2348 | $tb_ping = trim($tb_ping); |
2345 | 2349 | if ( !in_array($tb_ping, $pinged) ) { |
2346 | | trackback($tb_ping, $post_title, $excerpt, $post_id); |
| 2350 | trackback($tb_ping, $post_title, $excerpt, $post->ID); |
2347 | 2351 | $pinged[] = $tb_ping; |
2348 | 2352 | } else { |
2349 | | $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $tb_ping, $post_id) ); |
| 2353 | $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, |
| 2354 | '')) WHERE ID = %d", $tb_ping, $post->ID) ); |
2350 | 2355 | } |
2351 | 2356 | } |
2352 | 2357 | } |
… |
… |
function generic_ping( $post_id = 0 ) { |
2378 | 2383 | * |
2379 | 2384 | * @since 0.71 |
2380 | 2385 | * |
2381 | | * @param string $content Post content to check for links. |
2382 | | * @param int $post_ID Post ID. |
| 2386 | * @param string $content Post content to check for links. If empty will retrieve from post. |
| 2387 | * @param int|WP_Post $post Post Object or ID. |
2383 | 2388 | */ |
2384 | | function pingback($content, $post_ID) { |
| 2389 | function pingback($content, $post) { |
2385 | 2390 | include_once( ABSPATH . WPINC . '/class-IXR.php' ); |
2386 | 2391 | include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' ); |
2387 | 2392 | |
2388 | 2393 | // original code by Mort (http://mort.mine.nu:8080) |
2389 | 2394 | $post_links = array(); |
2390 | 2395 | |
2391 | | $pung = get_pung($post_ID); |
| 2396 | $post = get_post( $post ); |
| 2397 | if ( ! $post ) { |
| 2398 | return false; |
| 2399 | } |
| 2400 | |
| 2401 | $pung = get_pung( $post ); |
| 2402 | |
| 2403 | if ( empty( $content ) ) { |
| 2404 | $content = $post->post_content; |
| 2405 | } |
2392 | 2406 | |
2393 | 2407 | // Step 1 |
2394 | 2408 | // Parsing the post, external links (if any) are stored in the $post_links array |
… |
… |
function pingback($content, $post_ID) { |
2404 | 2418 | // We don't wanna ping first and second types, even if they have a valid <link/> |
2405 | 2419 | |
2406 | 2420 | foreach ( (array) $post_links_temp as $link_test ) : |
2407 | | 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 |
| 2421 | 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 |
2408 | 2422 | && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. |
2409 | 2423 | if ( $test = @parse_url($link_test) ) { |
2410 | 2424 | if ( isset($test['query']) ) |
… |
… |
function pingback($content, $post_ID) { |
2425 | 2439 | * @param array &$pung Whether a link has already been pinged, passed by reference. |
2426 | 2440 | * @param int $post_ID The post ID. |
2427 | 2441 | */ |
2428 | | do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post_ID ) ); |
| 2442 | do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post->ID ) ); |
2429 | 2443 | |
2430 | 2444 | foreach ( (array) $post_links as $pagelinkedto ) { |
2431 | 2445 | $pingback_server_url = discover_pingback_server_uri( $pagelinkedto ); |
… |
… |
function pingback($content, $post_ID) { |
2433 | 2447 | if ( $pingback_server_url ) { |
2434 | 2448 | @ set_time_limit( 60 ); |
2435 | 2449 | // Now, the RPC call |
2436 | | $pagelinkedfrom = get_permalink($post_ID); |
| 2450 | $pagelinkedfrom = get_permalink( $post ); |
2437 | 2451 | |
2438 | 2452 | // using a timeout of 3 seconds should be enough to cover slow servers |
2439 | 2453 | $client = new WP_HTTP_IXR_Client($pingback_server_url); |
… |
… |
function pingback($content, $post_ID) { |
2455 | 2469 | $client->debug = false; |
2456 | 2470 | |
2457 | 2471 | if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered |
2458 | | add_ping( $post_ID, $pagelinkedto ); |
| 2472 | add_ping( $post, $pagelinkedto ); |
2459 | 2473 | } |
2460 | 2474 | } |
2461 | 2475 | } |
diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
index c02108e..c7edd3e 100644
a
|
b
|
function wp_transition_post_status( $new_status, $old_status, $post ) { |
3909 | 3909 | * |
3910 | 3910 | * @since 1.5.0 |
3911 | 3911 | * |
| 3912 | * @since 4.7.0 Support Post Object. |
| 3913 | * |
3912 | 3914 | * @global wpdb $wpdb WordPress database abstraction object. |
3913 | 3915 | * |
3914 | | * @param int $post_id Post ID. |
| 3916 | * @param int|WP_Post $post Post Object or ID. |
3915 | 3917 | * @param string $uri Ping URI. |
3916 | 3918 | * @return int|false How many rows were updated. |
3917 | 3919 | */ |
3918 | | function add_ping( $post_id, $uri ) { |
| 3920 | function add_ping( $post, $uri ) { |
3919 | 3921 | global $wpdb; |
3920 | | $pung = $wpdb->get_var( $wpdb->prepare( "SELECT pinged FROM $wpdb->posts WHERE ID = %d", $post_id )); |
| 3922 | |
| 3923 | $post = get_post( $post ); |
| 3924 | if ( ! $post ) { |
| 3925 | return false; |
| 3926 | } |
| 3927 | |
| 3928 | $pung = $post-pinged; |
3921 | 3929 | $pung = trim($pung); |
3922 | 3930 | $pung = preg_split('/\s/', $pung); |
3923 | 3931 | $pung[] = $uri; |
… |
… |
function add_ping( $post_id, $uri ) { |
3934 | 3942 | |
3935 | 3943 | // expected_slashed ($new). |
3936 | 3944 | $new = wp_unslash($new); |
3937 | | return $wpdb->update( $wpdb->posts, array( 'pinged' => $new ), array( 'ID' => $post_id ) ); |
| 3945 | return $wpdb->update( $wpdb->posts, array( 'pinged' => $new ), array( 'ID' => $post->ID ) ); |
3938 | 3946 | } |
3939 | 3947 | |
3940 | 3948 | /** |
… |
… |
function get_enclosed( $post_id ) { |
3976 | 3984 | * |
3977 | 3985 | * @since 1.5.0 |
3978 | 3986 | * |
3979 | | * @global wpdb $wpdb WordPress database abstraction object. |
| 3987 | * @since 4.7.0 Accept Post Object |
3980 | 3988 | * |
3981 | | * @param int $post_id Post ID. |
| 3989 | * @param int|WP_Post $post Post ID or object. |
3982 | 3990 | * @return array |
3983 | 3991 | */ |
3984 | | function get_pung( $post_id ) { |
3985 | | global $wpdb; |
3986 | | $pung = $wpdb->get_var( $wpdb->prepare( "SELECT pinged FROM $wpdb->posts WHERE ID = %d", $post_id )); |
3987 | | $pung = trim($pung); |
3988 | | $pung = preg_split('/\s/', $pung); |
| 3992 | function get_pung( $post ) { |
| 3993 | $post = get_post( $post ); |
| 3994 | if ( ! $post ) { |
| 3995 | return false; |
| 3996 | } |
| 3997 | $pung = trim( $post->pinged ); |
| 3998 | $pung = preg_split( '/\s/', $pung ); |
3989 | 3999 | |
3990 | 4000 | /** |
3991 | 4001 | * Filters the list of already-pinged URLs for the given post. |
… |
… |
function get_pung( $post_id ) { |
4002 | 4012 | * |
4003 | 4013 | * @since 1.5.0 |
4004 | 4014 | * |
4005 | | * @global wpdb $wpdb WordPress database abstraction object. |
| 4015 | * @since 4.7.0 Support Post Object. |
4006 | 4016 | * |
4007 | | * @param int $post_id Post ID |
| 4017 | * @param int|WP_Post $post Post Object or ID |
4008 | 4018 | * @return array |
4009 | 4019 | */ |
4010 | | function get_to_ping( $post_id ) { |
4011 | | global $wpdb; |
4012 | | $to_ping = $wpdb->get_var( $wpdb->prepare( "SELECT to_ping FROM $wpdb->posts WHERE ID = %d", $post_id )); |
4013 | | $to_ping = sanitize_trackback_urls( $to_ping ); |
| 4020 | function get_to_ping( $post ) { |
| 4021 | $post = get_post( $post ); |
| 4022 | if ( ! $post ) { |
| 4023 | return false; |
| 4024 | } |
| 4025 | |
| 4026 | $to_ping = sanitize_trackback_urls( $post->to_ping ); |
4014 | 4027 | $to_ping = preg_split('/\s/', $to_ping, -1, PREG_SPLIT_NO_EMPTY); |
4015 | 4028 | |
4016 | 4029 | /** |