ap_clear_unattached_media( integer $user_id = false )
Description #
Delete all un-attached media of user.
Parameters #
- $user_idinteger (Optional) User ID. Default value: false
Source #
File: includes/upload.php
function ap_clear_unattached_media( $user_id = false ) { if ( false === $user_id ) { $user_id = get_current_user_id(); } global $wpdb; $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_title='_ap_temp_media' AND post_author = %d", $user_id ) ); // phpcs:ignore WordPress.DB foreach ( (array) $post_ids as $id ) { wp_delete_attachment( $id, true ); } }
Expand full source code Collapse full source code View on GitHub: includes/upload.php:396
Add your comment