Skip to content

Instantly share code, notes, and snippets.

Rick R. Duncan rickrduncan

Block or report user

Report or block rickrduncan

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
@rickrduncan
rickrduncan / oembed-gist.php
Last active Oct 3, 2019
A quick fix to this plugin: http://wordpress.org/plugins/oembed-gist/. Line 57, 61 & 69 were changed to rename the variable from 'gist' to 'oe-gist.' Line 79 was edited to add isset() to stop the error I was getting while testing.
View oembed-gist.php
<?php
/*
Plugin Name: oEmbed Gist
Plugin URI: http://firegoby.jp/wp/oembed-gist
Description: Embed source from gist.github.
Author: Takayuki Miyauchi
Version: 1.4.0
Author URI: http://firegoby.jp/
*/
@rickrduncan
rickrduncan / wordpress-functionality-plugin.php
Last active Sep 29, 2019
This WordPress functionality plugin contains code snippets that tweak WordPress core and do not contain theme specific functionality. This is code that I run on every single website I build using WordPress.
View wordpress-functionality-plugin.php
<?php
/**
* Plugin Name: WordPress Functionality Plugin
* Plugin URI: http://rickrduncan.com/wordpress/functionality-plugin
* Description: Core WordPress customizations that are theme independent.
* Author: Rick R. Duncan - B3Marketing, LLC
* Author URI: http://rickrduncan.com
*
*
* Version: 1.0.0
@rickrduncan
rickrduncan / genesis-page-titles-html5.php
Last active Sep 8, 2019
How to remove page titles from Genesis child themes using XHTML and HTML5 methods.
View genesis-page-titles-html5.php
<?php
//* Do NOT include the opening php tag
//* ALL EXAMPLES ON THIS PAGE USE THE NEW HTML5 METHOD
//* Remove page titles site wide (posts & pages) (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
View GTM-LinkOpener.js
<script>
var links = document.links;
for (var i = 0, linksLength = links.length; i < linksLength; i++) {
if (links[i].hostname != window.location.hostname && links[i].protocol != 'tel:' && links[i].protocol != 'mailto:' ) {
links[i].target = '_blank';
links[i].rel = 'noopener noreferrer';
}
}
</script>
@rickrduncan
rickrduncan / author-breadcrumb.php
Last active Dec 21, 2018
Customize Genesis breadcrumb
View author-breadcrumb.php
<?php
//* Do NOT include the opening php tag
//* Prefix author breadcrumb trail with the text 'Articles written by'
add_filter( 'genesis_breadcrumb_args', 'b3m_prefix_author_breadcrumb' );
function b3m_prefix_author_breadcrumb( $args ) {
$args['labels']['author'] = 'Articles written by ';
return $args;
@rickrduncan
rickrduncan / remove-cf7-css.php
Last active May 27, 2018
WordPress code snippet to remove contact form 7 bloat. Please visit http://rickrduncan.com/pro/wordpress/deregister-cf7-scripts-styles for details.
View remove-cf7-css.php
<?php
//* Do NOT include the opening php tag above
/**
*
* Remove Contact Form 7 CSS stylesheet from all pages except where needed.
*
*/
add_action('wp_print_styles', 'rrd_remove_cf7_css');
function rrd_remove_cf7_css() {
if ( function_exists( 'wpcf7_enqueue_styles' ) ) {
@rickrduncan
rickrduncan / posts-orderby-modified-date.php
Last active Nov 14, 2017
Order Posts by modified date on Archive pages.
View posts-orderby-modified-date.php
<?php
//* Do NOT include the opening php tag above
/**
* Sort Posts by "last modified date"
*
*/
add_filter('posts_orderby', 'b3m_order_posts_by_mod_date', 999);
function b3m_order_posts_by_mod_date($orderby) {
if ( is_archive() ) {
@rickrduncan
rickrduncan / custom-genesis-search-form.php
Last active Nov 9, 2017
508 compliant Genesis search form
View custom-genesis-search-form.php
<?php
//* Do NOT include the opening php tag
//* Alter the Genesis Search for so that we can change the destination page and our querystring parameter.
add_filter( 'genesis_search_form', 'b3m_search_form', 10, 4);
function b3m_search_form( $form, $search_text, $button_text, $label ) {
$onfocus = " onfocus=\"if (this.value == '$search_text') {this.value = '';}\"";
$onblur = " onblur=\"if (this.value == '') {this.value = '$search_text';}\"";
$form = '<form role="search" method="get" class="searchform search-form" action="' . home_url() . '/search">
View custom_widgets.php
<?php
/**
* Recent_Posts widget class
*
* @since 2.8.0
*/
class WP_Widget_Recent_Posts_Custom extends WP_Widget_Recent_Posts {
function __construct() {
@rickrduncan
rickrduncan / schema-logo.php
Last active May 15, 2017
Filter the Genesis 2.0 SEO title to remove the H1 tag and implement the Organization/Logo schema.
View schema-logo.php
<?php
//* Do NOT include the opening php tag
//* Add Organization schema to our logo
//* Note that logo location is not inside WordPress. It's in a folder named 'img' off of the root of website.
add_filter( 'genesis_seo_title', 'b3m_header_title', 10, 3 );
function b3m_header_title( $title, $inside, $wrap ) {
$inside = sprintf( '<div itemscope="itemscope" itemtype="http://schema.org/Organization"><a itemprop="url" href="%s" title="%s"><img class="logo" itemprop="logo" src="http://www.YOUR-DOMAIN.com/img/YOUR-LOGO.png" alt="%s" /></a></div>', trailingslashit( home_url() ), esc_attr( get_bloginfo( 'name' ) ), get_bloginfo( 'name' ) );
return sprintf( '<%1$s id="title">%2$s</%1$s>', 'span', $inside );
}
You can’t perform that action at this time.