Ticket 18164

First contribution to core!!

http://core.trac.wordpress.org/ticket/18164

Jane Wells has recently mentioned on the WordPress Development blog that there are still many open tickets in WordPress 3.3 Beta 2. Poking around the trac report linked from that post, I found that ticket 18164 was still open.

This ticket has been around for some time but no one seemed to want to take it up. Network admins can add themselves to individual sites in a WordPress Network. They can also promote or demote themselves from the Network Admin screen. However, if they are in the User settings on an individual site’s Dashboard, they cannot demote themselves. They’ll get an error message now allowing them to do so because the new role does not have the “promote_users” capability. This makes sense for normal site admins. It would be disastrous if they lost admin access to their site through a misclick. Network admins can always give themselves admin access again through the Network Admin screen.

The fix seemed simple enough, the code just has to check that the user is not a super admin before giving the error message. My first attempt at a patch involved using current_user_can( 'manage_network' ). nacin responded very quickly and suggested using is_super_admin() instead. I updated the patch and submitted it again. In short order the ticket had been closed and set to fixed.

The actual code committed (Changeset 19024) is different from my original patch. The redundant brackets have been removed and the unnecessary user ID has been taken out from the function argument. However, this still marks my first contribution to the core code of an open source project 🙂

Advertisements

Adding Links

This should be an easy thing to do. I added a page and created an unordered list of links. Done!

While looking at the WordPress admin options, I noticed a section for Links. That seemed a much better way to insert links. After all, if the functionality is already built in, why write the HTML code manually?

The problem is that the collection of links only seem to be used by the built in Links widget. This will limit it to the sidebars, which isn’t what I want. I want the list to be displayed on a page.

The solution is the wp_list_bookmarks() function. Create a page template then insert that function into the template.

Create a page and set the Links template you just created as the page template. There’s no need to put anything in the content section. Populate the Links area and WordPress will do the rest.

Another advantage of this method is that the task of keeping the links list updated can now be passed over to a non technical user as the interface is pretty simple.