File Upload Failure

After migrating to a cheaper hosting plan, the site administrator complained that audio files could not be uploaded.

Checking phpinfo(), the upload limit was 4MB, and the php.ini file in the root directory no longer had any effect.

Searching on Google led me to this article.

The fcgi-bin folder is in the public_html folder. So far there is no effect, but the article said it may take up to an hour, so we’ll see.

Edit: Ran the kill command suggested in the article. There was one ‘No such process’ error while the others were ‘Operation not permitted’. Refreshing the PHP info page showed that the maximum upload size had been updated.

Could not Edit Menus

I was having an annoying issue where a site’s menus could not be edited through the WordPress admin interface. The menu structure would load but drag and drop simply refused to work even when the cursor changed to the 4-way move arrow.

Checking the console in Chrome’s web inspector revealed some sort of JavaScript problem. Changing the theme to a default one made the problem go away, thus the problem had to be with the custom theme.

I started debugging by commenting out the add_action() functions enqueuing some extra js files used for the jQuery accordion. That fixed it. Putting back the accordion init script revealed that it was not the problem, so that left the custom jQuery UI file, version 1.8.13.

The latest stable version is now 1.10.2, so I got that by selecting the accordion widget on jQuery UI’s download page, letting the other checkboxes auto populate. Extracted the file into the scripts folder, updated functions.php to point to the new file, and the menus admin page now works again!!

tl;dr
Update the jQuery UI file.

Single Digit Numbering in List

When creating an ordered list recently with more than 10 items, the numbers looked like they reset at 0 and only had one digit. I knew that the list was being generated correctly with 2 digits because the visual view in the post editor showed the proper numbers. It just wasn’t showing up in the actual post itself.

Using Chrome’s Developer tools, it looked like the margins for the ol element weren’t wide enough. This was set by the CSS in the parent theme. I added an entry to the child theme’s style.css to override the margin and increase the left margin to 2 em. Refreshed the page and the numbers came up correctly!

ol {
        margin: 0 0 18px 2em;
}

Public Cannot View Scheduled Posts

A user going by the name of drober started a thread on the Announcements Ticker forum complaining that non admin users were unable to view the full text of announcements by using the “Read All” link. On his site, they would be prompted to login, but non admin accounts still could not see the content.

This is because the plugin sees future posts as active announcements. This is by design so the announcement can automatically when expire when it reaches the scheduled date. However, WordPress does not allow non admin users to view future posts. This never showed up in testing because I always used a logged in admin account.

The fix was to hook into the one of the save_post actions and change the post status from future to publish if an announcement is saved. I also had to take out the condition that the plugin only selects future posts for display.

For the full discussion, see the forum support thread.

Theme Change

WordPress has just released 3.5 beta 1, and with it the Twenty Twelve theme. As this blog is about WordPress, it seems fitting to use it as the blog’s theme.

EDIT: Temporary change to a dark theme because of the falling snow feature :)

Custom Post Type Permalinks

After creating the custom post type in my plugin, I tried visiting domain.com/, but got a 404 error page instead.

I came across a blog post by Kovshenin which explains how to get permalinks working with custom post types. The key thing is to specify the slug with the ‘rewrite’ parameter when registering the CPT. After that, remember to reset the permalinks by visiting the permalinks settings page in Settings -> Permalinks. Quite a lot of 404 grief can be solved by doing so.

It makes sense to automate this in the plugin. To do so, I added flush_rewrite_rules() to the activation and deactivation hooks. This would ensure that the permalinks are reset only when the CPT becomes active or inactive.

Do not let the function run on every page load. It is very resource intensive and will slow your site down.

Follow

Get every new post delivered to your Inbox.