Skip to content

Instantly share code, notes, and snippets.


thisbit thisbit

View GitHub Profile
thisbit / wp_db_cleanup.sql
Last active Aug 10, 2020
wp database cleanup and optimization
View wp_db_cleanup.sql
-- This list of sql commands cleans and optimized a wordpress database, good for speed and functionality in general
-- Remember in each query to replace table prefix with the one you are using
-- Remove post revisions
DELETE FROM wp_posts WHERE post_type = "revision";
-- Remove comments marked as spam
DELETE FROM wp_comments WHERE comment_approved = 'spam';
-- Remove unapproved comments
DELETE from wp_comments WHERE comment_approved = '0';
thisbit / copy-current-url.html
Created Jan 17, 2021
copy current url link
View copy-current-url.html
<!doctype html>
function Copy() {
var Url = document.getElementById("url");
Url.innerHTML = window.location.href;
View wp img alt always filled in
function myprefix_get_attachment_alt( $attachment_ID ) {
// Get ALT
$thumb_alt = get_post_meta( $attachment_ID, '_wp_attachment_image_alt', true );
// No ALT supplied get attachment info
if ( empty( $thumb_alt ) )
$attachment = get_post( $attachment_ID );
View list_of_documents_from_attatchment_post_type.php
// work in progress
// WP php script
// create a list of direct links to files via atattchment post type
// manage documents with media library
// have the documents appear in search results via attatchment post type
// made to work with because it has a more user friendly UI for handling media organisation AND it uses simple taxonomy rather then some similar, maybe better plugins
// If one wants to use it without the plugin uncomment the following block in order to create taxonomies for attatchment post type, and modify the args accordingly
thisbit /
Created Dec 7, 2021
A simple script for image optimization using FFMPEG (read the comment)
echo "WARNING: run this in the folder that contains images"
read -p "# IMAGE FILETYPE (type number):
(1) jpg
(2) png
(3) tif
(4) all (WARN: works only on raster images)
: " format
thisbit / hd-just-in-time-css.php
Created Jan 12, 2022 — forked from wpmark/hd-just-in-time-css.php
A plugin to provide Just in Time CSS for WordPress blocks
View hd-just-in-time-css.php
Plugin Name: Just in Time CSS
Plugin URI:
Description: A plugin from Highrise Digital to provide just in time CSS functionality.
Version: 1.0
License: GPL-2.0+
Author: Highrise Digital Ltd
Author URI:
Text domain: hd-just-in-time-css
thisbit / hide_gutenberg_for_nonadmins.php
Created Jan 12, 2022
Hide content field in post, or hide gutenberg from non admins
View hide_gutenberg_for_nonadmins.php
// this snippet extends the acf ability to hide content field with user based condition
// usecase: if a layout of posts_type is built with gutenberg,
// but one wants editor user group to not touch it while being able to inpt data via ACF fields
// use this in conjunction with acf shortcodes in the gutenberg layout
// this way admin can adapt and change layouts with ease making sure edtors do not interact with layouts
function thisbit_remove_post_type_support() {
thisbit / random_image_hero.php
Last active Feb 4, 2022
Random image header with Generatepress Premium and ACF free or ACF PRO
View random_image_hero.php
// Set the options page (Depends on ACF Pro)
if( function_exists('acf_add_options_page') ) {
'page_title' => 'Home Page Hero Settings',
'menu_title' => 'Home Hero',
'menu_slug' => 'home-hero-settings',
'capability' => 'edit_posts',
thisbit / gp-footer-bottom.css
Created Jan 18, 2022
fit generatepress footer to bottom
View gp-footer-bottom.css
View prevent_essential_plugin_deactivate.php
// best put in theme that depends on certain plugins
add_filter( 'plugin_action_links', 'disable_plugin_deactivation', 10, 4 );
function disable_plugin_deactivation( $actions, $plugin_file, $plugin_data, $context ) {
if ( array_key_exists( 'deactivate', $actions ) && in_array( $plugin_file, array(
unset( $actions['deactivate'] );