Skip to content

Instantly share code, notes, and snippets.

View chuckreynolds's full-sized avatar
🤖
building things

Chuck Reynolds chuckreynolds

🤖
building things
View GitHub Profile
@chuckreynolds
chuckreynolds / get_image_tag_class.php
Last active June 23, 2016 09:02
Adds classes to attached images when saving a new image in the post editor. Doesn't add for old images.
<?php
function foo_no_print_class( $class ) {
return $class . ' print-no';
}
add_filter( 'get_image_tag_class', 'foo_no_print_class' );
@chuckreynolds
chuckreynolds / unregister-simple-social-buttons-plus.php
Last active June 28, 2016 07:08
Simple Social Buttons Plus loads CSS & JS on every page, testing this to start to remove that stuff on anything but is_single()
<?php
/*
* Unregistering Simple Social Buttons Plus plugin test
*/
function XX_deregister_styles() {
if ( ! is_single() ) {
wp_deregister_style( 'ssbp_styles' );
}
}
add_action( 'wp_print_styles', 'XX_deregister_styles', 100 );
@chuckreynolds
chuckreynolds / nightbot-commands-reference.md
Last active December 12, 2022 08:33
Nightbot commands reference for Twitch and sometimes youtube gaming. Most are accessible via google and reading many docs but I like to keep things in one location for reference. If you want to see something here lmk on Twitter: https://twitter.com/chuckreynolds or comment below.

General stuff

Add, Edit, Delete Commands

  • !addcom !keyword New text here
  • !editcom !keyword Edited version of the text here
  • !delcom !keyword

Reference the user whom entered command

  • $(user)

Reference user-entered text

@chuckreynolds
chuckreynolds / 3-recent-posts.php
Created March 19, 2016 20:34
WordPress: Loop through 3 most recent posts from each category
<?php
/**
* Loop through 3 most recent posts from each category
* @see http://codex.wordpress.org/Function_Reference/get_categories
*/
$do_not_duplicate = array();
$categories = get_categories();
foreach ( $categories as $category ) :
$args = array(
@chuckreynolds
chuckreynolds / norcross-debug-functions.php
Created March 10, 2016 19:10 — forked from norcross/norcross-debug-functions.php
my list of debugging functions to keep in an MU file
<?php
/*
Plugin Name: Norcross Debug Functions
Plugin URI: https://gist.github.com/norcross/7864205/
Description: A set of functions I use on all sites while building
Author: Andrew Norcross
Version: 0.0.1
Requires at least: 3.0
Author URI: http://andrewnorcross.com
*/
@chuckreynolds
chuckreynolds / current-url.php
Created February 26, 2016 06:38
testing better way to get the current url in wordpress. resourced from: https://roots.io/routing-wp-requests/
<?php
function get_current_url() {
// Get current URL path, stripping out slashes on boundaries
$current_url = trim(esc_url_raw(add_query_arg([])), '/');
// Get the path of the home URL, stripping out slashes on boundaries
$home_path = trim(parse_url(home_url(), PHP_URL_PATH), '/');
// If a URL part exists, and the current URL part starts with it...
if ($home_path && strpos($current_url, $home_path) === 0) {
// ... just remove the home URL path form the current URL path
$current_url = trim(substr($current_url, strlen($home_path)), '/');
@chuckreynolds
chuckreynolds / wordpress-publish-facebook-recrawl.php
Created November 11, 2015 10:34
Ping Facebook Graph to crawl (scrape) or rescrape the URL if a scheduled post goes live or a draft is published. Depending on this specific need I may just do it on any time status goes to publish regardless of the old status.
<?php
/**
* If post goes from "future" (scheduled) or "draft" to "publish" then alert facebook to (re)crawl it.
* @see https://codex.wordpress.org/Post_Status_Transitions#transition_post_status_Hook
*/
function chuck_notify_facebook_scraper( $new_status, $old_status, $post ) {
if ( $new_status != 'publish' ) {
return;
}
@chuckreynolds
chuckreynolds / remove-genesis-settings-metaboxes.php
Last active June 13, 2018 06:25
Sometimes you need to remove some of the metaboxes from within the Genesis theme settings page - ideally the theme scripts - don't like clients randomly adding things without testing them first.
<?php
/**
* Remove Genesis Framework settings page metaboxes
*/
function chuck_remove_genesis_metaboxes( $_genesis_theme_settings_pagehook ) {
remove_meta_box( 'genesis-theme-settings-version', $_genesis_theme_settings_pagehook, 'main' ); // metabox: Information
remove_meta_box( 'genesis-theme-settings-feeds', $_genesis_theme_settings_pagehook, 'main' ); // metabox: Custom Feeds
remove_meta_box( 'genesis-theme-settings-layout', $_genesis_theme_settings_pagehook, 'main' ); // metabox: Default Layout
remove_meta_box( 'genesis-theme-settings-header', $_genesis_theme_settings_pagehook, 'main' ); // metabox: Header (site/title logo)
remove_meta_box( 'genesis-theme-settings-breadcrumb', $_genesis_theme_settings_pagehook, 'main' ); // metabox: Breadcrumbs
@chuckreynolds
chuckreynolds / rcp-protect-anything.php
Last active August 14, 2016 22:33
Restrict Content Pro doesn't seem to automatically protect post, category, taxonomy, custom post type, archives. This is a problem for me. It will however protect pages when the settings are correct so I made this redirect action for the top of my archive.php, taxonomy.php, single.php, page.php pages. This will work too when using template files…
<?php
/**
* Global Action to check if RCP user is logged; if not -> auth.
*
* RCP doesn't seem to protect archives that aren't pages or all posts/pages
* by default so this is my fix.
*/
function chuck_is_rcp_active () {
if ( ! rcp_is_active() ) :
@chuckreynolds
chuckreynolds / rcp-change-metabox-priority.php
Last active September 25, 2015 04:20
Restrict Content Pro defaults its post metabox to high. It was displaying above custom meta boxes on my custom post types and well I can't have that. So here's the filter to bump it to low.
<?php
/**
* RCP metabox is higher than cpt metafields so
* let's lower that priority a bit
*/
function chuck_rcp_chill_priority() {
return 'low';
}
add_filter( 'rcp_metabox_priority', 'chuck_rcp_chill_priority' );