get_enclosed example

$post = get_post( $post );
    if ( ! $post ) {
        return false;
    }

    if ( null === $content ) {
        $content = $post->post_content;
    }

    $post_links = array();

    $pung = get_enclosed( $post->ID );

    $post_links_temp = wp_extract_urls( $content );

    foreach ( $pung as $link_test ) {
        // Link is no longer in post.         if ( ! in_array( $link_test$post_links_temp, true ) ) {
            $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 ) . '%' ) );
            foreach ( $mids as $mid ) {
                delete_metadata_by_mid( 'post', $mid );
            }
        }
    }
Home | Imprint | This part of the site doesn't use cookies.