Skip to content

Instantly share code, notes, and snippets.

View stephanieleary's full-sized avatar

Stephanie Leary stephanieleary

View GitHub Profile
@stephanieleary
stephanieleary / functions.php
Last active August 26, 2016 19:54
Better Genesis a11y
<?php
// Replace primary navigation to remove unnecessary "Main navigation" heading, duplicated in ARIA label
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_after_header', 'scl_do_nav' );
function scl_do_nav() {
//* Do nothing if menu not supported
if ( ! genesis_nav_menu_supported( 'primary' ) || ! has_nav_menu( 'primary' ) )
return;
$class = 'menu genesis-nav-menu menu-primary';
@stephanieleary
stephanieleary / functions.php
Last active August 1, 2017 16:35
Change post excerpt meta box title and contents
<?php
remove_meta_box( 'postexcerpt', 'post', 'side' );
// use original box:
// add_meta_box('postexcerpt', __( 'Plain Text Summary' ), 'post_excerpt_meta_box', 'post', 'normal', 'high');
// replace box altogether:
add_meta_box( 'postexcerpt', __( 'Plain Text Summary' ), 'custom_post_excerpt_meta_box', 'post', 'normal', 'high' );
function custom_post_excerpt_meta_box( $post ) {
?>
@stephanieleary
stephanieleary / citation-importer-filters.php
Last active August 18, 2016 20:21
Example filters to add or edit custom fields for the Citation Importer plugin.
<?php
/*
Plugin Name: Citation Importer Filters
Plugin URI: http://stephanieleary.com/
Description: Add or edit fields for the Citation Importer.
Author: sillybean
Author URI: http://stephanieleary.com/
Version: 0.1
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
@stephanieleary
stephanieleary / html-importer.php
Created August 4, 2016 14:20
Add explicit categories to HTML Imported posts
<?php
// [file fragment]
// find this, around line 671
// ... and all the taxonomies...
$taxonomies = get_taxonomies( array( 'public' => true ), 'objects', 'and' );
foreach ( $taxonomies as $tax ) {
if ( isset( $options[$tax->name] ) )
wp_set_post_terms( $post_id, $options[$tax->name], $tax->name, false );
}
if ( isset( $customfieldtags ) )
@stephanieleary
stephanieleary / functions.php
Created July 21, 2016 22:13
Force Genesis Featured Page widget to use excerpts
<?php
//* Add excerpts to pages
add_post_type_support( 'page', 'excerpt' );
//* Use excerpts as Featured Page widget content
add_filter( 'get_the_content_limit', 'ebca_content_limit', 10, 4 );
function ebca_content_limit( $output, $content, $link, $max_characters ) {
$content = get_post_field( 'post_excerpt', get_the_ID() );
@stephanieleary
stephanieleary / searchwp-page.php
Created July 6, 2016 14:24
Feature requests for SearchWP Shortcodes extension
[searchwp_search_form engine="employee_directory" placeholder="Search for a name or custom field"] <!-- new -->
[searchwp_search_results_found] <!-- new -->
<div class="search-results-wrapper">
<h3>Search Results</h3>
[searchwp_search_results engine="employee_directory" posts_per_page=20]
<h4>[searchwp_search_result_link direct="true"]</h4>
[searchwp_search_result_excerpt]
[/searchwp_search_results]
</div>
@stephanieleary
stephanieleary / searchwp-page.php
Created July 6, 2016 14:21
Existing SearchWP Shortcodes setup
[searchwp_search_form engine="employee_directory"]
<div class="search-results-wrapper">
<h3>Search Results</h3>
[searchwp_search_results engine="employee_directory" posts_per_page=20]
<h4>[searchwp_search_result_link direct="true"]</h4>
[searchwp_search_result_excerpt]
[/searchwp_search_results]
</div>
@stephanieleary
stephanieleary / footer.php
Created June 24, 2016 20:32
Replace Genesis footer with Customizer text field
$('li.blurb').each(function(index) {
var words = $('dd.words', this).text();
words = words.replace(',', '');
words = parseInt(words, 10);
if ( words > 2000 )
words = Math.round(words / 1000) + 'K';
var title = $('h4.heading', this).html();
title = title.replace(/(\r\n|\n|\r)/gm, ' ');
title = title.replace('<!-- do not cache -->', '');
@stephanieleary
stephanieleary / functions.php
Last active May 11, 2016 16:03
Redirect 404 errors to posts with old path stored by HTML Import
<?php
add_filter( 'redirect_canonical', 'my_404_no_guessing', 10, 2 );
function my_404_no_guessing( $redirect_url, $request_url ) {
if ( is_404() ) {
// HTML Import redirects
$posts = get_posts( array(
'meta_key' => 'URL_before_HTML_Import',
'meta_value' => $request_url,