<?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>Emmense Technologies, LLC - WordPress Consulting&#187; b5media</title>
	<atom:link href="http://emmense.com/blog/tag/b5media/feed/" rel="self" type="application/rss+xml" />
	<link>http://emmense.com</link>
	<description>Just another Emmense.com weblog</description>
	<lastBuildDate>Wed, 25 Apr 2012 17:08:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-beta3-20582</generator>
		<item>
		<title>WordPress Preset Options Plugin</title>
		<link>http://emmense.com/blog/2009/07/11/wordpress-preset-options-plugin/</link>
		<comments>http://emmense.com/blog/2009/07/11/wordpress-preset-options-plugin/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 16:29:17 +0000</pubDate>
		<dc:creator>Aaron Brazell</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[b5media]]></category>
		<category><![CDATA[mu plugins]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress mu]]></category>
		<category><![CDATA[wpmu]]></category>

		<guid isPermaLink="false">http://emmense.com/?p=221</guid>
		<description><![CDATA[Late yesterday evening, my friend @immunity pointed me to Dan Gilmore&#8217;s post about hacking the database for WordPress MU to manually set options across a variety of blogs. @immunity figured there must be a better way and, indeed, there is. In fact, I had written some code while at b5media which just did this. Because [...]]]></description>
			<content:encoded><![CDATA[<p>Late yesterday evening, my friend <a href="http://twitter.com/immunity">@immunity</a> pointed me to <a href="http://www.dangilmore.com/?p=84">Dan Gilmore&#8217;s post about hacking the database for WordPress MU</a> to manually set options across a variety of blogs. @immunity figured there must be a better way and, indeed, there is.</p>
<p>In fact, I had written some code while at <a href="http://b5media.com">b5media</a> which just did this. Because I am a persistent packrat, I still had that plugin and got the permission from b5media to release the very simple plugin publicly.</p>
<p>This plugin is perfect for WordPress MU administrators who want to exercise some control, whether for QA or otherwise, over the WordPress blogs on the system. Drop this plugin into the mu-plugins folder and it will be universally applied.</p>
<p>Couple things to think about&#8230; as for now, with this cleaned up but made-for-b5media plugin, there is no admin interface. You do have to edit the file manually to preset the options you want and you might have to comb your database options table to find the names of certain options, etc. This is not a braindead stupid plugin, but for those who are savvy enough to be administrators, it shouldn&#8217;t be too difficult to figure out via the example usage in the plugin.</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>?php<br />
<span style="color: #666666; font-style: italic;">/*<br />
Plugin Name: Preset Options<br />
Plugin URI: #<br />
Description: A plugin created when I was working for &lt;a href=&quot;http://b5media.com&quot;&gt;b5media&lt;/a&gt; and released, with permission, under GPLv2. The plugin provides two functions that will set any blog option as defined and unchangeable. Perfect for WPMU.<br />
Author: Aaron Brazell<br />
Version: 1.0<br />
Author URI: http://technosailor.com<br />
*/</span><br />
<br />
<span style="color: #666666; font-style: italic;">/*<br />
Example Usage:<br />
<br />
Turn off Smilies across the board:<br />
po_hardcode_option('use_smilies', '0');<br />
<br />
Remove the lifestream plugin from the list of active plugins.<br />
po_hardcore_option_serialized('active_plugins', array('lifestream/lifestream.php'), false, true );<br />
*/</span><br />
<br />
<span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* Function takes two arguments and is meant for setting a setting for a single string/boolean option. It is not meant for serialized data.<br />
&nbsp;**/</span><br />
<span style="color: #000000; font-weight: bold;">function</span> po_hardcode_option<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pre_option_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <a href="http://www.php.net/create_function"><span style="color: #990000;">create_function</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'$a'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'return &quot;'</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/addslashes"><span style="color: #990000;">addslashes</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;;'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* Function takes two required arguments, the name of an option and an array of key/value array data. Two optional arguments are boolean<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">function</span> po_hardcode_option_serialized<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$setting</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$removekey</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$removevalue</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$exist_options</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #000088;">$setting</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$options</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$v</span> <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$removevalue</span> <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_search"><span style="color: #990000;">array_search</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$v</span><span style="color: #339933;">,</span> <span style="color: #000088;">$exist_options</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$exist_options</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array_key_exists"><span style="color: #990000;">array_key_exists</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$k</span><span style="color: #339933;">,</span> <span style="color: #000088;">$exist_options</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/is_int"><span style="color: #990000;">is_int</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$k</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$removekey</span> <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$exist_options</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$exist_options</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pre_option_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$setting</span><span style="color: #339933;">,</span> change_option_array<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$setting</span><span style="color: #339933;">,</span> <span style="color: #000088;">$exist_options</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> change_option_array<span style="color: #009900;">&#40;</span><span style="color: #000088;">$setting</span><span style="color: #339933;">,</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; update_option<span style="color: #009900;">&#40;</span><span style="color: #000088;">$setting</span><span style="color: #339933;">,</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p><a href="http://emmense.com/downloads/preset-options.php.zip">Download the plugin here</a>.</p>
<p>So Dan, you would have just added the following line to the bottom of the plugin and would have been set. <img src='http://emmense.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">po_hardcode_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comment_registration'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://emmense.com/blog/2009/07/11/wordpress-preset-options-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

