@apple4us typical "wolf's coming" for the gov has done 2 much evil. Hard 2 believe not related 2 them. Haha.

URL Rewriting for WordPress in IIS with wp_url_rewriting and patch

Thursday, May 5th, 2011

There are several ways to use URL rewriting for WordPress in IIS. I'm using wp_url_rewriting for my client. Recently, my client upgraded his WordPress to 3.1 which cause a problem that the page navigation does not work correctly.

Symptom: The page link in a category page, does not contain the category slug. Ex. in http://sampledomain/samplecate/, the page link should be http://sampledomain/samplecate/page/2, but it shows like http://sampledomain/page/2.

This does not happen on my Apache server. So I checked out wp_url_rewriting installation note and I found this:

3). Do a little hack to WordPress file ‘link-template.php’ to make paging works well for categories:(NOTE: You don’t need to do this step if you are using WordPress 2.3.0 or newer)

open file /wp-includes/link-template.php and find the following code:....

From 2.3.0 to 3.0.x, no need to do the hack. Since 3.1.0, it becomes a must again. The original hack does not working. It's been moved to another file. So do the hack as follows:

open file /wp-includes/functions.php and find following code:

  1. function add_query_arg() {
  2. $ret = '';
  3. if ( is_array( func_get_arg(0) ) ) {
  4. if ( @func_num_args() < 2 || false === @func_get_arg( 1 ) )
  5. $uri = $_SERVER['REQUEST_URI'];
  6. else
  7. $uri = @func_get_arg( 1 );
  8. } else {
  9. if ( @func_num_args() < 3 || false === @func_get_arg( 2 ) )
  10. $uri = $_SERVER['REQUEST_URI'];
  11. else
  12. $uri = @func_get_arg( 2 );
  13. }

Replace the $_SERVER['REQUEST_URI'] with $_SERVER['PATH_INFO']

Then wp_url_rewriting will work again.

BTW, after fixing this, I found some updates of ISAPI_Rewrite. The lite version could work well for WordPress. I used that before. I remember there were some limitations for the lite version. Since this article was written on Feb 17th, 2010. I guess it should work fine. If so, this could be a better solution for there's no hack needed.

 

Simplified Chinese Language Pack for NextGEN Gallery

Monday, April 13th, 2009

NextGEN Gallery in Chinese

NextGEN Gallery is a very powerful plugin for WordPress that can manage the photo easily. It has many features and provides multiple language support. I've just made the Simplified Chinese language pack for the current version. Download: Simplified Chinese Language Pack for NextGEN Gallery 1.21 1.33 1.43 1.52 1.55 1.60 1.72 1.73 1.81 1.83 1.91

(Following bug has been fixed after 1.21)

There is a bug in this version when using other languages which will result in a notice's translation can not be shown. It a very small issue but if you are completist you can fix it in this way: Open this file [NextGEN plugin folder]/lib/core.php and find out line 419.  Replace it with following code:

  1. $result = sprintf(  __( 'Note : Based on your server memory limit you should not upload larger images then <strong>%d x %d</strong> pixel', 'nggallery' ), $size['width'], $size['height']);

This notice appears in [Add Gallery / Images] -> [Upload a Zip-file] and similar pages. Well, in fact, there are two more bugs if you really want to fix... Open this file [NextGEN plugin folder]/admin/tinymce/window.php and find out line 29-30.  Replace them with following code:

  1. </span>
  2.  
  3. &nbsp;
  4.  
  5. <span style="text-decoration: line-through;">

Checkout what I did (very simple) with this wonderful plugin and know more about how to use it.

Custom Fields and Category Order in Atahualpa Theme

Tuesday, April 7th, 2009

Atahualpa theme for wordpress
Atahualpa
is a wonderful WordPress theme that can be customized with 200+ options. It can be use to build simple websites with a bunch of settings. I found that custom fields can not be displayed as it described. I'm not sure if it's a bug. I did some modifications and it works now. Here is how (For version 3.3.2):
Open /wp-content/themes/atahualpa332/functions/bfa_postinfo.php
Find line 10

  1. return get_post_meta($post->ID, $matches[1], TRUE);

Replace with the following lines

  1. ob_start(); the_ID(); $post_id = ob_get_contents(); ob_end_clean();
  2. return get_post_meta($post_id, $matches[1], TRUE);

I don't know why $post->ID can not get the post's id. And the way above is not efficient, but it works.
Now you can use the custom files with the tag %meta('fieldname')% in the theme options -> Post/Page Info Items.
I also would like to manually arrange the order of categories. This function is not built in. There are some plugins can make it happen. I'm using Category Order. Some modifications should be done in Atahualpa too.
Open /wp-content/themes/atahualpa332/functions/bfa_hor_cats.php
Find line 3

  1. $list_cat_string = wp_list_categories('orderby=' . $sort_order . '&order=' . $order . '&title_li=&depth=' . $levels . '&exclude=' . trim(str_replace(" ", "", $exclude)) . '&echo=0');

Replace with

  1. $list_cat_string = wp_list_categories('&title_li=&depth=' . $levels . '&exclude=' . trim(str_replace(" ", "", $exclude)) . '&echo=0');

This removes orderby, order parameters to meet the requirement of Category Order plugin.