コード例 #1
0
function bb_get_active_theme_directory()
{
    return apply_filters('bb_get_active_theme_directory', bb_get_theme_directory());
}
コード例 #2
0
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]));
}
コード例 #3
0
ファイル: themes.php プロジェクト: danielcoats/schoolpress
function bb_admin_theme_row($theme, $position)
{
    $theme_directory = bb_get_theme_directory($theme);
    $theme_data = file_exists($theme_directory . 'style.css') ? bb_get_theme_data($theme) : false;
    $screen_shot = file_exists($theme_directory . 'screenshot.png') ? esc_url(bb_get_theme_uri($theme) . 'screenshot.png') : false;
    $activation_url = bb_get_uri('bb-admin/themes.php', array('theme' => urlencode($theme)), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN);
    $activation_url = esc_url(bb_nonce_url($activation_url, 'switch-theme'));
    if (1 === $position || 0 === $position) {
        echo '<tr>';
    }
    ?>
	<td class="position-<?php 
    echo (int) $position;
    ?>
">
		<div class="screen-shot"><?php 
    if ($screen_shot) {
        ?>
<a href="<?php 
        echo $activation_url;
        ?>
" title="<?php 
        echo esc_attr(sprintf(__('Activate "%s"'), $theme_data['Title']));
        ?>
"><img alt="<?php 
        echo esc_attr($theme_data['Title']);
        ?>
" src="<?php 
        echo $screen_shot;
        ?>
" /></a><?php 
    }
    ?>
</div>
		<div class="description">
			<h3 class="themes">
<?php 
    printf(__('%1$s %2$s by <cite>%3$s</cite>'), $theme_data['Title'], $theme_data['Version'], $theme_data['Author']);
    ?>
			</h3>
			
<?php 
    if ($theme_data['Porter']) {
        ?>
			<p>
<?php 
        printf(__('Ported by <cite>%s</cite>'), $theme_data['Porter']);
        ?>
			</p>
<?php 
    }
    ?>
			
			<?php 
    echo $theme_data['Description'];
    // Description is autop'ed
    if (0 !== $position) {
        ?>
			<div class="actions">
				<a href="<?php 
        echo $activation_url;
        ?>
" title="<?php 
        echo esc_attr(sprintf(__('Activate "%s"'), $theme_data['Title']));
        ?>
"><?php 
        _e('Activate');
        ?>
</a>
			</div>
<?php 
    }
    ?>
			<p class="location"><?php 
    printf(__('All of this theme\'s files are located in the "%s" themes directory.'), $theme_data['Location']);
    ?>
</p>
		</div>
	</td>
<?php 
    if (3 === $position || 0 === $position) {
        echo '</tr>';
    }
}