Skip to content

Instantly share code, notes, and snippets.

Robin Cornett robincornett

Block or report user

Report or block robincornett

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@robincornett
robincornett / functions.php
Created Oct 16, 2019
Add the editor color palette to your site using wp_inline_style
View functions.php
<?php
add_action( 'enqueue_block_assets', 'rgc_editor_color_palette', 15 );
/**
* Add custom colors to the site using wp_inline_style, attached to the wp-block-library stylesheet.
* Colors must be defined in your theme or functionality plugin.
*/
function rgc_editor_color_palette() {
list( $colors, ) = (array) get_theme_support( 'editor-color-palette' );
if ( ! $colors ) {
@robincornett
robincornett / functions.php
Created Oct 14, 2019
Add custom editor font sizes to your site after the block library styles using wp_inline_style.
View functions.php
<?php
add_action( 'enqueue_block_assets', 'rgc_editor_font_sizes', 15 );
/**
* Add custom font sizes to the site using wp_inline_style, attached to the wp-block-library stylesheet.
* Editor font sizes must be defined in your theme.
*/
function rgc_editor_font_sizes() {
list( $font_sizes, ) = (array) get_theme_support( 'editor-font-sizes' );
if ( ! $font_sizes ) {
@robincornett
robincornett / functions.php
Created Sep 11, 2019
Sample code to add the Print Friendly service as a scriptless sharing button
View functions.php
<?php
add_filter( 'scriptlesssocialsharing_networks', 'rgc_scriptless_networks' );
/**
* Add Print Friendly to settings/allowed sharing buttons
*
* @param $networks
*
* @return mixed
*/
@robincornett
robincornett / functions.php
Created Aug 27, 2019
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).
View functions.php
<?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 Aug 21, 2019
Update Genesis comments to include only the date, not the time, the comment was posted.
View comments-remove-date.php
<?php
// Completely remove the date and time from comments.
add_filter( 'genesis_show_comment_date', '__return_false' );
@robincornett
robincornett / twitter-modification.php
Created Apr 23, 2019
Add a hashtag to all Twitter sharing buttons on a site (in Scriptless 3.0.0)
View twitter-modification.php
<?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 Mar 4, 2019
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.
View functions.php
<?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 / functions.php
Created Jan 30, 2019
Sample code to add Facebook Messenger as a sharing button to Scriptless Social Sharing.
View functions.php
<?php
add_filter( 'kses_allowed_protocols', 'prefix_allow_messenger' );
/**
* Add Facebook Messenger to the list of allowed URL protocols in WordPress.
*
* @param $protocols
*
* @return array
*/
@robincornett
robincornett / pocket.php
Last active Dec 17, 2018
Add a button for Pocket to Scriptless Social Sharing.
View pocket.php
<?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 Jun 27, 2018
Code snippet to add the WooCommerce cart quantity and total to a SuperSide Me custom cart button.
View woocommerce.php
<?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
*/
You can’t perform that action at this time.