Author: oacheson

Plugins and Shortcodes

Plugins and shortcodes can extend WordPress’s power markedly. Tons of free, pre-written ones are available at https://wordpress.org/plugins/. The header there says “Browse 60,453 free plugins” which means most every topic is covered, probably many times over.

What if you want to do your own plugins? It turns out that isn’t very difficult and there are many resources to help both getting started and with on-going development activities. Here are a few resources I started with. Note that many of these give code examples which I find very useful for learning anything new.

Some Examples

I followed the first reference to generate a shortcode for the current year, which is 2025 and then branched off from there to generate another for the current date and time: 10 Dec 2025 3:53 UTC. The highlighted items are the results of the shortcodes. Neither of these took any input, but merely returned the appropriate values when invoked.

Current Year:

<?php

/*
Plugin Name:  Salcodes
Version: 1.0
Description: Output the current year in your WordPress site.
Author: Salman Ravoof
Author URI: https://www.salmanravoof.com/
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: salcodes
*/

/**
 * [current_year] returns the Current Year as a 4-digit string.
 * @return string Current Year
*/

add_shortcode( 'current_year', 'salcodes_year' );
function salcodes_init($atts){
 function salcodes_year() {
 return getdate()['year'];
 //return "ollie";
 }
}
add_action('init', 'salcodes_init');

/** Always end your PHP files with this closing tag */
?>

Date-Time Display

<?php
/*
Plugin Name: date-time-display
Description: Displays the date and time of day.
Version: 1.0.1
Author: owa
License: GPL2
 */

/*
 * Shortcode is [date_time_display]
 * returns date string formatted like 17 Feb 2023 14:26 UTC
 * Prefix is dtd
 */

function date_time_display($atts) {
  // format date as 17 Feb 2023 14:26 UTC
  $current_date_time = date('d M Y G:i e');
  //then output it
  return $current_date_time;
}

function dtd_shortcodes_init(){
 add_shortcode('date_time_display', 'date_time_display');
}
add_action('init', 'dtd_shortcodes_init');
?>

User IP and Location

On a closing note, here is a plugin available at the WordPress site here that generates information about the current user. See an example of some of its features in the footer, below.

Leslie Requests – March 4, 2022

Pick from these:

Missouri Botanic Garden – Fall 2021

One of our must-sees every time we visit Gillian & Tim is the Missouri Botanic Garden. This time we got some rather splendid Fall colors, but it’s a beautiful place no matter the season.

Implementing https on site

Implementing SSL security on a website is now quite easy — and free, using the Let’s Encrypt free and automated certificate authority.

The process is well described here which takes you through the setup of the certificate and implementing it on an apache website. It includes setting up auto-renewal, to guarantee fresh certificates at all times.

A final step, forcing all web traffic to the secure (https) server using apache’s redirect (not rewrite) rule is described here.

All in all, the process took no more than a couple of hours, including a few redos along the way with typical first-time mistakes.

 

MOMA – February 2016

Paul and I decided to visit the Museum of Modern Art for our latest photo expedition. This is the first either of us had visited it since its major rebuild a few years ago.

The first exhibit was a major retrospective: Joaquín Torres-García: The Arcadian Modern. Torres-Garcia was an Uruguayan who participated in several of the European early modern avant-garde movements. His long career meant that he participated in a significant number of different movements.

He returned to Uruguay in 1934 where he was continued as a major figure in modern art until his death in 1949.


MOMA’s exhibit description concludes:

Torres-García is one of the most complex and important artists of the first half of the 20th century, and his work opened up transformational paths for modern art on both sides of the Atlantic. His personal involvement with a significant number of early avant-garde movements—from Catalan Noucentismo to Cubism, Ultraism-Vibrationism, and Neo-Plasticism—makes him an unparalleled figure whose work is ripe for a fresh critical reappraisal in the U.S.

The museum is filled with artists from De Koonig to Newman (seen at right), with numbers of famous works from Van Gogh to Matisse to Picasso to Pollack filling several floors of galleries. This was a trip well worth the effort.


It did raise a question in our mind about why the collection seemed to taper off sharply midway through the second half of the 20th century. Did benefactors not collect after 1970 or so? Is there a definitional thing going here? Do we need to go to the Museum of POST-Modern Art to see later works?

No matter, we enjoyed what we saw. 

We then picked a winner for lunch, Joe’s Shanghai Restaurant on 56th Street. Excellent dumplings in a very nice setting.

Some apt-get commands

Ubuntu uses the apt package management system which makes updates and upgrades pretty simple.

When logging on, ubuntu summarizes available updates. Use the following to do the updates:

sudo apt-get upgrade

Note, though:

However, if you want to upgrade, unconcerned of whether software packages will be added or removed to fulfill dependencies, use the ‘dist-upgrade‘ sub command.

Many more apt-get commands are summarized in 25 Useful Basic Commands of APT-GET and APT-CACHE for Package Management.

‘man apt-get‘ or ‘man apt-cache’ are also useful.

NameVirtualHosts

Apache’s NameVirtualHost mechanism allows (among other things) a single numeric ip address to handle multiple domains’ websites. For example, the DNS entries for both this site (home.acheson.org) and another site point to the same numeric ip address. Apache delivers the appropriate content to incoming requests based upon the domain name in the request record.

Setting this up is quite straightforward and is well described in Apache’s documentation: http://httpd.apache.org/docs/2.2/vhosts/examples.html