Making WordPress.org

Changeset 7381


Ignore:
Timestamp:
07/06/2018 06:46:39 PM (4 years ago)
Author:
obenland
Message:

DevHub: More flexible method permalink handling

Allows for the possiblity of more than one dash in a method's slug.

Props keesiemeijer.
Fixes #3688.

File:
1 edited

Legend:

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

    r7278 r7381  
    260260}
    261261
     262/**
     263 * Filters the permalink for a wp-parser-method post.
     264 *
     265 * @param string   $link The post's permalink.
     266 * @param \WP_Post $post The post in question.
     267 * @return string
     268 */
    262269function method_permalink( $link, $post ) {
    263270    global $wp_rewrite;
     
    267274    }
    268275
    269     list( $class, $method ) = explode( '-', $post->post_name );
    270     $link = home_url( user_trailingslashit( "reference/classes/$class/$method" ) );
    271     return $link;
     276    $parts  = explode( '-', $post->post_name );
     277    $method = array_pop( $parts );
     278    $class  = implode( '-', $parts );
     279
     280    return home_url( user_trailingslashit( "reference/classes/$class/$method" ) );
    272281}
    273282
Note: See TracChangeset for help on using the changeset viewer.