wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_update_attachment_metadata › WordPress Function

Da2.1.0
Deprecaton/a
wp_update_attachment_metadata ( $attachment_id, $data )
Parametri: (2)
  • (int) $attachment_id Attachment post ID.
    Richiesto:
  • (array) $data Attachment meta data.
    Richiesto:
Ritorna:
  • (int|false) False if $post is invalid.
Definito a:
Codex:

Updates metadata for an attachment.



Sorgenti

function wp_update_attachment_metadata( $attachment_id, $data ) {
	$attachment_id = (int) $attachment_id;

	$post = get_post( $attachment_id );

	if ( ! $post ) {
		return false;
	}

	/**
	 * Filters the updated attachment meta data.
	 *
	 * @since 2.1.0
	 *
	 * @param array $data          Array of updated attachment meta data.
	 * @param int   $attachment_id Attachment post ID.
	 */
	$data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID );
	if ( $data ) {
		return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
	} else {
		return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
	}
}