[wp-hackers] What are the point in hooking the `init` when writing a plugin?

Ryan Chan ryanchan404 at gmail.com
Sat May 5 06:23:15 UTC 2012

I think this is the same when you can put the code inside the main plugin file?

e.g. akismet: http://plugins.svn.wordpress.org/akismet/trunk/akismet.php

function akismet_init() {
	global $wpcom_api_key, $akismet_api_host, $akismet_api_port;

	if ( $wpcom_api_key )
		$akismet_api_host = $wpcom_api_key . '.rest.akismet.com';
		$akismet_api_host = get_option('wordpress_api_key') . '.rest.akismet.com';

	$akismet_api_port = 80;
add_action('init', 'akismet_init');


Why not just execute `akismet_init` directly? I can't see any drawback
and sound not really useful to hook the init?

More information about the wp-hackers mailing list