<?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>WhyPad &#187; Byron Bennett</title>
	<atom:link href="http://www.whypad.com/posts/author/byron/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.whypad.com</link>
	<description>Tips, tricks, and hacks for life and tech...</description>
	<lastBuildDate>Tue, 06 Jul 2010 15:21:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>WordPress: Add Your Plugin&#8217;s Settings Link to Admin Plugins Page</title>
		<link>http://www.whypad.com/posts/wordpress-add-settings-link-to-plugins-page/785/</link>
		<comments>http://www.whypad.com/posts/wordpress-add-settings-link-to-plugins-page/785/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 04:20:28 +0000</pubDate>
		<dc:creator>Byron Bennett</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[web dev]]></category>

		<guid isPermaLink="false">http://www.whypad.com/?p=785</guid>
		<description><![CDATA[Hello, WordPress plugin authors!  I&#8217;ve been envious of that little &#8220;Settings&#8221; link on the Plugins page in the Admin on several of the plugins I use on my blogs.  I wanted one for my own PhotoSmash plugin! My first stop, Google, yielded no fruit, but persistence paid off.  So, thanks to GD-Star Ratings and Shadowbox-JS, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.whypad.com/posts/wordpress-add-settings-link-to-plugins-page/785/"><img class="alignleft size-thumbnail wp-image-715" title="wp" src="http://www.whypad.com/wp-content/uploads/wp-150x150.png" alt="" width="150" height="150" /></a>Hello, WordPress plugin authors!  I&#8217;ve been envious of that little &#8220;Settings&#8221; link on the Plugins page in the Admin on several of the plugins I use on my blogs.  I wanted one for my own PhotoSmash plugin!</p>
<p><span id="more-785"></span></p>
<p>My first stop, Google, yielded no fruit, but persistence paid off.  So, thanks to GD-Star Ratings and Shadowbox-JS, I finally figured it out!</p>
<p>And now, for your coding pleasure, here&#8217;s the step-by-step:</p>
<h2>Steps for Showing Settings Link</h2>
<p>1. Add a function that injects your link into the links array.  The array_unshift adds your link to the front of the array.  The $this_plugin wizardry is determining whether this instance of the filter is being called for your plugin or another one.  You only want to add the link to your plugin <img src='http://www.whypad.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .  Here&#8217;s the code:</p>
<pre class="brush: php;">

/**
 * Add Settings link to plugins - code from GD Star Ratings
 */
 function add_settings_link($links, $file) {
static $this_plugin;
if (!$this_plugin) $this_plugin = plugin_basename(__FILE__);

if ($file == $this_plugin){
$settings_link = '&lt;a href=&quot;admin.php?page=bwb-photosmash.php&quot;&gt;'.__(&quot;Settings&quot;, &quot;photosmash-galleries&quot;).'&lt;/a&gt;';
 array_unshift($links, $settings_link);
}
return $links;
 }
</pre>
<p>Of course, you&#8217;ll need to change the page link as appropriate.  The easiest way to get that is to go to your plugin&#8217;s settings page and copy it from the URL.  You want everything after the last forward slash &#8220;/&#8221;. Screenshot!</p>
<p><a href="http://www.whypad.com/wp-content/uploads/plugin-url.png"><img class="aligncenter size-full wp-image-786" title="plugin-url" src="http://www.whypad.com/wp-content/uploads/plugin-url.png" alt="" width="480" height="51" /></a></p>
<p>2. Add a filter for the plugin_action_links filter. When the Plugins page is displayed in Admin, this filter will pass your function the links array.  Here&#8217;s the code:</p>
<pre class="brush: php;">

add_filter('plugin_action_links', array(&amp;$bwbPS, 'add_settings_link'), 10, 2 );
</pre>
<p>Note this part:  array(&amp;$bwbPS, &#8216;add_settings_link&#8217;)</p>
<p>If you&#8217;re putting your function inside a class, you need to use an array as a parameter, with your plugin&#8217;s instance variable&#8230;mine is $bwbPS.  The &#8220;&amp;&#8221; in front of the instance variable tells it to use the instance by reference (which I believe is automatic for objects anyway, but just do it <img src='http://www.whypad.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ).  The part after the &#8216;,&#8217; is the function name we&#8217;re calling.  You can name it whatever you like.</p>
<p>If you&#8217;re not placing your function inside a class, then you&#8217;re code will look like:</p>
<pre class="brush: php;">

add_filter('plugin_action_links', 'add_settings_link', 10, 2 );
</pre>
<p>But you&#8217;re going to want to make sure your function name is totally unique in the whole WordPress world.  Otherwise, POW!  Namespace collision.</p>
<p>Hope that helps!  It&#8217;s easy, and it&#8217;s so very helpful to have that link there.  I just love a plugin that has it because I don&#8217;t have to search for it in the sidebar, and secondly, I figure that the coder must know what he/she&#8217;s doing <img src='http://www.whypad.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>Cheers,</p>
<p>Byron</p>
<img src="http://www.whypad.com/?ak_action=api_record_view&id=785&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.whypad.com/posts/wordpress-add-settings-link-to-plugins-page/785/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SAP Account Determination</title>
		<link>http://www.whypad.com/posts/sap-account-determination/781/</link>
		<comments>http://www.whypad.com/posts/sap-account-determination/781/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 19:03:35 +0000</pubDate>
		<dc:creator>Byron Bennett</dc:creator>
				<category><![CDATA[Books/Movies]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[FICO]]></category>

		<guid isPermaLink="false">http://www.whypad.com/?p=781</guid>
		<description><![CDATA[I saw this book, &#8220;SAP Account Determination&#8221;, by Manish Patel, on the desk of one of my colleagues at work. My first reaction was, &#8220;Wow! A book on account determination&#8230;I mean, wow!&#8221; Her simple reply was, &#8220;I use it all the time.&#8221; So, I thought I would share it here since many of you are [...]]]></description>
			<content:encoded><![CDATA[<div class='alignleft' style='margin-right: 10px;'><iframe src="http://rcm.amazon.com/e/cm?t=byronbennett-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=1592291104&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></div>
<p><span id="more-781"></span></p>
<p>I saw this book, &#8220;SAP Account Determination&#8221;, by Manish Patel, on the desk of one of my colleagues at work.  My first reaction was, &#8220;Wow! A book on account determination&#8230;I mean, wow!&#8221;  Her simple reply was, &#8220;I use it all the time.&#8221; So, I thought I would share it here since many of you are FICO users.  </p>
<p>Patel covers the gamut of account determination in SAP.  Here is a brief rundown:</p>
<h4>Account Determination Scenarios Covered (from the TOC)</h4>
<li>General Ledger transactions</li>
<li>AR and AP</li>
<li>Tax</li>
<li>Bank Transactions</li>
<li>Assets</li>
<li>Travel Expense</li>
<li>Sales and Purchasing</li>
<li>Inventory</li>
<li>Payroll</li>
<p>Amazon has a &#8220;Look Inside&#8221; so you can see more of table of contents&#8230;<a href="http://www.amazon.com/gp/product/1592291104?ie=UTF8&#038;tag=byronbennett-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1592291104">SAP Account Determination</a><img src="http://www.assoc-amazon.com/e/ir?t=byronbennett-20&#038;l=as2&#038;o=1&#038;a=1592291104" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />**.</p>
<p>I plan to read through it (it&#8217;s short, only 90 pages), so I&#8217;ll let you know how it goes.</p>
<p>Cheers,<br />
Byron</p>
<p><span class='font-size: 11px; color: #777;'>**Disclosure: the links to Amazon here include my affiliate code which gives me commission on any sales.</span></p>
<img src="http://www.whypad.com/?ak_action=api_record_view&id=781&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.whypad.com/posts/sap-account-determination/781/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>C#: Break vs. Continue in Foreach Loops</title>
		<link>http://www.whypad.com/posts/c-break-vs-continue-in-foreach-loops/776/</link>
		<comments>http://www.whypad.com/posts/c-break-vs-continue-in-foreach-loops/776/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 14:17:40 +0000</pubDate>
		<dc:creator>Byron Bennett</dc:creator>
				<category><![CDATA[ASP.NET/C#]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://www.whypad.com/?p=776</guid>
		<description><![CDATA[A C# Quick Tip: You&#8217;ve probably seen &#8216;break&#8217; before in Switch Case statements, but it also plays an important role in Foreach Loops. To break completely out of a foreach loop (foregoing all the remaining loops), use: break; To go to the next iteration in the loop, use: continue; When is &#8216;break&#8217; useful? It is [...]]]></description>
			<content:encoded><![CDATA[<p><strong>A C# Quick Tip: </strong> You&#8217;ve probably seen &#8216;break&#8217; before in Switch Case statements, but it also plays an important role in Foreach Loops.</p>
<p>To break completely out of a foreach loop (foregoing all the remaining loops), use:  <strong>break;</strong></p>
<p>To go to the next iteration in the loop, use:  <strong>continue;</strong></p>
<p><span id="more-776"></span></p>
<p>When is &#8216;break&#8217; useful?  It is particularly useful if you&#8217;re looping through an a collection of Objects (like Rows in a Datatable) and you&#8217;re searching for a particular match.  When you find that match, there&#8217;s no need to continue through the remaining rows, so you want to Break out.  There are plenty of other cases as well.</p>
<p>&#8216;Continue&#8217; is useful when you&#8217;ve accomplished what you need to in side a loop iteration and you don&#8217;t want to process the remaining code for that particular iteration.  You&#8217;ll normally have &#8216;continue&#8217; after an &#8216;if&#8217;.</p>
<img src="http://www.whypad.com/?ak_action=api_record_view&id=776&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.whypad.com/posts/c-break-vs-continue-in-foreach-loops/776/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C#: That Pesky DBNull Error in Datatables</title>
		<link>http://www.whypad.com/posts/c-that-pesky-dbnull-error-in-datatables/767/</link>
		<comments>http://www.whypad.com/posts/c-that-pesky-dbnull-error-in-datatables/767/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 21:42:02 +0000</pubDate>
		<dc:creator>Byron Bennett</dc:creator>
				<category><![CDATA[ASP.NET/C#]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://www.whypad.com/?p=767</guid>
		<description><![CDATA[Datatables and Tableadapters are one of the most beautiful things about C# and Visual Studio, until you&#8217;re processing rows in your datatable and you get something that reads like &#8220;The value for column &#8216;your_column&#8217; in table &#8216;your_table&#8217; is DBNull.&#8221;  If you go a little further, you may get:  &#8220;Exception Details: System.InvalidCastException: Specified cast is not [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.whypad.com/wp-content/uploads/datatable.jpg"><img class="alignleft size-thumbnail wp-image-769" title="datatable" src="http://www.whypad.com/wp-content/uploads/datatable-150x150.jpg" alt="" width="150" height="150" /></a>Datatables and Tableadapters are one of the most beautiful things about C# and Visual Studio, until you&#8217;re processing rows in your datatable and you get something that reads like &#8220;The value for column &#8216;your_column&#8217; in table &#8216;your_table&#8217; is DBNull.&#8221;  If you go a little further, you may get:  &#8220;<strong>Exception Details: </strong>System.InvalidCastException: Specified cast is not  valid.&#8221;  You may go to your Datatable in your Dataset and start trying to change the NullValue for the offending column or trying to change the DefaultValue in the column properties, but chances are that the data type will not let you change that NullValue.  It will insist on &#8220;(Throw Exception)&#8221;.<span id="more-767"></span></p>
<h3>Help for the DBNull Problem has Arrived!</h3>
<p>The answer is so simple (at least in VS 2008 and greater, maybe before that too).  It is rather sad how much time I&#8217;ve wasted trying to deal with this problem.  Without further ado, the answer!</p>
<p>You&#8217;re probably using a Datarow object to get at the column values, probably buried in a foreach statement.  Instead of messing around with the specific column like  myRow.MyColumn, the Row object has an isNull method for each column in the row.  The method name takes the column&#8217;s name and puts &#8220;is&#8221; in front, and &#8220;null&#8221; behind.  So for a column called MyColumn, the method would be:   myRow.IsMyColumnNull();</p>
<p>Here&#8217;s a full example of dealing with nulls in a DateTime field.  The logic is the same for Int or other numerics as well.</p>
<pre class="brush: csharp;">

int iReq = 6196;
certdbTableAdapters.integration_procsTableAdapter taProcs = new certdbTableAdapters.integration_procsTableAdapter();
certdb.integration_procsDataTable dtProcs = taProcs.GetData(iReq);

certdb.integration_procsRow rowProc = dtProcs.Rows[0];

if(!rowProc.IsStartTimeNull())
{
    sProcDate = rowProc.StartTime.ToShortDateString();
}
else
{
    sProcDate = &quot;&quot;;
}
</pre>
<h3>The Craziness I Tried Before</h3>
<p>Before I finally found the answer to this, I was using all sorts of crazy workarounds, including using multiple queries to be sure I never got a null situation, and using the fabulous Case statement within SQL statements.  Here&#8217;s a little tast of a Case statement:</p>
<pre class="brush: sql;">
SELECT DISTINCT Process.ProcessID, Process.Name, Process.Description, Process.ResultLogStatusID,
Process.StatusTimeStamp, ResultLogStatus.Name AS ProcResult,
CASE WHEN LogProcess.EndTime IS NULL THEN '1/1/1900' ELSE LogProcess.EndTime END as rortime,
CASE WHEN LogProcess.Status IS NULL THEN 'missing' ELSE LogProcess.Status END as rorstatus
FROM         RequirementTestLink
LEFT JOIN Process ON Process.ProcessID = RequirementTestLink.ProcessID
LEFT JOIN ResultLogStatus ON Process.ResultLogStatusID = ResultLogStatus.ResultLogStatusID
LEFT JOIN LogProcess ON Process.ProcessID = LogProcess.ProcessID AND LogProcess.ResultOfRecord = 1 WHERE     (RequirementTestLink.RequirementID IN (&quot; + sReqs + &quot;)) ORDER BY Process.ProcessID
</pre>
<p>I tried lots of things&#8230;here are a couple others that didn&#8217;t work on my strongly typed datatables:</p>
<p>myRow.MyColumn != null<br />
or<br />
Convert.IsDBNull(myRow.MyColumn)</p>
<p>Neither worked! It&#8217;s a shame the answer was much simpler!</p>
<p>I hope this post will help someone else out there.  Hopefully I&#8217;ll remember this post the next time I&#8217;m dealing with DBNulls.<br />
Cheers,<br />
Byron</p>
<img src="http://www.whypad.com/?ak_action=api_record_view&id=767&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.whypad.com/posts/c-that-pesky-dbnull-error-in-datatables/767/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET: Hide Menu Items by Role with Security Trimming</title>
		<link>http://www.whypad.com/posts/asp-net-hide-menu-items-by-role-with-security-trimming/757/</link>
		<comments>http://www.whypad.com/posts/asp-net-hide-menu-items-by-role-with-security-trimming/757/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 17:37:56 +0000</pubDate>
		<dc:creator>Byron Bennett</dc:creator>
				<category><![CDATA[ASP.NET/C#]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.whypad.com/?p=757</guid>
		<description><![CDATA[ASP.NET makes authorizations and security fairly simple with its roleManager, Authentication, and SiteMap providers.  This quick hint only covers how to hide a particular menu item from the standard Menu and TreeList navigation components when using a SiteMap provider. Web.config Settings for Role-based Menu Security 1) When you declare your sitemap provider, turn sucrityTrimmingEnabled to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.whypad.com/wp-content/uploads/hideme.png"><img class="alignleft size-thumbnail wp-image-758" title="hideme" src="http://www.whypad.com/wp-content/uploads/hideme-150x150.png" alt="" width="150" height="150" /></a>ASP.NET makes authorizations and security fairly simple with its roleManager, Authentication, and SiteMap providers.  This quick hint only covers how to hide a particular menu item from the standard Menu and TreeList navigation components when using a SiteMap provider.<span id="more-757"></span></p>
<h2>Web.config Settings for Role-based Menu Security</h2>
<p>1) When you declare your sitemap provider, turn sucrityTrimmingEnabled to true:</p>
<pre class="brush: xml;">
&lt;siteMap defaultProvider=&quot;XmlSiteMapProvider&quot; enabled=&quot;true&quot;&gt;
&lt;providers&gt;
    &lt;add name=&quot;XmlSiteMapProvider&quot; description=&quot;Default SiteMap provider.&quot; type=&quot;System.Web.XmlSiteMapProvider &quot; siteMapFile=&quot;Web.sitemap&quot; securityTrimmingEnabled=&quot;true&quot;/&gt;
&lt;/providers&gt;
&lt;/siteMap&gt;
</pre>
<p>2) After you&#8217;ve turned securityTrimmingEnabled on, then you can tell ASP what &#8220;locations&#8221; or url node to hide&#8230;again, in your web.config file, after you close out &lt;/system.web&gt;:</p>
<pre class="brush: xml;">

&lt;location path=&quot;~/MgrReports&quot;&gt;

&lt;system.web&gt;

&lt;authorization&gt;

&lt;allow roles=&quot;managers&quot;/&gt;

&lt;deny users=&quot;*&quot;/&gt;

&lt;/authorization&gt;

&lt;/system.web&gt;

&lt;/location&gt;
</pre>
<p>You can set which roles get access in the &lt;allow roles&gt; node&#8230;use commas to separate multiple roles.</p>
<p>I searched long and hard for this, and finally found a great post by Danny Chen.  Read his post for a much fuller explanation:  <a href="http://blogs.msdn.com/dannychen/archive/2006/03/16/553005.aspx">http://blogs.msdn.com/dannychen/archive/2006/03/16/553005.aspx</a></p>
<p>Cheers,</p>
<p>Byron</p>
<img src="http://www.whypad.com/?ak_action=api_record_view&id=757&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.whypad.com/posts/asp-net-hide-menu-items-by-role-with-security-trimming/757/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress: Add Scripts to the Pages You Want</title>
		<link>http://www.whypad.com/posts/wordpress-add-scripts-to-the-pages-you-want/749/</link>
		<comments>http://www.whypad.com/posts/wordpress-add-scripts-to-the-pages-you-want/749/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 20:18:47 +0000</pubDate>
		<dc:creator>Byron Bennett</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.whypad.com/?p=749</guid>
		<description><![CDATA[WordPress makes it very easy to load Scripts into your blog. The beauty of the method that WordPress provides is that it allows plugins and themes to use the same script at the same time by ensuring the script is loaded only once.   The problem we often run into is that not everyone plays [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.whypad.com/wp-content/uploads/Lisu_script.gif"><img class="alignleft size-thumbnail wp-image-748" title="Lisu_script" src="http://www.whypad.com/wp-content/uploads/Lisu_script-150x150.gif" alt="" width="150" height="150" /></a>WordPress makes it very easy to load Scripts into your blog. The beauty of the method that WordPress provides is that it allows plugins and themes to use the same script at the same time by ensuring the script is loaded only once.  </p>
<p><span id="more-749"></span></p>
<p>The problem we often run into is that not everyone plays by the rules, and so you get plugin conflicts and fatal errors!</p>
<p>In this tip, I&#8217;ll show you how easy it is load scripts the right way with wp_enqueue_script and also, how to load them on only the pages you want.</p>
<h2>Load Scripts the Right Way with wp_enqueue_script()</h2>
<p>I have a couple of plugins out there that use jQuery and Thickbox, and probably 30% of my support questions are related to themes and/or plugins that load jQuery by hardcoding the link into the header!  This is a major sin by developers, because it assumes that your theme or your plugin is the only one in the whole wide world that your users will be using that rely on jQuery.  </p>
<p>When the jQuery (or really any other script) is hardcoded by a theme or plugin and it is loaded by another plugin (right way or wrong way), jQuery stops working!</p>
<p>WordPress, thankfully makes it amazingly simple to load jQuery and a ton of other scripts.  Here&#8217;s how:</p>
<pre class="brush: php;">
&lt;?php
//To load a script that isn't already registered with WordPress (it has a ton of pre-registered scripts like jQuery, Thickbox, etc)
wp_enqueue_script( $handle, $source, $deps, $ver, $in_footer );

//Here's one loading a script that's in my template folder
wp_enqueue_script('stlouie',get_bloginfo('template_url') . '/js/stl.js');

//Here's one loading a pre-registered script
wp_enqueue_script('jquery');
?&gt;
</pre>
<p>Check out the <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script">WP Codex page</a> for a full description of how to use wp_enqueue_script and a list of the pre-registered javascripts that you can easily use.</p>
<p><strong>Note: I was trying to use wp_enqueue_script with TinyMCE outside of the Admin, and it didn&#8217;t work.  So, some scripts might be Admin Only&#8230;not sure <img src='http://www.whypad.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </strong></p>
<h2><strong>Where to Use wp_enqueue_script()</strong></h2>
<p>If you want to use wp_enqueue_script() in your posts and pages, and you want to limit it to certain pages or posts, you can put the following in your theme&#8217;s functions.php file:</p>
<pre class="brush: php;">
&lt;?php
add_action('wp_print_scripts', 'enqueueMyScripts');

function enqueueMyScripts(){
  // To load a script only on a Page with ID = 23, follow this format:
    if( is_page('23') ) {
         wp_enqueue_script( 'myscript', get_bloginfo('template_url') . '/js/myscript.js');
   }

  //To load for any page/post that's not Admin
   if( !is_admin() ){
        wp_enqueue_script( 'myscript', get_bloginfo('template_url') . '/js/myscript.js');
   }

  //You can use pretty much any of the WP conditional tags to determine whether to enqueue or not
}
?&gt;
</pre>
<p>Here&#8217;s the link to the <a href="http://codex.wordpress.org/Conditional_Tags">WP Conditional Tags</a>.</p>
<p>Notice that you need to tap into the wp_print_scripts action instead of the &#8216;init&#8217; action since is_page() is not available yet in the init action.</p>
<p>I&#8217;ve recorded this because it took me a good bit of time to figure out to use wp_print_scripts instead of init&#8230;Placing the add_action() inside header.php didn&#8217;t work either. Vladimir Prelovac&#8217;s <a href="http://www.prelovac.com/vladimir/best-practice-for-adding-javascript-code-to-http://www.prelovac.com/vladimir/best-practice-for-adding-javascript-code-to-wordpress-plugin">helpful post</a> put me on the right track&#8230;He also has a great book,<a href="http://www.amazon.com/gp/product/1847193595?ie=UTF8&amp;tag=byronbennett-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1847193595">WordPress Plugin Development (Beginner&#8217;s Guide)</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=byronbennett-20&amp;l=as2&amp;o=1&amp;a=1847193595" border="0" alt="" width="1" height="1" />*! This book was very helpful to me with several techniques, particularly around adding images to the WordPress media library.</p>
<p>Cheers,<br />
Byron</p>
<p>* Note: the link to Vladimir&#8217;s book is my affiliate link, and I&#8217;ll receive a small commission should you click and buy.</p>
<img src="http://www.whypad.com/?ak_action=api_record_view&id=749&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.whypad.com/posts/wordpress-add-scripts-to-the-pages-you-want/749/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WordPress &#8211; Can&#8217;t Automatically Upgrade to New Versions?</title>
		<link>http://www.whypad.com/posts/wordpress-problem-automatic-upgrade/743/</link>
		<comments>http://www.whypad.com/posts/wordpress-problem-automatic-upgrade/743/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 04:52:06 +0000</pubDate>
		<dc:creator>Byron Bennett</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.whypad.com/?p=743</guid>
		<description><![CDATA[So, another security fix comes out for WordPress&#8230;2.8.6 this time.  And I begin making the rounds to my sites upgrading.  This is now a ritual for me since some kind hacker hacked me with the 2.7 hidden admin user exploit.  Everything is going smooth&#8230;I&#8217;ve done 3 sites, when I get to a new site I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.whypad.com/wp-content/uploads/wp.png"><img class="alignleft size-thumbnail wp-image-715" title="wp" src="http://www.whypad.com/wp-content/uploads/wp-150x150.png" alt="wp" width="150" height="150" /></a>So, another security fix comes out for WordPress&#8230;2.8.6 this time.  And I begin making the rounds to my sites upgrading.  This is now a ritual for me since some kind hacker hacked me with the 2.7 hidden admin user exploit.  Everything is going smooth&#8230;I&#8217;ve done 3 sites, when I get to a new site I&#8217;m working on, and it will not automatically upgrade for anything.<span id="more-743"></span></p>
<h2>Symptom: Upgrade WordPress Automatically gets Hung</h2>
<p>The symptoms here are that after clicking the Upgrade now link and then Upgrade Automatically, it goes through and faithfully uploads the new WordPress files from WordPress.org, but then it stops!  I&#8217;m stuck at the Uploading files message. </p>
<h2>Solution: You&#8217;ve gotta be on PHP5 (or at least some later version than my hosts version of 4)</h2>
<p>I found a Google post that recommended deactivating all plugins&#8230;no luck <img src='http://www.whypad.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>I&#8217;m deleting folders and checking permissions&#8230;everything I can think of.  I had the same problem last week when I upgraded to 2.8.5 and I don&#8217;t want this to be an ongoing issue.</p>
<p>This site is on the same server that 2 other sites upgraded perfectly on, mind you.</p>
<p><a href="http://www.whypad.com/wp-content/uploads/php.gif"><img class="alignright size-full wp-image-502" title="php" src="http://www.whypad.com/wp-content/uploads/php.gif" alt="php" width="120" height="67" /></a>Then, some synapse fires and I think&#8230;hmmm&#8230;.htaccess&#8230;PHP 4&#8230;.hmmm.</p>
<p>My host defaults to PHP 4 by default.  You have to include a cryptic little line in your .htaccess file to get it to use PHP 5: </p>
<p>AddType x-mapp-php5 .php</p>
<p>This is a new site and I forgot to do that&#8230;once added, the automatic WordPress upgrade works like a charm.</p>
<p>Your host may have a setting in the Admin panel or some other means of designating to use PHP5 instead of 4.  If you&#8217;re reading this, I hope this is your problem, simply because it&#8217;s easy to fix!</p>
<p>Mystery solved.  Hope it helps!</p>
<p>Byron</p>
<img src="http://www.whypad.com/?ak_action=api_record_view&id=743&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.whypad.com/posts/wordpress-problem-automatic-upgrade/743/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress ReWrite &#8211; new Plugin Coming and a Hint</title>
		<link>http://www.whypad.com/posts/wordpress-rewrite-new-plugin-coming-and-a-hint/738/</link>
		<comments>http://www.whypad.com/posts/wordpress-rewrite-new-plugin-coming-and-a-hint/738/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 06:08:07 +0000</pubDate>
		<dc:creator>Byron Bennett</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://www.whypad.com/?p=738</guid>
		<description><![CDATA[First of all, let me start by saying that Custom ReWriting in WordPress has consumed way more of my time than it ever should have.  I have prayed and pleaded, even considered asking one of the WordPress Gurus on their message board, but I&#8217;ve not had much luck getting responses there (questions were probably so [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, let me start by saying that Custom ReWriting in WordPress has consumed way more of my time than it ever should have.  I have prayed and pleaded, even considered asking one of the WordPress Gurus on their message board, but I&#8217;ve not had much luck getting responses there (questions were probably so esoteric that nobody cared but me <img src='http://www.whypad.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ).</p>
<p><span id="more-738"></span></p>
<p>Finally, I have my new plugin working, I think!  It gives you an interface in the Admin for setting up your ReWrite Rules and then handles all the rest behind the scenes.  I&#8217;m not sure how robust it is, but it meets my needs.</p>
<p>I had 2 humongous problems that ate up 10 hours or more of my time.  Hope this helps you if you decide not to go the easy route and just you Smashly ReWriter (coming soon to a download near you!).</p>
<h2>Page ID, ID, Post ID, PageName, P</h2>
<p>The aliases for getting a page to come up in WP are nearly endless.  But when using $wp_rewrite rules, you have to be careful.  While index.php?page_id=245 might work for a post if you type it into a browser, save yourself, oh, about 6 hours and make sure you match up Pages with ?page_id= and Posts with ?p= when creating rewrite rules.</p>
<h2>&amp;amp; or &amp; ?</h2>
<p>Save yourself another 4 hours and don&#8217;t try to get fancy and write your urls the way you think they ought to be to be XHTML compliant&#8230;that is, using &amp;amp; to join multiple query variables.  Sometimes it doesn&#8217;t pay to be too proper.</p>
<p>A good xhtml url would have parameters inserted like:  state=NC&amp;amp;city=CLT</p>
<p>WP Rewriter wants it just plain ole:  state=NC&amp;city=CLT</p>
<p>Well, I hope the new plugin will help somebody out there.  I&#8217;m planning to release in the next few days over on <a href="http://smashly.net">Smashly.net</a>.  It makes this business about as simple as I can possibly come up with.  Hopefully some RegEx wizards will contribute some common match rules to help people along.</p>
<p>Cheers,</p>
<p>Byron</p>
<img src="http://www.whypad.com/?ak_action=api_record_view&id=738&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.whypad.com/posts/wordpress-rewrite-new-plugin-coming-and-a-hint/738/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mac OS X Snow Leopard &#8211; NotificationExec Pop Up Annoyance</title>
		<link>http://www.whypad.com/posts/mac-os-x-snow-leopard-notificationexec-pop-up-annoyance/732/</link>
		<comments>http://www.whypad.com/posts/mac-os-x-snow-leopard-notificationexec-pop-up-annoyance/732/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 00:53:33 +0000</pubDate>
		<dc:creator>Byron Bennett</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Miscellany]]></category>
		<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://www.whypad.com/?p=732</guid>
		<description><![CDATA[Just installed Mac OS X 10.6 on my home iMac. It was truly a perfectly painless experience&#8230;click about 4 buttons and type your password and walk away for 45 minutes. The only thing that marred the experience was a nasty and undying popup for installing Rosetta so it could run NotificationExec. Click Not Now and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.whypad.com/wp-content/uploads/snowleopard.png"><img class="alignleft size-full wp-image-734" title="snowleopard" src="http://www.whypad.com/wp-content/uploads/snowleopard.png" alt="snowleopard" width="143" height="146" /></a>Just installed Mac OS X 10.6 on my home iMac.  It was truly a perfectly painless experience&#8230;click about 4 buttons and type your password and walk away for 45 minutes.</p>
<p><span id="more-732"></span></p>
<p>The only thing that marred the experience was a nasty and undying popup for installing Rosetta so it could run NotificationExec.  Click Not Now and it just comes back a few seconds later.  Truly annoying!</p>
<p>A couple minutes on Google yielded this <a href="http://forums.macrumors.com/showthread.php?t=435236">form post</a> on MacRumors.</p>
<p>The answer for me was to navigate to /Library/Driver Support/ and to trash the NotificationExec.app in between the popups.</p>
<p>So, the steps are:</p>
<ol>
<li>Navigate to: /Library/Driver Support/   &#8211; you should see NotificationExec.app in that folder</li>
<li>Go to Force Quit (Apple menu) and make sure there aren&#8217;t any instances of the popup hanging out</li>
<li>Wait for the popup and click:  &#8220;Not Now&#8221;</li>
<li>Then trash:  NotificationExec.app</li>
<li>You may have to enter your admin password so you can change Finder</li>
<li>Empty trash and resume life!</li>
</ol>
<p>Hope that helps!</p>
<p>Cheers,<br />
Byron</p>
<img src="http://www.whypad.com/?ak_action=api_record_view&id=732&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.whypad.com/posts/mac-os-x-snow-leopard-notificationexec-pop-up-annoyance/732/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Dilbert &#8211; Successful Work Avoider</title>
		<link>http://www.whypad.com/posts/dilbert-successful-work-avoider/722/</link>
		<comments>http://www.whypad.com/posts/dilbert-successful-work-avoider/722/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 15:31:35 +0000</pubDate>
		<dc:creator>Byron Bennett</dc:creator>
				<category><![CDATA[Miscellany]]></category>

		<guid isPermaLink="false">http://www.whypad.com/?p=722</guid>
		<description><![CDATA[My gosh, these are good!  Enjoy!]]></description>
			<content:encoded><![CDATA[<p>My gosh, these are good!  Enjoy!</p>
<p><a href="http://dilbert.com/strips/comic/2009-08-08/" title="Dilbert.com"><img src="http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/60000/3000/300/63348/63348.strip.gif" border="0" width='96%' alt="Dilbert.com" /></a></p>
<img src="http://www.whypad.com/?ak_action=api_record_view&id=722&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.whypad.com/posts/dilbert-successful-work-avoider/722/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
