Skip to content

111 Recipes

WordPress Plugins

A list of plugins that I use often and that I have grown to trust. The list is a work in progress.

Slugs for the ones available at WordPress:

admin-post-navigation classic-editor disable-comments disable-embeds disable-emojis omni-contact-form query-monitor relevanssi term-management-tools two-factor user-switching

How to delete (empty) the content of a file in Linux

truncate -s 0 filename

What this command does: Truncates filename to a size of zero.

Documentation: manpages.debian.org/unstable/coreutils/truncate.1.en

How to auto-renew Let’s Encrypt certificates in Debian 10

If Certbot is installed, renewal of certificates should be already automated and there is no need to do anything else:

The Debian Certbot package installs a systemd timer which runs every 12 hours and calls a Certbot service. The Certbot service then executes the Certbot command for renewing expiring certificates.

To make sure the certbot timer is running, check the list of active timers:

systemctl list-timers

Or look at the status of the Certbot timer itself:

systemctl status certbot.timer

To see what exactly the Certbot service does:

less /usr/lib/systemd/system/certbot.service

More: Certbot – User Guide

How to remove all CSS classes and IDs from WordPress menu items

add_filter('nav_menu_item_id', '__return_empty_string');
add_filter('nav_menu_css_class', '__return_empty_array');
add_filter('page_css_class', '__return_empty_array');

This will remove all IDs and classes from menu items, including classes for the current item. The current item can still be targeted and styled using the aria-current attribute:

.menu li a[aria-current="page"] {
  color: red;
}

Documentation

How to remove file lines that match a pattern

Using GNU sed:

sed -i '/pattern/d' ./file

To remove the lines and keep a copy of the original:

sed -i.bak '/pattern/d' ./file

Since the pattern is a regular expression, special characters should be escaped. For example, to remove all lines containing example.com:

sed -i '/example\.com/d' ./file

Documentation