Version Description
- Feb 17, 2021 =
- This is just a maintenance update after a couple years with no update. Thank you for still using this plugin
Download this release
Release Info
Developer | idenovasi |
Plugin | Recent Posts Widget Extended |
Version | 1.0.0 |
Comparing to | |
See all releases |
Code changes from version 0.9.9.7 to 1.0.0
- assets/css/rpwe-admin.css +0 -0
- classes/widget.php +149 -154
- includes/form.php +262 -260
- includes/functions.php +215 -138
- includes/helpers.php +20 -19
- includes/resizer.php +50 -52
- includes/shortcode.php +9 -8
- languages/recent-posts-widget-extended-de_DE.mo +0 -0
- languages/recent-posts-widget-extended-de_DE.po +0 -0
- languages/recent-posts-widget-extended-fa_IR.mo +0 -0
- languages/recent-posts-widget-extended-fa_IR.po +0 -0
- languages/recent-posts-widget-extended-fr_FR.mo +0 -0
- languages/recent-posts-widget-extended-fr_FR.po +0 -0
- languages/recent-posts-widget-extended-pt_BR.mo +0 -0
- languages/recent-posts-widget-extended-pt_BR.po +0 -0
- languages/recent-posts-widget-extended.pot +57 -119
- readme.txt +18 -64
- rpwe.php +105 -107
- screenshot-1.png +0 -0
assets/css/rpwe-admin.css
CHANGED
File without changes
|
classes/widget.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* The custom recent posts widget.
|
4 |
* This widget gives total control over the output to the user.
|
@@ -11,158 +12,152 @@
|
|
11 |
*/
|
12 |
class Recent_Posts_Widget_Extended extends WP_Widget {
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
// Loads the widget form.
|
164 |
-
include( RPWE_INCLUDES . 'form.php' );
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* The custom recent posts widget.
|
5 |
* This widget gives total control over the output to the user.
|
12 |
*/
|
13 |
class Recent_Posts_Widget_Extended extends WP_Widget {
|
14 |
|
15 |
+
/**
|
16 |
+
* Sets up the widgets.
|
17 |
+
*
|
18 |
+
* @since 0.1
|
19 |
+
*/
|
20 |
+
public function __construct() {
|
21 |
+
|
22 |
+
/* Set up the widget options. */
|
23 |
+
$widget_options = array(
|
24 |
+
'classname' => 'rpwe_widget recent-posts-extended',
|
25 |
+
'description' => __('An advanced widget that gives you total control over the output of your site’s most recent Posts.', 'recent-posts-widget-extended'),
|
26 |
+
'customize_selective_refresh' => true
|
27 |
+
);
|
28 |
+
|
29 |
+
$control_options = array(
|
30 |
+
'width' => 750,
|
31 |
+
'height' => 350
|
32 |
+
);
|
33 |
+
|
34 |
+
/* Create the widget. */
|
35 |
+
parent::__construct(
|
36 |
+
'rpwe_widget', // $this->id_base
|
37 |
+
__('Recent Posts Extended', 'recent-posts-widget-extended'), // $this->name
|
38 |
+
$widget_options, // $this->widget_options
|
39 |
+
$control_options // $this->control_options
|
40 |
+
);
|
41 |
+
|
42 |
+
$this->alt_option_name = 'rpwe_widget';
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Outputs the widget based on the arguments input through the widget controls.
|
47 |
+
*
|
48 |
+
* @since 0.1
|
49 |
+
*/
|
50 |
+
public function widget($args, $instance) {
|
51 |
+
extract($args);
|
52 |
+
|
53 |
+
$recent = rpwe_get_recent_posts($instance);
|
54 |
+
|
55 |
+
if ($recent) {
|
56 |
+
|
57 |
+
// Output the theme's $before_widget wrapper.
|
58 |
+
echo $before_widget;
|
59 |
+
|
60 |
+
// If both title and title url is not empty, display it.
|
61 |
+
if (!empty($instance['title_url']) && !empty($instance['title'])) {
|
62 |
+
echo $before_title . '<a href="' . esc_url($instance['title_url']) . '" title="' . esc_attr($instance['title']) . '">' . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . '</a>' . $after_title;
|
63 |
+
|
64 |
+
// If the title not empty, display it.
|
65 |
+
} elseif (!empty($instance['title'])) {
|
66 |
+
echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
|
67 |
+
}
|
68 |
+
|
69 |
+
// Get the recent posts query.
|
70 |
+
echo $recent;
|
71 |
+
|
72 |
+
// Close the theme's widget wrapper.
|
73 |
+
echo $after_widget;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Updates the widget control options for the particular instance of the widget.
|
79 |
+
*
|
80 |
+
* @since 0.1
|
81 |
+
*/
|
82 |
+
public function update($new_instance, $old_instance) {
|
83 |
+
|
84 |
+
// Validate post_type submissions
|
85 |
+
$name = get_post_types(array('public' => true), 'names');
|
86 |
+
$types = array();
|
87 |
+
foreach ($new_instance['post_type'] as $type) {
|
88 |
+
if (in_array($type, $name)) {
|
89 |
+
$types[] = $type;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
if (empty($types)) {
|
93 |
+
$types[] = 'post';
|
94 |
+
}
|
95 |
+
|
96 |
+
$instance = $old_instance;
|
97 |
+
$instance['title'] = sanitize_text_field($new_instance['title']);
|
98 |
+
$instance['title_url'] = esc_url_raw($new_instance['title_url']);
|
99 |
+
|
100 |
+
$instance['ignore_sticky'] = isset($new_instance['ignore_sticky']) ? (bool) $new_instance['ignore_sticky'] : 0;
|
101 |
+
$instance['exclude_current'] = isset($new_instance['exclude_current']) ? (bool) $new_instance['exclude_current'] : 0;
|
102 |
+
$instance['limit'] = intval($new_instance['limit']);
|
103 |
+
$instance['offset'] = intval($new_instance['offset']);
|
104 |
+
$instance['order'] = stripslashes($new_instance['order']);
|
105 |
+
$instance['orderby'] = stripslashes($new_instance['orderby']);
|
106 |
+
$instance['post_type'] = $types;
|
107 |
+
$instance['post_status'] = stripslashes($new_instance['post_status']);
|
108 |
+
$instance['cat'] = $new_instance['cat'];
|
109 |
+
$instance['tag'] = $new_instance['tag'];
|
110 |
+
$instance['taxonomy'] = esc_attr($new_instance['taxonomy']);
|
111 |
+
|
112 |
+
$instance['excerpt'] = isset($new_instance['excerpt']) ? (bool) $new_instance['excerpt'] : false;
|
113 |
+
$instance['length'] = intval($new_instance['length']);
|
114 |
+
$instance['date'] = isset($new_instance['date']) ? (bool) $new_instance['date'] : false;
|
115 |
+
$instance['date_relative'] = isset($new_instance['date_relative']) ? (bool) $new_instance['date_relative'] : false;
|
116 |
+
$instance['date_modified'] = isset($new_instance['date_modified']) ? (bool) $new_instance['date_modified'] : false;
|
117 |
+
$instance['readmore'] = isset($new_instance['readmore']) ? (bool) $new_instance['readmore'] : false;
|
118 |
+
$instance['readmore_text'] = sanitize_text_field($new_instance['readmore_text']);
|
119 |
+
$instance['comment_count'] = isset($new_instance['comment_count']) ? (bool) $new_instance['comment_count'] : false;
|
120 |
+
|
121 |
+
$instance['thumb'] = isset($new_instance['thumb']) ? (bool) $new_instance['thumb'] : false;
|
122 |
+
$instance['thumb_height'] = intval($new_instance['thumb_height']);
|
123 |
+
$instance['thumb_width'] = intval($new_instance['thumb_width']);
|
124 |
+
$instance['thumb_default'] = esc_url_raw($new_instance['thumb_default']);
|
125 |
+
$instance['thumb_align'] = esc_attr($new_instance['thumb_align']);
|
126 |
+
|
127 |
+
$instance['styles_default'] = isset($new_instance['styles_default']) ? (bool) $new_instance['styles_default'] : false;
|
128 |
+
$instance['cssID'] = sanitize_html_class($new_instance['cssID']);
|
129 |
+
$instance['css_class'] = sanitize_html_class($new_instance['css_class']);
|
130 |
+
$instance['css'] = $new_instance['css'];
|
131 |
+
|
132 |
+
if (current_user_can('unfiltered_html')) {
|
133 |
+
$instance['before'] = $new_instance['before'];
|
134 |
+
} else {
|
135 |
+
$instance['before'] = wp_kses_post($new_instance['before']);
|
136 |
+
}
|
137 |
+
|
138 |
+
if (current_user_can('unfiltered_html')) {
|
139 |
+
$instance['after'] = $new_instance['after'];
|
140 |
+
} else {
|
141 |
+
$instance['after'] = wp_kses_post($new_instance['after']);
|
142 |
+
}
|
143 |
+
|
144 |
+
return $instance;
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Displays the widget control options in the Widgets admin screen.
|
149 |
+
*
|
150 |
+
* @since 0.1
|
151 |
+
*/
|
152 |
+
public function form($instance) {
|
153 |
+
|
154 |
+
// Merge the user-selected arguments with the defaults.
|
155 |
+
$instance = wp_parse_args((array) $instance, rpwe_get_default_args());
|
156 |
+
|
157 |
+
// Extract the array to allow easy use of variables.
|
158 |
+
extract($instance);
|
159 |
+
|
160 |
+
// Loads the widget form.
|
161 |
+
include(RPWE_INCLUDES . 'form.php');
|
162 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
}
|
includes/form.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Widget forms.
|
4 |
*
|
@@ -12,283 +13,284 @@
|
|
12 |
|
13 |
<div class="rpwe-columns-3">
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
|
57 |
</div>
|
58 |
|
59 |
<div class="rpwe-columns-3">
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
|
|
168 |
|
169 |
</div>
|
170 |
|
171 |
<div class="rpwe-columns-3 rpwe-column-last">
|
172 |
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
|
277 |
</div>
|
278 |
|
279 |
<div class="clear"></div>
|
280 |
|
281 |
<p>
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
</p>
|
287 |
|
288 |
<p>
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
</p>
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Widget forms.
|
5 |
*
|
13 |
|
14 |
<div class="rpwe-columns-3">
|
15 |
|
16 |
+
<p>
|
17 |
+
<label for="<?php echo $this->get_field_id('title'); ?>">
|
18 |
+
<?php _e('Title', 'recent-posts-widget-extended'); ?>
|
19 |
+
</label>
|
20 |
+
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>" />
|
21 |
+
</p>
|
22 |
+
|
23 |
+
<p>
|
24 |
+
<label for="<?php echo $this->get_field_id('title_url'); ?>">
|
25 |
+
<?php _e('Title URL', 'recent-posts-widget-extended'); ?>
|
26 |
+
</label>
|
27 |
+
<input class="widefat" id="<?php echo $this->get_field_id('title_url'); ?>" name="<?php echo $this->get_field_name('title_url'); ?>" type="text" value="<?php echo esc_url($instance['title_url']); ?>" />
|
28 |
+
</p>
|
29 |
+
|
30 |
+
<p>
|
31 |
+
<label for="<?php echo $this->get_field_id('cssID'); ?>">
|
32 |
+
<?php _e('CSS ID', 'recent-posts-widget-extended'); ?>
|
33 |
+
</label>
|
34 |
+
<input class="widefat" id="<?php echo $this->get_field_id('cssID'); ?>" name="<?php echo $this->get_field_name('cssID'); ?>" type="text" value="<?php echo sanitize_html_class($instance['cssID']); ?>" />
|
35 |
+
</p>
|
36 |
+
|
37 |
+
<p>
|
38 |
+
<label for="<?php echo $this->get_field_id('css_class'); ?>">
|
39 |
+
<?php _e('CSS Class', 'recent-posts-widget-extended'); ?>
|
40 |
+
</label>
|
41 |
+
<input class="widefat" id="<?php echo $this->get_field_id('css_class'); ?>" name="<?php echo $this->get_field_name('css_class'); ?>" type="text" value="<?php echo sanitize_html_class($instance['css_class']); ?>" />
|
42 |
+
</p>
|
43 |
+
|
44 |
+
<p>
|
45 |
+
<label for="<?php echo $this->get_field_id('before'); ?>">
|
46 |
+
<?php _e('HTML or text before the recent posts', 'recent-posts-widget-extended'); ?>
|
47 |
+
</label>
|
48 |
+
<textarea class="widefat" id="<?php echo $this->get_field_id('before'); ?>" name="<?php echo $this->get_field_name('before'); ?>" rows="5"><?php echo htmlspecialchars(stripslashes($instance['before'])); ?></textarea>
|
49 |
+
</p>
|
50 |
+
|
51 |
+
<p>
|
52 |
+
<label for="<?php echo $this->get_field_id('after'); ?>">
|
53 |
+
<?php _e('HTML or text after the recent posts', 'recent-posts-widget-extended'); ?>
|
54 |
+
</label>
|
55 |
+
<textarea class="widefat" id="<?php echo $this->get_field_id('after'); ?>" name="<?php echo $this->get_field_name('after'); ?>" rows="5"><?php echo htmlspecialchars(stripslashes($instance['after'])); ?></textarea>
|
56 |
+
</p>
|
57 |
|
58 |
</div>
|
59 |
|
60 |
<div class="rpwe-columns-3">
|
61 |
|
62 |
+
<p>
|
63 |
+
<input class="checkbox" type="checkbox" <?php checked($instance['ignore_sticky'], 1); ?> id="<?php echo $this->get_field_id('ignore_sticky'); ?>" name="<?php echo $this->get_field_name('ignore_sticky'); ?>" />
|
64 |
+
<label for="<?php echo $this->get_field_id('ignore_sticky'); ?>">
|
65 |
+
<?php _e('Ignore sticky posts', 'recent-posts-widget-extended'); ?>
|
66 |
+
</label>
|
67 |
+
</p>
|
68 |
+
|
69 |
+
<p>
|
70 |
+
<input class="checkbox" type="checkbox" <?php checked($instance['exclude_current'], 1); ?> id="<?php echo $this->get_field_id('exclude_current'); ?>" name="<?php echo $this->get_field_name('exclude_current'); ?>" />
|
71 |
+
<label for="<?php echo $this->get_field_id('exclude_current'); ?>">
|
72 |
+
<?php _e('Exclude current post', 'recent-posts-widget-extended'); ?>
|
73 |
+
</label>
|
74 |
+
</p>
|
75 |
+
|
76 |
+
<div class="rpwe-multiple-check-form">
|
77 |
+
<label>
|
78 |
+
<?php _e('Post Types', 'recent-posts-widget-extended'); ?>
|
79 |
+
</label>
|
80 |
+
<ul>
|
81 |
+
<?php foreach (get_post_types(array('public' => true), 'objects') as $type) : ?>
|
82 |
+
<li>
|
83 |
+
<input type="checkbox" value="<?php echo esc_attr($type->name); ?>" id="<?php echo $this->get_field_id('post_type') . '-' . $type->name; ?>" name="<?php echo $this->get_field_name('post_type'); ?>[]" <?php checked(is_array($instance['post_type']) && in_array($type->name, $instance['post_type'])); ?> />
|
84 |
+
<label for="<?php echo $this->get_field_id('post_type') . '-' . $type->name; ?>">
|
85 |
+
<?php echo esc_html($type->labels->name); ?>
|
86 |
+
</label>
|
87 |
+
</li>
|
88 |
+
<?php endforeach; ?>
|
89 |
+
</ul>
|
90 |
+
</div>
|
91 |
+
|
92 |
+
<p>
|
93 |
+
<label for="<?php echo $this->get_field_id('post_status'); ?>">
|
94 |
+
<?php _e('Post Status', 'recent-posts-widget-extended'); ?>
|
95 |
+
</label>
|
96 |
+
<select class="widefat" id="<?php echo $this->get_field_id('post_status'); ?>" name="<?php echo $this->get_field_name('post_status'); ?>" style="width:100%;">
|
97 |
+
<?php foreach (get_available_post_statuses() as $status_value => $status_label) { ?>
|
98 |
+
<option value="<?php echo esc_attr($status_label); ?>" <?php selected($instance['post_status'], $status_label); ?>><?php echo esc_html(ucfirst($status_label)); ?></option>
|
99 |
+
<?php } ?>
|
100 |
+
</select>
|
101 |
+
</p>
|
102 |
+
|
103 |
+
<p>
|
104 |
+
<label for="<?php echo $this->get_field_id('order'); ?>">
|
105 |
+
<?php _e('Order', 'recent-posts-widget-extended'); ?>
|
106 |
+
</label>
|
107 |
+
<select class="widefat" id="<?php echo $this->get_field_id('order'); ?>" name="<?php echo $this->get_field_name('order'); ?>" style="width:100%;">
|
108 |
+
<option value="DESC" <?php selected($instance['order'], 'DESC'); ?>><?php _e('Descending', 'rpwe') ?></option>
|
109 |
+
<option value="ASC" <?php selected($instance['order'], 'ASC'); ?>><?php _e('Ascending', 'rpwe') ?></option>
|
110 |
+
</select>
|
111 |
+
</p>
|
112 |
+
|
113 |
+
<p>
|
114 |
+
<label for="<?php echo $this->get_field_id('orderby'); ?>">
|
115 |
+
<?php _e('Orderby', 'recent-posts-widget-extended'); ?>
|
116 |
+
</label>
|
117 |
+
<select class="widefat" id="<?php echo $this->get_field_id('orderby'); ?>" name="<?php echo $this->get_field_name('orderby'); ?>" style="width:100%;">
|
118 |
+
<option value="ID" <?php selected($instance['orderby'], 'ID'); ?>><?php _e('ID', 'rpwe') ?></option>
|
119 |
+
<option value="author" <?php selected($instance['orderby'], 'author'); ?>><?php _e('Author', 'rpwe') ?></option>
|
120 |
+
<option value="title" <?php selected($instance['orderby'], 'title'); ?>><?php _e('Title', 'rpwe') ?></option>
|
121 |
+
<option value="date" <?php selected($instance['orderby'], 'date'); ?>><?php _e('Date', 'rpwe') ?></option>
|
122 |
+
<option value="modified" <?php selected($instance['orderby'], 'modified'); ?>><?php _e('Modified', 'rpwe') ?></option>
|
123 |
+
<option value="rand" <?php selected($instance['orderby'], 'rand'); ?>><?php _e('Random', 'rpwe') ?></option>
|
124 |
+
<option value="comment_count" <?php selected($instance['orderby'], 'comment_count'); ?>><?php _e('Comment Count', 'rpwe') ?></option>
|
125 |
+
<option value="menu_order" <?php selected($instance['orderby'], 'menu_order'); ?>><?php _e('Menu Order', 'rpwe') ?></option>
|
126 |
+
</select>
|
127 |
+
</p>
|
128 |
+
|
129 |
+
<div class="rpwe-multiple-check-form">
|
130 |
+
<label>
|
131 |
+
<?php _e('Limit to Category', 'recent-posts-widget-extended'); ?>
|
132 |
+
</label>
|
133 |
+
<ul>
|
134 |
+
<?php foreach (rpwe_cats_list() as $category) : ?>
|
135 |
+
<li>
|
136 |
+
<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'])); ?> />
|
137 |
+
<label for="<?php echo $this->get_field_id('cat') . '-' . (int) $category->term_id; ?>">
|
138 |
+
<?php echo esc_html($category->name); ?>
|
139 |
+
</label>
|
140 |
+
</li>
|
141 |
+
<?php endforeach; ?>
|
142 |
+
</ul>
|
143 |
+
</div>
|
144 |
+
|
145 |
+
<div class="rpwe-multiple-check-form">
|
146 |
+
<label>
|
147 |
+
<?php _e('Limit to Tag', 'recent-posts-widget-extended'); ?>
|
148 |
+
</label>
|
149 |
+
<ul>
|
150 |
+
<?php foreach (rpwe_tags_list() as $post_tag) : ?>
|
151 |
+
<li>
|
152 |
+
<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'])); ?> />
|
153 |
+
<label for="<?php echo $this->get_field_id('tag') . '-' . (int) $post_tag->term_id; ?>">
|
154 |
+
<?php echo esc_html($post_tag->name); ?>
|
155 |
+
</label>
|
156 |
+
</li>
|
157 |
+
<?php endforeach; ?>
|
158 |
+
</ul>
|
159 |
+
</div>
|
160 |
+
|
161 |
+
<p>
|
162 |
+
<label for="<?php echo $this->get_field_id('taxonomy'); ?>">
|
163 |
+
<?php _e('Limit to Taxonomy', 'recent-posts-widget-extended'); ?>
|
164 |
+
</label>
|
165 |
+
<input type="text" class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>" value="<?php echo esc_attr($instance['taxonomy']); ?>" />
|
166 |
+
<small><?php _e('Ex: category=1,2,4&post_tag=6,12', 'rpwe'); ?><br />
|
167 |
+
<?php _e('Available: ', 'rpwe');
|
168 |
+
echo implode(', ', get_taxonomies(array('public' => true))); ?></small>
|
169 |
+
</p>
|
170 |
|
171 |
</div>
|
172 |
|
173 |
<div class="rpwe-columns-3 rpwe-column-last">
|
174 |
|
175 |
+
<p>
|
176 |
+
<label for="<?php echo $this->get_field_id('limit'); ?>">
|
177 |
+
<?php _e('Number of posts to show', 'recent-posts-widget-extended'); ?>
|
178 |
+
</label>
|
179 |
+
<input class="widefat" id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="number" step="1" min="-1" value="<?php echo (int)($instance['limit']); ?>" />
|
180 |
+
</p>
|
181 |
+
|
182 |
+
<p>
|
183 |
+
<label for="<?php echo $this->get_field_id('offset'); ?>">
|
184 |
+
<?php _e('Offset', 'recent-posts-widget-extended'); ?>
|
185 |
+
</label>
|
186 |
+
<input class="widefat" id="<?php echo $this->get_field_id('offset'); ?>" name="<?php echo $this->get_field_name('offset'); ?>" type="number" step="1" min="0" value="<?php echo (int)($instance['offset']); ?>" />
|
187 |
+
<small><?php _e('The number of posts to skip', 'recent-posts-widget-extended'); ?></small>
|
188 |
+
</p>
|
189 |
+
|
190 |
+
<?php if (current_theme_supports('post-thumbnails')) { ?>
|
191 |
+
|
192 |
+
<p>
|
193 |
+
<input id="<?php echo $this->get_field_id('thumb'); ?>" name="<?php echo $this->get_field_name('thumb'); ?>" type="checkbox" <?php checked($instance['thumb']); ?> />
|
194 |
+
<label for="<?php echo $this->get_field_id('thumb'); ?>">
|
195 |
+
<?php _e('Display Thumbnail', 'recent-posts-widget-extended'); ?>
|
196 |
+
</label>
|
197 |
+
</p>
|
198 |
+
|
199 |
+
<p>
|
200 |
+
<label class="rpwe-block" for="<?php echo $this->get_field_id('thumb_height'); ?>">
|
201 |
+
<?php _e('Thumbnail (height,width,align)', 'recent-posts-widget-extended'); ?>
|
202 |
+
</label>
|
203 |
+
<input class="small-input" id="<?php echo $this->get_field_id('thumb_height'); ?>" name="<?php echo $this->get_field_name('thumb_height'); ?>" type="number" step="1" min="0" value="<?php echo (int)($instance['thumb_height']); ?>" />
|
204 |
+
<input class="small-input" id="<?php echo $this->get_field_id('thumb_width'); ?>" name="<?php echo $this->get_field_name('thumb_width'); ?>" type="number" step="1" min="0" value="<?php echo (int)($instance['thumb_width']); ?>" />
|
205 |
+
<select class="small-input" id="<?php echo $this->get_field_id('thumb_align'); ?>" name="<?php echo $this->get_field_name('thumb_align'); ?>">
|
206 |
+
<option value="rpwe-alignleft" <?php selected($instance['thumb_align'], 'rpwe-alignleft'); ?>><?php _e('Left', 'recent-posts-widget-extended') ?></option>
|
207 |
+
<option value="rpwe-alignright" <?php selected($instance['thumb_align'], 'rpwe-alignright'); ?>><?php _e('Right', 'recent-posts-widget-extended') ?></option>
|
208 |
+
<option value="rpwe-aligncenter" <?php selected($instance['thumb_align'], 'rpwe-aligncenter'); ?>><?php _e('Center', 'recent-posts-widget-extended') ?></option>
|
209 |
+
</select>
|
210 |
+
</p>
|
211 |
+
|
212 |
+
<p>
|
213 |
+
<label for="<?php echo $this->get_field_id('thumb_default'); ?>">
|
214 |
+
<?php _e('Default Thumbnail', 'recent-posts-widget-extended'); ?>
|
215 |
+
</label>
|
216 |
+
<input class="widefat" id="<?php echo $this->get_field_id('thumb_default'); ?>" name="<?php echo $this->get_field_name('thumb_default'); ?>" type="text" value="<?php echo $instance['thumb_default']; ?>" />
|
217 |
+
<small><?php _e('Leave it blank to disable.', 'recent-posts-widget-extended'); ?></small>
|
218 |
+
</p>
|
219 |
+
|
220 |
+
<?php } ?>
|
221 |
+
|
222 |
+
<p>
|
223 |
+
<input id="<?php echo $this->get_field_id('excerpt'); ?>" name="<?php echo $this->get_field_name('excerpt'); ?>" type="checkbox" <?php checked($instance['excerpt']); ?> />
|
224 |
+
<label for="<?php echo $this->get_field_id('excerpt'); ?>">
|
225 |
+
<?php _e('Display Excerpt', 'recent-posts-widget-extended'); ?>
|
226 |
+
</label>
|
227 |
+
</p>
|
228 |
+
|
229 |
+
<p>
|
230 |
+
<label for="<?php echo $this->get_field_id('length'); ?>">
|
231 |
+
<?php _e('Excerpt Length', 'recent-posts-widget-extended'); ?>
|
232 |
+
</label>
|
233 |
+
<input class="widefat" id="<?php echo $this->get_field_id('length'); ?>" name="<?php echo $this->get_field_name('length'); ?>" type="number" step="1" min="0" value="<?php echo (int)($instance['length']); ?>" />
|
234 |
+
</p>
|
235 |
+
|
236 |
+
<p>
|
237 |
+
<input id="<?php echo $this->get_field_id('readmore'); ?>" name="<?php echo $this->get_field_name('readmore'); ?>" type="checkbox" <?php checked($instance['readmore']); ?> />
|
238 |
+
<label for="<?php echo $this->get_field_id('readmore'); ?>">
|
239 |
+
<?php _e('Display Readmore', 'recent-posts-widget-extended'); ?>
|
240 |
+
</label>
|
241 |
+
</p>
|
242 |
+
|
243 |
+
<p>
|
244 |
+
<label for="<?php echo $this->get_field_id('readmore_text'); ?>">
|
245 |
+
<?php _e('Readmore Text', 'recent-posts-widget-extended'); ?>
|
246 |
+
</label>
|
247 |
+
<input class="widefat" id="<?php echo $this->get_field_id('readmore_text'); ?>" name="<?php echo $this->get_field_name('readmore_text'); ?>" type="text" value="<?php echo strip_tags($instance['readmore_text']); ?>" />
|
248 |
+
</p>
|
249 |
+
|
250 |
+
<p>
|
251 |
+
<input id="<?php echo $this->get_field_id('comment_count'); ?>" name="<?php echo $this->get_field_name('comment_count'); ?>" type="checkbox" <?php checked($instance['comment_count']); ?> />
|
252 |
+
<label for="<?php echo $this->get_field_id('comment_count'); ?>">
|
253 |
+
<?php _e('Display Comment Count', 'recent-posts-widget-extended'); ?>
|
254 |
+
</label>
|
255 |
+
</p>
|
256 |
+
|
257 |
+
<p>
|
258 |
+
<input id="<?php echo $this->get_field_id('date'); ?>" name="<?php echo $this->get_field_name('date'); ?>" type="checkbox" <?php checked($instance['date']); ?> />
|
259 |
+
<label for="<?php echo $this->get_field_id('date'); ?>">
|
260 |
+
<?php _e('Display Date', 'recent-posts-widget-extended'); ?>
|
261 |
+
</label>
|
262 |
+
</p>
|
263 |
+
|
264 |
+
<p>
|
265 |
+
<input id="<?php echo $this->get_field_id('date_modified'); ?>" name="<?php echo $this->get_field_name('date_modified'); ?>" type="checkbox" <?php checked($instance['date_modified']); ?> />
|
266 |
+
<label for="<?php echo $this->get_field_id('date_modified'); ?>">
|
267 |
+
<?php _e('Display Modification Date', 'recent-posts-widget-extended'); ?>
|
268 |
+
</label>
|
269 |
+
</p>
|
270 |
+
|
271 |
+
<p>
|
272 |
+
<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']); ?> />
|
273 |
+
<label for="<?php echo $this->get_field_id('date_relative'); ?>">
|
274 |
+
<?php _e('Use Relative Date. eg: 5 days ago', 'recent-posts-widget-extended'); ?>
|
275 |
+
</label>
|
276 |
+
</p>
|
277 |
+
|
278 |
|
279 |
</div>
|
280 |
|
281 |
<div class="clear"></div>
|
282 |
|
283 |
<p>
|
284 |
+
<input id="<?php echo $this->get_field_id('styles_default'); ?>" name="<?php echo $this->get_field_name('styles_default'); ?>" type="checkbox" <?php checked($instance['styles_default']); ?> />
|
285 |
+
<label for="<?php echo $this->get_field_id('styles_default'); ?>">
|
286 |
+
<?php _e('Use Default Styles', 'recent-posts-widget-extended'); ?>
|
287 |
+
</label>
|
288 |
</p>
|
289 |
|
290 |
<p>
|
291 |
+
<label for="<?php echo $this->get_field_id('css'); ?>">
|
292 |
+
<?php _e('Custom CSS', 'recent-posts-widget-extended'); ?>
|
293 |
+
</label>
|
294 |
+
<textarea class="widefat" id="<?php echo $this->get_field_id('css'); ?>" name="<?php echo $this->get_field_name('css'); ?>" style="height:180px;"><?php echo $instance['css']; ?></textarea>
|
295 |
+
<small><?php _e('If you turn off the default styles, you can use these css code to customize the recent posts style.', 'recent-posts-widget-extended'); ?></small>
|
296 |
</p>
|
includes/functions.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Various functions used by the plugin.
|
4 |
*
|
@@ -19,7 +20,7 @@ function rpwe_get_default_args() {
|
|
19 |
$css_defaults = ".rpwe-block ul{\nlist-style: none !important;\nmargin-left: 0 !important;\npadding-left: 0 !important;\n}\n\n.rpwe-block li{\nborder-bottom: 1px solid #eee;\nmargin-bottom: 10px;\npadding-bottom: 10px;\nlist-style-type: none;\n}\n\n.rpwe-block a{\ndisplay: inline !important;\ntext-decoration: none;\n}\n\n.rpwe-block h3{\nbackground: none !important;\nclear: none;\nmargin-bottom: 0 !important;\nmargin-top: 0 !important;\nfont-weight: 400;\nfont-size: 12px !important;\nline-height: 1.5em;\n}\n\n.rpwe-thumb{\nborder: 1px solid #eee !important;\nbox-shadow: none !important;\nmargin: 2px 10px 2px 0;\npadding: 3px !important;\n}\n\n.rpwe-summary{\nfont-size: 12px;\n}\n\n.rpwe-time{\ncolor: #bbb;\nfont-size: 11px;\n}\n\n.rpwe-comment{\ncolor: #bbb;\nfont-size: 11px;\npadding-left: 5px;\n}\n\n.rpwe-alignleft{\ndisplay: inline;\nfloat: left;\n}\n\n.rpwe-alignright{\ndisplay: inline;\nfloat: right;\n}\n\n.rpwe-aligncenter{\ndisplay: block;\nmargin-left: auto;\nmargin-right: auto;\n}\n\n.rpwe-clearfix:before,\n.rpwe-clearfix:after{\ncontent: \"\";\ndisplay: table !important;\n}\n\n.rpwe-clearfix:after{\nclear: both;\n}\n\n.rpwe-clearfix{\nzoom: 1;\n}\n";
|
20 |
|
21 |
$defaults = array(
|
22 |
-
'title' => esc_attr__(
|
23 |
'title_url' => '',
|
24 |
|
25 |
'limit' => 5,
|
@@ -29,7 +30,7 @@ function rpwe_get_default_args() {
|
|
29 |
'cat' => array(),
|
30 |
'tag' => array(),
|
31 |
'taxonomy' => '',
|
32 |
-
'post_type' => array(
|
33 |
'post_status' => 'publish',
|
34 |
'ignore_sticky' => 1,
|
35 |
'exclude_current' => 1,
|
@@ -45,7 +46,7 @@ function rpwe_get_default_args() {
|
|
45 |
'date_relative' => false,
|
46 |
'date_modified' => false,
|
47 |
'readmore' => false,
|
48 |
-
'readmore_text' => __(
|
49 |
'comment_count' => false,
|
50 |
|
51 |
'styles_default' => true,
|
@@ -57,8 +58,7 @@ function rpwe_get_default_args() {
|
|
57 |
);
|
58 |
|
59 |
// Allow plugins/themes developer to filter the default arguments.
|
60 |
-
return apply_filters(
|
61 |
-
|
62 |
}
|
63 |
|
64 |
/**
|
@@ -66,8 +66,8 @@ function rpwe_get_default_args() {
|
|
66 |
*
|
67 |
* @since 0.9.4
|
68 |
*/
|
69 |
-
function rpwe_recent_posts(
|
70 |
-
echo rpwe_get_recent_posts(
|
71 |
}
|
72 |
|
73 |
/**
|
@@ -77,137 +77,139 @@ function rpwe_recent_posts( $args = array() ) {
|
|
77 |
* @param array $args
|
78 |
* @return string|array The HTML for the random posts.
|
79 |
*/
|
80 |
-
function rpwe_get_recent_posts(
|
81 |
|
82 |
// Set up a default, empty variable.
|
83 |
$html = '';
|
84 |
|
85 |
// Merge the input arguments and the defaults.
|
86 |
-
$args = wp_parse_args(
|
87 |
|
88 |
// Extract the array to allow easy use of variables.
|
89 |
-
extract(
|
90 |
|
91 |
// Allow devs to hook in stuff before the loop.
|
92 |
-
do_action(
|
93 |
|
94 |
// Display the default style of the plugin.
|
95 |
-
if (
|
96 |
rpwe_custom_styles();
|
97 |
}
|
98 |
|
99 |
// If the default style is disabled then use the custom css if it's not empty.
|
100 |
-
if (
|
101 |
echo '<style>' . $args['css'] . '</style>';
|
102 |
}
|
103 |
|
104 |
// Get the posts query.
|
105 |
-
$posts = rpwe_get_posts(
|
106 |
|
107 |
-
if (
|
108 |
|
109 |
// Recent posts wrapper
|
110 |
-
$html = '<div ' . (
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
|
|
|
|
211 |
|
212 |
$html .= '</div><!-- Generated by http://wordpress.org/plugins/recent-posts-widget-extended/ -->';
|
213 |
|
@@ -217,11 +219,10 @@ function rpwe_get_recent_posts( $args = array() ) {
|
|
217 |
wp_reset_postdata();
|
218 |
|
219 |
// Allow devs to hook in stuff after the loop.
|
220 |
-
do_action(
|
221 |
|
222 |
// Return the posts markup.
|
223 |
-
return wp_kses_post(
|
224 |
-
|
225 |
}
|
226 |
|
227 |
/**
|
@@ -231,7 +232,7 @@ function rpwe_get_recent_posts( $args = array() ) {
|
|
231 |
* @param array $args
|
232 |
* @return array
|
233 |
*/
|
234 |
-
function rpwe_get_posts(
|
235 |
|
236 |
// Query arguments.
|
237 |
$query = array(
|
@@ -245,17 +246,17 @@ function rpwe_get_posts( $args = array() ) {
|
|
245 |
);
|
246 |
|
247 |
// Exclude current post
|
248 |
-
if (
|
249 |
-
$query['post__not_in'] = array(
|
250 |
}
|
251 |
|
252 |
// Limit posts based on category.
|
253 |
-
if (
|
254 |
$query['category__in'] = $args['cat'];
|
255 |
}
|
256 |
|
257 |
// Limit posts based on post tag.
|
258 |
-
if (
|
259 |
$query['tag__in'] = $args['tag'];
|
260 |
}
|
261 |
|
@@ -263,15 +264,15 @@ function rpwe_get_posts( $args = array() ) {
|
|
263 |
* Taxonomy query.
|
264 |
* Prop Miniloop plugin by Kailey Lampert.
|
265 |
*/
|
266 |
-
if (
|
267 |
|
268 |
-
parse_str(
|
269 |
|
270 |
$operator = 'IN';
|
271 |
$tax_query = array();
|
272 |
-
foreach(
|
273 |
-
$ids = explode(
|
274 |
-
if (
|
275 |
// If there is only one id given, and it's negative
|
276 |
// Let's treat it as 'posts not in'
|
277 |
$ids['0'] = $ids['0'] * -1;
|
@@ -286,17 +287,15 @@ function rpwe_get_posts( $args = array() ) {
|
|
286 |
}
|
287 |
|
288 |
$query['tax_query'] = $tax_query;
|
289 |
-
|
290 |
}
|
291 |
|
292 |
// Allow plugins/themes developer to filter the default query.
|
293 |
-
$query = apply_filters(
|
294 |
|
295 |
// Perform the query.
|
296 |
-
$posts = new WP_Query(
|
297 |
|
298 |
return $posts;
|
299 |
-
|
300 |
}
|
301 |
|
302 |
/**
|
@@ -305,9 +304,87 @@ function rpwe_get_posts( $args = array() ) {
|
|
305 |
* @since 0.8
|
306 |
*/
|
307 |
function rpwe_custom_styles() {
|
308 |
-
|
309 |
-
<style>
|
310 |
-
.rpwe-block ul
|
311 |
-
|
312 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Various functions used by the plugin.
|
5 |
*
|
20 |
$css_defaults = ".rpwe-block ul{\nlist-style: none !important;\nmargin-left: 0 !important;\npadding-left: 0 !important;\n}\n\n.rpwe-block li{\nborder-bottom: 1px solid #eee;\nmargin-bottom: 10px;\npadding-bottom: 10px;\nlist-style-type: none;\n}\n\n.rpwe-block a{\ndisplay: inline !important;\ntext-decoration: none;\n}\n\n.rpwe-block h3{\nbackground: none !important;\nclear: none;\nmargin-bottom: 0 !important;\nmargin-top: 0 !important;\nfont-weight: 400;\nfont-size: 12px !important;\nline-height: 1.5em;\n}\n\n.rpwe-thumb{\nborder: 1px solid #eee !important;\nbox-shadow: none !important;\nmargin: 2px 10px 2px 0;\npadding: 3px !important;\n}\n\n.rpwe-summary{\nfont-size: 12px;\n}\n\n.rpwe-time{\ncolor: #bbb;\nfont-size: 11px;\n}\n\n.rpwe-comment{\ncolor: #bbb;\nfont-size: 11px;\npadding-left: 5px;\n}\n\n.rpwe-alignleft{\ndisplay: inline;\nfloat: left;\n}\n\n.rpwe-alignright{\ndisplay: inline;\nfloat: right;\n}\n\n.rpwe-aligncenter{\ndisplay: block;\nmargin-left: auto;\nmargin-right: auto;\n}\n\n.rpwe-clearfix:before,\n.rpwe-clearfix:after{\ncontent: \"\";\ndisplay: table !important;\n}\n\n.rpwe-clearfix:after{\nclear: both;\n}\n\n.rpwe-clearfix{\nzoom: 1;\n}\n";
|
21 |
|
22 |
$defaults = array(
|
23 |
+
'title' => esc_attr__('Recent Posts', 'rpwe'),
|
24 |
'title_url' => '',
|
25 |
|
26 |
'limit' => 5,
|
30 |
'cat' => array(),
|
31 |
'tag' => array(),
|
32 |
'taxonomy' => '',
|
33 |
+
'post_type' => array('post'),
|
34 |
'post_status' => 'publish',
|
35 |
'ignore_sticky' => 1,
|
36 |
'exclude_current' => 1,
|
46 |
'date_relative' => false,
|
47 |
'date_modified' => false,
|
48 |
'readmore' => false,
|
49 |
+
'readmore_text' => __('Read More »', 'recent-posts-widget-extended'),
|
50 |
'comment_count' => false,
|
51 |
|
52 |
'styles_default' => true,
|
58 |
);
|
59 |
|
60 |
// Allow plugins/themes developer to filter the default arguments.
|
61 |
+
return apply_filters('rpwe_default_args', $defaults);
|
|
|
62 |
}
|
63 |
|
64 |
/**
|
66 |
*
|
67 |
* @since 0.9.4
|
68 |
*/
|
69 |
+
function rpwe_recent_posts($args = array()) {
|
70 |
+
echo rpwe_get_recent_posts($args);
|
71 |
}
|
72 |
|
73 |
/**
|
77 |
* @param array $args
|
78 |
* @return string|array The HTML for the random posts.
|
79 |
*/
|
80 |
+
function rpwe_get_recent_posts($args = array()) {
|
81 |
|
82 |
// Set up a default, empty variable.
|
83 |
$html = '';
|
84 |
|
85 |
// Merge the input arguments and the defaults.
|
86 |
+
$args = wp_parse_args($args, rpwe_get_default_args());
|
87 |
|
88 |
// Extract the array to allow easy use of variables.
|
89 |
+
extract($args);
|
90 |
|
91 |
// Allow devs to hook in stuff before the loop.
|
92 |
+
do_action('rpwe_before_loop');
|
93 |
|
94 |
// Display the default style of the plugin.
|
95 |
+
if ($args['styles_default'] === true) {
|
96 |
rpwe_custom_styles();
|
97 |
}
|
98 |
|
99 |
// If the default style is disabled then use the custom css if it's not empty.
|
100 |
+
if ($args['styles_default'] === false && !empty($args['css'])) {
|
101 |
echo '<style>' . $args['css'] . '</style>';
|
102 |
}
|
103 |
|
104 |
// Get the posts query.
|
105 |
+
$posts = rpwe_get_posts($args);
|
106 |
|
107 |
+
if ($posts->have_posts()) :
|
108 |
|
109 |
// Recent posts wrapper
|
110 |
+
$html = '<div ' . (!empty($args['cssID']) ? 'id="' . sanitize_html_class($args['cssID']) . '"' : '') . ' class="rpwe-block ' . (!empty($args['css_class']) ? '' . sanitize_html_class($args['css_class']) . '' : '') . '">';
|
111 |
+
|
112 |
+
$html .= '<ul class="rpwe-ul">';
|
113 |
+
|
114 |
+
while ($posts->have_posts()) : $posts->the_post();
|
115 |
+
|
116 |
+
// Thumbnails
|
117 |
+
$thumb_id = get_post_thumbnail_id(); // Get the featured image id.
|
118 |
+
$img_url = wp_get_attachment_url($thumb_id); // Get img URL.
|
119 |
+
|
120 |
+
// Display the image url and crop using the resizer.
|
121 |
+
$image = rpwe_resize($img_url, $args['thumb_width'], $args['thumb_height'], true);
|
122 |
+
|
123 |
+
// Start recent posts markup.
|
124 |
+
$html .= '<li class="rpwe-li rpwe-clearfix">';
|
125 |
+
|
126 |
+
if ($args['thumb']) :
|
127 |
+
|
128 |
+
// Check if post has post thumbnail.
|
129 |
+
if (has_post_thumbnail()) :
|
130 |
+
$html .= '<a class="rpwe-img" href="' . esc_url(get_permalink()) . '" rel="bookmark">';
|
131 |
+
if ($image) :
|
132 |
+
$html .= '<img class="' . esc_attr($args['thumb_align']) . ' rpwe-thumb" src="' . esc_url($image) . '" alt="' . esc_attr(get_the_title()) . '">';
|
133 |
+
else :
|
134 |
+
$html .= get_the_post_thumbnail(
|
135 |
+
get_the_ID(),
|
136 |
+
array($args['thumb_width'], $args['thumb_height']),
|
137 |
+
array(
|
138 |
+
'class' => $args['thumb_align'] . ' rpwe-thumb the-post-thumbnail',
|
139 |
+
'alt' => esc_attr(get_the_title())
|
140 |
+
)
|
141 |
+
);
|
142 |
+
endif;
|
143 |
+
$html .= '</a>';
|
144 |
+
|
145 |
+
// If no post thumbnail found, check if Get The Image plugin exist and display the image.
|
146 |
+
elseif (function_exists('get_the_image')) :
|
147 |
+
$html .= get_the_image(array(
|
148 |
+
'height' => (int) $args['thumb_height'],
|
149 |
+
'width' => (int) $args['thumb_width'],
|
150 |
+
'image_class' => esc_attr($args['thumb_align']) . ' rpwe-thumb get-the-image',
|
151 |
+
'image_scan' => true,
|
152 |
+
'echo' => false,
|
153 |
+
'default_image' => esc_url($args['thumb_default'])
|
154 |
+
));
|
155 |
+
|
156 |
+
// Display default image.
|
157 |
+
elseif (!empty($args['thumb_default'])) :
|
158 |
+
$html .= sprintf(
|
159 |
+
'<a class="rpwe-img" href="%1$s" rel="bookmark"><img class="%2$s rpwe-thumb rpwe-default-thumb" src="%3$s" alt="%4$s" width="%5$s" height="%6$s"></a>',
|
160 |
+
esc_url(get_permalink()),
|
161 |
+
esc_attr($args['thumb_align']),
|
162 |
+
esc_url($args['thumb_default']),
|
163 |
+
esc_attr(get_the_title()),
|
164 |
+
(int) $args['thumb_width'],
|
165 |
+
(int) $args['thumb_height']
|
166 |
+
);
|
167 |
+
|
168 |
+
endif;
|
169 |
+
|
170 |
+
endif;
|
171 |
+
|
172 |
+
$html .= '<h3 class="rpwe-title"><a href="' . esc_url(get_permalink()) . '" title="' . sprintf(esc_attr__('Permalink to %s', 'recent-posts-widget-extended'), the_title_attribute('echo=0')) . '" rel="bookmark">' . esc_attr(get_the_title()) . '</a></h3>';
|
173 |
+
|
174 |
+
if ($args['date']) :
|
175 |
+
$date = get_the_date();
|
176 |
+
if ($args['date_relative']) :
|
177 |
+
$date = sprintf(__('%s ago', 'recent-posts-widget-extended'), human_time_diff(get_the_date('U'), current_time('timestamp')));
|
178 |
+
endif;
|
179 |
+
$html .= '<time class="rpwe-time published" datetime="' . esc_html(get_the_date('c')) . '">' . esc_html($date) . '</time>';
|
180 |
+
elseif ($args['date_modified']) : // if both date functions are provided, we use date to be backwards compatible
|
181 |
+
$date = get_the_modified_date();
|
182 |
+
if ($args['date_relative']) :
|
183 |
+
$date = sprintf(__('%s ago', 'recent-posts-widget-extended'), human_time_diff(get_the_modified_date('U'), current_time('timestamp')));
|
184 |
+
endif;
|
185 |
+
$html .= '<time class="rpwe-time modfied" datetime="' . esc_html(get_the_modified_date('c')) . '">' . esc_html($date) . '</time>';
|
186 |
+
endif;
|
187 |
+
|
188 |
+
if ($args['comment_count']) :
|
189 |
+
if (get_comments_number() == 0) {
|
190 |
+
$comments = __('No Comments', 'recent-posts-widget-extended');
|
191 |
+
} elseif (get_comments_number() > 1) {
|
192 |
+
$comments = sprintf(__('%s Comments', 'recent-posts-widget-extended'), get_comments_number());
|
193 |
+
} else {
|
194 |
+
$comments = __('1 Comment', 'recent-posts-widget-extended');
|
195 |
+
}
|
196 |
+
$html .= '<a class="rpwe-comment comment-count" href="' . get_comments_link() . '">' . $comments . '</a>';
|
197 |
+
endif;
|
198 |
+
|
199 |
+
if ($args['excerpt']) :
|
200 |
+
$html .= '<div class="rpwe-summary">';
|
201 |
+
$html .= wp_trim_words(apply_filters('rpwe_excerpt', get_the_excerpt()), $args['length'], ' …');
|
202 |
+
if ($args['readmore']) :
|
203 |
+
$html .= '<a href="' . esc_url(get_permalink()) . '" class="more-link">' . $args['readmore_text'] . '</a>';
|
204 |
+
endif;
|
205 |
+
$html .= '</div>';
|
206 |
+
endif;
|
207 |
+
|
208 |
+
$html .= '</li>';
|
209 |
+
|
210 |
+
endwhile;
|
211 |
+
|
212 |
+
$html .= '</ul>';
|
213 |
|
214 |
$html .= '</div><!-- Generated by http://wordpress.org/plugins/recent-posts-widget-extended/ -->';
|
215 |
|
219 |
wp_reset_postdata();
|
220 |
|
221 |
// Allow devs to hook in stuff after the loop.
|
222 |
+
do_action('rpwe_after_loop');
|
223 |
|
224 |
// Return the posts markup.
|
225 |
+
return wp_kses_post($args['before']) . apply_filters('rpwe_markup', $html, $args) . wp_kses_post($args['after']);
|
|
|
226 |
}
|
227 |
|
228 |
/**
|
232 |
* @param array $args
|
233 |
* @return array
|
234 |
*/
|
235 |
+
function rpwe_get_posts($args = array()) {
|
236 |
|
237 |
// Query arguments.
|
238 |
$query = array(
|
246 |
);
|
247 |
|
248 |
// Exclude current post
|
249 |
+
if ($args['exclude_current']) {
|
250 |
+
$query['post__not_in'] = array(get_the_ID());
|
251 |
}
|
252 |
|
253 |
// Limit posts based on category.
|
254 |
+
if (!empty($args['cat'])) {
|
255 |
$query['category__in'] = $args['cat'];
|
256 |
}
|
257 |
|
258 |
// Limit posts based on post tag.
|
259 |
+
if (!empty($args['tag'])) {
|
260 |
$query['tag__in'] = $args['tag'];
|
261 |
}
|
262 |
|
264 |
* Taxonomy query.
|
265 |
* Prop Miniloop plugin by Kailey Lampert.
|
266 |
*/
|
267 |
+
if (!empty($args['taxonomy'])) {
|
268 |
|
269 |
+
parse_str($args['taxonomy'], $taxes);
|
270 |
|
271 |
$operator = 'IN';
|
272 |
$tax_query = array();
|
273 |
+
foreach (array_keys($taxes) as $k => $slug) {
|
274 |
+
$ids = explode(',', $taxes[$slug]);
|
275 |
+
if (count($ids) == 1 && $ids['0'] < 0) {
|
276 |
// If there is only one id given, and it's negative
|
277 |
// Let's treat it as 'posts not in'
|
278 |
$ids['0'] = $ids['0'] * -1;
|
287 |
}
|
288 |
|
289 |
$query['tax_query'] = $tax_query;
|
|
|
290 |
}
|
291 |
|
292 |
// Allow plugins/themes developer to filter the default query.
|
293 |
+
$query = apply_filters('rpwe_default_query_arguments', $query);
|
294 |
|
295 |
// Perform the query.
|
296 |
+
$posts = new WP_Query($query);
|
297 |
|
298 |
return $posts;
|
|
|
299 |
}
|
300 |
|
301 |
/**
|
304 |
* @since 0.8
|
305 |
*/
|
306 |
function rpwe_custom_styles() {
|
307 |
+
?>
|
308 |
+
<style>
|
309 |
+
.rpwe-block ul {
|
310 |
+
list-style: none !important;
|
311 |
+
margin-left: 0 !important;
|
312 |
+
padding-left: 0 !important;
|
313 |
+
}
|
314 |
+
|
315 |
+
.rpwe-block li {
|
316 |
+
border-bottom: 1px solid #eee;
|
317 |
+
margin-bottom: 10px;
|
318 |
+
padding-bottom: 10px;
|
319 |
+
list-style-type: none;
|
320 |
+
}
|
321 |
+
|
322 |
+
.rpwe-block a {
|
323 |
+
display: inline !important;
|
324 |
+
text-decoration: none;
|
325 |
+
}
|
326 |
+
|
327 |
+
.rpwe-block h3 {
|
328 |
+
background: none !important;
|
329 |
+
clear: none;
|
330 |
+
margin-bottom: 0 !important;
|
331 |
+
margin-top: 0 !important;
|
332 |
+
font-weight: 400;
|
333 |
+
font-size: 12px !important;
|
334 |
+
line-height: 1.5em;
|
335 |
+
}
|
336 |
+
|
337 |
+
.rpwe-thumb {
|
338 |
+
border: 1px solid #EEE !important;
|
339 |
+
box-shadow: none !important;
|
340 |
+
margin: 2px 10px 2px 0;
|
341 |
+
padding: 3px !important;
|
342 |
+
}
|
343 |
+
|
344 |
+
.rpwe-summary {
|
345 |
+
font-size: 12px;
|
346 |
+
}
|
347 |
+
|
348 |
+
.rpwe-time {
|
349 |
+
color: #bbb;
|
350 |
+
font-size: 11px;
|
351 |
+
}
|
352 |
+
|
353 |
+
.rpwe-comment {
|
354 |
+
color: #bbb;
|
355 |
+
font-size: 11px;
|
356 |
+
padding-left: 5px;
|
357 |
+
}
|
358 |
+
|
359 |
+
.rpwe-alignleft {
|
360 |
+
display: inline;
|
361 |
+
float: left;
|
362 |
+
}
|
363 |
+
|
364 |
+
.rpwe-alignright {
|
365 |
+
display: inline;
|
366 |
+
float: right;
|
367 |
+
}
|
368 |
+
|
369 |
+
.rpwe-aligncenter {
|
370 |
+
display: block;
|
371 |
+
margin-left: auto;
|
372 |
+
margin-right: auto;
|
373 |
+
}
|
374 |
+
|
375 |
+
.rpwe-clearfix:before,
|
376 |
+
.rpwe-clearfix:after {
|
377 |
+
content: "";
|
378 |
+
display: table !important;
|
379 |
+
}
|
380 |
+
|
381 |
+
.rpwe-clearfix:after {
|
382 |
+
clear: both;
|
383 |
+
}
|
384 |
+
|
385 |
+
.rpwe-clearfix {
|
386 |
+
zoom: 1;
|
387 |
+
}
|
388 |
+
</style>
|
389 |
+
<?php
|
390 |
}
|
includes/helpers.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Function helper
|
4 |
*
|
@@ -16,18 +17,18 @@
|
|
16 |
*/
|
17 |
function rpwe_tags_list() {
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
}
|
32 |
|
33 |
/**
|
@@ -37,16 +38,16 @@ function rpwe_tags_list() {
|
|
37 |
*/
|
38 |
function rpwe_cats_list() {
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
|
49 |
-
|
50 |
|
51 |
-
|
52 |
-
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Function helper
|
5 |
*
|
17 |
*/
|
18 |
function rpwe_tags_list() {
|
19 |
|
20 |
+
// Arguments
|
21 |
+
$args = array(
|
22 |
+
'number' => 99
|
23 |
+
);
|
24 |
|
25 |
+
// Allow dev to filter the arguments
|
26 |
+
$args = apply_filters('rpwe_tags_list_args', $args);
|
27 |
|
28 |
+
// Get the tags
|
29 |
+
$tags = get_terms('post_tag', $args);
|
30 |
|
31 |
+
return $tags;
|
32 |
}
|
33 |
|
34 |
/**
|
38 |
*/
|
39 |
function rpwe_cats_list() {
|
40 |
|
41 |
+
// Arguments
|
42 |
+
$args = array(
|
43 |
+
'number' => 99
|
44 |
+
);
|
45 |
|
46 |
+
// Allow dev to filter the arguments
|
47 |
+
$args = apply_filters('rpwe_cats_list_args', $args);
|
48 |
|
49 |
+
// Get the cats
|
50 |
+
$cats = get_terms('category', $args);
|
51 |
|
52 |
+
return $cats;
|
53 |
+
}
|
includes/resizer.php
CHANGED
@@ -24,9 +24,8 @@
|
|
24 |
* @return str|array
|
25 |
*/
|
26 |
|
27 |
-
if(!class_exists('Rpwe_Resize')) {
|
28 |
-
class Rpwe_Resize
|
29 |
-
{
|
30 |
/**
|
31 |
* The singleton instance
|
32 |
*/
|
@@ -35,18 +34,20 @@ if(!class_exists('Rpwe_Resize')) {
|
|
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 Rpwe_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 |
|
@@ -56,100 +57,98 @@ if(!class_exists('Rpwe_Resize')) {
|
|
56 |
/**
|
57 |
* Run, forest.
|
58 |
*/
|
59 |
-
public function process(
|
60 |
// Validate inputs.
|
61 |
-
if (
|
62 |
|
63 |
// Caipt'n, ready to hook.
|
64 |
-
if (
|
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
|
77 |
-
$upload_url = str_replace($http_prefix
|
|
|
|
|
78 |
}
|
79 |
-
|
80 |
-
$upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
|
81 |
-
}
|
82 |
-
|
83 |
|
84 |
// Check if $img_url is local.
|
85 |
-
if (
|
86 |
|
87 |
// Define path of image.
|
88 |
-
$rel_path = str_replace(
|
89 |
$img_path = $upload_dir . $rel_path;
|
90 |
|
91 |
// Check if img path exists, and is an image indeed.
|
92 |
-
if (
|
93 |
|
94 |
// Get image info.
|
95 |
-
$info = pathinfo(
|
96 |
$ext = $info['extension'];
|
97 |
-
list(
|
98 |
|
99 |
// Get image size after cropping.
|
100 |
-
$dims = image_resize_dimensions(
|
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 (
|
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(
|
113 |
$destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
|
114 |
|
115 |
-
if (
|
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 (
|
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(
|
127 |
|
128 |
-
if (
|
129 |
return false;
|
130 |
|
131 |
$resized_file = $editor->save();
|
132 |
|
133 |
-
if (
|
134 |
-
$resized_rel_path = str_replace(
|
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 (
|
145 |
|
146 |
// Return the output.
|
147 |
-
if (
|
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
|
@@ -162,31 +161,31 @@ if(!class_exists('Rpwe_Resize')) {
|
|
162 |
/**
|
163 |
* Callback to overwrite WP computing of thumbnail measures
|
164 |
*/
|
165 |
-
function rpwe_upscale(
|
166 |
-
if (
|
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 (
|
174 |
-
$new_w = intval(
|
175 |
}
|
176 |
|
177 |
-
if (
|
178 |
-
$new_h = intval(
|
179 |
}
|
180 |
|
181 |
-
$size_ratio = max(
|
182 |
|
183 |
-
$crop_w = round(
|
184 |
-
$crop_h = round(
|
185 |
|
186 |
-
$s_x = floor(
|
187 |
-
$s_y = floor(
|
188 |
|
189 |
-
return array(
|
190 |
}
|
191 |
}
|
192 |
}
|
@@ -195,15 +194,14 @@ if(!class_exists('Rpwe_Resize')) {
|
|
195 |
|
196 |
|
197 |
|
198 |
-
if(!function_exists('rpwe_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 rpwe_resize(
|
205 |
$rpwe_resize = Rpwe_Resize::getInstance();
|
206 |
-
return $rpwe_resize->process(
|
207 |
}
|
208 |
}
|
209 |
-
|
24 |
* @return str|array
|
25 |
*/
|
26 |
|
27 |
+
if (!class_exists('Rpwe_Resize')) {
|
28 |
+
class Rpwe_Resize {
|
|
|
29 |
/**
|
30 |
* The singleton instance
|
31 |
*/
|
34 |
/**
|
35 |
* No initialization allowed
|
36 |
*/
|
37 |
+
private function __construct() {
|
38 |
+
}
|
39 |
|
40 |
/**
|
41 |
* No cloning allowed
|
42 |
*/
|
43 |
+
private function __clone() {
|
44 |
+
}
|
45 |
|
46 |
/**
|
47 |
* For your custom default usage you may want to initialize an Rpwe_Resize object by yourself and then have own defaults
|
48 |
*/
|
49 |
static public function getInstance() {
|
50 |
+
if (self::$instance == null) {
|
51 |
self::$instance = new self;
|
52 |
}
|
53 |
|
57 |
/**
|
58 |
* Run, forest.
|
59 |
*/
|
60 |
+
public function process($url, $width = null, $height = null, $crop = null, $single = true, $upscale = false) {
|
61 |
// Validate inputs.
|
62 |
+
if (!$url || (!$width && !$height)) return false;
|
63 |
|
64 |
// Caipt'n, ready to hook.
|
65 |
+
if (true === $upscale) add_filter('image_resize_dimensions', array($this, 'rpwe_upscale'), 10, 6);
|
66 |
|
67 |
// Define upload path & dir.
|
68 |
$upload_info = wp_upload_dir();
|
69 |
$upload_dir = $upload_info['basedir'];
|
70 |
$upload_url = $upload_info['baseurl'];
|
71 |
+
|
72 |
$http_prefix = "http://";
|
73 |
$https_prefix = "https://";
|
74 |
+
|
75 |
+
/* if the $url scheme differs from $upload_url scheme, make them match
|
76 |
if the schemes differe, images don't show up. */
|
77 |
+
if (!strncmp($url, $https_prefix, strlen($https_prefix))) { //if url begins with https:// make $upload_url begin with https:// as well
|
78 |
+
$upload_url = str_replace($http_prefix, $https_prefix, $upload_url);
|
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 |
// Okay, leave the ship.
|
143 |
+
if (true === $upscale) remove_filter('image_resize_dimensions', array($this, 'rpwe_upscale'));
|
144 |
|
145 |
// Return the output.
|
146 |
+
if ($single) {
|
147 |
// str return.
|
148 |
$image = $img_url;
|
149 |
} else {
|
150 |
// array return.
|
151 |
+
$image = array(
|
152 |
0 => $img_url,
|
153 |
1 => $dst_w,
|
154 |
2 => $dst_h
|
161 |
/**
|
162 |
* Callback to overwrite WP computing of thumbnail measures
|
163 |
*/
|
164 |
+
function rpwe_upscale($default, $orig_w, $orig_h, $dest_w, $dest_h, $crop) {
|
165 |
+
if (!$crop) return null; // Let the wordpress default function handle this.
|
166 |
|
167 |
// Here is the point we allow to use larger image size than the original one.
|
168 |
$aspect_ratio = $orig_w / $orig_h;
|
169 |
$new_w = $dest_w;
|
170 |
$new_h = $dest_h;
|
171 |
|
172 |
+
if (!$new_w) {
|
173 |
+
$new_w = intval($new_h * $aspect_ratio);
|
174 |
}
|
175 |
|
176 |
+
if (!$new_h) {
|
177 |
+
$new_h = intval($new_w / $aspect_ratio);
|
178 |
}
|
179 |
|
180 |
+
$size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
|
181 |
|
182 |
+
$crop_w = round($new_w / $size_ratio);
|
183 |
+
$crop_h = round($new_h / $size_ratio);
|
184 |
|
185 |
+
$s_x = floor(($orig_w - $crop_w) / 2);
|
186 |
+
$s_y = floor(($orig_h - $crop_h) / 2);
|
187 |
|
188 |
+
return array(0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h);
|
189 |
}
|
190 |
}
|
191 |
}
|
194 |
|
195 |
|
196 |
|
197 |
+
if (!function_exists('rpwe_resize')) {
|
198 |
|
199 |
/**
|
200 |
* This is just a tiny wrapper function for the class above so that there is no
|
201 |
* need to change any code in your own WP themes. Usage is still the same :)
|
202 |
*/
|
203 |
+
function rpwe_resize($url, $width = null, $height = null, $crop = null, $single = true, $upscale = false) {
|
204 |
$rpwe_resize = Rpwe_Resize::getInstance();
|
205 |
+
return $rpwe_resize->process($url, $width, $height, $crop, $single, $upscale);
|
206 |
}
|
207 |
}
|
|
includes/shortcode.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Shortcode helper
|
4 |
*
|
@@ -14,12 +15,12 @@
|
|
14 |
*
|
15 |
* @since 0.9.4
|
16 |
*/
|
17 |
-
function rpwe_shortcode(
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
}
|
25 |
-
add_shortcode(
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Shortcode helper
|
5 |
*
|
15 |
*
|
16 |
* @since 0.9.4
|
17 |
*/
|
18 |
+
function rpwe_shortcode($atts, $content) {
|
19 |
+
if (isset($atts['cssid'])) {
|
20 |
+
$atts['cssID'] = $atts['cssid'];
|
21 |
+
unset($atts['cssid']);
|
22 |
+
}
|
23 |
+
$args = shortcode_atts(rpwe_get_default_args(), $atts);
|
24 |
+
return rpwe_get_recent_posts($args);
|
25 |
}
|
26 |
+
add_shortcode('rpwe', 'rpwe_shortcode');
|
languages/recent-posts-widget-extended-de_DE.mo
CHANGED
File without changes
|
languages/recent-posts-widget-extended-de_DE.po
CHANGED
File without changes
|
languages/recent-posts-widget-extended-fa_IR.mo
CHANGED
File without changes
|
languages/recent-posts-widget-extended-fa_IR.po
CHANGED
File without changes
|
languages/recent-posts-widget-extended-fr_FR.mo
CHANGED
File without changes
|
languages/recent-posts-widget-extended-fr_FR.po
CHANGED
File without changes
|
languages/recent-posts-widget-extended-pt_BR.mo
CHANGED
File without changes
|
languages/recent-posts-widget-extended-pt_BR.po
CHANGED
File without changes
|
languages/recent-posts-widget-extended.pot
CHANGED
@@ -1,252 +1,190 @@
|
|
1 |
-
# Copyright (C)
|
2 |
-
# This file is distributed under the same license as the
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: \n"
|
6 |
-
"Report-Msgid-Bugs-To: https://www.theme-junkie.com/contact/\n"
|
7 |
-
"POT-Creation-Date: 2017-10-19 07:13:19+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
-
"Content-Type: text/plain; charset=
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
11 |
-
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
|
12 |
-
"Last-Translator: Theme Junkie\n"
|
13 |
-
"Language-Team: Theme Junkie\n"
|
14 |
-
"X-Generator: grunt-wp-i18n1.0.0\n"
|
15 |
-
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
16 |
"X-Poedit-Basepath: ..\n"
|
17 |
-
"X-Poedit-
|
18 |
-
"X-Poedit-Country: UNITED STATES\n"
|
19 |
-
"X-Poedit-SourceCharset: utf-8\n"
|
20 |
"X-Poedit-SearchPath-0: .\n"
|
21 |
-
"X-Poedit-
|
22 |
-
"
|
23 |
-
"
|
24 |
-
"X-Textdomain-Support: yes\n"
|
25 |
|
26 |
-
#: classes/widget.php:
|
27 |
-
msgid ""
|
28 |
-
"An advanced widget that gives you total control over the output of your "
|
29 |
-
"site’s most recent Posts."
|
30 |
msgstr ""
|
31 |
|
32 |
-
#: classes/widget.php:
|
33 |
msgid "Recent Posts Extended"
|
34 |
msgstr ""
|
35 |
|
36 |
-
#: includes/form.php:
|
37 |
msgid "Title"
|
38 |
msgstr ""
|
39 |
|
40 |
-
#: includes/form.php:
|
41 |
msgid "Title URL"
|
42 |
msgstr ""
|
43 |
|
44 |
-
#: includes/form.php:
|
45 |
msgid "CSS ID"
|
46 |
msgstr ""
|
47 |
|
48 |
-
#: includes/form.php:
|
49 |
msgid "CSS Class"
|
50 |
msgstr ""
|
51 |
|
52 |
-
#: includes/form.php:
|
53 |
msgid "HTML or text before the recent posts"
|
54 |
msgstr ""
|
55 |
|
56 |
-
#: includes/form.php:
|
57 |
msgid "HTML or text after the recent posts"
|
58 |
msgstr ""
|
59 |
|
60 |
-
#: includes/form.php:
|
61 |
msgid "Ignore sticky posts"
|
62 |
msgstr ""
|
63 |
|
64 |
-
#: includes/form.php:
|
65 |
msgid "Exclude current post"
|
66 |
msgstr ""
|
67 |
|
68 |
-
#: includes/form.php:
|
69 |
msgid "Post Types"
|
70 |
msgstr ""
|
71 |
|
72 |
-
#: includes/form.php:
|
73 |
msgid "Post Status"
|
74 |
msgstr ""
|
75 |
|
76 |
-
#: includes/form.php:
|
77 |
msgid "Order"
|
78 |
msgstr ""
|
79 |
|
80 |
-
#: includes/form.php:
|
81 |
-
msgid "Descending"
|
82 |
-
msgstr ""
|
83 |
-
|
84 |
-
#: includes/form.php:108
|
85 |
-
msgid "Ascending"
|
86 |
-
msgstr ""
|
87 |
-
|
88 |
-
#: includes/form.php:114
|
89 |
msgid "Orderby"
|
90 |
msgstr ""
|
91 |
|
92 |
-
#: includes/form.php:
|
93 |
-
msgid "ID"
|
94 |
-
msgstr ""
|
95 |
-
|
96 |
-
#: includes/form.php:118
|
97 |
-
msgid "Author"
|
98 |
-
msgstr ""
|
99 |
-
|
100 |
-
#: includes/form.php:120
|
101 |
-
msgid "Date"
|
102 |
-
msgstr ""
|
103 |
-
|
104 |
-
#: includes/form.php:121
|
105 |
-
msgid "Modified"
|
106 |
-
msgstr ""
|
107 |
-
|
108 |
-
#: includes/form.php:122
|
109 |
-
msgid "Random"
|
110 |
-
msgstr ""
|
111 |
-
|
112 |
-
#: includes/form.php:123
|
113 |
-
msgid "Comment Count"
|
114 |
-
msgstr ""
|
115 |
-
|
116 |
-
#: includes/form.php:124
|
117 |
-
msgid "Menu Order"
|
118 |
-
msgstr ""
|
119 |
-
|
120 |
-
#: includes/form.php:130
|
121 |
msgid "Limit to Category"
|
122 |
msgstr ""
|
123 |
|
124 |
-
#: includes/form.php:
|
125 |
msgid "Limit to Tag"
|
126 |
msgstr ""
|
127 |
|
128 |
-
#: includes/form.php:
|
129 |
msgid "Limit to Taxonomy"
|
130 |
msgstr ""
|
131 |
|
132 |
-
#: includes/form.php:
|
133 |
-
msgid "Ex: category=1,2,4&post_tag=6,12"
|
134 |
-
msgstr ""
|
135 |
-
|
136 |
-
#: includes/form.php:166
|
137 |
-
msgid "Available: "
|
138 |
-
msgstr ""
|
139 |
-
|
140 |
-
#: includes/form.php:175
|
141 |
msgid "Number of posts to show"
|
142 |
msgstr ""
|
143 |
|
144 |
-
#: includes/form.php:
|
145 |
msgid "Offset"
|
146 |
msgstr ""
|
147 |
|
148 |
-
#: includes/form.php:
|
149 |
msgid "The number of posts to skip"
|
150 |
msgstr ""
|
151 |
|
152 |
-
#: includes/form.php:
|
153 |
msgid "Display Thumbnail"
|
154 |
msgstr ""
|
155 |
|
156 |
-
#: includes/form.php:
|
157 |
msgid "Thumbnail (height,width,align)"
|
158 |
msgstr ""
|
159 |
|
160 |
-
#: includes/form.php:
|
161 |
msgid "Left"
|
162 |
msgstr ""
|
163 |
|
164 |
-
#: includes/form.php:
|
165 |
msgid "Right"
|
166 |
msgstr ""
|
167 |
|
168 |
-
#: includes/form.php:
|
169 |
msgid "Center"
|
170 |
msgstr ""
|
171 |
|
172 |
-
#: includes/form.php:
|
173 |
msgid "Default Thumbnail"
|
174 |
msgstr ""
|
175 |
|
176 |
-
#: includes/form.php:
|
177 |
msgid "Leave it blank to disable."
|
178 |
msgstr ""
|
179 |
|
180 |
-
#: includes/form.php:
|
181 |
msgid "Display Excerpt"
|
182 |
msgstr ""
|
183 |
|
184 |
-
#: includes/form.php:
|
185 |
msgid "Excerpt Length"
|
186 |
msgstr ""
|
187 |
|
188 |
-
#: includes/form.php:
|
189 |
msgid "Display Readmore"
|
190 |
msgstr ""
|
191 |
|
192 |
-
#: includes/form.php:
|
193 |
msgid "Readmore Text"
|
194 |
msgstr ""
|
195 |
|
196 |
-
#: includes/form.php:
|
197 |
msgid "Display Comment Count"
|
198 |
msgstr ""
|
199 |
|
200 |
-
#: includes/form.php:
|
201 |
msgid "Display Date"
|
202 |
msgstr ""
|
203 |
|
204 |
-
#: includes/form.php:
|
205 |
msgid "Display Modification Date"
|
206 |
msgstr ""
|
207 |
|
208 |
-
#: includes/form.php:
|
209 |
msgid "Use Relative Date. eg: 5 days ago"
|
210 |
msgstr ""
|
211 |
|
212 |
-
#: includes/form.php:
|
213 |
msgid "Use Default Styles"
|
214 |
msgstr ""
|
215 |
|
216 |
-
#: includes/form.php:
|
217 |
msgid "Custom CSS"
|
218 |
msgstr ""
|
219 |
|
220 |
-
#: includes/form.php:
|
221 |
-
msgid ""
|
222 |
-
"If you turn off the default styles, you can use these css code to customize "
|
223 |
-
"the recent posts style."
|
224 |
-
msgstr ""
|
225 |
-
|
226 |
-
#: includes/functions.php:22
|
227 |
-
msgid "Recent Posts"
|
228 |
msgstr ""
|
229 |
|
230 |
-
#: includes/functions.php:
|
231 |
msgid "Read More »"
|
232 |
msgstr ""
|
233 |
|
234 |
-
#: includes/functions.php:
|
235 |
msgid "Permalink to %s"
|
236 |
msgstr ""
|
237 |
|
238 |
-
#: includes/functions.php:
|
239 |
msgid "%s ago"
|
240 |
msgstr ""
|
241 |
|
242 |
-
#: includes/functions.php:
|
243 |
-
msgid "
|
244 |
msgstr ""
|
245 |
|
246 |
-
#: includes/functions.php:
|
247 |
msgid "%s Comments"
|
248 |
msgstr ""
|
249 |
|
250 |
-
#: includes/functions.php:
|
251 |
-
msgid "
|
252 |
-
msgstr ""
|
1 |
+
# Copyright (C) 2021 Recent Posts Widget Extended
|
2 |
+
# This file is distributed under the same license as the Recent Posts Widget Extended package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Recent Posts Widget Extended\n"
|
|
|
|
|
6 |
"MIME-Version: 1.0\n"
|
7 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
"Content-Transfer-Encoding: 8bit\n"
|
|
|
|
|
|
|
|
|
|
|
9 |
"X-Poedit-Basepath: ..\n"
|
10 |
+
"X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
|
|
|
|
|
11 |
"X-Poedit-SearchPath-0: .\n"
|
12 |
+
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
13 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
14 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
|
|
15 |
|
16 |
+
#: classes/widget.php:25
|
17 |
+
msgid "An advanced widget that gives you total control over the output of your site’s most recent Posts."
|
|
|
|
|
18 |
msgstr ""
|
19 |
|
20 |
+
#: classes/widget.php:37
|
21 |
msgid "Recent Posts Extended"
|
22 |
msgstr ""
|
23 |
|
24 |
+
#: includes/form.php:18
|
25 |
msgid "Title"
|
26 |
msgstr ""
|
27 |
|
28 |
+
#: includes/form.php:25
|
29 |
msgid "Title URL"
|
30 |
msgstr ""
|
31 |
|
32 |
+
#: includes/form.php:32
|
33 |
msgid "CSS ID"
|
34 |
msgstr ""
|
35 |
|
36 |
+
#: includes/form.php:39
|
37 |
msgid "CSS Class"
|
38 |
msgstr ""
|
39 |
|
40 |
+
#: includes/form.php:46
|
41 |
msgid "HTML or text before the recent posts"
|
42 |
msgstr ""
|
43 |
|
44 |
+
#: includes/form.php:53
|
45 |
msgid "HTML or text after the recent posts"
|
46 |
msgstr ""
|
47 |
|
48 |
+
#: includes/form.php:65
|
49 |
msgid "Ignore sticky posts"
|
50 |
msgstr ""
|
51 |
|
52 |
+
#: includes/form.php:72
|
53 |
msgid "Exclude current post"
|
54 |
msgstr ""
|
55 |
|
56 |
+
#: includes/form.php:78
|
57 |
msgid "Post Types"
|
58 |
msgstr ""
|
59 |
|
60 |
+
#: includes/form.php:94
|
61 |
msgid "Post Status"
|
62 |
msgstr ""
|
63 |
|
64 |
+
#: includes/form.php:105
|
65 |
msgid "Order"
|
66 |
msgstr ""
|
67 |
|
68 |
+
#: includes/form.php:115
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
msgid "Orderby"
|
70 |
msgstr ""
|
71 |
|
72 |
+
#: includes/form.php:131
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
msgid "Limit to Category"
|
74 |
msgstr ""
|
75 |
|
76 |
+
#: includes/form.php:147
|
77 |
msgid "Limit to Tag"
|
78 |
msgstr ""
|
79 |
|
80 |
+
#: includes/form.php:163
|
81 |
msgid "Limit to Taxonomy"
|
82 |
msgstr ""
|
83 |
|
84 |
+
#: includes/form.php:177
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
msgid "Number of posts to show"
|
86 |
msgstr ""
|
87 |
|
88 |
+
#: includes/form.php:184
|
89 |
msgid "Offset"
|
90 |
msgstr ""
|
91 |
|
92 |
+
#: includes/form.php:187
|
93 |
msgid "The number of posts to skip"
|
94 |
msgstr ""
|
95 |
|
96 |
+
#: includes/form.php:195
|
97 |
msgid "Display Thumbnail"
|
98 |
msgstr ""
|
99 |
|
100 |
+
#: includes/form.php:201
|
101 |
msgid "Thumbnail (height,width,align)"
|
102 |
msgstr ""
|
103 |
|
104 |
+
#: includes/form.php:206
|
105 |
msgid "Left"
|
106 |
msgstr ""
|
107 |
|
108 |
+
#: includes/form.php:207
|
109 |
msgid "Right"
|
110 |
msgstr ""
|
111 |
|
112 |
+
#: includes/form.php:208
|
113 |
msgid "Center"
|
114 |
msgstr ""
|
115 |
|
116 |
+
#: includes/form.php:214
|
117 |
msgid "Default Thumbnail"
|
118 |
msgstr ""
|
119 |
|
120 |
+
#: includes/form.php:217
|
121 |
msgid "Leave it blank to disable."
|
122 |
msgstr ""
|
123 |
|
124 |
+
#: includes/form.php:225
|
125 |
msgid "Display Excerpt"
|
126 |
msgstr ""
|
127 |
|
128 |
+
#: includes/form.php:231
|
129 |
msgid "Excerpt Length"
|
130 |
msgstr ""
|
131 |
|
132 |
+
#: includes/form.php:239
|
133 |
msgid "Display Readmore"
|
134 |
msgstr ""
|
135 |
|
136 |
+
#: includes/form.php:245
|
137 |
msgid "Readmore Text"
|
138 |
msgstr ""
|
139 |
|
140 |
+
#: includes/form.php:253
|
141 |
msgid "Display Comment Count"
|
142 |
msgstr ""
|
143 |
|
144 |
+
#: includes/form.php:260
|
145 |
msgid "Display Date"
|
146 |
msgstr ""
|
147 |
|
148 |
+
#: includes/form.php:267
|
149 |
msgid "Display Modification Date"
|
150 |
msgstr ""
|
151 |
|
152 |
+
#: includes/form.php:274
|
153 |
msgid "Use Relative Date. eg: 5 days ago"
|
154 |
msgstr ""
|
155 |
|
156 |
+
#: includes/form.php:286
|
157 |
msgid "Use Default Styles"
|
158 |
msgstr ""
|
159 |
|
160 |
+
#: includes/form.php:292
|
161 |
msgid "Custom CSS"
|
162 |
msgstr ""
|
163 |
|
164 |
+
#: includes/form.php:295
|
165 |
+
msgid "If you turn off the default styles, you can use these css code to customize the recent posts style."
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
msgstr ""
|
167 |
|
168 |
+
#: includes/functions.php:49
|
169 |
msgid "Read More »"
|
170 |
msgstr ""
|
171 |
|
172 |
+
#: includes/functions.php:172
|
173 |
msgid "Permalink to %s"
|
174 |
msgstr ""
|
175 |
|
176 |
+
#: includes/functions.php:183, includes/functions.php:177
|
177 |
msgid "%s ago"
|
178 |
msgstr ""
|
179 |
|
180 |
+
#: includes/functions.php:194
|
181 |
+
msgid "1 Comment"
|
182 |
msgstr ""
|
183 |
|
184 |
+
#: includes/functions.php:192
|
185 |
msgid "%s Comments"
|
186 |
msgstr ""
|
187 |
|
188 |
+
#: includes/functions.php:190
|
189 |
+
msgid "No Comments"
|
190 |
+
msgstr ""
|
readme.txt
CHANGED
@@ -1,9 +1,11 @@
|
|
1 |
=== Recent Posts Widget Extended ===
|
2 |
-
Contributors:
|
|
|
3 |
Tags: recent posts, random posts, popular posts, thumbnails, widget, widgets, sidebar, excerpt, category, post tag, taxonomy, post type, post status, shortcode, multiple widgets
|
4 |
-
Requires at least: 4.
|
5 |
-
Tested up to:
|
6 |
-
|
|
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -11,15 +13,15 @@ Provides flexible and advanced recent posts. Display it via shortcode or widget
|
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
This plugin will enable a custom, flexible and super advanced recent posts, you can display it via shortcode or widget. Allows you to display a list of the most recent posts with thumbnail, excerpt and post date, also you can display it from all or specific or multiple taxonomy, post type and much more!
|
15 |
|
16 |
= Features Include =
|
17 |
|
18 |
* Taxonomy support!
|
19 |
* Post status option.
|
20 |
* Custom html or text before and/or after recent posts.
|
21 |
-
* Available filter for dev.
|
22 |
-
* Shortcode feature.
|
23 |
* Better image cropping.
|
24 |
* Allow you to set title url.
|
25 |
* Display by date, comment count or random.
|
@@ -36,20 +38,11 @@ This plugin will enable a custom, flexible and super advanced recent posts, you
|
|
36 |
* Custom CSS.
|
37 |
* Multiple widgets.
|
38 |
|
39 |
-
=
|
40 |
|
41 |
-
*
|
42 |
-
*
|
43 |
-
*
|
44 |
-
* [Contribute to your language](https://github.com/themejunkie/recent-posts-widget-extended/issues)
|
45 |
-
|
46 |
-
= Support =
|
47 |
-
|
48 |
-
* [Forum support](http://wordpress.org/support/plugin/recent-posts-widget-extended).
|
49 |
-
* [Rate/Review the plugin](http://wordpress.org/support/view/plugin-reviews/recent-posts-widget-extended).
|
50 |
-
* [Submit translation](https://github.com/themejunkie/recent-posts-widget-extended/issues).
|
51 |
-
|
52 |
-
> Developed by [Theme Junkie](http://www.theme-junkie.com/)
|
53 |
|
54 |
== Installation ==
|
55 |
|
@@ -237,47 +230,8 @@ after=""
|
|
237 |
|
238 |
== Changelog ==
|
239 |
|
240 |
-
= 0.
|
241 |
-
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
- Bump **Requires at least** to version 4.5
|
246 |
-
- Support selective refresh
|
247 |
-
- Updated widget sanitization
|
248 |
-
|
249 |
-
= 0.9.9.4 - Nov 09, 2015 =
|
250 |
-
- Sanitize `before` and `after` element for better security
|
251 |
-
|
252 |
-
= 0.9.9.3 - 19/09/2015 =
|
253 |
-
- Change text-domain to matches the plugin slug
|
254 |
-
- **Add:** Exclude post option
|
255 |
-
|
256 |
-
= 0.9.9.2 - 13/08/2015 =
|
257 |
-
- **Add:** Brazilian portuguese translation. Props [Gil Barbara](https://github.com/gilbarbara)
|
258 |
-
- **Add:** Option to show modification date. Props [kurt-hectic](https://github.com/kurt-hectic)
|
259 |
-
- **Add:** Option to show comment count. Props [Oliver Larsen](https://github.com/CandyFace)
|
260 |
-
- **Improve:** Add validation to the `Order` and `Orderby` option before saving the widget.
|
261 |
-
|
262 |
-
= 0.9.9.1 - 12/07/2015 =
|
263 |
-
- Prepare to support WordPress 4.3
|
264 |
-
- **Update:** Limit the number of `tags` and `categories` displayed in the widget
|
265 |
-
|
266 |
-
= 0.9.9 - 29/11/2014 =
|
267 |
-
- **Fix:** for "cssID" attribute in shortcodes. Props [Ikart](https://github.com/lkart)
|
268 |
-
- **Fix:** Thumbnail fallback uses `get_the_post_thumbnail`
|
269 |
-
- **Add:** `rpwe-img` to the thumbnail.
|
270 |
-
- **Add:** `css class` option.
|
271 |
-
- **Improve:** Move `use styles default` option to above the custom css. I'm sorry for the incosistency.
|
272 |
-
- **Update:** Language
|
273 |
-
|
274 |
-
= 0.9.8 - 26/11/2014 =
|
275 |
-
* **Fix:** Compatibility issue with `Get The Image` plugin/extension.
|
276 |
-
* **Fix:** Issue with `html or text before and after recent posts`, now it allow all HTML tags.
|
277 |
-
|
278 |
-
= 0.9.7 - 13/09/2014 =
|
279 |
-
* **Add:** Relative date option `eg: 4 days ago`. Props [George Venios](https://github.com/veniosg)
|
280 |
-
* **Add:** [Featured Video Plus](http://wordpress.org/plugins/featured-video-plus/) plugin support.
|
281 |
-
* **Add:** Hide widget if no posts exist.
|
282 |
-
* **Add:** Fallback to the image attachment if no image url exist in the resizer script.
|
283 |
-
* **Fix:** Compatibility issue if the user theme use the same code library(Aqua Resizer) and causing blank screen.
|
1 |
=== Recent Posts Widget Extended ===
|
2 |
+
Contributors: idenovasi, satrya
|
3 |
+
Donate link: https://paypal.me/satrya
|
4 |
Tags: recent posts, random posts, popular posts, thumbnails, widget, widgets, sidebar, excerpt, category, post tag, taxonomy, post type, post status, shortcode, multiple widgets
|
5 |
+
Requires at least: 4.8
|
6 |
+
Tested up to: 5.6
|
7 |
+
Requires PHP: 7.2
|
8 |
+
Stable tag: 1.0.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
+
This plugin will enable a custom, flexible and super [advanced recent posts](https://idenovasi.com/projects/recent-posts-widget-extended/), you can display it via shortcode or widget. Allows you to display a list of the most recent posts with thumbnail, excerpt and post date, also you can display it from all or specific or multiple taxonomy, post type and much more!
|
17 |
|
18 |
= Features Include =
|
19 |
|
20 |
* Taxonomy support!
|
21 |
* Post status option.
|
22 |
* Custom html or text before and/or after recent posts.
|
23 |
+
* Available filter for dev.
|
24 |
+
* Shortcode feature.
|
25 |
* Better image cropping.
|
26 |
* Allow you to set title url.
|
27 |
* Display by date, comment count or random.
|
38 |
* Custom CSS.
|
39 |
* Multiple widgets.
|
40 |
|
41 |
+
= Support this project =
|
42 |
|
43 |
+
* [Translate to your language](https://translate.wordpress.org/projects/wp-plugins/recent-posts-widget-extended/).
|
44 |
+
* Contribute on [Github](https://github.com/satrya/recent-posts-widget-extended).
|
45 |
+
* [Donate](https://paypal.me/satrya).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
== Installation ==
|
48 |
|
230 |
|
231 |
== Changelog ==
|
232 |
|
233 |
+
= 1.0.0 - Feb 17, 2021 =
|
234 |
+
- This is just a maintenance update after a couple years with no update. Thank you for still using this plugin 🥳
|
235 |
+
|
236 |
+
|
237 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rpwe.php
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Plugin Name: Recent Posts Widget Extended
|
4 |
-
* Plugin URI: https://
|
5 |
* Description: Enables advanced widget that gives you total control over the output of your site’s most recent Posts.
|
6 |
-
* Version: 0.
|
7 |
* Author: Satrya
|
8 |
-
* Author URI: https://
|
9 |
-
* Author Email:
|
10 |
* Text Domain: recent-posts-widget-extended
|
11 |
* Domain Path: /languages
|
12 |
*
|
@@ -28,111 +29,108 @@
|
|
28 |
*/
|
29 |
|
30 |
// Exit if accessed directly
|
31 |
-
if (
|
32 |
|
33 |
class RPW_Extended {
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
add_image_size( 'rpwe-thumbnail', 45, 45, true );
|
134 |
-
}
|
135 |
-
|
136 |
}
|
137 |
|
138 |
-
new RPW_Extended;
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Plugin Name: Recent Posts Widget Extended
|
5 |
+
* Plugin URI: https://idenovasi.com/projects/recent-posts-widget-extended/
|
6 |
* Description: Enables advanced widget that gives you total control over the output of your site’s most recent Posts.
|
7 |
+
* Version: 1.0.0
|
8 |
* Author: Satrya
|
9 |
+
* Author URI: https://idenovasi.com/
|
10 |
+
* Author Email: satrya@idenovasi.com
|
11 |
* Text Domain: recent-posts-widget-extended
|
12 |
* Domain Path: /languages
|
13 |
*
|
29 |
*/
|
30 |
|
31 |
// Exit if accessed directly
|
32 |
+
if (!defined('ABSPATH')) exit;
|
33 |
|
34 |
class RPW_Extended {
|
35 |
|
36 |
+
/**
|
37 |
+
* PHP5 constructor method.
|
38 |
+
*
|
39 |
+
* @since 0.1
|
40 |
+
*/
|
41 |
+
public function __construct() {
|
42 |
+
|
43 |
+
// Set the constants needed by the plugin.
|
44 |
+
add_action('plugins_loaded', array(&$this, 'constants'), 1);
|
45 |
+
|
46 |
+
// Internationalize the text strings used.
|
47 |
+
add_action('plugins_loaded', array(&$this, 'i18n'), 2);
|
48 |
+
|
49 |
+
// Load the functions files.
|
50 |
+
add_action('plugins_loaded', array(&$this, 'includes'), 3);
|
51 |
+
|
52 |
+
// Load the admin style.
|
53 |
+
add_action('admin_enqueue_scripts', array(&$this, 'admin_style'));
|
54 |
+
|
55 |
+
// Register widget.
|
56 |
+
add_action('widgets_init', array(&$this, 'register_widget'));
|
57 |
+
|
58 |
+
// Register new image size.
|
59 |
+
add_action('init', array(&$this, 'register_image_size'));
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Defines constants used by the plugin.
|
64 |
+
*
|
65 |
+
* @since 0.1
|
66 |
+
*/
|
67 |
+
public function constants() {
|
68 |
+
|
69 |
+
// Set constant path to the plugin directory.
|
70 |
+
define('RPWE_DIR', trailingslashit(plugin_dir_path(__FILE__)));
|
71 |
+
|
72 |
+
// Set the constant path to the plugin directory URI.
|
73 |
+
define('RPWE_URI', trailingslashit(plugin_dir_url(__FILE__)));
|
74 |
+
|
75 |
+
// Set the constant path to the includes directory.
|
76 |
+
define('RPWE_INCLUDES', RPWE_DIR . trailingslashit('includes'));
|
77 |
+
|
78 |
+
// Set the constant path to the includes directory.
|
79 |
+
define('RPWE_CLASS', RPWE_DIR . trailingslashit('classes'));
|
80 |
+
|
81 |
+
// Set the constant path to the assets directory.
|
82 |
+
define('RPWE_ASSETS', RPWE_URI . trailingslashit('assets'));
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Loads the translation files.
|
87 |
+
*
|
88 |
+
* @since 0.1
|
89 |
+
*/
|
90 |
+
public function i18n() {
|
91 |
+
load_plugin_textdomain('recent-posts-widget-extended', false, dirname(plugin_basename(__FILE__)) . '/languages/');
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Loads the initial files needed by the plugin.
|
96 |
+
*
|
97 |
+
* @since 0.1
|
98 |
+
*/
|
99 |
+
public function includes() {
|
100 |
+
require_once(RPWE_INCLUDES . 'resizer.php');
|
101 |
+
require_once(RPWE_INCLUDES . 'functions.php');
|
102 |
+
require_once(RPWE_INCLUDES . 'shortcode.php');
|
103 |
+
require_once(RPWE_INCLUDES . 'helpers.php');
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Register custom style for the widget settings.
|
108 |
+
*
|
109 |
+
* @since 0.8
|
110 |
+
*/
|
111 |
+
public function admin_style() {
|
112 |
+
// Loads the widget style.
|
113 |
+
wp_enqueue_style('rpwe-admin-style', trailingslashit(RPWE_ASSETS) . 'css/rpwe-admin.css', null, null);
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Register the widget.
|
118 |
+
*
|
119 |
+
* @since 0.9.1
|
120 |
+
*/
|
121 |
+
public function register_widget() {
|
122 |
+
require_once(RPWE_CLASS . 'widget.php');
|
123 |
+
register_widget('Recent_Posts_Widget_Extended');
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Register new image size.
|
128 |
+
*
|
129 |
+
* @since 0.9.4
|
130 |
+
*/
|
131 |
+
function register_image_size() {
|
132 |
+
add_image_size('rpwe-thumbnail', 45, 45, true);
|
133 |
+
}
|
|
|
|
|
|
|
134 |
}
|
135 |
|
136 |
+
new RPW_Extended;
|
screenshot-1.png
CHANGED
File without changes
|