Skip to content

Instantly share code, notes, and snippets.

@machouinard
machouinard / wp-delete-trackbacks-pingbacks.php
Created April 9, 2022 07:08 — forked from kasparsd/wp-delete-trackbacks-pingbacks.php
Delete all WordPress trackbacks and pingbacks
<?php
$comments = get_comments( array(
'type' => 'pings',
'fields' => 'ids',
) );
foreach ( $comments as $no => $comment_id ) {
wp_delete_comment( $comment_id, true );
}
@machouinard
machouinard / budypress-xprofile-add-states.php
Created September 28, 2021 01:21 — forked from Garconis/budypress-xprofile-add-states.php
BuddyPress | xprofile add states as user dropdown field
<?php
/*
If you are using BP 2.1+, this will insert a State selectbox.
Add the function to bp-custom.php and then visit .../wp-admin/users.php?page=bp-profile-setup
Remove this function after the field is created.
*/
function bp_add_custom_state_list() {
@machouinard
machouinard / blocks.js
Created February 27, 2021 21:44
Disable that damn Welcome to the block editor message.
import { registerPlugin } from '@wordpress/plugins';
import { select, dispatch } from '@wordpress/data';
registerPlugin( 'disable-welcome-guide', {
render: function () {
return select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) &&
dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' );
},
} );
@machouinard
machouinard / .tmux.conf
Created February 18, 2021 00:54
Tmux Config
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# split panes using \ and - (need to escape \)
bind \ split-window -h
bind - split-window -v
unbind '"'
unbind %
@machouinard
machouinard / fd-clear-elementor-cache.php
Created September 11, 2020 06:59 — forked from heyfletch/fd-clear-elementor-cache.php
Clear Elementor Cache After a WP Migrate DB Pro Migration - Must Use Plugin (mu-plugins)
<?php
/*
Plugin Name: FD Clear Elementor Cache After WP Migrate DB Migration
Plugin URI: https://gist.github.com/heyfletch/769c64ad1fab8679032b076433afafd1
Description: Deletes CSS in uploads/elementor/css, which auto-regenerates on pageload. This clears the cache locally and remotely. Must-use plugin (mu-plugin).
Author: Fletcher Digital
Version: 0.1.1
Author URI: https://fletcherdigital.com
*/
@machouinard
machouinard / Makefile
Created July 13, 2020 17:03
Convert single or bulk files from markdown to other formats using Pandoc.
SRC := $(wildcard *.md)
OUTPUT=\
$(SRC:.md=.html) \
$(SRC:.md=.pdf) \
$(SRC:.md=.docx) \
$(SRC:.md=.rtf) \
PDFOUT=\
$(SRC:.md=.pdf)\
@machouinard
machouinard / gist:83d5101f755cefc361035f531f0326db
Created April 8, 2020 02:55
Simulate click to expose Metar on AWFN plugin
setTimeout( function() {
jQuery('section#metar').trigger('click');
}, 1000);
@machouinard
machouinard / class-mc-login-logo.php
Created December 1, 2019 07:58
Custom WordPress login logo
<?php
namespace Chouinard\Logo;
/**
* Class MCLoginLogo
* @package Chouinard\Logo
*/
class MCLoginLogo {
@machouinard
machouinard / setup-phpunit.sh
Created November 6, 2019 01:22 — forked from keesiemeijer/setup-phpunit.sh
Setup PHPUnit for use in the Local by Flywheel app
#!/usr/bin/env bash
# ===============================================================================
# Script to install PHPUnit in the Local by Flywheel Mac app
# These packages are installed
#
# PHPUnit, curl wget, rsync, git, subversion and composer.
#
# WordPress is installed in the `/tmp/wordpress` directory for use by PHPUnit.
# The WordPress test suite is installed in the `/tmp/wordpress-tests-lib` directory.
@machouinard
machouinard / remove_menu_items.php
Created June 20, 2018 21:22
Remove unwanted menu items from main blog in WP multisite
function remove_menus() {
global $blog_id, $menu;
if ( $blog_id == '1' ) {
$restricted = array( 'Plans', 'Providers' );
end( $menu );