Skip to content

Instantly share code, notes, and snippets.

View joshfitzgerald's full-sized avatar

Josh Fitzgerald joshfitzgerald

  • Slickdeals
  • Las Vegas
View GitHub Profile
@joshfitzgerald
joshfitzgerald / functions.php
Created March 6, 2018 19:47 — forked from mor10/functions.php
Custom page template with no sidebar for Twenty Sixteen child theme
<?php
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array (Maybe) filtered body classes.
*/
function wpcampus_body_classes( $classes ) {
// Adds a class of no-sidebar to custom no-sidebar page template.
if ( is_page_template('page-no-sidebar.php') ) {
@joshfitzgerald
joshfitzgerald / javascript_resources.md
Created November 19, 2016 03:57 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@joshfitzgerald
joshfitzgerald / css_resources.md
Created November 19, 2016 03:57 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

<?php
//Configuration
$perpage = 5; //number of results to show per page
$pagenum = 1; // set the starting page number
//what phrase did they search for?
$phrase = $_GET['phrase'];
//get all posts and comments that are similar to the query, make sure the posts are distinct
$query_search = "SELECT distinct *
<?php
//turn on tumblr-style post formats
add_theme_support('post-formats', array('image', 'video', 'audio', 'quote', 'gallery'));
//adds ability to have one featured image per post or page
add_theme_support('post-thumbnails');
//more robust feed links on every page
add_theme_support('automatic-feed-links');
<?php
function awesome_comment_reply(){
if( !is_admin() &amp;&amp; is_singular() &amp;&amp; comments_open() &amp;&amp; get_option('thread_comments') ):
wp_enqueue_script( 'comment-reply' );
endif;
}
add_action( 'wp_print_scripts', 'awesome_comment_reply' );
<?php
/**
* Set up Widget Areas (Dynamic Sidebars)
*/
register_sidebar( array(
'name' => 'Home Features',
'description' => 'An area near the bottom of the home page',
'id' => 'home-features',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
<?php
//show the form if the user is not logged in
if( !is_user_logged_in() ):
wp_login_form();
else:
$redirect = home_url();
echo '<a href="'.wp_logout_url( $redirect ).'">Log Out</a>';
endif;
?>
/*
== meyer reset
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
<?php
//change the default (55 words) length of excerpts to 20 words
function new_ex_length($length) {
return 20;
}
add_filter('excerpt_length', 'new_ex_length', 999);
//changes the [...] to a button when excerpt content is truncated
function new_excerpt_more($more) {
$readmore = 'Read More';