esc_html__('Asked Any Question','business-trade'),
'image' => '',
'background-image' => '',
'features' =>'',
);
return $defaults;
}
function __construct() {
parent::__construct(
/*Base ID of your widget*/
'business_trade_faq_widget',
/*Widget name will appear in UI*/
__( 'TM: Faq Widget', 'business-trade' ),
/*Widget description*/
array( 'description' => __( 'TM: Faq 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'] ) ? $instance['title'] : '', $instance, $this->id_base );
$image = esc_url($instance[ 'image']);
$bgimage = esc_url($instance[ 'background-image']);
$features = ( ! empty( $instance['features'] ) ) ? $instance['features'] : array();
echo $args['before_widget'];
if (isset($features) ) :
?>
0 && is_array($features) ){
$post_in[0] = $features['main'];
foreach ( $features as $faq ){
if( isset( $faq['page_ids'] ) && !empty( $faq['page_ids'] ) ){
$post_in[] = $faq['page_ids'];
}
}
}
if( !empty( $post_in )) :
$faq_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'
);
$faq_query = new WP_Query( $faq_page_args );
/*The Loop*/
$i=1;
if ( $faq_query->have_posts() ):
while ( $faq_query->have_posts() ):
$faq_query->the_post();
?>
defaults() );
$title = esc_attr( $instance['title'] );
$image = esc_attr($instance['image']);
$bgimage = esc_attr($instance['background-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 );
?>