Making WordPress.org

Ticket #1648: 1648.patch

File 1648.patch, 1.5 KB (added by keesiemeijer, 8 years ago)

Add check for pretty permalinks

  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/functions.php

     
    9595        add_action( 'wp_head', __NAMESPACE__ . '\\header_js' );
    9696        add_action( 'add_meta_boxes', __NAMESPACE__ . '\\rename_comments_meta_box', 10, 2 );
    9797
    98         add_filter( 'post_type_link', __NAMESPACE__ . '\\method_permalink', 10, 2 );
     98        add_filter( 'post_type_link', __NAMESPACE__ . '\\method_permalink', 9, 2 );
    9999        add_filter( 'term_link', __NAMESPACE__ . '\\taxonomy_permalink', 10, 3 );
    100100        add_filter( 'the_posts', __NAMESPACE__ . '\\rerun_empty_exact_search', 10, 2 );
    101101
     
    245245}
    246246
    247247function method_permalink( $link, $post ) {
    248         if ( $post->post_type !== 'wp-parser-method' )
     248        global $wp_rewrite;
     249
     250        if ( !$wp_rewrite->using_permalinks() || ( $post->post_type !== 'wp-parser-method' ) ) {
    249251                return $link;
     252        }
    250253
    251254        list( $class, $method ) = explode( '-', $post->post_name );
    252255        $link = home_url( user_trailingslashit( "reference/classes/$class/$method" ) );
     
    254257}
    255258
    256259function taxonomy_permalink( $link, $term, $taxonomy ) {
     260        global $wp_rewrite;
     261
     262        if ( !$wp_rewrite->using_permalinks() ) {
     263                return $link;
     264        }
     265
    257266        if ( $taxonomy === 'wp-parser-source-file' ) {
    258267                $slug = $term->slug;
    259268                if ( substr( $slug, -4 ) === '-php' ) {