Archive for the 'wordpress misc' Category

How to reset a wordpress 2.5 password when you can’t get emails

If you are using a good non trivial password for your wordpress blog, then it is very likely that at some point in time you will forget it. This is not a real issue as long as you can go to your login page and request that a new password will be generated and sent to your e-mail account, but sometimes you either don’t have access to your mail, or the server is not configured to send mails. If you are in this unfortunate situation you need a method to bypass the normal wordpress password administration procedures.

For pre-2.5 wordpress versions, all you needed is an access to your server’s phpmyadmin, and you could follow the simple instructions at devlounge to reset your password. Since the 2.5 the method in which passwords are being hashed when stored at the database had changed, and the hashing is no longer a simple MD5. More then that, the hashing function is now pluggable (can be overridden by a plugin) which means that there is no more a uniform way to calculate the hash results as was described at the devlounge article.

The following script pass-calc solves this problem by calculating a password hash using the relevant functions from your wordpress installation. All you have to do is download the script, install it at your wordpress root directory, and run it by navigating to {your wordpress url}/calc-pass.php.

The script will ask you to enter the new password, and will generate an hash code for it. This hash code should be stored at your database by following the same instructions described in the devlounge article.

The script intentionally does only the calculation and do not update the database as this can be a security breach.

Style information should be at the top, javascript at the bottom

The reason for having style information on top and javascript at the bottom has nothing to do with wordpress but everything to do with the way browsers are rendering the HTML page and the resulting user experience.

The browser tries to show activity as early as possible, and starts to draw the page almost immediately after the page was loaded. The drawing is based on the styling information available at the the time the element is being drawn. If a style information is read after the drawing process has started, the browser has to find all of the elements which might be affected by the new style and redraw them. The best thing to do is to give the style information a head start, and put it as close to the top of the page.

In terms of the wordpress plugin API it means that style information should be inserted at the wp_hook

function style() {
  echo " <style>p {color:red}</style>";
}

add_action('wp_head','style');

Javascript code may alter the structure of the page while it is being loaded (with the document.write function for example), but since the changes can have a bigger impact, the browser actually stop everything it does while a javascript code is being parsed and executed. If this happens while the page content is being rendered, for the user it feels like the page is loading slower. When the javascript is at the bottom of the file, it still takes the same amount of time for the page to load and the rendering to be completed, but since the page is rendered earlier the user feels as if the page was loaded faster, even if the progress indicator on the browser’s status bar had not reached its “complete” status.

In terms of the wordpress plugin API it means that javascript should be inserted at the wp_footer

function js() {
  echo " <script>var author="mark";</script>";
}

add_action('wp_footer','js');

Based on information from yslow related articles.

A fix for the kubrick theme no bullets with IE 6 or 7 bug

The reason for the bug is that the kubric theme generates list bullets by using a property (”before”) which is part of the CSS 2.1 standard which is not implemented by the IE 6 and IE 7 browsers.

One way to fix this problem is by specifying a different source for the bullet and using the IE conditional comments feature to specify it only for the IE browsers.

This is the code I’m using

<!–[if lte IE 7]>
<style type=”text/css” media=”screen”>
html > body .entry ul {
list-style: circle;
}
#sidebar ul li.page_item {
list-style: circle inside;
}
</style>
<![endif]–>