From 1447678ff4dbdd09b03ee961940d1c71deaf1fe8 Mon Sep 17 00:00:00 2001 From: gordielachance Date: Sun, 11 Sep 2016 17:52:52 +0200 Subject: [PATCH] 1.2.3 --- bbpress-pencil-unread.php | 33 ++++----------------------------- readme.txt | 27 ++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/bbpress-pencil-unread.php b/bbpress-pencil-unread.php index 0e962a9..2038462 100644 --- a/bbpress-pencil-unread.php +++ b/bbpress-pencil-unread.php @@ -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 @@ -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 @@ -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 */ @@ -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') ); @@ -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' ) ); @@ -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){ diff --git a/readme.txt b/readme.txt index 4c0176b..48af794 100644 --- a/readme.txt +++ b/readme.txt @@ -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 : + +` 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. @@ -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.