No public Twitter messages.

Archive for the ‘WordPress’ Category

WordPress auto upgrade in Mac local environment

Saturday, April 17th, 2010

When I test WordPress in local Mac OS X, the auto upgrade function is not available. It shows up like below:

Connection info needed

Here describes reasons and solution. But it doesn't work in my situation: Using XAMPP to set up the testing environment. Another solution were provided in comment 44 by Johan L. It works alright!

Do as follows:

 

To set up file ownership correctly:
In WP root directory
chown -R yourusername:apachegroupname *
In my case...
chown -R johan:apache *

find . -type d -exec chmod 770 {} ';'
find . -type f -exec chmod 660 {} ';'

WP 2.8: add
define('FS_METHOD', 'direct');
define('WP_TEMP_DIR', ABSPATH.'wp-content/tmp');
in wp-config.php
The function in file.php reads FS_METHOD and the tmp file creation test is never executed.
Make sure the wp-content/tmp directory exists and is writable by the apache user

Pre WP 2.8: well... you may need to patch the function in file.php by removing the if statement before $method='direct';
see comment #38 above
Only do this if you're sure you've setup file ownership correctly.

BTW the three numbers in chmod describe rights for "user", "group" and "others". read==4, write==2, execute==1. Sum of rights make up the number. Hence 777 means read, write and execute for user, group and others. 660 means read and write for user and group, no rights for others.

NEVER do a chmod 777 on any file or directory. NEVER recommend anyone to do it either!

Note that it's better to upgrade to 2.8 and above first.

The key is the two lines in wp-config.php.

Thanks Johan L.

PuSHPress

Thursday, March 4th, 2010

Just installed this new plugin. Try if it works well.

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

(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. </strike></p>
  2. <p>&nbsp;</p>
  3. <p><strike>

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

Coding standards

Monday, April 13th, 2009

For a beginner of programing, it's a good habit of writing codes in standard format. There are different rules in different companies/teams. Better than form your own, follow a standard of a popular application could be easier and more acceptable by people. For example, the WordPress Coding Standards and Inline Documentation.
Some good approach I just learned from it:

  • When doing logical comparisons always put the variable on the right side.
    I saw this in some codes, now I know why: If you forget an equal sign it'll throw a parse error instead of just evaluating true and executing the statement. It really takes no extra time to do, so if this saves one bug it's worth it.
  • Use real tabs and not spaces, as this allows the most flexibility across clients.
    In some courses, it's suggested that using spaces instead of tabs. Either of they has their reasons. As mentioned above, using the standards of popular applications could be better. And I have already had the habit of using tabs, so I just follow WordPress here.
  • Tabs should be used at the beginning of the line and spaces should be used mid-line.
    Exception for previous point: if you have a block of code that would be more readable if things aligned, use spaces.
  • Ternary operators are fine, but always have them test if the statement is true, not false. Otherwise it just gets confusing.
    1. // GOOD example:
    2. // (if statement is true) ? (do this) : (if false, do this);
    3. $musictype = ( 'jazz' == $music ) ? 'cool' : 'blah';