Ticket #36824: 36824.6.diff
File 36824.6.diff, 5.0 KB (added by , 8 years ago) |
---|
-
src/wp-includes/comment.php
2440 2440 * Perform all pingbacks, enclosures, trackbacks, and send to pingback services. 2441 2441 * 2442 2442 * @since 2.1.0 2443 *2444 * @global wpdb $wpdb WordPress database abstraction object.2445 2443 */ 2446 2444 function do_all_pings() { 2447 global $wpdb; 2445 2446 $ping_types = get_post_types_by_support( 'trackbacks' ); 2448 2447 2449 2448 // Do pingbacks 2450 while ($ping = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { 2451 delete_metadata_by_mid( 'post', $ping->meta_id ); 2452 pingback( $ping->post_content, $ping->ID ); 2449 $pings = get_posts( 2450 array( 2451 'post_type' => $ping_types, 2452 'suppress_filters' => false, 2453 'nopaging' => true, 2454 'meta_value' => '_pingme', 2455 'fields' => 'ids' 2456 ) 2457 ); 2458 foreach ( $pings as $ping ) { 2459 pingback( null, $ping ); 2460 delete_post_meta( $ping, '_pingme' ); 2453 2461 } 2454 2462 2455 2463 // Do Enclosures 2456 while ($enclosure = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { 2457 delete_metadata_by_mid( 'post', $enclosure->meta_id ); 2464 $enclosures = get_posts( 2465 array( 2466 'post_type' => get_post_types( array( 'publicly_queryable' => true ) ), 2467 'suppress_filters' => false, 2468 'nopaging' => true, 2469 'meta_value' => '_encloseme' 2470 ) 2471 ); 2472 foreach ( $enclosures as $enclosure ) { 2458 2473 do_enclose( $enclosure->post_content, $enclosure->ID ); 2474 delete_post_meta( $enclosure->ID, '_encloseme' ); 2459 2475 } 2460 2476 2461 2477 // Do Trackbacks 2462 $trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'"); 2463 if ( is_array($trackbacks) ) 2464 foreach ( $trackbacks as $trackback ) 2465 do_trackbacks($trackback); 2478 $trackbacks = get_posts( 2479 array( 2480 'post_type' => $ping_types, 2481 'suppress_filters' => false, 2482 'nopaging' => true, 2483 'to_ping' => true, 2484 'fields' => 'ids' 2485 ) 2486 ); 2487 foreach ( $trackbacks as $trackback ) { 2488 do_trackbacks( $trackback ); 2489 } 2466 2490 2467 2491 //Do Update Services/Generic Pings 2468 2492 generic_ping(); … … 3013 3037 * @param int $comment_post_ID Post ID. 3014 3038 */ 3015 3039 do_action( 'comment_on_draft', $comment_post_ID ); 3016 3040 3017 3041 if ( current_user_can( 'read_post', $comment_post_ID ) ) { 3018 3042 return new WP_Error( 'comment_on_draft', __( 'Sorry, comments are not allowed for this item.' ), 403 ); 3019 3043 } else { -
src/wp-includes/functions.php
550 550 * pingbacks and trackbacks. 551 551 * 552 552 * @since 1.5.0 553 * @since 4.9.0 $post_id can be a WP_Post object. 553 554 * 554 555 * @global wpdb $wpdb WordPress database abstraction object. 555 556 * 556 * @param string $content Post Content. 557 * @param int $post_ID PostID.557 * @param string $content Post Content. If empty will retrieve from post. 558 * @param int|WP_Post $post_id Post object or ID. 558 559 */ 559 function do_enclose( $content, $post_ ID) {560 function do_enclose( $content, $post_id ) { 560 561 global $wpdb; 562 $post = get_post( $post_id ); 563 if ( ! $post ) { 564 return false; 565 } 561 566 567 if ( empty( $content ) ) { 568 $content = $post->post_content; 569 } 570 562 571 //TODO: Tidy this ghetto code up and make the debug code optional 563 572 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 564 573 565 574 $post_links = array(); 566 575 567 $pung = get_enclosed( $post _ID );576 $pung = get_enclosed( $post->ID ); 568 577 569 578 $post_links_temp = wp_extract_urls( $content ); 570 579 … … 597 606 * @since 4.4.0 598 607 * 599 608 * @param array $post_links An array of enclosure links. 600 * @param int $post_ IDPost ID.609 * @param int $post_id Post ID. 601 610 */ 602 $post_links = apply_filters( 'enclosure_links', $post_links, $post _ID );611 $post_links = apply_filters( 'enclosure_links', $post_links, $post->ID ); 603 612 604 613 foreach ( (array) $post_links as $url ) { 605 if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post _ID, $wpdb->esc_like( $url ) . '%' ) ) ) {614 if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $url ) . '%' ) ) ) { 606 615 607 616 if ( $headers = wp_get_http_headers( $url) ) { 608 617 $len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0; … … 625 634 } 626 635 627 636 if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) { 628 add_post_meta( $post _ID, 'enclosure', "$url\n$len\n$mime\n" );637 add_post_meta( $post->ID, 'enclosure', "$url\n$len\n$mime\n" ); 629 638 } 630 639 } 631 640 }