Skip to content

Instantly share code, notes, and snippets.

@AWOL-TECH
AWOL-TECH / awol_modify_author_link.php
Created October 4, 2023 15:57
small WordPress function that will change the Author URL displayed in posts to something else. Can be set to nearly any wordpress constant or filter that returns a URL.
@AWOL-TECH
AWOL-TECH / awol-modify-blog-post-title.php
Created October 3, 2023 18:09
Code snippet to convert the h2 tag of a blog post (single) to h1 for better SEO. For some reason many themes are outputting H2 tags which will be flagged by SEO tools and such. This code will search for an h2 tag in your single post with the specified class and switch it over to an h1.
/**
* functions.php or main plugin file
**/
function awol_enqueue_modify_title_script() {
if (is_single()) {
wp_enqueue_script('modify-title', get_stylesheet_directory_uri() . '/js/awol-modify-title.js', array('jquery'), '1.0', true);
}
}
@AWOL-TECH
AWOL-TECH / switch_case_if_else.php
Created September 8, 2023 11:40
Created as a funny response to a programmer joke meme about using switch case instead of ifelse... however this code turns out to work and could be useful in some weird usecase so here it is.
<?php
$switch_case = 'something'; // define anything as your variable, doesn't have to be a string can be any type
if (isset($switch_case)) {
switch ($switch_case) {
case 'true':
echo "switch_case is true";
break;
case 'false':
@AWOL-TECH
AWOL-TECH / forminator_awol_submission_without_notification.php
Created September 1, 2023 13:26
WordPress plugin code snippet for forminator that sends email notifications to one or multiple recipients when a form is submitted without email notifications configured. It includes submission details and a link to review the form's email routing configuration.
<?php
/**
*
* Author: AWOL-TECH
* URL: https://gist.github.com/AWOL-TECH
* URL: https://github.com/AWOL-TECH
*
* Credit: Forminator support
*
* Function to extend Forminator functionality
@AWOL-TECH
AWOL-TECH / change-line-endings.sh
Created July 21, 2023 14:10
Change Line endings from dos to unix (CRLF to LF) with Git for Windows bash
# AWOL-TECH
#
# With Git for windows installed (https://gitforwindows.org/) navigate to your desired folder via explorer
# now open a Git Bash window from the right click context
#
# Now you can enter the line below to batch convert your files from CRLF to LF using dos2unix
# Dos2unix appears to be installed by default with git for windows.
#
# Have fun
@AWOL-TECH
AWOL-TECH / optimise all jpegs recursively
Created August 17, 2018 15:02
Batch processing JPEGs with jpegoptim - Make sure you have already navigated to the folder you want otherwise you could end up scanning and optimising your full drive
find -type f -name "*.jp*g" -exec jpegoptim --strip-all --force -t {} \;