Making WordPress.org


Ignore:
Timestamp:
09/05/2022 05:14:31 AM (2 years ago)
Author:
dufresnesteven
Message:

wporg-developer: Sync with https://github.com/WordPress/wporg-developer/commit/790d402933d2725374de0d19e6bf6a576c8b15d2

File:
1 edited

Legend:

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

    r6301 r12050  
    4343        wp_enqueue_script( 'awesomplete' );
    4444
    45         wp_register_script( 'autocomplete', get_template_directory_uri() . '/js/autocomplete.js', array( 'awesomplete' ), '20160524', true );
     45        wp_register_script( 'autocomplete', get_stylesheet_directory_uri() . '/js/autocomplete.js', array( 'awesomplete' ), filemtime( dirname( __DIR__ ) . '/js/autocomplete.js' ), true );
    4646        wp_localize_script( 'autocomplete', 'autocomplete', array(
    4747                'ajaxurl' => admin_url( 'admin-ajax.php' ),
     
    100100            'search_orderby_title' => 1,
    101101            'order'                => 'ASC',
     102            '_autocomplete_search' => true,
    102103        );
    103104
    104105        $search = get_posts( $args );
    105106
    106         if ( !empty( $search ) ) {
    107             $titles = wp_list_pluck( $search, 'post_title' );
    108             $form_data['posts'] = array_values( array_unique( $titles ) );
     107        if ( ! empty( $search ) ) {
     108            $post_types_function_like = array( 'wp-parser-function', 'wp-parser-method' );
     109
     110            foreach ( $search as $post ) {
     111                $permalink = get_permalink( $post->ID );
     112                $title     = $post->post_title;
     113
     114                if ( in_array( $post->post_type, $post_types_function_like ) ) {
     115                    $title .= '()';
     116                }
     117
     118                if ( $post->post_type == 'wp-parser-class' ) {
     119                    $title =  'class ' . $title . ' {}';
     120                }
     121
     122                $form_data['posts'][ $title ] = $permalink;
     123            }
    109124        }
    110125
Note: See TracChangeset for help on using the changeset viewer.