Skip to content

Instantly share code, notes, and snippets.

@jeremyfelt
Created November 22, 2013 17:19
Show Gist options
  • Select an option

  • Save jeremyfelt/7603573 to your computer and use it in GitHub Desktop.

Select an option

Save jeremyfelt/7603573 to your computer and use it in GitHub Desktop.
<?php
$prefix = $blog_prefix = '';
if ( ! got_url_rewrite() )
$prefix = '/index.php';
if ( is_multisite() && !is_subdomain_install() && is_main_site() )
$blog_prefix = '/blog';
if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
check_admin_referer('update-permalink');
if ( isset( $_POST['permalink_structure'] ) ) {
if ( isset( $_POST['selection'] ) && 'custom' != $_POST['selection'] )
$permalink_structure = $_POST['selection'];
else
$permalink_structure = $_POST['permalink_structure'];
if ( ! empty( $permalink_structure ) ) {
$permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );
if ( $prefix && $blog_prefix )
$permalink_structure = $prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure );
else
$permalink_structure = $blog_prefix . $permalink_structure;
}
$wp_rewrite->set_permalink_structure( $permalink_structure );
}
//...........
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment