| 开发者 | iftiarhossain |
|---|---|
| 更新时间 | 2026年7月21日 22:20 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.0 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
add_filter( 'postmediaweb_attachment_ids_to_delete', function( $ids, $post_id ) { $extra = get_post_meta( $post_id, 'my_custom_pdf', true ); if ( $extra ) $ids[] = (int) $extra; return $ids; }, 10, 2 );
Prevent a specific attachment from being deleted:
add_filter( 'postmediaweb_should_delete_attachment', function( $should, $att_id, $post_id ) { if ( $att_id === 999 ) return false; return $should; }, 10, 3 );
No. Only permanent deletion triggers cleanup. Trash is always safe.
With Skip Shared Media enabled (default), the plugin checks before deleting. If the file is used elsewhere it is preserved.
Yes. Enable Products in the Post Types setting.
Yes. It uses wp_delete_attachment() which cloud storage plugins hook into automatically.