WordPress 3.9 Beta 1

WordPress 3.9 Beta 1 has been released!

Changes

  • We updated TinyMCE, the software powering the visual editor, to the latest version. Be on the lookout for cleaner markup. Also try the new paste handling — if you paste in a block of text from Microsoft Word, for example, it will no longer come out terrible. (The “Paste from Word” button you probably never noticed has been removed.) It’s possible some plugins that added stuff to the visual editor (like a new toolbar button) no longer work, so we’d like to hear about them (#24067). (And be sure to open a support thread for the plugin author.)
  • We’ve added widget management to live previews (the customizer). Please test editing, adding, and rearranging widgets! (#27112) We’ve also added the ability to upload, crop, and manage header images, without needing to leave the preview. (#21785)
  • We brought 3.8?s beautiful new theme browsing experience to the theme installer. Check it out! (#27055)
  • Galleries now receive a live preview in the editor. Upload some photos and insert a gallery to see this in action. (#26959)
  • You can now drag-and-drop images directly onto the editor to upload them. It can be a bit finicky, so try it and help us work out the kinks. (#19845)
  • Some things got improved around editing images. It’s a lot easier to make changes to an image after you insert it into a post (#24409) and you no longer get kicked to a new window when you need to crop or rotate an image (#21811).
  • New audio/video playlists. Upload a few audio or video files to test these. (#26631)

Developer Related Changes

  • The load process in multisite got rewritten. If you notice any issues with your network, see #27003.
  • We now use the MySQL Improved (mysqli) database extension if you’re running a recent version of PHP (#21663). Please test your plugins and see that everything works well, and please make sure you’re not calling mysql_* functions directly.
  • Autosave was refactored, so if you see any issues related to autosaving, heartbeat, etc., let us know (#25272).
  • Library updates, in particular Backbone 1.1 and Underscore 1.6 (#26799). Also Masonry 3 (#25351), PHPMailer (#25560), Plupload (#25663), and TinyMCE (#24067).
  • TinyMCE 4.0 is a major update. Please see TinyMCE’s upgrade guide and our implementation ticket for more. If you have any questions or problems, please open a thread in the support forums.

Download: WordPress 3.9 Beta 1

1 Star2 Stars3 Stars4 Stars5 Stars (64 votes, average: 4.02 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 (129 votes, average: 4.01 out of 5)

Updated This Site WP-Polls To 2.11 RC1

I have updated this site WP-Polls to 2.11 RC1 to test out the multiple answers voting feature in WP-Polls 2.20. You can set the maximum number of answers that the user can vote, in this case, I set it to 14 as there are 14 answers.

Note the poll footer that says “Total Voters” and NOT “Total Votes”. The individual answer on the other hand is “Votes” and not “Voters” and the percentage is calculated based on the “Total Voters”.

Vote away on the right hand sidebar.

1 Star2 Stars3 Stars4 Stars5 Stars (105 votes, average: 4.01 out of 5)