Changeset 1664 for trunk/wp-admin/options-permalink.php
- Timestamp:
- 09/15/2004 03:09:39 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/options-permalink.php
r1599 r1664 5 5 $parent_file = 'options-general.php'; 6 6 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 } 7 require_once('./admin-header.php'); 8 if ($user_level <= 8) 9 die(__('You have do not have sufficient permissions to edit the options for this blog.')); 10 11 require('./options-head.php'); 22 12 23 13 $home = get_settings('home'); 24 if ( $home != '' && $home != get_settings('siteurl')) {25 26 27 28 14 if ( $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 . "/"; 29 19 } else { 30 20 $home_path = ABSPATH; 31 21 } 32 22 … … 42 32 } 43 33 34 if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') ) 35 $writable = true; 36 else 37 $writable = false; 44 38 39 if ( strstr($permalink_structure, 'index.php') ) // If they're using 40 $usingpi = true; 41 else 42 $usingpi = false; 45 43 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'); 44 if ( $writable && !$usingpi && $is_apache ) { 45 $rules = explode("\n", mod_rewrite_rules($permalink_structure)); 46 insert_with_markers($home_path.'.htaccess', 'WordPress', $rules); 47 } 51 48 ?> 49 52 50 <?php if (isset($_POST['submit'])) : ?> 53 51 <div class="updated"><p><?php _e('Permalink structure updated.'); ?></p></div> 54 52 <?php endif; ?> 55 53 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 <?php62 } else {63 ?>64 <div class="updated" id="htupdate"><p><?php _e('Failed to write mod_rewrite rules to .htaccess.'); ?></p></div>65 <?php66 }67 }68 ?>69 70 54 <div class="wrap"> 71 55 <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 “tags” 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> 73 57 58 <?php if ($is_apache) : ?> 74 59 <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 “This Is A Great Post!” becomes “<code>this-is-a-great-post</code>” 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> 115 69 </dl> 116 70 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’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 124 87 <form name="form" action="options-permalink.php" method="post"> 125 88 <p><?php _e('Use the template tags above to create a virtual site structure:') ?></p> 126 89 <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" /> 128 91 </p> 129 92 <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> 130 93 <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" /> 132 95 </p> 133 96 <p class="submit"> … … 135 98 </p> 136 99 </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’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> 141 102 <form action="options-permalink.php" method="post"> 142 103 <p> … … 144 105 </textarea> 145 106 </p> 146 <?php 107 <?php endif; ?> 108 </form> 147 109 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 »') ?>">152 </p>153 <?php } ?>154 </form>155 156 <?php157 } 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 } ?>163 110 </div> 164 111 165 <?php 166 require('./admin-footer.php'); 167 ?> 112 <?php require('./admin-footer.php'); ?>
Note: See TracChangeset
for help on using the changeset viewer.