Skip to content

Instantly share code, notes, and snippets.

Stephanie Leary sillybean

Block or report user

Report or block sillybean

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
@sillybean
sillybean / tinymce-widget-styleselect.txt
Created Sep 5, 2017
Customizing TinyMCE's Formats (style_select) dropdown in rich text widgets in WordPress 4.8x
View tinymce-widget-styleselect.txt
<?php
// PHP goes in functions.php or similar
// Callback function to filter the MCE settings
function my_mce_style_options( $init_array ) {
// Define the style_formats array
$style_formats = my_mce_styleselect_options();
// Insert the array, JSON ENCODED, into 'style_formats'
$init_array['style_formats'] = json_encode( $style_formats );
@sillybean
sillybean / bad-slugs.php
Created Sep 1, 2017
prevent users from saving pages with reserved rewrite rules as slugs
View bad-slugs.php
<?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',
@sillybean
sillybean / dashboard-my-sites.php
Created Jan 23, 2017
My Sites Dashboard widget to show all user's sites on network
View dashboard-my-sites.php
<?php
function mysites_network_dashboard_widget_setup() {
add_meta_box(
'dashboard_mysites_widget',
'My Sites',
'dashboard_mysites_widget',
'dashboard',
'side',
'high'
View livewhale-calendar-widget.php
<?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
@sillybean
sillybean / termlink-filters.php
Last active Oct 17, 2016
add post_type arg to term links (narrow down the query)
View termlink-filters.php
@sillybean
sillybean / dashboard-login-redirect.php
Created Oct 17, 2016
Redirect to top-level dashboard (instead of profile) if not superadmin or not allowed on this blog
View dashboard-login-redirect.php
<?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;
}
View archive-people.php
<?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,
) );
@sillybean
sillybean / functions.php
Created Oct 16, 2016
Genesis breadcrumbs for tag1+tag2 or tag1,tag2 combined term archives
View functions.php
<?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 ) )
@sillybean
sillybean / functions.php
Created Oct 16, 2016
Genesis titles for tag1+tag2 or tag1,tag2 combined term archives
View functions.php
<?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 );
}
@sillybean
sillybean / archive-courses.php
Created Oct 16, 2016
Course catalog using table loop for Genesis
View archive-courses.php
<?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() ) :
You can’t perform that action at this time.