Changeset 1402460
- Timestamp:
- 04/22/2016 09:44:27 PM (10 years ago)
- Location:
- random-posts-from-category
- Files:
-
- 11 added
- 2 edited
-
tags/1.30 (added)
-
tags/1.30/LICENSE (added)
-
tags/1.30/README.md (added)
-
tags/1.30/languages (added)
-
tags/1.30/languages/random-posts-from-category-be_BY.mo (added)
-
tags/1.30/languages/random-posts-from-category-be_BY.po (added)
-
tags/1.30/languages/random-posts-from-category.1.15-ro_RO.mo (added)
-
tags/1.30/languages/random-posts-from-category.1.15-ro_RO.po (added)
-
tags/1.30/languages/random-posts-from-category.pot (added)
-
tags/1.30/random-from-category-widget.php (added)
-
tags/1.30/readme.txt (added)
-
trunk/random-from-category-widget.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
random-posts-from-category/trunk/random-from-category-widget.php
r1045190 r1402460 4 4 Plugin URI: http://sillybean.net/code/wordpress/ 5 5 Description: A widget that lists random posts from a chosen category. 6 Version: 1. 26 Version: 1.30 7 7 Author: Stephanie Leary 8 8 Author URI: http://sillybean.net/ … … 13 13 class RandomPostsFromCategory extends WP_Widget { 14 14 15 function RandomPostsFromCategory() {15 function __construct() { 16 16 $widget_ops = array('classname' => 'random_from_cat', 'description' => __( 'random posts from a chosen category', 'random-posts-from-category') ); 17 $this->WP_Widget('RandomPostsFromCategory', __('Random Posts from Category', 'random-posts-from-category'), $widget_ops);17 parent::__construct('RandomPostsFromCategory', __('Random Posts from Category', 'random-posts-from-category'), $widget_ops); 18 18 } 19 19 … … 32 32 echo $before_title.$title.$after_title; 33 33 } 34 ?> 35 <ul> 36 <?php 34 37 35 $args = array( 38 36 'cat' => $instance['cat'], … … 44 42 // the Loop 45 43 if ($random->have_posts()) : 46 while ($random->have_posts()) : $random->the_post(); 47 global $post; 48 setup_postdata($post); 49 ?> 50 <li> 51 <?php 52 if ($instance['content'] != 'excerpt-notitle' && $instance['content'] != 'content-notitle') { ?> 53 <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 54 <?php 55 } 56 if ($instance['content'] == 'excerpt' || $instance['content'] == 'excerpt-notitle') { 57 if (function_exists('the_excerpt_reloaded')) 58 the_excerpt_reloaded($instance['words'], $instance['tags'], 'content', FALSE, '', '', '1', ''); 59 else the_excerpt(); // this covers Advanced Excerpt as well as the built-in one 60 } 61 if ($instance['content'] == 'content' || $instance['content'] == 'content-notitle') the_content(); 62 endwhile; endif; 63 ?> 64 </ul> 65 <?php 44 echo '<ul>'; 45 while ($random->have_posts()) : $random->the_post(); ?> 46 <li> 47 <?php 48 if ($instance['content'] != 'excerpt-notitle' && $instance['content'] != 'content-notitle') { ?> 49 <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 50 <?php 51 } 52 if ($instance['content'] == 'excerpt' || $instance['content'] == 'excerpt-notitle') { 53 if (function_exists('the_excerpt_reloaded')) 54 the_excerpt_reloaded($instance['words'], $instance['tags'], 'content', FALSE, '', '', '1', ''); 55 else the_excerpt(); // this covers Advanced Excerpt as well as the built-in one 56 } 57 if ($instance['content'] == 'content' || $instance['content'] == 'content-notitle') the_content(); 58 endwhile; 59 echo '</ul>'; 60 endif; 61 66 62 echo $after_widget; 67 68 wp_reset_postdata();69 63 wp_reset_query(); 70 64 } … … 73 67 function update( $new_instance, $old_instance ) { 74 68 $instance = $old_instance; 75 $instance['title'] = s trip_tags($new_instance['title']);76 $instance['cat'] = $new_instance['cat'];77 $instance['showposts'] = $new_instance['showposts'];78 $instance['content'] = $new_instance['content'];79 $instance['postlink'] = $new_instance['postlink'];80 $instance['words'] = $new_instance['words'];69 $instance['title'] = sanitize_text_field($new_instance['title']); 70 $instance['cat'] = intval($new_instance['cat']); 71 $instance['showposts'] = intval($new_instance['showposts']); 72 $instance['content'] = sanitize_text_field($new_instance['content']); 73 $instance['postlink'] = intval($new_instance['postlink']); 74 $instance['words'] = intval($new_instance['words']); 81 75 $instance['tags'] = $new_instance['tags']; 82 76 return $instance; … … 132 126 <label for="<?php echo $this->get_field_id('words'); ?>"><?php _e('Limit excerpts to how many words?:', 'random-posts-from-category'); ?></label> 133 127 <input class="widefat" id="<?php echo $this->get_field_id('words'); ?>" name="<?php echo $this->get_field_name('words'); ?>" 134 type="text" value="<?php echo $instance['words']; ?>" />128 type="text" value="<?php echo esc_attr($instance['words']); ?>" /> 135 129 </p> 136 130 -
random-posts-from-category/trunk/readme.txt
r1139592 r1402460 2 2 Contributors: sillybean 3 3 Tags: widget, random, posts 4 Donate link: http://stephanieleary.com/code/wordpress/random-posts-from-category/5 Text Domain: RandomPostsFromCategory6 Domain Path: /languages7 4 Requires at least: 2.8 8 Tested up to: 4. 29 Stable tag: 1. 165 Tested up to: 4.5 6 Stable tag: 1.30 10 7 11 8 A widget that lists random posts from a chosen category. … … 30 27 Go to Appearance → Widgets to add widgets to your sidebar in widget-ready themes. 31 28 32 To use with a custom post type, add this to your post type plugin file or theme functions.php: 29 == Frequently Asked Questions == 33 30 34 ` 35 add_filter('random_posts_from_category_args', 'random_post_widget_args'); 31 = Known bugs = 36 32 37 function random_post_widget_args($args) { 38 $args['post_type'] = 'mycpt_name'; 39 return $args; 40 } 41 ` 33 Some dropdown menus are not displaying correctly after widget options have been saved. This appears to be affecting many widgets, not just this one. This will be fixed as soon as we figure out what's happening! In the meantime, simply refreshing the widget page in your browser will knock the menus back into shape. 42 34 43 35 == Screenshots == … … 47 39 == Changelog == 48 40 49 = 1.2 =50 * Added 'random_posts_from_category_args' filter to query arguments; fixed query reset.51 41 = 1.16 = 52 42 * Romanian (ro_RO) translation by Web Geek Science (<a href="http://webhostinggeeks.com/">Web
Note: See TracChangeset
for help on using the changeset viewer.