Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Root-Wiley mrwweb

View GitHub Profile
@mrwweb
mrwweb / fpw_image_size_filter_examples.php
Last active Aug 29, 2015
Feature a Page Widget 2.0 Filter Examples
View fpw_image_size_filter_examples.php
See: https://gist.github.com/56edda993e0b7062c7af
@mrwweb
mrwweb / content-taxonomy-head.php
Last active Aug 29, 2015
These three files should go in a child theme of the WP Advocate theme if using the People Profile CPT to show individual People Category taxonomy archive pages
View content-taxonomy-head.php
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header clearfix">
<h1 class="entry-title"><?php echo single_term_title(); ?></h1>
</header><!-- .entry-header -->
<?php
$term_description = term_description();
if( $term_description ) : ?>
<div class="entry-content post-content">
@mrwweb
mrwweb / fpw_widget_templates_filter_examples.php
Last active Aug 29, 2015
Example of fpw_widget_templates filter in Feature a Page Widget 2.0. Allows remove of default layouts, "registering" of custom layouts, or setting one layout for all widget instances.
View fpw_widget_templates_filter_examples.php
<?php
/**
* remove a default template
*
* default templates are: big, banner, wrapped
*
* this example removes the "Big Image" template
*
* @param $templates array slug => label pairs of templates
*/
@mrwweb
mrwweb / fpw_auto_excerpt_filter_example.php
Created Sep 22, 2014
Example of fpw_auto_excerpt filter in Feature a Page Widget 2.0. By default, the widget only shows the excerpt for posts with an explicitly-set excerpt (i.e. has_excerpt() is TRUE).
View fpw_auto_excerpt_filter_example.php
<?php
/**
* Set fpw_auto_excerpt to TRUE to allow auto-generated excerpts if the Excerpt field is blank
*
* Uses the_excerpt() and associated filters.
*/
add_filter( 'fpw_auto_excerpt', '__return_true' );
@mrwweb
mrwweb / fpw_image_size_filter_examples.php
Last active Aug 29, 2015
Example of fpw_image_size filter in Feature a Page Widget 2.0. By default, Feature a Page Widget registers three sizes, one for each layout: fpw_big, fpw_square, fpw_banner. NOTE: To produce consistent image sizes and a good widget layout, CSS rules like max-width may at times affect the image's apparent size on the front end.
View fpw_image_size_filter_examples.php
<?php
/**
* replace one of the widget image sizes
*
* examples replaces the banner layout's image with the 'large' size image from Settings > Media
*
* If you replacing $size with a custom image size, you must register that separately with add_image_size()
*
* @param $size string slug of registered image size
* @return string|array slug of registered image size or "array( width, height )" (not recommended)
@mrwweb
mrwweb / fpw_post_types_filter_examples.php
Last active Aug 29, 2015
Examples of the fpw_post_types filter in Feature a Page Widget 2.0. By default, the widget will allow Pages and Posts to be featured.
View fpw_post_types_filter_examples.php
<?php
/**
* add a post type that can be featured in the Feature a Page Widget
*
* Any post types added via this filter automatically have support added for excerpts and featured images
*
* This example adds the ability to feature the "book" post type
*
* @param $post_types array array of post_type slugs that can be featured with the widget
*/
@mrwweb
mrwweb / functions.php
Created Nov 3, 2014
Move "Add to iCal / Google" links below event information in Modern Tribe's The Events Calendar plugin.
View functions.php
<?php
remove_filter('tribe_events_single_event_after_the_content', array('TribeiCal', 'single_event_links'), 10, 1);
add_filter( 'tribe_events_single_event_after_the_meta', array('TribeiCal', 'single_event_links'), 10, 1);
@mrwweb
mrwweb / gf_user_prefill_name.php
Created Nov 28, 2014
A snippet to autopopulate the default Name field in Gravity Forms (with separate first and last fields) with the current user's First and Last Names. INSTRUCTIONS: - Replace "PREFIX" with a form-specific value and supply "PREFIX_*n" in the dynamically autopopulate fields in Gravity Forms. - Snippet goes in `functions.php` or a functionality plug…
View gf_user_prefill_name.php
// prefill user first & last names on funding application "Volunteer Name" field
add_filter( 'gform_field_value_PREFIX_fn', 'mrw_user_first_name' );
add_filter( 'gform_field_value_PREFIX_ln', 'mrw_user_last_name' );
function mrw_user_first_name( $value ) {
$user = get_user_by( 'id', get_current_user_id() );
if( !is_wp_error( $user ) ) {
$value = $user->user_firstname;
}
return $value;
}
View fake-list.html
<p>
• First bullet<br>
• Second bullet. This one is really long and probably wraps and you’ll see why that’s important in a moment, but I just have to make sure that this line is really extra long to ensure that it wraps. There. I think that’s enough. Hopefully. Now. Stopping here for real this time.<br>
• Third bullet
</p>
View real-list.html
<ul>
<li>First bullet</li>
<li>Second bullet. This one is really long and probably wraps and you’ll see why that’s important in a moment, but I just have to make sure that this line is really extra long to ensure that it wraps. There. I think that’s enough. Hopefully. Now. Stopping here for real this time.</li>
<li>Third bullet</li>
</ul>