Last active
August 29, 2015 14:20
-
-
Save grok/48227330fe73e9f78f78 to your computer and use it in GitHub Desktop.
I don't really like categories. I prefer tags. Let's hide what's not going to be used.
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 | |
namespace ChangeMe\Theme\Modules; | |
class Core { | |
public function __construct() { | |
add_action('admin_init', array($this, 'disable_category_feature')); | |
add_filter('rewrite_rules_array', array($this, 'remove_category_rewrites')); | |
} | |
public function disable_category_feature() { | |
unregister_widget('WP_Widget_Categories'); // Remove widget. | |
register_taxonomy('category', array()); // Unhook all the category "functionality" but leave the data. | |
remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=category'); // Hide Administration menu. | |
} | |
// Permalinks for categories can go. | |
public function remove_category_rewrites($rules) { | |
foreach($rules as $rule => $rewrite) { | |
if(preg_match('/^category/', $rule)) { | |
unset($rules[$rule]); | |
} | |
} | |
return $rules; | |
} | |
} | |
$theme = new \ChangeMe\Theme\Modules\Core(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment