Rename Publish button in WordPress admin

There are scenarios where you want the WordPress Admin to behave differently, specially for the custom post types. Imagine you have custom post type called ‘contacts’ and you want to change the button from PUBLISH to SAVE. So how to achieve this without changing the core files?

Add the following code to your functions.php:

Note: Make sure you make a copy of your function.php before placing the code. Just incase if you break something you can always bring it back.

Happy Coding 🙂

How To Fix Incorrect Post Comment Counts In WordPress

If your WordPress comment counts got messed up, whether because of a plugin or you messed with your database manually and did something wrong, then there is always a solution for this 🙂

Comment Counts In WordPress

Here’s how comment counts work in WP:

  • Posts live in a table called wp_posts and each has an ID.
  • Comments reside in a table called wp_comments, each referring to an ID in wp_posts.
  • However, to make queries faster, the comment count is also cached in the wp_posts table, rather than getting calculated on every page load.

If this count ever gets out of sync with the actual number of comments for some reason, WordPress, while still displaying all comments properly, will simply show the wrong count.

How To Find Out Which Posts Are Out Of Sync

Fire up a MySQL shell or your favorite MySQL software and run this query.

It assumes your database is called wordpress and the prefix is wp_, so adjust those accordingly.

The result of this query is a list of posts whose comment_counts differ from the actual number of comments associated with each of them.

The left count is the cached number, while the right one is the right one.

How To Fix The Counts Automatically

Please make a backup of your database before performing any altering queries such as the one below.

The following query will recalculate and fix the comment counts for all posts that are out of sync (ones we just queried for above):

This will fix all your issues regarding comment count for sure.


Happy Coding 🙂

How to Remove Ads in Skype On Windows

When using Skype the other day I noticed a new ad placement that hadn’t been there before. Of course I found it annoying and wanted to get rid of it. Here’s how to get rid of that top banner ad in Skype by following some simple steps.

For Skype 7.x Only :

Step 1: Head to the Control Panel and click on Internet Options. This settings area may be hidden under Network and Sharing Center if you don’t see a direct shortcut for it.


Step 2: Click on the Security tab and select the Restricted Sites icon.

Step 3: Press the Sites button and add the following sites to block the ads.


Step 4: Head to C:\users\[your user name]\App Data\Roaming\Skype\[your Skype username]. You should see a config.xml file in this directory. Right-click it and choose Edit, then find the line that says <AdvertPlaceholder> and delete the entire line. Make sure to save your changes to the file before exiting. You can use Ctrl+F to find the line quickly.

Note: If you do not see the App Data folder, it’s probably because you don’t have Show hidden files enabled. Click the Organize button > Folder and search options > View tab > mark the radio button next to Show hidden files, folders, or drives.

Now your chat window and video conferences will be free of advertisements.

Delete Orphaned Meta Data in WordPress

Delete Post Meta Data

Sometimes while developing a new plugin you have to do lots of database work including creating posts, editing posts, and deleting posts. All of these actions affect the post meta data table and if you aren’t careful with how to manage the post meta data you’ll have thousands and thousands of rows of data. By deleting orphaned post meta data (meta data belonging to posts which no longer exist) you immediately remove thousands of records that weren’t doing anything.

Delete User Meta Data

Source :

Happy Coding 🙂

How To Add Custom Rewrite Rules In WordPress

WordPress rewrite API used to convert URLs from something programmatically convenient to something user and search engine friendly. This article will give you some background information about WordPress URL rewriting principles and API.

What Is Rewriting?

URL rewriting is when you change what content is displayed by the server, normally when you type in a URL the web server will simply search for any files in that location. But with rewriting you can still show the same URL but in the back-end change where the server will look for the content. Therefore we can have a URL of /website-1 but tell the server to display content that is located in /website-1/content/index.php

How WordPress Uses Rewrite For Custom URLs?

When you go to Settings -> Permalinks, you will need to select how you want your URLs to appear on WordPress. You have many different options to choose from the default WordPress will use is ?p={post_id}, this is the value that is stored in the wp_posts table and what the rewrite API will write to, when it wants to display the post data.

When you select a new permalink structure WordPress will store these rules in the wp_options table so it will know how to search the post table for the correct post. This means that we can have URLs with just the post title in them and WordPress will know that it needs to search on the post_name column to find the correct post to display.

WordPress Rewrite API

Imagine you need to integrate custom page in which you can list your products. How can we do this?..First we need to create a new rewrite rule so wordpress can translate to We can use add_rewrite_rule() function which accepts 3 parameters. The first parameter is the URL pattern. The second parameter is the URL replacement and the third parameter is the priority. Let’s explore how to create this rule.

Catching the query variables

Using with plugin Activation and Deactivation

Copy Blog 🙂

Disable Update WordPress nags with Plugin’s and Theme’s Update Notifications

1. To Disable Update WordPress nag :

Insert the following code to the functions.php file of your active theme. It will remove the WordPress update nag e.g. WordPress 3.9.1 is available! Please update now, from the all users dashboard, admin dashboard & from Updates page as well.

2. To Disable Plugin Update Notifications :

Insert the following code to the functions.php file of your active theme. It will remove the update notifications of all the installed plugins.

3. To Disable all the Nags & Notifications :

Insert the following code the functions.php file of your active theme. This code disables all the updates notifications regarding plugins, themes & WordPress completely.

Test Credit Card Account Numbers

Credit card numbers are not random. They can be checked by a mathematical formula for validity. Each kind of credit card uses a slightly different rule.

This sample form checks credit cards for validity, so you must enter a valid credit card number. While testing, only use the credit card numbers listed here. Other numbers produce an error.

Expiration Date must be a valid date in the future (use the mmyy format).

Test Credit Card Account Numbers

Credit Card Type

Credit Card Number

American Express


American Express


American Express Corporate


Australian BankCard


Diners Club


Diners Club




















Note : Even though this number has a different character count than the other test numbers, it is the correct and functional number.

Processor-specific Cards

Dankort (PBS)


Dankort (PBS)


Switch/Solo (Paymentech)


How To Install LAMP on Ubuntu

About LAMP

LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. Since the virtual private server is already running Ubuntu, the linux part is taken care of. Here is how to install the rest.

First things first: update

LAMP Stack (Apache, Mysql, PHP)

This will install the LAMP stack in one command




Want a more recent version of PHP 5 for Ubuntu? Then use the PPA for PHP5 offered by Ondřej Surý. PHP 5.4+

PHP 5.5+ note: there are significant differences between PHP 5.4. and PHP 5.5!

PHP 7.0 (prior to Ubuntu 16.04)


NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server.

NGINX doesn’t start on its own, so:

Learn about configuring NGINX as a front-end proxy with Apache


phpMyAdmin allows you to manage your MySQL Database via web browser.

Choose Apache and then YES for dbconfig-common. If you ever need to edit phpMyAdmin config:


Webmin is an open-source server management tool much like cPanel.

Scroll to the bottom and paste the following lines then save:

Import the key

Update the sources list

Run the install

Start Webmin

When it’s finished, open Firefox or Chrome and type:

If you’ve installed a fresh copy of Ubuntu (or if you don’t know your password) you can set a new one:

You’ll be prompted to enter your new password twice. Now, you can login to Webmin.


ProFTPd is a high-performance FTP server.

(I always select “standalone”) Turn on Passive FTP via Webmin: Servers –> ProFTPD server –> Virtual Servers –> Default Server –> Networking Options


PostFix Mail

Select “Internet Site” and then enter the domain name you want the Reverse DNS entry to be. BTW: To avoid your server being blacklisted, get a reverse DNS entry!

Alternative PHP Cache (APC)

APC is a PHP opcode cacher and works by caching PHP objects, functions, and database queries into your server’s RAM. If you run a WordPress website – then it takes full advantage of APC out-of-the-box. See my post on The Perfect APC Configuration Note, APC is no longer available in PHP 5.5+ as it’s now called OPCACHE.

By default, Ubuntu will install this from a repository which has an outdated version. To install the latest version of APC:

Uninstall APC


Memcached is a high-performance, distributed memory object caching system. However, it can work together with multiple servers (unlike APC).

Check to see if Memcached is running


Fail2Ban scans log files (e.g. /var/log/apache/error_log) and automatically bans IPs that show malicious signs for exploits.


RSYNC is a open source utility that provides fast incremental file transfer.

Server-to-server transfers with RSYNC


ImageMagick is a software suite to create, edit, compose, or convert bitmap images.


Icecast is a streaming audio server. If you ever wanted to have your own web radio station (like Shoutcast) this is the software.

Configure Icecast2. Mainly, setting up your passwords and default port.

Enable init.d script. Scroll to the bottom and change enable=true

Start icecast2

If you left the default port as 8000 then you can view your Icecast2 Server


Munin is a networked resource monitoring tool that can help analyze resource trends and “what just happened to kill our performance?” problems.

Now, this is a single server setup, so let’s install munin and munin-node

Configure Munin:

The first thing you should see is the operating directories. We need to change one of them:


Now let’s edit apache.conf

Delete everything inside apache.conf  and just add:

Move the web files to /var/www/munin

Set permissions

Restart Munin

Finally, restart Apache


Cacti graphical server monitor provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box.

Choose YES for dbconfig-common and Apache2. When finished you need to configure:

Default user & pass: admin / admin Remove cacti


bmon is a bandwidth monitor capable of retrieving statistics from various input modules.

When it’s finished installing:

Zip and Unzip

In my experience ZIP is great for creating archives for sharing via email or ftp. It’s a universal format that almost everyone can open. I would NOT use ZIP for file backups. For large backups, see 7ZIP or TAR below.

Zip up a folder:

Unzip (extract) an archive:


7ZIP is a very popular archiving program with excellent compression. Plus, it’s open source and supports multiple operating systems.

Create an archive

Extract an archive

TAR (Tape Archive)

TAR –  is the prefered way to handle file backups. I’ve read, the maximum allowed file size only depends on your hard drive. A disk formatted with FAT32 for example, only allows 2GB. You can also compress TAR using GZIP or BZ2.

GZIP – good compression, is very fast. Note: .tar.gz and .tgz are the same:

BZ2 – excellent compression, but slower. I find BZ2 works best if you’re archiving a smaller directory. Note: .tar.bz2 and .tbz are the same:

Untar (extract) an archive and if tarball already contains a directory name, strip it:

If you want to tarball the directory you’re currently in, with say, gzip:

Other handy commands:

View all running services

Restart PHP 7.0

Move files from one directory to another

Copy files from one directory to another

Set the server timezone

Add a user to the list of sudoers (you have to be logged in as root, or now the sudo password)

Download files

Server-to-server transfers with SCP

Server-to-server transfer with SCP into the current directory (Read more about SCP)

List size of directories

Set a password

Edit PHP.ini

Restart Apache

Set Recursive Permissions for your websites directory

Block IP address using IPTABLES

Single IP

IP Range

You can also manage IPTABLES (e.g., the linux firewall) via Webmin under Networking -> Linux Firewall

Manage packages

Remove LAMP

Happy Coding 🙂

Valid US Address for Developer Testing.

Many street addresses include a direction (e.g. E = EAST):

An example with the optional latter 4 digits of the zip code:

With an apartment/suite/etc. number (which many addresses don’t have):

If you don’t have room for the apartment/suite/etc. number on the street address line:

Many different terms for street type, or abbreviations for them, might follow the street name.

“PO Box” and “POB” are two valid ways of saying “Post Office Box.”

Some variants exist. In certain regions, some addresses have a direction after the street name.

If an address has two conflicting lines, such as a post office box line and a street address line, the lower line will normally be used if mail can be delivered to that address. Most often conflicting lines are not used.

How To Set Up Apache Virtual Host on Ubuntu


Before you begin this tutorial, you need to have Apache installed in order to work through these steps. If you haven’t already done so, you can get Apache installed on your server through apt-get:

After these steps are complete, we can get started.

For the purposes of this guide, my configuration will make a virtual host for This will be referenced throughout the guide, but you should substitute your own domains or values while following along.

I will show how to edit your local hosts file later on to test the configuration if you are using dummy values. This will allow you to test your configuration from your home computer, even though your content won’t be available through the domain name to other visitors.

Step One — Create the Directory Structure

The first step that we are going to take is to make a directory structure that will hold the site data that we will be serving to visitors.

Our document root (the top-level directory that Apache looks at to find content to serve) will be set to individual directories under the /var/www directory. We will create a directory here for the virtual host we plan on making.

Within this directory, we will create a public_html file that will hold our actual files. This gives us some flexibility in our hosting.

For instance, for our site, we’re going to make our directory like this:

Step Two — Grant Permissions

Now we have the directory structure for our files, but they are owned by our root user. If we want our regular user to be able to modify files in our web directory, we can change the ownership by doing this:

The $USER variable will take the value of the user you are currently logged in as when you press “ENTER”. By doing this, our regular user now owns the public_html subdirectory where we will be storing our content.
We should also modify our permissions a little bit to ensure that read access is permitted to the general web directory and all of the files and folders it contains so that pages can be served correctly:

Your web server should now have the permissions it needs to serve content, and your user should be able to create content within the necessary folders.

Step Three — Create Demo Pages for Each Virtual Host

We have our directory structure in place. Let’s create some content to serve.

We’re just going for a demonstration, so our page will be very simple. We’re just going to make anindex.php page for this site.

Let’s start with We can open up an index.php file in our editor by typing:

In this file, we will put a simple statement that indicates the site it is connected to. My file looks like this:

Save and close the file when you are finished. You now have the page necessary to test the virtual host.

Step Four — Create New Virtual Host Files

Virtual host files are the files that specify the actual configuration of our virtual hosts and dictate how the Apache web server will respond to various domain requests.

Apache comes with a default virtual host file called 000-default.conf that we can use as a jumping off point. We are going to copy it over to create a virtual host file for our domain.

The default Ubuntu configuration requires that each virtual host file end in .conf.

Create the First Virtual Host File

Start by copying the file for the domain:

Open the new file in your editor with root privileges:

The file will look something like this (I’ve removed the comments here to make the file more approachable):

As you can see, there’s not much here. We will customize the items here for our first domain and add some additional directives. This virtual host section matches any requests that are made on port 80, the default HTTP port.

First, we need to change the ServerAdmin directive to an email that the site administrator can receive emails through.

After this, we need to add two directives. The first, called ServerName, establishes the base domain that should match for this virtual host definition. This will most likely be your domain. The second, calledServerAlias, defines further names that should match as if they were the base name. This is useful for matching hosts you defined, like www:

The only other thing we need to change for a basic virtual host file is the location of the document root for this domain. We already created the directory we need, so we just need to alter the DocumentRootdirective to reflect the directory we created:

In total, our virtualhost file should look like this:

Save and close the file.

Step Five — Enable the New Virtual Host Files

Now that we have created our virtual host file, we must enable that. Apache includes some tools that allow us to do this.

We can use the a2ensite tool to enable our site like this:

When you are finished, you need to restart Apache to make these changes take effect:

You will most likely receive a message saying something similar to:

This is a harmless message that does not affect our site.

<h2 “>Step Six — Set Up Local Hosts File (Optional)

If you haven’t been using actual domain names that you own to test this procedure and have been using some example domains instead, you can at least test the functionality of this process by temporarily modifying the hosts file on your local computer.

This will intercept any requests for the domains that you configured and point them to your VPS server, just as the DNS system would do if you were using registered domains. This will only work from your computer though, and is simply useful for testing purposes.

Make sure you are operating on your local computer for these steps and not your VPS server. You will need to know the computer’s administrative password or otherwise be a member of the administrative group.

If you are on a Mac or Linux computer, edit your local file with administrative privileges by typing:

If you are on a Windows machine, you can find instructions on altering your hosts file here.

The details that you need to add are the public IP address of your VPS server followed by the domain you want to use to reach that VPS.

For the domains that I used in this guide, assuming that my VPS IP address is, I could add the following lines to the bottom of my hosts file:

This will direct any requests for on our computer and send them to our server at This is what we want if we are not actually the owners of these domains in order to test our virtual hosts.

Save and close the file.

Step Seven — Test your Results

Now that you have your virtual host configured, you can test your setup easily by going to the domains that you configured in your web browser:

You should see a page that looks like this:



If this site works well, you’ve successfully configured the virtual host on the same server.

If you adjusted your home computer’s hosts file, you may want to delete the lines you added now that you verified that your configuration works. This will prevent your hosts file from being filled with entries that are not actually necessary.


If you followed along, you should now have a single server handling two separate domain names. You can expand this process by following the steps we outlined above to make additional virtual hosts.

There is no software limit on the number of domain names Apache can handle, so feel free to make as many as your server is capable of handling.