Last Updated
Map- Hfeed and hentry are classic microformats, and remain in this implementation. In most themes, hfeed is attached to a main div and should be removed in favor of the implementation provided. The advantage is that it can be modified.
- CSS shouldn’t include microformats classes.
- If you duplicate the same classes attached to different elements, it can mess up parsing.
- Some of this is similar to the code in wordpress-uf2. wordpress-uf2 hasn’t been updated in a while and also uses ActivityStream as Microformats Vocabulary…h-as-page, h-as-article, which are not commonly used. This doesn’t include that. So, simpler, but taking advantage of changes in WordPress and Microformats.
- This isn’t really a stopgap measure. This is how any theme would update its structure.
- The post_class, comment_class, and body_class are functions that output standard classes for the body, post, and comment enclosures. They are not required, but have been around since WordPress 2.8, and are usually present in themes. It is a more dynamic way to add structure.
For most people, this is a simple way to add basic microformats structure that allows your site to be parsed by a microformats 2 parser. The second part will be covering some more complicated issues.
Why Microformats
Microformats are human-readable markup that are easily human readable as well as machine readable. They appear as classes attached to HTML elements in webpages. The most popular alternatives to Microformat markup are things like schema.org, RDFa, etc.
The mistake people make is that it is overly technical. The vocabulary of the current iteration of the standard is simple. The below is a simple example. For example, h-card is the vocabulary for marking up people, organizations, and places. The below is a minimal h-card identifying name and associated URL.
<div class="h-card"> <h3 class="p-name">David Shanske</h3> <a class="u-url" href="https://david.shanske.com">Website></a> </div>
Then there is h-entry, which is used for individual posts on this site, or any episodic content. It is a equally easy, though like h-card, you can add more elements.
<div class="h-entry"> <time class="dt-published" datetime="2016-06-22T02:34:16-0400">June 22, 2016</time> <p class="e-content">This is my content</p> </div>
And so on. Not only does it identify…what is the content, what is the publish date, etc. in a way a human could realistically read enough to mark it up, it can be parsed and read by a computer. It is easy, if you understand HTML enough to read it, how to mark up the elements.
And then come the advantages. If parsers can read the elements of your site, they can interpret your intent. The community has developed vocabulary to indicate many relevant things, and put out programs, sites, and in my case, WordPress plugins that take this data and turns it into things like: ‘likes’, meaningful comments, event RSVPs, etc.
I’ve been posting articles on adding Microformats to a WordPress site. Once added, the site can be properly parsed, and can be used to do these things. How do I know? My site already does them.
Timezone Offsets in WordPress Themes
$time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), get_the_date(), esc_attr( get_the_modified_date( 'c' ) ), get_the_modified_date() );
The string in question is used in a generated line of HTML, which usually looks like something below.
<time datetime="2
">June 21, 2016</time>A parser reading the above will read it as 10:48PM UTC/GMT. Assuming it converted that into local time, it would actually be 6:48PM EDT. However, in reality, I posted at 10:48PM Eastern Time. It just omitted the timezone offset, putting in +00:00.
The timezone offset is properly shown if you replace ‘c’ with DATE_W3C or DATE_ATOM. The alternative is to add the date in as GMT. Without proper timezone offsets, posts will be parsed as being at the wrong time.
Related:
https://core.trac.wordpress.org/ticket/25768
https://core.trac.wordpress.org/ticket/20973
Attending this event: yes
A Film by Michael Levine In Theaters April 20th from Menemsha Films Synopsis: As it has since 1925, the Streit’s matzo factory sits in a low-slung tenement b…
Why Webmentions in WordPress
Over the last few years, as the smartphone has become more popular, we’ve moved from being excited about notifications to being worried about notification overload. Companies are hoping to get more data on us so they can tailor their interactions with us. We install analytics on our websites to determine how many visitors we get and what they did on our sites. At its simplest level, a linkback is a way of having a site(the sender) notify another site(the receiver) when it links to it. It sounds like something we would want to know and would have many potential uses.
WordPress has two built in linkback protocols: Trackback and Pingback. To many users, they seem like the appendix of WordPress. People don’t care about them until they are exploited by bad actors. There is a newer protocol, the first linkback protocol to be accepted as a draft specification from the W3C, the main standards organization for the Internet, called Webmention.
Webmention improves upon the previous protocols. It uses an HTTP POST request to send two parameters…the source and target URL. By comparison, trackback, which also uses HTTP, only sends the source URL and does nothing in its WordPress form to verify the trackback is legitimate. Pingback, like webmention, sends both source and target, but it uses XML-RPC as opposed to a POST request. XML-RPC has had some controversy around it as well. There are also several practices that are recommended by the Webmention specification that would make an implementation more robust than the implementations of Trackback and Pingback.
WordPress has a longstanding reputation of commitment to backward compatibility and isn’t going to flick the switch and remove pingback and trackback code from WordPress Core so easily, with or without a replacement. It makes sense to make improvements to the older protocols concurrently with adopting webmentions, although it would also be a good idea to consider gradually deprecate the older protocols in favor of webmentions. Trackbacks have no source validation built into WordPress as it was not part of the original specification. The pingback code could use some love. However, with some refactoring, new webmention code could be used to update the older pingback/trackback code as well. This would create a better linkback system overall.
Even if webmention is a better delivery system for linkbacks than its predecessors, no one but a developer cares about protocols. People care about what it can do for you. All of the protocols converge in one place. Once you know a site has linked to you, what do you do with that information? That is where the exciting parts come in and where WordPress falls flat.
If one person would like to speak up in favor of the presentation of […]Useless Context. […], I’d love to hear it. The burden of presentation and use in a linkback relationship goes to the receiver and can be infinitely extensible. What WordPress lacks is a good base presentation for people to enhance and some innovative examples from the community of usage. If you can parse a page of HTML, you can come up with richer content and relationships by marking up the elements of a post with Microformats. WordPress already has some microformats embedded in most WordPress sites and supporting in many themes, and there are other efforts that can be made to better improve this side of things. But there are limitless possibilities, for example:
- Want to reply to a post on WP Tavern on your own site? Send a webmention(or more archaic protocol) to WP Tavern with the URL of your reply. WP Tavern could parse your site and generates an actual comment from it.
- Why only a reply? What about other types of relationships? Liking a post, for example?
- Even just simple administrator stats can be interesting and useful.
So, why not do all of this with an API? We have a new one coming into WordPress…and that’s a great thing I’m fully in favor of. But reading content from a website using an API creates a burden on both sides of the relationship. I have to write an API and you have to learn how to use it if you want to interface with my site. Why shouldn’t your website be your API?
If you are interested in trying webmention support, there is a basic plugin for WordPress. There is even a second plugin that uses Microformats2 plus linkbacks to generate richer comments. Both of these can be used to develop the more robust implementation that would be required for WordPress Core. For more information on how people have been using webmentions, visit IndieWebCamp.
Libraries often put me in a rhapsody, but never quite like this!
Comment Improvements in WordPress 4.4/4.5
Insert Comment with Meta
wp_insert_comment has a modification that allows comment meta to be added to a comment at the time it is created.
// If metadata is provided, store it.
if
( isset(
$commentdata
[
'comment_meta'
] ) &&
is_array
(
$commentdata
[
'comment_meta'
] ) ) {
foreach
(
$commentdata
[
'comment_meta'
]
as
$meta_key
=>
$meta_value
) {
add_comment_meta(
$comment
->comment_ID,
$meta_key
,
$meta_value
, true );
}
}
do_action( 'comment_post', $comment_ID, $commentdata['comment_approved'], $commentdata );
Music video for “Shed a Little Light” produced in honor of Martin Luther King, Jr. Day.
Figuring Out Music Genres
The hardest thing about digital music for me is metadata. Being able to play music of a specific genre, group, etc. is useful, as well as my interest on the year of the song released. Genre is a particular issue because poorly selected genres make it more difficult to find the type of music you are in the mood for.
In researching this issue now, I came across the advice of Dan Gravell, who maintains a commercial product named Bliss that he wrote to solve his own digital music collection problems and sells. In his article, MP3 genres: one size does not fit all, he comments that a problem for owners of large MP3 collections is out of control genres. The solution he suggests mirrors what I was thinking. Come up with the genres you will allow in your collection and make sure all your music complies with this list. Here’s his starting list, compiled from the common elements of four different online music databases.
The Fundamental Music Genre List
- Blues
- Classical
- Country
- Electronic
- Folk
- Jazz
- New age
- Reggae
- Rock
If you try to apply a list like this to a collection, you end up with a lack of balance. I, for example, have no Electronic in my collection that I know of. This is when you need to split your genres. What some would call sub-genres get promoted to better divide your music. You can then merge categories. For example, in my collection, Blues and Jazz would have to merge as I don’t have a large collection of either.
In addition to loading genres into metadata, they are a part of my filesystem organization. I still organize music into a directory structure of Genre -> Artist -> Album. Now, the simplest thing to do would be to eliminate that and go to Artist -> Album, but estimates are I have several hundred albums and artists. And multi-artist compilations seem to confuse it more.
By organizing it, I am hoping to get into the areas of my collection I forget I have and listen to more diverse playlists. It’s going to be a while though. At least I’m not alone in my problem.