Making WordPress.org

Ticket #4659: 4659.diff

File 4659.diff, 3.2 KB (added by valentinbora, 5 years ago)

Implementation of the latest proposal with a search form and a create topic button for Forums

  • 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 d49fdecd0..1215511c1 100644
    class Hooks { 
    515515         * Displays a link to the new topic form.
    516516         */
    517517        public function new_topic_link() {
    518                 if ( bbp_is_single_forum() ) {
     518                if (
     519                        bbp_is_single_forum()
     520                ||
     521                        bbp_is_single_view() && in_array( bbp_get_view_id(), array( 'plugin', 'reviews', 'theme' ) )
     522                ) {
     523                        $btn = null;
     524                        $is_forum = bbp_is_single_forum();
     525                        $is_reviews = 'reviews' === bbp_get_view_id();
     526
    519527                        if ( bbp_current_user_can_access_create_topic_form() ) {
    520                                 printf(
    521                                         '<a class="button create-topic" href="#new-topic-0">%s</a>',
    522                                         __( 'Create Topic', 'wporg-forums' )
     528                                $btn = sprintf(
     529                                        '<a class="button ' . ( $is_forum ? 'button-primary' : '' ) . ' create-topic" href="#new-topic-0">%s</a>',
     530                                        $is_reviews ? __( 'Create Review', 'wporg-forums' ) : __( 'Create Topic', 'wporg-forums' )
    523531                                );
    524532                        } elseif ( ! bbp_is_forum_closed() && ! is_user_logged_in() ) {
    525                                 printf(
    526                                         '<a class="button create-topic login" href="%s">%s</a>',
     533                                $btn = sprintf(
     534                                        '<a class="button ' . ( $is_forum ? 'button-primary' : '' ) . ' create-topic login" href="%s">%s</a>',
    527535                                        wp_login_url(),
    528                                         __( 'Log in to Create a Topic', 'wporg-forums' )
     536                                        $is_reviews ? __( 'Log in to Create a Review', 'wporg-forums' ) : __( 'Log in to Create a Topic', 'wporg-forums' )
    529537                                );
    530538                        }
    531539
    532                         remove_filter( 'bbp_template_before_pagination_loop', array( $this, 'new_topic_link' ) );
     540                        if ( $btn ) {
     541                                if ( $is_forum ) {
     542                                        echo '<div class="bbp-create-topic-wrapper">';
     543                                        require_once get_template_directory() . '/searchform.php';
     544                                        printf( '<span>%s</span>', __( 'or', 'wporg-forums' ) );
     545                                        echo $btn;
     546                                        echo '</div>';
     547                                } else {
     548                                        echo $btn;
     549                                }
     550
     551                                remove_filter( 'bbp_template_before_pagination_loop', array( $this, 'new_topic_link' ) );
     552                        }
    533553                }
    534554        }
    535555
  • wordpress.org/public_html/wp-content/themes/pub/wporg-support/sass/site/_bbpress.scss

    diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-support/sass/site/_bbpress.scss wordpress.org/public_html/wp-content/themes/pub/wporg-support/sass/site/_bbpress.scss
    index 6d7aa0361..fe4bcc092 100644
    section { 
    483483                        }
    484484                }
    485485
     486                .bbp-create-topic-wrapper {
     487                        padding: 15px 0 25px;
     488                        text-align: center;
     489
     490                        .create-topic {
     491                                float: none;
     492                                height: auto;
     493                                padding: 9px 12px;
     494
     495                                &::before {
     496                                        color: #FFF;
     497                                }
     498                        }
     499
     500                        > span {
     501                                margin: 0 8px 0 6px;
     502                                font-size: 0.8rem;
     503                        }
     504
     505                        .search-form {
     506                                display: inline-block;
     507                                width: 50%;
     508                                margin-bottom: 0;
     509                        }
     510
     511                        @media (max-width: 767px) {
     512                                .create-topic,
     513                                > span,
     514                                .search-form {
     515                                        display: block;
     516                                        width: 100%;
     517                                }
     518
     519                                > span {
     520                                        margin: 3px 0;
     521                                }
     522                        }
     523                }
     524
    486525                .bbp-pagination {
    487526                        font-size: ms(-2);
    488527                        float: none;