WP-Logs integrates with Notifo

Having detailed logs of how your services are being used is important, but sometimes it’s nice to have immediate notifications of critical events. Enter Notifo, the super-easy-to-use push notification service.

We recently updated WP-Logs to support the Notifo service so you can now receive notices just about anywhere. We have some of ours going straight to phone, email, and growl.

WP-Notifo is required and must be configured properly. After you’re all setup, use it with WP-Logs by adding the ‘notifo’ key to your event call; i.e.:

WP-Logs: a new WordPress plugin from Shockoe

When building a new application or plugin, sometimes its important to have detailed information about what actions are taking place. This can be crucial when testing APIs, hooks, and your users actions to make sure your design is having the desired effect.

In the course of creating, testing, and debugging our work at Shockoe, we’ve created a WordPress plugin that gives you the ability to track custom events and pass along any information you need. WP-Logs (catchy title, right?) lets you drop a single line into your plugin code to define an event title, user id, and any extra information you’d like to see. This information will appear under a new ‘Logs’ tab in the WordPress admin panel and can optionally be passed to a Google Analytics account to be viewed inline with your other site statistics.

It’s currently being reviewed by the WordPress staff and will be available soon in the official WordPress Plugins directory. For now, the plugin can be cloned from our github repository. Follow us on twitter at @shockoe for information and updates.

Update: The plugin has been approved and is now in the WordPress plugin directory. Check it out at http://wordpress.org/extend/plugins/wp-logs/

Integrating with Amazon S3 for fun, profit, and epic speed boosts.

The benefits of using Amazon S3 to store static resources is already well documented. It’s almost a no-brainer if you are building an app that hosts a lot of static files.

We just converted an app that we’re working on to use S3 for all user uploads. It not only sped up our development time, it also basically eliminated the need to worry about file-server scaling in our prototyping stage. And we may not need to worry about it for a quite a while after that.

Check out http://getcloudfusion.com/ for more information on the Amazon S3 SDK for PHP.

Working with WordPress Custom Post Types

One of the major features to be introduced in WordPress 3 was the ability to create custom post types. Basically, this lets you recreate the ‘Posts’ tab with specific functionality in mind. For example, creating a portfolio with fields for project images and client information. At Shockoe, we are using this in an upcoming project to that uses WordPress to provide content for a new iPhone app.

This makes WordPress much more viable as a CMS as opposed to blogging software that struggles to handle larger sites. In previous versions of WordPress this involved either a considerable amount of work or using a massive plugin. The best of those plugins, Magic Fields (a fork of Flutter), is several thousand lines of code. We can create a flexible solution in far fewer lines.

Code in action


add_action('init', 'post_type_example');
function post_type_example() {
register_post_type(
'example',
array(
'label' => __('Example'),
'public' => true,
'show_ui' => true,
'supports' => array(
'title',
'editor',
'excerpt',
'comments'),
'menu_position' => 5
)
);

register_taxonomy( ‘categories’, ‘example’, array( ‘hierarchical’ => true, ‘label’ => __(‘Categories’) ) );
register_taxonomy( ‘tags’, ‘example’, array(‘label’ => __(‘Tags’)));
}

Here we have created a new post type that will have it’s own sidebar tab under ‘Posts’ as well as fields for title, content (‘editor’), an excerpt, and comments. We also added functionality similar to WordPress’ tags and categories features by calling ‘register_taxonomy.’ Setting ‘hierarchal’ => true will make the field behave like categories while leaving it empty (or setting it to ‘false’) gives us the tags functionality.

That’s it. Simple. In a handful of lines we have a flexible solution that gives us the option of using better contextual grammar. That translates to a much better experience for clients and end users.

Adding Custom Functionality

The code above basically replicates the Posts functionality with the ability to have better labels. But what if we need to include custom information? For that we need add_meta_box:

add_action("admin_init", "admin_init");
function admin_init(){
add_meta_box("example_field", "Example Text Field", "example_field", "normal", "high");
}

function example_field () {
global $post;

$post_custom = get_post_custom($post->ID);
$text_field_content = $post_custom['text_field'][0];

print "


";
}

And to save our custom field’s information when we press ‘Publish’:

add_action('save_post', 'save_details');
function save_details(){
global $post;

update_post_meta($post->ID, ‘text_field’, $_POST[‘text_field’]);
}

Now we should have a custom text box that will appear below the content editor. When we save our post, the information in our custom field will be saved to the database. And when we edit our post, the text field will be repopulated.

Conclusion

With a little bit of coding knowledge you can create an elegant solution for turning WordPress into a functional CMS. And this is a very basic example; the possibilities of what can be created from this point are endless.

For more detailed information, see the register_post_type and add_meta_box reference pages in the WordPress Codex