post

Defer parsing of javascript to improve performance in wordpress

Nothing for introduction, hehe! A very small snippet which will help you to defer parsing all javascript files except jquery in wordpress. Here is the code:

You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

post

Why you shouldn’t use one click installer to install wordpress

Yes, you will fall at the mid-ocean, trust me!

Well, most of the bloggers just maintain a simple blog so usually they don’t need to worry. They just need to keep a regular backup. But if you are planning to run a business site in wordpress and if that site is your everything, never ever use one click installer to install wordpress! You’d be better off installing it manually which may take you a few minutes longer to install.

Here you can get an idea about manually installing wordpress:
codex.wordpress.org/Installing_WordPress
www.siteground.com/tutorials/wordpress/wordpress-installation.htm

If you want to install manually, download wordpress from here. Then you can upload this through ftp. You can use several ftp client such as – filezilla, coreftp, fireftp (a firefox add-on) etc. You can know about uses of filezilla here.

Why you shouldn’t?

  • Big WordPress Security Risks
  • Exporting and importing content with WordPress’s built in export tools
  • They use old scripts. Updated versions of WordPress or any script are not immediately released on those services. They install an outdated version of WordPress. It’s not a good start with outdated one.
  • They bypasses almost all settings used for installing
  • Sometimes it has issues while you want to upgrade.
  • Suppose first created database is wpdb1 and the next one is wpdb2 and so on. Malicious hackers know this is how they’re created and it gives them more ammo.
  • Created a file named fantversion.php (or something similar), which is common for all auto installers. This is a security risk if crackers know how to break into it.
  • The auto created database name and the database username is same in most cases.

So what if you have already installed?

  • First of all, keep a backup of whole site and the database.
  • Download latest wordpress from WP rep. (see above for link)
  • Delete wp_admin and wp_includes folder via ftp.
  • Extract the zip and upload only wp_admin and wp_includes folder via ftp.
  • Change (alter) the database name, db username and password.
  • Put the changed db name, db username and db password in wp-config.php.
  • Get new auth key, salt etc from api.wordpress.org/secret-key/1.1/salt
  • Copy and replace the keys in wp-config.php
  • Uninstall the plugins that come with default one-click installation

It should work.

WordPress is a 15min install when completely secured and optimized through htaccess. So it’s your decision what will be your route. I just showed you some examples, if you do a little research over google you will get lots of ideas about it.

Hope you will enjoy! :)

post

How to convert hexadecimal color value to RGB value in php

Most of the CMS provides a color picker in admin panel to user to choose a color. And almost all of the color pickers return the color code as hexadecimal mode, e.g. #4EE4D3. So, you can just get the value and set the color in css. For example:
[php]

body{
background:
}

[/php]

This is a very good practice. Problem occurs if you want to put a opacity option to the user. You can set background opacity with hexadecimal color value. You must use RGBA filter, so RGB color mode as well. Like:
[css]
body{
background: rgba(233, 122, 234, 0.7);
}
[/css]

So, we need to convert the hexadecimal value to its equivalent rgb value. Here is a very small function that will do the job:

So using this function you will get the rgb value, and with that you use the opacity :)

Hope you will enjoy! :)

post

Reorder or rearrange buddypress menu items

Don’t like the order of BuddyPress menu items? Change it!

Use the following code and organize in your way – how you want to reorder the BuddyPress menu items.

You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

:)

post

Get All posts by tag in a network – wordpress multisite

If you want to show some selected posts as popular posts across the network, then this snippet is for you :) You can fetch posts by any tag that is available in your wordpress multisite network and show those to anywhere, maybe in the main site or in any subsite.

If you want to show posts from some selected subsites, you just need to pass those blog IDs as an array parameter or if you send an empty parameter it will fetch posts from all subsites in the network.

Here is the code:

You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code. And then use the function in anywhere :)

post

Show posts based on user preference in wordpress

This is an interesting snippet that will help you to set a preference for the users, so that they will choose their favorite categories and they will see posts from these categories only.

You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

Enjoy! :)