Skip to content

Instantly share code, notes, and snippets.

View smededwards's full-sized avatar

Michael Edwards smededwards

View GitHub Profile
@sarahcssiqueira
sarahcssiqueira / webpack dependencies
Last active December 4, 2024 21:41
webpack.config.js for WordPress projects
{
"devDependencies": {
"@babel/cli": "^7.22.9",
"@babel/core": "^7.22.9",
"@babel/preset-env": "^7.22.9",
"@babel/preset-react": "^7.22.5",
"babel-loader": "^9.1.2",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"cross-env": "^7.0.3",
@wpmark
wpmark / alignment-options.js
Last active January 4, 2023 07:50
Add alignment options for WordPress core blocks.
// set alignment options for cover, video, and paragraph blocks.
wp.hooks.addFilter(
'blocks.registerBlockType',
'hd-theme/hd-theme',
function( settings, name ) {
if ( name === 'core/cover' || name === 'core/video' || name === 'core/paragraph' || name === 'core/list' ) {
return lodash.assign( {}, settings, {
supports: lodash.assign( {}, settings.supports, {
// allow support for full and wide alignment.
align: ['full', 'wide'],
@wpmark
wpmark / readme.md
Last active February 1, 2023 11:06
An example of caching data using a WordPress transient

Caching WordPress data using Transients - Example

In this simple example we create a function for obtaining data from an external source and caching it for 24 hours. You can use the function hd_get_external_data() to get the data and work with it in your site.

If you want to force a refresh of the cache, you can pass a value of true into the function.

You can place the code into your themes functions.php file or better still in a plugin. If you are placing it in a plugin, remember to use function_exists() when using this. This ensures that the code will fail correctly if the plugin is not active.

@wpmark
wpmark / hd-just-in-time-css.php
Created August 13, 2021 09:13
A plugin to provide Just in Time CSS for WordPress blocks
<?php
/*
Plugin Name: Just in Time CSS
Plugin URI: https://highrise.digital/
Description: A plugin from Highrise Digital to provide just in time CSS functionality.
Version: 1.0
License: GPL-2.0+
Author: Highrise Digital Ltd
Author URI: https://highrise.digital/
Text domain: hd-just-in-time-css
@hhhonzik
hhhonzik / deploy.yml
Last active March 27, 2025 14:28
Kinsta Deployment
# Kinsta Deployment through Github Actions for Bedrock/Sage.
#
# Placed at: .github/workflow/deploy.yml
#
# Process should be studied from code, but some quick brief:
# - runs composer / sage installation
# - moves correct `.env.*` file for multiple configs
# - uses rsync to sync files, uses /.rsyncignore file to exclude whatever should not be there
# - symlinks uploads folder and symlink release folder to kinsta public hostname
# - if you want to clear cache, please uncomment the last job
@scottjehl
scottjehl / whichones.js
Created August 21, 2020 15:40
which elements are wider than the viewport?
var list = [];
document.querySelectorAll("body *")
.forEach(function(elem){
if(elem.getBoundingClientRect().width > document.body.getBoundingClientRect().width){
list.push(elem.outerHTML.split('>')[0] + '>');
}
});
confirm( "these elements are wider than the viewport:\n\n " + list.join("\n") )
@resource11
resource11 / Accessible-smooth-scrolling
Last active December 10, 2023 17:04
A CSS snippet for leveraging a smooth scroll behavior in an accessible manner
/* Smooth scrolling */
@media (prefers-reduced-motion: no-preference) {
:root {
scroll-behavior: smooth;
}
}
@SimonPadbury
SimonPadbury / scss-color-palette-generator.scss
Last active July 15, 2024 21:43
SCSS color palette generator — use to generate a range of color utilities (text color, background, border-color).
// Example: Set your color variables
$color--gray: #888888;
$color--blue: #3366FF;
$color--teal: #43E7F9;
$color--green: #5BD642;
$color--orange: #ffae18;
$color--red: #FF4732;
// Example: Set a color shade step interval
// FLEXBOX CSS GRID
// by Laptev Pavel
// VARiABLES
// desktop grid
$grid-desktop-columns: 12;
$grid-desktop-sideMargin: 80px;
$grid-desktop-gutter: 40px;
$grid-desktop-breakpoint: 1400px;
@mariovalney
mariovalney / bitbucket-pipelines.yml
Last active April 8, 2021 13:39
Deploying from Bitbucket Pipelines to WP Engine using Gulp
image: node:10.9.0
pipelines:
custom:
production:
- step:
deployment: production
caches:
- node
script: