Skip to content

Instantly share code, notes, and snippets.

View stephenscaff's full-sized avatar

Stephen Scaff stephenscaff

View GitHub Profile
@stephenscaff
stephenscaff / script-styles.php
Created January 17, 2015 15:59
Scripts and Styles Enqueue for my little wp starter theme, The Jump Off. I actually require_once this file into functions.php from a lib folder to keep things organized.
/*-------------------------------------------*/
/* Register and enqueue scripts and styles
/*-------------------------------------------*/
function jumpoff_scripts_and_styles() {
if ( !is_admin() ) {
//Register Styles
wp_register_style( 'jumpoff_styles',get_template_directory_uri() . '/assets/css/app.min.css', false );
wp_register_style( 'jumpoff_fonts',get_template_directory_uri() . '/assets/css/fonts.min.css', false );
@stephenscaff
stephenscaff / Create New User Role Client.php
Last active January 11, 2017 17:25
Create a new user role called "client" in Wordpress.
/*-----------------------------------------------*/
/* Create new Role for: Client
/*-----------------------------------------------*/
$result = add_role( 'client', __('Client' ),
array(
'read' => true, // true allows this capability
'edit_posts' => false, // Allows user to edit their own posts
'edit_pages' => false, // Allows user to edit pages
'edit_others_posts' => false, // Allows user to edit others posts not just their own
@stephenscaff
stephenscaff / wordpress create new user role with user-based login redirect.php
Last active August 29, 2015 14:16
First steps in creating a Client Portal with user specific content in Wordpress. Create new User Role: Client. Then redirect them away from admin on login, to wherever. In this case 'yoursite.com/client-portal'.
/*-----------------------------------------------*/
/* Create new Role for: Client
/*-----------------------------------------------*/
$result = add_role( 'client', __('Client' ),
array(
'read' => true, // true allows this capability
'edit_posts' => false, // Allows user to edit their own posts
'edit_pages' => false, // Allows user to edit pages
'edit_others_posts' => false, // Allows user to edit others posts not just their own
@stephenscaff
stephenscaff / wordpress-customize-htm-editor-buttons.php
Last active August 29, 2015 14:16
Maintain your awesome blog styles by preventing client retardery. First, remove the evil WYSI editor. Then customize the output of built in HTML editor buttons. Finally, create some custom buttons for subheaders, figcaptions, hr separators, link styles, etc. For my own purposes, some outputs for syntax highlighting via Prism JS.
/*-----------------------------------------------*/
/* Kick Rocks Visual Editor form Admin
/*-----------------------------------------------*/
add_filter ( 'user_can_richedit' , create_function ( '$a' , 'return false;' ) , 50 );
/*-----------------------------------------------*/
/* Customize Output of HTML Editor Buttons
/*-----------------------------------------------*/
function my_show_quicktags( $qtInit ) {
$qtInit['buttons'] = 'strong,em,block,del,ul,ol,li,link,code,fullscreen';
@stephenscaff
stephenscaff / modernizr-videotestload.js
Created April 20, 2015 20:22
Modernizr test and load for video
// Exclude the iPad
Modernizr.addTest('ipad', function () {
return !!navigator.userAgent.match(/iPad/i);
});
// Exclude the iPhone
Modernizr.addTest('iphone', function () {
return !!navigator.userAgent.match(/iPhone/i);
});
/*
* ICM Easter Eggs © 2014
* Version 1.0
* Author: Joe Furfaro
*
*/
$(function(){
$('body').on('submit.easterEgg', 'form', function(e){
var $form = $(this),
jQuery(window).on('scroll resize', function() {
var scroll_top = jQuery(window).scrollTop();
var entry_region = jQuery('.sect-masthead');
var entry_region_bg = entry_region.find('.sect-masthead');
var entry_region_wrapper = entry_region.find('.sect-masthead');
var entry_region_height = entry_region.height();
if (scroll_top - 10 < entry_region_height) {
var power_opacity = 1 - (scroll_top / entry_region_height * 1.2);
var power_scale = 1.05 - (scroll_top / entry_region_height / 25);
var power_scale_strong = 1 - (scroll_top / entry_region_height / 8);
@stephenscaff
stephenscaff / IE-Target-MQs.scss
Last active August 29, 2015 14:26
A variety of IE specific media queries and hacks. In order or awesomeness
.foo{
/*----------------------------------------------
--Target ie10+ via ms-high-contrast mq (bestest)
----------------------------------------------- */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
color: #111;
}
/*----------------------------------------------
--Target ie9+ (okay)
@stephenscaff
stephenscaff / CPT-to-Archive.php
Created August 21, 2015 00:59
Add Custom Post Types to archive in Wordpress.
function namespace_add_custom_types( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array(
'post', 'nav_menu_item', 'your-custom-post-type-here'
));
return $query;
}
}
add_filter( 'pre_get_posts', 'namespace_add_custom_types' );
@stephenscaff
stephenscaff / wp-template-redirect.php
Created August 25, 2015 17:02
Wordpress Tempalte Redirect using template_include hook
add_filter( 'template_include', 'my_callback' );
function my_callback( $original_template ) {
if ( some_condition() ) {
return SOME_PATH . '/some-custom-file.php';
} else {
return $original_template;
}
}