Archives

Archive for July, 2011

Jul 25th

WordPress: The plugin generated 1 characters of unexpected output

2011
No comments | 1938 views

Sometimes, when you activate a plugin in the admin panel, you may see an error message like this:

The plugin generated 1 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

This is usually caused by additional white spaces or empty lines at the beginning and/or end in one of the plugin's PHP files. PHP files should start with the <?php tag in line 1 column 1 and end with a ?> on the very last line. Additional empty lines before the starting- or after the closing tag can cause this (basically harmless) error.

Read more...

Like

Jul 20th

JavaScript – $(document).ready() without jQuery

2011
2 comments | 3322 views

Everyone who has been using jQuery knows the purpose and how to use the jQuery(document).ready() function. But what if you want or need to implement such a construct without jQuery (for whatever reason, one  would be to avoid the jQuery overhead if all you really need is the ready() handler?

One would think it's as simple as using a onload event, just like:

<body onload="myReadyHandler();">

But it is not. There is an important and significant difference between onload and document.ready():

Read more...

1 Like Like

Jul 19th

No excerpt for pages in WordPress?

2011
No comments | 3113 views


Pages do not offer manual excerpts by default

So, I wanted to add a small modification to my WordPress theme to use the (manual) excerpt as a meta-description tag and found out that there is no way to set the excerpt for pages but only for posts. Really? I found that hard to believe.

The truth is that pages can have excerpts, but they are disabled by default for some unknown reason. I'm sure there is even a valid reason, but I still want to use excerpts for pages.

The solution is actually a one-liner and can be added to any theme.

Read more...

2 Likes Like
Tags: ,

Jul 16th

JavaScript – why simulating a click using the click() method doesn’t work in Chrome

2011
2 comments | 2245 views

Chrome doesn't allow simulating a click using the click() method.

While working on some WordPress plugin to enhance the comment system with a couple of Ajax features, i ran into a problem. My code was using the click() method on a link object to simulate a click on this link and while this did work fine in Opera, Firefox and Internet Explorer, it did not so in Google Chrome. Now, I know using click() is a bad thing and there is almost always a better way but in this specific case, there wasn't so I had to find a solution.

The reason why Chrome doesn't allow this is most likely related to its security model and I think it does it on purpose which is all fine, because  such functionality is rarely, if ever, needed.

Read more...

4 Likes Like