Making WordPress.org

Ticket #3688: 3688.patch

File 3688.patch, 966 bytes (added by keesiemeijer, 6 years ago)

Fix method permalinks

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

     
    266266                return $link;
    267267        }
    268268
    269         list( $class, $method ) = explode( '-', $post->post_name );
    270         $link = home_url( user_trailingslashit( "reference/classes/$class/$method" ) );
     269
     270        $parent = get_post( $post->post_parent );
     271        if ( ! $parent ) {
     272                return $link;
     273        }
     274
     275        $method = basename( $link );
     276        $name   = $parent->post_name . '-';
     277
     278        if ( substr( $method, 0, strlen( $name ) ) === $name ) {
     279                $method = substr( $method, strlen( $name ) );
     280        }
     281
     282        $link = home_url( user_trailingslashit( "reference/classes/{$parent->post_name}/{$method}" ) );
    271283        return $link;
    272284}
    273285