function init() { global $wp_version; // Load the localisation text load_theme_textdomain('k2_domain'); $exclude = array('sbm-direct.php', 'widgets-removal.php'); // Exclude SBM if there's already a sidebar manager if (K2_USING_SBM) { $exclude[] = 'widgets.php'; } else { $exclude[] = 'sbm.php'; } // Scan for includes and classes K2::include_all(TEMPLATEPATH . '/app/includes/', $exclude); K2::include_all(TEMPLATEPATH . '/app/classes/'); // Get the last modified time of the classes folder $last_modified = filemtime(dirname(__FILE__)); $last_modified_check = get_option('k2lastmodified'); // As only classes can add/remove options it's now time to install if there has been any changes if ($last_modified_check === false || $last_modified_check < $last_modified) { K2::install($last_modified); } // Check if the theme is being activated/deactivated if (!get_option('k2active')) { update_option('k2active', true); do_action('k2_activate'); // Ewww... header('Location: themes.php?activated=true'); exit; } add_action('switch_theme', array('K2', 'theme_switch')); // There may be some things we need to do before K2 is initialised // Let's do them now do_action('k2_init'); // Register our sidebar with SBM/Widgets if (function_exists('register_sidebars')) { register_sidebars(2, array('before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h4>', 'after_title' => '</h4>')); } // Check if there's a style, and if so if it has an attached PHP file if (($scheme = get_option('k2scheme')) != '') { $scheme_data = get_style_data($scheme); if ($scheme_data['php'] && file_exists($scheme_data['php'])) { include_once $scheme_data['php']; } } }
/** * Restores K2 to default settings */ function restore_defaults() { K2::uninstall(); K2::install(); }