2003-10-26 06:25:26 +01:00
< ? php
2004-04-25 05:59:12 +02:00
require_once ( '../wp-includes/wp-l10n.php' );
$title = __ ( 'Permalink Options' );
2004-04-19 10:09:27 +02:00
$parent_file = 'options-general.php' ;
2003-10-26 06:25:26 +01:00
2003-12-18 10:36:13 +01:00
$wpvarstoreset = array ( 'action' , 'standalone' , 'option_group_id' );
for ( $i = 0 ; $i < count ( $wpvarstoreset ); $i += 1 ) {
$wpvar = $wpvarstoreset [ $i ];
if ( ! isset ( $$wpvar )) {
2004-04-21 00:56:47 +02:00
if ( empty ( $_POST [ " $wpvar " ])) {
if ( empty ( $_GET [ " $wpvar " ])) {
2003-12-18 10:36:13 +01:00
$$wpvar = '' ;
2003-10-26 06:25:26 +01:00
} else {
2004-04-21 00:56:47 +02:00
$$wpvar = $_GET [ " $wpvar " ];
2003-10-26 06:25:26 +01:00
}
} else {
2004-04-21 00:56:47 +02:00
$$wpvar = $_POST [ " $wpvar " ];
2003-10-26 06:25:26 +01:00
}
}
}
2004-04-22 22:58:15 +02:00
require_once ( './optionhandler.php' );
2003-10-26 06:25:26 +01:00
2004-04-22 22:58:15 +02:00
if ( $_POST [ 'submit' ]) {
2004-04-21 00:56:47 +02:00
update_option ( 'permalink_structure' , $_POST [ 'permalink_structure' ]);
$permalink_structure = $_POST [ 'permalink_structure' ];
2003-10-26 06:25:26 +01:00
} else {
$permalink_structure = get_settings ( 'permalink_structure' );
}
switch ( $action ) {
default :
$standalone = 0 ;
2004-04-22 22:58:15 +02:00
require_once ( 'admin-header.php' );
2004-04-11 10:15:10 +02:00
if ( $user_level <= 6 ) {
2004-04-25 05:59:12 +02:00
die ( __ ( " You have do not have sufficient permissions to edit the options for this blog. " ));
2003-10-26 06:25:26 +01:00
}
2004-04-22 22:58:15 +02:00
require ( './options-head.php' );
2003-10-26 06:25:26 +01:00
?>
< div class = " wrap " >
2004-04-25 05:59:12 +02:00
< h2 >< ? php _e ( 'Edit Permalink Structure' ) ?> </h2>
< ? php _e ( '<p>WordPress offers you the ability to create a custom URI structure for your permalinks and archives. The following “tags” are available:</p>' ) ?>
2003-10-26 06:25:26 +01:00
< ul >
2004-04-25 05:59:12 +02:00
< li >< code >% year %</ code > --- < ? php _e ( 'The year of the post, 4 digits, for example <code>2004</code>' ) ?> </li>
< li >< code >% monthnum %</ code > --- < ? php _e ( 'Month of the year, for example <code>05</code>' ) ?> </li>
< li >< code >% day % </ code >--- < ? php _e ( 'Day of the month, for example <code>28</code>' ) ?> </li>
< li >< code >% postname %</ code > --- < ? php _e ( 'A sanitized version of the title of the post. So “This Is A Great Post!” becomes “<code>this-is-a-great-post</code>” in the URI' ) ?> </li>
2004-04-25 19:35:13 +02:00
< li >< code >% post_id %</ code > --- < ? php _e ( 'The unique ID # of the post, for example <code>423</code>' ) ?> </li>
2003-10-26 06:25:26 +01:00
</ ul >
2004-04-25 05:59:12 +02:00
< ? php _e ( ' < p > So for example a value like :</ p >
2004-04-15 09:53:45 +02:00
< p >< code >/ archives /% year %/% monthnum %/% day %/% postname %/</ code > </ p >
2004-04-21 23:38:38 +02:00
< p > would give you a permalink like :</ p >
< p >< code >/ archives / 2003 / 05 / 23 / my - cheese - sandwich /</ code ></ p >
< p > In general for this you must use mod_rewrite , however if you put a filename at the beginning WordPress will attempt to use that to pass the arguments , for example :</ p >
2004-04-15 09:53:45 +02:00
< p >< code >/ index . php / archives /% year %/% monthnum %/% day %/% postname %/</ code > </ p >
2004-04-25 05:59:12 +02:00
< p > If you use this option you can ignore the mod_rewrite rules . </ p > ' ) ?>
2003-12-11 01:22:36 +01:00
< form name = " form " action = " options-permalink.php " method = " post " >
2004-04-25 05:59:12 +02:00
< ? php _e ( '<p>Use the template tags above to create a virtual site structure:</p>' ) ?>
2003-10-26 06:25:26 +01:00
< p >
2004-04-22 22:58:15 +02:00
< input name = " permalink_structure " type = " text " style = " width: 98%; " value = " <?php echo $permalink_structure ; ?> " />
2003-10-26 06:25:26 +01:00
</ p >
2004-04-19 10:09:27 +02:00
< p class = " submit " >
2004-04-25 05:59:12 +02:00
< input type = " submit " name = " submit " value = " <?php _e('Update Permalink Structure') ?> " >
2003-10-26 06:25:26 +01:00
</ p >
</ form >
2003-10-30 16:03:30 +01:00
< ? php
if ( $permalink_structure ) {
?>
2004-04-25 05:59:12 +02:00
< ? php printf ( __ ( '<p>Using the permalink structure value you currently have, <code>%s</code>, these are the mod_rewrite rules you should have in your <code>.htaccess</code> file.</p>' ), $permalink_structure ) ?>
2003-10-26 06:25:26 +01:00
< ? php
2004-02-26 17:15:48 +01:00
$site_root = str_replace ( 'http://' , '' , trim ( get_settings ( 'siteurl' )));
2003-10-26 06:25:26 +01:00
$site_root = preg_replace ( '|([^/]*)(.*)|i' , '$2' , $site_root );
if ( '/' != substr ( $site_root , - 1 )) $site_root = $site_root . '/' ;
?>
2004-04-22 00:24:08 +02:00
< form action = " " >
2004-04-15 09:53:45 +02:00
< p >
< textarea rows = " 5 " style = " width: 100%; " > RewriteEngine On
2003-12-10 20:06:28 +01:00
RewriteBase < ? php echo $site_root ; ?>
2004-03-08 06:12:11 +01:00
< ? php
2004-03-09 04:55:01 +01:00
$rewrite = rewrite_rules ( '' , $permalink_structure );
2004-03-08 06:12:11 +01:00
foreach ( $rewrite as $match => $query ) {
echo 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA] \n " ;
}
2004-04-15 09:53:45 +02:00
?>
</ textarea >
</ p >
2004-04-25 05:59:12 +02:00
< ? php printf ( __ ( '<p>If your <code>.htaccess</code> file is writable by WordPress, you can <a href="%s">edit it through your template interface</a>.</p>' ), 'templates.php?file=.htaccess' ) ?>
2004-03-08 06:12:11 +01:00
</ form >
2003-10-26 06:25:26 +01:00
</ div >
< ? php
2003-10-30 16:03:30 +01:00
} else {
?>
< p >
2004-04-25 05:59:12 +02:00
< ? php _e ( 'You are not currently using customized permalinks. No special mod_rewrite rules are needed.' ) ?>
2003-10-30 16:03:30 +01:00
</ p >
< ? php
}
echo " </div> \n " ;
2003-10-26 06:25:26 +01:00
break ;
}
2004-04-22 22:58:15 +02:00
require ( './admin-footer.php' );
2004-04-25 05:59:12 +02:00
?>