<?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>Steve Taylor &#187; WordPress</title>
	<atom:link href="http://sltaylor.co.uk/blog/category/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://sltaylor.co.uk</link>
	<description>Freelance WordPress developer in London - XHTML, CSS &#38; design</description>
	<lastBuildDate>Wed, 25 Apr 2012 20:43:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>WordPress plugin for controlling upgrades when working with Git</title>
		<link>http://sltaylor.co.uk/blog/wordpress-plugin-upgrades-git/</link>
		<comments>http://sltaylor.co.uk/blog/wordpress-plugin-upgrades-git/#comments</comments>
		<pubDate>Wed, 25 Apr 2012 20:43:47 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/?p=920</guid>
		<description><![CDATA[I&#8217;ve just created a small WordPress plugin, Control Live Changes. It&#8217;s currently only on GitHub. It helps manage the disabling of core and plugin/theme changes when you&#8217;re working with a Version Control System. Here&#8217;s my situation. I have a bunch of sites versioned with Git via Beanstalk. I commit to the repository my custom theme, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just created a small WordPress plugin, Control Live Changes. It&#8217;s currently only on <a href="https://github.com/gyrus/Control-Live-Changes">GitHub</a>. It helps manage the disabling of core and plugin/theme changes when you&#8217;re working with a Version Control System.</p>
<p><span id="more-920"></span></p>
<p>Here&#8217;s my situation. I have a bunch of sites versioned with Git via <a href="http://beanstalkapp.com/">Beanstalk</a>. I commit to the repository my custom theme, all the plugins (I occasionally hack plugins), and a few files in the root (e.g. <code>robots.txt</code> and <code>.htaccess</code>). I don&#8217;t version the WP core files.</p>
<p>There are other developers working on these sites, too. We all have development copies running locally (the master branch), and there are branches for the staging and production servers. I created this plugin because I wanted to make sure no one upgraded plugins on the staging and production servers, making them out of synch with the dev master branch. Plugins should be upgraded locally (and tested), then pushed to staging for testing, and thence to production.</p>
<p>So, this plugin detects whether or not we&#8217;re in a development environment by searching for a particular configurable string in the <code>HTTP_HOST</code> (default: &#8220;localhost&#8221;). If this string isn&#8217;t present, the stuff that does the disabling kicks in. By default it disables plugin/theme upgrades and file editing, but you can also set things to disable core upgrades, or enable plugin/theme changes. There&#8217;s also a configurable option to show notices explaining why plugins etc. can&#8217;t be upgraded. Check the readme for details.</p>
<p>I&#8217;ll wait a while to put the plugin on the wordpress.org repository. Meanwhile, feedback very welcome! Post general comments here; if you find a genuine issue, use the <a href="https://github.com/gyrus/Control-Live-Changes/issues">GitHub issue tracking</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/wordpress-plugin-upgrades-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My plugins on GitHub</title>
		<link>http://sltaylor.co.uk/blog/my-plugins-on-github/</link>
		<comments>http://sltaylor.co.uk/blog/my-plugins-on-github/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 16:13:25 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/?p=902</guid>
		<description><![CDATA[I&#8217;ve just put all my WordPress plugins onto GitHub: Developer&#8217;s Custom Fields Lock Pages Simple Events Force Strong Passwords That&#8217;s all the ones that I&#8217;ve released via the wordpress.org plugins repository. On GitHub you&#8217;ll also find SLT Global, which is basically my collection of snippets that I want running on every WordPress project I deploy.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just put all my WordPress plugins onto GitHub:</p>
<ul>
<li><a href="https://github.com/gyrus/WordPress-Developers-Custom-Fields">Developer&#8217;s Custom Fields</a></li>
<li><a href="https://github.com/gyrus/Lock-Pages">Lock Pages</a></li>
<li><a href="https://github.com/gyrus/Simple-Events">Simple Events</a></li>
<li><a href="https://github.com/gyrus/Force-Strong-Passwords">Force Strong Passwords</a></li>
</ul>
<p>That&#8217;s all the ones that I&#8217;ve released via the wordpress.org plugins repository. On GitHub you&#8217;ll also find <a href="https://github.com/gyrus/SLT-Global">SLT Global</a>, which is basically my collection of snippets that I want running on every WordPress project I deploy.</p>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/my-plugins-on-github/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom Fields plugin update for WP 3.3</title>
		<link>http://sltaylor.co.uk/blog/custom-fields-plugin-update-for-wp-3-3/</link>
		<comments>http://sltaylor.co.uk/blog/custom-fields-plugin-update-for-wp-3-3/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 14:25:49 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/?p=869</guid>
		<description><![CDATA[I&#8217;ve just released version 0.7.1 of Developer&#8217;s Custom Fields. It should be showing up on the repository and in your WP admin very soon. It fixes a couple of bugs, one to do with the version number storage, and a more important one for anyone using Gmaps. Because of the attempt to exclude the Gmaps [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released version 0.7.1 of Developer&#8217;s Custom Fields. It should be showing up on the repository and in your WP admin very soon.</p>
<p>It fixes a couple of bugs, one to do with the version number storage, and a more important one for anyone using Gmaps. Because of the attempt to exclude the Gmaps functionality when it&#8217;s been turned off with <code>SLT_CF_USE_GMAPS</code>, the <code>[slt-cf-gmap]</code> shortcode wasn&#8217;t working. This should be fixed now.</p>
<p>Also, I&#8217;ve made the WYSIWYG field type play well with the nice new WP 3.3 <code>wp_editor</code> function. When you upgrade to 3.3 you&#8217;ll also be able to pass values to the <code>$settings</code> parameter of this function with the <code>wysiwyg_settings</code> field parameter. Follow the source to the <code>editor</code> method of the <code>WP_Editor</code> class for details of what settings you can pass through. Thanks to katoen on the wordpress.org forums for the heads up!</p>
<p>There are <a href="https://github.com/gyrus/WordPress-Developers-Custom-Fields/issues">some other things</a> I&#8217;m hoping to address very soon. I just had to release this asap because of the Gmaps shortcode fix and the compatibility with 3.3.</p>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/custom-fields-plugin-update-for-wp-3-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developer&#8217;s Custom Fields 0.7 released</title>
		<link>http://sltaylor.co.uk/blog/developers-custom-fields-0-7-released/</link>
		<comments>http://sltaylor.co.uk/blog/developers-custom-fields-0-7-released/#comments</comments>
		<pubDate>Sun, 02 Oct 2011 20:48:27 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/?p=855</guid>
		<description><![CDATA[I&#8217;ve just released 0.7 of my Developer&#8217;s Custom Fields plugin, which is now available for download from wordpress.org or automatically via your WordPress plugins page. There&#8217;s quite a few fixes and changes in this version. I&#8217;ll try and detail the most significant changes here in this post. Cleaning up 0.6.1 switched from using &#8220;yes&#8221; for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released 0.7 of my Developer&#8217;s Custom Fields plugin, which is now available for download from <a href="http://wordpress.org/extend/plugins/developers-custom-fields/">wordpress.org</a> or automatically via your WordPress plugins page.</p>
<p>There&#8217;s quite a few fixes and changes in this version. I&#8217;ll try and detail the most significant changes here in this post.</p>
<p><span id="more-855"></span></p>
<h2>Cleaning up</h2>
<p>0.6.1 switched from using &#8220;yes&#8221; for checked single checkboxes (and an empty value for unchecked) to storing either &#8220;1&#8243; or &#8220;0&#8243;. This is because the string &#8220;0&#8243; evaluates to false, but &#8220;no&#8221; evaluates to true! However, the switch may have caused some issues if anyone has code like this:</p>
<pre name="code" class="php">if ( slt_cf_field_value( 'checkbox-field' ) == 'yes' )
      [do some stuff]</pre>
<p>I did! There&#8217;s not much I can do automatically to fix this, so I&#8217;ve included an alert at the top of admin screens that directs people to a new page for tools for this plugin under <i>Tools > Custom Fields data</i>. There&#8217;s a cleanup tool here that:</p>
<ol>
<li>Converts any old &#8220;yes&#8221; / empty checkbox values to &#8220;1&#8243; and &#8220;0&#8243;</li>
<li>Deletes any empty values for fields defined through the plugin (0.7 now only creates meta table entries for fields with a value to store)</li>
<li>Deletes any meta table entries for fields that have the prefix used by the plugin, but which are no longer defined</li>
</ol>
<p>Needless to say, I&#8217;ve included plenty of warning to back up data before doing this. But once the tool has been run, enough attention should have been drawn to the potential issue with checkbox code (above), and the alert disappears.</p>
<h2>The Google map geocoder and jQuery autocomplete</h2>
<p>There had been an issue in that the handy address-finding geocoder field that is include with <code>gmap</code> fields used jQuery UI&#8217;s <code>autocomplete</code>. Turns out that this had been dropped from the version of jQuery UI in the WP core since 3.0&#8212;only I didn&#8217;t notice because I habitually use the Use Google Libraries plugin, and Google&#8217;s jQuery UI does include <code>autocomplete</code>.</p>
<p>WP 3.0 switched to <code>suggest</code>, and converting to this didn&#8217;t look like a simple case of switching functions. In the end, it turns out that <a href="http://wpdevel.wordpress.com/2011/09/23/javascript-changes-in-3-3/">WP 3.3 will ship with &#8220;jQuery 1.6.4 and jQuery UI 1.8.16. [...] the full UI including widgets and effects.&#8221;</a> So <code>autocomplete</code> will soon be there for everyone again. Until then, Developer&#8217;s Custom Fields includes the geocoder field via JS, on the condition that <code>autocomplete</code> is present.</p>
<h2>Scope defaults to all</h2>
<p>The <code>scope</code> parameter now, instead of being required, defaults to an empty array, which will apply the field to all items within the box&#8217;s scope.</p>
<h2>Globally disable functionality</h2>
<p>Some people have requested the ability to globally disable features like the <code>gmap</code> and <code>file</code> field types, which come with a load of JS and other stuff. Now you can do with using constants in wp-config.php, e.g.:</p>
<pre name="code" class="php">define( 'SLT_CF_USE_GMAPS', false );
define( 'SLT_CF_USE_FILE_SELECT', false );</pre>
<p>Both values default to true.</p>
<h2>Documentation and issue tracking</h2>
<p>I was going to shift most stuff for this plugin to GitHub with this version, but that&#8217;ll have to wait until I get more time to work out git for myself. For now, full documentation is now <a href="http://sltaylor.co.uk/wordpress/plugins/slt-custom-fields/docs/">here on this site</a>.</p>
<p>If you find a bug in the plugin, please raise an issue via <a href="https://github.com/gyrus/WordPress-Developers-Custom-Fields/issues">GitHub</a>. And if you&#8217;re not sure your problem is a genuine issue with the plugin or not, just start a <a href="http://wordpress.org/tags/developers-custom-fields?forum_id=10">WP forum thread</a>.</p>
<h2>Other highlights</h2>
<p>Other important changes include:</p>
<ul>
<li>Added <code>terms</code> as an <code>options_type</code> for populating multiple value fields with taxonomy terms</li>
<li>Added a <code>notice</code> field type for text-only notices to the user</li>
<li>Added an <code>above-content</code> settings for the box <code>context</code> parameter, to place boxes on post edit screens above the content editor</li>
<li>Added <code>except_posts</code> and <code>except_users</code> options to the <code>scope</code> field parameter, to exclude certain posts or users that would otherwise be included</li>
<li>Added <code>$file_attach_to_post</code> parameter for <code>file</code> field types, so you can choose whether a file uploaded on a post edit screen is attached to that post or not</li>
<li>Minified JS and CSS (full versions loaded when <a href="http://codex.wordpress.org/Editing_wp-config.php#Debug"><code>SCRIPT_DEBUG</code></a> is true)</li>
</ul>
<p>You can see the full list of changes in the <a href="http://wordpress.org/extend/plugins/developers-custom-fields/changelog/">changelog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/developers-custom-fields-0-7-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manipulating URLs in PHP and WordPress</title>
		<link>http://sltaylor.co.uk/blog/manipulating-urls-in-php-and-wordpress/</link>
		<comments>http://sltaylor.co.uk/blog/manipulating-urls-in-php-and-wordpress/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 13:56:48 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/?p=850</guid>
		<description><![CDATA[A quickie post about a few functions that I&#8217;ve only recently discovered, and really wish I&#8217;d discovered sooner! One is a PHP function, two are WordPress core functions. Both help immensely when you&#8217;re dealing with URLs. parse_url parse_url is a PHP function that takes a full URL and returns an array populated with all the [...]]]></description>
			<content:encoded><![CDATA[<p>A quickie post about a few functions that I&#8217;ve only recently discovered, and <em>really</em> wish I&#8217;d discovered sooner! One is a PHP function, two are WordPress core functions. Both help immensely when you&#8217;re dealing with URLs.</p>
<p><span id="more-850"></span></p>
<h2><code>parse_url</code></h2>
<p><a href="http://uk3.php.net/parse_url"><code>parse_url</code></a> is a PHP function that takes a full URL and returns an array populated with all the components, e.g. the host, the path, the query string, etc. For dealing with the query string you might also want to look at <a href="http://uk3.php.net/manual/en/function.parse-str.php"><code>parse_string</code></a>.</p>
<p>There&#8217;s also <a href="http://uk3.php.net/manual/en/function.http-build-query.php"><code>http_build_query</code></a>, which I think the following two WP functions make use of.</p>
<h2><code>add_query_arg</code></h2>
<p><a href="http://codex.wordpress.org/Function_Reference/add_query_arg"><code>add_query_arg</code></a> is incredibly useful if you want to add something to a URL&#8217;s query string without affecting the query parameters already in place. It defaults to the current URL, and you can either just add a key / value pair, or give it an array of key / value pairs to add.</p>
<h2><code>remove_query_arg</code></h2>
<p><a href="http://codex.wordpress.org/Function_Reference/remove_query_arg"><code>remove_query_arg</code></a> is simply the reverse of <code>add_query_arg</code>.</p>
<p>All together, manipulating URLs becomes a much simpler process with these handy functions!</p>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/manipulating-urls-in-php-and-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The WordPress edit_plugins capability</title>
		<link>http://sltaylor.co.uk/blog/wordpress-edit_plugins-capability/</link>
		<comments>http://sltaylor.co.uk/blog/wordpress-edit_plugins-capability/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 14:16:35 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/?p=755</guid>
		<description><![CDATA[I&#8217;ve been finding more and more WordPress plugins that, when they check if the current user should be allowed to view / edit the plugin&#8217;s settings page, check whether the user has the edit_plugins capability. I think this is a bad practice; let me explain why. If you check the Codex on Roles and Capabilities, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been finding more and more WordPress plugins that, when they check if the current user should be allowed to view / edit the plugin&#8217;s settings page, check whether the user has the <code>edit_plugins</code> capability. I think this is a bad practice; let me explain why.</p>
<p><span id="more-755"></span></p>
<p>If you check the Codex on <a href="http://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table">Roles and Capabilities</a>, you&#8217;ll see that there&#8217;s certain capabilities that are, by default, only assigned to admins.</p>
<p>Now, roles can be customized (most easily and reliably, I find, with Justin Tadlock&#8217;s <a href="http://wordpress.org/extend/plugins/members/">Members</a> plugin). That&#8217;s why it&#8217;s advised that, when checking whether a user can do something or not, you check what <em>capabilities</em> they have, not what role they&#8217;re in (usually using <a href="http://codex.wordpress.org/Function_Reference/current_user_can"><code>current_user_can</code></a>).</p>
<p>So, <a href="http://markjaquith.wordpress.com/2006/03/27/how-to-check-if-a-wordpress-user-is-an-administrator/">as detailed by Mark Jaquith</a>, if you want to check whether someone is an admin, you check against a capability that is by and large assigned only to admins&#8212;e.g. <code>manage_options</code>. True, someone might have customized their roles so, for instance, authors have the <code>manage_options</code> capability. But that&#8217;s stupid, and it&#8217;s their problem. As a plugin author, if you limit admin-only stuff to users with <code>manage_options</code>, you&#8217;ve done your job pretty well.</p>
<p>Checking for <code>manage_options</code> is obviously most suited to checks for editing options or settings. For other admin-only bits that are a bit more technical, I often use <code>update_core</code>. I often create a &#8220;Super Editor&#8221; role, which is pretty much like the default Editor role, but with <code>manage_options</code> (so clients can adjust site and plugin settings, but not upgrade or do other more technical things).</p>
<p>Now, as I mentioned, I&#8217;m discovering a number of plugins that use <code>edit_plugins</code> as a check for the plugin settings page. The thing that brought this to my attention as a problem is that I like to include this line in my wp-config.php file:</p>
<p><code>define( 'DISALLOW_FILE_EDIT', true );</code></p>
<p>You can see <a href="http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/capabilities.php#L968">in the core</a> that if this is set, it steps in on capability checks and blocks everyone from editing plugins, themes, or other files. I never use this feature of WordPress&#8212;it can be <em>very</em> risky on production servers, and is largely pointless on dev servers. And I certainly don&#8217;t want my clients using it. So I block it.</p>
<p>Unfortunately, as you&#8217;ll have guessed, this also blocks eveyone from editing the aforementioned plugins&#8217; settings. Not good!</p>
<p>Initially I thought these plugin authors were using <code>edit_plugins</code> as a generic &#8220;admin-only&#8221; check, in the way that I use <code>update_core</code>. I slowly realized that they might be using it under the impression that they&#8217;re being appropriate, i.e. that <code>edit_plugins</code> refers to editing anything to do with plugins, e.g. settings. However, as the core and <a href="http://codex.wordpress.org/Roles_and_Capabilities#edit_plugins">the Codex</a> testify, that&#8217;s not true. This capability refers to editing plugin <em>files</em>.</p>
<p>Unless you&#8217;ve got a good reason to do otherwise, the capability you should use to check if the user should access your plugin settings (usually passed to <a href="http://codex.wordpress.org/Function_Reference/add_options_page"><code>add_options_page</code></a>) is <code>manage_options</code>.</p>
<p>By all means choose something else if it&#8217;s related to the functionality you&#8217;re protecting. If your plugin include some kind of exporting functionality, check against the <code>export</code> capability. But if you do need a more generic &#8220;admin-only&#8221; capability to check against, use something unlikely to be disabled, such as <code>update_core</code>. The very handy <code>DISALLOW_FILE_EDIT</code> constant means that <code>edit_files</code>, <code>edit_themes</code> and <code>edit_plugins</code> are all a bad choice for checking if you&#8217;re dealing with an admin.</p>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/wordpress-edit_plugins-capability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress core 101</title>
		<link>http://sltaylor.co.uk/blog/wordpress-core-101/</link>
		<comments>http://sltaylor.co.uk/blog/wordpress-core-101/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 12:19:19 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/?p=711</guid>
		<description><![CDATA[Last night&#8217;s London WordPress meetup was good. Hosted by a company called Headshift, we got a quick-fire run through beginner, intermediate and advanced-level topics. Emily Weber gave an overview of how, as a non-techie, she got the social networking site yeah! Hackney going using BuddyPress. Keith Devon heroically compressed WordPress theme development into 20 minutes. [...]]]></description>
			<content:encoded><![CDATA[<p>Last night&#8217;s <a href="http://www.meetup.com/London-WordPress/">London WordPress meetup</a> was good. Hosted by a company called Headshift, we got a quick-fire run through beginner, intermediate and advanced-level topics. Emily Weber gave an overview of how, as a non-techie, she got the social networking site <a href="http://www.yeahhackney.com/">yeah! Hackney</a> going using <a href="http://buddypress.org/">BuddyPress</a>. Keith Devon heroically compressed WordPress theme development into 20 minutes. And Chris Adams gave an equally succinct tour of the WP core. This is an important topic for budding WP developers, I think. Do check out Chris&#8217; slideshow for some good pointers about where to look to start to understand the important aspects of the process that the core goes through when processing a request:</p>
<div style="width:550px;margin-bottom:1em;" id="__ss_8722212"><iframe src="http://www.slideshare.net/slideshow/embed_code/8722212" width="550" height="460" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></div>
<p>And come along to the next meeting!</p>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/wordpress-core-101/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add wmode parameter to WordPress oEmbeds</title>
		<link>http://sltaylor.co.uk/blog/add-wmode-parameter-wordpress-oembed/</link>
		<comments>http://sltaylor.co.uk/blog/add-wmode-parameter-wordpress-oembed/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 10:36:19 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/?p=704</guid>
		<description><![CDATA[OK, so we know how to solve the Flash and z-index problem, right? But how to make WordPress add the solution&#8212;the wmode parameter&#8212;to its auto-embedded videos? This should help: add_filter( 'oembed_result', 'slt_wmode_opaque', 10, 3 ); function slt_wmode_opaque( $html, $url, $args ) { if ( strpos( $html, '&#60;param name="movie"' ) !== false ) $html = preg_replace( [...]]]></description>
			<content:encoded><![CDATA[<p>OK, so we know how to solve the <a href="http://slightlymore.co.uk/flash-and-the-z-index-problem-solved/">Flash and <code>z-index</code> problem</a>, right? But how to make WordPress add the solution&#8212;the <code>wmode</code> parameter&#8212;to its auto-embedded videos?</p>
<p>This should help:</p>
<pre name="code" class="php">add_filter( 'oembed_result', 'slt_wmode_opaque', 10, 3 );
function slt_wmode_opaque( $html, $url, $args ) {
	if ( strpos( $html, '&lt;param name="movie"' ) !== false )
		$html = preg_replace( '|&lt;/param&gt;|', '&lt;/param&gt;&lt;param name="wmode" value="opaque"&gt;&lt;/param&gt;', $html, 1 );
	if ( strpos( $html, '&lt;embed' ) !== false )
		$html = str_replace( '&lt;embed', '&lt;embed wmode="opaque"', $html );
	return $html;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/add-wmode-parameter-wordpress-oembed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get post ID from custom post type URLs as well</title>
		<link>http://sltaylor.co.uk/blog/get-post-id-from-custom-post-types-urls/</link>
		<comments>http://sltaylor.co.uk/blog/get-post-id-from-custom-post-types-urls/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 22:47:06 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/?p=701</guid>
		<description><![CDATA[url_to_postid is a great core WordPress function. Give it a URL (from your own site!) and it&#8217;ll return the ID of the post or page it refers to. I&#8217;m using it so clients can paste a URL into a custom field (easy for them), then I can get other stuff related to the content using [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://codex.wordpress.org/Function_Reference/url_to_postid"><code>url_to_postid</code></a> is a great core WordPress function. Give it a URL (from your own site!) and it&#8217;ll return the ID of the post or page it refers to. I&#8217;m using it so clients can paste a URL into a custom field (easy for them), then I can get other stuff related to the content using the ID (easy for me).</p>
<p>But it doesn&#8217;t seem to handle custom post type URLs. So I wrote a little workaround&#8230;</p>
<p><span id="more-701"></span></p>
<pre name="code" class="php">function slt_url_to_postid( $url ) {
	// Try the core function
	$post_id = url_to_postid( $url );
	if ( $post_id == 0 ) {
		// Try custom post types
		$cpts = get_post_types( array(
			'public'   =&gt; true,
			'_builtin' =&gt; false
		), 'objects', 'and' );
		// Get path from URL
		$url_parts = explode( '/', trim( $url, '/' ) );
		$url_parts = array_splice( $url_parts, 3 );
		$path = implode( '/', $url_parts );
		// Test against each CPT's rewrite slug
		foreach ( $cpts as $cpt_name =&gt; $cpt ) {
			$cpt_slug = $cpt-&gt;rewrite['slug'];
			if ( strlen( $path ) &gt; strlen( $cpt_slug ) &amp;&amp; substr( $path, 0, strlen( $cpt_slug ) ) == $cpt_slug ) {
				$slug = substr( $path, strlen( $cpt_slug ) );
				$query = new WP_Query( array(
					'post_type'			=&gt; $cpt_name,
					'name'				=&gt; $slug,
					'posts_per_page'	=&gt; 1
				));
				if ( is_object( $query-&gt;post ) )
					$post_id = $query-&gt;post-&gt;ID;
			}
		}
	}
	return $post_id;
}</pre>
<p>I&#8217;ve had to alter it a little from the code I&#8217;m using. My code works, but if I&#8217;ve goofed in getting it ready for public consumption, please let me know!</p>
<p><strong class="alert">UPDATE 6/2/12:</strong> Some people have reported issues with this code that I haven&#8217;t had time to investigate. If it&#8217;s not working for you, I&#8217;ve been told <a href="http://betterwp.net/wordpress-tips/url_to_postid-for-custom-post-types/">this function</a> does this trick as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/get-post-id-from-custom-post-types-urls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Force display of description field in WordPress menus</title>
		<link>http://sltaylor.co.uk/blog/force-display-of-description-field-in-wordpress-menus/</link>
		<comments>http://sltaylor.co.uk/blog/force-display-of-description-field-in-wordpress-menus/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 20:49:25 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/?p=698</guid>
		<description><![CDATA[A very small but very good discovery I made at this year&#8217;s WordCamp Portsmouth was thanks to Robert O&#8217;Rourke. I never knew that if you folded down the Screen Options at the top of the Appearance > Menus admin screen in WordPress, you get a few extra fields for menu items. They&#8217;re hidden by default. [...]]]></description>
			<content:encoded><![CDATA[<p>A very small but very good discovery I made at this year&#8217;s WordCamp Portsmouth was thanks to Robert O&#8217;Rourke. I never knew that if you folded down the <b>Screen Options</b> at the top of the <i>Appearance > Menus</i> admin screen in WordPress, you get a few extra fields for menu items. They&#8217;re hidden by default.</p>
<p>The big one for me is &#8220;Description&#8221;. I&#8217;ve often used a menu for managing the items (i.e. posts and pages) that are featured in a carousel on the home page of a site. I wrote my own code to populate the menu query with information from the posts the menu items refer to&#8212;specifically, a description or extract to use as teaser text. Well, this little discovery that I can allow clients to set (or override) the teaser text right there while they&#8217;re managing the carousel &#8220;menu&#8221; is small; but I think little things like this really help clients when they&#8217;re busy managing their site.</p>
<p>But if you have to explain to them to open <b>Screen Options</b> and check a box to do something that might be important, it&#8217;s two steps forward and one step back. A bit better, but not ideal.</p>
<p>What if you could force &#8220;Description&#8221; to be checked?</p>
<p><span id="more-698"></span></p>
<p>Here&#8217;s how:</p>
<pre name="code" class="php">add_filter( 'get_user_option_managenav-menuscolumnshidden', 'slt_nav_menus_columns_hidden' );
function slt_nav_menus_columns_hidden( $result ) {
	if ( in_array( 'description', $result ) )
		unset( $result[ array_search( 'description', $result ) ] );
	return $result;
}</pre>
<p>These <b>Screen Options</b> are stored in user preferences, so you need to filter a specific user option. Look <a href="http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/user.php#L274">here</a> to see where this filter is being applied in the core. You&#8217;ll see the option that&#8217;s passed <a href="http://core.trac.wordpress.org/browser/tags/3.2.1/wp-admin/includes/template.php#L257">here</a>. The <code>$screen->id</code> is basically the admin file being viewed, with <code>.php</code> stripped off. These pointers should get you going working out how this all works to adapt the above code.</p>
<p>The callback hooked onto the filter just checks to see if <code>description</code> is in the list of hidden fields, and takes it out if it is.</p>
<p>Hey presto, the description field is always on!</p>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/force-display-of-description-field-in-wordpress-menus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  sltaylor.co.uk/blog/category/wordpress/feed/ ) in 0.29860 seconds, on May 17th, 2012 at 1:32 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 17th, 2012 at 2:32 pm UTC -->
