diff --git src/wp-includes/comment.php src/wp-includes/comment.php
index 4c78eb9b6a..4766651b47 100644
|
|
function discover_pingback_server_uri( $url, $deprecated = '' ) { |
2579 | 2579 | function do_all_pings() { |
2580 | 2580 | global $wpdb; |
2581 | 2581 | |
2582 | | // Do pingbacks |
2583 | | 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" ) ) { |
2584 | | delete_metadata_by_mid( 'post', $ping->meta_id ); |
2585 | | pingback( $ping->post_content, $ping->ID ); |
| 2582 | // Determine which classes support trackbacks and pingbacks |
| 2583 | $ping_types = get_post_types_by_support( 'trackbacks' ); |
| 2584 | |
| 2585 | // Do pingbacks. |
| 2586 | $pings = get_posts( |
| 2587 | array( |
| 2588 | 'post_type' => $ping_types, |
| 2589 | 'suppress_filters' => false, |
| 2590 | 'nopaging' => true, |
| 2591 | 'meta_value' => '_pingme', |
| 2592 | 'fields' => 'ids', |
| 2593 | ) |
| 2594 | ); |
| 2595 | |
| 2596 | foreach ( $pings as $ping ) { |
| 2597 | delete_post_meta( $ping, '_pingme' ); |
| 2598 | pingback( null, $ping ); |
2586 | 2599 | } |
2587 | 2600 | |
2588 | | // Do Enclosures |
2589 | | 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" ) ) { |
2590 | | delete_metadata_by_mid( 'post', $enclosure->meta_id ); |
2591 | | do_enclose( $enclosure->post_content, $enclosure->ID ); |
| 2601 | // Do enclosures. |
| 2602 | $enclosures = get_posts( |
| 2603 | array( |
| 2604 | 'post_type' => get_post_types( array( 'publicly_queryable' => true ) ), |
| 2605 | 'suppress_filters' => false, |
| 2606 | 'nopaging' => true, |
| 2607 | 'meta_key' => '_encloseme', |
| 2608 | 'fields' => 'ids', |
| 2609 | ) |
| 2610 | ); |
| 2611 | |
| 2612 | foreach ( $enclosures as $enclosure ) { |
| 2613 | delete_post_meta( $enclosure, '_encloseme' ); |
| 2614 | do_enclose( null, $enclosure ); |
2592 | 2615 | } |
2593 | 2616 | |
2594 | | // Do Trackbacks |
2595 | | $trackbacks = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'" ); |
2596 | | if ( is_array( $trackbacks ) ) { |
2597 | | foreach ( $trackbacks as $trackback ) { |
2598 | | do_trackbacks( $trackback ); |
2599 | | } |
| 2617 | // Do trackbacks. |
| 2618 | $trackbacks = get_posts( |
| 2619 | array( |
| 2620 | 'post_type' => $ping_types, |
| 2621 | 'suppress_filters' => false, |
| 2622 | 'nopaging' => true, |
| 2623 | 'to_ping' => true, |
| 2624 | 'fields' => 'ids', |
| 2625 | ) |
| 2626 | ); |
| 2627 | |
| 2628 | foreach ( $trackbacks as $trackback ) { |
| 2629 | do_trackbacks( $trackback ); |
2600 | 2630 | } |
2601 | 2631 | |
2602 | 2632 | //Do Update Services/Generic Pings |
diff --git src/wp-includes/functions.php src/wp-includes/functions.php
index 60229ee10b..20d36688ad 100644
|
|
function wp_extract_urls( $content ) { |
562 | 562 | * pingbacks and trackbacks. |
563 | 563 | * |
564 | 564 | * @since 1.5.0 |
| 565 | * @since 4.9.7 `$post` can be a WP_Post object. |
565 | 566 | * |
566 | 567 | * @global wpdb $wpdb WordPress database abstraction object. |
567 | 568 | * |
568 | | * @param string $content Post Content. |
569 | | * @param int $post_ID Post ID. |
| 569 | * @param string $content Post Content. If empty will retrieve from post. |
| 570 | * @param int|WP_Post $post Post object or ID. |
570 | 571 | */ |
571 | | function do_enclose( $content, $post_ID ) { |
| 572 | function do_enclose( $content, $post ) { |
572 | 573 | global $wpdb; |
573 | 574 | |
| 575 | $post = get_post( $post ); |
| 576 | if ( ! $post ) { |
| 577 | return false; |
| 578 | } |
| 579 | |
| 580 | if ( ! $content ) { |
| 581 | $content = $post->post_content; |
| 582 | } |
| 583 | |
574 | 584 | //TODO: Tidy this ghetto code up and make the debug code optional |
575 | 585 | include_once( ABSPATH . WPINC . '/class-IXR.php' ); |
576 | 586 | |
577 | 587 | $post_links = array(); |
578 | 588 | |
579 | | $pung = get_enclosed( $post_ID ); |
| 589 | $pung = get_enclosed( $post->ID ); |
580 | 590 | |
581 | 591 | $post_links_temp = wp_extract_urls( $content ); |
582 | 592 | |
583 | 593 | foreach ( $pung as $link_test ) { |
584 | 594 | if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post |
585 | | $mids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $link_test ) . '%' ) ); |
| 595 | $mids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $link_test ) . '%' ) ); |
586 | 596 | foreach ( $mids as $mid ) { |
587 | 597 | delete_metadata_by_mid( 'post', $mid ); |
588 | 598 | } |
… |
… |
function do_enclose( $content, $post_ID ) { |
591 | 601 | |
592 | 602 | foreach ( (array) $post_links_temp as $link_test ) { |
593 | 603 | if ( ! in_array( $link_test, $pung ) ) { // If we haven't pung it already |
594 | | $test = @parse_url( $link_test ); |
| 604 | $test = wp_parse_url( $link_test ); |
595 | 605 | if ( false === $test ) { |
596 | 606 | continue; |
597 | 607 | } |
… |
… |
function do_enclose( $content, $post_ID ) { |
612 | 622 | * @since 4.4.0 |
613 | 623 | * |
614 | 624 | * @param array $post_links An array of enclosure links. |
615 | | * @param int $post_ID Post ID. |
| 625 | * @param int $post_id Post ID. |
616 | 626 | */ |
617 | | $post_links = apply_filters( 'enclosure_links', $post_links, $post_ID ); |
| 627 | $post_links = apply_filters( 'enclosure_links', $post_links, $post->ID ); |
618 | 628 | |
619 | 629 | foreach ( (array) $post_links as $url ) { |
620 | | 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 ) . '%' ) ) ) { |
| 630 | 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 ) . '%' ) ) ) { |
621 | 631 | |
622 | 632 | if ( $headers = wp_get_http_headers( $url ) ) { |
623 | 633 | $len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0; |
… |
… |
function do_enclose( $content, $post_ID ) { |
640 | 650 | } |
641 | 651 | |
642 | 652 | if ( in_array( substr( $type, 0, strpos( $type, '/' ) ), $allowed_types ) ) { |
643 | | add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" ); |
| 653 | add_post_meta( $post->ID, 'enclosure', "$url\n$len\n$mime\n" ); |
644 | 654 | } |
645 | 655 | } |
646 | 656 | } |