Making WordPress.org

Ticket #5415: 5415.2.diff

File 5415.2.diff, 1.8 KB (added by dufresnesteven, 3 years ago)

This diff also supports adding the title to theme reviews (which was a problem with the first diff.)

  • wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php

    diff --git wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php
    index 673983b2e..5cfd6861c 100644
    class Hooks { 
    10961096        public function bbp_raw_title_array( $title ) {
    10971097                if ( bbp_is_single_forum() || bbp_is_single_topic() || bbp_is_single_view() ) {
    10981098                        $title['format'] = '%s';
     1099
     1100                        if( wporg_support_is_single_review() ) {
     1101                                $title['text'] .= sprintf( ' - [%s] %s',
     1102                                wporg_support_get_single_review_title(),
     1103                                        __( 'Review', 'wporg-forums' )
     1104                                );
     1105                        }
    10991106                }
    11001107
    11011108                return $title;
  • wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

    diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php
    index 47a6bb43c..dfd56e350 100644
    function wporg_support_is_single_review() { 
    338338        return ( WordPressdotorg\Forums\Plugin::REVIEWS_FORUM_ID == bbp_get_topic_forum_id() );
    339339}
    340340
     341/**
     342 * Get post title for single review
     343 *
     344 * @return string|bool Returns post title if it exists. Otherwise returns false.
     345 */
     346function wporg_support_get_single_review_title() {
     347        if ( ! class_exists( 'WordPressdotorg\Forums\Plugin' ) || ! bbp_is_single_topic() ) {
     348                return false;
     349        }
     350
     351        $plugin_instance = WordPressdotorg\Forums\Plugin::get_instance();
     352        $review = $plugin_instance->plugins->plugin ?? $plugin_instance->themes->theme;
     353
     354        return isset( $review ) ? $review->post_title : false;
     355}
     356
    341357/**
    342358 * Check if the current page is a user's "Reviews Written" page.
    343359 *