Skip to content

Instantly share code, notes, and snippets.

@heyjones
heyjones / wp-redirect.php
Created October 26, 2015 18:18
WP Redirects
function wp_redirects(){
$redirects = array(
'/old/' => '/new/'
);
$protocol = isset( $_SERVER['HTTPS'] ) ? 'https://' : 'http://';
$site_url = str_replace( $protocol, '', get_site_url() );
$url = str_replace( $site_url, '', $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
$redirect = $redirects[ $url ];
if( isset( $redirect )){
$redirect = $protocol . $site_url . $redirect;
@heyjones
heyjones / yoast-low-pri.php
Created March 21, 2018 16:58
Move the Yoast SEO metabox to the bottom of the post edit screen in WordPress
<?php
namespace yoast_low_pri;
add_action( 'plugins_loaded', __NAMESPACE__ . '\\plugins_loaded' );
function plugins_loaded(){
if( defined( 'WPSEO_VERSION' ) ){
add_filter( 'wpseo_metabox_prio', __NAMESPACE__ . '\\wpseo_metabox_prio' );
}
@heyjones
heyjones / template_wrapper.php
Created April 24, 2018 23:18
Simple Theme Wrapper for WordPress
add_filter( 'template_include', 'template_wrapper' );
function template_wrapper( $template ){
get_header();
include $template;
get_footer();
return false;
}
@import url('https://fonts.googleapis.com/css?family=Raleway:400,500,700,900');
.site-header{
background: #1d1f22!important;
border-bottom: none!important;
}
.navigation-container{
position: absolute;
left: 0;
right: 0;
width: 100vw;
@heyjones
heyjones / blog.protochimp.liquid
Last active November 6, 2018 19:42
ProtoChimp
{% layout none %}<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<atom:link href="{{ shop.url | append: blog.url }}?view=protochimp" rel="self" type="application/rss+xml" />
<title>
{{ blog.title | append: ' | ' | append: shop.name | escape }}
@heyjones
heyjones / events-manager-rest-api.php
Last active March 12, 2020 04:57
Add REST API support to the Events Manager plugin for WordPress.
<?php
/**
* Events Manager REST API
*
* Add REST API support to the Events Manager plugin for WordPress.
*
* https://wordpress.org/plugins/events-manager/
*/
namespace events_manager\rest_api;
@heyjones
heyjones / heyjones-userpass.php
Created December 14, 2020 01:24
Enables application password generation through the REST API. Use at your own risk!
<?php
namespace heyjones\userpass;
add_action( 'rest_api_init', __NAMESPACE__ . '\\rest_api_init' );
function rest_api_init() {
register_rest_route(
'heyjones',
<?php
namespace wp_orderby_termmeta;
add_action( 'posts_fields', __NAMESPACE__ . '\\posts_fields', 10, 2 );
add_action( 'posts_orderby', __NAMESPACE__ . '\\posts_orderby', 10, 2 );
// Append the "sort" column to the query...
function posts_fields( $fields, $query ) {
if( 'art' == $query->query_vars['post_type'] ) {
<?php
namespace WPGraphQL\Menu\Locations;
/**
* Enable all menus in WPGraphQL
*
* This code adds menu support, loops through all available menus
* and programatically syncs them to menu locations to make them
* all accessible through WPGraphQL.
<?php
namespace heyjones\wp_image_sizes;
add_action( 'after_setup_theme', __NAMESPACE__ . '\\after_setup_theme' );
function after_setup_theme() {
$sizes = array(
'thumbnail' => array(
'size_w' => 360,