Skip to content

Instantly share code, notes, and snippets.

View JAW-Dev's full-sized avatar

Jason Witt JAW-Dev

View GitHub Profile
@JAW-Dev
JAW-Dev / WordPress - Highlight Search Terms.php
Last active August 21, 2022 23:08
Highlight WordPress Search Terms
// source: http://bradsknutson.com/blog/highlight-search-terms-wordpress/
function highlight_search_term($text){
if(is_search()){
$keys = implode('|', explode(' ', get_search_query()));
$text = preg_replace('/(' . $keys .')/iu', '<span class="search-term">\0</span>', $text);
}
return $text;
}
add_filter('the_excerpt', 'highlight_search_term');
add_filter('the_title', 'highlight_search_term');
@JAW-Dev
JAW-Dev / jQuery - Split Lists.js
Last active December 19, 2015 00:09
Split a list with jQuery
$(function() {
$("ul").each(function() {
var list = $(this);
var size = 3;
var current_size = 0;
list.children().each(function() {
console.log(current_size + ": " + $(this).text());
if (++current_size > size) {
var new_list = $("<ul></ul>").insertAfter(list);
list = new_list;
@JAW-Dev
JAW-Dev / WordPress - Nofollow for External Links in Comment Text.php
Created August 3, 2013 14:13
Nofollow for external links in comment text
@JAW-Dev
JAW-Dev / WordPress - HTML Error Log for Plugin Activation Errors
Created May 31, 2014 21:52
HTML Error Log for Plugin Activation Errors
add_action('activated_plugin','save_error');
function save_error(){
file_put_contents(ABSPATH. 'wp-content/error_activation.html', ob_get_contents());
}
$(function($) {
// Split Browse Archive checkboxes into vertically alphabetized Omega columns.
var num_cols = 3,
container = $('.split-list'),
listItem = 'li',
listClass = 'sub-list';
// For each exposed filter that has checkboxes.
container.each(function() {
// Figure out how many elements should be in each column.
var items_per_col = new Array(),
@font-face {
font-family:FontFamily;
src: url('relatuve/directory/to/css/font.eot');
src: url('relatuve/directory/to/css/font.eot?#iefix') format('embedded-opentype'),
url('relatuve/directory/to/css/font.woff') format('woff'),
url('relatuve/directory/to/css/font.ttf') format('truetype'),
url('relatuve/directory/to/css/font.svg#FontFamily') format('svg');
font-weight: normal;
font-style: normal;
}
@JAW-Dev
JAW-Dev / PHP - US States and Territories Array.php
Created May 31, 2014 22:02
US States and Territories Array
$us_states_and_territories = array(
'Alabama',
'Alaska',
'American Samoa',
'Arizona',
'Arkansas',
'California',
'Colorado',
'Connecticut',
'Delaware',
$us_states = array(
'Alabama',
'Alaska',
'Arizona',
'Arkansas',
'California',
'Colorado',
'Connecticut',
'Delaware',
'District of Columbia',
@JAW-Dev
JAW-Dev / WordPress - Custom Query Paged.php
Last active July 28, 2016 09:34
WordPress Custom Query Paged
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query = new WP_Query(array(
'post_type' => 'post',
'no_found_rows' => true,
'no_found_rows' => true, // useful when pagination is not needed.
'update_post_meta_cache' => false, // useful when post meta will not be utilized.
'update_post_term_cache' => false, //useful when taxonomy terms will not be utilized.
'fields' => 'ids', //useful when only the post IDs are needed (less typical).
));
if (have_posts()) :
@JAW-Dev
JAW-Dev / WordPress - Custom Query.php
Last active July 28, 2016 09:34
WordPress Custom Query
$query = new WP_Query( array(
'post_type' => 'post',
'no_found_rows' => true,
'no_found_rows' => true, // useful when pagination is not needed.
'update_post_meta_cache' => false, // useful when post meta will not be utilized.
'update_post_term_cache' => false, //useful when taxonomy terms will not be utilized.
'fields' => 'ids', //useful when only the post IDs are needed (less typical).
) );
if( have_posts() ) :
while( $query->have_posts() ) :