Making WordPress.org


Ignore:
Timestamp:
07/09/2014 06:54:57 PM (8 years ago)
Author:
coffee2code
Message:

Code Reference: add post_type search filter checkboxes to search form (all checked by default). Fixes #552

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/searchform.php

    r743 r744  
    4242        <input type="submit" class="shiny-blue search-submit" value="<?php echo esc_attr_x( 'Search', 'submit button', 'wporg' ); ?>">
    4343        </div>
     44
     45        <div class="search-post-type">
     46            <span><?php _e( 'Filter by type:', 'wporg' ); ?></span>
     47            <?php
     48                $search_post_types = array(
     49                    'wp-parser-function' => __( 'Functions', 'wporg' ),
     50                    'wp-parser-hook'     => __( 'Hooks',     'wporg' ),
     51                    'wp-parser-class'    => __( 'Classes',   'wporg' ),
     52                    'wp-parser-method'   => __( 'Methods',   'wporg' ),
     53                );
     54                foreach ( $search_post_types as $post_type => $label ) {
     55                    $qv_post_type = (array) get_query_var( 'post_type' );
     56                ?>
     57                    <label><input type="checkbox" name="post_type[]" value="<?php echo esc_attr( $post_type ); ?>"
     58                    <?php checked( ! is_search() || in_array( 'any', $qv_post_type ) || in_array( $post_type, $qv_post_type ) ); ?> /> <?php echo $label; ?></label>
     59                <?php } ?>
     60        </div>
    4461    </form>
    4562
Note: See TracChangeset for help on using the changeset viewer.