Skip to content

Instantly share code, notes, and snippets.

View davidallenlewis's full-sized avatar

David Lewis davidallenlewis

  • Halifax, NS. Canada
View GitHub Profile
@davidallenlewis
davidallenlewis / get_acf_field.php
Last active March 3, 2019 15:24
Get ACF Block fields outside block template
<?php
// *******************************
// Get ACF block fields outside block templates
// -------------------------------
function get_block_field( $field_id, $post_id = '' ) {
// Get current post ID if post_id arg isn't passed
$post_id = $post_id ? $post_id : get_the_ID();
// *******************************
// Make Gutenberg Sidebar Wider / Fluid
// -------------------------------
function wider_gutenberg_settings_sidebar() { ?>
<style>
@media (min-width: 1080px) {
#wpwrap .edit-post-layout.is-sidebar-opened .components-notice-list {
right: 26vw !important;
}
#wpwrap .edit-post-layout.is-sidebar-opened .edit-post-plugin-sidebar__sidebar-layout,
/* Override Gutenbergs asymeteical column margins with the negative margin trick */
.wp-block-columns {
margin: 0 -20px;
}
.wp-block-columns .wp-block-column {
margin: 0 0 20px 0;
padding: 0 20px;
}
@davidallenlewis
davidallenlewis / gist:e6f63210e09d3f8e336c2254b2cb8083
Created February 24, 2020 15:26
Rename WordPress Posts to News
// *******************************
// Rename "Posts" to "News"
function change_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = 'News';
$submenu['edit.php'][5][0] = 'All Articles';
echo '';
}
function change_post_object_label() {
// *******************************
// Blocks Availability
// -------------------------------
add_filter( 'allowed_block_types', 'uwd_allowed_block_types', 10, 2 );
function uwd_allowed_block_types( $allowed_blocks, $post ) {
$allowed_blocks = array(
// ACF Blocks
'acf/accordion',
'acf/archive-cards',
// Min / Max http://www.sassmeister.com/gist/7f22e44ace49b5124eec
@mixin minmax(
$size-min,
$size-max,
$properties: font-size,
$vw-min: 320px,
$vw-max: 1280px
) {
@if(
unitless($size-min) or
@davidallenlewis
davidallenlewis / save_acf_to_post_content.php
Created September 29, 2020 16:26
Save ACF metadata to post_content on save
// *******************************
// Future-Proof content by saving ACF content to post_content
// -------------------------------
function save_acf_rich_text_to_post_content( $post_id ) {
if ( get_post_type( $post_id ) == ( 'post' || 'page' ) ) {
// Get ACF flex content
if( have_rows('content_blocks') ) {
$post_content = '';
@davidallenlewis
davidallenlewis / CANImmunize.css
Last active August 29, 2022 18:45
Hide Inactive Appointment Locations in CANImmunize
/* Remove extra spacing from all cards */
.card[appointment][class*="styles_appointmentTypeCard__"] {
margin: 0 !important;
border-top: 0 !important;
border-bottom: 0 !important;
}
/* Add bottom spacing back to visible cards */
.card[appointment][class*="styles_appointmentTypeCardSelectable__"] {
margin-bottom: 10px !important;
<div class="custom-homepage-hero-bg-overlay" style="background-image:
url(https://rps.charcoal.website/wp-content/uploads/2021/05/rps-arrow-fixed.png);
background-size: cover !important;
background-position: top right !important;">
</div>
<video class="custom-homepage-hero-bg" src="https://rps.charcoal.website/wp-content/uploads/2021/03/iStock-1175940323.mp4" autoplay loop playsinline muted>
</video>
<div class="custom-homepage-hero">
<div class="homepage-slider-container hidden">
@davidallenlewis
davidallenlewis / quote-variation.js
Last active December 15, 2023 16:41
core/quote Block Variation
import { registerBlockVariation } from '@wordpress/blocks';
import { addFilter } from '@wordpress/hooks';
const VARIATION_NAME = 'allswater/custom-quote-test';
registerBlockVariation( 'core/quote', {
name: VARIATION_NAME,
title: 'Quote Variation',
//isActive: [ namespace, authorCredentials ],
isActive: ( { namespace, authorCredentials } ) => {