mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Permalink settings administration panel.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 $title = __('Permalink Settings');
mp-wp_genesis 13 $parent_file = 'options-general.php';
mp-wp_genesis 14
mp-wp_genesis 15 include('admin-header.php');
mp-wp_genesis 16
mp-wp_genesis 17 $home_path = get_home_path();
mp-wp_genesis 18
mp-wp_genesis 19 if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
mp-wp_genesis 20 check_admin_referer('update-permalink');
mp-wp_genesis 21
mp-wp_genesis 22 if ( isset($_POST['permalink_structure']) ) {
mp-wp_genesis 23 $permalink_structure = $_POST['permalink_structure'];
mp-wp_genesis 24 if (! empty($permalink_structure) )
mp-wp_genesis 25 $permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']);
mp-wp_genesis 26 $wp_rewrite->set_permalink_structure($permalink_structure);
mp-wp_genesis 27 }
mp-wp_genesis 28
mp-wp_genesis 29 if ( isset($_POST['category_base']) ) {
mp-wp_genesis 30 $category_base = $_POST['category_base'];
mp-wp_genesis 31 if (! empty($category_base) )
mp-wp_genesis 32 $category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']);
mp-wp_genesis 33 $wp_rewrite->set_category_base($category_base);
mp-wp_genesis 34 }
mp-wp_genesis 35
mp-wp_genesis 36 if ( isset($_POST['tag_base']) ) {
mp-wp_genesis 37 $tag_base = $_POST['tag_base'];
mp-wp_genesis 38 if (! empty($tag_base) )
mp-wp_genesis 39 $tag_base = preg_replace('#/+#', '/', '/' . $_POST['tag_base']);
mp-wp_genesis 40 $wp_rewrite->set_tag_base($tag_base);
mp-wp_genesis 41 }
mp-wp_genesis 42 }
mp-wp_genesis 43
mp-wp_genesis 44 $permalink_structure = get_option('permalink_structure');
mp-wp_genesis 45 $category_base = get_option('category_base');
mp-wp_genesis 46 $tag_base = get_option( 'tag_base' );
mp-wp_genesis 47
mp-wp_genesis 48 if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
mp-wp_genesis 49 $writable = true;
mp-wp_genesis 50 else
mp-wp_genesis 51 $writable = false;
mp-wp_genesis 52
mp-wp_genesis 53 if ($wp_rewrite->using_index_permalinks())
mp-wp_genesis 54 $usingpi = true;
mp-wp_genesis 55 else
mp-wp_genesis 56 $usingpi = false;
mp-wp_genesis 57
mp-wp_genesis 58 $wp_rewrite->flush_rules();
mp-wp_genesis 59 ?>
mp-wp_genesis 60
mp-wp_genesis 61 <?php if (isset($_POST['submit'])) : ?>
mp-wp_genesis 62 <div id="message" class="updated fade"><p><?php
mp-wp_genesis 63 if ( $permalink_structure && !$usingpi && !$writable )
mp-wp_genesis 64 _e('You should update your .htaccess now.');
mp-wp_genesis 65 else
mp-wp_genesis 66 _e('Permalink structure updated.');
mp-wp_genesis 67 ?></p></div>
mp-wp_genesis 68 <?php endif; ?>
mp-wp_genesis 69
mp-wp_genesis 70 <div class="wrap">
mp-wp_genesis 71 <?php screen_icon(); ?>
mp-wp_genesis 72 <h2><?php echo wp_specialchars( $title ); ?></h2>
mp-wp_genesis 73
mp-wp_genesis 74 <form name="form" action="options-permalink.php" method="post">
mp-wp_genesis 75 <?php wp_nonce_field('update-permalink') ?>
mp-wp_genesis 76
mp-wp_genesis 77 <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>
mp-wp_genesis 78
mp-wp_genesis 79 <?php
mp-wp_genesis 80 $prefix = '';
mp-wp_genesis 81
mp-wp_genesis 82 if ( ! got_mod_rewrite() )
mp-wp_genesis 83 $prefix = '/index.php';
mp-wp_genesis 84
mp-wp_genesis 85 $structures = array(
mp-wp_genesis 86 '',
mp-wp_genesis 87 $prefix . '/%year%/%monthnum%/%day%/%postname%/',
mp-wp_genesis 88 $prefix . '/%year%/%monthnum%/%postname%/',
mp-wp_genesis 89 $prefix . '/archives/%post_id%'
mp-wp_genesis 90 );
mp-wp_genesis 91 ?>
mp-wp_genesis 92 <h3><?php _e('Common settings'); ?></h3>
mp-wp_genesis 93 <table class="form-table">
mp-wp_genesis 94 <tr>
mp-wp_genesis 95 <th><label><input name="selection" type="radio" value="" class="tog" <?php checked('', $permalink_structure); ?> /> <?php _e('Default'); ?></label></th>
mp-wp_genesis 96 <td><code><?php echo get_option('home'); ?>/?p=123</code></td>
mp-wp_genesis 97 </tr>
mp-wp_genesis 98 <tr>
mp-wp_genesis 99 <th><label><input name="selection" type="radio" value="<?php echo $structures[1]; ?>" class="tog" <?php checked($structures[1], $permalink_structure); ?> /> <?php _e('Day and name'); ?></label></th>
mp-wp_genesis 100 <td><code><?php echo get_option('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></td>
mp-wp_genesis 101 </tr>
mp-wp_genesis 102 <tr>
mp-wp_genesis 103 <th><label><input name="selection" type="radio" value="<?php echo $structures[2]; ?>" class="tog" <?php checked($structures[2], $permalink_structure); ?> /> <?php _e('Month and name'); ?></label></th>
mp-wp_genesis 104 <td><code><?php echo get_option('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/sample-post/'; ?></code></td>
mp-wp_genesis 105 </tr>
mp-wp_genesis 106 <tr>
mp-wp_genesis 107 <th><label><input name="selection" type="radio" value="<?php echo $structures[3]; ?>" class="tog" <?php checked($structures[3], $permalink_structure); ?> /> <?php _e('Numeric'); ?></label></th>
mp-wp_genesis 108 <td><code><?php echo get_option('home') . $prefix ; ?>/archives/123</code></td>
mp-wp_genesis 109 </tr>
mp-wp_genesis 110 <tr>
mp-wp_genesis 111 <th>
mp-wp_genesis 112 <label><input name="selection" id="custom_selection" type="radio" value="custom" class="tog"
mp-wp_genesis 113 <?php if ( !in_array($permalink_structure, $structures) ) { ?>
mp-wp_genesis 114 checked="checked"
mp-wp_genesis 115 <?php } ?>
mp-wp_genesis 116 />
mp-wp_genesis 117 <?php _e('Custom Structure'); ?>
mp-wp_genesis 118 </label>
mp-wp_genesis 119 </th>
mp-wp_genesis 120 <td>
mp-wp_genesis 121 <input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo attribute_escape($permalink_structure); ?>" class="regular-text code" />
mp-wp_genesis 122 </td>
mp-wp_genesis 123 </tr>
mp-wp_genesis 124 </table>
mp-wp_genesis 125
mp-wp_genesis 126 <h3><?php _e('Optional'); ?></h3>
mp-wp_genesis 127 <?php if ($is_apache) : ?>
mp-wp_genesis 128 <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <kbd>topics</kbd> as your category base would make your category links like <code>http://example.org/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p>
mp-wp_genesis 129 <?php else : ?>
mp-wp_genesis 130 <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>topics</code> as your category base would make your category links like <code>http://example.org/index.php/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p>
mp-wp_genesis 131 <?php endif; ?>
mp-wp_genesis 132
mp-wp_genesis 133 <table class="form-table">
mp-wp_genesis 134 <tr>
mp-wp_genesis 135 <th><label for="category_base"><?php _e('Category base'); ?></label></th>
mp-wp_genesis 136 <td><input name="category_base" id="category_base" type="text" value="<?php echo attribute_escape($category_base); ?>" class="regular-text code" /></td>
mp-wp_genesis 137 </tr>
mp-wp_genesis 138 <tr>
mp-wp_genesis 139 <th><label for="tag_base"><?php _e('Tag base'); ?></label></th>
mp-wp_genesis 140 <td><input name="tag_base" id="tag_base" type="text" value="<?php echo attribute_escape($tag_base); ?>" class="regular-text code" /></td>
mp-wp_genesis 141 </tr>
mp-wp_genesis 142 <?php do_settings_fields('permalink', 'optional'); ?>
mp-wp_genesis 143 </table>
mp-wp_genesis 144
mp-wp_genesis 145 <?php do_settings_sections('permalink'); ?>
mp-wp_genesis 146
mp-wp_genesis 147 <p class="submit">
mp-wp_genesis 148 <input type="submit" name="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
mp-wp_genesis 149 </p>
mp-wp_genesis 150 </form>
mp-wp_genesis 151 <?php if ( $permalink_structure && !$usingpi && !$writable ) : ?>
mp-wp_genesis 152 <p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">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>
mp-wp_genesis 153 <form action="options-permalink.php" method="post">
mp-wp_genesis 154 <?php wp_nonce_field('update-permalink') ?>
mp-wp_genesis 155 <p><textarea rows="6" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo wp_specialchars($wp_rewrite->mod_rewrite_rules()); ?></textarea></p>
mp-wp_genesis 156 </form>
mp-wp_genesis 157 <?php endif; ?>
mp-wp_genesis 158
mp-wp_genesis 159 </div>
mp-wp_genesis 160
mp-wp_genesis 161 <?php require('./admin-footer.php'); ?>