Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Howells-Mead markhowellsmead

View GitHub Profile
@markhowellsmead
markhowellsmead / wp-config.php
Created Jun 17, 2021 — forked from MikeNGarrett/wp-config.php
All those damned wp-config constants you can never remember.
View wp-config.php
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@markhowellsmead
markhowellsmead / youtube_srcdoc.php
Last active Jun 17, 2021
Uses the technique from https://css-tricks.com/lazy-load-embedded-youtube-videos/ to add an srcdoc attributes to YouTube embeds. This code is intended for WordPress through the use of the embed_oembed_html filter hook.
View youtube_srcdoc.php
<?php
/**
* Uses the technique from https://css-tricks.com/lazy-load-embedded-youtube-videos/ to add an srcdoc
* attribute to YouTube embeds, which prevents the content of the YouTube iframe from loading until
* the user clicks on the video link. This code is intended for WordPress through the use of the
* embed_oembed_html filter hook.
*
* Although the autoplay code is correct, current browsers appear to block the autoplay feature when
* loading the iframe content when the link is clicked. This means that the visitor will need to click
@markhowellsmead
markhowellsmead / index.js
Created Jun 10, 2021
WordPress Gutenberg - transform core list block to custom block with multiple InnerBlocks.
View index.js
transforms: {
from: [
{
type: 'block',
blocks: ['core/list'],
transform: ({ values }) => {
let entries = values.split('</li><li>');
const link_pattern = /<a href=['"]#endnote[0-9]+['"]>([0-9]+)<\/a>/gi;
entries.forEach((entry, index) => {
entries[index] = entry.replace('<li>', '').replace('</li>', '');
@markhowellsmead
markhowellsmead / vh.css
Last active Apr 9, 2021
Dynamically observe browser height (accounts for changes in e.g. iOS Safari on scroll)
View vh.css
:root {
--vh: 1vh;
}
.c-browserheight {
min-height: calc(100 * var(--vh));
}
@markhowellsmead
markhowellsmead / exif-gist.php
Created Feb 10, 2021 — forked from black-forever/exif-gist.php
EXIF 01 - Get EXIF-Information from wp_get_attachment_image_attributes
View exif-gist.php
<?php
/**
* *****************************************************************************
* GIST - EXIF 01 - Get EXIF-Information from wp_get_attachment_image_attributes
* *****************************************************************************
*/
if ( is_attachment() ) {
$imgmeta = wp_get_attachment_metadata( $id );
@markhowellsmead
markhowellsmead / full-codes.js
Created Jan 16, 2021 — forked from phpbits/full-codes.js
Extend core Gutenberg blocks with custom attributes and settings. View full tutorials here : https://jeffreycarandang.com/extending-gutenberg-core-blocks-with-custom-attributes-and-controls/
View full-codes.js
/**
* External Dependencies
*/
import classnames from 'classnames';
/**
* WordPress Dependencies
*/
const { __ } = wp.i18n;
const { addFilter } = wp.hooks;
@markhowellsmead
markhowellsmead / CustomizerPolylang.php
Last active Dec 14, 2020
This add-in gives you full Polylang support in WordPress customizer. By full support I mean that you customize each language site differently. Original from https://github.com/soderlind/customizer-polylang
View CustomizerPolylang.php
<?php
/**
* This add-in gives you full Polylang support in WordPress customizer. By full support I mean that you customize each language site differently.
* Minor adaptation from https://github.com/soderlind/customizer-polylang to fit into the Hello Roots logic.
*/
namespace SayHello\Theme\Plugin;
class CustomizerPolylang
@markhowellsmead
markhowellsmead / Gutenberg.php
Created May 19, 2020
Add post type and slug to Gutenberg editor wrapper
View Gutenberg.php
<?php
/**
* Extend the Gutenberg Package with the following function
*/
add_filter('admin_body_class', [$this, 'extendAdminBodyClass']);
View block-navigation-four-column.html
<!-- wp:group {"align":"full"} --><div class="wp-block-group alignfull"><div class="wp-block-group__inner-container"><!-- wp:columns --><div class="wp-block-columns"><!-- wp:column --><div class="wp-block-column"><!-- wp:heading {"level":4} --><h4>Menu 1</h4><!-- /wp:heading --><!-- wp:list {"className":"is-style-none"} --><ul class="is-style-none"><li><a href="#">Entry 1</a></li><li><a href="#">Entry 2</a></li><li><a href="#">Entry 3</a></li><li><a href="#">Entry 4</a></li></ul><!-- /wp:list --></div><!-- /wp:column --><!-- wp:column --><div class="wp-block-column"><!-- wp:heading {"level":4} --><h4>Menu 2</h4><!-- /wp:heading --><!-- wp:list {"className":"is-style-none"} --><ul class="is-style-none"><li><a href="#">Entry 1</a></li><li><a href="#">Entry 2</a></li><li><a href="#">Entry 3</a></li><li><a href="#">Entry 4</a></li></ul><!-- /wp:list --></div><!-- /wp:column --><!-- wp:column --><div class="wp-block-column"><!-- wp:heading {"level":4} --><h4>Menu 3</h4><!-- /wp:heading --><!-- wp:list {"className"
@markhowellsmead
markhowellsmead / _group.scss
Created Apr 15, 2020
Gutenberg: Group: custom styling
View _group.scss
.wp-block-group {
margin-top: 0;
margin-bottom: 0;
&.is-style-padding {
.wp-block-group__inner-container {
padding-top: var(--unit);
padding-bottom: var(--unit);
}