Big forms and PHP max_input_vars

Recently I was working in WordPress to create a big menu, with over 75 links in it. When I created it and tried to save it got save only partially, few menu items at the end got truncated. I was not sure what happened. So then I tried to add 1 more link and it was not saving. Then I decided to check if there were any PHP errors. I found the following in the error logs:

PHP Warning: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0, referer: http://mysite.com/wp-admin/nav-menus.php

Then I found out that there is a PHP setting “max_input_vars” (available since PHP 5.3.9) which limits the number of variables that PHP will process. If this value is 1000 (default is 1000) PHP will process first 1000 variables and drop the remaining. This was the reason why some menu items were saved and some not.
Read more »

How to change WordPress username

By default when you install WordPress, the username is “admin”. If someone is trying to hack into your site the first username they would try is “admin”, and if you use “admin” all they have to now do is guess your password. So, it is highly recommended that you never use “admin” as the username used to login into WordPress. You can choose a different username while first installing WordPress. However, you cannot change your username once created.

You can change the username by running queries in the database or use different plugins for it. However, there is a much simpler way to change your username. In this post lets see how we can change the “admin” username (you can use similar steps for any other username).
Read more »

How to hide apache information with ServerTokens and ServerSignature directives

In default Apache configuration, the server sends HTTP Header with the information of Apache version, modules, Operating System, etc of the Server. The HTTP response header “Server” displays all these details of the server. This information can be used by hackers to try to exploit any vulnerabilities in the Apache, OS or other modules you are running, specially if you are running an older version with known vulnerabilities.

Sample HTTP Response Header:

HTTP/1.1 200 OK
Date: Sun, 10 Feb 2012 07:24:47 GMT
Server: Apache/2.2.17 (Win32) PHP/5.2.17
Vary: Accept-Encoding,Cookie

Read more »

How to get size of BLOB in MySQL

Recently I wanted to get the size of the data stored in the BLOB field of a MySQL table. BLOB is a field which can be used to store variable amount of data. There is a simple MySQL String function, to find the size of BLOB data, OCTET_LENGTH. This function returns the length of BLOB in bytes. You can also use LENGTH function, because OCTET_LENGTH is synonym for LENGTH.

Sample usage:
Suppose in a table test_blob, there is a BLOB column (blob_content). We want to find the length of the BLOB field where id = 1.

SELECT OCTET_LENGTH(blob_content) FROM test_blob WHERE id = 1
I prefer to use OCTET_LENGTH, instead of LENGTH because the function name implies that I would get the result in terms of bytes and not characters.
Related Link:

How to add CSS classes to WordPress menu item

Recently I wanted to add some customization to some of my menu items. So I decided to add a CSS class to those particular menu items. I could modify my theme code and add some custom functions to do that. However, I first decided to explore the WordPress options and see if there was already some thing built in to do this. I found that there is an easy way to do this. This is normally a hidden option and in this post I will tell you how we can easily do that.

How to add CSS classes to WordPress menu item
1. Go to Appearance -> Menus in your sidebar
2. On the top right of the screen click the “Screen Options” tab
3. Check the “CSS Classes” option in the Screen Options tab. You don’t need to save, the changes will be visible immediately
4. Add or open up the menu item you wish to add the CSS Classes to. Now you will see a field that says “CSS Classes (optional)”. Add the CSS classes there
5. Click “Save Menu” to save your changes

These steps should work with WordPress 3.0+.

Follow

Get every new post delivered to your Inbox

Join other followers:

%d bloggers like this: