public static function insert_category($cat)
 {
     # make sure we have the necessary arguments in our array
     if (!isset($cat['cat_name'])) {
         return;
     }
     if (!isset($cat['category_nicename'])) {
         $cat['category_nicename'] = BBD_Init::clean_str_for_url($cat['cat_name']);
     }
     # check if category already exists
     if (get_term_by('slug', $cat['category_nicename'], 'category')) {
         echo 'Category <code>' . $cat['cat_name'] . '</code> already exists.<br />';
         return;
     }
     # insert the term
     if (!is_object(wp_insert_category($cat))) {
         echo '<span class="success">Category <code>' . $cat['cat_name'] . '</code> created.</span><br />';
         return;
     }
     echo '<span class="fail">Problem creating category <code>' . $cat['cat_name'] . '</code>.</span><br />';
 }
    public static function req_file($path)
    {
        if (file_exists($path)) {
            require_once $path;
        }
    }
    # return a permalink-friendly version of a string
    public static function clean_str_for_url($sIn)
    {
        if ($sIn == "") {
            return "";
        }
        $sOut = trim(strtolower($sIn));
        $sOut = preg_replace("/\\s\\s+/", " ", $sOut);
        $sOut = preg_replace("/[^a-zA-Z0-9 -]/", "", $sOut);
        $sOut = preg_replace("/--+/", "-", $sOut);
        $sOut = preg_replace("/ +- +/", "-", $sOut);
        $sOut = preg_replace("/\\s\\s+/", " ", $sOut);
        $sOut = preg_replace("/\\s/", "-", $sOut);
        $sOut = preg_replace("/--+/", "-", $sOut);
        $nWord_length = strlen($sOut);
        if ($sOut[$nWord_length - 1] == "-") {
            $sOut = substr($sOut, 0, $nWord_length - 1);
        }
        return $sOut;
    }
}
# require files for plugin
foreach (BBD_Init::$classes as $class) {
    BBD_Init::req_file(bbdi_dir("/lib/class-{$class}.php"));
}