Skip to content

Instantly share code, notes, and snippets.

@secretstache
secretstache / acf-hero-unit.json
Created November 8, 2016 02:55
Hero Unit Snippets
[
{
"key": "group_562025a91d355",
"title": "Hero Unit",
"fields": [
{
"key": "field_5620264fa0141",
"label": "Background Media",
"name": "background_media",
"type": "radio",
<?php
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'group_5525dfd96b4a0',
'title' => 'Brand Logo',
'fields' => array (
array (
'key' => 'field_5525dff1be331',
@secretstache
secretstache / data-attributes.php
Created July 28, 2016 16:48
data attributes for genesis
add_filter( 'genesis_attr_site-container', 'ssm_data_off_canvas_content' );
function ssm_data_off_canvas_content($attributes) {
$attributes['data'] = 'data-off-canvas-content';
return $attributes;
}
// this creates <div class="site-container" data='data-off-canvas-content'></div>
// is there a way to do something like <div class="site-container" data-off-canvas-content></div>
@secretstache
secretstache / acf-cac.php
Created April 8, 2015 23:41
Append ACF Post Object to Admin Column Pro Filter Dropdown
<?php
/**
* Filter the Admin Column results
*
*/
function my_cac_filtering_options_change_acf_label( $options, $column ) {
$column_type = 'column-acf_field'; // enter type of field. You can find this by hovering of the Type label of the column settings.
$field_label = 'Product Class'; // enter label of the ACF field.
@secretstache
secretstache / cart66-viewcart.php
Created April 8, 2015 16:35
Cart 66 Shortcode for View Cart
//Filter Through Store Nav
add_filter( 'wp_nav_menu_items', 'ssm_append_store_navigation', 10, 2 );
function ssm_append_store_navigation ( $items, $args ) {
if ( do_shortcode('[cc_cart_item_count]') == 1 ) {
$cart_item = '<li class="right cart"><a href="' . get_bloginfo('url') . '/view_cart/">' . do_shortcode('[cc_cart_item_count]') . ' Item</a></li>';
} else {
@secretstache
secretstache / layout.php
Created March 24, 2015 19:22
force content sidebar genesis
//* Force content-sidebar layout setting
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
@secretstache
secretstache / get-video-thumbnail.php
Last active January 16, 2024 09:43
Get Video Thumbnail from Youtube or Vimeo
<?php
/**
* Retrieves the thumbnail from a youtube or vimeo video
* @param - $src: the url of the "player"
* @return - string
* @todo - do some real world testing.
*
**/
function get_video_thumbnail( $src ) {
@secretstache
secretstache / acf-soliloquy.php
Created February 26, 2015 22:11
Dynamic Soliloquy Slideshow using ACF
<?php
add_action( 'genesis_after_header', 'ssm_insert_slideshow', 99 );
/**
* Builds the HTML for the homepage slideshow
*
*/
function ssm_insert_slideshow() { ?>
<?php if ( $slides = get_field( 'slides' ) ) { ?>
@secretstache
secretstache / admin-body-class-home.php
Last active August 29, 2015 14:13
Adds a unique body class to the editor screen of a specific page, in this case the home page
add_filter( 'admin_body_class', 'ssm_home_admin_body_class' );
/*
* Adds a body class to target the home page edit screen
*
*/
function ssm_home_admin_body_class( $classes ) {
global $post;
$screen = get_current_screen();
$homepage = get_page_by_title( 'Home' );
@secretstache
secretstache / gist:9f0a93a9953361edb7bb
Last active February 4, 2016 07:10
Get First Instance of Visual Editor Content Block
<?php
/*
* Returns the first instance of a given layout option
* @param - $id - the id of the post you are trying to target: '' by default
* @param - $fc_field - the name of the ACF flexible field: 'content_blocks' as the default
* @param - $fc_layout - the name of the flexible content layout: 'visual_editor' as the default
* @return - mixed
* @todo - test different types of returned content. at the moment, I am only using this for returning a string
*/
function get_first_instance_of_content_block( $id = '', $fc_field = 'content_blocks', $fc_layout = 'visual_editor' ) {