Skip to content

Instantly share code, notes, and snippets.

kucrut / gutenberg-page-only.php
Last active Feb 20, 2018
Gutenberg only for pages
View gutenberg-page-only.php
add_filter( 'gutenberg_can_edit_post_type', function ( $can_edit, $post_type ) {
$can_edit = $post_type === 'page';
return $can_edit;
}, 99, 2 );
kucrut / bridge-walker-nav-menu.php
Last active Mar 23, 2021
WordPress Nav Menu walker that returns menu items as multidimensional array (items will children)
View bridge-walker-nav-menu.php
* Nav menu walker
class Bridge_Walker_Nav_Menu extends Walker_Nav_Menu {
* Prepare item
View gist:643607c04714ea6237ef
### Keybase proof
I hereby claim:
* I am kucrut on github.
* I am kucrut ( on keybase.
* I have a public key whose fingerprint is A2B0 583F C30F F49B DBE8 8A93 C61B 570E 98E1 350E
To claim this, I am signing this object:
View Menu Item Custom Field Image
* Menu item custom fields example
* Copy this file into your wp-content/mu-plugins directory.
* @package Menu_Item_Custom_Fields
* @version 0.1.0
* @author Dzikri Aziz <>
View disable-plugins-when-doing-local-dev.php
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI:
View custom_page.php
* A helper class to implement arbitrary content at arbitrary URLs without a supporting post or page.
* Inherit from this class and implement the render_page method
* @author: Tom J Nowell
* @License: GPL 2+
abstract class Tomjn_Custom_Page {
View gist:5468029
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL
if ( !$frag->output() ) { // NOTE, testing for a return of false
// YOU CANNOT FORGET THIS. If you do, the site will break.
View gist:5192239
* This little class records how long it takes each WordPress action or filter
* takes to execute which gives a good indicator of what hooks are being slow.
* You can then debug those hooks to see what hooked functions are causing problems.
* This class does NOT time the core WordPress code that is being run between hooks.
* You could use similar code to this that doesn't have an end processor to do that.
kucrut / gist:5110603
Created Mar 7, 2013
For Alex: Passing Arguments to Callback Functions
View gist:5110603
* Example class
* This class demonstrates how to pass data to a callback function
* without using global varaibles.
class Example_Class {
public function __construct( $strings ) {
$this->strings = $strings;
View gist:4412813
// Use the new media manager to handle uploads to Soliloquy.
$('#soliloquy-area').on('click.soliloquyUpload', '#soliloquy-upload', function(e){
// Prevent the default action from occuring.
// Variable to hold our media applicaton.
var soliloquy_frame;
// If the media frame already exists, reopen it and return.
if ( soliloquy_frame ) {