Making WordPress.org

Ticket #2882: 2882.2.patch

File 2882.2.patch, 9.9 KB (added by grapplerulrich, 7 years ago)
  • wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/extras.php

    From 5515e51ec51d204fbf77d2c038a372a413108ad9 Mon Sep 17 00:00:00 2001
    From: Ulrich Pogson <grapplerulrich@gmail.com>
    Date: Sat, 19 Aug 2017 18:48:31 +0200
    Subject: [PATCH] 2882
    
    ---
     .../themes/pub/wporg-developer/inc/extras.php        |  3 +--
     .../themes/pub/wporg-developer/inc/handbooks.php     | 14 +++++++-------
     .../themes/pub/wporg-developer/inc/redirects.php     |  2 +-
     .../themes/pub/wporg-developer/inc/search.php        | 20 ++------------------
     .../themes/pub/wporg-developer/inc/template-tags.php |  2 +-
     .../wp-content/themes/pub/wporg-developer/search.php |  4 ++--
     .../themes/pub/wporg-developer/searchform.php        |  4 ++--
     7 files changed, 16 insertions(+), 33 deletions(-)
    
    diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/extras.php wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/extras.php
    index f8d05263..65ab8ab0 100755
    add_filter( 'document_title_parts', 'wporg_developer_document_title' ); 
    9696 * @return string
    9797 */
    9898function wporg_filter_archive_excerpt( $excerpt ) {
    99         if ( ! is_single() && ! get_query_var( 'is_handbook' ) && 'command' !== get_query_var( 'post_type' ) ) {
     99        if ( ! is_single() && ! $GLOBALS['wp_query']->is_handbook && 'command' !== get_query_var( 'post_type' ) ) {
    100100
    101101                $post_id = get_the_ID();
    102102                $type    = get_post_type_object( get_post_type( $post_id ) )->labels->singular_name;
    function wporg_loop_pagination( $page_links ) { 
    200200        return $page_links;
    201201}
    202202add_filter( 'loop_pagination', 'wporg_loop_pagination' );
    203 
  • wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/handbooks.php

    diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/handbooks.php wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/handbooks.php
    index c5deb110..df5ff37f 100644
    class Devhub_Handbooks { 
    6262         * @return array Array with public query vars.
    6363         */
    6464        public static function add_query_vars( $public_query_vars ) {
    65                 $public_query_vars['is_handbook'] = false;
    66                 $public_query_vars['current_handbook'] = false;
    67                 $public_query_vars['current_handbook_home_url'] = false;
    68                 $public_query_vars['current_handbook_name'] = '';
     65                $public_query_vars[] = 'current_handbook';
     66                $public_query_vars[] = 'current_handbook_home_url';
     67                $public_query_vars[] = 'current_handbook_name';
    6968
    7069                return $public_query_vars;
    7170        }
    class Devhub_Handbooks { 
    7776         */
    7877        public static function pre_get_posts( $query ) {
    7978                $is_handbook = function_exists( 'wporg_is_handbook' ) ? wporg_is_handbook() : false;
    80                 $query->set( 'is_handbook', $is_handbook );
     79                $query->is_handbook = $is_handbook;
    8180
    82                 $current_handbook = function_exists( 'wporg_get_current_handbook' ) ? wporg_get_current_handbook() : false;
     81                $current_handbook = function_exists( 'wporg_get_current_handbook' ) && wporg_get_current_handbook() ? wporg_get_current_handbook() : '';
    8382                $query->set( 'current_handbook', $current_handbook );
    8483
    85                 $current_handbook_home_url = function_exists( 'wporg_get_current_handbook_home_url' ) ? wporg_get_current_handbook_home_url() : false;
     84                $current_handbook_home_url = function_exists( 'wporg_get_current_handbook_home_url' ) && wporg_get_current_handbook_home_url() ? wporg_get_current_handbook_home_url() :
     85                '';
    8686                $query->set( 'current_handbook_home_url', $current_handbook_home_url );
    8787
    8888                $current_handbook_name = function_exists( 'wporg_get_current_handbook_name' ) ? wporg_get_current_handbook_name() : '';
  • wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/redirects.php

    diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/redirects.php wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/redirects.php
    index b81b1406..8758df13 100644
    class DevHub_Redirects { 
    3232         * Redirects a search query with only one result directly to that result.
    3333         */
    3434        public static function redirect_single_search_match() {
    35                 if ( is_search() && ! get_query_var( 'is_handbook' ) && 1 == $GLOBALS['wp_query']->found_posts ) {
     35                if ( is_search() && ! $GLOBALS['wp_query']->is_handbook && 1 == $GLOBALS['wp_query']->found_posts ) {
    3636                        wp_redirect( get_permalink( get_post() ) );
    3737                        exit();
    3838                }
  • wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/search.php

    diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/search.php wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/search.php
    index 3fce6373..6dfff780 100644
    class DevHub_Search { 
    2424                add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ), 20 );
    2525                add_filter( 'posts_orderby', array( __CLASS__, 'search_posts_orderby' ), 10, 2 );
    2626                add_filter( 'the_posts',     array( __CLASS__, 'rerun_empty_exact_search' ), 10, 2 );
    27                 add_filter( 'query_vars',    array( __CLASS__, 'default_qv_empty_post_type_search' ) );
    28         }
    29 
    30         /**
    31          * Add query var to indicate if no post type filters were explicitly used for
    32          * a search.
    33          *
    34          * Defaults the query var 'empty_post_type_search' to false. It is potentially
    35          * set to true elsewhere.
    36          *
    37          * @param array $public_query_vars The array of whitelisted query variables.
    38          * @return array
    39          */
    40         public static function default_qv_empty_post_type_search( $public_query_vars ) {
    41                 $public_query_vars['empty_post_type_search'] = false;
    42                 return $public_query_vars;
    4327        }
    4428
    4529        /**
    class DevHub_Search { 
    5943
    6044                // Separates searches for handbook pages from non-handbook pages depending on
    6145                // whether the search was performed within context of a handbook page or not.
    62                 if ( get_query_var( 'is_handbook' ) ) {
     46                if ( $query->is_handbook ) {
    6347                        // Search only in current handbook post type.
    6448                        // Just to make sure. post type should already be set.
    6549                        $query->set( 'post_type', wporg_get_current_handbook() );
    class DevHub_Search { 
    8266
    8367                if ( ! $qv_post_types ) {
    8468                        // Record the fact no post types were explicitly supplied.
    85                         $query->set( 'empty_post_type_search', true );
     69                        $query->is_empty_post_type_search = true;
    8670
    8771                        // Not a handbook page, or exact search, or filters used.
    8872                        // Fallback to parsed post types.
  • wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php

    diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
    index 15bceeee..5d748aa1 100755
    namespace DevHub { 
    13371337                $post_types = get_parsed_post_types();
    13381338                $taxonomies = array( 'wp-parser-since', 'wp-parser-package', 'wp-parser-source-file' );
    13391339
    1340                 return ! ( is_search() || is_404() ) && ( is_singular( $post_types ) || is_post_type_archive( $post_types ) || is_tax( $taxonomies ) || get_query_var( 'is_handbook' ) );
     1340                return ! ( is_search() || is_404() ) && ( is_singular( $post_types ) || is_post_type_archive( $post_types ) || is_tax( $taxonomies ) || $GLOBALS['wp_query']->is_handbook );
    13411341        }
    13421342
    13431343        /**
  • wordpress.org/public_html/wp-content/themes/pub/wporg-developer/search.php

    diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-developer/search.php wordpress.org/public_html/wp-content/themes/pub/wporg-developer/search.php
    index 0561c23c..24197b49 100755
    get_header(); ?> 
    1313                        <span class="trail-browse"><span class="trail-begin"><?php _e( 'Search Results', 'wporg' ); ?></span></span><span class="sep">:</span>
    1414                        <span><a href="<?php echo home_url( '/' ); ?>"><?php _e( 'Home', 'wporg' ); ?></a></span>
    1515                        <span class="sep">/</span>
    16                         <?php if ( get_query_var( 'is_handbook' ) ) : ?>
     16                        <?php if ( $GLOBALS['wp_query']->is_handbook ) : ?>
    1717                        <span><a href="<?php echo esc_url( get_query_var( 'current_handbook_home_url' ) ); ?>"><?php echo get_query_var( 'current_handbook_name' ); ?></a></span>
    1818                        <?php elseif ( $reference_page = get_page_by_path( 'reference' ) ) : ?>
    1919                        <span><a href="<?php echo esc_url( get_permalink( $reference_page ) ); ?>"><?php echo get_the_title( $reference_page ); ?></a></span>
    get_header(); ?> 
    3131                        <?php /* Start the Loop */ ?>
    3232                        <?php while ( have_posts() ) : the_post(); ?>
    3333
    34                                 <?php get_template_part( 'content', get_query_var( 'is_handbook' ) ? 'handbook-archive' : 'reference-archive' ); ?>
     34                                <?php get_template_part( 'content', $GLOBALS['wp_query']->is_handbook ? 'handbook-archive' : 'reference-archive' ); ?>
    3535
    3636                        <?php endwhile; ?>
    3737
  • wordpress.org/public_html/wp-content/themes/pub/wporg-developer/searchform.php

    diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-developer/searchform.php wordpress.org/public_html/wp-content/themes/pub/wporg-developer/searchform.php
    index 2f3ac5ec..32f9b009 100755
     
    3434<?php } ?>
    3535
    3636        <?php
    37                 $is_handbook = get_query_var( 'is_handbook' );
     37                $is_handbook = $GLOBALS['wp_query']->is_handbook;
    3838                $search_url  = get_query_var( 'current_handbook_home_url' );
    3939                $search_url  = $search_url ? $search_url : home_url( '/' );
    4040                $filters     = ! ( $is_handbook || is_404() );
     
    6161                                );
    6262                               
    6363                                $qv_post_type = array_filter( (array) get_query_var( 'post_type' ) );   
    64                                 $no_filters   = get_query_var( 'empty_post_type_search' );
     64                                $no_filters   = $GLOBALS['wp_query']->is_empty_post_type_search;
    6565
    6666                                if ( ! is_search() || in_array( 'any', $qv_post_type ) || $no_filters ) {
    6767                                        // No filters used.