Skip to content

Instantly share code, notes, and snippets.

View TylerB24890's full-sized avatar
:octocat:
Building a better internet.

Tyler Bailey TylerB24890

:octocat:
Building a better internet.
View GitHub Profile
@TylerB24890
TylerB24890 / serialize-gutenberg.php
Last active August 12, 2019 05:36
PHP Gutenberg Serializer
<?php
/**
* Serialize Gutenberg Blocks into HTML Markup
*
* @param array $block Array of block data to be serialized
* @return string Gutenberg HTML markup of serialized block
*/
function serialize_block( $block ) {
if ( ! isset( $block['blockName'] ) ) {
return false;
@TylerB24890
TylerB24890 / media-versioned-cache.php
Last active January 7, 2022 16:52
Add timestamp to end of media assets replaced by Enable Media Replace
<?php
/**
* Automatic Media & Post Cache Purging
* when using the Enable Media Replace plugin.
*
* @package Tyme
*/
namespace Tyme\CacheManager;
@TylerB24890
TylerB24890 / disable-variations.js
Created May 3, 2022 19:00
Disable Gutenberg Embed Block Variations
const { getBlockVariations, unregisterBlockVariation } = wp.blocks;
wp.domReady(() => {
const allowedEmbedBlocks = ['vimeo', 'youtube'];
getBlockVariations('core/embed').forEach(function (blockVariation) {
if (allowedEmbedBlocks.indexOf(blockVariation.name) === -1) {
unregisterBlockVariation('core/embed', blockVariation.name);
}
});
@TylerB24890
TylerB24890 / block-converter.php
Created April 18, 2024 17:00
HTML to Gutenberg Block Converter
<?php
/**
* Block Converter.
* Convert HTML to Gutenberg Blocks.
*
* @package Tyme\BlockConverter
*/
namespace Tyme;
@TylerB24890
TylerB24890 / ProcessTimer.php
Created May 3, 2024 18:28
PHP Process Timer
<?php
/**
* Process Timer.
* Create a system timer for determining the run-time of a specific process.
*
* Usage:
* $timer = new \Tyme\ProcessTimer();
* $timer->start();
* // Long running process
* $timer->stop();