The Widget Logic and is_home() solution

Sometimes you want to have a conditional widget to appear on your front page and your front page is not a blog as per your WordPress setup. Ok, you fire up Widget Logic, you checked wp_reset_query fix, you tried to include is_home() statement, does not work, you tried is_front_page (), same thing, you stuck.

You googled 1hr in a row and found many threads with similar problem, bad repeatability of the bug. But it exists! Your widget does not appear on front page! WTF!! I can tell you, there could be worse. In my case it appeared on OS X version of Safari, but never appeared on Windows browsers. You know – this is a clue, man!

Switch off your cache plugin and check your front page. If your widget is there – see, switch it back.
Hope I saved you some time ;-)

Testing micro-payments

What a tiny thing – Tinypass for WordPress, but it seems working only for standard setups. There are questions to this plugin yet to be answered.

UPD: Micropayment paywalls are not an option for me yet. I do not like one step in their workflow – user has to upload his money first and they do not give change.

/it seems TinyPass does not work for WP setups from directory other than root. Am I mistaken?/

How to add php mcrypt support on CentOS

The default php53 packages set on CentOS repo does not contain mcrypt support. To get this library working for your web server you can take one of two ways. Either build php53 mcrypt.so extension yourself, there is a short guide for that. Or go the lazy way:

1) Add EPEL repo to your repositories list.
2) Install the mcrypt module:

1
yum install php53-mcrypt.x86_64

3) Edit your php.ini, and add extension support

1
extension=mcrypt.so

4) Restart web server.

Mcrypt support is needed if you want to implement micro payments on your WordPress blog. Tinypass micro payments system is born to power micro stocks and self-hosted publishers.

Downgrading Lion back to Snow Leopard and back again

» For a bit tutorial how to downgrade Lion back to Snow Leopard OS X please mind that Snow Leopard install erases your partition. Backup before you do. A simple tip if you have enough space: repartition your drive, make 2nd partition for Snow Leopard, install it there. I had no space, so I had to restore user data from backup.

Since the office can’t longer bear Ready NAS NV+ hangs and network outages invoked by accidental Lion OS X “casts of death”, I am forced to downgrade Lion. And it is indeed painful.

I urge everyone not to use a machine “updated” to Lion together with ReadyNAS NV+ in one network. Even with 4.1.8 software it has severe problems. For now there is no 100% cure.

UPD: Fresh Lion install from scratch was painful as well, but it seems solved the problem. Something evil still lurks, however, in printing drivers for HP and Samsung. Unfortunately I lack knowledge to debug their tricks.

UPD2: Yay! @chirpah pointed right. Enabling jumbo frames on ReadyNAS NV+ solved the puzzle.

How to force Spotlight search to index PHP files

Besides many other problems in Lion OS X, this one bugged me especially hard. After upgrading the main workstation to Lion I made a very unpleasant discovery. Spotlight was not able to search within source code. A relevant mdi plugin, that was shipped with the previous version of Xcode mysteriously vanished. Yes, it became unavailable.

But fortunately, you still have RichText.mdimporter and you can modify its info.plist to do the job of indexing contents of your source code files on Lion OS X. How to do that.

1) Locate /System/Library/Spotlight and the RichText.mdimporter file.
2) The easiest way – Terminal

1
sudo nano /System/Library/Spotlight/RichText.mdimporter/Contents/Info.plist

3) Add strings for text file types you want to index in Apple UTI notation into dict array, like:
For PHP source files:

1
<string>public.php-script</string>

For JS source files:

1
<string>com.netscape.javascript-source</string>

And so on in the fashion of Apple Uniform Type Identifyers (UTI).
Here is a small list of UTI you may need.
And here is what Apple has to say about UTIs.
Save what you have edited.
3) Reindex your hard drive and enjoy your Spotlight search back again.

WP 3.3.1 Custom Post Types does not work?

After upgrade to 3.3.1 certain users may experience problems with their custom post type posts. If you experience 404 on every request to your old CPTs, go to General/Settings/Permalinks once. If your .htaccess file is writeable by server – that’ll be enough. WP will flush your permalinks and CPTs will be back again. If not – check whether .htaccess file in your WP root directory is writeable.
Also if you face problem like errors with reference to get_data(), it is quite possible that your theme is using RSS parsing somewhere. Remove the theme temporarily, allow WP 3.3.1 to upgrade database, return theme back, it should work now.

Consequences of using SEO software

If you are going to decide about using some SEO software for your projects, keep in mind that this “solution” has its dark sides. One of the most annoying drawbacks of using SEO software is that you shall almost immediately start to receive SEO spam to your clients mailboxes.

So think twice before going into any SEO “automation”. What this automation is designed for is to generate business for SEO software companies, not for you. And if you think deeper, you will find all that “solutions” useless.

If you are about doing SEO, do it by providing good content organised in a logical and consistent way, keeping a formidable structure of your links. Search engines will love you.

Also consider reading Yoast.

mDNSResponder problems and solution on Lion

If you have ReadyNAS NV+ in your network with 4.1.8 software installed, you may have server outages if you use OS X Lion machine. The outage is caused by poor new design of the mDNSResponder (Apple fault thinks different as always). Multicasts from Lion machine force avahi daemon on ReadyNAS NV+ to close services. Disabling Bonjour on ReadyNAS will not help. To fix the issue you have to disable multicast edit /etc/hosts on a Lion machine.

/I am leaving this as advice for those who wants to debug their network with Lion machines in it/

Be careful, since breaking mDNSResponder configuration can lock you out from OSX Lion.
Step 1. Make a backup of the mDNSResponder.plist file as a necessary precaution.
Step 2. Open the mDNSResponder.plist file in Terminal using your preferred text editor. Here is a command:
sudo nano /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
Step 3. Add “-NoMulticastAdvertisements” to the array in the “ProgramArguments” section.

The bad thing is that you will loose ability to discover network printers from Lion, if they are advertised via Bonjour service. Workaround – set printers by IP manually.

UPDATE: it “works as designed”. What Apple forgot to say is well put in this article by Justin Carmony. I reenabled multicasts and Bonjour after adding reverse resolution in /etc/hosts for local machines running Lion. So far so good, ReadyNAS NV+ feels good for the first 30 mins ;-)

Enable WordPress Update from SSH

There are few good tuts that works for CentOS 5.6 with php53.
Jacob from dynamichosting.biz wrote a good guide to install ssh2 extension for php53 that worked for me.
Than follow these directions provided by Johnathan Dingman.
After you succeed with install, have a look at this Codex Page and make amendments to your wp-config.file to perform further updates with a single click.
All credit goes to these fine gentlemen mentioned above. I will only remind you not to be afraid of a bunch of warnings when you install php-pear. Force install and may the Force be with you.