Changeset 1223847
- Timestamp:
- 08/18/2015 04:03:25 PM (11 years ago)
- Location:
- bbpress-new-topics/trunk
- Files:
-
- 2 edited
-
bbpress-new-topics.php (modified) (8 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bbpress-new-topics/trunk/bbpress-new-topics.php
r860389 r1223847 3 3 Plugin Name: bbPress New Topics 4 4 Plugin URI: http://bavotasan.com/2014/bbpress-new-topics-plugin/ 5 Description: Displays a "new" label on topics that are unread or have unread replies for all keymasters and moderators.5 Description: Displays a "new" label on topics that are unread or have unread replies for all keymasters, moderators and participants. 6 6 Author: c.bavota 7 Version: 1.0. 07 Version: 1.0.1 8 8 Author URI: http://bavotasan.com 9 9 Text Domain: new-topics … … 12 12 */ 13 13 14 /* Copyright 201 4c.bavota (email : [email protected])14 /* Copyright 2015 c.bavota (email : [email protected]) 15 15 16 16 This program is free software; you can redistribute it and/or modify … … 30 30 // Plugin version 31 31 if ( ! defined( 'NEW_TOPICS_VERSION' ) ) { 32 define( 'NEW_TOPICS_VERSION', '1.0. 0' );32 define( 'NEW_TOPICS_VERSION', '1.0.1' ); 33 33 } 34 34 … … 50 50 51 51 add_action( 'bbp_theme_before_topic_title', array( $this, 'bbp_theme_before_topic_title' ) ); 52 add_action( 'bbp_template_before_single_topic', array( $this, 'bbp_template_before_single_topic' ) ); 53 add_action( 'bbp_theme_before_forum_title', array( $this, 'bbp_theme_before_forum_title' ) ); 52 54 } 53 55 … … 80 82 $new_topics_array = (array) get_user_meta( $admin->ID, 'bbp_new_topics', true ); 81 83 82 if ( ! in_array( $topic_id, $new_topics_array) ) {84 if ( ! in_array( $topic_id, array_filter( $new_topics_array ) ) ) { 83 85 $new_topics_array[] = (int) $topic_id; 84 86 … … 106 108 $new_topics_array = (array) get_user_meta( $user_id, 'bbp_new_topics', true ); 107 109 108 if ( in_array( $topic_id, $new_topics_array) )110 if ( in_array( $topic_id, array_filter( $new_topics_array ) ) ) 109 111 $classes[] = 'new-topic'; 110 112 … … 122 124 $new_topics_array = (array) get_user_meta( $user_id, 'bbp_new_topics', true ); 123 125 124 if ( in_array( $topic_id, $new_topics_array ) ) { 125 if ( bbp_is_single_topic () ) { 126 unset( $new_topics_array[array_search( (int) $topic_id, $new_topics_array )] ); 126 if ( in_array( $topic_id, array_filter( $new_topics_array ) ) ) { 127 echo '<span class="new-topic-notifier">' . __( 'New', 'new-topics' ) . '</span> '; 128 } 129 } 127 130 128 update_user_meta( $user_id, 'bbp_new_topics', (array) $new_topics_array ); 129 } else { 131 /** 132 * Remove topic from unread topics array upon viewing. 133 * 134 * @since 1.0.1 135 */ 136 public function bbp_template_before_single_topic() { 137 $user_id = get_current_user_id(); 138 $topic_id = bbp_get_topic_id(); 139 $new_topics_array = (array) get_user_meta( $user_id, 'bbp_new_topics', true ); 140 141 if ( in_array( (int) $topic_id, $new_topics_array ) ) { 142 unset( $new_topics_array[array_search( (int) $topic_id, $new_topics_array )] ); 143 144 update_user_meta( $user_id, 'bbp_new_topics', (array) $new_topics_array ); 145 } 146 } 147 148 149 /** 150 * Adds 'New' label to all forums that contain topics which appear in the unread topics array. 151 * 152 * @since 1.0.1 153 */ 154 public function bbp_theme_before_forum_title(){ 155 $user_id = get_current_user_id(); 156 $forum_id = bbp_get_forum_id(); 157 $new_topics_array = (array) get_user_meta( $user_id, 'bbp_new_topics', true ); 158 159 global $wpdb; 160 $new_query = 'SELECT post_id FROM ' . $wpdb->prefix . 'postmeta WHERE meta_key = "_bbp_forum_id" AND meta_value = "' . $forum_id. '"'; 161 162 $result = $wpdb->get_results( $new_query ); 163 164 foreach( $result as $row ) { 165 if ( in_array( (int) $row->post_id, array_filter( $new_topics_array ) ) ) { 130 166 echo '<span class="new-topic-notifier">' . __( 'New', 'new-topics' ) . '</span> '; 131 167 } … … 134 170 135 171 /** 136 * Gathers all keymasters and moderators.172 * Gathers all keymasters, moderators and participants. 137 173 * 138 174 * @since 1.0.0 139 175 */ 140 176 public function bbp_get_admins() { 141 $keymaster = get_users( array(142 'role' => 'bbp_keymaster',143 ) );177 $keymaster = get_users( array( 178 'role' => 'bbp_keymaster', 179 ) ); 144 180 145 $moderators = get_users( array(146 'role' => 'bbp_moderator',147 ) );181 $moderators = get_users( array( 182 'role' => 'bbp_moderator', 183 ) ); 148 184 149 return array_merge( $keymaster, $moderators ); 185 $participant = get_users( array( 186 'role' => 'bbp_participant', 187 ) ); 188 189 return array_merge( $keymaster, $moderators, $participant ); 150 190 } 151 191 } -
bbpress-new-topics/trunk/readme.txt
r860389 r1223847 6 6 Domain Path: /languages 7 7 Requires at least: 3.5 8 Tested up to: 3.89 Stable tag: 1.0. 08 Tested up to: 4.3 9 Stable tag: 1.0.1 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 35 35 == Change Log == 36 36 37 = 2015-08-18 v1.0.1 = 38 * Small update to code 39 * Added participants to user array 40 * Added new tag to before forum title 41 * Fixed issue with removing new tag from read topics 42 * Updated version and stable tag 43 37 44 = 2014-02-18 v1.0.0 = 38 45 Initial Public Release
Note: See TracChangeset
for help on using the changeset viewer.