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 / 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() ) {
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 / 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' ) ) {
View genesis-search-form-label.php
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Customize Genesis search form label
add_filter( 'genesis_search_form_label', 'b3m_search_form_label' );
function b3m_search_form_label ( $text ) {
return esc_attr( 'Enter your text here...' );
View functions.php
<?php
//* Do NOT include the opening php tag
//* Enqueue FontAwesome. Note that the current version in the code is 4.5.0. Update as necessary.
//* https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts
//* https://fortawesome.github.io/Font-Awesome/icons/
<?php
//* Do NOT include the opening php tag
@rickrduncan
rickrduncan / 0_reuse_code.js
Created Jan 17, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View wp-dashboard-widget.php
<?php
//* Do NOT include the opening php tag
//* Add theme info box into WordPress Dashboard
add_action('wp_dashboard_setup', 'b3m_add_dashboard_widgets' );
function b3m_add_dashboard_widgets() {
wp_add_dashboard_widget('wp_dashboard_widget', 'Theme Details', 'b3m_theme_info');
}
View wp-admin-footer-text.php
View wp-failed-login.php
<?php
//* Do NOT include the opening php tag
//* Login Screen: Don't inform user which piece of credential was incorrect
add_filter ( 'login_errors', 'b3m_failed_login' );
function b3m_failed_login () {
return 'The login information you have entered is incorrect. Please try again.';
}
View wp-remember-me.php
<?php
//* Do NOT include the opening php tag
//* Login Screen: Set 'remember me' to be checked
add_action( 'init', 'b3m_login_checked_remember_me' );
function b3m_login_checked_remember_me() {
add_filter( 'login_footer', 'b3m_rememberme_checked' )
;
}
You can’t perform that action at this time.