Make WordPress Core


Ignore:
Timestamp:
09/15/2004 03:09:39 PM (20 years ago)
Author:
saxmatt
Message:

Axing of geo stuff, major cleanups on permalink options, style tweaks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/options-permalink.php

    r1599 r1664  
    55$parent_file = 'options-general.php';
    66
    7 $wpvarstoreset = array('action','standalone', 'option_group_id');
    8 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    9     $wpvar = $wpvarstoreset[$i];
    10     if (!isset($$wpvar)) {
    11         if (empty($_POST["$wpvar"])) {
    12             if (empty($_GET["$wpvar"])) {
    13                 $$wpvar = '';
    14             } else {
    15                 $$wpvar = $_GET["$wpvar"];
    16             }
    17         } else {
    18             $$wpvar = $_POST["$wpvar"];
    19         }
    20     }
    21 }
     7require_once('./admin-header.php');
     8if ($user_level <= 8)
     9    die(__('You have do not have sufficient permissions to edit the options for this blog.'));
     10
     11require('./options-head.php');
    2212
    2313$home = get_settings('home');
    24 if ($home != '' && $home != get_settings('siteurl')) {
    25   $home_path = parse_url($home);
    26   $home_path = $home_root['path'];
    27   $root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
    28   $home_path = $root . $home_path . "/";
     14if ( $home != '' && $home != get_settings('siteurl') ) {
     15    $home_path = parse_url($home);
     16    $home_path = $home_root['path'];
     17    $root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
     18    $home_path = $root . $home_path . "/";
    2919} else {
    30   $home_path = ABSPATH;
     20    $home_path = ABSPATH;
    3121}
    3222
     
    4232}
    4333
     34if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
     35    $writable = true;
     36else
     37    $writable = false;
    4438
     39if ( strstr($permalink_structure, 'index.php') ) // If they're using
     40    $usingpi = true;
     41else
     42    $usingpi = false;
    4543
    46     require_once('admin-header.php');
    47     if ($user_level <= 6) {
    48         die(__("You have do not have sufficient permissions to edit the options for this blog."));
    49     }
    50     require('./options-head.php');
     44if ( $writable && !$usingpi && $is_apache ) {
     45    $rules = explode("\n", mod_rewrite_rules($permalink_structure));
     46    insert_with_markers($home_path.'.htaccess', 'WordPress', $rules);
     47}
    5148?>
     49
    5250<?php if (isset($_POST['submit'])) : ?>
    5351<div class="updated"><p><?php _e('Permalink structure updated.'); ?></p></div>
    5452<?php endif; ?>
    5553
    56 <?php if(isset($_POST['rules'])) {
    57         $rules = explode("\n", $_POST['rules']);
    58         if(insert_with_markers($home_path.'.htaccess', 'WordPress', $rules)) {
    59 ?>
    60 <div class="updated" id="htupdate"><p><?php _e('mod_rewrite rules written to .htaccess.'); ?></p></div>
    61 <?php
    62         } else {
    63 ?>
    64 <div class="updated" id="htupdate"><p><?php _e('Failed to write mod_rewrite rules to .htaccess.'); ?></p></div>
    65 <?php
    66         }
    67     }
    68 ?>
    69 
    7054<div class="wrap">
    7155  <h2><?php _e('Edit Permalink Structure') ?></h2>
    72   <?php _e('<p>WordPress offers you the ability to create a custom URI structure for your permalinks and archives. The following &#8220;tags&#8221; are available:</p>')?>
     56  <p><?php _e('By default WordPress uses web URIs which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URI structure for your permalinks and archives. This can improve the aesthetics, usability, and longevity of your links. A <a href="http://codex.wordpress.org/Permalink_Structure">number of tags are available</a>, and here are some examples to get you started.'); ?></p>
    7357
     58<?php if ($is_apache) : ?>
    7459<dl>
    75     <dt><code>%year%</code></dt>
    76     <dd>
    77         <?php _e('The year of the post, 4 digits, for example <code>2004</code>') ?>
    78     </dd>
    79     <dt><code>%monthnum%</code></dt>
    80     <dd>
    81         <?php _e('Month of the year, for example <code>05</code>') ?>
    82     </dd>
    83     <dt><code>%day%</code></dt>
    84     <dd>
    85         <?php _e('Day of the month, for example <code>28</code>') ?>
    86     </dd>
    87     <dt><code>%hour%</code></dt>
    88     <dd>
    89         <?php _e('Hour of the day, for example <code>15</code>') ?>
    90     </dd>
    91     <dt><code>%minute%</code></dt>
    92     <dd>
    93         <?php _e('Minute of the hour, for example <code>43</code>') ?>
    94     </dd>
    95     <dt><code>%second%</code></dt>
    96     <dd>
    97         <?php _e('Second of the minute, for example <code>33</code>') ?>
    98     </dd>
    99     <dt><code>%postname%</code></dt>
    100     <dd>
    101         <?php _e('A sanitized version of the title of the post. So &#8220;This Is A Great Post!&#8221; becomes &#8220;<code>this-is-a-great-post</code>&#8221; in the URI') ?>
    102     </dd>
    103     <dt><code>%post_id%</code></dt>
    104     <dd>
    105         <?php _e('The unique ID # of the post, for example <code>423</code>') ?>
    106     </dd>
    107     <dt><code>%category%</code></dt>
    108     <dd>
    109         <?php _e('A sanitized version of the category name.') ?>
    110     </dd>
    111     <dt><code>%author%</code></dt>
    112     <dd>
    113         <?php _e('A sanitized version of the author name.') ?>
    114     </dd>
     60<dt><?php _e('Structure'); ?>: <code>/%year%/%monthnum%/%day%/%postname%/</code></dt>
     61    <strong>
     62    <dd><?php _e('Result'); ?>: <code><?php echo get_settings('home') . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></dd>
     63    </strong>
     64    <dt><?php _e('Structure'); ?>: <code>/archives/%post_id%</code></dt>
     65    <strong>
     66    <dd><?php _e('Result'); ?>: <code><?php echo get_settings('home'); ?>/archives/123</code></dd>
     67    </strong>
     68    <dt></dt>
    11569</dl>
    11670
    117   <?php _e('<p>So for example a value like:</p>
    118   <p><code>/archives/%year%/%monthnum%/%day%/%postname%/</code> </p>
    119   <p>would give you a permalink like:</p>
    120   <p><code>/archives/2003/05/23/my-cheese-sandwich/</code></p>
    121   <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>
    122   <p><code>/index.php/archives/%year%/%monthnum%/%day%/%postname%/</code> </p>
    123   <p>If you use this option you can ignore the mod_rewrite rules.</p>') ?>
     71<p><?php _e('For the above to work you must have something called <code>mod_rewrite</code> installed on your server. (Ask your host.) If that isn&#8217;t available, you can prefix the structure with <code>/index.php/</code> . This is the recommend method if you are on any web server but Apache.'); ?></p>
     72
     73<?php else : ?>
     74<dl>
     75<dt><?php _e('Structure'); ?>: <code>/index.php/%year%/%monthnum%/%day%/%postname%/</code></dt>
     76    <strong>
     77    <dd><?php _e('Result'); ?>: <code><?php echo get_settings('home') . '/index.php/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></dd>
     78    </strong>
     79    <dt><?php _e('Structure'); ?>: <code>/index.php/archives/%post_id%</code></dt>
     80    <strong>
     81    <dd><?php _e('Result'); ?>: <code><?php echo get_settings('home'); ?>/index.php/archives/123</code></dd>
     82    </strong>
     83    <dt></dt>
     84</dl>
     85<?php endif; ?>
     86
    12487  <form name="form" action="options-permalink.php" method="post">
    12588    <p><?php _e('Use the template tags above to create a virtual site structure:') ?></p>
    12689    <p>
    127       <input name="permalink_structure" type="text" style="width: 98%;" value="<?php echo $permalink_structure; ?>" />
     90      <?php _e('Structure'); ?>: <input name="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo $permalink_structure; ?>" size="50" />
    12891    </p>
    12992    <p><?php _e('If you like, you may enter a custom prefix for your category URIs here. For example, <code>/taxonomy/categorias</code> would make your category links like <code>http://example.org/taxonomy/categorias/general/</code>. If you leave this blank the default will be used.') ?></p>
    13093    <p>
    131   <input name="category_base" type="text" style="width: 98%;" value="<?php echo $category_base; ?>" />
     94  <?php _e('Category base'); ?>: <input name="category_base" type="text" class="code"  value="<?php echo $category_base; ?>" size="30" />
    13295     </p>
    13396    <p class="submit">
     
    13598    </p>
    13699  </form>
    137 <?php
    138  if ($permalink_structure) {
    139 ?>
    140   <p><?php printf(__('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. Click in the field and press <kbd>CTRL + a</kbd> to select all.'), $permalink_structure) ?></p>
     100<?php if ( $permalink_structure && !$usingpi && !$writable ) : ?>
     101  <p><?php _e('If your <code>.htaccess</code> was <a href="http://codex.wordpress.org/Make_a_Directory_Writable">writable</a> we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
    141102<form action="options-permalink.php" method="post">
    142103   <p>
     
    144105</textarea>
    145106    </p>
    146 <?php
     107<?php endif; ?>
     108</form>
    147109
    148 if ((! file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess')) {
    149 ?>
    150     <p class="submit">
    151         <input type="submit" name="writerules" value="<?php _e('Write mod_rewrite rules to .htaccess &raquo;') ?>">
    152     </p>
    153 <?php } ?>
    154 </form>
    155  
    156 <?php
    157 } else {
    158 ?>
    159 <p>
    160 <?php _e('You are not currently using customized permalinks. No special mod_rewrite rules are needed.') ?>
    161 </p>
    162 <?php } ?>
    163110</div>
    164111
    165 <?php
    166 require('./admin-footer.php');
    167 ?>
     112<?php require('./admin-footer.php'); ?>
Note: See TracChangeset for help on using the changeset viewer.