[COLOR=Red]Das Plugin funktioniert nur mit WP 2.2 und höher![/COLOR]
Aktuelle Version 0.15
- berücksichtigt die Tag-Links ab WP Version 2.3
Version 0.14
- Entfernt das html in Feed-Links
<?php
/*
Plugin Name: 123 HTML
Plugin URI: http://forum.wordpress-deutschland.org/konfiguration/21671-html-endung-3.html#post126487
Description: Setzt an die URLs ein '.html' hinten dran.
Author: Ingo Henze
Version: 0.15
Author URI: http://putzlowitsch.de/
*/
// Die Endung .html aus der Request-URI entfernen
$plw_request_uri = $_SERVER['REQUEST_URI'];
$plw_request_uri = preg_replace( '/\.html/i', "", $plw_request_uri );
// Bei einem Kategorie-Link die Bindestriche in Schrägstriche umwandeln
$plw_cat_base = get_option('category_base');
if( empty($plw_cat_base) )
$plw_cat_base = '/category';
else
$plw_cat_base = rtrim( $plw_cat_base, '/' );
$plw_cat_base = preg_quote( $plw_cat_base, '#' );
$plw_request_uri = preg_replace( "#^$plw_cat_base(.*)-#i", "$plw_cat_base$2/", $plw_request_uri );
// Ab WP-Version 2.3 müssen auch die Tag-Links behandelt werden
// die Verbindestrichung erfolgt wie bei Kategorien
// Bei einem Tag-Link die Bindestriche in Schrägstriche umwandeln
if( version_compare( get_bloginfo('version'), '2.3', '>=') ) {
$plw_tag_base = get_option('tag_base');
if( empty($plw_tag_base) )
$plw_tag_base = '/tag';
else
$plw_tag_base = rtrim( $plw_tag_base, '/' );
$plw_tag_base = preg_quote( $plw_tag_base, '#' );
$plw_request_uri = preg_replace( "#^$plw_tag_base(.*)-#i", "$plw_tag_base$2/", $plw_request_uri );
}
$_SERVER['REQUEST_URI'] = $plw_request_uri;
function plw_feed_link( $link ) {
// html in Feedlinks entfernen
if( preg_match( '~(.*)\.html(/feed.*)$~i', $link, $treffer ) ) {
$link = $treffer[1].$treffer[2];
}
return $link;
}
function plw_link_append_html( $link, $type_of_url ) {
// Mögliche Werte für $type_of_url:
// single, single_trackback, single_feed, single_paged, feed, category, page, year, month, day, paged
if( preg_match( '/^(single|page|category|year|month|day|paged)$/i', $type_of_url ) ) {
$link = rtrim( $link, '/' );
if( $type_of_url == 'category' )
{
// Bei einem Kategorie-Link die Schrägstriche in Bindestriche umwandeln
$link = preg_replace( "#([^.]+?)/#i", "$1-", $link );
}
return $link.'.html';
}
else
return $link;
}
add_filter( 'user_trailingslashit', 'plw_link_append_html', 66, 2 );
add_filter( 'post_comments_feed_link', 'plw_feed_link' );
add_filter( 'category_feed_link', 'plw_feed_link' );
?>
Alles anzeigen
Gruß
Ingo