I’m in the process of optimizing SQL queries in order to get better performance. Please let me know if you find any bugs.
I would also appreciate if you wrote something about whether you notice any difference in performance or not. A site with 10 posts/pages should not notice anything, but those of you with larger sites should see a difference.
To prevent comments from protected pages from appearing in “Recent comments” widget, open up “/wp-includes/widgets.php” and replace the function “wordpress_wp_widget_recent_comments” with this code:
function wordpress_wp_widget_recent_comments($args) {
global $wpdb, $comments, $comment, $current_user;
extract($args, EXTR_SKIP);
$options = get_option(’widget_recent_comments’);
$title = empty($options['title']) ? __(’Recent Comments’) : apply_filters(’widget_title’, $options['title']);
if ( !$number = (int) $options['number'] )
$number = 5;
else if ( $number < 1 )
$number = 1;
else if ( $number > 15 )
$number = 15;
if ( !$comments = wordpress_wp_cache_get( ‘recent_comments’, ‘widget’ ) ) {
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = ‘1′ AND comment_post_ID NOT IN (SELECT post_id FROM " . $wpdb->prefix . "named_users WHERE (user_id <> " . $current_user->ID . " OR group_id NOT IN (SELECT group_id FROM " . $wpdb->prefix . "named_users_groups_relations WHERE user_id = " . $current_user->ID . "))) ORDER BY comment_date_gmt DESC LIMIT $number");
wordpress_wp_cache_add( ‘recent_comments’, $comments, ‘widget’ );
}
?>
<?php echo $before_widget; ?>
<?php echo $before_title . $title . $after_title; ?>
<ul id="recentcomments"><?php
if ( $comments ) : foreach ( (array) $comments as $comment) :
echo ‘<li class="recentcomments">’ . sprintf(__(’%1$s on %2$s’), get_comment_author_link(), ‘<a href="’. get_comment_link($comment->comment_ID) . ‘">’ . get_the_title($comment->comment_post_ID) . ‘</a>’) . ‘</li>’;
endforeach; endif;?></ul>
<?php echo $after_widget; ?>
<?php
}
I’ve made some changes to the plugin to support internationalization. The POT file is placed in the plugin directory. Let me know if you find any bugs!
I’ve included a danish translation. Please write a comment if you want to share your translation files (.po and .mo) and remember to provide a link to the files, so that I can download them.
I’ve released version 0.3.5. This version has the “wpNamedUsers permissions” working with the group functionality, so now everything should be working. Let me know if there are any bugs!
With the release of version 0.3.2 the group functionality is implemented. If you find ANY bugs PLEASE report them to me in a comment!!
Remember to deactivate before upgrading as the database is upgraded when the plugin is activated!
I’ve made the group functionality so that it is possible to select users and groups who will have acces to posts/pages. This means that you can go on the old way and give permissions to single users. You can also combine the two things and give permissions to a group and a couple of users.
“wpNamedUsers permissions” is not done yet, so it still behaves as if there were no groups.
Does it make sence?
I’ve had some problems getting the plugin to work with WordPress 2.7, but version 0.2.6 of the plugin should be fully compatible. These problems have delayed the groups functionality, but I’m working on it.
I’ve released version 0.2 of the plugin. The functionality that was originally planned is now implemented. The next thing now, is to find a way to group users and to set permissions to these groups.
The management page is almost finished. I’ve implemented the “clear permissions” functionality, but the “set permissions” is still just a button.
I’ve started thinking about some kind of user management. I think it would be best, if it was possible to group users, so that it would be possible to set permissions to a group as well as individual users. Well, the “set permissions” has the highest priority at the moment, but I think that the grouping functionality would be nice to have.
I realized today, that if you had given permissions to a page or post to more than one user, none of the users would see the content. This bug has been fixed in version 0.1.4. This version also introduces the copy permissions feature.
I’m not sure if users that are not logged in, are able to see the comments of hidden pages. Please visit http://wordpress.sundskard.dk/archives/41/feed and tell me if you see my comment to “Protected post” or not. It might just be the browser cache that is playing around with me. 