Importing SSH key into keychain on Mac

Importing an SSH key to your keychain on Mac allows you to login without entering your passphrase each time. This helps if you are a developer and require to commit your changes to the server quite frequently. Here are the steps If you have a Cpanel on your server, login to your CPanel Generate an SSH Key (choose a suitable passphrase while generating the key and make a note of it) Once the SSH Key is generated, Authorise the key Download Private and Public keys and copy both the keys to your ~/.ssh directory Change permissions on both keys, Remove staff, everyone no access, Admin read write Open terminal and run: ssh-add -K ~/.ssh/KEY_NAME When prompted enter passphrase used while creating the key ...
Read More

How to create extra widget/sidebar areas

Depending upon your theme you may have some predefined widget/sidebar areas like Left Sidebar, Right Sidebar. If you want to create a new sidebar area let's say for footer then you can add below code in your functions.php file Replace THEME_NAME with the name of your theme [crayon-59c672d351d12511013249/] Finally add below code in the theme where the sidebar needs to appear [crayon-59c672d351d1d963693404/]  ...
Read More

WordPress Security – Configuration / Installation

1. Wordpress security at the Configuration and installation level This section explains measures to be taken for achieving wordpress security while installing and configuring wordpress. 1.1 Change default table prefix Many published WordPress-specific SQL-injection attacks make the assumption that the tableprefix is wp, the default. Changing this can block at least some SQL injection attacks. 1.2 Securing wp-config.php Are you aware that wp-config.php can be stored one directory level above the WordPress installation? This is quite a simple task. Also, make sure that only you (and the web server) can read this file (it generally means a 400 or 440 permission). This file contains quite sensitive information like password, database user etc so it's very imp to protect this file 1.3 Disable File Editing through Wordpress Dashboard The WordPress Dashboard by default allows administrators to edit PHP files, such as plugin and theme files. This is often the first tool an attacker will use if able to login, since it allows code execution. WordPress has a constant to disable editing...
Read More

Create wordpress plugin for custom PHP code

Often there is requirement to create your own PHP application and generally most people tend to install a plugin which allows to run PHP code snippets as it is much easier to do so. Although this approach may seem ok it may not be ideal. Lot of times people use this approach because they do not know how to create plugin for the same in Wordpress. Actually it is much easier to create wordpress plugin than you think. I understand it may take a bit longer to create a plugin than just writing a PHP code snippet. However the difference is not that big. Creating your own Wordpress plugin for your requirement works out better in the long run It allows you to deactivate as soon as you feel you do not need the code to run on your site You are in total control of the code. If the PHP plugin which allows you to run your PHP code snippets stops providing support or is no longer...
Read More

Geocoding an address using Google Maps PHP API

Geocoding address means finding Latitude and Longitude for physical address. This uses Google Maps PHP API. E.g. Let’s assume we need to plot some events happening in various locations on Google Maps Geocoding all events to find their latitude and longitude using below function [crayon-59c672d352d67079635373/] If the address provided is in a way google can understand, the above function returns $data_arr in array format where latitude => $data_arr[0] longitude => $data_arr[1]...
Read More

WordPress – How to disable dashboard access to subscribers

For security reasons you may wish to disable dashboard access to subscribers and allow access to only Admins, Editors and Authors. Below is a simple snippet of code to achieve this. Add below code in your theme's functions.php file [crayon-59c672d35345f291297421/] The above code will redirect the user to your home page when the user tries to visit the Dashboard. However in some cases you may want a certain subscriber to access Dashboard. In that case I have created a capability called as dashboard_access. This capability can be assigned to the required user....
Read More

WordPress – Limit pages displayed in the parent page drop down

If you have lot of pages in your wordpress site then it becomes quite big problem selecting parent pages from a huge drop down. There is a way to show only selected pages in the drop down as selectable parent pages. This is never an issue for bloggers who have majority of their content in posts as there is no need to select parent post for a blog. Download this plugin from Wordpress plugin directory Step 1: Create a custom field/Radio button to select if the page is to be listed in the drop down or not [crayon-59c672d35372e291009228/]   Step 2: Save the option to the post custom field [crayon-59c672d353737478983759/]   Step 3: Limit pages listed in the page attributes drop down and quick edit parent page drown down [crayon-59c672d35373c824297026/]   In Step 3 we are checking for pages which have custom field parent_dropdown set to 0 and excluding those pages from the page attributes drop down pages...
Read More

How to overcome Cloudflare 522: Connection timed out error

There are a few reasons why this error occurs. The most obvious is your server is down or a certain process is taking too long and your server is very busy. However that may not be the most likely reason for this error especially if this is happening quite frequently. Here are the 2 most likely reasons. When your website goes on clouflare, most of the incoming connections to your website are through the cloudflare IPs. If your server does not know about cloudflare IPs, its internal firewall limits access to any connections through those IPs simply because of the number of connections. So it is very important for your server firewall to whitelist those IPs. (Just to tell your server that connections through these IPs are ok). These IPs can be found on the cloudflare site: https://www.cloudflare.com/ips You may have tried something which may have triggered some rule set within the clouflare firewall. This block is only limited to you and mostly for a...
Read More