Skip to content

Instantly share code, notes, and snippets.

Ben Word retlehs

Block or report user

Report or block retlehs

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
@retlehs
retlehs / disable-gutenberg.php
Created May 21, 2019
Disable Gutenberg for all post types without a plugin
View disable-gutenberg.php
<?php
/**
* Disable Gutenberg
*/
add_action('init', function () {
$types = get_post_types([], 'objects');
foreach ($types as $type) {
add_filter('use_block_editor_for_'.$type->name, '__return_false');
}
});
@retlehs
retlehs / sync-prod.sh
Last active Sep 20, 2018
WP-CLI aliases sync example
View sync-prod.sh
read -r -p "Would you really like to reset your development database and pull the latest from production? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
wp @development db reset --yes &&
wp @production db export - > sql-dump-production.sql &&
wp @development db import sql-dump-production.sql &&
wp @development search-replace https://example.com https://example.dev
fi
View wordpress.patch
diff U3 a/wp/wp-includes/load.php b/wp/wp-includes/load.php
--- a/wp/wp-includes/load.php Tue Feb 02 19:38:52 2016
+++ b/wp/wp-includes/load.php Tue Feb 02 19:58:21 2016
@@ -285,7 +285,7 @@
*/
function wp_debug_mode() {
if ( WP_DEBUG ) {
- error_reporting( E_ALL );
+ error_reporting( E_ALL & ~E_DEPRECATED );
@retlehs
retlehs / gist:e5683cb8377e1b1836ab
Created May 26, 2015
Don't be scared of Sage
View gist:e5683cb8377e1b1836ab

This is from a comment on the Advanced WordPress Facebook group by Kevin Hoffman.


Disclaimer: I'm not affiliated with Roots, just a satisfied user.

In response to several recent questions on the topic of starter themes, the following are my thoughts on what I believe is the best starter theme available today, along with a heads-up on an upcoming resource that may help you in the near future.

Recommendations for starter themes come up quite often in AWP, and my first instinct is to recommend Roots' Sage starter theme (https://roots.io/sage/), but to be honest, it's not for everyone. I feel like I always have to attach the caveat concerning the prerequisites: Node.js, gulp, Bower, CSS preprocessing, build processes, etc. I often see advanced devs discouraging others from trying Sage if they're not 100% up to date on all of these tools. Don't let that scare you.

@retlehs
retlehs / header.php
Created Apr 29, 2015
Sage header template for Bootstrap top navbar component
View header.php
<?php
// This file assumes that you have included the nav walker from https://github.com/twittem/wp-bootstrap-navwalker
// somewhere in your theme.
?>
<header class="banner navbar navbar-default navbar-static-top" role="banner">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only"><?= __('Toggle navigation', 'sage'); ?></span>
@retlehs
retlehs / gist:01477d70c01f50a87553
Created Apr 14, 2015
Enable test mode for Easy Digital Downloads if you're not on production
View gist:01477d70c01f50a87553
<?php
/**
* If not on production, enable test mode for Easy Digital Downloads
*/
add_action('edd_is_test_mode', function() {
return WP_ENV !== 'production';
});
View an-introduction-to-the-roots-theme-wrapper.md

After reading through this guide, you will:

  • Understand the Roots Wrapper and recognize how it extends and complements the WordPress template hierarchy.
  • Know what is meant by the DRY Principle, why being DRY bests being WET, and see how most WordPress themes are WET.
  • Be able to filter the Roots Wrapper and create a new base template for a Custom Post Type.

Template Hierarchy

WordPress is pretty smart. Every time you load up a request it will search for the most relevant template available in your theme and load it. This is the Template Hierarchy in action and it enables us to easily customize the appearance of our sites.

@retlehs
retlehs / gist:4120053
Created Nov 20, 2012
Remove unnecessary markup from WooCommerce
View gist:4120053
<?php
/**
* Remove unnecessary markup from WooCommerce:
*
* 1. Remove <meta name="generator" content="WooCommerce (version)" />
* 2. Remove the addition of <body class="theme-themename">
*/
function woocommerce_head_cleanup() {
global $woocommerce;
@retlehs
retlehs / gist:2785401
Created May 25, 2012
Display YouTube thumbnail from embed URL
View gist:2785401
<?php
/**
* Display a thumbnail from YouTube based off the embed code saved in the
* video post format metabox used by the CF Post Formats plugin
*
* @link https://github.com/crowdfavorite/wp-post-formats
* @link http://stackoverflow.com/a/6382259
*/
global $post;
@retlehs
retlehs / gist:2703644
Created May 15, 2012
Add a class to widgets in a specific sidebar
View gist:2703644
<?php
/**
* Add 'class="span4"' to all widgets in the Content Bottom sidebar
*/
function bb_content_bottom_widget_class($params) {
if ($params[0]['id'] == 'roots-content-bottom') {
$class = 'class="span4 ';
$params[0]['before_widget'] = preg_replace('/class=\"/', "$class", $params[0]['before_widget'], 1);
}
You can’t perform that action at this time.