'business_era_widget_social', 'description' => esc_html__( 'Social Icons Widget', 'business-era' ), ); parent::__construct( 'business-era-social', esc_html__( 'Business Era: Social', 'business-era' ), $opts ); } /** * Echo the widget content. * * @since 1.0.0 * * @param array $args Display arguments including before_title, after_title, * before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget. */ function widget( $args, $instance ) { $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); echo $args['before_widget']; if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; } if ( has_nav_menu( 'social' ) ) { wp_nav_menu( array( 'theme_location' => 'social', 'link_before' => '', 'link_after' => '', ) ); } echo $args['after_widget']; } /** * Update widget instance. * * @since 1.0.0 * * @param array $new_instance New settings for this instance as input by the user via * {@see WP_Widget::form()}. * @param array $old_instance Old settings for this instance. * @return array Settings to save or bool false to cancel saving. */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = sanitize_text_field( $new_instance['title'] ); return $instance; } /** * Output the settings update form. * * @since 1.0.0 * * @param array $instance Current settings. */ function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', ) ); ?>

'business_era_widget_latest_news', 'description' => __( 'Latest News Widget', 'business-era' ), ); parent::__construct( 'business-era-latest-news', esc_html__( 'Business Era: Latest News', 'business-era' ), $opts ); } function widget( $args, $instance ) { $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $post_category = ! empty( $instance['post_category'] ) ? $instance['post_category'] : 0; $post_column = ! empty( $instance['post_column'] ) ? $instance['post_column'] : 4; $featured_image = ! empty( $instance['featured_image'] ) ? $instance['featured_image'] : 'medium'; $post_number = ! empty( $instance['post_number'] ) ? $instance['post_number'] : 4; $excerpt_length = !empty( $instance['excerpt_length'] ) ? $instance['excerpt_length'] : 10; $enable_excerpt = ! empty( $instance['enable_excerpt'] ) ? $instance['enable_excerpt'] : 0; echo $args['before_widget']; echo '
'; if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } ?> esc_attr( $post_number ), 'no_found_rows' => true, ); if ( absint( $post_category ) > 0 ) { $query_args['cat'] = absint( $post_category ); } $all_posts = get_posts( $query_args ); ?>
$post ) : ?>
'; echo $args['after_widget']; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = sanitize_text_field( $new_instance['title'] ); $instance['post_category'] = absint( $new_instance['post_category'] ); $instance['post_number'] = absint( $new_instance['post_number'] ); $instance['post_column'] = absint( $new_instance['post_column'] ); $instance['excerpt_length'] = absint( $new_instance['excerpt_length'] ); $instance['enable_excerpt']= (bool) $new_instance['enable_excerpt'] ? 1 : 0; $instance['featured_image'] = esc_url_raw( $new_instance['featured_image'] ); return $instance; } function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'post_category' => '', 'post_column' => 4, 'featured_image' => 'medium', 'post_number' => 4, 'excerpt_length' => 10, 'enable_excerpt'=> 0, ) ); ?>

'name', 'hide_empty' => 0, 'taxonomy' => 'category', 'name' => $this->get_field_name( 'post_category' ), 'id' => $this->get_field_id( 'post_category' ), 'class' => 'widefat', 'selected' => absint( $instance['post_category'] ), 'show_option_all' => __( 'All Categories','business-era' ), ); wp_dropdown_categories( $cat_args ); ?>

dropdown_post_columns( array( 'id' => $this->get_field_id( 'post_column' ), 'name' => $this->get_field_name( 'post_column' ), 'selected' => absint( $instance['post_column'] ), ) ); ?>

dropdown_image_sizes( array( 'id' => $this->get_field_id( 'featured_image' ), 'name' => $this->get_field_name( 'featured_image' ), 'selected' => esc_attr( $instance['featured_image'] ), ) ); ?>

 

id="get_field_id( 'enable_excerpt' ); ?>" name="get_field_name( 'enable_excerpt' ); ?>" />

'', 'name' => '', 'selected' => 0, ); $r = wp_parse_args( $args, $defaults ); $output = ''; $choices = array( '2' => 2, '3' => 3, '4' => 4, ); if ( ! empty( $choices ) ) { $output = "\n"; } echo $output; } function dropdown_image_sizes( $args ) { $defaults = array( 'id' => '', 'class' => 'widefat', 'name' => '', 'selected' => 0, ); $r = wp_parse_args( $args, $defaults ); $output = ''; $choices = array( 'business-era-blog' => esc_html__( 'Business Era Custom', 'business-era' ), 'thumbnail' => esc_html__( 'Thumbnail', 'business-era' ), 'medium' => esc_html__( 'Medium', 'business-era' ), 'large' => esc_html__( 'Large', 'business-era' ), 'full' => esc_html__( 'Full', 'business-era' ), ); if ( ! empty( $choices ) ) { $output = "\n"; } echo $output; } } endif; if ( ! class_exists( 'Business_Era_CTA_Widget' ) ) : /** * CTA widget class. * * @since 1.0.0 */ class Business_Era_CTA_Widget extends WP_Widget { /** * Constructor. * * @since 1.0.0 */ function __construct() { $opts = array( 'classname' => 'business_era_widget_call_to_action', 'description' => esc_html__( 'Call To Action Widget', 'business-era' ), ); parent::__construct( 'business-era-cta', esc_html__( 'Business Era: CTA', 'business-era' ), $opts ); } /** * Echo the widget content. * * @since 1.0.0 * * @param array $args Display arguments including before_title, after_title, * before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget. */ function widget( $args, $instance ) { $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $text = ! empty( $instance['text'] ) ? $instance['text'] : ''; $button_text = ! empty( $instance['button_text'] ) ? esc_html( $instance['button_text'] ) : ''; $button_url = ! empty( $instance['button_url'] ) ? esc_url( $instance['button_url'] ) : ''; echo $args['before_widget']; echo '
'; if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; } ?>
'; echo $args['after_widget']; } /** * Update widget instance. * * @since 1.0.0 * * @param array $new_instance New settings for this instance as input by the user via * {@see WP_Widget::form()}. * @param array $old_instance Old settings for this instance. * @return array Settings to save or bool false to cancel saving. */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = sanitize_text_field( $new_instance['title'] ); $instance['text'] = sanitize_text_field( $new_instance['text'] ); $instance['button_text'] = sanitize_text_field( $new_instance['button_text'] ); $instance['button_url'] = esc_url_raw( $new_instance['button_url'] ); return $instance; } /** * Output the settings update form. * * @since 1.0.0 * * @param array $instance Current settings. */ function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '', 'button_text' => esc_html__( 'Learn more', 'business-era' ), 'button_url' => '', ) ); ?>

'business_era_widget_advance_call_to_action', 'description' => esc_html__( 'Advance Call To Action Widget with multiple buttons and background image', 'business-era' ), ); parent::__construct( 'business-era-advance-cta', esc_html__( 'Business Era: Advance CTA', 'business-era' ), $opts ); } /** * Echo the widget content. * * @since 1.0.0 * * @param array $args Display arguments including before_title, after_title, * before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget. */ function widget( $args, $instance ) { $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $text = ! empty( $instance['text'] ) ? $instance['text'] : ''; $button_text = ! empty( $instance['button_text'] ) ? esc_html( $instance['button_text'] ) : ''; $button_url = ! empty( $instance['button_url'] ) ? esc_url( $instance['button_url'] ) : ''; $button_two_text = ! empty( $instance['button_two_text'] ) ? esc_html( $instance['button_two_text'] ) : ''; $button_two_url = ! empty( $instance['button_two_url'] ) ? esc_url( $instance['button_two_url'] ) : ''; $bg_pic = ! empty( $instance['bg_pic'] ) ? esc_url_raw( $instance['bg_pic'] ) : ''; // Add background image. if ( ! empty( $bg_pic ) ) { $background_style = ''; $background_style .= ' style="background-image:url(' . esc_url( $bg_pic ) . ');" '; $args['before_widget'] = implode( $background_style . ' ' . 'class="with_bg ', explode( 'class="', $args['before_widget'], 2 ) ); } echo $args['before_widget']; echo '
'; if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; } ?>
'; echo $args['after_widget']; } /** * Update widget instance. * * @since 1.0.0 * * @param array $new_instance New settings for this instance as input by the user via * {@see WP_Widget::form()}. * @param array $old_instance Old settings for this instance. * @return array Settings to save or bool false to cancel saving. */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = sanitize_text_field( $new_instance['title'] ); $instance['text'] = sanitize_text_field( $new_instance['text'] ); $instance['button_text'] = sanitize_text_field( $new_instance['button_text'] ); $instance['button_url'] = esc_url_raw( $new_instance['button_url'] ); $instance['button_two_text'] = sanitize_text_field( $new_instance['button_two_text'] ); $instance['button_two_url'] = esc_url_raw( $new_instance['button_two_url'] ); $instance['bg_pic'] = esc_url_raw( $new_instance['bg_pic'] ); return $instance; } /** * Output the settings update form. * * @since 1.0.0 * * @param array $instance Current settings. */ function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '', 'button_text' => esc_html__( 'Learn more', 'business-era' ), 'button_url' => '', 'button_two_text' => esc_html__( 'View more', 'business-era' ), 'button_two_url' => '', 'bg_pic' => '', ) ); $bg_pic = ''; if ( ! empty( $instance['bg_pic'] ) ) { $bg_pic = $instance['bg_pic']; } $wrap_style = ''; if ( empty( $bg_pic ) ) { $wrap_style = ' style="display:none;" '; } $image_status = false; if ( ! empty( $bg_pic ) ) { $image_status = true; } $delete_button = 'display:none;'; if ( true === $image_status ) { $delete_button = 'display:inline-block;'; } ?>




> <?php _e( 'Preview', 'business-era' ); ?>

'business_era_widget_services', 'description' => __( 'Display services.', 'business-era' ), ); parent::__construct( 'business-era-services', __( 'Business Era: Services', 'business-era' ), $opts ); } function widget( $args, $instance ) { $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $excerpt_length = !empty( $instance['excerpt_length'] ) ? $instance['excerpt_length'] : 20; $detail_link = ! empty( $instance['detail_link'] ) ? $instance['detail_link'] : 0; $services_ids = array(); $item_number = 6; for ( $i = 1; $i <= $item_number; $i++ ) { if ( ! empty( $instance["item_id_$i"] ) && absint( $instance["item_id_$i"] ) > 0 ) { $id = absint( $instance["item_id_$i"] ); $services_ids[ $id ]['id'] = $id; $services_ids[ $id ]['icon'] = $instance["item_icon_$i"]; } } echo $args['before_widget']; echo '
'; if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } if ( ! empty( $services_ids ) ) { $query_args = array( 'posts_per_page' => count( $services_ids ), 'post__in' => wp_list_pluck( $services_ids, 'id' ), 'orderby' => 'post__in', 'post_type' => 'page', 'no_found_rows' => true, ); $all_services = get_posts( $query_args ); ?> '; echo $args['after_widget']; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = sanitize_text_field( $new_instance['title'] ); $instance['excerpt_length'] = absint( $new_instance['excerpt_length'] ); $instance['detail_link'] = (bool) $new_instance['detail_link'] ? 1 : 0; $item_number = 8; for ( $i = 1; $i <= $item_number; $i++ ) { $instance["item_id_$i"] = absint( $new_instance["item_id_$i"] ); $instance["item_icon_$i"] = sanitize_text_field( $new_instance["item_icon_$i"] ); } return $instance; } function form( $instance ) { // Defaults. $defaults = array( 'title' => '', 'excerpt_length' => 20, 'detail_link' => 0, ); $item_number = 8; for ( $i = 1; $i <= $item_number; $i++ ) { $defaults["item_id_$i"] = ''; $defaults["item_icon_$i"] = 'fa-cog'; } $instance = wp_parse_args( (array) $instance, $defaults ); ?>

id="get_field_id( 'detail_link' ); ?>" name="get_field_name( 'detail_link' ); ?>" />

$this->get_field_id( "item_id_$i" ), 'class' => 'widefat', 'name' => $this->get_field_name( "item_id_$i" ), 'selected' => $instance["item_id_$i"], 'show_option_none' => esc_html__( '— Select —', 'business-era' ), ) ); ?>

" name="get_field_name( "item_icon_$i" ) ); ?>" type="text" value="" />

'business_era_widget_page', 'description' => __( 'Display page and its featured image.', 'business-era' ), ); parent::__construct( 'business-era-page', __( 'Business Era: Page', 'business-era' ), $opts ); } function widget( $args, $instance ) { $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $page_id = ! empty( $instance['page_id'] ) ? absint( $instance['page_id'] ) : ''; $img_position = ! empty( $instance['img_position'] ) ? sanitize_text_field( $instance['img_position'] ) : ''; echo $args['before_widget']; echo '
'; if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } if ( ! empty( $page_id ) ) { $page_args = array( 'posts_per_page' => 1, 'post_type' => 'page', 'page_id' => absint( $page_id ), 'post_status' => 'publish', ); $page_query = new WP_Query( $page_args ); if( $page_query->have_posts()){ while( $page_query->have_posts()){ $page_query->the_post(); $img_pos = ''; $page_pos_one = ''; $page_pos_two = ''; if( 'Left' === $img_position ){ $img_pos = 'img-in-left'; $page_pos_one = 'right'; $page_pos_two = 'left'; } elseif( 'Right' === $img_position ){ $img_pos = 'img-in-right'; $page_pos_one = 'left'; $page_pos_two = 'right'; } ?>
'; echo $args['after_widget']; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = sanitize_text_field( $new_instance['title'] ); $instance['page_id'] = absint( $new_instance['page_id'] ); $instance['img_position'] = sanitize_text_field( $new_instance['img_position'] ); return $instance; } function form( $instance ) { // Defaults. $defaults = array( 'title' => '', 'page_id' => '', 'img_position' => 'Left', ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

$this->get_field_id( "page_id" ), 'class' => 'widefat', 'name' => $this->get_field_name( "page_id" ), 'selected' => $instance["page_id"], 'show_option_none' => esc_html__( '— Select —', 'business-era' ), ) ); ?>