How to Increase WordPress Menu Items Limit

If you are going to add too many menu items in your WordPress then beware, on saving your menu you will lost menu items that are beyond WordPress menu items limit. This thing had happened to us and we did a lot of extra work to add those menu items again but only after increasing this limit.

This limit is not imposed by WordPress but by your web hosting server because of some security reasons. In PHP, there is a thing called post vars that controls menu items. By default maximum post vars are much limited as most of the websites require only a few menu items.

First Method

Increasing max_input_vars

To increase input_vars add the following code in your php.ini file

max_input_vars = 3000;

Note – Create a text file name php.ini and add this code to that file and place this file in your WordPress root. If your host doesn’t support custom php.ini file get their support to add this code to php.ini file.

Second method

1.Add php.ini in wp-admin folder

Create a php.ini file with the below given code and put it into wp-admin folder

max_input_vars = 3000;

2.Add .user.ini file

Create a file .user.ini and add the following code to it and try placing it in WordPress root or in wp-admin folder;

max_input_vars = 5000;

Hopefully one of the method should work for you.

How to get Controller, Action, URL informations with CodeIgniter

I have these urls:

How to get controller name, action name from these urls. I’m codeigniter newbie. Are there any helper function to get this info.

You could use the URI Class:

$this->uri->segment(n); // n=1 for controller, n=2 for method, etc

There is an optional second parameter that permits you to set your own default value if the segment is missing. For example, we could use

 $controllerName = $this->uri->segment(1, 'magazine');  

I’ve also been told that the following work, but am currently unable to test:


Remove directory and all its content in PHP

To recursively delete all the contents in the directory and then the directory itself. This function checks for files and sub directories and delete them first before deleting the main folder.

$directory      = "uploads";
function recursiveRemoveDirectory($directory) {
    foreach(glob("{$directory}/*") as $file) {
        if(is_dir($file)) {
        } else {

Unzip a Zip File in PHP

Here is the code to unzip a Zip file using php and store it to another location.

function unzip($location,$newLocation) {
	if(exec("unzip ".$location, $arr)) {
		for($i = 1; $i< count($arr); $i++){
			$file = trim(preg_replace("~inflating: ~","",$arr[$i]));
			copy($location.'/'.$file, $newLocation.'/'.$file);
		return TRUE;
	} else {
		return FALSE;

if( unzip('zipedfiles/', 'unziped/myNewZip') ) {
	echo 'Success!';
} else {
	echo 'Error';

Get Country By IP Address in PHP

How to Get Country By IP Address in PHP ?

Here is the simple solution to that.

function getLocationInfoByIp(){
	$client = @$_SERVER['HTTP_CLIENT_IP'];
	$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
	$remote = @$_SERVER['REMOTE_ADDR'];
	$result = array('country'=>'', 'city'=>'');
	if(filter_var($client, FILTER_VALIDATE_IP)){
		$ip = $client;
	}elseif(filter_var($forward, FILTER_VALIDATE_IP)){
		$ip = $forward;
		$ip = $remote;
	$ip_data = @json_decode(file_get_contents("".$ip));
	if($ip_data && $ip_data->geoplugin_countryName != null) {
		$result['country'] = $ip_data->geoplugin_countryCode;
		$result['city'] = $ip_data->geoplugin_city;
	return $result;
$result = getLocationInfoByIp();

echo $result['country']." -> ".$result['city'];

Output is

IN -> Ghaziabad