Website speed optimization: Additional tips for a faster website

fastcat

Make use of Data URI’s

Data URI’s can be useful for embedding images into HTML/CSS/JS to save on HTTP requests and consequently enhance the loading time of your site. The following function will create a Data URI based on $file for easier embedding.

function data_uri($file, $mime) {
  $contents=file_get_contents($file);
  $base64=base64_encode($contents);
  echo "data:$mime;base64,$base64";
}

Source: CSS Tricks

Manually move scripts and css files to the footer

This example features how to do it on a WordPress blog, but any developer with a little experience can modify the code to make it fit any kind of website.

First, open your functions.php file and paste the following code in it:

/**
 * Filter HTML code and leave allowed/disallowed tags only
 *
 * @param string 	$text 	Input HTML code.
 * @param string 	$tags 	Filtered tags.
 * @param bool 		$invert Define whether should leave or remove tags.
 * @return string Filtered tags
 */
function theme_strip_tags_content($text, $tags = '', $invert = false) {

    preg_match_all( '/<(.+?)[\s]*\/?[\s]*>/si', trim( $tags ), $tags );
    $tags = array_unique( $tags[1] );

    if ( is_array( $tags ) AND count( $tags ) > 0 ) {
        if ( false == $invert ) {
            return preg_replace( '@<(?!(?:'. implode( '|', $tags ) .')\b)(\w+)\b.*?>.*?</\1>@si', '', $text );
        }
        else {
            return preg_replace( '@<('. implode( '|', $tags ) .')\b.*?>.*?</\1>@si', '', $text );
        }
    }
    elseif ( false == $invert ) {
        return preg_replace( '@<(\w+)\b.*?>.*?</\1>@si', '', $text );
    }

    return $text;
}

/**
 * Generate script tags from given source code
 *
 * @param string $source HTML code.
 * @return string Filtered HTML code with script tags only
 */
function theme_insert_js($source) {

    $out = '';

    $fragment = new DOMDocument();
    $fragment->loadHTML( $source );

    $xp = new DOMXPath( $fragment );
    $result = $xp->query( '//script' );

    $scripts = array();
    $scripts_src = array();
    foreach ( $result as $key => $el ) {
        $src = $result->item( $key )->attributes->getNamedItem( 'src' )->value;
        if ( ! empty( $src ) ) {
            $scripts_src[] = $src;
        } else {
            $type = $result->item( $key )->attributes->getNamedItem( 'type' )->value;
            if ( empty( $type ) ) {
                $type = 'text/javascript';
            }

            $scripts[$type][] = $el->nodeValue;
        }
    }

    //used by inline code and rich snippets type like application/ld+json
    foreach ( $scripts as $key => $value ) {
        $out .= '<script type="'.$key.'">';

        foreach ( $value as $keyC => $valueC ) {
            $out .= "\n".$valueC;
        }

        $out .= '</script>';
    }

    //external script
    foreach ( $scripts_src as $value ) {
        $out .= '<script src="'.$value.'"></script>';
    }

    return $out;
}

Once done, edit your header.php file. Replace the wp_head() tag by this:

<?php
ob_start();
wp_head();
$themeHead = ob_get_contents();
ob_end_clean();
define( 'HEAD_CONTENT', $themeHead );

$allowedTags = '<style><link><meta><title>';
print theme_strip_tags_content( HEAD_CONTENT, $allowedTags );
?>

And finally, place the code below into your footer.php file, just before the closing </body> tag.

<?php theme_insert_js( HEAD_CONTENT ); ?>

Credit: Tomasz Dobrynski.

Manually combine JavaScript files

If you’re using WordPress, you should definitely use the W3 Total Cache plugin which combines, but also minifies JavaScript and CSS files. But if you’re working on a custom made website, you can definitely take advantage of this super simple technique to combine multiple .js files into one and consequently save on HTTP requests.

The first thing to do is to open your site’s .htaccess file and paste the following code into it:

RewriteEngine On
RewriteBase /
RewriteRule ^css/(.*\.css) /combine.php?type=css&files=$1
RewriteRule ^javascript/(.*\.js) /combine.php?type=javascript&files=$1

Once done, download the combine.php script and upload it on your server. By default this script looks in the JavaScript and CSS directories in the root of your website, but if you are currently using different directories you can manually change these values at the top of the script.

The last thing to do is to create a cache directory that is writable by the web server. Then, you’re all set!
Credit: Rakaz.nl.

Any other tip that you know which should be included in this list? Let us know in a comment!

10 jQuery snippets for efficient web development

Detect Internet Explorer

When it comes to CSS design, Internet Explorer has always been a problem for developpers and designers. Althought the dark ages of IE6 are now gone and IE is les and less popular, it still a good thing to be able to detect it easily. Of course, this snippet can be used to detect other browsers as well.

$(document).ready(function() {
      if (navigator.userAgent.match(/msie/i) ){
        alert('I am an old fashioned Internet Explorer');
      }
});

Source: Stack Overflow

Smooth scrolling to top of the page

Here is one of the most widely used jQuery effects: a click on a link will smoothly scroll the page to the top. Nothing new here, but a must have as every developer will have to code similar functions every once in a while.

$("a[href='#top']").click(function() {
  $("html, body").animate({ scrollTop: 0 }, "slow");
  return false;
});

Source: Stalk Overflow

Stay on top

A very handy code snippets which allows an element to stay fixed on top. Super useful for navigation menus, toolbars or important messages.

$(function(){
	var $win = $(window)
	var $nav = $('.mytoolbar');
	var navTop = $('.mytoolbar').length && $('.mytoolbar').offset().top;
	var isFixed=0;
 
	processScroll()
	$win.on('scroll', processScroll)
 
	function processScroll() {
	var i, scrollTop = $win.scrollTop()
 
	if (scrollTop >= navTop && !isFixed) { 
		isFixed = 1
		$nav.addClass('subnav-fixed')
	} else if (scrollTop <= navTop && isFixed) {
		isFixed = 0
 		$nav.removeClass('subnav-fixed')
	}
}

Source: DesignBump

Replace html tag by another

jQuery makes it super easy to replace a html tag by another. The possibilities are then endless.

$('li').replaceWith(function(){
  return $("<div />").append($(this).contents());
});

Source: Allure Web Solutions

Detect viewport width

Now that mobiles dvices are even more popular than old-fashioned computers, it’s super usefull to be able to easily detect a smaller viewport. Fortunately, it’s supêr easy to do with jQuery.

var responsive_viewport = $(window).width();

/* if is below 481px */
if (responsive_viewport < 481) {
    alert('Viewport is smaller than 481px.');
} /* end smallest screen */

Source: jQuery Rain

Automatically fix broken images

If your site is big and have been online for a couple of years, you’re always more or less at risk of having broken images somewhere. This useful function detects broken images and replace it with an image of your choice, noticing visitors about the problem.

$('img').error(function(){
	$(this).attr('src', 'img/broken.png');
});

Source: WebDesignerDepot

Detect Copy, Paste and Cut Behavior

Using jQuery, it’s super easy to detect copy, paste and cut behaviors on an element of your choice.

$("#textA").bind('copy', function() {
    $('span').text('copy behaviour detected!')
}); 
$("#textA").bind('paste', function() {
    $('span').text('paste behaviour detected!')
}); 
$("#textA").bind('cut', function() {
    $('span').text('cut behaviour detected!')
});

Source: Snipplr

Automatic target=”blank” attribute to external links

When linking to an external site, you might want to use the target="blank" attribute in order to open that site in a new tab. The problem is that the target="blank" attribute isn’t W3C valid. Let’s get jQuery to the rescue: this little snippet will detect if the link is external, and if yes, will automatically add a target="blank" attribute to it.

var root = location.protocol + '//' + location.host;
$('a').not(':contains(root)').click(function(){
    this.target = "_blank";
});

Source: jQuery Rain

Fade In/Out on Hover

Another “classic” snippet to have in your toolbox, as you’ll have to implement it every now and then.

$(document).ready(function(){
    $(".thumbs img").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 60% when the page loads

    $(".thumbs img").hover(function(){
        $(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
    },function(){
        $(this).fadeTo("slow", 0.6); // This should set the opacity back to 60% on mouseout
    });
});

Source: Snipplr

disable space in text/password inputs

Spaces aren’t needed in many form fields, like email, username, password, etc. Here’s a very simple trick to disable spaces on selected inputs.

$('input.nospace').keydown(function(e) {
	if (e.keyCode == 32) {
		return false;
	}
});

Source: Queness

De:comments WordPress plugin giveaway!

A word about de:comments

decomments

De:comments is a WordPress plugin which allows you to enhance the comments section of your blog. Key features include:

  • Multilingual: Already supports English, French, German, Polish, Russian, Ukrainian, Brazilian, Portuguese, Italian, Spanish, Dutch and Turkish.
  • Easy to customize: Open CSS-file so you can add your own web-site styles.
  • Single Sign-on with social networks: Plugin collects all users to your base and they can login from social networks also.
  • Supports WP multisite: One license is valid for all your networks.
  • Voting system: You can allow users to like and dislike each other’s comments. All information about those is stored in your database.
  • Badge system: Encourage the most active users by adding a gamification to commenting process.
  • Media-attachments: Plugin interacts with pictures (even GIFs) perfectly and embeds from social network.
  • Responsive: If your site is responsive the comments will also look wonderful on the mobile screen. Of course it’s Retina.

Pricing goes as follow: $50 for one site, $100 for 3 sites and $300 for ten sites. All prices include one year of free updates and support.

Now that I gave you an overview of how De:comments can improve your blog, the best you can do is to test the plugin and see by yourself. To do so, just head over the demo site.

Don’t forget to follow De:comments on Facebook or Twitter.

Exclusive discount for CatsWhoCode readers

If you’re not the lucky winner of our giveaway, I still have some great news for you: I negotiated an exclusive 30% discount on the De:comments plugin for all my readers.
To use this discount, follow this link and enter the coupon catswhocode30 at checkout!

De:comments plugin Giveaway!

Feeling lucky? Enter our giveaway to try to win a free copy of the de:comments plugin, or exclusive discount coupons of 50% and 40% respectfully.

As usual, entering the giveaway is super easy: just leave a comment on this post to let us know that you’re in. In one week, I will randomly pick three lucky winners who will receive their prize directly from the De:comments staff, by email.

Introduction to Mailtrap: A fake SMTP server for pre-production testing of application email

Using Mailtrap is free for most development tasks. It was created by Railsware team. Essentially, you sign up for Mailtrap and send all of your pre-production environment email via your fake Mailtrap SMTP server.

Later on, all of your emails are introduced to Mailtrap SMTP software. You can view and debug your email within Mailtrap’s friendly GUI.
ou can even use Mailtrap to place dumps of your production database with real user emails through tests on your staging server. Your automated tests can run against the real data—sending emails via Mailtrap, eliminating the risk that test emails go out to real customer email addresses.

How Much Does Mailtrap Cost?

Mailtrap is free for small developers or small tasks. Costs vary between $120 and $300 annually for bigger enterprises.

Let’s Get Started With Mailtrap

You can choose different way to sign up – fill out the registration form or use your Google\Github account:

I used my GitHub account to simplify the process.

After being confirmed, you can find your personal demo inbox:

Mailtrap Settings

Mailtrap can be set up perfectly within your development environment. When you click on the Settings icon in the inbox list, you see that each Mailtrap inbox has its own SMTP server credentials:

You can reset these credentials whenever you want. Various configurations can be found within Mailtrap settings:

For simplicity, I will use the Hello application from our Programming With Yii2 series to configure Mailtrap. If you wish to use the code from there to test Mailtrap, clone the GitHub repository linked to this tutorial.

With Yii, I’m updating the SwiftMailer SMTP settings in config/web.php. Here’s the default:

Which I changed with my Mailtrap settings:

'errorHandler' => [ 
    'errorAction' => 'site/error', 
], 

'mailer' => [ 
    'class' => 'yii\swiftmailer\Mailer', 
    'viewPath' => '@app/mailer', 
    'useFileTransport' => false, 
    'transport' => [ 
        'class' => 'Swift_SmtpTransport', 
        'host' => 'mailtrap.io', 
        'username' => '294XXXXXXXXXXdd20', 
        'password' => '403XXXXXXXXXX2f7', 
        'port' => '25', 
        'encryption' => 'tls', 
    ], 
], 

'log' => [ 
    'traceLevel' => YII_DEBUG ? 3 : 0,

Later on, I visited http://localhost:8888/hello/user/register to sign up again:

Yii sends a confirmation email:

The message instantly appears in my Mailtrap inbox.
Note: This is not to be confused with the Mailtrap account confirmation—it’s the Yii Hello app account confirmation email sent by my application.

The default display is what you might see in Gmail or another mail client:

However, there are many tabs to choose from to debug your application’s outbound email. Here is the HTML source:

Here is how an HTML against your email looks like:

You can also see an analysis of spam score and blacklisting or your message, which is the aim itself:

After using, I would like to admit that Mailtrap is a truly efficient way to debug your outbound email message content.

How Can You Share Inboxes and Messages with Your Team?

For bigger teams, Mailtrap allows inviting numerous developers to access certain mailbox with links:

The Mailtrap API

You can also write automated tests against Mailtrap mailbox content using its API, documented on apiary. In other words, you could run automated scripts against a snapshot of your live production database and verify the content and markup of the messages that would be delivered by your codebase using the Mailtrap API.

This is a guest post by Alex Denisov.

InMotion Hosting review and giveaway

A word about InMotion

InMotion Hosting is an employee-owned and -operated domain name and web hosting company that was founded in 2001. Its web hosting network is based on Linux and Unix operating systems. The company provides a wide range of web hosting solutions, including business class hosting, VPS hosting, personal/cheap hosting and dedicated servers.

What I tested

I was offered to test the popular “Launch Plan”, an all-in-one starter pack for personal websites and blogs. Because InMotion Hosting knows that I’m very interested in WordPress (as well as most of my readers) they thought that plan would be a great pick for me to try.

The first positive surprise was to see that WordPress was already installed on my server. Installing WordPress is super easy, but who wouldn’t want to save a few minutes by leaving the install process to your host?

The “Launch” plan is priced $4.89 a month, which is less than a yearly $60, including the domain name. Not bad!

Now, what if you need a very powerful server, or an unlimited amount of sites? Then go for the “pro” plan. It’s priced $10.49 a month and you can host as many sites as you want. Perfect for hosting a myriad of small websites, for example for your clients if you’re a designer or developer. This plan can also be a total bargain for affiliate marketers who need to set up a huge number of mini-sites and landing pages.

InMotion Highlights

There are three factors that should be always taken into account when choosing a web host:

Uptime: Indeed, you want your website to be available all the time for people to check it. I asked them about it, and the company replied that they have a 99.99% uptime on their servers, which is set to increase even further with the introduction of their new HA/Cloud solutions.
Since testing the InMotion plan, I haven’t experienced any downtime on it.

Security: On my recent article about WordPress security, I stated that you can’t expect a secure website on a non-secure server. InMotion Hosting is taking security seriously, and offers CMS updates, SSL, IMAP email, correro for DDOS, as well as large, fleet-wide backups every 4 months.

Speed: Speed is a super important factor to consider when choosing a web host. A bad quality or poorly optimized server will be slow and will consequently ruin the average quality of your site. InMotion Hosting have a pretty good average speed, as demonstrated below:

Exclusive discount for CatsWhoCode readers

If you’re not the lucky winner of our giveaway, or if you need another kind of hosting than the one we’re giving away, no problem! I negotiated an exclusive 38% discount on InMotion Hosting for my fellow readers.
To use this discount, simply follow this link. No coupon is needed and your 38% off discount will be automatically applied at checkout.

Hosting Giveaway!

InMotion Hosting is very happy to partner with Cats Who Code and offer one lucky reader a free one-year hosting plan, with the domain name!

Entering the giveaway couldn’t be easier: Just leave a comment on this post to let us know that you’re in. In one week, the lucky winner will be randomly picked and will receive his prize directly from the InMotion Hosting staff, by email.

10+ tips for a more secure WordPress blog

Stay updated

As a rule of thumb, every time the WordPress core or a plugin you’re using has an available update, apply it. Updates bring new features, but also security fixes. Although WordPress has automatic background updates since version 3.7, you should always keep an eye on them, as automatic updates may fail to complete from time to time.

Plugins are also a sensitive part of your WordPress installation. Don’t forget to update them as soon as an update is available.

Pick a strong password

It might seem like a dumb tip, but working with WordPress (and websites in general) every day, I can tell you that most people are still using weak passwords to protect something as important as their own website.

A strong password has:

  • at least 15 characters
  • uppercase letters
  • lowercase letters
  • numbers
  • symbols, such as ` ! " ? $ ? % ^ & * ( ) _ - + = { [ } ] :

A strong password is not:

  • your login or username
  • your name, your friend’s name, your family member’s name, or a common name
  • a dictionary word
  • like your previous passwords
  • your date of birth
  • a keyboard pattern, such as qwerty, asdfghjkl, or 12345678

Need help to pick a super strong password? Head over this simple but efficient web app.

Pick a random user name

Attackers know that most people are using usernames such as “admin” or the url of their website. By picking a random user name, you’re making their task more difficult.

Host your website on a reliable web host

Especially if you’re on a shared server (this is the case of most small websites such as a personal blog), attackers can use corrupted files on the server, even if they aren’t yours, to spread on other websites hosted on the server. This can’t be fully stopped by you alone, this is why you need to be sure that your web host is super serious about security and offers a strong customer support that will always be helpful in case something goes wrong.

Below are the three web hosts I personally work with and recommend for their performance and security:

Vidahost: this company has been hosting CatsWhoCode since 2012. The speed and availability are amazing and the support service always responds fast, even on Sundays or in the middle of the night. The only downpoint is the somewhat expensive price, but just like cheap hosting isn’t good, good hosting isn’t cheap.
Good news: by using the coupon CATSWHOCODE when checking out, you’ll get 10% off any hosting plan.

A Small Orange: A company I work with, as well as many of my partners do. A Small Orange is offering an exclusive discount to CWC readers consisting of one year of hosting + a domain name for only $40. Definitely a great deal for serious websites owners.

In Motion Hosting: I haven’t worked with them directly yet, but I’ve been fixing quite a lot of websites hosted on their servers and everything was smooth. Definitely worth checking!

Have backups

If a problem happens, it is essential that you have a backup of both your database and files, so you can restore it to your server. Backups can be done manually or using a plugin such as WP Database Backup. Your web host can also make regular back-ups of your website and database. The three hosts I mentioned above do free, regular backups for their clients and their support service can help you to restore it to your server in case of an attack.

Use .htaccess to protect wp-login

Password protecting your wp-login.php file can add an extra layer to your server. Because password protecting wp-admin can break any plugin that uses ajax on the front end, it’s usually sufficient to just protect wp-login.php.

To do this, you will need to create a .htpasswd file. To do so, go to htpasswd generator and follow the instructions. Once you have your file ready, upload it to your server.

Once done, you need to tell .htaccess where it’s at. Assuming you’ve put .htpasswd in your user’s home directory and your htpasswd username is mysecretuser, then you put this in your .htaccess file:

# Stop Apache from serving .ht* files
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>

# Protect wp-login
<Files wp-login.php>
AuthUserFile ~/.htpasswd
AuthName "Private access"
AuthType Basic
require user mysecretuser
</Files>

If you’re looking for a plugin instead of doing it by yourself, have a look at AskApache Password Protect. Please note though, that it hasn’t been updated in a year. I haven’t tried it myself so I can’t really neither recommend nor not recommend this plugin.

Remove unnecessary error messages

Login error messages are useful, but unfortunately, they can also provide information to attackers.

To get rid of login errors display on your wp-login.php page, open your functions.php file and append the code below to it:

add_filter('login_errors',create_function('$a', "return null;"));

Be careful with plugins and themes

Basically, everything you add to your WordPress install (Themes and Plugins) potentially contains vulnerable code. In fact, anyone can write and offer a plugin or theme.

When choosing a plugin or a theme, make sure that:

  • You get it from a reliable source, such as the official WordPress.org repositories
  • The plugin/theme is well maintained and has been updated recently
  • The plugin has a significant number of installs and/or ratings

Premium themes and plugins that you can find available for free might often contain malicious code injected in them. Sure, a premium theme or a plugin is an investment, but the average $60 you’ll spend is a lot cheaper than the help of a developer or security expert to help you with a broken or a hijacked website. Established premium theme/plugin sellers as such as ElegantThemes, ThemeForest or Themify are very serious about security.

Rename your database tables

By default, WordPress uses wp_ to prefix your database tables. While it can be easily changed when installing WordPress, unfortunately most users don’t modify the default prefix. It makes it easier for attackers to target your database.

Happily, there’s a handy plugin called DB Prefix Change which allows you to easily change your database prefix from the default wp_ to something unique and virtually impossible to guess.

Disable file editing

WordPress features a built-in file editor, which can be very useful to edit your theme on the fly. Unfortunately, if an attacker gains access to your WordPress dashboard as an administrator, he will be able to edit your files, and do much damage. For this reason, you might want to disable WordPress built-in file editor and use a regular FTP program to edit your theme files instead.

To do so, simply paste the code below into your wp-config.php file, which is located at the root of your WordPress install.

define('DISALLOW_FILE_EDIT', true);

Make use of the All In One WP Security & Firewall plugin

The All In One WordPress Security plugin will take your website security to a whole new level. Designed and written by experts, it reduces security risk by checking for vulnerabilities, and by implementing and enforcing the latest recommended WordPress security practices and techniques.

Install All In One WP Security from your WordPress dashboard or download it from here.

Giveaway: Win a license for the Salon booking WordPress plugin

Introducing Salon Booking

What is it?
A complete and easy to manage appointments booking system for busy barber shops, beauticians, therapist, tutors and whoever sell his skills and time to live on appointment base.

Who is it for?
Freelance web designers and web agencies that need a reliable solution for wordpress based projects where an online appointment booking system is required.

Which business fields can benefit from this system?

  • Hair dresser salons
  • Barber shops
  • Beauty salonSs
  • Spas
  • Car shops
  • Therapists
  • Tutors
  • Hourly based rental shops

What make this plugin different from the others already on the market?
Salon Booking is focused on specific needs of hourly based, “to-persons” services provided upon appointment. Is not-for all solution but is specific niche market focused solution.

What are the plus of Salon Booking?
Providing all those settings that allow to replicate all the common characteristics of our customers real business in order to control all crucial appointment bookings processes.

What’s the pricing of Salon booking plugin?
The pricing goes as follow:

  • Single activation PRO license: 69 euros
  • 5 activation PRO license: 149 euros
  • Unlimited activations PRO license: 229 euros

There is also a free version of the plugin available on: https://wordpress.org/plugins/salon-booking-system/

How to enter the giveaway

Entering our giveaway is simple and easy: Just comment on this post, and you’re in! In one week (March 8, 2016), the lucky winner will be randomly chosen and announced in the comments. You’ll receive your fee license for the plugin directly on your email, so make sure that it is valid!

If you don’t want to wait or participate to the giveaway, I negociated for you an exlusive 20% discount for CWC readers! Head over the Deals page of the site to grab it.

Now, good luck everybody!

5 ready-to-use Bootstrap form templates for your projects

Vertical login form


A very basic form template that can be easily enhanced and modified to suit almost any need. Use it as a starting point for almost any kind of simple forms, such as login forms, contact forms, etc.

 <form role="form">
  <div class="form-group">
    <label for="email">Email address:</label>
    <input type="email" class="form-control" id="email">
  </div>
  <div class="form-group">
    <label for="pwd">Password:</label>
    <input type="password" class="form-control" id="pwd">
  </div>
  <div class="checkbox">
    <label><input type="checkbox"> Remember me</label>
  </div>
  <button type="submit" class="btn btn-default">Submit</button>
</form>

→ Source: W3 Schools

Inline login form


Inline forms are widespread, especially when it comes to login forms. Look at the code below. Notice any change from the previous form? In fact the single difference between this code and the previous one is the .form-inline class added to the form HTML element.

 <form class="form-inline" role="form">
  <div class="form-group">
    <label for="email">Email address:</label>
    <input type="email" class="form-control" id="email">
  </div>
  <div class="form-group">
    <label for="pwd">Password:</label>
    <input type="password" class="form-control" id="pwd">
  </div>
  <div class="checkbox">
    <label><input type="checkbox"> Remember me</label>
  </div>
  <button type="submit" class="btn btn-default">Submit</button>
</form>

→ Source: W3 Schools

Contact form


Contact forms are probably the most popular forms ever, as nearly every website features at least one. Here’s a quality template for all your contact form needs, plus a little CSS to make it look better. Also note that this example makes an interesting usage of Bootstrap’s glyphicons.

<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="well well-sm">
                <form class="form-horizontal" method="post">
                    <fieldset>
                        <legend class="text-center header">Contact us</legend>

                        <div class="form-group">
                            <span class="col-md-1 col-md-offset-2 text-center"><i class="fa fa-user bigicon"></i></span>
                            <div class="col-md-8">
                                <input id="fname" name="name" type="text" placeholder="First Name" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <span class="col-md-1 col-md-offset-2 text-center"><i class="fa fa-user bigicon"></i></span>
                            <div class="col-md-8">
                                <input id="lname" name="name" type="text" placeholder="Last Name" class="form-control">
                            </div>
                        </div>

                        <div class="form-group">
                            <span class="col-md-1 col-md-offset-2 text-center"><i class="fa fa-envelope-o bigicon"></i></span>
                            <div class="col-md-8">
                                <input id="email" name="email" type="text" placeholder="Email Address" class="form-control">
                            </div>
                        </div>

                        <div class="form-group">
                            <span class="col-md-1 col-md-offset-2 text-center"><i class="fa fa-phone-square bigicon"></i></span>
                            <div class="col-md-8">
                                <input id="phone" name="phone" type="text" placeholder="Phone" class="form-control">
                            </div>
                        </div>

                        <div class="form-group">
                            <span class="col-md-1 col-md-offset-2 text-center"><i class="fa fa-pencil-square-o bigicon"></i></span>
                            <div class="col-md-8">
                                <textarea class="form-control" id="message" name="message" placeholder="Enter your massage for us here. We will get back to you within 2 business days." rows="7"></textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-12 text-center">
                                <button type="submit" class="btn btn-primary btn-lg">Submit</button>
                            </div>
                        </div>
                    </fieldset>
                </form>
            </div>
        </div>
    </div>
</div>

Associated CSS:

.header {
    color: #36A0FF;
    font-size: 27px;
    padding: 10px;
}

.bigicon {
    font-size: 35px;
    color: #36A0FF;
}

→ Source: PreBootstrap

Address form


Here is a pretty complete form, featuring basically everything you need to collect a postal address from a (US) customer. Use it as it is or customize it as needed!

<form>

	<div class="form-group"> <!-- Full Name -->
		<label for="full_name_id" class="control-label">Full Name</label>
		<input type="text" class="form-control" id="full_name_id" name="full_name" placeholder="John Deer">
	</div>	

	<div class="form-group"> <!-- Street 1 -->
		<label for="street1_id" class="control-label">Street Address 1</label>
		<input type="text" class="form-control" id="street1_id" name="street1" placeholder="Street address, P.O. box, company name, c/o">
	</div>					
							
	<div class="form-group"> <!-- Street 2 -->
		<label for="street2_id" class="control-label">Street Address 2</label>
		<input type="text" class="form-control" id="street2_id" name="street2" placeholder="Apartment, suite, unit, building, floor, etc.">
	</div>	

	<div class="form-group"> <!-- City-->
		<label for="city_id" class="control-label">City</label>
		<input type="text" class="form-control" id="city_id" name="city" placeholder="Smallville">
	</div>									
							
	<div class="form-group"> <!-- State Button -->
		<label for="state_id" class="control-label">State</label>
		<select class="form-control" id="state_id">
			<option value="AL">Alabama</option>
			<option value="AK">Alaska</option>
			<option value="AZ">Arizona</option>
			<option value="AR">Arkansas</option>
			<option value="CA">California</option>
			<option value="CO">Colorado</option>
			<option value="CT">Connecticut</option>
			<option value="DE">Delaware</option>
			<option value="DC">District Of Columbia</option>
			<option value="FL">Florida</option>
			<option value="GA">Georgia</option>
			<option value="HI">Hawaii</option>
			<option value="ID">Idaho</option>
			<option value="IL">Illinois</option>
			<option value="IN">Indiana</option>
			<option value="IA">Iowa</option>
			<option value="KS">Kansas</option>
			<option value="KY">Kentucky</option>
			<option value="LA">Louisiana</option>
			<option value="ME">Maine</option>
			<option value="MD">Maryland</option>
			<option value="MA">Massachusetts</option>
			<option value="MI">Michigan</option>
			<option value="MN">Minnesota</option>
			<option value="MS">Mississippi</option>
			<option value="MO">Missouri</option>
			<option value="MT">Montana</option>
			<option value="NE">Nebraska</option>
			<option value="NV">Nevada</option>
			<option value="NH">New Hampshire</option>
			<option value="NJ">New Jersey</option>
			<option value="NM">New Mexico</option>
			<option value="NY">New York</option>
			<option value="NC">North Carolina</option>
			<option value="ND">North Dakota</option>
			<option value="OH">Ohio</option>
			<option value="OK">Oklahoma</option>
			<option value="OR">Oregon</option>
			<option value="PA">Pennsylvania</option>
			<option value="RI">Rhode Island</option>
			<option value="SC">South Carolina</option>
			<option value="SD">South Dakota</option>
			<option value="TN">Tennessee</option>
			<option value="TX">Texas</option>
			<option value="UT">Utah</option>
			<option value="VT">Vermont</option>
			<option value="VA">Virginia</option>
			<option value="WA">Washington</option>
			<option value="WV">West Virginia</option>
			<option value="WI">Wisconsin</option>
			<option value="WY">Wyoming</option>
		</select>					
	</div>
	
	<div class="form-group"> <!-- Zip Code-->
		<label for="zip_id" class="control-label">Zip Code</label>
		<input type="text" class="form-control" id="zip_id" name="zip" placeholder="#####">
	</div>		
	
	<div class="form-group"> <!-- Submit Button -->
		<button type="submit" class="btn btn-primary">Buy!</button>
	</div>     
	
</form>			

→ Source: Formden.com

Credit card form


Let’s finish this round-up with another useful form, allowing visitors to communicate their credit card number. Please keep in mind that this is only the HTML interface, credit card forms need serious back-end validation.

<form action="#" class="credit-card-div">
<div class="panel panel-default" >
 <div class="panel-heading">
     
      <div class="row ">
              <div class="col-md-12">
                  <input type="text" class="form-control" placeholder="Enter Card Number" />
              </div>
          </div>
     <div class="row ">
              <div class="col-md-3 col-sm-3 col-xs-3">
                  <span class="help-block text-muted small-font" > Expiry Month</span>
                  <input type="text" class="form-control" placeholder="MM" />
              </div>
         <div class="col-md-3 col-sm-3 col-xs-3">
                  <span class="help-block text-muted small-font" >  Expiry Year</span>
                  <input type="text" class="form-control" placeholder="YY" />
              </div>
        <div class="col-md-3 col-sm-3 col-xs-3">
                  <span class="help-block text-muted small-font" >  CCV</span>
                  <input type="text" class="form-control" placeholder="CCV" />
              </div>
         <div class="col-md-3 col-sm-3 col-xs-3">
<img src="assets/img/1.png" class="img-rounded" />
         </div>
          </div>
     <div class="row ">
              <div class="col-md-12 pad-adjust">

                  <input type="text" class="form-control" placeholder="Name On The Card" />
              </div>
          </div>
     <div class="row">
<div class="col-md-12 pad-adjust">
    <div class="checkbox">
    <label>
      <input type="checkbox" checked class="text-muted"> Save details for fast payments <a href="#"> learn how ?</a>
    </label>
  </div>
</div>
     </div>
       <div class="row ">
            <div class="col-md-6 col-sm-6 col-xs-6 pad-adjust">
                 <input type="submit"  class="btn btn-danger" value="CANCEL" />
              </div>
              <div class="col-md-6 col-sm-6 col-xs-6 pad-adjust">
                  <input type="submit"  class="btn btn-warning btn-block" value="PAY NOW" />
              </div>
          </div>
     
                   </div>
              </div>
</form>

Associated CSS code:

<style>
.credit-card-div  span { padding-top:10px; }
.credit-card-div img { padding-top:30px; }
.credit-card-div .small-font { font-size:9px; }
.credit-card-div .pad-adjust { padding-top:10px; }
</style>

→ Source: Design Bootstrap

Want more?


If you’re looking for more Bootstrap form templates, or more complete stuff (including custom CSS and JavaScript) then make sure to have a look to this page where 150+ forms for all needs can be downloaded. A gold mine!

How to create a pure swift module

If you are already in touch with Swift, you probably assumed that including third party libraries into your project would be useful. Railsware.com Mobile Developers and Alex Denisov, iOS Engineer and a huge Open Source fan, are ready to talk about it.

Making a custom framework that includes both ObjC and Swift code is very easy because Apple provides a mechanism to distribute code via frameworks (eventually, for iOS too). Next step into proper development is a creation of a pure Swift module, like Apple does with Swift’ std lib and Cocoa/Cocoa Touch bridge.

Basically, we are generating a simple module call Logger that will contain only one method: log.
You need at least three files to form a Swift module, so we should get all of them as an output:
Logger.swiftmodule – public interface/definitions
Logger.swiftdoc – docs (surprisingly)
libLogger.a – built library (there also might be a dylib, it depends on your task)
We can start with creating an unserviceable Logger library:

The class just takes some prefix and logs it before actual object:

Now it’s time to make a libLogger.a. The code will look like this:

xcrun swift -emit-library -emit-object Logger.swift -sdk $(xcrun --show-sdk-path --sdk macosx) -module-name Logger
ar rcs libLogger.a Logger.o

-emit-library generates dynamically linked shared library, while -emit-object generates object file and includes main function, so you will have linker errors due to duplicated symbols.
The solution is simple: include both flags -emit-object and -emit-library, as is depicted above.

The next step is generating Logger.swiftdoc and Logger.swiftmodule:

xcrun swift -emit-module Logger.swift -sdk $(xcrun --show-sdk-path --sdk macosx) -module-name Logger

Now that you have a complete module, it is about time to integrate it into a real project. Create a simple Swift project and add the files:

Then setup “Import paths” for Swift:

You can now check out if your project works properly:

Voila!

Dealing with documentation is rather simple, as well. To add documentation to module you need to comment it using ///, e.g.:

You will see documentation on the right after its integration:

Note: to make it work after integrating, you have to restart Xcode.
This approach might not be applied for a regular iOS/OSX developer; it requires creating and supporting Make/CMake file, which complicates the process of generation. However, it may be useful if you want to create a pure module that does not include ObjC at all.

This is a guest post by Alex Denisov

Super useful tools to simplify forms development

jQuery UI


When it comes to forms, the easiest way to enhance them is to use to a well-known jQuery UI plugin. It adds a lot of functionalities to basic HTML5 forms, such as date pickers, autocomplete fields, tabs, and more. A must-use for every form that your visitors are going to love!

Info/Download

PureCSS.io


Styling forms is often a long task. Pure CSS is a lightweight CSS framework which allows you to create good looking forms in a matter of minutes, with an outstanding support of latest HTML5 specs.
Info/Download

Bootstrap


Bootstrap is widely known among front-end developers, and well, there’s really nothing surprising considering how amazing this free tool is. Bootstrap is a complete front-end framework that allows you to save a lot of time when creating forms, as well as any other parts of a website. Tons of nowadays’ websites has been made with the help of Bootstrap. If you haven’t tried it yet, well, you must do it a.s.a.p.!
Info/Download

jQuery Bootstrap validator


Talking about Bootstrap… what about enhancing its possibilities by coupling it with some jQuery? As its name says, this handy plugin provides a lot of front-end validation options and is especially designed to work on projects made with Bootstrap.
Info/Download

jQuery Form Plugin


The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. The main methods, ajaxForm and ajaxSubmit, gather information from the form element to determine how to manage the submit process. Both of these methods support numerous options which allows you to have full control over how the data is submitted. Submitting a form with AJAX doesn’t get any easier than this!
Info/Download

Pork Form Validation

Creating forms is one thing, validating the sent data is another. Forms are a sensitive part of a website and as a developer, you must always think about security first. This is why all data sent by forms should be carefully validated.

Pork Form Validation is a php class that handle, as you probably guessed, validation of data sent by forms. If you’re using a PHP framework such as CodeIgniter or Cake PHP you won’t need this as those powerful tools already have plenty of tools to validate data, but in case of a smaller development I definitely love to save time and hassle by using Pork Form Validation.

Here’s a quick example about how it works:

$validations = array(
    'name' => 'anything',
    'email' => 'email',
    'alias' => 'anything',
    'pwd'=>'anything',
    'gsm' => 'phone',
    'birthdate' => 'date');
$required = array('name', 'email', 'alias', 'pwd');
$sanatize = array('alias');

$validator = new FormValidator($validations, $required, $sanatize);

if($validator->validate($_POST)) {
    $_POST = $validator->sanatize($_POST);
    // now do your saving, $_POST has been sanatized.
    die($validator->getScript()."<script type='text/javascript'>alert('saved changes');</script>");
} else {
    die($validator->getScript());
}

To validate just one element:

$validated = new FormValidator()->validate('blah@bla.', 'email');

To sanitize just one element:

$sanatized = new FormValidator()->sanatize('<b>blah</b>', 'string');

Info/Download

Top 5 free WordPress plugins to monetize your blog

SEO Smart Links


When it comes to generating some money on a website without bloating it with countless ads, a very interesting solution to look at is definitely SEO Smart Links.

This plugin allows you to enter keywords or keyphrases, and link them to a hyperlink. So let’s say that you often blog about WordPress plugins. Just use the plugin to link the term “WordPress plugins” to your favorite WP Plugin vendor affiliate program, for example ThemeForest or WPZoom. An easy way to make a few bucks while keeping your content relevant and without a ton of ads.
Download

Disqus


I already blogged about the Disqus comment system, a plugin with a lot of good points: a lot less spam, less database queries, and the chance for your users to discover new content (including yours). But if you have already installed Disqus, you’ve probably noticed that ads are displayed on top of your comments. Go to your Disqus control panel and enter your details: once your earnings reach $100, Disqus will send you the money via PayPal.

Don’t expect to make millions with this, but if you’re owning a somewhat popular blog, Disqus could be the chance to cover your hosting expenses while providing interesting features to both you and your readers.

Note that Disqus ads are blocked by Adblock and other ad blockers.
Download

Redirection


Affiliate marketing is probably the best way to make money with a website. The principle is simple: You link to some vendor website, and if your referral buys the product, you get a commission. In order to multiply your chances to make some real money, you should never hesitate to join affiliate programs of products you are blogging about. But then, the problem is that you have to manage your countless affiliate links.

While it’s not the plugin’s primary purpose, Redirection is widely used as a way to manage affiliate links. Extremely easily, you can cloak your affiliate links, and keep a track of how many clicks they received. All that for free!
Download

Membership


While I’ve never done it myself, I know a bunch of bloggers who are making money by providing “premium” content in exchange for a monthly fee. If you own a WordPress blog, the Membership plugin can turn your site into a partly-premium content platform.

The basic version of Membership is free, and there’s also a premium version available if you need extra features. If you’re interested in the premium version, make sure to visit my Deals page to grab a 50% discount on WPmu Dev plugins, including Membership.
Download

WP125


A few years ago, 125*125 pixels ads were very popular among bloggers and advertisers. In 2016, this ad format is probably living its last months, but you can still make some money with those ads.

You can join an ad network such as BuySellAds.com, or manage your own ads yourself. If this is what you decide, then the WP125 plugin is definitely the best way to display 125*125px ads on your WordPress blog.
Download

10 WordPress themes for freelance web developers

Corporate




Corporate is a very nice looking theme with a lot of CSS3 eye-candy. It features all the sections a freelance web developer or designer can dream of, such as portfolio, testimonials, team, blog, and more.
Info/Demo/Download

Nimble




Nimble is a very elegant WordPress theme with a lot of page templates (contact form, image gallery, portfolio, login page, advanced search) and useful features for individual or small businesses looking for a simple and flexible way to showcase their work.
Info/Demo/Download

Vertex




Vertex is a responsive, fast loading and good-looking theme for freelancers, start-ups or small businesses. Everything you need to start your freelancer site is included: projects, blog, testimonials, skills…
Info/Demo/Download

Nexus




Nexus is a fully responsive, modern and multipurpose template based on the Bootstrap 3 framework. It’s created for creative professionals, agencies, content creators, freelancers, etc.
Info/Demo/Download

SeoHub




I really love this theme. The design looks great, it’s fully responsive, it loads fast, and it’s got everything a freelancer needs to kickstart his website. Definitely a great choice.
Info/Demo/Download

StartingUp




StartingUp is a nicely designed and well coded theme, perfect for freelance web developers, designers, or startups. It features many useful modules to get started quickly: price tables, media slider, contact form, call to action, and more.
Info/Demo/Download

Paris




Paris is based on popular Twitter Bootstrap framework. This all-in-one package includes the awesome Revolution Slider Plugin (18$ Value), Visual Composer Plugin ($32 Value), Ultimate Addons Plugin ($17 Value) unlimited customizability, built-in mega menu, full WooCommerce design integration, premium Cube Portfolio plugin ($16 value), typographic options with over 600+ Google fonts, robust admin panel with hundreds of options to make it your own, tons of useful visual page builder elements and 15 pre-configured page layouts, available with just 1 click (really!!) installation.
Info/Demo/Download

Make




Make is a beautifully crafted theme for portfolios, freelancing or showcasing products & services. The theme comes with more than 90 pre-designed demo pages.
Info/Demo/Download

Kreate




“Made by creatives, for creatives” is Kreate’s motto. This amazing theme features 12 different homepages and a ton of options to make the perfect freelancer/agency websites with minimum work.
Info/Demo/Download

Lydia




Lydia is a flat and responsive WordPress Theme with a clean and professional design which will be a great solution for creative freelancers. Lydia includes unlimited color schemes, visual composer, various homepages, and more.
Info/Demo/Download

10 easy yet amazing CSS tips to embellish your website

Font Smoothing


A very simple, yet efficient way to make your font look smoother.

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

Source: David Walsh

Fade in on hover

A very easy way to make your links (or any other element) look better.

a {
 color: #000;
 -webkit-transition: color 1s ease-in; /*safari and chrome */
 -moz-transition: color 1s ease-in; /* firefox */
 -o-transition: color 1s ease-in; /* opera */
}

a:hover { 
 color: #c00;
}

Source: Matt Lambert

Icon fonts embedding


Using icon webfonts is super easy. The first thing to do is to download a font. In this example I’m using the amazing MFG Labs font that you can download for free here. Feel free to browse the collection linked below if you prefer to use another font.

Once done, upload the files on your webserver and add the downloaded stylesheet to your website. For better performance, I recommend that you copy/paste the content of the stylesheet into your website’s main style.css file.

And finally, you simply have to drop the markup in your html file. Below is an example of creating two icons with links to my Twitter and Facebook profiles.

<a href="https://twitter.com/catswhocode"><i class="icon-twitter_circle icon2x"></i></a>
<a href="https://www.facebook.com/catswhocode"><i class="icon-facebook_cricle icon2x"></i></a>

Circular images


A super easy way to display any square image in a circular form.

The HTML

<img class="circular-square" src="woman.png" />

And the css:

.circular-square {
  border-radius: 50%;
}

Source: 6 Revisions

Glow text


This might be a bit “too much”, but it’s still quite interesting.

.glow{
        color: #fff;
        background-color: #474747;
        text-shadow: #fff 0 0 10px;

Source: CSS3 Gen

3D Text


A text in 3D, perfect for a site logo or a title.

h1 {
  text-shadow: 0 1px 0 #ccc,
               0 2px 0 #c9c9c9,
               0 3px 0 #bbb,
               0 4px 0 #b9b9b9,
               0 5px 0 #aaa,
               0 6px 1px rgba(0,0,0,.1),
               0 0 5px rgba(0,0,0,.1),
               0 1px 3px rgba(0,0,0,.3),
               0 3px 5px rgba(0,0,0,.2),
               0 5px 10px rgba(0,0,0,.25),
               0 10px 10px rgba(0,0,0,.2),
               0 20px 20px rgba(0,0,0,.15);
}

Source: Mark Dotto

Animated background image

A very simple trick to give life to any background image.

#cloud-scroll {
width: 200px;
height: 200px;
background: url(clouds-full.png) repeat-y;
-webkit-animation: backgroundScroll 20s linear infinite;
animation: backgroundScroll 20s linear infinite;
}
 
@-webkit-keyframes backgroundScroll {
from {background-position: 0 0;}
to {background-position: -400px 0;}
}
 
@keyframes backgroundScroll {
from {background-position: 0 0;}
to {background-position: -400px 0;}
}

Source: HTML5 and beyond

Text stroke effect


Using the .text-shadow property to create a stroke effect in no time. Who needs Photoshop anymore?

.stroke{
        font-size: 2em;
        font-family: 'Oswald', sans-serif;
        color: #fff;
        text-shadow: 1px 1px 0 #333, 1px -1px 0 #333, -1px 1px 0 #333, -1px -1px 0 #333;

Source: HTML5 and beyond

Shake element

Shake any element using pure CSS. Useful if you need to catch the attention of a visitor on a specific action, such as an error in a form.

.face:hover {
  animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  perspective: 1000px;
}

@keyframes shake {
  10%, 90% {
    transform: translate3d(-1px, 0, 0);
  }
  
  20%, 80% {
    transform: translate3d(2px, 0, 0);
  }

  30%, 50%, 70% {
    transform: translate3d(-4px, 0, 0);
  }

  40%, 60% {
    transform: translate3d(4px, 0, 0);
  }
}

Source: CSS Tricks

Rotate elements


Some extremely easy-to-do eye candy. Can look really cool when used on the :hover pseudo-class.

.rotate{
        transform: rotate(30deg);
}

Source: The art of web

WordPress tutorial: Create a minimal mobile menu

There’s a demo available for this tutorial, click here to see.

This menu is inspired by the awesome Treehouse tutorial. Check it out if you’re looking for a static, html/css menu!

WordPress Mobile Menu

Getting started

As we’re using WordPress, the first thing we have to do is to create a menu. You can use an existing menu from your blog, but I recommend creating a specific menu, since you might want to feature only the most important sections of your website in its mobile version.

Right on, login to your WordPress dashboard and navigate to “Appearence” → “Editor” and edit your theme’s functions.php file. We first have to create a new menu location. Here is the code to register a menu location named mobile-menu:

add_action( 'init', 'register_my_menu' );

function register_my_menu() {
        register_nav_menu( 'mobile-menu', __( 'Mobile Menu' ) );
}

If your theme already has one or more menu location(s), you should use the register_nav_menus() function instead. This function works the same as register_nav_menu() but allows you to register multiple menu locations at the same time. Here’s an example:

register_nav_menus( array(
	'main_menu' => 'Main Navigation Menu',
	'mobile_menu' => 'Mobile Menu',
) );

After registering the new menu location, you now have to edit the header.php file and paste the following code where you want your mobile menu to appear:

<nav id="mobile-menu">
    <a href="#" id="menu-icon"></a>
    <?php wp_nav_menu( array( 'theme_location' => 'mobile-menu' ) ); ?>
</nav>

Now, go to “Appearence” → “Menus”. Create a new menu named “Mobile Menu” and add a few pages/links into it, as shown in the picture below:

Once the menu is created, assign it to the Mobile Menu location.

Basic CSS

We don’t want our menu to be shown by default, but only on mobile devices. What we have to do is pretty simple, hide the menu by default by using the display css property.

The declarations I’ve put between comments are the ones I used as basic stylesheet on the demo, but you won’t need them if you implement this code into an existing WordPress theme.

The code below goes straight to the style.css file used by your WordPress theme.

/* body{ font-family: Arial; font-size:15px; color:#555} */
/* header, main{ width:900px;margin:0 auto;} */
/* header { position:relative } */
#mobile-menu{ display: none }

Adding Media queries

As we’re building a mobile menu, we just want it to be visible for smaller devices. Indeed, we have to use a media query to target devices with a screen width smaller than 767 pixels. Here’s the code:

@media only screen and (max-width: 767px) {
header, main{ width:90%}
	
	/* mobile menu */
	#mobile-menu{ display: block }
	
	#menu-icon {
		width: 40px;
		height: 40px;
		display: block;
		background: #7AD03A ;
		float: right;
		margin-top: 10px;
		text-indent:-9999px
	}

	nav ul, nav:active ul { 

		display: none;
		position: absolute;
		padding: 20px;
		background: #7AD03A;
		right: 0px;
		top: 35px;
		width: 50%;
		border-radius: 4px 0 4px 4px;

	}

	nav li {
		list-style-type:none;
		text-align: center;
		width: 100%;
		padding: 10px 0;
		margin: 0;
	}

	nav li a{ color:#fff !important; text-decoration:none !important; display:block}
	nav:hover ul { display: block; }

	}
	
}

If you save the modified files and have a look at your menu, it should already look pretty good. But wait, we’re gonna enhance it even more.

Using an icon font embedding to style the menu

Remember last week when I talked about using icon fonts instead of images? Well, today is definitely the right day to put that knowledge into practice.

In this example, I’m using the amazing MFG Labs font that you can download for free here. If you’d like to use another kit, feel free to browse this collection that I’ve compiled a few weeks ago.

Let’s go: download the MFG Labs Font, unzip the archive and upload the fonts and stylesheet to your server, in your theme directory. Then, open your header.php file and link to the stylesheet:

<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/mfglabs_iconset.css">

Now we have to modify a bit the code we wrote previously. Open your header.php file and look up for the following line:

<a href="#" id="menu-icon"></a>

Replace it by:

<a href="#" id="menu-icon"><i class="icon-list icon2x"></i></a>

The last thing we have to do is to tweak our css code a little for the icon to display nicely. Open your style.css file and look up for this:

#menu-icon {
	width: 40px;
	height: 40px;
	display: block;
	background: #7AD03A ;
	float: right;
	margin-top: 10px;
}

… and add the three declarations below:

text-align: center;
color: #fff;
text-decoration:none;

Save the files, and your menu is ready. Looks cool, doesn’t it?

Giveaway: Win a copy of the PE beauty center WordPress theme

All you need for a successful site!

It is standard nowadays that the theme includes tons of settings like unlimited theme colors, over 600 fonts or layout configuration with collapsible widget positions, so PE Beauty Center also does. Even more, excepting the general settings you may set the specific display options for blog, posts, pages or a contact page. You will find the detailed specification of each theme area in the open access documentation, and won’t have to wonder what you expect but check the flexibility of the theme.

Each beauty salon should have a list of available services for customers. With this theme you may create a comprehensive presentation of your company services and display them in an eye catching way by combining simple layout options. Display the image for each service, add the title and subtitle – it may be a service price or something special about the item. Then write the full description for the service to let your customer learn more about it.

Watch this short video and see how simple submitting the service is:

Moreover, you may optionally introduce your team to your customers by creating short description or portfolio of your workers. There are 2 custom widgets you may use for displaying team members.

The theme is fully widgetized and includes several custom widgets created for its purpose. Amongst others this WordPress theme for a beauty center provides lots of useful custom codes and shortcodes, awesome fonts, off canvas sidebar, social Addthis sharing integration or any code injection and a lot more! It’s also RTL compatible.

It’s worth mentioning that Revolution Slider is included in the theme price which is extremely low now! You may get it for $29 + have installed the demo copy for free if you send us a secret code, which is “catswhocode”.

PE Beauty Center is a responsive spa and beauty WordPress theme, lightweight, fast loading and mobile friendly – it supports mobile devices. You may check the high web performance scoring on PixelEmu site.

Watch the full theme presentation and catch other important info:

The giveaway

So, do you want a free copy of this amazing theme? If yes, retweet this post, like Pixelemu on Facebook and leave a comment below. In one week, I’ll randomly pick a lucky winner who’ll receive the theme by email directly by Pixelemu. Best of luck to you!