function bb_get_theme_data($theme_file)
{
    if (strpos($theme_file, '#') !== false) {
        $theme_file = bb_get_theme_directory($theme_file) . 'style.css';
    }
    $theme_code = implode('', file($theme_file));
    $theme_code = str_replace('\\r', '\\n', $theme_code);
    // Grab just the first commented area from the file
    preg_match('|/\\*(.*)\\*/|msU', $theme_code, $theme_block);
    $theme_data = trim($theme_block[1]);
    preg_match('|Theme Name:(.*)|i', $theme_data, $theme_name);
    preg_match('|Theme URI:(.*)|i', $theme_data, $theme_uri);
    preg_match('|Description:(.*)|i', $theme_data, $description);
    preg_match('|Author:(.*)|i', $theme_data, $author_name);
    preg_match('|Author URI:(.*)|i', $theme_data, $author_uri);
    preg_match('|Ported By:(.*)|i', $theme_data, $porter_name);
    preg_match('|Porter URI:(.*)|i', $theme_data, $porter_uri);
    //	preg_match( '|Template:(.*)|i', $theme_data, $template );
    if (preg_match('|Version:(.*)|i', $theme_data, $version)) {
        $version = esc_html(trim($version[1]));
    } else {
        $version = '';
    }
    if (preg_match('|Status:(.*)|i', $theme_data, $status)) {
        $status = esc_html(trim($status[1]));
    } else {
        $status = 'publish';
    }
    $description = trim($description[1]);
    $description = bb_encode_bad($description);
    $description = bb_code_trick($description);
    $description = force_balance_tags($description);
    $description = bb_filter_kses($description);
    $description = bb_autop($description);
    $name = $theme_name[1];
    $name = esc_html(trim($name));
    $theme = $name;
    if ($author_name || $author_uri) {
        if (empty($author_uri[1])) {
            $author = bb_filter_kses(trim($author_name[1]));
        } else {
            $author = '<a href="' . esc_url(trim($author_uri[1])) . '" title="' . esc_attr__('Visit author homepage') . '">' . bb_filter_kses(trim($author_name[1])) . '</a>';
        }
    } else {
        $author = '';
    }
    if ($porter_name || $porter_uri) {
        if (empty($porter_uri[1])) {
            $porter = bb_filter_kses(trim($porter_name[1]));
        } else {
            $porter = '<a href="' . esc_url(trim($porter_uri[1])) . '" title="' . esc_attr__('Visit porter homepage') . '">' . bb_filter_kses(trim($porter_name[1])) . '</a>';
        }
    } else {
        $porter = '';
    }
    global $bb;
    // Normalise the path to the theme
    $theme_file = str_replace('\\', '/', $theme_file);
    foreach ($bb->theme_locations as $_name => $_data) {
        $_directory = str_replace('\\', '/', $_data['dir']);
        if (0 === strpos($theme_file, $_directory)) {
            $location = $_name;
            break;
        }
    }
    return array('Location' => $location, 'Name' => $name, 'Title' => $theme, 'Description' => $description, 'Author' => $author, 'Porter' => $porter, 'Version' => $version, 'Status' => $status, 'URI' => esc_url($theme_uri[1]));
}
Пример #2
0
function code_trick($text)
{
    bb_log_deprecated('function', __FUNCTION__, 'bb_code_trick');
    return bb_code_trick($text);
}