YouTube Post Type v0.1 Released
YouTube Post Type allows you to easily add YouTube videos as post into your WordPress installation via the introduction of register_post_types in WordPress v2.9. This will make YouTube a first class citizen in your WordPress.
Why would you want to do this? If you want a post to represent a YouTube video.
You add YouTube videos by specifying the URL or the YouTube id.
Your YouTube thumbnails are also downloaded and pulled into the system so you can use them. Your YouTube also gets associated to the first thumbnail found.
Identifying WordPress Hooks
In order to develop WordPress solutions, you are required to understand how WordPress hooks work. Sadly WordPress has over 1000 hooks in the system, so the task may be daunting to know which hook to exactly use.
There are a few options to find out which hook to use:
- Comb through the source code
- Comb through WordPress documentation on hooks
- Search the Internet for the right hook to use.
Each one requires you to do some searching. Wouldn't it be easier if we let WordPress do that job for us? Whenever we load a page, WordPress will tell us what hooks were called, and in what order.
do_action
Note: WordPress has two kinds of hooks. An action hook, and a filter hook. This article only deals with the action hook. But it can also apply to the filter hook. The filter hook can also be found in wp-includes/plugin.php on line 134
WordPress calls its hooks via the function do_action. do_action calls out all the hooks attached to the hook specified in its arguments. If you open up wp-includes/plugin.php, you should be able to find a function called do_action on line 299.
Note: I am currently running WordPress v3.0 beta. Your file name and line positions may be different.
In order to output the called hook, your first thought may be to enter echo $tag. Sadly this won't work as it will output text all over the WordPress application, which will make it difficult in identifying the hooks called.
FirePHP to the Rescue
Instead we will use FirePHP. Make sure you have FirePHP installed. You can also ensure FirePHP gets loaded on all PHP pages.
Now change the file to:
function do_action($tag, $arg = '') {
global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
fb($tag);
Now reload the home page of your WordPress installation with FirePHP enabled and you should get a similar result.
- muplugins_loaded
- plugins_loaded
- sanitize_comment_cookies
- setup_theme
- load_textdomain
- after_setup_theme
- load_textdomain
- auth_cookie_malformed
- set_current_user
- init
- widgets_init
- wp_loaded
- posts_selection
- template_redirect
- get_header
- wp_head
- wp_enqueue_scripts
- wp_print_styles
- wp_print_scripts
- posts_selection
- posts_selection
- get_generic_template_loop
- get_sidebar
- get_search_form
- posts_selection
- wp_meta
- get_footer
- get_sidebar
- wp_footer
- wp_print_footer_scripts
- shutdown
Why don't you visit some other pages to test it out? It works in the Admin side as well.
Backtrace
This is all cool and all, but to get a better understanding of how the WordPress platform works, I sometimes I want to know where the hook was called.
Don't worry, we can solve that for you.
Replace the code you entered with:
function do_action($tag, $arg = '') {
global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
$backtrace = array_shift(debug_backtrace());
fb(substr($backtrace['file'], strlen(ABSPATH)) . ':' . $backtrace['line'] . ' ' . $tag);
The result should be like so:
- wp-settings.php:151 muplugins_loaded
- wp-settings.php:193 plugins_loaded
- wp-settings.php:201 sanitize_comment_cookies
- wp-settings.php:239 setup_theme
- wp-includes/l10n.php:300 load_textdomain
- wp-settings.php:270 after_setup_theme
- wp-includes/l10n.php:300 load_textdomain
- wp-includes/pluggable.php:548 auth_cookie_malformed
- wp-includes/pluggable.php:55 set_current_user
- wp-settings.php:287 init
- wp-includes/default-widgets.php:1144 widgets_init
- wp-settings.php:296 wp_loaded
- wp-includes/query.php:2322 posts_selection
- wp-includes/template-loader.php:7 template_redirect
- wp-includes/general-template.php:26 get_header
- wp-includes/general-template.php:1554 wp_head
- wp-includes/script-loader.php:700 wp_enqueue_scripts
- wp-includes/functions.wp-styles.php:21 wp_print_styles
- wp-includes/script-loader.php:672 wp_print_scripts
- wp-includes/query.php:2322 posts_selection
- wp-includes/query.php:2322 posts_selection
- wp-includes/general-template.php:114 get_generic_template_loop
- wp-includes/general-template.php:84 get_sidebar
- wp-includes/general-template.php:146 get_search_form
- wp-includes/query.php:2322 posts_selection
- wp-includes/general-template.php:350 wp_meta
- wp-includes/general-template.php:55 get_footer
- wp-includes/general-template.php:84 get_sidebar
- wp-includes/general-template.php:1564 wp_footer
- wp-includes/script-loader.php:620 wp_print_footer_scripts
- wp-includes/load.php:517 shutdown
Now how cool is that?
WordPress Plugin: Dewplayer
With my recent demo reel, I've only recently had the need to embed an MP3 file in my blog. Now there are multiple plugins you can try, but I'm sticking with Dewplayer ( Official Site, WordPress Plugin Site ) for now. The WordPress Plugin Dewplayer relies on the Dewplayer MP3 Flash Player.
Here's a teaser:
Easy
Dewplayer makes it easy to play an MP3 file in your browser in your WordPress blog.
Its as simple as entering:
[ dewplayer:url to your mp3 file ]
In fact you can load multiple MP3 files in one player.
Criticisms
While the Dewplayer WordPress plugin supports multiple files, the only way to enable the playlist is in the Dewplaeyer configuration page. It is not per shortcode basis. In fact to enable any of the other modes ( Mini, Classic, Multi ) is in the configuration.
Conclusion
I was sold on its simplicity and ease in loading an MP3. Its extremely great at doing just that. But don't expect any more.


