Skip to content

Instantly share code, notes, and snippets.

View thetwopct's full-sized avatar

James Hunt thetwopct

View GitHub Profile
<?php
namespace DeliciousBrains\Admin;
use DeliciousBrains\DBI;
class ACF {
public function init() {
add_filter( 'acf/settings/save_json', array( $this, 'get_local_json_path' ) );
@danyj
danyj / thz_disable_gutenberg.php
Created October 25, 2018 09:15
Disable Gutenberg globally or for specific post types for WordPress 5.0 and UP
<?php
/*
* Disable Gutenberg globally
* use this if you prefer one-liner
* add_filter('use_block_editor_for_post', '__return_false');
*/
function _thz_filter_disable_block_editor(){
return false;
}
add_filter( 'use_block_editor_for_post', '_thz_filter_disable_block_editor' );
@mattiasghodsian
mattiasghodsian / index.php
Last active April 28, 2023 08:36
[PHP] List any users public gists
/**
* Title: Get gists
* Author: Mattias Ghodsian
* Description: List any users public gists
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*/
$profile_url = "https://api.github.com/users/mattiasghodsian/gists";
$options = array('http' => array('user_agent'=> $_SERVER['HTTP_USER_AGENT']));
@nathanrice
nathanrice / modular-stylesheets.php
Last active April 11, 2020 14:36
A simple proof-of-concept for modularizing the CSS for each block, and linking it "just in time".
<?php
// this snippet requires PHP 5.3+
add_action( 'wp_enqueue_scripts', function() {
wp_register_style( 'atomic-blocks/ab-cta', '/path/to/atomic-blocks/css/ab-cta.css', array(), 1.0.0 );
} );
add_filter( 'render_block', function( $block_content, $block ) {
if ( 'atomic-blocks/ab-cta' === $block['blockName'] ) {
ob_start();
wp_print_styles( $block['blockName'] );
@kierzniak
kierzniak / functions.php
Last active February 5, 2020 09:57
Function to resolve assets url with attached content hash
<?php
/**
* Function to resolve assets url with attached content hash.
*
* Browser cache mechanism is used to store locally once downloaded assets. This
* improves website performance and saves network bandwidth. It may be also creating
* a problem when a user visits your website and do not see the newest changes in assets
* because the browser is serving an old file from cache.
*
@patrick-lienau
patrick-lienau / README.md
Last active July 24, 2024 14:45
Flame graph profiling for wordpress in lando

image

This assunmes you're running wp in lando with php >= 8

in ./lando.local.yml

services:
  appserver:
 build_as_root: