Making WordPress.org

Ticket #7762: 7762.patch

File 7762.patch, 1.6 KB (added by karthickmurugan, 6 months ago)

Patch file which creates "My Topics" link and it will link to current user profile "My Topics" page

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

     
    301301                        // Add output filters and actions.
    302302                        add_filter( 'bbp_get_view_link', array( $this, 'get_view_link' ), 10, 2 );
    303303                        add_filter( 'bbp_breadcrumbs',   array( $this, 'breadcrumbs' ) );
     304                        add_filter( 'bbp_get_breadcrumb', array( $this, 'add_my_topics_link' ) );
    304305
    305306                        // Handle new topic form at the bottom of support view.
    306307                        add_action( 'wporg_compat_after_single_view',      array( $this, 'add_topic_form' ) );
     
    713714        }
    714715
    715716        /**
     717         * Add "My Topics" link to the breadcrumbs.
     718         */
     719        public function add_my_topics_link( $r ) {
     720                if ( ! bbp_is_single_view() ) {
     721                        return $r;
     722                }
     723
     724                $view = bbp_get_view_id();
     725                if ( ! in_array( $view, $this->compat_views() ) ) {
     726                        return $r;
     727                }
     728
     729                // Add "My Topics" link after "Reviews"
     730                if ( 'reviews' == $view ) {
     731                        $current_user = wp_get_current_user();
     732                        $my_topics_url = esc_url( 'https://wordpress.org/support/users/' . $current_user->user_nicename . '/topics/' );
     733                        $r[] = sprintf(
     734                                '<a href="%s" class="bbp-breadcrumb-forum">%s</a>',
     735                                $my_topics_url,
     736                                __( 'My Topics', 'wporg-forums' )
     737                        );
     738                }
     739
     740                return $r;
     741        }
     742
     743        /**
    716744         * Add the new topic form at the bottom of appropriate views; the reviews view
    717745         * form addition is handled by Ratings_Compat.
    718746         */