Advanced Random Posts Widget - Version 2.0.7

Version Description

  • 08/14/2015 =
  • Fix: Hide widget if no posts exist
  • Add: Add display post modified date option
Download this release

Release Info

Developer satrya
Plugin Icon 128x128 Advanced Random Posts Widget
Version 2.0.7
Comparing to
See all releases

Code changes from version 2.0.6 to 2.0.7

Files changed (6) hide show
  1. arpw.php +2 -2
  2. classes/widget.php +23 -14
  3. includes/form.php +7 -0
  4. includes/functions.php +7 -0
  5. languages/arpw.pot +20 -8
  6. readme.txt +13 -21
arpw.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
- * Plugin Name: Advanced Random Posts Widget
4
  * Plugin URI: http://satrya.me/projects/advanced-random-posts-widget/
5
  * Description: Easy to display random posts via shortcode or widget.
6
- * Version: 2.0.6
7
  * Author: Satrya
8
  * Author URI: http://satrya.me/
9
  * Author Email: satrya@satrya.me
1
  <?php
2
  /**
3
+ * Plugin Name: Random Posts Widget Extended
4
  * Plugin URI: http://satrya.me/projects/advanced-random-posts-widget/
5
  * Description: Easy to display random posts via shortcode or widget.
6
+ * Version: 2.0.7
7
  * Author: Satrya
8
  * Author URI: http://satrya.me/
9
  * Author Email: satrya@satrya.me
classes/widget.php CHANGED
@@ -46,23 +46,31 @@ class Advanced_Random_Posts_Widget extends WP_Widget {
46
  function widget( $args, $instance ) {
47
  extract( $args );
48
 
49
- // Output the theme's $before_widget wrapper.
50
- echo $before_widget;
51
 
52
- // If both title and title url is not empty, display it.
53
- if ( ! empty( $instance['title_url'] ) && ! empty( $instance['title'] ) ) {
54
- 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;
55
 
56
- // If the title not empty, display it.
57
- } elseif ( ! empty( $instance['title'] ) ) {
58
- echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
59
- }
60
 
61
- // Get the random posts query.
62
- echo arpw_get_random_posts( $instance );
 
63
 
64
- // Close the theme's widget wrapper.
65
- echo $after_widget;
 
 
 
 
 
 
 
 
 
 
66
 
67
  }
68
 
@@ -76,7 +84,7 @@ class Advanced_Random_Posts_Widget extends WP_Widget {
76
  $instance = $old_instance;
77
 
78
  $instance['title'] = strip_tags( $new_instance['title'] );
79
- $instance['title_url'] = esc_url( $new_instance['title_url'] );
80
 
81
  $instance['offset'] = (int) $new_instance['offset'];
82
  $instance['limit'] = (int) $new_instance['limit'];
@@ -97,6 +105,7 @@ class Advanced_Random_Posts_Widget extends WP_Widget {
97
  $instance['excerpt'] = isset( $new_instance['excerpt'] ) ? (bool) $new_instance['excerpt'] : false;
98
  $instance['excerpt_length'] = (int) $new_instance['excerpt_length'];
99
  $instance['date'] = isset( $new_instance['date'] ) ? (bool) $new_instance['date'] : false;
 
100
  $instance['date_relative'] = isset( $new_instance['date_relative'] ) ? (bool) $new_instance['date_relative'] : false;
101
 
102
  $instance['css'] = $new_instance['css'];
46
  function widget( $args, $instance ) {
47
  extract( $args );
48
 
49
+ // Get the random posts.
50
+ $random = arpw_get_random_posts( $instance );
51
 
52
+ // Check if the random posts exist
53
+ if ( $random ) :
 
54
 
55
+ // Output the theme's $before_widget wrapper.
56
+ echo $before_widget;
 
 
57
 
58
+ // If both title and title url is not empty, display it.
59
+ if ( ! empty( $instance['title_url'] ) && ! empty( $instance['title'] ) ) {
60
+ 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;
61
 
62
+ // If the title not empty, display it.
63
+ } elseif ( ! empty( $instance['title'] ) ) {
64
+ echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
65
+ }
66
+
67
+ // Get the random posts query.
68
+ echo $random;
69
+
70
+ // Close the theme's widget wrapper.
71
+ echo $after_widget;
72
+
73
+ endif;
74
 
75
  }
76
 
84
  $instance = $old_instance;
85
 
86
  $instance['title'] = strip_tags( $new_instance['title'] );
87
+ $instance['title_url'] = esc_url_raw( $new_instance['title_url'] );
88
 
89
  $instance['offset'] = (int) $new_instance['offset'];
90
  $instance['limit'] = (int) $new_instance['limit'];
105
  $instance['excerpt'] = isset( $new_instance['excerpt'] ) ? (bool) $new_instance['excerpt'] : false;
106
  $instance['excerpt_length'] = (int) $new_instance['excerpt_length'];
107
  $instance['date'] = isset( $new_instance['date'] ) ? (bool) $new_instance['date'] : false;
108
+ $instance['date_modified'] = isset( $new_instance['date_modified'] ) ? (bool) $new_instance['date_modified'] : false;
109
  $instance['date_relative'] = isset( $new_instance['date_relative'] ) ? (bool) $new_instance['date_relative'] : false;
110
 
111
  $instance['css'] = $new_instance['css'];
includes/form.php CHANGED
@@ -212,6 +212,13 @@
212
  </label>
213
  </p>
214
 
 
 
 
 
 
 
 
215
  <p>
216
  <input id="<?php echo $this->get_field_id( 'date_relative' ); ?>" name="<?php echo $this->get_field_name( 'date_relative' ); ?>" type="checkbox" <?php checked( $instance['date_relative'] ); ?> />
217
  <label for="<?php echo $this->get_field_id( 'date_relative' ); ?>">
212
  </label>
213
  </p>
214
 
215
+ <p>
216
+ <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'] ); ?> />
217
+ <label for="<?php echo $this->get_field_id( 'date_modified' ); ?>">
218
+ <?php _e( 'Display Modified Date', 'arpw' ); ?>
219
+ </label>
220
+ </p>
221
+
222
  <p>
223
  <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'] ); ?> />
224
  <label for="<?php echo $this->get_field_id( 'date_relative' ); ?>">
includes/functions.php CHANGED
@@ -40,6 +40,7 @@ function arpw_get_default_args() {
40
  'excerpt' => false,
41
  'excerpt_length' => 10,
42
  'date' => false,
 
43
  'date_relative' => false,
44
 
45
  'css' => '',
@@ -153,6 +154,12 @@ function arpw_get_random_posts( $args = array() ) {
153
  $date = sprintf( __( '%s ago', 'arpw' ), human_time_diff( get_the_date( 'U' ), current_time( 'timestamp' ) ) );
154
  endif;
155
  $html .= '<time class="arpw-time published" datetime="' . esc_html( get_the_date( 'c' ) ) . '">' . esc_html( $date ) . '</time>';
 
 
 
 
 
 
156
  endif;
157
 
158
  if ( $args['excerpt'] ) :
40
  'excerpt' => false,
41
  'excerpt_length' => 10,
42
  'date' => false,
43
+ 'date_modified' => false,
44
  'date_relative' => false,
45
 
46
  'css' => '',
154
  $date = sprintf( __( '%s ago', 'arpw' ), human_time_diff( get_the_date( 'U' ), current_time( 'timestamp' ) ) );
155
  endif;
156
  $html .= '<time class="arpw-time published" datetime="' . esc_html( get_the_date( 'c' ) ) . '">' . esc_html( $date ) . '</time>';
157
+ elseif ( $args['date_modified'] ) : // if both date functions are provided, we use date to be backwards compatible
158
+ $date = get_the_modified_date();
159
+ if ( $args['date_relative'] ) :
160
+ $date = sprintf( __( '%s ago', 'rpwe' ), human_time_diff( get_the_modified_date( 'U' ), current_time( 'timestamp' ) ) );
161
+ endif;
162
+ $html .= '<time class="arpw-time modfied" datetime="' . esc_html( get_the_modified_date( 'c' ) ) . '">' . esc_html( $date ) . '</time>';
163
  endif;
164
 
165
  if ( $args['excerpt'] ) :
languages/arpw.pot CHANGED
@@ -1,17 +1,17 @@
1
  # Copyright (C) 2015 Satrya
2
- # This file is distributed under the same license as the Advanced Random Posts Widget package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Advanced Random Posts Widget 2.0.3\n"
6
  "Report-Msgid-Bugs-To: http://satrya.me/\n"
7
- "POT-Creation-Date: 2015-01-03 18:12:55+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
  "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: Satrya (satrya@satrya.me)\n"
13
  "Language-Team: Satrya (satrya@satrya.me)\n"
14
- "X-Generator: grunt-wp-i18n 0.4.9\n"
15
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
16
  "X-Poedit-Basepath: ..\n"
17
  "X-Poedit-Language: English\n"
@@ -150,23 +150,35 @@ msgid "Display Date"
150
  msgstr ""
151
 
152
  #: includes/form.php:218
 
 
 
 
153
  msgid "Use Relative Date. eg: 5 days ago"
154
  msgstr ""
155
 
156
- #: includes/functions.php:147
 
 
 
 
 
 
 
 
157
  msgid "Permalink to %s"
158
  msgstr ""
159
 
160
- #: includes/functions.php:152
161
  msgid "%s ago"
162
  msgstr ""
163
 
164
  #. Plugin Name of the plugin/theme
165
- msgid "Advanced Random Posts Widget"
166
  msgstr ""
167
 
168
  #. Plugin URI of the plugin/theme
169
- msgid "http://wordpress.org/plugins/advanced-random-posts-widget/"
170
  msgstr ""
171
 
172
  #. Description of the plugin/theme
1
  # Copyright (C) 2015 Satrya
2
+ # This file is distributed under the same license as the Random Posts Widget Extended package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Random Posts Widget Extended 2.0.7\n"
6
  "Report-Msgid-Bugs-To: http://satrya.me/\n"
7
+ "POT-Creation-Date: 2015-08-14 06:54:18+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
  "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: Satrya (satrya@satrya.me)\n"
13
  "Language-Team: Satrya (satrya@satrya.me)\n"
14
+ "X-Generator: grunt-wp-i18n 0.5.3\n"
15
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
16
  "X-Poedit-Basepath: ..\n"
17
  "X-Poedit-Language: English\n"
150
  msgstr ""
151
 
152
  #: includes/form.php:218
153
+ msgid "Display Modified Date"
154
+ msgstr ""
155
+
156
+ #: includes/form.php:225
157
  msgid "Use Relative Date. eg: 5 days ago"
158
  msgstr ""
159
 
160
+ #: includes/form.php:235
161
+ msgid "Custom CSS"
162
+ msgstr ""
163
+
164
+ #: includes/form.php:238
165
+ msgid "You can find the plugin css selector on %1$sFAQ page%2$s."
166
+ msgstr ""
167
+
168
+ #: includes/functions.php:149
169
  msgid "Permalink to %s"
170
  msgstr ""
171
 
172
+ #: includes/functions.php:154 includes/functions.php:160
173
  msgid "%s ago"
174
  msgstr ""
175
 
176
  #. Plugin Name of the plugin/theme
177
+ msgid "Random Posts Widget Extended"
178
  msgstr ""
179
 
180
  #. Plugin URI of the plugin/theme
181
+ msgid "http://satrya.me/projects/advanced-random-posts-widget/"
182
  msgstr ""
183
 
184
  #. Description of the plugin/theme
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
- === Advanced Random Posts Widget ===
2
- Contributors: satrya
3
  Tags: random posts, thumbnail, widget, widgets, sidebar, excerpt, category, post tag, post type, taxonomy, shortcode, multiple widgets
4
  Requires at least: 4.0
5
  Tested up to: 4.3
6
- Stable tag: 2.0.6
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -28,38 +28,26 @@ Before asking a support question:
28
  * Display from all, specific or multiple tag.
29
  * Display from all, specific or multiple taxonomy.
30
  * Display post date.
 
31
  * Post types.
32
  * Post status.
33
  * Allow you to set custom css class per widget.
34
  * Add custom html or text before and/or after random posts.
35
  * Multiple widgets.
36
 
37
- = Plugin Support =
38
- * [Get the Image](http://wordpress.org/plugins/get-the-image/).
39
- * [Page Builder by SiteOrigin](http://wordpress.org/plugins/siteorigin-panels/).
40
-
41
- = Image Sizes Issue =
42
-
43
- This plugin creates custom image sizes. If you use images that were uploaded to the media library before you installed this plugin, please install [Regenerate Thumbnails](https://wordpress.org/plugins/force-regenerate-thumbnails/) plugin to fix the image size.
44
-
45
  = Language =
46
  * English
47
  * Bahasa Indonesia
48
- * [Please contibute to submit your language](http://satrya.me/projects/advanced-random-posts-widget/)
49
 
50
  = Support =
51
 
52
- * Go to [forum support](http://wordpress.org/support/plugin/advanced-random-posts-widget).
53
  * [Rate/Review the plugin](http://wordpress.org/support/view/plugin-reviews/advanced-random-posts-widget).
54
- * Submit translation.
 
55
 
56
- = Plugin Info =
57
- * Developed by [Satrya](http://satrya.me/)
58
- * Check out the [Github](https://github.com/satrya/advanced-random-posts-widget) repo to contribute.
59
-
60
- = Posts Plugin Series =
61
- * [Recent Posts Widget Extended](http://wordpress.org/plugins/recent-posts-widget-extended/)
62
- * [Advanced Random Posts Widget](http://wordpress.org/plugins/advanced-random-posts-widget/)
63
 
64
  == Installation ==
65
 
@@ -168,6 +156,10 @@ after=""
168
 
169
  == Changelog ==
170
 
 
 
 
 
171
  = 2.0.6 - 07/12/2015 =
172
  * **Fix:** Deprecated function in WordPress 4.3
173
 
1
+ === Random Posts Widget Extended ===
2
+ Contributors: satrya, themephe
3
  Tags: random posts, thumbnail, widget, widgets, sidebar, excerpt, category, post tag, post type, taxonomy, shortcode, multiple widgets
4
  Requires at least: 4.0
5
  Tested up to: 4.3
6
+ Stable tag: 2.0.7
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
28
  * Display from all, specific or multiple tag.
29
  * Display from all, specific or multiple taxonomy.
30
  * Display post date.
31
+ * Display post modified date.
32
  * Post types.
33
  * Post status.
34
  * Allow you to set custom css class per widget.
35
  * Add custom html or text before and/or after random posts.
36
  * Multiple widgets.
37
 
 
 
 
 
 
 
 
 
38
  = Language =
39
  * English
40
  * Bahasa Indonesia
41
+ * [Please contibute to submit your language](https://github.com/themephe/advanced-random-posts-widget/issues)
42
 
43
  = Support =
44
 
45
+ * [Forum support](http://wordpress.org/support/plugin/advanced-random-posts-widget).
46
  * [Rate/Review the plugin](http://wordpress.org/support/view/plugin-reviews/advanced-random-posts-widget).
47
+ * [Submit translation](https://github.com/themephe/advanced-random-posts-widget/issues).
48
+ * [Contribute on Github](https://github.com/themephe/advanced-random-posts-widget/)
49
 
50
+ > Developed by [ThemePhe](https://themephe.com/) in Indonesia
 
 
 
 
 
 
51
 
52
  == Installation ==
53
 
156
 
157
  == Changelog ==
158
 
159
+ = 2.0.7 - 08/14/2015 =
160
+ * **Fix:** Hide widget if no posts exist
161
+ * **Add:** Add display post modified date option
162
+
163
  = 2.0.6 - 07/12/2015 =
164
  * **Fix:** Deprecated function in WordPress 4.3
165