Skip to content

Instantly share code, notes, and snippets.

View Jonnyauk's full-sized avatar
🎯
Focusing

Jonny Allbut Jonnyauk

🎯
Focusing
View GitHub Profile
@pento
pento / php-block.js
Last active March 20, 2025 14:59
Converting a shortcode to a block: this method is fast to do, but a mediocre UX. You should only use this as a stopgap until you can implement a full block UI.
// License: GPLv2+
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
ServerSideRender = wp.components.ServerSideRender,
TextControl = wp.components.TextControl,
InspectorControls = wp.editor.InspectorControls;
/*
* Here's where we register the block in JavaScript.
@johnbillion
johnbillion / wp_mail.md
Last active June 3, 2024 13:31
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail

@Rarst
Rarst / WordPress.xml
Last active September 5, 2024 01:49
WordPress Live Templates for PhpStorm
<?xml version="1.0" encoding="UTF-8"?>
<templateSet group="WordPress">
<template name="aa" value="add_action( '$hook$', '$callback$' );&#10;$END$" description="add_action" toReformat="false" toShortenFQNames="true">
<variable name="hook" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="callback" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="HTML_TEXT" value="false" />
<option name="HTML" value="false" />
<option name="XSL_TEXT" value="false" />
<option name="XML" value="false" />
@joyrexus
joyrexus / README.md
Last active March 22, 2025 12:57 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@WPsites
WPsites / gist:6083397
Last active December 20, 2015 06:09
Function to inspect WordPress filters/actions that match a regular expression
<?php
//hook into the 'shutdown' action and debug some filters... but not on the admin this time
if (! is_admin() )
add_action('shutdown', 'use_debug_filters',10);
function use_debug_filters(){
echo "<h3>Output hooks and filters that contain the string 'init'</h3>";
debug_filter("/init/i");
@Jonnyauk
Jonnyauk / wp-post-publish-first.php
Created June 25, 2012 14:35
Detect if WordPress post is published for the first time
<?php
/*
* On first publish set a special date in advance in custom field
*/
add_action('transition_post_status','tanc_first_schedule_publish_set',10,3);
function tanc_first_schedule_publish_set($new, $old, $post) {
// REFERENCE
// $new = new post status ('publish')
// $old = old post status ('draft')
@Jonnyauk
Jonnyauk / wp-jonnya-cpt-right-now.php
Created May 12, 2012 15:56
WordPress custom post type 'Right Now' panel integration
<?php
// Add all your custom post type counts to 'Right Now' dashboard widget
function tanc_admin_post_types_rightnow(){
$post_types = get_post_types(array('_builtin' => false), 'objects');
if (count($post_types) > 0)
foreach ($post_types as $pt => $args) {
$url = 'edit.php?post_type=' . $pt;
echo '<tr><td class="b"><a href="' . $url . '">' . wp_count_posts($pt)->publish . '</a></td><td class="t"><a href="' . $url . '">' . $args->labels->name . '</a></td></tr>';
}
@cs278
cs278 / is_serialized.php
Created October 23, 2009 18:25
PHP is_serialized() function.
<?php
/**
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/
/**