Skip to content

Instantly share code, notes, and snippets.

@rezzz-dev
rezzz-dev / .gitignore
Created May 19, 2013 17:00
Template for .git managed WordPress websites
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: As a result, we only stick the site's wp-content in the repo
#
# See the comments below for more info on how to add exceptions for your
# content. Or see git's documentation for more info on .gitignore files:
# http://kernel.org/pub/software/scm/git/docs/gitignore.html
@rezzz-dev
rezzz-dev / gist:5642924
Created May 24, 2013 11:38
Snippet: WP Custom Login Logo
/**
* Custom admin login header logo
*/
function jr_custom_login_logo() {
echo '<style type="text/css">'.
'h1 a { background-size: 201px 35px !important; background-image:url('.get_bloginfo( 'template_directory' ).'/images/logo.png) !important; }'.
'</style>';
}
add_action( 'login_head', 'jr_custom_login_logo' );
@rezzz-dev
rezzz-dev / template-blankpage.php
Last active December 18, 2015 01:59
Snippet: WP: Blank Template
<?php
/*
Template Name: Blank Page
Template By : Jason Resnick
URL : http://rezzz.com
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
@rezzz-dev
rezzz-dev / gist:6292812
Created August 21, 2013 10:25
Snippet: WP Login-Logout Menu Item
function jr_add_loginout_navitem($items, $args ) {
if( $args->theme_location == 'header_nav' ) {
if ( !(is_user_logged_in()) ) {
$login_item = '<li class="nav-login"><a href="/login">Log In</a></li>';
}
else {
$login_item = '<li class="nav-login">'.wp_loginout($_SERVER['REQUEST_URI'], false).'</li>';
}
$items .= $login_item;
}
@rezzz-dev
rezzz-dev / gist:6379035
Created August 29, 2013 14:45
Snippet: WP Get Excerpt by ID
function get_excerpt_by_id($post_id, $n){
$the_post = get_post($post_id); //Gets post ID
$the_excerpt = $the_post->post_content; //Gets post_content to be used as a basis for the excerpt
$excerpt_length = $n; //Sets excerpt length by word count
$the_excerpt = strip_tags(strip_shortcodes($the_excerpt)); //Strips tags and images
$words = explode(' ', $the_excerpt, $excerpt_length + 1);
if(count($words) > $excerpt_length) :
array_pop($words);
// array_push($words, '…');
@rezzz-dev
rezzz-dev / gist:6713387
Created September 26, 2013 12:21
Snippet: WP: List Custom Post Type Group By Taxonomy
<?php
$attractions = get_terms('attraction', array("fields" => "names"));
for ( $myterm = 0; $myterm < count($attractions); $myterm++) { ?>
<h3><?php echo $attractions[$myterm]; ?>:</h3>
<div class="taxonomy_group">
<?php $loop = new WP_Query(array('attraction' => $attractions[$myterm]));
while ( $loop->have_posts() ) : $loop->the_post();
get_template_part( 'content', 'things-to-do' );
endwhile; ?>
</div>
@rezzz-dev
rezzz-dev / functions.php
Last active January 20, 2016 14:35
Filter Recent Posts Widget by current categories, but excluding current post
<?php
/*
* Filter Recent Posts based around the categories of the post being displayed
*/
function rez_widget_posts_args( $args ) {
if ( is_single() ) { // Only want to appear on blog posts.
$post = get_queried_object();
$categories = wp_get_post_categories( $post->ID );
$cats = implode( ',',$categories );
@rezzz-dev
rezzz-dev / functions.php
Created February 25, 2016 13:29
Re-order WooCommerce Checkout Fields
<?php
/*
* Re-order Checkout Fields
*/
add_filter( 'woocommerce_checkout_fields', 'rez_move_checkout_fields' );
function rez_move_checkout_fields( $fields ) {
$fields2['billing']['billing_email'] = $fields['billing']['billing_email'];
@rezzz-dev
rezzz-dev / functions.php
Created May 4, 2016 16:19
Remove the conflict of select2 versions between ACF and LifterLMS
<?php
add_action( 'admin_enqueue_scripts', 'custom_admin_scripts_styles' );
function custom_admin_scripts_styles() {
global $post_type;
if ( 'course' == $post_type ) {
global $post_type;
wp_dequeue_script( 'select2' );
wp_dequeue_style( 'select2' );
@rezzz-dev
rezzz-dev / peb.php
Created August 10, 2016 16:16
Plugin Extension Boilerplate
<?php
/**
* Plugin Name: Plugin Extension Boilerplate
* Plugin URI: https://rezzz.com/
* Description: Extend an existing plugin with more functionality (based: https://codeable.io/community/how-to-extend-a-wordpress-plugin-my-plugin-boilerplate/)
* Version: 1.0.0
* Author: Jason Resnick
* Author URI: https://rezzz.com/
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html