Changeset 46175 for trunk/src/wp-includes/functions.php
- Timestamp:
- 09/19/2019 01:48:54 AM (7 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/functions.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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.