Version Description
- 04/02/2013
Download this release
Release Info
Developer | satrya |
Plugin | Advanced Random Posts Widget |
Version | 1.3 |
Comparing to | |
See all releases |
Code changes from version 1.2 to 1.3
- arpw.css +3 -6
- arpw.php +1 -1
- includes/widget-advanced-random-posts.php +56 -50
- readme.txt +10 -2
arpw.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/*
|
2 |
Description: Custom CSS for the Advanced Random Posts Widget.
|
3 |
-
Version: 1.
|
4 |
Author: Satrya
|
5 |
License: GPLv2
|
6 |
*/
|
@@ -28,12 +28,11 @@ License: GPLv2
|
|
28 |
margin-bottom: 0 !important;
|
29 |
font-weight: normal;
|
30 |
font-size: 12px !important;
|
31 |
-
|
32 |
-
line-height: 1.5em;
|
33 |
}
|
34 |
|
35 |
.arpw-alignleft {
|
36 |
-
border: 1px solid #
|
37 |
box-shadow: none !important;
|
38 |
display: inline;
|
39 |
float: left;
|
@@ -42,14 +41,12 @@ License: GPLv2
|
|
42 |
}
|
43 |
|
44 |
.arpw-summary {
|
45 |
-
font-family: Arial, sans-serif;
|
46 |
font-size: 12px;
|
47 |
}
|
48 |
|
49 |
.arpw-time {
|
50 |
color: #bbb;
|
51 |
font-size: 11px;
|
52 |
-
font-family: Arial, sans-serif;
|
53 |
}
|
54 |
|
55 |
.arpw-clearfix:before,
|
1 |
/*
|
2 |
Description: Custom CSS for the Advanced Random Posts Widget.
|
3 |
+
Version: 1.1
|
4 |
Author: Satrya
|
5 |
License: GPLv2
|
6 |
*/
|
28 |
margin-bottom: 0 !important;
|
29 |
font-weight: normal;
|
30 |
font-size: 12px !important;
|
31 |
+
line-height: 1.5;
|
|
|
32 |
}
|
33 |
|
34 |
.arpw-alignleft {
|
35 |
+
border: 1px solid #eee !important;
|
36 |
box-shadow: none !important;
|
37 |
display: inline;
|
38 |
float: left;
|
41 |
}
|
42 |
|
43 |
.arpw-summary {
|
|
|
44 |
font-size: 12px;
|
45 |
}
|
46 |
|
47 |
.arpw-time {
|
48 |
color: #bbb;
|
49 |
font-size: 11px;
|
|
|
50 |
}
|
51 |
|
52 |
.arpw-clearfix:before,
|
arpw.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Advanced Random Posts Widget
|
4 |
Plugin URI: https://github.com/themephe/advanced-random-posts-widget
|
5 |
Description: Enables advanced random posts widget.
|
6 |
-
Version: 1.
|
7 |
Author: Satrya
|
8 |
Author URI: http://satrya.me
|
9 |
Author Email: satrya@satrya.me
|
3 |
Plugin Name: Advanced Random Posts Widget
|
4 |
Plugin URI: https://github.com/themephe/advanced-random-posts-widget
|
5 |
Description: Enables advanced random posts widget.
|
6 |
+
Version: 1.3
|
7 |
Author: Satrya
|
8 |
Author URI: http://satrya.me
|
9 |
Author Email: satrya@satrya.me
|
includes/widget-advanced-random-posts.php
CHANGED
@@ -11,7 +11,7 @@ class arpw_widget extends WP_Widget {
|
|
11 |
function arpw_widget() {
|
12 |
|
13 |
$widget_ops = array(
|
14 |
-
'classname' => 'arpw_widget',
|
15 |
'description' => __( 'Enable advanced random posts widget.', 'arpw' )
|
16 |
);
|
17 |
|
@@ -40,69 +40,71 @@ class arpw_widget extends WP_Widget {
|
|
40 |
$thumb_width = (int)( $instance['thumb_width'] );
|
41 |
$cat = $instance['cat'];
|
42 |
$date = $instance['date'];
|
|
|
43 |
|
44 |
echo $before_widget;
|
|
|
|
|
|
|
45 |
|
46 |
-
if (!empty( $title ))
|
47 |
echo $before_title . $title . $after_title;
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
$args = array(
|
52 |
-
'numberposts' => $limit,
|
53 |
-
'cat' => $cat,
|
54 |
-
'post_type' => 'post',
|
55 |
-
'orderby' => 'rand'
|
56 |
-
);
|
57 |
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
<ul>
|
65 |
|
66 |
-
|
|
|
|
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'arpw' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
|
71 |
|
72 |
-
|
73 |
-
if( $thumb == true ) {
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
-
}
|
81 |
-
?>
|
82 |
|
83 |
-
|
|
|
|
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
|
93 |
-
|
94 |
-
<div class="arpw-summary"><?php echo arpw_excerpt( $length ); ?></div>
|
95 |
-
<?php } ?>
|
96 |
|
97 |
-
|
98 |
|
99 |
-
|
100 |
|
101 |
-
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
<?php
|
106 |
|
107 |
echo $after_widget;
|
108 |
|
@@ -123,6 +125,7 @@ class arpw_widget extends WP_Widget {
|
|
123 |
$instance['thumb_width'] = (int)( $new_instance['thumb_width'] );
|
124 |
$instance['cat'] = $new_instance['cat'];
|
125 |
$instance['date'] = $new_instance['date'];
|
|
|
126 |
|
127 |
return $instance;
|
128 |
|
@@ -143,7 +146,8 @@ class arpw_widget extends WP_Widget {
|
|
143 |
'thumb_height' => 45,
|
144 |
'thumb_width' => 45,
|
145 |
'cat' => '',
|
146 |
-
'date' => true
|
|
|
147 |
);
|
148 |
|
149 |
$instance = wp_parse_args( (array) $instance, $defaults );
|
@@ -156,6 +160,7 @@ class arpw_widget extends WP_Widget {
|
|
156 |
$thumb_width = (int)( $instance['thumb_width'] );
|
157 |
$cat = $instance['cat'];
|
158 |
$date = $instance['date'];
|
|
|
159 |
|
160 |
?>
|
161 |
|
@@ -181,7 +186,7 @@ class arpw_widget extends WP_Widget {
|
|
181 |
</p>
|
182 |
<p>
|
183 |
<label for="<?php echo esc_attr( $this->get_field_id( 'length' ) ); ?>"><?php _e( 'Excerpt length:', 'arpw' ); ?></label>
|
184 |
-
<input
|
185 |
</p>
|
186 |
|
187 |
<?php if( current_theme_supports( 'post-thumbnails' ) ) { ?>
|
@@ -203,7 +208,11 @@ class arpw_widget extends WP_Widget {
|
|
203 |
<?php wp_dropdown_categories( array( 'name' => $this->get_field_name( 'cat' ), 'show_option_all' => __( 'All categories' , 'arpw' ), 'hide_empty' => 1, 'hierarchical' => 1, 'selected' => $cat ) ); ?>
|
204 |
</p>
|
205 |
<p>
|
206 |
-
<
|
|
|
|
|
|
|
|
|
207 |
</p>
|
208 |
|
209 |
<?php
|
@@ -216,12 +225,10 @@ class arpw_widget extends WP_Widget {
|
|
216 |
*
|
217 |
* @since 1.0
|
218 |
*/
|
219 |
-
add_action( 'widgets_init', 'arpw_register_widget' );
|
220 |
function arpw_register_widget() {
|
221 |
-
|
222 |
register_widget( 'arpw_widget' );
|
223 |
-
|
224 |
}
|
|
|
225 |
|
226 |
/**
|
227 |
* Print a custom excerpt.
|
@@ -243,5 +250,4 @@ function arpw_excerpt( $length ) {
|
|
243 |
return $excerpt;
|
244 |
|
245 |
}
|
246 |
-
|
247 |
?>
|
11 |
function arpw_widget() {
|
12 |
|
13 |
$widget_ops = array(
|
14 |
+
'classname' => 'arpw_widget random-posts',
|
15 |
'description' => __( 'Enable advanced random posts widget.', 'arpw' )
|
16 |
);
|
17 |
|
40 |
$thumb_width = (int)( $instance['thumb_width'] );
|
41 |
$cat = $instance['cat'];
|
42 |
$date = $instance['date'];
|
43 |
+
$css = wp_filter_nohtml_kses( $instance['css'] );
|
44 |
|
45 |
echo $before_widget;
|
46 |
+
|
47 |
+
if( $css )
|
48 |
+
echo '<style>' . $css . '</style>';
|
49 |
|
50 |
+
if ( ! empty( $title ) )
|
51 |
echo $before_title . $title . $after_title;
|
52 |
|
53 |
+
global $post;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
+
$args = array(
|
56 |
+
'numberposts' => $limit,
|
57 |
+
'cat' => $cat,
|
58 |
+
'post_type' => 'post',
|
59 |
+
'orderby' => 'rand'
|
60 |
+
);
|
61 |
|
62 |
+
$arpwwidget = get_posts( $args );
|
63 |
|
64 |
+
if( $arpwwidget ) : ?>
|
|
|
|
|
65 |
|
66 |
+
<div class="arpw-block">
|
67 |
+
|
68 |
+
<ul>
|
69 |
|
70 |
+
<?php foreach( $arpwwidget as $post ) : setup_postdata( $post ); ?>
|
|
|
|
|
71 |
|
72 |
+
<li class="arpw-clearfix">
|
|
|
73 |
|
74 |
+
<?php if( has_post_thumbnail() && $thumb == true ) { ?>
|
75 |
+
|
76 |
+
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'arpw' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
|
77 |
+
<?php
|
78 |
+
if ( current_theme_supports( 'get-the-image' ) )
|
79 |
+
get_the_image( array( 'meta_key' => 'Thumbnail', 'height' => $thumb_height, 'width' => $thumb_width, 'image_class' => 'arpw-alignleft', 'link_to_post' => false ) );
|
80 |
+
else
|
81 |
+
the_post_thumbnail( array( $thumb_height, $thumb_width ), array( 'class' => 'arpw-alignleft', 'alt' => esc_attr( get_the_title() ), 'title' => esc_attr( get_the_title() ) ) );
|
82 |
+
?>
|
83 |
+
</a>
|
84 |
|
85 |
+
<?php } ?>
|
|
|
86 |
|
87 |
+
<h3 class="arpw-title">
|
88 |
+
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'arpw' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
|
89 |
+
</h3>
|
90 |
|
91 |
+
<?php if( $date == true ) { ?>
|
92 |
+
<span class="arpw-time"><?php echo human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) . __( ' ago', 'arpw' ); ?></span>
|
93 |
+
<?php } ?>
|
94 |
|
95 |
+
<?php if( $excerpt == true ) { ?>
|
96 |
+
<div class="arpw-summary"><?php echo arpw_excerpt( $length ); ?></div>
|
97 |
+
<?php } ?>
|
98 |
|
99 |
+
</li>
|
|
|
|
|
100 |
|
101 |
+
<?php endforeach; wp_reset_postdata(); ?>
|
102 |
|
103 |
+
</ul>
|
104 |
|
105 |
+
</div><!-- .arpw-block - http://wordpress.org/extend/plugins/advanced-random-posts-widget/ -->
|
106 |
|
107 |
+
<?php endif;
|
|
|
|
|
108 |
|
109 |
echo $after_widget;
|
110 |
|
125 |
$instance['thumb_width'] = (int)( $new_instance['thumb_width'] );
|
126 |
$instance['cat'] = $new_instance['cat'];
|
127 |
$instance['date'] = $new_instance['date'];
|
128 |
+
$instance['css'] = wp_filter_nohtml_kses( $new_instance['css'] );
|
129 |
|
130 |
return $instance;
|
131 |
|
146 |
'thumb_height' => 45,
|
147 |
'thumb_width' => 45,
|
148 |
'cat' => '',
|
149 |
+
'date' => true,
|
150 |
+
'css' => ''
|
151 |
);
|
152 |
|
153 |
$instance = wp_parse_args( (array) $instance, $defaults );
|
160 |
$thumb_width = (int)( $instance['thumb_width'] );
|
161 |
$cat = $instance['cat'];
|
162 |
$date = $instance['date'];
|
163 |
+
$css = wp_filter_nohtml_kses( $instance['css'] );
|
164 |
|
165 |
?>
|
166 |
|
186 |
</p>
|
187 |
<p>
|
188 |
<label for="<?php echo esc_attr( $this->get_field_id( 'length' ) ); ?>"><?php _e( 'Excerpt length:', 'arpw' ); ?></label>
|
189 |
+
<input id="<?php echo esc_attr( $this->get_field_id( 'length' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'length' ) ); ?>" type="text" value="<?php echo $length; ?>" />
|
190 |
</p>
|
191 |
|
192 |
<?php if( current_theme_supports( 'post-thumbnails' ) ) { ?>
|
208 |
<?php wp_dropdown_categories( array( 'name' => $this->get_field_name( 'cat' ), 'show_option_all' => __( 'All categories' , 'arpw' ), 'hide_empty' => 1, 'hierarchical' => 1, 'selected' => $cat ) ); ?>
|
209 |
</p>
|
210 |
<p>
|
211 |
+
<label for="<?php echo $this->get_field_id( 'css' ); ?>"><?php _e( 'Custom CSS:', 'arpw' ); ?></label>
|
212 |
+
<textarea class="widefat" id="<?php echo $this->get_field_id( 'css' ); ?>" name="<?php echo $this->get_field_name( 'css' ); ?>" style="height:100px;"><?php echo $css; ?></textarea>
|
213 |
+
</p>
|
214 |
+
<p>
|
215 |
+
<span style="color: #f00;"><?php printf( __( 'Advanced Random Posts Widget is a project by <a href="%s" target="_blank">Satrya</a>', 'arpw' ), esc_url( 'http://twitter.com/msattt' ) ); ?></span>
|
216 |
</p>
|
217 |
|
218 |
<?php
|
225 |
*
|
226 |
* @since 1.0
|
227 |
*/
|
|
|
228 |
function arpw_register_widget() {
|
|
|
229 |
register_widget( 'arpw_widget' );
|
|
|
230 |
}
|
231 |
+
add_action( 'widgets_init', 'arpw_register_widget' );
|
232 |
|
233 |
/**
|
234 |
* Print a custom excerpt.
|
250 |
return $excerpt;
|
251 |
|
252 |
}
|
|
|
253 |
?>
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: satrya
|
|
3 |
Tags: random posts, random, thumbnails, widget, widgets, sidebar, excerpt, multiple widgets
|
4 |
Requires at least: 3.4
|
5 |
Tested up to: 3.5
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -19,7 +19,7 @@ This plugin will enable a custom, flexible and advanced random posts widget. All
|
|
19 |
* Display excerpt, with customizable length.
|
20 |
* Display from all or a specific category.
|
21 |
* Display post date.
|
22 |
-
* Support
|
23 |
* Multiple widgets.
|
24 |
|
25 |
= Ugly Image Sizes =
|
@@ -42,6 +42,14 @@ This plugin creates custom image sizes. If you use images that were uploaded to
|
|
42 |
|
43 |
== Changelog ==
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
= 1.1 - 17/2/2013 =
|
46 |
* Minor update
|
47 |
|
3 |
Tags: random posts, random, thumbnails, widget, widgets, sidebar, excerpt, multiple widgets
|
4 |
Requires at least: 3.4
|
5 |
Tested up to: 3.5
|
6 |
+
Stable tag: 1.3
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
19 |
* Display excerpt, with customizable length.
|
20 |
* Display from all or a specific category.
|
21 |
* Display post date.
|
22 |
+
* Support [Get The Image](http://wordpress.org/extend/plugins/get-the-image/) plugin.
|
23 |
* Multiple widgets.
|
24 |
|
25 |
= Ugly Image Sizes =
|
42 |
|
43 |
== Changelog ==
|
44 |
|
45 |
+
= 1.3 - 04/02/2013 =
|
46 |
+
* Remove `a` tag when no thumbnail
|
47 |
+
* Add custom css box
|
48 |
+
* Inheritance `font-family`
|
49 |
+
|
50 |
+
= 1.2 - 02/23/13 =
|
51 |
+
* Minor update
|
52 |
+
|
53 |
= 1.1 - 17/2/2013 =
|
54 |
* Minor update
|
55 |
|