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' => 'http://indieweb.org/acquisition',
'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 );
?>
<section class="response h-product h-cite">
<header>
<?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( '<a href="%1s" class="p-name u-url">%2s', $url, $cite['name'] );
} else {
echo sprintf( '<span class="p-name">%1s</span>', $cite['name'] );
}
if ( $author ) {
echo ' ' . __( 'by', 'indieweb-post-kinds' ) . ' ' . $author;
}
if ( array_key_exists( 'publication', $cite ) ) {
echo sprintf( ' <em>(<span class="p-brand">%1s</span>)</em>', $cite['publication'] );
}
}
?>
</header>
<?php
if ( $cite ) {
if ( $embed ) {
echo sprintf( '<blockquote class="e-summary">%1s', $embed );
} elseif ( array_key_exists( 'summary', $cite ) ) {
echo sprintf( '<blockquote class="e-summary">%1s</blockquote>', $cite['summary'] );
}
}
// Close Response
?>
</section>
<?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.