Just a few brief notes on the basics. It is assumed you are familier with Linux, PHP, WordPress, etc, and just want some additional information.
Ubuntu 22.04 Find Files
Find a file find ./ -name “file_to_find.txt” 2>&1 | grep -v “Permission denied” Find In Files (File containing text), recursively from current folder grep -r “text_to_search_for” .
A Nightmare called Afrihost
And now for something completely different….. I just want to fill you in on what a rip off Afrihost is, and how they are either the most incompetant service provider on the planet, or as corrupt and crooked a company as you can get. Or perhaps everyone at Afrihost is simply dumb as nails…. who…
Using AJAX in WordPress
In the constructor of your PHP class add the following add_action(‘wp_ajax_send_email_test’,array($this,’send_email_test’)); add_action(‘wp_ajax_nopriv_send_email_test’,array($this,’send_email_test’)); In your enqueue function add the localize script function so you have a variable to use in the js file to call admin-ajax.php wp_enqueue_script(‘traffic-report’, ‘/js/myjsfile.js’, array(‘jquery’), ‘3.0’); wp_localize_script(‘traffic-report’, ‘script_vars’,array( ‘AJAXurl’ => admin_url( ‘admin-ajax.php’ ) ) ); Then add the callback functions to the…
Creating a WordPress Class with Backend and Frontend functionality
Firstly, a bare bones PHP class. Add this in it’s own file, eg mynewclass.php, and include it in functions.php <?php class MyNewClassName { public function __construct() { } } $mynewclass=new MyNewClassName(); ?> Now a slightly more sophisticated one to add an admin menu item and page, with page tabs. <?php class MyNewClassName { protected $admin_page_url;…
Read More Creating a WordPress Class with Backend and Frontend functionality
Ubuntu 22.04 Fix Broken Pipe on apt-get
apt-get -o DPkg::Options::=”–force-overwrite” install <package name> This will force an overwrite.
Ubuntu 20.04 Node Server on localhost with SSL
To get SSL on your localhost for testing purposes you will need a SSL key and certificate generated. I do the following in a certs directory to call up later in the node server app. openssl genrsa -des3 -out rootCA.key 2048 openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem Import the…
Installing Node on Ubuntu 20.04
Step 1 Do the usual first, i.e. sudo apt update and sudo apt upgrade Step 2 Make sure npm is up to date as well npm cache clean -f npm install -g n #if not already installed sudo n stable It might take some doing to achieve the above, as I had a few issues…
SQL to extract order report
SELECT pm.meta_value AS city,p.ID as order_id,p.post_excerpt as customer_note,p.post_date as order_date,pm2.meta_value as suburb,pm3.meta_value as customer_id, pm4.meta_value as sender_email, pm5.meta_value as sender_firstname, pm6.meta_value as sender_lastname FROM wp_posts p LEFT JOIN wp_postmeta pm ON p.ID = pm.post_id LEFT JOIN wp_postmeta pm2 ON p.ID = pm2.post_id LEFT JOIN wp_postmeta pm3 ON p.ID = pm3.post_id LEFT JOIN wp_postmeta pm4 ON…
Ubuntu 18.04 Disable Auto Time Updates
Firstly disable automatic times timedatectl set-ntp off Then simple set the time manualy, or the time itself will still automatically update. sudo date –set “21 Dec 2020 14:42:00” To re-enable automatic date/time updates use timedatectl set-ntp on To check the status use timedatectl status You should see something like below. the three ‘no’ mean it’s…
Cleaning Ubuntu boot partition
Often the Ubuntu upgrades will fail fue to a no space error. The only solution is to remove old kernels manually. The first step is to show which kernel you are currently running, as you do not want to delete this one. sudo su uname -r So change to the boot directory for simplicity and…
WP REST with JWT
Using the WordPress REST API with JWT authentication Step 1. Install this plugin => https://wordpress.org/plugins/advanced-access-manager/. The free version will suffice. This goes on the site you will be xtracting data from. The REST API must be enabled in the WordPress settings. Step 2. Configure the plugin and on it’s Settings tab add the Secret as…
WordPress Security
This applies to self-managed Apache2 servers. Shared servers require different permissions, for example wp-config : set that file’s permissions to 440 or 400. Site Lockdown File permissions to lock down website, from the websites home folder. Do this from the root directory for example and you will break your server. chown root:root -R * find…
SSL Localhost
To enable ssl on a localhost website, and stop Chrome from showing is as “unsafe” …. Pertains to Ubuntu 18.04 Bionic, and running Apache 2.4.29 Create localhost.cnf HOME = . RANDFILE = $ENV::HOME/.rnd oid_section = new_oids [ new_oids ] tsa_policy1 = 1.2.3.4.1 tsa_policy2 = 1.2.3.4.5.6 tsa_policy3 = 1.2.3.4.5.7 [ ca ] default_ca = CA_default #…
WordPress Basic Plugin
Below is a very simple working example of a plugin. Create a directory in your plugins directory, create a php file and copy the below into it. Then from the wordpress plugins menu simply activate it. Just know that this plugin does absolutely nothing other than to show the basic setup, including public and protected…
Ubuntu Must Have Apps
As Open Office is part of the standard Ubuntu install, like other software installed as default, I have not listed it. There are a number of must have applications needed to get the most out of Uubuntu 18.04, but first thing to do is change the deskop. Ubuntu’s standard is way too slow and reminds…
Linux miscellaneous
Pertains mostly to Ubuntu 18.04.4 and Apache 2.4.29 Get Ubuntu version lsb_release -a Get Apache version apache2 -v Get MySql version mysql –version Find Files and hide all permission denied messages find /start_directory -name filename 2>/dev/null Copy file with ssh from server to localhost scp user@server:/directory_from/filename.txt /local_directory/ Copy file from localhost to server with ssh…
Exporting/Importing Woocommerce Orders with SQL 2020
Covers WordPress version 5.3.2 No matter how you use the SQL, be it on the command line, PhpMyAdmin or PHP, These are just the SQL commands needed. There are 4 tables invlovled not counting the variable product data. I’ll be adding that as soon as a get a free moment. wp_postswp_postmetawp_woocommerce_order_itemswp_woocommerce_order_itemmeta wp_posts are where the…
Read More Exporting/Importing Woocommerce Orders with SQL 2020
Sharing a Viynl Cutter over the Network in Linux
This setup works for a cheap Chinese no name brand Cutting Plotter I use. On the host PC add a new printer and set the printer model to “Raw Queue” Set the device URI to, for example, serial:/dev/ttyUSB0?baud=9600. This assumes the servial device is attached to USB port 0. Make sure it is shared. On…
Setting up Inkscape for use with a Vinyl Cutter using Inkcut
Step 1 Download and install the InkCut Extension from the InkCut sourceforge page. Step 2 Install the following linux libraries : sudo apt-get install python-gtk2-dev sudo apt-get install python-cups sudo apt-get install python-serial Using InkCut to perform the cut Step 1 Select the objects you wish to cut Step 2 Ungroup the selected objects Step…
Read More Setting up Inkscape for use with a Vinyl Cutter using Inkcut
Raspberry PI Setup
use GParted to format SD to win32. sudo dd bs=4M status=progress if=~/Downloads/2018-06-27-raspbian-stretch.img of=/dev/sdc; sync NB note /dev/sdc, not /dev/sdb1. i.e. Must point to physical device, not partition. Edit config.txt on the SD to set hdmi hot plug support. put sd in the pi, plug in kb and monitor and boot. after install and upgrade process…