Skip to content

Instantly share code, notes, and snippets.

View florianbrinkmann's full-sized avatar

Florian Brinkmann florianbrinkmann

View GitHub Profile
@florianbrinkmann
florianbrinkmann / index.js
Last active February 26, 2024 21:40
Gutenberg FormTokenField block with posts as source
/**
* External dependencies
*/
const { isUndefined, pickBy } = lodash;
/**
* WordPress dependencies
*/
const {
registerBlockType,
<?php
/*
Plugin Name: UTF8mb4-convert
Version: 1.0
*/
function update_db_to_utf8mb4() {
if ( ! isset( $_GET['update-utf8bm4'] ) ) {
return;
}
/**
* If registration for new network sites is disabled,
* the NOBLOGREDIRECT constant redirects to a specific URL
* if a user tries to access a nonexisting network site.
*/
// add this to wp-config.php and adjust the URL
define( 'NOBLOGREDIRECT', 'https://example.com' );
/**
<?php
/**
* Needs php_mbstring extension
*/
ini_set( 'memory_limit', '1024M' );
date_default_timezone_set( 'UTC' );
// Damit es in der Konsole nicht so lange dauert
error_reporting( 0 );
// <load users file>
;(function () {
/**
* Run function when customizer is ready.
*/
wp.customize.bind('ready', function () {
wp.customize.control('slug_select_control', function (control) {
/**
* Run function on setting change of control.
*/
control.setting.bind(function (value) {
<?
$main_img_wppath = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full')[0];
$portfolio_cats = get_the_term_list( $post->ID, 'portfolio_category', '', ', ');
// declaring all possible custom fields (usually only some of them are populated in the portfolio page)
$portfolioPostIcon = get_post_meta($post->ID, 'portfolioPostIcon', true);
$customers = get_post_meta($post->ID, 'customers', true);
$relnotes = get_post_meta($post->ID, 'relnotes', true);
$appstore = get_post_meta($post->ID, 'appstore', true);
@florianbrinkmann
florianbrinkmann / functions.php
Created March 13, 2021 12:55
Add has-\d-columns class to columns blocks after 5.3 update.
<?php
/**
* Add has-\d-columns class to columns blocks after 5.3 update.
*
* @param string $block_content The block content about to be appended.
* @param array $block The full block, including name and attributes.
*
* @return string
*/
add_filter( 'render_block', function( $block_content, $block ) {
import classnames from 'classnames';
const {
registerBlockType,
} = wp.blocks;
const {
InspectorControls,
InnerBlocks,
withColors,
getColorClass
<?php
/**
* Do not show favicon (prevents WP logo from showing up since WP 5.4).
* Does NOT show a maybe-existent site icon instead. For that, look here: https://gist.github.com/webdados/a7702e588070f9a1cfa12dff89b3573c
*/
add_action( 'do_faviconico', function() {
header( 'Content-Type: image/vnd.microsoft.icon' );
exit;
} );
<?php
/**
* Add skip-lazy class to first image in content.
*/
add_filter( 'the_content', function( $content ) {
// Check if we have no content.
if ( empty( $content ) ) {
return $content;
}