Skip to content

Instantly share code, notes, and snippets.

@christianwach
christianwach / update-legacy-multisite.sh
Last active October 30, 2025 13:59
Remove "ms-files.php" dependency from a WordPress Multi-Network install.
#!/bin/sh
# ----------------------------------------------------------------------------------------
# Title: Remove "ms-files.php" dependency.
# Description: Removes the "ms-files.php" dependency from a WordPress Multi-Network install.
# This script will also work on a single WordPress Multisite instance because
# in that case there will only be one record in the `wp_sites` table.
# Author: Christian Wach <[email protected]>
# Props: Austin Ginder <https://anchor.host/removing-legacy-ms-files-php-from-multisite/>
# Version: 1.0.0
# Gist URL: https://gist.github.com/christianwach/1adc33da22515471c749f5ba55e8726a
@christianwach
christianwach / acfe-latest-acf-fix.php
Last active November 7, 2024 15:22
Temporary fix for AJAX selectors in ACF 6.3.10
<?php
/**
* ACFE Fix AJAX selectors
*
* Plugin Name: ACFE Fix AJAX selectors
* Description: Fixes AJAX selectors with ACF 6.3.10. Do not deacticate or delete.
* Plugin URI: https://haystack.co.uk
* Version: 1.0.0
* Author: Christian Wach
* Author URI: https://haystack.co.uk
@christianwach
christianwach / bp-hide-name-field.php
Last active September 18, 2025 09:21
Hides the default Name field on BuddyPress Registration form and Profile Edit screens.
<?php
/**
* BP Hide Name Field
*
* Plugin Name: BP Hide Name Field
* Description: Hides the default Name field on BuddyPress Registration form and Profile Edit screens.
* Plugin URI: https://gist.github.com/christianwach/06d878edc277ce1ca8a7e59a82052744
* Version: 1.1.1
* Author: Christian Wach
* Author URI: https://github.com/christianwach
@christianwach
christianwach / suppress-admin-notices.php
Last active August 10, 2025 14:26
A WordPress plugin that suppresses nagging admin notices from various plugins.
<?php
/**
* Suppress Admin Notices
*
* Plugin Name: Suppress Admin Notices
* Description: Stop that damn nagging!
* Version: 1.0.2
* Plugin URI: https://gist.github.com/christianwach/c30d2972d1807ad9a04dff1db971b7cd
* Author: Christian Wach
* Author URI: https://haystack.co.uk
@ipokkel
ipokkel / pmpro-restrict-all-cpt-posts.php
Last active April 7, 2025 08:51
Restrict all posts for a custom post type (CPT) automatically with PMPro but allow administrators access to the CPT #cpt #pmpro-cpt
<?php
/**
* This recipe restricts all content of a Custom Post Type (CPT)
* to members only.
*
* This recipe assumes your CPT name is "recipes".
* You should replace this with your CPT name for the filter name
* and the $my_cpt variable's value in the hook name on line 71,
* e.g. pmpro_has_membership_access_filter_cpt-name,
* and 74, e.g. $my_cpt = 'cpt-name'.
<?php
/**
* CiviCRM Multisite Domain functionality.
*
* @see https://gist.github.com/christianwach/5ca120670152df3dbfb8d3ca42079a96
*/
/**
* Define CiviCRM Multisite Domain constants and settings.
*
@tessak22
tessak22 / functions.php
Created March 12, 2019 12:06
Hero Gutenberg Block using Advanced Custom Fields 5.8 Pro
/**
* Register hero block
*/
add_action('acf/init', 'hero');
function hero() {
// check function exists
if( function_exists('acf_register_block') ) {
// register a hero block
@dvlop
dvlop / gist:fca36213ad6237891609e1e038a3bbc1
Last active September 13, 2025 15:16 — forked from allthingsdem/gist:63b3223a7d14ac1f2457
My long list of bad bots to block in htaccess, ready to copy and paste!
# Start Bad Bot Prevention
<IfModule mod_setenvif.c>
# SetEnvIfNoCase User-Agent ^$ bad_bot
SetEnvIfNoCase User-Agent "^12soso.*" bad_bot
SetEnvIfNoCase User-Agent "^192.comAgent.*" bad_bot
SetEnvIfNoCase User-Agent "^1Noonbot.*" bad_bot
SetEnvIfNoCase User-Agent "^1on1searchBot.*" bad_bot
SetEnvIfNoCase User-Agent "^3D_SEARCH.*" bad_bot
SetEnvIfNoCase User-Agent "^3DE_SEARCH2.*" bad_bot
SetEnvIfNoCase User-Agent "^3GSE.*" bad_bot
@xurizaemon
xurizaemon / strip-triggers.sh
Created March 16, 2017 18:57
MySQL - strip trigger owners from a .sql dump
perl -pi -e 's#\/\*\!5001[7|3].*?`[^\*]*\*\/##g' dumpfile.sql
@colemanw
colemanw / gitpr
Last active October 14, 2016 13:10
GitPR script
#!/bin/bash
# start at top directory if we're not already there
pushd "$(git rev-parse --show-toplevel)" > /dev/null
# run style checker
civilint
if [[ $? == 1 ]]
then
echo "PR aborted"