esc_html__('Testimonials','business-trade'),
'bg_image' => '',
'features' =>'',
);
return $defaults;
}
public function __construct()
{
parent::__construct(
/*Widget ID */
'business_trade_testimonial_widget',
/*Widget Name */
esc_html__( 'TM: Testimonial Widget', 'business-trade' ),
/*Widget description */
array('description' => esc_html__( 'TM: Testimonial Widget, Best Used in Home page or other page', 'business-trade' ) )
);
}
/**
* Function to Creating widget front-end. This is where the action happens
*
* @access public
* @since 1.0
*
* @param array $args widget setting
* @param array $instance saved values
*
* @return void
*
*/
public function widget($args, $instance)
{
if (!empty($instance))
{
$instance = wp_parse_args((array )$instance, $this->defaults());
$title = apply_filters('widget_title', !empty($instance['title']) ? esc_html( $instance['title']): '', $instance, $this->id_base);
$bg_image = esc_url($instance['bg_image']);
$features = ( ! empty( $instance['features'] ) ) ? $instance['features'] : array();
echo $args['before_widget'];
if (isset($features) && !empty($features['main'])) : ?>
0 && is_array($features) )
{
$post_in[0] = $features['main'];
foreach ( $features as $our_testimonial )
{
if( isset( $our_testimonial['page_ids'] ) && !empty( $our_testimonial['page_ids'] ) )
{
$post_in[] = $our_testimonial['page_ids'];
}
}
}
if( !empty( $post_in )) :
$testimonials_page_args = array(
'post__in' => $post_in,
'orderby' => 'post__in',
'posts_per_page' => count( $post_in ),
'post_type' => 'page',
'no_found_rows' => true,
'post_status' => 'publish'
);
$testimonials_query = new WP_Query( $testimonials_page_args );
/*The Loop*/
if ( $testimonials_query->have_posts() ):
while ( $testimonials_query->have_posts() ):$testimonials_query->the_post();
?>
defaults() );
$title = esc_attr( $instance['title'] );
$bgimage = esc_url( $instance['bg_image'] );
$features = ( ! empty( $instance['features'] ) ) ? $instance['features'] : array();
?>
= 1 && is_array( $features ) )
{
$selected = $features['main'];
}
else
{
$selected = "";
}
$repeater_id = $this->get_field_id( 'features' ).'-main';
$repeater_name = $this->get_field_name( 'features'). '[main]';
$args = array(
'selected' => $selected,
'name' => $repeater_name,
'id' => $repeater_id,
'class' => 'widefat ct-select',
'show_oction_none' => __( 'Select Page', 'business-trade'),
'oction_none_value' => 0 // string
);
wp_dropdown_pages( $args );
$counter = 0;
if ( count( $features ) > 0 )
{
foreach( $features as $feature )
{
if ( isset( $feature['page_ids'] ) )
{ ?>
get_field_id( 'features' ) .'-'. $counter.'-page_ids';
$repeater_name = $this->get_field_name( 'features' ) . '['.$counter.'][page_ids]';
$args = array(
'selected' => $feature['page_ids'],
'name' => $repeater_name,
'id' => $repeater_id,
'class' => 'widefat ct-select',
'show_oction_none' => __( 'Select Page', 'business-trade'),
'oction_none_value' => 0 // string
);
wp_dropdown_pages( $args );
?>
style="display:none;" >