defaults = array( 'title' => '', 'page_id' => '', 'show_image' => 0, 'image_alignment' => '', 'image_size' => '', 'show_title' => 0, 'show_content' => 0, 'content_limit' => '', 'more_text' => '', ); $widget_ops = array( 'classname' => 'featured-content featuredpage', 'description' => __( 'Displays featured page with thumbnails', 'bizznis' ), ); $control_ops = array( 'id_base' => 'featured-page', ); parent::__construct( 'featured-page', __( 'Bizznis - Featured Page', 'bizznis' ), $widget_ops, $control_ops ); } /** * Echo the widget content. * * @since 1.0.0 * * @global WP_Query $wp_query Query object. * @global integer $more * * @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 ) { global $wp_query; # Merge with defaults $instance = wp_parse_args( (array) $instance, $this->defaults ); echo $args['before_widget']; # Set up the title if ( ! empty( $instance['title'] ) ) { echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $args['after_title']; } $wp_query = new WP_Query( array( 'page_id' => $instance['page_id'] ) ); if ( have_posts() ) : while ( have_posts() ) : the_post(); printf( '
', bizznis_attr( 'entry', array( 'class' => implode( ' ', get_post_class() ) ) ) ); $image = bizznis_get_image( array( 'format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-page-widget', 'attr' => bizznis_parse_attr( 'entry-image-widget', array ( 'alt' => get_the_title() ) ), ) ); if ( $instance['show_image'] && $image ) { $role = empty( $instance['show_title'] ) ? '' : 'aria-hidden="true"'; printf( '%s', get_permalink(), esc_attr( $instance['image_alignment'] ), $role, $image ); } if ( ! empty( $instance['show_title'] ) ) { $title = get_the_title() ? get_the_title() : __( '(no title)', 'bizznis' ); /** * Filter the featured page widget title. * * @since 1.2.0 * * @param string $title Featured page title. * @param array $instance { * Widget settings for this instance. * * @type string $title Widget title. * @type int $page_id ID of the featured page. * @type bool $show_image True if featured image should be shown, false * otherwise. * @type string $image_alignment Image alignment: alignnone, alignleft, * aligncenter or alignright. * @type string $image_size Name of the image size. * @type bool $show_title True if featured page title should be shown, * false otherwise. * @type bool $show_content True if featured page content should be shown, * false otherwise. * @type int $content_limit Amount of content to show, in characters. * @type int $more_text Text to use for More link. * } * @param array $args { * Widget display arguments. * * @type string $before_widget Markup or content to display before the widget. * @type string $before_title Markup or content to display before the widget title. * @type string $after_title Markup or content to display after the widget title. * @type string $after_widget Markup or content to display after the widget. * } */ $title = apply_filters( 'bizznis_featured_page_title', $title, $instance, $args ); $heading = bizznis_a11y( 'headings' ) ? 'h4' : 'h2'; printf( '
<%s class="entry-title">%s
', $heading, get_permalink(), $title, $heading ); } if ( ! empty( $instance['show_content'] ) ) { printf( '
', bizznis_attr( 'entry-content' ) ); if ( empty( $instance['content_limit'] ) ) { global $more; $orig_more = $more; $more = 0; the_content( bizznis_a11y_more_link( $instance['more_text'] ) ); $more = $orig_more; } else { the_content_limit( (int) $instance['content_limit'], bizznis_a11y_more_link( esc_html( $instance['more_text'] ) ) ); } echo '
'; } echo '
'; endwhile; endif; # Restore original query wp_reset_query(); echo $args['after_widget']; } /** * Update a particular instance. * * This function should check that $new_instance is set correctly. * The newly calculated value of $instance should be returned. * If "false" is returned, the instance won't be saved/updated. * * @since 1.0.0 */ function update( $new_instance, $old_instance ) { $new_instance['title'] = strip_tags( $new_instance['title'] ); $new_instance['more_text'] = strip_tags( $new_instance['more_text'] ); return $new_instance; } /** * Echo the settings update form. * * @since 1.0.0 */ function form( $instance ) { # Merge with defaults $instance = wp_parse_args( (array) $instance, $this->defaults ); ?>

esc_attr( $this->get_field_name( 'page_id' ) ), 'id' => $this->get_field_id( 'page_id' ), 'selected' => $instance['page_id'] ) ); ?>


/>


/>

/>