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
*/
function widget( $args, $instance ) {
global $wp_query;
extract( $args );
# Merge with defaults
$instance = wp_parse_args( (array) $instance, $this->defaults );
echo $before_widget;
# Set up the author bio
if ( ! empty( $instance['title'] ) ) {
echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $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( 'class' => 'entry-image attachment-' . get_post_type( $wp_query->post->ID ) . ' ' . esc_attr( $instance['image_alignment'] ) ) ),
) );
if ( $instance['show_image'] && $image ) {
printf( '%s ', get_permalink(), the_title_attribute( 'echo=0' ), $image );
}
if ( ! empty( $instance['show_title'] ) ) {
printf( '', get_permalink(), the_title_attribute( 'echo=0' ), get_the_title() );
}
if ( ! empty( $instance['show_content'] ) ) {
echo '';
if ( empty( $instance['content_limit'] ) ) {
global $more;
$more = 0;
the_content( $instance['more_text'] );
} else {
the_content_limit( (int) $instance['content_limit'], esc_html( $instance['more_text'] ) );
}
echo '
';
}
echo ' ';
endwhile;
endif;
# Restore original query
wp_reset_query();
echo $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 );
?>
:
:
$this->get_field_name( 'page_id' ), 'selected' => $instance['page_id'] ) ); ?>
/>
:
thumbnail (x)
$size )
echo '' . esc_html( $name ) . ' (' . absint( $size['width'] ) . 'x' . absint( $size['height'] ) . ') ';
?>
:
- -
>
>
/>
/>
:
: