Skip to content

Instantly share code, notes, and snippets.

@Luehrsen
Luehrsen / edit.js
Created June 26, 2023 14:43
WordPress Block Editor: How to avoid switching to the block sidebar when a block is selected.
/**
* We want to open the document sidebar when the block is selected.
* We want this behavior for our meta block, as all relevant settings
* are in the document sidebar. The block sidebar is useless, empty and
* distracting.
*/
/**
* Import dispatch function from the core/edit-post store.
*/
@Luehrsen
Luehrsen / yoast-breadcrumbs-block-modifier.php
Created March 1, 2022 09:57
We needed the yoast-seo breadcrumbs block to have alignwide. This is how we did it.
<?php
/**
* Add our action to modify the registered yoast seo breadcrum block.
* Note the priority. Yoast registeres their blocks at priority 11, so we need to be
* higher than that.
*/
add_action( 'init', array( $this, 'modify_yoast_breadcrumbs_block' ), 12 );
/**
@Luehrsen
Luehrsen / innerLayoutControls.js
Created February 16, 2022 20:56
A hacky way how to return to formerly expected behaviour for the group block for the WordPress block editor.
/**
* @type {string[]} Array of block names that should be excluded from the layout settings.
*/
const haystack = ['core/group'];
wp.hooks.addFilter(
'blocks.registerBlockType',
'lh/fseFixes/layoutSettings',
(settings, name) => {
if (!haystack.includes(name)) {
<?php
/**
* Render the schema graph for the acf/gb-faq block.
*
* @param array $graph Schema data for the current page.
* @param WP_Block_Parser_Block $block The block data array.
* @param Meta_Tags_Context $context A value object with context variables.
*
* @return array Our Schema graph.
*/
@Luehrsen
Luehrsen / Lazysizes.php
Created January 14, 2021 13:49
A lazysizes implementation for WordPress
<?php
/**
* Lhtheme\Lazysizes\Component class
*
* @package lhtheme
*/
namespace WpMunich\lhtheme\Lazysizes;
use WpMunich\lhtheme\Component_Interface;
use function add_action;
@Luehrsen
Luehrsen / limitBlockToPostType.js
Created March 28, 2019 08:56
Removes the block type on non-whitelisted post types
/**
* Removes the block type on non-whitelisted post types
*
* @param {Array} postTypeNames An array of post type names as white list for this block
* @param {string} blockName The name of the block
*
* @example
* limitBlockToPostType( [ 'page' ], 'core/paragraph' );
*
* @return {void}
/**
* The function that extends the default quicklink options
*
* @param array $options The default Quicklink options.
*
* @return array The extended Quicklink options
*/
function my_extended_quicklink_options( $options ) {
// Do not preload 'add to wishlist' links.
/**
* The function that extends the default quicklink options
*
* @param array $options The default Quicklink options.
*
* @return array The extended Quicklink options
*/
function my_extended_quicklink_options( $options ) {
// Do not preload 'add to wishlist' links.

Keybase proof

I hereby claim:

  • I am luehrsen on github.
  • I am luehrsen (https://keybase.io/luehrsen) on keybase.
  • I have a public key ASAnbe_WUX0P6__8DQw2AbOgaAWsLZexQOUzjIKx7LMd5go

To claim this, I am signing this object:

@Luehrsen
Luehrsen / functions.php
Last active August 14, 2018 15:09
WordPress Responsive Embeds
/**
* Change the embed code, so we can apply awesome css classes
* Called by filter "oembed_result"
*
* @author Hendrik Luehrsen
* @since 1.0
*
* @param $html string The oembed html to edit
*
* @return string The edited html