Created
August 2, 2013 00:28
-
-
Save Viper007Bond/6136585 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( !function_exists( 'wpcom_vip_load_category_base' ) ): | |
/** | |
* Enables a custom or no category base, if the site wants to use one that's not the WP.com default (/category/) | |
* | |
* Usage: | |
* wpcom_vip_load_category_base( '' ); | |
* wpcom_vip_load_category_base( 'section' ); | |
* | |
* @link http://vip.wordpress.com/documentation/change-your-pretty-permalinks-or-add-custom-rewrite-rules/ Change Your Pretty Permalinks | |
* @param string $new_category_base New category base prefix | |
*/ | |
function wpcom_vip_load_category_base( $new_category_base ) { | |
define( 'WPCOM_VIP_CUSTOM_CATEGORY_BASE', true ); | |
global $wpcom_vip_category_base; | |
$wpcom_vip_category_base = $new_category_base; | |
add_filter( 'pre_option_category_base', '_wpcom_vip_filter_category_base', 99 ); // needs to be higher priority so we don't conflict with the WP.com filter | |
} | |
endif; | |
if ( !function_exists( '_wpcom_vip_filter_category_base' ) ): | |
/** | |
* Applies the new category base to the option value | |
* | |
* @link http://vip.wordpress.com/documentation/change-your-pretty-permalinks-or-add-custom-rewrite-rules/ Change Your Pretty Permalinks | |
* @param string $category_base New category base prefix | |
* @return string The category base prefix | |
*/ | |
function _wpcom_vip_filter_category_base( $category_base ) { | |
global $wpcom_vip_category_base; | |
return $wpcom_vip_category_base; | |
} | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment