Skip to content

Instantly share code, notes, and snippets.

View BeardedGinger's full-sized avatar

Josh Mallard BeardedGinger

View GitHub Profile
<?php
add_filter( 'set_url_scheme', 'lc_force_secure_scheme', 10, 3 );
/**
* Force all URLs run through the set_url_scheme to always be https if they're
* being accessed through our reverse proxy.
*
* @param string $url The complete URL including scheme and path.
* @param string $scheme Scheme applied to the URL. One of 'http', 'https', or 'relative'.
* @param string|null $orig_scheme Scheme requested for the URL. One of 'http', 'https', 'login',
* 'login_post', 'admin', 'relative', 'rest', 'rpc', or null.
@BeardedGinger
BeardedGinger / create reverse-proxy-conditional.php
Last active December 12, 2016 21:56
Reverse Proxy Conditional
<?php
/**
* Conditional to check if we're being served via the Reverse Proxy.
* The URL for the Forwarded Server below (example.com) should be the final
* URL for the site using the Reverse Proxy.
*/
function lc_is_reverse_proxy() {
if ( 'www.example.com' === $_SERVER['HTTP_X_FORWARDED_SERVER'] ) {
return true;
<?php
add_filter( 'register_post_type_args', 'lc_change_registered_post_type_slug', 10, 2 );
/**
* Change the slug for a registered post type.
*
* @param array $args Array of arguments for registering a post type.
* @param string $post_type Post type key.
*/
function lc_change_registered_post_type_slug( $args, $post_type ) {
<?php
/**
* Plugin Name: Reverse Proxy for WordPress Multisite
* Plugin URI: https://limecuda.com/
* Description: Reverse proxy setup for a WordPress multisite in subdirectory mode
* Version: 1.0.0
* Author: Josh Mallard
* Author URI: https://limecuda.com
*
* @package reverse-proxy-wp-multisite
@BeardedGinger
BeardedGinger / WooCommerce Template
Created September 23, 2013 20:12
WooCommerce Template page for Genesis Child Theme
<?php
/**
* WooCommerce Template
*
* Template used for all WooCommerce views for your site
*
*/
//* Remove standard post content output
remove_action( 'genesis_loop', 'genesis_do_loop');
@BeardedGinger
BeardedGinger / remove-genesis-blogpage-settings.php
Last active October 6, 2016 02:25
Remove the Genesis Blog Page settings from the Genesis Theme Settings page
<?php
add_action( 'toplevel_page_genesis_settings_page_boxes', 'lc_remove_unwanted_genesis_metaboxes' );
/**
* Remove the blog page settings metabox from the Genesis Theme Settings
* Desired if following the suggestion by Bill Erickson to not use the Blog page template
* that comes standard in the Genesis Theme
*
* @link http://www.billerickson.net/dont-use-genesis-blog-template/
*/
function lc_remove_unwanted_genesis_metaboxes() {
@BeardedGinger
BeardedGinger / filter_event_list_query_args.php
Last active September 6, 2016 16:56
Filter event list query for The Events Calendar plugin to show events that start 30 days from now
<?php
add_filter( 'tribe_events_list_widget_query_args', 'jm_filter_list_widget_query_args' );
/**
* Filter the query used for the Event List Widget to show only events starting
* in the future
*/
function jm_filter_list_widget_query_args( $args ) {
$offset = 86400 * 30;
$date = date( 'U' ) + $offset;
<?php
/**
* For use with the Owner/Author Ad Split plugin
*
* @link https://wordpress.org/plugins/ownerauthor-ad-split-for-genesis/
*/
add_filter( 'below_content_ad_priority','move_below_default_ad' );
/**
* Moves the below content ad above the content and below the post image
@BeardedGinger
BeardedGinger / is_child conditional
Created January 22, 2014 03:56
A simple function that allows you to conditionally check whether or not a page is a child page
<?php
function is_child( $page_id ) {
$child_check = get_post_ancestors( $page_id );
if($child_check) {
return true;
}
}
@BeardedGinger
BeardedGinger / Set WooCommerce Front-End Styles
Created December 23, 2013 03:31
Set front-end styles for WooCommerce on theme activation
//* Set the default WooCommerce front-end styles
global $pagenow;
if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) {
add_action( 'admin_init', 'woocommerce_default_frontend_styles' );
}
/**
* Define default WooCommerce frontend styles
*/