Making WordPress.org


Ignore:
Timestamp:
04/15/2016 08:12:38 PM (10 years ago)
Author:
coffee2code
Message:

developer.wordpress.org: Check if pretty permalinks are in use before attempting to modify permalink structure.

Props keesiemeijer.
Fixes #1648.

File:
1 edited

Legend:

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

    r2938 r2965  
    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( 'posts_orderby', __NAMESPACE__ . '\\search_posts_orderby', 10, 2 );
     
    336336
    337337function method_permalink( $link, $post ) {
    338         if ( $post->post_type !== 'wp-parser-method' )
     338        global $wp_rewrite;
     339
     340        if ( ! $wp_rewrite->using_permalinks() || ( 'wp-parser-method' !== $post->post_type ) ) {
    339341                return $link;
     342        }
    340343
    341344        list( $class, $method ) = explode( '-', $post->post_name );
     
    345348
    346349function taxonomy_permalink( $link, $term, $taxonomy ) {
     350        global $wp_rewrite;
     351
     352        if ( ! $wp_rewrite->using_permalinks() ) {
     353                return $link;
     354        }
     355
    347356        if ( $taxonomy === 'wp-parser-source-file' ) {
    348357                $slug = $term->slug;
Note: See TracChangeset for help on using the changeset viewer.