Hide wordpress password protected pages

A lot of the time it is not desirable to have a password protected post show up on your WordPress home page or recent posts list however it is the default behaviour.

This code is almost straight out of the manual, however it may help someone looking for a complete example with the plugin header/comment that is required for the file to be recognised as a plugin by WordPress.

 * @package hpp
 * @version 1.0
Plugin Name: HidePasswordProtected
Plugin URI: http://hotchipsnsource.com/
Description: As per name
Author: hot chips n source
Version: 1.6
Author URI: http://hotchipsnsource.com/
// Filter to hide protected posts
function exclude_protected($where) {
	global $wpdb;
	return $where .= " AND {$wpdb->posts}.post_password = '' ";

// Decide where to display them
function exclude_protected_action($query) {
	if( !is_single() && !is_page() && !is_admin() ) {
		add_filter( 'posts_where', 'exclude_protected' );

// Action to queue the filter at the right time
add_action('pre_get_posts', 'exclude_protected_action');


Save the code in a file named HidePasswordProtected.php and save it to your wp-content/plugins directory. Then just activate it from within the WordPress Plugins administration page.

There is one flaw with this, while viewing a single post if the next or previous post made was a hidden post the next and previous buttons will expose a link to a hidden page. I have not had time to dig into this as yet and as the posts are not actually accessible it’s not presently a priority. If you know the solution please leave a comment below.

Alternatively there are plugins available on the WordPress Plugins Directory, the ones I tried also suffered from the next and previous issue.


I’ve bought back this site after a long break, piecing together old posts from information I could find in the internet archives. Not everything made it, some of the older information has broken links and some posts needed tweaking. Despite any issues, I’m happy to once again have a place to share and save some of the things I get up to.

Arduino controlled – spooky Halloween themed birthday cake stand

A friends birthday promise to make a memorable cake resulted in a fun filled couple of days building an Arduino controlled cake stand and baking a cake 🙂

I had been tinkering with Arduino it in the past and after the commitment  thought it would bring something special to the task at hand.


Arduino is an open source electronics board with a number inputs that can be used for reading various sensors among other things and a number of outputs that can be used to control or power other things.

Cake stand features:
  • circling shark in pond (motor with reduction)
  • proximity sensor controlled coffin that opened if someone reached over it. (Added a Jaycar proximity sensor to trigger the input of the Arduino).
  • flapping bats (servo moving thin wire and black paper for the bats)
  • twinkling stars (random pattern)
  • button controlled flying witch across the moon in an arc with a message behind(servo controlled with long thin wire arm)
Cake features:
  • Cake
  • coloured icing

Modular Building Designer / Estimator Tool

Here are a couple of modular building design / estimating program prototypes I came up with. There is a Web App & Windows Version, the premise was to design and prebuild house as modules from substructure through to roof and sell them through an app, construction would be just placing the modules onsite and bolting them together hopefully reducing construction time onsite to a few weeks.

Windows Version


Luhn Formula, Mod 10, Modulus 10, Credit card & BPay Number Validation

Hans Peter Luhn the creator and original patent holder for the Modulus 10 Formula left us all a legacy. Just about every time you enter your credit card details online you will be subjected to the Luhn check. If you’re not, the website you are visiting is likely to be a little on the dodgy side.

Mod 10 as it’s commonly known is not the only check that a payment number goes through before validation of a payment occurs, it is only really usefull to check for typing errors and kids who think they might like to try random numbers. The real work of checking a payment number is going to be done by the bank or credit card gateway that is used by the merchant. When a check with mod 10 is done prior to sending a request to the final checker, it cuts down on millions of electronic requests to the many various payment providers and thus goes a long way to providing a smoother overall experience to users.

So now to the reason why I’m bothering to write about the Luhn Algorithm. The reason is not so much to do with the algorithm but with implimentation for bPay. bPay is a non-instant payment system popular in Australia where I live. With bPay you never have to give the store or service any payment details, they give you a unique payment number for either each user/account or for each unique transaction made for their business. A combination of both user and unique transaction is also possible. bPay numbers can become large due to the large amount of users who utilise the service and the amount of tracking the business decides to use. It’s common for CRN’s (Customer Reference Number) lengths of well over 20 digits. This is a rather large number and when considering doing calculations on it a few consideratons have to be made to ensure you get results. Your common off the shelf mod 10 program/script may not be able to cope with such large numbers due to the limitations of the data type programming language, or lack of forethough when it was written. So the reason as to why I have written this post is now ready to be revealed, I tried to use an off the shelf script in PHP for bPay validation and it failed…sometimes..

The script I initially utilised was written for credit card verification (16 digits in length), somewhat smaller than the 20+ digits I wanted to work with. After integrating the script and adding all the required functionality to the website shopping cart I was working on, everything seemed fine. CRN’s and check digits were getting produced during the checkout process and I was able to verify the CRN’s with some third party mod10 programs. It was only after producing the required 20 CRN’s during the bPay application process that any Issue was raised. The bank kindly sent an email in reply stating that some of the numbers didn’t check out. Admittidly it took a while to work out the issue, In my defence it was only every now and again the script would produce an incorrect check digit number. I rewrote the script a couple of times before it even occured to me to break the number up into chunks. Sure enough by processing the number in chunks it didn’t produce randomly incorrect numbers anymore. Further investigation showed that when dealing with larger numbers instead of producing an error message PHP would still provide an answer but the accuracy could be questionable. After a Google I found the PHP Integers page and the following

The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that’s 32 bits signed). 64-bit platforms usually have a maximum value of about 9E18. PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, and maximum value using the constant PHP_INT_MAX since PHP 4.4.0 and PHP 5.0.5.

Two billion eh! that’s 2,000,000,000 in the short scale of things. At the command line on my test server

[brendon@hotchipsnsource]# php -r 'echo PHP_INT_MAX;'

produced exactly “2,147,483,647″.

That is not even enough to hold the 16 digit credit cards that the script was created for, so what is going on?

~to be continued.

Wivenhoe Fishing Map

Wivenhoe is about an hour from home and a nice spot for camping and fishing, I think I will be visiting a lot more often now, so have taken to collecting as much fishing information I can find and have started putting it all together onto a map of the area. As I learn more I will continue to update it and hopefully it will become a usefull resource.


Mary River Cod
Mary River Cod

View Capitan Morgans – Wivenhoe Fishing Map in a larger map or add to your own Google account and update as you like. Just be sure to tell me about the good additions you make!

To use on a mobile phone web browser with GPS like the iPhone or Android use this shortened URL http://goo.gl/QIBpE

Another alternative that I have found better on the go is to save the map to your own Google “My Maps” and add it to Google Earth for iPhone or Android. Just make sure you browse to all the places you want to visit before you leave home so it caches the maps for quicker and less costly use, also incase you do not get reception.

How to work out a Hip or Valley length (Part 2)

Alright so in the last post we went through the reasons why the multiplying factor is not the same for a Hip or Valley as it is for the roof or for that matter a section of barge, this time you get what you were after, the actual formula.

To view the formula, or to save and edit this file go to: https://spreadsheets.google.com/ccc?key=0Am6p57KakXPVdFVLR3BGUGNqbnVQMGgxVjU0U1Vjdmc&hl=en select “File” -> “Download as” -> and then select “Excel” or “Openoffice”. If you have any issues just let me know in the comments.

Deleting Images within a range in Excel

I couldn’t find a way to delete images within a range of selected cells in Excel’s interface so put together the following code and set it to run with Ctrl+Shift+I.
Sub delimg()
Dim sh As Shape
With Excel.Application.ActiveSheet
For Each sh In .Shapes
On Error Resume Next
If Not Application.Intersect(sh.TopLeftCell, Selection) Is Nothing Then
End If
Next sh
End With
End Sub

Note: If you need to delete all images and objects you can use F5 select “Special” and click “Objects” and that will do the trick too.