Version Description
- 9/15/2014 =
- Bring back custom thumbnail size options!
- Bring back category and tag options!
- Added: Relative date option
eg: 5 days ago
.
Download this release
Release Info
Developer | satrya |
Plugin | Advanced Random Posts Widget |
Version | 2.0.1 |
Comparing to | |
See all releases |
Code changes from version 2.0.0 to 2.0.1
- README.md +0 -77
- arpw.php +2 -1
- assets/css/arpw-admin.css +18 -2
- classes/widget.php +7 -0
- includes/admin.css +0 -44
- includes/form.php +54 -0
- includes/functions.php +73 -27
- includes/resizer.php +209 -0
- includes/widget-advanced-random-posts.php +0 -329
- readme.txt +19 -16
README.md
DELETED
@@ -1,77 +0,0 @@
|
|
1 |
-
Advanced Random Posts Widget
|
2 |
-
===
|
3 |
-
Provides flexible and advanced random posts widget. Allows you to display them with thumbnails, post excerpt, multiple category and more.
|
4 |
-
|
5 |
-
## Project detail
|
6 |
-
Contributors: satrya
|
7 |
-
Donate link: http://satrya.me/donate/
|
8 |
-
Tags: random posts, random, thumbnails, widget, widgets, sidebar, excerpt, multiple widgets
|
9 |
-
Requires at least: 3.5
|
10 |
-
Tested up to: 3.6
|
11 |
-
Stable tag: 1.5
|
12 |
-
License: GPLv2 or later
|
13 |
-
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
14 |
-
|
15 |
-
## Installation
|
16 |
-
|
17 |
-
#### Manual
|
18 |
-
* Go to [this page](http://wordpress.org/plugins/advanced-random-posts-widget/), then download the plugin.
|
19 |
-
* Upload the **advanced-random-posts-widget** folder to the `/wp-content/plugins/` directory via your FTP.
|
20 |
-
* Activate the plugin through the dashboard.
|
21 |
-
* Go to the Widgets page.
|
22 |
-
|
23 |
-
#### Installation using "Add New Plugin"
|
24 |
-
* From your Admin UI (Dashboard), use the menu to select **Plugins -> Add New**.
|
25 |
-
* Search for **advanced random posts widget**.
|
26 |
-
* Click the **Install** button.
|
27 |
-
* Go to the Widgets page.
|
28 |
-
|
29 |
-
## Features Include
|
30 |
-
|
31 |
-
* Display thumbnails, with customizable size.
|
32 |
-
* Display excerpt, with customizable length.
|
33 |
-
* Display from all or a specific category.
|
34 |
-
* Display post date.
|
35 |
-
* Support `get_the_image` function.
|
36 |
-
* Multiple widgets.
|
37 |
-
|
38 |
-
#### New Features
|
39 |
-
|
40 |
-
* CSS ID option
|
41 |
-
* Widget title url
|
42 |
-
* Turn on/off default style
|
43 |
-
* Limit to spesfic or multiple category
|
44 |
-
* Limit to spesfic or multiple tag
|
45 |
-
|
46 |
-
## Screenshot
|
47 |
-
![alt text](https://raw.github.com/satrya/advanced-random-posts-widget/master/screenshot-1.png "Advanced Random Posts Widget Plugin")
|
48 |
-
|
49 |
-
## Changelog
|
50 |
-
```
|
51 |
-
1.5 - 09/07/2013
|
52 |
-
* Fix title widget filter bug
|
53 |
-
* Change Limit option to input text rather than selectbox
|
54 |
-
* Add CSS ID option
|
55 |
-
* Add widget title url
|
56 |
-
* Add turn on off default styles
|
57 |
-
* Add multiple category option
|
58 |
-
* Add multiple tag option
|
59 |
-
* Update language
|
60 |
-
|
61 |
-
1.4 - 04/19/2013
|
62 |
-
* Change support uri
|
63 |
-
|
64 |
-
1.3 - 04/02/2013
|
65 |
-
* Remove `a` tag when no thumbnail
|
66 |
-
* Add custom css box
|
67 |
-
* Inheritance `font-family`
|
68 |
-
|
69 |
-
1.2 - 02/23/13
|
70 |
-
* Minor update
|
71 |
-
|
72 |
-
1.1 - 17/2/2013
|
73 |
-
* Minor update
|
74 |
-
|
75 |
-
1.0 - 10/2/2013
|
76 |
-
* Initial release
|
77 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
arpw.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Advanced Random Posts Widget
|
4 |
* Plugin URI: http://wordpress.org/plugins/advanced-random-posts-widget/
|
5 |
* Description: Easy to display random posts via shortcode or widget.
|
6 |
-
* Version: 2.0.
|
7 |
* Author: Satrya
|
8 |
* Author URI: http://satrya.me/
|
9 |
* Author Email: satrya@satrya.me
|
@@ -99,6 +99,7 @@ class ARP_Widget {
|
|
99 |
* @since 0.0.1
|
100 |
*/
|
101 |
public function includes() {
|
|
|
102 |
require_once( ARPW_INC . 'functions.php' );
|
103 |
require_once( ARPW_INC . 'shortcode.php' );
|
104 |
}
|
3 |
* Plugin Name: Advanced Random Posts Widget
|
4 |
* Plugin URI: http://wordpress.org/plugins/advanced-random-posts-widget/
|
5 |
* Description: Easy to display random posts via shortcode or widget.
|
6 |
+
* Version: 2.0.1
|
7 |
* Author: Satrya
|
8 |
* Author URI: http://satrya.me/
|
9 |
* Author Email: satrya@satrya.me
|
99 |
* @since 0.0.1
|
100 |
*/
|
101 |
public function includes() {
|
102 |
+
require_once( ARPW_INC . 'resizer.php' );
|
103 |
require_once( ARPW_INC . 'functions.php' );
|
104 |
require_once( ARPW_INC . 'shortcode.php' );
|
105 |
}
|
assets/css/arpw-admin.css
CHANGED
@@ -23,8 +23,8 @@
|
|
23 |
font-style: italic;
|
24 |
}
|
25 |
|
26 |
-
.
|
27 |
-
width:
|
28 |
}
|
29 |
|
30 |
.arpw-block {
|
@@ -34,4 +34,20 @@
|
|
34 |
label.input-checkbox {
|
35 |
width: 100px;
|
36 |
display: inline-block;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
23 |
font-style: italic;
|
24 |
}
|
25 |
|
26 |
+
.arpw-input-half {
|
27 |
+
width: 47%;
|
28 |
}
|
29 |
|
30 |
.arpw-block {
|
34 |
label.input-checkbox {
|
35 |
width: 100px;
|
36 |
display: inline-block;
|
37 |
+
}
|
38 |
+
|
39 |
+
.arpw-multiple-check-form {
|
40 |
+
margin: 1em 0;
|
41 |
+
}
|
42 |
+
|
43 |
+
.arpw-multiple-check-form ul {
|
44 |
+
border: 1px solid #eee;
|
45 |
+
padding: 10px;
|
46 |
+
max-height: 110px;
|
47 |
+
overflow: auto;
|
48 |
+
margin-top: 0;
|
49 |
+
}
|
50 |
+
|
51 |
+
.arpw-multiple-check-form ul li:last-child {
|
52 |
+
margin-bottom: 0;
|
53 |
}
|
classes/widget.php
CHANGED
@@ -84,13 +84,20 @@ class Advanced_Random_Posts_Widget extends WP_Widget {
|
|
84 |
$instance['post_type'] = esc_attr( $new_instance['post_type'] );
|
85 |
$instance['post_status'] = esc_attr( $new_instance['post_status'] );
|
86 |
$instance['taxonomy'] = esc_attr( $new_instance['taxonomy'] );
|
|
|
|
|
87 |
|
88 |
$instance['thumbnail'] = isset( $new_instance['thumbnail'] ) ? (bool) $new_instance['thumbnail'] : false;
|
89 |
$instance['thumbnail_size'] = esc_attr( $new_instance['thumbnail_size'] );
|
90 |
$instance['thumbnail_align'] = esc_attr( $new_instance['thumbnail_align'] );
|
|
|
|
|
|
|
|
|
91 |
$instance['excerpt'] = isset( $new_instance['excerpt'] ) ? (bool) $new_instance['excerpt'] : false;
|
92 |
$instance['excerpt_length'] = (int) $new_instance['excerpt_length'];
|
93 |
$instance['date'] = isset( $new_instance['date'] ) ? (bool) $new_instance['date'] : false;
|
|
|
94 |
|
95 |
$instance['css_class'] = sanitize_html_class( $new_instance['css_class'] );
|
96 |
$instance['before'] = wp_filter_post_kses( $new_instance['before'] );
|
84 |
$instance['post_type'] = esc_attr( $new_instance['post_type'] );
|
85 |
$instance['post_status'] = esc_attr( $new_instance['post_status'] );
|
86 |
$instance['taxonomy'] = esc_attr( $new_instance['taxonomy'] );
|
87 |
+
$instance['cat'] = $new_instance['cat'];
|
88 |
+
$instance['tag'] = $new_instance['tag'];
|
89 |
|
90 |
$instance['thumbnail'] = isset( $new_instance['thumbnail'] ) ? (bool) $new_instance['thumbnail'] : false;
|
91 |
$instance['thumbnail_size'] = esc_attr( $new_instance['thumbnail_size'] );
|
92 |
$instance['thumbnail_align'] = esc_attr( $new_instance['thumbnail_align'] );
|
93 |
+
$instance['thumbnail_custom'] = isset( $new_instance['thumbnail_custom'] ) ? (bool) $new_instance['thumbnail_custom'] : false;
|
94 |
+
$instance['thumbnail_width'] = (int) $new_instance['thumbnail_width'];
|
95 |
+
$instance['thumbnail_height'] = (int) $new_instance['thumbnail_height'];
|
96 |
+
|
97 |
$instance['excerpt'] = isset( $new_instance['excerpt'] ) ? (bool) $new_instance['excerpt'] : false;
|
98 |
$instance['excerpt_length'] = (int) $new_instance['excerpt_length'];
|
99 |
$instance['date'] = isset( $new_instance['date'] ) ? (bool) $new_instance['date'] : false;
|
100 |
+
$instance['date_relative'] = isset( $new_instance['date_relative'] ) ? (bool) $new_instance['date_relative'] : false;
|
101 |
|
102 |
$instance['css_class'] = sanitize_html_class( $new_instance['css_class'] );
|
103 |
$instance['before'] = wp_filter_post_kses( $new_instance['before'] );
|
includes/admin.css
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
.widgets-php .arpw-columns-2 {
|
2 |
-
overflow: hidden;
|
3 |
-
float: left;
|
4 |
-
width: 48%;
|
5 |
-
}
|
6 |
-
|
7 |
-
.widgets-php .arpw-columns-3 {
|
8 |
-
overflow: hidden;
|
9 |
-
float: left;
|
10 |
-
width: 31%;
|
11 |
-
margin-right: 3.5%;
|
12 |
-
}
|
13 |
-
|
14 |
-
.widgets-php .arpw-columns-2 input.widefat,
|
15 |
-
.widgets-php .arpw-columns-2 select.widefat {
|
16 |
-
width: 99%;
|
17 |
-
}
|
18 |
-
|
19 |
-
.widgets-php .arpw-columns-3 select.widefat {
|
20 |
-
width: 98.5%;
|
21 |
-
}
|
22 |
-
|
23 |
-
.widgets-php .arpw-column-last {
|
24 |
-
float: right;
|
25 |
-
margin-right: 0;
|
26 |
-
}
|
27 |
-
|
28 |
-
.widgets-php .arpw-columns-2 label,
|
29 |
-
.widgets-php .arpw-columns-3 label {
|
30 |
-
font-size: 11px;
|
31 |
-
}
|
32 |
-
|
33 |
-
.small-input {
|
34 |
-
width: 78px;
|
35 |
-
}
|
36 |
-
|
37 |
-
.arpw-block {
|
38 |
-
display: block;
|
39 |
-
}
|
40 |
-
|
41 |
-
label.input-checkbox {
|
42 |
-
width: 100px;
|
43 |
-
display: inline-block;
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/form.php
CHANGED
@@ -96,6 +96,38 @@
|
|
96 |
</select>
|
97 |
</p>
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
<p>
|
100 |
<label for="<?php echo $this->get_field_id( 'taxonomy' ); ?>">
|
101 |
<?php _e( 'Limit to Taxonomy', 'arpw' ); ?>
|
@@ -131,6 +163,21 @@
|
|
131 |
<small><?php printf( __( 'Please read %1$sFAQ%2$s for more information.', 'arpw' ), '<a href="http://wordpress.org/plugins/advanced-random-posts-widget/faq/" target="_blank">', '</a>' ); ?></small>
|
132 |
</p>
|
133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
<p>
|
135 |
<label for="<?php echo $this->get_field_id( 'thumbnail_align' ); ?>">
|
136 |
<?php _e( 'Thumbnail Alignment', 'arpw' ); ?>
|
@@ -165,6 +212,13 @@
|
|
165 |
</label>
|
166 |
</p>
|
167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
</div>
|
169 |
|
170 |
<div class="clear"></div>
|
96 |
</select>
|
97 |
</p>
|
98 |
|
99 |
+
<div class="arpw-multiple-check-form">
|
100 |
+
<label>
|
101 |
+
<?php _e( 'Limit to Category', 'arpw' ); ?>
|
102 |
+
</label>
|
103 |
+
<ul>
|
104 |
+
<?php foreach ( get_terms( 'category' ) as $category ) : ?>
|
105 |
+
<li>
|
106 |
+
<input type="checkbox" value="<?php echo (int) $category->term_id; ?>" id="<?php echo $this->get_field_id( 'cat' ) . '-' . (int) $category->term_id; ?>" name="<?php echo $this->get_field_name( 'cat' ); ?>[]" <?php checked( is_array( $instance['cat'] ) && in_array( $category->term_id, $instance['cat'] ) ); ?> />
|
107 |
+
<label for="<?php echo $this->get_field_id( 'cat' ) . '-' . (int) $category->term_id; ?>">
|
108 |
+
<?php echo esc_html( $category->name ); ?>
|
109 |
+
</label>
|
110 |
+
</li>
|
111 |
+
<?php endforeach; ?>
|
112 |
+
</ul>
|
113 |
+
</div>
|
114 |
+
|
115 |
+
<div class="arpw-multiple-check-form">
|
116 |
+
<label>
|
117 |
+
<?php _e( 'Limit to Tag', 'arpw' ); ?>
|
118 |
+
</label>
|
119 |
+
<ul>
|
120 |
+
<?php foreach ( get_terms( 'post_tag' ) as $post_tag ) : ?>
|
121 |
+
<li>
|
122 |
+
<input type="checkbox" value="<?php echo (int) $post_tag->term_id; ?>" id="<?php echo $this->get_field_id( 'tag' ) . '-' . (int) $post_tag->term_id; ?>" name="<?php echo $this->get_field_name( 'tag' ); ?>[]" <?php checked( is_array( $instance['tag'] ) && in_array( $post_tag->term_id, $instance['tag'] ) ); ?> />
|
123 |
+
<label for="<?php echo $this->get_field_id( 'tag' ) . '-' . (int) $post_tag->term_id; ?>">
|
124 |
+
<?php echo esc_html( $post_tag->name ); ?>
|
125 |
+
</label>
|
126 |
+
</li>
|
127 |
+
<?php endforeach; ?>
|
128 |
+
</ul>
|
129 |
+
</div>
|
130 |
+
|
131 |
<p>
|
132 |
<label for="<?php echo $this->get_field_id( 'taxonomy' ); ?>">
|
133 |
<?php _e( 'Limit to Taxonomy', 'arpw' ); ?>
|
163 |
<small><?php printf( __( 'Please read %1$sFAQ%2$s for more information.', 'arpw' ), '<a href="http://wordpress.org/plugins/advanced-random-posts-widget/faq/" target="_blank">', '</a>' ); ?></small>
|
164 |
</p>
|
165 |
|
166 |
+
<p>
|
167 |
+
<input class="checkbox" type="checkbox" <?php checked( $instance['thumbnail_custom'] ); ?> id="<?php echo $this->get_field_id( 'thumbnail_custom' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_custom' ); ?>" />
|
168 |
+
<label for="<?php echo $this->get_field_id( 'thumbnail_custom' ); ?>">
|
169 |
+
<?php _e( 'Use custom thumbnail sizes', 'arpw' ); ?>
|
170 |
+
</label>
|
171 |
+
</p>
|
172 |
+
|
173 |
+
<p>
|
174 |
+
<label class="arpw-block" for="<?php echo $this->get_field_id( 'thumbnail_width' ); ?>">
|
175 |
+
<?php _e( 'Width & Height', 'arpw' ); ?>
|
176 |
+
</label>
|
177 |
+
<input class="arpw-input-half" id="<?php echo $this->get_field_id( 'thumbnail_width' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_width' ); ?>" type="number" step="1" min="0" value="<?php echo (int)( $instance['thumbnail_width'] ); ?>" />
|
178 |
+
<input class="arpw-input-half" id="<?php echo $this->get_field_id( 'thumbnail_height' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_height' ); ?>" type="number" step="1" min="0" value="<?php echo (int)( $instance['thumbnail_height'] ); ?>" />
|
179 |
+
</p>
|
180 |
+
|
181 |
<p>
|
182 |
<label for="<?php echo $this->get_field_id( 'thumbnail_align' ); ?>">
|
183 |
<?php _e( 'Thumbnail Alignment', 'arpw' ); ?>
|
212 |
</label>
|
213 |
</p>
|
214 |
|
215 |
+
<p>
|
216 |
+
<input id="<?php echo $this->get_field_id( 'date_relative' ); ?>" name="<?php echo $this->get_field_name( 'date_relative' ); ?>" type="checkbox" <?php checked( $instance['date_relative'] ); ?> />
|
217 |
+
<label for="<?php echo $this->get_field_id( 'date_relative' ); ?>">
|
218 |
+
<?php _e( 'Use Relative Date. eg: 5 days ago', 'arpw' ); ?>
|
219 |
+
</label>
|
220 |
+
</p>
|
221 |
+
|
222 |
</div>
|
223 |
|
224 |
<div class="clear"></div>
|
includes/functions.php
CHANGED
@@ -27,13 +27,20 @@ function arpw_get_default_args() {
|
|
27 |
'post_status' => 'publish',
|
28 |
'ignore_sticky' => 1,
|
29 |
'taxonomy' => '',
|
|
|
|
|
30 |
|
31 |
'thumbnail' => false,
|
32 |
'thumbnail_size' => 'arpw-thumbnail',
|
33 |
'thumbnail_align' => 'left',
|
|
|
|
|
|
|
|
|
34 |
'excerpt' => false,
|
35 |
'excerpt_length' => 10,
|
36 |
'date' => false,
|
|
|
37 |
|
38 |
'css_class' => '',
|
39 |
'before' => '',
|
@@ -95,18 +102,38 @@ function arpw_get_random_posts( $args = array() ) {
|
|
95 |
|
96 |
// Check if post has post thumbnail.
|
97 |
if ( has_post_thumbnail() ) :
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
$html .= '</a>';
|
101 |
|
102 |
// If no post thumbnail found, check if Get The Image plugin exist and display the image.
|
103 |
elseif ( function_exists( 'get_the_image' ) ) :
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
// Display nothing.
|
112 |
else :
|
@@ -118,11 +145,15 @@ function arpw_get_random_posts( $args = array() ) {
|
|
118 |
$html .= '<a class="arpw-title" href="' . esc_url( get_permalink() ) . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'arpw' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark">' . esc_attr( get_the_title() ) . '</a>';
|
119 |
|
120 |
if ( $args['date'] ) :
|
121 |
-
$
|
|
|
|
|
|
|
|
|
122 |
endif;
|
123 |
|
124 |
if ( $args['excerpt'] ) :
|
125 |
-
$html .= '<div class="arpw-summary">' . wp_trim_words( get_the_excerpt(), $args['excerpt_length'], ' …' ) . '</div>';
|
126 |
endif;
|
127 |
|
128 |
$html .= '</li>';
|
@@ -155,22 +186,6 @@ function arpw_get_random_posts( $args = array() ) {
|
|
155 |
*/
|
156 |
function arpw_get_posts( $args = array() ) {
|
157 |
|
158 |
-
/**
|
159 |
-
* Taxonomy query.
|
160 |
-
* Prop Miniloop plugin by Kailey Lampert.
|
161 |
-
*/
|
162 |
-
parse_str( $args['taxonomy'], $taxes );
|
163 |
-
$tax_query = array();
|
164 |
-
foreach( array_keys( $taxes ) as $k => $slug ) {
|
165 |
-
$ids = explode( ',', $taxes[ $slug ] );
|
166 |
-
$tax_query[] = array(
|
167 |
-
'taxonomy' => $slug,
|
168 |
-
'field' => 'id',
|
169 |
-
'terms' => $ids,
|
170 |
-
'operator' => 'IN'
|
171 |
-
);
|
172 |
-
}
|
173 |
-
|
174 |
// Query arguments.
|
175 |
$query = array(
|
176 |
'offset' => $args['offset'],
|
@@ -179,9 +194,40 @@ function arpw_get_posts( $args = array() ) {
|
|
179 |
'post_type' => $args['post_type'],
|
180 |
'post_status' => $args['post_status'],
|
181 |
'ignore_sticky_posts' => $args['ignore_sticky'],
|
182 |
-
'tax_query' => $tax_query,
|
183 |
);
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
// Allow plugins/themes developer to filter the default query.
|
186 |
$query = apply_filters( 'arpw_query', $query );
|
187 |
|
27 |
'post_status' => 'publish',
|
28 |
'ignore_sticky' => 1,
|
29 |
'taxonomy' => '',
|
30 |
+
'cat' => array(),
|
31 |
+
'tag' => array(),
|
32 |
|
33 |
'thumbnail' => false,
|
34 |
'thumbnail_size' => 'arpw-thumbnail',
|
35 |
'thumbnail_align' => 'left',
|
36 |
+
'thumbnail_custom' => false,
|
37 |
+
'thumbnail_width' => '',
|
38 |
+
'thumbnail_height' => '',
|
39 |
+
|
40 |
'excerpt' => false,
|
41 |
'excerpt_length' => 10,
|
42 |
'date' => false,
|
43 |
+
'date_relative' => false,
|
44 |
|
45 |
'css_class' => '',
|
46 |
'before' => '',
|
102 |
|
103 |
// Check if post has post thumbnail.
|
104 |
if ( has_post_thumbnail() ) :
|
105 |
+
|
106 |
+
// Custom thumbnail sizes.
|
107 |
+
$thumb_id = get_post_thumbnail_id(); // Get the featured image id.
|
108 |
+
$img_url = wp_get_attachment_url( $thumb_id ); // Get img URL.
|
109 |
+
$image = arpw_resize( $img_url, $args['thumbnail_width'], $args['thumbnail_height'], true );
|
110 |
+
|
111 |
+
$html .= '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">';
|
112 |
+
if ( $args['thumbnail_custom'] ) :
|
113 |
+
$html .= '<img class="arpw-thumbnail align' . esc_attr( $args['thumbnail_align'] ) . '" src="' . esc_url( $image ) . '" alt="' . esc_attr( get_the_title() ) . '">';
|
114 |
+
else :
|
115 |
+
$html .= get_the_post_thumbnail( get_the_ID(), $args['thumbnail_size'], array( 'alt' => esc_attr( get_the_title() ), 'class' => 'arpw-thumbnail align' . esc_attr( $args['thumbnail_align'] ) ) );
|
116 |
+
endif;
|
117 |
$html .= '</a>';
|
118 |
|
119 |
// If no post thumbnail found, check if Get The Image plugin exist and display the image.
|
120 |
elseif ( function_exists( 'get_the_image' ) ) :
|
121 |
+
if ( $args['thumbnail_custom'] ) :
|
122 |
+
$html .= get_the_image( array(
|
123 |
+
'width' => (int) $args['thumbnail_width'],
|
124 |
+
'height' => (int) $args['thumbnail_height'],
|
125 |
+
'image_class' => 'arpw-thumbnail align' . esc_attr( $args['thumbnail_align'] ),
|
126 |
+
'image_scan' => true,
|
127 |
+
'link_to_post' => true,
|
128 |
+
) );
|
129 |
+
else:
|
130 |
+
$html .= get_the_image( array(
|
131 |
+
'size' => $args['thumbnail_size'],
|
132 |
+
'image_class' => 'arpw-thumbnail align' . esc_attr( $args['thumbnail_align'] ),
|
133 |
+
'image_scan' => true,
|
134 |
+
'link_to_post' => true,
|
135 |
+
) );
|
136 |
+
endif;
|
137 |
|
138 |
// Display nothing.
|
139 |
else :
|
145 |
$html .= '<a class="arpw-title" href="' . esc_url( get_permalink() ) . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'arpw' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark">' . esc_attr( get_the_title() ) . '</a>';
|
146 |
|
147 |
if ( $args['date'] ) :
|
148 |
+
$date = get_the_date();
|
149 |
+
if ( $args['date_relative'] ) :
|
150 |
+
$date = sprintf( __( '%s ago', 'arpw' ), human_time_diff( get_the_date( 'U' ), current_time( 'timestamp' ) ) );
|
151 |
+
endif;
|
152 |
+
$html .= '<time class="arpw-time published" datetime="' . esc_html( get_the_date( 'c' ) ) . '">' . esc_html( $date ) . '</time>';
|
153 |
endif;
|
154 |
|
155 |
if ( $args['excerpt'] ) :
|
156 |
+
$html .= '<div class="arpw-summary">' . wp_trim_words( apply_filters( 'arpw_excerpt', get_the_excerpt() ), $args['excerpt_length'], ' …' ) . '</div>';
|
157 |
endif;
|
158 |
|
159 |
$html .= '</li>';
|
186 |
*/
|
187 |
function arpw_get_posts( $args = array() ) {
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
// Query arguments.
|
190 |
$query = array(
|
191 |
'offset' => $args['offset'],
|
194 |
'post_type' => $args['post_type'],
|
195 |
'post_status' => $args['post_status'],
|
196 |
'ignore_sticky_posts' => $args['ignore_sticky'],
|
|
|
197 |
);
|
198 |
|
199 |
+
// Limit posts based on category.
|
200 |
+
if ( ! empty( $args['cat'] ) ) {
|
201 |
+
$query['category__in'] = $args['cat'];
|
202 |
+
}
|
203 |
+
|
204 |
+
// Limit posts based on post tag.
|
205 |
+
if ( ! empty( $args['tag'] ) ) {
|
206 |
+
$query['tag__in'] = $args['tag'];
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Taxonomy query.
|
211 |
+
* Prop Miniloop plugin by Kailey Lampert.
|
212 |
+
*/
|
213 |
+
if ( ! empty( $args['taxonomy'] ) ) {
|
214 |
+
|
215 |
+
parse_str( $args['taxonomy'], $taxes );
|
216 |
+
$tax_query = array();
|
217 |
+
foreach( array_keys( $taxes ) as $k => $slug ) {
|
218 |
+
$ids = explode( ',', $taxes[ $slug ] );
|
219 |
+
$tax_query[] = array(
|
220 |
+
'taxonomy' => $slug,
|
221 |
+
'field' => 'id',
|
222 |
+
'terms' => $ids,
|
223 |
+
'operator' => 'IN'
|
224 |
+
);
|
225 |
+
}
|
226 |
+
|
227 |
+
$query['tax_query'] = $tax_query;
|
228 |
+
|
229 |
+
}
|
230 |
+
|
231 |
// Allow plugins/themes developer to filter the default query.
|
232 |
$query = apply_filters( 'arpw_query', $query );
|
233 |
|
includes/resizer.php
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Title : Aqua Resizer
|
5 |
+
* Description : Resizes WordPress images on the fly
|
6 |
+
* Version : 1.2.0
|
7 |
+
* Author : Syamil MJ
|
8 |
+
* Author URI : http://aquagraphite.com
|
9 |
+
* License : WTFPL - http://sam.zoy.org/wtfpl/
|
10 |
+
* Documentation : https://github.com/sy4mil/Aqua-Resizer/
|
11 |
+
*
|
12 |
+
* I changed the function and class name for compatibility purpose. It somtimes conflicted with a theme which uses the same library.
|
13 |
+
*
|
14 |
+
* @param string $url - (required) must be uploaded using wp media uploader
|
15 |
+
* @param int $width - (required)
|
16 |
+
* @param int $height - (optional)
|
17 |
+
* @param bool $crop - (optional) default to soft crop
|
18 |
+
* @param bool $single - (optional) returns an array if false
|
19 |
+
* @param bool $upscale - (optional) resizes smaller images
|
20 |
+
* @uses wp_upload_dir()
|
21 |
+
* @uses image_resize_dimensions()
|
22 |
+
* @uses wp_get_image_editor()
|
23 |
+
*
|
24 |
+
* @return str|array
|
25 |
+
*/
|
26 |
+
|
27 |
+
if(!class_exists('Arpw_Resize')) {
|
28 |
+
class Arpw_Resize
|
29 |
+
{
|
30 |
+
/**
|
31 |
+
* The singleton instance
|
32 |
+
*/
|
33 |
+
static private $instance = null;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* No initialization allowed
|
37 |
+
*/
|
38 |
+
private function __construct() {}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* No cloning allowed
|
42 |
+
*/
|
43 |
+
private function __clone() {}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* For your custom default usage you may want to initialize an Arpw_Resize object by yourself and then have own defaults
|
47 |
+
*/
|
48 |
+
static public function getInstance() {
|
49 |
+
if(self::$instance == null) {
|
50 |
+
self::$instance = new self;
|
51 |
+
}
|
52 |
+
|
53 |
+
return self::$instance;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Run, forest.
|
58 |
+
*/
|
59 |
+
public function process( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
|
60 |
+
// Validate inputs.
|
61 |
+
if ( ! $url || ( ! $width && ! $height ) ) return false;
|
62 |
+
|
63 |
+
// Caipt'n, ready to hook.
|
64 |
+
if ( true === $upscale ) add_filter( 'image_resize_dimensions', array($this, 'arpw_upscale'), 10, 6 );
|
65 |
+
|
66 |
+
// Define upload path & dir.
|
67 |
+
$upload_info = wp_upload_dir();
|
68 |
+
$upload_dir = $upload_info['basedir'];
|
69 |
+
$upload_url = $upload_info['baseurl'];
|
70 |
+
|
71 |
+
$http_prefix = "http://";
|
72 |
+
$https_prefix = "https://";
|
73 |
+
|
74 |
+
/* if the $url scheme differs from $upload_url scheme, make them match
|
75 |
+
if the schemes differe, images don't show up. */
|
76 |
+
if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
|
77 |
+
$upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
|
78 |
+
}
|
79 |
+
elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
|
80 |
+
$upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
// Check if $img_url is local.
|
85 |
+
if ( false === strpos( $url, $upload_url ) ) return false;
|
86 |
+
|
87 |
+
// Define path of image.
|
88 |
+
$rel_path = str_replace( $upload_url, '', $url );
|
89 |
+
$img_path = $upload_dir . $rel_path;
|
90 |
+
|
91 |
+
// Check if img path exists, and is an image indeed.
|
92 |
+
if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) ) return false;
|
93 |
+
|
94 |
+
// Get image info.
|
95 |
+
$info = pathinfo( $img_path );
|
96 |
+
$ext = $info['extension'];
|
97 |
+
list( $orig_w, $orig_h ) = getimagesize( $img_path );
|
98 |
+
|
99 |
+
// Get image size after cropping.
|
100 |
+
$dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
|
101 |
+
$dst_w = $dims[4];
|
102 |
+
$dst_h = $dims[5];
|
103 |
+
|
104 |
+
// Return the original image only if it exactly fits the needed measures.
|
105 |
+
if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
|
106 |
+
$img_url = $url;
|
107 |
+
$dst_w = $orig_w;
|
108 |
+
$dst_h = $orig_h;
|
109 |
+
} else {
|
110 |
+
// Use this to check if cropped image already exists, so we can return that instead.
|
111 |
+
$suffix = "{$dst_w}x{$dst_h}";
|
112 |
+
$dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
|
113 |
+
$destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
|
114 |
+
|
115 |
+
if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
|
116 |
+
// Can't resize, so return false saying that the action to do could not be processed as planned.
|
117 |
+
return false;
|
118 |
+
}
|
119 |
+
// Else check if cache exists.
|
120 |
+
elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
|
121 |
+
$img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
|
122 |
+
}
|
123 |
+
// Else, we resize the image and return the new resized image url.
|
124 |
+
else {
|
125 |
+
|
126 |
+
$editor = wp_get_image_editor( $img_path );
|
127 |
+
|
128 |
+
if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) )
|
129 |
+
return false;
|
130 |
+
|
131 |
+
$resized_file = $editor->save();
|
132 |
+
|
133 |
+
if ( ! is_wp_error( $resized_file ) ) {
|
134 |
+
$resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
|
135 |
+
$img_url = $upload_url . $resized_rel_path;
|
136 |
+
} else {
|
137 |
+
return false;
|
138 |
+
}
|
139 |
+
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
// Okay, leave the ship.
|
144 |
+
if ( true === $upscale ) remove_filter( 'image_resize_dimensions', array( $this, 'arpw_upscale' ) );
|
145 |
+
|
146 |
+
// Return the output.
|
147 |
+
if ( $single ) {
|
148 |
+
// str return.
|
149 |
+
$image = $img_url;
|
150 |
+
} else {
|
151 |
+
// array return.
|
152 |
+
$image = array (
|
153 |
+
0 => $img_url,
|
154 |
+
1 => $dst_w,
|
155 |
+
2 => $dst_h
|
156 |
+
);
|
157 |
+
}
|
158 |
+
|
159 |
+
return $image;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Callback to overwrite WP computing of thumbnail measures
|
164 |
+
*/
|
165 |
+
function arpw_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
|
166 |
+
if ( ! $crop ) return null; // Let the wordpress default function handle this.
|
167 |
+
|
168 |
+
// Here is the point we allow to use larger image size than the original one.
|
169 |
+
$aspect_ratio = $orig_w / $orig_h;
|
170 |
+
$new_w = $dest_w;
|
171 |
+
$new_h = $dest_h;
|
172 |
+
|
173 |
+
if ( ! $new_w ) {
|
174 |
+
$new_w = intval( $new_h * $aspect_ratio );
|
175 |
+
}
|
176 |
+
|
177 |
+
if ( ! $new_h ) {
|
178 |
+
$new_h = intval( $new_w / $aspect_ratio );
|
179 |
+
}
|
180 |
+
|
181 |
+
$size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
|
182 |
+
|
183 |
+
$crop_w = round( $new_w / $size_ratio );
|
184 |
+
$crop_h = round( $new_h / $size_ratio );
|
185 |
+
|
186 |
+
$s_x = floor( ( $orig_w - $crop_w ) / 2 );
|
187 |
+
$s_y = floor( ( $orig_h - $crop_h ) / 2 );
|
188 |
+
|
189 |
+
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
|
190 |
+
}
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
|
195 |
+
|
196 |
+
|
197 |
+
|
198 |
+
if(!function_exists('arpw_resize')) {
|
199 |
+
|
200 |
+
/**
|
201 |
+
* This is just a tiny wrapper function for the class above so that there is no
|
202 |
+
* need to change any code in your own WP themes. Usage is still the same :)
|
203 |
+
*/
|
204 |
+
function arpw_resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
|
205 |
+
$arpw_resize = Arpw_Resize::getInstance();
|
206 |
+
return $arpw_resize->process( $url, $width, $height, $crop, $single, $upscale );
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
includes/widget-advanced-random-posts.php
DELETED
@@ -1,329 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// Exit if accessed directly
|
4 |
-
if ( ! defined('ABSPATH') ) exit;
|
5 |
-
|
6 |
-
class arpw_widget extends WP_Widget {
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Widget setup
|
10 |
-
*/
|
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 |
-
|
18 |
-
$control_ops = array(
|
19 |
-
'width' => 800,
|
20 |
-
'height' => 350,
|
21 |
-
'id_base' => 'arpw_widget'
|
22 |
-
);
|
23 |
-
|
24 |
-
$this->WP_Widget( 'arpw_widget', __( 'Advanced Random Posts', 'arpw' ), $widget_ops, $control_ops );
|
25 |
-
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Display widget
|
30 |
-
*/
|
31 |
-
function widget( $args, $instance ) {
|
32 |
-
|
33 |
-
extract( $args, EXTR_SKIP );
|
34 |
-
|
35 |
-
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
|
36 |
-
$title_url = esc_url( $instance['title_url'] );
|
37 |
-
$limit = (int)( $instance['limit'] );
|
38 |
-
$excerpt = $instance['excerpt'];
|
39 |
-
$length = (int)( $instance['length'] );
|
40 |
-
$thumb = $instance['thumb'];
|
41 |
-
$thumb_height = (int)( $instance['thumb_height'] );
|
42 |
-
$thumb_width = (int)( $instance['thumb_width'] );
|
43 |
-
$cat = $instance['cat'];
|
44 |
-
$tag = $instance['tag'];
|
45 |
-
$date = $instance['date'];
|
46 |
-
$css = wp_filter_nohtml_kses( $instance['css'] );
|
47 |
-
$css_id = $instance['css_id'];
|
48 |
-
$css_default = $instance['css_default'];
|
49 |
-
|
50 |
-
echo $before_widget;
|
51 |
-
|
52 |
-
if ( $css_default == true )
|
53 |
-
arpw_custom_styles(); // load the custom style.
|
54 |
-
|
55 |
-
if( $css )
|
56 |
-
echo '<style>' . $css . '</style>';
|
57 |
-
|
58 |
-
if ( ! empty( $title_url ) && ! empty( $title ) )
|
59 |
-
echo $before_title . '<a href="' . $title_url . '" title="' . esc_attr( $title ) . '">' . $title . '</a>' . $after_title;
|
60 |
-
elseif ( ! empty( $title ) )
|
61 |
-
echo $before_title . $title . $after_title;
|
62 |
-
|
63 |
-
global $post;
|
64 |
-
|
65 |
-
$args = array(
|
66 |
-
'numberposts' => $limit,
|
67 |
-
'category__in' => $cat,
|
68 |
-
'tag__in' => $tag,
|
69 |
-
'post_type' => 'post',
|
70 |
-
'orderby' => 'rand'
|
71 |
-
);
|
72 |
-
|
73 |
-
$arpwwidget = get_posts( $args );
|
74 |
-
|
75 |
-
if( $arpwwidget ) : ?>
|
76 |
-
|
77 |
-
<div <?php echo( ! empty( $css_id ) ? 'id="' . $css_id . '"' : '' ); ?> class="arpw-block">
|
78 |
-
|
79 |
-
<ul>
|
80 |
-
|
81 |
-
<?php foreach( $arpwwidget as $post ) : setup_postdata( $post ); ?>
|
82 |
-
|
83 |
-
<li class="arpw-clearfix">
|
84 |
-
|
85 |
-
<?php if( $thumb == true && has_post_thumbnail() ) { ?>
|
86 |
-
|
87 |
-
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'arpw' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
|
88 |
-
<?php
|
89 |
-
if ( current_theme_supports( 'get-the-image' ) )
|
90 |
-
get_the_image( array( 'meta_key' => 'Thumbnail', 'height' => $thumb_height, 'width' => $thumb_width, 'image_class' => 'arpw-alignleft', 'link_to_post' => false ) );
|
91 |
-
else
|
92 |
-
the_post_thumbnail( array( $thumb_height, $thumb_width ), array( 'class' => 'arpw-alignleft', 'alt' => esc_attr( get_the_title() ), 'title' => esc_attr( get_the_title() ) ) );
|
93 |
-
?>
|
94 |
-
</a>
|
95 |
-
|
96 |
-
<?php } ?>
|
97 |
-
|
98 |
-
<h3 class="arpw-title">
|
99 |
-
<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>
|
100 |
-
</h3>
|
101 |
-
|
102 |
-
<?php if( $date == true ) { ?>
|
103 |
-
<span class="arpw-time"><?php echo human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) . __( ' ago', 'arpw' ); ?></span>
|
104 |
-
<?php } ?>
|
105 |
-
|
106 |
-
<?php if( $excerpt == true ) { ?>
|
107 |
-
<div class="arpw-summary"><?php echo arpw_excerpt( $length ); ?></div>
|
108 |
-
<?php } ?>
|
109 |
-
|
110 |
-
</li>
|
111 |
-
|
112 |
-
<?php endforeach; wp_reset_postdata(); ?>
|
113 |
-
|
114 |
-
</ul>
|
115 |
-
|
116 |
-
</div><!-- .arpw-block - http://wordpress.org/plugins/advanced-random-posts-widget/ -->
|
117 |
-
|
118 |
-
<?php endif;
|
119 |
-
|
120 |
-
echo $after_widget;
|
121 |
-
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Update widget
|
126 |
-
*/
|
127 |
-
function update( $new_instance, $old_instance ) {
|
128 |
-
|
129 |
-
$instance = $old_instance;
|
130 |
-
$instance['title'] = strip_tags( $new_instance['title'] );
|
131 |
-
$instance['title_url'] = esc_url_raw( $new_instance['title_url'] );
|
132 |
-
$instance['limit'] = (int)( $new_instance['limit'] );
|
133 |
-
$instance['excerpt'] = $new_instance['excerpt'];
|
134 |
-
$instance['length'] = (int)( $new_instance['length'] );
|
135 |
-
$instance['thumb'] = $new_instance['thumb'];
|
136 |
-
$instance['thumb_height'] = (int)( $new_instance['thumb_height'] );
|
137 |
-
$instance['thumb_width'] = (int)( $new_instance['thumb_width'] );
|
138 |
-
$instance['cat'] = $new_instance['cat'];
|
139 |
-
$instance['tag'] = $new_instance['tag'];
|
140 |
-
$instance['date'] = $new_instance['date'];
|
141 |
-
$instance['css'] = wp_filter_nohtml_kses( $new_instance['css'] );
|
142 |
-
$instance['css_id'] = sanitize_html_class( $new_instance['css_id'] );
|
143 |
-
$instance['css_default'] = $new_instance['css_default'];
|
144 |
-
|
145 |
-
return $instance;
|
146 |
-
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Widget setting
|
151 |
-
*/
|
152 |
-
function form( $instance ) {
|
153 |
-
|
154 |
-
/* Set up some default widget settings. */
|
155 |
-
$defaults = array(
|
156 |
-
'title' => '',
|
157 |
-
'title_url' => '',
|
158 |
-
'limit' => 5,
|
159 |
-
'excerpt' => '',
|
160 |
-
'length' => 10,
|
161 |
-
'thumb' => true,
|
162 |
-
'thumb_height' => 45,
|
163 |
-
'thumb_width' => 45,
|
164 |
-
'cat' => '',
|
165 |
-
'tag' => '',
|
166 |
-
'date' => true,
|
167 |
-
'css' => '',
|
168 |
-
'css_id' => '',
|
169 |
-
'css_default' => true
|
170 |
-
);
|
171 |
-
|
172 |
-
$instance = wp_parse_args( (array) $instance, $defaults );
|
173 |
-
$title = strip_tags( $instance['title'] );
|
174 |
-
$title_url = esc_url( $instance['title_url'] );
|
175 |
-
$limit = (int)( $instance['limit'] );
|
176 |
-
$excerpt = $instance['excerpt'];
|
177 |
-
$length = (int)($instance['length']);
|
178 |
-
$thumb = $instance['thumb'];
|
179 |
-
$thumb_height = (int)( $instance['thumb_height'] );
|
180 |
-
$thumb_width = (int)( $instance['thumb_width'] );
|
181 |
-
$cat = $instance['cat'];
|
182 |
-
$tag = $instance['tag'];
|
183 |
-
$date = $instance['date'];
|
184 |
-
$css = wp_filter_nohtml_kses( $instance['css'] );
|
185 |
-
$css_id = $instance['css_id'];
|
186 |
-
$css_default = $instance['css_default'];
|
187 |
-
|
188 |
-
?>
|
189 |
-
|
190 |
-
<div class="arpw-columns-3">
|
191 |
-
|
192 |
-
<p>
|
193 |
-
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', 'arpw' ); ?></label>
|
194 |
-
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo $title; ?>" />
|
195 |
-
</p>
|
196 |
-
<p>
|
197 |
-
<label for="<?php echo esc_attr( $this->get_field_id( 'title_url' ) ); ?>"><?php _e( 'Title URL:', 'arpw' ); ?></label>
|
198 |
-
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title_url' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title_url' ) ); ?>" type="text" value="<?php echo $title_url; ?>" />
|
199 |
-
</p>
|
200 |
-
<p>
|
201 |
-
<label for="<?php echo esc_attr( $this->get_field_id( 'css_id' ) ); ?>"><?php _e( 'CSS ID:', 'arpw' ); ?></label>
|
202 |
-
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'css_id' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'css_id' ) ); ?>" type="text" value="<?php echo $css_id; ?>" />
|
203 |
-
</p>
|
204 |
-
<p>
|
205 |
-
<label class="input-checkbox" for="<?php echo esc_attr( $this->get_field_id( 'css_default' ) ); ?>"><?php _e( 'Use Default Styles', 'arpw' ); ?></label>
|
206 |
-
<input id="<?php echo esc_attr( $this->get_field_id( 'css_default' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'css_default' ) ); ?>" type="checkbox" value="1" <?php checked( '1', $css_default ); ?> />
|
207 |
-
</p>
|
208 |
-
<p>
|
209 |
-
<label for="<?php echo $this->get_field_id( 'css' ); ?>"><?php _e( 'Custom CSS:', 'arpw' ); ?></label>
|
210 |
-
<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>
|
211 |
-
<small><?php _e( 'If you turn off the default styles, please create your own style.', 'arpw' ); ?></small>
|
212 |
-
</p>
|
213 |
-
|
214 |
-
</div><!-- .arpw-columns-3 -->
|
215 |
-
|
216 |
-
<div class="arpw-columns-3">
|
217 |
-
|
218 |
-
<p>
|
219 |
-
<label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Limit:', 'arpw' ); ?></label>
|
220 |
-
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>" type="text" value="<?php echo $limit; ?>"/>
|
221 |
-
</p>
|
222 |
-
<p>
|
223 |
-
<label for="<?php echo esc_attr( $this->get_field_id( 'cat' ) ); ?>"><?php _e( 'Limit to specific or multiple Category: ', 'arpw' ); ?></label>
|
224 |
-
<select class="widefat" multiple="multiple" id="<?php echo esc_attr( $this->get_field_id( 'cat' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'cat' ) ); ?>[]" style="width:100%;">
|
225 |
-
<optgroup label="<?php echo esc_attr_e( 'Categories', 'arpw' ); ?>">
|
226 |
-
<?php $categories = get_terms( 'category' ); ?>
|
227 |
-
<?php foreach( $categories as $category ) { ?>
|
228 |
-
<option value="<?php echo $category->term_id; ?>" <?php if ( is_array( $cat ) && in_array( $category->term_id, $cat ) ) echo ' selected="selected"'; ?>><?php echo $category->name; ?></option>
|
229 |
-
<?php } ?>
|
230 |
-
</optgroup>
|
231 |
-
</select>
|
232 |
-
</p>
|
233 |
-
<p>
|
234 |
-
<label for="<?php echo esc_attr( $this->get_field_id( 'tag' ) ); ?>"><?php _e( 'Limit to specific or multiple Tag: ', 'arpw' ); ?></label>
|
235 |
-
<select class="widefat" multiple="multiple" id="<?php echo esc_attr( $this->get_field_id( 'tag' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'tag' ) ); ?>[]" style="width:100%;">
|
236 |
-
<optgroup label="Tags">
|
237 |
-
<?php $tags = get_terms( 'post_tag' ); ?>
|
238 |
-
<?php foreach( $tags as $post_tag ) { ?>
|
239 |
-
<option value="<?php echo $post_tag->term_id; ?>" <?php if ( is_array( $tag ) && in_array( $post_tag->term_id, $tag ) ) echo ' selected="selected"'; ?>><?php echo $post_tag->name; ?></option>
|
240 |
-
<?php } ?>
|
241 |
-
</optgroup>
|
242 |
-
</select>
|
243 |
-
</p>
|
244 |
-
|
245 |
-
</div><!-- .arpw-columns-3 -->
|
246 |
-
|
247 |
-
<div class="arpw-columns-3 arpw-column-last">
|
248 |
-
|
249 |
-
<?php if( current_theme_supports( 'post-thumbnails' ) ) { ?>
|
250 |
-
|
251 |
-
<p>
|
252 |
-
<label class="input-checkbox" for="<?php echo esc_attr( $this->get_field_id( 'thumb' ) ); ?>"><?php _e( 'Display thumbnail?', 'arpw' ); ?></label>
|
253 |
-
<input id="<?php echo $this->get_field_id( 'thumb' ); ?>" name="<?php echo $this->get_field_name( 'thumb' ); ?>" type="checkbox" value="1" <?php checked( '1', $thumb ); ?> />
|
254 |
-
</p>
|
255 |
-
<p>
|
256 |
-
<label class="rpwe-block" for="<?php echo esc_attr( $this->get_field_id( 'thumb_height' ) ); ?>"><?php _e( 'Thumbnail size (height x width):', 'arpw' ); ?></label>
|
257 |
-
<input class= "small-input" id="<?php echo esc_attr( $this->get_field_id( 'thumb_height' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'thumb_height' ) ); ?>" type="text" value="<?php echo $thumb_height; ?>" />
|
258 |
-
<input class= "small-input" id="<?php echo esc_attr( $this->get_field_id( 'thumb_width' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'thumb_width' ) ); ?>" type="text" value="<?php echo $thumb_width; ?>" />
|
259 |
-
</p>
|
260 |
-
|
261 |
-
<?php } ?>
|
262 |
-
|
263 |
-
<p>
|
264 |
-
<label class="input-checkbox" for="<?php echo esc_attr( $this->get_field_id( 'excerpt' ) ); ?>"><?php _e( 'Display excerpt?', 'arpw' ); ?></label>
|
265 |
-
<input id="<?php echo $this->get_field_id( 'excerpt' ); ?>" name="<?php echo $this->get_field_name( 'excerpt' ); ?>" type="checkbox" value="1" <?php checked( '1', $excerpt ); ?> />
|
266 |
-
</p>
|
267 |
-
<p>
|
268 |
-
<label for="<?php echo esc_attr( $this->get_field_id( 'length' ) ); ?>"><?php _e( 'Excerpt length:', 'arpw' ); ?></label>
|
269 |
-
<input class="widefat" 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; ?>" />
|
270 |
-
</p>
|
271 |
-
|
272 |
-
<p>
|
273 |
-
<label class="input-checkbox" for="<?php echo esc_attr( $this->get_field_id( 'date' ) ); ?>"><?php _e( 'Display date?', 'arpw' ); ?></label>
|
274 |
-
<input id="<?php echo $this->get_field_id( 'date' ); ?>" name="<?php echo $this->get_field_name( 'date' ); ?>" type="checkbox" value="1" <?php checked( '1', $date ); ?> />
|
275 |
-
</p>
|
276 |
-
|
277 |
-
</div><!-- .arpw-columns-3 .arpw-column-last -->
|
278 |
-
|
279 |
-
<div class="clear"></div>
|
280 |
-
|
281 |
-
<?php
|
282 |
-
}
|
283 |
-
|
284 |
-
}
|
285 |
-
|
286 |
-
/**
|
287 |
-
* Register widget.
|
288 |
-
*
|
289 |
-
* @since 1.0
|
290 |
-
*/
|
291 |
-
function arpw_register_widget() {
|
292 |
-
register_widget( 'arpw_widget' );
|
293 |
-
}
|
294 |
-
add_action( 'widgets_init', 'arpw_register_widget' );
|
295 |
-
|
296 |
-
/**
|
297 |
-
* Print a custom excerpt.
|
298 |
-
* http://bavotasan.com/2009/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/
|
299 |
-
*
|
300 |
-
* @since 1.0
|
301 |
-
*/
|
302 |
-
function arpw_excerpt( $length ) {
|
303 |
-
|
304 |
-
$excerpt = explode( ' ', get_the_excerpt(), $length );
|
305 |
-
if ( count( $excerpt )>=$length ) {
|
306 |
-
array_pop( $excerpt );
|
307 |
-
$excerpt = implode( " ", $excerpt ) . '…';
|
308 |
-
} else {
|
309 |
-
$excerpt = implode( " ", $excerpt );
|
310 |
-
}
|
311 |
-
$excerpt = preg_replace( '`\[[^\]]*\]`', '', $excerpt );
|
312 |
-
|
313 |
-
return $excerpt;
|
314 |
-
|
315 |
-
}
|
316 |
-
|
317 |
-
/**
|
318 |
-
* Custom Styles.
|
319 |
-
*
|
320 |
-
* @since 1.5
|
321 |
-
*/
|
322 |
-
function arpw_custom_styles() {
|
323 |
-
?>
|
324 |
-
<style>
|
325 |
-
.arpw-block ul{list-style:none!important;margin-left:0!important;padding-left:0!important;}.arpw-block li{border-bottom:1px solid #eee;margin-bottom:10px;padding-bottom:10px;}.arpw-block a{display:inline!important;text-decoration:none;}.arpw-block h3{background:none!important;clear:none;margin-bottom:0!important;font-weight:400;font-size:12px!important;line-height:1.5;}.arpw-alignleft{border:1px solid #eee!important;box-shadow:none!important;display:inline;float:left;margin:2px 10px 0 0;padding:3px!important;}.arpw-summary{font-size:12px;}.arpw-time{color:#bbb;font-size:11px;}.arpw-clearfix:before,.arpw-clearfix:after{content:"";display:table;}.arpw-clearfix:after{clear:both;}.arpw-clearfix{zoom:1;}
|
326 |
-
</style>
|
327 |
-
<?php
|
328 |
-
}
|
329 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
=== Advanced Random Posts Widget ===
|
2 |
Contributors: satrya, themejunkie
|
|
|
3 |
Tags: random posts, thumbnail, widget, widgets, sidebar, excerpt, category, post tag, post type, taxonomy, shortcode, multiple widgets
|
4 |
-
Requires at least: 3.
|
5 |
Tested up to: 4.0
|
6 |
-
Stable tag: 2.0.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -13,17 +14,25 @@ Provides flexible and advanced random posts. Display it via shortcode or widget
|
|
13 |
|
14 |
This plugin will enable a custom, flexible and advanced random posts. It allows you to display a list of random posts via shortcode or widget with thumbnail, excerpt and post date, also you can display it from all or specific or multiple taxonomy.
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
= Features Include =
|
17 |
|
18 |
* WordPress 4.0 Support.
|
19 |
* Allow you to set title url.
|
20 |
* Display thumbnails, with customizable size and alignment.
|
21 |
* Display excerpt, with customizable length.
|
|
|
|
|
22 |
* Display from all, specific or multiple taxonomy.
|
23 |
* Display post date.
|
24 |
* Post types.
|
25 |
* Post status.
|
26 |
-
* Allow you to set custom css per widget.
|
27 |
* Add custom html or text before and/or after random posts.
|
28 |
* Multiple widgets.
|
29 |
|
@@ -37,13 +46,13 @@ This plugin creates custom image sizes. If you use images that were uploaded to
|
|
37 |
|
38 |
= Support =
|
39 |
|
40 |
-
* Go to [forum support](http://wordpress.org/support/plugin/
|
41 |
-
* [Rate/Review the plugin](http://wordpress.org/support/view/plugin-reviews/
|
42 |
* Submit translation.
|
43 |
|
44 |
= Plugin Info =
|
45 |
* Developed by [Satrya](http://satrya.me/) & [Theme Junkie](http://www.theme-junkie.com/)
|
46 |
-
* Check out the [Github](https://github.com/satrya/
|
47 |
|
48 |
= Posts Plugin Series =
|
49 |
* [Recent Posts Widget Extended](http://wordpress.org/plugins/recent-posts-widget-extended/)
|
@@ -159,13 +168,7 @@ after=""
|
|
159 |
|
160 |
== Changelog ==
|
161 |
|
162 |
-
= 2.0.
|
163 |
-
*
|
164 |
-
*
|
165 |
-
*
|
166 |
-
* Added shortcode support!
|
167 |
-
* Added taxonomy support
|
168 |
-
* Added post status support
|
169 |
-
* Changed how the post thumbnail size works
|
170 |
-
* Changed how the plugin style works
|
171 |
-
* Update language
|
1 |
=== Advanced Random Posts Widget ===
|
2 |
Contributors: satrya, themejunkie
|
3 |
+
Donate link: http://satrya.me/donate/
|
4 |
Tags: random posts, thumbnail, widget, widgets, sidebar, excerpt, category, post tag, post type, taxonomy, shortcode, multiple widgets
|
5 |
+
Requires at least: 3.7
|
6 |
Tested up to: 4.0
|
7 |
+
Stable tag: 2.0.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
14 |
|
15 |
This plugin will enable a custom, flexible and advanced random posts. It allows you to display a list of random posts via shortcode or widget with thumbnail, excerpt and post date, also you can display it from all or specific or multiple taxonomy.
|
16 |
|
17 |
+
= Important! =
|
18 |
+
Before asking a support question:
|
19 |
+
|
20 |
+
* Please see [FAQ](http://wordpress.org/plugins/advanced-random-posts-widget/faq/) page to read common questions.
|
21 |
+
* Please see [Other Notes](http://wordpress.org/plugins/advanced-random-posts-widget/other_notes/) to read how to use shortcode.
|
22 |
+
|
23 |
= Features Include =
|
24 |
|
25 |
* WordPress 4.0 Support.
|
26 |
* Allow you to set title url.
|
27 |
* Display thumbnails, with customizable size and alignment.
|
28 |
* Display excerpt, with customizable length.
|
29 |
+
* Display from all, specific or multiple category.
|
30 |
+
* Display from all, specific or multiple tag.
|
31 |
* Display from all, specific or multiple taxonomy.
|
32 |
* Display post date.
|
33 |
* Post types.
|
34 |
* Post status.
|
35 |
+
* Allow you to set custom css class per widget.
|
36 |
* Add custom html or text before and/or after random posts.
|
37 |
* Multiple widgets.
|
38 |
|
46 |
|
47 |
= Support =
|
48 |
|
49 |
+
* Go to [forum support](http://wordpress.org/support/plugin/advanced-random-posts-widget).
|
50 |
+
* [Rate/Review the plugin](http://wordpress.org/support/view/plugin-reviews/advanced-random-posts-widget).
|
51 |
* Submit translation.
|
52 |
|
53 |
= Plugin Info =
|
54 |
* Developed by [Satrya](http://satrya.me/) & [Theme Junkie](http://www.theme-junkie.com/)
|
55 |
+
* Check out the [Github](https://github.com/satrya/advanced-random-posts-widget) repo to contribute.
|
56 |
|
57 |
= Posts Plugin Series =
|
58 |
* [Recent Posts Widget Extended](http://wordpress.org/plugins/recent-posts-widget-extended/)
|
168 |
|
169 |
== Changelog ==
|
170 |
|
171 |
+
= 2.0.1 - 9/15/2014 =
|
172 |
+
* Bring back custom thumbnail size options!
|
173 |
+
* Bring back category and tag options!
|
174 |
+
* Added: Relative date option `eg: 5 days ago`.
|
|
|
|
|
|
|
|
|
|
|
|