Advanced Random Posts Widget - Version 2.0.0

Version Description

  • 9/05/2014 =
  • This is a major changes to the plugin, please re-save or re-install the plugin if you find it doesn't work properly.
  • Please read FAQ and Other Notes to read more about how the plugin works.
  • Tested for WordPress 4.0
  • Added shortcode support!
  • Added taxonomy support
  • Added post status support
  • Changed how the post thumbnail size works
  • Changed how the plugin style works
  • Update language
Download this release

Release Info

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

Code changes from version 1.5.1 to 2.0.0

arpw.php CHANGED
@@ -1,84 +1,153 @@
1
<?php
2
- /*
3
- Plugin Name: Advanced Random Posts Widget
4
- Plugin URI: http://wordpress.org/plugins/advanced-random-posts-widget/
5
- Description: Enables advanced random posts widget.
6
- Version: 1.5.1
7
- Author: Satrya
8
- Author URI: http://satrya.me/
9
- Author Email: satrya@satrya.me
10
- License: GPLv2
11
- */
12
13
// Exit if accessed directly
14
if ( ! defined( 'ABSPATH' ) ) exit;
15
16
- if ( ! class_exists( 'ARP_Widget' ) ) :
17
-
18
class ARP_Widget {
19
20
/**
21
* PHP5 constructor method.
22
*
23
- * @since 1.0
24
*/
25
public function __construct() {
26
27
- add_action( 'plugins_loaded' , array( &$this, 'constants' ), 1 );
28
29
- add_action( 'plugins_loaded' , array( &$this, 'i18n' ), 2 );
30
31
- add_action( 'plugins_loaded' , array( &$this, 'includes' ), 3 );
32
33
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_style' ) );
34
35
}
36
37
/**
38
* Defines constants used by the plugin.
39
*
40
- * @since 1.0
41
*/
42
public function constants() {
43
44
- define( 'ARPW_DIR' , trailingslashit( plugin_dir_path( __FILE__ ) ) );
45
46
- define( 'ARPW_URI' , trailingslashit( plugin_dir_url( __FILE__ ) ) );
47
48
- define( 'ARPW_INCLUDES', ARPW_DIR . trailingslashit( 'includes' ) );
49
50
}
51
52
/**
53
* Loads the translation files.
54
*
55
- * @since 1.0
56
*/
57
public function i18n() {
58
- /* Load the translation of the plugin. */
59
load_plugin_textdomain( 'arpw', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
60
}
61
62
/**
63
* Loads the initial files needed by the plugin.
64
*
65
- * @since 1.0
66
*/
67
public function includes() {
68
- require_once( ARPW_INCLUDES . 'widget-advanced-random-posts.php' );
69
}
70
71
/**
72
- * Register custom style for the widget setting.
73
*
74
- * @since 1.5
75
*/
76
function admin_style() {
77
- wp_enqueue_style( 'arpw-admin-style', ARPW_URI . 'includes/admin.css' );
78
}
79
80
}
81
82
- new ARP_Widget;
83
- endif;
84
- ?>
1
<?php
2
+ /**
3
+ * Plugin Name: Advanced Random Posts Widget
4
+ * Plugin URI: http://wordpress.org/plugins/advanced-random-posts-widget/
5
+ * Description: Easy to display random posts via shortcode or widget.
6
+ * Version: 2.0.0
7
+ * Author: Satrya
8
+ * Author URI: http://satrya.me/
9
+ * Author Email: satrya@satrya.me
10
+ *
11
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
12
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
13
+ * or (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
16
+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
+ *
18
+ * You should have received a copy of the GNU General Public License along with this program; if not, write
19
+ * to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
+ *
21
+ * @package Advanced_Random_Posts_Widget
22
+ * @since 0.0.1
23
+ * @author Satrya
24
+ * @copyright Copyright (c) 2014, Satrya
25
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
26
+ */
27
28
// Exit if accessed directly
29
if ( ! defined( 'ABSPATH' ) ) exit;
30
31
class ARP_Widget {
32
33
/**
34
* PHP5 constructor method.
35
*
36
+ * @since 0.0.1
37
*/
38
public function __construct() {
39
40
+ // Set the constants needed by the plugin.
41
+ add_action( 'plugins_loaded', array( &$this, 'constants' ), 1 );
42
43
+ // Internationalize the text strings used.
44
+ add_action( 'plugins_loaded', array( &$this, 'i18n' ), 2 );
45
46
+ // Load the functions files.
47
+ add_action( 'plugins_loaded', array( &$this, 'includes' ), 3 );
48
49
+ // Load the admin style.
50
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_style' ) );
51
52
+ // Register widget.
53
+ add_action( 'widgets_init', array( &$this, 'register_widget' ) );
54
+
55
+ // Register new image size.
56
+ add_action( 'init', array( &$this, 'register_image_size' ) );
57
+
58
+ // Enqueue the front-end style.
59
+ add_action( 'wp_enqueue_scripts', array( &$this, 'plugin_style' ) );
60
+
61
}
62
63
/**
64
* Defines constants used by the plugin.
65
*
66
+ * @since 0.0.1
67
*/
68
public function constants() {
69
70
+ // Set constant path to the plugin directory.
71
+ define( 'ARPW_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
72
+
73
+ // Set the constant path to the plugin directory URI.
74
+ define( 'ARPW_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
75
+
76
+ // Set the constant path to the includes directory.
77
+ define( 'ARPW_INC', ARPW_DIR . trailingslashit( 'includes' ) );
78
79
+ // Set the constant path to the classes directory.
80
+ define( 'ARPW_CLASS', ARPW_DIR . trailingslashit( 'classes' ) );
81
82
+ // Set the constant path to the assets directory.
83
+ define( 'ARPW_ASSETS', ARPW_URI . trailingslashit( 'assets' ) );
84
85
}
86
87
/**
88
* Loads the translation files.
89
*
90
+ * @since 0.0.1
91
*/
92
public function i18n() {
93
load_plugin_textdomain( 'arpw', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
94
}
95
96
/**
97
* Loads the initial files needed by the plugin.
98
*
99
+ * @since 0.0.1
100
*/
101
public function includes() {
102
+ require_once( ARPW_INC . 'functions.php' );
103
+ require_once( ARPW_INC . 'shortcode.php' );
104
}
105
106
/**
107
+ * Register custom style for the widget settings.
108
*
109
+ * @since 0.0.1
110
*/
111
function admin_style() {
112
+
113
+ // Check if current screen is Widgets page.
114
+ if ( 'widgets' != get_current_screen()->base ) {
115
+ return;
116
+ }
117
+
118
+ // Loads the widget style.
119
+ wp_enqueue_style( 'arpw-admin-style', trailingslashit( ARPW_ASSETS ) . 'css/arpw-admin.css', array(), null );
120
+
121
+ }
122
+
123
+ /**
124
+ * Register the widget.
125
+ *
126
+ * @since 0.0.1
127
+ */
128
+ function register_widget() {
129
+ require_once( ARPW_CLASS . 'widget.php' );
130
+ register_widget( 'Advanced_Random_Posts_Widget' );
131
+ }
132
+
133
+ /**
134
+ * Register new image size.
135
+ *
136
+ * @since 0.0.1
137
+ */
138
+ function register_image_size() {
139
+ add_image_size( 'arpw-thumbnail', 50, 50, true );
140
+ }
141
+
142
+ /**
143
+ * Enqueue front-end style.
144
+ *
145
+ * @since 0.0.1
146
+ */
147
+ function plugin_style() {
148
+ wp_enqueue_style( 'arpw-style', trailingslashit( ARPW_ASSETS ) . 'css/arpw-frontend.css', array(), null );
149
}
150
151
}
152
153
+ new ARP_Widget;
assets/css/arpw-admin.css ADDED
@@ -0,0 +1,37 @@
1
+ .widgets-php .arpw-columns-3 {
2
+ overflow: hidden;
3
+ float: left;
4
+ width: 31%;
5
+ margin-right: 3.5%;
6
+ }
7
+
8
+ .widgets-php .arpw-columns-3 select.widefat {
9
+ width: 98.5%;
10
+ }
11
+
12
+ .widgets-php .arpw-column-last {
13
+ float: right;
14
+ margin-right: 0;
15
+ }
16
+
17
+ .widgets-php .arpw-columns-3 label {
18
+ font-size: 11px;
19
+ }
20
+
21
+ .widgets-php .arpw-columns-3 p small {
22
+ color: #777;
23
+ font-style: italic;
24
+ }
25
+
26
+ .small-input {
27
+ width: 78px;
28
+ }
29
+
30
+ .arpw-block {
31
+ display: block;
32
+ }
33
+
34
+ label.input-checkbox {
35
+ width: 100px;
36
+ display: inline-block;
37
+ }
assets/css/arpw-frontend.css ADDED
@@ -0,0 +1,26 @@
1
+ .arpw-ul {
2
+ list-style: none;
3
+ }
4
+
5
+ .arpw-li {
6
+ margin-bottom: 10px;
7
+ }
8
+
9
+ .arpw-time {
10
+ display: block;
11
+ color: #aaa;
12
+ }
13
+
14
+ .arpw-clearfix:before,
15
+ .arpw-clearfix:after {
16
+ content: "";
17
+ display: table;
18
+ }
19
+
20
+ .arpw-clearfix:after {
21
+ clear:both;
22
+ }
23
+
24
+ .arpw-clearfix {
25
+ zoom:1;
26
+ }
classes/widget.php ADDED
@@ -0,0 +1,120 @@
1
+ <?php
2
+ /**
3
+ * Custom random posts widget.
4
+ *
5
+ * @package Advanced_Random_Posts_Widget
6
+ * @since 0.0.1
7
+ * @author Satrya
8
+ * @copyright Copyright (c) 2014, Satrya
9
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
10
+ */
11
+ class Advanced_Random_Posts_Widget extends WP_Widget {
12
+
13
+ /**
14
+ * Sets up the widgets.
15
+ *
16
+ * @since 0.0.1
17
+ */
18
+ function __construct() {
19
+
20
+ // Set up the widget options.
21
+ $widget_options = array(
22
+ 'classname' => 'arpw-widget-random',
23
+ 'description' => __( 'An advanced widget that gives you total control over the output of the random posts.', 'arpw' )
24
+ );
25
+
26
+ $control_ops = array(
27
+ 'width' => 700,
28
+ 'height' => 350,
29
+ );
30
+
31
+ // Create the widget.
32
+ $this->WP_Widget(
33
+ 'arpw-widget', // $this->id_base
34
+ __( 'Random Posts', 'arpw' ), // $this->name
35
+ $widget_options, // $this->widget_options
36
+ $control_ops // $this->control_options
37
+ );
38
+
39
+ }
40
+
41
+ /**
42
+ * Outputs the widget based on the arguments input through the widget controls.
43
+ *
44
+ * @since 0.0.1
45
+ */
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
+
69
+ /**
70
+ * Updates the widget control options for the particular instance of the widget.
71
+ *
72
+ * @since 0.0.1
73
+ */
74
+ function update( $new_instance, $old_instance ) {
75
+
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'];
83
+ $instance['ignore_sticky'] = isset( $new_instance['ignore_sticky'] ) ? (bool) $new_instance['ignore_sticky'] : 0;
84
+ $instance['post_type'] = esc_attr( $new_instance['post_type'] );
85
+ $instance['post_status'] = esc_attr( $new_instance['post_status'] );
86
+ $instance['taxonomy'] = esc_attr( $new_instance['taxonomy'] );
87
+
88
+ $instance['thumbnail'] = isset( $new_instance['thumbnail'] ) ? (bool) $new_instance['thumbnail'] : false;
89
+ $instance['thumbnail_size'] = esc_attr( $new_instance['thumbnail_size'] );
90
+ $instance['thumbnail_align'] = esc_attr( $new_instance['thumbnail_align'] );
91
+ $instance['excerpt'] = isset( $new_instance['excerpt'] ) ? (bool) $new_instance['excerpt'] : false;
92
+ $instance['excerpt_length'] = (int) $new_instance['excerpt_length'];
93
+ $instance['date'] = isset( $new_instance['date'] ) ? (bool) $new_instance['date'] : false;
94
+
95
+ $instance['css_class'] = sanitize_html_class( $new_instance['css_class'] );
96
+ $instance['before'] = wp_filter_post_kses( $new_instance['before'] );
97
+ $instance['after'] = wp_filter_post_kses( $new_instance['after'] );
98
+
99
+ return $instance;
100
+ }
101
+
102
+ /**
103
+ * Displays the widget control options in the Widgets admin screen.
104
+ *
105
+ * @since 0.0.1
106
+ */
107
+ function form( $instance ) {
108
+
109
+ // Merge the user-selected arguments with the defaults.
110
+ $instance = wp_parse_args( (array) $instance, arpw_get_default_args() );
111
+
112
+ // Extract the array to allow easy use of variables.
113
+ extract( $instance );
114
+
115
+ // Loads the widget form.
116
+ include( ARPW_INC . 'form.php' );
117
+
118
+ }
119
+
120
+ }
includes/form.php ADDED
@@ -0,0 +1,170 @@
1
+ <?php
2
+ /**
3
+ * Widget forms.
4
+ *
5
+ * @package Advanced_Random_Posts_Widget
6
+ * @since 0.0.1
7
+ * @author Satrya
8
+ * @copyright Copyright (c) 2014, Satrya
9
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
10
+ */
11
+ ?>
12
+
13
+ <div class="arpw-columns-3">
14
+
15
+ <p>
16
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>">
17
+ <?php _e( 'Title', 'arpw' ); ?>
18
+ </label>
19
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" />
20
+ </p>
21
+
22
+ <p>
23
+ <label for="<?php echo $this->get_field_id( 'title_url' ); ?>">
24
+ <?php _e( 'Title URL', 'arpw' ); ?>
25
+ </label>
26
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title_url' ); ?>" name="<?php echo $this->get_field_name( 'title_url' ); ?>" value="<?php echo esc_url( $instance['title_url'] ); ?>" placeholder="<?php echo esc_attr( 'http://' ); ?>" />
27
+ </p>
28
+
29
+ <p>
30
+ <label for="<?php echo $this->get_field_id( 'css_class' ); ?>">
31
+ <?php _e( 'CSS Class', 'arpw' ); ?>
32
+ </label>
33
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'css_class' ); ?>" name="<?php echo $this->get_field_name( 'css_class' ); ?>" value="<?php echo sanitize_html_class( $instance['css_class'] ); ?>" />
34
+ </p>
35
+
36
+ <p>
37
+ <label for="<?php echo $this->get_field_id( 'before' ); ?>">
38
+ <?php _e( 'HTML or text before the random posts', 'arpw' );?>
39
+ </label>
40
+ <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>
41
+ </p>
42
+
43
+ <p>
44
+ <label for="<?php echo $this->get_field_id( 'after' ); ?>">
45
+ <?php _e( 'HTML or text after the random posts', 'arpw' );?>
46
+ </label>
47
+ <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>
48
+ </p>
49
+
50
+ </div>
51
+
52
+ <div class="arpw-columns-3">
53
+
54
+ <p>
55
+ <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' ); ?>" />
56
+ <label for="<?php echo $this->get_field_id( 'ignore_sticky' ); ?>">
57
+ <?php _e( 'Ignore sticky posts', 'arpw' ); ?>
58
+ </label>
59
+ </p>
60
+
61
+ <p>
62
+ <label for="<?php echo $this->get_field_id( 'limit' ); ?>">
63
+ <?php _e( 'Number of posts to show', 'arpw' ); ?>
64
+ </label>
65
+ <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']; ?>" />
66
+ <small>-1 <?php _e( 'to show all posts.', 'arpw' ); ?></small>
67
+ </p>
68
+
69
+ <p>
70
+ <label for="<?php echo $this->get_field_id( 'offset' ); ?>">
71
+ <?php _e( 'Offset', 'arpw' ); ?>
72
+ </label>
73
+ <input type="number" step="1" min="0" class="widefat" id="<?php echo $this->get_field_id( 'offset' ); ?>" name="<?php echo $this->get_field_name( 'offset' ); ?>" value="<?php echo (int) $instance['offset']; ?>" />
74
+ <small><?php _e( 'The number of posts to skip', 'arpw' ); ?></small>
75
+ </p>
76
+
77
+ <p>
78
+ <label for="<?php echo $this->get_field_id( 'post_type' ); ?>">
79
+ <?php _e( 'Post type', 'arpw' ); ?>
80
+ </label>
81
+ <select class="widefat" id="<?php echo $this->get_field_id( 'post_type' ); ?>" name="<?php echo $this->get_field_name( 'post_type' ); ?>">
82
+ <?php foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $post_type ) { ?>
83
+ <option value="<?php echo esc_attr( $post_type->name ); ?>" <?php selected( $instance['post_type'], $post_type->name ); ?>><?php echo esc_html( $post_type->labels->singular_name ); ?></option>
84
+ <?php } ?>
85
+ </select>
86
+ </p>
87
+
88
+ <p>
89
+ <label for="<?php echo $this->get_field_id( 'post_status' ); ?>">
90
+ <?php _e( 'Post status', 'arpw' ); ?>
91
+ </label>
92
+ <select class="widefat" id="<?php echo $this->get_field_id( 'post_status' ); ?>" name="<?php echo $this->get_field_name( 'post_status' ); ?>" style="width:100%;">
93
+ <?php foreach ( get_available_post_statuses() as $status_value => $status_label ) { ?>
94
+ <option value="<?php echo esc_attr( $status_label ); ?>" <?php selected( $instance['post_status'], $status_label ); ?>><?php echo esc_html( ucfirst( $status_label ) ); ?></option>
95
+ <?php } ?>
96
+ </select>
97
+ </p>
98
+
99
+ <p>
100
+ <label for="<?php echo $this->get_field_id( 'taxonomy' ); ?>">
101
+ <?php _e( 'Limit to Taxonomy', 'arpw' ); ?>
102
+ </label>
103
+ <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'] ); ?>" />
104
+ <small><?php _e( 'Ex: category=1,2,4&amp;post_tag=6,12', 'arpw' );?><br />
105
+ <?php _e( 'Available: ', 'arpw' ); echo implode( ', ', get_taxonomies( array( 'public' => true ) ) ); ?></small>
106
+ </p>
107
+
108
+ </div>
109
+
110
+ <div class="arpw-columns-3 arpw-column-last">
111
+
112
+ <?php // Check if the theme support Post Thumbnail feature. ?>
113
+ <?php if ( current_theme_supports( 'post-thumbnails' ) ) : ?>
114
+
115
+ <p>
116
+ <input class="checkbox" type="checkbox" <?php checked( $instance['thumbnail'] ); ?> id="<?php echo $this->get_field_id( 'thumbnail' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail' ); ?>" />
117
+ <label for="<?php echo $this->get_field_id( 'thumbnail' ); ?>">
118
+ <?php _e( 'Display thumbnail', 'arpw' ); ?>
119
+ </label>
120
+ </p>
121
+
122
+ <p>
123
+ <label for="<?php echo $this->get_field_id( 'thumbnail_size' ); ?>">
124
+ <?php _e( 'Thumbnail Size ', 'arpw' ); ?>
125
+ </label>
126
+ <select class="widefat" id="<?php echo $this->get_field_id( 'thumbnail_size' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_size' ); ?>" style="width:100%;">
127
+ <?php foreach ( get_intermediate_image_sizes() as $size ) { ?>
128
+ <option value="<?php echo esc_attr( $size ); ?>" <?php selected( $instance['thumbnail_size'], $size ); ?>><?php echo esc_html( $size ); ?></option>
129
+ <?php } ?>
130
+ </select>
131
+ <small><?php printf( __( 'Please read %1$sFAQ%2$s for more information.', 'arpw' ), '<a href="http://wordpress.org/plugins/advanced-random-posts-widget/faq/" target="_blank">', '</a>' ); ?></small>
132
+ </p>
133
+
134
+ <p>
135
+ <label for="<?php echo $this->get_field_id( 'thumbnail_align' ); ?>">
136
+ <?php _e( 'Thumbnail Alignment', 'arpw' ); ?>
137
+ </label>
138
+ <select class="widefat" id="<?php echo $this->get_field_id( 'thumbnail_align' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_align' ); ?>" style="width:100%;">
139
+ <option value="left" <?php selected( $instance['thumbnail_align'], 'left' ); ?>><?php _e( 'Left', 'arpw' ) ?></option>
140
+ <option value="right" <?php selected( $instance['thumbnail_align'], 'right' ); ?>><?php _e( 'Right', 'arpw' ) ?></option>
141
+ <option value="center" <?php selected( $instance['thumbnail_align'], 'center' ); ?>><?php _e( 'Center', 'arpw' ) ?></option>
142
+ </select>
143
+ </p>
144
+
145
+ <?php endif; ?>
146
+
147
+ <p>
148
+ <input class="checkbox" type="checkbox" <?php checked( $instance['excerpt'] ); ?> id="<?php echo $this->get_field_id( 'excerpt' ); ?>" name="<?php echo $this->get_field_name( 'excerpt' ); ?>" />
149
+ <label for="<?php echo $this->get_field_id( 'excerpt' ); ?>">
150
+ <?php _e( 'Display excerpt', 'arpw' ); ?>
151
+ </label>
152
+ </p>
153
+
154
+ <p>
155
+ <label for="<?php echo $this->get_field_id( 'excerpt_length' ); ?>">
156
+ <?php _e( 'Excerpt Length', 'arpw' ); ?>
157
+ </label>
158
+ <input class="widefat" id="<?php echo $this->get_field_id( 'excerpt_length' ); ?>" name="<?php echo $this->get_field_name( 'excerpt_length' ); ?>" type="number" step="1" min="0" value="<?php echo (int)( $instance['excerpt_length'] ); ?>" />
159
+ </p>
160
+
161
+ <p>
162
+ <input class="checkbox" type="checkbox" <?php checked( $instance['date'] ); ?> id="<?php echo $this->get_field_id( 'date' ); ?>" name="<?php echo $this->get_field_name( 'date' ); ?>" />
163
+ <label for="<?php echo $this->get_field_id( 'date' ); ?>">
164
+ <?php _e( 'Display Date', 'arpw' ); ?>
165
+ </label>
166
+ </p>
167
+
168
+ </div>
169
+
170
+ <div class="clear"></div>
includes/functions.php ADDED
@@ -0,0 +1,193 @@
1
+ <?php
2
+ /**
3
+ * Various functions used by the plugin.
4
+ *
5
+ * @package Advanced_Random_Posts_Widget
6
+ * @since 0.0.1
7
+ * @author Satrya
8
+ * @copyright Copyright (c) 2014, Satrya
9
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
10
+ */
11
+
12
+ /**
13
+ * Sets up the default arguments.
14
+ *
15
+ * @since 0.0.1
16
+ */
17
+ function arpw_get_default_args() {
18
+
19
+ $defaults = array(
20
+ 'title' => esc_attr__( 'Random Posts', 'arpw' ),
21
+ 'title_url' => '',
22
+
23
+ 'offset' => 0,
24
+ 'limit' => 5,
25
+ 'orderby' => 'rand',
26
+ 'post_type' => 'post',
27
+ 'post_status' => 'publish',
28
+ 'ignore_sticky' => 1,
29
+ 'taxonomy' => '',
30
+
31
+ 'thumbnail' => false,
32
+ 'thumbnail_size' => 'arpw-thumbnail',
33
+ 'thumbnail_align' => 'left',
34
+ 'excerpt' => false,
35
+ 'excerpt_length' => 10,
36
+ 'date' => false,
37
+
38
+ 'css_class' => '',
39
+ 'before' => '',
40
+ 'after' => ''
41
+ );
42
+
43
+ // Allow plugins/themes developer to filter the default arguments.
44
+ return apply_filters( 'arpw_default_args', $defaults );
45
+
46
+ }
47
+
48
+ /**
49
+ * Outputs the random posts.
50
+ *
51
+ * @since 0.0.1
52
+ */
53
+ function arpw_random_posts( $args = array() ) {
54
+ echo arpw_get_random_posts( $args );
55
+ }
56
+
57
+ /**
58
+ * Generates the random posts markup.
59
+ *
60
+ * @since 0.0.1
61
+ * @param array $args
62
+ * @return string|array The HTML for the random posts.
63
+ */
64
+ function arpw_get_random_posts( $args = array() ) {
65
+
66
+ // Set up a default, empty $html variable.
67
+ $html = '';
68
+
69
+ // Get the default arguments.
70
+ $defaults = arpw_get_default_args();
71
+
72
+ // Merge the input arguments and the defaults.
73
+ $args = wp_parse_args( $args, $defaults );
74
+
75
+ // Extract the array to allow easy use of variables.
76
+ extract( $args );
77
+
78
+ // Allow devs to hook in stuff before the loop.
79
+ do_action( 'arpw_before_loop' );
80
+
81
+ // Get the posts query.
82
+ $posts = arpw_get_posts( $args );
83
+
84
+ if ( $posts->have_posts() ) :
85
+
86
+ $html = '<div id="arpw-random-posts" class="arpw-random-' . sanitize_html_class( $args['post_type'] ) . ' ' . sanitize_html_class( $args['css_class'] ) . '">';
87
+
88
+ $html .= '<ul class="arpw-ul">';
89
+
90
+ while ( $posts->have_posts() ) : $posts->the_post();
91
+
92
+ $html .= '<li class="arpw-li arpw-clearfix">';
93
+
94
+ if ( $args['thumbnail'] ) :
95
+
96
+ // Check if post has post thumbnail.
97
+ if ( has_post_thumbnail() ) :
98
+ $html .= '<a href="' . get_permalink() . '" rel="bookmark">';
99
+ $html .= get_the_post_thumbnail( get_the_ID(), $args['thumbnail_size'], array( 'alt' => esc_attr( get_the_title() ), 'class' => 'arpw-thumbnail align' . $args['thumbnail_align'] ) );
100
+ $html .= '</a>';
101
+
102
+ // If no post thumbnail found, check if Get The Image plugin exist and display the image.
103
+ elseif ( function_exists( 'get_the_image' ) ) :
104
+ $html .= get_the_image( array(
105
+ 'size' => $args['thumbnail_size'],
106
+ 'image_class' => 'arpw-thumbnail align' . $args['thumbnail_align'],
107
+ 'image_scan' => true,
108
+ 'link_to_post' => true,
109
+ ) );
110
+
111
+ // Display nothing.
112
+ else :
113
+ $html .= null;
114
+ endif;
115
+
116
+ endif;
117
+
118
+ $html .= '<a class="arpw-title" href="' . esc_url( get_permalink() ) . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'arpw' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark">' . esc_attr( get_the_title() ) . '</a>';
119
+
120
+ if ( $args['date'] ) :
121
+ $html .= '<time class="arpw-time published" datetime="' . esc_html( get_the_date( 'c' ) ) . '">' . esc_html( get_the_date() ) . '</time>';
122
+ endif;
123
+
124
+ if ( $args['excerpt'] ) :
125
+ $html .= '<div class="arpw-summary">' . wp_trim_words( get_the_excerpt(), $args['excerpt_length'], ' &hellip;' ) . '</div>';
126
+ endif;
127
+
128
+ $html .= '</li>';
129
+
130
+ endwhile;
131
+
132
+ $html .= '</ul>';
133
+
134
+ $html .= '</div><!-- Generated by WordPress Random Posts plugin -->';
135
+
136
+ endif;
137
+
138
+ // Restore original Post Data.
139
+ wp_reset_postdata();
140
+
141
+ // Allow devs to hook in stuff after the loop.
142
+ do_action( 'arpw_after_loop' );
143
+
144
+ // Return the related posts markup.
145
+ return $args['before'] . $html . $args['after'];
146
+
147
+ }
148
+
149
+ /**
150
+ * The posts query.
151
+ *
152
+ * @since 0.0.1
153
+ * @param array $args
154
+ * @return array
155
+ */
156
+ function arpw_get_posts( $args = array() ) {
157
+
158
+ /**
159
+ * Taxonomy query.
160
+ * Prop Miniloop plugin by Kailey Lampert.
161
+ */
162
+ parse_str( $args['taxonomy'], $taxes );
163
+ $tax_query = array();
164
+ foreach( array_keys( $taxes ) as $k => $slug ) {
165
+ $ids = explode( ',', $taxes[ $slug ] );
166
+ $tax_query[] = array(
167
+ 'taxonomy' => $slug,
168
+ 'field' => 'id',
169
+ 'terms' => $ids,
170
+ 'operator' => 'IN'
171
+ );
172
+ }
173
+
174
+ // Query arguments.
175
+ $query = array(
176
+ 'offset' => $args['offset'],
177
+ 'posts_per_page' => $args['limit'],
178
+ 'orderby' => $args['orderby'],
179
+ 'post_type' => $args['post_type'],
180
+ 'post_status' => $args['post_status'],
181
+ 'ignore_sticky_posts' => $args['ignore_sticky'],
182
+ 'tax_query' => $tax_query,
183
+ );
184
+
185
+ // Allow plugins/themes developer to filter the default query.
186
+ $query = apply_filters( 'arpw_query', $query );
187
+
188
+ // Perform the query.
189
+ $posts = new WP_Query( $query );
190
+
191
+ return $posts;
192
+
193
+ }
includes/shortcode.php ADDED
@@ -0,0 +1,21 @@
1
+ <?php
2
+ /**
3
+ * Shortcode helper
4
+ *
5
+ * @package Advanced_Random_Posts_Widget
6
+ * @since 0.0.1
7
+ * @author Satrya
8
+ * @copyright Copyright (c) 2014, Satrya
9
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
10
+ */
11
+
12
+ /**
13
+ * Display random posts with shortcode
14
+ *
15
+ * @since 0.0.1
16
+ */
17
+ function arpw_shortcode( $atts, $content ) {
18
+ $args = shortcode_atts( arpw_get_default_args(), $atts );
19
+ return arpw_get_random_posts( $args );
20
+ }
21
+ add_shortcode( 'arpw', 'arpw_shortcode' );
languages/arpw.mo CHANGED
Binary file
languages/arpw.po CHANGED
@@ -1,95 +1,133 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Advanced Random Posts Widget\n"
4
- "POT-Creation-Date: 2013-09-07 23:11+0700\n"
5
- "PO-Revision-Date: 2013-09-07 23:11+0700\n"
6
- "Last-Translator: M.Satrya <satrya@tokokoo.com>\n"
7
- "Language-Team: Satrya <satrya@satrya.me>\n"
8
- "Language: English\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.5.7\n"
13
- "X-Poedit-KeywordsList: __;_e;esc_attr__;esc_attr_e\n"
14
- "X-Poedit-Basepath: .\n"
15
- "Plural-Forms: nplurals=2; plural=n != 1;\n"
16
- "X-Poedit-SourceCharset: UTF-8\n"
17
- "X-Poedit-SearchPath-0: ..\n"
18
-
19
- #: ../includes/widget-advanced-random-posts.php:15
20
- msgid "Enable advanced random posts widget."
21
- msgstr ""
22
-
23
- #: ../includes/widget-advanced-random-posts.php:24
24
- msgid "Advanced Random Posts"
25
- msgstr ""
26
-
27
- #: ../includes/widget-advanced-random-posts.php:87
28
- #: ../includes/widget-advanced-random-posts.php:99
29
- #, php-format
30
- msgid "Permalink to %s"
31
- msgstr ""
32
-
33
- #: ../includes/widget-advanced-random-posts.php:103
34
- msgid " ago"
35
- msgstr ""
36
-
37
- #: ../includes/widget-advanced-random-posts.php:193
38
- msgid "Title:"
39
- msgstr ""
40
-
41
- #: ../includes/widget-advanced-random-posts.php:197
42
- msgid "Title URL:"
43
- msgstr ""
44
-
45
- #: ../includes/widget-advanced-random-posts.php:201
46
- msgid "CSS ID:"
47
- msgstr ""
48
-
49
- #: ../includes/widget-advanced-random-posts.php:205
50
- msgid "Use Default Styles"
51
- msgstr ""
52
-
53
- #: ../includes/widget-advanced-random-posts.php:209
54
- msgid "Custom CSS:"
55
- msgstr ""
56
-
57
- #: ../includes/widget-advanced-random-posts.php:211
58
- msgid "If you turn off the default styles, please create your own style."
59
- msgstr ""
60
-
61
- #: ../includes/widget-advanced-random-posts.php:219
62
- msgid "Limit:"
63
- msgstr ""
64
-
65
- #: ../includes/widget-advanced-random-posts.php:223
66
- msgid "Limit to specific or multiple Category: "
67
- msgstr ""
68
-
69
- #: ../includes/widget-advanced-random-posts.php:225
70
- msgid "Categories"
71
- msgstr ""
72
-
73
- #: ../includes/widget-advanced-random-posts.php:234
74
- msgid "Limit to specific or multiple Tag: "
75
- msgstr ""
76
-
77
- #: ../includes/widget-advanced-random-posts.php:252
78
- msgid "Display thumbnail?"
79
- msgstr ""
80
-
81
- #: ../includes/widget-advanced-random-posts.php:256
82
- msgid "Thumbnail size (height x width):"
83
- msgstr ""
84
-
85
- #: ../includes/widget-advanced-random-posts.php:264
86
- msgid "Display excerpt?"
87
- msgstr ""
88
-
89
- #: ../includes/widget-advanced-random-posts.php:268
90
- msgid "Excerpt length:"
91
- msgstr ""
92
-
93
- #: ../includes/widget-advanced-random-posts.php:273
94
- msgid "Display date?"
95
- msgstr ""
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Advanced Random Posts Widget v2.0.0\n"
4
+ "POT-Creation-Date: 2014-09-05 10:52+0700\n"
5
+ "PO-Revision-Date: 2014-09-05 10:52+0700\n"
6
+ "Last-Translator: Satrya <satrya@satrya.me>\n"
7
+ "Language-Team: Theme Junkie <satrya@theme-junkie.com>\n"
8
+ "Language: en_US\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.6.9\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-KeywordsList: _e;__;esc_attr__\n"
17
+ "X-Poedit-SearchPath-0: ..\n"
18
+
19
+ #: ../classes/widget.php:23
20
+ msgid ""
21
+ "An advanced widget that gives you total control over the output of the "
22
+ "random posts."
23
+ msgstr ""
24
+
25
+ #: ../classes/widget.php:34 ../includes/functions.php:20
26
+ msgid "Random Posts"
27
+ msgstr ""
28
+
29
+ #: ../includes/form.php:17
30
+ msgid "Title"
31
+ msgstr ""
32
+
33
+ #: ../includes/form.php:24
34
+ msgid "Title URL"
35
+ msgstr ""
36
+
37
+ #: ../includes/form.php:31
38
+ msgid "CSS Class"
39
+ msgstr ""
40
+
41
+ #: ../includes/form.php:38
42
+ msgid "HTML or text before the random posts"
43
+ msgstr ""
44
+
45
+ #: ../includes/form.php:45
46
+ msgid "HTML or text after the random posts"
47
+ msgstr ""
48
+
49
+ #: ../includes/form.php:57
50
+ msgid "Ignore sticky posts"
51
+ msgstr ""
52
+
53
+ #: ../includes/form.php:63
54
+ msgid "Number of posts to show"
55
+ msgstr ""
56
+
57
+ #: ../includes/form.php:66
58
+ msgid "to show all posts."
59
+ msgstr ""
60
+
61
+ #: ../includes/form.php:71
62
+ msgid "Offset"
63
+ msgstr ""
64
+
65
+ #: ../includes/form.php:74
66
+ msgid "The number of posts to skip"
67
+ msgstr ""
68
+
69
+ #: ../includes/form.php:79
70
+ msgid "Post type"
71
+ msgstr ""
72
+
73
+ #: ../includes/form.php:90
74
+ msgid "Post status"
75
+ msgstr ""
76
+
77
+ #: ../includes/form.php:101
78
+ msgid "Limit to Taxonomy"
79
+ msgstr ""
80
+
81
+ #: ../includes/form.php:104
82
+ msgid "Ex: category=1,2,4&amp;post_tag=6,12"
83
+ msgstr ""
84
+
85
+ #: ../includes/form.php:105
86
+ msgid "Available: "
87
+ msgstr ""
88
+
89
+ #: ../includes/form.php:118
90
+ msgid "Display thumbnail"
91
+ msgstr ""
92
+
93
+ #: ../includes/form.php:124
94
+ msgid "Thumbnail Size "
95
+ msgstr ""
96
+
97
+ #: ../includes/form.php:131
98
+ #, php-format
99
+ msgid "Please read %1$sFAQ%2$s for more information."
100
+ msgstr ""
101
+
102
+ #: ../includes/form.php:136
103
+ msgid "Thumbnail Alignment"
104
+ msgstr ""
105
+
106
+ #: ../includes/form.php:139
107
+ msgid "Left"
108
+ msgstr ""
109
+
110
+ #: ../includes/form.php:140
111
+ msgid "Right"
112
+ msgstr ""
113
+
114
+ #: ../includes/form.php:141
115
+ msgid "Center"
116
+ msgstr ""
117
+
118
+ #: ../includes/form.php:150
119
+ msgid "Display excerpt"
120
+ msgstr ""
121
+
122
+ #: ../includes/form.php:156
123
+ msgid "Excerpt Length"
124
+ msgstr ""
125
+
126
+ #: ../includes/form.php:164
127
+ msgid "Display Date"
128
+ msgstr ""
129
+
130
+ #: ../includes/functions.php:118
131
+ #, php-format
132
+ msgid "Permalink to %s"
133
+ msgstr ""
license.txt ADDED
@@ -0,0 +1,339 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ <signature of Ty Coon>, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
readme.txt CHANGED
@@ -1,88 +1,171 @@
1
- === Plugin Name ===
2
- Contributors: satrya
3
- Tags: random posts, random, thumbnails, widget, widgets, sidebar, excerpt, multiple widgets
4
- Requires at least: 3.5
5
- Tested up to: 3.6
6
- Stable tag: 1.5.1
7
License: GPLv2 or later
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
10
- Provides flexible and advanced random posts widget. Allows you to display them with thumbnails, post excerpt, multiple category and more.
11
12
== Description ==
13
14
- **After updating, please re-save the widget**
15
16
- This plugin will enable a custom, flexible and super advanced random posts widget. Allows you to display a list of the most random posts with thumbnail, excerpt and post date, also you can display it from all or specific or multiple category or tag.
17
18
- = Features Include: =
19
-
20
- * Display thumbnails, with customizable size.
21
* Display excerpt, with customizable length.
22
- * Display from all or a specific category.
23
* Display post date.
24
- * Support `get_the_image` function.
25
* Multiple widgets.
26
27
- **New Features**
28
29
- * CSS ID option
30
- * Widget title url
31
- * Turn on/off default style
32
- * Limit to spesfic or multiple category
33
- * Limit to spesfic or multiple tag
34
35
- = Ugly Image Sizes =
36
- 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](http://wordpress.org/extend/plugins/regenerate-thumbnails/) plugin to corrected the sizes.
37
38
= Support =
39
- * Go to [forum support](http://wordpress.org/support/plugin/advanced-random-posts-widget).
40
- * [Open issue on github](https://github.com/satrya/advanced-random-posts-widget/issues).
41
- * [Rate/Review the plugin](http://wordpress.org/support/view/plugin-reviews/advanced-random-posts-widget).
42
43
- = Developed by: =
44
- * [Satrya](http://satrya.me/) - [Twitter](https://twitter.com/msattt)
45
46
- **If you enjoy using this plugin, don't forget to rate it at [http://wordpress.org/support/view/plugin-reviews/advanced-random-posts-widget](http://wordpress.org/support/view/plugin-reviews/advanced-random-posts-widget)**
47
48
== Installation ==
49
50
- 1. Upload the 'advanced-random-posts-widget' folder to the `/wp-content/plugins/` directory
51
- 2. Activate the plugin through the 'Plugins' menu in WordPress
52
- 3. Go to the widgets page.
53
54
- == Screenshots ==
55
- 1. The widget settings
56
57
- == Changelog ==
58
59
- 1.5.1
60
- * Forgot to commit `admin.css`
61
62
- 1.5 - 09/07/2013
63
- * PLEASE RE-SAVE THE WIDGET
64
- * Fix title widget filter bug
65
- * Change Limit option to input text rather than selectbox
66
- * Add CSS ID option
67
- * Add widget title url
68
- * Add turn on off default styles
69
- * Add multiple category option
70
- * Add multiple tag option
71
- * Update language
72
73
- = 1.4 - 04/19/2013 =
74
- * Change support uri
75
76
- = 1.3 - 04/02/2013 =
77
- * Remove `a` tag when no thumbnail
78
- * Add custom css box
79
- * Inheritance `font-family`
80
81
- = 1.2 - 02/23/13 =
82
- * Minor update
83
84
- = 1.1 - 17/2/2013 =
85
- * Minor update
86
87
- = 1.0 - 10/2/2013 =
88
- * Initial release
1
+ === Advanced Random Posts Widget ===
2
+ Contributors: satrya, themejunkie
3
+ Tags: random posts, thumbnail, widget, widgets, sidebar, excerpt, category, post tag, post type, taxonomy, shortcode, multiple widgets
4
+ Requires at least: 3.6
5
+ Tested up to: 4.0
6
+ Stable tag: 2.0.0
7
License: GPLv2 or later
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
10
+ Provides flexible and advanced random posts. Display it via shortcode or widget with thumbnails, post excerpt, and much more!
11
12
== Description ==
13
14
+ This plugin will enable a custom, flexible and advanced random posts. It allows you to display a list of random posts via shortcode or widget with thumbnail, excerpt and post date, also you can display it from all or specific or multiple taxonomy.
15
16
+ = Features Include =
17
18
+ * WordPress 4.0 Support.
19
+ * Allow you to set title url.
20
+ * Display thumbnails, with customizable size and alignment.
21
* Display excerpt, with customizable length.
22
+ * Display from all, specific or multiple taxonomy.
23
* Display post date.
24
+ * Post types.
25
+ * Post status.
26
+ * Allow you to set custom css per widget.
27
+ * Add custom html or text before and/or after random posts.
28
* Multiple widgets.
29
30
+ = Plugin Support =
31
+ * [Get the Image](http://wordpress.org/plugins/get-the-image/).
32
+ * [Page Builder by SiteOrigin](http://wordpress.org/plugins/siteorigin-panels/).
33
34
+ = Image Sizes Issue =
35
36
+ 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](http://wordpress.org/extend/plugins/regenerate-thumbnails/) plugin to fix the image size.
37
38
= Support =
39
40
+ * Go to [forum support](http://wordpress.org/support/plugin/arpw).
41
+ * [Rate/Review the plugin](http://wordpress.org/support/view/plugin-reviews/arpw).
42
+ * Submit translation.
43
+
44
+ = Plugin Info =
45
+ * Developed by [Satrya](http://satrya.me/) & [Theme Junkie](http://www.theme-junkie.com/)
46
+ * Check out the [Github](https://github.com/satrya/arpw) repo to contribute.
47
48
+ = Posts Plugin Series =
49
+ * [Recent Posts Widget Extended](http://wordpress.org/plugins/recent-posts-widget-extended/)
50
+ * [Advanced Random Posts Widget](http://wordpress.org/plugins/advanced-random-posts-widget/)
51
52
== Installation ==
53
54
+ **Through Dashboard**
55
56
+ 1. Log in to your WordPress admin panel and go to Plugins -> Add New
57
+ 2. Type **advanced random posts widget** in the search box and click on search button.
58
+ 3. Find **Advanced Random Posts Widget** plugin.
59
+ 4. Then click on Install Now after that activate the plugin.
60
+ 5. Go to the widgets page **Appearance -> Widgets**.
61
+ 6. Find **Random Posts** widget.
62
63
+ **Installing Via FTP**
64
+
65
+ 1. Download the plugin to your hardisk.
66
+ 2. Unzip.
67
+ 3. Upload the **advanced-random-posts-widget** folder into your plugins directory.
68
+ 4. Log in to your WordPress admin panel and click the Plugins menu.
69
+ 5. Then activate the plugin.
70
+ 6. Go to the widgets page **Appearance -> Widgets**.
71
+ 6. Find **Random Posts** widget.
72
+
73
+ == Frequently Asked Questions ==
74
+
75
+ = No image/thumbnail options? =
76
+ 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.
77
+
78
+ = Thumbnail Size =
79
+ By default it uses **arpw-thumbnail** which have **50x50** size. If you want to use custom image size, you can install http://wordpress.org/plugins/simple-image-sizes/ then create new image size, it will appear in the **Thumbnail Size** selectbox in the widget option.
80
81
+ = Thumbnail Size Not Working Properly =
82
+ I have mentioned it in the plugin description. If you use images that were uploaded to the media library before you installed this plugin and/or you have your own custom image sizes, please install [Regenerate Thumbnails](http://wordpress.org/extend/plugins/regenerate-thumbnails/) plugin to fix the image size.
83
84
+ = How to add custom style? =
85
+ The plugin comes with a very basic style, if you want to add custom style please do `wp_dequeue_style` to remove the default stylesheet. Place the code below in your theme `functions.php`.
86
+ `
87
+ function prefix_remove_arpw_style() {
88
+ wp_dequeue_style( 'arpw-style' );
89
+ }
90
+ add_action( 'wp_enqueue_scripts', 'prefix_remove_arpw_style', 10 );
91
+ `
92
+ Then you can add your custom style using Custom CSS plugin or in your theme `style.css`. Here's the plugin selector
93
+ `
94
+ /* wrapper */
95
+ #arpw-random-posts {}
96
97
+ /* ul */
98
+ .arpw-ul {}
99
100
+ /* li */
101
+ .arpw-li {}
102
103
+ /* title */
104
+ .arpw-title {}
105
106
+ /* thumbnail */
107
+ .arpw-thumbnail {}
108
+
109
+ /* date */
110
+ .arpw-time {}
111
+
112
+ /* excerpt */
113
+ .arpw-summary {}
114
+ `
115
+
116
+ == Screenshots ==
117
+
118
+ 1. The widget settings
119
+
120
+ == Shorcode Explanation ==
121
+
122
+ Explanation of shortcode options:
123
+
124
+ Basic shortcode
125
+ `
126
+ [arpw]
127
+ `
128
+
129
+ Display 10 random posts
130
+ `
131
+ [arpw limit="10"]
132
+ `
133
+
134
+ Display with thumbnail and set the size
135
+ `
136
+ [arpw thumbnail="true" thumbnail_size="thumbnail"]
137
+ `
138
+
139
+ **Here's the full default shortcode arguments**
140
+ `
141
+ title=""
142
+ title_url=""
143
+ offset=""
144
+ limit="5"
145
+ post_type="post"
146
+ post_status="publish"
147
+ ignore_sticky="1"
148
+ taxonomy=""
149
+ thumbnail="false"
150
+ thumbnail_size="arpw-thumbnail"
151
+ thumbnail_align="left"
152
+ excerpt="false"
153
+ excerpt_length="10"
154
+ date="false"
155
+ css_class=""
156
+ before=""
157
+ after=""
158
+ `
159
+
160
+ == Changelog ==
161
162
+ = 2.0.0 - 9/05/2014 =
163
+ * This is a major changes to the plugin, please re-save or re-install the plugin if you find it doesn't work properly.
164
+ * Please read [FAQ](http://wordpress.org/plugins/advanced-random-posts-widget/faq) and [Other Notes](http://wordpress.org/plugins/advanced-random-posts-widget/other-notes) to read more about how the plugin works.
165
+ * Tested for WordPress 4.0
166
+ * Added shortcode support!
167
+ * Added taxonomy support
168
+ * Added post status support
169
+ * Changed how the post thumbnail size works
170
+ * Changed how the plugin style works
171
+ * Update language
screenshot-1.png CHANGED
Binary file