'K2', '%child%' => __('Child Theme', 'k2_domain'), '%content%' => 'wp-content' ); ?>
  • %s, needed to store custom styles is missing. For you to be able to use custom styles, you need to add this directory.', 'k2_domain'), $styles_dir ); ?>

    %s.', 'k2_domain'), $styles_dir); ?>
    />
  • tag - called by 'wp_head' action */ function load_styles() { $styles_url = K2Styles::get_styles_url(); // Styles $active_styles = get_option('k2styles'); if ( ! empty($active_styles) ) { krsort($active_styles); foreach ( $active_styles as $style ) { echo '' . "\n"; } } } /** * Adds current style data into database for quick access * * @return array style data */ function update_style_info() { $data = K2Styles::get_style_data( array_shift( get_option('k2styles') ) ); if ( !empty($data) and ($data['stylename'] != '') and ($data['stylelink'] != '') and ($data['author'] != '') ) { // No custom style info if ( $data['footer'] == '' ) { $data['footer'] = __('Styled with %style%','k2_domain'); } if ( strpos($data['footer'], '%') !== false ) { $keywords = array( '%author%', '%comments%', '%site%', '%style%', '%stylelink%', '%version%' ); $replace = array( $data['author'], $data['comments'], $data['site'], $data['stylename'], $data['stylelink'], $data['version'] ); $data['footer'] = str_replace( $keywords, $replace, $data['footer'] ); } } update_option('k2styleinfo', $data); return $data; } /** * Retrieve style data from parsed style file * * @param string $style_file style file path * @return array style data */ function get_style_data( $style_file = '' ) { // if no style selected, exit if ( '' == $style_file ) return false; $style_path = K2Styles::get_styles_dir() . "/$style_file"; if ( ! is_readable($style_path) ) return false; $style_data = implode( '', file($style_path) ); $style_data = str_replace( '\r', '\n', $style_data ); if ( preg_match("|Author Name\s*:(.*)$|mi", $style_data, $author) ) $author = trim( $author[1] ); else $author = ''; if ( preg_match("|Author Site\s*:(.*)$|mi", $style_data, $site) ) $site = esc_url( trim( $site[1] ) ); else $site = ''; if ( preg_match("|Style Name\s*:(.*)$|mi", $style_data, $stylename) ) $stylename = trim( $stylename[1] ); else $stylename = ''; if ( preg_match("|Style URI\s*:(.*)$|mi", $style_data, $stylelink) ) $stylelink = esc_url( trim( $stylelink[1] ) ); else $stylelink = ''; if ( preg_match("|Style Footer\s*:(.*)$|mi", $style_data, $footer) ) $footer = trim( $footer[1] ); else $footer = ''; if ( preg_match("|Version\s*:(.*)$|mi", $style_data, $version) ) $version = trim( $version[1] ); else $version = ''; if ( preg_match("|Comments\s*:(.*)$|mi", $style_data, $comments) ) $comments = trim( $comments[1] ); else $comments = ''; if ( preg_match("|Header Text Color\s*:\s*#*([\dABCDEF]+)|i", $style_data, $header_text_color) ) $header_text_color = $header_text_color[1]; else $header_text_color = ''; if ( preg_match("|Header Width\s*:\s*(\d+)|i", $style_data, $header_width) ) $header_width = (int) $header_width[1]; else $header_width = 0; if ( preg_match("|Header Height\s*:\s*(\d+)|i", $style_data, $header_height) ) $header_height = (int) $header_height[1]; else $header_height = 0; $layout_widths = array(); if ( preg_match("|Layout Widths\s*:\s*(\d+)\s*(px)?,\s*(\d+)\s*(px)?,\s*(\d+)|i", $style_data, $widths) ) { $layout_widths[1] = (int) $widths[1]; $layout_widths[2] = (int) $widths[3]; $layout_widths[3] = (int) $widths[5]; } if ( preg_match("|Tags\s*:(.*)$|mi", $style_data, $tags) ) $tags = trim($tags[1]); else $tags = ''; return array( 'path' => $style_file, 'modified' => filemtime($style_path), 'author' => $author, 'site' => $site, 'stylename' => $stylename, 'stylelink' => $stylelink, 'footer' => $footer, 'version' => $version, 'comments' => $comments, 'header_text_color' => $header_text_color, 'header_width' => $header_width, 'header_height' => $header_height, 'layout_widths' => $layout_widths, 'tags' => $tags ); } } add_action( 'k2_init', array('K2Styles', 'init') ); add_action( 'k2_install', array('K2Styles', 'install') ); add_action( 'k2_uninstall', array('K2Styles', 'uninstall') ); add_action( 'k2_display_options', array('K2Styles', 'display_options'), 15 ); add_action( 'k2_update_options', array('K2Styles', 'update_options') ); add_action( 'admin_init', array( 'K2Styles', 'theme_editor_append_styles') ); add_action( 'wp_head', array('K2Styles', 'load_styles') );