Force a valid base when saving permalinks

This commit is contained in:
Mike Jolley 2014-02-14 10:43:15 +00:00 committed by Coen Jacobs
parent c0eb6a5afa
commit ee7db46934
1 changed files with 10 additions and 1 deletions

View File

@ -176,7 +176,16 @@ class WC_Admin_Permalink_Settings {
$product_permalink = wc_clean( $_POST['product_permalink'] );
if ( $product_permalink == 'custom' ) {
$product_permalink = wc_clean( $_POST['product_permalink_structure'] );
// Get permalink without slashes
$product_permalink = trim( wc_clean( $_POST['product_permalink_structure'] ), '/' );
// This is an invalid base structure and breaks pages
if ( '%product_cat%' == $product_permalink ) {
$product_permalink = _x( 'product', 'slug', 'woocommerce' ) . '/' . $product_permalink;
}
// Prepending slash
$product_permalink = '/' . $product_permalink;
} elseif ( empty( $product_permalink ) ) {
$product_permalink = false;
}