[ Index ]
 

Code source de WordPress 2.1.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/wp-admin/ -> options-permalink.php (source)

   1  <?php
   2  require_once ('admin.php');
   3  
   4  $title = __('Permalink Options');
   5  $parent_file = 'options-general.php';
   6  
   7  function add_js() {
   8  ?>
   9  <script type="text/javascript">
  10  //<![CDATA[
  11  function GetElementsWithClassName(elementName, className) {
  12  var allElements = document.getElementsByTagName(elementName);
  13  var elemColl = new Array();
  14  for (i = 0; i < allElements.length; i++) {
  15  if (allElements[i].className == className) {
  16  elemColl[elemColl.length] = allElements[i];
  17  }
  18  }
  19  return elemColl;
  20  }
  21  
  22  function upit() {
  23  var inputColl = GetElementsWithClassName('input', 'tog');
  24  var structure = document.getElementById('permalink_structure');
  25  var inputs = '';
  26  for (i = 0; i < inputColl.length; i++) {
  27  if ( inputColl[i].checked && inputColl[i].value != '') {
  28  inputs += inputColl[i].value + ' ';
  29  }
  30  }
  31  inputs = inputs.substr(0,inputs.length - 1);
  32  if ( 'custom' != inputs )
  33  structure.value = inputs;
  34  }
  35  
  36  function blurry() {
  37  if (!document.getElementById) return;
  38  
  39  var structure = document.getElementById('permalink_structure');
  40  structure.onfocus = function () { document.getElementById('custom_selection').checked = 'checked'; }
  41  
  42  var aInputs = document.getElementsByTagName('input');
  43  
  44  for (var i = 0; i < aInputs.length; i++) {
  45  aInputs[i].onclick = aInputs[i].onkeyup = upit;
  46  }
  47  }
  48  
  49  window.onload = blurry;
  50  //]]>
  51  </script>
  52  <?php
  53  }
  54  add_filter('admin_head', 'add_js');
  55  
  56  include ('admin-header.php');
  57  
  58  $home_path = get_home_path();
  59  
  60  if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
  61      check_admin_referer('update-permalink');
  62  
  63      if ( isset($_POST['permalink_structure']) ) {
  64          $permalink_structure = $_POST['permalink_structure'];
  65          if (! empty($permalink_structure) )
  66              $permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']);
  67          $wp_rewrite->set_permalink_structure($permalink_structure);
  68      }
  69  
  70      if ( isset($_POST['category_base']) ) {
  71          $category_base = $_POST['category_base'];
  72          if (! empty($category_base) )
  73              $category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']);
  74          $wp_rewrite->set_category_base($category_base);
  75      }
  76  }
  77  
  78  $permalink_structure = get_option('permalink_structure');
  79  $category_base = get_option('category_base');
  80  
  81  if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
  82      $writable = true;
  83  else
  84      $writable = false;
  85  
  86  if ($wp_rewrite->using_index_permalinks())
  87      $usingpi = true;
  88  else
  89      $usingpi = false;
  90  
  91  $wp_rewrite->flush_rules();
  92  ?>
  93  
  94  <?php if (isset($_POST['submit'])) : ?>
  95  <div id="message" class="updated fade"><p><?php
  96  if ($writable)
  97      _e('Permalink structure updated.');
  98  else
  99      _e('You should update your .htaccess now.'); 
 100  ?></p></div>
 101  <?php endif; ?>
 102  
 103  <div class="wrap"> 
 104    <h2><?php _e('Customize Permalink Structure') ?></h2> 
 105  <form name="form" action="options-permalink.php" method="post"> 
 106  <?php wp_nonce_field('update-permalink') ?>
 107  <p class="submit"><input type="submit" name="submit" value="<?php _e('Update Permalink Structure &raquo;') ?>" /></p>
 108    <p><?php _e('By default WordPress uses web <abbr title="Universal Resource Locator">URL</abbr>s which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility 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>
 109  
 110  <?php
 111  $prefix = '';
 112  
 113  if ( ! got_mod_rewrite() )
 114      $prefix = '/index.php';
 115  
 116  $structures = array(
 117      '',
 118      $prefix . '/%year%/%monthnum%/%day%/%postname%/',
 119      $prefix . '/archives/%post_id%'
 120      );
 121  ?>
 122  <h3><?php _e('Common options:'); ?></h3>
 123  <p>
 124      <label>
 125  <input name="selection" type="radio" value="" class="tog" <?php checked('', $permalink_structure); ?> /> 
 126  <?php _e('Default'); ?><br /> <span> &raquo; <code><?php echo get_option('home'); ?>/?p=123</code></span>
 127     </label>
 128  </p>
 129  <p>
 130      <label>
 131  <input name="selection" type="radio" value="<?php echo $structures[1]; ?>" class="tog" <?php checked($structures[1], $permalink_structure); ?> /> 
 132  <?php _e('Date and name based'); ?><br /> <span> &raquo; <code><?php echo get_option('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></span>
 133     </label>
 134  </p>
 135  <p>
 136      <label>
 137  <input name="selection" type="radio" value="<?php echo $structures[2]; ?>" class="tog" <?php checked($structures[2], $permalink_structure); ?> /> 
 138  <?php _e('Numeric'); ?><br /> <span> &raquo; <code><?php echo get_option('home') . $prefix  ; ?>/archives/123</code></span>
 139     </label>
 140  </p>
 141  <p>
 142  <label>
 143  <input name="selection" id="custom_selection" type="radio" value="custom" class="tog"
 144  <?php if ( !in_array($permalink_structure, $structures) ) { ?>
 145  checked="checked"
 146  <?php } ?>
 147   />
 148  <?php _e('Custom, specify below'); ?>
 149  </label>
 150  <br />
 151  </p>
 152  <p id="customstructure"><?php _e('Custom structure'); ?>: <input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo attribute_escape($permalink_structure); ?>" size="50" /></p>
 153  
 154  <h3><?php _e('Optional'); ?></h3>
 155  <?php if ($is_apache) : ?>
 156      <p><?php _e('If you like, you may enter a custom prefix for your category <abbr title="Universal Resource Locator">URL</abbr>s here. For example, <code>/taxonomy/tags</code> would make your category links like <code>http://example.org/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
 157  <?php else : ?>
 158      <p><?php _e('If you like, you may enter a custom prefix for your category <abbr title="Universal Resource Locator">URL</abbr>s here. For example, <code>/index.php/taxonomy/tags</code> would make your category links like <code>http://example.org/index.php/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
 159  <?php endif; ?>
 160      <p> 
 161    <?php _e('Category base'); ?>: <input name="category_base" type="text" class="code"  value="<?php echo attribute_escape($category_base); ?>" size="30" /> 
 162       </p> 
 163      <p class="submit"> 
 164        <input type="submit" name="submit" value="<?php _e('Update Permalink Structure &raquo;') ?>" /> 
 165      </p> 
 166    </form> 
 167  <?php if ( $permalink_structure && !$usingpi && !$writable ) : ?>
 168    <p><?php _e('If your <code>.htaccess</code> file were <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>
 169  <form action="options-permalink.php" method="post">
 170  <?php wp_nonce_field('update-permalink') ?>
 171     <p>
 172  <textarea rows="5" style="width: 98%;" name="rules"><?php echo wp_specialchars($wp_rewrite->mod_rewrite_rules()); ?>
 173  </textarea>
 174      </p>
 175  </form>
 176  <?php endif; ?>
 177  
 178  </div>
 179  
 180  <?php require ('./admin-footer.php'); ?>


Généré le : Fri Mar 30 19:41:27 2007 par Balluche grâce à PHPXref 0.7