| Server IP : 216.250.13.251 / Your IP : 216.73.217.37 Web Server : nginx/1.24.0 System : Linux gunay 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : root ( 0) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/gunay/wp-content/plugins/rt19-extentions/inc/shortcodes/ |
Upload File : |
<?php
if( ! function_exists("rt_testimonials") ){
/**
* Testimonanials
* @param array $atts
* @param string $content
* @return output
*/
function rt_testimonials( $atts, $content = null ) {
global $client_images;
//counter
$counter = 1;
//defaults
extract(shortcode_atts(array(
"id" => 'testimonial-'.rand(100000, 1000000),
"class" => '',
"list_layout" => "1/1",
"ids" => array(),
"item_per_page"=> 9,
"list_orderby" => "date",
"list_order" => "DESC",
"pagination" => "false",
"style"=> "left",
"client_images" => "true",
"categories" => ""
), $atts));
//product id numbders
$ids = ! empty( $ids ) ? explode(",", trim( $ids ) ) : array();
//item width percentage
$list_layout = ! empty( $list_layout ) ? $list_layout : "1/3";
//row count
$column_count = rt_column_count( $list_layout );
//paged
if( $pagination !== "false" ){
if (get_query_var('paged') ) {$paged = get_query_var('paged');} elseif ( get_query_var('page') ) {$paged = get_query_var('page');} else {$paged = 1;}
}else{
$paged = 0;
}
//create a post status array
$post_status = is_user_logged_in() ? array( 'private', 'publish' ) : "publish";
//general query
$args=array(
'post_status' => $post_status,
'post_type' => 'testimonial',
'orderby' => $list_orderby,
'order' => $list_order,
'posts_per_page' => $item_per_page,
'paged' => $paged
);
if( ! empty ( $ids ) ){
$args = array_merge($args, array( 'post__in' => $ids) );
}
if( ! empty ( $categories ) ){
$categories = is_array( $categories ) ? $categories : explode(",", rt_wpml_lang_object_ids( $categories, "testimonial_categories" ) );
$args = array_merge($args, array(
'tax_query' => array(
array(
'taxonomy' => 'testimonial_categories',
'field' => 'id',
'terms' => $categories,
'operator' => "IN"
)
),
) );
}
ob_start();
$theQuery = new WP_Query($args);
//get page & post counts
$post_count = $theQuery->post_count;
//add additional classes
$class .= " ".$style;
//column class
$add_column_class = rt_column_class( $list_layout );
//id attr
$id_attr = ! empty( $id ) ? 'id="'.sanitize_html_class($id).'"' : "";
echo '<section '.$id_attr.' class="border_grid testimonials clearfix '.$class.' " data-column-width="'. $column_count .'">';
while ( $theQuery->have_posts() ) : $theQuery->the_post();
//add first last classes if filterable is off
$add_class = "";
if( $counter % $column_count == 1 || $column_count == 1 ){
$add_class .= " first";
}
if( ( $counter % $column_count == 0 || $post_count == $counter ) && $add_class == "" ){
$add_class .= " last";
}
//post class
$add_class .= " ". implode(" ", get_post_class("loop"));
//open row block
if( $counter % $column_count == 1 || $column_count == 1 ){
echo '<div class="row">';
}
printf('<div id="%s" class="testimonial col %s %s">'."\n", get_the_ID(), $add_column_class ,$add_class);
get_template_part( 'testimonial-contents/content');
echo '</div>'."\n";
//close row block and add hr
if( $counter % $column_count == 0 || $post_count == $counter ){
echo '</div>';
}
$counter++;
endwhile;
echo '</section>';
if( $pagination !== "false" ){
rt_get_pagination( $theQuery );
}
wp_reset_postdata();
$output_string = ob_get_contents();
ob_end_clean();
return $output_string;
}
}
add_shortcode('testimonial_box', 'rt_testimonials');