Skip to content

Instantly share code, notes, and snippets.

View TravisBallard's full-sized avatar

Travis Ballard TravisBallard

View GitHub Profile
@TravisBallard
TravisBallard / csodfind.py
Created July 11, 2017 18:39
Search our codebase for certain strings and output a report with the line number and file for each
#!/bin/env python
import os
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-q", "--quiet", dest="verbose", action="store_false", default=True, help="don't print status messages to stdout.")
parser.add_option("-p", "--path", dest="path", type="string", default="/Users/tballard/Sites/csod", help="The path to run the inspection on.")
parser.add_option("-t", "--text", dest="text", type="string", default="", help="The string to search for. Only 1 string at a time.")
parser.add_option("-o", "--output-file", dest="output_file", type="string", default="csodfind-report.txt", help="the output file to save to. default is non-us-report.txt")
<?php
$total = 3270;
$perPage = 20;
$curPage = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? intval( $_REQUEST['page'] ) : 1;
// set start position
$start = (($curPage * $perPage) - $perPage) + 1;
if( $start === 0 ) $start = 1;
<li class="testimonial">
<div class="testimonial-gravatar">{{ gravatar }}</div>
<div class="testimonial-data">
<p class="testimonial-content">{{ testimonial_excerpt }}</p>
<p class="testimonial-author">{{ author_prefix }}{{ author }}</p>
{% if company_url %}
<p class="testimonial-company"><a href="{{ company_url }}">{{ company_name }}</a></p>
{% endif %}
</div>
<div class="clear"></div>
@TravisBallard
TravisBallard / foo.php
Last active December 15, 2015 17:09
Adding custom more link to template tags in TB-Testimonials
<?php
add_action( 'tbt_template_functions', 'add_tags_to_tbt' );
/**
* add custom template tags to tbtestimonials plugin
*
* @param mixed $t - twig instance
*/
function add_tags_to_tbt( $t )
@TravisBallard
TravisBallard / TBTestimonialsSingleTestimonialWidget.php
Created February 15, 2013 17:29
Slimmed down single testimonial widget for TBTestimonials.
<?php
/**
* plugin name: TBTestimonials Single Testimonial Widget
* author: Travis Ballard
* author uri: http://travisballard.com
* version: 1.0
* description: Adds a slimmed down TBTestimonials widget that allows you to select a single testimonial
*/
class TBTestimonialsSingleTestimonialWidget extends WP_Widget
@TravisBallard
TravisBallard / gist:4770528
Created February 12, 2013 15:13
Causes 500 Internal Server Error after saving a page and clicking 'view page' in the updated notice.
<?php
/**
* add discount to logged in users based on available capabilities
*
* @param mixed $cart
*/
function vpm_apply_discount( $cart )
{
if( ! is_user_logged_in() ){
<?php
/**
* add meta box
*
*/
add_action( 'add_meta_boxes', 'add_testimonial_location_metabox' );
function add_testimonial_location_metabox()
{
global $tbtestimonials;
<?php
add_filter( 'tbtestimonials_shortcode', 'change_tbtestimonials_shortcode');
function change_tbtestimonials_shortcode(){
return 'tbtestimonial';
}
<?php
add_filter( 'test_shortcode_filter', 'change_test_shortcode');
function change_test_shortcode(){
return 'fooshortcode';
}
@TravisBallard
TravisBallard / gist:4458315
Last active December 10, 2015 15:59
filter shortcode example - does not work
<?php
/**
* plugin name: test shortcode filter
* author: travis ballard
*/
class ShortcodeFilter
{
public $shortcode = 'testshortcode';