Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Vary LCP Image Optimizations WordPress Plugin.
*
* @package VaryLcpImageOptimizations
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2023 Google Inc.
*
* @wordpress-plugin
@robwent
robwent / forcing-w3-total-cache-to-clear-parent-category-listing-pages-on-post-save.php
Last active May 13, 2024 13:26
Forcing W3 Total Cache to Clear Parent Category Listing Pages on Post Save
<?php
/**
* Clear Total Cache term listing pages for a post
* @param $post_id
* @param $post
*
* @return void
*/
function rw_clear_total_cache_terms_pages( $post_id, $post ) {
if ( function_exists( 'w3tc_flush_url' ) ) {
@carlodaniele
carlodaniele / edit.js
Created January 2, 2023 16:21
A custom Gutenberg block to add and manage custom meta fields in WordPress
/**
* Retrieves the translation of text.
*
* @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-i18n/
*/
import { __ } from '@wordpress/i18n';
/**
* React hook that is used to mark the block wrapper element.
* It provides all the necessary props like the class name.
@michaelbragg
michaelbragg / acf-validation.php
Last active April 30, 2024 08:21
Hotfix: ACF Block Validation not being checked.
<?php
/**
* Hotfix: ACF Block Validation not being checked.
*
* @version 1.0.0
*
* @author Seriphyn <https://support.advancedcustomfields.com/forums/users/seriphyn/>
* @author Michael Bragg <https://michaelbragg.com> <https://vatu.dev>
* @copyright 2022 Curiosity Stream Inc.
*/
@lennardv2
lennardv2 / 1. Building PHP-MAMP on Apple Silicon M1.md
Last active February 29, 2024 07:57
Native PHP development / MAMP stack on Apple silicon M1

Building the MAMP stack (php, apache & mysql) on Apple Silicon ARM (native)

Update! This tutorial is outdated. Nowadays brew installes m1 binaries just fine. Also use valet: https://laravel.com/docs/9.x/valet. It's 10x easier.

In this tutorial, we'll build the the nescessary packages for ARM via homebrew. After that we'll configure apache2 for using virtual hosts. The native php is ofcourse way faster, see the results of this benchmark below.

TEST NAME SECONDS OP/SEC
@nginx-gists
nginx-gists / ubuntu_install.sh
Last active May 31, 2024 10:15
Automating Installation of WordPress with NGINX Unit on Ubuntu
#!/usr/bin/env bash
if [ "$EUID" -ne 0 ];then
>&2 echo "This script requires root level access to run"
exit 1
fi
if [ -z "${WORDPRESS_DB_PASSWORD}" ]; then
>&2 echo "WORDPRESS_DB_PASSWORD must be set"
>&2 echo "Here is a random one that you can paste:"
@vikytech
vikytech / clean-my-mac.sh
Last active April 30, 2024 08:22
Script to clean the mac Almost like a new one
#!/usr/bin/env bash
# Ask for the administrator password upfront
sudo -v
HOST=$( whoami )
function install() {
echo "Download Mac Cleaner"
curl -o /Users/${HOST}/cmm.sh https://gist.githubusercontent.com/vikytech/f28c5480c1e1d8c2688981803b45a29a/raw/cleaner.sh
echo "Init Mac Cleanup"
#!/bin/sh
# non-interactive kde installer for alpine
# apk add curl && curl -L https://cutt.ly/alpine_kde | sh
echo "I will make Alpine Linux a Desktop Linux.. ."
## Desktop user
@JonTheNiceGuy
JonTheNiceGuy / AAA_Readme for wp-upgrade.sh.md
Created June 5, 2020 07:20
A simple script to upgrade all wordpress components in cron

wp-update.sh

A simple tool to update and upgrade Wordpress components

A few years ago, I hosted my blog on Dreamhost. They've customized something inside the blog which means it doesn't automatically update itself. I've long since moved this blog off to my own hosting, but I can't figure out which thing it was they changed, and I've got so much content and stuff in here, I don't really want to mess with it.

Anyway, I like keeping my systems up to date, and I hate logging into a blog and finding updates are pending, so I wrote this script. It uses wp-cli which I have installed to /usr/local/bin/wp as per the install guide.

@Ruzgfpegk
Ruzgfpegk / wp-perf.md
Last active May 29, 2024 02:56
WordPress Performance & Development tips