Skip to content

Instantly share code, notes, and snippets.

View TravisBallard's full-sized avatar

Travis Ballard TravisBallard

View GitHub Profile
@TravisBallard
TravisBallard / gist:4446207
Created January 3, 2013 19:21
Output Template - Creating a Paginated TBTestimonials Output Template
{% if paged %}
<p>Testimonials Page <em>{{ paged }}</em></p>
<div id="testimonials-page-{{ paged }}">
{% for testimonial in testimonials %}
<div class="testimonial">
<p>{{ testimonial.post_title }}</p>
{{ testimonial.post_content_html }}
</div>
{% endfor %}
</div>
@TravisBallard
TravisBallard / gist:4446188
Last active December 10, 2015 14:18
Creating a Paginated TBTestimonials Output Template
<?php
class TBTestimonialPaginate
{
public $per_page;
/**
* magic
*
* @param mixed $per_page - testimonials to show per page
<?php
# template name: Add Testimonial Form
get_header();
$testimonial = false;
$errors = array();
/**
* testimonial data is being submitted
*/
<?php
# add testimonial
global $tbtestimonials;
$testimonial = array(
'post_type' => $tbtestimonials->post_type,
'post_status' => 'draft',
'post_title' => esc_attr( $author ),
'post_content' => wp_filter_kses( $content ) // no dirty stuff, k? k!
);
<?php
/**
* success message
*
*/
function show_testimonial_success(){
echo '<div class="success"><p>Thanks for submitting your testimonial for review!</p></div>';
}
<?php
$testimonial = false;
$errors = array();
/**
* testimonial data is being submitted
*/
if( isset( $_POST['new_testimonial'] ) && is_array( $_POST['new_testimonial'] ) && count( $_POST['new_testimonial'] ) > 0 )
{
<?php
# template name: Add Testimonial Form
get_header();
?>
<div id="content">
<div class="entry-content">
<form action="" method="post">
<p>
<label for="testimonial-author">Name:</label>
/**
* add a post/goal
*
* @param mixed $title
* @param mixed $content
* @param mixed $tags
*/
public function add_goal( $title, $content, $tags = '' )
{
global $current_user;
/**
* outputting post meta must be done inside of 'the loop'
*/
# college
if( false !== ( $college = get_post_meta( get_the_ID, 'college', 1 ) ) )
echo $college;
else
echo 'No college';
@TravisBallard
TravisBallard / gist:3800689
Created September 28, 2012 16:03
Add new thumbnail image tag to TBTestimonials
<?php
/**
* add custom template tags to tbtestimonials plugin
*
* @param mixed $t - twig instance
*/
function add_tags_to_tbt( $t ){
$t->addGlobal( 'testimonial_thumbnail', call_user_func( 'tbt_featured_image_tag' ) ); // #adds {{ testimonial_thumbnail }} template tag mapped to tbt_featured_image function
}