Skip to content

Instantly share code, notes, and snippets.

View josephhinson's full-sized avatar

Joseph Hinson josephhinson

View GitHub Profile
@josephhinson
josephhinson / searchReviews.js
Last active January 7, 2018 15:23
Search Campendium
jQuery('body').on('click', '.leaflet-popup-content > div > a:first', function(e) {
e.preventDefault();
var t = jQuery(this);
var str = t.text();
//alert(tText);
var newStr = str.replace(" - Full Details", "");
var urlstr = 'https://www.google.com/search?q=site:campendium.com ';
urlstr = urlstr + newStr;
window.open(urlstr);
});
@josephhinson
josephhinson / jetpack_sharing_filters.php
Created May 23, 2016 17:55
These are some useful function for extending the jetpack sharing features.
// Add Twitter @username to Jetpack Sharing
// from http://wpspeak.com/adding-twitter-handle/
function custom_add_twitterhandle_via() {
return 'username';
}
add_filter ( 'jetpack_sharing_twitter_via', 'custom_add_twitterhandle_via' );
// This function adds a colon after the title of the twitter share
function custom_sharing_title() {
$post = get_post();
@josephhinson
josephhinson / return_season.php
Last active September 15, 2015 15:59
Return the current season based on day
<?php
function return_season() {
$day = date('z');
if( $day < 79) $season = 'winter';
elseif( $day < 171) $season = 'spring';
elseif( $day < 265) $season = 'summer';
elseif( $day < 354) $season = 'fall';
else $season = "winter";
return $season;
@josephhinson
josephhinson / dump_tags_and_categories.php
Created August 4, 2015 15:14
Quick dump of all tags and categories into a table with their name, slug, and count (in descending order of count)
<?php
$args = array(
'orderby' => 'count',
'order' => 'DESC',
'hide_empty' => true,
'exclude' => array(),
'exclude_tree' => array(),
'include' => array(),
'number' => '',
'fields' => 'all',
<?php
function my_login_logo() {
// this will add a block fo css to the page that you can customize on the login page.
?>
<style type="text/css">
body.login div#login h1 a {
background-image: url(<?php echo get_bloginfo( 'stylesheet_directory' ) ?>/images/login_logo.png);
padding-bottom: 3px;
background-size: contain;
width: 100%;
@josephhinson
josephhinson / responsive_embed
Created July 10, 2015 14:16
Make WordPress video embedding responsive
<?php
// add these lines to your functions file
add_filter( 'embed_oembed_html', 'embed_responsively_oembed_filter', 10, 4 ) ;
// the following function will wrap the embedded code in a responsive frame, where the video is 100% width
function embed_responsively_oembed_filter($html, $url, $attr, $post_ID) {
$return = "<style>
.embed-container {
position: relative;
@josephhinson
josephhinson / remote_folder_rewrite
Last active September 18, 2015 01:25
serve wp-uploads from production in dev htaccess
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^tempurl.com$
RewriteRule ^(.+)$ http://siteurl.com/wp-content/uploads/$1 [L,R=301,NE]
@josephhinson
josephhinson / login_wl_memberlevels
Created May 20, 2015 20:03
Wishlist Member Levels and Login Form
<?php ?>
<div class="member-login">
<?php if (is_user_logged_in()):
$loggedin = true;
$user = wp_get_current_user();
$levels = WLMAPI::GetUserLevels($user->ID);
$getlevels = WLMAPI::GetLevels();
endif; ?>
<a class="button" href="javascript:void(null);" onclick="jQuery('.dropdown-box').toggle();">
<?php if ($loggedin): ?>
@josephhinson
josephhinson / pageorblogwidget.php
Created December 6, 2013 16:30
Widget that allows users to pull featured image and link for either a selected page, or the latest blog post. I wrote this for a custom homepage widget, but it might be useful for something else later -- especially the per-page functionality.
<?php
// This is a widget for Homepage Widgets
// initializes the widget on WordPress Load
add_action('widgets_init', 'homepage_widget_init_widget');
// Should be called above from "add_action"
function homepage_widget_init_widget() {
register_widget( 'HomepageWidget' );
}
@josephhinson
josephhinson / filterArchive.php
Last active December 29, 2015 09:19
Insert this function into your functions file or plugin in order to filter your post type archive results.
<?php
function my_new_posts_filter($query) {
// in place of "press" put your custom post type -- you can add additional post types by duplicating the if block.
// you can also add more query variables such as 'order'. This is extremely useful
// the is_main_query makes sure you don't indiscriminantly filter secondary loops as well.
if ( !is_admin() && is_post_type_archive('book') && $query->is_main_query() ) {
$query->set( 'posts_per_page', '20' );
}
}