Skip to content

Instantly share code, notes, and snippets.

View colorful-tones's full-sized avatar
💓
Don’t believe the hype!

Damon Cook colorful-tones

💓
Don’t believe the hype!
View GitHub Profile
<!-- CURRENT block markup -->
<div class="wp-block-group cards">
<div class="wp-block-cover">
</div><!-- .wp-block-cover -->
</div><!-- .wp-block-group -->
<!-- DESIRED block markup -->
<ul class="wp-block-group cards">
<li class="wp-block-cover card"></li>
@colorful-tones
colorful-tones / twentytwentyfour-mock.json
Last active June 10, 2024 21:12
Testing Section Styles in WP 6.6 Beta 1
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 3,
"title": "Mock",
"blockTypes": [ "core/paragraph" ],
"styles": {
"color": {
"background": "#93008A",
"text": "#FFFB20"
},
@colorful-tones
colorful-tones / acf-field-group-demo.php
Last active April 26, 2024 14:29
ACF Chat Fridays - April 26, 2024 - Block Bindings with ACF demo
add_action( 'acf/include_fields', function() {
if ( ! function_exists( 'acf_add_local_field_group' ) ) {
return;
}
acf_add_local_field_group( array(
'key' => 'group_662ae89971cc7',
'title' => 'Call to action',
'fields' => array(
array(
@colorful-tones
colorful-tones / functions-alternative-approach.php
Last active April 18, 2024 20:39
Override core/navigation block styles without using `!important` (see comment below for implementation details)
/**
* Enqueues custom block styles for the theme.
*
* This function scans the styles folder in the theme to locate block styles.
* It then enqueues each block style using the `wp_enqueue_block_style` function.
*
* @url https://developer.wordpress.org/reference/functions/wp_enqueue_block_style/
*/
function devrel_enqueue_custom_block_styles() {
@colorful-tones
colorful-tones / my_link.php
Created January 9, 2024 16:30
Parsing an ACF Link field type with defaults
@colorful-tones
colorful-tones / my-plugin.php
Last active December 6, 2023 21:35
Load JavaScript once on the page if a core block exists. As adapted from https://wordpress.stackexchange.com/a/328553
function enqueue_my_awesome_script_if_there_is_block( $content = '' ) {
if ( has_block( 'core/list' ) ) {
wp_enqueue_script(
'my-awesome-script',
plugins_url( 'hello-world.js', __FILE__ ),
array(),
'0.1.1',
true
);
}
<?php
/**
* Limit capabilities of editing ACF fields,
* post types, taxonomies and more in WP Admin.
*/
/**
* @link https://www.advancedcustomfields.com/resources/how-to-hide-acf-menu-from-clients/
*/
add_filter( 'acf/settings/show_admin', 'demo_acf_show_admin' );
<?php
/**
* This file adds functions to the child WordPress theme.
*/
/**
* Check for Notification Bar, and display it.
*/
function demo_acf_output_notification() {
$has_notice = get_field( 'notification_bar', 'options' );
name: Deploy to a WP Engine Development environment
on:
push:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@colorful-tones
colorful-tones / .gitignore
Last active June 22, 2024 07:41
An example .gitignore optimized for WP Engine hosting
#----------------------------------------
# This Git ignore should be located
# in your WordPress install's wp-content/
# directory.
#----------------------------------------
#---------------------------
# WordPress general
#---------------------------
/index.php