Skip to content

Instantly share code, notes, and snippets.

View mrwweb's full-sized avatar

Mark Root-Wiley mrwweb

View GitHub Profile
@mrwweb
mrwweb / gf_user_prefill_name.php
Created November 28, 2014 18:19
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…
// 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;
}
@mrwweb
mrwweb / wp_email_shortcode.php
Last active June 19, 2017 22:38
Obfustcate Emails from Bots with WordPress Shortcode
<?php
// Hide Email from Spam Bots using a short code
// Place this in your functions.php file
//
// See: codex.wordpress.org/Function_Reference/antispambot
//
// Ex: [email]you@example.org[/email]
function mrw_hide_email( $atts , $content = null ) {
if ( ! is_email( $content ) ) {
@mrwweb
mrwweb / fake-list.html
Created January 26, 2015 21:08
A "fake" list.
<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>
@mrwweb
mrwweb / real-list.html
Created January 26, 2015 21:09
A real list.
<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>
@mrwweb
mrwweb / fpw_bug.html
Created March 7, 2015 01:12
fpw problem html
<div class="wrap">
<div class="content-sidebar-wrap">
<main class="content facetwp-template" role="main" itemprop="mainContentOfPage" itemscope="itemscope" itemtype="http://schema.org/Blog">
<div class="archive-description cpt-archive-description">
<h1 class="archive-title">Resource Library</h1>
</div>
<article class="post-398 hai_resources type-hai_resources status-publish has-post-thumbnail entry" itemscope="itemscope" itemtype="http://schema.org/CreativeWork">
<a href="http://localhost/hai/resources/resource-1/" title="Resource #1"><img width="150" height="182" src="http://localhost/hai/wp-content/uploads/2014/10/Unknown1-150x182.jpeg" class="alignright post-image entry-image" alt="Unknown" itemprop="image" /></a>
<header class="entry-header">
<h1 class="entry-title" itemprop="headline"><a href="http://localhost/hai/resources/resource-1/" rel="bookmark">Resource #1</a></h1>
@mrwweb
mrwweb / fpw_debugging.php
Created March 7, 2015 01:13
I'm not seeing any output from these
<?php
add_filter( 'facetwp_pre_filtered_post_ids', 'my_facetwp_pre_filtered_post_ids', 10, 2 );
function my_facetwp_pre_filtered_post_ids( $post_ids, $class ) {
var_dump($post_ids,$class,'hello world');
}
add_filter( 'facetwp_facet_html', 'my_facetwp_facet_html', 10, 2 );
function my_facetwp_facet_html( $output, $params ) {
var_dump($output,$params);
}
@mrwweb
mrwweb / fpw_query_tweaks.php
Last active August 29, 2015 14:16
`DOING_AJAX` check added. Still doesn't work.
<?php
/* For query modification */
add_action( 'pre_get_posts', 'hai_resources_pre_get_posts' );
function hai_resources_pre_get_posts( $query ) {
// stop immediately if we're in the admin or not working with the main query
if( ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) || !$query->is_main_query() ) {
return;
}
@mrwweb
mrwweb / fpw_facets_genesis_sidebar.php
Created March 7, 2015 01:16
adding fpw facets via a genesis hook (this isn't working, they appear but show 0 results)
<?php
/* add custom sidebar content */
add_action( 'genesis_sidebar', 'hai_resource_library_sidebar' );
function hai_resource_library_sidebar() {
if( is_post_type_archive( 'hai_resources' ) && class_exists( 'FacetWP' ) ) {
echo '<h2>Filter & Search</h2>';
echo '<label>Search: ' . facetwp_display( 'facet', 'library_search' ) . '</label>';
echo 'Countries: ' . facetwp_display( 'facet', 'countries' );
echo 'Topic Areas: ' . facetwp_display( 'facet', 'topic_areas' );
}
{"facets":[{"label":"Categories","name":"categories","type":"checkboxes","source":"tax\/category","parent_term":"","orderby":"count","operator":"and","hierarchical":"no","ghosts":"no","preserve_ghosts":"no","count":"10"},{"label":"Countries","name":"countries","type":"checkboxes","source":"tax\/hai_countries","parent_term":"","orderby":"display_value","operator":"or","hierarchical":"no","ghosts":"yes","preserve_ghosts":"yes","count":"100"},{"label":"Topic Areas","name":"topic_areas","type":"checkboxes","source":"tax\/hai_topics","parent_term":"","orderby":"display_value","operator":"or","hierarchical":"no","ghosts":"yes","preserve_ghosts":"yes","count":"100"},{"label":"Library Search","name":"library_search","type":"search","search_engine":"library_search","placeholder":""}]}
@mrwweb
mrwweb / 1-before.html
Last active August 29, 2015 14:17
WordPress 4.1.1 TinyMCE Remove Formatting Test
<strong>Bold</strong>
<em>Italic</em>
<h2>Heading</h2>
<a href="#">Link</a>
<span style="text-decoration: underline;">Underline</span>