WordPress.org

Plugin Directory

Changeset 604982


Ignore:
Timestamp:
09/28/12 01:52:48 (19 months ago)
Author:
jaredatch
Message:

push 1.2 beta to trunk

Location:
bbpress-new-topic-notifications/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • bbpress-new-topic-notifications/trunk/bbpress-topic-notifications.php

    r449317 r604982  
    33Plugin Name: bbPress New Topic Notifications 
    44Plugin URI: http://wordpress.org/extend/bbpress-new-topic-notifications 
    5 Description: Send notification emails to specific users when a new bbPress topic is posted. 
    6 Version: 1.1 
     5Description: Send notification emails to specific users when a new bbPress topic or reply is posted. 
     6Version: 1.2 
    77Author: jaredatch 
    88Author URI: http://jaredatchison.com  
     
    1313 
    1414/** 
    15  * Copyright (c) 2011 Jared Atchison. All rights reserved. 
    16  * 
    17  * Released under the GPL license 
    18  * http://www.opensource.org/licenses/gpl-license.php 
    19  * 
    20  * This is an add-on for WordPress 
    21  * http://wordpress.org/ 
    22  * 
    23  * ********************************************************************** 
    2415 * This program is free software; you can redistribute it and/or modify 
    2516 * it under the terms of the GNU General Public License as published by 
     
    3122 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    3223 * GNU General Public License for more details. 
    33  * ********************************************************************** 
     24 * 
     25 * @package bbpress-topic-notifications 
     26 * @version 1.2 
     27 * @author Jared Atchison <contact@jaredatchison.com> 
     28 * @copyright Copyright (c) 2012, Jared Atchison 
     29 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 
    3430 */ 
    3531 
     
    4339         
    4440        // Admin area 
    45         add_action( 'admin_init',           array( $this, 'admin_settings' ),       15      ); 
    46         add_filter( 'plugin_action_links',  array( $this, 'add_settings_link' ),    10, 2   ); 
     41        add_filter( 'plugin_action_links',  array( &$this, 'add_settings_link'       ),  10, 2   ); 
    4742         
    4843        // Triggers notification 
    49         add_action( 'bbp_new_topic',        array( $this, 'send_notification' ),    10, 4   ); 
    50          
     44        add_action( 'bbp_new_topic',        array( &$this, 'send_notification'       ),  10, 4   ); 
     45        add_action( 'bbp_new_reply',        array( &$this, 'send_notification_reply' ),  10, 5   ); 
     46 
    5147        // Triggers activation check 
    5248        register_activation_hook( __FILE__, array( $this, 'activation_hook' ) ); 
    5349    } 
    54      
     50 
    5551    /** 
    5652     * activation_hook() 
     
    6157        // Obviously, this wouldn't work to well without bbPress 
    6258        if( !class_exists( 'bbPress' ) ) { 
    63             deactivate_plugins( plugin_basename(__FILE__) ); // Deactivate ourself 
    64             wp_die( __('Sorry, you need to activate bbPress first.', 'ja_bbp_notifications') ); 
     59            deactivate_plugins( plugin_basename( __FILE__ ) ); // Deactivate ourself 
     60            wp_die( __( 'Sorry, you need to activate bbPress first.', 'ja_bbp_notifications' ) ); 
    6561        } 
    6662         
    6763        //Default email template 
    6864        $email_template =   "Howdy!\n\n"; 
    69         $email_template .=  "A new topic has been posted.\n\n"; 
     65        $email_template .=  "There's activity on the forum.\n\n"; 
    7066        $email_template .=  "Topic URL: [topic-url]\n"; 
    7167        $email_template .=  "Title: [topic-title]\n"; 
     
    112108        // Register our settings with the bbPress forum settings page 
    113109        register_setting( 'bbpress', 'ja_bbp_notification_email_addresses', array( $this, 'validate_email_addresses' ) ); 
    114         register_setting( 'bbpress', 'ja_bbp_notification_email_template', array( $this, 'validate_email_template' ) ); 
     110        register_setting( 'bbpress', 'ja_bbp_notification_email_template',  array( $this, 'validate_email_template' ) ); 
    115111    } 
    116112     
     
    119115     * 
    120116     * Output the new topic notification section in the bbPress forum settings 
    121      * 
    122117     */ 
    123118    function section_heading() { 
     
    144139    function email_template_textarea() { 
    145140        $email_template = get_option( 'ja_bbp_notification_email_template' ); 
    146         $shortcodes = '[topic-title], [topic-content], [topic-excerpt], [topic-url], [topic-author]'; 
     141        $shortcodes     = '[topic-title], [topic-content], [topic-excerpt], [topic-url], [topic-author]'; 
    147142         
    148143        echo '<textarea id="ja_bbp_notification_email_template" cols="50" rows="8" name="ja_bbp_notification_email_template">' . $email_template . '</textarea>'; 
     
    156151     * 
    157152     * @param string $email_addresses 
    158      * @return string 
    159      * 
     153     * @return string $email_addresses 
    160154     */ 
    161155    function validate_email_addresses( $email_addresses ) { 
     
    184178     * 
    185179     * @param string $email_template 
    186      * @return string 
    187      * 
     180     * @return string $email_template 
    188181     */ 
    189182    function validate_email_template( $email_template ) { 
     
    197190     * Gets the recipients 
    198191     * 
    199      * @return array 
     192     * @return array $recipients 
    200193     */ 
    201194    function get_recipients() { 
     
    211204     
    212205    /** 
     206     * send_notification_reply() 
     207     * 
     208     * Send the new reply notification e-mails to the addresses defined in options 
     209     */ 
     210    function send_notification_reply( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $topic_author = 0 ) { 
     211        self::send_notification( $topic_id, $forum_id, $anonymous_data, $topic_author, $reply_id ); 
     212    } 
     213     
     214    /** 
    213215     * send_notification() 
    214216     * 
    215      * Send the notification e-mails to the addresses defined in options 
    216      */ 
    217     function send_notification( $topic_id = 0, $forum_id = 0, $anonymous_data = false, $topic_author = 0 ) { 
    218          
     217     * Send the new topic notification e-mails to the addresses defined in options 
     218     */ 
     219    function send_notification( $topic_id = 0, $forum_id = 0, $anonymous_data = false, $topic_author = 0, $reply_id = 0 ) { 
     220         
     221        // Do not sent notifies for topics/replies marked as spam 
     222        if ( $reply_id && bbp_is_reply_spam( $reply_id ) { 
     223            return; 
     224        } elseif ( bbp_is_topic_spam( $topic_id ) ) { 
     225            return; 
     226        } 
     227             
    219228        // Grab stuff we will be needing for the email 
    220229        $recipients     = $this->get_recipients(); 
     230 
     231        // Do not sent new reply notifies to configured recipients 
     232        if ( $reply_id ) { 
     233            $reply_author_email = bbp_get_reply_author_email( $reply_id ); 
     234            if ( in_array( $reply_author_email, $recipients ) ) { 
     235                return; 
     236            } 
     237        } 
     238 
     239        $charset        = get_bloginfo( 'charset' ); 
    221240        $blogname       = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 
    222         $topic_title    = html_entity_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_NOQUOTES, 'UTF-8'); 
    223         $topic_content  = html_entity_decode( strip_tags( bbp_get_topic_content( $topic_id ) ), ENT_NOQUOTES, 'UTF-8'); 
    224         $topic_excerpt  = html_entity_decode( strip_tags( bbp_get_topic_excerpt( $topic_id, 100 ) ), ENT_NOQUOTES, 'UTF-8'); 
    225         $topic_author   = bbp_get_topic_author( $topic_id ); 
    226         $topic_url      = bbp_get_topic_permalink( $topic_id ); 
     241        $forum_title    = html_entity_decode( strip_tags( bbp_get_forum_title( $forum_id ) ), ENT_NOQUOTES, $charset ); 
     242        $topic_title    = html_entity_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_NOQUOTES, $charset ); 
     243 
     244        if ( $reply_id ) { 
     245            $topic_author   = bbp_get_reply_author( $reply_id ); 
     246            $topic_content  = html_entity_decode( strip_tags( bbp_get_reply_content( $reply_id ) ), ENT_NOQUOTES, $charset ); 
     247            $topic_excerpt  = html_entity_decode( strip_tags( bbp_get_reply_excerpt( $reply_id, 100 ) ), ENT_NOQUOTES, $charset ); 
     248            $topic_url      = bbp_get_reply_permalink( $reply_id ); 
     249        } else { 
     250            $topic_author   = bbp_get_topic_author( $topic_id ); 
     251            $topic_content  = html_entity_decode( strip_tags( bbp_get_reply_content( $topic_id ) ), ENT_NOQUOTES, $charset ); 
     252            $topic_excerpt  = html_entity_decode( strip_tags( bbp_get_reply_excerpt( $topic_id, 100 ) ), ENT_NOQUOTES, $charset ); 
     253            $topic_url      = bbp_get_topic_permalink( $topic_id ); 
     254        } 
    227255 
    228256        // Get the template 
     
    233261        $replace        = array( $topic_title, $topic_content, $topic_excerpt, $topic_author, $topic_url ); 
    234262        $email_body     = str_replace( $find, $replace, $email_template ); 
    235         $email_subject  = $blogname . __( ' new topic', 'ja_bbp_notifications' ) . ' - ' . $topic_title; 
     263        $email_subject  = $blogname . '/' . $forum_title . ' ' . __( $reply_id ? 'new reply' : 'new topic', 'ja_bbp_notifications' ) . ': ' . $topic_title; 
    236264 
    237265        if ( !empty( $recipients ) ) { 
     
    242270        } 
    243271    } 
    244      
    245272} 
    246273 
  • bbpress-new-topic-notifications/trunk/readme.txt

    r604978 r604982  
    44Tags: bbpress, notifications 
    55Requires at least: 3.2 
    6 Tested up to: 3.4.x 
     6Tested up to: 3.4 
    77Stable tag: 1.1 
    88  
     
    1717This plugin will send an e-mail notification to specific addresses when a new topic has been posted. The users who receive notification along with a simple e-mail template is configured in the bbPress settings. 
    1818 
    19 See the [author website](http://www.jaredatchison.com/2011/08/28/bbpress-new-topic-notifications/). 
     19**Note**: The current stable version of this plugin is 1.1. If you download it through the WordPress repo you will get version 1.1. However, there is a new beta version 1.2 that you can use and test if you choose. Version 1.2 adds  notifications for topic replies. 
    2020 
     21If you would like to try 1.2 you can grab it from trunk (plugin repo) or download it from GitHub - https://github.com/jaredatch/bbPress-New-Topic-Notifications/zipball/master 
     22 
     23If you download 1.2, please report any errors or any success to the support forums. 1.2 should be fairly stable, however I have not had enough people test it for me to push it out to everyone.  
    2124 
    2225== Installation == 
     
    3841== Changelog == 
    3942 
     43= 1.2 = 
     44* Added ability for topic reply notifications, props @Marcel 
     45* Various tweaks and code updates 
     46 
    4047= 1.1 = 
    4148* Occassionally the shortcodes would put html and encoded characters in the email notifications. This should be fixed! 
Note: See TracChangeset for help on using the changeset viewer.