mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Add radio button for our default permalink structure. Add got_mod_rewrite(). Props Mark Jaquith. fixes #1840
git-svn-id: http://svn.automattic.com/wordpress/trunk@3029 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
03567e7d88
commit
7710b94ad0
@ -975,6 +975,29 @@ function extract_from_markers($filename, $marker) {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function got_mod_rewrite() {
|
||||||
|
global $is_apache;
|
||||||
|
|
||||||
|
// take 3 educated guesses as to whether or not mod_rewrite is available
|
||||||
|
if ( !$is_apache )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( function_exists('apache_get_modules') ) {
|
||||||
|
if ( !in_array('mod_rewrite', apache_get_modules()) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( function_exists('ob_get_clean') ) {
|
||||||
|
ob_start();
|
||||||
|
phpinfo(INFO_MODULES);
|
||||||
|
$php_modules = ob_get_clean();
|
||||||
|
if ( strpos($php_modules, 'mod_rewrite') === false)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function save_mod_rewrite_rules() {
|
function save_mod_rewrite_rules() {
|
||||||
global $is_apache, $wp_rewrite;
|
global $is_apache, $wp_rewrite;
|
||||||
$home_path = get_home_path();
|
$home_path = get_home_path();
|
||||||
@ -985,7 +1008,7 @@ function save_mod_rewrite_rules() {
|
|||||||
if (!((!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess')))
|
if (!((!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess')))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!$is_apache)
|
if (! got_mod_rewrite())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$rules = explode("\n", $wp_rewrite->mod_rewrite_rules());
|
$rules = explode("\n", $wp_rewrite->mod_rewrite_rules());
|
||||||
|
@ -103,27 +103,40 @@ else
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
$prefix = '';
|
$prefix = '';
|
||||||
if ( !$is_apache )
|
|
||||||
|
if ( ! got_mod_rewrite() )
|
||||||
$prefix = '/index.php';
|
$prefix = '/index.php';
|
||||||
|
|
||||||
|
$structures = array(
|
||||||
|
'',
|
||||||
|
$prefix . '/%year%/%monthnum%/%day%/%postname%/',
|
||||||
|
$prefix . '/archives/%post_id%'
|
||||||
|
);
|
||||||
?>
|
?>
|
||||||
<form name="form" action="options-permalink.php" method="post">
|
<form name="form" action="options-permalink.php" method="post">
|
||||||
<h3><?php _e('Common options:'); ?></h3>
|
<h3><?php _e('Common options:'); ?></h3>
|
||||||
<p>
|
<p>
|
||||||
<label>
|
<label>
|
||||||
<input name="selection" type="radio" value="<?php echo $prefix; ?>/%year%/%monthnum%/%day%/%postname%/" class="tog" <?php checked( $prefix . '/%year%/%monthnum%/%day%/%postname%/', $permalink_structure); ?> />
|
<input name="selection" type="radio" value="" class="tog" <?php checked('', $permalink_structure); ?> />
|
||||||
<?php _e('Date and name based, example:'); ?> <code><?php echo get_settings('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code>
|
<?php _e('Default'); ?><br /> <span> » <code><?php echo get_settings('home'); ?>/?p=123</code></span>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label>
|
<label>
|
||||||
<input name="selection" type="radio" value="<?php echo $prefix; ?>/archives/%post_id%" class="tog" <?php checked( $prefix . '/archives/%post_id%', $permalink_structure); ?> />
|
<input name="selection" type="radio" value="<?php echo $structures[1]; ?>" class="tog" <?php checked($structures[1], $permalink_structure); ?> />
|
||||||
<?php _e('Numeric, example:'); ?> <code><?php echo get_settings('home') . $prefix ; ?>/archives/123</code>
|
<?php _e('Date and name based'); ?><br /> <span> » <code><?php echo get_settings('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></span>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
<input name="selection" type="radio" value="<?php echo $structures[2]; ?>" class="tog" <?php checked($structures[2], $permalink_structure); ?> />
|
||||||
|
<?php _e('Numeric'); ?><br /> <span> » <code><?php echo get_settings('home') . $prefix ; ?>/archives/123</code></span>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label>
|
<label>
|
||||||
<input name="selection" type="radio" value="custom" class="tog"
|
<input name="selection" type="radio" value="custom" class="tog"
|
||||||
<?php if ( $permalink_structure != $prefix . '/archives/%post_id%' && $permalink_structure != $prefix . '/%year%/%monthnum%/%day%/%postname%/' ) { ?>
|
<?php if ( !in_array($permalink_structure, $structures) ) { ?>
|
||||||
checked="checked"
|
checked="checked"
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user