Localization And AJAX Updates

Localization
I have localize WP-Stats and WP-UserOnline in addition to WP-Polls. If any one of you willing are to test it for me, the downloads links are as follows:
» WP-Stats 2.06 Localized Version
» WP-UserOnline 2.06 Localized Version

If you do test it, please feedback to me if there are any text not translated properly or can be improved. Thanks alot.

Example of WP-UserOnline: You need to create a new .po based on the .pot then after translating you need to save as for example: wp-useronline-de_DE.po where de_DE is your language. The poedit (I assume you are using poedit) will generate a file called wp-useronline-de_DE.mo.

Note: make sure that both files are in wp-content/plugins/useronline

AJAX
WP-Polls and WP-UserOnline now processes AJAX in their own file like polls.php and useronline.php instead of index.php. I think in this way it will be faster and it will have lesser conflicts with other plugins. I have also removed the Javascript variable site_url in them because it is not used.

1 Star2 Stars3 Stars4 Stars5 Stars (649 votes, average: 3.96 out of 5)

WordPress 3.0 Beta 2

WordPress 3.0 Beta 2 has been released and it seems WordPress 3.0 has miss the initial release date of 1st May 2010, which I think is good. They should not rush to meet the release date as it should be release when it is done. I am guessing they will head to RC1 in the next release.

Things to test:

  • Revised menu user interface
  • Changes to the WordPress exporter and importer to make it more flexible

Download: WordPress 3.0 Beta 1

1 Star2 Stars3 Stars4 Stars5 Stars (470 votes, average: 3.96 out of 5)

WordPress 3.3

WordPress 3.3 has been released! I have upgraded this site to WordPress 3.3. My plugins should be working fine with WordPress 3.3.

For Users
Experienced users will appreciate the new drag-and-drop uploader, hover menus for the navigation, the new toolbar, improved co-editing support, and the new Tumblr importer. We’ve also been thinking a ton about what the WordPress experience is like for people completely new to the software. Version 3.3 has significant improvements there with pointer tips for new features included in each update, a friendly welcome message for first-time users, and revamped help tabs throughout the interface. Finally we’ve improved the dashboard experience on the iPad and other tablets with better touch support.

For Developers
There is a ton of candy for developers as well. I’d recommend starting your exploration with the new editor API, new jQuery version, better ways to hook into the help screens, more performant post-slug-only permalinks, and of course the entire list of improvements on the Codex and in Trac.

Download: WordPress 3.3

1 Star2 Stars3 Stars4 Stars5 Stars (311 votes, average: 3.96 out of 5)

WP-PostRatings 1.61

I have released WP-PostRatings 1.61 which fixes a code injection via “HTTP Referrer” and affects users who are on WP-PostRatings 1.50 only. This is the same code injection fixed for WP-Polls few days back.

I have checked the rest of my plugins to ensure that the code is not in anymore of my plugins. Sorry for any inconvenienced cased.

Similar to WP-Polls, I also took this chance to port the readme.html to the proper readme.txt which WordPress.org is using and now you can see all the details of WP-PostRatings right from the plugins page itself regardless if it is from your WP-Admin or WordPress.org.

All users should upgrade now

Props to Dion Hulse aka dd32 for the report!

Download: WP-PostRatings 1.61

1 Star2 Stars3 Stars4 Stars5 Stars (264 votes, average: 3.96 out of 5)

Loading JavaScript In Footer In WordPress 2.8

As you may all know by now, WordPress 2.8 will have some optimization done on JavaScript as well as CSS. That includes concatenating the scripts/styles, minifying it instead of packing as well as gzipping. I have been paying much attention to the development of WordPress 2.8 especially when it comes to JavaScripts. I have filed 2 suggestion tickets in WordPress Trac, Ticket #8884 and Ticket #8859 which should be able to help plugin authors load their JavaScript easily in the footer of WordPress.

This post shall be a tutorial post and I will demonstrate how to load JavaScript in the theme’s footer in WordPress 2.8 Nightly using my WP-Polls as an example.

### Function: Enqueue Polls JavaScripts/CSS
add_action('wp_enqueue_scripts', 'poll_scripts');
function poll_scripts() {
	wp_enqueue_style('wp-polls', plugins_url('wp-polls/polls-css.css'), false, '2.50', 'all');
	wp_enqueue_script('wp-polls', plugins_url('wp-polls/polls-js.js'), array('jquery'), '2.50', true);
	wp_localize_script('wp-polls', 'pollsL10n', array(
		'ajax_url' => plugins_url('wp-polls/wp-polls.php'),
		'text_wait' => __('Your last request is still being processed. Please wait a while ...', 'wp-polls'),
	));
}

The poll_scripts() function will hook onto the wp_enqueue_scripts function. This will allow you to enqueue JavaScripts as well as CSS Styles for your plugin.

As the name goes, wp_enqueue_style() will queue and then print out your plugin’s CSS link.

wp_enqueue_script() will queue and then print out the JavaScript link. The difference between WP2.7’s wp_enqueue_script() and WP2.8’s wp_enqueue_script() is the addition of the last argument which is whether to load the JavaScript in the footer. If set to true, it will load it in the footer, PROVIDED that your theme has the following code:

in the theme footer (refer to the default theme footer.php if unsure). Many themes especially self-created ones has failed to include wp_head() in the header.php as well as wp_footer() in the footer.php. The default value of the last argument is false, which means it will load it in the header by default.

wp_localize_script() will allow your to translate strings within your plugin JavaScript. To access the translated variable, you can use “pollsL10n.text_wait” (without the quotes).

This new hook:

do_action('admin_enqueue_scripts', $hook_suffix);

will allow you to enqueue your plugin JavaScript or CSS within the WP-Admin area easily rather than calling many times add_action() repeatedly depending on how many pages your plugin has in the WP-Admin area.

The sample code from WP-Polls to print JavaScripts as well as CSS in the WP-Admin area are as follows:

### Function: Enqueue Polls Stylesheets/JavaScripts In WP-Admin
add_action('admin_enqueue_scripts', 'poll_scripts_admin');
function poll_scripts_admin($hook_suffix) {
	$poll_admin_pages = array('wp-polls/polls-manager.php', 'wp-polls/polls-add.php', 'wp-polls/polls-options.php', 'wp-polls/polls-templates.php', 'wp-polls/polls-uninstall.php');
	if(in_array($hook_suffix, $poll_admin_pages)) {
		wp_enqueue_style('wp-polls-admin', plugins_url('wp-polls/polls-admin-css.css'), false, '2.50', 'all');
		wp_enqueue_script('wp-polls-admin', plugins_url('wp-polls/polls-admin-js.js'), array('jquery'), '2.50', true);
		wp_localize_script('wp-polls-admin', 'pollsAdminL10n', array(
			'admin_ajax_url' => plugins_url('wp-polls/polls-admin-ajax.php'),
			'text_delete_all_logs' => __('Delete All Logs', 'wp-polls'),
		));
	}
}

Firstly, I assigned all the pages of WP-Polls that has an admin page to an array. Next I check whether the current page is within the array. If it is in the array, it means that the user is accessing WP-Polls admin area and thus, I will proceed on to enqueue the JavaScript or CSS needed in the WP-Polls admin area.

Note 1: When you use wp_enqueue_script(), it will automatically register the script and then print it out, whereas if you use wp_register_script(), you will have to manually print it out by calling wp_print_scripts().

1 Star2 Stars3 Stars4 Stars5 Stars (131 votes, average: 3.96 out of 5)