<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>theMojoWill</title>
	<atom:link href="http://www.mojowill.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mojowill.com</link>
	<description>developer/musician/geek</description>
	<lastBuildDate>Mon, 13 May 2013 16:08:57 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>How to install and configure LEMP (Linux, nginx, MySQL and PHP) on CentOS 6</title>
		<link>http://www.mojowill.com/geek/how-to-install-and-configure-lemp-linux-nginx-mysql-and-php-on-centos-6/</link>
		<comments>http://www.mojowill.com/geek/how-to-install-and-configure-lemp-linux-nginx-mysql-and-php-on-centos-6/#comments</comments>
		<pubDate>Tue, 07 May 2013 11:29:40 +0000</pubDate>
		<dc:creator>MojoWill</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[lemp]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[server setup]]></category>

		<guid isPermaLink="false">http://www.mojowill.com/?p=1184</guid>
		<description><![CDATA[Fellow developers have been on at me for the last couple of years to ditch Apache and move to nginx. If you know what nginx is then you know why, if not let&#8217;s have a quick look at what nginx is. Nginx (pronounced engine-x) is a free, open-source, high-performance HTTP server and reverse proxy, as [...]]]></description>
				<content:encoded><![CDATA[<p>Fellow developers have been on at me for the last couple of years to ditch <a title="Apache Webserver" href="http://httpd.apache.org" target="_blank">Apache</a> and move to <a title="Nginx" href="http://wiki.nginx.org/Main" target="_blank">nginx</a>. If you know what nginx is then you know why, if not let&#8217;s have a quick look at what nginx is.</p>
<blockquote><p>Nginx (<a title="Pronunciation" href="http://wiki.nginx.org/Pronunciation" target="_blank">pronounced engine-x</a>) is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. <a href="http://sysoev.ru/en/" rel="nofollow">Igor Sysoev</a>started development of Nginx in 2002, with the first public release in 2004. Nginx now hosts nearly <a href="http://news.netcraft.com/archives/2012/01/03/january-2012-web-server-survey.html" rel="nofollow">12.18% (22.2M)</a> of active sites across all domains. Nginx is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.<small><cite>Nginx Official Website</cite></small></p></blockquote>
<p>Now I&#8217;m not going to go into why nginx may or may not perform better than Apache, today I&#8217;m simply going to talk you through setting up a fresh CentOS 6 installation with a LEMP (Linux, nginx, MySQL and PHP) stack.</p>
<div class="alert alert-info">All the following commands need to be run as a user with root privileges, depending on how you prefer to configure your users you may need to add <code>sudo</code> to the start of your commands.</div>
<h3>CentOS and Repositories</h3>
<p>Let&#8217;s start with a clean install of CentOS with nothing installed. We&#8217;re going to make it easy by installing everything via <a title="Install Software with Yum" href="http://www.centos.org/docs/5/html/yum/" target="_blank">Yum</a>, however CentOS&#8217;s package support is a bit crap so we need to add a couple of extra repos:</p>
<pre class="brush: plain; title: ; notranslate">
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
</pre>
<h3>Installing MySQL</h3>
<p>Now we need to install MySQL. This is fairly simple:</p>
<pre class="brush: plain; title: ; notranslate">
yum install mysql mysql-server
</pre>
<p>Once the download and install is complete we start MySQL and ensure it starts on system boot up:</p>
<pre class="brush: plain; title: ; notranslate">
chkconfig --levels 235 mysqld on
service mysqld start
</pre>
<p>We also need to do some basic configuration which can be done easily using the <code>mysql_secure_installation</code> command. You will be prompted for your current password, as we&#8217;ve only just installed MySQL you can leave this blank.</p>
<pre class="brush: plain; title: ; notranslate">
Enter current password for root (enter for none):
OK, successfully used password, moving on...
</pre>
<p>CentOS automates the configuration process quite nicely, you&#8217;ll need to set a root password followed by a series of questions, most of which you can leave as the default answer. This does things like remove anonymous access and test tables etc. Once complete it will reload and implement all the changes. Simple.</p>
<pre class="brush: plain; title: ; notranslate">
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!
</pre>
<h3>Installing nginx</h3>
<p>Yum makes installing nginx nice and easy (now we have the right repos setup!):</p>
<pre class="brush: plain; title: ; notranslate">
yum install nginx
</pre>
<p>As with MySQL we need to start nginx and make sure it starts on system boot.</p>
<pre class="brush: plain; title: ; notranslate">
chkconfig --levels 235 nginx on
service nginx start
</pre>
<p>Now we can test to see if it has works by simply going to our IP or hostname in a browser. You should see the following.</p>
<p><a href="http://cdn.mojowill.com/wp-content/uploads/2013/05/nginx-default-screen.png"><img class="aligncenter size-large wp-image-1185" alt="Nginx Default Screen" src="http://cdn.mojowill.com/wp-content/uploads/2013/05/nginx-default-screen-1024x694.png" width="1024" height="694" /></a></p>
<h3>Installing PHP</h3>
<p>We&#8217;re going to be using <a title="PHP-FPM" href="http://php-fpm.org" target="_blank">PHP-FPM</a> which we can install from the REMI repo we added earlier. Our yum install script is a little different as we need to tell yum to use the REMI repo.</p>
<pre class="brush: plain; title: ; notranslate">
yum --enablerepo=remi install php-fpm php-mysql

.....

================================================================================
 Package               Arch          Version                  Repository   Size
================================================================================
Installing:
 php-fpm               x86_64        5.4.14-1.el6.remi        remi        1.3 M
 php-mysql             x86_64        5.4.14-1.el6.remi        remi        134 k
Installing for dependencies:
 compat-mysql51        x86_64        5.1.54-1.el6.remi        remi        1.4 M
 php-common            x86_64        5.4.14-1.el6.remi        remi        892 k
 php-pdo               x86_64        5.4.14-1.el6.remi        remi        117 k
Updating for dependencies:
 mysql-libs            x86_64        5.5.31-1.el6.remi        remi        774 k

Transaction Summary
================================================================================
Install       5 Package(s)
Upgrade       1 Package(s)

Total download size: 4.6 M
Is this ok [y/N]:
</pre>
<h3>Configuring PHP</h3>
<p>We need to make a small change to our default PHP config to tighten up the security a little. So open up your <code>php.ini</code> in your favourite code editor:</p>
<pre class="brush: plain; title: ; notranslate">
nano /etc/php.ini
</pre>
<p>Find the line, cgi.fix_pathinfo=1, and change the 1 to 0.</p>
<pre class="brush: plain; title: ; notranslate">
cgi.fix_pathinfo=0
</pre>
<p>When set to 1 the php interpreter will try to process the file that is as close to the requested file as possible. This could lead to possible PHP exploits, when set to 0 the interpreter will only process the exact file path. Save your changes and exit.</p>
<h3>Configuring nginx</h3>
<p>We need to alter a couple of things in our nginx configuration, open up the default config file in your favourite editor:</p>
<pre class="brush: plain; title: ; notranslate">
nano /etc/nginx/nginx.conf
</pre>
<p>We want to increase the number of worker_processes. With nginx the maximum number of clients = worker_processes * worker_connections so a basic config can handle nearly a thousand concurrent connections. However a good tweak is to increase your number of worker_processes based on the number of processor cores you have. Increase the number of worker processes to match how many CPU cores you have, you can check how many cores you have with the following command:</p>
<pre class="brush: plain; title: ; notranslate">
cat /proc/cpuinfo | grep processor
processor	: 0
processor	: 1
processor	: 2
processor	: 3
</pre>
<p>So in my case:</p>
<pre class="brush: plain; title: ; notranslate">
worker_processes 4;
</pre>
<p>We also want to modify the user that nginx or PHP-FPM run as. These need to be the same user so you have 2 choices:</p>
<pre class="brush: plain; title: ; notranslate">
nano /etc/php-fpm.d/www.conf
</pre>
<p>Then find the user and group settings and change them from apache to nginx:</p>
<pre class="brush: plain; title: ; notranslate">
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;	will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
</pre>
<p>Alternatively we can change the user nginx runs as to match the PHP-FPM default config. Open up the nginx confif file we edited earlier and edit the user found right at the top of the file:</p>
<pre class="brush: plain; title: ; notranslate">
user              apache;
</pre>
<p>Finally we need to configure our nginx virtual hosts. This is much simpler to configure than Apache. Take a look at the config below, it is slightly different to our default config, but I&#8217;ll explain the changes below:</p>
<pre class="brush: plain; title: ; notranslate">
#
# The default server
#
server {
    listen       80;
    server_name mydomain.com;

    location / {
        root   /usr/share/nginx/html;
        index index.php  index.html index.htm;
    }

    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}
</pre>
<p>So what did we change?</p>
<ul>
<li>We added index.php to the index line.</li>
<li>Change the server_name to your domain name or IP address (replace the mydomain.com in the configuration above)</li>
<li>Change the root to <code>/usr/share/nginx/html;</code> This of course can be whatever you like.</li>
<li>Uncomment the section beginning with <code>"location ~ \.php$ {"</code></li>
<li>Change the root to access the actual document root, <code>/usr/share/nginx/html;</code> This should match the root above.</li>
<li>Change the fastcgi_param line to help the PHP interpreter find the PHP script that we stored in the document root home.</li>
</ul>
<p>Once you&#8217;ve made your change save and exit. Then all we need to do is restart PHP-FPM to make the changes take effect:</p>
<pre class="brush: plain; title: ; notranslate">
service php-fpm restart
</pre>
<h3>Testing</h3>
<p>Our basic configuration is complete! Let&#8217;s test to make sure it is all working. Create a new file:</p>
<pre class="brush: plain; title: ; notranslate">
nano /usr/share/nginx/html/test.php
</pre>
<p>Then add the following line:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
phpinfo();
</pre>
<p>If you now browse to your hostname or IP address you should now see the PHP Info page! How easy was that?</p>
<p>This should get you up and running, have a play and you will find loads more you can do. Also check out this article on great <a title="Nginx and PHP-FPM Configuration and Optimizing Tips and Tricks" href="e-then-false.com/2011/nginx-and-php-fpm-configuration-and-optimizing-tips-and-tricks/" target="_blank">nginx and PHP-FPM config tips and tweaks</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mojowill.com/geek/how-to-install-and-configure-lemp-linux-nginx-mysql-and-php-on-centos-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looking all shiny!</title>
		<link>http://www.mojowill.com/developer/looking-all-shiny/</link>
		<comments>http://www.mojowill.com/developer/looking-all-shiny/#comments</comments>
		<pubDate>Tue, 09 Apr 2013 14:31:49 +0000</pubDate>
		<dc:creator>MojoWill</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Bootstrap]]></category>
		<category><![CDATA[Website]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.mojowill.com/?p=1179</guid>
		<description><![CDATA[As you may have noticed, things are looking a little bit different. I&#8217;ve been working on a bit of an updated look ever since launching the new site earlier this year. I decided to build the site on top of Bootstrap something which makes development so much easier. I&#8217;ve also got some great artwork provided [...]]]></description>
				<content:encoded><![CDATA[<p>As you may have noticed, things are looking a little bit different. I&#8217;ve been working on a bit of an updated look ever since launching the new site earlier this year. I decided to build the site on top of <a title="Bootstrap from Twitter" href="http://twitter.github.io/bootstrap/" target="_blank">Bootstrap</a> something which makes development so much easier. I&#8217;ve also got some great artwork provided by the super talented <a title="Vic Bell Illustrator" href="http://vicbell.co.uk" target="_blank">Vic Bell</a>, she did me a set of characters to use all over the site so you will be definitely be seeing more over the coming days as I get them into place.</p>
<p>I will be playing with it over the coming weeks to improve a few areas that still need some more love but would love to hear what you think?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mojowill.com/developer/looking-all-shiny/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jetpack Local Development Mode</title>
		<link>http://www.mojowill.com/developer/jetpack-local-development-mode/</link>
		<comments>http://www.mojowill.com/developer/jetpack-local-development-mode/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 09:10:55 +0000</pubDate>
		<dc:creator>MojoWill</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Developer Mode]]></category>
		<category><![CDATA[Jetpack]]></category>
		<category><![CDATA[Local Development]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.mojowill.com/?p=1175</guid>
		<description><![CDATA[I like Jetpack. I&#8217;ve already talked about it in an article over at Wptuts+ but I was really interested to see a small addition to the latest development version. What we are finally getting is a local development mode! No need to connect to your WordPress.com account one simple line in your wp-config.php will do [...]]]></description>
				<content:encoded><![CDATA[<p>I like <a title="Jetpack for WordPress" href="http://jetpack.me" target="_blank">Jetpack</a>. I&#8217;ve already talked about it in <a title="Getting started with Jetpack" href="http://wp.tutsplus.com/tutorials/plugins/give-your-wordpress-site-wings-with-jetpack/" target="_blank">an article over at Wptuts+</a> but I was really interested to see a small addition to the latest development version. What we are finally getting is a local development mode! No need to connect to your WordPress.com account one simple line in your <code>wp-config.php</code> will do it.</p>
<p>So head over and get yourself the latest <a title="Jetpack development Version" href="http://wordpress.org/extend/plugins/jetpack/developers/" target="_blank">development version of Jetpack</a> and add the following line to your <code>wp-config.php</code> before activating the plugin.</p>
<pre class="brush: php; title: ; notranslate">

define('JETPACK_DEV_DEBUG', true);

</pre>
<p>Just like magic Jetpack will now let you use it for local testing without having to connect to your WordPress.com account!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mojowill.com/developer/jetpack-local-development-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show Yourself Off With a Custom Author Box</title>
		<link>http://www.mojowill.com/developer/show-yourself-off-with-a-custom-author-box/</link>
		<comments>http://www.mojowill.com/developer/show-yourself-off-with-a-custom-author-box/#comments</comments>
		<pubDate>Mon, 25 Feb 2013 13:12:56 +0000</pubDate>
		<dc:creator>MojoWill</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Author Box]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tuts+]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wptuts+]]></category>

		<guid isPermaLink="false">http://www.mojowill.com/?p=1170</guid>
		<description><![CDATA[Another great article over at Wptuts+, even if I do say so myself! This time I&#8217;m looking at how you can add an author box to your blog posts and author page in WordPress as well as extend the profile page to be a bit more useful. Multi-Author blogs are becoming increasingly popular and with [...]]]></description>
				<content:encoded><![CDATA[<p>Another great article over at Wptuts+, even if I do say so myself! This time I&#8217;m looking at how you can add an author box to your blog posts and author page in WordPress as well as extend the profile page to be a bit more useful.</p>
<blockquote><p>Multi-Author blogs are becoming increasingly popular and with good reason. Creating regular, engaging content can often be a challenge for an individual blogger. With multiple authors it can be a lot easier and also allows you to cover a greater range of topics pulling from the knowledge of several people. On sites like Wptuts+ you get to read articles from a massive team of writers and bloggers, we all have our own writing style and personalities. Like Wptuts+, on most multi-author sites, you will find a nice little author information box somewhere on the page. Today I’m going to show you how you can create one for your very own site.</p></blockquote>
<p><a class="btn" title="Show Yourself Off With a Custom Author Box" href="http://wp.tutsplus.com/tutorials/creative-coding/show-yourself-off-with-a-custom-author-box/" target="_blank">Read the Full Article</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mojowill.com/developer/show-yourself-off-with-a-custom-author-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Javascript with WordPress correctly</title>
		<link>http://www.mojowill.com/developer/using-javascript-with-wordpress-correctly/</link>
		<comments>http://www.mojowill.com/developer/using-javascript-with-wordpress-correctly/#comments</comments>
		<pubDate>Tue, 19 Feb 2013 14:27:49 +0000</pubDate>
		<dc:creator>MojoWill</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Enqueue]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp_enqueue_scripts]]></category>

		<guid isPermaLink="false">http://mojowill.wpengine.com/?p=1015</guid>
		<description><![CDATA[JavaScript is something that is used on 99% on websites. In the last few years it seems to have exploded and become part of the fundamental toolkit for all web developers. I see it all the time in both WordPress themes and plugins however unfortunately a lot of developers still don&#8217;t really know how to [...]]]></description>
				<content:encoded><![CDATA[<p>JavaScript is something that is used on 99% on websites. In the last few years it seems to have exploded and become part of the fundamental toolkit for all web developers. I see it all the time in both WordPress themes and plugins however unfortunately a lot of developers still don&#8217;t really know how to work with it correctly with WordPress.</p>
<p>If you&#8217;re simply including the following in your header.php <strong>you&#8217;re doing it wrong!</strong></p>
<pre class="brush: xml; title: ; notranslate">

&lt;!-- Scripts --&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-1.8.3.min.js&quot;&gt;&lt;/script&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;js/bootstrap.js&quot;&gt;&lt;/script&gt;

</pre>
<p>WordPress gives us two functions for handling JavaScript in a way that doesn&#8217;t conflict with other plugins and themes and more importantly with the WordPress Core itself.</p>
<h3>wp_register_script()</h3>
<p>First up is <code><a href="http://codex.wordpress.org/Function_Reference/wp_register_script" target="_blank">wp_register_script()</a></code> think of this as letting WordPress know about your JavaScript. When you call this function is doesn&#8217;t do anything except let WordPress know it&#8217;s there and that you might want to use it at some point.</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php wp_register_script( $handle, $src, $deps, $ver, $in_footer ); ?&gt;

</pre>
<ul>
<li><strong>$handle</strong> &#8211; This is the name of the script, it should be unique as you will be using this later on in the <code>wp_enqueue_script()</code> function.</li>
<li><strong>$src</strong> &#8211; This is the URL to the script. If you are using a local script you should never hardcode the URL, instead make use of the functions available such as <code>get_template_directory_uri()</code>. Since WordPress 3.3 you can also use protocol agnostic URLs for remotely hosted scripts. (//remotehost.com/myscript.js).</li>
<li><strong>$deps</strong> &#8211; Array of handles of any script that this script depends on; scripts that must be loaded before this script. False if there are no dependencies. This parameter is only required when WordPress does not already know about this script. Useful if you are registering a jQuery plugin you can specify jQuery as a dependancy.</li>
<li><strong>$ver</strong> &#8211; String specifying the script version number, if it has one. Defaults to false (which uses the WordPress version number by default). This parameter is used to ensure that the correct version is sent to the client regardless of caching, and so should be included if a version number is available and makes sense for the script. Set to null to disable. <a title="Get your WordPress CSS changes noticed immediately!" href="http://www.mojowill.com/developer/get-your-wordpress-css-changes-noticed-immediately/">You can check out how to dynamically add a version number to your scripts and styles in this previous post</a>.</li>
<li><strong>$in_footer</strong> &#8211; Normally scripts are placed in thesection. If this parameter is true the script is placed at the bottom of the
<div></div>
<p>. This requires the theme to have the</p>
<div><code>wp_footer()</code></div>
<p>hook in the appropriate place. Note that you have to enqueue your script before wp_head is run, even if it will be placed in the footer.</li>
</ul>
<p>Let&#8217;s go back to our example and see how we can register our scripts correctly.</p>
<pre class="brush: php; title: ; notranslate">

function mojowill_scripts() {
    wp_register_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.js', array( 'jquery' ), '2.2.1', false );
}

add_action( 'wp_enqueue_scripts', 'mojowill_scripts' );

</pre>
<p>I created a function and inside it called the <code>wp_register_script()</code> function. I am then registering a local copy of <code>bootstrap.js</code>. You can also see that it depends on jQuery. jQuery is one of the bundled JavaScript libraries with the WordPress core so we don&#8217;t need to register it and can simply call it as a dependancy.</p>
<h3>wp_enqueue_script()</h3>
<p>Next up we have <code><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" target="_blank">wp_enqueue_script()</a></code> instead of simply letting WordPress know about our script this function loads the JavaScript and outputs it in your template.</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );?&gt;

</pre>
<p>You&#8217;ll notice that the parameters are exactly the same as the previous function. If you have already used <code>wp_register_script()</code> then you can simply do the following:</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php wp_enqueue_script( 'bootstrap' ); ?&gt;

</pre>
<p>If we hadn&#8217;t run the register function then it would look like this:</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.js', array( 'jquery' ), '2.2.1', false ); ?&gt;

</pre>
<p>Personally I <strong>always</strong> register my scripts first. Let&#8217;s have a look at the completed code:</p>
<pre class="brush: php; title: ; notranslate">

function mojowill_scripts() {
    wp_register_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.js', array( 'jquery' ), '2.2.1', false );
    wp_enqueue_script( 'bootstrap' );
}

add_action( 'wp_enqueue_scripts', 'mojowill_scripts' );

</pre>
<p>Always remember to call your own function with the correct action hook! Use the <code>wp_enqueue_scripts()</code> action to call this function, or <code>admin_enqueue_scripts()</code> to call it on the admin side, or use <code>login_enqueue_scripts()</code> for login screens.</p>
<h3>Bundled Libraries</h3>
<p><a title="Default Scripts Included with WordPress" href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress" target="_blank">WordPress comes with a whole heap of JavaScript libraries already included in the core</a> so all you need to do is enqueue the script. You would use as follows:</p>
<pre class="brush: php; title: ; notranslate">

function mojowill_builtin_scripts() {
    wp_enqueue_script( 'jquery' );
    wp_enqueue_script( 'backbone' );
}

add_action( 'wp_enqueue_scripts', 'mojowill_builtin_scripts' );

</pre>
<p>A <strong>huge</strong> number of developers still don&#8217;t use jQuery correctly, enqueue it properly and preferably use the built in core version. If you use a different version then there is a high chance you will break plugins or themes. This is still one of the biggest issues with WordPress developers. Now there maybe times you want to use a different version of a library that is included with WordPress perhaps to take advantage of a CDN version. This is fine on your own site as long as you know what you are doing, but if you are releasing a theme or plugin publicly then for the love of God use the bundled libraries! I&#8217;m not even going to tell you here how to use a non standard version of a bundled library as personally I hate it and it&#8217;s my site so I get to write what I want!</p>
<h3>jQuery noConflict Mode</h3>
<p>Finally a note about jQuery. The bundled library in WordPress loads in &#8220;<a title="jQuery noConflict Mode" href="http://docs.jquery.com/Using_jQuery_with_Other_Libraries" target="_blank">no-conflict</a>&#8221; mode. This helps to stop compatibility problems with other JavaScript libraries that WordPress can load. In &#8220;no-conflict&#8221; mode the $ shortcut is not available and you instead use the longer jQuery:</p>
<pre class="brush: jscript; title: ; notranslate">

// Old Way
$(document).ready(function(){
$(#myfunction)
});

// No Conflict Way
jQuery(document).ready(function(){
jQuery(#myfunction)
});

</pre>
<p>You can also use a shortcut alias, in the following examples the first piece of code will execute when the page has finished loading, however in the second example you can see how to execute the code immediately.</p>
<pre class="brush: jscript; title: ; notranslate">
jQuery(document).ready(function($) {
    // $() will work as an alias for jQuery() inside of this function
});

(function($) {
    // $() will work as an alias for jQuery() inside of this function
})(jQuery);

</pre>
<h3>Conclusion</h3>
<p>Do you feel all warm and fuzzy now you know how to do it properly? Probably not. Please, please, please do it the correct way though. It screws up so much other stuff when lazy developers don&#8217;t use the correct functions for JavaScript. It&#8217;s not difficult and becomes second nature very quickly!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mojowill.com/developer/using-javascript-with-wordpress-correctly/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>I&#8217;m not dead&#8230;.</title>
		<link>http://www.mojowill.com/geek/im-not-dead/</link>
		<comments>http://www.mojowill.com/geek/im-not-dead/#comments</comments>
		<pubDate>Wed, 06 Feb 2013 15:56:16 +0000</pubDate>
		<dc:creator>MojoWill</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[Busy]]></category>
		<category><![CDATA[Lazy]]></category>
		<category><![CDATA[Upcoming]]></category>

		<guid isPermaLink="false">http://www.mojowill.com/?p=1165</guid>
		<description><![CDATA[Howdy all, I just wanted to post a very brief update to say I&#8217;m not dead and neither is this blog. I&#8217;ve been extremely busy of the past couple of weeks and have had to concentrate more on work and projects. I do have some new articles coming up this month over at Wptuts+ and [...]]]></description>
				<content:encoded><![CDATA[<p>Howdy all, I just wanted to post a very brief update to say I&#8217;m not dead and neither is this blog. I&#8217;ve been extremely busy of the past couple of weeks and have had to concentrate more on work and projects. I do have some new articles coming up this month over at <a title="Wptuts+" href="http://wp.tutsplus.com" target="_blank">Wptuts+</a> and am also working on a WordPress theming course for <a title="Tuts+ Premium" href="http://tutsplus.com" target="_blank">Tuts+ Premium</a> which will be out soon. The next couple of weeks will be a little sporadic as I&#8217;m moving house. I&#8217;d be really interested in hearing your feedback, what kind of articles have you enjoyed? What do you want to see more off? If you have any blog suggestions then please do let me know, <a title="Finding the right balance" href="http://www.mojowill.com/geek/finding-the-right-balance/" target="_blank">I do listen!</a></p>
<p>Hugs!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mojowill.com/geek/im-not-dead/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the New WordPress 3.5 Media Manager in your Plugin or Theme</title>
		<link>http://www.mojowill.com/developer/using-the-new-wordpress-3-5-media-manager-in-your-plugin-or-theme/</link>
		<comments>http://www.mojowill.com/developer/using-the-new-wordpress-3-5-media-manager-in-your-plugin-or-theme/#comments</comments>
		<pubDate>Tue, 22 Jan 2013 10:42:27 +0000</pubDate>
		<dc:creator>MojoWill</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Plugin Development]]></category>
		<category><![CDATA[theme development]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Media Manager]]></category>

		<guid isPermaLink="false">http://www.mojowill.com/?p=1161</guid>
		<description><![CDATA[WordPress 3.5 brought with it a completely redesigned media manager. A long overdue update that looks great! You can find out more about that in my previous post What&#8217;s New In WordPress 3.5. The question is what does this new media manager mean for developers? Well firstly if you were hooking into the media manager [...]]]></description>
				<content:encoded><![CDATA[<p>WordPress 3.5 brought with it a completely redesigned media manager. A long overdue update that looks great! You can find out more about that in my previous post <a title="Wptuts+: What’s New in WordPress 3.5" href="http://www.mojowill.com/developer/wptuts-whats-new-in-wordpress-3-5/">What&#8217;s New In WordPress 3.5</a>. The question is what does this new media manager mean for developers? Well firstly if you were hooking into the media manager previously in your plugin or theme then the good news is it <em>should</em> still work. However as I found out last week that updating to use the new media manager isn&#8217;t too much of a nightmare when I updated my very own <a title="The Mojo Admin Toolbox" href="http://wordpress.org/extend/plugins/the-mojo-admin-toolbox/" target="_blank">Mojo Admin Toolbox</a>.</p>
<p>First off props go to <a title="Working with the new Media Manager" href="https://github.com/thomasgriffin/New-Media-Image-Uploader" target="_blank">Thomas Griffin who posted a great example on GitHub</a> of how to do this! Secondly I must admit I don&#8217;t fully understand everything but hey I&#8217;m not a Javascript Ninja, but I think I know what is going on!</p>
<p>So WordPress actually tries to make things a little easier for us&#8230;.a little bit anyway. Introducing <code>wp_enqueue_media</code>. Now documentation on this function is extremely lacking but what we do know is this.</p>
<blockquote><p>Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs.</p></blockquote>
<p>So instead of having to enqueue the media-upload script and thickbox we can now call this one function and it gets everything ready for us. We now need to do some of our own code to hook into the media uploader and then pass our images information back to our page. Let&#8217;s take a look at a form field from my <a title="The Mojo Admin Toolbox" href="http://wordpress.org/extend/plugins/the-mojo-admin-toolbox/" target="_blank">Mojo Admin Toolbox</a> plugin:</p>
<pre class="brush: php; title: ; notranslate">

&lt;label&gt;
&lt;input name=&quot;mojoToolbox_options[login_logo]&quot; type=&quot;text&quot; value=&quot;&lt;?php if ( isset( $this-&gt;options['login_logo'] ) ) echo $this-&gt;options['login_logo'];?&gt;&quot;/&gt;
&lt;input class=&quot;mojo-open-media button&quot; type=&quot;button&quot; value=&quot;&lt;?php echo _e( 'Upload Image', 'mojo-toolbox' );?&gt;&quot; /&gt;
&lt;span style=&quot;color:#666666;margin-left:2px;&quot;&gt;&lt;?php echo _e( 'The URL for your custom login page logo, (270px x 60px works well!)', 'mojo-toolbox' );?&gt;&lt;/span&gt;&lt;/label&gt;

</pre>
<p>So what we want to do is launch the media manager when the button is pressed and then passback our data to the text field. We need to create our own Javascript file and enqueue that after the new wp_enqueue_media function is run.</p>
<p>We want to create a new Javascript function and inside it do a few different things. We need to set a couple of variables that we will be using later on then we need to create a function a bind it to our on click event. You can get much more information by going to <a title="WordPress New Media Image Uploader" href="https://github.com/thomasgriffin/New-Media-Image-Uploader" target="_blank">Thomas Griffin&#8217;s GitHub example</a>. Inside the on click event we do the following:</p>
<ol>
<li><span style="line-height: 13px;">Prevent the default actions from occurring.</span></li>
<li>Set our Form Label variable using jQuery to get the parent element.</li>
<li>Check to see if a frame already exists, if so we open a new one.</li>
<li>We create a new media frame, there are variables we use to define what kind of media options we want. You can see in my code that I want a simple select option, that I don&#8217;t want to allow multiple selections and that finally we only want to deal with images.</li>
<li>We next grab the selected image from the media manager and pull some data from it as a JSON object.</li>
<li>Finally we use our previously set formlabel variable to pass back the image url to the correct field.</li>
</ol>
<p>Make sense? Have a look at the code:</p>
<pre class="brush: jscript; title: ; notranslate">

/**
 * Thanks to Thomas Griffin for his super useful example on Github
 *
 * https://github.com/thomasgriffin/New-Media-Image-Uploader
 */
jQuery(document).ready(function($){
 // Prepare the variable that holds our custom media manager.
 var mojo_media_frame;
 var formlabel = 0;

 // Bind to our click event in order to open up the new media experience.
 $(document.body).on('click.mojoOpenMediaManager', '.mojo-open-media', function(e){ //mojo-open-media is the class of our form button
 // Prevent the default action from occuring.
 e.preventDefault();
// Get our Parent element
formlabel = jQuery(this).parent();
 // If the frame already exists, re-open it.
 if ( mojo_media_frame ) {
 mojo_media_frame.open();
 return;
 }
 mojo_media_frame = wp.media.frames.mojo_media_frame = wp.media({

//Create our media frame
className: 'media-frame mojo-media-frame',
 frame: 'select', //Allow Select Only
 multiple: false, //Disallow Mulitple selections
 library: {
 type: 'image' //Only allow images
 },
 });
 mojo_media_frame.on('select', function(){
 // Grab our attachment selection and construct a JSON representation of the model.
 var media_attachment = mojo_media_frame.state().get('selection').first().toJSON();

// Send the attachment URL to our custom input field via jQuery.

 formlabel.find('input[type=&quot;text&quot;]').val(media_attachment.url);
 });

// Now that everything has been set, let's open up the frame.
 mojo_media_frame.open();
 });
});
</pre>
<p>Now I wish I could explain a whole lot better, however it works for me and hopefully looking at this along side <a title="WordPress New Media Image Uploader" href="https://github.com/thomasgriffin/New-Media-Image-Uploader" target="_blank">Thomas Griffins example</a> and <a title="Using the New WordPress Media Manager" href="http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/" target="_blank">a great post by Mike Jolley</a> on doing this you should be able to get head around all of this!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mojowill.com/developer/using-the-new-wordpress-3-5-media-manager-in-your-plugin-or-theme/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Wptuts+:Getting Started With WooCommerce: Launching Your Store</title>
		<link>http://www.mojowill.com/developer/wptutsgetting-started-with-woocommerce-launching-your-store/</link>
		<comments>http://www.mojowill.com/developer/wptutsgetting-started-with-woocommerce-launching-your-store/#comments</comments>
		<pubDate>Wed, 16 Jan 2013 21:40:36 +0000</pubDate>
		<dc:creator>MojoWill</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tuts+]]></category>
		<category><![CDATA[WooCommerce]]></category>
		<category><![CDATA[WooCommerce Setup]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wptuts+]]></category>

		<guid isPermaLink="false">http://www.mojowill.com/?p=1157</guid>
		<description><![CDATA[My series on getting started with WooCommerce continues today with part two. You can check out part one in my previous post. In this tutorial we are going to look at adding our first product and then take a look at how to style WooCommerce to fit in with your sites theme. WooCommerce brings serious [...]]]></description>
				<content:encoded><![CDATA[<p>My series on getting started with WooCommerce continues today with part two. You can check out part one in my previous post. In this tutorial we are going to look at adding our first product and then take a look at how to style WooCommerce to fit in with your sites theme.</p>
<blockquote><p>WooCommerce brings serious big boy e-commerce to WordPress in the first part of our series we looked at installation and getting everything setup. Today we’re going to move on and talk about products, we’ll discuss the different product types WooCommerce offers and we’ll add our first products to our site. We’ll then move on to styling and theming WooCommerce before wrapping up with some next steps.</p></blockquote>
<p><a class="btn" title="Getting Started with WooCommerce" href="http://wp.tutsplus.com/tutorials/plugins/getting-started-with-woocommerce-launching-your-store/" target="_blank">Read the Full Article</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mojowill.com/developer/wptutsgetting-started-with-woocommerce-launching-your-store/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Mojo Admin Toolbox 1.3 Released</title>
		<link>http://www.mojowill.com/my-plugins/the-mojo-admin-toolbox-1-3-released/</link>
		<comments>http://www.mojowill.com/my-plugins/the-mojo-admin-toolbox-1-3-released/#comments</comments>
		<pubDate>Tue, 15 Jan 2013 09:42:33 +0000</pubDate>
		<dc:creator>MojoWill</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Mojo Admin Toolbox]]></category>
		<category><![CDATA[Plugin Update]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wordpress Plugin]]></category>

		<guid isPermaLink="false">http://www.mojowill.com/?p=1155</guid>
		<description><![CDATA[I much overdue update to my Mojo Admin Toolbox has just hit the WordPress Repository. I&#8217;ve finally updated the plugin to use the new media manager included with WordPress 3.5 along with the option to disable the Windows Livewriter links that are inserted into the head. You can grab the update from your WordPress dashboard [...]]]></description>
				<content:encoded><![CDATA[<p>I much overdue update to my Mojo Admin Toolbox has just hit the WordPress Repository. I&#8217;ve finally updated the plugin to use the new media manager included with WordPress 3.5 along with the option to disable the Windows Livewriter links that are inserted into the head.</p>
<p>You can grab the update from your WordPress dashboard or download below:</p>
<p><a title="The Mojo Admin Toolbox" href="http://wordpress.org/extend/plugins/the-mojo-admin-toolbox/" target="_blank">Visit the Plugin page on WordPress.org</a> or <a title="The Mojo Admin Toolbox on GitHub" href="https://github.com/mojowill/Mojo-Admin-Toolbox" target="_blank">visit the project on GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mojowill.com/my-plugins/the-mojo-admin-toolbox-1-3-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wptuts+:Getting Started With WooCommerce: Initial Setup</title>
		<link>http://www.mojowill.com/developer/getting-started-with-woocommerce/</link>
		<comments>http://www.mojowill.com/developer/getting-started-with-woocommerce/#comments</comments>
		<pubDate>Mon, 14 Jan 2013 13:21:35 +0000</pubDate>
		<dc:creator>MojoWill</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Tuts+]]></category>
		<category><![CDATA[WooCommerce]]></category>
		<category><![CDATA[WooCommerce Setup]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wptuts+]]></category>

		<guid isPermaLink="false">http://www.mojowill.com/?p=1152</guid>
		<description><![CDATA[My most recent series on Wptuts+ talks you through getting WooCommerce setup. Check it out and keep an eye out for part two coming soon! E-Commerce is massive, most of us use it and global e-commerce sales are set to top $1.25 trillion by 2013. Over the past few years it has become easier to [...]]]></description>
				<content:encoded><![CDATA[<p>My most recent series on Wptuts+ talks you through getting WooCommerce setup. Check it out and keep an eye out for part two coming soon!</p>
<blockquote><p>E-Commerce is massive, most of us use it and global e-commerce sales are set to top $1.25 trillion by 2013. Over the past few years it has become easier to start your own e-commerce store with products like<a title="ZenCart" href="http://www.zen-cart.com/">ZenCart</a>, <a title="Open Cart" href="http://www.opencart.com/">Open Cart</a>, <a title="OSCommerce" href="http://www.oscommerce.com/">OSCommerce</a> and <a title="Magento" href="http://www.magentocommerce.com/">Magento</a>. WordPress has a few options for e-commerce but none have stood out as the full enterprise quality system that serious sellers need.</p>
<p>Today I’m going to talk about a product that has changed that and put WordPress right at the front as a serious contender as an e-commerce platform. Say hello to WooCommerce. In the first of our two part series we’ll look at installation and initial setup talking through the various options available to you. In our second tutorial we will look at adding our first product as well as theming and styling WooCommerce.</p></blockquote>
<p><a href="http://wp.tutsplus.com/tutorials/plugins/getting-started-with-woocommerce-initial-setup" class="btn" target="_blank" title="Getting Started with WooCommerce">Read the Full Article</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mojowill.com/developer/getting-started-with-woocommerce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
