Changeset 46175
- Timestamp:
- 09/19/2019 01:48:54 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment.php
r45932 r46175 2640 2640 } 2641 2641 2642 // Do Enclosures 2643 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" ) ) { 2644 delete_metadata_by_mid( 'post', $enclosure->meta_id ); 2645 do_enclose( $enclosure->post_content, $enclosure->ID ); 2642 // Do enclosures. 2643 $enclosures = get_posts( 2644 array( 2645 'post_type' => get_post_types(), 2646 'suppress_filters' => false, 2647 'nopaging' => true, 2648 'meta_key' => '_encloseme', 2649 'fields' => 'ids', 2650 ) 2651 ); 2652 2653 foreach ( $enclosure as $enclosure ) { 2654 delete_post_meta( $enclosure, '_encloseme' ); 2655 do_enclose( null, $enclosure->ID ); 2646 2656 } 2647 2657 -
trunk/src/wp-includes/functions.php
r46172 r46175 800 800 * 801 801 * @since 1.5.0 802 * @since 5.3.0 The `$content` parameter was made optional, and the `$post` parameter was 803 * updated to accept a post ID or a WP_Post object. 802 804 * 803 805 * @global wpdb $wpdb WordPress database abstraction object. 804 806 * 805 * @param string $content Post Content. 806 * @param int $post_ID Post ID. 807 */ 808 function do_enclose( $content, $post_ID ) { 807 * @param string $content Post content. If `null`, the `post_content` field from `$post` is used. 808 * @param int|WP_Post $post Post ID or post object. 809 * @return null|bool Returns false if post is not found. 810 */ 811 function do_enclose( $content = null, $post ) { 809 812 global $wpdb; 810 813 … … 812 815 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 813 816 817 $post = get_post( $post ); 818 if ( ! $post ) { 819 return false; 820 } 821 822 if ( null === $content ) { 823 $content = $post->post_content; 824 } 825 814 826 $post_links = array(); 815 827 816 $pung = get_enclosed( $post _ID );828 $pung = get_enclosed( $post->ID ); 817 829 818 830 $post_links_temp = wp_extract_urls( $content ); … … 820 832 foreach ( $pung as $link_test ) { 821 833 if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post 822 $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 ) . '%' ) );834 $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 ) . '%' ) ); 823 835 foreach ( $mids as $mid ) { 824 836 delete_metadata_by_mid( 'post', $mid ); … … 852 864 * @param int $post_ID Post ID. 853 865 */ 854 $post_links = apply_filters( 'enclosure_links', $post_links, $post _ID );866 $post_links = apply_filters( 'enclosure_links', $post_links, $post->ID ); 855 867 856 868 foreach ( (array) $post_links as $url ) { 857 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 ) . '%' ) ) ) {869 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 ) . '%' ) ) ) { 858 870 859 871 $headers = wp_get_http_headers( $url ); … … 879 891 880 892 if ( in_array( substr( $type, 0, strpos( $type, '/' ) ), $allowed_types ) ) { 881 add_post_meta( $post _ID, 'enclosure', "$url\n$len\n$mime\n" );893 add_post_meta( $post->ID, 'enclosure', "$url\n$len\n$mime\n" ); 882 894 } 883 895 }
Note: See TracChangeset
for help on using the changeset viewer.