Skip to content

Instantly share code, notes, and snippets.

View bjorn2404's full-sized avatar

Björn Holine bjorn2404

View GitHub Profile
@bjorn2404
bjorn2404 / wordpress_remote_images
Created May 21, 2015 20:51
WordPress load remote images if they don't exist on the local development server htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/(.*)$
RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads/%1 !-f
RewriteRule ^wp-content/uploads/(.*)$ http://www.remotesite.com/wp-content/uploads/$1 [R=301,L]
</IfModule>
@bjorn2404
bjorn2404 / update.js
Created January 30, 2023 07:37
Gutenberg panel status in v6+ to solve: select( 'core/edit-post' ).getPreference is deprecated since version 6.0. Please use select( 'core/preferences' ).get instead.
/**
* Didn't find much documentation on how to fix this issue
*
* This pull request made the panels change: https://github.com/WordPress/gutenberg/commit/9a195fca8e0a23af1605830b4128edb116a4964a
*/
// Instead of using this approach to get a single panel status:
const addressPanelStatus = select( 'core/edit-post' ).getPreference( 'panels' )['cardinal-locator-location-address/location-address-panel'];
// Get all the open panels and use a simple indexOf. Ex:
@bjorn2404
bjorn2404 / format.md
Created January 26, 2024 05:41
CircleCI environment variable access token format for GitHub

After a GitHub access token is created/rotated a CircleCI Environment Variable may need to be updated using the following steps:

CircleCI > Project Settings > Environment Variables > Add Environment Variable

The COMPOSER_AUTH name is picked up automatically - if there's an existing one just click the "Add Enviornment Variable" button with the same name to replace.

Value format (replace with your token value):

{"github-oauth": {"github.com": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}}

@bjorn2404
bjorn2404 / function.php
Last active February 25, 2024 00:19
Search WordPress Gutenberg blocks for a specific block name in all nested innerBlocks data
<?php
/**
* Search blocks and innerBlocks for a specific type of block
*
* @param array $blocks Blocks to search through (use parse_blocks prior to passing).
* @param string $block_name The type of block to search for.
*
* @return array Matching blocks
*/
@bjorn2404
bjorn2404 / wp_kses_post_tags.php
Last active April 22, 2024 15:08
WordPress allow iFrames with wp_kses_post filter
<?php
/**
* Add iFrame to allowed wp_kses_post tags
*
* @param array $tags Allowed tags, attributes, and/or entities.
* @param string $context Context to judge allowed tags by. Allowed values are 'post'.
*
* @return array
*/