home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / WordPress 1.5.1.dmg / wordpress / wp-admin / options-permalink.php < prev    next >
Encoding:
PHP Script  |  2005-02-14  |  5.1 KB  |  116 lines

  1. <?php
  2. require_once('admin.php');
  3.  
  4. $title = __('Permalink Options');
  5. $parent_file = 'options-general.php';
  6.  
  7. include('admin-header.php');
  8.  
  9. $home_path = get_home_path();
  10.  
  11. if ( isset($_POST) ) {
  12.     if ( isset($_POST['permalink_structure']) ) {
  13.         $permalink_structure = $_POST['permalink_structure'];
  14.         if (! empty($permalink_structure) )
  15.             $permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']);
  16.         $wp_rewrite->set_permalink_structure($permalink_structure);
  17.     }
  18.     
  19.     if ( isset($_POST['category_base']) ) {
  20.         $category_base = $_POST['category_base'];
  21.         if (! empty($category_base) )
  22.             $category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']);
  23.         $wp_rewrite->set_category_base($category_base);
  24.     }
  25. }
  26.     
  27. $permalink_structure = get_settings('permalink_structure');
  28. $category_base = get_settings('category_base');
  29.  
  30. generate_page_rewrite_rules();
  31.  
  32. if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
  33.     $writable = true;
  34. else
  35.     $writable = false;
  36.  
  37. if ($wp_rewrite->using_index_permalinks())
  38.     $usingpi = true;
  39. else
  40.     $usingpi = false;
  41.  
  42. save_mod_rewrite_rules();
  43. ?>
  44.  
  45. <?php if (isset($_POST['submit'])) : ?>
  46. <div class="updated"><p><?php
  47. if ($writable)
  48.     _e('Permalink structure updated.');
  49. else
  50.     _e('You should update your .htaccess now.'); 
  51. ?></p></div>
  52. <?php endif; ?>
  53.  
  54. <div class="wrap"> 
  55.   <h2><?php _e('Edit Permalink Structure') ?></h2> 
  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/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p>
  57.  
  58. <?php if ($is_apache) : ?>
  59. <dl>
  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>
  69. </dl>
  70.  
  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.  
  87.   <form name="form" action="options-permalink.php" method="post"> 
  88.     <p><?php _e('Use the template tags above to create a virtual site structure:') ?></p>
  89.     <p> 
  90.       <?php _e('Structure'); ?>: <input name="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo $permalink_structure; ?>" size="50" /> 
  91.     </p> 
  92. <?php if ($is_apache) : ?>
  93.     <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/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
  94. <?php else : ?>
  95.     <p><?php _e('If you like, you may enter a custom prefix for your category URIs here. For example, <code>/index.php/taxonomy/categorias</code> would make your category links like <code>http://example.org/index.php/taxonomy/categorias/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
  96. <?php endif; ?>
  97.     <p> 
  98.   <?php _e('Category base'); ?>: <input name="category_base" type="text" class="code"  value="<?php echo $category_base; ?>" size="30" /> 
  99.      </p> 
  100.     <p class="submit"> 
  101.       <input type="submit" name="submit" value="<?php _e('Update Permalink Structure »') ?>" /> 
  102.     </p> 
  103.   </form> 
  104. <?php if ( $permalink_structure && !$usingpi && !$writable ) : ?>
  105.   <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>
  106. <form action="options-permalink.php" method="post">
  107.    <p>
  108. <textarea rows="5" style="width: 98%;" name="rules"><?php echo $wp_rewrite->mod_rewrite_rules(); ?>
  109. </textarea>
  110.     </p>
  111. </form>
  112. <?php endif; ?>
  113.  
  114. </div>
  115.  
  116. <?php require('./admin-footer.php'); ?>