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 May 4, 2016 21:31
Genesis color scheme selector meta box
<?php
// Register admin stylesheet
add_action( 'admin_enqueue_scripts', 'berkeley_settings_admin_styles' );
function berkeley_settings_admin_styles( $hook ) {
wp_enqueue_style( 'berkeley-admin-css', get_stylesheet_directory_uri() . '/css/admin-style.css' );
}
@stephanieleary
stephanieleary / admin-style.css
Created May 4, 2016 21:30
Genesis color scheme selector styles
/* Genesis Settings screen */
#berkeley-color-settings .genesis-layout-selector label.box {
max-height: inherit;
}
.genesis-layout-selector label.box {
padding: 5px;
}
@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,
$('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 / footer.php
Created June 24, 2016 20:32
Replace Genesis footer with Customizer text field
@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 / 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 / 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 / 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 / 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
*/