WordPress/Data

From IndieWeb
Jump to: navigation, search

In order to ensure interoperability between Indieweb WordPress plugins, as much as possible, the same data structures should be used.

Contents

Metadata

WordPress allows for for metadata to be attached to various objects.

By default, WordPress includes a metadata table for post types(posts, pages, etc), comments, taxonomy terms, and users.

WordPress contains a Metadata API that it uses to handle metadata.

Microformats data

Proposal by Ryan Barrett: store a post's top-level microformats2 string properties in post metadata with the property names as the keys, prefixed by mf2_. wordpress-micropub does this now.

In accordance with MF2 JSON format, all values MUST be specified as arrays, even if there is only one value, identical to the Microformats 2 JSON format. This was implemented in the latest version of the Micropub plugin.

For example, this RSVP snippet:

<data class="p-rsvp" value="yes">I'm in!</data>

would be stored in post meta with the key mf2_rsvp and value yes.

For mf2 properties with multiple values, just store multiple values for the post meta key. WordPress supports this with e.g. add_post_meta.

Use code like this to get multiple post meta values in a single database query:

$query = new WP_Query(array('meta_query' => array(array(
  'key' => 'meta_key',
  'value' => array('mf2_name', 'mf2_content', ...),
  'compare' => 'IN'))));

use uf2 instead of mf2

Tantek Çelik minor revision of Ryan Barrett's proposal - same but use "uf2" instead of "mf2" because the "u" looks closer to a µ for "micro":

Store a post's top-level microformats2 string properties in post metadata with the property names as the keys, prefixed by uf2_. For example, this RSVP snippet:

<data class="p-rsvp" value="yes">I'm in!</data>

would be stored in post meta with the key uf2_rsvp and value yes.

For uf2 properties with multiple values, just store multiple values for the post meta key. WordPress supports this with e.g. add_post_meta.

Use code like this to get multiple post meta values in a single database query:

$query = new WP_Query(array('meta_query' => array(array(
  'key' => 'meta_key',
  'value' => array('uf2_name', 'uf2_content', ...),
  'compare' => 'IN'))));

why mf2 is better than uf2

Per Ryan Barrett's follow-up in IRC:

  • mf2 is seen in existing code much more often than uf2
    • e.g. php-mf2, mf2py, mf2util, etc
  • mf2 is more obvious (and maybe less clever)

Location

WordPress currently provides a Geodata data structure.

  • geo_latitude REQUIRED
   (float) decimal degrees -90 to 90 (negative values are in the southern hemisphere). 
  • geo_longitude REQUIRED
  (float) decimal degrees -180 to 180 (negative values are in the western hemisphere). 
  • geo_altitude OPTIONAL
  (int) Not part of the WordPress standard
  • geo_public OPTIONAL
  (int) is the geodata public (1) or private (0)? If value is missing, assume public. 
  • geo_address OPTIONAL
    (string) freeform textual description of coordinates. 
   "221B Baker St, Westminster, London NW1 6XE, UK", 
   "Pasadena, CA", "Soho, NYC", "Idaho", etc. 
   Accuracy level and language is arbitrary. 

As of WordPress 4.4, taxonomy term metadata is allowed to attach to a taxonomy term. Therefore, David Shanske is planning to declare a venue as a taxonomy term, and add location properties as taxonomy term meta attached to them.

User

WordPress supports user metadata. As part of the revamping of the Indieweb plugin, metadata reflecting rel-me and reflecting h-card properties were added to the user profile.

However, the rel-me silo URLs were not prefaced with mf2_ as using just the sitename...e.g. twitter instead of mf2_twitter allows for cross compatibility with other plugins that store this data. There were issues with those, due to standardization issues amongst different plugins.

Comment

Webmention Plugin adds an additional comment type of 'webmention' to comments.

Semantic Linkbacks stores extra information in the comment metadata.


  • semantic_linkbacks_canonical - the canonical source url
  • semantic_linkbacks_avatar - the author avatar URL
  • semantic_linkbacks_type - the comment type. The plugin currently supports the following types:
    • mention(default)
    • reply
    • repost
    • like
    • favorite
    • tag
    • rsvp:yes, rsvp:no, rsvp:maybe, rsvp:invited, rsvp:tracking.

Comment Data Brainstorming

Built into the WordPress Comment Database, the following relevant properties are stored:

  • comment_author - Name of the Author of the 'comment'
  • comment_author_url - While officially the author_URL, this is used by Pingbacks, Trackbacks, and Webmentions to reflect the source URL for a linkback, which creates an issue
  • comment_type - comments are stored as , otherwise name of type. 'webmention' is a custom type used by the Webmention Plugin
  • user_id - Theoretically, the comment author and such could be stored as a user in the user table. But this is not done by everyone.

Avatar/Author photos by default in WordPress is derived from Gravatar. The WordPress Webmention plugin does not modify this in any way, but Semantic Linkbacks sets an external URL for the avatar. There are multiple plugins for local avatar storage, but they only store photos for users, not for commenters.

Possible storage structure

  • For webmentions, source could be stored in metadata as 'mf2_url' keeping the practice of the object being the top-level microformat element.
  • Being as comment_author_url is used for source, actual author URL could be kept in mf2_author.
  • The author could either be stored in the comment metadats or a new subscriber role user created to store it.

Taxonomies

A taxonomy called 'kind' is currently used for the Post Kinds Plugin. This is meant to indicate the post kind

Current post kinds are all lowercase. List appears below:

  • article
  • note
  • reply
  • repost
  • like
  • favorite
  • bookmark
  • photo
  • tag
  • rsvp
  • listen
  • watch
  • play
  • checkin
  • wish

Many can be disabled by sites not using them

Considering the following additions:

  • weather
  • exercise

Post Kinds Plugin

In response to Ryan Barrett's proposal to organize using mf2_ as a key prefix, David Shanske changed to using 'mf2_cite' as a key instead of 'response'. All fields are optional(See Below)

  • mf2_cite
    • ['url'] - The URL the post is responding to.
    • ['name'] - The title of same
    • ['author'] - The URL of an h-card (if external)
    • ['published'] - URL publish date in ISO8601 with timezone offset
    • ['updated'] - URL updated date in ISO8601 with timezone offset
    • ['publication'] - The name of the site, or for citing articles in publications with more than one author.
    • ['content'] - the content or partial content of the work itself.
    • ['card']['name'] = Author Name / Artist Name
    • ['card']['photo'] = Author photo
  • mf2_in-reply-to, mf2_like-of, mf2_repost-of are now supported as URL properties. Any details are still stored in mf2_cite.
  • mf2_dt-start and mf2_dt-end to indicate duration
  • mf2_duration is deprecated in the interface, but will still be used in lieu of dt-end minus dt-start if set.

Future Data Plans

  • All properties to support either multi-dimensional or not, in order to allow for multi-replies and other multiple property situations

Deprecated

The Post Kinds Plugin, prior to Version 1.2.0,used the following array of metadata using the key 'response' to store details on what a post is responding to. All fields are optional.

  • response['url'] - The URL the post is responding to.
  • response['title'] - The title of same
  • response['author'] - The author name
  • response['icon'] - The author icon/image/avatar
  • response['published'] - URL publish date in ISO8601 with timezone offset
  • response['content'] - Content or a Citation...to allow for an excerpt for context.

Syndication

David Shanske's Syndication Links plugin uses a single data field with the key 'syndication_urls' with URLs separated by newlines for syndication URLs to be marked up for syndication. Entry is a textbox with one URL per line. This means there is no requirement that WordPress know about a service to add a link to it.

It also supports reading from mf2_syndication if it exists per the standardization proposal.

The plugin formerly stored an array of URLs of various syndication services under the metadata key 'synlinks'. This is now deprecated.

Themes

Both David Shanske's mf2_s fork and  Matthias Pfefferle's SemPress theme register theme support for 'microformats2'. This allows both themes to tell plugins and other functions that they support the microformats2 standard and to act appropriately.

This usually means workarounds such as adding in microformats by the plugin can and should be disabled if this is set.


WordPress
Topics Getting Started on WordPressAdvanced WordPress Set UpPluginsThemesExamplesWordPress with BridgyDevelopmentDataSecurityWordPress related wiki pages
Plugins Indieweb PluginWebmentionSemantic LinkbacksPost KindsOpenIDMicropub
Themes SemPressSemPress Lite (SemPress Child Theme)SenPress (SemPress Child Theme)Index (Sempress Child Theme)Independent Publishermf2_s
Assistance WordPress Outreach ClubJoin the #indieweb chatIRC and other chat options


See Also

Personal tools
Namespaces
Variants
Actions
Recent & Upcoming
Resources
Toolbox