<?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>Brett TerpstraWordpress page  - Brett Terpstra</title>
	<atom:link href="http://brettterpstra.com/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://brettterpstra.com</link>
	<description>Elegant solutions to complex problems.</description>
	<lastBuildDate>Tue, 22 May 2012 02:49:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Markdown QuickTags 0.8 for Christmas</title>
		<link>http://brettterpstra.com/markdown-quicktags-0-8-for-christmas/</link>
		<comments>http://brettterpstra.com/markdown-quicktags-0-8-for-christmas/#comments</comments>
		<pubDate>Sun, 25 Dec 2011 21:38:28 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[mdqt]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=3450</guid>
		<description><![CDATA[<p>We’re having a low-key holiday this year. I mean really low-key. Aditi’s napping on the couch, the dogs are all sleeping, the cats and the bird are lazily preening themselves and I just fixed Markdown QuickTags. Markdown QuickTags, my WordPress plugin which adds a massive number of Markdown-editing features to the built-in post/page editor had broken with the release of&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/markdown-quicktags-0-8-for-christmas/">Markdown QuickTags 0.8 for Christmas</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://cdn2.brettterpstra.com/wp-content/uploads/2011/12/mdqt0.8screenshot-full.jpg?9d7bd4"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-full wp-image-3452 shadow" title="Markdown QuickTags 0.8" src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/12/mdqt0.8screenshot.jpg?9d7bd4" alt="Markdown QuickTags 0.8 Screenshot" width="300" height="227" /></a>We’re having a low-key holiday this year. I mean <em>really</em> low-key. Aditi’s napping on the couch, the dogs are all sleeping, the cats and the bird are lazily preening themselves and I just fixed Markdown QuickTags.</p>

<p><a href="http://wordpress.org/extend/plugins/markdown-quicktags/">Markdown QuickTags</a>, my WordPress plugin which adds a massive number of Markdown-editing features to the built-in post/page editor had broken with the release of WordPress 3.3. Basically, the <code>quicktags.js</code> file which generates the buttons in the HTML editor changed completely. For the better, of course, but that’s what Markdown QuickTags (hackishly) overrides to work its magic, and the change pulled the rug out from under the plugin. I had to rewrite a good portion of the JavaScript, and it took me a while just to figure out what was going on, but it’s back in action. I’m writing this post with it right now.</p>

<p>I added some new font options (served via Google Fonts), more size choices and a live editor preview from the settings page. I’m working on adding a few “themes” to the editor and making it a little more customizable, but it’s lower on my list than things like, <em>um,</em> working.</p>

<p>Eventually I’ll make a video of it in action, I think I’ve probably snuck in a few features that I’ve done a poor job of documenting, anyway. I revamped the look this time, too (much more <a href="http://bywordapp.com/">Byword</a>–esque) so a screenshot refresh is in order as well. But that’s for <em>after</em> Christmas.</p>

<p>Happy Holidays, hope you’re all having great times.</p>

<p>If you write in Markdown and use WordPress, you’d be insane not to try this out. Version 0.8 just became available <a href="http://wordpress.org/extend/plugins/markdown-quicktags/">in the WordPress Plugin Repository</a>.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/markdown-quicktags-wordpress-plugin/' rel='bookmark' title='Markdown QuickTags: WordPress plugin for Markdown lovers'>Markdown QuickTags: WordPress plugin for Markdown lovers</a></li>
<li><a href='http://brettterpstra.com/markdown-quicktags-0-7/' rel='bookmark' title='Markdown QuickTags 0.7'>Markdown QuickTags 0.7</a></li>
<li><a href='http://brettterpstra.com/markdown-quicktags-makes-1000-people-happier-and-more-attractive/' rel='bookmark' title='Markdown QuickTags makes 1000 people happier and more attractive'>Markdown QuickTags makes 1000 people happier and more attractive</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/markdown-quicktags-0-8-for-christmas/">Markdown QuickTags 0.8 for Christmas</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/markdown-quicktags-0-8-for-christmas/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>I think I’m switching to Jekyll…</title>
		<link>http://brettterpstra.com/i-think-im-switching-to-jekyll/</link>
		<comments>http://brettterpstra.com/i-think-im-switching-to-jekyll/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 02:04:57 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[jekyll]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/i-think-im-switching-to-jekyll/</guid>
		<description><![CDATA[<p>I just spent the weekend experimenting with the idea of converting this whole blog from WordPress to Jekyll. It’s a blogging system that runs entirely off of static html files, and you can store your posts as individual Markdown files. Add a post and you can regenerate all of the indexes and archives at once and deploy the static site.&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/i-think-im-switching-to-jekyll/">I think I’m switching to Jekyll…</a></p>]]></description>
			<content:encoded><![CDATA[<p>I just spent the weekend experimenting with the idea of converting this whole blog from WordPress to <a href="http://jekyllrb.com/">Jekyll</a>. It’s a blogging system that runs entirely off of static html files, and you can store your posts as individual Markdown files. Add a post and you can regenerate all of the indexes and archives at once and deploy the static site. The speed and stability increase is immense.</p>

<p>Exporting from WordPress to Jekyll took a good, I don’t know, five minutes. Since I stored all of my posts in Markdown in the WordPress database, it was basically a few minutes of scripting to add YAML headers and get things rolling. The biggest issue is WordPress-specific markup and custom shortcodes that I need to clean up. I spent way too long tweaking the design, though, and my weekend got away from me. In the meantime…</p>

<p>It’s up as a temporary <a href="http://brettterpstra.github.com/">test site on GitHub</a>. It’s really, really rough; it’s very much still a work in progress, but I know you’ll be forgiving. nvALT 2.1 should be out very soon, and I have secret project keeping me busy right now, so I’m not giving any ETA’s on the final product. In the meantime, I’d love to hear everyone’s thoughts on Jekyll and other blog-related nerdery.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/markdown-quicktags-wordpress-plugin/' rel='bookmark' title='Markdown QuickTags: WordPress plugin for Markdown lovers'>Markdown QuickTags: WordPress plugin for Markdown lovers</a></li>
<li><a href='http://brettterpstra.com/marked-1-3-drawing-winners/' rel='bookmark' title='Marked 1.3 drawing winners'>Marked 1.3 drawing winners</a></li>
<li><a href='http://brettterpstra.com/markdown-quicktags-makes-1000-people-happier-and-more-attractive/' rel='bookmark' title='Markdown QuickTags makes 1000 people happier and more attractive'>Markdown QuickTags makes 1000 people happier and more attractive</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/i-think-im-switching-to-jekyll/">I think I’m switching to Jekyll…</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/i-think-im-switching-to-jekyll/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Markdown QuickTags makes 1000 people happier and more attractive</title>
		<link>http://brettterpstra.com/markdown-quicktags-makes-1000-people-happier-and-more-attractive/</link>
		<comments>http://brettterpstra.com/markdown-quicktags-makes-1000-people-happier-and-more-attractive/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 19:04:15 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[mdqt]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=2227</guid>
		<description><![CDATA[<p>I can’t prove that anybody is happier, really, and attraction is entirely subjective. For all I know they were run off by the “invalid header” error1 and never even tried it out, but Markdown QuickTags finally passed the 1000 downloads mark on the WordPress Plugins site. I’m celebrating by diving into nvALT for the weekend, but version 0.8 of MDQT&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/markdown-quicktags-makes-1000-people-happier-and-more-attractive/">Markdown QuickTags makes 1000 people happier and more attractive</a></p>]]></description>
			<content:encoded><![CDATA[<p>I can’t prove that anybody is happier, really, and attraction is entirely subjective. For all I know they were run off by the “invalid header” error<sup id="fnref:invalidheader"><a href="#fn:invalidheader" rel="footnote">1</a></sup> and never even tried it out, but <a href="http://wordpress.org/extend/plugins/markdown-quicktags/">Markdown QuickTags</a> <em>finally</em> passed the <a href="http://wordpress.org/extend/plugins/markdown-quicktags/stats/">1000 downloads mark</a> on the WordPress Plugins site. I’m celebrating by diving into nvALT for the weekend, but version 0.8 of <abbr title="Markdown QuickTags">MDQT</abbr> is in the works.</p>

<p>I’ve handled almost all of the bug reports for the plugin and it’s a smooth-running machine for me now. If you like <a href="http://en.wikipedia.org/wiki/Markdown">Markdown</a> and use WordPress, you really should check it out. I’m not making any money on it, but it makes my insides feel gooey to know I made your life that much easier. You’re totally worth it.</p>

<p>Here’s a quick breakdown, if you’ve previously never heard of Markdown QuickTags:</p>

<p><span id="more-2227"></span></p>

<div id="attachment_2228" class="wp-caption alignright" style="width: 310px;  border: 1px solid #dddddd; background-color: #f3f3f3; padding-top: 4px; margin: 10px; text-align:center; float: right;"><a href="http://cdn2.brettterpstra.com/wp-content/uploads/2011/04/MarkdownQuickTagsScreenshot4-23.jpg?9d7bd4"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/04/MarkdownQuickTagsScreenshot4-23-300x213.jpg?9d7bd4" alt="Markdown QuickTags Screenshot" title="Markdown QuickTags Screenshot" width="300" height="213" class="size-medium wp-image-2228" /></a><p style=' padding: 0 4px 5px; margin: 0;'  class="wp-caption-text">Click for big.</p></div>

<p>It’s a plugin with a powerful Markdown editor that replaces the WordPress HTML view. It provides auto-pairing, wrapping, link detection, smart list continuation, reference link title completion and much more.</p>

<p>Auto-pairing and wrapping are my favorite features; select text and type the left character of a double or single quote, square, curly or angle brackets or a backtick and the appropriate pairing will surround your selection. If you type the left character without a selection, it will create the pair and place your cursor in the middle. If you finish typing and your cursor is to the immediate left of the right character in the pair, typing the right character will jump you out of the scope and not double the quote/bracket.</p>

<p>If you have some reference-format links in your post (<code>[link title]: http://link.com</code>) and you select some text and hit the left square bracket twice, it will create a reference link (<code>[linked text][]</code>) and go into autocomplete mode with the list of all your reference titles ready to fill in as you type the first couple of characters. Pressing <code>[(</code> with text selected will start an inline link and fill in the “http://” for you, leaving it selected so you can just paste over it if you like. There’s even a button that pops up a text field where you can paste <em>any</em> text containing links, even the full source code for a page, and it will parse them out, give them titles and insert a list of reference links into your post for you to work with.</p>

<p>You can save your post as Markdown if you have a plugin installed to render it on the front end (<a href="http://wordpress.org/extend/plugins/markdown-for-wordpress-and-bbpress/">like this one</a>), or you can use the built-in Markdown (Extra) converter to turn it into clean HTML and switch back the the visual view. You can also go the other way, turning existing HTML posts into Markdown for editing using the Markdownify button at the bottom. It works <a href="http://markdownrules.com/">just like Marky</a>. There’s also an overlay preview system (which can take custom styles) and a full-screen editing mode with customizable background color and transparency. You can even customize the font in the editor with built-in <a href="http://www.google.com/webfonts">Google fonts</a>. Whew.</p>

<p>I could go on for a long, long time, but I just wanted to let people know that Markdown QuickTags is alive and kicking, and making some new strides soon. It’s not perfect, but it definitely makes my life easier. Check it out <a href="http://wordpress.org/extend/plugins/markdown-quicktags/">at the WordPress Plugins site</a>.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:invalidheader">
<p>There’s an error that’s still plaguing the plugin where, when you first install it, it tells you it was unsuccessful because of an “invalid header”. I can <strong>not</strong> find the problem, but going back to your plugins page and activating it manually works fine. When it upgrades, it disables itself for the same reason, so you have to go back and enable it <em>again</em>. If you happen to know the answer to this problem, <em>please</em> let me know. <a href="#fnref:invalidheader" rev="footnote">↩</a></p>
</li>

</ol>
</div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/markdown-quicktags-wordpress-plugin/' rel='bookmark' title='Markdown QuickTags: WordPress plugin for Markdown lovers'>Markdown QuickTags: WordPress plugin for Markdown lovers</a></li>
<li><a href='http://brettterpstra.com/markdown-quicktags-0-7/' rel='bookmark' title='Markdown QuickTags 0.7'>Markdown QuickTags 0.7</a></li>
<li><a href='http://brettterpstra.com/markdown-quicktags-0-8-for-christmas/' rel='bookmark' title='Markdown QuickTags 0.8 for Christmas'>Markdown QuickTags 0.8 for Christmas</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/markdown-quicktags-makes-1000-people-happier-and-more-attractive/">Markdown QuickTags makes 1000 people happier and more attractive</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/markdown-quicktags-makes-1000-people-happier-and-more-attractive/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>AutoTag2: smarter tagging for TextMate and WordPress</title>
		<link>http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/</link>
		<comments>http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/#comments</comments>
		<pubDate>Sun, 03 Apr 2011 20:11:53 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[tagging]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=2154</guid>
		<description><![CDATA[<p>I was tooling around the Vim website looking at blogging plugins this morning. I noticed that one of them, Vimpress, had linked to an old project of mine that allowed you to work with Ultimate Tag Warrior tags through XML-RPC. Since the inclusion of tagging support in WordPress, Ultimate Tag Warrior has been defunct, and so have the UTW-RPC plugin&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/">AutoTag2: smarter tagging for TextMate and WordPress</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/04/autotag_add_tags_panel.jpg?9d7bd4" alt="Autotag Add Tags panel" height="469" width="349" class="alignright">I was tooling around the <a href="http://www.vim.org">Vim website</a> looking at blogging plugins this morning. I noticed that one of them, <a href="http://www.vim.org/scripts/script.php?script_id=1953">Vimpress</a>, had linked to an old <a href="http://blog.circlesixdesign.com/download/utw-rpc-autotag/">project of mine</a> that allowed you to work with Ultimate Tag Warrior tags through <a href="http://en.wikipedia.org/wiki/XML-RPC">XML-RPC</a>. Since the inclusion of tagging support in WordPress, Ultimate Tag Warrior has been defunct, and so have the UTW-RPC plugin and associated AutoTag TextMate bundle.</p>

<p>Thinking about it for a minute, I realized I really did miss the functionality that AutoTag had given me. While I’ve toyed around with blogging from Vim, I still primarily use TextMate, not least because of the <a href="http://bundle.weblogzinc.com/docs/index.php">Blogsmith Blogging Bundle</a>. Until that kind of functionality is ported to Vim, I’m happy right here. Thus, I spent my Sunday afternoon reviving the AutoTag bundle.</p>

<p>If you use <a href="http://blog.macromates.com/2006/blogging-from-textmate/">TextMate to blog on a WordPress site</a>, you’ll want to see this.</p>

<p><span id="more-2154"></span></p>

<p>There are two parts to this: a WordPress plugin that adds an XML-RPC call for getting all of the tags in use on the blog, and a small TextMate bundle for making good use of it. The TextMate bundle cribs off of my previous AutoTag project, and borrows most of the remote functionality from the original TextMate blogging bundle. Why reinvent the wheel? I’m bundling both together in the download, so if you want to use the WordPress plugin to port the functionality elsewhere (say, Vim?), you can just pull out the parts you need.</p>

<p>[<a href="#download">Skip to download</a>]</p>

<h2>AutoTagging in TextMate</h2>

<p>What the bundle does (short version) is find the most appropriate tags for your content based on <em>tags you’ve already used</em> before. This helps you easily keep your tag collection trim and <em>useful</em>. No disparate tags because of inconsistent capitalization, plurals or conjugation. Things that are related stay related. This can be especially difficult blogging from TextMate because you can’t quickly see “all tags” the way you can from the WordPress editor. This solves the problem.</p>

<h3>Install the WordPress plugin</h3>

<p>Standard install, like any other (manually-installed) plugin:</p>

<ul>
<li>Upload the gettags-rpc folder from the zip download to your <code>wp-content/plugins</code> folder on your server.</li>
<li>Open your admin page and go to the Plugins panel.</li>
<li>Activate the GetTags-RPC plugin in the plugin list.</li>
</ul>

<p>If the plugin activates without error, you should be ready to go. It’s a very simple plugin without a lot of error checking, so let me know if you have any trouble with it.</p>

<h3>Install the AutoTag bundle</h3>

<p>To install AutoTag in TextMate, double click on the bundle in the download zip file. It should open TextMate, pop up the Bundle Editor and show you the installed bundle and its commands. Done.</p>

<p>Assuming you have AutoTag installed in TextMate and the GetTags-RPC plugin installed in WordPress, you’re ready to go. Well, you’ll need to have your blog set up (Bundles &gt; Blogging &gt; Setup Blogs) in TextMate, but we’ll assume you’ve done that by now.</p>

<h3>Using the commands</h3>

<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/04/autotag_tab_trigger.jpg?9d7bd4" alt="AutoTag Tab Trigger" height="166" width="287" class="alignright shadow">The AutoTag commands can be triggered in two ways. First, you can just put your cursor one space after the colon in the “Keywords:” line of the template headers. If you don’t have that line in your template, you can just type “Keywords: ” on a line before the end of the headers, or add it permanently by editing the template in the Bundle Editor. Hit tab from there and you’ll get a menu of the three commands in the bundle. You can trigger that from the same point even if you already have tags on the line; it will add appropriate commas automatically. Second, you can use Control-Option-T to get the same menu at any point in the file, although I’m not sure why you’d call it from anywhere <em>other</em> than the “Keywords” line.</p>

<h4>Commands</h4>

<p><strong>AutoTag:</strong> This is the primary command, or at least my favorite in the bundle. It’s only good when you run it <em>after</em> you write your post; it doesn’t have anything to work with on a blank template. Finish your post (or open an existing one) and trigger the command. It will grab all existing tags on your blog and compare them to your text, resulting in a dialog with a list of the best matches ranked by relevance. If you’re curious, here’s what it does when processing:</p>

<ul>
<li>Strips out all punctuation from the content of your post and creates an array of words</li>
<li>Uses the Porter Stemming algorithm to get the stem of each word. This makes plurals, adjective, adverb and verb forms all represent the same word.</li>
<li>Compares the list of stemmed words to the stems of each tag returned by your blog, keeping matches.</li>
<li>Measures the frequency of each match in the content and sorts the list accordingly.</li>
</ul>

<p><strong>Common Words:</strong> This command ignores the tags on your blog and just gives you the most common words from your post for selection as tags. It’s a good way to figure out what new tags might be worth adding. Again, it’s not very useful if you don’t have your content written yet.</p>

<p><strong>All Tags:</strong> If you’re not finding the AutoTag results satisfactory on a given post, or you want to tag before you have any content, this command will simply return your entire list of available tags. You can use it to check what form or casing you used on an existing tag, and it can be run at any time.</p>

<p>That’s it. If you use WordPress and TextMate together, I know you’re going to love this. Let me know how it goes! By the way, I’ll probably (eventually) build similar functionality right into the WordPress editor, and I’d love to see this ported to Vim, too. Any Vim plugin writers want a challenge?</p>

<h2>Download</h2>

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/AutoTag2_1.0.1.zip?9d7bd4" title="Download AutoTag2 and GetTags-RPC (310)"><img src="http://brettterpstra.com/wp-content/plugins/download-monitor/page-addon/thumbnail.gif?9d7bd4" alt="download image for AutoTag2 and GetTags-RPC" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/AutoTag2_1.0.1.zip?9d7bd4" title="Download AutoTag2 and GetTags-RPC (310)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/AutoTag2_1.0.1.zip?9d7bd4" title="Download AutoTag2 and GetTags-RPC (310)">AutoTag2 and GetTags-RPC</a> — A combination WordPress plugin and TextMate bundle to provide additional tag functionality when blogging from TextMate to WordPress. <a href="http://brettterpstra.com/?p=2154">More Info</a></p></div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/markdown-quicktags-wordpress-plugin/' rel='bookmark' title='Markdown QuickTags: WordPress plugin for Markdown lovers'>Markdown QuickTags: WordPress plugin for Markdown lovers</a></li>
<li><a href='http://brettterpstra.com/textmate-as-writeroom-for-free/' rel='bookmark' title='TextMate as WriteRoom, for free'>TextMate as WriteRoom, for free</a></li>
<li><a href='http://brettterpstra.com/getting-back-into-real-textmate-blogging/' rel='bookmark' title='Getting back into real TextMate blogging'>Getting back into real TextMate blogging</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/">AutoTag2: smarter tagging for TextMate and WordPress</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress, custom taxonomy, and XML-RPC</title>
		<link>http://brettterpstra.com/wordpress-custom-taxonomy-and-xml-rpc/</link>
		<comments>http://brettterpstra.com/wordpress-custom-taxonomy-and-xml-rpc/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 16:52:52 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[xmlrpc]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1952</guid>
		<description><![CDATA[<p>This is a quick tip for anyone who may be searching for an answer to the question: “Is there any way to use XMLRPC to send custom post types to WordPress and attach custom taxonomy terms to them?” Yes, there is. It took me longer than it should have to find it, but I’ve successfully uploaded images, and attached them&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/wordpress-custom-taxonomy-and-xml-rpc/">WordPress, custom taxonomy, and XML-RPC</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/02/wordpresslogopeeling.jpg?9d7bd4" alt="Wordpresslogopeeling" border="0" width="284" height="285" class="alignright" />This is a quick tip for anyone who may be searching for an answer to the question: “Is there any way to use <a href="http://www.xmlrpc.com/">XMLRPC</a> to send <a href="http://codex.wordpress.org/Post_Types#Custom_Types">custom post types</a> to <a href="http://wordpress.com/">WordPress</a> <em>and</em> attach custom taxonomy terms to them?” Yes, there is. It took me longer than it should have to find it, but I’ve successfully uploaded images, and attached them to a “howtos” post type with “level” and “topic” set under its custom taxonomies.</p>

<p><span id="more-1952"></span>
The custom post part is easy, and if you’re working with XML-RPC, you’ve probably already figured it out. Just set your ‘post_type’ to your registered custom post type when you pass the construct to create a new post.</p>

<p>Then it got sticky for me. I ended up finding a nearly <a href="http://core.trac.wordpress.org/ticket/10776">2-year-old patch</a> to the xmlrpc.php file with the answer, and I was pleasantly surprised to see it had already been applied in current versions. So much for documentation. <strong>The construct just needs an element called <code>mt_taxonomy</code>, and it takes an associative array with two keys: <code>tags</code> and <code>taxonomy</code>. <code>tags</code> holds the terms you want to apply, either as another array or in a comma-separated list, and <code>taxonomy</code> is the name of the custom taxonomy they’re assigned/available to.</strong></p>

<p>I ended up adding my own methods to the MetaWeblog interface for handling my specific post types. Quick example:</p>


<div class="wp_syntax"><div class="code"><pre class="php">add_filter<span class="br0">&#40;</span><span class="st_h">'xmlrpc_methods'</span><span class="sy0">,</span> <span class="st_h">'bt_xmlrpc_methods'</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="kw2">function</span> bt_xmlrpc_methods<span class="br0">&#40;</span><span class="re0">$methods</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span>
	<span class="re0">$methods</span><span class="br0">&#91;</span><span class="st_h">'metaWeblog.addHowTo'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'bt_add_howto'</span><span class="sy0">;</span>
	<span class="kw1">return</span> <span class="re0">$methods</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div>


<p>Then a function called <code>bt_add_howto</code> receives the $args, which will generally be:</p>


<div class="wp_syntax"><div class="code"><pre class="php"><span class="re0">$post_ID</span>         <span class="sy0">=</span> <span class="br0">&#40;</span>int<span class="br0">&#41;</span> <span class="re0">$args</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="re0">$username</span>        <span class="sy0">=</span> <span class="re0">$args</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="re0">$password</span>        <span class="sy0">=</span> <span class="re0">$args</span><span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="re0">$content_struct</span> <span class="sy0">=</span> <span class="re0">$args</span><span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="re0">$publish</span>         <span class="sy0">=</span> <span class="re0">$args</span><span class="br0">&#91;</span><span class="nu0">4</span><span class="br0">&#93;</span><span class="sy0">;</span></pre></div></div>


<p>At this point, I think I’m just taking notes for myself. Hopefully this pointer will be enough to help someone else not spend an hour banging their head against the desk. Custom post types are fun, and growing more flexible, but there are a lot of walls you can run into right now.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/adding-a-tinymce-button/' rel='bookmark' title='Adding a TinyMCE button to WordPress'>Adding a TinyMCE button to WordPress</a></li>
<li><a href='http://brettterpstra.com/edit-your-wordpress-quicktags-the-right-way/' rel='bookmark' title='Edit your WordPress QuickTags the right way'>Edit your WordPress QuickTags the right way</a></li>
<li><a href='http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/' rel='bookmark' title='Evernote Site Memory tagger for WordPress'>Evernote Site Memory tagger for WordPress</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/wordpress-custom-taxonomy-and-xml-rpc/">WordPress, custom taxonomy, and XML-RPC</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/wordpress-custom-taxonomy-and-xml-rpc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Markdown QuickTags 0.7</title>
		<link>http://brettterpstra.com/markdown-quicktags-0-7/</link>
		<comments>http://brettterpstra.com/markdown-quicktags-0-7/#comments</comments>
		<pubDate>Sun, 28 Nov 2010 16:18:13 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[quicktags]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1383</guid>
		<description><![CDATA[<p>Markdown QuickTags, my WordPress plugin which adds extensive Markdown features to the HTML editor, has been upped to 0.7. The download link has actually been incrementing for the last week, but this is the first real stable release, so I’ve held off on writing this up until today. The latest version has too many new features to list, but you&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/markdown-quicktags-0-7/">Markdown QuickTags 0.7</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://cdn2.brettterpstra.com/wp-content/uploads/2010/11/markdownquicktagsscreenshot.jpg?9d7bd4"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/11/markdownquicktagsscreenshot-150x150.jpg?9d7bd4" alt="Markdown QuickTags screenshot" title="markdownquicktagsscreenshot" width="150" height="150" class="alignright size-thumbnail wp-image-1384" /></a>Markdown QuickTags, my WordPress plugin which adds extensive Markdown features to the HTML editor, has been upped to 0.7. The download link has actually been incrementing for the last week, but this is the first real stable release, so I’ve held off on writing this up until today.</p>

<p>The latest version has too many new features to list, but you can get an overview on the <a href="http://brettterpstra.com/code/markdown-quicktags/">plugin page</a>. One of the coolest new features is reference link auto-completion. If you surround some text in square brackets (which you can do just by highlighting the text and hitting the left square bracket key), and then follow it immediately with another pair of square brackets, typing the first letter or two of a reference that already exists in your document will autocomplete the title for you. Square brackets, of course, are auto-paired, so when you type the left bracket, the right one is automatically added and your cursor is placed between them. It’s <em>fast</em>.</p>

<p>There are improvements to the undo stack, which now records 100 screen states and lets you step forward and back through them using [Shift]-Command/Control-Z. There have been lots of text-editing improvements, and new dialog boxes for pasting bunches of links as references. Note that it will parse links out of any text format, so any list of links–even with other text in the paste–will turn into a nicely formatted list with automatic titles based on the domain.</p>

<p>The plugin has been submitted for approval in the official WordPress Plugin Repository, so hopefully you’ll be able to grab it there and get automatic updates shortly. For now, grab it on the <a href="http://brettterpstra.com/code/markdown-quicktags/">plugin’s project page</a>.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/markdown-quicktags-makes-1000-people-happier-and-more-attractive/' rel='bookmark' title='Markdown QuickTags makes 1000 people happier and more attractive'>Markdown QuickTags makes 1000 people happier and more attractive</a></li>
<li><a href='http://brettterpstra.com/markdown-quicktags-wordpress-plugin/' rel='bookmark' title='Markdown QuickTags: WordPress plugin for Markdown lovers'>Markdown QuickTags: WordPress plugin for Markdown lovers</a></li>
<li><a href='http://brettterpstra.com/markdown-quicktags-0-8-for-christmas/' rel='bookmark' title='Markdown QuickTags 0.8 for Christmas'>Markdown QuickTags 0.8 for Christmas</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/markdown-quicktags-0-7/">Markdown QuickTags 0.7</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/markdown-quicktags-0-7/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Markdown QuickTags: WordPress plugin for Markdown lovers</title>
		<link>http://brettterpstra.com/markdown-quicktags-wordpress-plugin/</link>
		<comments>http://brettterpstra.com/markdown-quicktags-wordpress-plugin/#comments</comments>
		<pubDate>Fri, 12 Nov 2010 15:05:44 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[mdqt]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1323</guid>
		<description><![CDATA[<p>Introducing Markdown Quicktags, a new WordPress plugin for Markdown lovers! If you edit your blog in Markdown, whether you publish that way or not, this plugin will make your life almost 37% better. It’s quickly turning out to be one of the coolest things I think I’ve ever done! It replaces the default QuickTags in the WordPress HTML editor with&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/markdown-quicktags-wordpress-plugin/">Markdown QuickTags: WordPress plugin for Markdown lovers</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://cdn2.brettterpstra.com/wp-content/uploads/2010/11/MarkdownQuickTagsScreenShot.jpg?9d7bd4"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/11/MarkdownQuickTagsScreenShot-300x190.jpg?9d7bd4" alt="" title="Markdown QuickTags Screenshot" width="300" height="190" class="alignright size-medium wp-image-1326 shadow" /></a>Introducing Markdown Quicktags, a new <a href="http://wordpress.org/">WordPress</a> plugin for <a href="http://daringfireball.net/projects/markdown/">Markdown</a> lovers! If you edit your blog in Markdown, whether you publish that way or not, this plugin will make your life almost 37% better. It’s quickly turning out to be one of the coolest things I think I’ve ever done!</p>

<p>It replaces the default QuickTags in the WordPress HTML editor with a set of Markdown-optimized tags, with plenty of extra features. I had mentioned discovering a <a href="http://brettterpstra.com/edit-your-wordpress-quicktags-the-right-way/">non-intrusive way to edit the WordPress QuickTags</a> the other day, and then my insomnia took it to this level. I basically put most of my favorite features of TextMate into a textarea. Auto pairing and selection wrapping, list generation from multipe lines, indentation preservation, parsing multiple urls from pasted text, and more. The buttons are really just the beginning.</p>

<p>Note that this plugin in <strong>BETA</strong>. It has a ways to go, and you’ll probably find glitches. Please give it a try, though, and let me know what you think, either in the comments here, or <a href="http://brettterpstra.com/contact/">contact me directly</a>.</p>

<p>Once I feel like this is stable, <del datetime="2011-01-14T21:47:16+00:00">I’ll add it to the WordPress plugin repository</del> <ins datetime="2011-01-14T21:47:16+00:00">(<a href="http://wordpress.org/extend/plugins/markdown-quicktags/">check it out in the WordPress plugins</a>)</ins> and you’ll be able to get automatic updates. For now, please check back to get the latest versions. The download link will always be up to date throughout the blog, and when I push the next tagged release, I’ll start a changelog on the <a href="http://brettterpstra.com/code/markdown-quicktags/">project page</a>.</p>

<p>The next step is to modify this into a Safari Extension which will allow <em>any</em> text field to become a Markdown Editor. The basic editing features will probably also turn into a jQuery plugin. For now, WordPress users who love Markdown should <a href="http://brettterpstra.com/code/markdown-quicktags/">go get it</a>!</p>


<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/markdown-quicktags-0-8-for-christmas/' rel='bookmark' title='Markdown QuickTags 0.8 for Christmas'>Markdown QuickTags 0.8 for Christmas</a></li>
<li><a href='http://brettterpstra.com/markdown-quicktags-0-7/' rel='bookmark' title='Markdown QuickTags 0.7'>Markdown QuickTags 0.7</a></li>
<li><a href='http://brettterpstra.com/edit-your-wordpress-quicktags-the-right-way/' rel='bookmark' title='Edit your WordPress QuickTags the right way'>Edit your WordPress QuickTags the right way</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/markdown-quicktags-wordpress-plugin/">Markdown QuickTags: WordPress plugin for Markdown lovers</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/markdown-quicktags-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Edit your WordPress QuickTags the right way</title>
		<link>http://brettterpstra.com/edit-your-wordpress-quicktags-the-right-way/</link>
		<comments>http://brettterpstra.com/edit-your-wordpress-quicktags-the-right-way/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 15:08:34 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1228</guid>
		<description><![CDATA[<p>You may have cause, at some point, to modify the behavior of the QuickTags in the HTML editor of WordPress (the non-WYSIWYG, non-“Visual” editor). There are a lot of tutorials available for editing the quicktags.js file in the WordPress wp-includes folder, but they all seem to want you to edit the file directly. That’s a Bad Idea™ because the next&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/edit-your-wordpress-quicktags-the-right-way/">Edit your WordPress QuickTags the right way</a></p>]]></description>
			<content:encoded><![CDATA[<p>You may have cause, at some point, to modify the behavior of the QuickTags in the HTML editor of WordPress (the non-WYSIWYG, non-“Visual” editor). There are a lot of tutorials available for editing the quicktags.js file in the WordPress wp-includes folder, but they all seem to want you to edit the file directly. That’s a Bad Idea™ because the next time you upgrade, your changes are kaput. Here’s how to make your own quicktags.js and do whatever you want with it.</p>

<p>There are some perfectly capable plugins for adding new buttons, too. This morning I wanted to change the behavior of existing buttons, though, so it came down to this.</p>

<p>This post is directed toward people who are at least moderately comfortable editing php and javascript. I’m not going to go into a lot of detail on the actual edits, but will get you started on modifying your QuickTags and provide some source code.</p>

<p><span id="more-1228"></span></p>

<h3>The quicktags.js file</h3>

<p>Go into the /wp-includes/js folder and find quicktags.dev.js. Copy it to your template folder (or any subfolder) and rename it quicktags.js.</p>

<p>Edit the file. The code has some localization in it which we’re about to break, so search for quicktagsL10n and replace every instance with an appropriate, quoted string. For example, you’ll find <code>quicktagsL10n.enterURL</code>, which should be replaced with something like ‘Enter the URL’. You can find all of the original strings in /wp-includes/script-loader.php, if you like.</p></p>

<p>Now you can edit the buttons and functions as you see fit. There’s a pretty good <a href="http://www.tamba2.org.uk/wordpress/quicktags/">overview at Tamba2</a>. You’ll notice that some buttons have functions associated with them, such as the “link” and “img” buttons, so be sure to edit those as well if you’re modifying those buttons.</p>

<h3>Overriding the original</h3>

<p>Now we just need to change which script gets called when you’re in the post editor. Add the following to your theme’s functions.php file:</p>


<div class="wp_syntax"><div class="code"><pre class="php"><span class="kw2">function</span> bt_load_admin_scripts<span class="br0">&#40;</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span>
  <span class="kw1">if</span> <span class="br0">&#40;</span> is_admin<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span>
    wp_deregister_script<span class="br0">&#40;</span><span class="st_h">'quicktags'</span><span class="br0">&#41;</span><span class="sy0">;</span>
    wp_register_script<span class="br0">&#40;</span><span class="st_h">'quicktags'</span><span class="sy0">,</span> <span class="br0">&#40;</span><span class="st0">&quot;/path/to/your/quicktags.js&quot;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="kw4">false</span><span class="sy0">,</span> <span class="st_h">''</span><span class="sy0">,</span> <span class="kw4">true</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="br0">&#125;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="kw1">if</span> <span class="br0">&#40;</span>is_admin<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
  add_action<span class="br0">&#40;</span><span class="st_h">'init'</span><span class="sy0">,</span> bt_load_admin_scripts<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div>


<p>Modify the path in wp_register_script to point to the location where you put your quicktags.js file. This will tell WordPress to load your file instead of its own.</p>

<p>Now, edit a new post (in the HTML editor, not the Visual editor) to test out your changes. If everything is correct, modified and new buttons should show up and function the way you want. Your changes will persist, even after a WordPress upgrade!</p>

<p>Here’s my copy of quicktags.js, modified to turn it into a Markdown editor.</p>

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/quicktags.markdown.zip?9d7bd4" title="Download QuickTags to Markdown (132)"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/downloads/thumbnails/2010/11/wordpress-icon.png?9d7bd4" alt="download image for QuickTags to Markdown" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/quicktags.markdown.zip?9d7bd4" title="Download QuickTags to Markdown (132)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/quicktags.markdown.zip?9d7bd4" title="Download QuickTags to Markdown (132)">QuickTags to Markdown</a> — A replacement quicktags.js file for WordPress which modifies the behavior of existing buttons to output Markdown, with a couple of useful button additions. <a href="http://brettterpstra.com/edit-your-wordpress-quicktags-the-right-way/">More Info</a></p></div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/markdown-quicktags-wordpress-plugin/' rel='bookmark' title='Markdown QuickTags: WordPress plugin for Markdown lovers'>Markdown QuickTags: WordPress plugin for Markdown lovers</a></li>
<li><a href='http://brettterpstra.com/markdown-quicktags-0-8-for-christmas/' rel='bookmark' title='Markdown QuickTags 0.8 for Christmas'>Markdown QuickTags 0.8 for Christmas</a></li>
<li><a href='http://brettterpstra.com/markdown-quicktags-0-7/' rel='bookmark' title='Markdown QuickTags 0.7'>Markdown QuickTags 0.7</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/edit-your-wordpress-quicktags-the-right-way/">Edit your WordPress QuickTags the right way</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/edit-your-wordpress-quicktags-the-right-way/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Four WordPress Plugins I love</title>
		<link>http://brettterpstra.com/four-wordpress-plugins-i-love/</link>
		<comments>http://brettterpstra.com/four-wordpress-plugins-i-love/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 12:20:48 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Write]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1209</guid>
		<description><![CDATA[<p>I know some people have been moving away from WordPress and toward blogging solutions like Tumblr. The number one reason I hear for making this move is that WordPress gets to complicated once you start customizing. Distractingly so. I don’t disagree. I love tweaking WordPress websites, though, and have built quite a few of them. The plugin community is part&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/four-wordpress-plugins-i-love/">Four WordPress Plugins I love</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display:none'  class="headerimg" src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/11/4wordpresspluginspostheader.jpg?9d7bd4" alt="Header image" /></p>

<p>I know some people have been moving away from WordPress and toward blogging solutions like Tumblr. The number one reason I hear for making this move is that WordPress gets to complicated once you start customizing. Distractingly so. I don’t disagree.</p>

<p>I love tweaking WordPress websites, though, and have built quite a few of them. The plugin community is part of what makes it so much fun. I’m constantly amazed by the creativity and craftsmanship I see go into these projects. Most of them don’t make any money, but I thought I’d show you a few I’ve been more than happy to donate to.</p>

<p>There are a few bedrock plugins that I think everyone should have, and as such I’m only going to mention them in passing: <a href="http://www.w3-edge.com/wordpress-plugins/w3-total-cache/">W3 Total Cache</a>, <a href="http://michelf.com/projects/php-markdown/">Markdown Extra</a>, and of course, Akismet. There are others, though, that I hadn’t heard much about before, yet they’ve become integral to my current blog. Here are my plugin crushes right now…</p>

<p><span id="more-1209"></span></p>

<dl>
<dt><a href="http://langui.sh/updraft-wp-backup-restore">Updraft</a></dt>
<dd>I’ve tried quite a few plugins for backing up my blog, but all have eventually failed me, with the exception of Updraft. I think its simplicity is its saving grace; it doesn’t try to be anything more than a hassle-free way to back up your entire WordPress blog, including uploads, themes and database. I’m using it to back up to my Amazon S3 account, and it also works with Rackspace, your own FTP server, or, if you really want to, it can email your backups to you. It can purge older backups, and the restore feature is as fast as your storage system of choice.</dd>

<dt><a href="http://deanjrobinson.com/projects/fluency-admin/">Fluency Admin</a></dt>
<dd>This one is just wicked. It’s a theme for the admin panel which not only looks amazing, it adds extensive keyboard navigation to the back end. If you know me, you know that makes me happy.</dd>

<dt><a href="http://neop.gbtopia.com/?p=108">Postalicious</a></dt>
<dd>I’ve been toying a lot with how to share my bookmarks and web trails lately. Postalicious came along and made it easy to post groups of links to my blog automatically, and with complete control over formatting. Right now I have it pulling from Delicious, waiting until there are at least 4 new bookmarks (and not more than 6) with the tag “blogit,” and publishing the list with links and my notes, and the date in the title. All I have to do is pop up Delibar once in a while and bookmark something I think is worth sharing. Postalicious also works with ma.gnolia, Google Reader, Reddit, Yahoo Pipes and Jumptags.</dd>

<dt><a href="http://wordpress.org/extend/plugins/wp-syntax-download-extension">WP-Syntax Download Extension</a></dt>
<dd>WP-Syntax is a great solution for code highlighting. It’s taken me a lot of tweaking to get it running, and I hadn’t liked the idea of offering syntax-highlighted code without a raw backup. This extension, used in combination with WP-Syntax, allows users to grab the raw source or force a download of a file. It’s rather ingenious once you dig into the code, if not a bit of a hack (I mean that in a good way, I’m intrigued). But it works, and it solves a few of my concerns!</dd>
</dl>

<p>If you’re a WordPress user and you haven’t tried some of these out, give them a shot. None of the plugins above add anything to the front end which would slow your site down for end users, so go ahead and play!</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/markdown-quicktags-wordpress-plugin/' rel='bookmark' title='Markdown QuickTags: WordPress plugin for Markdown lovers'>Markdown QuickTags: WordPress plugin for Markdown lovers</a></li>
<li><a href='http://brettterpstra.com/i-think-im-switching-to-jekyll/' rel='bookmark' title='I think I’m switching to Jekyll…'>I think I’m switching to Jekyll…</a></li>
<li><a href='http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/' rel='bookmark' title='AutoTag2: smarter tagging for TextMate and WordPress'>AutoTag2: smarter tagging for TextMate and WordPress</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/four-wordpress-plugins-i-love/">Four WordPress Plugins I love</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/four-wordpress-plugins-i-love/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Evernote Site Memory tagger for WordPress</title>
		<link>http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/</link>
		<comments>http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 10:06:52 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=947</guid>
		<description><![CDATA[<p>Evernote introduced Site Memory today, providing an easy way to help people clip to Evernote from your site while maintaining control over how your content appears and is attributed. While some instructions are provided for WordPress, some of us will obviously want to customize things a little further. Brett Kelly posted a quick PHP script on the Evernote WordPress docs&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/">Evernote Site Memory tagger for WordPress</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display:none'  class="headerimg" src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/09/evernotesitememoryheaderimage.jpg?9d7bd4" alt="Header image" /></p>

<p><a href="https://www.evernote.com/">Evernote</a> introduced <a href="http://www.evernote.com/about/developer/sitememory/">Site Memory</a> today, providing an easy way to help people clip to Evernote from your site while maintaining control over how your content appears and is attributed. While some instructions are <a href="http://www.evernote.com/about/developer/sitememory/wordpress.php">provided for WordPress</a>, some of us will obviously want to customize things a little further.</p>

<p><a href="http://brettkelly.org/">Brett Kelly</a> posted a quick PHP script on the Evernote WordPress docs to include the first three tags from your post as suggested tags in the clipper. I wanted to weight these, though, so here’s my version…</p>

<p><span id="more-947"></span></p>

<div markdown=0>
<pre><code>
&lt;a href=&quot;javascript:void()&quot; title=&quot;Clip to Evernote&quot; class=&quot;evernoteclip&quot; 
  onclick=&quot;Evernote.doClip({ title: &#x27;&lt;?php the_title_attribute(); ?&gt;&#x27;,
    providerName: &#x27;Brett Terpstra&#x27;,
    url: &#x27;&lt;?php the_permalink(); ?&gt;&#x27;,
    contentId: &#x27;post-&lt;?php the_ID(); ?&gt;-clip&#x27;,
    suggestTags: &#x27;&lt;?php
    if (get_post_meta($post-&gt;ID, &#x27;evernoteTags&#x27;, true)) {
      echo get_post_meta($post-&gt;ID, &#x27;evernoteTags&#x27;, true);
    } else {
      $posttags = get_the_tags();
      $out = array();
      if ($posttags) {
        foreach($posttags as $tag) {
          $out[trim($tag-&gt;name)] = intval($tag-&gt;count); 
        }
        ksort($out,SORT_NUMERIC);
        echo implode(array_keys(array_slice($out, 0, 3)),&#x27;,&#x27;);
      }
    }?&gt;&#x27;});return false;&quot;&gt;
&lt;img src=&quot;&lt;?php bloginfo(&#x27;template_url&#x27;); ?&gt;/images/evernoteclipper.png&quot; alt=&quot;Evernote Clipper Icon&quot;/&gt;
&lt;/a&gt;
</code></pre>
</div>

<p>It first checks for a custom field called “evernoteTags,” so you can override the whole thing by specifying up to three tags in a custom field in the post editor. The tags should be separated by commas, spaces aren’t important: “tag1,tag2,tag3”, no quotes. Moving on…</p>

<p>The rest of the code grabs all of the tags for the post and their use counts on your site, sorts by the use count and outputs the tag names. Pretty simple.</p>

<p>I should also note that the JavaScript library for the clipper weighs in at 33k compressed, so it’s not a lightweight addition to your blog. I grabbed the online source, minified it and am serving it from a CDN, so the hit was minimized, but still there. I’m also loading the clipper image from my CDN, just to avoid the extra offsite hit. I may eventually attempt to lazy load the script only when the link is clicked, but this works for now.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/antique-safari-reader-hack-update-with-evernote-goodness/' rel='bookmark' title='Antique Safari Reader hack update with Evernote goodness'>Antique Safari Reader hack update with Evernote goodness</a></li>
<li><a href='http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/' rel='bookmark' title='A better System Service for Evernote clipping — with MultiMarkdown'>A better System Service for Evernote clipping — with MultiMarkdown</a></li>
<li><a href='http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/' rel='bookmark' title='Taking the Markdown to Evernote service further'>Taking the Markdown to Evernote service further</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/">Evernote Site Memory tagger for WordPress</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Notes on cleaning up the MediaTemple hack (JohnnyA)</title>
		<link>http://brettterpstra.com/notes-on-cleaning-up-the-mediatemple-hack-johnnya/</link>
		<comments>http://brettterpstra.com/notes-on-cleaning-up-the-mediatemple-hack-johnnya/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 22:19:57 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[exploit]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=823</guid>
		<description><![CDATA[<p>NOTE: Be sure to read through the comments, there’s a lot of additional and very useful information in there. I’ll compile the notes as soon as I’m able and add them to the main post. First, the hack described here is not MediaTemple’s fault, nor an exploit of their security system. It’s a reminder to all of us that checking&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/notes-on-cleaning-up-the-mediatemple-hack-johnnya/">Notes on cleaning up the MediaTemple hack (JohnnyA)</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display:none'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/07/johnnyapostheaderimage.jpg?9d7bd4" alt="johnnyapostheaderimage.jpg" border="0" width="650" height="187" class="headerimg" /></p>

<p><strong>NOTE:</strong> Be sure to read through the comments, there’s a lot of additional and very useful information in there. I’ll compile the notes as soon as I’m able and add them to the main post.</p>

<p>First, the hack described here is <del datetime="2010-08-14T21:11:43+00:00">not MediaTemple’s fault, nor an exploit of their security system. It’s a reminder to all of us that checking permissions and updating software are the bare minimum we can do to avoid a lot of headache and potential security issues. MediaTemple was apparently just targeted because of their size, the responsibility for the hacked sites lies with the site’s owner/webmaster.</del><sup id="fnref:mediatemple"><a href="#fn:mediatemple" rel="footnote">1</a></sup></p>

<p>Second, it doesn’t just affect WordPress. I found bits of the exploit in MODx files, static files, and even some sites that weren’t accessible through the internet.</p>

<p>Lastly, to the perpetrators: thanks for the security reminder, but curses upon you and your families. May you spend eternity grepping for obscure lines of code while every client you have calls you to tell you their business is going to fail because their site is throwing security warnings.</p>

<p>What follows is not a full-fledged guide to cleaning up a hacked server, just some notes from my experience with this round.</p>

<h3>Have you been hacked?</h3>

<p>The exploit is a little difficult to notice. It inserts percent-escaped lines of code into JavaScript files you’re already including on your page, which then use document.write to add redirect code to the rendered page. This means that viewing source won’t show it, you have to see the rendered source, ala Firebug, Safari Web Inspector, or one of various plugins that show the actual source after the DOM has loaded.</p>

<p>What you’ll find in the rendered source is a little function that uses an array of colors and urls to generate somewhat random redirects. A url called ‘edisonsnightclub’ is always in the mix, so that’s what I search for. The redirect has the side-effect of triggering Firefox’s security warnings, which is a fair sight better than just sending clients off to malicious sites. However, it appears to only execute the code for search engine bots, so it could potentially go unnoticed on your site for quite some time.</p>

<p><span id="more-823"></span></p>

<h3>Cleanup</h3>

<p>I did my cleanup job hastily, and didn’t track everything as well as I should have. There were lines inserted into main template PHP files which I just quickly deleted. These always began with <code>$o=</code>, so that became my server-wide search pattern (more on that in a second). This didn’t only affect WordPress, it also hit my MODx sites and the exploit would probably hit static sites or any other CMS just fine, so check everything.</p>

<p>Once the PHP files were cleaned up, I realized that the most insidious part of the hack was that it picked random script files from your page to insert itself into. Tracking it down got interesting. One thing to note: you can tell what file it’s in when you view the rendered source by looking at the script tag right before the exploit code. The included script is where you’ll find the <code>document.write</code> line.</p>

<p>The point of entry on my GridServer turned out to be a single directory in a single WordPress install, from which a rootkit (identifiable by the existence of an <code>is_writable.php</code> file) was able to gain write access to 20+ sites that I host there. The rootkit was found in the <code>img</code> directory of a TinyMCE theme within a WordPress install.</p>

<p>The exploit doesn’t even change the mod dates on the files, so it’s hard to filter out the infected scripts. What I did was SSH in and <code>cd</code> to the <code>domains</code> directory, where I ran a grep for the patterns I’d found so far. The line within the javascript file looks like this (truncated):</p>

<p><code>var st1 = 0;document.write(unescape('%3C%73%63...%74%3E'));var gr0=0;</code></p>

<p>So I set up a grep command like this:</p>

<p><code>find ./ -name "*.js" -exec grep -l "gr0=0" {} \;</code></p>

<p>That gives me just the name and path of any file which contains a match to the string “gr0=0,” which is unique enough to narrow things down. I ran a similar grep for the PHP files:</p>

<p><code>find ./ -name "*.php" -exec grep -l '$o=' {} \;</code></p>

<p>That one yields some false positives, I need to find a more specific search criteria. It gets the job done, though. Then it’s just a matter of manually cleaning out the inserted lines. Be careful not to delete anything in your JavaScript files after the <code>gr0=0;</code>, such as the opening of a comment block or the first line of a jQuery plugin. Just delete up to the semicolon and you’ll be fine.</p>

<p>You’ll also want to check <em>all</em> of your databases. First look for extra admin users (JohnnyA is what they were always called in mine), then check for lines in your content tables as mentioned on the <a href="http://wiki.mediatemple.net/w/WordPress_Redirect_Exploit">MediaTemple wiki</a>.</p>

<p>Check that your permissions are secure<sup id="fnref:harden"><a href="#fn:harden" rel="footnote">2</a></sup> and make sure you find the rootkit and remove it. That will be several PHP files in a random directory, and they’ll have recent modification timestamps. As I mentioned, one of them should be called <code>is_writeable.php</code>, which you can use in a <code>find</code> statement as well.</p>

<p>Best of luck, and please add any additional notes or corrections in the comments!</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:mediatemple">
<p>I no longer have any confidence that MediaTemple is not at fault for this. I completely cleaned out the hack, updated all installs and plugins across the 20+ sites I host there, and today I’m starting over with a whole new blast of malware on the sites. <a href="#fnref:mediatemple" rev="footnote">↩</a></p>
</li>

<li id="fn:harden">
<p>See <a href="http://codex.wordpress.org/Hardening_WordPress">Hardening WordPress</a> in the Codex for examples <a href="#fnref:harden" rev="footnote">↩</a></p>
</li>

</ol>
</div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/quick-notes-on-cross-browser-html5-video/' rel='bookmark' title='Quick notes on cross-browser HTML5 video'>Quick notes on cross-browser HTML5 video</a></li>
<li><a href='http://brettterpstra.com/homecontrol-local-mac-control-for-iphone/' rel='bookmark' title='HomeControl: Local Mac control for iPhone'>HomeControl: Local Mac control for iPhone</a></li>
<li><a href='http://brettterpstra.com/meet-marky-the-markdownifier/' rel='bookmark' title='Meet Marky, the Markdownifier'>Meet Marky, the Markdownifier</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/notes-on-cleaning-up-the-mediatemple-hack-johnnya/">Notes on cleaning up the MediaTemple hack (JohnnyA)</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/notes-on-cleaning-up-the-mediatemple-hack-johnnya/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Better WordPress security through comment filters</title>
		<link>http://brettterpstra.com/better-wordpress-security-through-comment-filters/</link>
		<comments>http://brettterpstra.com/better-wordpress-security-through-comment-filters/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 11:57:22 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[functions.php]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=727</guid>
		<description><![CDATA[<p>I have an admin username (it’s not admin) which I use to manage my WordPress blog, and an editor user with which I write posts and leave comments. Sometimes, though, I get confused, lazy or both, and end up leaving comments as my admin user. This rather defeats the purpose of using a non-default admin username, which is generally done&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/better-wordpress-security-through-comment-filters/">Better WordPress security through comment filters</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display:none'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/07/wordpresssecuritycommentfiltersheader.jpg?9d7bd4" alt="Wordpress security comment filters header image" border="0" width="650" height="187" class="headerimg" /></p>

<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/07/combolock200.jpg?9d7bd4" alt="Combination Lock" border="0" width="200" height="200" class="alignright" />I have an admin username (it’s not <em>admin</em>) which I use to manage my WordPress blog, and an editor user with which I write posts and leave comments. Sometimes, though, I get confused, lazy or both, and end up leaving comments as my admin user. This rather defeats the purpose of using a non-default admin username, which is generally done for security purposes (if they can’t guess the admin’s username, it makes it that much harder to hack the admin account).</p>

<p>More out of laziness than anything else (we can call it efficiency, right?), I dropped the functions below into my <code>functions.php</code> file. They filter my admin username out of any comments I leave. WordPress also adds the user’s name in a class for the list item of the comment, so I needed to remove that as well. If you’re in a similar situation, feel free to grab the code and place it in your own theme’s <code>functions.php</code> file, replacing the adminuser and regularuser placeholders with your own admin and editor usernames. The comment class code is modified from a hack <a href="http://www.wprecipes.com/wordpress-hack-remove-admin-name-in-comments-class">found at WPRecipes</a>.</p>

<div markdown=0>
<pre><code>
// change the class that wordpress assigns to the comment
function change_comment_author_class( $classes ) {
    foreach( $classes as $key => $class ) {
        // change adminuser to your admin username
        if(strstr($class, "comment-author-adminuser")) {
            // change regularuser to the user you comment with
            $classes[$key] = 'comment-author-regularuser';
        }
    }
    return $classes;
}
// substitute a user name for the admin name
function change_comment_author($author)
{
    // change this to the admin username
    if(strstr($author,"adminuser")) { 
        // change this to the name of the user you comment with
        return "regularuser"; 
    }
    return $author;
}
// apply the filters
add_filter( 'comment_class' , 'change_comment_author_class' );
add_filter( 'get_comment_author' , 'change_comment_author' );
</code></pre>
</div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/four-wordpress-plugins-i-love/' rel='bookmark' title='Four WordPress Plugins I love'>Four WordPress Plugins I love</a></li>
<li><a href='http://brettterpstra.com/adding-a-tinymce-button/' rel='bookmark' title='Adding a TinyMCE button to WordPress'>Adding a TinyMCE button to WordPress</a></li>
<li><a href='http://brettterpstra.com/gvoice-command-line-sms-revisited/' rel='bookmark' title='GVoice command line SMS revisited'>GVoice command line SMS revisited</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/better-wordpress-security-through-comment-filters/">Better WordPress security through comment filters</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/better-wordpress-security-through-comment-filters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto-lightboxing image links</title>
		<link>http://brettterpstra.com/auto-lightboxing-image-links/</link>
		<comments>http://brettterpstra.com/auto-lightboxing-image-links/#comments</comments>
		<pubDate>Wed, 26 May 2010 15:15:14 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=492</guid>
		<description><![CDATA[<p>I ran into a problem recently. I wanted to have links to images be “lightboxed,” but I also wanted to blog in Markdown and not have to write out link tags with “rel” attributes for every image link. There are several existing plugins for WordPress that will do this automatically, but I’ve been sticking with the jQuery Lightbox plugin, which&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/auto-lightboxing-image-links/">Auto-lightboxing image links</a></p>]]></description>
			<content:encoded><![CDATA[<p>I ran into a problem recently. I wanted to have links to images be “lightboxed,” but I also wanted to blog in Markdown and not have to write out link tags with “rel” attributes for every image link. There are several existing plugins for WordPress that will do this automatically, but I’ve been sticking with the <a href="http://wordpress.org/extend/plugins/jquery-lightbox-balupton-edition/" title="jQuery Lightbox WordPress plugin">jQuery Lightbox plugin</a>, which handles WordPress galleries in this manner, but requires the “rel=lightbox” attribute to handle single image links.</p>

<p>I’m not a big fan of directly modifying plugins, primarily because it means that my changes will be scrapped if I ever automatically update the plugin. Since all I’m doing is adding a little jQuery to apply the effect to some additional selectors, I’ve just added it into an external Javascript file that I was already loading. Here’s what I did…</p>

<p><span id="more-492"></span>
The extra jQuery to run the lightbox effect on every link whose target ends with “jpg” is very simple:</p>

<div markdown=0>
<pre><code>
// Auto-handle direct jpeg links
$('a[href$="jpg"]').not('.gallery a').each(function() {
    $(this).lightbox();
});
</code></pre>
</div>

<p>It selects any link whose href value ends with ‘jpg’. I added a <code>.not()</code> selector to exclude the WordPress gallery links that the plugin already does a nice job of handling and turning into navigable lightbox galleries. This little bit of code will work with any flavor of the jQuery Lightbox plugin that uses “lightbox()” as its main function. Next I put this snippet into my js file, in the function that executes when the document is ready:</p>

<div markdown=0>
<pre><code>
jQuery(document).ready(function($) {
    // Auto-handle direct jpeg links
    $('a[href$="jpg"]').not('.gallery a').each(function() {
        $(this).lightbox();
    });
});
</code></pre>
</div>

<p>The “$” inside of the function’s parameters (<code>function($)</code>) lets us use the standard jQuery “$” inside of the function, instead of the no-conflict “jQuery.” Just a convenience, but if you don’t do this, and you have the default jQuery library loaded in WordPress, you’ll need to replace all of the “$” in the original snippet with “jQuery” to get it to work.</p>

<p>I add the external javascript to the queue in my theme’s functions.php file like this:</p>

<div markdown=0>
<pre><code>
function bt_load_scripts() {
    wp_enqueue_script('brettterpstra',TEMPLATEPATH.'/js/brettterpstra.js',array('jquery'),false,true);
}    

if (!is_admin()) {
    add_action('init', bt_load_scripts);
}
</code></pre>
</div>

<p>That did the trick, and any JPEG image I link to directly now gets the lightbox treatment. I haven’t run into any conflicts yet, but I’ll keep my eyes peeled and refine the selector if I need to.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/markdown-quicktags-0-7/' rel='bookmark' title='Markdown QuickTags 0.7'>Markdown QuickTags 0.7</a></li>
<li><a href='http://brettterpstra.com/auto-convert-your-inline-markdown-links-to-references/' rel='bookmark' title='Auto-convert your inline Markdown links to references'>Auto-convert your inline Markdown links to references</a></li>
<li><a href='http://brettterpstra.com/markdown-quicktags-wordpress-plugin/' rel='bookmark' title='Markdown QuickTags: WordPress plugin for Markdown lovers'>Markdown QuickTags: WordPress plugin for Markdown lovers</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/auto-lightboxing-image-links/">Auto-lightboxing image links</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/auto-lightboxing-image-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a TinyMCE button to WordPress</title>
		<link>http://brettterpstra.com/adding-a-tinymce-button/</link>
		<comments>http://brettterpstra.com/adding-a-tinymce-button/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 18:03:06 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[functions.php]]></category>
		<category><![CDATA[TinyMCE]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=378</guid>
		<description><![CDATA[<p>I was working on a quick website for my wife, and trying to make things as simple as possible for both of us. For me, I just wanted to give her a flexible template that I didn’t have to hack much on (I went with Thesis), and for her, I wanted her to be able to start posting with a&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/adding-a-tinymce-button/">Adding a TinyMCE button to WordPress</a></p>]]></description>
			<content:encoded><![CDATA[<p>I was working on a quick <a href="http://theurbaneanimal.com/">website for my wife</a>, and trying to make things as simple as possible for both of us. For me, I just wanted to give her a flexible template that I didn’t have to hack much on (I went with <a href="http://diythemes.com/thesis/">Thesis</a>), and for her, I wanted her to be able to start posting with a minimal learning curve. She just got a <a href="http://www.theflip.com/">Flip</a>, and wanted to start posting video. Since she was already posting to YouTube, I just wrote a quick shortcode in Thesis’ custom functions file that would take a YouTube id and turn it into a link that the <a href="http://wordpress.org/extend/plugins/shadowbox-js/">Shadowbox plugin</a> could pick up and make into a “lightboxed” video player. It worked great.</p>

<p>Then, I thought I’d just add a quick button to WordPress’ TinyMCE editor to make adding the shortcode even easier. That turned out to be a real pain, at least the first time around, so I thought I’d detail how I ended up pulling it off. Read on for a step-by-step as I add a button to the built-in visual editor that will request an ID (or a full url) and insert a custom shortcode to play the video. You can see the end results <a href="http://theurbaneanimal.com/2010/04/big-dog-in-a-little-package/">here</a>. I’m positive there are plugins that do just this, but I wanted to figure it out for myself…</p>

<p><img src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/04/youtubebutton662135.jpg?9d7bd4" alt="" title="youtubebutton662135" width="330" height="89" class="alignnone size-full wp-image-384" /></p>

<p><span id="more-378"></span>
<strong><em>Note that these instructions are for WordPress 2.5+.</em></strong></p>

<p>Want to just download the skeleton files and go for it? <a href="http://brettterpstra.com/downloads/YourYouTubeButton.zip?9d7bd4" title="Download and get started">YourYouTubeButton.zip</a></p>

<p>First, the shortcode. Because the shadowbox plugin just needs a YouTube link to do it’s job, all the shortcode is going to do is take an id and turn it into a properly formatted link, inserting the necessary markup for shadowbox to do its job. In your functions.php (or custom/custom_functions.php if you’re using Thesis), add this code:</p>

<div markdown=0>
<pre><code class="php">
// add the shortcode handler for YouTube videos
function addYouTube($atts, $content = null) {
        extract(shortcode_atts(array( &quot;id&quot; =&gt; &#x27;&#x27; ), $atts));
        return &#x27;&lt;p style=&quot;text-align:center&quot;&gt; \
        &lt;a href=&quot;http://www.youtube.com/v/&#x27;.$id.&#x27;&quot;&gt; \
        &lt;img src=&quot;http://img.youtube.com/vi/&#x27;.$id.&#x27;/0.jpg&quot; width=&quot;400&quot; height=&quot;300&quot; class=&quot;aligncenter&quot; /&gt; \
        &lt;span&gt;Watch the video&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&#x27;;
}
add_shortcode(&#x27;youtube&#x27;, &#x27;addYouTube&#x27;);
</code></pre>
</div>

<p>This lets you use a shortcode in your post that looks like <code>[youtube id="xxxxx"]</code> and have that turned into a centered paragraph containing a preview image and a link to the video. If you’re running the <a href="http://wordpress.org/extend/plugins/shadowbox-js/">shadowbox plugin</a>, or any plugin that detects YouTube links and handles them, clicking the link in your post will load the destination video in a hovering box, without leaving the page. Otherwise, it will go to the YouTube page for the video. The screenshot is pulled straight from YouTube, and (poorly) resized using HTML. I needed a 400x300 image to fit into the template, and since it wasn’t a huge change, it was easiest to just hardcode the size into the tag and let the browser handle it. For reference, you can get a YouTube-generated screenshot by inserting the video’s id into a string like this: http://img.youtube.com/vi/
	<!-- Begin Video.js -->
	<video id="example_video_id_832029309" class="video-js vjs-default-skin" width="" height="" controls  data-setup="{}">
		
		
		
	</video>
	<!-- End Video.js -->
/0.jpg. Use that inside of an image tag, as shown in the script, and you’ve got a preview image, ready to go.</p>

<p>Adding a button to the “quick tags” in the HTML editor is a cinch, but we’ll skip that since anyone using that editor can probably handle writing out a shortcode. It’s my wife and clients using the Visual editor that I want to save the trouble. So now, in your functions.php or custom_functions.php, we’ll first add the function that will insert the button:</p>

<div markdown=0>
<pre><code class="php">
function add_youtube_button() {
   if ( ! current_user_can(&#x27;edit_posts&#x27;) &amp;&amp; ! current_user_can(&#x27;edit_pages&#x27;) )
     return;
   if ( get_user_option(&#x27;rich_editing&#x27;) == &#x27;true&#x27;) {
     add_filter(&#x27;mce_external_plugins&#x27;, &#x27;add_youtube_tinymce_plugin&#x27;);
     add_filter(&#x27;mce_buttons&#x27;, &#x27;register_youtube_button&#x27;);
   }
}

add_action(&#x27;init&#x27;, &#x27;add_youtube_button&#x27;);
</code></pre>
</div>

<p>The first thing the above code does is check to make sure the current user has permission to edit, otherwise there’s no point in loading this code. Next, it checks that we’re in Rich Text (Visual) mode, and then adds filters that are executed at the time that the editor loads its plugins, and when it loads its buttons. Lastly, the add_action call tells it to run the function when we load the page.</p>

<p>The functions that it calls, <code>add_youtube_tinymce_plugin</code> and <code>register_youtube_button</code> are custom functions that we’ll create underneath it in the same file:</p>

<div markdown=0>
<pre><code class="php">
function register_youtube_button($buttons) {
   array_push($buttons, &quot;|&quot;, &quot;brettsyoutube&quot;);
   return $buttons;
}

function add_youtube_tinymce_plugin($plugin_array) {
   $plugin_array[&#x27;brettsyoutube&#x27;] = get_bloginfo(&#x27;template_url&#x27;).&#x27;/custom/editor_plugin.js&#x27;;
   return $plugin_array;
}
</code></pre>
</div>

<p>The first function tells the editor to add a divider and the button, in my case <code>brettsyoutube</code>, to the array of buttons. The second function tells it what that button’s going to do, which, in this case, is execute a statement found in an external Javascript file in the “custom” directory of my template.</p>

<p>The last thing we need to do before we get into the Javascript portion is to work a little magic on the TinyMCE version check. TinyMCE defaults to caching everything, so in order for our changes to show up, we have to trick it into thinking its version number has changed:</p>

<div markdown=0>
<pre><code class="php">
function my_refresh_mce($ver) {
  $ver += 3;
  return $ver;
}

add_filter( &#x27;tiny_mce_version&#x27;, &#x27;my_refresh_mce&#x27;);
</code></pre>
</div>

<p>This will intercept the version check and increment the current version number by 3. It’s the quick and dirty way to do it without messing with the settings directly, but if you’re curious, read more on the <a href="http://codex.wordpress.org/TinyMCE_Custom_Buttons">WordPress Codex</a>.</p>

<p>Now that we’ve got the necessary pieces in our functions file, it’s time to add the Javascript that the button’s going to need to function. I’ve located mine in the same folder as my functions file (custom/), but if you want to be tidier about it, make a subfolder. Just make sure that the <code>add_youtube_tinymce_plugin</code> function knows where to look for it. Here’s what’s in my <code>editor_plugin.js</code> file:</p>

<div markdown=0>
<pre><code class="js">
(function() {
    tinymce.create(&#x27;tinymce.plugins.BrettsYouTube&#x27;, {
        init : function(ed, url) {
            ed.addButton(&#x27;brettsyoutube&#x27;, {
                title : &#x27;brettsyoutube.youtube&#x27;,
                image : url+&#x27;/youtube.png&#x27;,
                onclick : function() {
                    idPattern = /(?:(?:[^v]+)+v.)?([^&amp;=]{11})(?=&amp;|$)/;
                    var vidId = prompt(&quot;YouTube Video&quot;, &quot;Enter the id or url for your video&quot;);
                    var m = idPattern.exec(vidId);
                    if (m != null &amp;&amp; m != &#x27;undefined&#x27;)
                        ed.execCommand(&#x27;mceInsertContent&#x27;, false, &#x27;[youtube id=&quot;&#x27;+m[1]+&#x27;&quot;]&#x27;);
                }
            });
        },
        createControl : function(n, cm) {
            return null;
        },
        getInfo : function() {
            return {
                longname : &quot;Brett&#x27;s YouTube Shortcode&quot;,
                author : &#x27;Brett Terpstra&#x27;,
                authorurl : &#x27;http://brettterpstra.com/&#x27;,
                infourl : &#x27;http://brettterpstra.com/&#x27;,
                version : &quot;1.0&quot;
            };
        }
    });
    tinymce.PluginManager.add(&#x27;brettsyoutube&#x27;, tinymce.plugins.BrettsYouTube);
})();
</code></pre>
</div>

<p>This function initializes the plugin, sets up what it’s going to accomplish, adds an array of info about the plugin, and then adds the plugin to the existing TinyMCE plugin list. The lines that contain <code>brettsyoutube</code> are referenced by the previous functions, so if you change the name of the plugin in one place, make sure to match it up in both the PHP and the Javascript portions. In the <code>onclick</code> handler inside the addButton call, you’ll find a function that prompts for a string (YouTube ID or URL), runs it against a regular expression to extract the ID (if necessary) and then inserts the shortcode as defined in our earlier functions. The last line of the main function does the actual adding of the plugin with the name <code>brettsyoutube</code>, so that it can be found by the editor when needed.</p>

<p>Note that the plugin references a <code>youtube.png</code> file in the same directory as the plugin. I lifted mine from Viper’s Video Quicktags, but you can use any 20px by 20px image, adjusting the name (and, if desired, location) in the above code appropriately.</p>

<p>Now I have a button in the visual editor that makes life that much easier for my wife. I can add more now, any time I like, and with a lot less effort than this first one turned out to be. I expect to be using this fairly frequently on client sites, as well.</p>

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/YourYouTubeButton.zip?9d7bd4" title="Download TinyMCE Button Skeleton (2295)"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/downloads/thumbnails/2010/11/wordpress-icon.png?9d7bd4" alt="download image for TinyMCE Button Skeleton" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/YourYouTubeButton.zip?9d7bd4" title="Download TinyMCE Button Skeleton (2295)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/YourYouTubeButton.zip?9d7bd4" title="Download TinyMCE Button Skeleton (2295)">TinyMCE Button Skeleton</a> — A skeleton php and javascript file for adding a button to TinyMCE. This one inserts a YouTube button that adds custom shortcode to insert a YouTube video link with preview image. Includes a YouTube icon for the button. <a href="http://brettterpstra.com/adding-a-tinymce-button/">More Info</a></p></div>

<h3>References:</h3>

<ul>
<li><a href="http://codex.wordpress.org/TinyMCE_Custom_Buttons">TinyMCE Custom Buttons on the WordPress Codex</a></li>
<li><a href="http://www.viper007bond.com/wordpress-plugins/vipers-video-quicktags/">Viper’s Video Quicktags plugin</a></li>
</ul>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/auto-lightboxing-image-links/' rel='bookmark' title='Auto-lightboxing image links'>Auto-lightboxing image links</a></li>
<li><a href='http://brettterpstra.com/better-wordpress-security-through-comment-filters/' rel='bookmark' title='Better WordPress security through comment filters'>Better WordPress security through comment filters</a></li>
<li><a href='http://brettterpstra.com/edit-your-wordpress-quicktags-the-right-way/' rel='bookmark' title='Edit your WordPress QuickTags the right way'>Edit your WordPress QuickTags the right way</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/adding-a-tinymce-button/">Adding a TinyMCE button to WordPress</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/adding-a-tinymce-button/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using disk: enhanced
Database Caching 36/149 queries in 0.312 seconds using xcache
Object Caching 4154/4267 objects using xcache
Content Delivery Network via cdn2.brettterpstra.com

Served from: brettterpstra.com @ 2012-05-23 05:07:39 -->
