• Feed RSS

WordPress Multisite Beyond Basics: Essentials and Domain Mapping

"Today we will be discussing a few very important aspects of WordPress Multisite. If you are new to WordPress Multisite please go through the WordPress installation tutorial first to get an overall idea of the Multisite feature in WordPress. In this tutorial I shall be discussing a few key things essential for WordPress Multisite installation, along with some common troubleshooting tips. Finally I shall discuss WordPress Multisite Domain Mapping in detail.

Key Things to Know About WordPress Multisite Installation

Installing WordPress Multisite Using Plugin

You can install WordPress Multisite using two methods. One is using the plugin Enable Multi-Site and another is manual installation. It’s recommended to use manual installation since the installation changes will then be transparent and can be easily altered later.

Changing From Sub-Directory to Sub-Domain

In case you want to change your installation type from sub-directory to sub-domain, please use the following steps:
  • You need to delete all the sites which were created under your main site
  • Enable the sub-domain option from the wp-config.php file by modifying the following code:
    define( 'SUBDOMAIN_INSTALL', true );
  • Finally update your Permalinks
Since you will need to delete all your sites it’s recommended to make the decision carefully while choosing between sub-domain and sub-directory during installation.

Keeping a Default Theme for All Your New Sites

If you want to keep a default theme for all your newly created sites then please go to your wp-config.php file and add the following line of code below the specified line:
// Below this line
 define('WPLANG', '');
 // Add this line
 define('WP_DEFAULT_THEME', 'classic');
Replace ‘classic’ with the folder name of the theme you like.

Add Yourself to All Your Sites

The different sites created will only be visible under My Sites if you have been added as a user for that site. If you are a Network Admin then please add yourself as a regular user for all your created sites so that you can manage them straight from your dashboard.

Let Users Define Custom CSS

Generally the users are not able to edit the themes for their sites but once you (as a Network Administrator) install and activate the Custom User CSS plugin then the site owners can design their themes by defining custom CSS.

Common WordPress Multisite Troubleshooting

Created Sub-Domains Not Working

Your hosting platform should support the Wildcard DNS feature. Please check with your hosting provider prior to installing WordPress Multisite.
To create a Wildcard DNS entry please login to your Control Panel provided by your host and look for the Domain section. Under Domain click on the Subdomain option. This is the place to enable sub-domains for your website.
Once you click on the Subdomain option in the control panel, under Create a Subdomain enter an asterisk ‘*’ in the Subdomain field and then click on Create. The Document Root should point to the root directory of your WordPress installation.

Created Sub-Directories Not Working

The Apache mod_rewrite module should be supported by your hosting provider. This is required in the creation of multiple sites. If you are using WAMP you can enable it by going to Apache > Apache modules > mod_rewrite.

Network Cannot Be Enabled Error

This error occurs if the Site URL is not the same as the WordPress URL, so under WordPress’ Admin Dashboard Settings > General please ensure that they are the same prior to installing Multisite.

Wildcard Sub-Domain Incorrect Error

In order to solve this problem please go to your hosting provider’s control panel where you have defined the wildcard DNS and then update the Document Root of your sub-domain to point to the correct location.

My Uploaded Media Not Working

All the uploaded media including images are located under your created blogs.dir folder. Please check your .htaccess file if the following line of code is in the same format or not. Also ensure that mod_rewrite is enabled for your server.
# uploaded files
 RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
If you find any other issue with WordPress Multisite please feel free to refer to the Official Multisite Support Forum, it contains hundreds of solutions for your common Multisite problems.

Domain Mapping

One of the coolest parts of WordPress Multisite installation is the mapping of domains to turn your network sites into unique domains that carry their own identities. Using Domain Mapping lets you define a custom domain for your blog/site instead of the default address you get when you sign up or create a new site. For example, using a sub-domain install, if you create a new site you will have the URL newsite.parentsite.com. But using Domain Mapping you can turn it into www.newsite.com. Thus Domain Mapping can be used to point external domains to your network sites.
Domain Mapping hides the fact that the site is a part of a Multisite network.
Let’s discuss Domain Mapping in detail.

Step 1 A Little Bit of Your Host cPanel

Before going for the Domain Mapping let’s do a bit of backend work from our cPanel. Please login to your host’s cPanel. Generally the URL of your cPanel will look something like http://www.hostname.com/cpanel or http://www.hostname.com:2082 . Once you log in, you will find two options under the Domains section named Addon Domains and Parked Domains.
Here we will be using the Parked Domains option since we have our WordPress installation in the root directory. The Addon Domain option can be used if you are utilizing WordPress outside the root directory. Under Parked Domains enter the name of the new domain you want to park on your primary domain and then click on Add Domain. The parked domain should automatically point to the root directory of your installation which is generally public_html.
The new domain name should be registered prior to parking.
If you are using the Addon Domains option then you are probably not using your Primary Domain for mapping purposes. After clicking the Addon Domains option fill in all the required details in the window and click on Add Domain.

Step 2 The DNS Settings

After your new domain has been parked, you need to be sure that the DNS Settings are properly configured for your domain. For this you should have your DNS / Name Server information. This can usually be found in the Account Information section of your host’s cPanel. Once you have that info you need to login to your registrar’s website where the domain was registered. Here we have used Go Daddy for registration. Once you login, under My Account > Domain select the required domain name to open the domain editor and then click on Set Nameservers option under the Nameserver section.
Here you can use either of the four options to set up your Name Server.
  • I want to park my domains: This option will park your domain on GoDaddy’s parked servers.
  • I want to forward my domains: This option will forward your domain to another URL.
  • I have a hosting account with these domains: This option is used if the domain is hosted with GoDaddy.
  • I have specific nameservers for my domains: This option is used if your domain is hosted by another company. Here you need to enter the Name Servers provided by your hosting company. We will be using this option for this tutorial.
Once done click on the OK button.
If the nameserver info is changed it may take some time to propagate.
Although I have used GoDaddy and Host Gator in this tutorial, these options are very similar to any other vendor’s interface.

Step 3 WordPress MU Domain Mapping Plugin Installation

Now you need to manually install the WordPress MU Domain Mapping plugin in order to activate your domain mapping. Please download the plugin and extract the files. Copy all files (except the sunrise.php file) to your wp-content > plugins folder. Then copy the sunrise.php file to your wp-content folder.
Open your wp-config.php file and enter the following line of code under the code where you have enabled your multisite feature.
define('WP_DEBUG', false);
define('WP_ALLOW_MULTISITE', true);

define('SUNRISE', 'on'); // Add this line here:

define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
$base = '/';
define( 'DOMAIN_CURRENT_SITE', 'localhost' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

/* That's all, stop editing! Happy blogging. */
Save the changes.
After that you will be able to see the Domain Mapping option under the Settings menu of your Network Admin dashboard.

Step 4 Mapping The External Domain to One Of Your Child Sites

Now you are ready to map the external domain to one of your child sites. For this please click on the Settings > Domain Mapping option of your Network Admin Dashboard.
Under Server IP Address put the IP address of your web server. You may contact your host for this address or visit this site to find your site’s IP address.
Finally click on Save.
Next go to the Dashboard of one of your child sites for which you want to map the domain.
Then under Tools > Domain Mapping add the external domain which we have registered. Check the Primary Domain For this Blog checkbox to make it a primary domain for this site. Finally click on Add.
If your domain name includes a hostname like "www", "blog" or some other prefix before the actual domain name you will need to add a CNAME record for that hostname in your DNS pointing at this blog URL. For this please log in to your host cPanel and click on Advanced DNS Zone Editor under the Domains section and set up your CNAME record.
That’s it you have successfully mapped an external domain to your site. To verify please check the URL by visiting your child site.

Step 5 Final Steps

If you don’t want to utilize the original sub-domain URL of your child site any more, you may remove all the traces of the URL from the Network Admin Dashboard. For this go to Sites > All Sites and Edit the Site which you have mapped. In each of the tabs search for the old URL and replace it with the new URL.
In order to redirect users who type the old URL, please log into your cPanel and click on Redirects under the Domain section. Here you need to select the Type, the URL to be redirected and the URL to which it will be redirected. Finally click on Add.
That’s it for now, in my next tutorial I shall be explaining the WordPress Multisite Database in detail using phpMyAdmin and some really cool functions to be used in WordPress Multisite. Thanks a lot for reading."
read more

How to Include JavaScript and CSS in Your WordPress Themes and Plugins

"Knowing the proper way to include JavaScript and CSS files in your WordPress themes and plugins is very important for designers and developers. If you don’t adhere to best practices, you run the risk of conflicting with other themes and plugins, and potentially creating problems that could have been easily avoided. This article is intended as a reference for playing nicely with others.


Best Practices Make Everyone Happy

If you’ve ever developed a theme or plugin for WordPress, or worked with one that someone else has created, you’ve probably come across several different methods for including JavaScript and CSS. While there are several methods that may appear to work in a specific set of circumstances, there is one primary method recommended in the WordPress Codex. This preferred way will ensure your theme or plugin works in all cases, assuming others also code the correct way.
There’s also some misunderstanding about what exactly the Codex says about this, which I will help clarify.

What’s in the Box?

When you download WordPress, a selection of common JavaScript libraries are already included that you can use for your JavaScript development. A list of included libraries can be found in the WordPress Codex wp_enqueue_script article.
All those libraries are included, but by default WordPress only loads the ones it needs to, and only when it needs them in the admin. If you write JavaScript that utilises one of these libraries, you need to tell WordPress that your script needs the library loaded first.

Telling WordPress About Your Script and What It Needs

Some of the things to think about when you’re coding JavaScript for WordPress are:
  • Is there an included library I can use?
  • Can I use the version that’s included?
  • Do I need to load my script in the front-end and in the admin?
  • Which front-end and admin pages do I need to load my script on?
Answering these questions helps you know what you need to do to register and load your script. This is done using a WordPress function called wp_register_script, and here is its usage according to the WordPress Codex:
wp_register_script( $handle, $src, $deps, $ver, $in_footer );
So what are these variables and do we need them every time? (This is covered on the Codex page, so I’ll be brief and use plain English)
  • $handle – what you’ll use to refer to this particular script wherever you might need to enqueue it, and you have to include this variable at the very least
  • $src – the path to the source file within your plugin or theme
  • $deps – an array containing the $handle for any other scripts your script needs to run (i.e. a dependency)
  • $ver – the version number for your script, which can be used for cache-busting. By default, WordPress will use its own version number as the version number for your script
  • $in_footer – do you want your script to load in the footer? Set this to true or false. It is false by default, so it loads in the header where wp_head() is, and if you specify true it will load where wp_footer() appears in the theme

What Is “Cache-Busting”?

Browsers remember what scripts and stylesheets they’ve downloaded for a particular site based on the URL of the script and stylesheet. If you change the URL, even just by adding a querystring, the browser assumes it’s a new file and downloads it.

Ok, So Let’s Try Some Examples

Here is the most basic example for loading a custom script:
function wptuts_scripts_basic()
{
 // Register the script like this for a plugin:
 wp_register_script( 'custom-script', plugins_url( '/js/custom-script.js', __FILE__ ) );
 // or
 // Register the script like this for a theme:
 wp_register_script( 'custom-script', get_template_directory_uri() . '/js/custom-script.js' );

 // For either a plugin or a theme, you can then enqueue the script:
 wp_enqueue_script( 'custom-script' );
}
add_action( 'wp_enqueue_scripts', 'wptuts_scripts_basic' );
First, we register the script, so WordPress knows what we’re talking about. The way to find the path for our JavaScript file is different whether we’re coding a plugin or a theme, so I’ve included examples of both above. Then we queue it up to be added into the HTML for the page when it’s generated, by default in the <head> where the wp_head() is in the theme.
The output we get from that basic example is:
<script type="text/javascript" src="http://yourdomain.com/wp-content/plugins/yourplugin/js/custom-script.js?ver=3.3.1"></script>
Now if your script relies on one of the libraries included with WordPress, like jQuery, you can make a very simple change to the code:
function wptuts_scripts_with_jquery()
{
 // Register the script like this for a plugin:
 wp_register_script( 'custom-script', plugins_url( '/js/custom-script.js', __FILE__ ), array( 'jquery' ) );
 // or
 // Register the script like this for a theme:
 wp_register_script( 'custom-script', get_template_directory_uri() . '/js/custom-script.js', array( 'jquery' ) );

 // For either a plugin or a theme, you can then enqueue the script:
 wp_enqueue_script( 'custom-script' );
}
add_action( 'wp_enqueue_scripts', 'wptuts_scripts_with_jquery' );
Note: By default, jQuery is loaded with noConflict to prevent clashes with other libraries (such as Prototype). See the noConflict section of the Codex if you don’t know how to deal with that.
See what I did there? You just add an array with the ‘jquery’ handle as a dependency. It uses an array here, because your script could have multiple dependencies. If your script uses jQuery and jQuery UI, you’d add jQuery UI to your dependency array, like array( 'jquery', 'jquery-ui-core' )
So now the output has changed, and we can see that jQuery has also been added into the <head> of the page:
<script type='text/javascript' src='http://yourdomain.com/wp-includes/js/jquery/jquery.js?ver=1.7.1'></script>
<script type='text/javascript' src='http://yourdomain.com/wp-content/plugins/yourplugin/js/custom-script.js?ver=3.3.1'></script>
Let’s try an example with all the bells and whistles:
function wptuts_scripts_with_the_lot()
{
 // Register the script like this for a plugin:
 wp_register_script( 'custom-script', plugins_url( '/js/custom-script.js', __FILE__ ), array( 'jquery', 'jquery-ui-core' ), '20120208', true );
 // or
 // Register the script like this for a theme:
 wp_register_script( 'custom-script', get_template_directory_uri() . '/js/custom-script.js', array( 'jquery', 'jquery-ui-core' ), '20120208', true );

 // For either a plugin or a theme, you can then enqueue the script:
 wp_enqueue_script( 'custom-script' );
}
add_action( 'wp_enqueue_scripts', 'wptuts_scripts_with_the_lot' );
Ok, so I’ve now added a version and specified that this script needs to be loaded in the footer. For the version number, I’ve chosen to use today’s date because it’s easy to keep track of, but you can use any version numbering you like. The output for this one is slightly different too, jQuery is output in the <head> and our script along with jQuery UI is output just before </body>, like this:
<head>
...
<script type='text/javascript' src='http://yourdomain.com/wp-includes/js/jquery/jquery.js?ver=1.7.1'></script>
...
</head>
<body>
...
<script type='text/javascript' src='http://yourdomain.com/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.8.16'></script>
<script type='text/javascript' src='http://yourdomain.com/wp-content/plugins/yourplugin/js/custom-script.js?ver=20120208'></script>
</body>

Getting Your Priorities Straight

Some people may prefer not to use the proper enqueuing methods because they feel they have less control over the order in which scripts are loaded. For example, in a theme that uses modernizr, the theme author might want to make sure modernizr is loaded early on.
Something I haven’t mentioned earlier is more detail on how the add_action function works, as this is where we can exercise a little influence over the order of things. Here’s the usage of the function according to the WordPress Codex page:
add_action( $tag, $function_to_add, $priority, $accepted_args );
Note that often, and up until now in this article, only the $tag and $function_to_add parameters are used. The $priority parameter defaults to 10, and the $accepted_args parameter defaults to 1. If we want our scripts or styles to be enqueued earlier, we simply lower the value for $priority from the default. For example:
function wptuts_scripts_important()
{
 // Register the script like this for a plugin:
 wp_register_script( 'custom-script', plugins_url( '/js/custom-script.js', __FILE__ ) );
 // or
 // Register the script like this for a theme:
 wp_register_script( 'custom-script', get_template_directory_uri() . '/js/custom-script.js' );

 // For either a plugin or a theme, you can then enqueue the script:
 wp_enqueue_script( 'custom-script' );
}
add_action( 'wp_enqueue_scripts', 'wptuts_scripts_important', 5 );
The output will be the same as we’ve seen previously, but it will occur earlier in the HTML document.

Overriding Default Libraries and Using Content Delivery Networks

There may be times when you want to use a different version of a library that’s included with WordPress. Perhaps you want to use a cutting-edge version or you don’t want to wait for the next release of WordPress before using the latest stable version of jQuery. Another reason might be that you want to take advantage of Google’s CDN version of a library.
It’s important to note that this should only be done on plugins or themes used on sites that you will be personally maintaining. Any plugins or themes that you release for public use should use the libraries included with WordPress.
“Why?!”, I hear you ask. For the simple reason that you don’t control those sites. You don’t know what other plugins and themes might be used there, and you don’t know how often they will update your plugin or theme. Using the libraries packaged with WordPress is the safest option.
Having said that, if you are wanting to do this on a site you control, here’s how it’s done:
function wptuts_scripts_load_cdn()
{
 // Deregister the included library
 wp_deregister_script( 'jquery' );

 // Register the library again from Google's CDN
 wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', array(), null, false );

 // Register the script like this for a plugin:
 wp_register_script( 'custom-script', plugins_url( '/js/custom-script.js', __FILE__ ), array( 'jquery' ) );
 // or
 // Register the script like this for a theme:
 wp_register_script( 'custom-script', get_template_directory_uri() . '/js/custom-script.js', array( 'jquery' ) );

 // For either a plugin or a theme, you can then enqueue the script:
 wp_enqueue_script( 'custom-script' );
}
add_action( 'wp_enqueue_scripts', 'wptuts_scripts_load_cdn' );
So first of all, I deregister the included version of the library, otherwise conflicts between different versions could be introduced. Then register the alternate version, using the same handle, and I’ve chosen to specify null as the version (it’s already in the URL!) and specified not in the footer. The rest of our code is the same, because we were depending on whatever script used the ‘jquery’ handle. The output we get now looks like:
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
<script type='text/javascript' src='http://yourdomain.com/wp-content/plugins/yourplugin/js/custom-script.js?ver=3.3.1'></script>
Note: One of the reasons this is a bad idea to do in a plugin or theme for public release, is that all other plugins and themes used on this site will now have to use this version of jQuery. Also, the newly registered version of jQuery doesn’t have noConflict set, so if any other plugin or theme scripts use Prototype for example, this will break things.

Don’t Be Greedy

So far we haven’t mentioned anything about how to do all this in the admin, only on the front-end. The primary difference is what action to use. Instead of add_action( 'wp_enqueue_scripts', 'wptuts_scripts_basic' ); which we use for the front-end, the action for the admin is add_action( 'admin_enqueue_scripts', 'wptuts_scripts_basic' );
Something that’s important to do for both the front-end and admin is be selective about which pages you load your scripts on. If your plugin or theme has a script that only does something on one front-end or admin page, such as the theme’s options page, or maybe a page with a specific widget, you only need to load your script on that page. No point clogging things up and loading scripts on pages where they’re not being used!
There’s a great example in the WordPress Codex on how to load scripts only on plugin pages. Because plugins and themes can vary a lot in how they’re written, I won’t go into specifics here on how to be choosy about which pages you load scripts on, but it was important to mention so you’re aware of it when you’re coding.

That’s Scripts, Now Styles

The process for styles is almost exactly the same as the process for scripts. It is done using a WordPress function called wp_register_style, and here is its usage according to the WordPress Codex:
wp_register_style( $handle, $src, $deps, $ver, $media );
Note that the only difference there between wp_register_script and wp_register_style is that instead of an $in_footer parameter, we have a $media parameter. This parameter can be set to any of the following: 'all', 'screen', 'handheld', and 'print', or any other W3C recognised media type.
So an example of how you might enqueue a style would be:
function wptuts_styles_with_the_lot()
{
 // Register the style like this for a plugin:
 wp_register_style( 'custom-style', plugins_url( '/css/custom-style.css', __FILE__ ), array(), '20120208', 'all' );
 // or
 // Register the style like this for a theme:
 wp_register_style( 'custom-style', get_template_directory_uri() . '/css/custom-style.css', array(), '20120208', 'all' );

 // For either a plugin or a theme, you can then enqueue the style:
 wp_enqueue_style( 'custom-style' );
}
add_action( 'wp_enqueue_scripts', 'wptuts_styles_with_the_lot' );
This is a fairly comprehensive example, utilising most of the parameters, and the output it produces looks like:
<link rel='stylesheet' id='custom-style-css'  href='http://yourdomain.com/wp-content/plugins/yourplugin/css/custom-style.css?ver=20120208' type='text/css' media='all' />

So, Why Doesn’t Everyone Already Do Things This Way?

Good question, and the other question I guess you might ask is, “What makes you think this is the ‘right’ way and not just your preference?”. Essentially the answer is that this is the approach recommended by WordPress. It ensures that any combination of plugins and themes should be able to work together happily and without doubling up.
I’ve seen a few themes and frameworks around the place that use <script></script> and <link /> tags in their header.php, and even footer.php, files to load the scripts and styles for the theme itself. There’s really no reason to do things this way. As I’ve demonstrated above, it’s perfectly possible to prioritise scripts and styles and nominate whether they load in the header or footer from the comfort and safety of your functions.php. The benefit being that your theme / framework will work with a wider range of other plugins / child themes.
One example was loading jQuery using the <script></script> tags, which might appear to work nicely, but this can actually cause jQuery to be loaded twice! Loading jQuery in this way will not stop WordPress from loading its version of jQuery for other plugins, as WordPress’ version is in noConflict mode by default, and a plugin may specify it as a dependancy. So now you’ll have jQuery working for both noConflict mode and $, and also probably break any plugin that uses the Prototype library.

Conclusion

WordPress is a fantastic system, and it has been developed with a lot of thought. If there’s a mechanism made available to do something, it’s often a good idea to use it. When developing your plugins and themes, try to remember to code thoughtfully and for playing nicely with others.
What do you think about the use of wp_enqueue_script and its associated functions and actions? Do you know of any examples where it’s being done incorrectly? Do you know of any reason not to follow the advice above?"
read more

Quick Tip: Add Extra Contact Methods to User Profiles

"If you Google “add extra fields to WordPress user profile” you’ll find all sorts of involved coding examples for adding extra inputs to the user profile page so you can capture additional user information. But if all you want to do is expand the default contact methods section then there’s a much simpler way to go.

The user_contactmethods Filter

The user_contactmethods filter allows you to set and unset the contact info fields on the user profile page. The great thing about using this method is that WordPress looks after the creation and updating of the fields.
Let’s add fields for Twitter and Facebook info. Put this in your functions.php file:
add_filter('user_contactmethods', 'my_user_contactmethods');

function my_user_contactmethods($user_contactmethods){

 $user_contactmethods['twitter'] = 'Twitter Username';
 $user_contactmethods['facebook'] = 'Facebook Username';

 return $user_contactmethods;
}
Here is what you’ll get:
If you want to remove some fields, just unset them from the array:
function my_user_contactmethods($user_contactmethods){

 unset($user_contactmethods['yim']);
 unset($user_contactmethods['aim']);
 unset($user_contactmethods['jabber']);

 $user_contactmethods['twitter'] = 'Twitter Username';
 $user_contactmethods['facebook'] = 'Facebook Username';

 return $user_contactmethods;
}
To display the user’s info, simply use the get_user_meta function.
echo get_user_meta(1, 'twitter', true);
This will show the Twitter username for the user with an ID of 1. The true argument causes the data to be returned as a single value as opposed to an array.
That’s all there is to it!"
read more

Secure Your WordPress Against User-Agents and Bots

"Lately there have been a lot of WordPress sites compromised only due to the bots that roam the world wide web! There are a lot of plugins out there which can protect your WordPress baby by blocking these “roguish” bots!
In this article you will be learning an easy and useful method of adeptly configuring your .htaccess file to filter these bots which can infect your website and can eat up your server resources. So get your .htaccess file ready for editing!

Step 1 Preparing the Code

The code mainly consists of bot names. I have added the most famous bots in here that I can think of. If there is some bot missing, please mention it in the comments.
The code is pretty straightforward. Go ahead and copy the code below and paste it in your .htaccess file.
# Bot Blocker
<IfModule mod_setenvif.c>
 SetEnvIfNoCase User-Agent ^$ keep_out
 SetEnvIfNoCase User-Agent (pycurl|casper|cmsworldmap|diavol|dotbot) keep_out
 SetEnvIfNoCase User-Agent (flicky|ia_archiver|jakarta|kmccrew) keep_out
 SetEnvIfNoCase User-Agent (purebot|comodo|feedfinder|planetwork) keep_out
 <Limit GET POST PUT>
   Order Allow,Deny
   Allow from all
   Deny from env=keep_out
 </Limit>
</IfModule>

Step 2 Testing the Code

To see whether the code is doing its job, I using recommend this website Bots VS Browsers. This website is a good place to simulate these types of attacks. Once on their website all you have to do is select any bot from the code, which you just added to your .htaccess file, and use that as the user agent. Enter the URL of your site and hit enter. If you see a “403 Error” this means that the code is doing its job. If not the code must’ve gotten messed up while being copied into your .htaccess file, so try again.

Step 3 Adding More Bots

Now you are familiar with the code and how to test it, we can add more bots to the code. You must have noticed the repetition in the code, and by using the same logic, you can add a dozen more bots to be blocked by setting the same parameters. Cool huh!
SetEnvIfNoCase User-Agent (i-IS-evilBOT) keep_out
As you can see in the code above, now I am blocking the “i-IS-evilBOT” (which I just made up). Other than that the name of the bot is not case sensitive and you can add it as per your liking. Go to the Bots VS Browsers page and this time enter the user agent which I just created, and voila, you’ll see that this user agent which was added to my .htaccess file is also blocked! You can add as many bots as you want to be blocked separated with a pipe character “|”

Conclusion

I said in the beginning that there are many plugins which can do the same thing and you can avoid this editing. But by manually editing the .htaccess file you can effectively block bad user-agents and bots with better efficiency and better site performance!"
read more

Using the Envato API with WordPress

"Today we are going to discuss how to use the Envato API in WordPress and create a WordPress shortcode that promotes our Envato Marketplace Items inside our WordPress site. We will combine the powerful Envato API, WordPress’ flexibility and a little bit of creativity, to build an amazing plugin for our site.

Let’s Set Our Goal

In this tutorial we are going to focus on:
  • Some basic knowledge about the Envato API
  • How to use API result data inside WordPress
  • Build a WordPress Shortcode that promotes Envato Marketplace items in our WordPress site.
So let’s get into the first one!

Step 1: Understanding the Envato API

Envato provides an API that allows developers to get some information about Envato Marketplace items, users info, popular projects and so on. All possible queries are listed in the official documentation. In this article we discuss the public API only.
The Envato Public API has the following structure.
http://marketplace.envato.com/api/edge/set.json
The word set must to be replaced with an option listed in the set column of the API documentation. So if we want all information about a marketplace item we have to replace set with item:the_item_id. The final request URL will be:
http://marketplace.envato.com/api/edge/item:1263846.json
You can try to insert the URL above in your web browser and see the returned data.
We can also concatenate more than one set option in a single request to get more data. For example we want the item data and its author information. So the previous URL will become:
http://marketplace.envato.com/api/edge/item:1263846+user:evoG.json
The Envato API returns JSON, so in the next paragraph we are going to show how to manage it in WordPress.

Step 2: How to Use API Results in WordPress

In this tutorial we are not going to discuss how to create a WordPress plugin, but we are going to focus on some techniques to use the API in WordPress:
  • Send the API request
  • Manage the result data (the JSON string)
The function below fetches the data from the Envato server and returns a PHP array that contains all the informations we want.
/**
* @param String $item_id - The ID of an Envato Marketplace item
* @returns Array - The item informations
*/
function WPTP_get_item_info( $item_id ) {

 /* Set the API URL, %s will be replaced with the item ID  */
 $api_url = "http://marketplace.envato.com/api/edge/item:%s.json";

 /* Fetch data using the WordPress function wp_remote_get() */
 $response = wp_remote_get( sprintf( $api_url, $item_id ) );

 /* Check for errors, if there are some errors return false */
 if ( is_wp_error( $response ) or ( wp_remote_retrieve_response_code( $response ) != 200 ) ) {
  return false;
 }

 /* Transform the JSON string into a PHP array */
 $item_data = json_decode( wp_remote_retrieve_body( $response ), true );

 /* Check for incorrect data */
 if ( !is_array( $item_data ) ) {
  return false;
 }

 /* Return item info array */
 return $item_data;

}
We can improve the function above. To prevent stress on the Envato API server we can cache item data and request the info again after a timeout. WordPress offers us some functions to implement this feature. Let’s add it.
/**
* @param String $item_id - The ID of an Envato Marketplace item
* @returns Array - The item informations
*/
function WPTP_get_item_info( $item_id ) {

 /* Data cache timeout in seconds - It send a new request each hour instead of each page refresh */
 $CACHE_EXPIRATION = 3600;

 /* Set the transient ID for caching */
 $transient_id = 'WPTP_envato_item_data';

 /* Get the cached data */
 $cached_item = get_transient( $transient_id );

 /* Check if the function has to send a new API request */
 if ( !$cached_item || ( $cached_item->item_id != $item_id ) ) {

  /* Set the API URL, %s will be replaced with the item ID  */
  $api_url = "http://marketplace.envato.com/api/edge/item:%s.json";

  /* Fetch data using the WordPress function wp_remote_get() */
  $response = wp_remote_get( sprintf( $api_url, $item_id ) );

  /* Check for errors, if there are some errors return false */
  if ( is_wp_error( $response ) or ( wp_remote_retrieve_response_code( $response ) != 200 ) ) {
   return false;
  }

  /* Transform the JSON string into a PHP array */
  $item_data = json_decode( wp_remote_retrieve_body( $response ), true );

  /* Check for incorrect data */
  if ( !is_array( $item_data ) ) {
   return false;
  }

  /* Prepare data for caching */
  $data_to_cache = new stdClass();
  $data_to_cache->item_id = $item_id;
  $data_to_cache->item_info = $item_data;

  /* Set the transient - cache item data*/
  set_transient( $transient_id, $data_to_cache, $CACHE_EXPIRATION );

  /* Return item info array */
  return $item_data;

 }

 /* If the item is already cached return the cached info */
 return $cached_item->item_info;

}
Now the core function of our WordPress plugin is ready. We have used some WordPress functions that help us to save time. All information about them is explained in the official WordPress Codex.

Step 3: Build WordPress Shortcode

In the next steps we are going to code a useful WordPress plugin that allows us to display some informations about an Envato Marketplace item. All code below is well commented so you can easily understand each line. For more details about Writing a WordPress Plugin and the WordPress Shortcode API check out the online documentation in the WordPress Codex.

Let’s start

Let’s write the header informations for our plugin
<?php
/*
Plugin Name: WordPress Tutsplus Envato Item Info
Plugin URI: http://wp.tutsplus.com
Description: Display some informations about Envato Marketplace items
Version: 1.0
Author: Michele Ivani
Author URI: http://evographics.net
*/

Add the WordPress shortcode

Now we write the code to add the shortcode and its functionalities.
<?php
/**
* Add the shortcode using the WordPress function add_shortcode()
* We used as shortcode tag "wptp-envato-item"
*/
add_shortcode( 'wptp-envato-item', 'WPTP_add_shortcode' );

/**
* Hook to run when the shortcode is found
* @param Array $atts - shortcode attributes
* @param String $content - shortcode content (not necessary for our plugin)
* @return String - plugin HTML code
*/
function WPTP_add_shortcode( $atts, $content = null ) {

 /* Default shortcode attributes  */
 $atts = shortcode_atts( array(
  'item_id' => ''
 ), $atts );

 extract( $atts );

 /* Validation */
 if ( empty( $item_id ) ) {
  return "<p>Please insert an Envato Marketplace Item ID.</p>";
 }

 /* Get data from the API*/
 $item = WPTP_get_item_info( $item_id );

 /* Validation - Check if something went wrong */
 if ( $item === false ) {
  return "<p>Oops… Something went wrong. Please check out the item ID and try again.</p>";
 }

 /* Format the $item array */
 $item = $item['item'];
 extract( $item );

 /* Prepare the Plugin HTML */
 $html = '';

 $html .= '
 <div class="wptp_envato_item">

  <div class="wptp_title">'.$item.'</div>

  <div class="wptp_wrap">

   <div class="wptp_top">

    <div class="wptp_rating">

     <span class="wptp_desc">rating</span>'.

     WPTP_get_stars($rating)

    .'</div> <!-- end wptp_rating -->

   </div> <!-- end wptp_top -->

   <div class="wptp_middle">

    <div class="wptp_sales">

     <span class="wptp_img_sales"></span>

     <div class="wptp_text">

      <span class="wptp_num">'.$sales.'</span>
      <span class="wptp_desc">sales</span>

     </div> <!-- end  wptp_text -->

    </div> <!-- end wptp_sales -->

    <div class="wptp_thumb">
     <img src="'.$thumbnail.'" alt="'.$item.'" width="80" height="80"/>
    </div> <!-- end wptp_thumb -->

    <div class="wptp_price">

     <span class="wptp_img_price"></span>

     <div class="wptp_text">

      <span class="wptp_num"><span>${body}lt;/span>'.round($cost).'</span>
      <span class="wptp_desc">only</span>

     </div> <!-- end wptp_text -->

    </div> <!-- end wptp_price -->

   </div> <!-- end wptp_middle -->

   <div class="wptp_bottom">

    <a href="'.$url.'" target="_blank"></a>

   </div> <!-- end wptp_bottom -->

  </div> <!-- end wptp_wrap -->

 </div> <!-- end wptp_envato_item -->'; 

 return $html;
}

Star ratings function

The WPTP_add_shortcode() function above has the WPTP_get_stars() procedure that coverts the rating number to HTML stars. Let’s implement it.
<?php
/**
* Convert the rating number to HTML stars
* @param String $rating - Envato Item rating
*/
function WPTP_get_stars( $rating ) {

 /* If item rating is null the function prints a message */
 if ( ( int ) $rating == 0 ) {
  return '<div class="wptp_not_rating">Not rate yet</div>';
 }

 /* Else if rating is >= 1 the function converts it to HTML stars and returns them as a string */
 $return = '<ul class="wptp_stars">';
 $i=1;
 while ( ( --$rating ) >= 0 ) {
  $return .= '<li class="wptp_full_star"></li>';
  $i++;
 }

 if ( $rating == -0.5 ) {
  $return .= '<li class="wptp_full_star"></li>';
  $i++;
 }

 while ( $i <= 5 ) {
  $return .= '<li class="wptp_empty_star"></li>';
  $i++;
 }

 $return .= '</ul>';

 return $return;

}

Include CSS

When the shortcode functions are completed, we have to include the style.css file that styles our plugin.
<?php
/**
* Add the CSS style file
*/
add_action( 'wp_print_styles', 'WPTP_add_css' );

/**
* Attach the plugin CSS file to the WordPress site
*/
function WPTP_add_css() {
 /* Register style */
 wp_register_style( 'WPTP_css', plugins_url( 'style.css', __FILE__ ) );

 /* Enqueue style */
 wp_enqueue_style( 'WPTP_css' );
}

Step 4: Write CSS Rules

The style.css file is inside the same directory as the main plugin file and it contains all the CSS rules.
/* WordPress Tutsplus Envato Item Info - CSS Rules*/

/* Main layout and typography */
.wptp_envato_item {
 font-family: "Helvetiva Neue", Arial, sans-serif;
 margin: 20px 0;
}

.wptp_wrap { width: 210px; }

.wptp_text { display: block; }

.wptp_num {
 display: block;
 font-size: 24px;
 font-weight: 300;
 margin: 0;
 padding: 0;
 line-height: 24px;
 color: #66696d;
}

.wptp_num span {
 font-size: 14px;
 vertical-align: super;
}

.wptp_desc {
 display: block;
 font-size: 12px;
 font-weight: 300;
 margin: 0;
 padding: 0;
 line-height: 12px;
 color: #96999d;
}

.wptp_not_rating {
 color: #66696d;
 font-size: 13px;
 font-weight: bold;
}

.wptp_title { font-size: 14px; font-weight: 300; color: #66696d; margin-bottom: 10px; }

/* Stars rating section */

.wptp_rating {
 width: 82px;
 text-align: center;
 margin: 0 auto 10px auto;
}

.wptp_stars {
 margin: 0;
 padding: 0;
 list-style: none;
}

.wptp_stars li {
 margin-left: 2px;
 display: inline-block;
 vertical-align: middle;
 width: 13px;
 height: 13px;
}

.wptp_stars li.wptp_full_star { background: url(icons-sprite.png) 0px -64px ; }

.wptp_stars li.wptp_empty_star { background: url(icons-sprite.png) -14px -64px ; }

/* Sales and Price sections */
.wptp_sales, .wptp_thumb, .wptp_price {
 display: inline-block;
 vertical-align: middle;
}

.wptp_sales {
 text-align: right;
 margin-right: 10px;
}

.wptp_sales .wptp_text {
 width: 52px;
}

.wptp_img_sales {
 background: url(icons-sprite.png) 0px 0px;
 width: 32px;
 height: 32px;
 display: block;
 margin: 0 0 12px 20px;
}

.wptp_img_price {
 background: url(icons-sprite.png) 0px -32px ;
 width: 32px;
 height: 32px;
 display: block;
 margin-bottom: 7px;
}

.wptp_price {
 text-align: left;
 margin-left: 10px;
}

.wptp_price .wptp_text { width: 34px; }

/* Purchase button section */
.wptp_bottom a {
 display: block;
 width: 78px;
 height: 33px;
 background: url(icons-sprite.png) -32px 0px;
 margin: 10px auto 0 auto;
}

Conclusion

That’s it, now we can upload the plugin to our Worpdress site and use the power of WordPress shortcodes to display some info about Envato Marketplace items. For more details about Writing a WordPress Plugin and the WordPress Shortcode API check out the online documentation on the WordPress Codex.
I’m Michele Ivani and I hope this tutorial was helpful for your WordPress development. Thanks so much for reading."
read more

How to Build an E-Commerce Website Using WordPress: Part 2

"This is the second and final part of the WordPress E-Commerce tutorial. Here we will go through the final steps of completing our WordPress e-commerce web site. You will be shown with the process of adding products to your site, using different widgets to enhance your site, using different reports to keep track of the sales and efficient use of shortcodes.

Once done with the wp-ecommerce settings, adding your products and selling becomes child’s play.

Before We Move On

Before we dive straight into the process, let’s look at a few changes we made to the e-commerce site since part 1.
1. We have installed the latest version of Liquorice theme, i.e Liquorice 2.2 by Nudge Design.
2. We have updated WordPress to the latest WordPress 3.3 version.
3. Under Settings -> Store -> Shipping we have edited the Flat Rate option and put $ 0.00 under all the fields. This is done since we will use different shipping rates for different products (without any base rates). Putting $ 0.00 keeps this feature enabled. If you want to keep a Base rate to be added to the individual shipping cost of each product, you may enter your Base rates here.
Now our site looks like….

Adding Products

Lets discuss a few useful options before we add our first product.
1. The Product -> Coupons page lets us add special discount coupons for the products. Here you can specify the Coupon Code, Discount, Coupon Expiry Date and other conditions as per your requirements.
2. The Product -> Variations options lets you add variations to your products.
Supose you are selling T-Shirts and you want to specify its variations in Size or Color. This options lets you define your Variations Set first and then define the different variations under it. You can also set a price for each of the variations.
3. The Product -> Product Tags options lets you define your own product tags useful for searching a product while using the Product Tags widget.

Adding Product Categories

Before adding a product lets add our product categories from the Products -> Categories page.
While adding a category you need to specify the Name, Parent Category (if any) and Description. You may specify a Thumbnail image and also restrict a few countries from accessing this product. As of now we have added three categories- Flowers, Confectioneries and Chocolates.

Adding Your First Product

The Products -> Add New option lets you add products to your e-commerce site.
Here you need to specify the Product Name, Product Description, Product Tags and categorize your product under the created Categories. The Variations option lets you add your created Variations to this product.
Now you need to add the Price, Stock and Taxes(if any) of this product. While adding the Price, you can also specify a Sale Price to show a discounted price to your customers, which will increase the customer’s interest.
The Product Download option is used if you are selling downloadable products.
Please upload Product image by clicking the Manage Products Images link. Here you have the option to upload the image form your local hard disk, URL or using your WordPress Media Library. You can also Drag and Drop your images in this page.
The most important part is specifying your shipping options. Here at first you need to specify a Weight for your product and then specify the Local and International Shipping Charges. You also have the option to disregard the shipping charges.
After making all the changes click on Publish.
Now your product appears under the Products -> Products option. You can edit/delete the product from here.
Lets add two more products to our site.
Lightbox effect Image of products.
In the same way you can add different products to your site. You can also use the Settings -> Store -> Import option to upload products in a batch using a comma delimited text file.. After adding the products you can upload the images and insert the additional details.

Using a Few Essential Widgets

Under the Appearance -> Widgets, you will find many useful widgets. You just need to drag and drop it in the area of the page where you want to place it. Lets discuss a few of these one by one.
1. Latest Products– Using the Latest Products widget will display the recently added products on your sidebar or the area where you are placing this widget.
2. Products Categories – Using this widget will show all your product categories in your sidebar. The customer can search for products using those categories.
3. Product Specials – This widget displays those products that is on Sale in your site, i.e if the product has any discounted price or the Table Rate Price.
4. Product Tags- This widget displays the specified product tags in your sidebar so that customer can search for their required products using those Tags.
5. Price Range – This widget adds the price range of the products in your sidebar through which the customer can search for the products using different price ranges.
6. Shopping Cart – If you have selected the Widget option for your Cart Location , you can use this widget to display the shopping cart in your sidebar.
7. Text- This wizard is very helpful if you want to display any special ad on your website. You can also copy paste html snippets in this widget.

Reporting

Once the products have been purchased, you can see the purchase reports under the Sales Summary, Sales by Quarter and Sales by Month. Under the Sales Summary you will get to know the current month’s sales as well as the Total Income. The Sales by Quarter displays the sales by Financial Quarters and Sales by Month displays Last four months of sales on a per product basis.
Under Dashboard -> Store Sales, you will get a summary of the sales for the Current Month. It is through this screen that you will be able to see all the sales details and also process the orders. You can change the Sales Status and also add anew Tracking IDs to each of the products. Clicking on the Details->Items displays the invoice. You can also email the customer the purchase receipt from this page.
That’s it your e-commerce site is ready for the first sale.While checking out, the system automatically asks for you Login Credentials or Registers you if you are a new customer.

Importance of Shortcodes

Introduction
A shortcode is a specific code in WordPress that lets you do great things using very little effort. The other name of Shortcode is Shortcut, you can embed files or create objects using just one line of shortcode which otherwise would have required lots of ugly codes.
Here are the details of a few important shortcodes used in our site.
productspage shortcode helps in displaying the complete list of products and their presentation in the website. This is a very important shortcode in Wp e-commercerce that is used within Products Pages, Products Categories and single Product Templates.
shoppingcart shortcode displays the checkout page or the checkout template in the site.
transactionresults shortcode displays the transaction page which shows the customers the status and the summary of their purchase.
userlog shortcode displays the My Account page of the site. Its is used by already registered customers to see their details regarding purchase history, downloads and account details.
Some other examples of shortcodes-
[wpsc_products product_id='288'] – Displays the product which has ID of 288 [buy_now_button product_id='198'] – Displays a PayPal buy now button for the product(ID-198). [add_to_cart=112] – Displays an add to cart button for the product(ID-112).

Conclusion

I hope you have enjoyed both the e-commerce tutorials.This is only the tip of the iceberg of what can be done with the Wp e-commerce plugin. In the future I shall try to bring more tutorials on WordPress e-commerce."
read more

How to Build an E-Commerce Website Using WordPress: Part 1

"Today we will be creating a simple but powerful e-commerce site using one of the most popular WordPress plugins called WP e-Commerce. Using this plugin we will be creating a website which sells holiday gifts!


Knowing WP e-Commerce Plugin

WP e-Commerce is a powerful shopping cart plugin for WordPress developed by GetShopped.org. Using this plugin in WordPress lets users buy your products and services online. Given below are some of the features of this amazing plugin.
  • Easy to install.
  • Works with any WordPress theme.
  • Supports all kind of WordPress Widgets.
  • Template modification is very easy.
  • Instant support community.
  • All the popular payment gateways supported.
  • 100% Search Engine friendly.
  • Can be used to promote products on social networking sites.
  • Supports multiple languages.
  • Can be integrated with Google.
  • Supports multiple currencies.
  • Multi shipping options.
  • SSL security integration and many more.
You can start selling your products, downloads and services right away.
There are also additional features for premium customers. You can go through all of these features by clicking here.

Prerequisites of installing WP e-Commerce

Before installing and activating the plugin lets discuss some core pre requirements.
1. WordPress development environment must be ready in your system.You can either host your site locally or using a web hosting service. You can also use BitNami for WordPress, which is a great combined tool for WordPress development and testing.
2. Please log in to your WordPress admin and go to Post -> All Posts and remove (trash) the default post from the list.
3. Please go to Posts -> Categories and create categories relevant to your products. Here we will create Bakery Items, Confectionaries and Flowers. While creating the categories you just need to provide the name and a short description.We have changed the Uncategorized category to Bakery Items.
4. Please go to Pages -> All Pages and remove (trash) the default page from there.
5. You can customize and keep the current theme or go to Appearance -> Themes to install a new one that suits your e-commerce site. You can also use third party themes for your e-commerce site.
6. On the Appearance menu click on Header and upload your site’s header image. You may need to crop the image while uploading.
7. Under the Settings -> General change the following things.
  • Site Title to Christmas Shopping
  • Tagline to Gift n Enjoy
  • Select the Anyone can Register option.
Please click on Save Changes after changing these options.
8. Please go to Settings-> Permalinks. Select Custom Structure and enter /%postname%/. Finally Save the changes done. Permalinks helps you to create customized urls for your pages instead of the default ones.
9. In the Settings -> Discussions page, uncheck all the options and click Save Changes. This will prevent any type of comment in your e-commerce site.

Installing WP-eCommerce

This plugin can be installed either manually or from the WordPress plugin menu.
Lets install it using the easiest method that is by using the WordPress plugin menu.
Please go to Plugins -> Add New and Search for WP e-commerce. In the list generated locate the WP e-commerce plugin and click on Install Now.
After the plugin is installed, click on Activate Plugin to activate the plugin.
That’s it the plug has been installed and ready to use.
After the plugin is installed, you will see a Products menu in your dashboard and a Store option under Settings. The Products menu is used for adding different products to your site and the Store option is used for the plugin settings.
In your dashboard you will also find three new items which shows- Sales by Quarter, Sales by Month and Sales Summary.

A few more additional changes before configuring the plugin

Please go to Settings -> Reading and under Front page displays select A static page and choose the Products Page as your front page. This will ensure that when customers visits your site, the products page will be displayed by default.

Defining a Contact Us page for your site.

We shall use the Contact Form 7 plugin to create a Contact Us page for the site.
For this please go to Plugins -> Installed Plugins and Activate the Contact Form 7 plugin. After activation please click on the plugin settings.
In the plugin’s settings page you can create a customized contact us form by using different types of options available there. Under the Mail option enter your email address beside the To: field. Under Messages you can use your own error messages. Finally copy the generated short code and paste it into your post, page or text widget content. In our case we have copied the code [contact-form-7 id="18" title="Contact form 1"] to a newly created page named Contact Us.
Finally our site looks…

Lets set up the WP-eCommerce plugin before adding products

Please go to Settings -> Store. Here you can set the different options for the plugin.

1. General

a) Select a Base Country/ Region.
b) Select the markets you are selling products to.
c) Set the amount of time the items in a customer's cart are kept reserved.
d) Select a Currency Type and Currency Sign Location.
Finally click Update.

2. Presentation

a) Select Add to Cart under Button Type.
b)You can enable additional options from Show Product Ratings, Show Stock Availability, Display Fancy Purchase Notifications, Display per item shipping etc. For now we will only enable the Display per item shipping: option.
c) Under Gird View Settings we will enter 3 products per row and select Display Description, Display "Add to Cart" Button and Display "More Details" Button options.
d) Under Shopping Cart Settings select Cart Location as Widget. and enable Display "+ Postage & Tax":
e) You can set the product image thumbnail format from the Thumbnail Settings.
f) You may enable other options as per your requirements. As of now we shall keep the other options as default.
Finally click Update.

3. Admin

a) The first three options are used for downloadable products like software, music, games etc.
b) Under Purchase Log Email and Purchase Receipt – Reply Address: enter your email address.
c) Enter your name against Purchase Receipt – Reply Name:
d) Set Terms and Conditions if any.
e) You can edit the Purchase Receipt and Admin Report formats under the Custom Messages.
f) Tracking responses can also be created from this page.
Finally click Update.

4. Taxes

Here you can define the tax rules according to your requirements. You can also define the tax per item.

5. Shipping

a) We will enable the Use Shipping option since we are selling Christmas Gifts.
b) By selecting the Enable Free Shipping Discount, you can provide shippings discounts to customers.
c) Under Shipping Modules we have selected and edited the Fixed Rate shipping option and provided the shipping rates for the customers of different countries.
d) Under External Shipping Calculators we have selected UPS as our shipping gateway and provided all the details.
Please note: You need to have a UPS account in order to use this option. You can also use other shipping options.
Finally click Update.

6. Payments

Here you can define the payment gateway for the customers. Among the various options available, we will use the Test Gateway and PayPal Payments Standard 2.0. The PayPal Payments Standard 2.0 option can be used if you have a PayPal account. This lets customers buy products using PayPal. We will also use the Test Gateway option as a means of manual payment. After selecting and editing the payment options you need to provide all the details.
Finally click Update when done.

7. Checkout

a) Under Misc Checkout Options enable Users must register before checking out, Enable Shipping Same as Billing Option: and Force users to use SSL options.
b) The Form Fields define the Customer's checkout form. You can create a new form or use the default one. You can change the field's Name, Type and Mandatory options. You can also Drag and Drop, Delete different fields based on your requirements.
Finally click Save Changes after its done.

8. Marketing

This option is used to share and broadcast your products among different social networking sites, RSS and Google Merchant Center. For now we shall select the Show Share This, Customer Survey and Facebook Like options.
Click Update when done.

9. Import

The import option is used to upload products automatically using a csv file. We shall come to this later.
In the next part of this Tutorial I shall explain how to add products and use different widgets/plugins in your e-commerce site."
read more