Tag name:self.note

Even more WordPress plugins I've used (but don't currently)

28th June 2022

I've audited again the plugins I've used on this site. I've removed the following, but not because they aren't useful (they are), but because I don't need them right at the moment:

Enhanced Media Library
Originally used to improve the functionally of the Media Library, but since outclassed by the Media Library Assistant".
Custom Post Type UI
Used to prototype the custom taxonomy I use to identify and the photos and images to which I'm the sole copyright owner. Doesn't need to be installed since I copied the taxonomy into my child theme.
Updates API Inspector
Used to get a view on what wordpress does to identify and install updates to plugins and themes. Doesn't need to remain installed once the investigation is completed.

Don't create your own Map class/global in javascript

7th April 2022

In my Domain of the Ancients javascript game I have a class (which, of course, is therefore a global variable) called Map to represent the game map. As it turns out that's a bad idea! There's a perfectly good global object in javascript already called Map and so, of course, my definition ended up replacing that one. As it happens I don't use that object (at least not at the time of writing), but node.js does and it will break12. As my unit tests in my build process use node.js for my unit testing my unit tests broke3. Anyway, to cut the story short, I've renamed my Map class to GameMap.

Footnotes

  1. At least on linux it does
  2. The error message, for reference is TypeError: cache.get is not a function
  3. or, more accurately they broke on Linux. Quite why the unit tests worked on windows is an interesting question I can't answer!

Bookmarks to links

24th October 2021

Over time I've collected a fair number of bookmarks and it's time to move some of them to links on this website of mine. Of course the home page is basically a collection of links, but those are, in general, links I regularly use. In this post I'm going to record the more interesting ones that aren't used regularly enough to make it to the home page.


Fan Fiction
Computing

Setting up a ubuntu for my development enviroment

13th May 2021

So I'm experimenting with a new development environment - this one is a ubuntu 20.04 running inside of Oracle VM Virtual Box. The initial installation was done following the cookbook from Abhishek Prakash.

Initial VM setup

  • Download and install VirtualBox
  • Download the ISO for Ubuntu
  • Start Virtual Box and create a new VM - I specified 4GB memory, 4 processor and approx 60GB Hard Disc
  • Start the VM using the ISO image and complete the Ubuntu installation

Development Environment Setup

  • Install fossil using sudo apt install fossil
  • Install ant using sudo apt install ant
  • Install npm using sudo apt install npm
  • Install php 7.4 using sudo apt install php7.4
  • Create directory for the website development mkdir website
  • Clone the website fossil and open it:
    • fossil clone http://david:password@virtual.internal:7780/website website.fossil
    • cd website
    • fossil open ../website.fossil
  • Install prereq npm packages:
    • sudo npm -g install jshint@2.11
    • sudo npm -g install qunit@2.10
    • sudo npm -g install ajv-cli@4.0
  • Test the build by
    • cd build
    • ant rebuild-all

WordPress setup

  • Install prereqs by sudo apt install apache2 mysql-server libapache2-mod-php php-mysql
  • Configure and enable apache2 by
    • sudo systemctl start apache2
    • sudo systemctl enable apache2
    • sudo ufw allow in "Apache Full"
  • Configure mysql and setup a database for wordpress by
    • sudo mysql_secure_installation
    • sudo mysql -u root -p and enter these commands:
      • CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
      • CREATE USER wordpress IDENTIFIED WITH mysql_native_password BY '12345';
      • GRANT ALL ON wordpress.* TO 'wordpress'@'%';
      • quit
  • Install php extensions used by wordpress using sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
  • Restart apache2 using sudo systemctl restart apache2
  • Install curl using sudo apt install curl
  • Download wordpress using curl -O https://wordpress.org/latest.tar.gz
  • Extract the archive and move under apache:
    • tar -xzvf latest.tar.gz
    • sudo mv wordpress /var/www/html
    • sudo chown -R www-data:www-data /var/www/html/wordpress
    • sudo chmod -R 775 /var/www/html/wordpress
  • Setup the wordpress config:
    • cd /var/www/html/wordpress
    • sudo mv wp-config-sample.php wp-config.php
    • Edit wp-config.php to setup the credentials for the database
  • Setup the apache2 config for wordpress:
    • sudo nano /etc/apache2/sites-available/wordpress.conf
    • Make the contents to these lines:
      <Directory /var/www/html>
              Options Indexes FollowSymLinks MultiViews
              AllowOverride All
              Require all granted
      </Directory>
      <VirtualHost *:80>
              ServerName wordpress
              ServerAdmin webmaster@localhost
              DocumentRoot /var/www/html/wordpress
              ErrorLog ${APACHE_LOG_DIR}/error.log
              CustomLog ${APACHE_LOG_DIR}/access.log combined
      </VirtualHost>
      
    • Check the config via: apache2ctl -t
    • Enable it with sudo a2ensite wordpress
    • Disable the default site with sudo a2dissite 000-default
    • Activate the new apache2 configuration with sudo systemctl restart apache2
  • Complete the wordpress install by browsing the image's website

phpMyAdmin installation

  • Install phpmyadmin via sudo apt install phpmyadmin
  • You may need to enable the apache2 conf via:
    • sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
    • sudo a2enconf phpmyadmin
    • udo systemctl reload apache2

Yet more wordpress plugins I've uninstalled but want to keep a record of

7th February 2021

I've recently done another audit of the plugins used on this site. This was in response to the Media Library insisting that it couldn't update the metadata for media in the media library because it already existed in the library. To track this down I ended up doing a review of the media related plugins. The ones I've uninstalled are:

Bulk Change Media Author Plugin
Allowed me to fix up the author field on multiple media items. I'm now less concerned about this and hence no longer need this
Enable Media Replace
Having sorted out the correct directory structure for my plugins and themes I no longer need this plugin
Phoenix Media Rename
As with the previous plugin, sorting out the directory structure means I no longer need this plugin

Enabling updates for self-hosted WordPress themes and updates

30th January 2021

I recently experimented with changing my themes and plugins to support self-hosted updates. For plugins this was relatively straight-forward once I'd found two articles, one by Misha Rudrastyh, which got me to adjust the contents of the zip files down one level (which allows WordPress to understand that the new zip file being uploaded is a replacement/update for a plugin that is already installed) and gave the basics of the self-hosted update process1, including hosting a file that describes the update along side the zip file that is the actual update. The second article by Paul Biron showed what the current version of WordPress is expecting in the php code for plugins

However those articles don't talk about themes that much. To be fair the process for themes is very similar2. However the expection of the WordPress code is different to that for plugins, so as a record here's my code:

function ningxia_check_for_update( $slug ) {
 $info = ningxia_get_remote_update_info( $slug );
 if ( false == $info ) {
  return false;
 }
 if ( version_compare( '@@@VERSION@@@', $info['version'], ' $slug,
    'new_version'   => $info['version'],
    'url'           => $info['homepage'],
    'package'       => $info['download_link'],
    'icons'         => array(),
    'banners'       => array(),
    'banners_rtl'   => array(),
    'tested'        => '',
    'requires_php'  => '',
    'compatability' => new StdClass()
  );
  return $update;
 } else {
  return false;
 }
}

function ningxia_pre_set_site_transient_update_themes( $transient ) {
 // Check for update
 $themeslug = 'Ningxia';
 $update = ningxia_check_for_update( $themeslug );
 if ( $update ) {
  $transient->response[$themeslug] = $update;
 }
 return $transient;
}
add_filter( 'pre_set_site_transient_update_themes', 'ningxia_pre_set_site_transient_update_themes' );

My build process modifies the @@@VERSION@@@ string into the current version number for the build being created (for example, 3.80.1) whereas the $info[['version']] comes from the json that been retrieved from the self-hosting site.


Last updated: May 30, 2021 at 9:36 am

Footnotes

  1. Though I did have to adjust the logic slightly - when you detect that the filter call is not for the current plugin you need to return the current value of first parameter and not just return false
  2. Though the articles I've read suggest that there could be differences for multi-site setups - as this site is not a multi-site setup, I've yet to test how well this description works for that kind of setup

Fixing the Simply Static plugin

18th November 2020

After updating my Ubuntu system to 20.04, I discovered that my method for generating the static version of the site no longer works. It turns out that the Simply Static plugin has a hidden dependency on PHP 7.2 (and upgrading Ubuntu from 18.04 to 20.04 incidently updates the PHP level from 7.2 to 7.4).

After doing some digging I discovered that the Simply Static plugin has an included library called PhpSimpleHtmlDom and the version in the plugin (1.5) is the culprit, I downloaded a more recent version of that library from github and replaced the version of the library with that level and (after a minor hack to change the namespace of the library to match the old namespace being used), Simply Static is now working again.

Hopefully, at some point, the author of the plugin will update it and I won't need the hack. That said the plugin has not been updated for a few years so may now be abandoned. If so I'll probably have to change the infrastructure that builds the static version of the website...

My thanks to Github user caophihung94 for providing a newer version of the PhpSimpleHtmlDom library

WordPress plugins I have used but are now uninstalled (but want to keep a record of)

19th May 2020

I have used (indeed am still using) a number of wordpress plugins. I have actually written quite a few myself as well as several others. There are a few I've used in the past and may well use again, but are currently uninstalled.

They are:

Merge + Minify + Refresh
Used to minimise the size of the css and javascript sent out by wordpress when delivering pages. Not currently simply because it seriously interferes with debugging the javascript!
WP Content Security Policy Plugin
Used to play with the content security policy that allows cautious browsers (and the server) to manage the javascript being used. I did use this to clean up the delivery, but couldn't get to a really clean content policy. I'd still like to do that, but it's not so trivial for the this site (from memory it's mostly the theme that causes trouble).
WP Super Cache
used when the site on dreamhost was an actual wordpress installation to reduce the server load. Since the dreamhost is now just a static version of the site I don't need it there and don't use on the version on my local network since the caching gets in the way of my testing.
WP-DBManager
I have used this to explore the wordpress database. I don't currently need to do this, but would use it if I needed to
WP-RSSImport
Used to query RSS feeds - As I described on the affected page I used to follow a bunch of RSS feeds, but no longer do so (and it's less useful for this static version of the site anyway).