Help create a simple admin plugin
-
I am trying to create a simple plugin to tweak the Write Post page in the admin area. My purpose is to choose only one category instead of several by changing the checkbox into a radio button. I can edit the core file in 30s, but I prefer a more elegant way by writing my first plugin.
However, I think I’m missing the right action of filter. I tried different combinations without success. Can someone help me?
function one_category_only() {
// only when we are at post.php
if(preg_match('|post.php|i', $_SERVER['REQUEST_URI'])) {
$content = str_replace('type="checkbox" name="post_category', 'type="radio" name="post_category', $content);
return $content;
}}
add_action('admin_footer' , 'one_category_only');I tried several add_action and add_filter with different options without success. Or, is it much more complicated?
- The topic ‘Help create a simple admin plugin’ is closed to new replies.