WP_Site_Icon::insert_attachment()publicWP 4.3.0

Inserts an attachment.

{} Это метод класса: WP_Site_Icon{}

Хуки из метода

Возвращает

int. Attachment ID.

Использование

$WP_Site_Icon = new WP_Site_Icon();
$WP_Site_Icon->insert_attachment( $attachment, $file );
$attachment(массив) (обязательный)
An array with attachment object data.
$file(строка) (обязательный)
File path of the attached image.

Список изменений

С версии 4.3.0 Введена.

Код WP_Site_Icon::insert_attachment() WP 6.0

public function insert_attachment( $attachment, $file ) {
	$attachment_id = wp_insert_attachment( $attachment, $file );
	$metadata      = wp_generate_attachment_metadata( $attachment_id, $file );

	/**
	 * Filters the site icon attachment metadata.
	 *
	 * @since 4.3.0
	 *
	 * @see wp_generate_attachment_metadata()
	 *
	 * @param array $metadata Attachment metadata.
	 */
	$metadata = apply_filters( 'site_icon_attachment_metadata', $metadata );
	wp_update_attachment_metadata( $attachment_id, $metadata );

	return $attachment_id;
}