Make WordPress Core

Changeset 3029


Ignore:
Timestamp:
11/10/2005 11:25:39 PM (19 years ago)
Author:
ryan
Message:

Add radio button for our default permalink structure. Add got_mod_rewrite(). Props Mark Jaquith. fixes #1840

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r3000 r3029  
    976976}
    977977
     978function got_mod_rewrite() {
     979    global $is_apache;
     980
     981    // take 3 educated guesses as to whether or not mod_rewrite is available
     982    if ( !$is_apache )
     983        return false;
     984
     985    if ( function_exists('apache_get_modules') ) {
     986        if ( !in_array('mod_rewrite', apache_get_modules()) )
     987            return false;
     988    }
     989
     990    if ( function_exists('ob_get_clean') ) {
     991      ob_start();
     992      phpinfo(INFO_MODULES);
     993      $php_modules = ob_get_clean();
     994      if ( strpos($php_modules, 'mod_rewrite') === false)
     995        return false;
     996    }
     997
     998    return true;
     999}
     1000
    9781001function save_mod_rewrite_rules() {
    9791002    global $is_apache, $wp_rewrite;
     
    9861009        return;
    9871010
    988     if (!$is_apache)
     1011    if (! got_mod_rewrite())
    9891012        return;
    9901013
  • trunk/wp-admin/options-permalink.php

    r2762 r3029  
    104104<?php
    105105$prefix = '';
    106 if ( !$is_apache )
     106
     107if ( ! got_mod_rewrite() )
    107108    $prefix = '/index.php';
     109
     110$structures = array(
     111    '',
     112    $prefix . '/%year%/%monthnum%/%day%/%postname%/',
     113    $prefix . '/archives/%post_id%'
     114    );
    108115?>
    109116<form name="form" action="options-permalink.php" method="post">
     
    111118<p>
    112119    <label>
    113 <input name="selection" type="radio" value="<?php echo $prefix; ?>/%year%/%monthnum%/%day%/%postname%/" class="tog" <?php checked( $prefix . '/%year%/%monthnum%/%day%/%postname%/', $permalink_structure); ?> />
    114 <?php _e('Date and name based, example:'); ?> <code><?php echo get_settings('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code>
     120<input name="selection" type="radio" value="" class="tog" <?php checked('', $permalink_structure); ?> />
     121<?php _e('Default'); ?><br /> <span> &raquo; <code><?php echo get_settings('home'); ?>/?p=123</code></span>
    115122   </label>
    116123</p>
    117124<p>
    118125    <label>
    119 <input name="selection" type="radio" value="<?php echo $prefix; ?>/archives/%post_id%" class="tog" <?php checked( $prefix . '/archives/%post_id%', $permalink_structure); ?> />
    120 <?php _e('Numeric, example:'); ?> <code><?php echo get_settings('home') . $prefix  ; ?>/archives/123</code>
     126<input name="selection" type="radio" value="<?php echo $structures[1]; ?>" class="tog" <?php checked($structures[1], $permalink_structure); ?> />
     127<?php _e('Date and name based'); ?><br /> <span> &raquo; <code><?php echo get_settings('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></span>
     128   </label>
     129</p>
     130<p>
     131    <label>
     132<input name="selection" type="radio" value="<?php echo $structures[2]; ?>" class="tog" <?php checked($structures[2], $permalink_structure); ?> />
     133<?php _e('Numeric'); ?><br /> <span> &raquo; <code><?php echo get_settings('home') . $prefix  ; ?>/archives/123</code></span>
    121134   </label>
    122135</p>
     
    124137<label>
    125138<input name="selection" type="radio" value="custom" class="tog"
    126 <?php if ( $permalink_structure != $prefix . '/archives/%post_id%' && $permalink_structure != $prefix . '/%year%/%monthnum%/%day%/%postname%/' ) { ?>
     139<?php if ( !in_array($permalink_structure, $structures) ) { ?>
    127140checked="checked"
    128141<?php } ?>
Note: See TracChangeset for help on using the changeset viewer.