wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema
update_attached_file › WordPress Function
Desde2.1.0
Obsoleton/a
› update_attached_file ( $attachment_id, $file )
| Parâmetros: (2) |
|
| Retorna: |
|
| Definido em: |
|
| Codex: |
Updates attachment file path based on attachment ID.
Used to update the file path of the attachment, which uses post meta name_wp_attached_file to store the path of the attachment.Funções relacionadas: get_attached_file, wp_delete_attachment_files, update_archived, update_meta_cache, update_page_cache
Fonte
function update_attached_file( $attachment_id, $file ) {
if ( ! get_post( $attachment_id ) ) {
return false;
}
/**
* Filters the path to the attached file to update.
*
* @since 2.1.0
*
* @param string $file Path to the attached file to update.
* @param int $attachment_id Attachment ID.
*/
$file = apply_filters( 'update_attached_file', $file, $attachment_id );
$file = _wp_relative_upload_path( $file );
if ( $file ) {
return update_post_meta( $attachment_id, '_wp_attached_file', $file );
} else {
return delete_post_meta( $attachment_id, '_wp_attached_file' );
}
}