Skip to content

Instantly share code, notes, and snippets.

View JustinSainton's full-sized avatar

Justin Sainton JustinSainton

View GitHub Profile
@JustinSainton
JustinSainton / gist:396c7057a8c4ce19f37c654418ecbfdd
Created May 12, 2016 03:50 — forked from lucasstark/gist:6594983
Example to add meta data to woocommerce cart items
<?php
/*
* Plugin Name: Example Modify Price
*/
class Example_Modify_Price {
private static $instance;
public static function register() {
if (self::$instance == null) {
@JustinSainton
JustinSainton / test.php
Last active August 29, 2015 14:21 — forked from lizkaraffa/gist:190587cfb7e653160141
Description
<?php
public function add_meta_box( $post_type ) {
$post_type = 'notes'; //limit meta box to certain post types
add_meta_box(
'handshaken_note_settings',
__( 'Note Settings', 'handshaken' ),
array( $this, 'render_meta_box_content_note' ),
$post_type,
'advanced',
@JustinSainton
JustinSainton / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
/** Automatically append mtime to script and style versions for cache-busting action **/
add_action( 'wp_enqueue_scripts', function() {
global $wp_styles, $wp_scripts;
foreach( array( 'wp_styles', 'wp_scripts' ) as $resource ) {
foreach( $$resource->registered as $name => $registered_resource ) {
// Not hosted here
/**
* overlay.js
*
* Handles toggling the whole screen overlay when nav button is clicked.
*/
jQuery( document ).ready( function( $ ) {
$("#slider-btn").toggle(function() {
$('#page-overlay').css('display','block');
$('.menu-main-menu-container').css('display','block');
<?php
/* This actually all looks fine and shouldn't be problematic really. I'd do a few things differently, most likely, but mostly because I'd envision it within the WordPress context. */
function get_list_view_html( $product_id, $product ) {
$products = get_products_all();
$output = "";
$output = $output . "<li>";
$output = $output . '<a href="shirt.php?id=' . $product_id . '">';
$output = $output . '<img src="' . $product["img"] . '" alt="' . $product["name"] . '">';
<!DOCTYPE html>
<html lang="en">
<head>
<title> JavaScript Foundations: Arrays</title>
<style>
html {
background: #FAFAFA;
font-family: sans-serif;
}
</style>

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

@JustinSainton
JustinSainton / url-spamcheck.php
Last active February 4, 2016 13:02 — forked from norcross/url-spamcheck.php
Marks any comment as spam whose author link is greater than 50 chars.
<?php
function rkv_url_spamcheck( $approved , $commentdata ) {
return ( strlen( $commentdata['comment_author_url'] ) > 50 ) ? 'spam' : $approved;
}
add_filter( 'pre_comment_approved', 'rkv_url_spamcheck', 99, 2 );
function avr_replace_title_with_meta( $title, $id ) {
$type = get_post_type();
if ( in_array( $type, array( 'property', 'rate' ) ) )
$title = get_post_meta( $id, 'avr_' . $type . '_title', true );
return $title;
}
add_filter( 'the_title', 'avr_replace_title_with_meta', 10, 2 );