WordPress Deployment with Deploy, Git and Bitbucket

In recent years, developers have used WordPress for more powerful and complex sites.

As WordPress sites have become more complex, developers have required better tools. It’s not common to version control and to have multiple deployment environments for production, staging or testing.

In this tutorial, we’re going to show you one way to manage and deploy WordPress sites professionally. We’re going to use Bitbucket, Deploy and Git to deploy a WordPress site.

Read more on OSTraining.com

Using Bootstrap the Right (Semantic) Way

Back in the year 2000, when I first started learning web development, tables were my best friend.

The web was filled with <tr> and <td> and semantics were non-existent. Images were broken down and placed in bits & pieces inside different table cells.

Things changed in mid-2003 when I came across a site csszengarden.com. This site showcased the new and the right way of doing things, which was to separate content & presentation. After all, that is the reason CSS was created in the first place.

Learn more on OSTraining.com

http://youtu.be/WMMig4VIXlI

Advertisement like these come and go without ever getting etched into our memory. There are very few advertisements remembered for their uniqueness and some just for the controversy they generate.

What is this advertisement about?

A kid remembers t0o late about his next day’s school project and so his parent’s work on his project which results in him getting an “A” grade.

Why I feel so strongly about this advertisement to write about it?

State of India

In a country like India with many religions and caste system, the backward classes never had any chance until India achieved independence in 1947. To tackle these issues, quota (reservations) were set up wherein seats were reserved for backward castes in colleges and government jobs. But like everything else, this too is often misused and holds no sense in today’s India.

Everything should be based purely on merit. I don’t believe in setting up any reservation but I do believe that even today these reservations do help some deserving students. And this oftens gets me into arguments with my friends and colleagues who hate reservations and feel it’s not fair.

A perfect system would be a system where reservation is based on a person’s merit and exceptions should be made only after considering a person’s talent and their financial situation. But there is no perfect system. And when I see people complaining about the reservations in colleges, this particular advertisement comes to my mind.

Is there actually a level playing field?

We don’t live in a fair world. While growing up, I have seen educated parents helping their kids with their school projects. Most parents now a days send their kids for coaching classes for every single school subject from as early as they are 4 years old. And I find it really irritating when a person who had the most resources complains about reservation system and merit.

I like learning new things but I have never been someone who worked hard to get good grades. I just learned enough to get a passing grade. I am writing this because even though I did not struggle, I have seen the struggle of people like my brother and few friends who worked hard and succeeded on their own despite facing so many challenges.

So when I find someone complaining about reservation system in India and about level playing field, my question to them would be?—?“who deserves an “A” grade? the student who worked hard and managed to make something on their own or the one whose parents did it for him?”

Get Plugin Download Count from WordPress.org API

Since last 3 days, I have been looking out for a way to get the total download count of my plugin.

But there is almost no information about API for WordPress.org except on http://codex.wordpress.org/WordPress.org_API which is just links and some more information on http://dd32.id.au/projects/wordpressorg-plugin-information-api-docs/ which provides details on WordPress Plugin Information API. So after some tweaking and testing here is the final code to get the download count.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
&lt;?php
$payload = array(
'action' =&gt; 'plugin_information',
'request' =&gt; serialize(
(object)array(
'slug' =&gt; 'i-recommend-this',
'fields' =&gt; array(
'downloaded' =&gt; true,
'description' =&gt; false
)
)
)
);

$body = wp_remote_post( 'http://api.wordpress.org/plugins/info/1.0/', array( 'body' =&gt; $payload) );

$body = unserialize($body['body']);
echo '&lt;p&gt;Downloaded: ' . print_r( $body-&gt;downloaded, true ) . '&lt;/p&gt;';

?&gt;

Now to avoid requesting information from WordPress.org on every page load, the required information can be saved in a transient and refreshed once a day.  This is in no way a final code. I have not placed any additional logic to display arrays, etc. So just use this as a starting point.

I will write a plugin to do this but until then if you know a better way, please share your ideas in comments.

Updates

Well it seems there is plugin_api using which most of the things I did above was unnecessary. If we use plugins_api we can get the total download count using few lines of code below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/** If plugins_api isn't available, load the file that holds the function */
if ( ! function_exists( 'plugins_api' ) )
require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );

/** Prepare our query */
$call_api = plugins_api( 'plugin_information',
array(
'slug' =&gt; 'i-recommend-this'
)
);

/** Display the results */
if ( is_wp_error( $call_api ) )
echo '&lt;pre&gt;' . print_r( $call_api-&gt;get_error_message(), true ) . '&lt;/pre&gt;';
else
//echo '&lt;pre&gt;' . print_r( $call_api, true ) . '&lt;/pre&gt;';
echo '&lt;p&gt;' . print_r( $call_api-&gt;downloaded, true ) . '&lt;/p&gt;';

Sublime Text 2 Shortcuts

After using Dreamweaver for years I have finally started using and loving Sublime Text for its simplicity and speed. In this post I plan to post every shortcut for my own reference and anyone else who needs it. If I miss any shortcuts, do share those in the comments.

(NOTE: I am only sharing Windows Shortcuts)

  • Move Lines Up or Down

    Shortcut for moving line up:  Ctrl + Shit + ?
    Shortcut for moving line down: Ctrl + Shift + ?

    The above are used to quickly move any line up or down without having to cut & paste.

  • Open Command Prompt

    Ctrl + Shift + P

  • Toogle Sidebar

    Ctrl + KB

  • Quick File Switching

    Ctrl + PPress above and start typing the name of the file. Based on the matches, the file will be opened instantly and if there are multiple options, you can press Up/Down arrow to select a file from the list. The search is done for the project or among the currently opened files.

  • Go to Symbol (Function / Classes)Ctrl + R
    (or Ctrl + P and then enter @)
    Similar to Ctrl + P, this is used to quickly go to a function or class. In HTML document, you can also go to a ID.

Flat Colors in UI & Web Design

As more and more designers tend to use flat ui colors in their web design projects and mobile apps, there seem to be far less resource on this topic. There are few good articles such as  http://designmodo.com/flat-design-colors/ & a great site with a list of the colors mostly used in flat ui.

I am currently trying to put a collection of websites using flat ui colors as a source for inspiration. Anyone interested in this project and want to help do let me know by sending me a tweet at @harishchouhan

Check out Flat UI Design Gallery

The Absolute Beginners Guide to LESS

CSS is a simple language. It allows us to style properties of HTML elements using selectors. This makes it easy for beginners to get started with CSS.

However, as the size of your web projects grow, you end up repeating much of your CSS code. If you face this issue, then it’s time to use a CSS preprocessor.

Read more on OSTraining.com

How to Customize the WordPress Login Screen

By default, every WordPress site looks the same.

For a variety of reasons, people want to customize the WordPress sites with their own logo or styles.

In this tutorial we’re going to show you an example of how to customize WordPress the right way. We’re going give you an introduction to using functions and CSS to style your site in a way that’s safe from any updates.

Learn more on OSTraining.com