Skip to content

Instantly share code, notes, and snippets.

View gaambo's full-sized avatar

Fabian Todt gaambo

View GitHub Profile
@gaambo
gaambo / Dockerfile-phpunit
Created August 24, 2021 12:02
WordPress Core Developing with Xdebug + VSCode + WSL 2
FROM wordpressdevelop/phpunit:${LOCAL_PHPUNIT:-latest}
# install xdebug
RUN pecl install -f xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini;
@gaambo
gaambo / block-editor.php
Last active January 26, 2022 08:14
UPDATE: No longer needed in WP 5.9 // Fixes Bug #51612 in WordPress Core where block filters (pre_render_block and render_block_data) only get called for top level blocks (not for innerBlocks/nested)
<?php
// phpcs:ignoreFile PSR1.Files.SideEffects
namespace CoreFunctionality\BlockEditor;
/**
* Fixes Bug #51612 in WordPress Core
* where block filters (pre_render_block and render_block_data)
* only get called for top level blocks (not for innerBlocks/nested)
*
@gaambo
gaambo / mainwp-updraft.php
Last active February 3, 2021 12:23
nippet to allow setting UpdraftPlus settings via wp-config.php constants
<?php
/**
* Allows setting UpdraftPlus settings via wp-config.php constants
*
* Usefull for setting AWS S3 Access/Secret Keys in a constant instead of saving it in the database
* Set the constant UPDRAFT_S3_SETTINGS with configuration like this:
* ```php
* define('UPDRAFT_S3_SETTINGS', [
* 'accesskey' => 'accesskey',
@gaambo
gaambo / mainwp-backwpup.php
Created February 2, 2021 12:08
Snippet to allow setting BackWPup settings via wp-config.php constants
<?php
/**
* Allows setting BackWPup settings via wp-config.php constants
*
* Usefull for setting AWS S3 Access/Secret Keys in a constant instead of saving it in the database
* Set the constant BACKWPUP_SETTINGS with configuration per jobid(!) like this:
* ```php
* define('BACKWPUP_SETTINGS', [
* '1' => [ // jobid
@gaambo
gaambo / functions.php
Created May 4, 2020 08:08
Duplicate Elementor Templates with Duplicate Post Plugin (WordPress)
// when duplicating a elementor template elementor save_post hook get's fired before all the post meta is duplicated
// and elementor sets the template type to the default page --> popups cannot be dupliated
// so the elementor key is removed from duplicating and duplicatd manually later on
add_filter('duplicate_post_meta_keys_filter', function ($keys) {
if ($k = array_search('_elementor_template_type', $keys)) {
array_splice($keys, $k, 1);
}
return $keys;
});
@gaambo
gaambo / front-end-guidelines.md
Created October 25, 2019 20:05 — forked from stowball/front-end-guidelines.md
Front-End Guidelines
@gaambo
gaambo / front-end-guidelines.md
Created October 25, 2019 20:05 — forked from stowball/front-end-guidelines.md
Front-End Guidelines
@gaambo
gaambo / acf.js
Last active December 29, 2021 18:11
ACF Block with Innerblocks
import { Fragment } from "@wordpress/element";
import { InnerBlocks } from "@wordpress/editor";
/**
* Changes the edit function of an ACF-block to allow InnerBlocks
* Should be called like this on `editor.BlockEdit` hook:
* ` addFilter("editor.BlockEdit", "namespace/block", editWithInnerBlocks("acf/block-name"));`
*
* @param {string} blockName the name of the block to wrap
* @param {object} innerBlockParams params to be passed to the InnerBlocks component (like allowedChildren)
@gaambo
gaambo / acf.php
Created July 29, 2019 08:35
ACF Post Type location rule in block field groups
/**
* Sets the post id from an acf ajax request
* This is needed for the post_type location rule to work on block field groups
*/
add_filter('acf/location/screen', function ($screen) {
$postID = get_the_ID();
if (!$postID) {
$postID = $_REQUEST['post_id'] ?? false;
}