Skip to content

Instantly share code, notes, and snippets.

@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' );
@stephanieleary
stephanieleary / blockquote-cite-tinymce.php
Last active August 1, 2017 16:36
Blockquote + Cite TinyMCE button PHP
<?php
function scl_pullquote_mce_button() {
// check if WYSIWYG is enabled
if ( 'true' == get_user_option( 'rich_editing' ) ) {
add_filter( 'mce_external_plugins', 'scl_pullquote_add_tinymce_plugin' );
add_filter( 'mce_buttons', 'scl_pullquote_register_mce_button' );
// enforce Dashicon font
echo '<style>
.dashicons-testimonial::before {
@stephanieleary
stephanieleary / blockquote-cite-tinymce.js
Created October 16, 2016 20:01
Blockquote + Cite TinyMCE button JS
(function() {
tinymce.PluginManager.add('blockquote_cite', function( editor, url ) {
editor.addButton( 'blockquote_cite', {
title: 'Blockquote & Cite',
icon: "icon dashicons-testimonial",
onclick: function() {
editor.windowManager.open( {
title: 'Insert Blockquote and Citation',
body: [
{