github posts

Playing with GitHub Pages

This past weekend, I started playing with GitHub Pages for the first time. It took a while to figure out, but was somewhat fun. I’ve been interested in it for a while, but was unsure of how to do what I wanted, such as building with PHP, Sass, and Rollup. Turns out it was fairly easy with GitHub Actions to do most any sort of build steps I want. It is very interesting for free static site web-hosting.

Continue reading post "Playing with GitHub Pages"

Github repo backup script

For some time, I’ve been wanting to set up a backup for my Github repos. Technically they are all backed up by my local copies, which are also backed up when I back up my local computer. However, I wanted something that was sure to have everything from all the repos (all branches, tags, etc) and could be set up and run continuously on a yet-to-be-created backup server. I have create a bash script to do this for me.

Continue reading post "Github repo backup script"

WPThemeHelper, my helper for WordPress themes

In remaking my website using WordPress, I’ve been working on a base theme that I can use for other sites. I decided to take some of my experience from the Symfony world, such as organizing functionality into namespaced classes, grouped into “bundles” of functionality that can be (somewhat) independently installed as needed depending on the project. I already mentioned the PHP-BufferManager I’m using in a previous post. I’ve also created a more specific to WordPress project with more varied functionality, a theme helper called WPThemeHelper.

The theme helper has several classes to help make theme development cleaner and perhaps a bit easier. The readme on github has more details, but some of the more important ones are:

  • SettingHelper: Allows setting of WordPress settings with a map (associative array). It calls the appropriate WordPress function at the appropriate time in WordPress’s initialization cycle. Helps clean up the ‘functions.php’ file and makes remembering what functions to call for various theme settings easier.
Continue reading post "WPThemeHelper, my helper for WordPress themes"

PHP Output Buffer Manager

With rebuilding my website with WordPress, I have made progress on the WordPress starter theme I’ve been working on. One thing I used for it was PHP’s output buffering to control output and allow me to define “blocks” of content, then render them at a later point in their proper location. To this end, I created some helper methods to manage this for me and allow easy creating of named buffers. I got the idea for this from the slots of Symfony’s PHP templating engine.

I have since broken this out of my WordPress theme helper classes into its own class and created a github repo, PHP-BufferManager to allow its use for generic purposes. This is a very simple repo and class. The most common way to use it would be to use $instance->start('name'); to start a buffer named ‘name’ and $instance->end(); to end it, then $instance->get('name'); at a later point to get the string value of the buffer for output or other purposes. A simple example:

Continue reading post "PHP Output Buffer Manager"