_wp_before_delete_font_face()
Deletes associated font files when a font face is deleted.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
null
. Nothing (null).
Usage
_wp_before_delete_font_face( $post_id, $post );
- $post_id(int) (required)
- Post ID.
- $post(WP_Post) (required)
- Post object.
Changelog
Since 6.5.0 | Introduced. |
_wp_before_delete_font_face() wp before delete font face code WP 6.8.1
function _wp_before_delete_font_face( $post_id, $post ) { if ( 'wp_font_face' !== $post->post_type ) { return; } $font_files = get_post_meta( $post_id, '_wp_font_face_file', false ); $font_dir = untrailingslashit( wp_get_font_dir()['basedir'] ); foreach ( $font_files as $font_file ) { wp_delete_file( $font_dir . '/' . $font_file ); } }