'',
'at_all_page_items' => '',
'single_item_link_option' => 'disable',
'column_number' => 3,
'display_type' => 'column',
'view_all_option' => 'disable',
'all_link_text' => '',
'all_link_url' => '',
'enable_prev_next' => 1
);
function __construct() {
parent::__construct(
/*Base ID of your widget*/
'online_shop_about',
/*Widget name will appear in UI*/
esc_html__( 'AT About/Service Section', 'online-shop' ),
/*Widget description*/
array( 'description' => esc_html__( 'Show Section with beautiful Icons.', 'online-shop' ), )
);
}
/*Widget Backend*/
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, $this->defaults );
/*default values*/
$online_shop_widget_title = esc_attr( $instance['online_shop_widget_title'] );
$at_all_page_items = $instance['at_all_page_items'];
$single_item_link_option = esc_attr( $instance[ 'single_item_link_option' ] );
$column_number = absint( $instance['column_number'] );
$display_type = esc_attr( $instance[ 'display_type' ] );
$view_all_option = esc_attr( $instance[ 'view_all_option' ] );
$all_link_text = esc_attr( $instance['all_link_text'] );
$all_link_url = esc_url( $instance['all_link_url'] );
$enable_prev_next = esc_attr( $instance['enable_prev_next'] );
?>
0 && is_array($at_all_page_items) ){
foreach ($at_all_page_items as $about){
$repeater_id = $this->get_field_id( 'at_all_page_items') .$total_repeater.'page_id';
$repeater_name = $this->get_field_name( 'at_all_page_items' ).'['.$total_repeater.']['.'page_id'.']';
?>
$about['page_id'],
'name' => $repeater_name,
'id' => $repeater_id,
'class' => 'widefat at-select',
'show_option_none' => esc_html__( 'Select Page', 'online-shop'),
'option_none_value'=> 0 // string
);
wp_dropdown_pages( $args );
?>
get_field_id( 'at_all_page_items') .$coder_repeater_depth.'page_id';
$repeater_name = $this->get_field_name( 'at_all_page_items' ).'['.$coder_repeater_depth.']['.'page_id'.']';
?>
';
$add_field = esc_html__('Add Item', 'online-shop');
echo '
'.$add_field.'';
?>
/>
0 && is_array($at_all_page_items) ){
foreach ($at_all_page_items as $key=>$about ){
$page_ids[$key]['page_id'] = absint( $about['page_id'] );
}
}
}
$instance[ 'at_all_page_items' ] = $page_ids;
$online_shop_link_options = online_shop_adv_link_options();
$instance[ 'single_item_link_option' ] = online_shop_sanitize_choice_options( $new_instance[ 'single_item_link_option' ], $online_shop_link_options, 'disable' );
$instance[ 'column_number' ] = absint( $new_instance['column_number'] );
$online_shop_widget_display_types = online_shop_widget_display_type();
$instance[ 'display_type' ] = online_shop_sanitize_choice_options( $new_instance[ 'display_type' ], $online_shop_widget_display_types, 'column' );
$instance[ 'view_all_option' ] = online_shop_sanitize_choice_options( $new_instance[ 'view_all_option' ], $online_shop_link_options, 'disable' );
$instance[ 'all_link_text' ] = sanitize_text_field( $new_instance[ 'all_link_text' ] );
$instance[ 'all_link_url' ] = esc_url_raw( $new_instance[ 'all_link_url' ] );
$instance[ 'enable_prev_next' ] = isset( $new_instance['enable_prev_next'] )? 1 : 0;
return $instance;
}
/**
* 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 ) {
$instance = wp_parse_args( (array) $instance, $this->defaults );
/*default values*/
$online_shop_widget_title = !empty( $instance['online_shop_widget_title'] ) ? esc_attr( $instance['online_shop_widget_title'] ) : '';
$online_shop_widget_title = apply_filters( 'widget_title', $online_shop_widget_title, $instance, $this->id_base );
$at_all_page_items = $instance['at_all_page_items'];
$single_item_link_option = esc_attr( $instance[ 'single_item_link_option' ] );
$column_number = absint( $instance['column_number'] );
$display_type = esc_attr( $instance[ 'display_type' ] );
$view_all_option = esc_attr( $instance[ 'view_all_option' ] );
$all_link_text = esc_html( $instance[ 'all_link_text' ] );
$all_link_url = esc_url( $instance[ 'all_link_url' ] );
$enable_prev_next = esc_attr( $instance['enable_prev_next'] );
$div_attr = 'class="featured-entries-col featured-entries-about '.$display_type.'"';
if( 'carousel' == $display_type ){
$div_attr = 'class="featured-entries-col featured-entries-about acme-slick-carausel" data-column="'.absint( $column_number ).'"';
}
echo $args['before_widget'];
if ( !empty( $online_shop_widget_title ) ||
'disable' != $view_all_option ||
( 1 == $enable_prev_next && 'carousel' == $display_type )
){
echo $args['before_title'];
echo $online_shop_widget_title;
echo "";
if( 'disable' != $view_all_option && !empty( $all_link_text ) && !empty( $all_link_url )){
$target ='';
if( 'new-tab-link' == $view_all_option ){
$target = 'target="_blank"';
}
echo ''.$all_link_text.'';
}
if( 1 == $enable_prev_next && 'carousel' == $display_type){
echo '';
}
echo "";/*.at-action-wrapper*/
echo $args['after_title'];
}
?>
>
0 && is_array($at_all_page_items) ){
foreach ( $at_all_page_items as $about ){
if( isset( $about['page_id'] ) && !empty( $about['page_id'] ) ){
$post_in[] = $about['page_id'];
}
}
}
if( !empty( $post_in )) :
$query_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'
);
$online_shop_featured_query = new WP_Query( $query_args );
$online_shop_featured_index = 1;
while ( $online_shop_featured_query->have_posts() ) :$online_shop_featured_query->the_post();
$online_shop_list_classes = 'single-list';
if( 'carousel' != $display_type ){
if( 1 != $online_shop_featured_index && $online_shop_featured_index % $column_number == 1 ){
echo "
";
}
if( 1 == $column_number ){
$online_shop_list_classes .= " acme-col-1";
}
elseif( 2 == $column_number ){
$online_shop_list_classes .= " acme-col-2";
}
elseif( 3 == $column_number ){
$online_shop_list_classes .= " acme-col-3";
}
else{
$online_shop_list_classes .= " acme-col-4";
}
}
?>