Last active
August 7, 2017 23:47
-
-
Save neilgee/9a62ac916835b8999bb6abf2f94cf29c to your computer and use it in GitHub Desktop.
Testimonial Rotator & Genesis Templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action ( 'get_header', 'tt_remove_post_info_archive' ); | |
// Remove Post Info, Post Meta from CPT | |
function tt_remove_post_info_archive() { | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
} | |
add_action('genesis_before_loop','tt_cpt_change_all'); | |
function tt_cpt_change_all() { | |
if ( is_post_type_archive( 'testimonial' ) ) { | |
add_filter( 'genesis_pre_get_option_content_archive','cpt_change_content' ); | |
function cpt_change_content() { | |
return 'full'; | |
} | |
add_filter( 'genesis_pre_get_option_content_archive_thumbnail','cpt_change_image_presence' ); | |
function cpt_change_image_presence() { | |
return 0; | |
} | |
} | |
} | |
add_action( 'genesis_entry_footer', 'tt_add_testi_author', 5 ); | |
function tt_add_testi_author() { | |
global $post; | |
$testimonial_id = isset($testimonial_id) ? $testimonial_id : $post->ID; | |
$cite = get_post_meta( $testimonial_id, '_cite', true ); | |
echo "<hr class=\"longform_hr\">\n"; | |
echo "<div class=\"testimonial_rotator_author_info cf-tr\">\n"; | |
echo wpautop($cite); | |
echo "</div>\n"; | |
} | |
add_action( 'genesis_entry_content', 'tt_add_testi_image', 5 ); | |
function tt_add_testi_image() { | |
global $post; | |
if( has_post_thumbnail() ) { | |
$img_size = 'thumbnail'; | |
$testimonial_id = isset($testimonial_id) ? $testimonial_id : $post->ID; | |
echo "<div class=\"testimonial_rotator_img img\">" . get_the_post_thumbnail( get_the_ID(), $img_size) . "</div>\n"; | |
} | |
} | |
add_action( 'genesis_before_loop','eg_testimonialheader', 5 ); | |
/** | |
* Position Footer Widget Header. | |
*/ | |
function eg_testimonialheader() { | |
if ( is_active_sidebar( 'testimonial-header' ) ) { | |
echo '<div class="testimonialheader-container"><div class="wrap entry">'; | |
genesis_widget_area( 'testimonial-header' ); | |
echo '</div></div>'; | |
} | |
} | |
genesis(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.testimonial_rotator.template-default .has-image .img, | |
.testimonial_rotator_single.has-image.template-default .img { | |
width: auto; | |
margin-right: 20px; | |
float: left; | |
padding: 0; | |
padding-top: .5em; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action ( 'get_header', 'tt_remove_post_info_single' ); | |
// Remove Post Info, Post Meta from CPT | |
function tt_remove_post_info_single() { | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
} | |
// All of the content comes in apart from the testimonial featured image - which the function below takes care of | |
add_action('genesis_entry_content', 'tt_add_testi_image', 5); | |
function tt_add_testi_image() { | |
$img_size = 'thumbnail'; // Add size | |
echo "<div class=\"testimonial_rotator_img img\">" . get_the_post_thumbnail( get_the_ID(), $img_size) . "</div>\n"; | |
} | |
genesis(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This is copied from /wp-content/plugins/testimonial-rotator/templates/longform/loop-testimonial.php and filed in your theme root - you can chose the default or longform | |
// Adjust as required - loop-testimonial-home-rotator.php | |
// WRAPPER | |
echo "<div class=\"slide slide{$slide_count} testimonial_rotator_slide hreview itemreviewed item {$has_image} cf-tr\">\n"; | |
// RATING | |
if( $rating AND $show_stars ) { | |
echo "<div class=\"testimonial_rotator_stars cf-tr\">\n"; | |
for($r=1; $r <= $rating; $r++) | |
{ | |
echo " <span class=\"testimonial_rotator_star testimonial_rotator_star_$r\"><i class=\"fa {$testimonial_rotator_star}\"></i></span>"; | |
} | |
echo "</div>\n"; | |
} | |
// IF SHOW TITLE | |
if( $show_title ) { | |
echo "<{$title_heading} class=\"testimonial_rotator_slide_title\">"; | |
// if( $show_link ) | |
echo "<a href=\"" . get_permalink() . "\">"; | |
echo get_the_title(); | |
// if( $show_link ) | |
echo "</a>"; | |
echo "</{$title_heading}>\n"; | |
} | |
// DESCRIPTION | |
echo "<div class=\"text testimonial_rotator_description\">\n"; | |
// CONTENT | |
if( $show_body ) { | |
echo "<div class=\"testimonial_rotator_quote\">\n"; | |
echo ($show_size == "full") ? do_shortcode(nl2br(get_the_content(' '))) : testimonial_rotator_excerpt( $excerpt_length, $link_text ); | |
echo "</div>\n"; | |
} | |
// AUTHOR INFO | |
if( $cite AND $show_author ) { | |
echo '<hr class="longform_hr">'; | |
if ( $has_image AND $show_image ) echo " <div class=\"testimonial_rotator_img img\">" . get_the_post_thumbnail( get_the_ID(), $img_size) . "</div>\n"; | |
echo "<div class=\"testimonial_rotator_author_info cf-tr\">\n"; | |
echo wpautop($cite); | |
echo "</div>\n"; | |
} | |
echo "</div>\n"; | |
// MICRODATA | |
if( $show_microdata ) { | |
$global_rating = $global_rating + $rating; | |
echo "<div class=\"testimonial_rotator_microdata\">\n"; | |
if($itemreviewed) echo "\t<div class=\"item\"><div class=\"fn\">{$itemreviewed}</div></div>\n"; | |
if($rating) echo "\t<div class=\"rating\">{$rating}.0</div>\n"; | |
echo " <div class=\"dtreviewed\"> " . get_the_date('c') . "</div>"; | |
echo " <div class=\"reviewer\"> "; | |
echo " <div class=\"fn\"> " . wpautop($cite) . "</div>"; | |
if ( has_post_thumbnail() ) { echo get_the_post_thumbnail( get_the_ID(), 'thumbnail', array('class' => 'photo' )); } | |
echo " </div>"; | |
echo " <div class=\"summary\"> " . testimonial_rotator_excerpt(apply_filters('testimonial_rotator_microdata_summary_length', 300)) . "</div>"; | |
echo " <div class=\"permalink\"> " . get_permalink() . "</div>"; | |
echo "</div> <!-- .testimonial_rotator_microdata -->\n"; | |
} | |
echo "</div>\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment