Skip to content

Commit

Permalink
1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gordielachance authored and gordielachance committed Sep 11, 2016
1 parent 5368573 commit 1447678
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 32 deletions.
33 changes: 4 additions & 29 deletions bbpress-pencil-unread.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: bbPress Pencil Unread
Plugin URI: http://wordpress.org/extend/plugins/bbpress-pencil-unread
Description: Display which bbPress forums/topics have already been read by the user.
Version: 1.2.2
Version: 1.2.3
Author: G.Breant
Author URI: https://profiles.wordpress.org/grosbouff/
Text Domain: bbppu
Expand All @@ -16,7 +16,7 @@ class bbP_Pencil_Unread {
/**
* @public string plugin version
*/
public $version = '1.2.2';
public $version = '1.2.3';

/**
* @public string plugin DB version
Expand Down Expand Up @@ -48,16 +48,8 @@ class bbP_Pencil_Unread {
public $topic_readby_metaname = 'bbppu_read_by'; // contains an array of user IDs having read that post (stored in postmeta)
public $marked_forums_metaname = 'bbppu_marked_forums'; // contains an array of 'marked as read' timestamps for forums (stored in usermeta)


public $qvar = 'bbppu';

/**
* When creating a new post (topic/reply), set this var to true or false
* So we can update the forum status after the post creation (keep it read if it was read)
* @var type
*/
public $forum_was_read_before_new_post = false;


/**
* @var The one true Instance
*/
Expand Down Expand Up @@ -190,7 +182,7 @@ function upgrade(){
}

//remove 'bbppu_forums_visits' usermetas
//TO FIX could be done for v1.2.3, but wait a little that we will not revert that stuff before removing it.
//TO FIX could be done for v1.2.3, but wait a little that we will not revert that stuff enabling removing it.
//$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE meta_key = %s",'bbppu_forums_visits') );


Expand All @@ -215,11 +207,9 @@ function logged_in_user_actions(){
add_action('bbp_template_after_replies_loop',array(&$this,'update_current_topic_read_by')); //single topic

//save post actions
add_action( 'bbp_new_topic_pre_extras',array(&$this,"forum_was_read_before_new_topic"));
add_action( 'bbp_new_topic',array(&$this,"new_topic"),10,4 );
add_action( 'save_post',array( $this, 'new_topic_backend' ) );

add_action( 'bbp_new_reply_pre_extras',array(&$this,"forum_was_read_before_new_reply"),10,2);
add_action( 'bbp_new_reply',array(&$this,"new_reply"),10,5 );
add_action( 'save_post',array( $this, 'new_reply_backend' ) );

Expand Down Expand Up @@ -524,21 +514,6 @@ public function mark_single_forum_as_read($forum_id) {

return update_user_meta($user_id, $this->marked_forums_metaname, $marked_forums );
}

/**
* Before saving a new post/reply,
* store the forum status (read/unread) so we can update its status after the post creation
* (see fn
* @param type $post_id
* @param type $forum_id
*/
function forum_was_read_before_new_topic($forum_id){
$this->forum_was_read_before_new_post = self::has_user_read($forum_id);
}

function forum_was_read_before_new_reply($topic_id, $forum_id){
$this->forum_was_read_before_new_post = self::has_user_read($forum_id);
}

function new_topic_backend($post_id){

Expand Down
27 changes: 24 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ If it doesn't work for you, please try to check/override our CSS styles (bbppu.c
= How can I get it in my language ? =
If it hasn't been done already, you can translate the plugin and send me the translation. I recommand [Loco Translate](https://fr.wordpress.org/plugins/loco-translate/) to work on your translations within Wordpress.

= How can I filter topics to display only the unread or read ones ? =
Just add the **bbppu** arg to your [Wordpress queries](https://fr.wordpress.org/plugins/loco-translate/). You can set it either to *read* or *unread*.
Of course, this works for the current logged user and will be skipped if the visitor is not logged.

Example :

`<?php
$last_unread_topics_query_args = array(
'post_type' => bbp_topic_post_type(), //or 'topic'
'posts_per_page' => 5,
'bbppu' => 'unread' //only unread ones
);

$last_unread_topics_query = new WP_Query( $last_unread_topics_query_args );
?>`


= How does it work? =

*bbPress Pencil Unread* handles differently the way forums & topics are set as read.
Expand All @@ -75,10 +92,14 @@ Have a look at the file /bbppu-template.php, which contains functions you could

== Changelog ==

= XXX =
* No faking anymore ! Now the plugin **really** checks if a forum has its topics all read - before, it was checking if the forum had been **opened**.
* topic_readby_metaname is now multiple (+ upgrade function)
= 1.2.3 =
* No faking anymore ! Now the plugin **really** checks if a forum has its topics all read; while before, it was checking if the forum had been **opened**.
* Allow to filter queries to get topics by read/unread status (see FAQ)
* fixed loadHTML() error (https://wordpress.org/support/topic/just-upgraded-to-v-1-2-errors/#post-8169136)
* Arabic translation (thanks to Mohammad Sy)
* has_user_read_all_forum_topics() : store the results in a short transient (5s) to avoid querying several times the same stuff.
* deleted 'bbppu_forums_visits' usermetas and related functions (+ upgrade function)
* topic_readby_metaname is now multiple (+ upgrade function) : do not store array of user IDs in a single meta, but store multiple metas with single user ID each time

= 1.2.2 =
* Do not show 'Mark as read' link if no activity since last marked.
Expand Down

0 comments on commit 1447678

Please sign in to comment.