WordPress.org

Making WordPress.org

Changeset 9663


Ignore:
Timestamp:
03/31/2020 11:17:28 PM (13 months ago)
Author:
coffee2code
Message:

Support Forums: Output search form and button for creating topic/review next to each other above topics table.

Props valentinbora, bcworkz, melchoyce, coffee2code.
See #4659.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php

    r9621 r9663  
    313313            add_action( 'wporg_compat_before_single_view', array( $this, 'do_view_header' ) );
    314314            add_action( 'wporg_compat_before_single_view', array( $this, 'do_subscription_link' ), 11 );
    315             add_action( 'wporg_compat_before_single_view', array( $this, 'do_search_form' ), 11 );
    316315
    317316            // Add output filters and actions.
     
    793792
    794793    /**
    795      * Display a project-specific search form in compat views.
    796      */
    797     function do_search_form() {
    798         get_search_form();
    799     }
    800 
    801     /**
    802794     * Term subscriptions use `get_term_link` for the redirect. This needs to be
    803795     * filtered to redirect to the appropriate theme/plugin support view.
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php

    r9612 r9663  
    607607            bbp_is_single_view() && in_array( bbp_get_view_id(), array( 'plugin', 'reviews', 'theme' ) )
    608608        ) {
     609            $btn = null;
    609610            $is_reviews = 'reviews' === bbp_get_view_id();
     611
    610612            if ( bbp_current_user_can_access_create_topic_form() ) {
    611                 printf(
    612                     '<a class="button create-topic" href="#new-topic-0">%s</a>',
     613                $btn = sprintf(
     614                    '<a class="button button-secondary create-topic" href="#new-topic-0">%s</a>',
    613615                    $is_reviews ? __( 'Create Review', 'wporg-forums' ) : __( 'Create Topic', 'wporg-forums' )
    614616                );
    615617            } elseif ( ! bbp_is_forum_closed() && ! is_user_logged_in() ) {
    616                 printf(
    617                     '<a class="button create-topic login" href="%s">%s</a>',
     618                $btn = sprintf(
     619                    '<a class="button button-secondary create-topic login" href="%s">%s</a>',
    618620                    wp_login_url(),
    619621                    $is_reviews ? __( 'Log in to Create a Review', 'wporg-forums' ) : __( 'Log in to Create a Topic', 'wporg-forums' )
    620622                );
     623            }
     624
     625            if ( $btn ) {
     626                $searchform = get_search_form( [ 'echo' => false ] );
     627
     628                echo '<div class="bbp-create-topic-wrapper">';
     629                if ( $searchform ) {
     630                    printf(
     631                        /* translators: 1: markup for forums search field which is primary action, 2: markup for button to create topic */
     632                        __( '%1$s or %2$s', 'wporg-forums' ),
     633                        $searchform,
     634                        $btn
     635                    );
     636                } else {
     637                    echo $btn;
     638                }
     639                echo "</div>\n";
    621640            }
    622641
Note: See TracChangeset for help on using the changeset viewer.