Skip to content

Instantly share code, notes, and snippets.

@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
@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 / plugins-scriptlesssocialsharing.php
Last active May 7, 2018 13:31
Change Scriptless Social Sharing links to use SVG icons instead of CSS pseudo elements
<?php
add_filter( 'scriptlesssocialsharing_link_markup', 'leaven_modify_scriptless_link_markup', 10, 2 );
/**
* Add SVG icons to Scriptless sharing buttons.
*
* @param $output
*
* @param $button
*
@robincornett
robincornett / supersideme-svg_01.php
Last active March 8, 2018 18:35
Tell SuperSide Me (2.4.0) to use your theme's SVG icons.
<?php
add_filter( 'supersideme_svg', 'leaven_prefer_theme_svg' );
/**
* Tell SuperSide Me not to load any icons.
* @param $args
*
* @return mixed
*/
function leaven_prefer_theme_svg( $args ) {
@robincornett
robincornett / scriptless-amp.php
Last active January 31, 2018 19:30
Example for adding Scriptless Social Sharing buttons to an AMP page (requires the Automattic AMP plugin).
<?php
add_action( 'pre_amp_render_post', 'prefix_add_scriptless_amp' );
/**
* Add Scriptless Social Sharing buttons to AMP posts
* (using the Automattic AMP plugin: https://wordpress.org/plugins/amp/).
*/
function prefix_add_scriptless_amp() {
if ( ! function_exists( 'scriptlesssocialsharing_do_buttons' ) ) {
return;
@robincornett
robincornett / 00-functions.php
Last active November 20, 2017 17:22
Functions to help Bylines (https://bylines.io/) and the Genesis Framework play nicely together
<?php
add_action( 'init', 'leaven_load_bylines' );
/**
* Maybe load Bylines files.
*/
function leaven_load_bylines() {
if ( ! function_exists( 'the_bylines' ) ) {
return;
}
@robincornett
robincornett / Updater-1.7.php
Created November 17, 2017 13:45
Comparing updater classes in Envira 1.6.1.6 and 1.7.x (rewrite)
<?php
/**
* Updater class.
*
* @since 1.7.0
*
* @package Envira_Gallery
* @author Envira Gallery Team
*/
@robincornett
robincornett / plugin.php
Created November 10, 2017 18:52
Code snippet to add a custom plugin icon to the WordPress plugins update page. Icons were added to this page in WordPress 4.9 and are automatically shown for plugins hosted in the WordPress repository, but not for plugins hosted/updated elsewhere.
<?php
add_filter( 'all_plugins', 'prefix_add_plugin_icon' );
/**
* Add a custom plugin icon to the plugins update page (introduced in WP4.9).
*
* @param $plugins
*
* @return mixed
*/