Skip to content

Instantly share code, notes, and snippets.

View gaambo's full-sized avatar

Fabian Todt gaambo

View GitHub Profile
@afragen
afragen / mu-loader.php
Last active March 21, 2024 12:54
A generic mu-plugins loader for plugins stored in wp-content/plugins folder.
<?php
/**
* MU Loader
*
* @author Andy Fragen, Colin Stewart
* @license MIT
* @package mu-plugins
*/
/**
@aurooba
aurooba / wp_inline_svg.php
Last active February 17, 2024 23:33
Helper function to inline your SVG files in a WordPress theme or plugin and optionally also update the attributes. Only works with WordPress 6.2 and onwards. Blog post with explanation and usage instructions: https://aurooba.com/inline-svgs-in-your-wordpress-code-with-this-helper-function/
<?php
/**
* Get an SVG file from the imgs/ folder in the theme, update its attributes if necessary and return it as a string.
*
* @author Aurooba Ahmed
* @see https://aurooba.com/inline-svgs-in-your-wordpress-code-with-this-helper-function/
*
* @param string $filename The name of the SVG file to get.
* @param array $attributes (optional) An array of attributes to add/modify to the SVG file.
@seanlanglands
seanlanglands / cta-block-pattern.php
Last active July 21, 2022 09:35
Example block pattern that's based on a cover block featuring move and remove locking attributes.
<?php
$default_attachment_url = get_stylesheet_directory_uri() . '/assets/images/default-cover-bg.jpg';
$block_pattern_content = '<!-- wp:cover {"url":"' . esc_url( $default_attachment_url ) . '","id":42,"dimRatio":90,"minHeight":0,"minHeightUnit":"px","gradient":"vivid-cyan-blue-to-vivid-purple","align":"full","style":{"spacing":{"padding":{"top":"5rem","right":"14rem","bottom":"5rem","left":"14rem"}}}} -->
<div class="wp-block-cover alignfull" style="padding-top:5rem;padding-right:14rem;padding-bottom:5rem;padding-left:14rem;min-height:0px">
<span aria-hidden="true" class="has-background-dim-90 wp-block-cover__gradient-background has-vivid-cyan-blue-to-vivid-purple-gradient-background has-background-dim has-background-gradient"></span>
<img class="wp-block-cover__image-background wp-image-42" alt="" src="' . esc_url( $default_attachment_url ) . '" data-object-fit="cover"/>
<div class="wp-block-cover__inner-container">
<!-- wp:heading {"textAlign":"center","level":4,"style":{"spacing":{"margin":{"top"
@seanlanglands
seanlanglands / theme.json
Created March 28, 2022 22:33
Example theme.json for an existing Classic Theme that excludes many default color and typography controls from being enabled.
{
"schema": "https://schemas.wp.org/trunk/theme.json",
"version": 2,
"settings": {
"layout": {
"contentSize": "800px",
"wideSize": "1000px"
},
"color": {
"link": false
@TimothyBJacobs
TimothyBJacobs / app-passwords-client-demo.php
Created January 19, 2021 23:55
App Passwords Client Demo Plugin
<?php
declare( strict_types=1 );
/*
* Plugin Name: Demo App Passwords Client
*/
namespace TimothyBJacobs\AppPasswordsClientDemo;
const META_KEY = '_app_passwords_client_demo_creds';
@bph
bph / psl-theme-test.txt
Last active October 19, 2023 15:21
Blocks for Themes Test
<!-- wp:paragraph -->
<p><a href="https://gist.github.com/bph/335ddef358bb41efdcd159cbc76f582e">https://gist.github.com/bph/335ddef358bb41efdcd159cbc76f582e</a></p>
<!-- /wp:paragraph -->
<!-- wp:heading {"className":"eplus-oOhLNH"} -->
<h2 class="eplus-oOhLNH">Common Blocks / Formatting / Layout Elements / Widgets and Embeds</h2>
<!-- /wp:heading -->
<!-- wp:list {"className":"eplus-eI3gin"} -->
<ul class="eplus-eI3gin"><li><a href="#images">Images</a> (Single image, cover image, gallery </li><li><a href="#quotes">Pull Quote / Quote</a></li><li><a href="#verse">Verse</a></li><li><a href="#buttons">Buttons</a></li><li><a href="#socialicons" data-type="internal" data-id="#socialicons">Social Icons</a></li><li><a href="#columns">Columns </a> Text (only) columns / Columns experimental</li><li><a href="#cover" data-type="internal" data-id="#cover">Cover</a> with CAT + button</li><li><a href="#paragraphs">Paragraph</a> </li><li><a href="#audio">Audio</a> </li><li><a href="#video">Video</a></li><li><a href="#w
@jasonbahl
jasonbahl / gutenberg-page-template-switcher.js
Created May 4, 2018 21:01
Gutenberg Page Template Switcher
import gql from 'graphql-tag'
import { client } from '../utils/apollo-client'
const { parse } = wp.blocks;
const { select, subscribe, dispatch } = wp.data;
const GET_PAGE_BLOCK_TEMPLATE = gql`
query GET_PAGE_BLOCK_TEMPLATE($id: ID!, $template: String) {
page( id: $id ) {
blockTemplate( pageTemplate: $template )
}
}
@chrisgrabinski
chrisgrabinski / wordpress-s3-backup.sh
Last active June 7, 2022 08:12
WordPress S3 Backup Bash Script
# WordPress S3 Backup Script
# ---------------------------------------------------------------------------------
#!/bin/bash
bucket="s3://" # Your S3 Bucket
if [ -z "$1" ]
then
path=$PWD
else
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active May 1, 2024 01:29
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@stowball
stowball / front-end-guidelines.md
Last active April 12, 2024 09:04
Front-End Guidelines