function init() { if (function_exists('add_custom_image_header') and is_writable(K2_HEADERS_PATH)) { $styleinfo = get_style_data(get_option('k2scheme')); $header_image = get_option('k2header_picture'); define('HEADER_IMAGE_HEIGHT', empty($styleinfo['header_height']) ? 200 : $styleinfo['header_height']); define('HEADER_IMAGE_WIDTH', empty($styleinfo['header_width']) ? 950 : $styleinfo['header_width']); define('HEADER_TEXTCOLOR', empty($styleinfo['header_text_color']) ? 'ffffff' : $styleinfo['header_text_color']); define('HEADER_IMAGE', empty($header_image) ? '%s/images/transparent.gif' : get_k2info('headers_url') . $header_image); add_custom_image_header(array('K2Header', 'output_header_css'), array('K2Header', 'output_admin_header_css')); } else { add_action('wp_head', array('K2Header', 'output_header_css')); } }
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']; } } }
function update_style_info() { $styleinfo = ''; $data = get_style_data(get_option('k2scheme')); if (!empty($data) and $data['style'] != '' and $data['stylelink'] != '' and $data['author'] != '') { $styleinfo = $data['styleinfo']; // No custom style info if ($styleinfo == '') { $styleinfo = K2_STYLE_INFO_FORMAT; } if (strpos($styleinfo, '%') !== false) { $styleinfo = str_replace("%author%", $data['author'], $styleinfo); $styleinfo = str_replace("%site%", $data['site'], $styleinfo); $styleinfo = str_replace("%style%", $data['style'], $styleinfo); $styleinfo = str_replace("%stylelink%", $data['stylelink'], $styleinfo); $styleinfo = str_replace("%version%", $data['version'], $styleinfo); $styleinfo = str_replace("%comments%", $data['comments'], $styleinfo); } } update_option('k2styleinfo', $styleinfo); }