Changeset 38852 for trunk/src/wp-includes/comment.php
- Timestamp:
- 10/21/2016 05:59:34 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/comment.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment.php
r38783 r38852 2406 2406 * 2407 2407 * @since 1.5.0 2408 * @since 4.7.0 $post_id can be a WP_Post object. 2408 2409 * 2409 2410 * @global wpdb $wpdb WordPress database abstraction object. 2410 2411 * 2411 * @param int $post_id PostID to do trackbacks on.2412 */ 2413 function do_trackbacks( $post_id) {2412 * @param int|WP_Post $post_id Post object or ID to do trackbacks on. 2413 */ 2414 function do_trackbacks( $post_id ) { 2414 2415 global $wpdb; 2415 2416 2416 $post = get_post( $post_id ); 2417 $to_ping = get_to_ping($post_id); 2418 $pinged = get_pung($post_id); 2419 if ( empty($to_ping) ) { 2420 $wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post_id) ); 2417 if ( ! $post ) { 2418 return false; 2419 } 2420 2421 $to_ping = get_to_ping( $post ); 2422 $pinged = get_pung( $post ); 2423 if ( empty( $to_ping ) ) { 2424 $wpdb->update($wpdb->posts, array( 'to_ping' => '' ), array( 'ID' => $post->ID ) ); 2421 2425 return; 2422 2426 } … … 2441 2445 $tb_ping = trim($tb_ping); 2442 2446 if ( !in_array($tb_ping, $pinged) ) { 2443 trackback( $tb_ping, $post_title, $excerpt, $post_id);2447 trackback( $tb_ping, $post_title, $excerpt, $post->ID ); 2444 2448 $pinged[] = $tb_ping; 2445 2449 } else { 2446 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $tb_ping, $post_id) ); 2450 $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, 2451 '')) WHERE ID = %d", $tb_ping, $post->ID ) ); 2447 2452 } 2448 2453 } … … 2475 2480 * 2476 2481 * @since 0.71 2477 * 2478 * @param string $content Post content to check for links. 2479 * @param int $post_ID Post ID. 2480 */ 2481 function pingback($content, $post_ID) { 2482 * @since 4.7.0 $post_id can be a WP_Post object. 2483 * 2484 * @param string $content Post content to check for links. If empty will retrieve from post. 2485 * @param int|WP_Post $post_id Post Object or ID. 2486 */ 2487 function pingback( $content, $post_id ) { 2482 2488 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 2483 2489 include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' ); … … 2486 2492 $post_links = array(); 2487 2493 2488 $pung = get_pung($post_ID); 2494 $post = get_post( $post_id ); 2495 if ( ! $post ) { 2496 return; 2497 } 2498 2499 $pung = get_pung( $post ); 2500 2501 if ( empty( $content ) ) { 2502 $content = $post->post_content; 2503 } 2489 2504 2490 2505 // Step 1 … … 2502 2517 2503 2518 foreach ( (array) $post_links_temp as $link_test ) : 2504 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 itself2519 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 2505 2520 && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. 2506 2521 if ( $test = @parse_url($link_test) ) { … … 2523 2538 * @param int $post_ID The post ID. 2524 2539 */ 2525 do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post _ID ) );2540 do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post->ID ) ); 2526 2541 2527 2542 foreach ( (array) $post_links as $pagelinkedto ) { … … 2531 2546 @ set_time_limit( 60 ); 2532 2547 // Now, the RPC call 2533 $pagelinkedfrom = get_permalink( $post_ID);2548 $pagelinkedfrom = get_permalink( $post ); 2534 2549 2535 2550 // using a timeout of 3 seconds should be enough to cover slow servers … … 2553 2568 2554 2569 if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered 2555 add_ping( $post _ID, $pagelinkedto );2570 add_ping( $post, $pagelinkedto ); 2556 2571 } 2557 2572 }
Note: See TracChangeset
for help on using the changeset viewer.