Add support for acquisition kind

Filed an Issue dshanske/indieweb-post-kinds (GitHub)

Adds support for responding to and interacting with other sites using the standards developed by the IndieWeb Community

Based on prior art and details in the IndieWeb Wiki for acquisitions.

I’m including some potential code below, though it will also require adding the appropriate icon and some meta data in a few places for the “Kinds” meta box as well as to the admin UI locations which are currently missing.

I’ve “cheated” a bit and defaulted to display the “wish” icon and thus some of its metadata, so the acquisition kind would need its own icon (the same shopping cart icon may be best) and some small meta data would need to be changed as well in the final.

For those who need to have this right away, the code below will “work” from a display standpoint.

Taxonomy Code template

Code snippet I’ve added to indieweb-post-kinds/includes/class-kind-taxonomy.php just under the section for the wish kind:

'acquisition' => array(
'singular_name' => __( 'Acquisition', 'indieweb-post-kinds' ), // Name for one instance of the kind
'name' => __( 'Acquisitions', 'indieweb-post-kinds' ), // General name for the kind plural
'verb' => __( 'Acquired', 'indieweb-post-kinds' ), // The string for the verb or action (liked this)
'property' => 'acquired-of', // microformats 2 property
'format' => 'status', // Post Format that maps to this
'description' => __( 'Purchases, gifts, found things, or objects donated to me', 'indieweb-post-kinds' ),
'description-url' => '
'show' => true, // Show in Settings
),

Naturally the “true” flag for ‘show’ should be set to “false” until the code is feature complete.

A simple view for the acquisition post kind

Add the following code to the folder indieweb-post-kinds/views/ in a file named kind-acquisition.php

<?php
/*
* Acquisition Template
*
*/
$mf2_post = new MF2_Post( get_the_ID() );
$cite = $mf2_post->fetch();
if ( ! $cite ) {
return;
}
$author = Kind_View::get_hcard( ifset( $cite['author'] ) );
$url = ifset( $cite['url'] );
$embed = self::get_embed( $url );
?>





<?php
echo Kind_Taxonomy::get_before_kind( 'wish' );
if ( ! $embed ) {
if ( ! array_key_exists( 'name', $cite ) ) {
$cite['name'] = self::get_post_type_string( $url );
}
if ( isset( $url ) ) {
echo sprintf( '%2s', $url, $cite['name'] );
} else {
echo sprintf( '%1s', $cite['name'] );
}
if ( $author ) {
echo ' ' . __( 'by', 'indieweb-post-kinds' ) . ' ' . $author;
}
if ( array_key_exists( 'publication', $cite ) ) {
echo sprintf( ' (%1s)', $cite['publication'] );
}
}
?>



<?php
if ( $cite ) {
if ( $embed ) {
echo sprintf( ' %1s', $embed );
} elseif ( array_key_exists( 'summary', $cite ) ) {
echo sprintf( ' %1s ', $cite['summary'] );
}
}
// Close Response
?>



<?php

Future enhancements

Future additions/improvements to this kind could include potentially adding new data fields to indicate the “location purchased” as well as the “purchase price”, the “manufacturer” and maybe the “condition” with a dropdown for selecting options like brand new, like new, very good, good, acceptable, poor, and unspecified. These could be marked up with the h-product related microformats of p-price and p-brand. These would then need to be tucked into the view as appropriate as well.