{"id":3750,"date":"2013-07-24T15:20:41","date_gmt":"2013-07-24T07:20:41","guid":{"rendered":"http:\/\/hazelong.com\/?p=3750"},"modified":"2013-07-24T15:20:41","modified_gmt":"2013-07-24T07:20:41","slug":"wordpress-espresso","status":"publish","type":"post","link":"https:\/\/musenmaker.com\/hazelong\/?p=3750","title":{"rendered":"Using LESS for WordPress with Espresso"},"content":{"rendered":"<p>When it comes to developing original themes for WordPress, the development time spike up when there&#8217;s a need for a responsive theme and the clients keep implementing changes. Instead of overriding css with stricter rules and creating a whole lot of havoc, using the .less option would speed things up considerably and keep the code clean.<\/p>\n<p>I&#8217;ve been using <a href=\"http:\/\/macrabbit.com\/\">Espresso<\/a> to develop websites for the longest time and I can&#8217;t live without it. Especially since CSSedit have been merged with Espresso already. Although the child app CSSedit within the current Espresso(version 2) are laggy compared to the standalone app, I am sure the folks at MacRabbit are working on improving it.<\/p>\n<p>Anyway, here are the steps involved.<\/p>\n<h3>Make WordPress Play Nice with Less<\/h3>\n<p>If you are developing on another cms platform, these bunch of steps can be ignored.<\/p>\n<ol>\n<li><span style=\"line-height: 13px;\">Install this plugin, <a title=\"From Paintlust to Art Misfits\" href=\"http:\/\/wordpress.org\/plugins\/wp-less\/\">WP-less<\/a> in your WordPress site<\/span><\/li>\n<li>Activate it<\/li>\n<li>Create a .less file somewhere in your theme.<\/li>\n<li>In your WordPress theme <code>functions.php<\/code>, paste this in and change the location of the file to reflect your new .less file&#8217;s location:<br \/>\n[php] add_action(&#8216;init&#8217;, &#8216;theme_enqueue_styles&#8217;);function theme_enqueue_styles() {<br \/>\nwp_enqueue_style(&#8216;misfits&#8217;, get_stylesheet_directory_uri().&#8217;\/css\/misfits.less&#8217;);<br \/>\n}[\/php]<\/li>\n<li>Fire up your ftp and edit your WordPress <code>wp-config.php<\/code><\/li>\n<li>Paste this in<br \/>\n[php]\/**less recompiling**\/<br \/>\ndefine(&#8216;wp_LESS_COMPILATION&#8217;, &#8216;deep&#8217;);[\/php]<\/li>\n<li>And you are done! If you have a <code>name.less<\/code> file, you can put in all your less codes. And when you load your WordPress website in the browser, you can see that your <code>name.less<\/code> file have been compiled to a <code>name.css<\/code> file with all your variables converted.<\/li>\n<\/ol>\n<p>**Notes : I&#8217;m using Espresso to develop my WordPress websites but if you are using something else and want a better visual representation of your .less files when you work with them, you can consider the <a href=\"http:\/\/incident57.com\/codekit\/\">CodeKit<\/a>. With the CodeKit, you don&#8217;t even need the plugin as the app compiles the .less files to .css before they go on the server. \u00a0Using the WP-less plugin makes your server compile the codes everytime your .less file is modified or updated.<\/p>\n<p>&nbsp;<\/p>\n<h3>Quick way to get Espresso to go Less<\/h3>\n<p>There are a few Sugars on Less for the Espresso but they are not that solid yet. Working with .less files in Espresso gives you a plain text visual representation. I can&#8217;t work with that, I can go code blind. The simplest way to fix this is to extend the CSS native plugin to support .less files.<\/p>\n<ol>\n<li>Go to Applications folder and find Espresso App, Right click (Control + Click) and \u201c<strong>Show Package Content<\/strong>\u201d then look inside <strong>\u201cContent\/SharedSupport\/Sugars\u201d<\/strong> \u00a0and you will find \u00a0the <strong>CSS.sugar<\/strong>. Alternatively, if the sugar can&#8217;t be found, look into the <strong>&#8220;Content\/SharedSupport\/Plug-Ins\/&#8221;<\/strong> folder and you will see a <strong>CSS.espressoplugin<\/strong><\/li>\n<li>Copy this file.<\/li>\n<li>In your Finder window, click on\u00a0<strong>Go.\u00a0<\/strong>A dropdown of locations will show up, hit\u00a0<strong>ALT\/Option<\/strong> and the hidden Library folder will come up. Click on it. Navigate to <strong>&#8220;Application Support\/Espresso\/Sugars<\/strong> or<strong> Plug-Ins&#8221;<\/strong> depending on which file you&#8217;ve ended up with.<\/li>\n<li>Paste in the file you&#8217;ve copied.<\/li>\n<li>Right click on the file and &#8220;<strong>Show Package Content<\/strong>&#8220;. Edit the <code>language.xml<\/code> file with a text editor.<\/li>\n<li>Find this line :<br \/>\n[xml]&lt;extension&gt;css&lt;\/extension&gt;[\/xml]<br \/>\nand add this line below it :<br \/>\n[xml]&lt;extension&gt;less&lt;\/extension&gt; \/\/.less syntax support[\/xml]<\/li>\n<li>Save and exit.<\/li>\n<li>Edit the <code>info.plist<\/code> file.<\/li>\n<li>Locate this chunk of code<br \/>\n[xml]&lt;key&gt;CFBundleVersion&lt;\/key&gt;<br \/>\n&lt;string&gt;2.0.1&lt;\/string&gt;<\/p>\n<p>[\/xml]<br \/>\nand adjust the number within the <code>&lt;string&gt;&lt;\/string&gt;<\/code>\u00a0to a slightly higher number. This forces Espresso to use this modified plugin instead of the original one that you&#8217;ve duplicated from.<\/li>\n<li>Save and Exit. You are done! Enjoy using Less. For More. Haha.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When it comes to developing original themes for WordPress, the development time spike up when there&#8217;s a need for a responsive theme and the clients keep implementing changes. Instead of overriding css with stricter rules and creating a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1776,2005],"tags":[],"class_list":["post-3750","post","type-post","status-publish","format-standard","hentry","category-coding-tutorials","category-geekery"],"acf":[],"_links":{"self":[{"href":"https:\/\/musenmaker.com\/hazelong\/index.php?rest_route=\/wp\/v2\/posts\/3750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/musenmaker.com\/hazelong\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/musenmaker.com\/hazelong\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/musenmaker.com\/hazelong\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/musenmaker.com\/hazelong\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3750"}],"version-history":[{"count":0,"href":"https:\/\/musenmaker.com\/hazelong\/index.php?rest_route=\/wp\/v2\/posts\/3750\/revisions"}],"wp:attachment":[{"href":"https:\/\/musenmaker.com\/hazelong\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/musenmaker.com\/hazelong\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/musenmaker.com\/hazelong\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}