Skip to content

Instantly share code, notes, and snippets.

View craigsimps's full-sized avatar

Craig Simpson craigsimps

View GitHub Profile
@craigsimps
craigsimps / functions.php
Last active December 8, 2023 10:47
Escape the output of an ACF Wysiwyg field, but allow for oEmbed video and shortcodes.
<?php
function return_escaped_acf_wysiwyg( $field, $post_id = false ) {
// if there's no post id defined, get id from current post.
if( !$post_id ) {
$post_id = (int) get_the_ID();
}
// get the kses'd content
<?php
add_action( 'bcn_after_fill', 'project_rebuild_breadcrumb' );
/**
* Rebuild the breadcrumb created by Breadcrumb NavXT.
*
* @param bcn_breadcrumb_trail $breadcrumb Instance of the currently active breadcrumb trail.
*/
function project_rebuild_breadcrumbs( $breadcrumb ) {
@craigsimps
craigsimps / functions.php
Last active April 8, 2022 04:34
Example of multiple uses of genesis_register_sidebar.
<?php
//* Register widget areas
genesis_register_sidebar( array(
'id' => 'home-section-1',
'name' => __( 'Home Section 1', 'parallax' ),
'description' => __( 'This is the home section 1 section.', 'parallax' ),
) );
genesis_register_sidebar( array(
'id' => 'home-section-2',
<?php
add_filter( 'gform_form_post_get_meta', __NAMESPACE__ . '\\enforce_gravity_forms_anti_spam_honeypot' );
/**
* Enforce anti-spam honeypot on all Gravity forms.
*
* @param array $form The current form to be filtered.
*
* @return array
*/
/* ========================================================================
* DOM-based Routing
* Based on http://goo.gl/EUTi53 by Paul Irish
* ======================================================================== */
(function ($) {
var Whitespace = {
common: {
init: function () {
// Run everywhere.
<?php
/**
* Remove redundant Genesis meta boxes.
*
* @param string $pagehook Page hook for the Theme Settings page.
*
* @since 1.1.0
*/
add_action( 'genesis_theme_settings_metaboxes', function ( $pagehook ) {
<?php
/**
* Generico Core
*
* Core plugin, holding theme-agnostic functionality specific to the site.
*
* @package Generico\Core
* @author Craig Simpson <craig@craigsimpson.scot>
* @license MIT
* @link https://craigsimpson.scot
<?php
/**
* Stop Genesis adding `header-*` classes to <body>.
*
* @since 1.0.0
*/
remove_filter( 'body_class', 'genesis_header_body_classes' );
<?php
add_action( 'genesis_meta', __NAMESPACE__ . '\\remove_redundant_markup' );
/**
* Remove the redundant .site-inner and .content-sidebar-wrap markup.
*
* @since 1.0.0
*/
function remove_redundant_markup() {
<?php
/**
* Template Name: Testimonials - ACF Functions
*/
add_action( 'genesis_entry_content', 'prefix_output_testimonials' );
/**
* Output ACF testimonials.
*
* @link https://acfextras.com/simple-testimonials-repeater-field/