<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Bring Your Own Terms Of Service &#187; Code Sample</title>
	<atom:link href="http://byotos.com/tag/code-sample/feed/" rel="self" type="application/rss+xml" />
	<link>http://byotos.com</link>
	<description></description>
	<lastBuildDate>Mon, 07 May 2012 20:14:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='byotos.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Bring Your Own Terms Of Service &#187; Code Sample</title>
		<link>http://byotos.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://byotos.com/osd.xml" title="Bring Your Own Terms Of Service" />
	<atom:link rel='hub' href='http://byotos.com/?pushpress=hub'/>
		<item>
		<title>Hijacking WordPress Internationalisation</title>
		<link>http://byotos.com/2010/04/08/hijacking-wordpress-internationalisation/</link>
		<comments>http://byotos.com/2010/04/08/hijacking-wordpress-internationalisation/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 19:27:20 +0000</pubDate>
		<dc:creator>Paul Gibbs</dc:creator>
				<category><![CDATA[BuddyPress]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Code Sample]]></category>

		<guid isPermaLink="false">http://byotos.com/?p=129</guid>
		<description><![CDATA[As part of a new feature I am developing for the next release of my Welcome Pack plugin for BuddyPress, I needed a really smart way of dynamically adding my own translations for strings at page-load time; creating a stand-alone .mo file to load the strings wasn&#8217;t a great solution, for reasons of requiring people [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=byotos.com&#038;blog=18766096&#038;post=129&#038;subd=byotos&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As part of a new feature I am developing for the next release of my <a href="http://wordpress.org/extend/plugins/welcome-pack/" target="_blank">Welcome Pack</a> plugin for <a href="http://buddypress.org/" target="_blank">BuddyPress</a>, I needed a really smart way of dynamically adding my own translations for strings at page-load time; creating a stand-alone <a href="http://codex.wordpress.org/Translating_WordPress#gettext_files" target="_blank">.mo </a>file to load the strings wasn&#8217;t a great solution, for reasons of requiring people to know how to configure file permissions on the server, having to figure out how to write a .mo file (I wish they were as easy as XML, but they aren&#8217;t), and &#8212; honestly &#8212; doing it that way feels like such a hack.</p>
<p><span id="more-129"></span>Here&#8217;s how. Be warned that this will overwrite any translation loaded by a .mo file, but that&#8217;s exactly what I needed to do.</p>
<p>To add a new string into the localisation table:</p>
<p><pre class="brush: php; gutter: false;">
function example() {
global $l10n;

$mo = new MO();
$mo-&amp;gt;add_entry( array( 'singular' =&amp;gt; 'Spongebob', 'translations' =&amp;gt; array( 'Squarepants' ) ) );
if ( isset( $l10n['buddypress'] ) )  //buddypress is the textdomain
$mo-&amp;gt;merge_with( $l10n['buddypress'] );

$l10n['buddypress'] = &amp;amp;$mo;
}

_e( 'Spongebob', 'buddypress' );  // This will return &quot;Squarepants&quot;.
</pre></p>
<p>To change an existing string:</p>
<p><pre class="brush: php; gutter: false;">
function example() {
global $l10n;

if ( isset( $l10n['buddypress'] ) &amp;amp;&amp;amp; isset( $l10n['buddypress']-&amp;gt;entries['%s posted an update:'] ) )
$l10n['buddypress']-&amp;gt;entries['%s posted an update:']-&amp;gt;translations[0] = '%s posted a monkey:';
}
</pre></p>
<p>Post a comment if you use this technique for anything interesting</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/byotos.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/byotos.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/byotos.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/byotos.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/byotos.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/byotos.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/byotos.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/byotos.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/byotos.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/byotos.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/byotos.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/byotos.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/byotos.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/byotos.wordpress.com/129/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=byotos.com&#038;blog=18766096&#038;post=129&#038;subd=byotos&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://byotos.com/2010/04/08/hijacking-wordpress-internationalisation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3bc9ab796299d67ce83dceb9554f75df?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">DJPaul</media:title>
		</media:content>
	</item>
		<item>
		<title>SVN is now public</title>
		<link>http://byotos.com/2009/09/03/svn-is-now-public/</link>
		<comments>http://byotos.com/2009/09/03/svn-is-now-public/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 17:42:37 +0000</pubDate>
		<dc:creator>Paul Gibbs</dc:creator>
				<category><![CDATA[BuddyPress]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Code Sample]]></category>

		<guid isPermaLink="false">http://metabiscuits.com/?p=27</guid>
		<description><![CDATA[I made my SVN repository public which I use for my BuddyPress plugins (Welcome Pack and Achievements). It is at http://svn.dangerous-minds.com/djpaul/. For example, to get the latest trunk (development) version of Achievements  — which requires BuddyPress trunk/1.1 — use http://svn.dangerous-minds.com/djpaul/achievements/trunk/.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=byotos.com&#038;blog=18766096&#038;post=27&#038;subd=byotos&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I made my SVN repository public which I use for my BuddyPress plugins (<a href="http://wordpress.org/extend/plugins/welcome-pack/">Welcome Pack</a> and <a href="http://wordpress.org/extend/plugins/achievements/">Achievements</a>).  It is at <a href="http://svn.dangerous-minds.com/djpaul/" rel="nofollow">http://svn.dangerous-minds.com/djpaul/</a>.</p>
<p>For example, to get the latest trunk (development) version of Achievements  — which requires BuddyPress trunk/1.1 — use <a href="http://svn.dangerous-minds.com/djpaul/achievements/trunk/" rel="nofollow">http://svn.dangerous-minds.com/djpaul/achievements/trunk/</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/byotos.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/byotos.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/byotos.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/byotos.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/byotos.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/byotos.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/byotos.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/byotos.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/byotos.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/byotos.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/byotos.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/byotos.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/byotos.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/byotos.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=byotos.com&#038;blog=18766096&#038;post=27&#038;subd=byotos&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://byotos.com/2009/09/03/svn-is-now-public/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3bc9ab796299d67ce83dceb9554f75df?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">DJPaul</media:title>
		</media:content>
	</item>
		<item>
		<title>Improving custom component installation</title>
		<link>http://byotos.com/2009/07/25/improving-custom-component-installation/</link>
		<comments>http://byotos.com/2009/07/25/improving-custom-component-installation/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 18:53:08 +0000</pubDate>
		<dc:creator>Paul Gibbs</dc:creator>
				<category><![CDATA[BuddyPress]]></category>
		<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[WPMU]]></category>

		<guid isPermaLink="false">http://metabiscuits.com/?p=9</guid>
		<description><![CDATA[When implementing a custom component in BuddyPress, you will often have additions for the member theme. Member themes live in their own folder, /wp-content/bp-themes/. To render a member theme template, your component will call dpa_load_template() which takes an argument of the name of the template to load. The path is hardcoded to the /wp-content/bp-themes/ folder. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=byotos.com&#038;blog=18766096&#038;post=9&#038;subd=byotos&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When implementing a <a href="http://codex.buddypress.org/how-to-guides/creating-a-custom-buddypress-component/">custom component</a> in <a href="http://buddypress.org/">BuddyPress</a>, you will often have additions for the member theme. Member themes live in their own folder, <code>/wp-content/bp-themes/</code>.</p>
<p>To render a member theme template, your component will call <code>dpa_load_template()</code> which takes an argument of the name of the template to load. The path is hardcoded to the <code>/wp-content/bp-themes/</code> folder.</p>
<p>The problem with this is that after installation of a custom component, the site administrator will need to move the relevant member theme files (bundled with your component) into <code>/wp-content/bp-themes/</code>. This is an annoyance to site administrator, and it may end up being a frequent support request (&#8220;why is X not working?&#8221;).  This very first hurdle may even stop people trying out your component.</p>
<p>Something else I&#8217;ve seen is that when installing future updates, people may forget that they need to move the updated member theme files into place; this can cause incompatibility issues between versions of your software, something we&#8217;ve seen with recent versions of BuddyPress.</p>
<p>For my upcoming &#8220;Achievements&#8221; plugin (think a cross between forum points and <a href="http://en.wikipedia.org/wiki/Xbox_Live">Xbox Live</a>), I decided all that I wanted the site administrator to do would be to download it from the Plugins admin panel &#8211; no moving files into the member theme.</p>
<p>So, I present to you my code: (06/01/10 &#8211; updated for BP 1.1.3+)</p>
<p><pre class="brush: php;">
bp_core_load_template( 'yourcomponent_theme_filename' );  // loads /plugins/your_plugin/filename.php

function yourcomponent_screen_filter_template( $located_template, $template_name ) {
	if ( !empty( $located_template ) )
		return $located_template;

	if ( $bp-&amp;gt;current_component != $bp-&amp;gt;your_component-&amp;gt;slug )
		return false;

	if ( false !== strpos( $template_name[0], 'yourcomponent_theme_' ) ) {
		$prefix = strlen( 'yourcomponent_theme_' );
		$template_name = substr( $template_name[0], $prefix, strlen( $template_name[0] ) - $prefix );
		$template_path = WP_PLUGIN_DIR . &amp;quot;/your_plugin/$template_name&amp;quot;;

		if ( file_exists( $template_path ) )
			return $template_path;
	}

	return false;
}
add_filter( 'bp_located_template', 'yourcomponent_screen_filter_template', 10, 2 );
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/byotos.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/byotos.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/byotos.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/byotos.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/byotos.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/byotos.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/byotos.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/byotos.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/byotos.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/byotos.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/byotos.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/byotos.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/byotos.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/byotos.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=byotos.com&#038;blog=18766096&#038;post=9&#038;subd=byotos&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://byotos.com/2009/07/25/improving-custom-component-installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3bc9ab796299d67ce83dceb9554f75df?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">DJPaul</media:title>
		</media:content>
	</item>
	</channel>
</rss>
