Skip to content

Instantly share code, notes, and snippets.

View stephanieleary's full-sized avatar

Stephanie Leary stephanieleary

View GitHub Profile
@stephanieleary
stephanieleary / bad-slugs.php
Created September 1, 2017 15:32
prevent users from saving pages with reserved rewrite rules as slugs
<?php
// prevent users from saving pages with reserved rewrite rules as slugs
// includes post types, feeds, and search
function my_reserved_slugs() {
return array(
'post',
'attachment',
'category',
@stephanieleary
stephanieleary / dashboard-my-sites.php
Created January 23, 2017 18:11
My Sites Dashboard widget to show all user's sites on network
<?php
function mysites_network_dashboard_widget_setup() {
add_meta_box(
'dashboard_mysites_widget',
'My Sites',
'dashboard_mysites_widget',
'dashboard',
'side',
'high'
@stephanieleary
stephanieleary / livewhale-calendar-widget.php
Created October 17, 2016 21:29
LiveWhale Calendar Widget
<?php
/*
Plugin Name: LiveWhale Calendar Widget (TAMU)
Description: WordPress widget to display events from a LiveWhale calendar feed.
Author: Stephanie Leary
Version: 1.0
Author URI: http://stephanieleary.com
*/
// initialize all custom widgets
@stephanieleary
stephanieleary / termlink-filters.php
Last active October 17, 2016 16:44
add post_type arg to term links (narrow down the query)
@stephanieleary
stephanieleary / dashboard-login-redirect.php
Created October 17, 2016 14:58
Redirect to top-level dashboard (instead of profile) if not superadmin or not allowed on this blog
<?php
add_filter( 'login_redirect', 'scl_network_dashboard_login_redirect', 100, 3 );
function scl_network_dashboard_login_redirect( $redirect_to, $request_redirect_to, $user ) {
if ( !is_user_member_of_blog() || ( is_main_site() && !is_super_admin() ) )
return network_admin_url();
return $redirect_to;
}
<?php
add_action( 'genesis_loop', 'scl_people_types_loop', 10 );
remove_action( 'genesis_loop', 'genesis_do_loop' );
function scl_people_types_loop( $parent = 0 ) {
$terms = get_terms( array(
'taxonomy' => 'people_type',
'hide_empty' => true,
'parent' => $parent,
) );
@stephanieleary
stephanieleary / functions.php
Created October 16, 2016 21:05
Genesis breadcrumbs for tag1+tag2 or tag1,tag2 combined term archives
<?php
// Display titles of all terms in combined term archive breadcrumbs (tag1+tag2 or tag1,tag2)
function scl_multiple_tax_breadcrumbs( $crumbs, $args ) {
if ( !is_tax() )
return $crumbs;
$taxonomy = get_query_var( 'taxonomy' );
$topics = get_query_var( $taxonomy );
if ( empty( $topics ) )
@stephanieleary
stephanieleary / functions.php
Created October 16, 2016 20:55
Genesis titles for tag1+tag2 or tag1,tag2 combined term archives
<?php
// Have to unhook the original function early
add_action( 'init', 'scl_fix_taxonomy_archive_titles' );
function scl_fix_taxonomy_archive_titles() {
remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );
add_action( 'genesis_before_loop', 'scl_do_taxonomy_title_description', 14 );
}
@stephanieleary
stephanieleary / archive-courses.php
Created October 16, 2016 20:26
Course catalog using table loop for Genesis
<?php
// replace the usual post listing with directory table
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'scl_course_table_loop', 10 );
function scl_course_table_loop() {
if ( have_posts() ) :
@stephanieleary
stephanieleary / taxonomy.php
Created October 16, 2016 20:13
List post type links instead of posts if this taxonomy archive includes multiple post types
<?php
add_action( 'genesis_meta', 'scl_taxonomy_loop_switch' );
function scl_taxonomy_loop_switch() {
if ( function_exists( 'scl_find_post_type' ) )
$type = tees_find_post_type();
else
$type = get_query_var( 'post_type' );