Skip to content

Instantly share code, notes, and snippets.


Decodist decodist

View GitHub Profile
decodist / regex.txt
Last active Jun 24, 2021
Regex to find URLs that include one of multiple strings or words, excluding multiple other strings or words
View regex.txt
decodist / wp-user-login-time.sql
Last active Dec 2, 2020
Find Wordpress users who have logged in at some point, but not within the past year
View wp-user-login-time.sql
SELECT, u.user_login, u.user_email, u.user_registered,
trim( trailing ';}}' from
(LENGTH(um.meta_value) - LOCATE('login',um.meta_value) - 8)
,'%Y-%m-%d') as last_login
FROM wp_users u, wp_usermeta um
View error-output.php
#put these at the top of any PHP file to output server errors
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 'On');
decodist / table-size.sql
Created Sep 10, 2020
List all MySQL tables in size order
View table-size.sql
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;
decodist /
Created Sep 9, 2020
Find size of Wordpress install on Linux
#Show a list of the largest files (change "/wproot" to the actual root folder)
find /wproot -type f -exec du -Sh {} + | sort -rh | head -n 20
#Show size of WP root folder
du -sh /wproot
#Show size of wp-content folder
du -sh /wproot/wp-content
#Show size of uploads folder
decodist / post-author.php
Last active Jul 7, 2020
Add author info to WordPress blog post using a shortcode
View post-author.php
//add any of the following shortcode functions to your theme's functions.php file
//display the author name which is linked to the About page
function author_name_shortcode(){
global $post;
$post_id = $post->ID;
$author = get_the_author($post_id);
$linkedAuthor = "<a href='/about'>".$author."</a>";
return $linkedAuthor;