Skip to content

Commit

Permalink
Added category and tag base.
Browse files Browse the repository at this point in the history
Added removal of /blog slug from category and tag base. Updated plugin
description accordingly. Updated version number to 1.0.2.
  • Loading branch information
glueckpress committed Mar 30, 2014
1 parent 262f9cc commit d8f88f9
Showing 1 changed file with 48 additions and 4 deletions.
52 changes: 48 additions & 4 deletions remove-blog-slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/*
Plugin Name: Remove /blog slug
Plugin URI: http://webdevstudios.com
Description: Removes /blog from permalinks once they've been generated
Description: Removes /blog from permalinks and default taxonomy bases once they've been generated.
Author: WebDevStudios
Version: 1.0.1
Version: 1.0.2
Author URI: http://webdevstudios.com
License: GPLv2
*/
Expand Down Expand Up @@ -82,8 +82,12 @@ protected function remove_blog_slug() {

$rules = $this->update_rewrite_rules();

// If both options were updated, success!
if ( $structure && $rules ) {
$cat_base = $this->update_category_base();

$tag_base = $this->update_tag_base();

// If any options were updated, success!
if ( ( $structure && $rules ) || $cat_base || $tag_base ) {

add_settings_error( 'remove_blog_slug', esc_attr( 'settings_updated' ), 'Updated rules successfully!', 'updated' );

Expand Down Expand Up @@ -150,6 +154,46 @@ protected function update_rewrite_rules() {
}


/**
* Update 'category_base' option
*
* @since 1.0.2
*
* @return bool True if option was updated, false on failure
*/
protected function update_category_base() {

$cat_base = get_option( 'category_base' );

$cat_base = str_replace( 'blog/', '', $cat_base );

$cat_base = update_option( 'category_base', $cat_base );

return $cat_base;

}


/**
* Update 'tag_base' option
*
* @since 1.0.2
*
* @return bool True if option was updated, false on failure
*/
protected function update_tag_base() {

$tag_base = get_option( 'tag_base' );

$tag_base = str_replace( 'blog/', '', $tag_base );

$tag_base = update_option( 'tag_base', $tag_base );

return $tag_base;

}


}

new Remove_Blog_Slug;

0 comments on commit d8f88f9

Please sign in to comment.