Making WordPress.org

Ticket #5415: 5415.3.diff

File 5415.3.diff, 1.9 KB (added by dufresnesteven, 4 years ago)

Add a check before updating title text.

  • 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..1df5f9103 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                                $page_title = wporg_support_get_single_review_title();
     1102
     1103                                if( $page_title ) {
     1104                                        $title['text'] .= sprintf( ' - [%s] %s',
     1105                                                $page_title,
     1106                                                        __( 'Review', 'wporg-forums' )
     1107                                                );
     1108                                }
     1109                        }
    10991110                }
    11001111
    11011112                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 *