.PHP

WordPress List Child Pages

I love the Piano Black WordPress theme but it hasn’t been updated in a while and doesn’t support WordPress’ native menus.  This isn’t a big enough drawback for me to change to a different theme and with a few tweaks here and there I’m satisfied with the current state of the menus.  Other than the several blog posts, I’ve also created a hierarchy of pages for both my project pages and code samples.

What I didn’t want to have to do is to update each category landing page whenever adding child pages to it so I created a few template pages, this one is simply called ‘List child page titles’.  Dropping this into a file within your WordPress theme directory and making sure that ‘Template Name’ comment is still in place will give an additional drop-down option for ‘Template’ in the ‘Edit Page’ screen for the page/post you’re editing.

Show the code

WordPress List Child Pages with Content

I created this page template for similar reasons as the WordPress List Child Pages.  The main difference between the two is this one simply displays the content of the children pages of the current page.  The second level under Code Samples is an example of this, clicking ‘PHP’ or ‘JavaScript’ will bring you to a child-page-with-content listing much like category or tag listing of WordPress blog posts.

Show the code

Captcha

The latter code segment of this captcha is to be placed in a separate file that’s invoked by an img tag in the form function. It uses multiple background files but can be modified to randomly generate a background image. The font is picked randomly from 4 different true type fonts and the size/angle is randomized also.

Show the code

HTML2Image

The incredibly long example of code below has been one of my favorite and most recent projects with Zetec. I have generalized the functions and have probably left out some constants but the point here is to provide samples :) . I created this in about 2 days (after mulling and dreading over it for a while). There is wrapper file that it uses to actually create the final graphic but that’s a little too specific to post publicly. The code below is an example of object oriented PHP, parsing HTML style rules, image creation and manipulation including transparency, text and external images. I opted out of using PHP’s built in DOM API since I really was just dealing with style rules

Show the code

Watermark

I made this simple bit of watermarking code for the images on Westlake Eletronic Supply‘s website some time ago to help eliminate the copying of product images from their website. This is a little stripped down but you get the idea, the victim variable is to be created using GET parameters after being validated.

Show the code