Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow periods in @since taxonomy terms slugs #36

Open
GaryJones opened this issue Feb 10, 2014 · 8 comments
Open

Allow periods in @since taxonomy terms slugs #36

GaryJones opened this issue Feb 10, 2014 · 8 comments
Labels

Comments

@GaryJones
Copy link
Member

http://txfx.net/wordpress-plugins/periods-in-titles/ allows periods in post and term slugs. I use it at, for example, http://genesischangelog.com/2.0.2 .

It would be good if periods would be allowed for the @since taxonomy terms, so docs.example.com/since/1-0-0 would become a friendlier looking and naturally quicker to type docs.example.com/since/1.0.0 .

@rmccue
Copy link
Contributor

rmccue commented Feb 11, 2014

Could you adapt Mark's plugin? I'd rather it stay modular, rather than us hacking around in WP for everything.

@GaryJones
Copy link
Member Author

You mean do a patch for WP-Parser, or me just implement it for my own use case?

@rmccue
Copy link
Contributor

rmccue commented Feb 11, 2014

You mean do a patch for WP-Parser, or me just implement it for my own use case?

The latter; WP doesn't support it out of the box, and I prefer the "do one thing and do it well" philosophy rather than the kitchen-sink philosophy. :)

@Rarst
Copy link
Contributor

Rarst commented Feb 25, 2014

I am all for better URLs, however in my opinion parser already butts in too much into site. Right now we cannot even keep it enabled on DevHub outside of parsing process running because it messes things up.

So my current opinion is - whatever data parser creates it should remain viable data without it. URLs shouldn't break if parser plugin is no longer present/enabled.

It would, however, be beneficial to have a snippet around that easily provides clean "dot" URLs on top of parser data, just not as its default functionality.

@Rarst Rarst added the wontfix label Feb 25, 2014
@GaryJones
Copy link
Member Author

So long as there's a filter right before the slug is inserted, then it should be trivial for an external plugin to look for slugs matching of ~\d-\d-\d~ and replace it with \d\.\d\.\d.

@nacin
Copy link
Member

nacin commented Apr 24, 2014

Yeah, this is definitely something I want for developer.wordpress.org, but whether it is actually included as part of the parser itself is not a big issue. I think it'd actually be easier to do this on runtime and rewrite taxonomy=wp-parser-since&term=3.8.0 to query for 3-8-0 instead.

@Rarst
Copy link
Contributor

Rarst commented Dec 21, 2014

Seems like this has been done in devhub reference. Anyone cares to comment on and/or document the process? It still doesn't seem like something Parser itself should do.

@DrewAPicture
Copy link
Member

I agree with both @Rarst and @nacin ... much better to handle it on the theme side. On the DevHub theme, looks like we just use simple replacements for source file and since version permalinks:

function taxonomy_permalink( $link, $term, $taxonomy ) {
    if ( $taxonomy === 'wp-parser-source-file' ) {
        $slug = $term->slug;
        if ( substr( $slug, -4 ) === '-php' ) {
            $slug = substr( $slug, 0, -4 ) . '.php';
            $slug = str_replace( '_', '/', $slug );
        }
        $link = home_url( user_trailingslashit( "reference/files/$slug" ) );
    } elseif ( $taxonomy === 'wp-parser-since' ) {
        $link = str_replace( $term->slug, str_replace( '-', '.', $term->slug ), $link );
    }
    return $link;
}
add_filter( 'term_link', 'taxonomy_permalink', 10, 3 );

Though it occurs to me that alone just handles changing term links. I can't find anything about parsing the actual value of x.x.x vs x-x-x at runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants