Category: Content Management Solutions

Contact Form 7 is a WordPress plugin that allows you to add forms to pages. A downside to using it is that out of the box it adds the Contact Form 7 JavaScript and CSS to every page even if there is no contact form there. It does the same with the reCaptcha assets if you have that enabled. This results in unnecessary page bloat and adds the reCaptcha badge to the bottom right corner of every page. This is the code I have used to hide it:

 * Dequeue the Contact Form 7 and reCaptcha assets on pages without a contact form.
function restrict_contactform7_assets() {
    // Add/edit the page numbers to match your site.
    if(!is_page(10) && !is_page(240)) {
add_action( 'wp_enqueue_scripts', 'restrict_contactform7_assets' );

You can get the page id number from the address bar when you open it for editing in the admin.

I’ve been using the Members plugin on a client’s WordPress site to define custom roles. It’s been working great except for one thing; the authors dropdown on the Gutenberg document editor does not show anyone who has a custom role.

I had a look around and found several posts that suggested using the the wp_dropdown_users_args filter which worked for the Quick Edit author dropdown but not for the main document editor. In fact I couldn’t find anybody with a solution for that since Gutenberg was introduced. I managed to suss it out for myself and thought I’d share the code for anyone stuck in a similar situation. The following goes inside functions.php. Make sure to replace “custom_role_one” and “custom_role_two” with your actual role names.

// Handles the Quick Edit authors dropdown
function display_custom_roles_in_author_dropdown($query_args, $r)
	if (isset($r['name']) && ($r['name'] === 'post_author_override' || $r['name'] === 'post_author')) {
		if (isset($query_args['who'])) {
        $query_args['role__in'] = ['administrator', 'author', 'editor', 'custom_role_one', 'custom_role_two'];
    return $query_args;
add_filter('wp_dropdown_users_args', 'display_custom_roles_in_author_dropdown', 10, 2);

// Handles the Gutenberg document editor authors dropdown
function display_custom_roles_in_gutenberg_author_dropdown($prepared_args, $request = null)
	if (isset($prepared_args['who']) && $prepared_args['who'] === 'authors') {
		$prepared_args['role__in'] = ['administrator', 'author', 'editor', 'custom_role_one', 'custom_role_two'];
    return $prepared_args;
add_filter('rest_user_query', 'display_custom_roles_in_gutenberg_author_dropdown', 10, 2);

Today is a double celebration; my web development company Nine Three Limited celebrated it’s 9th year of business on May 1st 2018 and my shiny new personal website is finally live!  My personal site fell into disuse over the last few years as my life took a big downward turn and I didn’t feel like sharing those dark days with the world but I have been fighting hard to overcome the challenges and the latest part of that journey involves me looking for a new job and I figure nobody would want to hire a web dev whose personal website was so outdated! ?

The new site is fully responsive with a customised Bootstrap 4 layout.  I wrote a new WordPress plugin which uses the Node-Vibrant library to pick colors from the background images so I could have a dynamic theme engine which is something I’ve wanted to do for ages.  I’m very pleased with the result.  The theme selection is stored for one hour and then a new random one is picked.  You can also use the button in the bottom right to pick one sooner than that.  Another big change is that I have reworked the curriculum vitae page to separate my past “jobs” from my past “projects” as I found this was confusing recruiters.  I’ve covered a lot of work projects over the last 15 years but most of them have gone offline so now the new site is complete I can start going back over the projects and uploading screenshots for them. If you click on a project then it will expand so you can read more about it.  The data for each is fetched from the backend via Ajax so the initial page loads quickly and only spends time downloading the data for the projects you are interested in.

I still have to setup the old personal projects page for things like the Stargate Simulator and the Blade Runner Game Installer but those will come with time. Nothing has been lost, I just need to port them over to the new site format.  If you need any of the old projects before I have had time to put them live then drop a comment on this post and I’ll do what I can to help you out.

I am back.

This had me banging my head for ages today. On the design I am implementing there needs to be both a “Best Seller” panel and a “Latest Products”. There is no latest product module as default and I refuse to pay for a third party one when I can just make my own. The problem I ran into was that no matter what I did the internal products array would only ever show four products. This was driving me crazy until I finally took a step back and thought about what was happening. I think the home/welcome page is actually using its own fake category called “Featured Products”. So even though my module was supposed to pull the entire product list it was only actually pulling items from the featured products category.

In the end I decided to ditch my “Latest Products” module and just use the “Featured Products” one instead. That led me to the next problem, how do I change which products are set as featured? Turns out it is well easy. Just head into the admin section and then on the main menu Catalog->Categories. At the bottom of the page you can add and remove products from the featured category. That mostly handles my problem, the final step was to modify the featured_products template file and impose a static limit to the number of items visible. The most we want to show are 4 as more will break the tile wrapping we’re using for displaying them.

b2evolution uses a base tag to help with its template system. This is fine in modern browsers but depending on how the base tag is written IE6 may refuse to show the site at all, even going to the point of giving the user a popup warning dialogue. The fix is quite simple and I’ve implemented it in the past for both Joomla and CMS Made Simple. Now it’s time for the b2evolution version.

Continue reading “b2evolution Base Tag Issue”

Yet another opensource system that makes use of the HTML base tag as a hard-coded feature. Why is that a problem? Well if you use SWF Object to output the relevent HTML code necessary to display a Adobe SWF file on your page then you’ll be in for a surprise on IE6. You will get a popup prompt that states “Operation Aborted” for each SWF file on the page. Then once the page actually loads none of the SWF content is visible. Sucks. They detail a simple fix in the FAQ that uses IE conditional tags to add the required closing base tag which doesn’t solve the problem here. Their solution assumes you don’t need a self closing tag as default, for when it is not IE as the browser. That in turn leads to XHTML validation errors. The cheat is to write the conditional in PHP instead.

Continue reading “CMS Made Simple Base Tag Issue”

I’m really having a love hate relationship with Joomla. The latest bump in the road came when I tried to change a Global Config setting. It told me:

JFTP::store: Bad response Warning! – Failed to move file

There were loads of other errors depending on what I did but they all started out with various JFTP messages. The outcome was that I could not change the config file with the admin interface and I could not upload any files at all via the Media Manager or the JCE Image Uploader. After getting very angry I finally worked it out. In the config file are three paths:

var $log_path = ‘/home/user_name/public_html/logs’;
var $tmp_path = ‘/home/user_name/public_html/tmp’;
var $ftp_root = ‘/home/user_name/public_html’;

The first thing was that my server host had not created a temp directory for me. I uploaded a file with phpinfo in it and saw that I they’d set it to be /home/user_name/wwwtmp but they hadn’t actually created that directory or set permissions for it (since it didn’t exist). I did both of those myself. The next step was to set the right permissions on the /home/user_name/public_html/tmp directory. The final task was to work out that the joomla FTP system is odd! To make it work I had to change the paths above to:

var $log_path = ‘/home/user_name/public_html/logs’;
var $tmp_path = ‘/home/user_name/public_html/tmp’;
var $ftp_root = ‘/public_html’;

Basically the rest of the system uses the full path while the ftp_root variable has to be a partial path. Joomla, I love you but if you were a person I would of broke your nose by now Yell

I’ve been putting the finishing touches on a new Joomla 1.5 install. I decided to switch from the default TinyMCE text editor and start using the JCE one instead. After customising the menu I reached my final task; removing most of the options in the Format drop down box. That drop down lets you pick Paragraph, Heading 1, Heading 2 and so on. After reading all the docs, scouring both the JCE and TinyMCE forums, rooting through the MySQL database, general searching and then performing the usual techy head2desk incantations I couldn’t find the answer. In my searches I found alot of other people asking the same question but with no answer. Turns out it’s easy.

Open up /plugins/editors/jce.php and find this line (#86 for me):

$param[‘theme_advanced_blockformats’] = “p,div,h1,h2,h3,h4,h5,h6,blockquote,dt,dd,code,samp”;

Just remove the ones you don’t want and save the file. Here’s my pruned version:

$param[‘theme_advanced_blockformats’] = “p,h1,h2,h3,h4”;

Adding extra ones is another matter which luckily I don’t have to worry about Wink

For the past few months I’ve been using Unobtrusive Flash Objects for writing the code required to display Flash in a HTML page. I’ve never had a problem with it until I decided to use it on my own site. The wiki side worked straight away but the blog consistently died in Internet Explorer 6. It worked in Internet Explorer 7, Firefox 2 and Opera 9. The loading bar would show stuff was going on although nothing would be displayed and then I would get an “Operation Aborted” popup box. After about an hour of checking my code character by character and googling all the terms I thought would be relevant I found the solution on the UFO home page. If you scroll way down the page there is a Q and A for “How do I prevent Internet Explorer from crashing when a <base> tag is defined?”. That provides the fix. Phew, panic over ?