Skip to content

Instantly share code, notes, and snippets.

@robincornett
robincornett / functions.php
Created August 27, 2019 18:56
Sample function to change the banner featured image output in Display Featured Image for Genesis to a slideshow. This example is not applied conditionally, so would change the output sitewide. It starts with four image IDs and adds them to the slider output as URLs (required).
<?php
add_filter( 'display_featured_image_genesis_backstretch_variables', 'rgc_test_slider_filter' );
/**
* Change the banner featured image to be a slidehow sitewide.
*
* @param array $variables
* @return array
*/
function rgc_test_slider_filter( $variables ) {
@robincornett
robincornett / comments-remove-date.php
Last active August 21, 2019 14:55
Update Genesis comments to include only the date, not the time, the comment was posted.
<?php
// Completely remove the date and time from comments.
add_filter( 'genesis_show_comment_date', '__return_false' );
@robincornett
robincornett / plugins-supersideme.php
Created May 7, 2018 12:30
Suggested/optional code for multisite and SuperSide Me, if the preference is to use the same settings on all sites in the network.
<?php
// Disable the SuperSide Me settings page and customizer panel on child sites
if ( ! is_main_site() ) {
add_filter( 'supersideme_disable_customizer_panel', '__return_true' );
add_filter( 'supersideme_disable_settings_page', '__return_true' );
}
add_filter( 'supersideme_get_plugin_setting', 'prefix_supersideme_use_main_site_setting', 20 );
/**
@robincornett
robincornett / functions.php
Last active April 29, 2019 14:59
Modify the "no content matched your criteria" message in Genesis
<?php
// do not include the opening tag
add_filter( 'genesis_noposts_text', 'leaven_change_search_text_one', 10, 2 );
function leaven_change_search_text_one( $text ) {
$text .= __( ' Would you like to try again?', 'leaven' );
$text .= get_search_form( false );
return $text;
@robincornett
robincornett / twitter-modification.php
Created April 23, 2019 20:06
Add a hashtag to all Twitter sharing buttons on a site (in Scriptless 3.0.0)
<?php
add_filter( 'scriptlesssocialsharing_twitter_query_args', 'prefix_add_twitter_hashtag_scriptless' );
/**
* Add a hashtag to every Twitter button on a site.
* Requires Scriptless Social Sharing 3.0.0
*
* @param $query_args
* @return mixed
*/
@robincornett
robincornett / functions.php
Created March 4, 2019 22:58
Use Simple Social Icons' SVG in Scriptless Social Sharing. Note: unless you are enqueueing the SSI CSS/JS independently, these will only work on pages where an instance of the SSI widget is being output.
<?php
add_filter( 'scriptlesssocialsharing_link_markup', 'prefix_modify_scriptless_link_markup', 10, 2 );
/**
* Add SVG icons to Scriptless sharing buttons.
*
* @param $output
*
* @param $button
*
@robincornett
robincornett / pocket.php
Last active December 17, 2018 13:53
Add a button for Pocket to Scriptless Social Sharing.
<?php
add_filter( 'scriptlesssocialsharing_pocket_url', 'prefix_add_pocket', 10, 3 );
/**
* Create the URL for the Pocket share/save button.
*
* @param $url
* @param $button
* @param $attributes
*
@robincornett
robincornett / woocommerce.php
Created June 27, 2018 18:06
Code snippet to add the WooCommerce cart quantity and total to a SuperSide Me custom cart button.
<?php
add_filter( 'supersideme_custom_buttons', 'prefix_add_woocommerce_quantity_total_button' );
/**
* Add the WooCommerce quantity and total to a shopping cart button.
*
* @param $buttons
*
* @return mixed
*/
@robincornett
robincornett / update.txt
Last active May 31, 2018 14:45
Updated responsive, mobile first, accessible, navigation menus for Genesis child themes. Uses SVG icons, and submenu toggle buttons on all screens. Submenus open on click/keypress/hover, but can be bypassed. Do not include Genesis support for accessible menus. Accommodations for no-JS users.
now located at: https://github.com/robincornett/leaven-responsive-menu
@robincornett
robincornett / svg-get.php
Last active May 8, 2018 18:15
Output SVG icons in shortcodes.
<?php
/**
* Build the string/markup for an SVG icon.
*
* @param $icon
*
* @param array $args
*
* @return string