Refresh a Metabox in the WordPress Block Editor

The WordPress block editor shows registered metaboxes under the post / page content, but since it does not reload the webpage when saving content, metaboxes are not refreshed or reloaded when you save a draft or publish the post / page.

If your metabox needs to be refreshed, to show the new saved content (like the WPSSO Core or JSM Show Post Metadata plugins, for example), you need to add a change listener in javascript and refresh your metabox (using an ajax call) after the block editor has finished saving the metaboxes.

Continue reading


Conceal Email Address with JavaScript

I wrote this perl script years ago when I needed to include my email address on a webpage, but also conceal it from spam bots and spiders.

#!/usr/bin/perl -w

# /usr/local/bin/esc-mailto.pl
# Conceal email address with javaScript.
# by Jean-Sebastien Morisset (https://surniaulula.com/)

use strict;

my ($email, $text) = @ARGV;
$text = $email if (!$text);

if ($email && $text) {
	my $mailto = "<a href=\"mailto:$email\" class=\"esc-mailto\">$text</a>";
	$mailto =~ s/(.)/sprintf("%%%x", ord($1))/ge;
	print "<script language=\"JavaScript\">document.write(unescape(\"$mailto\"))</script>\n";
} else {
	print "syntax: $0 {email_address} [optional_link_text]\n";
	exit 1;
}

exit 0;

Continue reading