Skip to content

Instantly share code, notes, and snippets.

View Mamaduka's full-sized avatar

George Mamadashvili Mamaduka

View GitHub Profile
<?php
add_filter( 'block_type_metadata', function( $metadata ) {
if ( in_array( $metadata['name'], [ 'core/paragraph', 'core/heading'], true ) ) {
$metadata['supports']['typography']['__experimentalFontFamily'] = true;
}
return $metadata;
} );

Local dev environment with Valet/DBngin on Apple Silicon

Setup

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/mamaduka/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@Mamaduka
Mamaduka / helpers.php
Created January 23, 2021 06:29
View helper function
<?php
namespace Mamaduka\ProjectName\Helpers;
use const Mamaduka\ProjectName\PLUGIN_DIR;
/**
* Render a view.
*
* @param string $name Name of the view.
@Mamaduka
Mamaduka / gist:29f9b717ba4755e3774ff276d990de73
Created August 2, 2020 13:15 — forked from mannieschumpert/gist:8886289
Code Examples from Andrew Nacin's "Current User Can Watch This Talk"
<?php
// If you can edit pages, you can edit widgets
add_filter( 'user_has_cap',
function( $caps ) {
if ( ! empty( $caps['edit_pages'] ) )
$caps['edit_theme_options'] = true;
return $caps;
} );
@Mamaduka
Mamaduka / paste-as-text.php
Created July 14, 2020 10:39
Force TinyMCE in WordPress to paste as plain text.
<?php
/**
* Configure "Paste" plugin before TinyMCE init.
*
* @param array $mceInit
* @return array $mceInit
*/
add_filter( 'tiny_mce_before_init', function( $mceInit ) {
$mceInit['paste_as_text'] = true;
<?php
use CBOX\Upgrades\Upgrade;
use CBOX\Upgrades\Upgrade_Item;
use CBOX\Upgrades\Upgrade_Registry;
class CBOXOL_Upgrade_Nav_Menus extends Upgrade {
public $id = 'upgrade_nav_menus';
Cypress.Commands.add('login', () => {
cy.request({
url: '/wp-login.php',
method: 'POST',
form: true,
body: {
log: Cypress.env('wp_user'),
pwd: Cypress.env('wp_pass'),
rememberme: 'forever',
testcookie: 1,

Contact SQL files

cat *.sql >> ../backup/contacted.sql
find . -type f -name "*.sql" -print0 | xargs -0 cat >> ../backup/concated.sql
@Mamaduka
Mamaduka / example.js
Last active August 25, 2019 13:02
Get form data as name => value pair in ES6.
const form = document.getElementById( 'acme-form' );
// Checkboxe, select and radios are handled differently
const dataArray = Array
.from( form.elements )
.filter( input => ( input.type === 'text' || input.type === 'textarea' ) )
.map( input => {
return { [input.name] : input.value }
} );