Recent Posts Widget Extended - Version 1.1.0

Version Description

Download this release

Release Info

Developer idenovasi
Plugin Icon 128x128 Recent Posts Widget Extended
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.0 to 1.1.0

assets/css/rpwe-admin.css CHANGED
@@ -1,48 +1,18 @@
1
- .widgets-php .rpwe-columns-3 {
2
- overflow: hidden;
3
- float: left;
4
- width: 31%;
5
- margin-right: 3.5%;
6
- }
7
-
8
- .widgets-php .rpwe-columns-3 select.widefat {
9
- width: 98.5%;
10
- }
11
-
12
- .widgets-php .rpwe-column-last {
13
- float: right;
14
- margin-right: 0;
15
- }
16
-
17
- .widgets-php .rpwe-columns-3 label {
18
- font-size: 11px;
19
- }
20
-
21
- .widgets-php .rpwe-columns-3 p small {
22
- color: #777;
23
- font-style: italic;
24
- }
25
-
26
- .small-input {
27
- width: 30%;
28
- }
29
-
30
- .rpwe-block {
31
- display: block;
32
- }
33
-
34
- .rpwe-multiple-check-form {
35
- margin: 1em 0;
36
- }
37
-
38
- .rpwe-multiple-check-form ul {
39
- border: 1px solid #eee;
40
- padding: 10px;
41
- max-height: 110px;
42
- overflow: auto;
43
- margin-top: 0;
44
- }
45
-
46
- .rpwe-multiple-check-form ul li:last-child {
47
- margin-bottom: 0;
48
- }
1
+ .rpwe-options small {
2
+ font-size: 0.7em;
3
+ color: #999;
4
+ }
5
+
6
+ .rpwe-info {
7
+ font-size: 0.8em;
8
+ line-height: 1.4;
9
+ }
10
+
11
+ .rpwe-options .small-input {
12
+ width: 32% !important;
13
+ display: inline-block !important;
14
+ }
15
+
16
+ .rpwe-block {
17
+ display: block;
18
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/widget.php CHANGED
@@ -1,163 +1,157 @@
1
- <?php
2
-
3
- /**
4
- * The custom recent posts widget.
5
- * This widget gives total control over the output to the user.
6
- *
7
- * @package Recent_Posts_Widget_Extended
8
- * @since 0.1
9
- * @author Satrya
10
- * @copyright Copyright (c) 2014, Satrya
11
- * @license http://www.gnu.org/licenses/gpl-2.0.html
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
- }
1
+ <?php
2
+
3
+ /**
4
+ * The custom recent posts widget.
5
+ * This widget gives total control over the output to the user.
6
+ */
7
+ class Recent_Posts_Widget_Extended extends WP_Widget {
8
+
9
+ /**
10
+ * Sets up the widgets.
11
+ *
12
+ * @since 0.1
13
+ */
14
+ public function __construct() {
15
+
16
+ /* Set up the widget options. */
17
+ $widget_options = array(
18
+ 'classname' => 'rpwe_widget recent-posts-extended',
19
+ 'description' => __('An advanced widget that gives you total control over the output of your site’s most recent Posts.', 'recent-posts-widget-extended'),
20
+ 'customize_selective_refresh' => true
21
+ );
22
+
23
+ $control_options = array(
24
+ 'width' => 750,
25
+ 'height' => 350
26
+ );
27
+
28
+ /* Create the widget. */
29
+ parent::__construct(
30
+ 'rpwe_widget', // $this->id_base
31
+ __('Recent Posts Extended', 'recent-posts-widget-extended'), // $this->name
32
+ $widget_options, // $this->widget_options
33
+ $control_options // $this->control_options
34
+ );
35
+
36
+ $this->alt_option_name = 'rpwe_widget';
37
+ }
38
+
39
+ /**
40
+ * Outputs the widget based on the arguments input through the widget controls.
41
+ *
42
+ * @since 0.1
43
+ */
44
+ public function widget($args, $instance) {
45
+ extract($args);
46
+
47
+ $recent = rpwe_get_recent_posts($instance);
48
+
49
+ if ($recent) {
50
+
51
+ // Output the theme's $before_widget wrapper.
52
+ echo $before_widget;
53
+
54
+ // If both title and title url is not empty, display it.
55
+ if (!empty($instance['title_url']) && !empty($instance['title'])) {
56
+ 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;
57
+
58
+ // If the title not empty, display it.
59
+ } elseif (!empty($instance['title'])) {
60
+ echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
61
+ }
62
+
63
+ // Get the recent posts query.
64
+ echo $recent;
65
+
66
+ // Close the theme's widget wrapper.
67
+ echo $after_widget;
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Updates the widget control options for the particular instance of the widget.
73
+ *
74
+ * @since 0.1
75
+ */
76
+ public function update($new_instance, $old_instance) {
77
+
78
+ // Validate post_type submissions
79
+ $name = get_post_types(array('public' => true), 'names');
80
+ $types = array();
81
+ foreach ($new_instance['post_type'] as $type) {
82
+ if (in_array($type, $name)) {
83
+ $types[] = $type;
84
+ }
85
+ }
86
+ if (empty($types)) {
87
+ $types[] = 'post';
88
+ }
89
+
90
+ $instance = $old_instance;
91
+ $instance['title'] = sanitize_text_field($new_instance['title']);
92
+ $instance['title_url'] = esc_url_raw($new_instance['title_url']);
93
+
94
+ $instance['ignore_sticky'] = isset($new_instance['ignore_sticky']) ? (bool) $new_instance['ignore_sticky'] : 0;
95
+ $instance['exclude_current'] = isset($new_instance['exclude_current']) ? (bool) $new_instance['exclude_current'] : 0;
96
+ $instance['limit'] = intval($new_instance['limit']);
97
+ $instance['offset'] = intval($new_instance['offset']);
98
+ $instance['order'] = stripslashes($new_instance['order']);
99
+ $instance['orderby'] = stripslashes($new_instance['orderby']);
100
+ $instance['post_type'] = $types;
101
+ $instance['post_status'] = stripslashes($new_instance['post_status']);
102
+ $instance['cat'] = $new_instance['cat'];
103
+ $instance['tag'] = $new_instance['tag'];
104
+ $instance['taxonomy'] = esc_attr($new_instance['taxonomy']);
105
+
106
+ $instance['excerpt'] = isset($new_instance['excerpt']) ? (bool) $new_instance['excerpt'] : false;
107
+ $instance['length'] = intval($new_instance['length']);
108
+ $instance['date'] = isset($new_instance['date']) ? (bool) $new_instance['date'] : false;
109
+ $instance['date_relative'] = isset($new_instance['date_relative']) ? (bool) $new_instance['date_relative'] : false;
110
+ $instance['date_modified'] = isset($new_instance['date_modified']) ? (bool) $new_instance['date_modified'] : false;
111
+ $instance['readmore'] = isset($new_instance['readmore']) ? (bool) $new_instance['readmore'] : false;
112
+ $instance['readmore_text'] = sanitize_text_field($new_instance['readmore_text']);
113
+ $instance['comment_count'] = isset($new_instance['comment_count']) ? (bool) $new_instance['comment_count'] : false;
114
+
115
+ $instance['thumb'] = isset($new_instance['thumb']) ? (bool) $new_instance['thumb'] : false;
116
+ $instance['thumb_height'] = intval($new_instance['thumb_height']);
117
+ $instance['thumb_width'] = intval($new_instance['thumb_width']);
118
+ $instance['thumb_default'] = esc_url_raw($new_instance['thumb_default']);
119
+ $instance['thumb_align'] = esc_attr($new_instance['thumb_align']);
120
+
121
+ $instance['styles_default'] = isset($new_instance['styles_default']) ? (bool) $new_instance['styles_default'] : false;
122
+ $instance['cssID'] = sanitize_html_class($new_instance['cssID']);
123
+ $instance['css_class'] = sanitize_html_class($new_instance['css_class']);
124
+ $instance['css'] = $new_instance['css'];
125
+
126
+ if (current_user_can('unfiltered_html')) {
127
+ $instance['before'] = $new_instance['before'];
128
+ } else {
129
+ $instance['before'] = wp_kses_post($new_instance['before']);
130
+ }
131
+
132
+ if (current_user_can('unfiltered_html')) {
133
+ $instance['after'] = $new_instance['after'];
134
+ } else {
135
+ $instance['after'] = wp_kses_post($new_instance['after']);
136
+ }
137
+
138
+ return $instance;
139
+ }
140
+
141
+ /**
142
+ * Displays the widget control options in the Widgets admin screen.
143
+ *
144
+ * @since 0.1
145
+ */
146
+ public function form($instance) {
147
+
148
+ // Merge the user-selected arguments with the defaults.
149
+ $instance = wp_parse_args((array) $instance, rpwe_get_default_args());
150
+
151
+ // Extract the array to allow easy use of variables.
152
+ extract($instance);
153
+
154
+ // Loads the widget form.
155
+ include(RPWE_INCLUDES . 'form.php');
156
+ }
157
+ }
 
 
 
 
 
 
includes/form.php CHANGED
@@ -1,296 +1,279 @@
1
- <?php
2
-
3
- /**
4
- * Widget forms.
5
- *
6
- * @package Recent_Posts_Widget_Extended
7
- * @since 0.9.4
8
- * @author Satrya
9
- * @copyright Copyright (c) 2014, Satrya
10
- * @license http://www.gnu.org/licenses/gpl-2.0.html
11
- */
12
- ?>
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&amp;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>
1
+ <?php
2
+
3
+ /**
4
+ * Widget forms.
5
+ */
6
+ ?>
7
+
8
+ <div class="rpwe-options">
9
+
10
+ <p>
11
+ <label for="<?php echo $this->get_field_id('title'); ?>">
12
+ <?php _e('Title', 'recent-posts-widget-extended'); ?>
13
+ </label>
14
+ <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']); ?>" />
15
+ </p>
16
+
17
+ <p>
18
+ <label for="<?php echo $this->get_field_id('title_url'); ?>">
19
+ <?php _e('Title URL', 'recent-posts-widget-extended'); ?>
20
+ </label>
21
+ <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']); ?>" />
22
+ </p>
23
+
24
+ <p>
25
+ <label for="<?php echo $this->get_field_id('cssID'); ?>">
26
+ <?php _e('CSS ID', 'recent-posts-widget-extended'); ?>
27
+ </label>
28
+ <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']); ?>" />
29
+ </p>
30
+
31
+ <p>
32
+ <label for="<?php echo $this->get_field_id('css_class'); ?>">
33
+ <?php _e('CSS Class', 'recent-posts-widget-extended'); ?>
34
+ </label>
35
+ <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']); ?>" />
36
+ </p>
37
+
38
+ <p>
39
+ <label for="<?php echo $this->get_field_id('before'); ?>">
40
+ <?php _e('HTML or text before the recent posts', 'recent-posts-widget-extended'); ?>
41
+ </label>
42
+ <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>
43
+ </p>
44
+
45
+ <p>
46
+ <label for="<?php echo $this->get_field_id('after'); ?>">
47
+ <?php _e('HTML or text after the recent posts', 'recent-posts-widget-extended'); ?>
48
+ </label>
49
+ <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>
50
+ </p>
51
+
52
+
53
+ <p>
54
+ <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'); ?>" />
55
+ <label for="<?php echo $this->get_field_id('ignore_sticky'); ?>">
56
+ <?php _e('Ignore sticky posts', 'recent-posts-widget-extended'); ?>
57
+ </label>
58
+ </p>
59
+
60
+ <p>
61
+ <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'); ?>" />
62
+ <label for="<?php echo $this->get_field_id('exclude_current'); ?>">
63
+ <?php _e('Exclude current post', 'recent-posts-widget-extended'); ?>
64
+ </label>
65
+ </p>
66
+
67
+ <div class="rpwe-multiple-check-form">
68
+ <label>
69
+ <?php _e('Post Types', 'recent-posts-widget-extended'); ?>
70
+ </label>
71
+ <?php foreach (get_post_types(array('public' => true), 'objects') as $type) : ?>
72
+ <p>
73
+ <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'])); ?> />
74
+ <label for="<?php echo $this->get_field_id('post_type') . '-' . $type->name; ?>">
75
+ <?php echo esc_html($type->labels->name); ?>
76
+ </label>
77
+ </p>
78
+ <?php endforeach; ?>
79
+ </div>
80
+
81
+ <p>
82
+ <label for="<?php echo $this->get_field_id('post_status'); ?>">
83
+ <?php _e('Post Status', 'recent-posts-widget-extended'); ?>
84
+ </label>
85
+ <select class="widefat" id="<?php echo $this->get_field_id('post_status'); ?>" name="<?php echo $this->get_field_name('post_status'); ?>" style="width:100%;">
86
+ <?php foreach (array_keys(get_object_vars(wp_count_posts('post'))) as $status_value => $status_label) { ?>
87
+ <option value="<?php echo esc_attr($status_label); ?>" <?php selected($instance['post_status'], $status_label); ?>><?php echo esc_html(ucfirst($status_label)); ?></option>
88
+ <?php } ?>
89
+ </select>
90
+ </p>
91
+
92
+ <p>
93
+ <label for="<?php echo $this->get_field_id('order'); ?>">
94
+ <?php _e('Order', 'recent-posts-widget-extended'); ?>
95
+ </label>
96
+ <select class="widefat" id="<?php echo $this->get_field_id('order'); ?>" name="<?php echo $this->get_field_name('order'); ?>" style="width:100%;">
97
+ <option value="DESC" <?php selected($instance['order'], 'DESC'); ?>><?php _e('Descending', 'rpwe') ?></option>
98
+ <option value="ASC" <?php selected($instance['order'], 'ASC'); ?>><?php _e('Ascending', 'rpwe') ?></option>
99
+ </select>
100
+ </p>
101
+
102
+ <p>
103
+ <label for="<?php echo $this->get_field_id('orderby'); ?>">
104
+ <?php _e('Orderby', 'recent-posts-widget-extended'); ?>
105
+ </label>
106
+ <select class="widefat" id="<?php echo $this->get_field_id('orderby'); ?>" name="<?php echo $this->get_field_name('orderby'); ?>" style="width:100%;">
107
+ <option value="ID" <?php selected($instance['orderby'], 'ID'); ?>><?php _e('ID', 'rpwe') ?></option>
108
+ <option value="author" <?php selected($instance['orderby'], 'author'); ?>><?php _e('Author', 'rpwe') ?></option>
109
+ <option value="title" <?php selected($instance['orderby'], 'title'); ?>><?php _e('Title', 'rpwe') ?></option>
110
+ <option value="date" <?php selected($instance['orderby'], 'date'); ?>><?php _e('Date', 'rpwe') ?></option>
111
+ <option value="modified" <?php selected($instance['orderby'], 'modified'); ?>><?php _e('Modified', 'rpwe') ?></option>
112
+ <option value="rand" <?php selected($instance['orderby'], 'rand'); ?>><?php _e('Random', 'rpwe') ?></option>
113
+ <option value="comment_count" <?php selected($instance['orderby'], 'comment_count'); ?>><?php _e('Comment Count', 'rpwe') ?></option>
114
+ <option value="menu_order" <?php selected($instance['orderby'], 'menu_order'); ?>><?php _e('Menu Order', 'rpwe') ?></option>
115
+ </select>
116
+ </p>
117
+
118
+ <div class="rpwe-multiple-check-form">
119
+ <label>
120
+ <?php _e('Limit to Category', 'recent-posts-widget-extended'); ?>
121
+ </label>
122
+
123
+ <?php foreach (rpwe_cats_list() as $category) : ?>
124
+ <p>
125
+ <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'])); ?> />
126
+ <label for="<?php echo $this->get_field_id('cat') . '-' . (int) $category->term_id; ?>">
127
+ <?php echo esc_html($category->name); ?>
128
+ </label>
129
+ </p>
130
+ <?php endforeach; ?>
131
+ </div>
132
+
133
+ <div class="rpwe-multiple-check-form">
134
+ <label>
135
+ <?php _e('Limit to Tag', 'recent-posts-widget-extended'); ?>
136
+ </label>
137
+ <?php foreach (rpwe_tags_list() as $post_tag) : ?>
138
+ <p>
139
+ <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'])); ?> />
140
+ <label for="<?php echo $this->get_field_id('tag') . '-' . (int) $post_tag->term_id; ?>">
141
+ <?php echo esc_html($post_tag->name); ?>
142
+ </label>
143
+ </p>
144
+ <?php endforeach; ?>
145
+ </div>
146
+
147
+ <p>
148
+ <label for="<?php echo $this->get_field_id('taxonomy'); ?>">
149
+ <?php _e('Limit to Taxonomy', 'recent-posts-widget-extended'); ?>
150
+ </label>
151
+ <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']); ?>" />
152
+ <small><?php _e('Ex: category=1,2,4&amp;post_tag=6,12. ', 'rpwe'); ?>
153
+ <?php _e('Available: ', 'rpwe');
154
+ echo implode(', ', get_taxonomies(array('public' => true))); ?></small>
155
+ </p>
156
+
157
+ <p>
158
+ <label for="<?php echo $this->get_field_id('limit'); ?>">
159
+ <?php _e('Number of posts to show', 'recent-posts-widget-extended'); ?>
160
+ </label>
161
+ <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']); ?>" />
162
+ </p>
163
+
164
+ <p>
165
+ <label for="<?php echo $this->get_field_id('offset'); ?>">
166
+ <?php _e('Offset', 'recent-posts-widget-extended'); ?>
167
+ </label>
168
+ <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']); ?>" />
169
+ <small><?php _e('The number of posts to skip', 'recent-posts-widget-extended'); ?></small>
170
+ </p>
171
+
172
+ <?php if (current_theme_supports('post-thumbnails')) { ?>
173
+
174
+ <p>
175
+ <input id="<?php echo $this->get_field_id('thumb'); ?>" name="<?php echo $this->get_field_name('thumb'); ?>" type="checkbox" <?php checked($instance['thumb']); ?> />
176
+ <label for="<?php echo $this->get_field_id('thumb'); ?>">
177
+ <?php _e('Display Thumbnail', 'recent-posts-widget-extended'); ?>
178
+ </label>
179
+ </p>
180
+
181
+ <p>
182
+ <label class="rpwe-block" for="<?php echo $this->get_field_id('thumb_height'); ?>">
183
+ <?php _e('Thumbnail (height,width,align)', 'recent-posts-widget-extended'); ?>
184
+ </label>
185
+
186
+ <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']); ?>" />
187
+
188
+ <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']); ?>" />
189
+
190
+ <select class="small-input" id="<?php echo $this->get_field_id('thumb_align'); ?>" name="<?php echo $this->get_field_name('thumb_align'); ?>">
191
+ <option value="rpwe-alignleft" <?php selected($instance['thumb_align'], 'rpwe-alignleft'); ?>><?php _e('Left', 'recent-posts-widget-extended') ?></option>
192
+ <option value="rpwe-alignright" <?php selected($instance['thumb_align'], 'rpwe-alignright'); ?>><?php _e('Right', 'recent-posts-widget-extended') ?></option>
193
+ <option value="rpwe-aligncenter" <?php selected($instance['thumb_align'], 'rpwe-aligncenter'); ?>><?php _e('Center', 'recent-posts-widget-extended') ?></option>
194
+ </select>
195
+ </p>
196
+
197
+ <p>
198
+ <label for="<?php echo $this->get_field_id('thumb_default'); ?>">
199
+ <?php _e('Default Thumbnail', 'recent-posts-widget-extended'); ?>
200
+ </label>
201
+ <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']; ?>" />
202
+ <small><?php _e('Leave it blank to disable.', 'recent-posts-widget-extended'); ?></small>
203
+ </p>
204
+
205
+ <?php } ?>
206
+
207
+ <p>
208
+ <input id="<?php echo $this->get_field_id('excerpt'); ?>" name="<?php echo $this->get_field_name('excerpt'); ?>" type="checkbox" <?php checked($instance['excerpt']); ?> />
209
+ <label for="<?php echo $this->get_field_id('excerpt'); ?>">
210
+ <?php _e('Display Excerpt', 'recent-posts-widget-extended'); ?>
211
+ </label>
212
+ </p>
213
+
214
+ <p>
215
+ <label for="<?php echo $this->get_field_id('length'); ?>">
216
+ <?php _e('Excerpt Length', 'recent-posts-widget-extended'); ?>
217
+ </label>
218
+ <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']); ?>" />
219
+ </p>
220
+
221
+ <p>
222
+ <input id="<?php echo $this->get_field_id('readmore'); ?>" name="<?php echo $this->get_field_name('readmore'); ?>" type="checkbox" <?php checked($instance['readmore']); ?> />
223
+ <label for="<?php echo $this->get_field_id('readmore'); ?>">
224
+ <?php _e('Display Readmore', 'recent-posts-widget-extended'); ?>
225
+ </label>
226
+ </p>
227
+
228
+ <p>
229
+ <label for="<?php echo $this->get_field_id('readmore_text'); ?>">
230
+ <?php _e('Readmore Text', 'recent-posts-widget-extended'); ?>
231
+ </label>
232
+ <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']); ?>" />
233
+ </p>
234
+
235
+ <p>
236
+ <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']); ?> />
237
+ <label for="<?php echo $this->get_field_id('comment_count'); ?>">
238
+ <?php _e('Display Comment Count', 'recent-posts-widget-extended'); ?>
239
+ </label>
240
+ </p>
241
+
242
+ <p>
243
+ <input id="<?php echo $this->get_field_id('date'); ?>" name="<?php echo $this->get_field_name('date'); ?>" type="checkbox" <?php checked($instance['date']); ?> />
244
+ <label for="<?php echo $this->get_field_id('date'); ?>">
245
+ <?php _e('Display Date', 'recent-posts-widget-extended'); ?>
246
+ </label>
247
+ </p>
248
+
249
+ <p>
250
+ <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']); ?> />
251
+ <label for="<?php echo $this->get_field_id('date_modified'); ?>">
252
+ <?php _e('Display Modification Date', 'recent-posts-widget-extended'); ?>
253
+ </label>
254
+ </p>
255
+
256
+ <p>
257
+ <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']); ?> />
258
+ <label for="<?php echo $this->get_field_id('date_relative'); ?>">
259
+ <?php _e('Use Relative Date. eg: 5 days ago', 'recent-posts-widget-extended'); ?>
260
+ </label>
261
+ </p>
262
+
263
+
264
+ <p>
265
+ <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']); ?> />
266
+ <label for="<?php echo $this->get_field_id('styles_default'); ?>">
267
+ <?php _e('Use Default Styles', 'recent-posts-widget-extended'); ?>
268
+ </label>
269
+ </p>
270
+
271
+ <p>
272
+ <label for="<?php echo $this->get_field_id('css'); ?>">
273
+ <?php _e('Custom CSS', 'recent-posts-widget-extended'); ?>
274
+ </label>
275
+ <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>
276
+ <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>
277
+ </p>
278
+
279
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/functions.php CHANGED
@@ -1,390 +1,384 @@
1
- <?php
2
-
3
- /**
4
- * Various functions used by the plugin.
5
- *
6
- * @package Recent_Posts_Widget_Extended
7
- * @since 0.9.4
8
- * @author Satrya
9
- * @copyright Copyright (c) 2014, Satrya
10
- * @license http://www.gnu.org/licenses/gpl-2.0.html
11
- */
12
-
13
- /**
14
- * Sets up the default arguments.
15
- *
16
- * @since 0.9.4
17
- */
18
- function rpwe_get_default_args() {
19
-
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,
27
- 'offset' => 0,
28
- 'order' => 'DESC',
29
- 'orderby' => 'date',
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,
37
-
38
- 'excerpt' => false,
39
- 'length' => 10,
40
- 'thumb' => true,
41
- 'thumb_height' => 45,
42
- 'thumb_width' => 45,
43
- 'thumb_default' => 'http://placehold.it/45x45/f0f0f0/ccc',
44
- 'thumb_align' => 'rpwe-alignleft',
45
- 'date' => true,
46
- 'date_relative' => false,
47
- 'date_modified' => false,
48
- 'readmore' => false,
49
- 'readmore_text' => __('Read More &raquo;', 'recent-posts-widget-extended'),
50
- 'comment_count' => false,
51
-
52
- 'styles_default' => true,
53
- 'css' => $css_defaults,
54
- 'cssID' => '',
55
- 'css_class' => '',
56
- 'before' => '',
57
- 'after' => ''
58
- );
59
-
60
- // Allow plugins/themes developer to filter the default arguments.
61
- return apply_filters('rpwe_default_args', $defaults);
62
- }
63
-
64
- /**
65
- * Outputs the recent posts.
66
- *
67
- * @since 0.9.4
68
- */
69
- function rpwe_recent_posts($args = array()) {
70
- echo rpwe_get_recent_posts($args);
71
- }
72
-
73
- /**
74
- * Generates the posts markup.
75
- *
76
- * @since 0.9.4
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'], ' &hellip;');
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
-
216
- endif;
217
-
218
- // Restore original Post Data.
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
- /**
229
- * The posts query.
230
- *
231
- * @since 0.0.1
232
- * @param array $args
233
- * @return array
234
- */
235
- function rpwe_get_posts($args = array()) {
236
-
237
- // Query arguments.
238
- $query = array(
239
- 'offset' => $args['offset'],
240
- 'posts_per_page' => $args['limit'],
241
- 'orderby' => $args['orderby'],
242
- 'order' => $args['order'],
243
- 'post_type' => $args['post_type'],
244
- 'post_status' => $args['post_status'],
245
- 'ignore_sticky_posts' => $args['ignore_sticky'],
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
-
263
- /**
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;
279
- $operator = 'NOT IN';
280
- }
281
- $tax_query[] = array(
282
- 'taxonomy' => $slug,
283
- 'field' => 'id',
284
- 'terms' => $ids,
285
- 'operator' => $operator
286
- );
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
- /**
302
- * Custom Styles.
303
- *
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
- }
1
+ <?php
2
+
3
+ /**
4
+ * Various functions used by the plugin.
5
+ */
6
+
7
+ /**
8
+ * Sets up the default arguments.
9
+ *
10
+ * @since 0.9.4
11
+ */
12
+ function rpwe_get_default_args() {
13
+
14
+ $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";
15
+
16
+ $defaults = array(
17
+ 'title' => esc_attr__('Recent Posts', 'rpwe'),
18
+ 'title_url' => '',
19
+
20
+ 'limit' => 5,
21
+ 'offset' => 0,
22
+ 'order' => 'DESC',
23
+ 'orderby' => 'date',
24
+ 'cat' => array(),
25
+ 'tag' => array(),
26
+ 'taxonomy' => '',
27
+ 'post_type' => array('post'),
28
+ 'post_status' => 'publish',
29
+ 'ignore_sticky' => 1,
30
+ 'exclude_current' => 1,
31
+
32
+ 'excerpt' => false,
33
+ 'length' => 10,
34
+ 'thumb' => true,
35
+ 'thumb_height' => 45,
36
+ 'thumb_width' => 45,
37
+ 'thumb_default' => 'http://placehold.it/45x45/f0f0f0/ccc',
38
+ 'thumb_align' => 'rpwe-alignleft',
39
+ 'date' => true,
40
+ 'date_relative' => false,
41
+ 'date_modified' => false,
42
+ 'readmore' => false,
43
+ 'readmore_text' => __('Read More &raquo;', 'recent-posts-widget-extended'),
44
+ 'comment_count' => false,
45
+
46
+ 'styles_default' => true,
47
+ 'css' => $css_defaults,
48
+ 'cssID' => '',
49
+ 'css_class' => '',
50
+ 'before' => '',
51
+ 'after' => ''
52
+ );
53
+
54
+ // Allow plugins/themes developer to filter the default arguments.
55
+ return apply_filters('rpwe_default_args', $defaults);
56
+ }
57
+
58
+ /**
59
+ * Outputs the recent posts.
60
+ *
61
+ * @since 0.9.4
62
+ */
63
+ function rpwe_recent_posts($args = array()) {
64
+ echo rpwe_get_recent_posts($args);
65
+ }
66
+
67
+ /**
68
+ * Generates the posts markup.
69
+ *
70
+ * @since 0.9.4
71
+ * @param array $args
72
+ * @return string|array The HTML for the random posts.
73
+ */
74
+ function rpwe_get_recent_posts($args = array()) {
75
+
76
+ // Set up a default, empty variable.
77
+ $html = '';
78
+
79
+ // Merge the input arguments and the defaults.
80
+ $args = wp_parse_args($args, rpwe_get_default_args());
81
+
82
+ // Extract the array to allow easy use of variables.
83
+ extract($args);
84
+
85
+ // Allow devs to hook in stuff before the loop.
86
+ do_action('rpwe_before_loop');
87
+
88
+ // Display the default style of the plugin.
89
+ if ($args['styles_default'] === true) {
90
+ rpwe_custom_styles();
91
+ }
92
+
93
+ // If the default style is disabled then use the custom css if it's not empty.
94
+ if ($args['styles_default'] === false && !empty($args['css'])) {
95
+ echo '<style>' . $args['css'] . '</style>';
96
+ }
97
+
98
+ // Get the posts query.
99
+ $posts = rpwe_get_posts($args);
100
+
101
+ if ($posts->have_posts()) :
102
+
103
+ // Recent posts wrapper
104
+ $html = '<div ' . (!empty($args['cssID']) ? 'id="' . sanitize_html_class($args['cssID']) . '"' : '') . ' class="rpwe-block ' . (!empty($args['css_class']) ? '' . sanitize_html_class($args['css_class']) . '' : '') . '">';
105
+
106
+ $html .= '<ul class="rpwe-ul">';
107
+
108
+ while ($posts->have_posts()) : $posts->the_post();
109
+
110
+ // Thumbnails
111
+ $thumb_id = get_post_thumbnail_id(); // Get the featured image id.
112
+ $img_url = wp_get_attachment_url($thumb_id); // Get img URL.
113
+
114
+ // Display the image url and crop using the resizer.
115
+ $image = rpwe_resize($img_url, $args['thumb_width'], $args['thumb_height'], true);
116
+
117
+ // Start recent posts markup.
118
+ $html .= '<li class="rpwe-li rpwe-clearfix">';
119
+
120
+ if ($args['thumb']) :
121
+
122
+ // Check if post has post thumbnail.
123
+ if (has_post_thumbnail()) :
124
+ $html .= '<a class="rpwe-img" href="' . esc_url(get_permalink()) . '">';
125
+ if ($image) :
126
+ $html .= '<img class="' . esc_attr($args['thumb_align']) . ' rpwe-thumb" src="' . esc_url($image) . '" alt="' . esc_attr(get_the_title()) . '" height="' . absint($args['thumb_height']) . '" width="' . absint($args['thumb_width']) . '">';
127
+ else :
128
+ $html .= get_the_post_thumbnail(
129
+ get_the_ID(),
130
+ array($args['thumb_width'], $args['thumb_height']),
131
+ array(
132
+ 'class' => $args['thumb_align'] . ' rpwe-thumb the-post-thumbnail',
133
+ 'alt' => esc_attr(get_the_title())
134
+ )
135
+ );
136
+ endif;
137
+ $html .= '</a>';
138
+
139
+ // If no post thumbnail found, check if Get The Image plugin exist and display the image.
140
+ elseif (function_exists('get_the_image')) :
141
+ $html .= get_the_image(array(
142
+ 'height' => (int) $args['thumb_height'],
143
+ 'width' => (int) $args['thumb_width'],
144
+ 'image_class' => esc_attr($args['thumb_align']) . ' rpwe-thumb get-the-image',
145
+ 'image_scan' => true,
146
+ 'echo' => false,
147
+ 'default_image' => esc_url($args['thumb_default'])
148
+ ));
149
+
150
+ // Display default image.
151
+ elseif (!empty($args['thumb_default'])) :
152
+ $html .= sprintf(
153
+ '<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>',
154
+ esc_url(get_permalink()),
155
+ esc_attr($args['thumb_align']),
156
+ esc_url($args['thumb_default']),
157
+ esc_attr(get_the_title()),
158
+ (int) $args['thumb_width'],
159
+ (int) $args['thumb_height']
160
+ );
161
+
162
+ endif;
163
+
164
+ endif;
165
+
166
+ $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>';
167
+
168
+ if ($args['date']) :
169
+ $date = get_the_date();
170
+ if ($args['date_relative']) :
171
+ $date = sprintf(__('%s ago', 'recent-posts-widget-extended'), human_time_diff(get_the_date('U'), current_time('timestamp')));
172
+ endif;
173
+ $html .= '<time class="rpwe-time published" datetime="' . esc_html(get_the_date('c')) . '">' . esc_html($date) . '</time>';
174
+ elseif ($args['date_modified']) : // if both date functions are provided, we use date to be backwards compatible
175
+ $date = get_the_modified_date();
176
+ if ($args['date_relative']) :
177
+ $date = sprintf(__('%s ago', 'recent-posts-widget-extended'), human_time_diff(get_the_modified_date('U'), current_time('timestamp')));
178
+ endif;
179
+ $html .= '<time class="rpwe-time modfied" datetime="' . esc_html(get_the_modified_date('c')) . '">' . esc_html($date) . '</time>';
180
+ endif;
181
+
182
+ if ($args['comment_count']) :
183
+ if (get_comments_number() == 0) {
184
+ $comments = __('No Comments', 'recent-posts-widget-extended');
185
+ } elseif (get_comments_number() > 1) {
186
+ $comments = sprintf(__('%s Comments', 'recent-posts-widget-extended'), get_comments_number());
187
+ } else {
188
+ $comments = __('1 Comment', 'recent-posts-widget-extended');
189
+ }
190
+ $html .= '<a class="rpwe-comment comment-count" href="' . get_comments_link() . '">' . $comments . '</a>';
191
+ endif;
192
+
193
+ if ($args['excerpt']) :
194
+ $html .= '<div class="rpwe-summary">';
195
+ $html .= wp_trim_words(apply_filters('rpwe_excerpt', get_the_excerpt()), $args['length'], ' &hellip;');
196
+ if ($args['readmore']) :
197
+ $html .= '<a href="' . esc_url(get_permalink()) . '" class="more-link">' . $args['readmore_text'] . '</a>';
198
+ endif;
199
+ $html .= '</div>';
200
+ endif;
201
+
202
+ $html .= '</li>';
203
+
204
+ endwhile;
205
+
206
+ $html .= '</ul>';
207
+
208
+ $html .= '</div><!-- Generated by http://wordpress.org/plugins/recent-posts-widget-extended/ -->';
209
+
210
+ endif;
211
+
212
+ // Restore original Post Data.
213
+ wp_reset_postdata();
214
+
215
+ // Allow devs to hook in stuff after the loop.
216
+ do_action('rpwe_after_loop');
217
+
218
+ // Return the posts markup.
219
+ return wp_kses_post($args['before']) . apply_filters('rpwe_markup', $html, $args) . wp_kses_post($args['after']);
220
+ }
221
+
222
+ /**
223
+ * The posts query.
224
+ *
225
+ * @since 0.0.1
226
+ * @param array $args
227
+ * @return array
228
+ */
229
+ function rpwe_get_posts($args = array()) {
230
+
231
+ // Query arguments.
232
+ $query = array(
233
+ 'offset' => $args['offset'],
234
+ 'posts_per_page' => $args['limit'],
235
+ 'orderby' => $args['orderby'],
236
+ 'order' => $args['order'],
237
+ 'post_type' => $args['post_type'],
238
+ 'post_status' => $args['post_status'],
239
+ 'ignore_sticky_posts' => $args['ignore_sticky'],
240
+ );
241
+
242
+ // Exclude current post
243
+ if ($args['exclude_current']) {
244
+ $query['post__not_in'] = array(get_the_ID());
245
+ }
246
+
247
+ // Limit posts based on category.
248
+ if (!empty($args['cat'])) {
249
+ $query['category__in'] = $args['cat'];
250
+ }
251
+
252
+ // Limit posts based on post tag.
253
+ if (!empty($args['tag'])) {
254
+ $query['tag__in'] = $args['tag'];
255
+ }
256
+
257
+ /**
258
+ * Taxonomy query.
259
+ * Prop Miniloop plugin by Kailey Lampert.
260
+ */
261
+ if (!empty($args['taxonomy'])) {
262
+
263
+ parse_str($args['taxonomy'], $taxes);
264
+
265
+ $operator = 'IN';
266
+ $tax_query = array();
267
+ foreach (array_keys($taxes) as $k => $slug) {
268
+ $ids = explode(',', $taxes[$slug]);
269
+ if (count($ids) == 1 && $ids['0'] < 0) {
270
+ // If there is only one id given, and it's negative
271
+ // Let's treat it as 'posts not in'
272
+ $ids['0'] = $ids['0'] * -1;
273
+ $operator = 'NOT IN';
274
+ }
275
+ $tax_query[] = array(
276
+ 'taxonomy' => $slug,
277
+ 'field' => 'id',
278
+ 'terms' => $ids,
279
+ 'operator' => $operator
280
+ );
281
+ }
282
+
283
+ $query['tax_query'] = $tax_query;
284
+ }
285
+
286
+ // Allow plugins/themes developer to filter the default query.
287
+ $query = apply_filters('rpwe_default_query_arguments', $query);
288
+
289
+ // Perform the query.
290
+ $posts = new WP_Query($query);
291
+
292
+ return $posts;
293
+ }
294
+
295
+ /**
296
+ * Custom Styles.
297
+ *
298
+ * @since 0.8
299
+ */
300
+ function rpwe_custom_styles() {
301
+ ?>
302
+ <style>
303
+ .rpwe-block ul {
304
+ list-style: none !important;
305
+ margin-left: 0 !important;
306
+ padding-left: 0 !important;
307
+ }
308
+
309
+ .rpwe-block li {
310
+ border-bottom: 1px solid #eee;
311
+ margin-bottom: 10px;
312
+ padding-bottom: 10px;
313
+ list-style-type: none;
314
+ }
315
+
316
+ .rpwe-block a {
317
+ display: inline !important;
318
+ text-decoration: none;
319
+ }
320
+
321
+ .rpwe-block h3 {
322
+ background: none !important;
323
+ clear: none;
324
+ margin-bottom: 0 !important;
325
+ margin-top: 0 !important;
326
+ font-weight: 400;
327
+ font-size: 12px !important;
328
+ line-height: 1.5em;
329
+ }
330
+
331
+ .rpwe-thumb {
332
+ border: 1px solid #EEE !important;
333
+ box-shadow: none !important;
334
+ margin: 2px 10px 2px 0;
335
+ padding: 3px !important;
336
+ }
337
+
338
+ .rpwe-summary {
339
+ font-size: 12px;
340
+ }
341
+
342
+ .rpwe-time {
343
+ color: #bbb;
344
+ font-size: 11px;
345
+ }
346
+
347
+ .rpwe-comment {
348
+ color: #bbb;
349
+ font-size: 11px;
350
+ padding-left: 5px;
351
+ }
352
+
353
+ .rpwe-alignleft {
354
+ display: inline;
355
+ float: left;
356
+ }
357
+
358
+ .rpwe-alignright {
359
+ display: inline;
360
+ float: right;
361
+ }
362
+
363
+ .rpwe-aligncenter {
364
+ display: block;
365
+ margin-left: auto;
366
+ margin-right: auto;
367
+ }
368
+
369
+ .rpwe-clearfix:before,
370
+ .rpwe-clearfix:after {
371
+ content: "";
372
+ display: table !important;
373
+ }
374
+
375
+ .rpwe-clearfix:after {
376
+ clear: both;
377
+ }
378
+
379
+ .rpwe-clearfix {
380
+ zoom: 1;
381
+ }
382
+ </style>
383
+ <?php
384
+ }
 
 
 
 
 
 
includes/helpers.php CHANGED
@@ -1,53 +1,47 @@
1
- <?php
2
-
3
- /**
4
- * Function helper
5
- *
6
- * @package Recent_Posts_Widget_Extended
7
- * @since 0.9.9.1
8
- * @author Satrya
9
- * @copyright Copyright (c) 2015, Satrya
10
- * @license http://www.gnu.org/licenses/gpl-2.0.html
11
- */
12
-
13
- /**
14
- * Display list of tags for widget.
15
- *
16
- * @since 0.9.9.1
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
- /**
35
- * Display list of categories for widget.
36
- *
37
- * @since 0.9.9.1
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
- }
1
+ <?php
2
+
3
+ /**
4
+ * Function helper
5
+ */
6
+
7
+ /**
8
+ * Display list of tags for widget.
9
+ *
10
+ * @since 0.9.9.1
11
+ */
12
+ function rpwe_tags_list() {
13
+
14
+ // Arguments
15
+ $args = array(
16
+ 'number' => 99
17
+ );
18
+
19
+ // Allow dev to filter the arguments
20
+ $args = apply_filters('rpwe_tags_list_args', $args);
21
+
22
+ // Get the tags
23
+ $tags = get_terms('post_tag', $args);
24
+
25
+ return $tags;
26
+ }
27
+
28
+ /**
29
+ * Display list of categories for widget.
30
+ *
31
+ * @since 0.9.9.1
32
+ */
33
+ function rpwe_cats_list() {
34
+
35
+ // Arguments
36
+ $args = array(
37
+ 'number' => 99
38
+ );
39
+
40
+ // Allow dev to filter the arguments
41
+ $args = apply_filters('rpwe_cats_list_args', $args);
42
+
43
+ // Get the cats
44
+ $cats = get_terms('category', $args);
45
+
46
+ return $cats;
47
+ }
 
 
 
 
 
 
includes/resizer.php CHANGED
@@ -1,207 +1,207 @@
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('Rpwe_Resize')) {
28
- class Rpwe_Resize {
29
- /**
30
- * The singleton instance
31
- */
32
- static private $instance = null;
33
-
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
-
54
- return self::$instance;
55
- }
56
-
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
155
- );
156
- }
157
-
158
- return $image;
159
- }
160
-
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
- }
192
-
193
-
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
- }
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('Rpwe_Resize')) {
28
+ class Rpwe_Resize {
29
+ /**
30
+ * The singleton instance
31
+ */
32
+ static private $instance = null;
33
+
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
+
54
+ return self::$instance;
55
+ }
56
+
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
155
+ );
156
+ }
157
+
158
+ return $image;
159
+ }
160
+
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
+ }
192
+
193
+
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,26 +1,20 @@
1
- <?php
2
-
3
- /**
4
- * Shortcode helper
5
- *
6
- * @package Recent_Posts_Widget_Extended
7
- * @since 0.9.4
8
- * @author Satrya
9
- * @copyright Copyright (c) 2014, Satrya
10
- * @license http://www.gnu.org/licenses/gpl-2.0.html
11
- */
12
-
13
- /**
14
- * Display recent posts with shortcode.
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');
1
+ <?php
2
+
3
+ /**
4
+ * Shortcode helper
5
+ */
6
+
7
+ /**
8
+ * Display recent posts with shortcode.
9
+ *
10
+ * @since 0.9.4
11
+ */
12
+ function rpwe_shortcode($atts, $content) {
13
+ if (isset($atts['cssid'])) {
14
+ $atts['cssID'] = $atts['cssid'];
15
+ unset($atts['cssid']);
16
+ }
17
+ $args = shortcode_atts(rpwe_get_default_args(), $atts);
18
+ return rpwe_get_recent_posts($args);
19
+ }
20
+ 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
@@ -13,178 +13,178 @@ msgstr ""
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 &raquo;"
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 ""
13
  "X-Poedit-SourceCharset: UTF-8\n"
14
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
 
16
+ #: classes/widget.php:19
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:31
21
  msgid "Recent Posts Extended"
22
  msgstr ""
23
 
24
+ #: includes/form.php:12
25
  msgid "Title"
26
  msgstr ""
27
 
28
+ #: includes/form.php:19
29
  msgid "Title URL"
30
  msgstr ""
31
 
32
+ #: includes/form.php:26
33
  msgid "CSS ID"
34
  msgstr ""
35
 
36
+ #: includes/form.php:33
37
  msgid "CSS Class"
38
  msgstr ""
39
 
40
+ #: includes/form.php:40
41
  msgid "HTML or text before the recent posts"
42
  msgstr ""
43
 
44
+ #: includes/form.php:47
45
  msgid "HTML or text after the recent posts"
46
  msgstr ""
47
 
48
+ #: includes/form.php:56
49
  msgid "Ignore sticky posts"
50
  msgstr ""
51
 
52
+ #: includes/form.php:63
53
  msgid "Exclude current post"
54
  msgstr ""
55
 
56
+ #: includes/form.php:69
57
  msgid "Post Types"
58
  msgstr ""
59
 
60
+ #: includes/form.php:83
61
  msgid "Post Status"
62
  msgstr ""
63
 
64
+ #: includes/form.php:94
65
  msgid "Order"
66
  msgstr ""
67
 
68
+ #: includes/form.php:104
69
  msgid "Orderby"
70
  msgstr ""
71
 
72
+ #: includes/form.php:120
73
  msgid "Limit to Category"
74
  msgstr ""
75
 
76
+ #: includes/form.php:135
77
  msgid "Limit to Tag"
78
  msgstr ""
79
 
80
+ #: includes/form.php:149
81
  msgid "Limit to Taxonomy"
82
  msgstr ""
83
 
84
+ #: includes/form.php:159
85
  msgid "Number of posts to show"
86
  msgstr ""
87
 
88
+ #: includes/form.php:166
89
  msgid "Offset"
90
  msgstr ""
91
 
92
+ #: includes/form.php:169
93
  msgid "The number of posts to skip"
94
  msgstr ""
95
 
96
+ #: includes/form.php:177
97
  msgid "Display Thumbnail"
98
  msgstr ""
99
 
100
+ #: includes/form.php:183
101
  msgid "Thumbnail (height,width,align)"
102
  msgstr ""
103
 
104
+ #: includes/form.php:191
105
  msgid "Left"
106
  msgstr ""
107
 
108
+ #: includes/form.php:192
109
  msgid "Right"
110
  msgstr ""
111
 
112
+ #: includes/form.php:193
113
  msgid "Center"
114
  msgstr ""
115
 
116
+ #: includes/form.php:199
117
  msgid "Default Thumbnail"
118
  msgstr ""
119
 
120
+ #: includes/form.php:202
121
  msgid "Leave it blank to disable."
122
  msgstr ""
123
 
124
+ #: includes/form.php:210
125
  msgid "Display Excerpt"
126
  msgstr ""
127
 
128
+ #: includes/form.php:216
129
  msgid "Excerpt Length"
130
  msgstr ""
131
 
132
+ #: includes/form.php:224
133
  msgid "Display Readmore"
134
  msgstr ""
135
 
136
+ #: includes/form.php:230
137
  msgid "Readmore Text"
138
  msgstr ""
139
 
140
+ #: includes/form.php:238
141
  msgid "Display Comment Count"
142
  msgstr ""
143
 
144
+ #: includes/form.php:245
145
  msgid "Display Date"
146
  msgstr ""
147
 
148
+ #: includes/form.php:252
149
  msgid "Display Modification Date"
150
  msgstr ""
151
 
152
+ #: includes/form.php:259
153
  msgid "Use Relative Date. eg: 5 days ago"
154
  msgstr ""
155
 
156
+ #: includes/form.php:267
157
  msgid "Use Default Styles"
158
  msgstr ""
159
 
160
+ #: includes/form.php:273
161
  msgid "Custom CSS"
162
  msgstr ""
163
 
164
+ #: includes/form.php:276
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:43
169
  msgid "Read More &raquo;"
170
  msgstr ""
171
 
172
+ #: includes/functions.php:166
173
  msgid "Permalink to %s"
174
  msgstr ""
175
 
176
+ #: includes/functions.php:177, includes/functions.php:171
177
  msgid "%s ago"
178
  msgstr ""
179
 
180
+ #: includes/functions.php:188
181
  msgid "1 Comment"
182
  msgstr ""
183
 
184
+ #: includes/functions.php:186
185
  msgid "%s Comments"
186
  msgstr ""
187
 
188
+ #: includes/functions.php:184
189
  msgid "No Comments"
190
  msgstr ""
readme.txt CHANGED
@@ -1,237 +1,252 @@
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
-
12
- Provides flexible and advanced recent posts. Display it via shortcode or widget with thumbnails, post excerpt, taxonomy and more.
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.
28
- * Display thumbnails, with customizable size and alignment.
29
- * Display excerpt, with customizable length.
30
- * Display from all, specific or multiple category.
31
- * Display from all, specific or multiple tag.
32
- * Display post date.
33
- * Display modification date
34
- * Display comment count
35
- * Exclude current post
36
- * Read more option.
37
- * Post type option.
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
-
49
- **Through Dashboard**
50
-
51
- 1. Log in to your WordPress admin panel and go to Plugins -> Add New
52
- 2. Type **recent posts widget extended** in the search box and click on search button.
53
- 3. Find Recent Posts Widget Extended plugin.
54
- 4. Then click on Install Now after that activate the plugin.
55
- 5. Go to the widgets page **Appearance -> Widgets**.
56
- 6. Find **Recent Posts Extended** widget.
57
-
58
- **Installing Via FTP**
59
-
60
- 1. Download the plugin to your hardisk.
61
- 2. Unzip.
62
- 3. Upload the **recent-posts-widget-extended** folder into your plugins directory.
63
- 4. Log in to your WordPress admin panel and click the Plugins menu.
64
- 5. Then activate the plugin.
65
- 6. Go to the widgets page **Appearance -> Widgets**.
66
- 7. Find **Recent Posts Extended** widget.
67
-
68
- == Frequently Asked Questions ==
69
-
70
- = How to filter the post query? =
71
- You can use `rpwe_default_query_arguments` to filter it. Example:
72
- `
73
- add_filter( 'rpwe_default_query_arguments', 'your_custom_function' );
74
- function your_custom_function( $args ) {
75
- $args['posts_per_page'] = 10; // Changing the number of posts to show.
76
- return $args;
77
- }
78
- `
79
-
80
- = How to filter the post excerpt? =
81
- Post excerpt now comes with filter to easily dev to change/customize it. `apply_filters( 'rpwe_excerpt', get_the_excerpt() )`
82
-
83
- = Ordering not working! =
84
- Did you installed any Post or Post Type Order? Please try to deactivate it and try again the ordering. [(related question)](http://wordpress.org/support/topic/ordering-set-to-descending-not-working)
85
-
86
- = No image options =
87
- Your theme needs to support Post Thumbnail, please go to http://codex.wordpress.org/Post_Thumbnails to read more info and how to activate it in your theme.
88
-
89
- = How to add custom style? =
90
- First, please uncheck the **Use Default Style** option then place the css code below in the Custom CSS box, then you can customize it to fit your needs
91
- `
92
- .rpwe-block ul {
93
- list-style: none !important;
94
- margin-left: 0 !important;
95
- padding-left: 0 !important;
96
- }
97
- .rpwe-block li {
98
- border-bottom: 1px solid #eee;
99
- margin-bottom: 10px;
100
- padding-bottom: 10px;
101
- list-style-type: none;
102
- }
103
- .rpwe-block a {
104
- display: inline !important;
105
- text-decoration: none;
106
- }
107
- .rpwe-block h3 {
108
- background: none !important;
109
- clear: none;
110
- margin-bottom: 0 !important;
111
- margin-top: 0 !important;
112
- font-weight: 400;
113
- font-size: 12px !important;
114
- line-height: 1.5em;
115
- }
116
- .rpwe-thumb {
117
- border: 1px solid #eee !important;
118
- box-shadow: none !important;
119
- margin: 2px 10px 2px 0;
120
- padding: 3px !important;
121
- }
122
- .rpwe-summary {
123
- font-size: 12px;
124
- }
125
- .rpwe-time {
126
- color: #bbb;
127
- font-size: 11px;
128
- }
129
- .rpwe-alignleft {
130
- display: inline;
131
- float: left;
132
- }
133
- .rpwe-alignright {
134
- display: inline;
135
- float: right;
136
- }
137
- .rpwe-aligncenter {
138
- display: block;
139
- margin-left: auto;
140
- margin-right: auto;
141
- }
142
- .rpwe-clearfix:before,.rpwe-clearfix:after {
143
- content: "";
144
- display: table !important;
145
- }
146
- .rpwe-clearfix:after {
147
- clear: both;
148
- }
149
- .rpwe-clearfix {
150
- zoom: 1;
151
- }
152
- `
153
-
154
- = Why so many !important in the css code? =
155
- I know it's not good but I have a good reason, the `!important` is to make sure the built-in style compatible with all themes. But if you don't like it, you can turn of the **Use Default Styles** and remove all custom css code in the **Custom CSS** box then create your own style.
156
-
157
- = Available filters =
158
- Default arguments
159
- `
160
- rpwe_default_args
161
- `
162
-
163
- Post excerpt
164
- `
165
- rpwe_excerpt
166
- `
167
-
168
- Post markup
169
- `
170
- rpwe_markup
171
- `
172
-
173
- Post query arguments
174
- `
175
- rpwe_default_query_arguments
176
- `
177
-
178
- == Screenshots ==
179
-
180
- 1. The widget settings
181
-
182
- == Shorcode Explanation ==
183
-
184
- Explanation of shortcode options:
185
-
186
- Basic shortcode
187
- `
188
- [rpwe]
189
- `
190
-
191
- Display 10 recent posts
192
- `
193
- [rpwe limit="10"]
194
- `
195
-
196
- Display 10 recent posts with thumbnail
197
- `
198
- [rpwe limit="10" thumb="true"]
199
- `
200
-
201
- **Here's the full default shortcode arguments**
202
- `
203
- limit="5"
204
- offset=""
205
- order="DESC"
206
- orderby="date"
207
- post_type="post"
208
- cat=""
209
- tag=""
210
- taxonomy=""
211
- post_type="post"
212
- post_status="publish"
213
- ignore_sticky="1"
214
- taxonomy=""
215
- excerpt="false"
216
- length="10"
217
- thumb="true"
218
- thumb_height="45"
219
- thumb_width="45"
220
- thumb_default="http://placehold.it/45x45/f0f0f0/ccc"
221
- thumb_align="rpwe-alignleft"
222
- date="true"
223
- readmore="false"
224
- readmore_text="Read More &raquo;"
225
- styles_default="true"
226
- cssID=""
227
- before=""
228
- after=""
229
- `
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
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 5.8
6
+ Tested up to: 5.8
7
+ Requires PHP: 7.2
8
+ Stable tag: 1.1.0
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+
12
+ Provides flexible and advanced recent posts. Display it via shortcode or widget with thumbnails, post excerpt, taxonomy and more.
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.
28
+ * Display thumbnails, with customizable size and alignment.
29
+ * Display excerpt, with customizable length.
30
+ * Display from all, specific or multiple category.
31
+ * Display from all, specific or multiple tag.
32
+ * Display post date.
33
+ * Display modification date
34
+ * Display comment count
35
+ * Exclude current post
36
+ * Read more option.
37
+ * Post type option.
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/idenovasi/recent-posts-widget-extended).
45
+ * [Donate](https://paypal.me/satrya).
46
+
47
+ == Installation ==
48
+
49
+ **Through Dashboard**
50
+
51
+ 1. Log in to your WordPress admin panel and go to Plugins -> Add New
52
+ 2. Type **recent posts widget extended** in the search box and click on search button.
53
+ 3. Find Recent Posts Widget Extended plugin.
54
+ 4. Then click on Install Now after that activate the plugin.
55
+ 5. Go to the widgets page **Appearance -> Widgets**.
56
+ 6. Find **Recent Posts Extended** widget.
57
+
58
+ **Installing Via FTP**
59
+
60
+ 1. Download the plugin to your hardisk.
61
+ 2. Unzip.
62
+ 3. Upload the **recent-posts-widget-extended** folder into your plugins directory.
63
+ 4. Log in to your WordPress admin panel and click the Plugins menu.
64
+ 5. Then activate the plugin.
65
+ 6. Go to the widgets page **Appearance -> Widgets**.
66
+ 7. Find **Recent Posts Extended** widget.
67
+
68
+ == Frequently Asked Questions ==
69
+
70
+ = How to filter the post query? =
71
+ You can use `rpwe_default_query_arguments` to filter it. Example:
72
+ `
73
+ add_filter( 'rpwe_default_query_arguments', 'your_custom_function' );
74
+ function your_custom_function( $args ) {
75
+ $args['posts_per_page'] = 10; // Changing the number of posts to show.
76
+ return $args;
77
+ }
78
+ `
79
+
80
+ = How to filter the post excerpt? =
81
+ Post excerpt now comes with filter to easily dev to change/customize it. `apply_filters( 'rpwe_excerpt', get_the_excerpt() )`
82
+
83
+ = Ordering not working! =
84
+ Did you installed any Post or Post Type Order? Please try to deactivate it and try again the ordering. [(related question)](http://wordpress.org/support/topic/ordering-set-to-descending-not-working)
85
+
86
+ = No image options =
87
+ Your theme needs to support Post Thumbnail, please go to http://codex.wordpress.org/Post_Thumbnails to read more info and how to activate it in your theme.
88
+
89
+ = How to add custom style? =
90
+ First, please uncheck the **Use Default Style** option then place the css code below in the Custom CSS box, then you can customize it to fit your needs
91
+ `
92
+ .rpwe-block ul {
93
+ list-style: none !important;
94
+ margin-left: 0 !important;
95
+ padding-left: 0 !important;
96
+ }
97
+ .rpwe-block li {
98
+ border-bottom: 1px solid #eee;
99
+ margin-bottom: 10px;
100
+ padding-bottom: 10px;
101
+ list-style-type: none;
102
+ }
103
+ .rpwe-block a {
104
+ display: inline !important;
105
+ text-decoration: none;
106
+ }
107
+ .rpwe-block h3 {
108
+ background: none !important;
109
+ clear: none;
110
+ margin-bottom: 0 !important;
111
+ margin-top: 0 !important;
112
+ font-weight: 400;
113
+ font-size: 12px !important;
114
+ line-height: 1.5em;
115
+ }
116
+ .rpwe-thumb {
117
+ border: 1px solid #eee !important;
118
+ box-shadow: none !important;
119
+ margin: 2px 10px 2px 0;
120
+ padding: 3px !important;
121
+ }
122
+ .rpwe-summary {
123
+ font-size: 12px;
124
+ }
125
+ .rpwe-time {
126
+ color: #bbb;
127
+ font-size: 11px;
128
+ }
129
+ .rpwe-alignleft {
130
+ display: inline;
131
+ float: left;
132
+ }
133
+ .rpwe-alignright {
134
+ display: inline;
135
+ float: right;
136
+ }
137
+ .rpwe-aligncenter {
138
+ display: block;
139
+ margin-left: auto;
140
+ margin-right: auto;
141
+ }
142
+ .rpwe-clearfix:before,.rpwe-clearfix:after {
143
+ content: "";
144
+ display: table !important;
145
+ }
146
+ .rpwe-clearfix:after {
147
+ clear: both;
148
+ }
149
+ .rpwe-clearfix {
150
+ zoom: 1;
151
+ }
152
+ `
153
+
154
+ = Why so many !important in the css code? =
155
+ I know it's not good but I have a good reason, the `!important` is to make sure the built-in style compatible with all themes. But if you don't like it, you can turn of the **Use Default Styles** and remove all custom css code in the **Custom CSS** box then create your own style.
156
+
157
+ = Available filters =
158
+ Default arguments
159
+ `
160
+ rpwe_default_args
161
+ `
162
+
163
+ Post excerpt
164
+ `
165
+ rpwe_excerpt
166
+ `
167
+
168
+ Post markup
169
+ `
170
+ rpwe_markup
171
+ `
172
+
173
+ Post query arguments
174
+ `
175
+ rpwe_default_query_arguments
176
+ `
177
+
178
+ == Screenshots ==
179
+
180
+ 1. The widget settings
181
+
182
+ == Shorcode Explanation ==
183
+
184
+ Explanation of shortcode options:
185
+
186
+ Basic shortcode
187
+ `
188
+ [rpwe]
189
+ `
190
+
191
+ Display 10 recent posts
192
+ `
193
+ [rpwe limit="10"]
194
+ `
195
+
196
+ Display 10 recent posts with thumbnail
197
+ `
198
+ [rpwe limit="10" thumb="true"]
199
+ `
200
+
201
+ **Here's the full default shortcode arguments**
202
+ `
203
+ limit="5"
204
+ offset=""
205
+ order="DESC"
206
+ orderby="date"
207
+ post_type="post"
208
+ cat=""
209
+ tag=""
210
+ taxonomy=""
211
+ post_type="post"
212
+ post_status="publish"
213
+ ignore_sticky="1"
214
+ taxonomy=""
215
+ excerpt="false"
216
+ length="10"
217
+ thumb="true"
218
+ thumb_height="45"
219
+ thumb_width="45"
220
+ thumb_default="http://placehold.it/45x45/f0f0f0/ccc"
221
+ thumb_align="rpwe-alignleft"
222
+ date="true"
223
+ readmore="false"
224
+ readmore_text="Read More &raquo;"
225
+ styles_default="true"
226
+ cssID=""
227
+ before=""
228
+ after=""
229
+ `
230
+
231
+ == Changelog ==
232
+
233
+ **1.1.0**
234
+
235
+ Release Date: Oct 25, 2021
236
+
237
+ This release comes with several fixes and enhancements to support the new Widget Block in WordPress 5.8.
238
+
239
+ **Enhancements:**
240
+
241
+ - Adds `height` and `width` attribute to the image thumbnail.
242
+
243
+ **Bugfixes:**
244
+
245
+ - Fixes a bug the widget couldn't load on new Widgets Block page.
246
+
247
+ **Warning:**
248
+
249
+ Current thumbnail resize system will be deprecated and replaced with WordPress built-in thumbnail resize function.
250
+
251
+
252
+
rpwe.php CHANGED
@@ -1,136 +1,123 @@
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
- *
14
- * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
15
- * General Public License as published by the Free Software Foundation; either version 2 of the License,
16
- * or (at your option) any later version.
17
- *
18
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
19
- * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20
- *
21
- * You should have received a copy of the GNU General Public License along with this program; if not, write
22
- * to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
- *
24
- * @package Recent_Posts_Widget_Extended
25
- * @since 0.1
26
- * @author Satrya
27
- * @copyright Copyright (c) 2014, Satrya
28
- * @license http://www.gnu.org/licenses/gpl-2.0.html
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;
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.1.0
8
+ * Requires at least: 5.8
9
+ * Requires PHP: 7.2
10
+ * Author: Idenovasi
11
+ * Author URI: https://idenovasi.com/
12
+ * License: GPL v2 or later
13
+ * License URI: https://www.gnu.org/licenses/gpl-2.0.html
14
+ * Text Domain: recent-posts-widget-extended
15
+ * Domain Path: /languages
16
+ */
17
+
18
+ // Exit if accessed directly
19
+ if (!defined('ABSPATH')) exit;
20
+
21
+ class RPW_Extended {
22
+
23
+ /**
24
+ * PHP5 constructor method.
25
+ *
26
+ * @since 0.1
27
+ */
28
+ public function __construct() {
29
+
30
+ // Set the constants needed by the plugin.
31
+ add_action('plugins_loaded', array(&$this, 'constants'), 1);
32
+
33
+ // Internationalize the text strings used.
34
+ add_action('plugins_loaded', array(&$this, 'i18n'), 2);
35
+
36
+ // Load the functions files.
37
+ add_action('plugins_loaded', array(&$this, 'includes'), 3);
38
+
39
+ // Load the admin style.
40
+ add_action('admin_enqueue_scripts', array(&$this, 'admin_style'));
41
+
42
+ // Register widget.
43
+ add_action('widgets_init', array(&$this, 'register_widget'));
44
+
45
+ // Register new image size.
46
+ add_action('init', array(&$this, 'register_image_size'));
47
+ }
48
+
49
+ /**
50
+ * Defines constants used by the plugin.
51
+ *
52
+ * @since 0.1
53
+ */
54
+ public function constants() {
55
+
56
+ // Set constant path to the plugin directory.
57
+ define('RPWE_DIR', trailingslashit(plugin_dir_path(__FILE__)));
58
+
59
+ // Set the constant path to the plugin directory URI.
60
+ define('RPWE_URI', trailingslashit(plugin_dir_url(__FILE__)));
61
+
62
+ // Set the constant path to the includes directory.
63
+ define('RPWE_INCLUDES', RPWE_DIR . trailingslashit('includes'));
64
+
65
+ // Set the constant path to the includes directory.
66
+ define('RPWE_CLASS', RPWE_DIR . trailingslashit('classes'));
67
+
68
+ // Set the constant path to the assets directory.
69
+ define('RPWE_ASSETS', RPWE_URI . trailingslashit('assets'));
70
+ }
71
+
72
+ /**
73
+ * Loads the translation files.
74
+ *
75
+ * @since 0.1
76
+ */
77
+ public function i18n() {
78
+ load_plugin_textdomain('recent-posts-widget-extended', false, dirname(plugin_basename(__FILE__)) . '/languages/');
79
+ }
80
+
81
+ /**
82
+ * Loads the initial files needed by the plugin.
83
+ *
84
+ * @since 0.1
85
+ */
86
+ public function includes() {
87
+ require_once(RPWE_INCLUDES . 'resizer.php');
88
+ require_once(RPWE_INCLUDES . 'functions.php');
89
+ require_once(RPWE_INCLUDES . 'shortcode.php');
90
+ require_once(RPWE_INCLUDES . 'helpers.php');
91
+ }
92
+
93
+ /**
94
+ * Register custom style for the widget settings.
95
+ *
96
+ * @since 0.8
97
+ */
98
+ public function admin_style() {
99
+ // Loads the widget style.
100
+ wp_enqueue_style('rpwe-admin-style', trailingslashit(RPWE_ASSETS) . 'css/rpwe-admin.css', null, null);
101
+ }
102
+
103
+ /**
104
+ * Register the widget.
105
+ *
106
+ * @since 0.9.1
107
+ */
108
+ public function register_widget() {
109
+ require_once(RPWE_CLASS . 'widget.php');
110
+ register_widget('Recent_Posts_Widget_Extended');
111
+ }
112
+
113
+ /**
114
+ * Register new image size.
115
+ *
116
+ * @since 0.9.4
117
+ */
118
+ function register_image_size() {
119
+ add_image_size('rpwe-thumbnail', 45, 45, true);
120
+ }
121
+ }
122
+
123
+ new RPW_Extended;
 
 
 
 
 
 
 
 
 
 
 
 
 
screenshot-1.png DELETED
Binary file