2 require_once('admin.php');
4 $title = __('Permalink Options');
5 $parent_file = 'options-general.php';
9 <script type="text/javascript">
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];
23 var inputColl = GetElementsWithClassName('input', 'tog');
24 var structure = document.getElementById('permalink_structure');
26 for (i = 0; i < inputColl.length; i++) {
27 if ( inputColl[i].checked && inputColl[i].value != '') {
28 inputs += inputColl[i].value + ' ';
31 inputs = inputs.substr(0,inputs.length - 1);
32 if ( 'custom' != inputs )
33 structure.value = inputs;
37 if (!document.getElementById) return;
39 var structure = document.getElementById('permalink_structure');
40 structure.onfocus = function () { document.getElementById('custom_selection').checked = 'checked'; }
42 var aInputs = document.getElementsByTagName('input');
44 for (var i = 0; i < aInputs.length; i++) {
45 aInputs[i].onclick = aInputs[i].onkeyup = upit;
49 window.onload = blurry;
54 add_filter('admin_head', 'add_js');
56 include('admin-header.php');
58 $home_path = get_home_path();
60 if ( isset($_POST) ) {
61 if ( isset($_POST['permalink_structure']) ) {
62 $permalink_structure = $_POST['permalink_structure'];
63 if (! empty($permalink_structure) )
64 $permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']);
65 $wp_rewrite->set_permalink_structure($permalink_structure);
68 if ( isset($_POST['category_base']) ) {
69 $category_base = $_POST['category_base'];
70 if (! empty($category_base) )
71 $category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']);
72 $wp_rewrite->set_category_base($category_base);
76 $permalink_structure = get_settings('permalink_structure');
77 $category_base = get_settings('category_base');
79 if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
84 if ($wp_rewrite->using_index_permalinks())
89 $wp_rewrite->flush_rules();
92 <?php if (isset($_POST['submit'])) : ?>
93 <div id="message" class="updated fade"><p><?php
95 _e('Permalink structure updated.');
97 _e('You should update your .htaccess now.');
102 <h2><?php _e('Customize Permalink Structure') ?></h2>
103 <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 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>
108 if ( ! got_mod_rewrite() )
109 $prefix = '/index.php';
113 $prefix . '/%year%/%monthnum%/%day%/%postname%/',
114 $prefix . '/archives/%post_id%'
117 <form name="form" action="options-permalink.php" method="post">
118 <h3><?php _e('Common options:'); ?></h3>
121 <input name="selection" type="radio" value="" class="tog" <?php checked('', $permalink_structure); ?> />
122 <?php _e('Default'); ?><br /> <span> » <code><?php echo get_settings('home'); ?>/?p=123</code></span>
127 <input name="selection" type="radio" value="<?php echo $structures[1]; ?>" class="tog" <?php checked($structures[1], $permalink_structure); ?> />
128 <?php _e('Date and name based'); ?><br /> <span> » <code><?php echo get_settings('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></span>
133 <input name="selection" type="radio" value="<?php echo $structures[2]; ?>" class="tog" <?php checked($structures[2], $permalink_structure); ?> />
134 <?php _e('Numeric'); ?><br /> <span> » <code><?php echo get_settings('home') . $prefix ; ?>/archives/123</code></span>
139 <input name="selection" id="custom_selection" type="radio" value="custom" class="tog"
140 <?php if ( !in_array($permalink_structure, $structures) ) { ?>
144 <?php _e('Custom, specify below'); ?>
148 <p id="customstructure"><?php _e('Custom structure'); ?>: <input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo $permalink_structure; ?>" size="50" /></p>
150 <h3><?php _e('Optional'); ?></h3>
151 <?php if ($is_apache) : ?>
152 <p><?php _e('If you like, you may enter a custom prefix for your category URIs 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>
154 <p><?php _e('If you like, you may enter a custom prefix for your category URIs 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>
157 <?php _e('Category base'); ?>: <input name="category_base" type="text" class="code" value="<?php echo $category_base; ?>" size="30" />
160 <input type="submit" name="submit" value="<?php _e('Update Permalink Structure »') ?>" />
163 <?php if ( $permalink_structure && !$usingpi && !$writable ) : ?>
164 <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’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>
165 <form action="options-permalink.php" method="post">
167 <textarea rows="5" style="width: 98%;" name="rules"><?php echo $wp_rewrite->mod_rewrite_rules(); ?>
175 <?php require('./admin-footer.php'); ?>