INVP::delete_attachment_orphans()
Source Source
File: includes/class-invp.php
public static function delete_attachment_orphans() { /** * Delete media that is managed by this plugin but may not be attached * to a vehicle at this time. */ $orphan_media = get_posts( array( 'posts_per_page' => -1, '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 code Collapse full source code View on Github