Skip to content

Instantly share code, notes, and snippets.

@westonruter
westonruter / amp-auto-ads.php
Last active July 8, 2023 13:48
Plugin code to add <amp-auto-ads> on WordPress sites powered by the official AMP plugin. Installation instructions: https://gist.github.com/westonruter/6110fbc4bef0c4b8c021a112012f7e9c
<?php
/**
* AMP Auto Ads for AdSense (WordPress Plugin)
*
* @package AMP_Auto_Ads
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
* @wordpress-plugin
@zgordon
zgordon / registerblock-custom-icon-gutenberg.js
Last active January 2, 2022 19:56
Example for how to create use a custom SVG icon for a block in Gutenberg
// Import __ from i18n internationalization library
const { __ } = wp.i18n;
// Import registerBlockType() from block building libary
const { registerBlockType } = wp.blocks;
// Import the element creator function (React abstraction layer)
const el = wp.element.createElement;
/**
* Example of a custom SVG path taken from fontastic
*/
@carlosleopoldo
carlosleopoldo / delete-orphans-usermeta.sql
Last active June 16, 2023 13:23
Delete all orphans user meta in WordPress
DELETE FROM wp_usermeta
WHERE NOT EXISTS (
SELECT * FROM wp_users
WHERE wp_usermeta.user_id = wp_users.ID
)