Created
October 22, 2020 03:59
-
-
Save raselupm/eb6ac066d8ed7e03cea3f91ce10d20ba to your computer and use it in GitHub Desktop.
gf-modal.php
This file contains hidden or 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
function modal_testimonial_btn( $atts, $content = null ) { | |
extract( shortcode_atts( array( | |
'form_id' => '' | |
), $atts ) ); | |
$q = new WP_Query( | |
array('posts_per_page' => -1, 'post_type' => 'review') | |
); | |
$html = ''; | |
while($q->have_posts()) : $q->the_post(); | |
$html .= '<div class="single-testimonial-item"> | |
<div class="testimonial-content"> | |
'.wpautop(get_the_content()).' | |
</div> | |
<h4>'.get_the_title().'</h4> | |
</div>'; | |
endwhile; wp_reset_query(); | |
if(!empty($form_id)) { | |
$html .=' | |
<button data-toggle="modal" data-target="#submit-testimonial" class="boxed-btn submit-testimonial-btn">Submit testimonial</button> | |
<div class="modal fade" id="submit-testimonial" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> | |
<div class="modal-dialog"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<h5 class="modal-title" id="exampleModalLabel">Submit testimonial</h5> | |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
<span aria-hidden="true">×</span> | |
</button> | |
</div> | |
<div class="modal-body"> | |
'.do_shortcode('[gravityform id="'.$form_id.'" title="false" ajax="true"]').' | |
</div> | |
</div> | |
</div> | |
</div> | |
'; | |
} | |
return $html; | |
} | |
add_shortcode('testimonials', 'modal_testimonial_btn'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment