Making WordPress.org

Ticket #7: 7.patch

File 7.patch, 5.4 KB (added by SergeyBiryukov, 8 years ago)
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php

     
    277277                        $this->term = get_term_by( 'slug', $this->slug(), $this->taxonomy() );
    278278
    279279                        // Add plugin- and theme-specific filters and actions.
    280                         add_action( 'wporg_compat_view_sidebar', array( $this, 'do_view_sidebar' ) );
     280                        add_action( 'wporg_compat_view_sidebar',       array( $this, 'do_view_sidebar' ) );
    281281                        add_action( 'wporg_compat_before_single_view', array( $this, 'do_view_header' ) );
    282282                        add_action( 'wporg_compat_before_single_view', array( $this, 'do_subscription_link' ), 11 );
     283                        add_action( 'wporg_compat_before_single_view', array( $this, 'do_search_form' ), 11 );
    283284
    284285                        // Add output filters and actions.
    285286                        add_filter( 'bbp_get_view_link', array( $this, 'get_view_link' ), 10, 2 );
     
    707708        }
    708709
    709710        /**
     711         * Display a project-specific search form in compat views.
     712         */
     713        function do_search_form() {
     714                get_search_form();
     715        }
     716
     717        /**
    710718         * Term subscriptions use `get_term_link` for the redirect. This needs to be
    711719         * filtered to redirect to the appropriate theme/plugin support view.
    712720         *
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php

     
    8686                        $search_terms = get_search_query( false );
    8787                }
    8888
     89                if ( isset( $_GET['intext'] ) ) {
     90                        $search_terms .= ' intext:"' . esc_attr( $_GET['intext'] ) . '"';
     91                }
     92
    8993                if ( $search_terms ) {
    9094                        $search_url = sprintf( 'https://wordpress.org/search/%s/?forums=1', urlencode( $search_terms ) );
    9195                        $search_url = esc_url_raw( $search_url );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

     
    261261}
    262262
    263263/**
     264 * Get current plugin or theme object in plugin- or theme-specific views.
     265 *
     266 * @return object|null Plugin or theme object on success, false on failure.
     267 */
     268function wporg_support_get_compat_object() {
     269        if ( ! class_exists( 'WordPressdotorg\Forums\Plugin' ) ) {
     270                return null;
     271        }
     272
     273        $object          = null;
     274        $plugin_instance = WordPressdotorg\Forums\Plugin::get_instance();
     275
     276        if ( ! empty( $plugin_instance->plugins->plugin ) ) {
     277                $object = $plugin_instance->plugins->plugin;
     278
     279                /* translators: %s: link to plugin support or review forum */
     280                $object->prefixed_title = sprintf( __( 'Plugin: %s', 'wporg-forums' ), $object->post_title );
     281                $object->type           = 'plugin';
     282        } elseif ( ! empty( $plugin_instance->themes->theme ) ) {
     283                $object = $plugin_instance->themes->theme;
     284
     285                /* translators: %s: link to theme support or review forum */
     286                $object->prefixed_title = sprintf( __( 'Theme: %s', 'wporg-forums' ), $object->post_title );
     287                $object->type           = 'theme';
     288        }
     289
     290        return $object;
     291}
     292
     293/**
    264294 * Display a notice for messages caught in the moderation queue.
    265295 */
    266296function wporg_support_add_moderation_notice() {
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/searchform.php

     
    1515
    1616<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
    1717        <label for="s" class="screen-reader-text"><?php _ex( 'Search for:', 'label', 'wporg-forums' ); ?></label>
    18         <input type="search" id="s" class="search-field" placeholder="<?php echo esc_attr_x( 'Search forums', 'placeholder', 'wporg-forums' ); ?>" value="<?php the_search_query(); ?>" name="s" />
     18        <?php
     19                if ( 'wporg_compat_before_single_view' === current_action() ) {
     20                        $placeholder = _x( 'Search this forum', 'placeholder', 'wporg-forums' );
     21                        $project     = wporg_support_get_compat_object();
     22                } else {
     23                        $placeholder = _x( 'Search forums', 'placeholder', 'wporg-forums' );
     24                        $project     = null;
     25                }
     26        ?>
     27        <input type="search" id="s" class="search-field" placeholder="<?php echo esc_attr( $placeholder ); ?>" value="<?php the_search_query(); ?>" name="s" />
     28        <?php if ( $project ) : ?>
     29        <input type="hidden" name="intext" value="<?php echo esc_attr( $project->prefixed_title ); ?>" />
     30        <?php endif; ?>
    1931        <button class="button button-primary button-search"><i class="dashicons dashicons-search"></i><span class="screen-reader-text"><?php _e( 'Search forums', 'wporg-forums' ); ?></span></button>
    2032</form>
    2133