Making WordPress.org

Ticket #3722: 3722.patch

File 3722.patch, 2.4 KB (added by Clorith, 7 years ago)
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php

     
    44
    55class Hooks {
    66
     7        private $has_new_topic_button = false;
     8
    79        const SITE_URL_META = '_wporg_bbp_topic_site_url';
    810
    911        public function __construct() {
     
    241243         * Displays a link to the new topic form.
    242244         */
    243245        public function new_topic_link() {
    244                 if ( bbp_is_single_forum() ) {
     246                if ( bbp_is_single_forum() && bbp_current_user_can_access_create_topic_form() && ! $this->has_new_topic_button ) {
    245247                        printf( '<a class="button create-topic" href="#new-topic-0">%s</a>', __( 'Create Topic', 'wporg-forums' ) );
     248
     249                        /*
     250                         * The $has_new_topic_button class variable prevents us from adding the create topic button
     251                         * multiple times on the same page in cases where the pagination links are used more than once.
     252                         *
     253                         * This avoids adding a create button at the bottom of the page, next to the create form.
     254                         */
     255                        $this->has_new_topic_button = true;
    246256                }
    247257        }
    248258
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/sidebar.php

     
    2525                                        <?php bb_base_single_forum_description(); ?>
    2626                                        <li><a class="feed" href="<?php bbp_forum_permalink(); ?>feed/"><?php _e( 'Recent Posts', 'wporg-forums' ); ?></a></li>
    2727                                        <li><a class="feed" href="<?php bbp_forum_permalink(); ?>feed/?type=topic"><?php _e( 'Recent Topics', 'wporg-forums' ); ?></a></li>
    28                                         <?php if ( bbp_current_user_can_access_create_topic_form() ) : ?>
    29                                                 <li class="create-topic"><a href="#new-post"><?php _e( 'Create Topic', 'wporg-forums' ); ?></a></li>
    30                                         <?php endif; ?>
    3128                                        <?php if ( is_user_logged_in() && $forum_subscription_link = bbp_get_forum_subscription_link() ) : ?>
    3229                                                <li class="forum-subscribe"><?php echo $forum_subscription_link; ?></li>
    3330                                        <?php endif; ?>