Skip to content

Instantly share code, notes, and snippets.

View JiveDig's full-sized avatar

Mike Hemberger JiveDig

View GitHub Profile
@JiveDig
JiveDig / acf-json-nested-tabs.json
Last active October 18, 2017 22:34
A Genesis-based page template for ACF Pro that allows nested tab groups. 1st level is horizontal tabs, 2nd level is vertical tabs. Uses Flexington for columns (not required but would need additional CSS. Works as-is in https://maipro.io.
[
{
"key": "group_59c02d79966e4",
"title": "Tabbed Content",
"fields": [
{
"key": "field_59c02db106f90",
"label": "Tabs",
"name": "tabs",
"type": "repeater",
@JiveDig
JiveDig / genesis-force-p-site-title.php
Created September 18, 2017 17:10
Force the Genesis site title to use 'p' whenever an 'h1' would be used.
<?php
// Force the site title to use 'p' whenever an 'h1' would be used.
add_filter( 'genesis_seo_title','prefix_force_p_site_title_wrap', 99, 3 );
function prefix_force_p_site_title_wrap( $title, $inside, $wrap ) {
$title = str_replace( '<h1', '<p', $title );
$title = str_replace( '</h1>', '</p>', $title );
return $title;
}
@JiveDig
JiveDig / sidebar-content-sidebar-equal-widths.php
Created July 28, 2017 16:43
Mai Pro - Force primary and secondary sidebars to the same width
<?php
// Add near the bottom of functions.php, without the above <?php
// Force secondary sidebar to 1/4th width on Sidebar Content Sidebar layout.
add_filter( 'genesis_attr_sidebar-primary', function( $attributes ) {
$layout = genesis_site_layout();
if ( 'sidebar-content-sidebar' !== $layout ) {
return $attributes;
}
$attributes['class'] = str_replace( 'col-lg-4', 'col-lg-3', $attributes['class'] );
@JiveDig
JiveDig / mai-adjacent-post-nav-by-category.php
Last active July 27, 2017 18:59
Add adjacent post navigation to posts in a specific category, by ID.
<?php
// Remove adjacent post nav.
add_action( 'after_setup_theme', function(){
remove_post_type_support( 'post', 'genesis-adjacent-entry-nav' );
});
/**
* Add adjacent post navigation to posts
* in a specific category, by ID.
@JiveDig
JiveDig / recursive-term-metadata.php
Created July 21, 2017 14:05
Get the specified metadata value for the term or from one of it's parent terms.
<?php
/**
* Get the specified metadata value for the term or from
* one of it's parent terms.
*
* @param WP_Term $term Term object
* @param string $key The meta key to retrieve.
* @param bool $check_enabled Whether to check if custom archive settings are enabled.
*
@JiveDig
JiveDig / functions.php
Created June 19, 2017 17:01
Ignore WooCommerce Membership product restrictions when facets are used on Shop page.
<?php
/**
* Ignore WooCommerce Membership product restrictions when facets are used on Shop page.
*
* @uses FacetWP
* @uses WooCommerce Memberships
*/
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
if ( 'wc_user_membership' == $query->get( 'post_type' ) ) {
@JiveDig
JiveDig / genesis_author_box_shortcode.php
Last active May 15, 2019 14:49
WordPress shortcode to Genesis author boxes by role or user ID(s)
/**
* Shortcode to get author box(es) by user IDs or roles.
* Originally taken from genesis_author_box()
*
* [author_box] will display the author box of the current post author.
* [author_box users="12,4,20"] will display author boxes of users 12, 4, and 20.
* [author_box users="12,4,20"] will display author boxes of users 12, 4, and 20.
* [author_box roles="author"] will display author boxes of all authors.
* [author_box roles="author, editor"] will display author boxes of all authors and contributors.
* [author_box roles="author, editor" exclude="24"] will display author boxes of all authors and contributors, excluding user 24.
@JiveDig
JiveDig / restful-p2p-connection-button.php
Last active May 31, 2021 23:34
Example usage of helper function to display a Restful P2P connection button. Uses https://github.com/JiveDig/restful-p2p/
<?php
$args = array(
'name' => 'users_to_pages', // name of the P2P connection
'from' => get_current_user_id(), // ID of the P2P 'from' object
'to' => get_the_ID(), // ID of the P2P 'to' object
'connect' => 'Connect', // Text to create a connection
'connected' => 'Connected!', // Text when a connection is already made
'loading' => 'Loading...', // Text to display while connection is being made
);
@JiveDig
JiveDig / restful-p2p-connection-button.php
Created August 27, 2016 23:16
Display a Restful P2P connection button
<?php
$args = array(
'name' => 'users_to_pages', // name of the P2P connection
'from' => get_current_user_id(), // ID of the P2P 'from' object
'to' => get_the_ID(), // ID of the P2P 'to' object
'connect' => 'Connect', // Text to create a connection
'connected' => 'Connected!', // Text when a connection is already made
'loading' => 'Loading...', // Text to display while connection is being made
);
@JiveDig
JiveDig / remove-tinymce-editor-buttons.php
Last active February 24, 2023 06:00
Remove buttons/items from the WordPress TinyMCE editor
<?php
/**
* Removes buttons from the first row of the tiny mce editor
*
* @link http://thestizmedia.com/remove-buttons-items-wordpress-tinymce-editor/
*
* @param array $buttons The default array of buttons
* @return array The updated array of buttons that exludes some items
*/
add_filter( 'mce_buttons', 'jivedig_remove_tiny_mce_buttons_from_editor');