WordPress.org

Making WordPress.org

Changeset 4639


Ignore:
Timestamp:
01/12/2017 05:36:44 PM (5 years ago)
Author:
coffee2code
Message:

Support Forums, Topic Resolution: Denote resolved topics in better ways than prepending "[RESOLVED]" to topic titles.

  • Prepends markup to resolved topic titles in topic listings, suitable for being shown as a checkmark.
  • Outputs resolved indicator in single topic view for resolved topics, with the text "Answered".
  • Discontinues prepending "[RESOLVED]" to topic titles.

Props mapk, coffee2code.
See #2359.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-topic-resolution/inc/class-plugin.php

    r4034 r4639  
    3838        add_filter( 'bbp_get_topic_title', array( $this, 'get_topic_title' ), 10, 2 );
    3939
     40        // Add resolved indicator to single topic view.
     41        add_action( 'bbp_theme_before_topic_author_details', array( $this, 'single_topic_resolved_indicator' ) );
     42
    4043        // Display the form for new/edit topics.
    4144        add_action( 'bbp_theme_before_topic_form_content', array( $this, 'form_topic_resolution_dropdown' ) );
     
    6669    public function get_topic_title( $title, $topic_id ) {
    6770        // Only run when enabled on a topic's forum.
    68         if ( ! $this->is_enabled_on_forum( bbp_get_topic_forum_id( $topic_id ) ) ) {
     71        if ( bbp_is_single_topic() || ! $this->is_enabled_on_forum( bbp_get_topic_forum_id( $topic_id ) ) ) {
    6972            return $title;
    7073        }
    7174
    72         $resolved = __( 'Resolved', 'wporg-forums' );
    7375        if ( 'yes' == $this->get_topic_resolution( array( 'id' => $topic_id ) ) ) {
    74            return sprintf( '[%s] %s', esc_html( $resolved ), $title );
    75         }
     76            $title = sprintf(
     77                '<span class="resolved" aria-label="%s" title="%s"></span>',
     78                esc_attr__( 'Resolved', 'wporg-forums' ),
     79                esc_attr__( 'Topic is resolved.', 'wporg-forums' )
     80            ) . $title;
     81        }
     82
    7683        return $title;
     84    }
     85
     86    /**
     87     * Outputs resolved topic indicator.
     88     */
     89    public function single_topic_resolved_indicator() {
     90        $topic_id = bbp_get_topic_forum_id();
     91
     92        if (
     93            // Must be single topic view
     94            ! bbp_is_single_topic()
     95            ||
     96            // Must be enabled on the forum
     97            ! $this->is_enabled_on_forum( bbp_get_topic_forum_id( $topic_id ) )
     98            ||
     99            // Must be a resolved topic
     100            'yes' == $this->get_topic_resolution( array( 'id' => $topic_id ) )
     101        ) {
     102            return;
     103        }
     104
     105        echo '<span class="topic-resolved-indicator">' . __( 'Answered', 'wporg-forums' ) . '</span>';
    77106    }
    78107
Note: See TracChangeset for help on using the changeset viewer.