INVP::delete_attachment_orphans()
Deletes media that is managed by this plugin but not attached to a post.
Return Return
(void)
Source Source
File: includes/class-invp.php
public static function delete_attachment_orphans() {
$orphan_media = get_posts(
array(
'posts_per_page' => apply_filters( 'invp_query_limit', 1000, __METHOD__ ),
'post_status' => 'any',
'post_type' => 'attachment',
'meta_query' => array(
array(
'key' => apply_filters( 'invp_prefix_meta_key', 'photo_number' ),
'compare' => 'EXISTS',
),
),
)
);
$settings = self::settings();
foreach ( $orphan_media as $post ) {
wp_delete_attachment( $post->ID, $settings['skip_trash'] );
}
}
Expand full source codeCollapse full source codeView on Github