Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions classes/widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ function __construct() {
$widget_options = array(
'classname' => 'arpw-widget-random',
'description' => __( 'An advanced widget that gives you total control over the output of the random posts.', 'arpw' )
);
);

$control_ops = array(
'width' => 700,
'height' => 350,
);
);

// Create the widget.
$this->WP_Widget(
'arpw-widget', // $this->id_base
__( 'Random Posts', 'arpw' ), // $this->name
$widget_options, // $this->widget_options
$control_ops // $this->control_options
);
);

}

Expand Down Expand Up @@ -94,6 +94,8 @@ function update( $new_instance, $old_instance ) {
$instance['thumbnail_width'] = (int) $new_instance['thumbnail_width'];
$instance['thumbnail_height'] = (int) $new_instance['thumbnail_height'];

$instance['content'] = isset( $new_instance['content'] ) ? (bool) $new_instance['content'] : false;

$instance['excerpt'] = isset( $new_instance['excerpt'] ) ? (bool) $new_instance['excerpt'] : false;
$instance['excerpt_length'] = (int) $new_instance['excerpt_length'];
$instance['date'] = isset( $new_instance['date'] ) ? (bool) $new_instance['date'] : false;
Expand Down
7 changes: 7 additions & 0 deletions includes/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@

<?php endif; ?>

<p>
<input class="checkbox" type="checkbox" <?php checked( $instance['content'] ); ?> id="<?php echo $this->get_field_id( 'content' ); ?>" name="<?php echo $this->get_field_name( 'content' ); ?>" />
<label for="<?php echo $this->get_field_id( 'content' ); ?>">
<?php _e( 'Display full post', 'arpw' ); ?>
</label>
</p>

<p>
<input class="checkbox" type="checkbox" <?php checked( $instance['excerpt'] ); ?> id="<?php echo $this->get_field_id( 'excerpt' ); ?>" name="<?php echo $this->get_field_name( 'excerpt' ); ?>" />
<label for="<?php echo $this->get_field_id( 'excerpt' ); ?>">
Expand Down
5 changes: 5 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function arpw_get_default_args() {
'thumbnail_width' => '',
'thumbnail_height' => '',

'content' => false,
'excerpt' => false,
'excerpt_length' => 10,
'date' => false,
Expand Down Expand Up @@ -159,6 +160,10 @@ function arpw_get_random_posts( $args = array() ) {
$html .= '<div class="arpw-summary">' . wp_trim_words( apply_filters( 'arpw_excerpt', get_the_excerpt() ), $args['excerpt_length'], ' &hellip;' ) . '</div>';
endif;

if ( $args['content'] ) :
$html .= '<div class="arpw-content">' . apply_filters( 'arpw_content', get_the_content() ) . '</div>';
endif;

$html .= '</li>';

endwhile;
Expand Down