Front-end Editor: Version 2.2

Editable groups

It’s now possible to create arbitrary groups of editable elements. This opens the door for a lot of possibilities. For example, you can now edit all fields of a post at once, instead of one at a time. Go to the FEE settings page to enable it.

Post creation

One feature that was often requested was the ability to create posts from the front-end, not just to edit them. This is now possible by using the fee_inject_dummy_post() template tag.

Aloha 0.20

This release features the most recent version of Aloha Editor available, 0.20.0-RC9. This fixes the jQuery compatibility issues, as well as a bunch of other bugs. Thanks again to Jotschi for lending a hand with this.

Thanks to AppThemes and Jason Buksh for supporting this release financially.

Happy holidays!

The Magic of WP_User

In previous versions of WordPress, when you called get_userdata() or get_user_by(), you got a plain stdClass object, filled with all the fields from both wp_users and wp_usermeta tables. This had two disadvantages:

  • dashes were removed, so that ‘my-custom-field’ became ‘mycustomfield’
  • all fields were loaded and kept in memory, wasting precious resources

Since WordPress 3.3, all user-related functions return WP_User instances. This class has some magic methods that make it behave as if it contained all the custom fields.

Accessing a single custom field

For example, let’s try to display the user description of the currently logged in user:

$current_user = wp_get_current_user();
 
if ( isset( $current_user->bio ) )
	echo '<p>' . $current_user->bio . '</p>';

This code works fine both in WP 3.2 and in WP 3.3. The difference is that in WP 3.3 that code is equivalent to this:

if ( $current_user->__isset( 'bio' ) ) )
	echo '<p>' . $current_user->__get( 'bio' ) . '</p>';

Internally, the __isset() and __get() methods call get_user_meta().

If you have a variable key or a key with dashes, there are prettier aliases which you can use:

if ( $current_user->has_prop( 'my-field' ) ) )
	echo '<p>' . $current_user->get( 'my-field' ) . '</p>';

Accessing all custom fields

Unfortunately, iterating over all the custom fields by casting to an array isn’t possible anymore:

foreach ( (array) $user as $key => $value ) {
	var_dump( $key, $value );
}

It will have to be replaced with this:

foreach ( get_user_meta( $user->ID ) as $key => $values ) {
	var_dump( $key, $values );
}

Note that, in the later case, $values is an array.

When economists base their models on their fantasies of an “economic man” motivated only by self-interest, they forget community – the all-important web of meaning we spin around each other – the inescapable context within which anything truly human has taken place

Christopher Ryan and Cacilda Jetha

Easier way to update submodules in git

I love using git submodules to avoid duplicating common code. Unfortunately, updating a submodule reference to the lastest revision is a chore:

cd framework
git checkout master
git pull
git submodule update --init --recursive
cd ..

However, we can store all of those commands using a git alias:

git config --global alias.up-sub '!f() { cd $1 && git checkout master && git pull && git submodule update --init --recursive; }; f'

Now, to update the ‘framework’ submodule, we can just do:

git up-sub framework

I picked up the trick for running multiple commands in an alias from this article on the Mozilla blog.

Update Use && instead of ; to prevent losing work when you mistype the submodule name.

Posts 2 Posts: Version 1.1

I’m pleased to announce that the Posts 2 Posts plugin now also supports posts-to-users connections. (It supports users-to-users connections as well, but there’s no UI for them).

This is made possible by a new p2p_type column on the wp_p2p table, with which we can clearly distinguish between user ids and post ids. If you’re upgrading from a previous version of Posts 2 Posts, all the existing connections will be automatically updated to have the correct value for this column.

For the next version, I’m thinking of supporting connections between posts on different blogs in a multisite network.

Lisp and Vim

What makes Lisp special is that executable code has the same syntax as data structures.

What makes Vim special is that the mode for entering text uses the same keys as the mode for executing commands.

Both Lisp and Vim have very powerful macro systems.

Both Lisp and Vim rock my socks off.

Posts 2 Posts: Version 1.0

It’s been a year and a half since the initial 0.1 release. Posts 2 Posts has come a long way since then and it’s been a very interesting journey.

Here’s what’s new in version 1.0:

Indeterminate connection types

Initially, connection types were organised exclusively around post types. Since version 0.9.5, you can use arbitrary query variables to define the sides of a connection type.

And with this release, there’s a clear distinction between regular connection types and indeterminate connection types, which are a lot easier to control now.

Improved support for ordered connections

You can now order connections both ways. Also, you can get the previous and next post in the list. See Connection ordering.

Related posts

If you have actors and movies, it’s a lot easier now to get other actors that have played in the same movies as a particular actor. See the wiki page about related posts.

Additionally, you can show related posts using the widget.

More connection field types

In previous versions, a connection field could be either a text input or a dropdown. Now, you can also add radio buttons, checkboxes and textareas. See Connection information.

You can see all the tickets closed for this release on github:

https://github.com/scribu/wp-posts-to-posts/issues?milestone=2&state=closed

The Social Graph Is Neither

The Social Graph Is Neither is a brilliant article on why the current idea of “social networking” is utterly flawed. Some highlights:

But even if we go ahead and build the Semantic Web, 2004 edition, and populate it with information about all our connections to other people, it still won’t be expressive enough.

There’s another fundamental problem in that a graph is a static thing, with no concept of time. Real life relationships are a shared history, but in the social graph they’re just a single connection.

Social networks exist to sell you crap. [...] Because their collection methods are kind of primitive, these sites have to coax you into doing as much of your social interaction as possible while logged in, so they can see it.

Open data advocates tell us the answer is to reclaim this obsessive dossier for ourselves, so we can decide where to store it. But this misses the point of how stifling it is to have such a permanent record in the first place.

The Future of Multisite

The original use case of the Multisite feature in WordPress (formerly WPMU) was wordpress.com, where users can create and manage their own blogs, independent from all the other blogs in the network.

Outside of wordpress.com, this is the more common story: someone sets up a multisite installation and needs to create and manage several sites, usually with similar appearance and functionality, but different enough to warrant distinct child themes.

In this later scenario is where the administration interface falls short. This is what needs to be streamlined in order to make Multisite as user-friendly as all the rest of WordPress.

I’ve found myself writing several plugins for this use case already:

Update: Ipstenu posted some common scenarios when multisite should not be used.

When we travel, we travel not to see new places with new eyes; but that when we come home we see home with new eyes.

G. K. Chesterton