Skip to content

Instantly share code, notes, and snippets.

View bjorn2404's full-sized avatar

Björn Holine bjorn2404

View GitHub Profile
@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 / 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 / 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 / functions.php
Last active January 27, 2021 20:39
ElasticPress exclude post type from "Weight results by date" decay
<?php
/**
* Filter the arguments sent to EP query
*
* @param array $formatted_args Formatted Elasticsearch query
* @param array $query_vars Query variables
* @param array $query Query part
*
* @return array
@bjorn2404
bjorn2404 / locations-import.csv
Created January 17, 2021 22:08
Cardinal Locator CSV import structure
name description website address city state postal country hours1 hours2 hours3 hours4 hours5 hours6 hours7 phone email categories
@bjorn2404
bjorn2404 / functions.php
Last active May 11, 2018 05:41
CSL manual front-end filters register example
<?php
/**
* Manually add categories for static data.
* The property ('category' below) should match the property/attribute name in your JSON or XML data.
* The value ('category-filter' below) should match the ID of the HTML container element around the input fields.
*/
function bh_sl_manual_categories() {
?>
<script>
@bjorn2404
bjorn2404 / page-template.php
Last active May 11, 2018 04:50
CSL manual front-end filters markup example
<div class="bh-sl-container">
<div class="bh-sl-form-container">
<form id="bh-sl-user-location" method="post" action="#">
<div class="form-input">
<label for="bh-sl-address">Enter Address or Zip Code:</label>
<input type="text" id="bh-sl-address" name="bh-sl-address" />
</div>
<button id="bh-sl-submit" type="submit">Submit</button>
@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
*/
@bjorn2404
bjorn2404 / nginx.conf
Created March 28, 2016 20:12
WordPress load remote images if they don't exist on the local development server NGINX. vagrant provision after editing site conf file.
location ~ ^/wp-content/uploads/(.*) {
if (!-f $request_filename) {
rewrite ^/wp-content/uploads/(.*)$ http://www.remotesite.com/wp-content/uploads/$1 redirect;
}
}
@bjorn2404
bjorn2404 / favicon.txt
Created November 10, 2015 19:55
Imagemagick favicon
convert favicon.png -bordercolor white -border 0 \
\( -clone 0 -resize 16x16 \) \
\( -clone 0 -resize 32x32 \) \
\( -clone 0 -resize 48x48 \) \
\( -clone 0 -resize 64x64 \) \
\( -clone 0 -resize 128x128 \) \
\( -clone 0 -resize 256x256 \) \
-delete 0 -alpha off -colors 256 favicon.ico