<?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>Tobias Labs</title>
	<atom:link href="http://www.tobiaslabs.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tobiaslabs.com</link>
	<description>Engineering and code: My research and studies.</description>
	<lastBuildDate>Wed, 19 Oct 2011 21:49:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Status Update, Finally!</title>
		<link>http://www.tobiaslabs.com/727/status-update-finally/</link>
		<comments>http://www.tobiaslabs.com/727/status-update-finally/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 21:49:33 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Sermon Posts]]></category>

		<guid isPermaLink="false">http://www.tobiaslabs.com/?p=727</guid>
		<description><![CDATA[Hey all, I just watned to let you know that I am finally back at they keyboard, and I&#8217;ve already started cranking out the next big update. I anticipate one more update, and then a release through the WordPress site. &#8230;<p class="read-more"><a href="http://www.tobiaslabs.com/727/status-update-finally/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Hey all, I just watned to let you know that I am finally back at they keyboard, and I&#8217;ve already started cranking out the next big update. I anticipate one more update, and then a release through the WordPress site.</p>
<p>I started using Trello to track bugs and whatnot as a Project Tracker, I&#8217;ve found it to increase productivity in my code work here and all my other projects as well. Check it out at the top under &#8220;Sermon Posts &gt; Project Tracker&#8221;.</p>
<p>Stay tuned, I&#8217;m currently updating the import process, you&#8217;ll find it much easier to work with, and much more accurate!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tobiaslabs.com/727/status-update-finally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Everything is a mess and I apologize.</title>
		<link>http://www.tobiaslabs.com/703/everything-is-a-mess-and-i-apologize/</link>
		<comments>http://www.tobiaslabs.com/703/everything-is-a-mess-and-i-apologize/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 03:44:38 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Sermon Posts]]></category>

		<guid isPermaLink="false">http://www.tobiaslabs.com/?p=703</guid>
		<description><![CDATA[Hello everyone, I know I said I would be back shortly, working on projects that you care about, and I apologize that I have been unable to fulfill those promises. As past readers know, I got a co-op (like an &#8230;<p class="read-more"><a href="http://www.tobiaslabs.com/703/everything-is-a-mess-and-i-apologize/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Hello everyone, I know I said I would be back shortly, working on projects that you care about, and I apologize that I have been unable to fulfill those promises.</p>
<p>As past readers know, I got a co-op (like an intern, but longer) at a really great company. The bad news is that there wasn&#8217;t any internet nearby (problem solved now) and that it happened very quickly during finals week, so I was bogged down really badly.</p>
<p>Now more bad news keeps piling up: Perhaps you have heard of the Missouri river flooding? Yeah, the river is high. It&#8217;s pretty intense. The place I am employed is so badly flooded that they had to shut down their big machinery and go on standby (a <em>very</em> expensive task at this company!) and all the co-ops were requisitioned to flood detail. This won&#8217;t change until the river goes back down about two more feet, so&#8230;</p>
<p>Anyway, I am not going to make any promises here except one: I have not abandoned this project, and I remain dedicated to producing a plugin to not only replace the old Sermon Browser plugin, but to replace it with something <em>far better</em>.</p>
<p>It&#8217;s just that life keeps getting in the way of progress.</p>
<p>Anyway, I really have no idea when I&#8217;ll get back to working on this, but if I had to guess it will probably be another several weeks before I can dig into it again. It&#8217;s on my to-do list, and it&#8217;s even on the high priority to-do list, so&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tobiaslabs.com/703/everything-is-a-mess-and-i-apologize/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Apologies for delays</title>
		<link>http://www.tobiaslabs.com/702/apologies-for-delays/</link>
		<comments>http://www.tobiaslabs.com/702/apologies-for-delays/#comments</comments>
		<pubDate>Tue, 17 May 2011 21:08:31 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Sermon Posts]]></category>

		<guid isPermaLink="false">http://www.tobiaslabs.com/?p=702</guid>
		<description><![CDATA[Hello all, I wanted to apologize for the delays in promised updates. As you may be aware I am still a university student, and I had to stop working on this during final exams. Immediately after final exams I was &#8230;<p class="read-more"><a href="http://www.tobiaslabs.com/702/apologies-for-delays/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Hello all, I wanted to apologize for the delays in promised updates.</p>
<p>As you may be aware I am still a university student, and I had to stop working on this during final exams. Immediately after final exams I was offered a great job in another city, so I had to pack up and move. The place I moved to is out into the countryside a ways, so it doesn&#8217;t have internet yet.</p>
<p>I talked to the phone company, and they do offer moderate (it&#8217;s slow-ish, but reasonable) internet access via a typical DSL phone-modem, so I&#8217;ll be setting that up within the next few weeks. Until then, I&#8217;ll be working from home and toting from my laptop so I can drag that into town to a coffee shop and commit updates. Progress will be slow until early June, when I get settled into the new job and have internet access.</p>
<p>My next update will be a few repairs and code standardizations, and then I&#8217;ll be releasing it via the official WordPress website. Hooray!</p>
<p>Until then, keep on serving the Lord!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tobiaslabs.com/702/apologies-for-delays/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Site Overhaul</title>
		<link>http://www.tobiaslabs.com/653/site-overhaul/</link>
		<comments>http://www.tobiaslabs.com/653/site-overhaul/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 04:54:37 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://www.tobiaslabs.com/?p=653</guid>
		<description><![CDATA[I&#8217;ve been putting in many long hours and making several updates on my latest project, the Sermon Posts WordPress plugin, so the updates have been all that&#8217;s been coming through. Although the old layout suited my needs at the time, &#8230;<p class="read-more"><a href="http://www.tobiaslabs.com/653/site-overhaul/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been putting in many long hours and making several updates on my latest project, the<a href="http://www.tobiaslabs.com/sermonposts/"> Sermon Posts</a> WordPress plugin, so the updates have been all that&#8217;s been coming through.</p>
<p>Although the old layout suited my needs at the time, the focus of this site is not only on the totally cool plugin but on my general research and projects. Because of this, and in anticipation of several new hot projects I&#8217;ll be working on over the summer, I gave the site a major overhaul.</p>
<p>You&#8217;ll notice a friendlier new theme, a big change in layout, and soon you&#8217;ll be able to customize your own RSS feed! No log-in or registration required!</p>
<p>Want to hear every single thing I say? Haha!You&#8217;re making me blush!</p>
<p>But seriously, if you aren&#8217;t interested in a particular project but want to stay informed of other things, you&#8217;ll have that option! It&#8217;s actually in place now, but I need to make some sort of form for it.</p>
<p>Also, do people want emails instead? You&#8217;ll be able to do that as well!</p>
<p><em>[Update: So apparently designing on a small screen makes some aspects difficult to check. Like centering and repeating header images. Yeah...]</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tobiaslabs.com/653/site-overhaul/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sermon Posts 0.13</title>
		<link>http://www.tobiaslabs.com/630/sermon-posts-0-13/</link>
		<comments>http://www.tobiaslabs.com/630/sermon-posts-0-13/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 02:57:52 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Sermon Posts]]></category>

		<guid isPermaLink="false">http://www.tobiaslabs.com/?p=630</guid>
		<description><![CDATA[Update to fix editing and deleting the preacher, service, and series.]]></description>
			<content:encoded><![CDATA[<p>Update to fix editing and deleting the preacher, service, and series.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tobiaslabs.com/630/sermon-posts-0-13/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Sermon Posts 0.12</title>
		<link>http://www.tobiaslabs.com/628/sermon-posts-0-12/</link>
		<comments>http://www.tobiaslabs.com/628/sermon-posts-0-12/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 05:21:15 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Sermon Posts]]></category>

		<guid isPermaLink="false">http://www.tobiaslabs.com/?p=628</guid>
		<description><![CDATA[Added support to set a default preacher, service, and series. I&#8217;ll be adding a good &#8220;How-To&#8221; on this website next, so you can see some of the features you might not have noticed.]]></description>
			<content:encoded><![CDATA[<p>Added support to set a default preacher, service, and series.</p>
<p>I&#8217;ll be adding a good &#8220;How-To&#8221; on this website next, so you can see some of the features you might not have noticed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tobiaslabs.com/628/sermon-posts-0-12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sermon Posts 0.11</title>
		<link>http://www.tobiaslabs.com/625/sermon-posts-0-11/</link>
		<comments>http://www.tobiaslabs.com/625/sermon-posts-0-11/#comments</comments>
		<pubDate>Sun, 17 Apr 2011 09:18:30 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Sermon Posts]]></category>

		<guid isPermaLink="false">http://www.tobiaslabs.com/?p=625</guid>
		<description><![CDATA[Added a couple more options to adjust the size of the Thickbox &#8220;Add/View Files&#8221; pop-up, hopefully I&#8217;ll make it dynamic at some point. Speaking of which: The &#8220;Add/View Files&#8221; button now works! It&#8217;s even pretty close to what I wanted! &#8230;<p class="read-more"><a href="http://www.tobiaslabs.com/625/sermon-posts-0-11/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Added a couple more options to adjust the size of the Thickbox &#8220;Add/View Files&#8221; pop-up, hopefully I&#8217;ll make it dynamic at some point.</p>
<p>Speaking of which: The &#8220;Add/View Files&#8221; button now works! It&#8217;s even pretty close to what I wanted! Check it out, try and break it, then let me know what happened because I&#8217;m pretty sure there are still bugs. It took me forever, wow.</p>
<p>Which reminds me: <strong>This plugin is still BETA!</strong> I just want to make it clear, since it still has the possibility to be insecure, or trash your data. I try hard to do the Right Thing, but it&#8217;s getting to be pretty big.</p>
<p>Other SVN-esque notes: Piles of new functions added to sermonposts.php, and pretty much the whole fileupload.php was rewritten. The metabox.php really doesn&#8217;t have much different, just the link to the thickbox pop-up changed.</p>
<p>I removed a bit of code that was supposed to allow for plugin updating for unofficial plugins. It would have been nice to have during beta, but I couldn&#8217;t get it working and was planning on taking it out anyway, so now it&#8217;s gone. Wheeee!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tobiaslabs.com/625/sermon-posts-0-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sermon Posts 0.09</title>
		<link>http://www.tobiaslabs.com/619/sermon-posts-0-09/</link>
		<comments>http://www.tobiaslabs.com/619/sermon-posts-0-09/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 04:38:44 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Sermon Posts]]></category>

		<guid isPermaLink="false">http://www.tobiaslabs.com/?p=619</guid>
		<description><![CDATA[Added functionality to be able to add new Series/Service/Preacher, although not on the &#8220;Add Sermon&#8221; page (future update). The HTML displays on the same page, clicking the &#8220;Add New&#8221; button changes it&#8217;s visibility state. Thanks to Joe for the catch &#8230;<p class="read-more"><a href="http://www.tobiaslabs.com/619/sermon-posts-0-09/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Added functionality to be able to add new Series/Service/Preacher, although not on the &#8220;Add Sermon&#8221; page (future update). The HTML displays on the same page, clicking the &#8220;Add New&#8221; button changes it&#8217;s visibility state. Thanks to Joe for the catch :-)</p>
<p>The import procedure has been given a once-over, so if your Series/Services/Preachers were importing incorrectly, you can try again now.</p>
<p>Repaired a date issue in the &#8220;Add Sermon&#8221; metabox that was saving months one greater than they should have been.</p>
<p>The settings window now has a few settings, it will display the rest as soon as they are added to the database (some options are currently hard-coded).</p>
<p>Additionally, there is now a link at the bottom of the &#8220;Settings > Sermon Posts&#8221; page that leads to a database cleaner. If your import broke, you can now go there and remove all sermons, sermon files (hopefully!), and taxonomy items associated with this plugin. You&#8217;ll need to disable and re-enable the plugin to recreate a couple tables.</p>
<p>School is getting increasingly busy, with finals coming up in only three weeks, so I won&#8217;t be as active as my initial burst. If you have suggestions, now is a perfect time to make them!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tobiaslabs.com/619/sermon-posts-0-09/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WordPress Tutorial: Creating a new pop-up</title>
		<link>http://www.tobiaslabs.com/620/tutorial-creating-a-new-pop-up/</link>
		<comments>http://www.tobiaslabs.com/620/tutorial-creating-a-new-pop-up/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 03:06:17 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.tobiaslabs.com/?p=620</guid>
		<description><![CDATA[Have you ever wondered how to make your own pop-up I-Frame in WordPress, like the one used in blogs? Something that looks like this, but with custom interior HTML? You can probably think of about a billion uses for something &#8230;<p class="read-more"><a href="http://www.tobiaslabs.com/620/tutorial-creating-a-new-pop-up/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Have you ever wondered how to make your own pop-up I-Frame in WordPress, like the one used in blogs? Something that looks like this, but with custom interior HTML?<br />
<a href="http://www.tobiaslabs.com/media/2011/04/thickboxpopup.jpg"><img class="alignnone size-medium wp-image-621" title="thickboxpopup" src="http://www.tobiaslabs.com/media/2011/04/thickboxpopup-300x101.jpg" alt="" width="300" height="101" /></a></p>
<p>You can probably think of about a billion uses for something like this, but there are probably very few uses that I would consider legitimate. Using the approach I outline below gives great power, but with it, as Uncle Ben says, comes great responsibility.</p>
<p>I&#8217;ll be outlining the code used, and describing each section carefully, but you can download the final code from <a href="http://www.tobiaslabs.com/media/2011/04/tobiaslabs-addthickbox.zip">this link</a> (a zip file, installable directly as a plugin).</p>
<p>There are two files here, the first one is the core code for the plugin, and the second is what creates the pages within the pop-up page. Here&#8217;s what&#8217;s in the first file:</p>
<h2>Core Plugin File</h2>
<p>Most plugins that I write are enclosed inside a PHP class, to avoid namespacing issues. PHP now supports proper namespaces, but may not be supported on older version of PHP. For this example, we&#8217;ll create the basic class:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$MyThing</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyThing_Class<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> MyThing_Class <span style="color: #009900;">&#123;</span></pre></td></tr></table></div>

<p>Now, you don&#8217;t need to put the following information as variables, but for the purpose of this tutorial I think it will be helpful:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$html_name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'myupload'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$page_name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'mynewpage'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$title_name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'My Sweet Pop-Up'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$popup_width</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'600'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$popup_height</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'400'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$link</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<ul>
<li><code>$html_name</code> is the name used by the pop-up link, and is part of the <code>add_action</code> used to add the pop-up.</li>
<li><code>$page_name</code> is part of the URL as <code>$_GET['paged']</code></li>
<li><code>$title_name</code> is the title of the pop-up box</li>
<li><code>$popup_width</code> and <code>$popup_height</code> are the size parameters for the pop-up box</li>
<li><code>$link</code> holds the link to the thickbox page</li>
</ul>
<p>Inside PHP classes, the function <code>__construct()</code> is run whenever the class is initialized with <code>$var = new MyClass</code> so the function is used to place all the <code>add_action</code> and similar hooks:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_menu'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'MyMenu'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'media_upload_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">html_name</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'MyFrameAdder'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_init'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'AdminInit'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">link</span> <span style="color: #339933;">=</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/wp-admin/media-upload.php?tab=<span style="color: #006699; font-weight: bold;">{$this-&gt;html_name}</span>&amp;TB_iframe=1&amp;width=<span style="color: #006699; font-weight: bold;">{$this-&gt;popup_width}</span>&amp;height=<span style="color: #006699; font-weight: bold;">{$this-&gt;popup_height}</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The <code>add_action</code> sets should be familiar, the second paramater is the function name, but inside a class it is stored as an array, with <code>$this</code> being a reserved PHP variable, and the second element of the array as the function name.</p>
<p>Let&#8217;s look at the functions listed:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> MyMenu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
add_options_page<span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'My Thing Options'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'My Thing'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'manage_options'</span><span style="color: #339933;">,</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">page_name</span><span style="color: #339933;">,</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'MyDisplay'</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The function <code>MyMenu</code> is called when WordPress creates the admin menus. In this example we&#8217;ll just add a menu item in &#8220;Settings&#8221;. The first two lines are the two labels used, the second one, <code>My Thing</code> in this case, is the label that will show up in the &#8220;Settings&#8221; menu. The third element, <code>manage_options</code> is a test that determines which users will be able to see the menu item. See the <a href="http://codex.wordpress.org/Roles_and_Capabilities">Roles and Capabilities</a> section for more tests.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> AdminInit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">page_name</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'thickbox'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
wp_enqueue_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'thickbox'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>It&#8217;s bad practice to just queue up scripts everywhere, so we limit it to just the settings page made in the <code>MyMenu</code> function.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> MyDisplay<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;&lt;a id='my_thickbox' class='button-secondary thickbox' title='<span style="color: #006699; font-weight: bold;">{$this-&gt;title_name}</span>' href='<span style="color: #006699; font-weight: bold;">{$this-&gt;link}</span>'&gt;Click Here!&lt;/a&gt;&lt;/p&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The function <code>MyDisplay</code> would normally display settings, and you would want to work out a way to show and save them, but here all we are doing is adding a link which will call the Thickbox pop-up when clicked.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> MyFrameAdder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	wp_iframe<span style="color: #009900;">&#40;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'MyUploadForm'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>We need to use <code>wp_iframe</code> (defined in /wp-admin/includes/media.php) to register the frame used to display our new pop-up HTML. The Thickbox pop-up is actually just an embedded <a href="http://en.wikipedia.org/wiki/HTML_element#Frames">iframe</a>, styled to look like a pop-up.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> MyUploadForm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'popuppage.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>All this does is call in the pop-up display PHP. Depending on how big your setup is, you might find it just as handy to print out the HTML right here, of course.</p>
<p>All that&#8217;s remaining for this file is to end the class with a <code>}</code></p>
<h2>The Pop-Up File</h2>
<p>The pop-up file is the file included in the previous <code>MyUploadForm</code> function. It basically just spits out HTML, but you&#8217;ll want at least one security check, this is the start of the file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload_files'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
wp_die<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'You do not have permission to upload files.'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span><span style="color: #339933;">:</span></pre></td></tr></table></div>

<p>We can just wrap the whole file in this <code>if</code> statement, to secure it a little more. Now the rest of the output is just whatever HTML you want. Here&#8217;s a sample that shows how a simple two-paged pop-up could be constructed:
</pre>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'paged'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'paged'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'2'</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;This is page 2.&lt;/p&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;&lt;a href='<span style="color: #006699; font-weight: bold;">{$this-&gt;link}</span>&amp;paged=2'&gt;Click to go to page 2.&lt;/a&gt;&lt;/p&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>That's really it! Here's what it looks like right now:<br />
<a href="http://www.tobiaslabs.com/media/2011/04/thickboxpopup_new.jpg"><img src="http://www.tobiaslabs.com/media/2011/04/thickboxpopup_new-300x104.jpg" alt="" title="thickboxpopup_new" width="300" height="104" class="alignnone size-medium wp-image-623" /></a></p>
<h2>Final Notes</h2>
<p>The variable <code>$_GET['page']</code> is reserved by WordPress, and if you use it in your pop-up you'll end up with a broken page, usually it dies saying "You don't have sufficient permission" or similar.</p>
<p>Obviously you'll need to use some <a href="http://codex.wordpress.org/Function_Reference/wp_nonce_field">wp_nonce</a> security checks inside your pop-up window.</p>
<p>For media management, check out the file at /wp-admin/media-upload.php for a little inspiration.</p>
<p>I don't think I ever would have figured this out without the help of jameslafferty, so a big thanks to him!</p>
<p>Again, here's the <a href="http://www.tobiaslabs.com/media/2011/04/tobiaslabs-addthickbox.zip">full code download</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tobiaslabs.com/620/tutorial-creating-a-new-pop-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sermon Posts 0.08 &#8211; Importing Fixed</title>
		<link>http://www.tobiaslabs.com/618/sermon-posts-0-8/</link>
		<comments>http://www.tobiaslabs.com/618/sermon-posts-0-8/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 09:39:32 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Sermon Posts]]></category>

		<guid isPermaLink="false">http://www.tobiaslabs.com/?p=618</guid>
		<description><![CDATA[Finally! The import procedure should be fully functional now! If it finishes and says &#8220;there were errors&#8221;, but doesn&#8217;t throw any PHP errors (red), it just means there were some verse ranges from the Sermon Browser plugin that were invalid. &#8230;<p class="read-more"><a href="http://www.tobiaslabs.com/618/sermon-posts-0-8/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Finally!</strong> The import procedure should be fully functional now! If it finishes and says &#8220;there were errors&#8221;, but doesn&#8217;t throw any PHP errors (red), it just means there were some verse ranges from the Sermon Browser plugin that were invalid. Next update I&#8217;ll have the output be made more human readable.</p>
<p><strong>SVN Commit Notes:</strong></p>
<p>In the &#8220;File Manager&#8221; screen: Added ability to sort columns ascending and descending. Removed last column &#8220;File Type&#8221;, since it was redundant&#8211;full file names are visible. Can be added back easily if requested, but <em>cannot</em> be sortable.</p>
<p>Moved the Bible array and initial Bible database and sermon reference ranges setup into a separate file for easier code reading in the main Sermon Posts class.</p>
<p>Modified several import queries to improve efficiency and accuracy, repaired the broken &#8220;Preachers&#8221;  import procedure, and a section which associated verse ranges with sermons incorrectly. Cleaned up the core import procedure code a bit.</p>
<p>Renamed the sermon_biblebooks to sermon_biblebook in keeping with the singular table naming standard.</p>
<p><strong>Additional Note:</strong></p>
<p><strong></strong>I modified one of the tables, and the activate/deactivate procedure is what will update the table, so if you get a MySQL error in the sermon metabox, just deactivate and reactivate the plugin.</p>
<p><strong>Plans for next update:</strong></p>
<p>Display the import procedure output in a human readable form, and explain errors (most errors are from incorrectly stored verse ranges from the Sermon Browser plugin). Add an actual options screen.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tobiaslabs.com/618/sermon-posts-0-8/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 3.555 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-05 19:36:08 -->

