Making WordPress.org

Ticket #1899: 1899.diff

File 1899.diff, 2.1 KB (added by netweb, 8 years ago)
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-topic-title-closed/wporg-bbp-topic-title-closed.php

     
     1<?php
     2/**
     3 * Plugin Name: bbPress: Closed Topic Title
     4 * Description: Adds [Closed] to closed topic titles.
     5 * Version:     1.0
     6 * Author:      WordPress.org
     7 * Author URI:  https://wordpress.org/
     8 * License:     GPLv2 or later
     9 */
     10
     11/**
     12 *      This program is free software; you can redistribute it and/or modify
     13 *      it under the terms of the GNU General Public License, version 2, as
     14 *      published by the Free Software Foundation.
     15 *
     16 *      This program is distributed in the hope that it will be useful,
     17 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
     18 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     19 *      GNU General Public License for more details.
     20 *
     21 *      You should have received a copy of the GNU General Public License
     22 *      along with this program; if not, see <http://www.gnu.org/licenses/>.
     23 */
     24
     25if ( ! defined( 'ABSPATH' ) ) exit;
     26
     27if ( ! class_exists( 'WPORG_bbPress_Topic_Closed_Title' ) ) {
     28class WPORG_bbPress_Topic_Closed_Title {
     29
     30        /**
     31         * Instantiates a new Plugin object.
     32         */
     33        public function __construct() {
     34                add_action( 'bbp_loaded', array( $this, 'bbp_loaded' ) );
     35        }
     36
     37        /**
     38         * Initializes the plugin.
     39         */
     40        public function bbp_loaded() {
     41                // Change the topic title when resolved.
     42                add_filter( 'bbp_get_topic_title', array( $this, 'get_topic_title' ), 10, 2 );
     43        }
     44
     45        /**
     46         * Add "Resolved" status to title.
     47         */
     48        public function get_topic_title( $title, $topic_id ) {
     49                $closed = __( 'Closed', 'wporg-forums' );
     50                if ( bbp_is_topic_closed( array( 'id' => $topic_id ) ) ) {
     51                   return sprintf( esc_html( '[%s]: %s' ), $closed, $title );
     52                }
     53                return $title;
     54        }
     55} }
     56
     57new WPORG_bbPress_Topic_Closed_Title;